@nice2dev/ui-buildings 1.0.27 → 1.0.29
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/CHANGELOG.md +15 -0
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +3884 -3722
- package/dist/ui-buildings.css +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),Me=require("@nice2dev/ui"),V=require("@nice2dev/spatial-core"),os="_root_hctnw_1",as="_dark_hctnw_27",cs="_topBar_hctnw_41",rs="_floorTabs_hctnw_71",is="_floorTab_hctnw_71",ls="_floorTabActive_hctnw_107",ds="_overlayControls_hctnw_119",us="_overlayBtn_hctnw_131",ps="_overlayBtnActive_hctnw_163",_s="_zoomBar_hctnw_175",hs="_editorBody_hctnw_229",ms="_toolPalette_hctnw_243",xs="_toolBtn_hctnw_273",ys="_toolBtnActive_hctnw_309",vs="_canvasWrapper_hctnw_323",fs="_canvas_hctnw_323",gs="_cur_select_hctnw_359",bs="_cur_drawzone_hctnw_361",js="_cur_drawwall_hctnw_363",ws="_cur_placedevice_hctnw_365",Ns="_cur_placedoor_hctnw_367",ks="_cur_placewindow_hctnw_369",Cs="_cur_pan_hctnw_371",Is="_cur_erase_hctnw_373",Ss="_cur_measure_hctnw_375",Ls="_cur_annotate_hctnw_377",zs="_gridLine_hctnw_383",Ts="_zoneGroup_hctnw_397",Bs="_zonePath_hctnw_405",$s="_zoneLabel_hctnw_413",Ps="_climateLabel_hctnw_431",Ms="_occupancyLabel_hctnw_443",Os="_dimLabel_hctnw_455",As="_deviceGroup_hctnw_467",Es="_devCircle_hctnw_471",Ds="_devOnline_hctnw_483",Rs="_devOffline_hctnw_485",Gs="_devSelected_hctnw_487",Ws="_propPanel_hctnw_499",qs="_propTitle_hctnw_527",Fs="_propRow_hctnw_545",Vs="_statusBar_hctnw_581",Hs="_emptyState_hctnw_613",Q={root:os,dark:as,topBar:cs,floorTabs:rs,floorTab:is,floorTabActive:ls,overlayControls:ds,overlayBtn:us,overlayBtnActive:ps,zoomBar:_s,editorBody:hs,toolPalette:ms,toolBtn:xs,toolBtnActive:ys,canvasWrapper:vs,canvas:fs,cur_select:gs,cur_drawzone:bs,cur_drawwall:js,cur_placedevice:ws,cur_placedoor:Ns,cur_placewindow:ks,cur_pan:Cs,cur_erase:Is,cur_measure:Ss,cur_annotate:Ls,gridLine:zs,zoneGroup:Ts,zonePath:Bs,zoneLabel:$s,climateLabel:Ps,occupancyLabel:Ms,dimLabel:Os,deviceGroup:As,devCircle:Es,devOnline:Ds,devOffline:Rs,devSelected:Gs,propPanel:Ws,propTitle:qs,propRow:Fs,statusBar:Vs,emptyState:Hs},Us=[{target:".nice-floor-plan-editor",titleKey:"tutorial.floorPlanEditor.intro.title",title:"Floor plan editor",contentKey:"tutorial.floorPlanEditor.intro.content",content:"Draw rooms and zones with the tools, place devices on the plan, switch floors and toggle overlays like dimensions, grid and occupancy.",placement:"auto"}],Zs={living_room:"var(--nice-primary-bg, #dbeafe)",bedroom:"var(--nice-accent-bg, #fce7f3)",master_bedroom:"#f3e8ff",kids_room:"var(--nice-warning-bg, #fef3c7)",bathroom:"#cffafe",kitchen:"var(--nice-warning-bg, #fef9c3)",dining_room:"var(--nice-warning-bg, #fde8d8)",hallway:"var(--nice-bg-secondary, #f1f5f9)",office:"var(--nice-success-bg, #dcfce7)",garage:"var(--nice-border, #e2e8f0)",basement:"var(--nice-border, #e5e7eb)",attic:"var(--nice-success-bg, #f0fdf4)",balcony:"var(--nice-success-bg, #ecfdf5)",garden:"var(--nice-success-bg, #d1fae5)",gym:"var(--nice-danger-bg, #fee2e2)",cinema:"var(--nice-accent-bg, #ede9fe)",open_office:"var(--nice-success-bg, #dcfce7)",private_office:"var(--nice-success-bg, #d1fae5)",meeting_room:"var(--nice-primary-bg, #dbeafe)",boardroom:"var(--nice-accent-bg, #ede9fe)",reception:"var(--nice-warning-bg, #fef3c7)",waiting_area:"var(--nice-warning-bg, #fef9c3)",server_room:"var(--nice-danger-bg, #fee2e2)",it_room:"var(--nice-warning-bg, #fde8d8)",break_room:"var(--nice-accent-bg, #fce7f3)",lobby:"var(--nice-primary-bg, #f0f4ff)",corridor:"var(--nice-bg-secondary, #f8fafc)",stairwell:"var(--nice-bg-secondary, #f1f5f9)",parking:"var(--nice-border, #e2e8f0)",mechanical_room:"var(--nice-bg-secondary, #f3f4f6)"};function Ys(t){return Zs[t]??"var(--nice-primary-bg, #f0f4ff)"}function zt(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 Tt(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 Ks(t,s,a){return a?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function Xs(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 Js=[{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ń"}],Qs={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:"📡"},en=({floors:t,devices:s=[],onFloorChange:a,onDeviceMove:o,readOnly:n=!1,initialFloorId:c,showDevices:l=!0,showDimensions:y=!1,showGrid:v=!0,showOccupancy:k=!1,showClimate:d=!0,className:C,style:b,theme:p="light",tutorial:N})=>{var re,ce;const u=r.useRef(null),w=r.useRef(!1),T=r.useRef({x:0,y:0}),[i,h]=r.useReducer(Xs,{floorId:c??((re=t[0])==null?void 0:re.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:v,showDim:y,showLabels:!0,showOccupancy:k,showClimate:d,snapGrid:!0,gridSize:20}),j=t.find(S=>S.id===i.floorId)??t[0],f=r.useCallback(S=>{var ie;const F=(ie=u.current)==null?void 0:ie.getBoundingClientRect();return F?{x:(S.clientX-F.left-i.pan.x)/i.zoom,y:(S.clientY-F.top-i.pan.y)/i.zoom}:{x:0,y:0}},[i.pan,i.zoom]),g=r.useCallback(S=>{i.tool==="pan"&&(w.current=!0,T.current={x:S.clientX,y:S.clientY})},[i.tool]),m=r.useCallback(S=>{w.current&&(h({t:"PAN",v:{x:i.pan.x+S.clientX-T.current.x,y:i.pan.y+S.clientY-T.current.y}}),T.current={x:S.clientX,y:S.clientY})},[i.pan]),A=r.useCallback(()=>{w.current=!1},[]),H=r.useCallback(S=>{if(i.tool==="draw_zone"){const F=Ks(f(S),i.gridSize,i.snapGrid);h({t:"DRAW_PT",v:F})}else i.tool==="select"&&h({t:"SELECT",v:null})},[i.tool,i.gridSize,i.snapGrid,f]),W=r.useCallback(S=>{if(i.tool==="draw_zone"&&i.drawing&&i.drawing.length>=3&&a&&j){const F={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:j.id,polygon:[...i.drawing]};a(t.map(ie=>ie.id===j.id?{...j,zones:[...j.zones,F]}:ie)),h({t:"DRAW_END"})}},[i.tool,i.drawing,j,t,a]),me=r.useCallback(S=>{S.preventDefault(),h({t:"ZOOM",v:i.zoom*(S.deltaY>0?.9:1.1)})},[i.zoom]),ue=r.useCallback((S,F)=>{S.stopPropagation(),i.tool==="select"?h({t:"SELECT",v:{type:"zone",id:F.id}}):i.tool==="erase"&&!n&&a&&j&&a(t.map(ie=>ie.id===j.id?{...j,zones:j.zones.filter(Ne=>Ne.id!==F.id)}:ie))},[i.tool,n,j,t,a]);if(!j)return e.jsx("div",{className:Q.emptyState,children:"Brak kondygnacji."});const de=((ce=i.selected)==null?void 0:ce.type)==="zone"?j.zones.find(S=>{var F;return S.id===((F=i.selected)==null?void 0:F.id)}):null,ye=l?s.filter(S=>j.zones.some(F=>F.id===S.zoneId)||S.floorPlanPosition):[],ne=[{key:"grid",icon:"⊞",active:i.showGrid},{key:"dim",icon:"↔",active:i.showDim},{key:"labels",icon:"🏷",active:i.showLabels},{key:"occupancy",icon:"👥",active:i.showOccupancy},{key:"climate",icon:"🌡",active:i.showClimate}];return e.jsxs("div",{className:`nice-floor-plan-editor ${Q.root} ${p==="dark"?Q.dark:""} ${C??""}`,style:{position:"relative",...b},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(N,Us)})}),e.jsxs("div",{className:Q.topBar,children:[e.jsx("div",{className:Q.floorTabs,children:[...t].sort((S,F)=>S.level-F.level).map(S=>e.jsx("button",{className:`${Q.floorTab} ${i.floorId===S.id?Q.floorTabActive:""}`,onClick:()=>h({t:"FLOOR",v:S.id}),children:S.name},S.id))}),e.jsx("div",{className:Q.overlayControls,children:ne.map(S=>e.jsx("button",{title:S.key,className:`${Q.overlayBtn} ${S.active?Q.overlayBtnActive:""}`,onClick:()=>h({t:"TOGGLE",v:S.key}),children:S.icon},S.key))}),e.jsxs("div",{className:Q.zoomBar,children:[e.jsx("button",{onClick:()=>h({t:"ZOOM",v:i.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(i.zoom*100),"%"]}),e.jsx("button",{onClick:()=>h({t:"ZOOM",v:i.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok",onClick:()=>{h({t:"ZOOM",v:1}),h({t:"PAN",v:{x:0,y:0}})},children:"⊡"})]})]}),e.jsxs("div",{className:Q.editorBody,children:[!n&&e.jsx("div",{className:Q.toolPalette,children:Js.map(({tool:S,icon:F,label:ie})=>e.jsx("button",{title:ie,className:`${Q.toolBtn} ${i.tool===S?Q.toolBtnActive:""}`,onClick:()=>h({t:"TOOL",v:S}),children:F},S))}),e.jsx("div",{className:Q.canvasWrapper,children:e.jsxs("svg",{ref:u,className:`${Q.canvas} ${Q[`cur_${i.tool.replace("_","")}`]??""}`,onMouseDown:g,onMouseMove:m,onMouseUp:A,onClick:H,onDoubleClick:W,onWheel:me,children:[j.backgroundImage&&e.jsx("image",{href:j.backgroundImage,x:i.pan.x,y:i.pan.y,width:j.width*i.zoom,height:j.height*i.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${i.pan.x},${i.pan.y}) scale(${i.zoom})`,children:[i.showGrid&&(()=>{const S=[];for(let F=0;F<=j.width;F+=i.gridSize)S.push(e.jsx("line",{x1:F,y1:0,x2:F,y2:j.height,className:Q.gridLine},`v${F}`));for(let F=0;F<=j.height;F+=i.gridSize)S.push(e.jsx("line",{x1:0,y1:F,x2:j.width,y2:F,className:Q.gridLine},`h${F}`));return e.jsx("g",{children:S})})(),j.zones.map(S=>{var ke;const F=((ke=i.selected)==null?void 0:ke.id)===S.id,ie=zt(S.polygon),Ne=S.color??Ys(S.type);return e.jsxs("g",{className:Q.zoneGroup,onClick:fe=>ue(fe,S),children:[e.jsx("path",{d:Tt(S.polygon),fill:Ne,fillOpacity:S.opacity??.55,stroke:F?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:F?2.5:1.5,className:Q.zonePath}),i.showLabels&&e.jsx("text",{x:ie.x,y:ie.y,textAnchor:"middle",dominantBaseline:"middle",className:Q.zoneLabel,children:S.name}),i.showClimate&&S.temperature!=null&&e.jsxs("text",{x:ie.x,y:ie.y+14,textAnchor:"middle",className:Q.climateLabel,children:[S.temperature.toFixed(1),"°C"," ",S.humidity!=null?`· ${S.humidity}%`:""]}),i.showOccupancy&&S.occupancy!=null&&e.jsxs("text",{x:ie.x,y:ie.y+26,textAnchor:"middle",className:Q.occupancyLabel,children:["👥 ",S.occupancy]}),i.showDim&&S.polygon.length>1&&S.polygon.map((fe,Te)=>{const Be=S.polygon[(Te+1)%S.polygon.length],Ge=(fe.x+Be.x)/2,tt=(fe.y+Be.y)/2,Oe=Math.sqrt((Be.x-fe.x)**2+(Be.y-fe.y)**2),$e=j.scale??0;return e.jsx("text",{x:Ge,y:tt-4,textAnchor:"middle",className:Q.dimLabel,children:$e>0?`${(Oe/$e).toFixed(1)}m`:`${Oe.toFixed(0)}px`},Te)})]},S.id)}),ye.map(S=>{var ke;const F=j.zones.find(fe=>fe.id===S.zoneId),ie=S.floorPlanPosition??(F?zt(F.polygon):null);if(!ie)return null;const Ne=((ke=i.selected)==null?void 0:ke.id)===S.id;return e.jsxs("g",{transform:`translate(${ie.x},${ie.y})`,className:Q.deviceGroup,onClick:fe=>{fe.stopPropagation(),h({t:"SELECT",v:{type:"device",id:S.id}})},children:[e.jsx("circle",{r:14,className:`${Q.devCircle} ${S.status==="online"?Q.devOnline:Q.devOffline} ${Ne?Q.devSelected:""}`}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:12,children:Qs[S.type]??"📟"})]},S.id)}),i.drawing&&i.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:Tt(i.drawing,!1),fill:"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:"6,3"}),i.drawing.map((S,F)=>e.jsx("circle",{cx:S.x,cy:S.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},F))]})]})]})}),de&&e.jsxs("div",{className:Q.propPanel,children:[e.jsx("div",{className:Q.propTitle,children:de.name}),e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:de.type})]}),de.area!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[de.area," m²"]})]}),de.temperature!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[de.temperature.toFixed(1)," °C"]})]}),de.humidity!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[de.humidity," %"]})]}),de.co2!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[de.co2," ppm"]})]}),de.occupancy!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[de.occupancy," os."]})]})]})]}),e.jsxs("div",{className:Q.statusBar,children:[i.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":i.selected?`Zaznaczono: ${i.selected.type} #${i.selected.id}`:`${j.name} — ${j.zones.length} strefa(y)`,i.tool==="draw_zone"&&i.drawing&&` (${i.drawing.length} pkt)`]})]})},tn="_overlay_58xqu_9",sn="_dialog_58xqu_55",nn="_header_58xqu_103",on="_title_58xqu_119",an="_closeButton_58xqu_133",cn="_content_58xqu_163",rn="_preview_58xqu_179",ln="_previewCanvas_58xqu_199",dn="_previewSvg_58xqu_217",un="_info_58xqu_227",pn="_section_58xqu_237",_n="_sectionTitle_58xqu_245",hn="_statGrid_58xqu_265",mn="_stat_58xqu_265",xn="_statLabel_58xqu_289",yn="_statValue_58xqu_301",vn="_warningsList_58xqu_313",fn="_warning_58xqu_313",gn="_warningIcon_58xqu_357",bn="_error_58xqu_367",jn="_errorIcon_58xqu_399",wn="_footer_58xqu_409",Nn="_cancelButton_58xqu_429",kn="_confirmButton_58xqu_461",Cn="_noWarnings_58xqu_503",In="_layersList_58xqu_515",Sn="_layer_58xqu_515",Ln="_layerIcon_58xqu_557",zn="_layerName_58xqu_565",Tn="_layerCount_58xqu_575",G={overlay:tn,dialog:sn,header:nn,title:on,closeButton:an,content:cn,preview:rn,previewCanvas:ln,previewSvg:dn,info:un,section:pn,sectionTitle:_n,statGrid:hn,stat:mn,statLabel:xn,statValue:yn,warningsList:vn,warning:fn,warningIcon:gn,error:bn,errorIcon:jn,footer:wn,cancelButton:Nn,confirmButton:kn,noWarnings:Cn,layersList:In,layer:Sn,layerIcon:Ln,layerName:zn,layerCount:Tn},Bn=()=>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"})}),Bt=()=>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"})}),Pt=()=>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 Pn({result:t,onConfirm:s,onCancel:a}){const o=t.document,n=r.useMemo(()=>{var i,h;if(!((i=o==null?void 0:o.floors)!=null&&i.length))return null;const d=o.floors[0],C=(d==null?void 0:d.layers)||[],b=C.flatMap(j=>j.objects);let p=1/0,N=1/0,u=-1/0,w=-1/0;for(const j of b)j.bounds?(p=Math.min(p,j.bounds.x),N=Math.min(N,j.bounds.y),u=Math.max(u,j.bounds.x+j.bounds.width),w=Math.max(w,j.bounds.y+j.bounds.height)):(h=j.transform)!=null&&h.position&&(p=Math.min(p,j.transform.position.x),N=Math.min(N,j.transform.position.y),u=Math.max(u,j.transform.position.x),w=Math.max(w,j.transform.position.y));isFinite(p)||(d!=null&&d.bounds?(p=d.bounds.x,N=d.bounds.y,u=d.bounds.x+d.bounds.width,w=d.bounds.y+d.bounds.height):(p=0,N=0,u=1e3,w=800));const T=20;return{viewBox:{x:p-T,y:N-T,width:u-p+T*2,height:w-N+T*2},objects:b,layers:C}},[o]),c=r.useMemo(()=>{if(!n||!o)return null;const{viewBox:d,objects:C}=n,b=[],p=50,N=`
|
|
2
|
-
<pattern id="grid" width="${
|
|
3
|
-
<path d="M ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("@nice2dev/ui"),r=require("react"),Z=require("@nice2dev/spatial-core"),ds="_root_176kw_1",us="_shell_176kw_27",ps="_dark_176kw_35",_s="_topBar_176kw_49",ms="_floorTabs_176kw_79",hs="_floorTab_176kw_79",xs="_floorTabActive_176kw_115",fs="_overlayControls_176kw_127",vs="_overlayBtn_176kw_139",ys="_overlayBtnActive_176kw_171",gs="_zoomBar_176kw_183",js="_toolPalette_176kw_237",bs="_toolBtn_176kw_267",ws="_toolBtnActive_176kw_303",Ns="_canvasWrapper_176kw_317",ks="_canvas_176kw_317",Is="_cur_select_176kw_353",Cs="_cur_drawzone_176kw_355",zs="_cur_drawwall_176kw_357",Ss="_cur_placedevice_176kw_359",Ls="_cur_placedoor_176kw_361",Ts="_cur_placewindow_176kw_363",$s="_cur_pan_176kw_365",Bs="_cur_erase_176kw_367",Ps="_cur_measure_176kw_369",Ms="_cur_annotate_176kw_371",Os="_gridLine_176kw_377",As="_zoneGroup_176kw_391",Es="_zonePath_176kw_399",Ds="_zoneLabel_176kw_407",Rs="_climateLabel_176kw_425",Ws="_occupancyLabel_176kw_437",Gs="_dimLabel_176kw_449",Fs="_deviceGroup_176kw_461",Vs="_devCircle_176kw_465",Hs="_devOnline_176kw_477",Us="_devOffline_176kw_479",qs="_devSelected_176kw_481",Zs="_propPanel_176kw_493",Ys="_propTitle_176kw_521",Ks="_propRow_176kw_539",Xs="_statusBar_176kw_575",Js="_emptyState_176kw_607",ee={root:ds,shell:us,dark:ps,topBar:_s,floorTabs:ms,floorTab:hs,floorTabActive:xs,overlayControls:fs,overlayBtn:vs,overlayBtnActive:ys,zoomBar:gs,toolPalette:js,toolBtn:bs,toolBtnActive:ws,canvasWrapper:Ns,canvas:ks,cur_select:Is,cur_drawzone:Cs,cur_drawwall:zs,cur_placedevice:Ss,cur_placedoor:Ls,cur_placewindow:Ts,cur_pan:$s,cur_erase:Bs,cur_measure:Ps,cur_annotate:Ms,gridLine:Os,zoneGroup:As,zonePath:Es,zoneLabel:Ds,climateLabel:Rs,occupancyLabel:Ws,dimLabel:Gs,deviceGroup:Fs,devCircle:Vs,devOnline:Hs,devOffline:Us,devSelected:qs,propPanel:Zs,propTitle:Ys,propRow:Ks,statusBar:Xs,emptyState:Js},Qs=[{target:".nice-floor-plan-editor",titleKey:"tutorial.floorPlanEditor.intro.title",title:"Floor plan editor",contentKey:"tutorial.floorPlanEditor.intro.content",content:"Draw rooms and zones with the tools, place devices on the plan, switch floors and toggle overlays like dimensions, grid and occupancy.",placement:"auto"}],en={living_room:"var(--nice-primary-bg, #dbeafe)",bedroom:"var(--nice-accent-bg, #fce7f3)",master_bedroom:"#f3e8ff",kids_room:"var(--nice-warning-bg, #fef3c7)",bathroom:"#cffafe",kitchen:"var(--nice-warning-bg, #fef9c3)",dining_room:"var(--nice-warning-bg, #fde8d8)",hallway:"var(--nice-bg-secondary, #f1f5f9)",office:"var(--nice-success-bg, #dcfce7)",garage:"var(--nice-border, #e2e8f0)",basement:"var(--nice-border, #e5e7eb)",attic:"var(--nice-success-bg, #f0fdf4)",balcony:"var(--nice-success-bg, #ecfdf5)",garden:"var(--nice-success-bg, #d1fae5)",gym:"var(--nice-danger-bg, #fee2e2)",cinema:"var(--nice-accent-bg, #ede9fe)",open_office:"var(--nice-success-bg, #dcfce7)",private_office:"var(--nice-success-bg, #d1fae5)",meeting_room:"var(--nice-primary-bg, #dbeafe)",boardroom:"var(--nice-accent-bg, #ede9fe)",reception:"var(--nice-warning-bg, #fef3c7)",waiting_area:"var(--nice-warning-bg, #fef9c3)",server_room:"var(--nice-danger-bg, #fee2e2)",it_room:"var(--nice-warning-bg, #fde8d8)",break_room:"var(--nice-accent-bg, #fce7f3)",lobby:"var(--nice-primary-bg, #f0f4ff)",corridor:"var(--nice-bg-secondary, #f8fafc)",stairwell:"var(--nice-bg-secondary, #f1f5f9)",parking:"var(--nice-border, #e2e8f0)",mechanical_room:"var(--nice-bg-secondary, #f3f4f6)"};function tn(t){return en[t]??"var(--nice-primary-bg, #f0f4ff)"}function Tt(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 $t(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 sn(t,s,a){return a?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function nn(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 on=[{tool:"select",icon:"cursor",label:"Zaznaczenie"},{tool:"draw_zone",icon:"hexagon",label:"Rysuj strefę"},{tool:"draw_wall",icon:"line",label:"Rysuj ścianę"},{tool:"place_device",icon:"wifi",label:"Urządzenie"},{tool:"place_door",icon:"door",label:"Drzwi"},{tool:"place_window",icon:"window",label:"Okno"},{tool:"annotate",icon:"edit",label:"Adnotacja"},{tool:"measure",icon:"ruler",label:"Miarka"},{tool:"erase",icon:"trash",label:"Usuń"},{tool:"pan",icon:"move",label:"Przesuń"}],an={light:"lightbulb",dimmer:"lightbulb",rgb_light:"lightbulb",led_strip:"lightbulb",thermostat:"thermometer",air_conditioner:"thermometer",fan:"wifi",heat_pump:"thermometer",lock:"lock",door:"door",window:"window",blind:"columns",camera:"camera",doorbell:"bell",alarm:"bell",motion_sensor:"eye",smoke_detector:"warning",temperature_sensor:"thermometer",humidity_sensor:"droplet",switch:"plug",outlet:"plug",speaker:"music",tv:"monitor",vacuum:"refresh",ev_charger:"zap",solar_panel:"zap",energy_meter:"zap",hub:"wifi",router:"wifi"},cn=({floors:t,devices:s=[],onFloorChange:a,onDeviceMove:o,readOnly:n=!1,initialFloorId:c,showDevices:i=!0,showDimensions:y=!1,showGrid:g=!0,showOccupancy:k=!1,showClimate:d=!0,className:C,style:j,theme:m="light",tutorial:N})=>{var ze,Pe;const b=r.useRef(null),I=r.useRef(!1),w=r.useRef({x:0,y:0}),[u,v]=r.useReducer(nn,{floorId:c??((ze=t[0])==null?void 0:ze.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:g,showDim:y,showLabels:!0,showOccupancy:k,showClimate:d,snapGrid:!0,gridSize:20}),l=t.find(S=>S.id===u.floorId)??t[0],_=r.useCallback(S=>{var de;const H=(de=b.current)==null?void 0:de.getBoundingClientRect();return H?{x:(S.clientX-H.left-u.pan.x)/u.zoom,y:(S.clientY-H.top-u.pan.y)/u.zoom}:{x:0,y:0}},[u.pan,u.zoom]),x=r.useCallback(S=>{u.tool==="pan"&&(I.current=!0,w.current={x:S.clientX,y:S.clientY})},[u.tool]),p=r.useCallback(S=>{I.current&&(v({t:"PAN",v:{x:u.pan.x+S.clientX-w.current.x,y:u.pan.y+S.clientY-w.current.y}}),w.current={x:S.clientX,y:S.clientY})},[u.pan]),A=r.useCallback(()=>{I.current=!1},[]),Y=r.useCallback(S=>{if(u.tool==="draw_zone"){const H=sn(_(S),u.gridSize,u.snapGrid);v({t:"DRAW_PT",v:H})}else u.tool==="select"&&v({t:"SELECT",v:null})},[u.tool,u.gridSize,u.snapGrid,_]),V=r.useCallback(S=>{if(u.tool==="draw_zone"&&u.drawing&&u.drawing.length>=3&&a&&l){const H={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:l.id,polygon:[...u.drawing]};a(t.map(de=>de.id===l.id?{...l,zones:[...l.zones,H]}:de)),v({t:"DRAW_END"})}},[u.tool,u.drawing,l,t,a]),xe=r.useCallback(S=>{S.preventDefault(),v({t:"ZOOM",v:u.zoom*(S.deltaY>0?.9:1.1)})},[u.zoom]),pe=r.useCallback((S,H)=>{S.stopPropagation(),u.tool==="select"?v({t:"SELECT",v:{type:"zone",id:H.id}}):u.tool==="erase"&&!n&&a&&l&&a(t.map(de=>de.id===l.id?{...l,zones:l.zones.filter(ke=>ke.id!==H.id)}:de))},[u.tool,n,l,t,a]);if(!l)return e.jsx("div",{className:ee.emptyState,children:"Brak kondygnacji."});const ue=((Pe=u.selected)==null?void 0:Pe.type)==="zone"?l.zones.find(S=>{var H;return S.id===((H=u.selected)==null?void 0:H.id)}):null,ve=i?s.filter(S=>l.zones.some(H=>H.id===S.zoneId)||S.floorPlanPosition):[],oe=[{key:"grid",icon:"grid",active:u.showGrid},{key:"dim",icon:"ruler",active:u.showDim},{key:"labels",icon:"tag",active:u.showLabels},{key:"occupancy",icon:"users",active:u.showOccupancy},{key:"climate",icon:"thermometer",active:u.showClimate}],le=e.jsxs("div",{className:ee.topBar,children:[e.jsx("div",{className:ee.floorTabs,children:[...t].sort((S,H)=>S.level-H.level).map(S=>e.jsx("button",{className:`${ee.floorTab} ${u.floorId===S.id?ee.floorTabActive:""}`,onClick:()=>v({t:"FLOOR",v:S.id}),children:S.name},S.id))}),e.jsx("div",{className:ee.overlayControls,children:oe.map(S=>e.jsx("button",{title:S.key,"aria-label":S.key,className:`${ee.overlayBtn} ${S.active?ee.overlayBtnActive:""}`,onClick:()=>v({t:"TOGGLE",v:S.key}),children:e.jsx(L.NiceIcon,{name:S.icon,size:16})},S.key))}),e.jsxs("div",{className:ee.zoomBar,children:[e.jsx("button",{onClick:()=>v({t:"ZOOM",v:u.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(u.zoom*100),"%"]}),e.jsx("button",{onClick:()=>v({t:"ZOOM",v:u.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok","aria-label":"Resetuj widok",onClick:()=>{v({t:"ZOOM",v:1}),v({t:"PAN",v:{x:0,y:0}})},children:e.jsx(L.NiceIcon,{name:"refresh",size:16})})]})]}),ie=n?void 0:e.jsx("div",{className:ee.toolPalette,children:on.map(({tool:S,icon:H,label:de})=>e.jsx("button",{title:de,"aria-label":de,className:`${ee.toolBtn} ${u.tool===S?ee.toolBtnActive:""}`,onClick:()=>v({t:"TOOL",v:S}),children:e.jsx(L.NiceIcon,{name:H,size:18})},S))});return e.jsxs("div",{className:`nice-floor-plan-editor ${ee.root} ${m==="dark"?ee.dark:""} ${C??""}`,style:{position:"relative",...j},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(L.NiceTutorialButton,{steps:L.resolveTutorial(N,Qs)})}),e.jsx(L.NiceAppShell,{flush:!0,className:ee.shell,menubar:le,sidebar:ie,rightSidebar:ue?e.jsxs("div",{className:ee.propPanel,children:[e.jsx("div",{className:ee.propTitle,children:ue.name}),e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:ue.type})]}),ue.area!=null&&e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[ue.area," m²"]})]}),ue.temperature!=null&&e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[ue.temperature.toFixed(1)," °C"]})]}),ue.humidity!=null&&e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[ue.humidity," %"]})]}),ue.co2!=null&&e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[ue.co2," ppm"]})]}),ue.occupancy!=null&&e.jsxs("div",{className:ee.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[ue.occupancy," os."]})]})]}):void 0,statusBar:e.jsxs("div",{className:ee.statusBar,children:[u.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":u.selected?`Zaznaczono: ${u.selected.type} #${u.selected.id}`:`${l.name} — ${l.zones.length} strefa(y)`,u.tool==="draw_zone"&&u.drawing&&` (${u.drawing.length} pkt)`]}),children:e.jsx("div",{className:ee.canvasWrapper,children:e.jsxs("svg",{ref:b,className:`${ee.canvas} ${ee[`cur_${u.tool.replace("_","")}`]??""}`,onMouseDown:x,onMouseMove:p,onMouseUp:A,onClick:Y,onDoubleClick:V,onWheel:xe,children:[l.backgroundImage&&e.jsx("image",{href:l.backgroundImage,x:u.pan.x,y:u.pan.y,width:l.width*u.zoom,height:l.height*u.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${u.pan.x},${u.pan.y}) scale(${u.zoom})`,children:[u.showGrid&&(()=>{const S=[];for(let H=0;H<=l.width;H+=u.gridSize)S.push(e.jsx("line",{x1:H,y1:0,x2:H,y2:l.height,className:ee.gridLine},`v${H}`));for(let H=0;H<=l.height;H+=u.gridSize)S.push(e.jsx("line",{x1:0,y1:H,x2:l.width,y2:H,className:ee.gridLine},`h${H}`));return e.jsx("g",{children:S})})(),l.zones.map(S=>{var Ie;const H=((Ie=u.selected)==null?void 0:Ie.id)===S.id,de=Tt(S.polygon),ke=S.color??tn(S.type);return e.jsxs("g",{className:ee.zoneGroup,onClick:je=>pe(je,S),children:[e.jsx("path",{d:$t(S.polygon),fill:ke,fillOpacity:S.opacity??.55,stroke:H?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:H?2.5:1.5,className:ee.zonePath}),u.showLabels&&e.jsx("text",{x:de.x,y:de.y,textAnchor:"middle",dominantBaseline:"middle",className:ee.zoneLabel,children:S.name}),u.showClimate&&S.temperature!=null&&e.jsxs("text",{x:de.x,y:de.y+14,textAnchor:"middle",className:ee.climateLabel,children:[S.temperature.toFixed(1),"°C"," ",S.humidity!=null?`· ${S.humidity}%`:""]}),u.showOccupancy&&S.occupancy!=null&&e.jsxs("text",{x:de.x,y:de.y+26,textAnchor:"middle",className:ee.occupancyLabel,children:[S.occupancy," os."]}),u.showDim&&S.polygon.length>1&&S.polygon.map((je,Ae)=>{const Ee=S.polygon[(Ae+1)%S.polygon.length],De=(je.x+Ee.x)/2,Me=(je.y+Ee.y)/2,Le=Math.sqrt((Ee.x-je.x)**2+(Ee.y-je.y)**2),be=l.scale??0;return e.jsx("text",{x:De,y:Me-4,textAnchor:"middle",className:ee.dimLabel,children:be>0?`${(Le/be).toFixed(1)}m`:`${Le.toFixed(0)}px`},Ae)})]},S.id)}),ve.map(S=>{var Ie;const H=l.zones.find(je=>je.id===S.zoneId),de=S.floorPlanPosition??(H?Tt(H.polygon):null);if(!de)return null;const ke=((Ie=u.selected)==null?void 0:Ie.id)===S.id;return e.jsxs("g",{transform:`translate(${de.x},${de.y})`,className:ee.deviceGroup,onClick:je=>{je.stopPropagation(),v({t:"SELECT",v:{type:"device",id:S.id}})},children:[e.jsx("circle",{r:14,className:`${ee.devCircle} ${S.status==="online"?ee.devOnline:ee.devOffline} ${ke?ee.devSelected:""}`}),e.jsx("g",{transform:"translate(-8,-8)",children:e.jsx(L.NiceIcon,{name:an[S.type]??"monitor",size:16})})]},S.id)}),u.drawing&&u.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:$t(u.drawing,!1),fill:"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:"6,3"}),u.drawing.map((S,H)=>e.jsx("circle",{cx:S.x,cy:S.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},H))]})]})]})})})]})},rn="_overlay_58xqu_9",ln="_dialog_58xqu_55",dn="_header_58xqu_103",un="_title_58xqu_119",pn="_closeButton_58xqu_133",_n="_content_58xqu_163",mn="_preview_58xqu_179",hn="_previewCanvas_58xqu_199",xn="_previewSvg_58xqu_217",fn="_info_58xqu_227",vn="_section_58xqu_237",yn="_sectionTitle_58xqu_245",gn="_statGrid_58xqu_265",jn="_stat_58xqu_265",bn="_statLabel_58xqu_289",wn="_statValue_58xqu_301",Nn="_warningsList_58xqu_313",kn="_warning_58xqu_313",In="_warningIcon_58xqu_357",Cn="_error_58xqu_367",zn="_errorIcon_58xqu_399",Sn="_footer_58xqu_409",Ln="_cancelButton_58xqu_429",Tn="_confirmButton_58xqu_461",$n="_noWarnings_58xqu_503",Bn="_layersList_58xqu_515",Pn="_layer_58xqu_515",Mn="_layerIcon_58xqu_557",On="_layerName_58xqu_565",An="_layerCount_58xqu_575",F={overlay:rn,dialog:ln,header:dn,title:un,closeButton:pn,content:_n,preview:mn,previewCanvas:hn,previewSvg:xn,info:fn,section:vn,sectionTitle:yn,statGrid:gn,stat:jn,statLabel:bn,statValue:wn,warningsList:Nn,warning:kn,warningIcon:In,error:Cn,errorIcon:zn,footer:Sn,cancelButton:Ln,confirmButton:Tn,noWarnings:$n,layersList:Bn,layer:Pn,layerIcon:Mn,layerName:On,layerCount:An},En=()=>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"})}),Bt=()=>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"})}),Pt=()=>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"})}),Mt=()=>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"})}),Dn=()=>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 Rn({result:t,onConfirm:s,onCancel:a}){const o=t.document,n=r.useMemo(()=>{var u,v;if(!((u=o==null?void 0:o.floors)!=null&&u.length))return null;const d=o.floors[0],C=(d==null?void 0:d.layers)||[],j=C.flatMap(l=>l.objects);let m=1/0,N=1/0,b=-1/0,I=-1/0;for(const l of j)l.bounds?(m=Math.min(m,l.bounds.x),N=Math.min(N,l.bounds.y),b=Math.max(b,l.bounds.x+l.bounds.width),I=Math.max(I,l.bounds.y+l.bounds.height)):(v=l.transform)!=null&&v.position&&(m=Math.min(m,l.transform.position.x),N=Math.min(N,l.transform.position.y),b=Math.max(b,l.transform.position.x),I=Math.max(I,l.transform.position.y));isFinite(m)||(d!=null&&d.bounds?(m=d.bounds.x,N=d.bounds.y,b=d.bounds.x+d.bounds.width,I=d.bounds.y+d.bounds.height):(m=0,N=0,b=1e3,I=800));const w=20;return{viewBox:{x:m-w,y:N-w,width:b-m+w*2,height:I-N+w*2},objects:j,layers:C}},[o]),c=r.useMemo(()=>{if(!n||!o)return null;const{viewBox:d,objects:C}=n,j=[],m=50,N=`
|
|
2
|
+
<pattern id="grid" width="${m}" height="${m}" patternUnits="userSpaceOnUse">
|
|
3
|
+
<path d="M ${m} 0 L 0 0 0 ${m}" fill="none" stroke="var(--nice-border, #e2e8f0)" strokeWidth="0.5"/>
|
|
4
4
|
</pattern>
|
|
5
|
-
`;return C.forEach((u,w)=>{if(u.type==="wall"&&u.bounds)b.push(e.jsx("rect",{x:u.bounds.x,y:u.bounds.y,width:u.bounds.width,height:u.bounds.height,fill:"var(--nice-text-secondary, #475569)",stroke:"var(--nice-text, #334155)",strokeWidth:"1"},`wall-${w}`));else if(u.type==="zone"&&u.boundary){const i=u.boundary.map((h,j)=>`${j===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:i,fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:"1"},`zone-${w}`))}else if(u.type==="room"&&u.boundary){const i=u.boundary.map((h,j)=>`${j===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:i,fill:"var(--nice-success-tint-15, rgba(34, 197, 94, 0.15))",stroke:"var(--nice-success, #22c55e)",strokeWidth:"1"},`room-${w}`))}else u.bounds&&b.push(e.jsx("rect",{x:u.bounds.x,y:u.bounds.y,width:u.bounds.width,height:u.bounds.height,fill:"var(--nice-accent-tint-30, rgba(99, 102, 241, 0.3))",stroke:"var(--nice-info, #6366f1)",strokeWidth:"0.5",rx:"2"},`obj-${w}`))}),e.jsxs("svg",{viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,className:G.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:N}}),e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"url(#grid)"}),b]})},[n,o]),l=r.useCallback(d=>{d.key==="Escape"&&a()},[a]),y=r.useCallback(d=>{d.target===d.currentTarget&&a()},[a]),v=t.errors.some(d=>d.fatal),k=t.errors.filter(d=>!d.fatal);return e.jsx("div",{className:G.overlay,onClick:y,onKeyDown:l,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:G.dialog,children:[e.jsxs("div",{className:G.header,children:[e.jsx("h2",{id:"import-preview-title",className:G.title,children:"Import Preview"}),e.jsx("button",{className:G.closeButton,onClick:a,title:"Close","aria-label":"Close dialog",children:e.jsx(Bn,{})})]}),e.jsxs("div",{className:G.content,children:[e.jsx("div",{className:G.preview,children:c||e.jsx("div",{className:G.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:G.info,children:[e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx($n,{})," Import Statistics"]}),e.jsxs("div",{className:G.statGrid,children:[e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Walls"}),e.jsx("div",{className:G.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Zones"}),e.jsx("div",{className:G.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Objects"}),e.jsx("div",{className:G.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Skipped"}),e.jsx("div",{className:G.statValue,children:t.stats.entitiesSkipped})]})]})]}),n&&n.layers.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx(Pt,{})," Layers (",n.layers.length,")"]}),e.jsxs("ul",{className:G.layersList,children:[n.layers.slice(0,6).map((d,C)=>{var b;return e.jsxs("li",{className:G.layer,children:[e.jsx("span",{className:G.layerIcon,children:e.jsx(Pt,{})}),e.jsx("span",{className:G.layerName,children:d.name}),e.jsx("span",{className:G.layerCount,children:((b=d.objects)==null?void 0:b.length)||0})]},d.id||C)}),n.layers.length>6&&e.jsx("li",{className:G.layer,children:e.jsxs("span",{className:G.layerName,children:["+",n.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx(Bt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:G.warningsList,children:[t.warnings.slice(0,5).map((d,C)=>e.jsxs("li",{className:G.warning,children:[e.jsx("span",{className:G.warningIcon,children:e.jsx(Bt,{})}),e.jsx("span",{children:d.message})]},C)),t.warnings.length>5&&e.jsxs("li",{className:G.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),k.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx($t,{})," Errors (",k.length,")"]}),e.jsx("ul",{className:G.warningsList,children:k.slice(0,5).map((d,C)=>e.jsxs("li",{className:G.error,children:[e.jsx("span",{className:G.errorIcon,children:e.jsx($t,{})}),e.jsx("span",{children:d.message})]},C))})]}),t.warnings.length===0&&k.length===0&&e.jsx("div",{className:G.section,children:e.jsx("p",{className:G.noWarnings,children:"✓ No warnings or errors found"})})]})]}),e.jsxs("div",{className:G.footer,children:[e.jsx("button",{className:G.cancelButton,onClick:a,children:"Cancel"}),e.jsx("button",{className:G.confirmButton,onClick:s,disabled:v,children:v?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const Mn="_overlay_1okdy_9",On="_dialog_1okdy_55",An="_header_1okdy_103",En="_title_1okdy_119",Dn="_closeButton_1okdy_133",Rn="_content_1okdy_163",Gn="_description_1okdy_175",Wn="_mappingTable_1okdy_187",qn="_sourceLayer_1okdy_237",Fn="_layerIcon_1okdy_249",Vn="_layerName_1okdy_257",Hn="_objectCount_1okdy_269",Un="_targetSelect_1okdy_281",Zn="_skipOption_1okdy_323",Yn="_arrowIcon_1okdy_333",Kn="_presets_1okdy_343",Xn="_presetButton_1okdy_357",Jn="_footer_1okdy_389",Qn="_footerLeft_1okdy_409",eo="_checkbox_1okdy_421",to="_checkboxLabel_1okdy_433",so="_footerRight_1okdy_443",no="_cancelButton_1okdy_453",oo="_confirmButton_1okdy_485",te={overlay:Mn,dialog:On,header:An,title:En,closeButton:Dn,content:Rn,description:Gn,mappingTable:Wn,sourceLayer:qn,layerIcon:Fn,layerName:Vn,objectCount:Hn,targetSelect:Un,skipOption:Zn,arrowIcon:Yn,presets:Kn,presetButton:Xn,footer:Jn,footerLeft:Qn,checkbox:eo,checkboxLabel:to,footerRight:so,cancelButton:no,confirmButton:oo},Mt=()=>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"})}),ao=()=>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"})}),co=()=>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"})}),Ot={"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 ro(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 io(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 At(t,s){const a=new Map;for(const o of t){const n=s.find(y=>y.type===o.type);if(n){a.set(o.id,n.id);continue}const c=o.name.toLowerCase(),l=s.find(y=>y.name.toLowerCase()===c);if(l){a.set(o.id,l.id);continue}a.set(o.id,o.id)}return a}const lo=({importResult:t,existingDocument:s,onConfirm:a,onCancel:o})=>{const n=r.useMemo(()=>ro(t),[t]),c=r.useMemo(()=>io(s),[s]),[l,y]=r.useState(()=>At(n,c)),[v,k]=r.useState(!0),d=r.useCallback((u,w)=>{y(T=>{const i=new Map(T);return i.set(u,w),i})},[]),C=r.useCallback(u=>{const w=new Map;switch(u){case"auto":y(At(n,c));return;case"skip-all":for(const T of n)w.set(T.id,"skip");break;case"preserve":for(const T of n)w.set(T.id,T.id);break}y(w)},[n,c]),b=r.useCallback(()=>{a(l,v)},[l,v,a]),p=r.useCallback(u=>{u.key==="Escape"?o():u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&b()},[o,b]),N=r.useCallback(u=>{u.target===u.currentTarget&&o()},[o]);return n.length===0?e.jsx("div",{className:te.overlay,onClick:N,onKeyDown:p,tabIndex:-1,children:e.jsxs("div",{className:te.dialog,children:[e.jsxs("div",{className:te.header,children:[e.jsx("h2",{className:te.title,children:"Mapowanie warstw"}),e.jsx("button",{className:te.closeButton,onClick:o,children:e.jsx(Mt,{})})]}),e.jsx("div",{className:te.content,children:e.jsx("p",{className:te.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:te.footer,children:[e.jsx("div",{className:te.footerLeft}),e.jsx("div",{className:te.footerRight,children:e.jsx("button",{className:te.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:te.overlay,onClick:N,onKeyDown:p,tabIndex:-1,children:e.jsxs("div",{className:te.dialog,children:[e.jsxs("div",{className:te.header,children:[e.jsx("h2",{className:te.title,children:"Mapowanie warstw"}),e.jsx("button",{className:te.closeButton,onClick:o,children:e.jsx(Mt,{})})]}),e.jsxs("div",{className:te.content,children:[e.jsx("p",{className:te.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:te.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(u=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:te.sourceLayer,children:[e.jsx("span",{className:te.layerIcon,children:e.jsx(ao,{})}),e.jsx("span",{className:te.layerName,children:u.name}),e.jsxs("span",{className:te.objectCount,children:["(",u.objectCount," ",u.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:te.arrowIcon,children:e.jsx(co,{})}),e.jsx("td",{children:e.jsxs("select",{className:te.targetSelect,value:l.get(u.id)||u.id,onChange:w=>d(u.id,w.target.value),children:[e.jsx("option",{value:"skip",className:te.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:u.id,children:["Utwórz: ",u.name," (",Ot[u.type],")"]}),c.map(w=>e.jsxs("option",{value:w.id,children:[w.name," (",Ot[w.type],")"]},w.id))]})})]},u.id))})]}),e.jsxs("div",{className:te.presets,children:[e.jsx("button",{className:te.presetButton,onClick:()=>C("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:te.presetButton,onClick:()=>C("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:te.presetButton,onClick:()=>C("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:te.footer,children:[e.jsxs("div",{className:te.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:te.checkbox,checked:v,onChange:u=>k(u.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:te.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:te.footerRight,children:[e.jsx("button",{className:te.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:te.confirmButton,onClick:b,children:"Zastosuj mapowanie"})]})]})]})})},uo="_root_4ino1_9",po="_header_4ino1_21",_o="_title_4ino1_31",ho="_layerList_4ino1_45",mo="_layerItem_4ino1_55",xo="_hidden_4ino1_83",yo="_locked_4ino1_91",vo="_visibilityBtn_4ino1_99",fo="_lockBtn_4ino1_101",go="_layerIcon_4ino1_139",bo="_layerName_4ino1_147",jo="_opacitySlider_4ino1_157",Ce={root:uo,header:po,title:_o,layerList:ho,layerItem:mo,hidden:xo,locked:yo,visibilityBtn:vo,lockBtn:fo,layerIcon:go,layerName:bo,opacitySlider:jo},wo={"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"}},Yt=({layers:t,onVisibilityToggle:s,onLockToggle:a,onOpacityChange:o,className:n})=>{const c=[...t].sort((l,y)=>y.zIndex-l.zIndex);return e.jsxs("div",{className:`${Ce.root} ${n??""}`,children:[e.jsx("div",{className:Ce.header,children:e.jsx("h3",{className:Ce.title,children:"Layers"})}),e.jsx("div",{className:Ce.layerList,children:c.map(l=>{const y=wo[l.type]||{icon:"📦",label:l.type};return e.jsxs("div",{className:`${Ce.layerItem} ${l.visible?"":Ce.hidden} ${l.locked?Ce.locked:""}`,children:[e.jsx("button",{className:Ce.visibilityBtn,onClick:()=>s(l.type),title:l.visible?"Hide layer":"Show layer",children:l.visible?"👁":"👁🗨"}),e.jsx("button",{className:Ce.lockBtn,onClick:()=>a(l.type),title:l.locked?"Unlock layer":"Lock layer",children:l.locked?"🔒":"🔓"}),e.jsx("span",{className:Ce.layerIcon,children:y.icon}),e.jsx("span",{className:Ce.layerName,children:y.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:l.opacity,onChange:v=>o(l.type,parseFloat(v.target.value)),className:Ce.opacitySlider,title:`Opacity: ${Math.round(l.opacity*100)}%`})]},l.type)})})]})},No="_root_1lufq_9",ko="_svg_1lufq_31",Co="_viewportRect_1lufq_41",Io="_zoomIndicator_1lufq_49",at={root:No,svg:ko,viewportRect:Co,zoomIndicator:Io},Kt=({document:t,activeFloorId:s,viewport:a,onViewportChange:o,size:n=150,className:c})=>{var h,j;const l=r.useRef(null),y=r.useMemo(()=>t.floors.find(f=>f.id===s)??t.floors[0]??null,[t,s]);if(!y)return null;const v=((h=y.dimensions)==null?void 0:h.width)??1e3,k=((j=y.dimensions)==null?void 0:j.height)??800,d=Math.min(n/v,n/k)*.9,C=v*d,b=k*d,p=n/a.zoom*d,N=n/a.zoom*d,u=-a.pan.x/a.zoom*d,w=-a.pan.y/a.zoom*d,T=r.useCallback(f=>{var me;const g=(me=l.current)==null?void 0:me.getBoundingClientRect();if(!g)return;const m=(f.clientX-g.left-(n-C)/2)/d,A=(f.clientY-g.top-(n-b)/2)/d,H=-(m-n/a.zoom/2)*a.zoom,W=-(A-n/a.zoom/2)*a.zoom;o({pan:{x:H,y:W}})},[d,n,C,b,a.zoom,o]),i=r.useMemo(()=>{const f=y.layers.find(g=>g.name==="zones");return f?f.objects.map(g=>{const m=g;if(!m.polygon||m.polygon.length<3)return null;const A=m.polygon.map((H,W)=>`${W===0?"M":"L"}${H.x*d},${H.y*d}`).join(" ")+" Z";return e.jsx("path",{d:A,fill:m.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.6,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:.5},m.id)}):null},[y,d]);return e.jsxs("div",{className:`${at.root} ${c??""}`,children:[e.jsxs("svg",{ref:l,width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:at.svg,onClick:T,children:[e.jsx("rect",{x:(n-C)/2,y:(n-b)/2,width:C,height:b,fill:"var(--nice-text, #1e293b)",stroke:"var(--nice-text-secondary, #475569)",strokeWidth:1}),e.jsx("g",{transform:`translate(${(n-C)/2}, ${(n-b)/2})`,children:i}),e.jsx("rect",{x:(n-C)/2+u,y:(n-b)/2+w,width:Math.min(p,C),height:Math.min(N,b),fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:1.5,rx:2,className:at.viewportRect})]}),e.jsxs("div",{className:at.zoomIndicator,children:[Math.round(a.zoom*100),"%"]})]})},So="_panel_vacy7_9",Lo="_header_vacy7_27",zo="_title_vacy7_45",To="_closeButton_vacy7_59",Bo="_content_vacy7_85",$o="_endpointSection_vacy7_99",Po="_endpointLabel_vacy7_107",Mo="_endpointSelect_vacy7_123",Oo="_optionsSection_vacy7_157",Ao="_metricButton_vacy7_169",Eo="_metricButtonActive_vacy7_205",Do="_analyzeButton_vacy7_219",Ro="_resultsSection_vacy7_267",Go="_resultsTitle_vacy7_277",Wo="_noResults_vacy7_293",qo="_pathCard_vacy7_309",Fo="_pathCardSelected_vacy7_333",Vo="_pathCardHeader_vacy7_343",Ho="_pathCardTitle_vacy7_361",Uo="_pathBadge_vacy7_373",Zo="_badgePrimary_vacy7_389",Yo="_badgeAlternate_vacy7_399",Ko="_pathName_vacy7_409",Xo="_pathStatus_vacy7_421",Jo="_statusDot_vacy7_435",Qo="_statusActive_vacy7_447",ea="_statusDegraded_vacy7_449",ta="_statusInactive_vacy7_451",sa="_statusError_vacy7_453",na="_pathStats_vacy7_459",oa="_statItem_vacy7_473",aa="_statValue_vacy7_481",ca="_statLabel_vacy7_493",ra="_pathVisualization_vacy7_507",ia="_pathDiagram_vacy7_519",la="_pathNode_vacy7_535",da="_pathNodeStart_vacy7_567",ua="_pathNodeEnd_vacy7_569",pa="_pathLink_vacy7_579",_a="_pathLinkLine_vacy7_591",ha="_showOnMapButton_vacy7_605",ma="_loading_vacy7_641",xa="_spinner_vacy7_655",ya="_spin_vacy7_655",R={panel:So,header:Lo,title:zo,closeButton:To,content:Bo,endpointSection:$o,endpointLabel:Po,endpointSelect:Mo,optionsSection:Oo,metricButton:Ao,metricButtonActive:Eo,analyzeButton:Do,resultsSection:Ro,resultsTitle:Go,noResults:Wo,pathCard:qo,pathCardSelected:Fo,pathCardHeader:Vo,pathCardTitle:Ho,pathBadge:Uo,badgePrimary:Zo,badgeAlternate:Yo,pathName:Ko,pathStatus:Xo,statusDot:Jo,statusActive:Qo,statusDegraded:ea,statusInactive:ta,statusError:sa,pathStats:na,statItem:oa,statValue:aa,statLabel:ca,pathVisualization:ra,pathDiagram:ia,pathNode:la,pathNodeStart:da,pathNodeEnd:ua,pathLink:pa,pathLinkLine:_a,showOnMapButton:ha,loading:ma,spinner:xa,spin:ya},va=()=>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 ba(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function ja(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const wa=({document:t,connections:s,onHighlightPath:a,onClose:o})=>{const[n,c]=r.useState(""),[l,y]=r.useState(""),[v,k]=r.useState("latency"),[d,C]=r.useState([]),[b,p]=r.useState(null),[N,u]=r.useState(!1),w=r.useMemo(()=>{const f=[];for(const g of t.floors)for(const m of g.layers)if(m.type==="network"||m.type==="devices"||m.type==="infrastructure")for(const A of m.objects)f.push({id:A.id,name:A.name??A.id});return f},[t]),T=r.useCallback(f=>{var g;return((g=w.find(m=>m.id===f))==null?void 0:g.name)??f},[w]),i=r.useCallback(()=>{!n||!l||n===l||(u(!0),C([]),p(null),setTimeout(()=>{const f=V.findShortestPath(s,n,l,v),g=V.findAllPaths(s,n,l,5),m=[];f&&m.push(f);for(const A of g)m.some(H=>H.connectionIds.length===A.connectionIds.length&&H.connectionIds.every((W,me)=>A.connectionIds[me]===W))||m.push({...A,isPrimary:!1});C(m),m.length>0&&(p(m[0].id),a==null||a(m[0])),u(!1)},300))},[n,l,v,s,a]),h=r.useCallback(f=>{p(f.id),a==null||a(f)},[a]),j=r.useCallback(f=>{const g=[f.startDeviceId];for(const m of f.connectionIds){const A=s.find(H=>H.id===m);if(A){const H=g[g.length-1],W=A.sourceId===H?A.targetId:A.sourceId;g.includes(W)||g.push(W)}}return g},[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(va,{})})]}),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:f=>c(f.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),w.map(f=>e.jsx("option",{value:f.id,children:f.name},f.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:l,onChange:f=>y(f.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),w.filter(f=>f.id!==n).map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]}),e.jsxs("div",{className:R.optionsSection,children:[e.jsx("button",{className:`${R.metricButton} ${v==="latency"?R.metricButtonActive:""}`,onClick:()=>k("latency"),children:"Latencja"}),e.jsx("button",{className:`${R.metricButton} ${v==="hops"?R.metricButtonActive:""}`,onClick:()=>k("hops"),children:"Hops"}),e.jsx("button",{className:`${R.metricButton} ${v==="bandwidth"?R.metricButtonActive:""}`,onClick:()=>k("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:R.analyzeButton,onClick:i,disabled:!n||!l||n===l||N,children:N?"Analizowanie...":"Analizuj ścieżkę"}),N?e.jsx("div",{className:R.loading,children:e.jsx("div",{className:R.spinner})}):d.length>0?e.jsxs("div",{className:R.resultsSection,children:[e.jsxs("div",{className:R.resultsTitle,children:["Znalezione ścieżki (",d.length,")"]}),d.map((f,g)=>{const m=j(f),A=b===f.id;return e.jsxs("div",{className:`${R.pathCard} ${A?R.pathCardSelected:""}`,onClick:()=>h(f),children:[e.jsxs("div",{className:R.pathCardHeader,children:[e.jsxs("div",{className:R.pathCardTitle,children:[e.jsx("span",{className:`${R.pathBadge} ${f.isPrimary?R.badgePrimary:R.badgeAlternate}`,children:f.isPrimary?"Optymalna":`Alt ${g}`}),e.jsxs("span",{className:R.pathName,children:[f.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:R.pathStatus,children:[e.jsx("span",{className:`${R.statusDot} ${R[`status${f.status.charAt(0).toUpperCase()+f.status.slice(1)}`]??""}`}),e.jsx("span",{children:ga(f.status)})]})]}),e.jsxs("div",{className:R.pathStats,children:[e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:ba(f.totalLatency)}),e.jsx("div",{className:R.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:f.connectionIds.length}),e.jsx("div",{className:R.statLabel,children:"Hops"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:f.bottleneckBandwidth>0?ja(f.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:R.statLabel,children:"Przepustowość"})]})]}),A&&e.jsxs("div",{className:R.pathVisualization,children:[e.jsx("div",{className:R.pathDiagram,children:m.map((H,W)=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:`${R.pathNode} ${W===0?R.pathNodeStart:W===m.length-1?R.pathNodeEnd:""}`,children:T(H).substring(0,8)}),W<m.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(f)},children:"Pokaż na mapie"})]})]},f.id)})]}):n&&l&&n!==l?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"})]})]})},Na="_root_6pirz_9",ka="_header_6pirz_27",Ca="_title_6pirz_37",Ia="_search_6pirz_51",Sa="_categories_6pirz_79",La="_category_6pirz_91",za="_categoryHeader_6pirz_107",Ta="_categoryIcon_6pirz_143",Ba="_categoryLabel_6pirz_151",$a="_categoryCount_6pirz_161",Pa="_expandIcon_6pirz_171",Ma="_items_6pirz_181",Oa="_item_6pirz_181",Aa="_itemIcon_6pirz_241",Ea="_itemName_6pirz_249",Da="_emptyState_6pirz_269",be={root:Na,header:ka,title:Ca,search:Ia,categories:Sa,category:La,categoryHeader:za,categoryIcon:Ta,categoryLabel:Ba,categoryCount:$a,expandIcon:Pa,items:Ma,item:Oa,itemIcon:Aa,itemName:Ea,emptyState:Da},Ra={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},Ga={"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"}},Xt=({mode:t,onObjectSelect:s,customObjects:a=[],className:o})=>{const[n,c]=r.useState(""),[l,y]=r.useState(new Set(["smart-home","furniture","network"])),v=Ra[t]||[],k=r.useMemo(()=>{const b={},p=V.OBJECT_CATALOG.reduce((N,u)=>{var w;return(N[w=u.category]??(N[w]=[])).push(u),N},{});return Object.entries(p).forEach(([N,u])=>{if(!v.includes(N))return;const w=u.filter(T=>!n||T.name.toLowerCase().includes(n.toLowerCase()));w.length>0&&(b[N]=w.map(T=>({id:T.id,name:T.name,category:N,icon:T.icon})))}),a.forEach(N=>{v.includes(N.category)&&(!n||N.name.toLowerCase().includes(n.toLowerCase()))&&(b[N.category]||(b[N.category]=[]),b[N.category].push(N))}),b},[v,n,a]),d=b=>{y(p=>{const N=new Set(p);return N.has(b)?N.delete(b):N.add(b),N})},C=(b,p)=>{b.dataTransfer.setData("application/json",JSON.stringify(p)),b.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${be.root} ${o??""}`,children:[e.jsxs("div",{className:be.header,children:[e.jsx("h3",{className:be.title,children:"Objects"}),e.jsx("input",{type:"text",className:be.search,placeholder:"Search...",value:n,onChange:b=>c(b.target.value)})]}),e.jsxs("div",{className:be.categories,children:[Object.entries(k).map(([b,p])=>{const N=Ga[b]||{icon:"📦",label:b},u=l.has(b);return e.jsxs("div",{className:be.category,children:[e.jsxs("button",{className:be.categoryHeader,onClick:()=>d(b),children:[e.jsx("span",{className:be.categoryIcon,children:N.icon}),e.jsx("span",{className:be.categoryLabel,children:N.label}),e.jsxs("span",{className:be.categoryCount,children:["(",p.length,")"]}),e.jsx("span",{className:be.expandIcon,children:u?"▼":"▶"})]}),u&&e.jsx("div",{className:be.items,children:p.map(w=>e.jsxs("div",{className:be.item,draggable:!0,onDragStart:T=>C(T,w),onClick:()=>s(w),title:w.name,children:[e.jsx("span",{className:be.itemIcon,children:w.icon||"📦"}),e.jsx("span",{className:be.itemName,children:w.name})]},w.id))})]},b)}),Object.keys(k).length===0&&e.jsx("div",{className:be.emptyState,children:n?`No objects matching "${n}"`:"No objects available for this mode"})]})]})},Wa="_root_o3eqo_9",qa="_header_o3eqo_23",Fa="_title_o3eqo_39",Va="_multiSelect_o3eqo_53",Ha="_content_o3eqo_63",Ua="_section_o3eqo_73",Za="_sectionHeader_o3eqo_89",Ya="_sectionContent_o3eqo_127",Ka="_fieldRow_o3eqo_135",Xa="_fieldLabel_o3eqo_157",Ja="_textInput_o3eqo_169",Qa="_numberInput_o3eqo_171",ec="_select_o3eqo_173",tc="_checkbox_o3eqo_215",sc="_colorInput_o3eqo_227",nc="_readOnly_o3eqo_245",oc="_emptyState_o3eqo_263",ee={root:Wa,header:qa,title:Fa,multiSelect:Va,content:Ha,section:Ua,sectionHeader:Za,sectionContent:Ya,fieldRow:Ka,fieldLabel:Xa,textInput:Ja,numberInput:Qa,select:ec,checkbox:tc,colorInput:sc,readOnly:nc,emptyState:oc},wt=[{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"}],ac=[{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}],cc=[{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"}]}],Jt=({selection:t,document:s,onPropertyChange:a,className:o})=>{const[n,c]=r.useState(new Set(["general","position","appearance"])),l=t.objectIds.map(p=>{for(const N of s.floors)for(const u of N.layers){const w=u.objects.find(T=>T.id===p);if(w)return w}return null}).filter(Boolean),y=p=>{c(N=>{const u=new Set(N);return u.has(p)?u.delete(p):u.add(p),u})},v=r.useCallback((p,N)=>{const u=N.split(".");let w=p;for(const T of u)if(w&&typeof w=="object"&&T in w)w=w[T];else return;return w},[]),k=r.useCallback((p,N)=>{var w;const u=v(N,p.key);switch(p.type){case"text":return e.jsx("input",{type:"text",value:String(u??""),onChange:T=>a(N.id,p.key,T.target.value),className:ee.textInput});case"number":return e.jsx("input",{type:"number",value:Number(u??0),min:p.min,max:p.max,step:p.step,onChange:T=>a(N.id,p.key,parseFloat(T.target.value)),className:ee.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!u,onChange:T=>a(N.id,p.key,T.target.checked),className:ee.checkbox});case"color":return e.jsx("input",{type:"color",value:String(u??"var(--nice-bg, #fff)"),onChange:T=>a(N.id,p.key,T.target.value),className:ee.colorInput});case"select":return e.jsx("select",{value:String(u??""),onChange:T=>a(N.id,p.key,T.target.value),className:ee.select,children:(w=p.options)==null?void 0:w.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))});default:return e.jsx("span",{children:String(u??"-")})}},[v,a]);if(l.length===0)return e.jsxs("div",{className:`${ee.root} ${o??""}`,children:[e.jsx("div",{className:ee.header,children:e.jsx("h3",{className:ee.title,children:"Properties"})}),e.jsx("div",{className:ee.emptyState,children:"No object selected"})]});const d=l[0],C=l.length>1,b=d.category==="zone"?ac:["smart-home","network","infrastructure"].includes(d.category??"")?cc:[];return e.jsxs("div",{className:`${ee.root} ${o??""}`,children:[e.jsxs("div",{className:ee.header,children:[e.jsx("h3",{className:ee.title,children:"Properties"}),C&&e.jsxs("span",{className:ee.multiSelect,children:[l.length," selected"]})]}),e.jsxs("div",{className:ee.content,children:[e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("general"),children:[e.jsx("span",{children:n.has("general")?"▼":"▶"}),e.jsx("span",{children:"General"})]}),n.has("general")&&e.jsxs("div",{className:ee.sectionContent,children:[wt.slice(0,1).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key)),e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:"ID"}),e.jsx("span",{className:ee.readOnly,children:d.id})]}),e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:"Category"}),e.jsx("span",{className:ee.readOnly,children:d.category})]})]})]}),e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("position"),children:[e.jsx("span",{children:n.has("position")?"▼":"▶"}),e.jsx("span",{children:"Transform"})]}),n.has("position")&&e.jsx("div",{className:ee.sectionContent,children:wt.slice(1,4).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]}),b.length>0&&e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("appearance"),children:[e.jsx("span",{children:n.has("appearance")?"▼":"▶"}),e.jsx("span",{children:"Appearance"})]}),n.has("appearance")&&e.jsx("div",{className:ee.sectionContent,children:b.map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]}),e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("visibility"),children:[e.jsx("span",{children:n.has("visibility")?"▼":"▶"}),e.jsx("span",{children:"Visibility"})]}),n.has("visibility")&&e.jsx("div",{className:ee.sectionContent,children:wt.slice(4).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]})]})]})},rc="_panel_ldte3_9",ic="_header_ldte3_33",lc="_headerTitle_ldte3_51",dc="_title_ldte3_65",uc="_closeButton_ldte3_79",pc="_summarySection_ldte3_111",_c="_summaryStats_ldte3_121",hc="_statBadge_ldte3_133",mc="_statValue_ldte3_147",xc="_statLabel_ldte3_159",yc="_visibilityControls_ldte3_175",vc="_visibilityLabel_ldte3_193",fc="_visibilityButtons_ldte3_203",gc="_visibilityBtn_ldte3_213",bc="_active_ldte3_243",jc="_content_ldte3_257",wc="_emptyState_ldte3_271",Nc="_emptyHint_ldte3_317",kc="_vlanList_ldte3_329",Cc="_vlanCard_ldte3_343",Ic="_highlighted_ldte3_369",Sc="_hidden_ldte3_379",Lc="_vlanHeader_ldte3_387",zc="_colorIndicator_ldte3_413",Tc="_vlanInfo_ldte3_427",Bc="_vlanName_ldte3_437",$c="_vlanId_ldte3_451",Pc="_vlanNameText_ldte3_463",Mc="_vlanSubnet_ldte3_479",Oc="_vlanStats_ldte3_495",Ac="_chipStat_ldte3_507",Ec="_vlanActions_ldte3_537",Dc="_iconBtn_ldte3_549",Rc="_inactive_ldte3_587",Gc="_expanded_ldte3_603",Wc="_vlanDetails_ldte3_615",qc="_detailRow_ldte3_627",Fc="_detailLabel_ldte3_649",Vc="_detailValue_ldte3_667",Hc="_badge_ldte3_679",Uc="_badgeSuccess_ldte3_693",Zc="_badgeNeutral_ldte3_703",Yc="_deviceList_ldte3_715",Kc="_deviceItems_ldte3_723",Xc="_deviceItem_ldte3_723",Jc="_deviceDot_ldte3_757",Qc="_deviceMore_ldte3_771",er="_highlightButton_ldte3_787",tr="_footer_ldte3_827",sr="_legendTitle_ldte3_839",nr="_legend_ldte3_839",or="_legendItem_ldte3_867",ar="_legendColor_ldte3_879",cr="_legendLabel_ldte3_893",$={panel:rc,header:ic,headerTitle:lc,title:dc,closeButton:uc,summarySection:pc,summaryStats:_c,statBadge:hc,statValue:mc,statLabel:xc,visibilityControls:yc,visibilityLabel:vc,visibilityButtons:fc,visibilityBtn:gc,active:bc,content:jc,emptyState:wc,emptyHint:Nc,vlanList:kc,vlanCard:Cc,highlighted:Ic,hidden:Sc,vlanHeader:Lc,colorIndicator:zc,vlanInfo:Tc,vlanName:Bc,vlanId:$c,vlanNameText:Pc,vlanSubnet:Mc,vlanStats:Oc,chipStat:Ac,vlanActions:Ec,iconBtn:Dc,inactive:Rc,expanded:Gc,vlanDetails:Wc,detailRow:qc,detailLabel:Fc,detailValue:Vc,badge:Hc,badgeSuccess:Uc,badgeNeutral:Zc,deviceList:Yc,deviceItems:Kc,deviceItem:Xc,deviceDot:Jc,deviceMore:Qc,highlightButton:er,footer:tr,legendTitle:sr,legend:nr,legendItem:or,legendColor:ar,legendLabel:cr},rr=()=>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"})}),ir=()=>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"})]}),lr=()=>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"})]}),Et=()=>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"})]}),dr=()=>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 ur(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function pr(t,s){return s.filter(a=>a.vlanId===t.id).length}function _r(t){return t||"—"}const hr=({document:t,connections:s,vlans:a,visibleVlanIds:o,onVlanVisibilityChange:n,onHighlightVlan:c,onClose:l})=>{const[y,v]=r.useState(null),[k,d]=r.useState(null),C=r.useMemo(()=>[...a].sort((h,j)=>h.id-j.id),[a]),b=r.useMemo(()=>{const h=new Set,j=new Set;for(const f of a)for(const g of f.deviceIds??[])h.add(g);for(const f of s)f.vlanId!==void 0&&j.add(f.id);return{vlanCount:a.length,deviceCount:h.size,connectionCount:j.size}},[a,s]),p=r.useCallback(h=>{const j=o.has(h);n==null||n(h,!j)},[o,n]),N=r.useCallback(h=>{for(const j of a)n==null||n(j.id,h)},[a,n]),u=r.useCallback(h=>{v((h==null?void 0:h.id)??null),c==null||c(h)},[c]),w=r.useCallback(h=>{d(j=>j===h?null:h)},[]),T=r.useCallback(h=>{const j=[];for(const f of h.deviceIds??[])for(const g of t.floors)for(const m of g.layers){const A=m.objects.find(H=>H.id===f);A&&j.push({id:f,name:A.name??f})}return j},[t]),i=r.useMemo(()=>{const h=a.filter(j=>o.has(j.id)).length;return{visible:h,total:a.length,allVisible:h===a.length,noneVisible:h===0}},[a,o]);return e.jsxs("div",{className:$.panel,children:[e.jsxs("div",{className:$.header,children:[e.jsxs("div",{className:$.headerTitle,children:[e.jsx(Et,{}),e.jsx("h3",{className:$.title,children:"Nakładka VLAN"})]}),l&&e.jsx("button",{className:$.closeButton,onClick:l,title:"Zamknij",children:e.jsx(rr,{})})]}),e.jsx("div",{className:$.summarySection,children:e.jsxs("div",{className:$.summaryStats,children:[e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.vlanCount}),e.jsx("span",{className:$.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.deviceCount}),e.jsx("span",{className:$.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.connectionCount}),e.jsx("span",{className:$.statLabel,children:"Połączeń"})]})]})}),e.jsxs("div",{className:$.visibilityControls,children:[e.jsxs("span",{className:$.visibilityLabel,children:["Widoczność: ",i.visible,"/",i.total]}),e.jsxs("div",{className:$.visibilityButtons,children:[e.jsx("button",{className:`${$.visibilityBtn} ${i.allVisible?$.active:""}`,onClick:()=>N(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${$.visibilityBtn} ${i.noneVisible?$.active:""}`,onClick:()=>N(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:$.content,children:C.length===0?e.jsxs("div",{className:$.emptyState,children:[e.jsx(Et,{}),e.jsx("p",{children:"Brak zdefiniowanych VLAN-ów"}),e.jsx("span",{className:$.emptyHint,children:"Dodaj VLAN w trybie network-topology lub infrastructure"})]}):e.jsx("div",{className:$.vlanList,children:C.map(h=>{const j=o.has(h.id),f=y===h.id,g=k===h.id,m=ur(h),A=pr(h,s),H=g?T(h):[];return e.jsxs("div",{className:`${$.vlanCard} ${f?$.highlighted:""} ${j?"":$.hidden}`,onMouseEnter:()=>u(h),onMouseLeave:()=>u(null),children:[e.jsxs("div",{className:$.vlanHeader,children:[e.jsx("div",{className:$.colorIndicator,style:{backgroundColor:h.color}}),e.jsxs("div",{className:$.vlanInfo,children:[e.jsxs("div",{className:$.vlanName,children:[e.jsxs("span",{className:$.vlanId,children:["VLAN ",h.id]}),h.name&&e.jsx("span",{className:$.vlanNameText,children:h.name})]}),h.subnet&&e.jsx("div",{className:$.vlanSubnet,children:_r(h.subnet)})]}),e.jsxs("div",{className:$.vlanStats,children:[e.jsx("span",{className:$.chipStat,title:"Urządzenia",children:m}),e.jsx("span",{className:$.chipStat,title:"Połączenia",children:A})]}),e.jsxs("div",{className:$.vlanActions,children:[e.jsx("button",{className:`${$.iconBtn} ${j?"":$.inactive}`,onClick:W=>{W.stopPropagation(),p(h.id)},title:j?"Ukryj VLAN":"Pokaż VLAN",children:j?e.jsx(ir,{}):e.jsx(lr,{})}),e.jsx("button",{className:`${$.iconBtn} ${g?$.expanded:""}`,onClick:W=>{W.stopPropagation(),w(h.id)},title:"Szczegóły",children:e.jsx(dr,{})})]})]}),g&&e.jsxs("div",{className:$.vlanDetails,children:[h.description&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Opis:"}),e.jsx("span",{className:$.detailValue,children:h.description})]}),h.subnet&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:$.detailValue,children:h.subnet})]}),h.gateway&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Brama:"}),e.jsx("span",{className:$.detailValue,children:h.gateway})]}),e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${$.detailValue} ${$.badge} ${h.dhcpEnabled?$.badgeSuccess:$.badgeNeutral}`,children:h.dhcpEnabled?"Włączone":"Wyłączone"})]}),H.length>0&&e.jsxs("div",{className:$.deviceList,children:[e.jsxs("span",{className:$.detailLabel,children:["Urządzenia (",H.length,"):"]}),e.jsxs("ul",{className:$.deviceItems,children:[H.slice(0,10).map(W=>e.jsxs("li",{className:$.deviceItem,children:[e.jsx("span",{className:$.deviceDot,style:{backgroundColor:h.color}}),W.name]},W.id)),H.length>10&&e.jsxs("li",{className:$.deviceMore,children:["... i ",H.length-10," więcej"]})]})]}),e.jsx("button",{className:$.highlightButton,onClick:()=>c==null?void 0:c(h),children:"Zaznacz na mapie"})]})]},h.id)})})}),C.length>0&&e.jsxs("div",{className:$.footer,children:[e.jsx("div",{className:$.legendTitle,children:"Legenda kolorów"}),e.jsx("div",{className:$.legend,children:C.map(h=>e.jsxs("div",{className:$.legendItem,children:[e.jsx("span",{className:$.legendColor,style:{backgroundColor:h.color}}),e.jsxs("span",{className:$.legendLabel,children:[h.id,h.name?`: ${h.name}`:""]})]},h.id))})]})]})},mr="_root_e4i3q_9",xr="_dark_e4i3q_35",yr="_topBar_e4i3q_59",vr="_modeSwitcher_e4i3q_77",fr="_modeBtn_e4i3q_87",gr="_modeBtnActive_e4i3q_123",br="_modeIcon_e4i3q_135",jr="_modeLabel_e4i3q_143",wr="_floorTabs_e4i3q_151",Nr="_floorTab_e4i3q_151",kr="_floorTabActive_e4i3q_195",Cr="_viewportControls_e4i3q_207",Ir="_active_e4i3q_249",Sr="_disabled_e4i3q_259",Lr="_separator_e4i3q_273",zr="_zoomLevel_e4i3q_287",Tr="_exportDropdown_e4i3q_305",Br="_exportMenu_e4i3q_353",$r="_mainContent_e4i3q_427",Pr="_editorContainer_e4i3q_443",Mr="_toolbar_e4i3q_461",Or="_toolGroup_e4i3q_481",Ar="_toolBtn_e4i3q_509",Er="_toolBtnActive_e4i3q_549",Dr="_canvasWrapper_e4i3q_573",Rr="_canvas_e4i3q_573",Gr="_cursor_select_e4i3q_601",Wr="_cursor_multi_select_e4i3q_603",qr="_cursor_pan_e4i3q_605",Fr="_cursor_zoom_e4i3q_609",Vr="_cursor_draw_wall_e4i3q_611",Hr="_cursor_draw_zone_e4i3q_613",Ur="_cursor_draw_polyline_e4i3q_615",Zr="_cursor_draw_rectangle_e4i3q_617",Yr="_cursor_draw_circle_e4i3q_619",Kr="_cursor_draw_arc_e4i3q_621",Xr="_cursor_place_device_e4i3q_623",Jr="_cursor_place_furniture_e4i3q_625",Qr="_cursor_place_network_e4i3q_627",ei="_cursor_place_infra_e4i3q_629",ti="_cursor_place_door_e4i3q_631",si="_cursor_place_window_e4i3q_633",ni="_cursor_place_stairs_e4i3q_635",oi="_cursor_connect_e4i3q_637",ai="_cursor_route_cable_e4i3q_639",ci="_cursor_annotate_e4i3q_641",ri="_cursor_dimension_e4i3q_643",ii="_cursor_label_e4i3q_645",li="_cursor_measure_distance_e4i3q_647",di="_cursor_measure_angle_e4i3q_649",ui="_cursor_measure_area_e4i3q_651",pi="_cursor_move_e4i3q_653",_i="_cursor_rotate_e4i3q_655",hi="_cursor_scale_e4i3q_657",mi="_cursor_erase_e4i3q_659",xi="_cursor_copy_e4i3q_661",yi="_cursor_paste_e4i3q_663",vi="_grid_e4i3q_669",fi="_gridLine_e4i3q_671",gi="_zonesLayer_e4i3q_683",bi="_zone_e4i3q_683",ji="_zoneLabel_e4i3q_689",wi="_connectionsLayer_e4i3q_703",Ni="_connection_e4i3q_703",ki="_connectionPreview_e4i3q_709",Ci="_guides_e4i3q_715",Ii="_guideLine_e4i3q_717",Si="_drawingPreview_e4i3q_731",Li="_rightSidebar_e4i3q_739",zi="_statusBar_e4i3q_761",Ti="_modeIndicator_e4i3q_783",Bi="_toolIndicator_e4i3q_785",$i="_selectionInfo_e4i3q_797",Pi="_drawingInfo_e4i3q_799",Mi="_connectingInfo_e4i3q_813",Oi="_gridInfo_e4i3q_827",Ai="_emptyState_e4i3q_839",Ei="_emptyIcon_e4i3q_861",Di="_primaryBtn_e4i3q_891",Ri="_modeActions_e4i3q_925",Gi="_actionBtn_e4i3q_943",O={root:mr,dark:xr,topBar:yr,modeSwitcher:vr,modeBtn:fr,modeBtnActive:gr,modeIcon:br,modeLabel:jr,floorTabs:wr,floorTab:Nr,floorTabActive:kr,viewportControls:Cr,active:Ir,disabled:Sr,separator:Lr,zoomLevel:zr,exportDropdown:Tr,exportMenu:Br,mainContent:$r,editorContainer:Pr,toolbar:Mr,toolGroup:Or,toolBtn:Ar,toolBtnActive:Er,canvasWrapper:Dr,canvas:Rr,cursor_select:Gr,cursor_multi_select:Wr,cursor_pan:qr,cursor_zoom:Fr,cursor_draw_wall:Vr,cursor_draw_zone:Hr,cursor_draw_polyline:Ur,cursor_draw_rectangle:Zr,cursor_draw_circle:Yr,cursor_draw_arc:Kr,cursor_place_device:Xr,cursor_place_furniture:Jr,cursor_place_network:Qr,cursor_place_infra:ei,cursor_place_door:ti,cursor_place_window:si,cursor_place_stairs:ni,cursor_connect:oi,cursor_route_cable:ai,cursor_annotate:ci,cursor_dimension:ri,cursor_label:ii,cursor_measure_distance:li,cursor_measure_angle:di,cursor_measure_area:ui,cursor_move:pi,cursor_rotate:_i,cursor_scale:hi,cursor_erase:mi,cursor_copy:xi,cursor_paste:yi,grid:vi,gridLine:fi,zonesLayer:gi,zone:bi,zoneLabel:ji,connectionsLayer:wi,connection:Ni,connectionPreview:ki,guides:Ci,guideLine:Ii,drawingPreview:Si,rightSidebar:Li,statusBar:zi,modeIndicator:Ti,toolIndicator:Bi,selectionInfo:$i,drawingInfo:Pi,connectingInfo:Mi,gridInfo:Oi,emptyState:Ai,emptyIcon:Ei,primaryBtn:Di,modeActions:Ri,actionBtn:Gi},Ye={"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}},Ct={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 Wi(t){var n,c;const s=t.defaultMode??"floor-plan",a=Ye[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 Ue(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 Ze(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function Re(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 ct(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 rt(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 it(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 qi(t,s){var a;switch(s.type){case"SET_MODE":{const o=Ye[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=it(t.document,t.activeFloorId,o,s.object),c=Ue("create",[s.object.id],null,s.object);return{...t,document:n,...Ze(t,c)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=Re(t.document,s.objectId);if(!o)return t;const n=ct(t.document,s.objectId,s.updates),c=Ue("update",[s.objectId],o,{...o,...s.updates});return{...t,document:n,...Ze(t,c)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(l=>Re(t.document,l)).filter(Boolean),n=rt(t.document,s.objectIds),c=Ue("delete",s.objectIds,o,null);return{...t,document:n,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(y=>Re(t.document,y)).filter(Boolean);let n=t.document;for(const y of s.objectIds){const v=Re(n,y);if(v&&"transform"in v&&v.transform&&"position"in v.transform){const k=v.transform.position;n=ct(n,y,{transform:{...v.transform,position:{x:k.x+s.delta.x,y:k.y+s.delta.y}}})}}const c=s.objectIds.map(y=>Re(n,y)).filter(Boolean),l=Ue("move",s.objectIds,o,c);return{...t,document:n,...Ze(t,l)}}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=rt(n,o.objectIds);break}case"delete":{const c=o.before;for(const l of c){const y=l.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,y,l)}break}case"update":case"move":{const c=o.before;for(const l of c)n=ct(n,l.id,l);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,l=c.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,l,c);break}case"delete":{n=rt(n,o.objectIds);break}case"update":case"move":{const c=o.after;for(const l of c)n=ct(n,l.id,l);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=>Re(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(l=>Re(t.document,l)).filter(Boolean),n=rt(t.document,t.selection.objectIds),c=Ue("delete",t.selection.objectIds,o,null);return{...t,document:n,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const n=[],c=[];for(const y of t.clipboard){const v=`${y.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,k=y.transform,d={position:{x:k.position.x+s.position.x+20,y:k.position.y+s.position.y+20},rotation:k.rotation,scale:k.scale},C={...y,id:v,transform:d},b=C.layer||"devices";o=it(o,t.activeFloorId,b,C),n.push(v),c.push(C)}const l=Ue("create",n,null,c);return{...t,document:o,selection:{objectIds:n,bounds:null,locked:!1},...Ze(t,l)}}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 Fi=({mode:t,activeTool:s,onToolSelect:a,readOnly:o})=>{const c=Ye[t].tools.map(y=>Ct[y]).filter(Boolean),l=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:O.toolbar,children:l.map(y=>{const v=c.filter(k=>k.group===y);return v.length===0?null:e.jsx("div",{className:O.toolGroup,children:v.map(({tool:k,icon:d,label:C,shortcut:b})=>e.jsx("button",{title:`${C}${b?` (${b})`:""}`,className:`${O.toolBtn} ${s===k?O.toolBtnActive:""}`,onClick:()=>a(k),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(k),children:d},k))},y)})})},Vi=({currentMode:t,availableModes:s,onModeChange:a})=>e.jsx("div",{className:O.modeSwitcher,children:s.map(o=>{const n=Ye[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 Dt(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 Hi(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 l=c.metadata;if((l==null?void 0:l.vlanId)!==void 0&&!a.has(l.vlanId))a.add(l.vlanId),s.push({id:l.vlanId,name:l.vlanName??`VLAN ${l.vlanId}`,color:l.vlanColor??Ui(l.vlanId),deviceIds:[c.id],subnet:l.subnet,gateway:l.gateway,dhcpEnabled:l.dhcpEnabled});else if((l==null?void 0:l.vlanId)!==void 0){const y=s.find(v=>v.id===l.vlanId);y&&!y.deviceIds.includes(c.id)&&y.deviceIds.push(c.id)}}return s.sort((o,n)=>o.id-n.id)}function Ui(t){const s=["var(--nice-primary, #3b82f6)","var(--nice-success, #22c55e)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-accent-pink, #ec4899)","var(--nice-info, #06b6d4)","var(--nice-warning, #f97316)","var(--nice-info, #14b8a6)","var(--nice-accent, #a855f7)"];return s[t%s.length]}const Zi=[{target:".nice-spatial-editor",titleKey:"tutorial.spatialEditor.intro.title",title:"Spatial editor",contentKey:"tutorial.spatialEditor.intro.content",content:"Lay out floor plans across modes: draw walls, rooms and objects with the tools, manage layers, snap to the grid, then export.",placement:"auto"}],Yi=t=>{var St,Lt;const{defaultMode:s="floor-plan",availableModes:a=Object.keys(Ye),readOnly:o=!1,theme:n="light",locale:c="en",onDocumentChange:l,onSelectionChange:y,onModeChange:v,onExport:k,onImport:d,tutorial:C,className:b,style:p,cookies:N=!1,localStorage:u=!0,sessionStorage:w=!1,storageMode:T,storageKey:i,persistPreferences:h=!1}=t,j=Me.useStorageAdapter(i??"nice-spatial-editor"),[f]=r.useState(()=>h?j.get("prefs")??{}:{}),[g,m]=r.useReducer(qi,t,Wi),A=r.useRef(null),H=r.useRef(!1),W=r.useRef({x:0,y:0}),[me,ue]=r.useState(!1),[de,ye]=r.useState(!1),[ne,re]=r.useState(null),[ce,S]=r.useState(null),[F,ie]=r.useState(!1),[Ne,ke]=r.useState(!1),[fe,Te]=r.useState(!1),[Be,Ge]=r.useState(new Set),[tt,Oe]=r.useState(null),$e=r.useRef(null),Ee=r.useRef(null),Ie=r.useRef(null),{mode:je,tool:he,document:se,activeFloorId:De,layers:we,selection:ve,viewport:oe,drawing:_e,connecting:X,guides:We,ui:Pe,history:Ke}=g,qe=Ye[je],st=Ke.past.length>0,Xe=Ke.future.length>0;r.useEffect(()=>{var x,M,P;!h||!f||((f.zoom||f.pan)&&m({type:"SET_VIEWPORT",viewport:{zoom:f.zoom,pan:f.pan,showGrid:(x=f.gridConfig)==null?void 0:x.visible,gridSize:(M=f.gridConfig)==null?void 0:M.size,snapEnabled:(P=f.gridConfig)==null?void 0:P.snapEnabled}}),f.mode&&m({type:"SET_MODE",mode:f.mode}),f.tool&&m({type:"SET_TOOL",tool:f.tool}),f.layerVisibility&&Object.entries(f.layerVisibility).forEach(([D,U])=>{U!==void 0&&m({type:"SET_LAYER_VISIBILITY",layerType:D,visible:U})}))},[]),r.useEffect(()=>{if(!h)return;const x={zoom:oe.zoom,pan:oe.pan,gridConfig:{size:oe.gridSize,visible:oe.showGrid,snapEnabled:oe.snapEnabled},mode:je,tool:he,layerVisibility:Object.fromEntries(we.map(M=>[M.type,M.visible])),uiPanels:Pe};j.set("prefs",x)},[h,oe,je,he,we,Pe,j]);const xe=r.useMemo(()=>(se==null?void 0:se.floors.find(x=>x.id===De))??(se==null?void 0:se.floors[0])??null,[se,De]),Ae=r.useCallback((x,M)=>{var D;const P=(D=A.current)==null?void 0:D.getBoundingClientRect();return P?{x:(x-P.left-oe.pan.x)/oe.zoom,y:(M-P.top-oe.pan.y)/oe.zoom}:{x:0,y:0}},[oe.pan,oe.zoom]),Fe=r.useCallback(x=>{if(!oe.snapEnabled)return x;const M={cellSize:oe.gridSize,majorInterval:10,origin:{x:0,y:0},visible:oe.showGrid,color:"var(--nice-border, #e5e7eb)",majorColor:"var(--nice-text-muted, #9ca3af)",opacity:1,snapModes:["grid"],snapThreshold:10,angleIncrement:15};return V.snapToGrid(x,M)},[oe.snapEnabled,oe.gridSize,oe.showGrid]),pt=r.useCallback(x=>{if(he==="pan"||x.button===1){H.current=!0,W.current={x:x.clientX,y:x.clientY};return}const M=Fe(Ae(x.clientX,x.clientY));if(he==="draw-zone"||he==="draw-wall"||he==="draw-polyline")_e.active?m({type:"ADD_DRAWING_POINT",point:M}):m({type:"START_DRAWING",point:M});else if(he==="connect"){const P=xe==null?void 0:xe.layers.flatMap(D=>D.objects).find(D=>{if(!D.bounds)return!1;const U=D.bounds;return M.x>=U.x&&M.x<=U.x+U.width&&M.y>=U.y&&M.y<=U.y+U.height});if(P)if(X.active){m({type:"FINISH_CONNECTING",targetId:P.id});const D=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,U=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M,Y={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(X.sourcePosition.x,U.x),y:Math.min(X.sourcePosition.y,U.y),width:Math.abs(U.x-X.sourcePosition.x),height:Math.abs(U.y-X.sourcePosition.y)},metadata:{sourceId:X.sourceId,targetId:P.id,sourcePosition:X.sourcePosition,targetPosition:U,medium:"ethernet-cat6",status:"active"}};m({type:"ADD_OBJECT",object:Y})}else{const D=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M;m({type:"START_CONNECTING",sourceId:P.id,sourcePosition:D})}else X.active&&m({type:"CANCEL_CONNECTING"})}else he==="select"&&m({type:"CLEAR_SELECTION"})},[he,_e.active,X.active,X.sourceId,X.sourcePosition,Fe,Ae,xe]),_t=r.useCallback(x=>{if(H.current){const P=x.clientX-W.current.x,D=x.clientY-W.current.y;m({type:"PAN",delta:{x:P,y:D}}),W.current={x:x.clientX,y:x.clientY};return}const M=Fe(Ae(x.clientX,x.clientY));if(_e.active&&(m({type:"UPDATE_DRAWING_PREVIEW",point:M}),oe.snapEnabled&&xe)){const P=xe.layers.flatMap(Y=>Y.objects.filter(ae=>ae.bounds).map(ae=>({id:ae.id,bounds:ae.bounds}))),D={x:M.x,y:M.y,width:1,height:1},U=V.generateAlignmentGuides(D,P,10);m({type:"SET_GUIDES",guides:U})}X.active&&m({type:"UPDATE_CONNECTING_PREVIEW",position:M})},[_e.active,X.active,Fe,Ae,oe.snapEnabled,xe]),ht=r.useCallback(()=>{H.current=!1},[]),mt=r.useCallback(x=>{_e.active&&_e.points.length>=2&&m({type:"FINISH_DRAWING"})},[_e.active,_e.points.length]),xt=r.useCallback(x=>{x.preventDefault();const M=x.deltaY>0?-1:1;m({type:"ZOOM",delta:M,center:Ae(x.clientX,x.clientY)})},[Ae]),yt=r.useCallback(x=>{x.key==="Escape"&&(_e.active?m({type:"CANCEL_DRAWING"}):X.active?m({type:"CANCEL_CONNECTING"}):m({type:"CLEAR_SELECTION"})),x.key==="Delete"&&ve.objectIds.length>0&&m({type:"DELETE_OBJECTS",objectIds:ve.objectIds}),(x.ctrlKey||x.metaKey)&&(x.key==="z"&&m({type:"UNDO"}),x.key==="y"&&m({type:"REDO"}),x.key==="c"&&m({type:"COPY"}),x.key==="v"&&m({type:"PASTE",position:{x:0,y:0}}),x.key==="x"&&m({type:"CUT"}))},[_e.active,X.active,ve.objectIds]),vt=r.useCallback(x=>{m({type:"SET_MODE",mode:x}),v==null||v(x)},[v]),ft=r.useCallback(x=>{m({type:"SET_TOOL",tool:x})},[]),Ve=r.useCallback(async x=>{var M;if(se){ue(!1);try{const P={includeGrid:!1,includeDimensions:!0};if(x==="nsp"){const D=V.exportToNSP(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="svg"){const D=V.exportToSVG(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="dxf"){const D=V.exportToDXF(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="png"&&A.current){const D=await V.exportSVGToPNG(A.current,((M=se.metadata)==null?void 0:M.name)||"export");V.downloadExport(D),k==null||k(x,D.data)}}catch(P){console.error(`Export to ${x} failed:`,P)}}},[se,k]),gt=r.useCallback(async x=>{var P;const M=(P=x.target.files)==null?void 0:P[0];if(M){ye(!1);try{const D={convertClosedPolylinesToZones:!0,minZoneArea:1},U=await V.importFromBrowserFile(M,D);U.success&&U.document?S(U):re(U),Ie.current&&(Ie.current.value="")}catch(D){console.error("Import failed:",D),re({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}})}}},[]),bt=r.useCallback(()=>{ce!=null&&ce.success&&ce.document?ie(!0):S(null)},[ce]),nt=r.useCallback(()=>{S(null),ie(!1)},[]),_=r.useCallback((x,M)=>{if(!(ce!=null&&ce.document)){ie(!1);return}const P=ce.document,D={...P,floors:P.floors.map(U=>({...U,layers:U.layers.filter(Y=>x.get(Y.id)!=="skip").map(Y=>{const ae=x.get(Y.id);if(ae===Y.id||!ae)return Y;const Se=se==null?void 0:se.floors.flatMap(He=>He.layers).find(He=>He.id===ae);return Se?{...Y,id:Se.id,name:Se.name,type:Se.type}:Y})}))};m({type:"SET_DOCUMENT",document:D}),d==null||d(D),re(ce),ie(!1),S(null)},[ce,se,d]),z=r.useCallback(()=>{ie(!1)},[]),I=r.useCallback(x=>{if(Ie.current){let M=".dxf,.svg,.geojson,.json,.ifc";x==="dxf"?M=".dxf":x==="svg"?M=".svg":x==="geojson"?M=".geojson,.json":x==="ifc"&&(M=".ifc"),Ie.current.accept=M,Ie.current.click()}ye(!1)},[]);r.useEffect(()=>{const x=M=>{$e.current&&!$e.current.contains(M.target)&&ue(!1),Ee.current&&!Ee.current.contains(M.target)&&ye(!1)};return(me||de)&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[me,de]);const K=r.useCallback(()=>{var U,Y;if(!oe.showGrid||!xe)return null;const x=[],{gridSize:M}=oe,P=((U=xe.bounds)==null?void 0:U.width)??1e3,D=((Y=xe.bounds)==null?void 0:Y.height)??800;for(let ae=0;ae<=P;ae+=M)x.push(e.jsx("line",{x1:ae,y1:0,x2:ae,y2:D,className:O.gridLine},`v${ae}`));for(let ae=0;ae<=D;ae+=M)x.push(e.jsx("line",{x1:0,y1:ae,x2:P,y2:ae,className:O.gridLine},`h${ae}`));return e.jsx("g",{className:O.grid,children:x})},[oe.showGrid,oe.gridSize,xe]),le=r.useCallback(()=>{if(!xe)return null;const x=xe.layers.find(M=>M.name==="zones");return x?e.jsx("g",{className:O.zonesLayer,children:x.objects.map(M=>{const P=M;if(!P.boundary||P.boundary.length<3)return null;const D=P.boundary.map((ae,Se)=>`${Se===0?"M":"L"}${ae.x},${ae.y}`).join(" ")+" Z",U=ve.objectIds.includes(P.id),Y=P.boundary.reduce((ae,Se)=>({x:ae.x+Se.x/P.boundary.length,y:ae.y+Se.y/P.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:O.zone,onClick:ae=>{ae.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[P.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:D,fill:P.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.5,stroke:U?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:U?2:1}),P.name&&e.jsx("text",{x:Y.x,y:Y.y,textAnchor:"middle",dominantBaseline:"middle",className:O.zoneLabel,children:P.name})]},P.id)})}):null},[xe,ve.objectIds]),J=r.useCallback(()=>We.length===0?null:e.jsx("g",{className:O.guides,children:We.map((x,M)=>e.jsx("line",{x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y,className:O.guideLine},M))}),[We]),pe=r.useCallback(()=>{if(!_e.active||_e.points.length===0)return null;const x=[..._e.points];_e.preview&&x.push(_e.preview);const M=x.map((D,U)=>`${U===0?"M":"L"}${D.x},${D.y}`).join(" "),P=he==="draw-zone"&&x.length>2;return e.jsxs("g",{className:O.drawingPreview,children:[e.jsx("path",{d:M+(P?" Z":""),fill:P?"var(--nice-primary-tint-10, rgba(37, 99, 235, 0.1))":"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:P?"none":"6,3"}),x.map((D,U)=>e.jsx("circle",{cx:D.x,cy:D.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},U))]})},[_e,he]),ge=r.useCallback(()=>!X.active||!X.sourcePosition||!X.previewPosition?null:e.jsxs("g",{className:O.connectionPreview,children:[e.jsx("line",{x1:X.sourcePosition.x,y1:X.sourcePosition.y,x2:X.previewPosition.x,y2:X.previewPosition.y,stroke:"var(--nice-success, #10b981)",strokeWidth:2,strokeDasharray:"8,4",markerEnd:"url(#connectionArrow)"}),e.jsx("circle",{cx:X.sourcePosition.x,cy:X.sourcePosition.y,r:6,fill:"var(--nice-success, #10b981)"}),e.jsx("circle",{cx:X.previewPosition.x,cy:X.previewPosition.y,r:6,fill:"var(--nice-success, #10b981)",fillOpacity:.5,stroke:"var(--nice-success, #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:"var(--nice-success, #10b981)"})})})]}),[X]),Le=r.useCallback(()=>{if(!xe)return null;const x=xe.layers.find(U=>U.type==="network");if(!x)return null;const M=x.objects.filter(U=>U.type==="connection");if(M.length===0)return null;const P={"ethernet-cat5":{color:"var(--nice-primary, #3b82f6)",width:2},"ethernet-cat6":{color:"var(--nice-primary-hover, #2563eb)",width:2},"ethernet-cat6a":{color:"var(--nice-primary-dark, #1d4ed8)",width:2},"ethernet-cat7":{color:"var(--nice-primary-dark, #1e40af)",width:3},"fiber-single":{color:"var(--nice-warning, #f59e0b)",width:3},"fiber-multi":{color:"var(--nice-warning-dark, #d97706)",width:3},"wifi-2.4ghz":{color:"var(--nice-accent, #8b5cf6)",dashArray:"6,4",width:2},"wifi-5ghz":{color:"var(--nice-accent, #7c3aed)",dashArray:"6,4",width:2},"wifi-6ghz":{color:"var(--nice-accent-dark, #6d28d9)",dashArray:"6,4",width:2},default:{color:"var(--nice-text-secondary, #64748b)",width:2}},D={active:"var(--nice-success, #10b981)",inactive:"var(--nice-text-muted, #94a3b8)",error:"var(--nice-danger, #ef4444)",degraded:"var(--nice-warning, #f59e0b)",unknown:"var(--nice-text-secondary, #64748b)"};return e.jsx("g",{className:O.connectionsLayer,children:M.map(U=>{const Y=U.metadata;if(!(Y!=null&&Y.sourcePosition)||!(Y!=null&&Y.targetPosition))return null;const ae=P[Y.medium??"default"]||P.default,Se=D[Y.status??"unknown"]||D.unknown,He=ve.objectIds.includes(U.id);let jt=`M${Y.sourcePosition.x},${Y.sourcePosition.y}`;if(Y.waypoints&&Y.waypoints.length>0)for(const ot of Y.waypoints)jt+=` L${ot.x},${ot.y}`;return jt+=` L${Y.targetPosition.x},${Y.targetPosition.y}`,e.jsxs("g",{className:O.connection,onClick:ot=>{ot.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[U.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:jt,fill:"none",stroke:He?"var(--nice-primary-hover, #2563eb)":ae.color,strokeWidth:He?ae.width+1:ae.width,strokeDasharray:ae.dashArray,strokeLinecap:"round",strokeLinejoin:"round"}),Y.status&&Y.status!=="active"&&e.jsx("circle",{cx:(Y.sourcePosition.x+Y.targetPosition.x)/2,cy:(Y.sourcePosition.y+Y.targetPosition.y)/2,r:5,fill:Se}),e.jsx("circle",{cx:Y.sourcePosition.x,cy:Y.sourcePosition.y,r:4,fill:ae.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:Y.targetPosition.x,cy:Y.targetPosition.y,r:4,fill:ae.color,stroke:"white",strokeWidth:1})]},U.id)})})},[xe,ve.objectIds]);return!se&&!xe?e.jsx("div",{className:`${O.root} ${O[n]} ${b??""}`,style:p,children:e.jsxs("div",{className:O.emptyState,children:[e.jsx("div",{className:O.emptyIcon,children:qe.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 x=V.createFloorPlanDocument("New Project","floor-plan");m({type:"SET_DOCUMENT",document:x})},children:"Create New Document"})]})}):e.jsxs("div",{className:`nice-spatial-editor ${O.root} ${O[n]} ${b??""}`,style:{position:"relative",...p},tabIndex:0,onKeyDown:yt,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(C,Zi)})}),e.jsxs("div",{className:O.topBar,children:[e.jsx(Vi,{currentMode:je,availableModes:a,onModeChange:vt}),se&&se.floors.length>1&&e.jsx("div",{className:O.floorTabs,children:se.floors.map(x=>e.jsx("button",{className:`${O.floorTab} ${De===x.id?O.floorTabActive:""}`,onClick:()=>m({type:"SET_ACTIVE_FLOOR",floorId:x.id}),children:x.name},x.id))}),e.jsxs("div",{className:O.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>m({type:"UNDO"}),disabled:!st,className:st?"":O.disabled,children:"↶"}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>m({type:"REDO"}),disabled:!Xe,className:Xe?"":O.disabled,children:"↷"}),e.jsx("div",{className:O.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>m({type:"TOGGLE_GRID"}),className:oe.showGrid?O.active:"",children:"⊞"}),e.jsx("button",{title:"Toggle Snap",onClick:()=>m({type:"TOGGLE_SNAP"}),className:oe.snapEnabled?O.active:"",children:"🧲"}),e.jsxs("span",{className:O.zoomLevel,children:[Math.round(oe.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>m({type:"ZOOM",delta:1}),children:"+"}),e.jsx("button",{title:"Zoom Out",onClick:()=>m({type:"ZOOM",delta:-1}),children:"−"}),e.jsx("button",{title:"Reset View",onClick:()=>m({type:"RESET_VIEW"}),children:"⊡"}),!o&&e.jsxs("div",{className:O.exportDropdown,ref:Ee,children:[e.jsx("input",{type:"file",ref:Ie,onChange:gt,style:{display:"none"}}),e.jsx("button",{title:"Import",onClick:()=>ye(!de),className:de?O.active:"",children:"📥 Import"}),de&&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)"})]})]}),se&&e.jsxs("div",{className:O.exportDropdown,ref:$e,children:[e.jsx("button",{title:"Export",onClick:()=>ue(!me),className:me?O.active:"",children:"📤 Export"}),me&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>Ve("nsp"),children:"📄 NiceToDev Spatial Plan (.nsp.json)"}),e.jsx("button",{onClick:()=>Ve("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>Ve("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>Ve("png"),children:"🖼️ PNG Image (.png)"})]})]})]})]}),e.jsxs("div",{className:O.mainContent,children:[Pe.showObjectLibrary&&!o&&e.jsx(Xt,{mode:je,onObjectSelect:x=>{m({type:"SET_TOOL",tool:`place-${x.category}`}),m({type:"START_DRAG",objectType:x.category,objectData:x})}}),e.jsxs("div",{className:O.editorContainer,children:[!o&&e.jsx(Fi,{mode:je,activeTool:he,onToolSelect:ft,readOnly:o}),(je==="network-topology"||je==="infrastructure")&&e.jsxs("div",{className:O.modeActions,children:[e.jsx("button",{className:`${O.actionBtn} ${Ne?O.active:""}`,onClick:()=>ke(!Ne),title:"Analiza ścieżki sieciowej",children:"📊 Analiza ścieżki"}),e.jsx("button",{className:`${O.actionBtn} ${fe?O.active:""}`,onClick:()=>Te(!fe),title:"Nakładka VLAN",children:"🌐 VLAN Overlay"})]}),e.jsxs("div",{className:O.canvasWrapper,children:[e.jsx("svg",{ref:A,className:`${O.canvas} ${O[`cursor_${he.replace("-","_")}`]??""}`,onMouseDown:pt,onMouseMove:_t,onMouseUp:ht,onDoubleClick:mt,onWheel:xt,children:e.jsxs("g",{transform:`translate(${oe.pan.x}, ${oe.pan.y}) scale(${oe.zoom})`,children:[K(),le(),Le(),J(),pe(),ge()]})}),Pe.showMinimap&&e.jsx(Kt,{document:se,activeFloorId:De,viewport:oe,onViewportChange:x=>m({type:"SET_VIEWPORT",viewport:x})})]})]}),e.jsxs("div",{className:O.rightSidebar,children:[Pe.showLayerPanel&&e.jsx(Yt,{layers:we.filter(x=>qe.layerTypes.includes(x.type)),onVisibilityToggle:x=>{var M;return m({type:"SET_LAYER_VISIBILITY",layerType:x,visible:!((M=we.find(P=>P.type===x))!=null&&M.visible)})},onLockToggle:x=>{var M;return m({type:"SET_LAYER_LOCKED",layerType:x,locked:!((M=we.find(P=>P.type===x))!=null&&M.locked)})},onOpacityChange:(x,M)=>m({type:"SET_LAYER_OPACITY",layerType:x,opacity:M})}),Pe.showPropertiesPanel&&ve.objectIds.length>0&&e.jsx(Jt,{selection:ve,document:se,onPropertyChange:(x,M,P)=>{m({type:"UPDATE_OBJECT",objectId:x,updates:{[M]:P}})}})]})]}),e.jsxs("div",{className:O.statusBar,children:[e.jsxs("span",{className:O.modeIndicator,children:[qe.icon," ",qe.label]}),e.jsxs("span",{className:O.toolIndicator,children:[(St=Ct[he])==null?void 0:St.icon," ",(Lt=Ct[he])==null?void 0:Lt.label]}),ve.objectIds.length>0&&e.jsxs("span",{className:O.selectionInfo,children:[ve.objectIds.length," selected"]}),_e.active&&e.jsxs("span",{className:O.drawingInfo,children:["Drawing: ",_e.points.length," points"]}),X.active&&e.jsx("span",{className:O.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:O.gridInfo,children:["Grid: ",oe.gridSize,"px | Snap: ",oe.snapEnabled?"ON":"OFF"]})]}),ce&&!F&&e.jsx(Pn,{result:ce,onConfirm:bt,onCancel:nt}),ce&&F&&e.jsx(lo,{importResult:ce,existingDocument:se??void 0,onConfirm:_,onCancel:z}),Ne&&se&&e.jsx(wa,{document:se,connections:Dt(se),onHighlightPath:x=>{m(x?{type:"SET_SELECTION",selection:{objectIds:x.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>ke(!1)}),fe&&se&&e.jsx(hr,{document:se,connections:Dt(se),vlans:Hi(se),visibleVlanIds:Be,onVlanVisibilityChange:(x,M)=>{Ge(P=>{const D=new Set(P);return M?D.add(x):D.delete(x),D})},onHighlightVlan:x=>{Oe((x==null?void 0:x.id)??null),m(x?{type:"SET_SELECTION",selection:{objectIds:x.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Te(!1)})]})},Ki="_viewer_fazwr_13",Xi="_theme_light_fazwr_37",Ji="_theme_dark_fazwr_59",Qi="_debugOverlay_fazwr_85",el="_topBar_fazwr_137",tl="_searchContainer_fazwr_159",sl="_searchInput_fazwr_171",nl="_clearBtn_fazwr_227",ol="_searchResults_fazwr_261",al="_searchResultItem_fazwr_291",cl="_searchResultInfo_fazwr_335",rl="_searchResultName_fazwr_347",il="_searchResultDesc_fazwr_357",ll="_floorSelector_fazwr_371",dl="_navBtn_fazwr_421",ul="_active_fazwr_459",pl="_layersBtn_fazwr_475",_l="_legendBtn_fazwr_529",hl="_content_fazwr_583",ml="_navPanel_fazwr_599",xl="_navPanelHeader_fazwr_617",yl="_routeInputs_fazwr_671",vl="_routeInput_fazwr_671",fl="_routeMarker_fazwr_705",gl="_routeHint_fazwr_745",bl="_routeInfo_fazwr_761",jl="_routeStat_fazwr_779",wl="_routeStatLabel_fazwr_791",Nl="_routeStatValue_fazwr_805",kl="_clearRouteBtn_fazwr_817",Cl="_refPointsList_fazwr_851",Il="_refPointItem_fazwr_879",Sl="_refPointIcon_fazwr_917",Ll="_layersPanel_fazwr_929",zl="_layersPanelHeader_fazwr_947",Tl="_layersList_fazwr_1001",Bl="_layerItem_fazwr_1015",$l="_layerToggle_fazwr_1039",Pl="_layerName_fazwr_1075",Ml="_layerType_fazwr_1087",Ol="_canvasWrapper_fazwr_1101",Al="_canvas_fazwr_1101",El="_grid_fazwr_1137",Dl="_gridLine_fazwr_1145",Rl="_zonesLayer_fazwr_1161",Gl="_zone_fazwr_1161",Wl="_zoneSelected_fazwr_1185",ql="_zoneLabel_fazwr_1195",Fl="_objectsLayer_fazwr_1211",Vl="_object_fazwr_1211",Hl="_objectSelected_fazwr_1233",Ul="_objectLabel_fazwr_1241",Zl="_referencePoints_fazwr_1257",Yl="_referencePoint_fazwr_1257",Kl="_refLabel_fazwr_1277",Xl="_routeLayer_fazwr_1293",Jl="_routePath_fazwr_1297",Ql="_routeDash_fazwr_1",ed="_routeMarkers_fazwr_1323",td="_currentLocation_fazwr_1331",sd="_locationPulse_fazwr_1335",nd="_pulse_fazwr_1",od="_zoomControls_fazwr_1369",ad="_minimap_fazwr_1445",cd="_minimapContent_fazwr_1471",rd="_minimapViewport_fazwr_1485",id="_legendPanel_fazwr_1505",ld="_legendPanelHeader_fazwr_1537",dd="_legendList_fazwr_1593",ud="_legendItem_fazwr_1609",pd="_legendColor_fazwr_1633",_d="_legendIcon_fazwr_1649",hd="_legendLabel_fazwr_1663",md="_legendType_fazwr_1675",xd="_objectInfo_fazwr_1693",yd="_objectInfoHeader_fazwr_1721",vd="_navigateBtn_fazwr_1791",L={viewer:Ki,theme_light:Xi,theme_dark:Ji,debugOverlay:Qi,topBar:el,searchContainer:tl,searchInput:sl,clearBtn:nl,searchResults:ol,searchResultItem:al,searchResultInfo:cl,searchResultName:rl,searchResultDesc:il,floorSelector:ll,navBtn:dl,active:ul,layersBtn:pl,legendBtn:_l,content:hl,navPanel:ml,navPanelHeader:xl,routeInputs:yl,routeInput:vl,routeMarker:fl,routeHint:gl,routeInfo:bl,routeStat:jl,routeStatLabel:wl,routeStatValue:Nl,clearRouteBtn:kl,refPointsList:Cl,refPointItem:Il,refPointIcon:Sl,layersPanel:Ll,layersPanelHeader:zl,layersList:Tl,layerItem:Bl,layerToggle:$l,layerName:Pl,layerType:Ml,canvasWrapper:Ol,canvas:Al,grid:El,gridLine:Dl,zonesLayer:Rl,zone:Gl,zoneSelected:Wl,zoneLabel:ql,objectsLayer:Fl,object:Vl,objectSelected:Hl,objectLabel:Ul,referencePoints:Zl,referencePoint:Yl,refLabel:Kl,routeLayer:Xl,routePath:Jl,routeDash:Ql,routeMarkers:ed,currentLocation:td,locationPulse:sd,pulse:nd,zoomControls:od,minimap:ad,minimapContent:cd,minimapViewport:rd,legendPanel:id,legendPanelHeader:ld,legendList:dd,legendItem:ud,legendColor:pd,legendIcon:_d,legendLabel:hd,legendType:md,objectInfo:xd,objectInfoHeader:yd,navigateBtn:vd},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:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3",strokeLinecap:"round"})]}),Rt=()=>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"})}),gd=()=>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"})]}),bd=()=>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"})]}),jd=()=>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"})]}),wd=()=>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"})]}),Nd=()=>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"})]}),Je=()=>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"})}),Gt=()=>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"})]}),Wt=()=>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"})]}),kd=()=>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"})]}),Cd=()=>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 Id(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function Sd(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Ld(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 zd=({document:t,initialFloorId:s,showNavigation:a=!0,showMinimap:o=!0,showFloorSelector:n=!0,showSearch:c=!0,showLayersPanel:l=!0,showLegend:y=!0,enableRoutePlanning:v=!0,referencePoints:k=[],onObjectClick:d,onRouteCalculated:C,currentLocation:b,theme:p="light",className:N,virtualRendering:u,virtualRenderingThreshold:w=200,debugVirtualRendering:T=!1})=>{var nt;const[i,h]=r.useState(s??((nt=t.floors[0])==null?void 0:nt.id)??""),[j,f]=r.useState({zoom:1,pan:{x:0,y:0}}),[g,m]=r.useState(""),[A,H]=r.useState([]),[W,me]=r.useState(null),[ue,de]=r.useState(null),[ye,ne]=r.useState(null),[re,ce]=r.useState(null),[S,F]=r.useState(!1),[ie,Ne]=r.useState(!1),[ke,fe]=r.useState(!1),[Te,Be]=r.useState(new Map),[Ge,tt]=r.useState({width:1e3,height:600}),Oe=r.useRef(null),$e=r.useRef(null),Ee=r.useRef(!1),Ie=r.useRef({x:0,y:0}),je=r.useMemo(()=>{const _=t.floors.find(z=>z.id===i);return _?_.layers.reduce((z,I)=>{var K;return z+(((K=I.objects)==null?void 0:K.length)??0)},0):0},[t.floors,i]),he=u??V.shouldUseVirtualRendering(je,w),se=r.useMemo(()=>{if(!he)return null;const _=t.floors.find(I=>I.id===i);if(!_)return null;const z=[];for(const I of _.layers)if(!(I.type==="zones"||I.type==="grid"||I.type==="background"))for(const K of I.objects??[]){const le=K.position??{x:0,y:0},J=K.size??{width:20,height:20};z.push({id:K.id,position:le,size:J,data:{object:K,layerId:I.id}})}return V.createFloorPlanQuadTree(z)},[t.floors,i,he]),De=r.useMemo(()=>V.calculateVisibleBounds(j,Ge,100),[j,Ge]),we=r.useMemo(()=>!he||!se?null:se.query(De),[he,se,De]),ve=r.useMemo(()=>!T||!he?null:V.calculateRenderStats(je,(we==null?void 0:we.length)??je,j),[T,he,je,we,j]);r.useEffect(()=>{const _=$e.current;if(!_)return;const z=new ResizeObserver(I=>{for(const K of I)tt({width:K.contentRect.width,height:K.contentRect.height})});return z.observe(_),()=>z.disconnect()},[]),r.useEffect(()=>{const _=t.floors.find(z=>z.id===i);if(_){const z=new Map;for(const I of _.layers)z.set(I.id,Te.get(I.id)??!0);Be(z)}},[i,t.floors]);const oe=r.useCallback(_=>{Be(z=>{const I=new Map(z);return I.set(_,!z.get(_)),I})},[]),_e=r.useCallback(_=>Te.get(_)!==!1,[Te]),X=r.useMemo(()=>t.floors.find(_=>_.id===i)??t.floors[0],[t.floors,i]),We=r.useMemo(()=>{if(!X)return[];const _=[],z=X.layers.find(J=>J.type==="zones");if(z){const J=new Map;for(const pe of z.objects){const ge=pe.metadata,Le=(ge==null?void 0:ge.zoneType)??pe.type??"zone";J.has(Le)||J.set(Le,(ge==null?void 0:ge.fill)??"var(--nice-primary, #3b82f6)")}for(const[pe,ge]of J)_.push({id:`zone-${pe}`,label:pe.charAt(0).toUpperCase()+pe.slice(1).replace(/-/g," "),color:ge,type:"zone"})}const I=new Map;for(const J of X.layers)if(!(J.type==="zones"||J.type==="grid"||J.type==="background"))for(const pe of J.objects){const ge=pe.type??"object",Le=I.get(ge);Le?Le.count++:I.set(ge,{count:1,color:"var(--nice-text-secondary, #64748b)"})}for(const[J,pe]of I)_.push({id:`obj-${J}`,label:`${J.charAt(0).toUpperCase()+J.slice(1).replace(/-/g," ")} (${pe.count})`,color:pe.color,type:"object"});const K=new Map,le={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};for(const J of k.filter(pe=>pe.floorId===i))K.has(J.type)||K.set(J.type,le[J.type]??"📍");for(const[J,pe]of K)_.push({id:`ref-${J}`,label:J.charAt(0).toUpperCase()+J.slice(1),color:"var(--nice-primary, #3b82f6)",icon:pe,type:"reference"});return _},[X,k,i]),Pe=r.useCallback((_,z)=>{var K;const I=(K=Oe.current)==null?void 0:K.getBoundingClientRect();return I?{x:(_-I.left-j.pan.x)/j.zoom,y:(z-I.top-j.pan.y)/j.zoom}:{x:0,y:0}},[j]);r.useEffect(()=>{if(!g.trim()){H([]);return}const _=g.toLowerCase(),z=[];for(const I of t.floors)for(const K of I.layers)for(const le of K.objects){const J=(le.name??le.id).toLowerCase(),pe=(le.description??"").toLowerCase();(J.includes(_)||pe.includes(_))&&z.push(le)}H(z.slice(0,10))},[g,t.floors]);const Ke=r.useCallback((_,z)=>{const I=Id(_,z);return{id:`route-${Date.now()}`,startPoint:_,endPoint:z,path:[_,z],floorTransitions:[],totalDistance:I,estimatedTime:I/1.4,instructions:[{type:"straight",distance:I,direction:"forward"},{type:"arrive"}]}},[]);r.useEffect(()=>{if(ue&&ye){const _=Ke(ue,ye);ce(_),C==null||C(_)}else ce(null),C==null||C(null)},[ue,ye,Ke,C]);const qe=r.useCallback(_=>{(_.button===1||_.button===0&&_.altKey)&&(Ee.current=!0,Ie.current={x:_.clientX,y:_.clientY},_.preventDefault())},[]),st=r.useCallback(_=>{if(Ee.current){const z=_.clientX-Ie.current.x,I=_.clientY-Ie.current.y;Ie.current={x:_.clientX,y:_.clientY},f(K=>({...K,pan:{x:K.pan.x+z,y:K.pan.y+I}}))}},[]),Xe=r.useCallback(()=>{Ee.current=!1},[]),xe=r.useCallback(_=>{var J;_.preventDefault();const z=_.deltaY>0?.9:1.1,I=(J=Oe.current)==null?void 0:J.getBoundingClientRect();if(!I)return;const K=_.clientX-I.left,le=_.clientY-I.top;f(pe=>{const ge=Math.min(Math.max(pe.zoom*z,.1),10),Le=ge/pe.zoom;return{zoom:ge,pan:{x:K-(K-pe.pan.x)*Le,y:le-(le-pe.pan.y)*Le}}})},[]),Ae=r.useCallback(_=>{if(v&&_.ctrlKey){const z=Pe(_.clientX,_.clientY);ue?ye?(de(z),ne(null)):ne(z):de(z)}},[v,ue,ye,Pe]),Fe=r.useCallback(()=>{f(_=>({..._,zoom:Math.min(_.zoom*1.25,10)}))},[]),pt=r.useCallback(()=>{f(_=>({..._,zoom:Math.max(_.zoom/1.25,.1)}))},[]),_t=r.useCallback(()=>{f({zoom:1,pan:{x:0,y:0}})},[]),ht=r.useCallback(_=>{me(_);for(const I of t.floors)for(const K of I.layers)if(K.objects.find(le=>le.id===_.id)){h(I.id);break}const z=_.position??{x:0,y:0};f(I=>({...I,pan:{x:-(z.x*I.zoom)+400,y:-(z.y*I.zoom)+300}})),m(""),H([]),d==null||d(_)},[t.floors,d]),mt=r.useCallback(()=>{de(null),ne(null),ce(null)},[]),xt=r.useCallback(()=>{const z=[];for(let I=-2e3;I<=2e3;I+=50)z.push(e.jsx("line",{x1:I,y1:-2e3,x2:I,y2:2e3,className:L.gridLine},`v-${I}`));for(let I=-2e3;I<=2e3;I+=50)z.push(e.jsx("line",{x1:-2e3,y1:I,x2:2e3,y2:I,className:L.gridLine},`h-${I}`));return e.jsx("g",{className:L.grid,children:z})},[]),yt=r.useCallback(()=>{if(!X)return null;const _=X.layers.find(z=>z.type==="zones");return!_||!_e(_.id)?null:e.jsx("g",{className:L.zonesLayer,children:_.objects.map(z=>{const I=z.metadata;if(!(I!=null&&I.points)||I.points.length<3)return null;const K=`M${I.points.map(J=>`${J.x},${J.y}`).join(" L")} Z`,le=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.zone} ${le?L.zoneSelected:""}`,onClick:()=>{me(z),d==null||d(z)},children:[e.jsx("path",{d:K,fill:I.fill??"var(--nice-primary, #3b82f6)",fillOpacity:.2,stroke:I.fill??"var(--nice-primary, #3b82f6)",strokeWidth:le?2:1}),z.name&&e.jsx("text",{x:I.points[0].x+10,y:I.points[0].y+20,className:L.zoneLabel,children:z.name})]},z.id)})})},[X,W,d,_e]),vt=r.useCallback(()=>X?he&&we?e.jsx("g",{className:L.objectsLayer,children:we.map(_=>{const{object:z,layerId:I}=_.data;if(!_e(I))return null;const K=z.position??{x:0,y:0},le=z.size??{width:20,height:20},J=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.object} ${J?L.objectSelected:""}`,transform:`translate(${K.x}, ${K.y})`,onClick:pe=>{pe.stopPropagation(),me(z),d==null||d(z)},children:[e.jsx("rect",{x:-le.width/2,y:-le.height/2,width:le.width,height:le.height,rx:4,fill:J?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:J?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:le.height/2+14,textAnchor:"middle",className:L.objectLabel,children:z.name})]},z.id)})}):e.jsx("g",{className:L.objectsLayer,children:X.layers.map(_=>_.type==="zones"||_.type==="grid"||_.type==="background"||!_e(_.id)?null:_.objects.map(z=>{const I=z.position??{x:0,y:0},K=z.size??{width:20,height:20},le=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.object} ${le?L.objectSelected:""}`,transform:`translate(${I.x}, ${I.y})`,onClick:J=>{J.stopPropagation(),me(z),d==null||d(z)},children:[e.jsx("rect",{x:-K.width/2,y:-K.height/2,width:K.width,height:K.height,rx:4,fill:le?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:le?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:K.height/2+14,textAnchor:"middle",className:L.objectLabel,children:z.name})]},z.id)}))}):null,[X,W,d,_e,he,we]),ft=r.useCallback(()=>{const _=k.filter(I=>I.floorId===i),z={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};return e.jsx("g",{className:L.referencePoints,children:_.map(I=>e.jsxs("g",{className:L.referencePoint,transform:`translate(${I.position.x}, ${I.position.y})`,onClick:()=>{v&&(ue?ne(I.position):de(I.position))},children:[e.jsx("circle",{r:16,fill:"white",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:2}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:"16",children:I.icon??z[I.type]??"📍"}),e.jsx("text",{y:30,textAnchor:"middle",className:L.refLabel,children:I.name})]},I.id))})},[k,i,v,ue]),Ve=r.useCallback(()=>{if(!re)return null;const _=`M${re.path.map(z=>`${z.x},${z.y}`).join(" L")}`;return e.jsxs("g",{className:L.routeLayer,children:[e.jsx("path",{d:_,fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:L.routePath}),e.jsx("circle",{cx:re.startPoint.x,cy:re.startPoint.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:re.endPoint.x,cy:re.endPoint.y,r:8,fill:"var(--nice-danger, #ef4444)",stroke:"white",strokeWidth:2})]})},[re]),gt=r.useCallback(()=>b?e.jsxs("g",{className:L.currentLocation,children:[e.jsx("circle",{cx:b.x,cy:b.y,r:12,fill:"var(--nice-primary, #3b82f6)",fillOpacity:.3,className:L.locationPulse}),e.jsx("circle",{cx:b.x,cy:b.y,r:6,fill:"var(--nice-primary, #3b82f6)",stroke:"white",strokeWidth:2})]}):null,[b]),bt=r.useCallback(()=>e.jsx("g",{className:L.routeMarkers,children:ue&&!re&&e.jsx("circle",{cx:ue.x,cy:ue.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2})}),[ue,re]);return e.jsxs("div",{ref:$e,className:`${L.viewer} ${L[`theme_${p}`]} ${N??""}`,children:[T&&ve&&e.jsxs("div",{className:L.debugOverlay,children:[e.jsx("div",{children:"Virtual: ON"}),e.jsxs("div",{children:["Total: ",ve.total]}),e.jsxs("div",{children:["Visible: ",ve.visible]}),e.jsxs("div",{children:["Culled: ",ve.culled," (",ve.cullPercentage,"%)"]}),e.jsxs("div",{children:["Zoom: ",ve.zoom.toFixed(2),"x"]})]}),e.jsxs("div",{className:L.topBar,children:[c&&e.jsxs("div",{className:L.searchContainer,children:[e.jsxs("div",{className:L.searchInput,children:[e.jsx(fd,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:g,onChange:_=>m(_.target.value)}),g&&e.jsx("button",{className:L.clearBtn,onClick:()=>m(""),children:e.jsx(Je,{})})]}),A.length>0&&e.jsx("div",{className:L.searchResults,children:A.map(_=>e.jsxs("button",{className:L.searchResultItem,onClick:()=>ht(_),children:[e.jsx(gd,{}),e.jsxs("div",{className:L.searchResultInfo,children:[e.jsx("span",{className:L.searchResultName,children:_.name??_.id}),_.description&&e.jsx("span",{className:L.searchResultDesc,children:_.description})]})]},_.id))})]}),n&&t.floors.length>1&&e.jsxs("div",{className:L.floorSelector,children:[e.jsx(bd,{}),e.jsx("select",{value:i,onChange:_=>h(_.target.value),children:t.floors.map(_=>e.jsx("option",{value:_.id,children:_.name??`Piętro ${_.level}`},_.id))})]}),a&&e.jsxs("button",{className:`${L.navBtn} ${S?L.active:""}`,onClick:()=>F(!S),children:[e.jsx(Rt,{}),e.jsx("span",{children:"Nawigacja"})]}),l&&e.jsxs("button",{className:`${L.layersBtn} ${ie?L.active:""}`,onClick:()=>Ne(!ie),children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"})]}),y&&e.jsxs("button",{className:`${L.legendBtn} ${ke?L.active:""}`,onClick:()=>fe(!ke),children:[e.jsx(Wt,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:L.content,children:[S&&e.jsxs("div",{className:L.navPanel,children:[e.jsxs("div",{className:L.navPanelHeader,children:[e.jsx(jd,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>F(!1),children:e.jsx(Je,{})})]}),e.jsxs("div",{className:L.routeInputs,children:[e.jsxs("div",{className:L.routeInput,children:[e.jsx("div",{className:L.routeMarker,style:{background:"var(--nice-success, #10b981)"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:ue?`${ue.x.toFixed(0)}, ${ue.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:L.routeInput,children:[e.jsx("div",{className:L.routeMarker,style:{background:"var(--nice-danger, #ef4444)"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:ye?`${ye.x.toFixed(0)}, ${ye.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:L.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),re&&e.jsxs("div",{className:L.routeInfo,children:[e.jsxs("div",{className:L.routeStat,children:[e.jsx("span",{className:L.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:L.routeStatValue,children:Sd(re.totalDistance)})]}),e.jsxs("div",{className:L.routeStat,children:[e.jsx("span",{className:L.routeStatLabel,children:"Czas"}),e.jsx("span",{className:L.routeStatValue,children:Ld(re.estimatedTime)})]})]}),(ue||ye)&&e.jsx("button",{className:L.clearRouteBtn,onClick:mt,children:"Wyczyść trasę"}),k.length>0&&e.jsxs("div",{className:L.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),k.filter(_=>_.floorId===i).map(_=>e.jsxs("button",{className:L.refPointItem,onClick:()=>{ue?ne(_.position):de(_.position)},children:[e.jsx("span",{className:L.refPointIcon,children:_.icon??"📍"}),e.jsx("span",{children:_.name})]},_.id))]})]}),ie&&X&&e.jsxs("div",{className:L.layersPanel,children:[e.jsxs("div",{className:L.layersPanelHeader,children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>Ne(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:L.layersList,children:X.layers.map(_=>{const z=_e(_.id);return e.jsxs("div",{className:L.layerItem,children:[e.jsx("button",{className:L.layerToggle,onClick:()=>oe(_.id),title:z?"Ukryj warstwę":"Pokaż warstwę",children:z?e.jsx(kd,{}):e.jsx(Cd,{})}),e.jsx("span",{className:L.layerName,children:_.name??_.id}),e.jsxs("span",{className:L.layerType,children:["(",_.type,")"]})]},_.id)})})]}),e.jsxs("div",{className:L.canvasWrapper,children:[e.jsx("svg",{ref:Oe,className:L.canvas,onMouseDown:qe,onMouseMove:st,onMouseUp:Xe,onMouseLeave:Xe,onWheel:xe,onClick:Ae,children:e.jsxs("g",{transform:`translate(${j.pan.x}, ${j.pan.y}) scale(${j.zoom})`,children:[xt(),yt(),vt(),ft(),bt(),Ve(),gt()]})}),e.jsxs("div",{className:L.zoomControls,children:[e.jsx("button",{onClick:Fe,title:"Powiększ",children:e.jsx(wd,{})}),e.jsx("button",{onClick:pt,title:"Pomniejsz",children:e.jsx(Nd,{})}),e.jsx("button",{onClick:_t,title:"Resetuj widok",children:"⟲"})]}),o&&e.jsx("div",{className:L.minimap,children:e.jsx("div",{className:L.minimapContent,children:e.jsx("div",{className:L.minimapViewport})})}),ke&&We.length>0&&e.jsxs("div",{className:L.legendPanel,children:[e.jsxs("div",{className:L.legendPanelHeader,children:[e.jsx(Wt,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>fe(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:L.legendList,children:We.map(_=>e.jsxs("div",{className:L.legendItem,children:[_.icon?e.jsx("span",{className:L.legendIcon,children:_.icon}):e.jsx("span",{className:L.legendColor,style:{background:_.color}}),e.jsx("span",{className:L.legendLabel,children:_.label}),e.jsx("span",{className:L.legendType,children:_.type==="zone"?"strefa":_.type==="object"?"obiekt":"punkt ref."})]},_.id))})]})]})]}),W&&e.jsxs("div",{className:L.objectInfo,children:[e.jsxs("div",{className:L.objectInfoHeader,children:[e.jsx("h4",{children:W.name??W.id}),e.jsx("button",{onClick:()=>me(null),children:e.jsx(Je,{})})]}),W.description&&e.jsx("p",{children:W.description}),v&&e.jsxs("button",{className:L.navigateBtn,onClick:()=>{const _=W.position??{x:0,y:0};ue?ne(_):de(_)},children:[e.jsx(Rt,{}),ue?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Td(t={}){var ye;const{initialDocument:s,defaultMode:a="floor-plan",gridSize:o=20,snapEnabled:n=!0,onChange:c}=t,l={mode:a,tool:"select",document:s??null,activeFloorId:((ye=s==null?void 0:s.floors[0])==null?void 0:ye.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}},[y,v]=r.useReducer((ne,re)=>({...ne,...re}),l),k=r.useCallback(ne=>{v({mode:ne})},[]),d=r.useCallback(ne=>{v({tool:ne})},[]),C=r.useCallback((ne="Untitled")=>{var ce;const re=V.createFloorPlanDocument(ne,"floor-plan");v({document:re,activeFloorId:((ce=re.floors[0])==null?void 0:ce.id)??null}),c==null||c(re)},[c]),b=r.useCallback(ne=>{var re;v({document:ne,activeFloorId:((re=ne.floors[0])==null?void 0:re.id)??null}),c==null||c(ne)},[c]),p=r.useCallback(ne=>{v({viewport:{...y.viewport,zoom:Math.max(.1,Math.min(10,y.viewport.zoom*(1+ne*.1)))}})},[y.viewport]),N=r.useCallback(ne=>{v({viewport:{...y.viewport,pan:{x:y.viewport.pan.x+ne.x,y:y.viewport.pan.y+ne.y}}})},[y.viewport]),u=r.useCallback(()=>{v({viewport:{...y.viewport,zoom:1,pan:{x:0,y:0}}})},[y.viewport]),w=r.useCallback(()=>{v({viewport:{...y.viewport,showGrid:!y.viewport.showGrid}})},[y.viewport]),T=r.useCallback(()=>{v({viewport:{...y.viewport,snapEnabled:!y.viewport.snapEnabled}})},[y.viewport]),i=r.useCallback(ne=>{v({viewport:{...y.viewport,gridSize:ne}})},[y.viewport]),h=r.useCallback((ne,re)=>{v({layers:y.layers.map(ce=>ce.type===ne?{...ce,visible:re}:ce)})},[y.layers]),j=r.useCallback((ne,re)=>{v({layers:y.layers.map(ce=>ce.type===ne?{...ce,locked:re}:ce)})},[y.layers]),f=r.useCallback(ne=>{v({selection:{objectIds:ne,bounds:null,locked:!1}})},[]),g=r.useCallback(()=>{v({selection:{objectIds:[],bounds:null,locked:!1}})},[]),m=r.useCallback(()=>{},[]),A=r.useCallback(()=>{},[]),H=y.history.past.length>0,W=y.history.future.length>0,me=r.useCallback(()=>{},[]),ue=r.useCallback(ne=>{},[]),de=r.useCallback(()=>{},[]);return{state:y,setMode:k,setTool:d,newDocument:C,loadDocument:b,zoom:p,pan:N,resetView:u,toggleGrid:w,toggleSnap:T,setGridSize:i,setLayerVisible:h,setLayerLocked:j,select:f,clearSelection:g,undo:m,redo:A,canUndo:H,canRedo:W,copy:me,paste:ue,cut:de}}function Bd(t={}){const{gridSize:s=20,enabled:a=!0,snapModes:o=["grid","endpoint","midpoint"],objects:n=[],threshold:c=10}=t,l=r.useMemo(()=>({...V.DEFAULT_GRID_CONFIG,cellSize:s,snapModes:o,snapThreshold:c}),[s,o,c]),y=r.useMemo(()=>n.map((p,N)=>({id:`obj-${N}`,bounds:p})),[n]),v=r.useCallback(p=>a?V.snapToGrid(p,l):p,[a,l]),k=r.useCallback(p=>a?V.snapToGrid3D(p,s):p,[a,s]),d=r.useCallback(p=>{if(!a||y.length===0)return[];const N={x:p.x,y:p.y,width:0,height:0};return V.generateAlignmentGuides(N,y,c)},[a,y,c]),C=r.useCallback(p=>{if(!a)return{point:p,snapped:!1,guides:[]};const N=V.performSnap(p,y,l);return{point:N.position,snapped:N.snapped,guides:N.guides??[]}},[a,l,y]),b=r.useCallback((p,N)=>{const u=[];for(let w=0;w<=p;w+=s)u.push({x1:w,y1:0,x2:w,y2:N});for(let w=0;w<=N;w+=s)u.push({x1:0,y1:w,x2:p,y2:w});return u},[s]);return{snap:v,snap3D:k,getGuides:d,performAdvancedSnap:C,generateGridLines:b}}function $d(t={}){const{unitSystem:s="metric",lengthUnit:a="m",areaUnit:o="m2",angleUnit:n="deg",scale:c=100}=t,[l,y]=r.useState(null),[v,k]=r.useState([]),d=r.useCallback(g=>g/c,[c]),C=r.useCallback(g=>{y(g),k([])},[]),b=r.useCallback((g,m=!1)=>{k(A=>[...A,{position:g,snapped:m}])},[]),p=r.useCallback(()=>{y(null),k([])},[]),N=r.useCallback(()=>{if(!l||v.length<2)return null;const g=v.map(m=>m.position);if(l==="distance"&&v.length===2){const m=V.distance2D(g[0],g[1]),A=d(m);return{type:"distance",value:A,formatted:V.autoFormatLength(A,s).formatted,points:g}}if(l==="angle"&&v.length===3){const m=V.angleAtVertex(g[0],g[1],g[2]);return{type:"angle",value:m,formatted:V.formatAngle(m,n).formatted,points:g}}if(l==="area"&&v.length>=3){const A=V.polygonArea(g)/(c*c);return{type:"area",value:A,formatted:V.autoFormatArea(A,s).formatted,points:g}}return null},[l,v,c,s,n,d]),u=v.length>=2&&l==="distance"?V.autoFormatLength(d(V.distance2D(v[0].position,v[v.length-1].position)),s).formatted:null,w=v.length>=3&&l==="angle"?V.formatAngle(V.angleAtVertex(v[0].position,v[1].position,v[2].position),n).formatted:null,T=v.length>=3&&l==="area"?V.autoFormatArea(V.polygonArea(v.map(g=>g.position))/(c*c),s).formatted:null,i=r.useCallback((g,m)=>{const A=V.distance2D(g,m),H=d(A);return{value:H,formatted:V.autoFormatLength(H,s).formatted}},[d,s]),h=r.useCallback((g,m,A)=>{const H=V.angleAtVertex(g,m,A);return{value:H,formatted:V.formatAngle(H,n).formatted}},[n]),j=r.useCallback(g=>{const A=V.polygonArea(g)/(c*c);return{value:A,formatted:V.autoFormatArea(A,s).formatted}},[c,s]),f=r.useCallback(g=>{const m=V.polylineLength(g),A=d(m);return{value:A,formatted:V.autoFormatLength(A,s).formatted}},[d,s]);return{startMeasurement:C,addPoint:b,clearMeasurement:p,finishMeasurement:N,measurementType:l,points:v,liveDistance:u,liveAngle:w,liveArea:T,getDistance:i,getAngle:h,getArea:j,getLength:f}}const Pd="_root_1er3p_3",Md="_dark_1er3p_25",Od="_header_1er3p_31",Ad="_buildingInfo_1er3p_45",Ed="_buildingName_1er3p_49",Dd="_buildingAddress_1er3p_67",Rd="_modeSelector_1er3p_81",Gd="_modeBtn_1er3p_93",Wd="_modeBtnActive_1er3p_127",qd="_weather_1er3p_141",Fd="_weatherTemp_1er3p_155",Vd="_weatherDesc_1er3p_171",Hd="_statsRow_1er3p_183",Ud="_statsCard_1er3p_195",Zd="_statsHeader_1er3p_225",Yd="_statsIcon_1er3p_239",Kd="_statsLabel_1er3p_243",Xd="_statsValue_1er3p_257",Jd="_statsSub_1er3p_275",Qd="_zoneGrid_1er3p_289",eu="_zoneCard_1er3p_303",tu="_zoneOccupied_1er3p_347",su="_zoneCardHeader_1er3p_351",nu="_zoneCardIcon_1er3p_365",ou="_zoneCardTitles_1er3p_369",au="_zoneCardName_1er3p_379",cu="_zoneCardArea_1er3p_403",ru="_occupancyBadge_1er3p_413",iu="_occupancyBadgeOn_1er3p_431",lu="_sensorRow_1er3p_443",du="_sensorChip_1er3p_457",uu="_sensorWarn_1er3p_475",pu="_deviceList_1er3p_489",_u="_deviceChip_1er3p_501",hu="_deviceChipOn_1er3p_535",mu="_deviceChipName_1er3p_547",xu="_deviceChipVal_1er3p_561",yu="_moreBtn_1er3p_571",vu="_scenesBar_1er3p_597",fu="_sceneBarLabel_1er3p_627",gu="_sceneList_1er3p_645",bu="_sceneBtn_1er3p_657",ju="_sceneBtnActive_1er3p_683",q={root:Pd,dark:Md,header:Od,buildingInfo:Ad,buildingName:Ed,buildingAddress:Dd,modeSelector:Rd,modeBtn:Gd,modeBtnActive:Wd,weather:qd,weatherTemp:Fd,weatherDesc:Vd,statsRow:Hd,statsCard:Ud,statsHeader:Zd,statsIcon:Yd,statsLabel:Kd,statsValue:Xd,statsSub:Jd,zoneGrid:Qd,zoneCard:eu,zoneOccupied:tu,zoneCardHeader:su,zoneCardIcon:nu,zoneCardTitles:ou,zoneCardName:au,zoneCardArea:cu,occupancyBadge:ru,occupancyBadgeOn:iu,sensorRow:lu,sensorChip:du,sensorWarn:uu,deviceList:pu,deviceChip:_u,deviceChipOn:hu,deviceChipName:mu,deviceChipVal:xu,moreBtn:yu,scenesBar:vu,sceneBarLabel:fu,sceneList:gu,sceneBtn:bu,sceneBtnActive:ju},Qt={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 wu(t){return Qt[t]??"🏠"}function Nu(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 es=({zone:t,devices:s=[],expanded:a=!1,onExpand:o,onDeviceControl:n,onClick:c,theme:l="light",className:y,style:v})=>{const k=t.occupancy!=null&&t.occupancy>0,d=a?s:s.slice(0,4);return e.jsxs("div",{className:`${q.zoneCard} ${l==="dark"?q.dark:""} ${k?q.zoneOccupied:""} ${y??""}`,style:v,onClick:c,children:[e.jsxs("div",{className:q.zoneCardHeader,children:[e.jsx("span",{className:q.zoneCardIcon,children:wu(t.type)}),e.jsxs("div",{className:q.zoneCardTitles,children:[e.jsx("span",{className:q.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:q.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${q.occupancyBadge} ${k?q.occupancyBadgeOn:""}`,children:["👥 ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:q.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:q.sensorChip,children:["🌡 ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:q.sensorChip,children:["💧 ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${q.sensorChip} ${t.co2>1e3?q.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),d.length>0&&e.jsxs("div",{className:q.deviceList,children:[d.map(C=>{const b=C.state,p=(b==null?void 0:b.on)===!0||(b==null?void 0:b.locked)===!1;return e.jsxs("button",{className:`${q.deviceChip} ${p?q.deviceChipOn:""}`,onClick:N=>{N.stopPropagation(),n==null||n(C.id,{on:!p})},title:C.name,children:[e.jsx("span",{children:Qt[C.type]??"📟"}),e.jsx("span",{className:q.deviceChipName,children:C.name}),e.jsx("span",{className:q.deviceChipVal,children:Nu(C)})]},C.id)}),s.length>4&&e.jsx("button",{className:q.moreBtn,onClick:C=>{C.stopPropagation(),o==null||o()},children:a?"−":`+${s.length-4}`})]})]})},Nt={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"},qt={home:"🏠",away:"🚗",night:"🌙",vacation:"✈",guest:"👋",party:"🎉",occupied:"🏢",closed:"🔒",weekend:"☀",event:"🎉",emergency:"🚨",maintenance:"🔧"},ku=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:q.weather,children:[e.jsxs("span",{className:q.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:q.weatherDesc,children:s})]}):null,lt=({label:t,value:s,sub:a,icon:o,accent:n})=>e.jsxs("div",{className:q.statsCard,style:n?{borderTopColor:n}:void 0,children:[e.jsxs("div",{className:q.statsHeader,children:[o&&e.jsx("span",{className:q.statsIcon,children:o}),e.jsx("span",{className:q.statsLabel,children:t})]}),e.jsx("div",{className:q.statsValue,children:s}),a&&e.jsx("div",{className:q.statsSub,children:a})]}),Cu=({building:t,state:s,onModeChange:a,onDeviceControl:o,onSceneActivate:n,onZoneClick:c,className:l,style:y,theme:v="light",weather:k})=>{var h,j,f;const[d,C]=r.useState(null);t.floors[0];const b=t.floors.flatMap(g=>g.zones??[]).filter(g=>g.type!=="hallway"&&g.type!=="corridor"),p=((h=s==null?void 0:s.activeAlerts)==null?void 0:h.length)??0,N=(j=s==null?void 0:s.energy)==null?void 0:j.currentPowerW,u=(f=s==null?void 0:s.energy)==null?void 0:f.todayKwh,w=s!=null&&s.occupancy?Object.values(s.occupancy).reduce((g,m)=>g+((m==null?void 0:m.occupancy)??0),0):null;t.floors.flatMap(g=>g.zones??[]).flatMap(g=>g.deviceIds??[]).slice(0,8);const T=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],i=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${q.root} ${v==="dark"?q.dark:""} ${l??""}`,style:y,children:[e.jsxs("div",{className:q.header,children:[e.jsxs("div",{className:q.buildingInfo,children:[e.jsx("h2",{className:q.buildingName,children:t.name}),t.address&&e.jsx("p",{className:q.buildingAddress,children:t.address})]}),e.jsx("div",{className:q.modeSelector,children:T.map(g=>e.jsxs("button",{title:Nt[g],className:`${q.modeBtn} ${i===g?q.modeBtnActive:""}`,onClick:()=>a==null?void 0:a(g),children:[qt[g],e.jsx("span",{children:Nt[g]})]},g))}),e.jsx(ku,{temperature:k==null?void 0:k.temperature,description:k==null?void 0:k.description})]}),e.jsxs("div",{className:q.statsRow,children:[N!=null&&e.jsx(lt,{icon:"⚡",label:"Moc",value:N>=1e3?`${(N/1e3).toFixed(2)} kW`:`${N} W`,sub:u!=null?`Dziś: ${u.toFixed(2)} kWh`:void 0,accent:"var(--nice-warning, #f59e0b)"}),w!=null&&e.jsx(lt,{icon:"👥",label:"Obecność",value:`${w} os.`,sub:`${b.length} stref`,accent:"var(--nice-success, #22c55e)"}),p>0&&e.jsx(lt,{icon:"🚨",label:"Alarmy",value:e.jsx("span",{style:{color:"var(--nice-danger, #ef4444)"},children:p}),sub:"aktywnych",accent:"var(--nice-danger, #ef4444)"}),e.jsx(lt,{icon:qt[i],label:"Tryb",value:Nt[i],accent:"var(--nice-accent, #8b5cf6)"})]}),e.jsx("div",{className:q.zoneGrid,children:b.map(g=>{const m=t.floors.flatMap(A=>(A.zones??[]).find(H=>H.id===g.id)?t.devices??[]:[]).filter(A=>A.zoneId===g.id);return e.jsx(es,{zone:g,devices:m,expanded:d===g.id,onExpand:()=>C(d===g.id?null:g.id),onDeviceControl:o,onClick:()=>c==null?void 0:c(g.id),theme:v},g.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:q.scenesBar,children:[e.jsx("span",{className:q.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:q.sceneList,children:t.scenes.map(g=>{var m;return e.jsxs("button",{className:`${q.sceneBtn} ${(m=s==null?void 0:s.activeScenes)!=null&&m.includes(g.id)?q.sceneBtnActive:""}`,onClick:()=>n==null?void 0:n(g.id),children:[g.icon??"🎭"," ",g.name]},g.id)})})]})]})},Iu="_deviceControl_ev96o_3",Su="_dark_ev96o_23",Lu="_compact_ev96o_35",zu="_offline_ev96o_39",Tu="_offlineBanner_ev96o_43",Bu="_toggleControl_ev96o_67",$u="_toggleLabel_ev96o_81",Pu="_toggleBtn_ev96o_97",Mu="_toggleOn_ev96o_123",Ou="_blindControl_ev96o_137",Au="_blindLabel_ev96o_139",Eu="_blindActions_ev96o_143",Du="_blindBtn_ev96o_145",Ru="_blindSlider_ev96o_149",Gu="_blindPct_ev96o_151",Wu="_lockControl_ev96o_157",qu="_lockLabel_ev96o_159",Fu="_lockBtn_ev96o_163",Vu="_lockLocked_ev96o_165",Hu="_lockUnlocked_ev96o_167",Uu="_cameraControl_ev96o_173",Zu="_cameraLabel_ev96o_175",Yu="_cameraSnapshot_ev96o_179",Ku="_cameraPlaceholder_ev96o_181",Xu="_cameraStatus_ev96o_183",Ju="_cameraDot_ev96o_185",Qu="_cameraOnline_ev96o_187",ep="_cameraOffline_ev96o_189",tp="_sensorControl_ev96o_195",sp="_sensorLabel_ev96o_197",np="_sensorValues_ev96o_201",op="_sensorRow_ev96o_203",ap="_sensorKey_ev96o_205",cp="_sensorVal_ev96o_201",rp="_thermostat_ev96o_215",ip="_thermostatTitle_ev96o_229",lp="_thermostatDial_ev96o_247",dp="_dialTempCurrent_ev96o_257",up="_dialTempLabel_ev96o_273",pp="_dialTempTarget_ev96o_283",_p="_dialHumidity_ev96o_299",hp="_thermostatAdjust_ev96o_309",mp="_adjustBtn_ev96o_321",xp="_adjustTemp_ev96o_355",yp="_hvacModes_ev96o_375",vp="_hvacModeBtn_ev96o_389",fp="_hvacModeBtnActive_ev96o_413",gp="_hvacAction_ev96o_425",bp="_hvacActionDot_ev96o_441",jp="_lightControl_ev96o_455",wp="_lightHeader_ev96o_467",Np="_lightIcon_ev96o_479",kp="_lightName_ev96o_483",Cp="_lightToggle_ev96o_507",Ip="_lightToggleOn_ev96o_535",Sp="_sliderRow_ev96o_547",Lp="_sliderIcon_ev96o_561",zp="_slider_ev96o_547",Tp="_sliderVal_ev96o_579",Bp="_colorRow_ev96o_591",$p="_colorSwatch_ev96o_605",Pp="_colorPicker_ev96o_621",Mp="_colorPresets_ev96o_637",Op="_colorPreset_ev96o_637",Ap="_lightOff_ev96o_663",B={deviceControl:Iu,dark:Su,compact:Lu,offline:zu,offlineBanner:Tu,toggleControl:Bu,toggleLabel:$u,toggleBtn:Pu,toggleOn:Mu,blindControl:Ou,blindLabel:Au,blindActions:Eu,blindBtn:Du,blindSlider:Ru,blindPct:Gu,lockControl:Wu,lockLabel:qu,lockBtn:Fu,lockLocked:Vu,lockUnlocked:Hu,cameraControl:Uu,cameraLabel:Zu,cameraSnapshot:Yu,cameraPlaceholder:Ku,cameraStatus:Xu,cameraDot:Ju,cameraOnline:Qu,cameraOffline:ep,sensorControl:tp,sensorLabel:sp,sensorValues:np,sensorRow:op,sensorKey:ap,sensorVal:cp,thermostat:rp,thermostatTitle:ip,thermostatDial:lp,dialTempCurrent:dp,dialTempLabel:up,dialTempTarget:pp,dialHumidity:_p,thermostatAdjust:hp,adjustBtn:mp,adjustTemp:xp,hvacModes:yp,hvacModeBtn:vp,hvacModeBtnActive:fp,hvacAction:gp,hvacActionDot:bp,lightControl:jp,lightHeader:wp,lightIcon:Np,lightName:kp,lightToggle:Cp,lightToggleOn:Ip,sliderRow:Sp,sliderIcon:Lp,slider:zp,sliderVal:Tp,colorRow:Bp,colorSwatch:$p,colorPicker:Pp,colorPresets:Mp,colorPreset:Op,lightOff:Ap};function Ft(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 Ep(t,s,a){return"#"+[t,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Vt(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 ts=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{var i,h,j;const l=t.state,y=(l==null?void 0:l.on)??!1,v=(l==null?void 0:l.brightness)??100,k=(l==null?void 0:l.colorTemperature)??4e3,d=l==null?void 0:l.rgbColor,[C,b]=r.useState(!1),p=r.useCallback(f=>{s==null||s(t.id,f)},[t.id,s]),N=d?Ep(d[0],d[1],d[2]):"var(--nice-bg, #fff)",u=((i=t.capabilities)==null?void 0:i.includes("dimming"))??v!==void 0,w=(h=t.capabilities)==null?void 0:h.includes("color_temperature"),T=((j=t.capabilities)==null?void 0:j.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:y?1:.4},children:"💡"}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${y?B.lightToggleOn:""}`,onClick:()=>p({on:!y}),children:y?"●":"○"})]}),y&&e.jsxs(e.Fragment,{children:[u&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🔅"}),e.jsx("input",{type:"range",min:1,max:100,value:v,className:B.slider,style:{"--pct":`${v}%`},onChange:f=>p({brightness:+f.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[v,"%"]})]}),w&&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:k,className:B.slider,style:{background:`linear-gradient(to right, ${Ft(2700)}, ${Ft(6500)})`},onChange:f=>p({colorTemperature:+f.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(k/100)*100,"K"]})]}),T&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🎨"}),e.jsx("button",{className:B.colorSwatch,style:{background:N},onClick:()=>b(f=>!f)}),C&&e.jsx("input",{type:"color",value:N,className:B.colorPicker,onChange:f=>{const[g,m,A]=Vt(f.target.value);p({rgbColor:[g,m,A]})}}),e.jsx("div",{className:B.colorPresets,children:["var(--nice-bg, #fff)","var(--nice-warning-bg, #fde68a)","var(--nice-danger-bg, #fca5a5)","var(--nice-primary-light, #93c5fd)","var(--nice-success-light, #86efac)","var(--nice-accent, #c4b5fd)"].map(f=>e.jsx("button",{className:B.colorPreset,style:{background:f},onClick:()=>{const[g,m,A]=Vt(f);p({rgbColor:[g,m,A]})}},f))})]})]}),!y&&!a&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},Ht={heat:"🔥 Grzanie",cool:"❄ Chłodzenie",auto:"⚡ Auto",off:"⏻ Wyłącz",fan_only:"💨 Wentylacja",dry:"💧 Osuszanie"},Dp={heating:"var(--nice-danger, #ef4444)",cooling:"var(--nice-primary, #3b82f6)",fan:"var(--nice-success, #22c55e)",drying:"var(--nice-warning, #f59e0b)",idle:"var(--nice-text-muted, #94a3b8)",off:"var(--nice-border, #e2e8f0)"};function Ut(t,s,a,o,n){const c=C=>(C-90)*(Math.PI/180),l=t+a*Math.cos(c(o)),y=s+a*Math.sin(c(o)),v=t+a*Math.cos(c(n)),k=s+a*Math.sin(c(n)),d=n-o>180?1:0;return`M${l.toFixed(2)},${y.toFixed(2)} A${a},${a} 0 ${d},1 ${v.toFixed(2)},${k.toFixed(2)}`}const Qe=5,dt=35,ut=-140,ss=140;function Zt(t){return ut+(t-Qe)/(dt-Qe)*(ss-ut)}const ns=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{const l=t.state,y=(l==null?void 0:l.temperature)??20,v=(l==null?void 0:l.targetTemperature)??21,k=l==null?void 0:l.humidity,d=(l==null?void 0:l.mode)??"auto",C=(l==null?void 0:l.hvacAction)??"idle",b=80,p=80,N=60,u=Ut(b,p,N,ut,ss),w=Zt(Math.min(Math.max(y,Qe),dt)),T=Zt(Math.min(Math.max(v,Qe),dt)),i=Ut(b,p,N,ut,Math.min(w,T)),h=Dp[C]??"var(--nice-text-muted, #94a3b8)",j=r.useCallback(g=>{const m=Math.round((v+g)*2)/2;m>=Qe&&m<=dt&&(s==null||s(t.id,{targetTemperature:m}))},[v,t.id,s]),f=r.useCallback(g=>{s==null||s(t.id,{mode:g})},[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:u,fill:"none",stroke:"var(--nice-border, #e2e8f0)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:i,fill:"none",stroke:h,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:b+N*Math.cos((T-90)*(Math.PI/180)),cy:p+N*Math.sin((T-90)*(Math.PI/180)),r:7,fill:h,stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsxs("text",{x:b,y:p-6,textAnchor:"middle",className:B.dialTempCurrent,children:[y.toFixed(1),"°"]}),e.jsx("text",{x:b,y:p+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:b,y:p+32,textAnchor:"middle",className:B.dialTempTarget,children:["▶ ",v.toFixed(1),"°"]}),k!=null&&e.jsxs("text",{x:b,y:p+48,textAnchor:"middle",className:B.dialHumidity,children:["💧 ",k,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>j(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[v.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>j(.5),children:"+"})]}),!a&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(g=>e.jsx("button",{title:Ht[g],className:`${B.hvacModeBtn} ${d===g?B.hvacModeBtnActive:""}`,onClick:()=>f(g),children:Ht[g].split(" ")[0]},g))}),e.jsxs("div",{className:B.hvacAction,style:{color:h},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:h}}),C]})]})},Rp=({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"})]})},Gp=({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,"%"]})]})},Wp=({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"})]})},qp=({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]})]})},Fp=({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))})]})},Vp=({device:t,onControl:s,compact:a=!1,className:o,style:n,theme:c="light"})=>{const l=t.type,y=["light","dimmer","rgb_light","led_strip"].includes(l)?e.jsx(ts,{device:t,onControl:s,compact:a,theme:c}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(l)?e.jsx(ns,{device:t,onControl:s,compact:a,theme:c}):["blind","shutter","curtain","awning","garage_door"].includes(l)?e.jsx(Gp,{device:t,onControl:s}):["lock","door"].includes(l)?e.jsx(Wp,{device:t,onControl:s}):["camera","doorbell"].includes(l)?e.jsx(qp,{device:t}):l.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(l)?e.jsx(Fp,{device:t}):e.jsx(Rp,{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:[y,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},Hp="_root_o9ptx_3",Up="_dark_o9ptx_27",Zp="_listPanel_o9ptx_33",Yp="_listHeader_o9ptx_55",Kp="_listTitle_o9ptx_75",Xp="_addBtn_o9ptx_89",Jp="_list_o9ptx_33",Qp="_listItem_o9ptx_117",e_="_listItemActive_o9ptx_145",t_="_listItemName_o9ptx_151",s_="_listItemMeta_o9ptx_175",n_="_enableToggle_o9ptx_189",o_="_enableOn_o9ptx_207",a_="_detailPanel_o9ptx_213",c_="_detailHeader_o9ptx_225",r_="_nameInput_o9ptx_239",i_="_deleteBtn_o9ptx_267",l_="_section_o9ptx_293",d_="_sectionHeader_o9ptx_301",u_="_sectionTitle_o9ptx_315",p_="_sectionAddBtn_o9ptx_331",__="_ruleBlock_o9ptx_357",h_="_ruleBlockHeader_o9ptx_377",m_="_typeSelect_o9ptx_391",x_="_removeBtn_o9ptx_415",y_="_ruleFields_o9ptx_447",v_="_input_o9ptx_479",f_="_textarea_o9ptx_503",g_="_dayPicker_o9ptx_531",b_="_dayBtn_o9ptx_535",j_="_dayBtnActive_o9ptx_555",w_="_noSelection_o9ptx_561",N_="_emptyHint_o9ptx_561",E={root:Hp,dark:Up,listPanel:Zp,listHeader:Yp,listTitle:Kp,addBtn:Xp,list:Jp,listItem:Qp,listItemActive:e_,listItemName:t_,listItemMeta:s_,enableToggle:n_,enableOn:o_,detailPanel:a_,detailHeader:c_,nameInput:r_,deleteBtn:i_,section:l_,sectionHeader:d_,sectionTitle:u_,sectionAddBtn:p_,ruleBlock:__,ruleBlockHeader:h_,typeSelect:m_,removeBtn:x_,ruleFields:y_,input:v_,textarea:f_,dayPicker:g_,dayBtn:b_,dayBtnActive:j_,noSelection:w_,emptyHint:N_},k_=[{target:".nice-building-automation-editor",titleKey:"tutorial.buildingAutomationEditor.intro.title",title:"Automation editor",contentKey:"tutorial.buildingAutomationEditor.intro.content",content:"Create building automations: pick one from the list, define its triggers, conditions and actions, then save, enable or delete it.",placement:"auto"}],ze=(t,s,a="")=>{const o=t[s];return typeof o=="string"?o:a},It=(t,s,a=0)=>{const o=t[s];return typeof o=="number"?o:a},C_=(t,s,a)=>{const o=t[s];return Array.isArray(o)?o:a},I_=(t,s)=>{const a=t[s];return a&&typeof a=="object"?a:{}},S_=({trigger:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:E.ruleBlock,children:[e.jsxs("div",{className:E.ruleBlockHeader,children:[e.jsxs("select",{className:E.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:E.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="time"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:E.input,value:ze(t,"time","08:00"),onChange:c=>n({time:c.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:E.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((c,l)=>{const y=C_(t,"days",[0,1,2,3,4]),v=y.includes(l);return e.jsx("button",{className:`${E.dayBtn} ${v?E.dayBtnActive:""}`,onClick:()=>n({days:v?y.filter(k=>k!==l):[...y,l]}),children:c},l)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:E.input,min:-120,max:120,step:5,value:It(t,"offsetMinutes",0),onChange:c=>n({offsetMinutes:+c.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:E.input,value:ze(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:E.input,value:ze(t,"attribute",""),onChange:c=>n({attribute:c.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:E.input,value:ze(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:E.input,value:It(t,"threshold",0),onChange:c=>n({threshold:+c.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:E.input,value:ze(t,"webhookId",""),onChange:c=>n({webhookId:c.target.value})})]})})]})},L_=({action:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:E.ruleBlock,children:[e.jsxs("div",{className:E.ruleBlockHeader,children:[e.jsxs("select",{className:E.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:E.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="device_control"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:E.input,value:ze(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:E.textarea,rows:3,value:JSON.stringify(I_(t,"state"),null,2),onChange:c=>{try{n({state:JSON.parse(c.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:E.input,value:ze(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:E.input,value:ze(t,"message",""),onChange:c=>n({message:c.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:E.input,min:1,value:It(t,"delaySeconds",60),onChange:c=>n({delaySeconds:+c.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:E.input,value:ze(t,"url",""),onChange:c=>n({url:c.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:E.input,value:ze(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"})]})]})]})]})},z_=({automations:t,devices:s=[],onAutomationsChange:a,readOnly:o=!1,className:n,style:c,theme:l="light",tutorial:y})=>{var N;const[v,k]=r.useState(((N=t[0])==null?void 0:N.id)??null),d=t.find(u=>u.id===v)??null,C=r.useCallback(u=>{d&&(a==null||a(t.map(w=>w.id===d.id?{...w,...u}:w)))},[d,t,a]),b=r.useCallback(()=>{const u={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};a==null||a([...t,u]),k(u.id)},[t,a]),p=r.useCallback(u=>{var w;a==null||a(t.filter(T=>T.id!==u)),v===u&&k(((w=t.find(T=>T.id!==u))==null?void 0:w.id)??null)},[t,v,a]);return e.jsxs("div",{className:`nice-building-automation-editor ${E.root} ${l==="dark"?E.dark:""} ${n??""}`,style:{position:"relative",...c},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(y,k_)})}),e.jsxs("div",{className:E.listPanel,children:[e.jsxs("div",{className:E.listHeader,children:[e.jsx("span",{className:E.listTitle,children:"Automatyzacje"}),!o&&e.jsx("button",{className:E.addBtn,onClick:b,children:"+ Dodaj"})]}),e.jsxs("div",{className:E.list,children:[t.map(u=>e.jsxs("div",{className:`${E.listItem} ${v===u.id?E.listItemActive:""}`,onClick:()=>k(u.id),children:[e.jsx("div",{className:E.listItemName,children:u.name}),e.jsxs("div",{className:E.listItemMeta,children:[u.triggers.length," wyzw · ",u.actions.length," akcji"]}),e.jsx("button",{className:`${E.enableToggle} ${u.enabled?E.enableOn:""}`,onClick:w=>{w.stopPropagation(),C({enabled:!u.enabled})},title:u.enabled?"Wyłącz":"Włącz",children:u.enabled?"●":"○"})]},u.id)),t.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak automatyzacji"})]})]}),e.jsx("div",{className:E.detailPanel,children:d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:E.detailHeader,children:[e.jsx("input",{className:E.nameInput,value:d.name,onChange:u=>C({name:u.target.value}),readOnly:o}),!o&&e.jsx("button",{className:E.deleteBtn,onClick:()=>p(d.id),children:"Usuń"})]}),e.jsxs("section",{className:E.section,children:[e.jsxs("div",{className:E.sectionHeader,children:[e.jsx("span",{className:E.sectionTitle,children:"Wyzwalacze"}),!o&&e.jsx("button",{className:E.sectionAddBtn,onClick:()=>C({triggers:[...d.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),d.triggers.map((u,w)=>e.jsx(S_,{trigger:u,devices:s,onChange:T=>C({triggers:d.triggers.map((i,h)=>h===w?T:i)}),onRemove:()=>C({triggers:d.triggers.filter((T,i)=>i!==w)})},w)),d.triggers.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:E.section,children:[e.jsxs("div",{className:E.sectionHeader,children:[e.jsx("span",{className:E.sectionTitle,children:"Akcje"}),!o&&e.jsx("button",{className:E.sectionAddBtn,onClick:()=>C({actions:[...d.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),d.actions.map((u,w)=>e.jsx(L_,{action:u,devices:s,onChange:T=>C({actions:d.actions.map((i,h)=>h===w?T:i)}),onRemove:()=>C({actions:d.actions.filter((T,i)=>i!==w)})},w)),d.actions.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:E.noSelection,children:"Wybierz automatyzację lub dodaj nową"})})]})},T_="_root_1sm37_3",B_="_dark_1sm37_27",$_="_gridPanel_1sm37_33",P_="_gridHeader_1sm37_55",M_="_gridTitle_1sm37_75",O_="_addBtn_1sm37_81",A_="_sceneGrid_1sm37_105",E_="_sceneCard_1sm37_123",D_="_sceneCardActive_1sm37_147",R_="_sceneCardSelected_1sm37_149",G_="_sceneCardIcon_1sm37_153",W_="_sceneCardName_1sm37_157",q_="_sceneCardDevices_1sm37_175",F_="_activeBadge_1sm37_193",V_="_activateBtn_1sm37_197",H_="_emptyGrid_1sm37_237",U_="_detailPanel_1sm37_255",Z_="_metaRow_1sm37_273",Y_="_iconPicker_1sm37_285",K_="_currentIcon_1sm37_289",X_="_iconGrid_1sm37_307",J_="_iconOpt_1sm37_323",Q_="_iconOptActive_1sm37_345",eh="_metaFields_1sm37_349",th="_nameInput_1sm37_353",sh="_descInput_1sm37_381",nh="_colorPicker_1sm37_411",oh="_colorOpt_1sm37_421",ah="_colorOptActive_1sm37_437",ch="_targetsSection_1sm37_443",rh="_targetsSectionHeader_1sm37_447",ih="_addTargetBtn_1sm37_469",lh="_targetRow_1sm37_493",dh="_targetSelect_1sm37_517",uh="_targetState_1sm37_541",ph="_targetField_1sm37_555",_h="_tempInput_1sm37_575",hh="_removeTargetBtn_1sm37_593",mh="_noTargets_1sm37_627",xh="_detailActions_1sm37_647",yh="_activateFullBtn_1sm37_661",vh="_deleteBtn_1sm37_689",Z={root:T_,dark:B_,gridPanel:$_,gridHeader:P_,gridTitle:M_,addBtn:O_,sceneGrid:A_,sceneCard:E_,sceneCardActive:D_,sceneCardSelected:R_,sceneCardIcon:G_,sceneCardName:W_,sceneCardDevices:q_,activeBadge:F_,activateBtn:V_,emptyGrid:H_,detailPanel:U_,metaRow:Z_,iconPicker:Y_,currentIcon:K_,iconGrid:X_,iconOpt:J_,iconOptActive:Q_,metaFields:eh,nameInput:th,descInput:sh,colorPicker:nh,colorOpt:oh,colorOptActive:ah,targetsSection:ch,targetsSectionHeader:rh,addTargetBtn:ih,targetRow:lh,targetSelect:dh,targetState:uh,targetField:ph,tempInput:_h,removeTargetBtn:hh,noTargets:mh,detailActions:xh,activateFullBtn:yh,deleteBtn:vh},fh=[{target:".nice-scene-editor",titleKey:"tutorial.buildingSceneEditor.intro.title",title:"Scene editor",contentKey:"tutorial.buildingSceneEditor.intro.content",content:"Create scenes that set multiple devices at once: pick a scene, choose device target states, then save or activate it.",placement:"auto"}],et=t=>t&&typeof t=="object"?t:{},gh=(t,s,a=!1)=>{const o=et(t)[s];return typeof o=="boolean"?o:a},kt=(t,s,a=0)=>{const o=et(t)[s];return typeof o=="number"?o:a},bh=["🎭","🌙","🌅","🎬","🎮","💼","🍽","☕","🏃","🛁","🎵","🌿","🔆","❄","🔒","🏠"],jh=["var(--nice-primary-bg, #e0f2fe)","var(--nice-accent-bg, #fce7f3)","var(--nice-success-bg, #dcfce7)","var(--nice-warning-bg, #fef9c3)","var(--nice-accent-bg, #ede9fe)","var(--nice-danger-bg, #fee2e2)","var(--nice-success-bg, #f0fdf4)","#fff7ed"],wh=({target:t,devices:s,onChange:a,onRemove:o})=>{const n=s.find(c=>c.id===t.deviceId);return e.jsxs("div",{className:Z.targetRow,children:[e.jsxs("select",{className:Z.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:Z.targetState,children:[e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:gh(t.state,"on",!1),onChange:c=>a({...t,state:{...et(t.state),on:c.target.checked}})})]}),(n.type==="dimmer"||n.type==="light"||n.type==="rgb_light"||n.type==="led_strip")&&e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:kt(t.state,"brightness",100),onChange:c=>a({...t,state:{...et(t.state),brightness:+c.target.value}})}),e.jsxs("span",{children:[kt(t.state,"brightness",100),"%"]})]}),(n.type==="thermostat"||n.type==="air_conditioner")&&e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:Z.tempInput,min:10,max:30,step:.5,value:kt(t.state,"targetTemperature",20),onChange:c=>a({...t,state:{...et(t.state),targetTemperature:+c.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:Z.removeTargetBtn,onClick:o,title:"Usuń",children:"✕"})]})},Nh=({scenes:t,devices:s=[],activeSceneIds:a=[],onScenesChange:o,onActivate:n,readOnly:c=!1,className:l,style:y,theme:v="light",tutorial:k})=>{var T;const[d,C]=r.useState(((T=t[0])==null?void 0:T.id)??null),b=t.find(i=>i.id===d)??null,p=r.useCallback(i=>{b&&(o==null||o(t.map(h=>h.id===b.id?{...h,...i}:h)))},[b,t,o]),N=r.useCallback(()=>{const i={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"🎭",color:"var(--nice-primary-bg, #e0f2fe)"};o==null||o([...t,i]),C(i.id)},[t,o]),u=r.useCallback(i=>{var h;o==null||o(t.filter(j=>j.id!==i)),d===i&&C(((h=t.find(j=>j.id!==i))==null?void 0:h.id)??null)},[t,d,o]),w=()=>{if(!b)return;const i={deviceId:"",state:{on:!0},transitionMs:1e3};p({deviceTargets:[...b.deviceTargets,i]})};return e.jsxs("div",{className:`nice-scene-editor ${Z.root} ${v==="dark"?Z.dark:""} ${l??""}`,style:{position:"relative",...y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(k,fh)})}),e.jsxs("div",{className:Z.gridPanel,children:[e.jsxs("div",{className:Z.gridHeader,children:[e.jsx("span",{className:Z.gridTitle,children:"Sceny"}),!c&&e.jsx("button",{className:Z.addBtn,onClick:N,children:"+ Nowa"})]}),e.jsxs("div",{className:Z.sceneGrid,children:[t.map(i=>{const h=a.includes(i.id),j=d===i.id;return e.jsxs("div",{className:`${Z.sceneCard} ${h?Z.sceneCardActive:""} ${j?Z.sceneCardSelected:""}`,style:{background:i.color??"var(--nice-bg-secondary, #f8fafc)"},onClick:()=>C(i.id),children:[e.jsx("div",{className:Z.sceneCardIcon,children:i.icon??"🎭"}),e.jsx("div",{className:Z.sceneCardName,children:i.name}),e.jsxs("div",{className:Z.sceneCardDevices,children:[i.deviceTargets.length," urządzeń",h&&e.jsx("span",{className:Z.activeBadge,children:"●"})]}),e.jsx("button",{className:Z.activateBtn,onClick:f=>{f.stopPropagation(),n==null||n(i.id)},children:"▶"})]},i.id)}),t.length===0&&e.jsx("div",{className:Z.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),b&&e.jsxs("div",{className:Z.detailPanel,children:[e.jsxs("div",{className:Z.metaRow,children:[e.jsxs("div",{className:Z.iconPicker,children:[e.jsx("span",{className:Z.currentIcon,children:b.icon??"🎭"}),e.jsx("div",{className:Z.iconGrid,children:bh.map(i=>e.jsx("button",{className:`${Z.iconOpt} ${b.icon===i?Z.iconOptActive:""}`,onClick:()=>p({icon:i}),children:i},i))})]}),e.jsxs("div",{className:Z.metaFields,children:[e.jsx("input",{className:Z.nameInput,value:b.name,readOnly:c,onChange:i=>p({name:i.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:Z.descInput,value:b.description??"",readOnly:c,onChange:i=>p({description:i.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!c&&e.jsx("div",{className:Z.colorPicker,children:jh.map(i=>e.jsx("button",{className:`${Z.colorOpt} ${b.color===i?Z.colorOptActive:""}`,style:{background:i},onClick:()=>p({color:i})},i))}),e.jsxs("div",{className:Z.targetsSection,children:[e.jsxs("div",{className:Z.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!c&&e.jsx("button",{className:Z.addTargetBtn,onClick:w,children:"+ Dodaj"})]}),b.deviceTargets.map((i,h)=>e.jsx(wh,{target:i,devices:s,onChange:j=>p({deviceTargets:b.deviceTargets.map((f,g)=>g===h?j:f)}),onRemove:()=>p({deviceTargets:b.deviceTargets.filter((j,f)=>f!==h)})},h)),b.deviceTargets.length===0&&e.jsx("div",{className:Z.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:Z.detailActions,children:[e.jsx("button",{className:Z.activateFullBtn,onClick:()=>n==null?void 0:n(b.id),children:"▶ Aktywuj scenę"}),!c&&e.jsx("button",{className:Z.deleteBtn,onClick:()=>u(b.id),children:"Usuń"})]})]})]})};exports.LayerPanel=Yt;exports.Minimap=Kt;exports.NiceAutomationEditor=z_;exports.NiceBuildingDashboard=Cu;exports.NiceDeviceControl=Vp;exports.NiceFloorPlanEditor=en;exports.NiceLightControl=ts;exports.NiceSceneEditor=Nh;exports.NiceSpatialEditor=Yi;exports.NiceSpatialViewer=zd;exports.NiceThermostatControl=ns;exports.NiceZoneCard=es;exports.ObjectLibrary=Xt;exports.PropertiesPanel=Jt;exports.useMeasurement=$d;exports.useSnapToGrid=Bd;exports.useSpatialEditor=Td;
|
|
5
|
+
`;return C.forEach((b,I)=>{if(b.type==="wall"&&b.bounds)j.push(e.jsx("rect",{x:b.bounds.x,y:b.bounds.y,width:b.bounds.width,height:b.bounds.height,fill:"var(--nice-text-secondary, #475569)",stroke:"var(--nice-text, #334155)",strokeWidth:"1"},`wall-${I}`));else if(b.type==="zone"&&b.boundary){const u=b.boundary.map((v,l)=>`${l===0?"M":"L"} ${v.x} ${v.y}`).join(" ")+" Z";j.push(e.jsx("path",{d:u,fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:"1"},`zone-${I}`))}else if(b.type==="room"&&b.boundary){const u=b.boundary.map((v,l)=>`${l===0?"M":"L"} ${v.x} ${v.y}`).join(" ")+" Z";j.push(e.jsx("path",{d:u,fill:"var(--nice-success-tint-15, rgba(34, 197, 94, 0.15))",stroke:"var(--nice-success, #22c55e)",strokeWidth:"1"},`room-${I}`))}else b.bounds&&j.push(e.jsx("rect",{x:b.bounds.x,y:b.bounds.y,width:b.bounds.width,height:b.bounds.height,fill:"var(--nice-accent-tint-30, rgba(99, 102, 241, 0.3))",stroke:"var(--nice-info, #6366f1)",strokeWidth:"0.5",rx:"2"},`obj-${I}`))}),e.jsxs("svg",{viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,className:F.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:N}}),e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"url(#grid)"}),j]})},[n,o]),i=r.useCallback(d=>{d.key==="Escape"&&a()},[a]),y=r.useCallback(d=>{d.target===d.currentTarget&&a()},[a]),g=t.errors.some(d=>d.fatal),k=t.errors.filter(d=>!d.fatal);return e.jsx("div",{className:F.overlay,onClick:y,onKeyDown:i,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:F.dialog,children:[e.jsxs("div",{className:F.header,children:[e.jsx("h2",{id:"import-preview-title",className:F.title,children:"Import Preview"}),e.jsx("button",{className:F.closeButton,onClick:a,title:"Close","aria-label":"Close dialog",children:e.jsx(En,{})})]}),e.jsxs("div",{className:F.content,children:[e.jsx("div",{className:F.preview,children:c||e.jsx("div",{className:F.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:F.info,children:[e.jsxs("div",{className:F.section,children:[e.jsxs("h3",{className:F.sectionTitle,children:[e.jsx(Dn,{})," Import Statistics"]}),e.jsxs("div",{className:F.statGrid,children:[e.jsxs("div",{className:F.stat,children:[e.jsx("div",{className:F.statLabel,children:"Walls"}),e.jsx("div",{className:F.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:F.stat,children:[e.jsx("div",{className:F.statLabel,children:"Zones"}),e.jsx("div",{className:F.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:F.stat,children:[e.jsx("div",{className:F.statLabel,children:"Objects"}),e.jsx("div",{className:F.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:F.stat,children:[e.jsx("div",{className:F.statLabel,children:"Skipped"}),e.jsx("div",{className:F.statValue,children:t.stats.entitiesSkipped})]})]})]}),n&&n.layers.length>0&&e.jsxs("div",{className:F.section,children:[e.jsxs("h3",{className:F.sectionTitle,children:[e.jsx(Mt,{})," Layers (",n.layers.length,")"]}),e.jsxs("ul",{className:F.layersList,children:[n.layers.slice(0,6).map((d,C)=>{var j;return e.jsxs("li",{className:F.layer,children:[e.jsx("span",{className:F.layerIcon,children:e.jsx(Mt,{})}),e.jsx("span",{className:F.layerName,children:d.name}),e.jsx("span",{className:F.layerCount,children:((j=d.objects)==null?void 0:j.length)||0})]},d.id||C)}),n.layers.length>6&&e.jsx("li",{className:F.layer,children:e.jsxs("span",{className:F.layerName,children:["+",n.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:F.section,children:[e.jsxs("h3",{className:F.sectionTitle,children:[e.jsx(Bt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:F.warningsList,children:[t.warnings.slice(0,5).map((d,C)=>e.jsxs("li",{className:F.warning,children:[e.jsx("span",{className:F.warningIcon,children:e.jsx(Bt,{})}),e.jsx("span",{children:d.message})]},C)),t.warnings.length>5&&e.jsxs("li",{className:F.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),k.length>0&&e.jsxs("div",{className:F.section,children:[e.jsxs("h3",{className:F.sectionTitle,children:[e.jsx(Pt,{})," Errors (",k.length,")"]}),e.jsx("ul",{className:F.warningsList,children:k.slice(0,5).map((d,C)=>e.jsxs("li",{className:F.error,children:[e.jsx("span",{className:F.errorIcon,children:e.jsx(Pt,{})}),e.jsx("span",{children:d.message})]},C))})]}),t.warnings.length===0&&k.length===0&&e.jsx("div",{className:F.section,children:e.jsxs("p",{className:F.noWarnings,children:[e.jsx(L.NiceIcon,{name:"check",size:14})," No warnings or errors found"]})})]})]}),e.jsxs("div",{className:F.footer,children:[e.jsx("button",{className:F.cancelButton,onClick:a,children:"Cancel"}),e.jsx("button",{className:F.confirmButton,onClick:s,disabled:g,children:g?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const Wn="_overlay_1okdy_9",Gn="_dialog_1okdy_55",Fn="_header_1okdy_103",Vn="_title_1okdy_119",Hn="_closeButton_1okdy_133",Un="_content_1okdy_163",qn="_description_1okdy_175",Zn="_mappingTable_1okdy_187",Yn="_sourceLayer_1okdy_237",Kn="_layerIcon_1okdy_249",Xn="_layerName_1okdy_257",Jn="_objectCount_1okdy_269",Qn="_targetSelect_1okdy_281",eo="_skipOption_1okdy_323",to="_arrowIcon_1okdy_333",so="_presets_1okdy_343",no="_presetButton_1okdy_357",oo="_footer_1okdy_389",ao="_footerLeft_1okdy_409",co="_checkbox_1okdy_421",ro="_checkboxLabel_1okdy_433",io="_footerRight_1okdy_443",lo="_cancelButton_1okdy_453",uo="_confirmButton_1okdy_485",se={overlay:Wn,dialog:Gn,header:Fn,title:Vn,closeButton:Hn,content:Un,description:qn,mappingTable:Zn,sourceLayer:Yn,layerIcon:Kn,layerName:Xn,objectCount:Jn,targetSelect:Qn,skipOption:eo,arrowIcon:to,presets:so,presetButton:no,footer:oo,footerLeft:ao,checkbox:co,checkboxLabel:ro,footerRight:io,cancelButton:lo,confirmButton:uo},Ot=()=>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"})}),po=()=>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"})}),_o=()=>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"})}),At={"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 mo(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 ho(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 Et(t,s){const a=new Map;for(const o of t){const n=s.find(y=>y.type===o.type);if(n){a.set(o.id,n.id);continue}const c=o.name.toLowerCase(),i=s.find(y=>y.name.toLowerCase()===c);if(i){a.set(o.id,i.id);continue}a.set(o.id,o.id)}return a}const xo=({importResult:t,existingDocument:s,onConfirm:a,onCancel:o})=>{const n=r.useMemo(()=>mo(t),[t]),c=r.useMemo(()=>ho(s),[s]),[i,y]=r.useState(()=>Et(n,c)),[g,k]=r.useState(!0),d=r.useCallback((b,I)=>{y(w=>{const u=new Map(w);return u.set(b,I),u})},[]),C=r.useCallback(b=>{const I=new Map;switch(b){case"auto":y(Et(n,c));return;case"skip-all":for(const w of n)I.set(w.id,"skip");break;case"preserve":for(const w of n)I.set(w.id,w.id);break}y(I)},[n,c]),j=r.useCallback(()=>{a(i,g)},[i,g,a]),m=r.useCallback(b=>{b.key==="Escape"?o():b.key==="Enter"&&(b.ctrlKey||b.metaKey)&&j()},[o,j]),N=r.useCallback(b=>{b.target===b.currentTarget&&o()},[o]);return n.length===0?e.jsx("div",{className:se.overlay,onClick:N,onKeyDown:m,tabIndex:-1,children:e.jsxs("div",{className:se.dialog,children:[e.jsxs("div",{className:se.header,children:[e.jsx("h2",{className:se.title,children:"Mapowanie warstw"}),e.jsx("button",{className:se.closeButton,onClick:o,children:e.jsx(Ot,{})})]}),e.jsx("div",{className:se.content,children:e.jsx("p",{className:se.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:se.footer,children:[e.jsx("div",{className:se.footerLeft}),e.jsx("div",{className:se.footerRight,children:e.jsx("button",{className:se.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:se.overlay,onClick:N,onKeyDown:m,tabIndex:-1,children:e.jsxs("div",{className:se.dialog,children:[e.jsxs("div",{className:se.header,children:[e.jsx("h2",{className:se.title,children:"Mapowanie warstw"}),e.jsx("button",{className:se.closeButton,onClick:o,children:e.jsx(Ot,{})})]}),e.jsxs("div",{className:se.content,children:[e.jsx("p",{className:se.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:se.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(b=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:se.sourceLayer,children:[e.jsx("span",{className:se.layerIcon,children:e.jsx(po,{})}),e.jsx("span",{className:se.layerName,children:b.name}),e.jsxs("span",{className:se.objectCount,children:["(",b.objectCount," ",b.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:se.arrowIcon,children:e.jsx(_o,{})}),e.jsx("td",{children:e.jsxs("select",{className:se.targetSelect,value:i.get(b.id)||b.id,onChange:I=>d(b.id,I.target.value),children:[e.jsx("option",{value:"skip",className:se.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:b.id,children:["Utwórz: ",b.name," (",At[b.type],")"]}),c.map(I=>e.jsxs("option",{value:I.id,children:[I.name," (",At[I.type],")"]},I.id))]})})]},b.id))})]}),e.jsxs("div",{className:se.presets,children:[e.jsx("button",{className:se.presetButton,onClick:()=>C("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:se.presetButton,onClick:()=>C("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:se.presetButton,onClick:()=>C("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:se.footer,children:[e.jsxs("div",{className:se.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:se.checkbox,checked:g,onChange:b=>k(b.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:se.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:se.footerRight,children:[e.jsx("button",{className:se.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:se.confirmButton,onClick:j,children:"Zastosuj mapowanie"})]})]})]})})},fo="_root_4ino1_9",vo="_header_4ino1_21",yo="_title_4ino1_31",go="_layerList_4ino1_45",jo="_layerItem_4ino1_55",bo="_hidden_4ino1_83",wo="_locked_4ino1_91",No="_visibilityBtn_4ino1_99",ko="_lockBtn_4ino1_101",Io="_layerIcon_4ino1_139",Co="_layerName_4ino1_147",zo="_opacitySlider_4ino1_157",Ce={root:fo,header:vo,title:yo,layerList:go,layerItem:jo,hidden:bo,locked:wo,visibilityBtn:No,lockBtn:ko,layerIcon:Io,layerName:Co,opacitySlider:zo},So={"floor-plan":{icon:"home",label:"Floor Plan"},zones:{icon:"hexagon",label:"Zones"},devices:{icon:"wifi",label:"Devices"},furniture:{icon:"sofa",label:"Furniture"},network:{icon:"globe",label:"Network"},infrastructure:{icon:"settings",label:"Infrastructure"},annotations:{icon:"edit",label:"Annotations"},dimensions:{icon:"ruler",label:"Dimensions"},grid:{icon:"grid",label:"Grid"},background:{icon:"image",label:"Background"},"game-objects":{icon:"gamepad",label:"Game Objects"},collision:{icon:"square",label:"Collision"}},Kt=({layers:t,onVisibilityToggle:s,onLockToggle:a,onOpacityChange:o,className:n})=>{const c=[...t].sort((i,y)=>y.zIndex-i.zIndex);return e.jsxs("div",{className:`${Ce.root} ${n??""}`,children:[e.jsx("div",{className:Ce.header,children:e.jsx("h3",{className:Ce.title,children:"Layers"})}),e.jsx("div",{className:Ce.layerList,children:c.map(i=>{const y=So[i.type]||{icon:"box",label:i.type};return e.jsxs("div",{className:`${Ce.layerItem} ${i.visible?"":Ce.hidden} ${i.locked?Ce.locked:""}`,children:[e.jsx("button",{className:Ce.visibilityBtn,onClick:()=>s(i.type),title:i.visible?"Hide layer":"Show layer",children:e.jsx(L.NiceIcon,{name:i.visible?"eye":"eye-off",size:16})}),e.jsx("button",{className:Ce.lockBtn,onClick:()=>a(i.type),title:i.locked?"Unlock layer":"Lock layer",children:e.jsx(L.NiceIcon,{name:"lock",size:16})}),e.jsx("span",{className:Ce.layerIcon,children:e.jsx(L.NiceIcon,{name:y.icon,size:16})}),e.jsx("span",{className:Ce.layerName,children:y.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:i.opacity,onChange:g=>o(i.type,parseFloat(g.target.value)),className:Ce.opacitySlider,title:`Opacity: ${Math.round(i.opacity*100)}%`})]},i.type)})})]})},Lo="_root_1lufq_9",To="_svg_1lufq_31",$o="_viewportRect_1lufq_41",Bo="_zoomIndicator_1lufq_49",at={root:Lo,svg:To,viewportRect:$o,zoomIndicator:Bo},Xt=({document:t,activeFloorId:s,viewport:a,onViewportChange:o,size:n=150,className:c})=>{var v,l;const i=r.useRef(null),y=r.useMemo(()=>t.floors.find(_=>_.id===s)??t.floors[0]??null,[t,s]);if(!y)return null;const g=((v=y.dimensions)==null?void 0:v.width)??1e3,k=((l=y.dimensions)==null?void 0:l.height)??800,d=Math.min(n/g,n/k)*.9,C=g*d,j=k*d,m=n/a.zoom*d,N=n/a.zoom*d,b=-a.pan.x/a.zoom*d,I=-a.pan.y/a.zoom*d,w=r.useCallback(_=>{var xe;const x=(xe=i.current)==null?void 0:xe.getBoundingClientRect();if(!x)return;const p=(_.clientX-x.left-(n-C)/2)/d,A=(_.clientY-x.top-(n-j)/2)/d,Y=-(p-n/a.zoom/2)*a.zoom,V=-(A-n/a.zoom/2)*a.zoom;o({pan:{x:Y,y:V}})},[d,n,C,j,a.zoom,o]),u=r.useMemo(()=>{const _=y.layers.find(x=>x.name==="zones");return _?_.objects.map(x=>{const p=x;if(!p.polygon||p.polygon.length<3)return null;const A=p.polygon.map((Y,V)=>`${V===0?"M":"L"}${Y.x*d},${Y.y*d}`).join(" ")+" Z";return e.jsx("path",{d:A,fill:p.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.6,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:.5},p.id)}):null},[y,d]);return e.jsxs("div",{className:`${at.root} ${c??""}`,children:[e.jsxs("svg",{ref:i,width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:at.svg,onClick:w,children:[e.jsx("rect",{x:(n-C)/2,y:(n-j)/2,width:C,height:j,fill:"var(--nice-text, #1e293b)",stroke:"var(--nice-text-secondary, #475569)",strokeWidth:1}),e.jsx("g",{transform:`translate(${(n-C)/2}, ${(n-j)/2})`,children:u}),e.jsx("rect",{x:(n-C)/2+b,y:(n-j)/2+I,width:Math.min(m,C),height:Math.min(N,j),fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:1.5,rx:2,className:at.viewportRect})]}),e.jsxs("div",{className:at.zoomIndicator,children:[Math.round(a.zoom*100),"%"]})]})},Po="_panel_vacy7_9",Mo="_header_vacy7_27",Oo="_title_vacy7_45",Ao="_closeButton_vacy7_59",Eo="_content_vacy7_85",Do="_endpointSection_vacy7_99",Ro="_endpointLabel_vacy7_107",Wo="_endpointSelect_vacy7_123",Go="_optionsSection_vacy7_157",Fo="_metricButton_vacy7_169",Vo="_metricButtonActive_vacy7_205",Ho="_analyzeButton_vacy7_219",Uo="_resultsSection_vacy7_267",qo="_resultsTitle_vacy7_277",Zo="_noResults_vacy7_293",Yo="_pathCard_vacy7_309",Ko="_pathCardSelected_vacy7_333",Xo="_pathCardHeader_vacy7_343",Jo="_pathCardTitle_vacy7_361",Qo="_pathBadge_vacy7_373",ea="_badgePrimary_vacy7_389",ta="_badgeAlternate_vacy7_399",sa="_pathName_vacy7_409",na="_pathStatus_vacy7_421",oa="_statusDot_vacy7_435",aa="_statusActive_vacy7_447",ca="_statusDegraded_vacy7_449",ra="_statusInactive_vacy7_451",ia="_statusError_vacy7_453",la="_pathStats_vacy7_459",da="_statItem_vacy7_473",ua="_statValue_vacy7_481",pa="_statLabel_vacy7_493",_a="_pathVisualization_vacy7_507",ma="_pathDiagram_vacy7_519",ha="_pathNode_vacy7_535",xa="_pathNodeStart_vacy7_567",fa="_pathNodeEnd_vacy7_569",va="_pathLink_vacy7_579",ya="_pathLinkLine_vacy7_591",ga="_showOnMapButton_vacy7_605",ja="_loading_vacy7_641",ba="_spinner_vacy7_655",wa="_spin_vacy7_655",W={panel:Po,header:Mo,title:Oo,closeButton:Ao,content:Eo,endpointSection:Do,endpointLabel:Ro,endpointSelect:Wo,optionsSection:Go,metricButton:Fo,metricButtonActive:Vo,analyzeButton:Ho,resultsSection:Uo,resultsTitle:qo,noResults:Zo,pathCard:Yo,pathCardSelected:Ko,pathCardHeader:Xo,pathCardTitle:Jo,pathBadge:Qo,badgePrimary:ea,badgeAlternate:ta,pathName:sa,pathStatus:na,statusDot:oa,statusActive:aa,statusDegraded:ca,statusInactive:ra,statusError:ia,pathStats:la,statItem:da,statValue:ua,statLabel:pa,pathVisualization:_a,pathDiagram:ma,pathNode:ha,pathNodeStart:xa,pathNodeEnd:fa,pathLink:va,pathLinkLine:ya,showOnMapButton:ga,loading:ja,spinner:ba,spin:wa},Na=()=>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"})}),ka=()=>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 Ia(t){switch(t){case"active":return"Aktywna";case"degraded":return"Degradacja";case"inactive":return"Nieaktywna";case"error":return"Błąd";default:return"Nieznany"}}function Ca(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function za(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const Sa=({document:t,connections:s,onHighlightPath:a,onClose:o})=>{const[n,c]=r.useState(""),[i,y]=r.useState(""),[g,k]=r.useState("latency"),[d,C]=r.useState([]),[j,m]=r.useState(null),[N,b]=r.useState(!1),I=r.useMemo(()=>{const _=[];for(const x of t.floors)for(const p of x.layers)if(p.type==="network"||p.type==="devices"||p.type==="infrastructure")for(const A of p.objects)_.push({id:A.id,name:A.name??A.id});return _},[t]),w=r.useCallback(_=>{var x;return((x=I.find(p=>p.id===_))==null?void 0:x.name)??_},[I]),u=r.useCallback(()=>{!n||!i||n===i||(b(!0),C([]),m(null),setTimeout(()=>{const _=Z.findShortestPath(s,n,i,g),x=Z.findAllPaths(s,n,i,5),p=[];_&&p.push(_);for(const A of x)p.some(Y=>Y.connectionIds.length===A.connectionIds.length&&Y.connectionIds.every((V,xe)=>A.connectionIds[xe]===V))||p.push({...A,isPrimary:!1});C(p),p.length>0&&(m(p[0].id),a==null||a(p[0])),b(!1)},300))},[n,i,g,s,a]),v=r.useCallback(_=>{m(_.id),a==null||a(_)},[a]),l=r.useCallback(_=>{const x=[_.startDeviceId];for(const p of _.connectionIds){const A=s.find(Y=>Y.id===p);if(A){const Y=x[x.length-1],V=A.sourceId===Y?A.targetId:A.sourceId;x.includes(V)||x.push(V)}}return x},[s]);return e.jsxs("div",{className:W.panel,children:[e.jsxs("div",{className:W.header,children:[e.jsx("h3",{className:W.title,children:"Analiza ścieżki sieciowej"}),o&&e.jsx("button",{className:W.closeButton,onClick:o,children:e.jsx(Na,{})})]}),e.jsxs("div",{className:W.content,children:[e.jsxs("div",{className:W.endpointSection,children:[e.jsx("label",{className:W.endpointLabel,children:"Urządzenie źródłowe"}),e.jsxs("select",{className:W.endpointSelect,value:n,onChange:_=>c(_.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),I.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]})]}),e.jsxs("div",{className:W.endpointSection,children:[e.jsx("label",{className:W.endpointLabel,children:"Urządzenie docelowe"}),e.jsxs("select",{className:W.endpointSelect,value:i,onChange:_=>y(_.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),I.filter(_=>_.id!==n).map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]})]}),e.jsxs("div",{className:W.optionsSection,children:[e.jsx("button",{className:`${W.metricButton} ${g==="latency"?W.metricButtonActive:""}`,onClick:()=>k("latency"),children:"Latencja"}),e.jsx("button",{className:`${W.metricButton} ${g==="hops"?W.metricButtonActive:""}`,onClick:()=>k("hops"),children:"Hops"}),e.jsx("button",{className:`${W.metricButton} ${g==="bandwidth"?W.metricButtonActive:""}`,onClick:()=>k("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:W.analyzeButton,onClick:u,disabled:!n||!i||n===i||N,children:N?"Analizowanie...":"Analizuj ścieżkę"}),N?e.jsx("div",{className:W.loading,children:e.jsx("div",{className:W.spinner})}):d.length>0?e.jsxs("div",{className:W.resultsSection,children:[e.jsxs("div",{className:W.resultsTitle,children:["Znalezione ścieżki (",d.length,")"]}),d.map((_,x)=>{const p=l(_),A=j===_.id;return e.jsxs("div",{className:`${W.pathCard} ${A?W.pathCardSelected:""}`,onClick:()=>v(_),children:[e.jsxs("div",{className:W.pathCardHeader,children:[e.jsxs("div",{className:W.pathCardTitle,children:[e.jsx("span",{className:`${W.pathBadge} ${_.isPrimary?W.badgePrimary:W.badgeAlternate}`,children:_.isPrimary?"Optymalna":`Alt ${x}`}),e.jsxs("span",{className:W.pathName,children:[_.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:W.pathStatus,children:[e.jsx("span",{className:`${W.statusDot} ${W[`status${_.status.charAt(0).toUpperCase()+_.status.slice(1)}`]??""}`}),e.jsx("span",{children:Ia(_.status)})]})]}),e.jsxs("div",{className:W.pathStats,children:[e.jsxs("div",{className:W.statItem,children:[e.jsx("div",{className:W.statValue,children:Ca(_.totalLatency)}),e.jsx("div",{className:W.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:W.statItem,children:[e.jsx("div",{className:W.statValue,children:_.connectionIds.length}),e.jsx("div",{className:W.statLabel,children:"Hops"})]}),e.jsxs("div",{className:W.statItem,children:[e.jsx("div",{className:W.statValue,children:_.bottleneckBandwidth>0?za(_.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:W.statLabel,children:"Przepustowość"})]})]}),A&&e.jsxs("div",{className:W.pathVisualization,children:[e.jsx("div",{className:W.pathDiagram,children:p.map((Y,V)=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:`${W.pathNode} ${V===0?W.pathNodeStart:V===p.length-1?W.pathNodeEnd:""}`,children:w(Y).substring(0,8)}),V<p.length-1&&e.jsxs("div",{className:W.pathLink,children:[e.jsx("div",{className:W.pathLinkLine}),e.jsx(ka,{})]})]},Y))}),e.jsx("button",{className:W.showOnMapButton,onClick:Y=>{Y.stopPropagation(),a==null||a(_)},children:"Pokaż na mapie"})]})]},_.id)})]}):n&&i&&n!==i?e.jsx("div",{className:W.noResults,children:'Wybierz urządzenia i kliknij „Analizuj ścieżkę"'}):e.jsx("div",{className:W.noResults,children:"Wybierz urządzenie źródłowe i docelowe"})]})]})},La="_root_6pirz_9",Ta="_header_6pirz_27",$a="_title_6pirz_37",Ba="_search_6pirz_51",Pa="_categories_6pirz_79",Ma="_category_6pirz_91",Oa="_categoryHeader_6pirz_107",Aa="_categoryIcon_6pirz_143",Ea="_categoryLabel_6pirz_151",Da="_categoryCount_6pirz_161",Ra="_expandIcon_6pirz_171",Wa="_items_6pirz_181",Ga="_item_6pirz_181",Fa="_itemIcon_6pirz_241",Va="_itemName_6pirz_249",Ha="_emptyState_6pirz_269",ge={root:La,header:Ta,title:$a,search:Ba,categories:Pa,category:Ma,categoryHeader:Oa,categoryIcon:Aa,categoryLabel:Ea,categoryCount:Da,expandIcon:Ra,items:Wa,item:Ga,itemIcon:Fa,itemName:Va,emptyState:Ha},Ua={"💡":"lightbulb","🔆":"lightbulb","🌈":"lightbulb","🌡️":"thermometer","❄️":"thermometer","💨":"wifi","📷":"camera","🔔":"bell","🔒":"lock","👁️":"eye","🚪":"door","🔊":"wifi","🗣️":"mic","📺":"monitor","📡":"wifi","🔌":"plug","🛡️":"lock","📶":"wifi","🖥️":"monitor","💾":"database","🗄️":"server","🔋":"zap","⚡":"zap","🧱":"square","🪟":"window","🪜":"stairs","🎯":"target","🏁":"target","📦":"box","👾":"gamepad","🛗":"elevator","🛏️":"bed","🛏":"bed","🛋️":"sofa","🛋":"sofa","🪑":"chair","🍽️":"utensils","🍽":"utensils"},qa=t=>t&&Ua[t]||"box",Za={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},Ya={"smart-home":{icon:"home",label:"Smart Home"},furniture:{icon:"sofa",label:"Furniture"},network:{icon:"globe",label:"Network"},infrastructure:{icon:"settings",label:"Infrastructure"},building:{icon:"building",label:"Building"},zone:{icon:"map-pin",label:"Zones"},game:{icon:"gamepad",label:"Game Objects"},annotation:{icon:"edit",label:"Annotations"}},Jt=({mode:t,onObjectSelect:s,customObjects:a=[],className:o})=>{const[n,c]=r.useState(""),[i,y]=r.useState(new Set(["smart-home","furniture","network"])),g=Za[t]||[],k=r.useMemo(()=>{const j={},m=Z.OBJECT_CATALOG.reduce((N,b)=>{var I;return(N[I=b.category]??(N[I]=[])).push(b),N},{});return Object.entries(m).forEach(([N,b])=>{if(!g.includes(N))return;const I=b.filter(w=>!n||w.name.toLowerCase().includes(n.toLowerCase()));I.length>0&&(j[N]=I.map(w=>({id:w.id,name:w.name,category:N,icon:w.icon})))}),a.forEach(N=>{g.includes(N.category)&&(!n||N.name.toLowerCase().includes(n.toLowerCase()))&&(j[N.category]||(j[N.category]=[]),j[N.category].push(N))}),j},[g,n,a]),d=j=>{y(m=>{const N=new Set(m);return N.has(j)?N.delete(j):N.add(j),N})},C=(j,m)=>{j.dataTransfer.setData("application/json",JSON.stringify(m)),j.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${ge.root} ${o??""}`,children:[e.jsxs("div",{className:ge.header,children:[e.jsx("h3",{className:ge.title,children:"Objects"}),e.jsx("input",{type:"text",className:ge.search,placeholder:"Search...",value:n,onChange:j=>c(j.target.value)})]}),e.jsxs("div",{className:ge.categories,children:[Object.entries(k).map(([j,m])=>{const N=Ya[j]||{icon:"box",label:j},b=i.has(j);return e.jsxs("div",{className:ge.category,children:[e.jsxs("button",{className:ge.categoryHeader,onClick:()=>d(j),children:[e.jsx("span",{className:ge.categoryIcon,children:e.jsx(L.NiceIcon,{name:N.icon,size:16})}),e.jsx("span",{className:ge.categoryLabel,children:N.label}),e.jsxs("span",{className:ge.categoryCount,children:["(",m.length,")"]}),e.jsx("span",{className:ge.expandIcon,children:e.jsx(L.NiceIcon,{name:b?"chevron-down":"chevron-right",size:14})})]}),b&&e.jsx("div",{className:ge.items,children:m.map(I=>e.jsxs("div",{className:ge.item,draggable:!0,onDragStart:w=>C(w,I),onClick:()=>s(I),title:I.name,children:[e.jsx("span",{className:ge.itemIcon,children:e.jsx(L.NiceIcon,{name:qa(I.icon),size:16})}),e.jsx("span",{className:ge.itemName,children:I.name})]},I.id))})]},j)}),Object.keys(k).length===0&&e.jsx("div",{className:ge.emptyState,children:n?`No objects matching "${n}"`:"No objects available for this mode"})]})]})},Ka="_root_o3eqo_9",Xa="_header_o3eqo_23",Ja="_title_o3eqo_39",Qa="_multiSelect_o3eqo_53",ec="_content_o3eqo_63",tc="_section_o3eqo_73",sc="_sectionHeader_o3eqo_89",nc="_sectionContent_o3eqo_127",oc="_fieldRow_o3eqo_135",ac="_fieldLabel_o3eqo_157",cc="_textInput_o3eqo_169",rc="_numberInput_o3eqo_171",ic="_select_o3eqo_173",lc="_checkbox_o3eqo_215",dc="_colorInput_o3eqo_227",uc="_readOnly_o3eqo_245",pc="_emptyState_o3eqo_263",te={root:Ka,header:Xa,title:Ja,multiSelect:Qa,content:ec,section:tc,sectionHeader:sc,sectionContent:nc,fieldRow:oc,fieldLabel:ac,textInput:cc,numberInput:rc,select:ic,checkbox:lc,colorInput:dc,readOnly:uc,emptyState:pc},Nt=[{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"}],_c=[{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}],mc=[{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"}]}],Qt=({selection:t,document:s,onPropertyChange:a,className:o})=>{const[n,c]=r.useState(new Set(["general","position","appearance"])),i=t.objectIds.map(m=>{for(const N of s.floors)for(const b of N.layers){const I=b.objects.find(w=>w.id===m);if(I)return I}return null}).filter(Boolean),y=m=>{c(N=>{const b=new Set(N);return b.has(m)?b.delete(m):b.add(m),b})},g=r.useCallback((m,N)=>{const b=N.split(".");let I=m;for(const w of b)if(I&&typeof I=="object"&&w in I)I=I[w];else return;return I},[]),k=r.useCallback((m,N)=>{var I;const b=g(N,m.key);switch(m.type){case"text":return e.jsx("input",{type:"text",value:String(b??""),onChange:w=>a(N.id,m.key,w.target.value),className:te.textInput});case"number":return e.jsx("input",{type:"number",value:Number(b??0),min:m.min,max:m.max,step:m.step,onChange:w=>a(N.id,m.key,parseFloat(w.target.value)),className:te.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!b,onChange:w=>a(N.id,m.key,w.target.checked),className:te.checkbox});case"color":return e.jsx("input",{type:"color",value:String(b??"var(--nice-bg, #fff)"),onChange:w=>a(N.id,m.key,w.target.value),className:te.colorInput});case"select":return e.jsx("select",{value:String(b??""),onChange:w=>a(N.id,m.key,w.target.value),className:te.select,children:(I=m.options)==null?void 0:I.map(w=>e.jsx("option",{value:w.value,children:w.label},w.value))});default:return e.jsx("span",{children:String(b??"-")})}},[g,a]);if(i.length===0)return e.jsxs("div",{className:`${te.root} ${o??""}`,children:[e.jsx("div",{className:te.header,children:e.jsx("h3",{className:te.title,children:"Properties"})}),e.jsx("div",{className:te.emptyState,children:"No object selected"})]});const d=i[0],C=i.length>1,j=d.category==="zone"?_c:["smart-home","network","infrastructure"].includes(d.category??"")?mc:[];return e.jsxs("div",{className:`${te.root} ${o??""}`,children:[e.jsxs("div",{className:te.header,children:[e.jsx("h3",{className:te.title,children:"Properties"}),C&&e.jsxs("span",{className:te.multiSelect,children:[i.length," selected"]})]}),e.jsxs("div",{className:te.content,children:[e.jsxs("div",{className:te.section,children:[e.jsxs("button",{className:te.sectionHeader,onClick:()=>y("general"),children:[e.jsx("span",{children:e.jsx(L.NiceIcon,{name:n.has("general")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"General"})]}),n.has("general")&&e.jsxs("div",{className:te.sectionContent,children:[Nt.slice(0,1).map(m=>e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:m.label}),k(m,d)]},m.key)),e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:"ID"}),e.jsx("span",{className:te.readOnly,children:d.id})]}),e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:"Category"}),e.jsx("span",{className:te.readOnly,children:d.category})]})]})]}),e.jsxs("div",{className:te.section,children:[e.jsxs("button",{className:te.sectionHeader,onClick:()=>y("position"),children:[e.jsx("span",{children:e.jsx(L.NiceIcon,{name:n.has("position")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Transform"})]}),n.has("position")&&e.jsx("div",{className:te.sectionContent,children:Nt.slice(1,4).map(m=>e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:m.label}),k(m,d)]},m.key))})]}),j.length>0&&e.jsxs("div",{className:te.section,children:[e.jsxs("button",{className:te.sectionHeader,onClick:()=>y("appearance"),children:[e.jsx("span",{children:e.jsx(L.NiceIcon,{name:n.has("appearance")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Appearance"})]}),n.has("appearance")&&e.jsx("div",{className:te.sectionContent,children:j.map(m=>e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:m.label}),k(m,d)]},m.key))})]}),e.jsxs("div",{className:te.section,children:[e.jsxs("button",{className:te.sectionHeader,onClick:()=>y("visibility"),children:[e.jsx("span",{children:e.jsx(L.NiceIcon,{name:n.has("visibility")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Visibility"})]}),n.has("visibility")&&e.jsx("div",{className:te.sectionContent,children:Nt.slice(4).map(m=>e.jsxs("div",{className:te.fieldRow,children:[e.jsx("label",{className:te.fieldLabel,children:m.label}),k(m,d)]},m.key))})]})]})]})},hc="_panel_ldte3_9",xc="_header_ldte3_33",fc="_headerTitle_ldte3_51",vc="_title_ldte3_65",yc="_closeButton_ldte3_79",gc="_summarySection_ldte3_111",jc="_summaryStats_ldte3_121",bc="_statBadge_ldte3_133",wc="_statValue_ldte3_147",Nc="_statLabel_ldte3_159",kc="_visibilityControls_ldte3_175",Ic="_visibilityLabel_ldte3_193",Cc="_visibilityButtons_ldte3_203",zc="_visibilityBtn_ldte3_213",Sc="_active_ldte3_243",Lc="_content_ldte3_257",Tc="_emptyState_ldte3_271",$c="_emptyHint_ldte3_317",Bc="_vlanList_ldte3_329",Pc="_vlanCard_ldte3_343",Mc="_highlighted_ldte3_369",Oc="_hidden_ldte3_379",Ac="_vlanHeader_ldte3_387",Ec="_colorIndicator_ldte3_413",Dc="_vlanInfo_ldte3_427",Rc="_vlanName_ldte3_437",Wc="_vlanId_ldte3_451",Gc="_vlanNameText_ldte3_463",Fc="_vlanSubnet_ldte3_479",Vc="_vlanStats_ldte3_495",Hc="_chipStat_ldte3_507",Uc="_vlanActions_ldte3_537",qc="_iconBtn_ldte3_549",Zc="_inactive_ldte3_587",Yc="_expanded_ldte3_603",Kc="_vlanDetails_ldte3_615",Xc="_detailRow_ldte3_627",Jc="_detailLabel_ldte3_649",Qc="_detailValue_ldte3_667",er="_badge_ldte3_679",tr="_badgeSuccess_ldte3_693",sr="_badgeNeutral_ldte3_703",nr="_deviceList_ldte3_715",or="_deviceItems_ldte3_723",ar="_deviceItem_ldte3_723",cr="_deviceDot_ldte3_757",rr="_deviceMore_ldte3_771",ir="_highlightButton_ldte3_787",lr="_footer_ldte3_827",dr="_legendTitle_ldte3_839",ur="_legend_ldte3_839",pr="_legendItem_ldte3_867",_r="_legendColor_ldte3_879",mr="_legendLabel_ldte3_893",P={panel:hc,header:xc,headerTitle:fc,title:vc,closeButton:yc,summarySection:gc,summaryStats:jc,statBadge:bc,statValue:wc,statLabel:Nc,visibilityControls:kc,visibilityLabel:Ic,visibilityButtons:Cc,visibilityBtn:zc,active:Sc,content:Lc,emptyState:Tc,emptyHint:$c,vlanList:Bc,vlanCard:Pc,highlighted:Mc,hidden:Oc,vlanHeader:Ac,colorIndicator:Ec,vlanInfo:Dc,vlanName:Rc,vlanId:Wc,vlanNameText:Gc,vlanSubnet:Fc,vlanStats:Vc,chipStat:Hc,vlanActions:Uc,iconBtn:qc,inactive:Zc,expanded:Yc,vlanDetails:Kc,detailRow:Xc,detailLabel:Jc,detailValue:Qc,badge:er,badgeSuccess:tr,badgeNeutral:sr,deviceList:nr,deviceItems:or,deviceItem:ar,deviceDot:cr,deviceMore:rr,highlightButton:ir,footer:lr,legendTitle:dr,legend:ur,legendItem:pr,legendColor:_r,legendLabel:mr},hr=()=>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"})}),xr=()=>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"})]}),fr=()=>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"})]}),Dt=()=>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"})]}),vr=()=>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 yr(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function gr(t,s){return s.filter(a=>a.vlanId===t.id).length}function jr(t){return t||"—"}const br=({document:t,connections:s,vlans:a,visibleVlanIds:o,onVlanVisibilityChange:n,onHighlightVlan:c,onClose:i})=>{const[y,g]=r.useState(null),[k,d]=r.useState(null),C=r.useMemo(()=>[...a].sort((v,l)=>v.id-l.id),[a]),j=r.useMemo(()=>{const v=new Set,l=new Set;for(const _ of a)for(const x of _.deviceIds??[])v.add(x);for(const _ of s)_.vlanId!==void 0&&l.add(_.id);return{vlanCount:a.length,deviceCount:v.size,connectionCount:l.size}},[a,s]),m=r.useCallback(v=>{const l=o.has(v);n==null||n(v,!l)},[o,n]),N=r.useCallback(v=>{for(const l of a)n==null||n(l.id,v)},[a,n]),b=r.useCallback(v=>{g((v==null?void 0:v.id)??null),c==null||c(v)},[c]),I=r.useCallback(v=>{d(l=>l===v?null:v)},[]),w=r.useCallback(v=>{const l=[];for(const _ of v.deviceIds??[])for(const x of t.floors)for(const p of x.layers){const A=p.objects.find(Y=>Y.id===_);A&&l.push({id:_,name:A.name??_})}return l},[t]),u=r.useMemo(()=>{const v=a.filter(l=>o.has(l.id)).length;return{visible:v,total:a.length,allVisible:v===a.length,noneVisible:v===0}},[a,o]);return e.jsxs("div",{className:P.panel,children:[e.jsxs("div",{className:P.header,children:[e.jsxs("div",{className:P.headerTitle,children:[e.jsx(Dt,{}),e.jsx("h3",{className:P.title,children:"Nakładka VLAN"})]}),i&&e.jsx("button",{className:P.closeButton,onClick:i,title:"Zamknij",children:e.jsx(hr,{})})]}),e.jsx("div",{className:P.summarySection,children:e.jsxs("div",{className:P.summaryStats,children:[e.jsxs("div",{className:P.statBadge,children:[e.jsx("span",{className:P.statValue,children:j.vlanCount}),e.jsx("span",{className:P.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:P.statBadge,children:[e.jsx("span",{className:P.statValue,children:j.deviceCount}),e.jsx("span",{className:P.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:P.statBadge,children:[e.jsx("span",{className:P.statValue,children:j.connectionCount}),e.jsx("span",{className:P.statLabel,children:"Połączeń"})]})]})}),e.jsxs("div",{className:P.visibilityControls,children:[e.jsxs("span",{className:P.visibilityLabel,children:["Widoczność: ",u.visible,"/",u.total]}),e.jsxs("div",{className:P.visibilityButtons,children:[e.jsx("button",{className:`${P.visibilityBtn} ${u.allVisible?P.active:""}`,onClick:()=>N(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${P.visibilityBtn} ${u.noneVisible?P.active:""}`,onClick:()=>N(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:P.content,children:C.length===0?e.jsxs("div",{className:P.emptyState,children:[e.jsx(Dt,{}),e.jsx("p",{children:"Brak zdefiniowanych VLAN-ów"}),e.jsx("span",{className:P.emptyHint,children:"Dodaj VLAN w trybie network-topology lub infrastructure"})]}):e.jsx("div",{className:P.vlanList,children:C.map(v=>{const l=o.has(v.id),_=y===v.id,x=k===v.id,p=yr(v),A=gr(v,s),Y=x?w(v):[];return e.jsxs("div",{className:`${P.vlanCard} ${_?P.highlighted:""} ${l?"":P.hidden}`,onMouseEnter:()=>b(v),onMouseLeave:()=>b(null),children:[e.jsxs("div",{className:P.vlanHeader,children:[e.jsx("div",{className:P.colorIndicator,style:{backgroundColor:v.color}}),e.jsxs("div",{className:P.vlanInfo,children:[e.jsxs("div",{className:P.vlanName,children:[e.jsxs("span",{className:P.vlanId,children:["VLAN ",v.id]}),v.name&&e.jsx("span",{className:P.vlanNameText,children:v.name})]}),v.subnet&&e.jsx("div",{className:P.vlanSubnet,children:jr(v.subnet)})]}),e.jsxs("div",{className:P.vlanStats,children:[e.jsx("span",{className:P.chipStat,title:"Urządzenia",children:p}),e.jsx("span",{className:P.chipStat,title:"Połączenia",children:A})]}),e.jsxs("div",{className:P.vlanActions,children:[e.jsx("button",{className:`${P.iconBtn} ${l?"":P.inactive}`,onClick:V=>{V.stopPropagation(),m(v.id)},title:l?"Ukryj VLAN":"Pokaż VLAN",children:l?e.jsx(xr,{}):e.jsx(fr,{})}),e.jsx("button",{className:`${P.iconBtn} ${x?P.expanded:""}`,onClick:V=>{V.stopPropagation(),I(v.id)},title:"Szczegóły",children:e.jsx(vr,{})})]})]}),x&&e.jsxs("div",{className:P.vlanDetails,children:[v.description&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Opis:"}),e.jsx("span",{className:P.detailValue,children:v.description})]}),v.subnet&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:P.detailValue,children:v.subnet})]}),v.gateway&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Brama:"}),e.jsx("span",{className:P.detailValue,children:v.gateway})]}),e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${P.detailValue} ${P.badge} ${v.dhcpEnabled?P.badgeSuccess:P.badgeNeutral}`,children:v.dhcpEnabled?"Włączone":"Wyłączone"})]}),Y.length>0&&e.jsxs("div",{className:P.deviceList,children:[e.jsxs("span",{className:P.detailLabel,children:["Urządzenia (",Y.length,"):"]}),e.jsxs("ul",{className:P.deviceItems,children:[Y.slice(0,10).map(V=>e.jsxs("li",{className:P.deviceItem,children:[e.jsx("span",{className:P.deviceDot,style:{backgroundColor:v.color}}),V.name]},V.id)),Y.length>10&&e.jsxs("li",{className:P.deviceMore,children:["... i ",Y.length-10," więcej"]})]})]}),e.jsx("button",{className:P.highlightButton,onClick:()=>c==null?void 0:c(v),children:"Zaznacz na mapie"})]})]},v.id)})})}),C.length>0&&e.jsxs("div",{className:P.footer,children:[e.jsx("div",{className:P.legendTitle,children:"Legenda kolorów"}),e.jsx("div",{className:P.legend,children:C.map(v=>e.jsxs("div",{className:P.legendItem,children:[e.jsx("span",{className:P.legendColor,style:{backgroundColor:v.color}}),e.jsxs("span",{className:P.legendLabel,children:[v.id,v.name?`: ${v.name}`:""]})]},v.id))})]})]})},wr="_root_1fj3i_9",Nr="_shell_1fj3i_35",kr="_dark_1fj3i_43",Ir="_topBar_1fj3i_67",Cr="_modeSwitcher_1fj3i_85",zr="_modeBtn_1fj3i_95",Sr="_modeBtnActive_1fj3i_131",Lr="_modeIcon_1fj3i_143",Tr="_modeLabel_1fj3i_151",$r="_floorTabs_1fj3i_159",Br="_floorTab_1fj3i_159",Pr="_floorTabActive_1fj3i_203",Mr="_viewportControls_1fj3i_215",Or="_active_1fj3i_257",Ar="_disabled_1fj3i_267",Er="_separator_1fj3i_281",Dr="_zoomLevel_1fj3i_295",Rr="_exportDropdown_1fj3i_313",Wr="_exportMenu_1fj3i_361",Gr="_editorContainer_1fj3i_435",Fr="_toolbar_1fj3i_453",Vr="_toolGroup_1fj3i_473",Hr="_toolBtn_1fj3i_501",Ur="_toolBtnActive_1fj3i_541",qr="_canvasWrapper_1fj3i_565",Zr="_canvas_1fj3i_565",Yr="_cursor_select_1fj3i_593",Kr="_cursor_multi_select_1fj3i_595",Xr="_cursor_pan_1fj3i_597",Jr="_cursor_zoom_1fj3i_601",Qr="_cursor_draw_wall_1fj3i_603",ei="_cursor_draw_zone_1fj3i_605",ti="_cursor_draw_polyline_1fj3i_607",si="_cursor_draw_rectangle_1fj3i_609",ni="_cursor_draw_circle_1fj3i_611",oi="_cursor_draw_arc_1fj3i_613",ai="_cursor_place_device_1fj3i_615",ci="_cursor_place_furniture_1fj3i_617",ri="_cursor_place_network_1fj3i_619",ii="_cursor_place_infra_1fj3i_621",li="_cursor_place_door_1fj3i_623",di="_cursor_place_window_1fj3i_625",ui="_cursor_place_stairs_1fj3i_627",pi="_cursor_connect_1fj3i_629",_i="_cursor_route_cable_1fj3i_631",mi="_cursor_annotate_1fj3i_633",hi="_cursor_dimension_1fj3i_635",xi="_cursor_label_1fj3i_637",fi="_cursor_measure_distance_1fj3i_639",vi="_cursor_measure_angle_1fj3i_641",yi="_cursor_measure_area_1fj3i_643",gi="_cursor_move_1fj3i_645",ji="_cursor_rotate_1fj3i_647",bi="_cursor_scale_1fj3i_649",wi="_cursor_erase_1fj3i_651",Ni="_cursor_copy_1fj3i_653",ki="_cursor_paste_1fj3i_655",Ii="_grid_1fj3i_661",Ci="_gridLine_1fj3i_663",zi="_zonesLayer_1fj3i_675",Si="_zone_1fj3i_675",Li="_zoneLabel_1fj3i_681",Ti="_connectionsLayer_1fj3i_695",$i="_connection_1fj3i_695",Bi="_connectionPreview_1fj3i_701",Pi="_guides_1fj3i_707",Mi="_guideLine_1fj3i_709",Oi="_drawingPreview_1fj3i_723",Ai="_rightSidebar_1fj3i_731",Ei="_statusBar_1fj3i_753",Di="_modeIndicator_1fj3i_775",Ri="_toolIndicator_1fj3i_777",Wi="_selectionInfo_1fj3i_789",Gi="_drawingInfo_1fj3i_791",Fi="_connectingInfo_1fj3i_805",Vi="_gridInfo_1fj3i_819",Hi="_emptyState_1fj3i_831",Ui="_emptyIcon_1fj3i_853",qi="_primaryBtn_1fj3i_883",Zi="_modeActions_1fj3i_917",Yi="_actionBtn_1fj3i_935",E={root:wr,shell:Nr,dark:kr,topBar:Ir,modeSwitcher:Cr,modeBtn:zr,modeBtnActive:Sr,modeIcon:Lr,modeLabel:Tr,floorTabs:$r,floorTab:Br,floorTabActive:Pr,viewportControls:Mr,active:Or,disabled:Ar,separator:Er,zoomLevel:Dr,exportDropdown:Rr,exportMenu:Wr,editorContainer:Gr,toolbar:Fr,toolGroup:Vr,toolBtn:Hr,toolBtnActive:Ur,canvasWrapper:qr,canvas:Zr,cursor_select:Yr,cursor_multi_select:Kr,cursor_pan:Xr,cursor_zoom:Jr,cursor_draw_wall:Qr,cursor_draw_zone:ei,cursor_draw_polyline:ti,cursor_draw_rectangle:si,cursor_draw_circle:ni,cursor_draw_arc:oi,cursor_place_device:ai,cursor_place_furniture:ci,cursor_place_network:ri,cursor_place_infra:ii,cursor_place_door:li,cursor_place_window:di,cursor_place_stairs:ui,cursor_connect:pi,cursor_route_cable:_i,cursor_annotate:mi,cursor_dimension:hi,cursor_label:xi,cursor_measure_distance:fi,cursor_measure_angle:vi,cursor_measure_area:yi,cursor_move:gi,cursor_rotate:ji,cursor_scale:bi,cursor_erase:wi,cursor_copy:Ni,cursor_paste:ki,grid:Ii,gridLine:Ci,zonesLayer:zi,zone:Si,zoneLabel:Li,connectionsLayer:Ti,connection:$i,connectionPreview:Bi,guides:Pi,guideLine:Mi,drawingPreview:Oi,rightSidebar:Ai,statusBar:Ei,modeIndicator:Di,toolIndicator:Ri,selectionInfo:Wi,drawingInfo:Gi,connectingInfo:Fi,gridInfo:Vi,emptyState:Hi,emptyIcon:Ui,primaryBtn:qi,modeActions:Zi,actionBtn:Yi},Ye={"floor-plan":{mode:"floor-plan",label:"Floor Plan",icon:"home",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:"globe",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:"building",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:"ruler",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:"sofa",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:"gamepad",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}},dt={select:{tool:"select",icon:"cursor",label:"Select",shortcut:"V",group:"select"},"multi-select":{tool:"multi-select",icon:"grid",label:"Multi-Select",shortcut:"M",group:"select"},pan:{tool:"pan",icon:"cursor",label:"Pan",shortcut:"H",group:"select"},zoom:{tool:"zoom",icon:"search",label:"Zoom",shortcut:"Z",group:"select"},"draw-wall":{tool:"draw-wall",icon:"line",label:"Wall",shortcut:"W",group:"draw"},"draw-zone":{tool:"draw-zone",icon:"hexagon",label:"Zone",shortcut:"R",group:"draw"},"draw-polyline":{tool:"draw-polyline",icon:"pen",label:"Polyline",shortcut:"L",group:"draw"},"draw-rectangle":{tool:"draw-rectangle",icon:"square",label:"Rectangle",shortcut:"U",group:"draw"},"draw-circle":{tool:"draw-circle",icon:"circle",label:"Circle",shortcut:"C",group:"draw"},"draw-arc":{tool:"draw-arc",icon:"pen",label:"Arc",shortcut:"A",group:"draw"},"place-device":{tool:"place-device",icon:"wifi",label:"Device",shortcut:"D",group:"place"},"place-furniture":{tool:"place-furniture",icon:"chair",label:"Furniture",shortcut:"F",group:"place"},"place-network":{tool:"place-network",icon:"server",label:"Network",shortcut:"N",group:"place"},"place-infra":{tool:"place-infra",icon:"settings",label:"Infrastructure",shortcut:"I",group:"place"},"place-door":{tool:"place-door",icon:"door",label:"Door",group:"place"},"place-window":{tool:"place-window",icon:"window",label:"Window",group:"place"},"place-stairs":{tool:"place-stairs",icon:"stairs",label:"Stairs",group:"place"},connect:{tool:"connect",icon:"link",label:"Connect",shortcut:"K",group:"connect"},"route-cable":{tool:"route-cable",icon:"plug",label:"Cable Route",group:"connect"},annotate:{tool:"annotate",icon:"edit",label:"Annotate",shortcut:"T",group:"annotate"},dimension:{tool:"dimension",icon:"ruler",label:"Dimension",group:"annotate"},label:{tool:"label",icon:"tag",label:"Label",group:"annotate"},"measure-distance":{tool:"measure-distance",icon:"ruler",label:"Distance",group:"measure"},"measure-angle":{tool:"measure-angle",icon:"triangle",label:"Angle",group:"measure"},"measure-area":{tool:"measure-area",icon:"square",label:"Area",group:"measure"},move:{tool:"move",icon:"move",label:"Move",shortcut:"G",group:"edit"},rotate:{tool:"rotate",icon:"refresh",label:"Rotate",shortcut:"R",group:"edit"},scale:{tool:"scale",icon:"scale",label:"Scale",shortcut:"S",group:"edit"},erase:{tool:"erase",icon:"trash",label:"Delete",shortcut:"Del",group:"edit"},copy:{tool:"copy",icon:"copy",label:"Copy",shortcut:"Ctrl+C",group:"edit"},paste:{tool:"paste",icon:"clipboard",label:"Paste",shortcut:"Ctrl+V",group:"edit"}};function Ki(t){var n,c;const s=t.defaultMode??"floor-plan",a=Ye[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 qe(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 Ze(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function We(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 ct(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 rt(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 it(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 Xi(t,s){var a;switch(s.type){case"SET_MODE":{const o=Ye[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=it(t.document,t.activeFloorId,o,s.object),c=qe("create",[s.object.id],null,s.object);return{...t,document:n,...Ze(t,c)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=We(t.document,s.objectId);if(!o)return t;const n=ct(t.document,s.objectId,s.updates),c=qe("update",[s.objectId],o,{...o,...s.updates});return{...t,document:n,...Ze(t,c)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(i=>We(t.document,i)).filter(Boolean),n=rt(t.document,s.objectIds),c=qe("delete",s.objectIds,o,null);return{...t,document:n,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(y=>We(t.document,y)).filter(Boolean);let n=t.document;for(const y of s.objectIds){const g=We(n,y);if(g&&"transform"in g&&g.transform&&"position"in g.transform){const k=g.transform.position;n=ct(n,y,{transform:{...g.transform,position:{x:k.x+s.delta.x,y:k.y+s.delta.y}}})}}const c=s.objectIds.map(y=>We(n,y)).filter(Boolean),i=qe("move",s.objectIds,o,c);return{...t,document:n,...Ze(t,i)}}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=rt(n,o.objectIds);break}case"delete":{const c=o.before;for(const i of c){const y=i.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,y,i)}break}case"update":case"move":{const c=o.before;for(const i of c)n=ct(n,i.id,i);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,i=c.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,i,c);break}case"delete":{n=rt(n,o.objectIds);break}case"update":case"move":{const c=o.after;for(const i of c)n=ct(n,i.id,i);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=>We(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(i=>We(t.document,i)).filter(Boolean),n=rt(t.document,t.selection.objectIds),c=qe("delete",t.selection.objectIds,o,null);return{...t,document:n,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const n=[],c=[];for(const y of t.clipboard){const g=`${y.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,k=y.transform,d={position:{x:k.position.x+s.position.x+20,y:k.position.y+s.position.y+20},rotation:k.rotation,scale:k.scale},C={...y,id:g,transform:d},j=C.layer||"devices";o=it(o,t.activeFloorId,j,C),n.push(g),c.push(C)}const i=qe("create",n,null,c);return{...t,document:o,selection:{objectIds:n,bounds:null,locked:!1},...Ze(t,i)}}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 Ji=({mode:t,activeTool:s,onToolSelect:a,readOnly:o})=>{const c=Ye[t].tools.map(y=>dt[y]).filter(Boolean),i=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:E.toolbar,children:i.map(y=>{const g=c.filter(k=>k.group===y);return g.length===0?null:e.jsx("div",{className:E.toolGroup,children:g.map(({tool:k,icon:d,label:C,shortcut:j})=>e.jsx("button",{title:`${C}${j?` (${j})`:""}`,className:`${E.toolBtn} ${s===k?E.toolBtnActive:""}`,onClick:()=>a(k),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(k),children:e.jsx(L.NiceIcon,{name:d,size:16})},k))},y)})})},Qi=({currentMode:t,availableModes:s,onModeChange:a})=>e.jsx("div",{className:E.modeSwitcher,children:s.map(o=>{const n=Ye[o];return e.jsxs("button",{title:n.label,className:`${E.modeBtn} ${t===o?E.modeBtnActive:""}`,onClick:()=>a(o),children:[e.jsx("span",{className:E.modeIcon,children:e.jsx(L.NiceIcon,{name:n.icon,size:16})}),e.jsx("span",{className:E.modeLabel,children:n.label})]},o)})});function Rt(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 el(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 i=c.metadata;if((i==null?void 0:i.vlanId)!==void 0&&!a.has(i.vlanId))a.add(i.vlanId),s.push({id:i.vlanId,name:i.vlanName??`VLAN ${i.vlanId}`,color:i.vlanColor??tl(i.vlanId),deviceIds:[c.id],subnet:i.subnet,gateway:i.gateway,dhcpEnabled:i.dhcpEnabled});else if((i==null?void 0:i.vlanId)!==void 0){const y=s.find(g=>g.id===i.vlanId);y&&!y.deviceIds.includes(c.id)&&y.deviceIds.push(c.id)}}return s.sort((o,n)=>o.id-n.id)}function tl(t){const s=["var(--nice-primary, #3b82f6)","var(--nice-success, #22c55e)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-accent-pink, #ec4899)","var(--nice-info, #06b6d4)","var(--nice-warning, #f97316)","var(--nice-info, #14b8a6)","var(--nice-accent, #a855f7)"];return s[t%s.length]}const sl=[{target:".nice-spatial-editor",titleKey:"tutorial.spatialEditor.intro.title",title:"Spatial editor",contentKey:"tutorial.spatialEditor.intro.content",content:"Lay out floor plans across modes: draw walls, rooms and objects with the tools, manage layers, snap to the grid, then export.",placement:"auto"}],nl=t=>{var St,Lt;const{defaultMode:s="floor-plan",availableModes:a=Object.keys(Ye),readOnly:o=!1,theme:n="light",locale:c="en",onDocumentChange:i,onSelectionChange:y,onModeChange:g,onExport:k,onImport:d,tutorial:C,className:j,style:m,cookies:N=!1,localStorage:b=!0,sessionStorage:I=!1,storageMode:w,storageKey:u,persistPreferences:v=!1}=t,l=L.useStorageAdapter(u??"nice-spatial-editor"),[_]=r.useState(()=>v?l.get("prefs")??{}:{}),[x,p]=r.useReducer(Xi,t,Ki),A=r.useRef(null),Y=r.useRef(!1),V=r.useRef({x:0,y:0}),[xe,pe]=r.useState(!1),[ue,ve]=r.useState(!1),[oe,le]=r.useState(null),[ie,ze]=r.useState(null),[Pe,S]=r.useState(!1),[H,de]=r.useState(!1),[ke,Ie]=r.useState(!1),[je,Ae]=r.useState(new Set),[Ee,De]=r.useState(null),Me=r.useRef(null),Le=r.useRef(null),be=r.useRef(null),{mode:we,tool:_e,document:ne,activeFloorId:Re,layers:Ne,selection:ye,viewport:ae,drawing:me,connecting:Q,guides:Ge,ui:Be,history:Ke}=x,Fe=Ye[we],tt=Ke.past.length>0,Xe=Ke.future.length>0;r.useEffect(()=>{var f,O,M;!v||!_||((_.zoom||_.pan)&&p({type:"SET_VIEWPORT",viewport:{zoom:_.zoom,pan:_.pan,showGrid:(f=_.gridConfig)==null?void 0:f.visible,gridSize:(O=_.gridConfig)==null?void 0:O.size,snapEnabled:(M=_.gridConfig)==null?void 0:M.snapEnabled}}),_.mode&&p({type:"SET_MODE",mode:_.mode}),_.tool&&p({type:"SET_TOOL",tool:_.tool}),_.layerVisibility&&Object.entries(_.layerVisibility).forEach(([R,K])=>{K!==void 0&&p({type:"SET_LAYER_VISIBILITY",layerType:R,visible:K})}))},[]),r.useEffect(()=>{if(!v)return;const f={zoom:ae.zoom,pan:ae.pan,gridConfig:{size:ae.gridSize,visible:ae.showGrid,snapEnabled:ae.snapEnabled},mode:we,tool:_e,layerVisibility:Object.fromEntries(Ne.map(O=>[O.type,O.visible])),uiPanels:Be};l.set("prefs",f)},[v,ae,we,_e,Ne,Be,l]);const fe=r.useMemo(()=>(ne==null?void 0:ne.floors.find(f=>f.id===Re))??(ne==null?void 0:ne.floors[0])??null,[ne,Re]),Oe=r.useCallback((f,O)=>{var R;const M=(R=A.current)==null?void 0:R.getBoundingClientRect();return M?{x:(f-M.left-ae.pan.x)/ae.zoom,y:(O-M.top-ae.pan.y)/ae.zoom}:{x:0,y:0}},[ae.pan,ae.zoom]),Ve=r.useCallback(f=>{if(!ae.snapEnabled)return f;const O={cellSize:ae.gridSize,majorInterval:10,origin:{x:0,y:0},visible:ae.showGrid,color:"var(--nice-border, #e5e7eb)",majorColor:"var(--nice-text-muted, #9ca3af)",opacity:1,snapModes:["grid"],snapThreshold:10,angleIncrement:15};return Z.snapToGrid(f,O)},[ae.snapEnabled,ae.gridSize,ae.showGrid]),_t=r.useCallback(f=>{if(_e==="pan"||f.button===1){Y.current=!0,V.current={x:f.clientX,y:f.clientY};return}const O=Ve(Oe(f.clientX,f.clientY));if(_e==="draw-zone"||_e==="draw-wall"||_e==="draw-polyline")me.active?p({type:"ADD_DRAWING_POINT",point:O}):p({type:"START_DRAWING",point:O});else if(_e==="connect"){const M=fe==null?void 0:fe.layers.flatMap(R=>R.objects).find(R=>{if(!R.bounds)return!1;const K=R.bounds;return O.x>=K.x&&O.x<=K.x+K.width&&O.y>=K.y&&O.y<=K.y+K.height});if(M)if(Q.active){p({type:"FINISH_CONNECTING",targetId:M.id});const R=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,K=M.bounds?{x:M.bounds.x+M.bounds.width/2,y:M.bounds.y+M.bounds.height/2}:O,X={id:R,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(Q.sourcePosition.x,K.x),y:Math.min(Q.sourcePosition.y,K.y),width:Math.abs(K.x-Q.sourcePosition.x),height:Math.abs(K.y-Q.sourcePosition.y)},metadata:{sourceId:Q.sourceId,targetId:M.id,sourcePosition:Q.sourcePosition,targetPosition:K,medium:"ethernet-cat6",status:"active"}};p({type:"ADD_OBJECT",object:X})}else{const R=M.bounds?{x:M.bounds.x+M.bounds.width/2,y:M.bounds.y+M.bounds.height/2}:O;p({type:"START_CONNECTING",sourceId:M.id,sourcePosition:R})}else Q.active&&p({type:"CANCEL_CONNECTING"})}else _e==="select"&&p({type:"CLEAR_SELECTION"})},[_e,me.active,Q.active,Q.sourceId,Q.sourcePosition,Ve,Oe,fe]),mt=r.useCallback(f=>{if(Y.current){const M=f.clientX-V.current.x,R=f.clientY-V.current.y;p({type:"PAN",delta:{x:M,y:R}}),V.current={x:f.clientX,y:f.clientY};return}const O=Ve(Oe(f.clientX,f.clientY));if(me.active&&(p({type:"UPDATE_DRAWING_PREVIEW",point:O}),ae.snapEnabled&&fe)){const M=fe.layers.flatMap(X=>X.objects.filter(ce=>ce.bounds).map(ce=>({id:ce.id,bounds:ce.bounds}))),R={x:O.x,y:O.y,width:1,height:1},K=Z.generateAlignmentGuides(R,M,10);p({type:"SET_GUIDES",guides:K})}Q.active&&p({type:"UPDATE_CONNECTING_PREVIEW",position:O})},[me.active,Q.active,Ve,Oe,ae.snapEnabled,fe]),ht=r.useCallback(()=>{Y.current=!1},[]),xt=r.useCallback(f=>{me.active&&me.points.length>=2&&p({type:"FINISH_DRAWING"})},[me.active,me.points.length]),ft=r.useCallback(f=>{f.preventDefault();const O=f.deltaY>0?-1:1;p({type:"ZOOM",delta:O,center:Oe(f.clientX,f.clientY)})},[Oe]),vt=r.useCallback(f=>{f.key==="Escape"&&(me.active?p({type:"CANCEL_DRAWING"}):Q.active?p({type:"CANCEL_CONNECTING"}):p({type:"CLEAR_SELECTION"})),f.key==="Delete"&&ye.objectIds.length>0&&p({type:"DELETE_OBJECTS",objectIds:ye.objectIds}),(f.ctrlKey||f.metaKey)&&(f.key==="z"&&p({type:"UNDO"}),f.key==="y"&&p({type:"REDO"}),f.key==="c"&&p({type:"COPY"}),f.key==="v"&&p({type:"PASTE",position:{x:0,y:0}}),f.key==="x"&&p({type:"CUT"}))},[me.active,Q.active,ye.objectIds]),yt=r.useCallback(f=>{p({type:"SET_MODE",mode:f}),g==null||g(f)},[g]),gt=r.useCallback(f=>{p({type:"SET_TOOL",tool:f})},[]),He=r.useCallback(async f=>{var O;if(ne){pe(!1);try{const M={includeGrid:!1,includeDimensions:!0};if(f==="nsp"){const R=Z.exportToNSP(ne,M);Z.downloadExport(R),k==null||k(f,R.data)}else if(f==="svg"){const R=Z.exportToSVG(ne,M);Z.downloadExport(R),k==null||k(f,R.data)}else if(f==="dxf"){const R=Z.exportToDXF(ne,M);Z.downloadExport(R),k==null||k(f,R.data)}else if(f==="png"&&A.current){const R=await Z.exportSVGToPNG(A.current,((O=ne.metadata)==null?void 0:O.name)||"export");Z.downloadExport(R),k==null||k(f,R.data)}}catch(M){console.error(`Export to ${f} failed:`,M)}}},[ne,k]),jt=r.useCallback(async f=>{var M;const O=(M=f.target.files)==null?void 0:M[0];if(O){ve(!1);try{const R={convertClosedPolylinesToZones:!0,minZoneArea:1},K=await Z.importFromBrowserFile(O,R);K.success&&K.document?ze(K):le(K),be.current&&(be.current.value="")}catch(R){console.error("Import failed:",R),le({success:!1,warnings:[],errors:[{code:"IMPORT_ERROR",message:R instanceof Error?R.message:"Unknown import error",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})}}},[]),bt=r.useCallback(()=>{ie!=null&&ie.success&&ie.document?S(!0):ze(null)},[ie]),st=r.useCallback(()=>{ze(null),S(!1)},[]),h=r.useCallback((f,O)=>{if(!(ie!=null&&ie.document)){S(!1);return}const M=ie.document,R={...M,floors:M.floors.map(K=>({...K,layers:K.layers.filter(X=>f.get(X.id)!=="skip").map(X=>{const ce=f.get(X.id);if(ce===X.id||!ce)return X;const Se=ne==null?void 0:ne.floors.flatMap(Ue=>Ue.layers).find(Ue=>Ue.id===ce);return Se?{...X,id:Se.id,name:Se.name,type:Se.type}:X})}))};p({type:"SET_DOCUMENT",document:R}),d==null||d(R),le(ie),S(!1),ze(null)},[ie,ne,d]),z=r.useCallback(()=>{S(!1)},[]),$=r.useCallback(f=>{if(be.current){let O=".dxf,.svg,.geojson,.json,.ifc";f==="dxf"?O=".dxf":f==="svg"?O=".svg":f==="geojson"?O=".geojson,.json":f==="ifc"&&(O=".ifc"),be.current.accept=O,be.current.click()}ve(!1)},[]);r.useEffect(()=>{const f=O=>{Me.current&&!Me.current.contains(O.target)&&pe(!1),Le.current&&!Le.current.contains(O.target)&&ve(!1)};return(xe||ue)&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[xe,ue]);const J=r.useCallback(()=>{var K,X;if(!ae.showGrid||!fe)return null;const f=[],{gridSize:O}=ae,M=((K=fe.bounds)==null?void 0:K.width)??1e3,R=((X=fe.bounds)==null?void 0:X.height)??800;for(let ce=0;ce<=M;ce+=O)f.push(e.jsx("line",{x1:ce,y1:0,x2:ce,y2:R,className:E.gridLine},`v${ce}`));for(let ce=0;ce<=R;ce+=O)f.push(e.jsx("line",{x1:0,y1:ce,x2:M,y2:ce,className:E.gridLine},`h${ce}`));return e.jsx("g",{className:E.grid,children:f})},[ae.showGrid,ae.gridSize,fe]),G=r.useCallback(()=>{if(!fe)return null;const f=fe.layers.find(O=>O.name==="zones");return f?e.jsx("g",{className:E.zonesLayer,children:f.objects.map(O=>{const M=O;if(!M.boundary||M.boundary.length<3)return null;const R=M.boundary.map((ce,Se)=>`${Se===0?"M":"L"}${ce.x},${ce.y}`).join(" ")+" Z",K=ye.objectIds.includes(M.id),X=M.boundary.reduce((ce,Se)=>({x:ce.x+Se.x/M.boundary.length,y:ce.y+Se.y/M.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:E.zone,onClick:ce=>{ce.stopPropagation(),p({type:"SET_SELECTION",selection:{objectIds:[M.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:R,fill:M.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.5,stroke:K?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:K?2:1}),M.name&&e.jsx("text",{x:X.x,y:X.y,textAnchor:"middle",dominantBaseline:"middle",className:E.zoneLabel,children:M.name})]},M.id)})}):null},[fe,ye.objectIds]),re=r.useCallback(()=>Ge.length===0?null:e.jsx("g",{className:E.guides,children:Ge.map((f,O)=>e.jsx("line",{x1:f.start.x,y1:f.start.y,x2:f.end.x,y2:f.end.y,className:E.guideLine},O))}),[Ge]),he=r.useCallback(()=>{if(!me.active||me.points.length===0)return null;const f=[...me.points];me.preview&&f.push(me.preview);const O=f.map((R,K)=>`${K===0?"M":"L"}${R.x},${R.y}`).join(" "),M=_e==="draw-zone"&&f.length>2;return e.jsxs("g",{className:E.drawingPreview,children:[e.jsx("path",{d:O+(M?" Z":""),fill:M?"var(--nice-primary-tint-10, rgba(37, 99, 235, 0.1))":"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:M?"none":"6,3"}),f.map((R,K)=>e.jsx("circle",{cx:R.x,cy:R.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},K))]})},[me,_e]),Te=r.useCallback(()=>!Q.active||!Q.sourcePosition||!Q.previewPosition?null:e.jsxs("g",{className:E.connectionPreview,children:[e.jsx("line",{x1:Q.sourcePosition.x,y1:Q.sourcePosition.y,x2:Q.previewPosition.x,y2:Q.previewPosition.y,stroke:"var(--nice-success, #10b981)",strokeWidth:2,strokeDasharray:"8,4",markerEnd:"url(#connectionArrow)"}),e.jsx("circle",{cx:Q.sourcePosition.x,cy:Q.sourcePosition.y,r:6,fill:"var(--nice-success, #10b981)"}),e.jsx("circle",{cx:Q.previewPosition.x,cy:Q.previewPosition.y,r:6,fill:"var(--nice-success, #10b981)",fillOpacity:.5,stroke:"var(--nice-success, #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:"var(--nice-success, #10b981)"})})})]}),[Q]),nt=r.useCallback(()=>{if(!fe)return null;const f=fe.layers.find(K=>K.type==="network");if(!f)return null;const O=f.objects.filter(K=>K.type==="connection");if(O.length===0)return null;const M={"ethernet-cat5":{color:"var(--nice-primary, #3b82f6)",width:2},"ethernet-cat6":{color:"var(--nice-primary-hover, #2563eb)",width:2},"ethernet-cat6a":{color:"var(--nice-primary-dark, #1d4ed8)",width:2},"ethernet-cat7":{color:"var(--nice-primary-dark, #1e40af)",width:3},"fiber-single":{color:"var(--nice-warning, #f59e0b)",width:3},"fiber-multi":{color:"var(--nice-warning-dark, #d97706)",width:3},"wifi-2.4ghz":{color:"var(--nice-accent, #8b5cf6)",dashArray:"6,4",width:2},"wifi-5ghz":{color:"var(--nice-accent, #7c3aed)",dashArray:"6,4",width:2},"wifi-6ghz":{color:"var(--nice-accent-dark, #6d28d9)",dashArray:"6,4",width:2},default:{color:"var(--nice-text-secondary, #64748b)",width:2}},R={active:"var(--nice-success, #10b981)",inactive:"var(--nice-text-muted, #94a3b8)",error:"var(--nice-danger, #ef4444)",degraded:"var(--nice-warning, #f59e0b)",unknown:"var(--nice-text-secondary, #64748b)"};return e.jsx("g",{className:E.connectionsLayer,children:O.map(K=>{const X=K.metadata;if(!(X!=null&&X.sourcePosition)||!(X!=null&&X.targetPosition))return null;const ce=M[X.medium??"default"]||M.default,Se=R[X.status??"unknown"]||R.unknown,Ue=ye.objectIds.includes(K.id);let wt=`M${X.sourcePosition.x},${X.sourcePosition.y}`;if(X.waypoints&&X.waypoints.length>0)for(const ot of X.waypoints)wt+=` L${ot.x},${ot.y}`;return wt+=` L${X.targetPosition.x},${X.targetPosition.y}`,e.jsxs("g",{className:E.connection,onClick:ot=>{ot.stopPropagation(),p({type:"SET_SELECTION",selection:{objectIds:[K.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:wt,fill:"none",stroke:Ue?"var(--nice-primary-hover, #2563eb)":ce.color,strokeWidth:Ue?ce.width+1:ce.width,strokeDasharray:ce.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:Se}),e.jsx("circle",{cx:X.sourcePosition.x,cy:X.sourcePosition.y,r:4,fill:ce.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:X.targetPosition.x,cy:X.targetPosition.y,r:4,fill:ce.color,stroke:"white",strokeWidth:1})]},K.id)})})},[fe,ye.objectIds]);if(!ne&&!fe)return e.jsx("div",{className:`${E.root} ${E[n]} ${j??""}`,style:m,children:e.jsxs("div",{className:E.emptyState,children:[e.jsx("div",{className:E.emptyIcon,children:e.jsx(L.NiceIcon,{name:Fe.icon,size:48})}),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:E.primaryBtn,onClick:()=>{const f=Z.createFloorPlanDocument("New Project","floor-plan");p({type:"SET_DOCUMENT",document:f})},children:"Create New Document"})]})});const as=e.jsxs("div",{className:E.topBar,children:[e.jsx(Qi,{currentMode:we,availableModes:a,onModeChange:yt}),ne&&ne.floors.length>1&&e.jsx("div",{className:E.floorTabs,children:ne.floors.map(f=>e.jsx("button",{className:`${E.floorTab} ${Re===f.id?E.floorTabActive:""}`,onClick:()=>p({type:"SET_ACTIVE_FLOOR",floorId:f.id}),children:f.name},f.id))}),e.jsxs("div",{className:E.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>p({type:"UNDO"}),disabled:!tt,className:tt?"":E.disabled,children:e.jsx(L.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>p({type:"REDO"}),disabled:!Xe,className:Xe?"":E.disabled,children:e.jsx(L.NiceIcon,{name:"forward",size:16})}),e.jsx("div",{className:E.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>p({type:"TOGGLE_GRID"}),className:ae.showGrid?E.active:"",children:e.jsx(L.NiceIcon,{name:"grid",size:16})}),e.jsx("button",{title:"Toggle Snap",onClick:()=>p({type:"TOGGLE_SNAP"}),className:ae.snapEnabled?E.active:"",children:e.jsx(L.NiceIcon,{name:"target",size:16})}),e.jsxs("span",{className:E.zoomLevel,children:[Math.round(ae.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>p({type:"ZOOM",delta:1}),children:e.jsx(L.NiceIcon,{name:"plus",size:16})}),e.jsx("button",{title:"Zoom Out",onClick:()=>p({type:"ZOOM",delta:-1}),children:e.jsx(L.NiceIcon,{name:"minus",size:16})}),e.jsx("button",{title:"Reset View",onClick:()=>p({type:"RESET_VIEW"}),children:e.jsx(L.NiceIcon,{name:"expand",size:16})}),!o&&e.jsxs("div",{className:E.exportDropdown,ref:Le,children:[e.jsx("input",{type:"file",ref:be,onChange:jt,style:{display:"none"}}),e.jsxs("button",{title:"Import",onClick:()=>ve(!ue),className:ue?E.active:"",children:[e.jsx(L.NiceIcon,{name:"download",size:14})," Import"]}),ue&&e.jsxs("div",{className:E.exportMenu,children:[e.jsxs("button",{onClick:()=>$(),children:[e.jsx(L.NiceIcon,{name:"file",size:14})," Auto-detect format"]}),e.jsxs("button",{onClick:()=>$("dxf"),children:[e.jsx(L.NiceIcon,{name:"ruler",size:14})," AutoCAD DXF (.dxf)"]}),e.jsxs("button",{onClick:()=>$("svg"),children:[e.jsx(L.NiceIcon,{name:"image",size:14})," SVG Vector Graphics (.svg)"]}),e.jsxs("button",{onClick:()=>$("geojson"),children:[e.jsx(L.NiceIcon,{name:"globe",size:14})," GeoJSON (.geojson)"]}),e.jsxs("button",{onClick:()=>$("ifc"),children:[e.jsx(L.NiceIcon,{name:"building",size:14})," IFC (BIM) (.ifc)"]})]})]}),ne&&e.jsxs("div",{className:E.exportDropdown,ref:Me,children:[e.jsxs("button",{title:"Export",onClick:()=>pe(!xe),className:xe?E.active:"",children:[e.jsx(L.NiceIcon,{name:"upload",size:14})," Export"]}),xe&&e.jsxs("div",{className:E.exportMenu,children:[e.jsxs("button",{onClick:()=>He("nsp"),children:[e.jsx(L.NiceIcon,{name:"file",size:14})," NiceToDev Spatial Plan (.nsp.json)"]}),e.jsxs("button",{onClick:()=>He("svg"),children:[e.jsx(L.NiceIcon,{name:"image",size:14})," SVG Vector Graphics (.svg)"]}),e.jsxs("button",{onClick:()=>He("dxf"),children:[e.jsx(L.NiceIcon,{name:"ruler",size:14})," AutoCAD DXF (.dxf)"]}),e.jsxs("button",{onClick:()=>He("png"),children:[e.jsx(L.NiceIcon,{name:"image",size:14})," PNG Image (.png)"]})]})]})]})]}),cs=Be.showObjectLibrary&&!o?e.jsx(Jt,{mode:we,onObjectSelect:f=>{p({type:"SET_TOOL",tool:`place-${f.category}`}),p({type:"START_DRAG",objectType:f.category,objectData:f})}}):void 0,rs=e.jsxs("div",{className:E.editorContainer,children:[!o&&e.jsx(Ji,{mode:we,activeTool:_e,onToolSelect:gt,readOnly:o}),(we==="network-topology"||we==="infrastructure")&&e.jsxs("div",{className:E.modeActions,children:[e.jsxs("button",{className:`${E.actionBtn} ${H?E.active:""}`,onClick:()=>de(!H),title:"Analiza ścieżki sieciowej",children:[e.jsx(L.NiceIcon,{name:"bar-chart",size:14})," Analiza ścieżki"]}),e.jsxs("button",{className:`${E.actionBtn} ${ke?E.active:""}`,onClick:()=>Ie(!ke),title:"Nakładka VLAN",children:[e.jsx(L.NiceIcon,{name:"globe",size:14})," VLAN Overlay"]})]}),e.jsxs("div",{className:E.canvasWrapper,children:[e.jsx("svg",{ref:A,className:`${E.canvas} ${E[`cursor_${_e.replace("-","_")}`]??""}`,onMouseDown:_t,onMouseMove:mt,onMouseUp:ht,onDoubleClick:xt,onWheel:ft,children:e.jsxs("g",{transform:`translate(${ae.pan.x}, ${ae.pan.y}) scale(${ae.zoom})`,children:[J(),G(),nt(),re(),he(),Te()]})}),Be.showMinimap&&e.jsx(Xt,{document:ne,activeFloorId:Re,viewport:ae,onViewportChange:f=>p({type:"SET_VIEWPORT",viewport:f})})]})]}),is=e.jsxs("div",{className:E.rightSidebar,children:[Be.showLayerPanel&&e.jsx(Kt,{layers:Ne.filter(f=>Fe.layerTypes.includes(f.type)),onVisibilityToggle:f=>{var O;return p({type:"SET_LAYER_VISIBILITY",layerType:f,visible:!((O=Ne.find(M=>M.type===f))!=null&&O.visible)})},onLockToggle:f=>{var O;return p({type:"SET_LAYER_LOCKED",layerType:f,locked:!((O=Ne.find(M=>M.type===f))!=null&&O.locked)})},onOpacityChange:(f,O)=>p({type:"SET_LAYER_OPACITY",layerType:f,opacity:O})}),Be.showPropertiesPanel&&ye.objectIds.length>0&&e.jsx(Qt,{selection:ye,document:ne,onPropertyChange:(f,O,M)=>{p({type:"UPDATE_OBJECT",objectId:f,updates:{[O]:M}})}})]}),ls=e.jsxs("div",{className:E.statusBar,children:[e.jsxs("span",{className:E.modeIndicator,children:[e.jsx(L.NiceIcon,{name:Fe.icon,size:14})," ",Fe.label]}),e.jsxs("span",{className:E.toolIndicator,children:[((St=dt[_e])==null?void 0:St.icon)&&e.jsx(L.NiceIcon,{name:dt[_e].icon,size:14})," ",(Lt=dt[_e])==null?void 0:Lt.label]}),ye.objectIds.length>0&&e.jsxs("span",{className:E.selectionInfo,children:[ye.objectIds.length," selected"]}),me.active&&e.jsxs("span",{className:E.drawingInfo,children:["Drawing: ",me.points.length," points"]}),Q.active&&e.jsx("span",{className:E.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:E.gridInfo,children:["Grid: ",ae.gridSize,"px | Snap: ",ae.snapEnabled?"ON":"OFF"]})]});return e.jsxs("div",{className:`nice-spatial-editor ${E.root} ${E[n]} ${j??""}`,style:{position:"relative",...m},tabIndex:0,onKeyDown:vt,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(L.NiceTutorialButton,{steps:L.resolveTutorial(C,sl)})}),e.jsx(L.NiceAppShell,{flush:!0,className:E.shell,menubar:as,sidebar:cs,rightSidebar:is,statusBar:ls,children:rs}),ie&&!Pe&&e.jsx(Rn,{result:ie,onConfirm:bt,onCancel:st}),ie&&Pe&&e.jsx(xo,{importResult:ie,existingDocument:ne??void 0,onConfirm:h,onCancel:z}),H&&ne&&e.jsx(Sa,{document:ne,connections:Rt(ne),onHighlightPath:f=>{p(f?{type:"SET_SELECTION",selection:{objectIds:f.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>de(!1)}),ke&&ne&&e.jsx(br,{document:ne,connections:Rt(ne),vlans:el(ne),visibleVlanIds:je,onVlanVisibilityChange:(f,O)=>{Ae(M=>{const R=new Set(M);return O?R.add(f):R.delete(f),R})},onHighlightVlan:f=>{De((f==null?void 0:f.id)??null),p(f?{type:"SET_SELECTION",selection:{objectIds:f.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Ie(!1)})]})},ol="_viewer_fazwr_13",al="_theme_light_fazwr_37",cl="_theme_dark_fazwr_59",rl="_debugOverlay_fazwr_85",il="_topBar_fazwr_137",ll="_searchContainer_fazwr_159",dl="_searchInput_fazwr_171",ul="_clearBtn_fazwr_227",pl="_searchResults_fazwr_261",_l="_searchResultItem_fazwr_291",ml="_searchResultInfo_fazwr_335",hl="_searchResultName_fazwr_347",xl="_searchResultDesc_fazwr_357",fl="_floorSelector_fazwr_371",vl="_navBtn_fazwr_421",yl="_active_fazwr_459",gl="_layersBtn_fazwr_475",jl="_legendBtn_fazwr_529",bl="_content_fazwr_583",wl="_navPanel_fazwr_599",Nl="_navPanelHeader_fazwr_617",kl="_routeInputs_fazwr_671",Il="_routeInput_fazwr_671",Cl="_routeMarker_fazwr_705",zl="_routeHint_fazwr_745",Sl="_routeInfo_fazwr_761",Ll="_routeStat_fazwr_779",Tl="_routeStatLabel_fazwr_791",$l="_routeStatValue_fazwr_805",Bl="_clearRouteBtn_fazwr_817",Pl="_refPointsList_fazwr_851",Ml="_refPointItem_fazwr_879",Ol="_refPointIcon_fazwr_917",Al="_layersPanel_fazwr_929",El="_layersPanelHeader_fazwr_947",Dl="_layersList_fazwr_1001",Rl="_layerItem_fazwr_1015",Wl="_layerToggle_fazwr_1039",Gl="_layerName_fazwr_1075",Fl="_layerType_fazwr_1087",Vl="_canvasWrapper_fazwr_1101",Hl="_canvas_fazwr_1101",Ul="_grid_fazwr_1137",ql="_gridLine_fazwr_1145",Zl="_zonesLayer_fazwr_1161",Yl="_zone_fazwr_1161",Kl="_zoneSelected_fazwr_1185",Xl="_zoneLabel_fazwr_1195",Jl="_objectsLayer_fazwr_1211",Ql="_object_fazwr_1211",ed="_objectSelected_fazwr_1233",td="_objectLabel_fazwr_1241",sd="_referencePoints_fazwr_1257",nd="_referencePoint_fazwr_1257",od="_refLabel_fazwr_1277",ad="_routeLayer_fazwr_1293",cd="_routePath_fazwr_1297",rd="_routeDash_fazwr_1",id="_routeMarkers_fazwr_1323",ld="_currentLocation_fazwr_1331",dd="_locationPulse_fazwr_1335",ud="_pulse_fazwr_1",pd="_zoomControls_fazwr_1369",_d="_minimap_fazwr_1445",md="_minimapContent_fazwr_1471",hd="_minimapViewport_fazwr_1485",xd="_legendPanel_fazwr_1505",fd="_legendPanelHeader_fazwr_1537",vd="_legendList_fazwr_1593",yd="_legendItem_fazwr_1609",gd="_legendColor_fazwr_1633",jd="_legendIcon_fazwr_1649",bd="_legendLabel_fazwr_1663",wd="_legendType_fazwr_1675",Nd="_objectInfo_fazwr_1693",kd="_objectInfoHeader_fazwr_1721",Id="_navigateBtn_fazwr_1791",T={viewer:ol,theme_light:al,theme_dark:cl,debugOverlay:rl,topBar:il,searchContainer:ll,searchInput:dl,clearBtn:ul,searchResults:pl,searchResultItem:_l,searchResultInfo:ml,searchResultName:hl,searchResultDesc:xl,floorSelector:fl,navBtn:vl,active:yl,layersBtn:gl,legendBtn:jl,content:bl,navPanel:wl,navPanelHeader:Nl,routeInputs:kl,routeInput:Il,routeMarker:Cl,routeHint:zl,routeInfo:Sl,routeStat:Ll,routeStatLabel:Tl,routeStatValue:$l,clearRouteBtn:Bl,refPointsList:Pl,refPointItem:Ml,refPointIcon:Ol,layersPanel:Al,layersPanelHeader:El,layersList:Dl,layerItem:Rl,layerToggle:Wl,layerName:Gl,layerType:Fl,canvasWrapper:Vl,canvas:Hl,grid:Ul,gridLine:ql,zonesLayer:Zl,zone:Yl,zoneSelected:Kl,zoneLabel:Xl,objectsLayer:Jl,object:Ql,objectSelected:ed,objectLabel:td,referencePoints:sd,referencePoint:nd,refLabel:od,routeLayer:ad,routePath:cd,routeDash:rd,routeMarkers:id,currentLocation:ld,locationPulse:dd,pulse:ud,zoomControls:pd,minimap:_d,minimapContent:md,minimapViewport:hd,legendPanel:xd,legendPanelHeader:fd,legendList:vd,legendItem:yd,legendColor:gd,legendIcon:jd,legendLabel:bd,legendType:wd,objectInfo:Nd,objectInfoHeader:kd,navigateBtn:Id},Cd=()=>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"})]}),Wt=()=>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"})}),zd=()=>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"})]}),Sd=()=>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"})]}),Ld=()=>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"})]}),Td=()=>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"})]}),$d=()=>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"})]}),Je=()=>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"})}),Gt=()=>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"})]}),Ft=()=>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"})]}),Bd=()=>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"})]}),Pd=()=>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"})]}),Md={entrance:"door",elevator:"elevator",stairs:"stairs",exit:"bell",poi:"map-pin",parking:"map-pin"};function kt(t){return t.icon??Md[t.type]??"map-pin"}function Od(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function Ad(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Ed(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 Dd=({document:t,initialFloorId:s,showNavigation:a=!0,showMinimap:o=!0,showFloorSelector:n=!0,showSearch:c=!0,showLayersPanel:i=!0,showLegend:y=!0,enableRoutePlanning:g=!0,referencePoints:k=[],onObjectClick:d,onRouteCalculated:C,currentLocation:j,theme:m="light",className:N,virtualRendering:b,virtualRenderingThreshold:I=200,debugVirtualRendering:w=!1})=>{var st;const[u,v]=r.useState(s??((st=t.floors[0])==null?void 0:st.id)??""),[l,_]=r.useState({zoom:1,pan:{x:0,y:0}}),[x,p]=r.useState(""),[A,Y]=r.useState([]),[V,xe]=r.useState(null),[pe,ue]=r.useState(null),[ve,oe]=r.useState(null),[le,ie]=r.useState(null),[ze,Pe]=r.useState(!1),[S,H]=r.useState(!1),[de,ke]=r.useState(!1),[Ie,je]=r.useState(new Map),[Ae,Ee]=r.useState({width:1e3,height:600}),De=r.useRef(null),Me=r.useRef(null),Le=r.useRef(!1),be=r.useRef({x:0,y:0}),we=r.useMemo(()=>{const h=t.floors.find(z=>z.id===u);return h?h.layers.reduce((z,$)=>{var J;return z+(((J=$.objects)==null?void 0:J.length)??0)},0):0},[t.floors,u]),_e=b??Z.shouldUseVirtualRendering(we,I),ne=r.useMemo(()=>{if(!_e)return null;const h=t.floors.find($=>$.id===u);if(!h)return null;const z=[];for(const $ of h.layers)if(!($.type==="zones"||$.type==="grid"||$.type==="background"))for(const J of $.objects??[]){const G=J.position??{x:0,y:0},re=J.size??{width:20,height:20};z.push({id:J.id,position:G,size:re,data:{object:J,layerId:$.id}})}return Z.createFloorPlanQuadTree(z)},[t.floors,u,_e]),Re=r.useMemo(()=>Z.calculateVisibleBounds(l,Ae,100),[l,Ae]),Ne=r.useMemo(()=>!_e||!ne?null:ne.query(Re),[_e,ne,Re]),ye=r.useMemo(()=>!w||!_e?null:Z.calculateRenderStats(we,(Ne==null?void 0:Ne.length)??we,l),[w,_e,we,Ne,l]);r.useEffect(()=>{const h=Me.current;if(!h)return;const z=new ResizeObserver($=>{for(const J of $)Ee({width:J.contentRect.width,height:J.contentRect.height})});return z.observe(h),()=>z.disconnect()},[]),r.useEffect(()=>{const h=t.floors.find(z=>z.id===u);if(h){const z=new Map;for(const $ of h.layers)z.set($.id,Ie.get($.id)??!0);je(z)}},[u,t.floors]);const ae=r.useCallback(h=>{je(z=>{const $=new Map(z);return $.set(h,!z.get(h)),$})},[]),me=r.useCallback(h=>Ie.get(h)!==!1,[Ie]),Q=r.useMemo(()=>t.floors.find(h=>h.id===u)??t.floors[0],[t.floors,u]),Ge=r.useMemo(()=>{if(!Q)return[];const h=[],z=Q.layers.find(G=>G.type==="zones");if(z){const G=new Map;for(const re of z.objects){const he=re.metadata,Te=(he==null?void 0:he.zoneType)??re.type??"zone";G.has(Te)||G.set(Te,(he==null?void 0:he.fill)??"var(--nice-primary, #3b82f6)")}for(const[re,he]of G)h.push({id:`zone-${re}`,label:re.charAt(0).toUpperCase()+re.slice(1).replace(/-/g," "),color:he,type:"zone"})}const $=new Map;for(const G of Q.layers)if(!(G.type==="zones"||G.type==="grid"||G.type==="background"))for(const re of G.objects){const he=re.type??"object",Te=$.get(he);Te?Te.count++:$.set(he,{count:1,color:"var(--nice-text-secondary, #64748b)"})}for(const[G,re]of $)h.push({id:`obj-${G}`,label:`${G.charAt(0).toUpperCase()+G.slice(1).replace(/-/g," ")} (${re.count})`,color:re.color,type:"object"});const J=new Map;for(const G of k.filter(re=>re.floorId===u))J.has(G.type)||J.set(G.type,kt(G));for(const[G,re]of J)h.push({id:`ref-${G}`,label:G.charAt(0).toUpperCase()+G.slice(1),color:"var(--nice-primary, #3b82f6)",icon:re,type:"reference"});return h},[Q,k,u]),Be=r.useCallback((h,z)=>{var J;const $=(J=De.current)==null?void 0:J.getBoundingClientRect();return $?{x:(h-$.left-l.pan.x)/l.zoom,y:(z-$.top-l.pan.y)/l.zoom}:{x:0,y:0}},[l]);r.useEffect(()=>{if(!x.trim()){Y([]);return}const h=x.toLowerCase(),z=[];for(const $ of t.floors)for(const J of $.layers)for(const G of J.objects){const re=(G.name??G.id).toLowerCase(),he=(G.description??"").toLowerCase();(re.includes(h)||he.includes(h))&&z.push(G)}Y(z.slice(0,10))},[x,t.floors]);const Ke=r.useCallback((h,z)=>{const $=Od(h,z);return{id:`route-${Date.now()}`,startPoint:h,endPoint:z,path:[h,z],floorTransitions:[],totalDistance:$,estimatedTime:$/1.4,instructions:[{type:"straight",distance:$,direction:"forward"},{type:"arrive"}]}},[]);r.useEffect(()=>{if(pe&&ve){const h=Ke(pe,ve);ie(h),C==null||C(h)}else ie(null),C==null||C(null)},[pe,ve,Ke,C]);const Fe=r.useCallback(h=>{(h.button===1||h.button===0&&h.altKey)&&(Le.current=!0,be.current={x:h.clientX,y:h.clientY},h.preventDefault())},[]),tt=r.useCallback(h=>{if(Le.current){const z=h.clientX-be.current.x,$=h.clientY-be.current.y;be.current={x:h.clientX,y:h.clientY},_(J=>({...J,pan:{x:J.pan.x+z,y:J.pan.y+$}}))}},[]),Xe=r.useCallback(()=>{Le.current=!1},[]),fe=r.useCallback(h=>{var re;h.preventDefault();const z=h.deltaY>0?.9:1.1,$=(re=De.current)==null?void 0:re.getBoundingClientRect();if(!$)return;const J=h.clientX-$.left,G=h.clientY-$.top;_(he=>{const Te=Math.min(Math.max(he.zoom*z,.1),10),nt=Te/he.zoom;return{zoom:Te,pan:{x:J-(J-he.pan.x)*nt,y:G-(G-he.pan.y)*nt}}})},[]),Oe=r.useCallback(h=>{if(g&&h.ctrlKey){const z=Be(h.clientX,h.clientY);pe?ve?(ue(z),oe(null)):oe(z):ue(z)}},[g,pe,ve,Be]),Ve=r.useCallback(()=>{_(h=>({...h,zoom:Math.min(h.zoom*1.25,10)}))},[]),_t=r.useCallback(()=>{_(h=>({...h,zoom:Math.max(h.zoom/1.25,.1)}))},[]),mt=r.useCallback(()=>{_({zoom:1,pan:{x:0,y:0}})},[]),ht=r.useCallback(h=>{xe(h);for(const $ of t.floors)for(const J of $.layers)if(J.objects.find(G=>G.id===h.id)){v($.id);break}const z=h.position??{x:0,y:0};_($=>({...$,pan:{x:-(z.x*$.zoom)+400,y:-(z.y*$.zoom)+300}})),p(""),Y([]),d==null||d(h)},[t.floors,d]),xt=r.useCallback(()=>{ue(null),oe(null),ie(null)},[]),ft=r.useCallback(()=>{const z=[];for(let $=-2e3;$<=2e3;$+=50)z.push(e.jsx("line",{x1:$,y1:-2e3,x2:$,y2:2e3,className:T.gridLine},`v-${$}`));for(let $=-2e3;$<=2e3;$+=50)z.push(e.jsx("line",{x1:-2e3,y1:$,x2:2e3,y2:$,className:T.gridLine},`h-${$}`));return e.jsx("g",{className:T.grid,children:z})},[]),vt=r.useCallback(()=>{if(!Q)return null;const h=Q.layers.find(z=>z.type==="zones");return!h||!me(h.id)?null:e.jsx("g",{className:T.zonesLayer,children:h.objects.map(z=>{const $=z.metadata;if(!($!=null&&$.points)||$.points.length<3)return null;const J=`M${$.points.map(re=>`${re.x},${re.y}`).join(" L")} Z`,G=(V==null?void 0:V.id)===z.id;return e.jsxs("g",{className:`${T.zone} ${G?T.zoneSelected:""}`,onClick:()=>{xe(z),d==null||d(z)},children:[e.jsx("path",{d:J,fill:$.fill??"var(--nice-primary, #3b82f6)",fillOpacity:.2,stroke:$.fill??"var(--nice-primary, #3b82f6)",strokeWidth:G?2:1}),z.name&&e.jsx("text",{x:$.points[0].x+10,y:$.points[0].y+20,className:T.zoneLabel,children:z.name})]},z.id)})})},[Q,V,d,me]),yt=r.useCallback(()=>Q?_e&&Ne?e.jsx("g",{className:T.objectsLayer,children:Ne.map(h=>{const{object:z,layerId:$}=h.data;if(!me($))return null;const J=z.position??{x:0,y:0},G=z.size??{width:20,height:20},re=(V==null?void 0:V.id)===z.id;return e.jsxs("g",{className:`${T.object} ${re?T.objectSelected:""}`,transform:`translate(${J.x}, ${J.y})`,onClick:he=>{he.stopPropagation(),xe(z),d==null||d(z)},children:[e.jsx("rect",{x:-G.width/2,y:-G.height/2,width:G.width,height:G.height,rx:4,fill:re?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:re?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:G.height/2+14,textAnchor:"middle",className:T.objectLabel,children:z.name})]},z.id)})}):e.jsx("g",{className:T.objectsLayer,children:Q.layers.map(h=>h.type==="zones"||h.type==="grid"||h.type==="background"||!me(h.id)?null:h.objects.map(z=>{const $=z.position??{x:0,y:0},J=z.size??{width:20,height:20},G=(V==null?void 0:V.id)===z.id;return e.jsxs("g",{className:`${T.object} ${G?T.objectSelected:""}`,transform:`translate(${$.x}, ${$.y})`,onClick:re=>{re.stopPropagation(),xe(z),d==null||d(z)},children:[e.jsx("rect",{x:-J.width/2,y:-J.height/2,width:J.width,height:J.height,rx:4,fill:G?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:G?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:J.height/2+14,textAnchor:"middle",className:T.objectLabel,children:z.name})]},z.id)}))}):null,[Q,V,d,me,_e,Ne]),gt=r.useCallback(()=>{const h=k.filter(z=>z.floorId===u);return e.jsx("g",{className:T.referencePoints,children:h.map(z=>e.jsxs("g",{className:T.referencePoint,transform:`translate(${z.position.x}, ${z.position.y})`,onClick:()=>{g&&(pe?oe(z.position):ue(z.position))},children:[e.jsx("circle",{r:16,fill:"white",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:2}),e.jsx("g",{transform:"translate(-8, -8)",style:{color:"var(--nice-primary, #3b82f6)"},"aria-hidden":"true",children:e.jsx(L.NiceIcon,{name:kt(z),size:16})}),e.jsx("text",{y:30,textAnchor:"middle",className:T.refLabel,children:z.name})]},z.id))})},[k,u,g,pe]),He=r.useCallback(()=>{if(!le)return null;const h=`M${le.path.map(z=>`${z.x},${z.y}`).join(" L")}`;return e.jsxs("g",{className:T.routeLayer,children:[e.jsx("path",{d:h,fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:T.routePath}),e.jsx("circle",{cx:le.startPoint.x,cy:le.startPoint.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:le.endPoint.x,cy:le.endPoint.y,r:8,fill:"var(--nice-danger, #ef4444)",stroke:"white",strokeWidth:2})]})},[le]),jt=r.useCallback(()=>j?e.jsxs("g",{className:T.currentLocation,children:[e.jsx("circle",{cx:j.x,cy:j.y,r:12,fill:"var(--nice-primary, #3b82f6)",fillOpacity:.3,className:T.locationPulse}),e.jsx("circle",{cx:j.x,cy:j.y,r:6,fill:"var(--nice-primary, #3b82f6)",stroke:"white",strokeWidth:2})]}):null,[j]),bt=r.useCallback(()=>e.jsx("g",{className:T.routeMarkers,children:pe&&!le&&e.jsx("circle",{cx:pe.x,cy:pe.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2})}),[pe,le]);return e.jsxs("div",{ref:Me,className:`${T.viewer} ${T[`theme_${m}`]} ${N??""}`,children:[w&&ye&&e.jsxs("div",{className:T.debugOverlay,children:[e.jsx("div",{children:"Virtual: ON"}),e.jsxs("div",{children:["Total: ",ye.total]}),e.jsxs("div",{children:["Visible: ",ye.visible]}),e.jsxs("div",{children:["Culled: ",ye.culled," (",ye.cullPercentage,"%)"]}),e.jsxs("div",{children:["Zoom: ",ye.zoom.toFixed(2),"x"]})]}),e.jsxs("div",{className:T.topBar,children:[c&&e.jsxs("div",{className:T.searchContainer,children:[e.jsxs("div",{className:T.searchInput,children:[e.jsx(Cd,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:x,onChange:h=>p(h.target.value)}),x&&e.jsx("button",{className:T.clearBtn,onClick:()=>p(""),children:e.jsx(Je,{})})]}),A.length>0&&e.jsx("div",{className:T.searchResults,children:A.map(h=>e.jsxs("button",{className:T.searchResultItem,onClick:()=>ht(h),children:[e.jsx(zd,{}),e.jsxs("div",{className:T.searchResultInfo,children:[e.jsx("span",{className:T.searchResultName,children:h.name??h.id}),h.description&&e.jsx("span",{className:T.searchResultDesc,children:h.description})]})]},h.id))})]}),n&&t.floors.length>1&&e.jsxs("div",{className:T.floorSelector,children:[e.jsx(Sd,{}),e.jsx("select",{value:u,onChange:h=>v(h.target.value),children:t.floors.map(h=>e.jsx("option",{value:h.id,children:h.name??`Piętro ${h.level}`},h.id))})]}),a&&e.jsxs("button",{className:`${T.navBtn} ${ze?T.active:""}`,onClick:()=>Pe(!ze),children:[e.jsx(Wt,{}),e.jsx("span",{children:"Nawigacja"})]}),i&&e.jsxs("button",{className:`${T.layersBtn} ${S?T.active:""}`,onClick:()=>H(!S),children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"})]}),y&&e.jsxs("button",{className:`${T.legendBtn} ${de?T.active:""}`,onClick:()=>ke(!de),children:[e.jsx(Ft,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:T.content,children:[ze&&e.jsxs("div",{className:T.navPanel,children:[e.jsxs("div",{className:T.navPanelHeader,children:[e.jsx(Ld,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>Pe(!1),children:e.jsx(Je,{})})]}),e.jsxs("div",{className:T.routeInputs,children:[e.jsxs("div",{className:T.routeInput,children:[e.jsx("div",{className:T.routeMarker,style:{background:"var(--nice-success, #10b981)"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:pe?`${pe.x.toFixed(0)}, ${pe.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:T.routeInput,children:[e.jsx("div",{className:T.routeMarker,style:{background:"var(--nice-danger, #ef4444)"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:ve?`${ve.x.toFixed(0)}, ${ve.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:T.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),le&&e.jsxs("div",{className:T.routeInfo,children:[e.jsxs("div",{className:T.routeStat,children:[e.jsx("span",{className:T.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:T.routeStatValue,children:Ad(le.totalDistance)})]}),e.jsxs("div",{className:T.routeStat,children:[e.jsx("span",{className:T.routeStatLabel,children:"Czas"}),e.jsx("span",{className:T.routeStatValue,children:Ed(le.estimatedTime)})]})]}),(pe||ve)&&e.jsx("button",{className:T.clearRouteBtn,onClick:xt,children:"Wyczyść trasę"}),k.length>0&&e.jsxs("div",{className:T.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),k.filter(h=>h.floorId===u).map(h=>e.jsxs("button",{className:T.refPointItem,onClick:()=>{pe?oe(h.position):ue(h.position)},children:[e.jsx("span",{className:T.refPointIcon,children:e.jsx(L.NiceIcon,{name:kt(h),size:16})}),e.jsx("span",{children:h.name})]},h.id))]})]}),S&&Q&&e.jsxs("div",{className:T.layersPanel,children:[e.jsxs("div",{className:T.layersPanelHeader,children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>H(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:T.layersList,children:Q.layers.map(h=>{const z=me(h.id);return e.jsxs("div",{className:T.layerItem,children:[e.jsx("button",{className:T.layerToggle,onClick:()=>ae(h.id),title:z?"Ukryj warstwę":"Pokaż warstwę",children:z?e.jsx(Bd,{}):e.jsx(Pd,{})}),e.jsx("span",{className:T.layerName,children:h.name??h.id}),e.jsxs("span",{className:T.layerType,children:["(",h.type,")"]})]},h.id)})})]}),e.jsxs("div",{className:T.canvasWrapper,children:[e.jsx("svg",{ref:De,className:T.canvas,onMouseDown:Fe,onMouseMove:tt,onMouseUp:Xe,onMouseLeave:Xe,onWheel:fe,onClick:Oe,children:e.jsxs("g",{transform:`translate(${l.pan.x}, ${l.pan.y}) scale(${l.zoom})`,children:[ft(),vt(),yt(),gt(),bt(),He(),jt()]})}),e.jsxs("div",{className:T.zoomControls,children:[e.jsx("button",{onClick:Ve,title:"Powiększ",children:e.jsx(Td,{})}),e.jsx("button",{onClick:_t,title:"Pomniejsz",children:e.jsx($d,{})}),e.jsx("button",{onClick:mt,title:"Resetuj widok",children:e.jsx(L.NiceIcon,{name:"refresh",size:16})})]}),o&&e.jsx("div",{className:T.minimap,children:e.jsx("div",{className:T.minimapContent,children:e.jsx("div",{className:T.minimapViewport})})}),de&&Ge.length>0&&e.jsxs("div",{className:T.legendPanel,children:[e.jsxs("div",{className:T.legendPanelHeader,children:[e.jsx(Ft,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>ke(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:T.legendList,children:Ge.map(h=>e.jsxs("div",{className:T.legendItem,children:[h.icon?e.jsx("span",{className:T.legendIcon,children:e.jsx(L.NiceIcon,{name:h.icon,size:16})}):e.jsx("span",{className:T.legendColor,style:{background:h.color}}),e.jsx("span",{className:T.legendLabel,children:h.label}),e.jsx("span",{className:T.legendType,children:h.type==="zone"?"strefa":h.type==="object"?"obiekt":"punkt ref."})]},h.id))})]})]})]}),V&&e.jsxs("div",{className:T.objectInfo,children:[e.jsxs("div",{className:T.objectInfoHeader,children:[e.jsx("h4",{children:V.name??V.id}),e.jsx("button",{onClick:()=>xe(null),children:e.jsx(Je,{})})]}),V.description&&e.jsx("p",{children:V.description}),g&&e.jsxs("button",{className:T.navigateBtn,onClick:()=>{const h=V.position??{x:0,y:0};pe?oe(h):ue(h)},children:[e.jsx(Wt,{}),pe?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Rd(t={}){var ve;const{initialDocument:s,defaultMode:a="floor-plan",gridSize:o=20,snapEnabled:n=!0,onChange:c}=t,i={mode:a,tool:"select",document:s??null,activeFloorId:((ve=s==null?void 0:s.floors[0])==null?void 0:ve.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}},[y,g]=r.useReducer((oe,le)=>({...oe,...le}),i),k=r.useCallback(oe=>{g({mode:oe})},[]),d=r.useCallback(oe=>{g({tool:oe})},[]),C=r.useCallback((oe="Untitled")=>{var ie;const le=Z.createFloorPlanDocument(oe,"floor-plan");g({document:le,activeFloorId:((ie=le.floors[0])==null?void 0:ie.id)??null}),c==null||c(le)},[c]),j=r.useCallback(oe=>{var le;g({document:oe,activeFloorId:((le=oe.floors[0])==null?void 0:le.id)??null}),c==null||c(oe)},[c]),m=r.useCallback(oe=>{g({viewport:{...y.viewport,zoom:Math.max(.1,Math.min(10,y.viewport.zoom*(1+oe*.1)))}})},[y.viewport]),N=r.useCallback(oe=>{g({viewport:{...y.viewport,pan:{x:y.viewport.pan.x+oe.x,y:y.viewport.pan.y+oe.y}}})},[y.viewport]),b=r.useCallback(()=>{g({viewport:{...y.viewport,zoom:1,pan:{x:0,y:0}}})},[y.viewport]),I=r.useCallback(()=>{g({viewport:{...y.viewport,showGrid:!y.viewport.showGrid}})},[y.viewport]),w=r.useCallback(()=>{g({viewport:{...y.viewport,snapEnabled:!y.viewport.snapEnabled}})},[y.viewport]),u=r.useCallback(oe=>{g({viewport:{...y.viewport,gridSize:oe}})},[y.viewport]),v=r.useCallback((oe,le)=>{g({layers:y.layers.map(ie=>ie.type===oe?{...ie,visible:le}:ie)})},[y.layers]),l=r.useCallback((oe,le)=>{g({layers:y.layers.map(ie=>ie.type===oe?{...ie,locked:le}:ie)})},[y.layers]),_=r.useCallback(oe=>{g({selection:{objectIds:oe,bounds:null,locked:!1}})},[]),x=r.useCallback(()=>{g({selection:{objectIds:[],bounds:null,locked:!1}})},[]),p=r.useCallback(()=>{},[]),A=r.useCallback(()=>{},[]),Y=y.history.past.length>0,V=y.history.future.length>0,xe=r.useCallback(()=>{},[]),pe=r.useCallback(oe=>{},[]),ue=r.useCallback(()=>{},[]);return{state:y,setMode:k,setTool:d,newDocument:C,loadDocument:j,zoom:m,pan:N,resetView:b,toggleGrid:I,toggleSnap:w,setGridSize:u,setLayerVisible:v,setLayerLocked:l,select:_,clearSelection:x,undo:p,redo:A,canUndo:Y,canRedo:V,copy:xe,paste:pe,cut:ue}}function Wd(t={}){const{gridSize:s=20,enabled:a=!0,snapModes:o=["grid","endpoint","midpoint"],objects:n=[],threshold:c=10}=t,i=r.useMemo(()=>({...Z.DEFAULT_GRID_CONFIG,cellSize:s,snapModes:o,snapThreshold:c}),[s,o,c]),y=r.useMemo(()=>n.map((m,N)=>({id:`obj-${N}`,bounds:m})),[n]),g=r.useCallback(m=>a?Z.snapToGrid(m,i):m,[a,i]),k=r.useCallback(m=>a?Z.snapToGrid3D(m,s):m,[a,s]),d=r.useCallback(m=>{if(!a||y.length===0)return[];const N={x:m.x,y:m.y,width:0,height:0};return Z.generateAlignmentGuides(N,y,c)},[a,y,c]),C=r.useCallback(m=>{if(!a)return{point:m,snapped:!1,guides:[]};const N=Z.performSnap(m,y,i);return{point:N.position,snapped:N.snapped,guides:N.guides??[]}},[a,i,y]),j=r.useCallback((m,N)=>{const b=[];for(let I=0;I<=m;I+=s)b.push({x1:I,y1:0,x2:I,y2:N});for(let I=0;I<=N;I+=s)b.push({x1:0,y1:I,x2:m,y2:I});return b},[s]);return{snap:g,snap3D:k,getGuides:d,performAdvancedSnap:C,generateGridLines:j}}function Gd(t={}){const{unitSystem:s="metric",lengthUnit:a="m",areaUnit:o="m2",angleUnit:n="deg",scale:c=100}=t,[i,y]=r.useState(null),[g,k]=r.useState([]),d=r.useCallback(x=>x/c,[c]),C=r.useCallback(x=>{y(x),k([])},[]),j=r.useCallback((x,p=!1)=>{k(A=>[...A,{position:x,snapped:p}])},[]),m=r.useCallback(()=>{y(null),k([])},[]),N=r.useCallback(()=>{if(!i||g.length<2)return null;const x=g.map(p=>p.position);if(i==="distance"&&g.length===2){const p=Z.distance2D(x[0],x[1]),A=d(p);return{type:"distance",value:A,formatted:Z.autoFormatLength(A,s).formatted,points:x}}if(i==="angle"&&g.length===3){const p=Z.angleAtVertex(x[0],x[1],x[2]);return{type:"angle",value:p,formatted:Z.formatAngle(p,n).formatted,points:x}}if(i==="area"&&g.length>=3){const A=Z.polygonArea(x)/(c*c);return{type:"area",value:A,formatted:Z.autoFormatArea(A,s).formatted,points:x}}return null},[i,g,c,s,n,d]),b=g.length>=2&&i==="distance"?Z.autoFormatLength(d(Z.distance2D(g[0].position,g[g.length-1].position)),s).formatted:null,I=g.length>=3&&i==="angle"?Z.formatAngle(Z.angleAtVertex(g[0].position,g[1].position,g[2].position),n).formatted:null,w=g.length>=3&&i==="area"?Z.autoFormatArea(Z.polygonArea(g.map(x=>x.position))/(c*c),s).formatted:null,u=r.useCallback((x,p)=>{const A=Z.distance2D(x,p),Y=d(A);return{value:Y,formatted:Z.autoFormatLength(Y,s).formatted}},[d,s]),v=r.useCallback((x,p,A)=>{const Y=Z.angleAtVertex(x,p,A);return{value:Y,formatted:Z.formatAngle(Y,n).formatted}},[n]),l=r.useCallback(x=>{const A=Z.polygonArea(x)/(c*c);return{value:A,formatted:Z.autoFormatArea(A,s).formatted}},[c,s]),_=r.useCallback(x=>{const p=Z.polylineLength(x),A=d(p);return{value:A,formatted:Z.autoFormatLength(A,s).formatted}},[d,s]);return{startMeasurement:C,addPoint:j,clearMeasurement:m,finishMeasurement:N,measurementType:i,points:g,liveDistance:b,liveAngle:I,liveArea:w,getDistance:u,getAngle:v,getArea:l,getLength:_}}const Fd="_root_1er3p_3",Vd="_dark_1er3p_25",Hd="_header_1er3p_31",Ud="_buildingInfo_1er3p_45",qd="_buildingName_1er3p_49",Zd="_buildingAddress_1er3p_67",Yd="_modeSelector_1er3p_81",Kd="_modeBtn_1er3p_93",Xd="_modeBtnActive_1er3p_127",Jd="_weather_1er3p_141",Qd="_weatherTemp_1er3p_155",eu="_weatherDesc_1er3p_171",tu="_statsRow_1er3p_183",su="_statsCard_1er3p_195",nu="_statsHeader_1er3p_225",ou="_statsIcon_1er3p_239",au="_statsLabel_1er3p_243",cu="_statsValue_1er3p_257",ru="_statsSub_1er3p_275",iu="_zoneGrid_1er3p_289",lu="_zoneCard_1er3p_303",du="_zoneOccupied_1er3p_347",uu="_zoneCardHeader_1er3p_351",pu="_zoneCardIcon_1er3p_365",_u="_zoneCardTitles_1er3p_369",mu="_zoneCardName_1er3p_379",hu="_zoneCardArea_1er3p_403",xu="_occupancyBadge_1er3p_413",fu="_occupancyBadgeOn_1er3p_431",vu="_sensorRow_1er3p_443",yu="_sensorChip_1er3p_457",gu="_sensorWarn_1er3p_475",ju="_deviceList_1er3p_489",bu="_deviceChip_1er3p_501",wu="_deviceChipOn_1er3p_535",Nu="_deviceChipName_1er3p_547",ku="_deviceChipVal_1er3p_561",Iu="_moreBtn_1er3p_571",Cu="_scenesBar_1er3p_597",zu="_sceneBarLabel_1er3p_627",Su="_sceneList_1er3p_645",Lu="_sceneBtn_1er3p_657",Tu="_sceneBtnActive_1er3p_683",U={root:Fd,dark:Vd,header:Hd,buildingInfo:Ud,buildingName:qd,buildingAddress:Zd,modeSelector:Yd,modeBtn:Kd,modeBtnActive:Xd,weather:Jd,weatherTemp:Qd,weatherDesc:eu,statsRow:tu,statsCard:su,statsHeader:nu,statsIcon:ou,statsLabel:au,statsValue:cu,statsSub:ru,zoneGrid:iu,zoneCard:lu,zoneOccupied:du,zoneCardHeader:uu,zoneCardIcon:pu,zoneCardTitles:_u,zoneCardName:mu,zoneCardArea:hu,occupancyBadge:xu,occupancyBadgeOn:fu,sensorRow:vu,sensorChip:yu,sensorWarn:gu,deviceList:ju,deviceChip:bu,deviceChipOn:wu,deviceChipName:Nu,deviceChipVal:ku,moreBtn:Iu,scenesBar:Cu,sceneBarLabel:zu,sceneList:Su,sceneBtn:Lu,sceneBtnActive:Tu},es={living_room:"sofa",bedroom:"bed",master_bedroom:"bed",kids_room:"star",bathroom:"droplet",kitchen:"utensils",dining_room:"utensils",hallway:"door",office:"briefcase",garage:"box",gym:"medal",cinema:"video",balcony:"home",garden:"home",open_office:"briefcase",private_office:"monitor",meeting_room:"clipboard",boardroom:"users",reception:"building",server_room:"server",lobby:"building",corridor:"arrow-right",stairwell:"stairs",parking:"box",break_room:"utensils",it_room:"monitor",cafeteria:"utensils"};function $u(t){return es[t]??"home"}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"?e.jsx(L.NiceIcon,{name:"lock",size:14}):null}const ts=({zone:t,devices:s=[],expanded:a=!1,onExpand:o,onDeviceControl:n,onClick:c,theme:i="light",className:y,style:g})=>{const k=t.occupancy!=null&&t.occupancy>0,d=a?s:s.slice(0,4);return e.jsxs("div",{className:`${U.zoneCard} ${i==="dark"?U.dark:""} ${k?U.zoneOccupied:""} ${y??""}`,style:g,onClick:c,children:[e.jsxs("div",{className:U.zoneCardHeader,children:[e.jsx("span",{className:U.zoneCardIcon,children:e.jsx(L.NiceIcon,{name:$u(t.type),size:18})}),e.jsxs("div",{className:U.zoneCardTitles,children:[e.jsx("span",{className:U.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:U.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${U.occupancyBadge} ${k?U.occupancyBadgeOn:""}`,children:[e.jsx(L.NiceIcon,{name:"users",size:14})," ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:U.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:U.sensorChip,children:[e.jsx(L.NiceIcon,{name:"thermometer",size:14})," ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:U.sensorChip,children:[e.jsx(L.NiceIcon,{name:"droplet",size:14})," ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${U.sensorChip} ${t.co2>1e3?U.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),d.length>0&&e.jsxs("div",{className:U.deviceList,children:[d.map(C=>{const j=C.state,m=(j==null?void 0:j.on)===!0||(j==null?void 0:j.locked)===!1;return e.jsxs("button",{className:`${U.deviceChip} ${m?U.deviceChipOn:""}`,onClick:N=>{N.stopPropagation(),n==null||n(C.id,{on:!m})},title:C.name,children:[e.jsx("span",{children:e.jsx(L.NiceIcon,{name:es[C.type]??"monitor",size:14})}),e.jsx("span",{className:U.deviceChipName,children:C.name}),e.jsx("span",{className:U.deviceChipVal,children:Bu(C)})]},C.id)}),s.length>4&&e.jsx("button",{className:U.moreBtn,onClick:C=>{C.stopPropagation(),o==null||o()},children:a?"−":`+${s.length-4}`})]})]})},It={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"},Vt={home:"home",away:"external-link",night:"eye-off",vacation:"rocket",guest:"user",party:"gift",occupied:"building",closed:"lock",weekend:"calendar",event:"calendar",emergency:"bell",maintenance:"settings"},Pu=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:U.weather,children:[e.jsxs("span",{className:U.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:U.weatherDesc,children:s})]}):null,lt=({label:t,value:s,sub:a,icon:o,accent:n})=>e.jsxs("div",{className:U.statsCard,style:n?{borderTopColor:n}:void 0,children:[e.jsxs("div",{className:U.statsHeader,children:[o&&e.jsx("span",{className:U.statsIcon,children:e.jsx(L.NiceIcon,{name:o,size:16})}),e.jsx("span",{className:U.statsLabel,children:t})]}),e.jsx("div",{className:U.statsValue,children:s}),a&&e.jsx("div",{className:U.statsSub,children:a})]}),Mu=({building:t,state:s,onModeChange:a,onDeviceControl:o,onSceneActivate:n,onZoneClick:c,className:i,style:y,theme:g="light",weather:k})=>{var v,l,_;const[d,C]=r.useState(null);t.floors[0];const j=t.floors.flatMap(x=>x.zones??[]).filter(x=>x.type!=="hallway"&&x.type!=="corridor"),m=((v=s==null?void 0:s.activeAlerts)==null?void 0:v.length)??0,N=(l=s==null?void 0:s.energy)==null?void 0:l.currentPowerW,b=(_=s==null?void 0:s.energy)==null?void 0:_.todayKwh,I=s!=null&&s.occupancy?Object.values(s.occupancy).reduce((x,p)=>x+((p==null?void 0:p.occupancy)??0),0):null;t.floors.flatMap(x=>x.zones??[]).flatMap(x=>x.deviceIds??[]).slice(0,8);const w=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],u=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${U.root} ${g==="dark"?U.dark:""} ${i??""}`,style:y,children:[e.jsxs("div",{className:U.header,children:[e.jsxs("div",{className:U.buildingInfo,children:[e.jsx("h2",{className:U.buildingName,children:t.name}),t.address&&e.jsx("p",{className:U.buildingAddress,children:t.address})]}),e.jsx("div",{className:U.modeSelector,children:w.map(x=>e.jsxs("button",{title:It[x],className:`${U.modeBtn} ${u===x?U.modeBtnActive:""}`,onClick:()=>a==null?void 0:a(x),children:[e.jsx(L.NiceIcon,{name:Vt[x],size:16}),e.jsx("span",{children:It[x]})]},x))}),e.jsx(Pu,{temperature:k==null?void 0:k.temperature,description:k==null?void 0:k.description})]}),e.jsxs("div",{className:U.statsRow,children:[N!=null&&e.jsx(lt,{icon:"zap",label:"Moc",value:N>=1e3?`${(N/1e3).toFixed(2)} kW`:`${N} W`,sub:b!=null?`Dziś: ${b.toFixed(2)} kWh`:void 0,accent:"var(--nice-warning, #f59e0b)"}),I!=null&&e.jsx(lt,{icon:"users",label:"Obecność",value:`${I} os.`,sub:`${j.length} stref`,accent:"var(--nice-success, #22c55e)"}),m>0&&e.jsx(lt,{icon:"bell",label:"Alarmy",value:e.jsx("span",{style:{color:"var(--nice-danger, #ef4444)"},children:m}),sub:"aktywnych",accent:"var(--nice-danger, #ef4444)"}),e.jsx(lt,{icon:Vt[u],label:"Tryb",value:It[u],accent:"var(--nice-accent, #8b5cf6)"})]}),e.jsx("div",{className:U.zoneGrid,children:j.map(x=>{const p=t.floors.flatMap(A=>(A.zones??[]).find(Y=>Y.id===x.id)?t.devices??[]:[]).filter(A=>A.zoneId===x.id);return e.jsx(ts,{zone:x,devices:p,expanded:d===x.id,onExpand:()=>C(d===x.id?null:x.id),onDeviceControl:o,onClick:()=>c==null?void 0:c(x.id),theme:g},x.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:U.scenesBar,children:[e.jsx("span",{className:U.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:U.sceneList,children:t.scenes.map(x=>{var p;return e.jsxs("button",{className:`${U.sceneBtn} ${(p=s==null?void 0:s.activeScenes)!=null&&p.includes(x.id)?U.sceneBtnActive:""}`,onClick:()=>n==null?void 0:n(x.id),children:[e.jsx(L.NiceIcon,{name:x.icon??"video",size:14})," ",x.name]},x.id)})})]})]})},Ou="_deviceControl_ev96o_3",Au="_dark_ev96o_23",Eu="_compact_ev96o_35",Du="_offline_ev96o_39",Ru="_offlineBanner_ev96o_43",Wu="_toggleControl_ev96o_67",Gu="_toggleLabel_ev96o_81",Fu="_toggleBtn_ev96o_97",Vu="_toggleOn_ev96o_123",Hu="_blindControl_ev96o_137",Uu="_blindLabel_ev96o_139",qu="_blindActions_ev96o_143",Zu="_blindBtn_ev96o_145",Yu="_blindSlider_ev96o_149",Ku="_blindPct_ev96o_151",Xu="_lockControl_ev96o_157",Ju="_lockLabel_ev96o_159",Qu="_lockBtn_ev96o_163",ep="_lockLocked_ev96o_165",tp="_lockUnlocked_ev96o_167",sp="_cameraControl_ev96o_173",np="_cameraLabel_ev96o_175",op="_cameraSnapshot_ev96o_179",ap="_cameraPlaceholder_ev96o_181",cp="_cameraStatus_ev96o_183",rp="_cameraDot_ev96o_185",ip="_cameraOnline_ev96o_187",lp="_cameraOffline_ev96o_189",dp="_sensorControl_ev96o_195",up="_sensorLabel_ev96o_197",pp="_sensorValues_ev96o_201",_p="_sensorRow_ev96o_203",mp="_sensorKey_ev96o_205",hp="_sensorVal_ev96o_201",xp="_thermostat_ev96o_215",fp="_thermostatTitle_ev96o_229",vp="_thermostatDial_ev96o_247",yp="_dialTempCurrent_ev96o_257",gp="_dialTempLabel_ev96o_273",jp="_dialTempTarget_ev96o_283",bp="_dialHumidity_ev96o_299",wp="_thermostatAdjust_ev96o_309",Np="_adjustBtn_ev96o_321",kp="_adjustTemp_ev96o_355",Ip="_hvacModes_ev96o_375",Cp="_hvacModeBtn_ev96o_389",zp="_hvacModeBtnActive_ev96o_413",Sp="_hvacAction_ev96o_425",Lp="_hvacActionDot_ev96o_441",Tp="_lightControl_ev96o_455",$p="_lightHeader_ev96o_467",Bp="_lightIcon_ev96o_479",Pp="_lightName_ev96o_483",Mp="_lightToggle_ev96o_507",Op="_lightToggleOn_ev96o_535",Ap="_sliderRow_ev96o_547",Ep="_sliderIcon_ev96o_561",Dp="_slider_ev96o_547",Rp="_sliderVal_ev96o_579",Wp="_colorRow_ev96o_591",Gp="_colorSwatch_ev96o_605",Fp="_colorPicker_ev96o_621",Vp="_colorPresets_ev96o_637",Hp="_colorPreset_ev96o_637",Up="_lightOff_ev96o_663",B={deviceControl:Ou,dark:Au,compact:Eu,offline:Du,offlineBanner:Ru,toggleControl:Wu,toggleLabel:Gu,toggleBtn:Fu,toggleOn:Vu,blindControl:Hu,blindLabel:Uu,blindActions:qu,blindBtn:Zu,blindSlider:Yu,blindPct:Ku,lockControl:Xu,lockLabel:Ju,lockBtn:Qu,lockLocked:ep,lockUnlocked:tp,cameraControl:sp,cameraLabel:np,cameraSnapshot:op,cameraPlaceholder:ap,cameraStatus:cp,cameraDot:rp,cameraOnline:ip,cameraOffline:lp,sensorControl:dp,sensorLabel:up,sensorValues:pp,sensorRow:_p,sensorKey:mp,sensorVal:hp,thermostat:xp,thermostatTitle:fp,thermostatDial:vp,dialTempCurrent:yp,dialTempLabel:gp,dialTempTarget:jp,dialHumidity:bp,thermostatAdjust:wp,adjustBtn:Np,adjustTemp:kp,hvacModes:Ip,hvacModeBtn:Cp,hvacModeBtnActive:zp,hvacAction:Sp,hvacActionDot:Lp,lightControl:Tp,lightHeader:$p,lightIcon:Bp,lightName:Pp,lightToggle:Mp,lightToggleOn:Op,sliderRow:Ap,sliderIcon:Ep,slider:Dp,sliderVal:Rp,colorRow:Wp,colorSwatch:Gp,colorPicker:Fp,colorPresets:Vp,colorPreset:Hp,lightOff:Up};function Ht(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 qp(t,s,a){return"#"+[t,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Ut(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 ss=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{var u,v,l;const i=t.state,y=(i==null?void 0:i.on)??!1,g=(i==null?void 0:i.brightness)??100,k=(i==null?void 0:i.colorTemperature)??4e3,d=i==null?void 0:i.rgbColor,[C,j]=r.useState(!1),m=r.useCallback(_=>{s==null||s(t.id,_)},[t.id,s]),N=d?qp(d[0],d[1],d[2]):"var(--nice-bg, #fff)",b=((u=t.capabilities)==null?void 0:u.includes("dimming"))??g!==void 0,I=(v=t.capabilities)==null?void 0:v.includes("color_temperature"),w=((l=t.capabilities)==null?void 0:l.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:y?1:.4},children:e.jsx(L.NiceIcon,{name:"lightbulb",size:16})}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${y?B.lightToggleOn:""}`,"aria-label":y?"Włączone":"Wyłączone",onClick:()=>m({on:!y}),children:e.jsx(L.NiceIcon,{name:y?"check":"close",size:14})})]}),y&&e.jsxs(e.Fragment,{children:[b&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(L.NiceIcon,{name:"lightbulb",size:16})}),e.jsx("input",{type:"range",min:1,max:100,value:g,className:B.slider,style:{"--pct":`${g}%`},onChange:_=>m({brightness:+_.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[g,"%"]})]}),I&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(L.NiceIcon,{name:"thermometer",size:16})}),e.jsx("input",{type:"range",min:2700,max:6500,step:100,value:k,className:B.slider,style:{background:`linear-gradient(to right, ${Ht(2700)}, ${Ht(6500)})`},onChange:_=>m({colorTemperature:+_.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(k/100)*100,"K"]})]}),w&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(L.NiceIcon,{name:"palette",size:16})}),e.jsx("button",{className:B.colorSwatch,style:{background:N},onClick:()=>j(_=>!_)}),C&&e.jsx("input",{type:"color",value:N,className:B.colorPicker,onChange:_=>{const[x,p,A]=Ut(_.target.value);m({rgbColor:[x,p,A]})}}),e.jsx("div",{className:B.colorPresets,children:["var(--nice-bg, #fff)","var(--nice-warning-bg, #fde68a)","var(--nice-danger-bg, #fca5a5)","var(--nice-primary-light, #93c5fd)","var(--nice-success-light, #86efac)","var(--nice-accent, #c4b5fd)"].map(_=>e.jsx("button",{className:B.colorPreset,style:{background:_},onClick:()=>{const[x,p,A]=Ut(_);m({rgbColor:[x,p,A]})}},_))})]})]}),!y&&!a&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},qt={heat:"Grzanie",cool:"Chłodzenie",auto:"Auto",off:"Wyłącz",fan_only:"Wentylacja",dry:"Osuszanie"},Zp={heat:"zap",cool:"thermometer",auto:"refresh",off:"stop",fan_only:"wifi",dry:"droplet"},Yp={heating:"var(--nice-danger, #ef4444)",cooling:"var(--nice-primary, #3b82f6)",fan:"var(--nice-success, #22c55e)",drying:"var(--nice-warning, #f59e0b)",idle:"var(--nice-text-muted, #94a3b8)",off:"var(--nice-border, #e2e8f0)"};function Zt(t,s,a,o,n){const c=C=>(C-90)*(Math.PI/180),i=t+a*Math.cos(c(o)),y=s+a*Math.sin(c(o)),g=t+a*Math.cos(c(n)),k=s+a*Math.sin(c(n)),d=n-o>180?1:0;return`M${i.toFixed(2)},${y.toFixed(2)} A${a},${a} 0 ${d},1 ${g.toFixed(2)},${k.toFixed(2)}`}const Qe=5,ut=35,pt=-140,ns=140;function Yt(t){return pt+(t-Qe)/(ut-Qe)*(ns-pt)}const os=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{const i=t.state,y=(i==null?void 0:i.temperature)??20,g=(i==null?void 0:i.targetTemperature)??21,k=i==null?void 0:i.humidity,d=(i==null?void 0:i.mode)??"auto",C=(i==null?void 0:i.hvacAction)??"idle",j=80,m=80,N=60,b=Zt(j,m,N,pt,ns),I=Yt(Math.min(Math.max(y,Qe),ut)),w=Yt(Math.min(Math.max(g,Qe),ut)),u=Zt(j,m,N,pt,Math.min(I,w)),v=Yp[C]??"var(--nice-text-muted, #94a3b8)",l=r.useCallback(x=>{const p=Math.round((g+x)*2)/2;p>=Qe&&p<=ut&&(s==null||s(t.id,{targetTemperature:p}))},[g,t.id,s]),_=r.useCallback(x=>{s==null||s(t.id,{mode:x})},[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:b,fill:"none",stroke:"var(--nice-border, #e2e8f0)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:u,fill:"none",stroke:v,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:j+N*Math.cos((w-90)*(Math.PI/180)),cy:m+N*Math.sin((w-90)*(Math.PI/180)),r:7,fill:v,stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsxs("text",{x:j,y:m-6,textAnchor:"middle",className:B.dialTempCurrent,children:[y.toFixed(1),"°"]}),e.jsx("text",{x:j,y:m+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:j,y:m+32,textAnchor:"middle",className:B.dialTempTarget,children:[g.toFixed(1),"°"]}),k!=null&&e.jsxs("text",{x:j,y:m+48,textAnchor:"middle",className:B.dialHumidity,children:[k,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>l(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[g.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>l(.5),children:"+"})]}),!a&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(x=>e.jsx("button",{title:qt[x],"aria-label":qt[x],className:`${B.hvacModeBtn} ${d===x?B.hvacModeBtnActive:""}`,onClick:()=>_(x),children:e.jsx(L.NiceIcon,{name:Zp[x],size:16})},x))}),e.jsxs("div",{className:B.hvacAction,style:{color:v},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:v}}),C]})]})},Kp=({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"})]})},Xp=({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,"aria-label":"Otwórz",onClick:()=>s==null?void 0:s(t.id,{command:"open"}),children:e.jsx(L.NiceIcon,{name:"arrow-up",size:16})}),e.jsx("button",{className:B.blindBtn,"aria-label":"Zatrzymaj",onClick:()=>s==null?void 0:s(t.id,{command:"stop"}),children:e.jsx(L.NiceIcon,{name:"stop",size:16})}),e.jsx("button",{className:B.blindBtn,"aria-label":"Zamknij",onClick:()=>s==null?void 0:s(t.id,{command:"close"}),children:e.jsx(L.NiceIcon,{name:"arrow-down",size:16})})]}),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,"%"]})]})},Jp=({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.jsxs("button",{className:`${B.lockBtn} ${o?B.lockLocked:B.lockUnlocked}`,onClick:()=>s==null?void 0:s(t.id,{locked:!o}),children:[e.jsx(L.NiceIcon,{name:"lock",size:14})," ",o?"Zablokowany":"Odblokowany"]})]})},Qp=({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(L.NiceIcon,{name:"camera",size:16}),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]})]})},e_=({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))})]})},t_=({device:t,onControl:s,compact:a=!1,className:o,style:n,theme:c="light"})=>{const i=t.type,y=["light","dimmer","rgb_light","led_strip"].includes(i)?e.jsx(ss,{device:t,onControl:s,compact:a,theme:c}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(i)?e.jsx(os,{device:t,onControl:s,compact:a,theme:c}):["blind","shutter","curtain","awning","garage_door"].includes(i)?e.jsx(Xp,{device:t,onControl:s}):["lock","door"].includes(i)?e.jsx(Jp,{device:t,onControl:s}):["camera","doorbell"].includes(i)?e.jsx(Qp,{device:t}):i.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(i)?e.jsx(e_,{device:t}):e.jsx(Kp,{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:[y,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},s_="_root_aupw6_3",n_="_shell_aupw6_29",o_="_dark_aupw6_37",a_="_listPanel_aupw6_43",c_="_listHeader_aupw6_65",r_="_listTitle_aupw6_85",i_="_addBtn_aupw6_99",l_="_list_aupw6_43",d_="_listItem_aupw6_127",u_="_listItemActive_aupw6_155",p_="_listItemName_aupw6_161",__="_listItemMeta_aupw6_185",m_="_enableToggle_aupw6_199",h_="_enableOn_aupw6_217",x_="_detailPanel_aupw6_223",f_="_detailHeader_aupw6_235",v_="_nameInput_aupw6_249",y_="_deleteBtn_aupw6_277",g_="_section_aupw6_303",j_="_sectionHeader_aupw6_311",b_="_sectionTitle_aupw6_325",w_="_sectionAddBtn_aupw6_341",N_="_ruleBlock_aupw6_367",k_="_ruleBlockHeader_aupw6_387",I_="_typeSelect_aupw6_401",C_="_removeBtn_aupw6_425",z_="_ruleFields_aupw6_457",S_="_input_aupw6_489",L_="_textarea_aupw6_513",T_="_dayPicker_aupw6_541",$_="_dayBtn_aupw6_545",B_="_dayBtnActive_aupw6_565",P_="_noSelection_aupw6_571",M_="_emptyHint_aupw6_571",D={root:s_,shell:n_,dark:o_,listPanel:a_,listHeader:c_,listTitle:r_,addBtn:i_,list:l_,listItem:d_,listItemActive:u_,listItemName:p_,listItemMeta:__,enableToggle:m_,enableOn:h_,detailPanel:x_,detailHeader:f_,nameInput:v_,deleteBtn:y_,section:g_,sectionHeader:j_,sectionTitle:b_,sectionAddBtn:w_,ruleBlock:N_,ruleBlockHeader:k_,typeSelect:I_,removeBtn:C_,ruleFields:z_,input:S_,textarea:L_,dayPicker:T_,dayBtn:$_,dayBtnActive:B_,noSelection:P_,emptyHint:M_},O_=[{target:".nice-building-automation-editor",titleKey:"tutorial.buildingAutomationEditor.intro.title",title:"Automation editor",contentKey:"tutorial.buildingAutomationEditor.intro.content",content:"Create building automations: pick one from the list, define its triggers, conditions and actions, then save, enable or delete it.",placement:"auto"}],$e=(t,s,a="")=>{const o=t[s];return typeof o=="string"?o:a},zt=(t,s,a=0)=>{const o=t[s];return typeof o=="number"?o:a},A_=(t,s,a)=>{const o=t[s];return Array.isArray(o)?o:a},E_=(t,s)=>{const a=t[s];return a&&typeof a=="object"?a:{}},D_=({trigger:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:D.ruleBlock,children:[e.jsxs("div",{className:D.ruleBlockHeader,children:[e.jsxs("select",{className:D.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:D.removeBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(L.NiceIcon,{name:"close",size:14})})]}),t.type==="time"&&e.jsxs("div",{className:D.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:D.input,value:$e(t,"time","08:00"),onChange:c=>n({time:c.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:D.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((c,i)=>{const y=A_(t,"days",[0,1,2,3,4]),g=y.includes(i);return e.jsx("button",{className:`${D.dayBtn} ${g?D.dayBtnActive:""}`,onClick:()=>n({days:g?y.filter(k=>k!==i):[...y,i]}),children:c},i)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:D.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:D.input,min:-120,max:120,step:5,value:zt(t,"offsetMinutes",0),onChange:c=>n({offsetMinutes:+c.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:D.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:D.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:D.input,value:$e(t,"attribute",""),onChange:c=>n({attribute:c.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:D.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:D.input,value:zt(t,"threshold",0),onChange:c=>n({threshold:+c.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:D.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:D.input,value:$e(t,"webhookId",""),onChange:c=>n({webhookId:c.target.value})})]})})]})},R_=({action:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:D.ruleBlock,children:[e.jsxs("div",{className:D.ruleBlockHeader,children:[e.jsxs("select",{className:D.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:D.removeBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(L.NiceIcon,{name:"close",size:14})})]}),t.type==="device_control"&&e.jsxs("div",{className:D.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:D.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:D.textarea,rows:3,value:JSON.stringify(E_(t,"state"),null,2),onChange:c=>{try{n({state:JSON.parse(c.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:D.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:D.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:D.input,value:$e(t,"message",""),onChange:c=>n({message:c.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:D.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:D.input,min:1,value:zt(t,"delaySeconds",60),onChange:c=>n({delaySeconds:+c.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:D.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:D.input,value:$e(t,"url",""),onChange:c=>n({url:c.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:D.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"})]})]})]})]})},W_=({automations:t,devices:s=[],onAutomationsChange:a,readOnly:o=!1,className:n,style:c,theme:i="light",tutorial:y})=>{var I;const[g,k]=r.useState(((I=t[0])==null?void 0:I.id)??null),d=t.find(w=>w.id===g)??null,C=r.useCallback(w=>{d&&(a==null||a(t.map(u=>u.id===d.id?{...u,...w}:u)))},[d,t,a]),j=r.useCallback(()=>{const w={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};a==null||a([...t,w]),k(w.id)},[t,a]),m=r.useCallback(w=>{var u;a==null||a(t.filter(v=>v.id!==w)),g===w&&k(((u=t.find(v=>v.id!==w))==null?void 0:u.id)??null)},[t,g,a]),N=e.jsxs("div",{className:D.listPanel,children:[e.jsxs("div",{className:D.listHeader,children:[e.jsx("span",{className:D.listTitle,children:"Automatyzacje"}),!o&&e.jsx("button",{className:D.addBtn,onClick:j,children:"+ Dodaj"})]}),e.jsxs("div",{className:D.list,children:[t.map(w=>e.jsxs("div",{className:`${D.listItem} ${g===w.id?D.listItemActive:""}`,onClick:()=>k(w.id),children:[e.jsx("div",{className:D.listItemName,children:w.name}),e.jsxs("div",{className:D.listItemMeta,children:[w.triggers.length," wyzw · ",w.actions.length," akcji"]}),e.jsx("button",{className:`${D.enableToggle} ${w.enabled?D.enableOn:""}`,onClick:u=>{u.stopPropagation(),C({enabled:!w.enabled})},title:w.enabled?"Wyłącz":"Włącz","aria-label":w.enabled?"Wyłącz":"Włącz",children:e.jsx(L.NiceIcon,{name:w.enabled?"check":"close",size:14})})]},w.id)),t.length===0&&e.jsx("div",{className:D.emptyHint,children:"Brak automatyzacji"})]})]}),b=e.jsx("div",{className:D.detailPanel,children:d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:D.detailHeader,children:[e.jsx("input",{className:D.nameInput,value:d.name,onChange:w=>C({name:w.target.value}),readOnly:o}),!o&&e.jsx("button",{className:D.deleteBtn,onClick:()=>m(d.id),children:"Usuń"})]}),e.jsxs("section",{className:D.section,children:[e.jsxs("div",{className:D.sectionHeader,children:[e.jsx("span",{className:D.sectionTitle,children:"Wyzwalacze"}),!o&&e.jsx("button",{className:D.sectionAddBtn,onClick:()=>C({triggers:[...d.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),d.triggers.map((w,u)=>e.jsx(D_,{trigger:w,devices:s,onChange:v=>C({triggers:d.triggers.map((l,_)=>_===u?v:l)}),onRemove:()=>C({triggers:d.triggers.filter((v,l)=>l!==u)})},u)),d.triggers.length===0&&e.jsx("div",{className:D.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:D.section,children:[e.jsxs("div",{className:D.sectionHeader,children:[e.jsx("span",{className:D.sectionTitle,children:"Akcje"}),!o&&e.jsx("button",{className:D.sectionAddBtn,onClick:()=>C({actions:[...d.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),d.actions.map((w,u)=>e.jsx(R_,{action:w,devices:s,onChange:v=>C({actions:d.actions.map((l,_)=>_===u?v:l)}),onRemove:()=>C({actions:d.actions.filter((v,l)=>l!==u)})},u)),d.actions.length===0&&e.jsx("div",{className:D.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:D.noSelection,children:"Wybierz automatyzację lub dodaj nową"})});return e.jsxs("div",{className:`nice-building-automation-editor ${D.root} ${i==="dark"?D.dark:""} ${n??""}`,style:{position:"relative",...c},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(L.NiceTutorialButton,{steps:L.resolveTutorial(y,O_)})}),e.jsx(L.NiceAppShell,{flush:!0,className:D.shell,sidebar:N,children:b})]})},G_="_root_1asyv_3",F_="_shell_1asyv_29",V_="_dark_1asyv_37",H_="_gridPanel_1asyv_43",U_="_gridHeader_1asyv_65",q_="_gridTitle_1asyv_85",Z_="_addBtn_1asyv_91",Y_="_sceneGrid_1asyv_115",K_="_sceneCard_1asyv_133",X_="_sceneCardActive_1asyv_157",J_="_sceneCardSelected_1asyv_159",Q_="_sceneCardIcon_1asyv_163",em="_sceneCardName_1asyv_167",tm="_sceneCardDevices_1asyv_185",sm="_activeBadge_1asyv_203",nm="_activateBtn_1asyv_207",om="_emptyGrid_1asyv_247",am="_detailPanel_1asyv_265",cm="_metaRow_1asyv_283",rm="_iconPicker_1asyv_295",im="_currentIcon_1asyv_299",lm="_iconGrid_1asyv_317",dm="_iconOpt_1asyv_333",um="_iconOptActive_1asyv_355",pm="_metaFields_1asyv_359",_m="_nameInput_1asyv_363",mm="_descInput_1asyv_391",hm="_colorPicker_1asyv_421",xm="_colorOpt_1asyv_431",fm="_colorOptActive_1asyv_447",vm="_targetsSection_1asyv_453",ym="_targetsSectionHeader_1asyv_457",gm="_addTargetBtn_1asyv_479",jm="_targetRow_1asyv_503",bm="_targetSelect_1asyv_527",wm="_targetState_1asyv_551",Nm="_targetField_1asyv_565",km="_tempInput_1asyv_585",Im="_removeTargetBtn_1asyv_603",Cm="_noTargets_1asyv_637",zm="_detailActions_1asyv_657",Sm="_activateFullBtn_1asyv_671",Lm="_deleteBtn_1asyv_699",q={root:G_,shell:F_,dark:V_,gridPanel:H_,gridHeader:U_,gridTitle:q_,addBtn:Z_,sceneGrid:Y_,sceneCard:K_,sceneCardActive:X_,sceneCardSelected:J_,sceneCardIcon:Q_,sceneCardName:em,sceneCardDevices:tm,activeBadge:sm,activateBtn:nm,emptyGrid:om,detailPanel:am,metaRow:cm,iconPicker:rm,currentIcon:im,iconGrid:lm,iconOpt:dm,iconOptActive:um,metaFields:pm,nameInput:_m,descInput:mm,colorPicker:hm,colorOpt:xm,colorOptActive:fm,targetsSection:vm,targetsSectionHeader:ym,addTargetBtn:gm,targetRow:jm,targetSelect:bm,targetState:wm,targetField:Nm,tempInput:km,removeTargetBtn:Im,noTargets:Cm,detailActions:zm,activateFullBtn:Sm,deleteBtn:Lm},Tm=[{target:".nice-scene-editor",titleKey:"tutorial.buildingSceneEditor.intro.title",title:"Scene editor",contentKey:"tutorial.buildingSceneEditor.intro.content",content:"Create scenes that set multiple devices at once: pick a scene, choose device target states, then save or activate it.",placement:"auto"}],et=t=>t&&typeof t=="object"?t:{},$m=(t,s,a=!1)=>{const o=et(t)[s];return typeof o=="boolean"?o:a},Ct=(t,s,a=0)=>{const o=et(t)[s];return typeof o=="number"?o:a},Bm=["video","eye-off","lightbulb","gamepad","briefcase","utensils","music","droplet","rocket","home","thermometer","lock","star","gift","heart","settings"],Pm=["var(--nice-primary-bg, #e0f2fe)","var(--nice-accent-bg, #fce7f3)","var(--nice-success-bg, #dcfce7)","var(--nice-warning-bg, #fef9c3)","var(--nice-accent-bg, #ede9fe)","var(--nice-danger-bg, #fee2e2)","var(--nice-success-bg, #f0fdf4)","#fff7ed"],Mm=({target:t,devices:s,onChange:a,onRemove:o})=>{const n=s.find(c=>c.id===t.deviceId);return e.jsxs("div",{className:q.targetRow,children:[e.jsxs("select",{className:q.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:q.targetState,children:[e.jsxs("label",{className:q.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:$m(t.state,"on",!1),onChange:c=>a({...t,state:{...et(t.state),on:c.target.checked}})})]}),(n.type==="dimmer"||n.type==="light"||n.type==="rgb_light"||n.type==="led_strip")&&e.jsxs("label",{className:q.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:Ct(t.state,"brightness",100),onChange:c=>a({...t,state:{...et(t.state),brightness:+c.target.value}})}),e.jsxs("span",{children:[Ct(t.state,"brightness",100),"%"]})]}),(n.type==="thermostat"||n.type==="air_conditioner")&&e.jsxs("label",{className:q.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:q.tempInput,min:10,max:30,step:.5,value:Ct(t.state,"targetTemperature",20),onChange:c=>a({...t,state:{...et(t.state),targetTemperature:+c.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:q.removeTargetBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(L.NiceIcon,{name:"close",size:14})})]})},Om=({scenes:t,devices:s=[],activeSceneIds:a=[],onScenesChange:o,onActivate:n,readOnly:c=!1,className:i,style:y,theme:g="light",tutorial:k})=>{var v;const[d,C]=r.useState(((v=t[0])==null?void 0:v.id)??null),j=t.find(l=>l.id===d)??null,m=r.useCallback(l=>{j&&(o==null||o(t.map(_=>_.id===j.id?{..._,...l}:_)))},[j,t,o]),N=r.useCallback(()=>{const l={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"video",color:"var(--nice-primary-bg, #e0f2fe)"};o==null||o([...t,l]),C(l.id)},[t,o]),b=r.useCallback(l=>{var _;o==null||o(t.filter(x=>x.id!==l)),d===l&&C(((_=t.find(x=>x.id!==l))==null?void 0:_.id)??null)},[t,d,o]),I=()=>{if(!j)return;const l={deviceId:"",state:{on:!0},transitionMs:1e3};m({deviceTargets:[...j.deviceTargets,l]})},w=e.jsxs("div",{className:q.gridPanel,children:[e.jsxs("div",{className:q.gridHeader,children:[e.jsx("span",{className:q.gridTitle,children:"Sceny"}),!c&&e.jsx("button",{className:q.addBtn,onClick:N,children:"+ Nowa"})]}),e.jsxs("div",{className:q.sceneGrid,children:[t.map(l=>{const _=a.includes(l.id),x=d===l.id;return e.jsxs("div",{className:`${q.sceneCard} ${_?q.sceneCardActive:""} ${x?q.sceneCardSelected:""}`,style:{background:l.color??"var(--nice-bg-secondary, #f8fafc)"},onClick:()=>C(l.id),children:[e.jsx("div",{className:q.sceneCardIcon,children:e.jsx(L.NiceIcon,{name:l.icon??"video",size:20})}),e.jsx("div",{className:q.sceneCardName,children:l.name}),e.jsxs("div",{className:q.sceneCardDevices,children:[l.deviceTargets.length," urządzeń",_&&e.jsx("span",{className:q.activeBadge,children:e.jsx(L.NiceIcon,{name:"check",size:12})})]}),e.jsx("button",{className:q.activateBtn,"aria-label":"Aktywuj",onClick:p=>{p.stopPropagation(),n==null||n(l.id)},children:e.jsx(L.NiceIcon,{name:"play",size:14})})]},l.id)}),t.length===0&&e.jsx("div",{className:q.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),u=j?e.jsxs("div",{className:q.detailPanel,children:[e.jsxs("div",{className:q.metaRow,children:[e.jsxs("div",{className:q.iconPicker,children:[e.jsx("span",{className:q.currentIcon,children:e.jsx(L.NiceIcon,{name:j.icon??"video",size:20})}),e.jsx("div",{className:q.iconGrid,children:Bm.map(l=>e.jsx("button",{className:`${q.iconOpt} ${j.icon===l?q.iconOptActive:""}`,"aria-label":l,onClick:()=>m({icon:l}),children:e.jsx(L.NiceIcon,{name:l,size:16})},l))})]}),e.jsxs("div",{className:q.metaFields,children:[e.jsx("input",{className:q.nameInput,value:j.name,readOnly:c,onChange:l=>m({name:l.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:q.descInput,value:j.description??"",readOnly:c,onChange:l=>m({description:l.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!c&&e.jsx("div",{className:q.colorPicker,children:Pm.map(l=>e.jsx("button",{className:`${q.colorOpt} ${j.color===l?q.colorOptActive:""}`,style:{background:l},onClick:()=>m({color:l})},l))}),e.jsxs("div",{className:q.targetsSection,children:[e.jsxs("div",{className:q.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!c&&e.jsx("button",{className:q.addTargetBtn,onClick:I,children:"+ Dodaj"})]}),j.deviceTargets.map((l,_)=>e.jsx(Mm,{target:l,devices:s,onChange:x=>m({deviceTargets:j.deviceTargets.map((p,A)=>A===_?x:p)}),onRemove:()=>m({deviceTargets:j.deviceTargets.filter((x,p)=>p!==_)})},_)),j.deviceTargets.length===0&&e.jsx("div",{className:q.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:q.detailActions,children:[e.jsxs("button",{className:q.activateFullBtn,onClick:()=>n==null?void 0:n(j.id),children:[e.jsx(L.NiceIcon,{name:"play",size:14})," Aktywuj scenę"]}),!c&&e.jsx("button",{className:q.deleteBtn,onClick:()=>b(j.id),children:"Usuń"})]})]}):void 0;return e.jsxs("div",{className:`nice-scene-editor ${q.root} ${g==="dark"?q.dark:""} ${i??""}`,style:{position:"relative",...y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(L.NiceTutorialButton,{steps:L.resolveTutorial(k,Tm)})}),e.jsx(L.NiceAppShell,{flush:!0,className:q.shell,sidebar:w,children:u})]})};exports.LayerPanel=Kt;exports.Minimap=Xt;exports.NiceAutomationEditor=W_;exports.NiceBuildingDashboard=Mu;exports.NiceDeviceControl=t_;exports.NiceFloorPlanEditor=cn;exports.NiceLightControl=ss;exports.NiceSceneEditor=Om;exports.NiceSpatialEditor=nl;exports.NiceSpatialViewer=Dd;exports.NiceThermostatControl=os;exports.NiceZoneCard=ts;exports.ObjectLibrary=Jt;exports.PropertiesPanel=Qt;exports.useMeasurement=Gd;exports.useSnapToGrid=Wd;exports.useSpatialEditor=Rd;
|