@nice2dev/ui-buildings 1.1.6 → 1.1.7
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 +51 -0
- package/dist/assets/import.worker-DmRf3ygm.js +1 -0
- package/dist/index.cjs +138 -4
- package/dist/index.d.ts +12 -3
- package/dist/index.mjs +5942 -3930
- package/dist/ui-buildings.css +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,139 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";var Ms=Object.defineProperty;var Bs=(t,s,n)=>s in t?Ms(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var ct=(t,s,n)=>Bs(t,typeof s!="symbol"?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),z=require("@nice2dev/ui"),u=require("react"),Ps="_root_1qthv_1",Es="_shell_1qthv_27",Os="_dark_1qthv_35",As="_topBar_1qthv_49",Ds="_floorTabs_1qthv_79",Rs="_floorTab_1qthv_79",Fs="_floorTabActive_1qthv_119",Ws="_overlayControls_1qthv_131",Gs="_overlayBtn_1qthv_143",qs="_overlayBtnActive_1qthv_179",Vs="_zoomBar_1qthv_191",Us="_toolPalette_1qthv_245",Hs="_toolBtn_1qthv_275",Ys="_toolBtnActive_1qthv_311",Zs="_canvasWrapper_1qthv_325",Xs="_canvas_1qthv_325",Ks="_cur_select_1qthv_365",Js="_cur_drawzone_1qthv_371",Qs="_cur_drawwall_1qthv_377",en="_cur_placedevice_1qthv_383",tn="_cur_placedoor_1qthv_389",sn="_cur_placewindow_1qthv_395",nn="_cur_pan_1qthv_401",on="_cur_erase_1qthv_407",an="_cur_measure_1qthv_413",rn="_cur_annotate_1qthv_419",cn="_gridLine_1qthv_429",ln="_zoneGroup_1qthv_447",dn="_zonePath_1qthv_455",un="_zoneLabel_1qthv_463",hn="_climateLabel_1qthv_485",mn="_occupancyLabel_1qthv_497",pn="_dimLabel_1qthv_509",_n="_deviceGroup_1qthv_521",fn="_devCircle_1qthv_529",gn="_devOnline_1qthv_541",yn="_devOffline_1qthv_547",xn="_devSelected_1qthv_553",bn="_propPanel_1qthv_565",vn="_propTitle_1qthv_593",jn="_propRow_1qthv_615",wn="_statusBar_1qthv_655",Nn="_emptyState_1qthv_687",te={root:Ps,shell:Es,dark:Os,topBar:As,floorTabs:Ds,floorTab:Rs,floorTabActive:Fs,overlayControls:Ws,overlayBtn:Gs,overlayBtnActive:qs,zoomBar:Vs,toolPalette:Us,toolBtn:Hs,toolBtnActive:Ys,canvasWrapper:Zs,canvas:Xs,cur_select:Ks,cur_drawzone:Js,cur_drawwall:Qs,cur_placedevice:en,cur_placedoor:tn,cur_placewindow:sn,cur_pan:nn,cur_erase:on,cur_measure:an,cur_annotate:rn,gridLine:cn,zoneGroup:ln,zonePath:dn,zoneLabel:un,climateLabel:hn,occupancyLabel:mn,dimLabel:pn,deviceGroup:_n,devCircle:fn,devOnline:gn,devOffline:yn,devSelected:xn,propPanel:bn,propTitle:vn,propRow:jn,statusBar:wn,emptyState:Nn},kn=[{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"}],In={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 Cn(t){return In[t]??"var(--nice-primary-bg, #f0f4ff)"}function qt(t){if(!t.length)return{x:0,y:0};const s=t.reduce((n,o)=>({x:n.x+o.x,y:n.y+o.y}),{x:0,y:0});return{x:s.x/t.length,y:s.y/t.length}}function Vt(t,s=!0){return t.length<2?"":t.map((n,o)=>`${o===0?"M":"L"}${n.x.toFixed(1)},${n.y.toFixed(1)}`).join(" ")+(s?" Z":"")}function Sn(t,s,n){return n?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function zn(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 Ln=[{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ń"}],$n={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"},Tn=({floors:t,defaultFloors:s,devices:n=[],onFloorChange:o,onDeviceMove:a,readOnly:r=!1,initialFloorId:i,showDevices:l=!0,showDimensions:h=!1,showGrid:b=!0,showOccupancy:d=!1,showClimate:x=!0,className:v,style:y,theme:_="light",tutorial:f})=>{var Me,Be;const[p,C]=z.useControllableState({value:t,defaultValue:s,fallbackValue:[],onChange:o,componentName:"NiceFloorPlanEditor"}),L=u.useRef(null),I=u.useRef(!1),k=u.useRef({x:0,y:0}),[c,g]=u.useReducer(zn,{floorId:i??((Me=p[0])==null?void 0:Me.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:b,showDim:h,showLabels:!0,showOccupancy:d,showClimate:x,snapGrid:!0,gridSize:20}),m=p.find(T=>T.id===c.floorId)??p[0],j=u.useCallback(T=>{var me;const U=(me=L.current)==null?void 0:me.getBoundingClientRect();return U?{x:(T.clientX-U.left-c.pan.x)/c.zoom,y:(T.clientY-U.top-c.pan.y)/c.zoom}:{x:0,y:0}},[c.pan,c.zoom]),E=u.useCallback(T=>{c.tool==="pan"&&(I.current=!0,k.current={x:T.clientX,y:T.clientY})},[c.tool]),F=u.useCallback(T=>{I.current&&(g({t:"PAN",v:{x:c.pan.x+T.clientX-k.current.x,y:c.pan.y+T.clientY-k.current.y}}),k.current={x:T.clientX,y:T.clientY})},[c.pan]),de=u.useCallback(()=>{I.current=!1},[]),ee=u.useCallback(T=>{if(c.tool==="draw_zone"){const U=Sn(j(T),c.gridSize,c.snapGrid);g({t:"DRAW_PT",v:U})}else c.tool==="select"&&g({t:"SELECT",v:null})},[c.tool,c.gridSize,c.snapGrid,j]),xe=u.useCallback(T=>{if(c.tool==="draw_zone"&&c.drawing&&c.drawing.length>=3&&m){const U={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:m.id,polygon:[...c.drawing]};C(p.map(me=>me.id===m.id?{...m,zones:[...m.zones,U]}:me)),g({t:"DRAW_END"})}},[c.tool,c.drawing,m,p,C]),ue=u.useCallback(T=>{T.preventDefault(),g({t:"ZOOM",v:c.zoom*(T.deltaY>0?.9:1.1)})},[c.zoom]),ae=u.useCallback((T,U)=>{T.stopPropagation(),c.tool==="select"?g({t:"SELECT",v:{type:"zone",id:U.id}}):c.tool==="erase"&&!r&&m&&C(p.map(me=>me.id===m.id?{...m,zones:m.zones.filter(Le=>Le.id!==U.id)}:me))},[c.tool,r,m,p,C]);if(!m)return e.jsx("div",{className:te.emptyState,children:"Brak kondygnacji."});const X=((Be=c.selected)==null?void 0:Be.type)==="zone"?m.zones.find(T=>{var U;return T.id===((U=c.selected)==null?void 0:U.id)}):null,le=l?n.filter(T=>m.zones.some(U=>U.id===T.zoneId)||T.floorPlanPosition):[],ze=[{key:"grid",icon:"grid",active:c.showGrid},{key:"dim",icon:"ruler",active:c.showDim},{key:"labels",icon:"tag",active:c.showLabels},{key:"occupancy",icon:"users",active:c.showOccupancy},{key:"climate",icon:"thermometer",active:c.showClimate}],De=e.jsxs("div",{className:te.topBar,children:[e.jsx("div",{className:te.floorTabs,children:[...p].sort((T,U)=>T.level-U.level).map(T=>e.jsx("button",{className:`${te.floorTab} ${c.floorId===T.id?te.floorTabActive:""}`,onClick:()=>g({t:"FLOOR",v:T.id}),children:T.name},T.id))}),e.jsx("div",{className:te.overlayControls,children:ze.map(T=>e.jsx("button",{title:T.key,"aria-label":T.key,className:`${te.overlayBtn} ${T.active?te.overlayBtnActive:""}`,onClick:()=>g({t:"TOGGLE",v:T.key}),children:e.jsx(z.NiceIcon,{name:T.icon,size:16})},T.key))}),e.jsxs("div",{className:te.zoomBar,children:[e.jsx("button",{onClick:()=>g({t:"ZOOM",v:c.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(c.zoom*100),"%"]}),e.jsx("button",{onClick:()=>g({t:"ZOOM",v:c.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok","aria-label":"Resetuj widok",onClick:()=>{g({t:"ZOOM",v:1}),g({t:"PAN",v:{x:0,y:0}})},children:e.jsx(z.NiceIcon,{name:"refresh",size:16})})]})]}),Ce=r?void 0:e.jsx("div",{className:te.toolPalette,children:Ln.map(({tool:T,icon:U,label:me})=>e.jsx("button",{title:me,"aria-label":me,className:`${te.toolBtn} ${c.tool===T?te.toolBtnActive:""}`,onClick:()=>g({t:"TOOL",v:T}),children:e.jsx(z.NiceIcon,{name:U,size:18})},T))});return e.jsxs("div",{className:`nice-floor-plan-editor ${te.root} ${_==="dark"?te.dark:""} ${v??""}`,style:{position:"relative",...y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(z.NiceTutorialButton,{steps:z.resolveTutorial(f,kn)})}),e.jsx(z.NiceAppShell,{flush:!0,className:te.shell,menubar:De,sidebar:Ce,rightSidebar:X?e.jsxs("div",{className:te.propPanel,children:[e.jsx("div",{className:te.propTitle,children:X.name}),e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:X.type})]}),X.area!=null&&e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[X.area," m²"]})]}),X.temperature!=null&&e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[X.temperature.toFixed(1)," °C"]})]}),X.humidity!=null&&e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[X.humidity," %"]})]}),X.co2!=null&&e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[X.co2," ppm"]})]}),X.occupancy!=null&&e.jsxs("div",{className:te.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[X.occupancy," os."]})]})]}):void 0,statusBar:e.jsxs("div",{className:te.statusBar,children:[c.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":c.selected?`Zaznaczono: ${c.selected.type} #${c.selected.id}`:`${m.name} — ${m.zones.length} strefa(y)`,c.tool==="draw_zone"&&c.drawing&&` (${c.drawing.length} pkt)`]}),children:e.jsx("div",{className:te.canvasWrapper,children:e.jsxs("svg",{ref:L,className:`${te.canvas} ${te[`cur_${c.tool.replace("_","")}`]??""}`,onMouseDown:E,onMouseMove:F,onMouseUp:de,onClick:ee,onDoubleClick:xe,onWheel:ue,children:[m.backgroundImage&&e.jsx("image",{href:m.backgroundImage,x:c.pan.x,y:c.pan.y,width:m.width*c.zoom,height:m.height*c.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${c.pan.x},${c.pan.y}) scale(${c.zoom})`,children:[c.showGrid&&(()=>{const T=[];for(let U=0;U<=m.width;U+=c.gridSize)T.push(e.jsx("line",{x1:U,y1:0,x2:U,y2:m.height,className:te.gridLine},`v${U}`));for(let U=0;U<=m.height;U+=c.gridSize)T.push(e.jsx("line",{x1:0,y1:U,x2:m.width,y2:U,className:te.gridLine},`h${U}`));return e.jsx("g",{children:T})})(),m.zones.map(T=>{var Oe;const U=((Oe=c.selected)==null?void 0:Oe.id)===T.id,me=qt(T.polygon),Le=T.color??Cn(T.type);return e.jsxs("g",{className:te.zoneGroup,onClick:be=>ae(be,T),children:[e.jsx("path",{d:Vt(T.polygon),fill:Le,fillOpacity:T.opacity??.55,stroke:U?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:U?2.5:1.5,className:te.zonePath}),c.showLabels&&e.jsx("text",{x:me.x,y:me.y,textAnchor:"middle",dominantBaseline:"middle",className:te.zoneLabel,children:T.name}),c.showClimate&&T.temperature!=null&&e.jsxs("text",{x:me.x,y:me.y+14,textAnchor:"middle",className:te.climateLabel,children:[T.temperature.toFixed(1),"°C"," ",T.humidity!=null?`· ${T.humidity}%`:""]}),c.showOccupancy&&T.occupancy!=null&&e.jsxs("text",{x:me.x,y:me.y+26,textAnchor:"middle",className:te.occupancyLabel,children:[T.occupancy," os."]}),c.showDim&&T.polygon.length>1&&T.polygon.map((be,Pe)=>{const ke=T.polygon[(Pe+1)%T.polygon.length],we=(be.x+ke.x)/2,je=(be.y+ke.y)/2,he=Math.sqrt((ke.x-be.x)**2+(ke.y-be.y)**2),ne=m.scale??0;return e.jsx("text",{x:we,y:je-4,textAnchor:"middle",className:te.dimLabel,children:ne>0?`${(he/ne).toFixed(1)}m`:`${he.toFixed(0)}px`},Pe)})]},T.id)}),le.map(T=>{var Oe;const U=m.zones.find(be=>be.id===T.zoneId),me=T.floorPlanPosition??(U?qt(U.polygon):null);if(!me)return null;const Le=((Oe=c.selected)==null?void 0:Oe.id)===T.id;return e.jsxs("g",{transform:`translate(${me.x},${me.y})`,className:te.deviceGroup,onClick:be=>{be.stopPropagation(),g({t:"SELECT",v:{type:"device",id:T.id}})},children:[e.jsx("circle",{r:14,className:`${te.devCircle} ${T.status==="online"?te.devOnline:te.devOffline} ${Le?te.devSelected:""}`}),e.jsx("g",{transform:"translate(-8,-8)",children:e.jsx(z.NiceIcon,{name:$n[T.type]??"monitor",size:16})})]},T.id)}),c.drawing&&c.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:Vt(c.drawing,!1),fill:"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:"6,3"}),c.drawing.map((T,U)=>e.jsx("circle",{cx:T.x,cy:T.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},U))]})]})]})})})]})},Mn={cellSize:20,majorInterval:5,origin:{x:0,y:0},visible:!0,color:"#e0e0e0",majorColor:"#b0b0b0",opacity:.5,snapModes:["grid","endpoint","center"],snapThreshold:10,angleIncrement:15};function Ft(t,s){const{cellSize:n,origin:o}=s;return{x:Math.round((t.x-o.x)/n)*n+o.x,y:Math.round((t.y-o.y)/n)*n+o.y}}function Bn(t,s){return{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s,z:Math.round(t.z/s)*s}}function Pn(t){if(t.snapPoints)return t.snapPoints;const{x:s,y:n,width:o,height:a}=t.bounds;return[{x:s,y:n},{x:s+o,y:n},{x:s+o,y:n+a},{x:s,y:n+a},{x:s+o/2,y:n+a/2},{x:s+o/2,y:n},{x:s+o,y:n+a/2},{x:s+o/2,y:n+a},{x:s,y:n+a/2}]}function En(t,s,n){let o=null;for(const a of s){const r=Pn(a);for(const i of r){const l=tt(t,i);l<=n&&(!o||l<o.distance)&&(o={point:i,targetId:a.id,distance:l})}}return o}function tt(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function ps(t,s,n){const o=[],a={x:t.x+t.width/2,y:t.y+t.height/2};for(const r of s){const i={x:r.bounds.x+r.bounds.width/2,y:r.bounds.y+r.bounds.height/2};Math.abs(a.y-i.y)<=n&&o.push({type:"horizontal",start:{x:Math.min(t.x,r.bounds.x),y:i.y},end:{x:Math.max(t.x+t.width,r.bounds.x+r.bounds.width),y:i.y},distance:Math.abs(a.y-i.y),sourceObjectId:r.id}),Math.abs(a.x-i.x)<=n&&o.push({type:"vertical",start:{x:i.x,y:Math.min(t.y,r.bounds.y)},end:{x:i.x,y:Math.max(t.y+t.height,r.bounds.y+r.bounds.height)},distance:Math.abs(a.x-i.x),sourceObjectId:r.id});const l=[{dragged:t.y,other:r.bounds.y,axis:"horizontal"},{dragged:t.y+t.height,other:r.bounds.y+r.bounds.height,axis:"horizontal"},{dragged:t.x,other:r.bounds.x,axis:"vertical"},{dragged:t.x+t.width,other:r.bounds.x+r.bounds.width,axis:"vertical"}];for(const h of l)Math.abs(h.dragged-h.other)<=n&&(h.axis==="horizontal"?o.push({type:"horizontal",start:{x:Math.min(t.x,r.bounds.x),y:h.other},end:{x:Math.max(t.x+t.width,r.bounds.x+r.bounds.width),y:h.other},distance:Math.abs(h.dragged-h.other),sourceObjectId:r.id}):o.push({type:"vertical",start:{x:h.other,y:Math.min(t.y,r.bounds.y)},end:{x:h.other,y:Math.max(t.y+t.height,r.bounds.y+r.bounds.height)},distance:Math.abs(h.dragged-h.other),sourceObjectId:r.id}))}return On(o)}function On(t){const s=new Set;return t.filter(n=>{const o=`${n.type}-${n.start.x.toFixed(1)}-${n.start.y.toFixed(1)}-${n.end.x.toFixed(1)}-${n.end.y.toFixed(1)}`;return s.has(o)?!1:(s.add(o),!0)})}function An(t,s,n){const o={position:{...t},snapped:!1,snapMode:null,guides:[]},{snapModes:a,snapThreshold:r}=n;if(a.includes("endpoint")||a.includes("center")||a.includes("midpoint")){const i=En(t,s,r);if(i)return o.position=i.point,o.snapped=!0,o.snapMode="endpoint",o.targetObjectId=i.targetId,o}if(a.includes("grid")){const i=Ft(t,n);if(tt(t,i)<=r)return o.position=i,o.snapped=!0,o.snapMode="grid",o}return o}const Dn=[{id:"sh-light-bulb",name:"Smart Bulb",category:"smart-home",type:"light",icon:"💡",tags:["lighting","bulb"]},{id:"sh-light-dimmer",name:"Dimmer Switch",category:"smart-home",type:"light-dimmer",icon:"🔆",tags:["lighting","switch"]},{id:"sh-light-rgb",name:"RGB Light",category:"smart-home",type:"light-rgb",icon:"🌈",tags:["lighting","color"]},{id:"sh-light-strip",name:"LED Strip",category:"smart-home",type:"light-strip",icon:"💡",tags:["lighting","strip"]},{id:"sh-thermostat",name:"Thermostat",category:"smart-home",type:"thermostat",icon:"🌡️",tags:["climate","temperature"]},{id:"sh-hvac",name:"HVAC Unit",category:"smart-home",type:"hvac",icon:"❄️",tags:["climate","cooling","heating"]},{id:"sh-fan",name:"Smart Fan",category:"smart-home",type:"fan",icon:"💨",tags:["climate","fan"]},{id:"sh-camera",name:"Security Camera",category:"smart-home",type:"camera",icon:"📷",tags:["security","camera"]},{id:"sh-doorbell",name:"Video Doorbell",category:"smart-home",type:"camera-doorbell",icon:"🔔",tags:["security","doorbell"]},{id:"sh-lock",name:"Smart Lock",category:"smart-home",type:"lock",icon:"🔒",tags:["security","lock"]},{id:"sh-sensor-motion",name:"Motion Sensor",category:"smart-home",type:"sensor-motion",icon:"👁️",tags:["security","sensor"]},{id:"sh-sensor-door",name:"Door Sensor",category:"smart-home",type:"sensor-door",icon:"🚪",tags:["security","sensor"]},{id:"sh-speaker",name:"Smart Speaker",category:"smart-home",type:"speaker",icon:"🔊",tags:["audio","speaker"]},{id:"sh-voice-assistant",name:"Voice Assistant",category:"smart-home",type:"voice-assistant",icon:"🗣️",tags:["audio","assistant"]},{id:"sh-tv",name:"Smart TV",category:"smart-home",type:"tv",icon:"📺",tags:["video","tv"]},{id:"furn-sofa-3",name:"3-Seater Sofa",category:"furniture",type:"sofa",defaultSize:{x:2.2,y:.9,z:.85},tags:["seating","sofa"]},{id:"furn-sofa-2",name:"2-Seater Sofa",category:"furniture",type:"sofa",defaultSize:{x:1.6,y:.9,z:.85},tags:["seating","sofa"]},{id:"furn-armchair",name:"Armchair",category:"furniture",type:"armchair",defaultSize:{x:.9,y:.9,z:.85},tags:["seating","chair"]},{id:"furn-dining-chair",name:"Dining Chair",category:"furniture",type:"chair",defaultSize:{x:.45,y:.5,z:.9},tags:["seating","dining"]},{id:"furn-office-chair",name:"Office Chair",category:"furniture",type:"chair",defaultSize:{x:.65,y:.65,z:1.2},tags:["seating","office"]},{id:"furn-dining-table-6",name:"Dining Table (6p)",category:"furniture",type:"table",defaultSize:{x:1.8,y:.9,z:.75},tags:["table","dining"]},{id:"furn-coffee-table",name:"Coffee Table",category:"furniture",type:"table",defaultSize:{x:1.2,y:.6,z:.45},tags:["table","living"]},{id:"furn-desk",name:"Office Desk",category:"furniture",type:"desk",defaultSize:{x:1.6,y:.8,z:.75},tags:["table","office","desk"]},{id:"furn-side-table",name:"Side Table",category:"furniture",type:"table",defaultSize:{x:.5,y:.5,z:.55},tags:["table","side"]},{id:"furn-bed-king",name:"King Bed",category:"furniture",type:"bed",defaultSize:{x:2,y:2.2,z:.5},tags:["bed","bedroom"]},{id:"furn-bed-queen",name:"Queen Bed",category:"furniture",type:"bed",defaultSize:{x:1.6,y:2.1,z:.5},tags:["bed","bedroom"]},{id:"furn-bed-single",name:"Single Bed",category:"furniture",type:"bed",defaultSize:{x:.9,y:2,z:.5},tags:["bed","bedroom"]},{id:"furn-wardrobe",name:"Wardrobe",category:"furniture",type:"wardrobe",defaultSize:{x:1.8,y:.6,z:2.2},tags:["storage","bedroom"]},{id:"furn-bookshelf",name:"Bookshelf",category:"furniture",type:"bookshelf",defaultSize:{x:.8,y:.3,z:2},tags:["storage","books"]},{id:"furn-dresser",name:"Dresser",category:"furniture",type:"dresser",defaultSize:{x:1.2,y:.5,z:.8},tags:["storage","bedroom"]},{id:"net-router",name:"Router",category:"network",type:"router",icon:"📡",tags:["network","router"]},{id:"net-switch-24",name:"24-Port Switch",category:"network",type:"switch",icon:"🔌",tags:["network","switch"]},{id:"net-switch-48",name:"48-Port Switch",category:"network",type:"switch",icon:"🔌",tags:["network","switch"]},{id:"net-firewall",name:"Firewall",category:"network",type:"firewall",icon:"🛡️",tags:["network","security"]},{id:"net-access-point",name:"WiFi Access Point",category:"network",type:"access-point",icon:"📶",tags:["network","wifi"]},{id:"net-server",name:"Server",category:"network",type:"server",icon:"🖥️",tags:["network","server"]},{id:"net-storage",name:"NAS Storage",category:"network",type:"nas",icon:"💾",tags:["network","storage"]},{id:"infra-rack-42u",name:"42U Rack",category:"infrastructure",type:"rack-42u",icon:"🗄️",defaultSize:{x:.6,y:1,z:2},tags:["datacenter","rack"]},{id:"infra-rack-24u",name:"24U Rack",category:"infrastructure",type:"rack-24u",icon:"🗄️",defaultSize:{x:.6,y:1,z:1.2},tags:["datacenter","rack"]},{id:"infra-ups",name:"UPS",category:"infrastructure",type:"ups-floor",icon:"🔋",tags:["datacenter","power"]},{id:"infra-pdu",name:"PDU",category:"infrastructure",type:"pdu-vertical",icon:"⚡",tags:["datacenter","power"]},{id:"infra-cooling",name:"CRAC Unit",category:"infrastructure",type:"cooling-crac",icon:"❄️",tags:["datacenter","cooling"]},{id:"bld-wall",name:"Wall",category:"building",type:"wall",icon:"🧱",tags:["building","wall"]},{id:"bld-door",name:"Door",category:"building",type:"door",icon:"🚪",tags:["building","door"]},{id:"bld-window",name:"Window",category:"building",type:"window",icon:"🪟",tags:["building","window"]},{id:"bld-stair",name:"Staircase",category:"building",type:"stair",icon:"🪜",tags:["building","stair"]},{id:"game-spawn",name:"Spawn Point",category:"game",type:"spawn-point",icon:"🎯",tags:["game","spawn"]},{id:"game-checkpoint",name:"Checkpoint",category:"game",type:"checkpoint",icon:"🏁",tags:["game","checkpoint"]},{id:"game-trigger",name:"Trigger Zone",category:"game",type:"trigger-zone",icon:"⚡",tags:["game","trigger"]},{id:"game-item",name:"Item Pickup",category:"game",type:"item-pickup",icon:"📦",tags:["game","item"]},{id:"game-enemy",name:"Enemy Spawner",category:"game",type:"enemy-spawner",icon:"👾",tags:["game","enemy"]}];function _s(t,s="floor-plan"){const n=new Date().toISOString();return{$schema:"https://nice2dev.com/schemas/nsp-v1.json",version:"1.0.0",type:s,metadata:{id:Rn(),name:t,created:n,modified:n},floors:[],settings:{units:"metric",scale:50,grid:{visible:!0,size:.5,snapEnabled:!0},defaultWallHeight:2.7,defaultWallThickness:.15,precision:2}}}function Rn(){return`${Date.now().toString(36)}-${Math.random().toString(36).substr(2,9)}`}const Ut={ft:3.28084,in:39.3701},Ht={"ft²":.092903,acre:4046.86};function Fn(t){return t*(180/Math.PI)}function Wn(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function Gn(t){if(t.length<2)return 0;let s=0;for(let n=1;n<t.length;n++)s+=Wn(t[n-1],t[n]);return s}function Tt(t,s,n){const o={x:t.x-s.x,y:t.y-s.y},a={x:n.x-s.x,y:n.y-s.y},r=o.x*a.x+o.y*a.y,i=Math.sqrt(o.x**2+o.y**2),l=Math.sqrt(a.x**2+a.y**2);if(i===0||l===0)return 0;const h=r/(i*l);return Math.acos(Math.max(-1,Math.min(1,h)))}function Mt(t){if(t.length<3)return 0;let s=0;const n=t.length;for(let o=0;o<n;o++){const a=(o+1)%n;s+=t[o].x*t[a].y,s-=t[a].x*t[o].y}return Math.abs(s)/2}function Qe(t,s="m",n=2){const o=`${t.toFixed(n)} ${s}`;return{value:t,unit:s,formatted:o}}function lt(t,s="m²",n=2){const o=`${t.toFixed(n)} ${s}`;return{value:t,unit:s,formatted:o}}function Bt(t,s="deg",n=1){const o=s==="deg"?Fn(t):t,a=s==="deg"?"°":" rad",r=`${o.toFixed(n)}${a}`;return{value:o,unit:s,formatted:r}}function dt(t,s="metric",n=2){if(s==="metric")return t<.01?Qe(t*1e3,"mm",n):t<1?Qe(t*100,"cm",n):Qe(t,"m",n);{const o=t*Ut.ft;return o<1?Qe(t*Ut.in,"in",n):Qe(o,"ft",n)}}function Pt(t,s="metric",n=2){if(s==="metric")return t>=1e4?lt(t/1e4,"ha",n):lt(t,"m²",n);{const o=t/Ht["ft²"];return o>=43560?lt(t/Ht.acre,"acre",n):lt(o,"ft²",n)}}function qn(t,s={}){const{pretty:n=!1,includeSchema:o=!0,excludeEmptyLayers:a=!1,includeMetadata:r=!0}=s,i=JSON.parse(JSON.stringify(t));if(o&&!i.$schema&&(i.$schema="https://nice2dev.com/schemas/nsp-v1.json"),r&&(i.metadata=i.metadata??{id:"",name:"",created:new Date().toISOString(),modified:new Date().toISOString()},i.metadata.modified=new Date().toISOString()),a)for(const l of i.floors)l.layers=l.layers.filter(h=>h.objects.length>0);return n?JSON.stringify(i,null,2):JSON.stringify(i)}function Vn(t,s={}){var i;const n=Qn(t,s),o=qn(n),a=new Blob([o],{type:"application/json"});return{format:"nsp",filename:`${((i=t.metadata)==null?void 0:i.name)||"document"}.nsp.json`,mimeType:"application/json",data:a,size:a.size}}const Un="http://www.w3.org/2000/svg";function Hn(t,s={}){var _,f;const{floorIds:n,includeGrid:o=!1,scale:a=1,backgroundColor:r}=s,i=n?t.floors.filter(p=>n.includes(p.id)):t.floors;if(i.length===0)throw new Error("No floors to export");const l=Jn(i),h=(l.maxX-l.minX)*a,b=(l.maxY-l.minY)*a,d=((_=t.metadata)==null?void 0:_.name)||"Floor Plan";let x=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="${Un}"
|
|
3
|
+
viewBox="${l.minX} ${l.minY} ${l.maxX-l.minX} ${l.maxY-l.minY}"
|
|
4
|
+
width="${h}"
|
|
5
|
+
height="${b}"
|
|
6
|
+
style="background: ${r||"transparent"}">
|
|
7
|
+
<title>${d}</title>
|
|
8
|
+
<desc>Exported from NiceToDev Spatial Editor</desc>
|
|
9
|
+
<defs>
|
|
10
|
+
<style>
|
|
11
|
+
.wall { stroke: #1e293b; stroke-width: 3; fill: none; }
|
|
12
|
+
.zone { fill-opacity: 0.3; stroke-width: 1; }
|
|
13
|
+
.device { fill: #3b82f6; }
|
|
14
|
+
.furniture { fill: #a3e635; stroke: #84cc16; }
|
|
15
|
+
.grid { stroke: #e2e8f0; stroke-width: 0.5; }
|
|
16
|
+
.dimension { stroke: #64748b; stroke-width: 1; fill: none; }
|
|
17
|
+
.dimension-text { font-family: sans-serif; font-size: 10px; fill: #64748b; }
|
|
18
|
+
.annotation { font-family: sans-serif; font-size: 12px; fill: #334155; }
|
|
19
|
+
</style>
|
|
20
|
+
</defs>
|
|
21
|
+
`;for(const p of i){x+=` <g id="${p.id}" class="floor" data-name="${p.name}">
|
|
22
|
+
`,o&&(x+=Yn(l));for(const C of p.layers)if(fs(C.name,s)){x+=` <g id="${C.id}" class="layer-${C.name}">
|
|
23
|
+
`;for(const L of C.objects)x+=Zn(L);x+=` </g>
|
|
24
|
+
`}x+=` </g>
|
|
25
|
+
`}x+="</svg>";const v=new Blob([x],{type:"image/svg+xml"});return{format:"svg",filename:`${((f=t.metadata)==null?void 0:f.name)||"document"}.svg`,mimeType:"image/svg+xml",data:v,size:v.size}}function Yn(t){let n=` <g class="grid">
|
|
26
|
+
`;for(let o=Math.floor(t.minX/20)*20;o<=t.maxX;o+=20)n+=` <line x1="${o}" y1="${t.minY}" x2="${o}" y2="${t.maxY}" />
|
|
27
|
+
`;for(let o=Math.floor(t.minY/20)*20;o<=t.maxY;o+=20)n+=` <line x1="${t.minX}" y1="${o}" x2="${t.maxX}" y2="${o}" />
|
|
28
|
+
`;return n+=` </g>
|
|
29
|
+
`,n}function Zn(t){const s=t;if(s.boundary&&Array.isArray(s.boundary)&&s.boundary.length>=3)return` <path d="${s.boundary.map((o,a)=>`${a===0?"M":"L"}${o.x},${o.y}`).join(" ")+" Z"}" class="zone" fill="${s.color||"#dbeafe"}" stroke="${s.color||"#3b82f6"}" />
|
|
30
|
+
`;if(s.start&&s.end)return` <line x1="${s.start.x}" y1="${s.start.y}" x2="${s.end.x}" y2="${s.end.y}" class="wall" stroke-width="${s.thickness||3}" />
|
|
31
|
+
`;if(t.bounds){const{x:n,y:o,width:a,height:r}=t.bounds,i=n+a/2,l=o+r/2;return t.category==="smart-home"?` <circle cx="${i}" cy="${l}" r="${Math.min(a,r)/2}" class="device" />
|
|
32
|
+
`:` <rect x="${n}" y="${o}" width="${a}" height="${r}" class="${t.category||"object"}" />
|
|
33
|
+
`}return""}function Xn(t,s={}){var b;const{floorIds:n,scale:o=1}=s,a=n?t.floors.filter(d=>n.includes(d.id)):t.floors;if(a.length===0)throw new Error("No floors to export");let r="";r+=`0
|
|
34
|
+
SECTION
|
|
35
|
+
2
|
|
36
|
+
HEADER
|
|
37
|
+
9
|
|
38
|
+
$ACADVER
|
|
39
|
+
1
|
|
40
|
+
AC1015
|
|
41
|
+
9
|
|
42
|
+
$INSUNITS
|
|
43
|
+
70
|
|
44
|
+
4
|
|
45
|
+
0
|
|
46
|
+
ENDSEC
|
|
47
|
+
`,r+=`0
|
|
48
|
+
SECTION
|
|
49
|
+
2
|
|
50
|
+
TABLES
|
|
51
|
+
0
|
|
52
|
+
TABLE
|
|
53
|
+
2
|
|
54
|
+
LAYER
|
|
55
|
+
`;const i=new Set;for(const d of a)for(const x of d.layers)i.add(x.name);for(const d of i)r+=`0
|
|
56
|
+
LAYER
|
|
57
|
+
2
|
|
58
|
+
${d.toUpperCase()}
|
|
59
|
+
70
|
|
60
|
+
0
|
|
61
|
+
62
|
|
62
|
+
7
|
|
63
|
+
6
|
|
64
|
+
CONTINUOUS
|
|
65
|
+
`;r+=`0
|
|
66
|
+
ENDTAB
|
|
67
|
+
0
|
|
68
|
+
ENDSEC
|
|
69
|
+
`,r+=`0
|
|
70
|
+
SECTION
|
|
71
|
+
2
|
|
72
|
+
ENTITIES
|
|
73
|
+
`;for(const d of a)for(const x of d.layers){if(!fs(x.name,s))continue;const v=x.name.toUpperCase();for(const y of x.objects)r+=Kn(y,v,o)}r+=`0
|
|
74
|
+
ENDSEC
|
|
75
|
+
0
|
|
76
|
+
EOF
|
|
77
|
+
`;const l=new Blob([r],{type:"application/dxf"});return{format:"dxf",filename:`${((b=t.metadata)==null?void 0:b.name)||"document"}.dxf`,mimeType:"application/dxf",data:l,size:l.size}}function Kn(t,s,n){const o=t;if(o.boundary&&Array.isArray(o.boundary)&&o.boundary.length>=3){let a=`0
|
|
78
|
+
LWPOLYLINE
|
|
79
|
+
8
|
|
80
|
+
${s}
|
|
81
|
+
90
|
|
82
|
+
${o.boundary.length}
|
|
83
|
+
70
|
|
84
|
+
1
|
|
85
|
+
`;for(const r of o.boundary)a+=`10
|
|
86
|
+
${r.x*n}
|
|
87
|
+
20
|
|
88
|
+
${r.y*n}
|
|
89
|
+
`;return a}if(o.start&&o.end)return`0
|
|
90
|
+
LINE
|
|
91
|
+
8
|
|
92
|
+
${s}
|
|
93
|
+
10
|
|
94
|
+
${o.start.x*n}
|
|
95
|
+
20
|
|
96
|
+
${o.start.y*n}
|
|
97
|
+
11
|
|
98
|
+
${o.end.x*n}
|
|
99
|
+
21
|
|
100
|
+
${o.end.y*n}
|
|
101
|
+
`;if(t.bounds){const{x:a,y:r,width:i,height:l}=t.bounds,h=(a+i/2)*n,b=(r+l/2)*n;if(t.category==="smart-home"){const d=Math.min(i,l)/2*n;return`0
|
|
102
|
+
CIRCLE
|
|
103
|
+
8
|
|
104
|
+
${s}
|
|
105
|
+
10
|
|
106
|
+
${h}
|
|
107
|
+
20
|
|
108
|
+
${b}
|
|
109
|
+
40
|
|
110
|
+
${d}
|
|
111
|
+
`}return`0
|
|
112
|
+
LWPOLYLINE
|
|
113
|
+
8
|
|
114
|
+
${s}
|
|
115
|
+
90
|
|
116
|
+
4
|
|
117
|
+
70
|
|
118
|
+
1
|
|
119
|
+
10
|
|
120
|
+
${a*n}
|
|
121
|
+
20
|
|
122
|
+
${r*n}
|
|
123
|
+
10
|
|
124
|
+
${(a+i)*n}
|
|
125
|
+
20
|
|
126
|
+
${r*n}
|
|
127
|
+
10
|
|
128
|
+
${(a+i)*n}
|
|
129
|
+
20
|
|
130
|
+
${(r+l)*n}
|
|
131
|
+
10
|
|
132
|
+
${a*n}
|
|
133
|
+
20
|
|
134
|
+
${(r+l)*n}
|
|
135
|
+
`}return""}function Jn(t){let s=1/0,n=1/0,o=-1/0,a=-1/0;for(const r of t){r.bounds&&(s=Math.min(s,r.bounds.x),n=Math.min(n,r.bounds.y),o=Math.max(o,r.bounds.x+r.bounds.width),a=Math.max(a,r.bounds.y+r.bounds.height));for(const i of r.layers)for(const l of i.objects){l.bounds&&(s=Math.min(s,l.bounds.x),n=Math.min(n,l.bounds.y),o=Math.max(o,l.bounds.x+l.bounds.width),a=Math.max(a,l.bounds.y+l.bounds.height));const h=l;if(h.boundary)for(const b of h.boundary)s=Math.min(s,b.x),n=Math.min(n,b.y),o=Math.max(o,b.x),a=Math.max(a,b.y)}}return isFinite(s)||(s=0),isFinite(n)||(n=0),isFinite(o)||(o=1e3),isFinite(a)||(a=800),{minX:s,minY:n,maxX:o,maxY:a}}function Qn(t,s){const{floorIds:n,layerNames:o}=s;let a=t.floors;return n&&n.length>0&&(a=a.filter(r=>n.includes(r.id))),o&&o.length>0&&(a=a.map(r=>({...r,layers:r.layers.filter(i=>o.includes(i.name))}))),{...t,floors:a}}function fs(t,s){const{layerNames:n,includeGrid:o,includeDimensions:a}=s;return t==="grid"&&!o||(t==="dimensions"||t==="annotations")&&a===!1?!1:n&&n.length>0?n.includes(t):!0}function ut(t){const s=t.data instanceof Blob?t.data:new Blob([t.data],{type:t.mimeType}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}async function eo(t,s,n={}){const{dpi:o=96,backgroundColor:a="#ffffff"}=n,r=new XMLSerializer().serializeToString(t),i=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(i);return new Promise((h,b)=>{const d=new Image;d.onload=()=>{const x=o/96,v=document.createElement("canvas");v.width=d.width*x,v.height=d.height*x;const y=v.getContext("2d");if(!y){b(new Error("Could not get canvas context"));return}y.fillStyle=a,y.fillRect(0,0,v.width,v.height),y.scale(x,x),y.drawImage(d,0,0),v.toBlob(_=>{if(URL.revokeObjectURL(l),!_){b(new Error("Could not create PNG blob"));return}h({format:"png",filename:s.endsWith(".png")?s:`${s}.png`,mimeType:"image/png",data:_,size:_.size})},"image/png")},d.onerror=()=>{URL.revokeObjectURL(l),b(new Error("Failed to load SVG for PNG export"))},d.src=l})}function gs(t){const s=new Map;for(const n of t)n.status!=="error"&&(s.has(n.sourceId)||s.set(n.sourceId,[]),s.get(n.sourceId).push({deviceId:n.targetId,connection:n}),s.has(n.targetId)||s.set(n.targetId,[]),s.get(n.targetId).push({deviceId:n.sourceId,connection:n}));return s}function to(t,s,n,o="latency"){const a=gs(t);if(!a.has(s)||!a.has(n))return null;const r=new Map,i=new Map,l=new Set,h=[];for(const _ of a.keys())r.set(_,1/0),i.set(_,null);for(r.set(s,0),h.push({deviceId:s,distance:0});h.length>0;){h.sort((p,C)=>p.distance-C.distance);const _=h.shift();if(l.has(_.deviceId))continue;if(l.add(_.deviceId),_.deviceId===n)break;const f=a.get(_.deviceId)??[];for(const p of f){if(l.has(p.deviceId))continue;let C;switch(o){case"latency":C=p.connection.latency??1;break;case"hops":C=1;break;case"bandwidth":C=1/(p.connection.bandwidth??1);break}const L=r.get(_.deviceId)+C;L<r.get(p.deviceId)&&(r.set(p.deviceId,L),i.set(p.deviceId,{deviceId:_.deviceId,connection:p.connection}),h.push({deviceId:p.deviceId,distance:L}))}}if(!i.has(n)||r.get(n)===1/0)return null;const b=[];let d=0,x=1/0,v="active",y=n;for(;y&&i.get(y);){const _=i.get(y);b.unshift(_.connection.id),d+=_.connection.latency??0,_.connection.bandwidth!==void 0&&(x=Math.min(x,_.connection.bandwidth)),_.connection.status==="error"?v="error":_.connection.status==="degraded"&&v!=="error"?v="degraded":_.connection.status==="inactive"&&v==="active"&&(v="inactive"),y=_.deviceId}return{id:`path-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,startDeviceId:s,endDeviceId:n,connectionIds:b,totalLatency:d,bottleneckBandwidth:x===1/0?0:x,status:v,isPrimary:!0}}function so(t,s,n,o=5){const a=[],r=gs(t);function i(l,h,b,d){if(a.length>=o)return;if(l===h&&d.length>0){let v=0,y=1/0,_="active";for(const f of d)v+=f.latency??0,f.bandwidth!==void 0&&(y=Math.min(y,f.bandwidth)),f.status==="error"?_="error":f.status==="degraded"&&_!=="error"&&(_="degraded");a.push({id:`path-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,startDeviceId:s,endDeviceId:n,connectionIds:d.map(f=>f.id),totalLatency:v,bottleneckBandwidth:y===1/0?0:y,status:_,isPrimary:a.length===0});return}b.add(l);const x=r.get(l)??[];for(const v of x)b.has(v.deviceId)||i(v.deviceId,h,new Set(b),[...d,v.connection])}return i(s,n,new Set,[]),a}function no(t){var h,b;const s=[],n=t.split(/\r?\n/);let o=0,a=!1,r=null,i=[],l=null;for(;o<n.length;){const d=parseInt(((h=n[o])==null?void 0:h.trim())??"",10),x=((b=n[o+1])==null?void 0:b.trim())??"";if(o+=2,d===2&&x==="ENTITIES"){a=!0;continue}if(d===0&&x==="ENDSEC"&&a){r!=null&&r.type&&(i.length>0&&(r.vertices=[...i]),s.push(r)),a=!1;continue}if(a){if(d===0){r!=null&&r.type&&(i.length>0&&(r.vertices=[...i]),s.push(r)),r={type:x,layer:"0"},i=[],l=null;continue}if(r)switch(d){case 8:r.layer=x;break;case 5:r.handle=x;break;case 10:l=parseFloat(x);break;case 20:l!==null&&(i.push({x:l,y:parseFloat(x)}),r.position||(r.position={x:l,y:parseFloat(x)}),l=null);break;case 11:l=parseFloat(x);break;case 21:l!==null&&(i.push({x:l,y:parseFloat(x)}),l=null);break;case 40:(r.type==="CIRCLE"||r.type==="ARC")&&(r.radius=parseFloat(x));break;case 50:r.startAngle=parseFloat(x);break;case 51:r.endAngle=parseFloat(x);break;case 1:r.text=x;break;case 2:r.blockName=x;break;case 70:parseInt(x,10)&1&&(r.closed=!0);break}}}return s}function oo(t,s={}){var l,h;const n=Date.now(),o=[],a=[],r=s.scaleFactor??1,i=s.originOffset??{x:0,y:0};try{const b=no(t),d=[],x=[],v=[],y=new Set;let _=0;for(const p of b){if(y.add(p.layer),s.includeLayers&&!s.includeLayers.includes(p.layer)){_++;continue}if((l=s.excludeLayers)!=null&&l.includes(p.layer)){_++;continue}const C=((h=s.layerMappings)==null?void 0:h[p.layer])??p.layer;switch(p.type){case"LINE":if(p.vertices&&p.vertices.length>=2){const L=ge(p.vertices[0],r,i),I=ge(p.vertices[1],r,i);d.push({start:L,end:I,layer:C})}break;case"LWPOLYLINE":case"POLYLINE":if(p.vertices&&p.vertices.length>=2){const L=p.vertices.map(k=>ge(k,r,i));if(p.closed&&s.convertClosedPolylinesToZones){const k=ys(L),c=s.minZoneArea??.1;if(k>=c){x.push({name:C,boundary:L,layer:C});continue}}const I=p.closed?L.length:L.length-1;for(let k=0;k<I;k++){const c=L[k],g=L[(k+1)%L.length];d.push({start:c,end:g,layer:C})}}break;case"CIRCLE":if(p.position&&p.radius){const L=ge(p.position,r,i);v.push({type:"circle",position:L,layer:C,metadata:{radius:p.radius*r}})}break;case"INSERT":if(p.position&&p.blockName){const L=ge(p.position,r,i);v.push({type:"block-reference",position:L,layer:C,metadata:{blockName:p.blockName}})}break;default:_++,o.push({code:"UNSUPPORTED_ENTITY",message:`Unsupported DXF entity type: ${p.type}`,context:{type:p.type,layer:p.layer}})}}return{success:!0,document:bt(d,x,v,y,{name:"Imported DXF",sourceFormat:"dxf",units:s.defaultUnits??"metric"}),warnings:o,errors:a,stats:{wallsImported:d.length,zonesImported:x.length,objectsImported:v.length,layersFound:y.size,entitiesSkipped:_,importTimeMs:Date.now()-n}}}catch(b){return a.push({code:"PARSE_ERROR",message:b instanceof Error?b.message:"Unknown error parsing DXF",fatal:!0}),{success:!1,warnings:o,errors:a,stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:Date.now()-n}}}}function ao(t){const s=[];let n=[],o=0,a=0,r=0,i=0;const l=t.match(/[MmLlHhVvCcSsQqTtAaZz]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[];let h=0;for(;h<l.length;){const b=l[h];h++;const d=()=>{const x=parseFloat(l[h]??"0");return h++,x};switch(b){case"M":n.length>0&&(s.push(n),n=[]),o=d(),a=d(),r=o,i=a,n.push({x:o,y:a});break;case"m":n.length>0&&(s.push(n),n=[]),o+=d(),a+=d(),r=o,i=a,n.push({x:o,y:a});break;case"L":o=d(),a=d(),n.push({x:o,y:a});break;case"l":o+=d(),a+=d(),n.push({x:o,y:a});break;case"H":o=d(),n.push({x:o,y:a});break;case"h":o+=d(),n.push({x:o,y:a});break;case"V":a=d(),n.push({x:o,y:a});break;case"v":a+=d(),n.push({x:o,y:a});break;case"Z":case"z":n.length>0&&n.push({x:r,y:i}),o=r,a=i;break;case"C":d(),d(),d(),d(),o=d(),a=d(),n.push({x:o,y:a});break;case"c":d(),d(),d(),d(),o+=d(),a+=d(),n.push({x:o,y:a});break;case"Q":d(),d(),o=d(),a=d(),n.push({x:o,y:a});break;case"q":d(),d(),o+=d(),a+=d(),n.push({x:o,y:a});break}}return n.length>0&&s.push(n),s}function ro(t){let s=0,n=0,o=1;const a=t.match(/translate\s*\(\s*([-\d.]+)(?:\s*,?\s*([-\d.]+))?\s*\)/);a&&(s=parseFloat(a[1]),n=parseFloat(a[2]??"0"));const r=t.match(/scale\s*\(\s*([-\d.]+)(?:\s*,?\s*([-\d.]+))?\s*\)/);return r&&(o=parseFloat(r[1])),{translate:{x:s,y:n},scale:o}}function io(t,s={}){const n=Date.now(),o=[],a=[],r=s.scaleFactor??1,i=s.originOffset??{x:0,y:0};try{const l=[],h=[],b=[],d=new Set,x=/<path[^>]*\bd="([^"]+)"[^>]*>/gi;let v;for(;(v=x.exec(t))!==null;){const k=v[1],c=v[0],g=c.match(/\bid="([^"]+)"/),m=(g==null?void 0:g[1])??"default";d.add(m);const j=c.match(/\btransform="([^"]+)"/),E=j?ro(j[1]):{translate:{x:0,y:0},scale:1},F=ao(k);for(const de of F){if(de.length<2)continue;const ee=de.map(ue=>ge({x:ue.x*E.scale+E.translate.x,y:ue.y*E.scale+E.translate.y},r,i));if(Math.abs(ee[0].x-ee[ee.length-1].x)<.1&&Math.abs(ee[0].y-ee[ee.length-1].y)<.1&&s.convertClosedPolylinesToZones&&ys(ee)>=(s.minZoneArea??.1)){h.push({name:m,boundary:ee,layer:m});continue}for(let ue=0;ue<ee.length-1;ue++)l.push({start:ee[ue],end:ee[ue+1],layer:m})}}const y=/<line[^>]*\bx1="([^"]+)"[^>]*\by1="([^"]+)"[^>]*\bx2="([^"]+)"[^>]*\by2="([^"]+)"[^>]*>/gi;let _;for(;(_=y.exec(t))!==null;){const k=parseFloat(_[1]),c=parseFloat(_[2]),g=parseFloat(_[3]),m=parseFloat(_[4]),j=ge({x:k,y:c},r,i),E=ge({x:g,y:m},r,i);l.push({start:j,end:E,layer:"default"}),d.add("default")}const f=/<rect[^>]*\bx="([^"]+)"[^>]*\by="([^"]+)"[^>]*\bwidth="([^"]+)"[^>]*\bheight="([^"]+)"[^>]*>/gi;let p;for(;(p=f.exec(t))!==null;){const k=parseFloat(p[1]),c=parseFloat(p[2]),g=parseFloat(p[3]),m=parseFloat(p[4]),j=[ge({x:k,y:c},r,i),ge({x:k+g,y:c},r,i),ge({x:k+g,y:c+m},r,i),ge({x:k,y:c+m},r,i)];s.convertClosedPolylinesToZones?h.push({name:"rect",boundary:j,layer:"default"}):(l.push({start:j[0],end:j[1],layer:"default"}),l.push({start:j[1],end:j[2],layer:"default"}),l.push({start:j[2],end:j[3],layer:"default"}),l.push({start:j[3],end:j[0],layer:"default"})),d.add("default")}const C=/<circle[^>]*\bcx="([^"]+)"[^>]*\bcy="([^"]+)"[^>]*\br="([^"]+)"[^>]*>/gi;let L;for(;(L=C.exec(t))!==null;){const k=parseFloat(L[1]),c=parseFloat(L[2]),g=parseFloat(L[3]),m=ge({x:k,y:c},r,i);b.push({type:"circle",position:m,layer:"default",metadata:{radius:g*r}}),d.add("default")}return{success:!0,document:bt(l,h,b,d,{name:"Imported SVG",sourceFormat:"svg",units:s.defaultUnits??"metric"}),warnings:o,errors:a,stats:{wallsImported:l.length,zonesImported:h.length,objectsImported:b.length,layersFound:d.size,entitiesSkipped:0,importTimeMs:Date.now()-n}}}catch(l){return a.push({code:"PARSE_ERROR",message:l instanceof Error?l.message:"Unknown error parsing SVG",fatal:!0}),{success:!1,warnings:o,errors:a,stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:Date.now()-n}}}}function co(t,s={}){var l;const n=Date.now(),o=[],a=[],r=s.scaleFactor??1,i=s.originOffset??{x:0,y:0};try{const h=JSON.parse(t),b=[],d=[],x=[],v=new Set;let y=0;const _=h.type==="FeatureCollection"?h.features:[h];for(const p of _){const C=((l=p.properties)==null?void 0:l.layer)??"default";v.add(C);const L=p.geometry;switch(L.type){case"Point":{const I=L.coordinates,k=ge({x:I[0],y:I[1]},r,i);x.push({type:"marker",position:k,layer:C,metadata:{properties:p.properties}});break}case"LineString":{const I=L.coordinates;for(let k=0;k<I.length-1;k++){const c=ge({x:I[k][0],y:I[k][1]},r,i),g=ge({x:I[k+1][0],y:I[k+1][1]},r,i);b.push({start:c,end:g,layer:C})}break}case"MultiLineString":{const I=L.coordinates;for(const k of I)for(let c=0;c<k.length-1;c++){const g=ge({x:k[c][0],y:k[c][1]},r,i),m=ge({x:k[c+1][0],y:k[c+1][1]},r,i);b.push({start:g,end:m,layer:C})}break}case"Polygon":{const c=L.coordinates[0].map(g=>ge({x:g[0],y:g[1]},r,i));d.push({name:C,boundary:c,layer:C});break}case"MultiPolygon":{const I=L.coordinates;for(const k of I){const g=k[0].map(m=>ge({x:m[0],y:m[1]},r,i));d.push({name:C,boundary:g,layer:C})}break}default:y++,o.push({code:"UNSUPPORTED_GEOMETRY",message:`Unsupported GeoJSON geometry: ${L.type}`})}}return{success:!0,document:bt(b,d,x,v,{name:"Imported GeoJSON",sourceFormat:"geojson",units:s.defaultUnits??"metric"}),warnings:o,errors:a,stats:{wallsImported:b.length,zonesImported:d.length,objectsImported:x.length,layersFound:v.size,entitiesSkipped:y,importTimeMs:Date.now()-n}}}catch(h){return a.push({code:"PARSE_ERROR",message:h instanceof Error?h.message:"Unknown error parsing GeoJSON",fatal:!0}),{success:!1,warnings:o,errors:a,stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:Date.now()-n}}}}function lo(t,s={}){const n=Date.now(),o=[],a=[];o.push({code:"LIMITED_IFC_SUPPORT",message:"IFC import is limited. For full support, use a dedicated IFC library like web-ifc."});try{const r=[],i=[],l=[],h=new Set;let b=0;const d=t.split(/\r?\n/),x=new Map;for(const y of d){const _=y.match(/^#(\d+)\s*=\s*(\w+)\s*\((.+)\)\s*;?$/);_&&x.set(`#${_[1]}`,{type:_[2],params:_[3]})}for(const[y,_]of x)if(_.type==="IFCWALLSTANDARDCASE"||_.type==="IFCWALL"){h.add("Walls");const f=_.params.match(/'([^']+)'/),p=(f==null?void 0:f[1])??"Wall";o.push({code:"IFC_WALL_SIMPLIFIED",message:`Wall "${p}" (${y}) geometry simplified to placeholder`}),b++}else if(_.type==="IFCSPACE"){h.add("Spaces");const f=_.params.match(/'([^']+)'/),p=(f==null?void 0:f[1])??"Space";o.push({code:"IFC_SPACE_SIMPLIFIED",message:`Space "${p}" (${y}) geometry simplified to placeholder`}),b++}return{success:!0,document:bt(r,i,l,h,{name:"Imported IFC",sourceFormat:"ifc",units:s.defaultUnits??"metric"}),warnings:o,errors:a,stats:{wallsImported:r.length,zonesImported:i.length,objectsImported:l.length,layersFound:h.size,entitiesSkipped:b,importTimeMs:Date.now()-n}}}catch(r){return a.push({code:"PARSE_ERROR",message:r instanceof Error?r.message:"Unknown error parsing IFC",fatal:!0}),{success:!1,warnings:o,errors:a,stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:Date.now()-n}}}}function uo(t,s,n={}){switch(s){case"dxf":return oo(t,n);case"svg":return io(t,n);case"geojson":return co(t,n);case"ifc":return lo(t,n);default:return{success:!1,warnings:[],errors:[{code:"UNSUPPORTED_FORMAT",message:`Unsupported import format: ${s}`,fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}}}}function ho(t,s){const n=t.toLowerCase().split(".").pop();switch(n){case"dxf":return"dxf";case"svg":return"svg";case"geojson":case"json":return s!=null&&s.includes('"type"')&&(s.includes('"Feature"')||s.includes('"FeatureCollection"'))||n==="geojson"?"geojson":null;case"ifc":return"ifc";default:if(s){if(s.includes("ISO-10303-21")||s.includes("IFCPROJECT"))return"ifc";if(s.includes("<?xml")&&s.includes("<svg"))return"svg";if(s.includes("SECTION")&&s.includes("ENTITIES"))return"dxf"}return null}}async function mo(t,s={}){return new Promise(n=>{const o=new FileReader;o.onload=()=>{const a=o.result,r=s.format??ho(t.name,a);if(!r){n({success:!1,warnings:[],errors:[{code:"UNKNOWN_FORMAT",message:`Unable to detect format for file: ${t.name}`,fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}});return}n(uo(a,r,s))},o.onerror=()=>{n({success:!1,warnings:[],errors:[{code:"FILE_READ_ERROR",message:"Error reading file",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})},o.readAsText(t)})}function He(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ge(t,s,n){return{x:t.x*s+n.x,y:t.y*s+n.y}}function ys(t){let s=0;const n=t.length;for(let o=0;o<n;o++){const a=(o+1)%n;s+=t[o].x*t[a].y,s-=t[a].x*t[o].y}return Math.abs(s/2)}function Yt(t){if(t.length===0)return{x:0,y:0,width:0,height:0};let s=1/0,n=1/0,o=-1/0,a=-1/0;for(const r of t)r.x<s&&(s=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>a&&(a=r.y);return{x:s,y:n,width:o-s,height:a-n}}function Zt(t){let s=0;for(let o=0;o<t.length;o++)s=t.charCodeAt(o)+((s<<5)-s);return`hsl(${Math.abs(s)%360}, 60%, 50%)`}function Xt(t){return{position:t,rotation:0,scale:{x:1,y:1}}}function bt(t,s,n,o,a){const r=new Date().toISOString(),i=`floor-${He()}`,l=[];for(const f of t)l.push(f.start,f.end);for(const f of s)l.push(...f.boundary);for(const f of n)l.push(f.position);const h=Yt(l),b=t.map(f=>({id:`wall-${He()}`,type:"wall",category:"building",name:"Wall",transform:Xt(f.start),bounds:Yt([f.start,f.end]),layer:f.layer,locked:!1,visible:!0,metadata:{end:f.end,thickness:f.thickness??.15,importedAt:r},childIds:[]})),d=n.map(f=>({id:`obj-${He()}`,type:f.type,category:"annotation",name:f.type,transform:Xt(f.position),bounds:{x:f.position.x-10,y:f.position.y-10,width:20,height:20},layer:f.layer,locked:!1,visible:!0,metadata:{...f.metadata,importedAt:r},childIds:[]})),x=Array.from(o).map(f=>({id:`layer-${He()}`,name:f,type:f.toLowerCase().includes("wall")?"walls":"custom",visible:!0,locked:!1,opacity:1,color:Zt(f),objects:[...b.filter(p=>p.layer===f),...d.filter(p=>p.layer===f)]})),v={id:i,name:"Imported Floor",level:0,elevation:0,ceilingHeight:2.7,bounds:h,layers:x},y=s.map(f=>({id:`zone-${He()}`,name:f.name,type:"custom",boundary:f.boundary,floorId:i,roomIds:[],color:Zt(f.name)})),_={$schema:"https://nice2dev.com/schemas/nsp-v1.json",version:"1.0.0",type:"floor-plan",metadata:{id:`doc-${He()}`,name:a.name,description:`Imported from ${a.sourceFormat.toUpperCase()}`,created:r,modified:r,tags:["imported",a.sourceFormat]},floors:[v],settings:{units:a.units,scale:50,grid:{visible:!0,size:.5,snapEnabled:!0},defaultWallHeight:2.7,defaultWallThickness:.15,precision:2}};return _.zones=y,_}const po=10,_o=8;class fo{constructor(s,n=po){ct(this,"root");ct(this,"maxItems");ct(this,"itemMap",new Map);this.root={bounds:s,items:[],children:null},this.maxItems=n}insert(s){this.itemMap.set(s.id,s),this.insertIntoNode(this.root,s,0)}remove(s){const n=this.itemMap.get(s);return n?(this.itemMap.delete(s),this.removeFromNode(this.root,n)):!1}update(s,n){const o=this.itemMap.get(s);return o?(this.remove(s),o.bounds=n,this.insert(o),!0):!1}query(s){const n=[];return this.queryNode(this.root,s,n),n}getAll(){return Array.from(this.itemMap.values())}get(s){return this.itemMap.get(s)}get size(){return this.itemMap.size}clear(){this.itemMap.clear(),this.root.items=[],this.root.children=null}rebuild(){const s=Array.from(this.itemMap.values());this.root.items=[],this.root.children=null;for(const n of s)this.insertIntoNode(this.root,n,0)}insertIntoNode(s,n,o){if(s.children){const a=this.getChildIndex(s,n.bounds);if(a!==-1){this.insertIntoNode(s.children[a],n,o+1);return}s.items.push(n);return}if(s.items.push(n),s.items.length>this.maxItems&&o<_o){this.split(s);const a=[...s.items];s.items=[];for(const r of a)this.insertIntoNode(s,r,o)}}removeFromNode(s,n){const o=s.items.findIndex(a=>a.id===n.id);if(o!==-1)return s.items.splice(o,1),!0;if(s.children){for(const a of s.children)if(this.boundsIntersect(a.bounds,n.bounds)&&this.removeFromNode(a,n))return!0}return!1}queryNode(s,n,o){for(const a of s.items)this.boundsIntersect(a.bounds,n)&&o.push(a);if(s.children)for(const a of s.children)this.boundsIntersect(a.bounds,n)&&this.queryNode(a,n,o)}split(s){const{x:n,y:o,width:a,height:r}=s.bounds,i=a/2,l=r/2;s.children=[{bounds:{x:n,y:o,width:i,height:l},items:[],children:null},{bounds:{x:n+i,y:o,width:i,height:l},items:[],children:null},{bounds:{x:n,y:o+l,width:i,height:l},items:[],children:null},{bounds:{x:n+i,y:o+l,width:i,height:l},items:[],children:null}]}getChildIndex(s,n){if(!s.children)return-1;const o=s.bounds.x+s.bounds.width/2,a=s.bounds.y+s.bounds.height/2,r=n.x+n.width<=o,i=n.x>=o,l=n.y+n.height<=a,h=n.y>=a;return l&&r?0:l&&i?1:h&&r?2:h&&i?3:-1}boundsIntersect(s,n){return s.x<n.x+n.width&&s.x+s.width>n.x&&s.y<n.y+n.height&&s.y+s.height>n.y}}function go(t,s=100){let n=1/0,o=1/0,a=-1/0,r=-1/0;for(const h of t){const{x:b,y:d}=h.position,{width:x=20,height:v=20}=h.size??{};n=Math.min(n,b-x/2),o=Math.min(o,d-v/2),a=Math.max(a,b+x/2),r=Math.max(r,d+v/2)}Number.isFinite(n)||(n=o=0,a=r=1e3);const i={x:n-s,y:o-s,width:a-n+s*2,height:r-o+s*2},l=new fo(i);for(const h of t){const{x:b,y:d}=h.position,{width:x=20,height:v=20}=h.size??{};l.insert({id:h.id,bounds:{x:b-x/2,y:d-v/2,width:x,height:v},data:h.data})}return l}function yo(t,s,n=100){const o=(s.width+n*2)/t.zoom,a=(s.height+n*2)/t.zoom,r=(-t.pan.x-n)/t.zoom,i=(-t.pan.y-n)/t.zoom;return{x:r,y:i,width:o,height:a}}function xo(t,s=200){return t>=s}function bo(t,s,n){const o=t-s;return{total:t,visible:s,culled:o,cullPercentage:t>0?Math.round(o/t*100):0,zoom:n.zoom}}const vo="_overlay_18dh4_9",jo="_dialog_18dh4_55",wo="_header_18dh4_103",No="_title_18dh4_119",ko="_closeButton_18dh4_133",Io="_content_18dh4_167",Co="_preview_18dh4_183",So="_previewCanvas_18dh4_203",zo="_previewSvg_18dh4_221",Lo="_info_18dh4_231",$o="_section_18dh4_241",To="_sectionTitle_18dh4_249",Mo="_statGrid_18dh4_269",Bo="_stat_18dh4_269",Po="_statLabel_18dh4_293",Eo="_statValue_18dh4_305",Oo="_warningsList_18dh4_317",Ao="_warning_18dh4_317",Do="_warningIcon_18dh4_361",Ro="_error_18dh4_371",Fo="_errorIcon_18dh4_403",Wo="_footer_18dh4_413",Go="_cancelButton_18dh4_433",qo="_confirmButton_18dh4_465",Vo="_noWarnings_18dh4_507",Uo="_layersList_18dh4_519",Ho="_layer_18dh4_519",Yo="_layerIcon_18dh4_561",Zo="_layerName_18dh4_569",Xo="_layerCount_18dh4_579",V={overlay:vo,dialog:jo,header:wo,title:No,closeButton:ko,content:Io,preview:Co,previewCanvas:So,previewSvg:zo,info:Lo,section:$o,sectionTitle:To,statGrid:Mo,stat:Bo,statLabel:Po,statValue:Eo,warningsList:Oo,warning:Ao,warningIcon:Do,error:Ro,errorIcon:Fo,footer:Wo,cancelButton:Go,confirmButton:qo,noWarnings:Vo,layersList:Uo,layer:Ho,layerIcon:Yo,layerName:Zo,layerCount:Xo},Ko=()=>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"})}),Kt=()=>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"})}),Jt=()=>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"})}),Qt=()=>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"})}),Jo=()=>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 Qo({result:t,onConfirm:s,onCancel:n}){const o=t.document,a=u.useMemo(()=>{var L,I;if(!((L=o==null?void 0:o.floors)!=null&&L.length))return null;const d=o.floors[0],x=(d==null?void 0:d.layers)||[],v=x.flatMap(k=>k.objects);let y=1/0,_=1/0,f=-1/0,p=-1/0;for(const k of v)k.bounds?(y=Math.min(y,k.bounds.x),_=Math.min(_,k.bounds.y),f=Math.max(f,k.bounds.x+k.bounds.width),p=Math.max(p,k.bounds.y+k.bounds.height)):(I=k.transform)!=null&&I.position&&(y=Math.min(y,k.transform.position.x),_=Math.min(_,k.transform.position.y),f=Math.max(f,k.transform.position.x),p=Math.max(p,k.transform.position.y));isFinite(y)||(d!=null&&d.bounds?(y=d.bounds.x,_=d.bounds.y,f=d.bounds.x+d.bounds.width,p=d.bounds.y+d.bounds.height):(y=0,_=0,f=1e3,p=800));const C=20;return{viewBox:{x:y-C,y:_-C,width:f-y+C*2,height:p-_+C*2},objects:v,layers:x}},[o]),r=u.useMemo(()=>{if(!a||!o)return null;const{viewBox:d,objects:x}=a,v=[],y=50,_=`
|
|
136
|
+
<pattern id="grid" width="${y}" height="${y}" patternUnits="userSpaceOnUse">
|
|
137
|
+
<path d="M ${y} 0 L 0 0 0 ${y}" fill="none" stroke="var(--nice-border, #e2e8f0)" strokeWidth="0.5"/>
|
|
4
138
|
</pattern>
|
|
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;
|
|
139
|
+
`;return x.forEach((f,p)=>{if(f.type==="wall"&&f.bounds)v.push(e.jsx("rect",{x:f.bounds.x,y:f.bounds.y,width:f.bounds.width,height:f.bounds.height,fill:"var(--nice-text-secondary, #475569)",stroke:"var(--nice-text, #334155)",strokeWidth:"1"},`wall-${p}`));else if(f.type==="zone"&&f.boundary){const L=f.boundary.map((I,k)=>`${k===0?"M":"L"} ${I.x} ${I.y}`).join(" ")+" Z";v.push(e.jsx("path",{d:L,fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:"1"},`zone-${p}`))}else if(f.type==="room"&&f.boundary){const L=f.boundary.map((I,k)=>`${k===0?"M":"L"} ${I.x} ${I.y}`).join(" ")+" Z";v.push(e.jsx("path",{d:L,fill:"var(--nice-success-tint-15, rgba(34, 197, 94, 0.15))",stroke:"var(--nice-success, #22c55e)",strokeWidth:"1"},`room-${p}`))}else f.bounds&&v.push(e.jsx("rect",{x:f.bounds.x,y:f.bounds.y,width:f.bounds.width,height:f.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-${p}`))}),e.jsxs("svg",{viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,className:V.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:_}}),e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"url(#grid)"}),v]})},[a,o]),i=u.useCallback(d=>{d.key==="Escape"&&n()},[n]),l=u.useCallback(d=>{d.target===d.currentTarget&&n()},[n]),h=t.errors.some(d=>d.fatal),b=t.errors.filter(d=>!d.fatal);return e.jsx("div",{className:V.overlay,onClick:l,onKeyDown:i,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:V.dialog,children:[e.jsxs("div",{className:V.header,children:[e.jsx("h2",{id:"import-preview-title",className:V.title,children:"Import Preview"}),e.jsx("button",{className:V.closeButton,onClick:n,title:"Close","aria-label":"Close dialog",children:e.jsx(Ko,{})})]}),e.jsxs("div",{className:V.content,children:[e.jsx("div",{className:V.preview,children:r||e.jsx("div",{className:V.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:V.info,children:[e.jsxs("div",{className:V.section,children:[e.jsxs("h3",{className:V.sectionTitle,children:[e.jsx(Jo,{})," Import Statistics"]}),e.jsxs("div",{className:V.statGrid,children:[e.jsxs("div",{className:V.stat,children:[e.jsx("div",{className:V.statLabel,children:"Walls"}),e.jsx("div",{className:V.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:V.stat,children:[e.jsx("div",{className:V.statLabel,children:"Zones"}),e.jsx("div",{className:V.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:V.stat,children:[e.jsx("div",{className:V.statLabel,children:"Objects"}),e.jsx("div",{className:V.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:V.stat,children:[e.jsx("div",{className:V.statLabel,children:"Skipped"}),e.jsx("div",{className:V.statValue,children:t.stats.entitiesSkipped})]})]})]}),a&&a.layers.length>0&&e.jsxs("div",{className:V.section,children:[e.jsxs("h3",{className:V.sectionTitle,children:[e.jsx(Qt,{})," Layers (",a.layers.length,")"]}),e.jsxs("ul",{className:V.layersList,children:[a.layers.slice(0,6).map((d,x)=>{var v;return e.jsxs("li",{className:V.layer,children:[e.jsx("span",{className:V.layerIcon,children:e.jsx(Qt,{})}),e.jsx("span",{className:V.layerName,children:d.name}),e.jsx("span",{className:V.layerCount,children:((v=d.objects)==null?void 0:v.length)||0})]},d.id||x)}),a.layers.length>6&&e.jsx("li",{className:V.layer,children:e.jsxs("span",{className:V.layerName,children:["+",a.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:V.section,children:[e.jsxs("h3",{className:V.sectionTitle,children:[e.jsx(Kt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:V.warningsList,children:[t.warnings.slice(0,5).map((d,x)=>e.jsxs("li",{className:V.warning,children:[e.jsx("span",{className:V.warningIcon,children:e.jsx(Kt,{})}),e.jsx("span",{children:d.message})]},x)),t.warnings.length>5&&e.jsxs("li",{className:V.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),b.length>0&&e.jsxs("div",{className:V.section,children:[e.jsxs("h3",{className:V.sectionTitle,children:[e.jsx(Jt,{})," Errors (",b.length,")"]}),e.jsx("ul",{className:V.warningsList,children:b.slice(0,5).map((d,x)=>e.jsxs("li",{className:V.error,children:[e.jsx("span",{className:V.errorIcon,children:e.jsx(Jt,{})}),e.jsx("span",{children:d.message})]},x))})]}),t.warnings.length===0&&b.length===0&&e.jsx("div",{className:V.section,children:e.jsxs("p",{className:V.noWarnings,children:[e.jsx(z.NiceIcon,{name:"check",size:14})," No warnings or errors found"]})})]})]}),e.jsxs("div",{className:V.footer,children:[e.jsx("button",{className:V.cancelButton,onClick:n,children:"Cancel"}),e.jsx("button",{className:V.confirmButton,onClick:s,disabled:h,children:h?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const ea="_overlay_332j1_9",ta="_dialog_332j1_55",sa="_header_332j1_103",na="_title_332j1_119",oa="_closeButton_332j1_133",aa="_content_332j1_167",ra="_description_332j1_179",ia="_mappingTable_332j1_191",ca="_sourceLayer_332j1_241",la="_layerIcon_332j1_253",da="_layerName_332j1_261",ua="_objectCount_332j1_273",ha="_targetSelect_332j1_285",ma="_skipOption_332j1_327",pa="_arrowIcon_332j1_337",_a="_presets_332j1_347",fa="_presetButton_332j1_361",ga="_footer_332j1_393",ya="_footerLeft_332j1_413",xa="_checkbox_332j1_425",ba="_checkboxLabel_332j1_437",va="_footerRight_332j1_447",ja="_cancelButton_332j1_457",wa="_confirmButton_332j1_489",oe={overlay:ea,dialog:ta,header:sa,title:na,closeButton:oa,content:aa,description:ra,mappingTable:ia,sourceLayer:ca,layerIcon:la,layerName:da,objectCount:ua,targetSelect:ha,skipOption:ma,arrowIcon:pa,presets:_a,presetButton:fa,footer:ga,footerLeft:ya,checkbox:xa,checkboxLabel:ba,footerRight:va,cancelButton:ja,confirmButton:wa},es=()=>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"})}),Na=()=>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"})}),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"})}),ts={"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 Ia(t){if(!t.document)return[];const s=[];for(const n of t.document.floors)for(const o of n.layers)s.push({id:o.id,name:o.name,type:o.type,objectCount:o.objects.length});return s}function Ca(t){if(!t)return[];const s=[];for(const n of t.floors)for(const o of n.layers)s.find(a=>a.id===o.id)||s.push(o);return s}function ss(t,s){const n=new Map;for(const o of t){const a=s.find(l=>l.type===o.type);if(a){n.set(o.id,a.id);continue}const r=o.name.toLowerCase(),i=s.find(l=>l.name.toLowerCase()===r);if(i){n.set(o.id,i.id);continue}n.set(o.id,o.id)}return n}const Sa=({importResult:t,existingDocument:s,onConfirm:n,onCancel:o})=>{const a=u.useMemo(()=>Ia(t),[t]),r=u.useMemo(()=>Ca(s),[s]),[i,l]=u.useState(()=>ss(a,r)),[h,b]=u.useState(!0),d=u.useCallback((f,p)=>{l(C=>{const L=new Map(C);return L.set(f,p),L})},[]),x=u.useCallback(f=>{const p=new Map;switch(f){case"auto":l(ss(a,r));return;case"skip-all":for(const C of a)p.set(C.id,"skip");break;case"preserve":for(const C of a)p.set(C.id,C.id);break}l(p)},[a,r]),v=u.useCallback(()=>{n(i,h)},[i,h,n]),y=u.useCallback(f=>{f.key==="Escape"?o():f.key==="Enter"&&(f.ctrlKey||f.metaKey)&&v()},[o,v]),_=u.useCallback(f=>{f.target===f.currentTarget&&o()},[o]);return a.length===0?e.jsx("div",{className:oe.overlay,onClick:_,onKeyDown:y,tabIndex:-1,children:e.jsxs("div",{className:oe.dialog,children:[e.jsxs("div",{className:oe.header,children:[e.jsx("h2",{className:oe.title,children:"Mapowanie warstw"}),e.jsx("button",{className:oe.closeButton,onClick:o,children:e.jsx(es,{})})]}),e.jsx("div",{className:oe.content,children:e.jsx("p",{className:oe.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:oe.footer,children:[e.jsx("div",{className:oe.footerLeft}),e.jsx("div",{className:oe.footerRight,children:e.jsx("button",{className:oe.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:oe.overlay,onClick:_,onKeyDown:y,tabIndex:-1,children:e.jsxs("div",{className:oe.dialog,children:[e.jsxs("div",{className:oe.header,children:[e.jsx("h2",{className:oe.title,children:"Mapowanie warstw"}),e.jsx("button",{className:oe.closeButton,onClick:o,children:e.jsx(es,{})})]}),e.jsxs("div",{className:oe.content,children:[e.jsx("p",{className:oe.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:oe.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:a.map(f=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:oe.sourceLayer,children:[e.jsx("span",{className:oe.layerIcon,children:e.jsx(Na,{})}),e.jsx("span",{className:oe.layerName,children:f.name}),e.jsxs("span",{className:oe.objectCount,children:["(",f.objectCount," ",f.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:oe.arrowIcon,children:e.jsx(ka,{})}),e.jsx("td",{children:e.jsxs("select",{className:oe.targetSelect,value:i.get(f.id)||f.id,onChange:p=>d(f.id,p.target.value),children:[e.jsx("option",{value:"skip",className:oe.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:f.id,children:["Utwórz: ",f.name," (",ts[f.type],")"]}),r.map(p=>e.jsxs("option",{value:p.id,children:[p.name," (",ts[p.type],")"]},p.id))]})})]},f.id))})]}),e.jsxs("div",{className:oe.presets,children:[e.jsx("button",{className:oe.presetButton,onClick:()=>x("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:oe.presetButton,onClick:()=>x("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:oe.presetButton,onClick:()=>x("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:oe.footer,children:[e.jsxs("div",{className:oe.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:oe.checkbox,checked:h,onChange:f=>b(f.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:oe.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:oe.footerRight,children:[e.jsx("button",{className:oe.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:oe.confirmButton,onClick:v,children:"Zastosuj mapowanie"})]})]})]})})},za="_root_4ino1_9",La="_header_4ino1_21",$a="_title_4ino1_31",Ta="_layerList_4ino1_45",Ma="_layerItem_4ino1_55",Ba="_hidden_4ino1_83",Pa="_locked_4ino1_91",Ea="_visibilityBtn_4ino1_99",Oa="_lockBtn_4ino1_101",Aa="_layerIcon_4ino1_139",Da="_layerName_4ino1_147",Ra="_opacitySlider_4ino1_157",Ie={root:za,header:La,title:$a,layerList:Ta,layerItem:Ma,hidden:Ba,locked:Pa,visibilityBtn:Ea,lockBtn:Oa,layerIcon:Aa,layerName:Da,opacitySlider:Ra},Fa={"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"}},xs=({layers:t,onVisibilityToggle:s,onLockToggle:n,onOpacityChange:o,className:a})=>{const r=[...t].sort((i,l)=>l.zIndex-i.zIndex);return e.jsxs("div",{className:`${Ie.root} ${a??""}`,children:[e.jsx("div",{className:Ie.header,children:e.jsx("h3",{className:Ie.title,children:"Layers"})}),e.jsx("div",{className:Ie.layerList,children:r.map(i=>{const l=Fa[i.type]||{icon:"box",label:i.type};return e.jsxs("div",{className:`${Ie.layerItem} ${i.visible?"":Ie.hidden} ${i.locked?Ie.locked:""}`,children:[e.jsx("button",{className:Ie.visibilityBtn,onClick:()=>s(i.type),title:i.visible?"Hide layer":"Show layer",children:e.jsx(z.NiceIcon,{name:i.visible?"eye":"eye-off",size:16})}),e.jsx("button",{className:Ie.lockBtn,onClick:()=>n(i.type),title:i.locked?"Unlock layer":"Lock layer",children:e.jsx(z.NiceIcon,{name:"lock",size:16})}),e.jsx("span",{className:Ie.layerIcon,children:e.jsx(z.NiceIcon,{name:l.icon,size:16})}),e.jsx("span",{className:Ie.layerName,children:l.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:i.opacity,onChange:h=>o(i.type,parseFloat(h.target.value)),className:Ie.opacitySlider,title:`Opacity: ${Math.round(i.opacity*100)}%`})]},i.type)})})]})},Wa="_root_1lufq_9",Ga="_svg_1lufq_31",qa="_viewportRect_1lufq_41",Va="_zoomIndicator_1lufq_49",ht={root:Wa,svg:Ga,viewportRect:qa,zoomIndicator:Va},bs=({document:t,activeFloorId:s,viewport:n,onViewportChange:o,size:a=150,className:r})=>{var I,k;const i=u.useRef(null),l=u.useMemo(()=>t.floors.find(c=>c.id===s)??t.floors[0]??null,[t,s]);if(!l)return null;const h=((I=l.dimensions)==null?void 0:I.width)??1e3,b=((k=l.dimensions)==null?void 0:k.height)??800,d=Math.min(a/h,a/b)*.9,x=h*d,v=b*d,y=a/n.zoom*d,_=a/n.zoom*d,f=-n.pan.x/n.zoom*d,p=-n.pan.y/n.zoom*d,C=u.useCallback(c=>{var de;const g=(de=i.current)==null?void 0:de.getBoundingClientRect();if(!g)return;const m=(c.clientX-g.left-(a-x)/2)/d,j=(c.clientY-g.top-(a-v)/2)/d,E=-(m-a/n.zoom/2)*n.zoom,F=-(j-a/n.zoom/2)*n.zoom;o({pan:{x:E,y:F}})},[d,a,x,v,n.zoom,o]),L=u.useMemo(()=>{const c=l.layers.find(g=>g.name==="zones");return c?c.objects.map(g=>{const m=g;if(!m.polygon||m.polygon.length<3)return null;const j=m.polygon.map((E,F)=>`${F===0?"M":"L"}${E.x*d},${E.y*d}`).join(" ")+" Z";return e.jsx("path",{d:j,fill:m.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.6,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:.5},m.id)}):null},[l,d]);return e.jsxs("div",{className:`${ht.root} ${r??""}`,children:[e.jsxs("svg",{ref:i,width:a,height:a,viewBox:`0 0 ${a} ${a}`,className:ht.svg,onClick:C,children:[e.jsx("rect",{x:(a-x)/2,y:(a-v)/2,width:x,height:v,fill:"var(--nice-text, #1e293b)",stroke:"var(--nice-text-secondary, #475569)",strokeWidth:1}),e.jsx("g",{transform:`translate(${(a-x)/2}, ${(a-v)/2})`,children:L}),e.jsx("rect",{x:(a-x)/2+f,y:(a-v)/2+p,width:Math.min(y,x),height:Math.min(_,v),fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:1.5,rx:2,className:ht.viewportRect})]}),e.jsxs("div",{className:ht.zoomIndicator,children:[Math.round(n.zoom*100),"%"]})]})},Ua="_panel_716sa_9",Ha="_header_716sa_27",Ya="_title_716sa_45",Za="_closeButton_716sa_59",Xa="_content_716sa_85",Ka="_endpointSection_716sa_99",Ja="_endpointLabel_716sa_107",Qa="_endpointSelect_716sa_123",er="_optionsSection_716sa_157",tr="_metricButton_716sa_169",sr="_metricButtonActive_716sa_205",nr="_analyzeButton_716sa_219",or="_resultsSection_716sa_267",ar="_resultsTitle_716sa_277",rr="_noResults_716sa_293",ir="_pathCard_716sa_309",cr="_pathCardSelected_716sa_333",lr="_pathCardHeader_716sa_343",dr="_pathCardTitle_716sa_361",ur="_pathBadge_716sa_373",hr="_badgePrimary_716sa_389",mr="_badgeAlternate_716sa_399",pr="_pathName_716sa_409",_r="_pathStatus_716sa_421",fr="_statusDot_716sa_435",gr="_statusActive_716sa_447",yr="_statusDegraded_716sa_453",xr="_statusInactive_716sa_459",br="_statusError_716sa_465",vr="_pathStats_716sa_475",jr="_statItem_716sa_489",wr="_statValue_716sa_497",Nr="_statLabel_716sa_509",kr="_pathVisualization_716sa_523",Ir="_pathDiagram_716sa_535",Cr="_pathNode_716sa_551",Sr="_pathNodeStart_716sa_583",zr="_pathNodeEnd_716sa_585",Lr="_pathLink_716sa_595",$r="_pathLinkLine_716sa_607",Tr="_showOnMapButton_716sa_621",Mr="_loading_716sa_657",Br="_spinner_716sa_671",Pr="_spin_716sa_671",G={panel:Ua,header:Ha,title:Ya,closeButton:Za,content:Xa,endpointSection:Ka,endpointLabel:Ja,endpointSelect:Qa,optionsSection:er,metricButton:tr,metricButtonActive:sr,analyzeButton:nr,resultsSection:or,resultsTitle:ar,noResults:rr,pathCard:ir,pathCardSelected:cr,pathCardHeader:lr,pathCardTitle:dr,pathBadge:ur,badgePrimary:hr,badgeAlternate:mr,pathName:pr,pathStatus:_r,statusDot:fr,statusActive:gr,statusDegraded:yr,statusInactive:xr,statusError:br,pathStats:vr,statItem:jr,statValue:wr,statLabel:Nr,pathVisualization:kr,pathDiagram:Ir,pathNode:Cr,pathNodeStart:Sr,pathNodeEnd:zr,pathLink:Lr,pathLinkLine:$r,showOnMapButton:Tr,loading:Mr,spinner:Br,spin:Pr},Er=()=>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"})}),Or=()=>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 Ar(t){switch(t){case"active":return"Aktywna";case"degraded":return"Degradacja";case"inactive":return"Nieaktywna";case"error":return"Błąd";default:return"Nieznany"}}function Dr(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function Rr(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const Fr=({document:t,connections:s,onHighlightPath:n,onClose:o})=>{const[a,r]=u.useState(""),[i,l]=u.useState(""),[h,b]=u.useState("latency"),[d,x]=u.useState([]),[v,y]=u.useState(null),[_,f]=u.useState(!1),p=u.useMemo(()=>{const c=[];for(const g of t.floors)for(const m of g.layers)if(m.type==="network"||m.type==="devices"||m.type==="infrastructure")for(const j of m.objects)c.push({id:j.id,name:j.name??j.id});return c},[t]),C=u.useCallback(c=>{var g;return((g=p.find(m=>m.id===c))==null?void 0:g.name)??c},[p]),L=u.useCallback(()=>{!a||!i||a===i||(f(!0),x([]),y(null),setTimeout(()=>{const c=to(s,a,i,h),g=so(s,a,i,5),m=[];c&&m.push(c);for(const j of g)m.some(E=>E.connectionIds.length===j.connectionIds.length&&E.connectionIds.every((F,de)=>j.connectionIds[de]===F))||m.push({...j,isPrimary:!1});x(m),m.length>0&&(y(m[0].id),n==null||n(m[0])),f(!1)},300))},[a,i,h,s,n]),I=u.useCallback(c=>{y(c.id),n==null||n(c)},[n]),k=u.useCallback(c=>{const g=[c.startDeviceId];for(const m of c.connectionIds){const j=s.find(E=>E.id===m);if(j){const E=g[g.length-1],F=j.sourceId===E?j.targetId:j.sourceId;g.includes(F)||g.push(F)}}return g},[s]);return e.jsxs("div",{className:G.panel,children:[e.jsxs("div",{className:G.header,children:[e.jsx("h3",{className:G.title,children:"Analiza ścieżki sieciowej"}),o&&e.jsx("button",{className:G.closeButton,onClick:o,children:e.jsx(Er,{})})]}),e.jsxs("div",{className:G.content,children:[e.jsxs("div",{className:G.endpointSection,children:[e.jsx("label",{className:G.endpointLabel,children:"Urządzenie źródłowe"}),e.jsxs("select",{className:G.endpointSelect,value:a,onChange:c=>r(c.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),p.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("div",{className:G.endpointSection,children:[e.jsx("label",{className:G.endpointLabel,children:"Urządzenie docelowe"}),e.jsxs("select",{className:G.endpointSelect,value:i,onChange:c=>l(c.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),p.filter(c=>c.id!==a).map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("div",{className:G.optionsSection,children:[e.jsx("button",{className:`${G.metricButton} ${h==="latency"?G.metricButtonActive:""}`,onClick:()=>b("latency"),children:"Latencja"}),e.jsx("button",{className:`${G.metricButton} ${h==="hops"?G.metricButtonActive:""}`,onClick:()=>b("hops"),children:"Hops"}),e.jsx("button",{className:`${G.metricButton} ${h==="bandwidth"?G.metricButtonActive:""}`,onClick:()=>b("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:G.analyzeButton,onClick:L,disabled:!a||!i||a===i||_,children:_?"Analizowanie...":"Analizuj ścieżkę"}),_?e.jsx("div",{className:G.loading,children:e.jsx("div",{className:G.spinner})}):d.length>0?e.jsxs("div",{className:G.resultsSection,children:[e.jsxs("div",{className:G.resultsTitle,children:["Znalezione ścieżki (",d.length,")"]}),d.map((c,g)=>{const m=k(c),j=v===c.id;return e.jsxs("div",{className:`${G.pathCard} ${j?G.pathCardSelected:""}`,onClick:()=>I(c),children:[e.jsxs("div",{className:G.pathCardHeader,children:[e.jsxs("div",{className:G.pathCardTitle,children:[e.jsx("span",{className:`${G.pathBadge} ${c.isPrimary?G.badgePrimary:G.badgeAlternate}`,children:c.isPrimary?"Optymalna":`Alt ${g}`}),e.jsxs("span",{className:G.pathName,children:[c.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:G.pathStatus,children:[e.jsx("span",{className:`${G.statusDot} ${G[`status${c.status.charAt(0).toUpperCase()+c.status.slice(1)}`]??""}`}),e.jsx("span",{children:Ar(c.status)})]})]}),e.jsxs("div",{className:G.pathStats,children:[e.jsxs("div",{className:G.statItem,children:[e.jsx("div",{className:G.statValue,children:Dr(c.totalLatency)}),e.jsx("div",{className:G.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:G.statItem,children:[e.jsx("div",{className:G.statValue,children:c.connectionIds.length}),e.jsx("div",{className:G.statLabel,children:"Hops"})]}),e.jsxs("div",{className:G.statItem,children:[e.jsx("div",{className:G.statValue,children:c.bottleneckBandwidth>0?Rr(c.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:G.statLabel,children:"Przepustowość"})]})]}),j&&e.jsxs("div",{className:G.pathVisualization,children:[e.jsx("div",{className:G.pathDiagram,children:m.map((E,F)=>e.jsxs(u.Fragment,{children:[e.jsx("div",{className:`${G.pathNode} ${F===0?G.pathNodeStart:F===m.length-1?G.pathNodeEnd:""}`,children:C(E).substring(0,8)}),F<m.length-1&&e.jsxs("div",{className:G.pathLink,children:[e.jsx("div",{className:G.pathLinkLine}),e.jsx(Or,{})]})]},E))}),e.jsx("button",{className:G.showOnMapButton,onClick:E=>{E.stopPropagation(),n==null||n(c)},children:"Pokaż na mapie"})]})]},c.id)})]}):a&&i&&a!==i?e.jsx("div",{className:G.noResults,children:'Wybierz urządzenia i kliknij „Analizuj ścieżkę"'}):e.jsx("div",{className:G.noResults,children:"Wybierz urządzenie źródłowe i docelowe"})]})]})},Wr="_root_6pirz_9",Gr="_header_6pirz_27",qr="_title_6pirz_37",Vr="_search_6pirz_51",Ur="_categories_6pirz_79",Hr="_category_6pirz_91",Yr="_categoryHeader_6pirz_107",Zr="_categoryIcon_6pirz_143",Xr="_categoryLabel_6pirz_151",Kr="_categoryCount_6pirz_161",Jr="_expandIcon_6pirz_171",Qr="_items_6pirz_181",ei="_item_6pirz_181",ti="_itemIcon_6pirz_241",si="_itemName_6pirz_249",ni="_emptyState_6pirz_269",ve={root:Wr,header:Gr,title:qr,search:Vr,categories:Ur,category:Hr,categoryHeader:Yr,categoryIcon:Zr,categoryLabel:Xr,categoryCount:Kr,expandIcon:Jr,items:Qr,item:ei,itemIcon:ti,itemName:si,emptyState:ni},oi={"💡":"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"},ai=t=>t&&oi[t]||"box",ri={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},ii={"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"}},vs=({mode:t,onObjectSelect:s,customObjects:n=[],className:o})=>{const[a,r]=u.useState(""),[i,l]=u.useState(new Set(["smart-home","furniture","network"])),h=ri[t]||[],b=u.useMemo(()=>{const v={},y=Dn.reduce((_,f)=>{var p;return(_[p=f.category]??(_[p]=[])).push(f),_},{});return Object.entries(y).forEach(([_,f])=>{if(!h.includes(_))return;const p=f.filter(C=>!a||C.name.toLowerCase().includes(a.toLowerCase()));p.length>0&&(v[_]=p.map(C=>({id:C.id,name:C.name,category:_,icon:C.icon})))}),n.forEach(_=>{h.includes(_.category)&&(!a||_.name.toLowerCase().includes(a.toLowerCase()))&&(v[_.category]||(v[_.category]=[]),v[_.category].push(_))}),v},[h,a,n]),d=v=>{l(y=>{const _=new Set(y);return _.has(v)?_.delete(v):_.add(v),_})},x=(v,y)=>{v.dataTransfer.setData("application/json",JSON.stringify(y)),v.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${ve.root} ${o??""}`,children:[e.jsxs("div",{className:ve.header,children:[e.jsx("h3",{className:ve.title,children:"Objects"}),e.jsx("input",{type:"text",className:ve.search,placeholder:"Search...",value:a,onChange:v=>r(v.target.value)})]}),e.jsxs("div",{className:ve.categories,children:[Object.entries(b).map(([v,y])=>{const _=ii[v]||{icon:"box",label:v},f=i.has(v);return e.jsxs("div",{className:ve.category,children:[e.jsxs("button",{className:ve.categoryHeader,onClick:()=>d(v),children:[e.jsx("span",{className:ve.categoryIcon,children:e.jsx(z.NiceIcon,{name:_.icon,size:16})}),e.jsx("span",{className:ve.categoryLabel,children:_.label}),e.jsxs("span",{className:ve.categoryCount,children:["(",y.length,")"]}),e.jsx("span",{className:ve.expandIcon,children:e.jsx(z.NiceIcon,{name:f?"chevron-down":"chevron-right",size:14})})]}),f&&e.jsx("div",{className:ve.items,children:y.map(p=>e.jsxs("div",{className:ve.item,draggable:!0,onDragStart:C=>x(C,p),onClick:()=>s(p),title:p.name,children:[e.jsx("span",{className:ve.itemIcon,children:e.jsx(z.NiceIcon,{name:ai(p.icon),size:16})}),e.jsx("span",{className:ve.itemName,children:p.name})]},p.id))})]},v)}),Object.keys(b).length===0&&e.jsx("div",{className:ve.emptyState,children:a?`No objects matching "${a}"`:"No objects available for this mode"})]})]})},ci="_root_o3eqo_9",li="_header_o3eqo_23",di="_title_o3eqo_39",ui="_multiSelect_o3eqo_53",hi="_content_o3eqo_63",mi="_section_o3eqo_73",pi="_sectionHeader_o3eqo_89",_i="_sectionContent_o3eqo_127",fi="_fieldRow_o3eqo_135",gi="_fieldLabel_o3eqo_157",yi="_textInput_o3eqo_169",xi="_numberInput_o3eqo_171",bi="_select_o3eqo_173",vi="_checkbox_o3eqo_215",ji="_colorInput_o3eqo_227",wi="_readOnly_o3eqo_245",Ni="_emptyState_o3eqo_263",se={root:ci,header:li,title:di,multiSelect:ui,content:hi,section:mi,sectionHeader:pi,sectionContent:_i,fieldRow:fi,fieldLabel:gi,textInput:yi,numberInput:xi,select:bi,checkbox:vi,colorInput:ji,readOnly:wi,emptyState:Ni},Et=[{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"}],ki=[{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}],Ii=[{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"}]}],js=({selection:t,document:s,onPropertyChange:n,className:o})=>{const[a,r]=u.useState(new Set(["general","position","appearance"])),i=t.objectIds.map(y=>{for(const _ of s.floors)for(const f of _.layers){const p=f.objects.find(C=>C.id===y);if(p)return p}return null}).filter(Boolean),l=y=>{r(_=>{const f=new Set(_);return f.has(y)?f.delete(y):f.add(y),f})},h=u.useCallback((y,_)=>{const f=_.split(".");let p=y;for(const C of f)if(p&&typeof p=="object"&&C in p)p=p[C];else return;return p},[]),b=u.useCallback((y,_)=>{var p;const f=h(_,y.key);switch(y.type){case"text":return e.jsx("input",{type:"text",value:String(f??""),onChange:C=>n(_.id,y.key,C.target.value),className:se.textInput});case"number":return e.jsx("input",{type:"number",value:Number(f??0),min:y.min,max:y.max,step:y.step,onChange:C=>n(_.id,y.key,parseFloat(C.target.value)),className:se.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!f,onChange:C=>n(_.id,y.key,C.target.checked),className:se.checkbox});case"color":return e.jsx("input",{type:"color",value:String(f??"var(--nice-bg, #fff)"),onChange:C=>n(_.id,y.key,C.target.value),className:se.colorInput});case"select":return e.jsx("select",{value:String(f??""),onChange:C=>n(_.id,y.key,C.target.value),className:se.select,children:(p=y.options)==null?void 0:p.map(C=>e.jsx("option",{value:C.value,children:C.label},C.value))});default:return e.jsx("span",{children:String(f??"-")})}},[h,n]);if(i.length===0)return e.jsxs("div",{className:`${se.root} ${o??""}`,children:[e.jsx("div",{className:se.header,children:e.jsx("h3",{className:se.title,children:"Properties"})}),e.jsx("div",{className:se.emptyState,children:"No object selected"})]});const d=i[0],x=i.length>1,v=d.category==="zone"?ki:["smart-home","network","infrastructure"].includes(d.category??"")?Ii:[];return e.jsxs("div",{className:`${se.root} ${o??""}`,children:[e.jsxs("div",{className:se.header,children:[e.jsx("h3",{className:se.title,children:"Properties"}),x&&e.jsxs("span",{className:se.multiSelect,children:[i.length," selected"]})]}),e.jsxs("div",{className:se.content,children:[e.jsxs("div",{className:se.section,children:[e.jsxs("button",{className:se.sectionHeader,onClick:()=>l("general"),children:[e.jsx("span",{children:e.jsx(z.NiceIcon,{name:a.has("general")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"General"})]}),a.has("general")&&e.jsxs("div",{className:se.sectionContent,children:[Et.slice(0,1).map(y=>e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:y.label}),b(y,d)]},y.key)),e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:"ID"}),e.jsx("span",{className:se.readOnly,children:d.id})]}),e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:"Category"}),e.jsx("span",{className:se.readOnly,children:d.category})]})]})]}),e.jsxs("div",{className:se.section,children:[e.jsxs("button",{className:se.sectionHeader,onClick:()=>l("position"),children:[e.jsx("span",{children:e.jsx(z.NiceIcon,{name:a.has("position")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Transform"})]}),a.has("position")&&e.jsx("div",{className:se.sectionContent,children:Et.slice(1,4).map(y=>e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:y.label}),b(y,d)]},y.key))})]}),v.length>0&&e.jsxs("div",{className:se.section,children:[e.jsxs("button",{className:se.sectionHeader,onClick:()=>l("appearance"),children:[e.jsx("span",{children:e.jsx(z.NiceIcon,{name:a.has("appearance")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Appearance"})]}),a.has("appearance")&&e.jsx("div",{className:se.sectionContent,children:v.map(y=>e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:y.label}),b(y,d)]},y.key))})]}),e.jsxs("div",{className:se.section,children:[e.jsxs("button",{className:se.sectionHeader,onClick:()=>l("visibility"),children:[e.jsx("span",{children:e.jsx(z.NiceIcon,{name:a.has("visibility")?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{children:"Visibility"})]}),a.has("visibility")&&e.jsx("div",{className:se.sectionContent,children:Et.slice(4).map(y=>e.jsxs("div",{className:se.fieldRow,children:[e.jsx("label",{className:se.fieldLabel,children:y.label}),b(y,d)]},y.key))})]})]})]})},Ci="_panel_62set_9",Si="_header_62set_33",zi="_headerTitle_62set_51",Li="_title_62set_65",$i="_closeButton_62set_79",Ti="_summarySection_62set_111",Mi="_summaryStats_62set_129",Bi="_statBadge_62set_141",Pi="_statValue_62set_155",Ei="_statLabel_62set_167",Oi="_visibilityControls_62set_183",Ai="_visibilityLabel_62set_201",Di="_visibilityButtons_62set_211",Ri="_visibilityBtn_62set_221",Fi="_active_62set_251",Wi="_content_62set_265",Gi="_emptyState_62set_279",qi="_emptyHint_62set_325",Vi="_vlanList_62set_337",Ui="_vlanCard_62set_351",Hi="_highlighted_62set_377",Yi="_hidden_62set_387",Zi="_vlanHeader_62set_395",Xi="_colorIndicator_62set_421",Ki="_vlanInfo_62set_435",Ji="_vlanName_62set_445",Qi="_vlanId_62set_459",ec="_vlanNameText_62set_471",tc="_vlanSubnet_62set_487",sc="_vlanStats_62set_503",nc="_chipStat_62set_515",oc="_vlanActions_62set_545",ac="_iconBtn_62set_557",rc="_inactive_62set_595",ic="_expanded_62set_611",cc="_vlanDetails_62set_623",lc="_detailRow_62set_635",dc="_detailLabel_62set_657",uc="_detailValue_62set_675",hc="_badge_62set_687",mc="_badgeSuccess_62set_701",pc="_badgeNeutral_62set_711",_c="_deviceList_62set_723",fc="_deviceItems_62set_731",gc="_deviceItem_62set_731",yc="_deviceDot_62set_765",xc="_deviceMore_62set_779",bc="_highlightButton_62set_795",vc="_footer_62set_835",jc="_legendTitle_62set_847",wc="_legend_62set_847",Nc="_legendItem_62set_875",kc="_legendColor_62set_887",Ic="_legendLabel_62set_901",P={panel:Ci,header:Si,headerTitle:zi,title:Li,closeButton:$i,summarySection:Ti,summaryStats:Mi,statBadge:Bi,statValue:Pi,statLabel:Ei,visibilityControls:Oi,visibilityLabel:Ai,visibilityButtons:Di,visibilityBtn:Ri,active:Fi,content:Wi,emptyState:Gi,emptyHint:qi,vlanList:Vi,vlanCard:Ui,highlighted:Hi,hidden:Yi,vlanHeader:Zi,colorIndicator:Xi,vlanInfo:Ki,vlanName:Ji,vlanId:Qi,vlanNameText:ec,vlanSubnet:tc,vlanStats:sc,chipStat:nc,vlanActions:oc,iconBtn:ac,inactive:rc,expanded:ic,vlanDetails:cc,detailRow:lc,detailLabel:dc,detailValue:uc,badge:hc,badgeSuccess:mc,badgeNeutral:pc,deviceList:_c,deviceItems:fc,deviceItem:gc,deviceDot:yc,deviceMore:xc,highlightButton:bc,footer:vc,legendTitle:jc,legend:wc,legendItem:Nc,legendColor:kc,legendLabel:Ic},Cc=()=>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"})}),Sc=()=>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"})]}),zc=()=>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"})]}),ns=()=>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"})]}),Lc=()=>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 $c(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function Tc(t,s){return s.filter(n=>n.vlanId===t.id).length}function Mc(t){return t||"—"}const Bc=({document:t,connections:s,vlans:n,visibleVlanIds:o,onVlanVisibilityChange:a,onHighlightVlan:r,onClose:i})=>{const[l,h]=u.useState(null),[b,d]=u.useState(null),x=u.useMemo(()=>[...n].sort((I,k)=>I.id-k.id),[n]),v=u.useMemo(()=>{const I=new Set,k=new Set;for(const c of n)for(const g of c.deviceIds??[])I.add(g);for(const c of s)c.vlanId!==void 0&&k.add(c.id);return{vlanCount:n.length,deviceCount:I.size,connectionCount:k.size}},[n,s]),y=u.useCallback(I=>{const k=o.has(I);a==null||a(I,!k)},[o,a]),_=u.useCallback(I=>{for(const k of n)a==null||a(k.id,I)},[n,a]),f=u.useCallback(I=>{h((I==null?void 0:I.id)??null),r==null||r(I)},[r]),p=u.useCallback(I=>{d(k=>k===I?null:I)},[]),C=u.useCallback(I=>{const k=[];for(const c of I.deviceIds??[])for(const g of t.floors)for(const m of g.layers){const j=m.objects.find(E=>E.id===c);j&&k.push({id:c,name:j.name??c})}return k},[t]),L=u.useMemo(()=>{const I=n.filter(k=>o.has(k.id)).length;return{visible:I,total:n.length,allVisible:I===n.length,noneVisible:I===0}},[n,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(ns,{}),e.jsx("h3",{className:P.title,children:"Nakładka VLAN"})]}),i&&e.jsx("button",{className:P.closeButton,onClick:i,title:"Zamknij",children:e.jsx(Cc,{})})]}),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:v.vlanCount}),e.jsx("span",{className:P.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:P.statBadge,children:[e.jsx("span",{className:P.statValue,children:v.deviceCount}),e.jsx("span",{className:P.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:P.statBadge,children:[e.jsx("span",{className:P.statValue,children:v.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ść: ",L.visible,"/",L.total]}),e.jsxs("div",{className:P.visibilityButtons,children:[e.jsx("button",{className:`${P.visibilityBtn} ${L.allVisible?P.active:""}`,onClick:()=>_(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${P.visibilityBtn} ${L.noneVisible?P.active:""}`,onClick:()=>_(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:P.content,children:x.length===0?e.jsxs("div",{className:P.emptyState,children:[e.jsx(ns,{}),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:x.map(I=>{const k=o.has(I.id),c=l===I.id,g=b===I.id,m=$c(I),j=Tc(I,s),E=g?C(I):[];return e.jsxs("div",{className:`${P.vlanCard} ${c?P.highlighted:""} ${k?"":P.hidden}`,onMouseEnter:()=>f(I),onMouseLeave:()=>f(null),children:[e.jsxs("div",{className:P.vlanHeader,children:[e.jsx("div",{className:P.colorIndicator,style:{backgroundColor:I.color}}),e.jsxs("div",{className:P.vlanInfo,children:[e.jsxs("div",{className:P.vlanName,children:[e.jsxs("span",{className:P.vlanId,children:["VLAN ",I.id]}),I.name&&e.jsx("span",{className:P.vlanNameText,children:I.name})]}),I.subnet&&e.jsx("div",{className:P.vlanSubnet,children:Mc(I.subnet)})]}),e.jsxs("div",{className:P.vlanStats,children:[e.jsx("span",{className:P.chipStat,title:"Urządzenia",children:m}),e.jsx("span",{className:P.chipStat,title:"Połączenia",children:j})]}),e.jsxs("div",{className:P.vlanActions,children:[e.jsx("button",{className:`${P.iconBtn} ${k?"":P.inactive}`,onClick:F=>{F.stopPropagation(),y(I.id)},title:k?"Ukryj VLAN":"Pokaż VLAN",children:k?e.jsx(Sc,{}):e.jsx(zc,{})}),e.jsx("button",{className:`${P.iconBtn} ${g?P.expanded:""}`,onClick:F=>{F.stopPropagation(),p(I.id)},title:"Szczegóły",children:e.jsx(Lc,{})})]})]}),g&&e.jsxs("div",{className:P.vlanDetails,children:[I.description&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Opis:"}),e.jsx("span",{className:P.detailValue,children:I.description})]}),I.subnet&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:P.detailValue,children:I.subnet})]}),I.gateway&&e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"Brama:"}),e.jsx("span",{className:P.detailValue,children:I.gateway})]}),e.jsxs("div",{className:P.detailRow,children:[e.jsx("span",{className:P.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${P.detailValue} ${P.badge} ${I.dhcpEnabled?P.badgeSuccess:P.badgeNeutral}`,children:I.dhcpEnabled?"Włączone":"Wyłączone"})]}),E.length>0&&e.jsxs("div",{className:P.deviceList,children:[e.jsxs("span",{className:P.detailLabel,children:["Urządzenia (",E.length,"):"]}),e.jsxs("ul",{className:P.deviceItems,children:[E.slice(0,10).map(F=>e.jsxs("li",{className:P.deviceItem,children:[e.jsx("span",{className:P.deviceDot,style:{backgroundColor:I.color}}),F.name]},F.id)),E.length>10&&e.jsxs("li",{className:P.deviceMore,children:["... i ",E.length-10," więcej"]})]})]}),e.jsx("button",{className:P.highlightButton,onClick:()=>r==null?void 0:r(I),children:"Zaznacz na mapie"})]})]},I.id)})})}),x.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:x.map(I=>e.jsxs("div",{className:P.legendItem,children:[e.jsx("span",{className:P.legendColor,style:{backgroundColor:I.color}}),e.jsxs("span",{className:P.legendLabel,children:[I.id,I.name?`: ${I.name}`:""]})]},I.id))})]})]})},Pc="_root_16w3g_9",Ec="_shell_16w3g_35",Oc="_dark_16w3g_43",Ac="_topBar_16w3g_67",Dc="_modeSwitcher_16w3g_85",Rc="_modeBtn_16w3g_95",Fc="_modeBtnActive_16w3g_131",Wc="_modeIcon_16w3g_143",Gc="_modeLabel_16w3g_151",qc="_floorTabs_16w3g_159",Vc="_floorTab_16w3g_159",Uc="_floorTabActive_16w3g_203",Hc="_viewportControls_16w3g_215",Yc="_active_16w3g_257",Zc="_disabled_16w3g_267",Xc="_separator_16w3g_281",Kc="_zoomLevel_16w3g_295",Jc="_exportDropdown_16w3g_313",Qc="_exportMenu_16w3g_361",el="_editorContainer_16w3g_435",tl="_toolbar_16w3g_453",sl="_toolGroup_16w3g_473",nl="_toolBtn_16w3g_501",ol="_toolBtnActive_16w3g_541",al="_canvasWrapper_16w3g_565",rl="_canvas_16w3g_565",il="_cursor_select_16w3g_593",cl="_cursor_multi_select_16w3g_599",ll="_cursor_pan_16w3g_605",dl="_cursor_zoom_16w3g_617",ul="_cursor_draw_wall_16w3g_623",hl="_cursor_draw_zone_16w3g_625",ml="_cursor_draw_polyline_16w3g_627",pl="_cursor_draw_rectangle_16w3g_629",_l="_cursor_draw_circle_16w3g_631",fl="_cursor_draw_arc_16w3g_633",gl="_cursor_place_device_16w3g_639",yl="_cursor_place_furniture_16w3g_641",xl="_cursor_place_network_16w3g_643",bl="_cursor_place_infra_16w3g_645",vl="_cursor_place_door_16w3g_647",jl="_cursor_place_window_16w3g_649",wl="_cursor_place_stairs_16w3g_651",Nl="_cursor_connect_16w3g_657",kl="_cursor_route_cable_16w3g_659",Il="_cursor_annotate_16w3g_665",Cl="_cursor_dimension_16w3g_667",Sl="_cursor_label_16w3g_669",zl="_cursor_measure_distance_16w3g_675",Ll="_cursor_measure_angle_16w3g_677",$l="_cursor_measure_area_16w3g_679",Tl="_cursor_move_16w3g_685",Ml="_cursor_rotate_16w3g_691",Bl="_cursor_scale_16w3g_697",Pl="_cursor_erase_16w3g_703",El="_cursor_copy_16w3g_709",Ol="_cursor_paste_16w3g_711",Al="_grid_16w3g_721",Dl="_gridLine_16w3g_727",Rl="_zonesLayer_16w3g_739",Fl="_zone_16w3g_739",Wl="_zoneLabel_16w3g_755",Gl="_connectionsLayer_16w3g_769",ql="_connection_16w3g_769",Vl="_connectionPreview_16w3g_785",Ul="_guides_16w3g_795",Hl="_guideLine_16w3g_801",Yl="_drawingPreview_16w3g_815",Zl="_rightSidebar_16w3g_827",Xl="_statusBar_16w3g_849",Kl="_modeIndicator_16w3g_871",Jl="_toolIndicator_16w3g_873",Ql="_selectionInfo_16w3g_885",ed="_drawingInfo_16w3g_887",td="_connectingInfo_16w3g_901",sd="_gridInfo_16w3g_915",nd="_emptyState_16w3g_927",od="_emptyIcon_16w3g_949",ad="_primaryBtn_16w3g_979",rd="_modeActions_16w3g_1013",id="_actionBtn_16w3g_1031",D={root:Pc,shell:Ec,dark:Oc,topBar:Ac,modeSwitcher:Dc,modeBtn:Rc,modeBtnActive:Fc,modeIcon:Wc,modeLabel:Gc,floorTabs:qc,floorTab:Vc,floorTabActive:Uc,viewportControls:Hc,active:Yc,disabled:Zc,separator:Xc,zoomLevel:Kc,exportDropdown:Jc,exportMenu:Qc,editorContainer:el,toolbar:tl,toolGroup:sl,toolBtn:nl,toolBtnActive:ol,canvasWrapper:al,canvas:rl,cursor_select:il,cursor_multi_select:cl,cursor_pan:ll,cursor_zoom:dl,cursor_draw_wall:ul,cursor_draw_zone:hl,cursor_draw_polyline:ml,cursor_draw_rectangle:pl,cursor_draw_circle:_l,cursor_draw_arc:fl,cursor_place_device:gl,cursor_place_furniture:yl,cursor_place_network:xl,cursor_place_infra:bl,cursor_place_door:vl,cursor_place_window:jl,cursor_place_stairs:wl,cursor_connect:Nl,cursor_route_cable:kl,cursor_annotate:Il,cursor_dimension:Cl,cursor_label:Sl,cursor_measure_distance:zl,cursor_measure_angle:Ll,cursor_measure_area:$l,cursor_move:Tl,cursor_rotate:Ml,cursor_scale:Bl,cursor_erase:Pl,cursor_copy:El,cursor_paste:Ol,grid:Al,gridLine:Dl,zonesLayer:Rl,zone:Fl,zoneLabel:Wl,connectionsLayer:Gl,connection:ql,connectionPreview:Vl,guides:Ul,guideLine:Hl,drawingPreview:Yl,rightSidebar:Zl,statusBar:Xl,modeIndicator:Kl,toolIndicator:Jl,selectionInfo:Ql,drawingInfo:ed,connectingInfo:td,gridInfo:sd,emptyState:nd,emptyIcon:od,primaryBtn:ad,modeActions:rd,actionBtn:id},Xe={"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}},gt={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 cd(t){var a,r;const s=t.defaultMode??"floor-plan",n=Xe[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:n.tools[0]??"select",document:t.document??t.initialDocument??null,activeFloorId:((r=(a=t.document)==null?void 0:a.floors[0])==null?void 0:r.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??n.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 Ye(t,s,n,o){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,timestamp:Date.now(),type:t,objectIds:s,before:n,after:o}}function Ze(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function Fe(t,s){if(t)for(const n of t.floors)for(const o of n.layers){const a=o.objects.find(r=>r.id===s);if(a)return a}}function mt(t,s,n){return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(a=>({...a,objects:a.objects.map(r=>r.id===s?{...r,...n}:r)}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function pt(t,s){const n=new Set(s);return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(a=>({...a,objects:a.objects.filter(r=>!n.has(r.id))}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function _t(t,s,n,o){return{...t,floors:t.floors.map(a=>a.id!==s?a:{...a,layers:a.layers.map(r=>r.name!==n?r:{...r,objects:[...r.objects,o]})}),metadata:{...t.metadata,modified:new Date().toISOString()}}}function ld(t,s){var n;switch(s.type){case"SET_MODE":{const o=Xe[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:((n=s.document.floors[0])==null?void 0:n.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",a=_t(t.document,t.activeFloorId,o,s.object),r=Ye("create",[s.object.id],null,s.object);return{...t,document:a,...Ze(t,r)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=Fe(t.document,s.objectId);if(!o)return t;const a=mt(t.document,s.objectId,s.updates),r=Ye("update",[s.objectId],o,{...o,...s.updates});return{...t,document:a,...Ze(t,r)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(i=>Fe(t.document,i)).filter(Boolean),a=pt(t.document,s.objectIds),r=Ye("delete",s.objectIds,o,null);return{...t,document:a,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,r)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(l=>Fe(t.document,l)).filter(Boolean);let a=t.document;for(const l of s.objectIds){const h=Fe(a,l);if(h&&"transform"in h&&h.transform&&"position"in h.transform){const b=h.transform.position;a=mt(a,l,{transform:{...h.transform,position:{x:b.x+s.delta.x,y:b.y+s.delta.y}}})}}const r=s.objectIds.map(l=>Fe(a,l)).filter(Boolean),i=Ye("move",s.objectIds,o,r);return{...t,document:a,...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 a=t.document;switch(o.type){case"create":{a=pt(a,o.objectIds);break}case"delete":{const r=o.before;for(const i of r){const l=i.layer||"devices";a=_t(a,t.activeFloorId??a.floors[0].id,l,i)}break}case"update":case"move":{const r=o.before;for(const i of r)a=mt(a,i.id,i);break}}return{...t,document:a,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 a=t.document;switch(o.type){case"create":{const r=o.after,i=r.layer||"devices";a=_t(a,t.activeFloorId??a.floors[0].id,i,r);break}case"delete":{a=pt(a,o.objectIds);break}case"update":case"move":{const r=o.after;for(const i of r)a=mt(a,i.id,i);break}}return{...t,document:a,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(a=>Fe(t.document,a)).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=>Fe(t.document,i)).filter(Boolean),a=pt(t.document,t.selection.objectIds),r=Ye("delete",t.selection.objectIds,o,null);return{...t,document:a,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,r)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const a=[],r=[];for(const l of t.clipboard){const h=`${l.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,b=l.transform,d={position:{x:b.position.x+s.position.x+20,y:b.position.y+s.position.y+20},rotation:b.rotation,scale:b.scale},x={...l,id:h,transform:d},v=x.layer||"devices";o=_t(o,t.activeFloorId,v,x),a.push(h),r.push(x)}const i=Ye("create",a,null,r);return{...t,document:o,selection:{objectIds:a,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 dd=({mode:t,activeTool:s,onToolSelect:n,readOnly:o})=>{const r=Xe[t].tools.map(l=>gt[l]).filter(Boolean),i=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:D.toolbar,children:i.map(l=>{const h=r.filter(b=>b.group===l);return h.length===0?null:e.jsx("div",{className:D.toolGroup,children:h.map(({tool:b,icon:d,label:x,shortcut:v})=>e.jsx("button",{title:`${x}${v?` (${v})`:""}`,className:`${D.toolBtn} ${s===b?D.toolBtnActive:""}`,onClick:()=>n(b),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(b),children:e.jsx(z.NiceIcon,{name:d,size:16})},b))},l)})})},ud=({currentMode:t,availableModes:s,onModeChange:n})=>e.jsx("div",{className:D.modeSwitcher,children:s.map(o=>{const a=Xe[o];return e.jsxs("button",{title:a.label,className:`${D.modeBtn} ${t===o?D.modeBtnActive:""}`,onClick:()=>n(o),children:[e.jsx("span",{className:D.modeIcon,children:e.jsx(z.NiceIcon,{name:a.icon,size:16})}),e.jsx("span",{className:D.modeLabel,children:a.label})]},o)})});function os(t){if(!t)return[];const s=[];for(const n of t.floors)for(const o of n.layers)if(o.type==="network"||o.type==="infrastructure"){for(const a of o.objects)if(a.type==="connection"){const r=a.metadata;r!=null&&r.sourceId&&(r!=null&&r.targetId)&&s.push({id:a.id,sourceId:r.sourceId,sourcePort:r.sourcePort,targetId:r.targetId,targetPort:r.targetPort,medium:r.medium??"ethernet-cat6",status:r.status??"unknown",bandwidth:r.bandwidth,latency:r.latency??1,waypoints:r.waypoints??[]})}}return s}function hd(t){if(!t)return[];const s=[],n=new Set;for(const o of t.floors)for(const a of o.layers)if(a.type==="network"||a.type==="infrastructure")for(const r of a.objects){const i=r.metadata;if((i==null?void 0:i.vlanId)!==void 0&&!n.has(i.vlanId))n.add(i.vlanId),s.push({id:i.vlanId,name:i.vlanName??`VLAN ${i.vlanId}`,color:i.vlanColor??md(i.vlanId),deviceIds:[r.id],subnet:i.subnet,gateway:i.gateway,dhcpEnabled:i.dhcpEnabled});else if((i==null?void 0:i.vlanId)!==void 0){const l=s.find(h=>h.id===i.vlanId);l&&!l.deviceIds.includes(r.id)&&l.deviceIds.push(r.id)}}return s.sort((o,a)=>o.id-a.id)}function md(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 pd=[{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"}],_d=t=>{var Wt,Gt;const{defaultMode:s="floor-plan",availableModes:n=Object.keys(Xe),readOnly:o=!1,theme:a="light",locale:r="en",onDocumentChange:i,onSelectionChange:l,onModeChange:h,onExport:b,onImport:d,tutorial:x,className:v,style:y,cookies:_=!1,localStorage:f=!0,sessionStorage:p=!1,storageMode:C,storageKey:L,persistPreferences:I=!1}=t,k=z.useStorageAdapter(L??"nice-spatial-editor"),[c]=u.useState(()=>I?k.get("prefs")??{}:{}),[g,m]=u.useReducer(ld,t,cd),j=u.useRef(null),E=u.useRef(!1),F=u.useRef({x:0,y:0}),[de,ee]=u.useState(!1),[xe,ue]=u.useState(!1),[ae,X]=u.useState(null),[le,ze]=u.useState(null),[De,Ce]=u.useState(!1),[Me,Be]=u.useState(!1),[T,U]=u.useState(!1),[me,Le]=u.useState(new Set),[Oe,be]=u.useState(null),Pe=u.useRef(null),ke=u.useRef(null),we=u.useRef(null),{mode:je,tool:he,document:ne,activeFloorId:Re,layers:Ne,selection:ye,viewport:re,drawing:pe,connecting:Q,guides:We,ui:Ee,history:Ke}=g,Ge=Xe[je],ot=Ke.past.length>0,Je=Ke.future.length>0;u.useEffect(()=>{var N,A,O;!I||!c||((c.zoom||c.pan)&&m({type:"SET_VIEWPORT",viewport:{zoom:c.zoom,pan:c.pan,showGrid:(N=c.gridConfig)==null?void 0:N.visible,gridSize:(A=c.gridConfig)==null?void 0:A.size,snapEnabled:(O=c.gridConfig)==null?void 0:O.snapEnabled}}),c.mode&&m({type:"SET_MODE",mode:c.mode}),c.tool&&m({type:"SET_TOOL",tool:c.tool}),c.layerVisibility&&Object.entries(c.layerVisibility).forEach(([W,Z])=>{Z!==void 0&&m({type:"SET_LAYER_VISIBILITY",layerType:W,visible:Z})}))},[]),u.useEffect(()=>{if(!I)return;const N={zoom:re.zoom,pan:re.pan,gridConfig:{size:re.gridSize,visible:re.showGrid,snapEnabled:re.snapEnabled},mode:je,tool:he,layerVisibility:Object.fromEntries(Ne.map(A=>[A.type,A.visible])),uiPanels:Ee};k.set("prefs",N)},[I,re,je,he,Ne,Ee,k]);const fe=u.useMemo(()=>(ne==null?void 0:ne.floors.find(N=>N.id===Re))??(ne==null?void 0:ne.floors[0])??null,[ne,Re]),Ae=u.useCallback((N,A)=>{var W;const O=(W=j.current)==null?void 0:W.getBoundingClientRect();return O?{x:(N-O.left-re.pan.x)/re.zoom,y:(A-O.top-re.pan.y)/re.zoom}:{x:0,y:0}},[re.pan,re.zoom]),qe=u.useCallback(N=>{if(!re.snapEnabled)return N;const A={cellSize:re.gridSize,origin:{x:0,y:0},visible:re.showGrid};return Ft(N,A)},[re.snapEnabled,re.gridSize,re.showGrid]),vt=u.useCallback(N=>{if(he==="pan"||N.button===1){E.current=!0,F.current={x:N.clientX,y:N.clientY};return}const A=qe(Ae(N.clientX,N.clientY));if(he==="draw-zone"||he==="draw-wall"||he==="draw-polyline")pe.active?m({type:"ADD_DRAWING_POINT",point:A}):m({type:"START_DRAWING",point:A});else if(he==="connect"){const O=fe==null?void 0:fe.layers.flatMap(W=>W.objects).find(W=>{if(!W.bounds)return!1;const Z=W.bounds;return A.x>=Z.x&&A.x<=Z.x+Z.width&&A.y>=Z.y&&A.y<=Z.y+Z.height});if(O)if(Q.active){m({type:"FINISH_CONNECTING",targetId:O.id});const W=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,Z=O.bounds?{x:O.bounds.x+O.bounds.width/2,y:O.bounds.y+O.bounds.height/2}:A,K={id:W,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,Z.x),y:Math.min(Q.sourcePosition.y,Z.y),width:Math.abs(Z.x-Q.sourcePosition.x),height:Math.abs(Z.y-Q.sourcePosition.y)},metadata:{sourceId:Q.sourceId,targetId:O.id,sourcePosition:Q.sourcePosition,targetPosition:Z,medium:"ethernet-cat6",status:"active"}};m({type:"ADD_OBJECT",object:K})}else{const W=O.bounds?{x:O.bounds.x+O.bounds.width/2,y:O.bounds.y+O.bounds.height/2}:A;m({type:"START_CONNECTING",sourceId:O.id,sourcePosition:W})}else Q.active&&m({type:"CANCEL_CONNECTING"})}else he==="select"&&m({type:"CLEAR_SELECTION"})},[he,pe.active,Q.active,Q.sourceId,Q.sourcePosition,qe,Ae,fe]),jt=u.useCallback(N=>{if(E.current){const O=N.clientX-F.current.x,W=N.clientY-F.current.y;m({type:"PAN",delta:{x:O,y:W}}),F.current={x:N.clientX,y:N.clientY};return}const A=qe(Ae(N.clientX,N.clientY));if(pe.active&&(m({type:"UPDATE_DRAWING_PREVIEW",point:A}),re.snapEnabled&&fe)){const O=fe.layers.flatMap(K=>K.objects.filter(ie=>ie.bounds).map(ie=>({id:ie.id,bounds:ie.bounds}))),W={x:A.x,y:A.y,width:1,height:1},Z=ps(W,O,10);m({type:"SET_GUIDES",guides:Z})}Q.active&&m({type:"UPDATE_CONNECTING_PREVIEW",position:A})},[pe.active,Q.active,qe,Ae,re.snapEnabled,fe]),wt=u.useCallback(()=>{E.current=!1},[]),Nt=u.useCallback(N=>{pe.active&&pe.points.length>=2&&m({type:"FINISH_DRAWING"})},[pe.active,pe.points.length]),kt=u.useCallback(N=>{N.preventDefault();const A=N.deltaY>0?-1:1;m({type:"ZOOM",delta:A,center:Ae(N.clientX,N.clientY)})},[Ae]),It=u.useCallback(N=>{N.key==="Escape"&&(pe.active?m({type:"CANCEL_DRAWING"}):Q.active?m({type:"CANCEL_CONNECTING"}):m({type:"CLEAR_SELECTION"})),N.key==="Delete"&&ye.objectIds.length>0&&m({type:"DELETE_OBJECTS",objectIds:ye.objectIds}),(N.ctrlKey||N.metaKey)&&(N.key==="z"&&m({type:"UNDO"}),N.key==="y"&&m({type:"REDO"}),N.key==="c"&&m({type:"COPY"}),N.key==="v"&&m({type:"PASTE",position:{x:0,y:0}}),N.key==="x"&&m({type:"CUT"}))},[pe.active,Q.active,ye.objectIds]),Ct=u.useCallback(N=>{m({type:"SET_MODE",mode:N}),h==null||h(N)},[h]),St=u.useCallback(N=>{m({type:"SET_TOOL",tool:N})},[]),Ve=u.useCallback(async N=>{var A;if(ne){ee(!1);try{const O={includeGrid:!1,includeDimensions:!0};if(N==="nsp"){const W=Vn(ne,O);ut(W),b==null||b(N,W.data)}else if(N==="svg"){const W=Hn(ne,O);ut(W),b==null||b(N,W.data)}else if(N==="dxf"){const W=Xn(ne,O);ut(W),b==null||b(N,W.data)}else if(N==="png"&&j.current){const W=await eo(j.current,((A=ne.metadata)==null?void 0:A.name)||"export");ut(W),b==null||b(N,W.data)}}catch(O){console.error(`Export to ${N} failed:`,O)}}},[ne,b]),zt=u.useCallback(async N=>{var O;const A=(O=N.target.files)==null?void 0:O[0];if(A){ue(!1);try{const Z=await mo(A,{convertClosedPolylinesToZones:!0,minZoneArea:1});Z.success&&Z.document?ze(Z):X(Z),we.current&&(we.current.value="")}catch(W){console.error("Import failed:",W),X({success:!1,warnings:[],errors:[{code:"IMPORT_ERROR",message:W instanceof Error?W.message:"Unknown import error",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})}}},[]),Lt=u.useCallback(()=>{le!=null&&le.success&&le.document?Ce(!0):ze(null)},[le]),at=u.useCallback(()=>{ze(null),Ce(!1)},[]),w=u.useCallback((N,A)=>{if(!(le!=null&&le.document)){Ce(!1);return}const O=le.document,W={...O,floors:O.floors.map(Z=>({...Z,layers:Z.layers.filter(K=>N.get(K.id)!=="skip").map(K=>{const ie=N.get(K.id);if(ie===K.id||!ie)return K;const Se=ne==null?void 0:ne.floors.flatMap(Ue=>Ue.layers).find(Ue=>Ue.id===ie);return Se?{...K,id:Se.id,name:Se.name,type:Se.type}:K})}))};m({type:"SET_DOCUMENT",document:W}),d==null||d(W),X(le),Ce(!1),ze(null)},[le,ne,d]),S=u.useCallback(()=>{Ce(!1)},[]),M=u.useCallback(N=>{if(we.current){let A=".dxf,.svg,.geojson,.json,.ifc";N==="dxf"?A=".dxf":N==="svg"?A=".svg":N==="geojson"?A=".geojson,.json":N==="ifc"&&(A=".ifc"),we.current.accept=A,we.current.click()}ue(!1)},[]);u.useEffect(()=>{const N=A=>{Pe.current&&!Pe.current.contains(A.target)&&ee(!1),ke.current&&!ke.current.contains(A.target)&&ue(!1)};return(de||xe)&&document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[de,xe]);const J=u.useCallback(()=>{var Z,K;if(!re.showGrid||!fe)return null;const N=[],{gridSize:A}=re,O=((Z=fe.bounds)==null?void 0:Z.width)??1e3,W=((K=fe.bounds)==null?void 0:K.height)??800;for(let ie=0;ie<=O;ie+=A)N.push(e.jsx("line",{x1:ie,y1:0,x2:ie,y2:W,className:D.gridLine},`v${ie}`));for(let ie=0;ie<=W;ie+=A)N.push(e.jsx("line",{x1:0,y1:ie,x2:O,y2:ie,className:D.gridLine},`h${ie}`));return e.jsx("g",{className:D.grid,children:N})},[re.showGrid,re.gridSize,fe]),q=u.useCallback(()=>{if(!fe)return null;const N=fe.layers.find(A=>A.name==="zones");return N?e.jsx("g",{className:D.zonesLayer,children:N.objects.map(A=>{const O=A;if(!O.boundary||O.boundary.length<3)return null;const W=O.boundary.map((ie,Se)=>`${Se===0?"M":"L"}${ie.x},${ie.y}`).join(" ")+" Z",Z=ye.objectIds.includes(O.id),K=O.boundary.reduce((ie,Se)=>({x:ie.x+Se.x/O.boundary.length,y:ie.y+Se.y/O.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:D.zone,onClick:ie=>{ie.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[O.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:W,fill:O.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.5,stroke:Z?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:Z?2:1}),O.name&&e.jsx("text",{x:K.x,y:K.y,textAnchor:"middle",dominantBaseline:"middle",className:D.zoneLabel,children:O.name})]},O.id)})}):null},[fe,ye.objectIds]),ce=u.useCallback(()=>We.length===0?null:e.jsx("g",{className:D.guides,children:We.map((N,A)=>e.jsx("line",{x1:N.start.x,y1:N.start.y,x2:N.end.x,y2:N.end.y,className:D.guideLine},A))}),[We]),_e=u.useCallback(()=>{if(!pe.active||pe.points.length===0)return null;const N=[...pe.points];pe.preview&&N.push(pe.preview);const A=N.map((W,Z)=>`${Z===0?"M":"L"}${W.x},${W.y}`).join(" "),O=he==="draw-zone"&&N.length>2;return e.jsxs("g",{className:D.drawingPreview,children:[e.jsx("path",{d:A+(O?" Z":""),fill:O?"var(--nice-primary-tint-10, rgba(37, 99, 235, 0.1))":"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:O?"none":"6,3"}),N.map((W,Z)=>e.jsx("circle",{cx:W.x,cy:W.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},Z))]})},[pe,he]),$e=u.useCallback(()=>!Q.active||!Q.sourcePosition||!Q.previewPosition?null:e.jsxs("g",{className:D.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]),rt=u.useCallback(()=>{if(!fe)return null;const N=fe.layers.find(Z=>Z.type==="network");if(!N)return null;const A=N.objects.filter(Z=>Z.type==="connection");if(A.length===0)return null;const O={"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}},W={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:D.connectionsLayer,children:A.map(Z=>{const K=Z.metadata;if(!(K!=null&&K.sourcePosition)||!(K!=null&&K.targetPosition))return null;const ie=O[K.medium??"default"]||O.default,Se=W[K.status??"unknown"]||W.unknown,Ue=ye.objectIds.includes(Z.id);let $t=`M${K.sourcePosition.x},${K.sourcePosition.y}`;if(K.waypoints&&K.waypoints.length>0)for(const it of K.waypoints)$t+=` L${it.x},${it.y}`;return $t+=` L${K.targetPosition.x},${K.targetPosition.y}`,e.jsxs("g",{className:D.connection,onClick:it=>{it.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[Z.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:$t,fill:"none",stroke:Ue?"var(--nice-primary-hover, #2563eb)":ie.color,strokeWidth:Ue?ie.width+1:ie.width,strokeDasharray:ie.dashArray,strokeLinecap:"round",strokeLinejoin:"round"}),K.status&&K.status!=="active"&&e.jsx("circle",{cx:(K.sourcePosition.x+K.targetPosition.x)/2,cy:(K.sourcePosition.y+K.targetPosition.y)/2,r:5,fill:Se}),e.jsx("circle",{cx:K.sourcePosition.x,cy:K.sourcePosition.y,r:4,fill:ie.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:K.targetPosition.x,cy:K.targetPosition.y,r:4,fill:ie.color,stroke:"white",strokeWidth:1})]},Z.id)})})},[fe,ye.objectIds]);if(!ne&&!fe)return e.jsx("div",{className:`${D.root} ${D[a]} ${v??""}`,style:y,children:e.jsxs("div",{className:D.emptyState,children:[e.jsx("div",{className:D.emptyIcon,children:e.jsx(z.NiceIcon,{name:Ge.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:D.primaryBtn,onClick:()=>{const N=_s("New Project","floor-plan");m({type:"SET_DOCUMENT",document:N})},children:"Create New Document"})]})});const Ss=e.jsxs("div",{className:D.topBar,children:[e.jsx(ud,{currentMode:je,availableModes:n,onModeChange:Ct}),ne&&ne.floors.length>1&&e.jsx("div",{className:D.floorTabs,children:ne.floors.map(N=>e.jsx("button",{className:`${D.floorTab} ${Re===N.id?D.floorTabActive:""}`,onClick:()=>m({type:"SET_ACTIVE_FLOOR",floorId:N.id}),children:N.name},N.id))}),e.jsxs("div",{className:D.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>m({type:"UNDO"}),disabled:!ot,className:ot?"":D.disabled,children:e.jsx(z.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>m({type:"REDO"}),disabled:!Je,className:Je?"":D.disabled,children:e.jsx(z.NiceIcon,{name:"forward",size:16})}),e.jsx("div",{className:D.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>m({type:"TOGGLE_GRID"}),className:re.showGrid?D.active:"",children:e.jsx(z.NiceIcon,{name:"grid",size:16})}),e.jsx("button",{title:"Toggle Snap",onClick:()=>m({type:"TOGGLE_SNAP"}),className:re.snapEnabled?D.active:"",children:e.jsx(z.NiceIcon,{name:"target",size:16})}),e.jsxs("span",{className:D.zoomLevel,children:[Math.round(re.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>m({type:"ZOOM",delta:1}),children:e.jsx(z.NiceIcon,{name:"plus",size:16})}),e.jsx("button",{title:"Zoom Out",onClick:()=>m({type:"ZOOM",delta:-1}),children:e.jsx(z.NiceIcon,{name:"minus",size:16})}),e.jsx("button",{title:"Reset View",onClick:()=>m({type:"RESET_VIEW"}),children:e.jsx(z.NiceIcon,{name:"expand",size:16})}),!o&&e.jsxs("div",{className:D.exportDropdown,ref:ke,children:[e.jsx("input",{type:"file",ref:we,onChange:zt,style:{display:"none"}}),e.jsxs("button",{title:"Import",onClick:()=>ue(!xe),className:xe?D.active:"",children:[e.jsx(z.NiceIcon,{name:"download",size:14})," Import"]}),xe&&e.jsxs("div",{className:D.exportMenu,children:[e.jsxs("button",{onClick:()=>M(),children:[e.jsx(z.NiceIcon,{name:"file",size:14})," Auto-detect format"]}),e.jsxs("button",{onClick:()=>M("dxf"),children:[e.jsx(z.NiceIcon,{name:"ruler",size:14})," AutoCAD DXF (.dxf)"]}),e.jsxs("button",{onClick:()=>M("svg"),children:[e.jsx(z.NiceIcon,{name:"image",size:14})," SVG Vector Graphics (.svg)"]}),e.jsxs("button",{onClick:()=>M("geojson"),children:[e.jsx(z.NiceIcon,{name:"globe",size:14})," GeoJSON (.geojson)"]}),e.jsxs("button",{onClick:()=>M("ifc"),children:[e.jsx(z.NiceIcon,{name:"building",size:14})," IFC (BIM) (.ifc)"]})]})]}),ne&&e.jsxs("div",{className:D.exportDropdown,ref:Pe,children:[e.jsxs("button",{title:"Export",onClick:()=>ee(!de),className:de?D.active:"",children:[e.jsx(z.NiceIcon,{name:"upload",size:14})," Export"]}),de&&e.jsxs("div",{className:D.exportMenu,children:[e.jsxs("button",{onClick:()=>Ve("nsp"),children:[e.jsx(z.NiceIcon,{name:"file",size:14})," NiceToDev Spatial Plan (.nsp.json)"]}),e.jsxs("button",{onClick:()=>Ve("svg"),children:[e.jsx(z.NiceIcon,{name:"image",size:14})," SVG Vector Graphics (.svg)"]}),e.jsxs("button",{onClick:()=>Ve("dxf"),children:[e.jsx(z.NiceIcon,{name:"ruler",size:14})," AutoCAD DXF (.dxf)"]}),e.jsxs("button",{onClick:()=>Ve("png"),children:[e.jsx(z.NiceIcon,{name:"image",size:14})," PNG Image (.png)"]})]})]})]})]}),zs=Ee.showObjectLibrary&&!o?e.jsx(vs,{mode:je,onObjectSelect:N=>{m({type:"SET_TOOL",tool:`place-${N.category}`}),m({type:"START_DRAG",objectType:N.category,objectData:N})}}):void 0,Ls=e.jsxs("div",{className:D.editorContainer,children:[!o&&e.jsx(dd,{mode:je,activeTool:he,onToolSelect:St,readOnly:o}),(je==="network-topology"||je==="infrastructure")&&e.jsxs("div",{className:D.modeActions,children:[e.jsxs("button",{className:`${D.actionBtn} ${Me?D.active:""}`,onClick:()=>Be(!Me),title:"Analiza ścieżki sieciowej",children:[e.jsx(z.NiceIcon,{name:"bar-chart",size:14})," Analiza ścieżki"]}),e.jsxs("button",{className:`${D.actionBtn} ${T?D.active:""}`,onClick:()=>U(!T),title:"Nakładka VLAN",children:[e.jsx(z.NiceIcon,{name:"globe",size:14})," VLAN Overlay"]})]}),e.jsxs("div",{className:D.canvasWrapper,children:[e.jsx("svg",{ref:j,className:`${D.canvas} ${D[`cursor_${he.replace("-","_")}`]??""}`,onMouseDown:vt,onMouseMove:jt,onMouseUp:wt,onDoubleClick:Nt,onWheel:kt,children:e.jsxs("g",{transform:`translate(${re.pan.x}, ${re.pan.y}) scale(${re.zoom})`,children:[J(),q(),rt(),ce(),_e(),$e()]})}),Ee.showMinimap&&e.jsx(bs,{document:ne,activeFloorId:Re,viewport:re,onViewportChange:N=>m({type:"SET_VIEWPORT",viewport:N})})]})]}),$s=e.jsxs("div",{className:D.rightSidebar,children:[Ee.showLayerPanel&&e.jsx(xs,{layers:Ne.filter(N=>Ge.layerTypes.includes(N.type)),onVisibilityToggle:N=>{var A;return m({type:"SET_LAYER_VISIBILITY",layerType:N,visible:!((A=Ne.find(O=>O.type===N))!=null&&A.visible)})},onLockToggle:N=>{var A;return m({type:"SET_LAYER_LOCKED",layerType:N,locked:!((A=Ne.find(O=>O.type===N))!=null&&A.locked)})},onOpacityChange:(N,A)=>m({type:"SET_LAYER_OPACITY",layerType:N,opacity:A})}),Ee.showPropertiesPanel&&ye.objectIds.length>0&&e.jsx(js,{selection:ye,document:ne,onPropertyChange:(N,A,O)=>{m({type:"UPDATE_OBJECT",objectId:N,updates:{[A]:O}})}})]}),Ts=e.jsxs("div",{className:D.statusBar,children:[e.jsxs("span",{className:D.modeIndicator,children:[e.jsx(z.NiceIcon,{name:Ge.icon,size:14})," ",Ge.label]}),e.jsxs("span",{className:D.toolIndicator,children:[((Wt=gt[he])==null?void 0:Wt.icon)&&e.jsx(z.NiceIcon,{name:gt[he].icon,size:14})," ",(Gt=gt[he])==null?void 0:Gt.label]}),ye.objectIds.length>0&&e.jsxs("span",{className:D.selectionInfo,children:[ye.objectIds.length," selected"]}),pe.active&&e.jsxs("span",{className:D.drawingInfo,children:["Drawing: ",pe.points.length," points"]}),Q.active&&e.jsx("span",{className:D.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:D.gridInfo,children:["Grid: ",re.gridSize,"px | Snap: ",re.snapEnabled?"ON":"OFF"]})]});return e.jsxs("div",{className:`nice-spatial-editor ${D.root} ${D[a]} ${v??""}`,style:{position:"relative",...y},tabIndex:0,onKeyDown:It,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(z.NiceTutorialButton,{steps:z.resolveTutorial(x,pd)})}),e.jsx(z.NiceAppShell,{flush:!0,className:D.shell,menubar:Ss,sidebar:zs,rightSidebar:$s,statusBar:Ts,children:Ls}),le&&!De&&e.jsx(Qo,{result:le,onConfirm:Lt,onCancel:at}),le&&De&&e.jsx(Sa,{importResult:le,existingDocument:ne??void 0,onConfirm:w,onCancel:S}),Me&&ne&&e.jsx(Fr,{document:ne,connections:os(ne),onHighlightPath:N=>{m(N?{type:"SET_SELECTION",selection:{objectIds:N.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Be(!1)}),T&&ne&&e.jsx(Bc,{document:ne,connections:os(ne),vlans:hd(ne),visibleVlanIds:me,onVlanVisibilityChange:(N,A)=>{Le(O=>{const W=new Set(O);return A?W.add(N):W.delete(N),W})},onHighlightVlan:N=>{be((N==null?void 0:N.id)??null),m(N?{type:"SET_SELECTION",selection:{objectIds:N.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>U(!1)})]})},fd="_viewer_nyfnl_13",gd="_theme_light_nyfnl_37",yd="_theme_dark_nyfnl_59",xd="_debugOverlay_nyfnl_85",bd="_topBar_nyfnl_137",vd="_searchContainer_nyfnl_159",jd="_searchInput_nyfnl_171",wd="_clearBtn_nyfnl_227",Nd="_searchResults_nyfnl_261",kd="_searchResultItem_nyfnl_291",Id="_searchResultInfo_nyfnl_335",Cd="_searchResultName_nyfnl_347",Sd="_searchResultDesc_nyfnl_357",zd="_floorSelector_nyfnl_371",Ld="_navBtn_nyfnl_421",$d="_active_nyfnl_459",Td="_layersBtn_nyfnl_475",Md="_legendBtn_nyfnl_529",Bd="_content_nyfnl_583",Pd="_navPanel_nyfnl_599",Ed="_navPanelHeader_nyfnl_617",Od="_routeInputs_nyfnl_671",Ad="_routeInput_nyfnl_671",Dd="_routeMarker_nyfnl_705",Rd="_routeHint_nyfnl_745",Fd="_routeInfo_nyfnl_761",Wd="_routeStat_nyfnl_779",Gd="_routeStatLabel_nyfnl_791",qd="_routeStatValue_nyfnl_805",Vd="_clearRouteBtn_nyfnl_817",Ud="_refPointsList_nyfnl_851",Hd="_refPointItem_nyfnl_879",Yd="_refPointIcon_nyfnl_917",Zd="_layersPanel_nyfnl_929",Xd="_layersPanelHeader_nyfnl_947",Kd="_layersList_nyfnl_1001",Jd="_layerItem_nyfnl_1015",Qd="_layerToggle_nyfnl_1039",eu="_layerName_nyfnl_1075",tu="_layerType_nyfnl_1087",su="_canvasWrapper_nyfnl_1101",nu="_canvas_nyfnl_1101",ou="_grid_nyfnl_1137",au="_gridLine_nyfnl_1145",ru="_zonesLayer_nyfnl_1161",iu="_zone_nyfnl_1161",cu="_zoneSelected_nyfnl_1187",lu="_zoneLabel_nyfnl_1197",du="_objectsLayer_nyfnl_1213",uu="_object_nyfnl_1213",hu="_objectSelected_nyfnl_1237",mu="_objectLabel_nyfnl_1245",pu="_referencePoints_nyfnl_1261",_u="_referencePoint_nyfnl_1261",fu="_refLabel_nyfnl_1283",gu="_routeLayer_nyfnl_1299",yu="_routePath_nyfnl_1305",xu="_routeDash_nyfnl_1",bu="_routeMarkers_nyfnl_1331",vu="_currentLocation_nyfnl_1341",ju="_locationPulse_nyfnl_1347",wu="_pulse_nyfnl_1",Nu="_zoomControls_nyfnl_1383",ku="_minimap_nyfnl_1459",Iu="_minimapContent_nyfnl_1485",Cu="_minimapViewport_nyfnl_1499",Su="_legendPanel_nyfnl_1519",zu="_legendPanelHeader_nyfnl_1551",Lu="_legendList_nyfnl_1607",$u="_legendItem_nyfnl_1623",Tu="_legendColor_nyfnl_1647",Mu="_legendIcon_nyfnl_1663",Bu="_legendLabel_nyfnl_1677",Pu="_legendType_nyfnl_1689",Eu="_objectInfo_nyfnl_1707",Ou="_objectInfoHeader_nyfnl_1735",Au="_navigateBtn_nyfnl_1805",$={viewer:fd,theme_light:gd,theme_dark:yd,debugOverlay:xd,topBar:bd,searchContainer:vd,searchInput:jd,clearBtn:wd,searchResults:Nd,searchResultItem:kd,searchResultInfo:Id,searchResultName:Cd,searchResultDesc:Sd,floorSelector:zd,navBtn:Ld,active:$d,layersBtn:Td,legendBtn:Md,content:Bd,navPanel:Pd,navPanelHeader:Ed,routeInputs:Od,routeInput:Ad,routeMarker:Dd,routeHint:Rd,routeInfo:Fd,routeStat:Wd,routeStatLabel:Gd,routeStatValue:qd,clearRouteBtn:Vd,refPointsList:Ud,refPointItem:Hd,refPointIcon:Yd,layersPanel:Zd,layersPanelHeader:Xd,layersList:Kd,layerItem:Jd,layerToggle:Qd,layerName:eu,layerType:tu,canvasWrapper:su,canvas:nu,grid:ou,gridLine:au,zonesLayer:ru,zone:iu,zoneSelected:cu,zoneLabel:lu,objectsLayer:du,object:uu,objectSelected:hu,objectLabel:mu,referencePoints:pu,referencePoint:_u,refLabel:fu,routeLayer:gu,routePath:yu,routeDash:xu,routeMarkers:bu,currentLocation:vu,locationPulse:ju,pulse:wu,zoomControls:Nu,minimap:ku,minimapContent:Iu,minimapViewport:Cu,legendPanel:Su,legendPanelHeader:zu,legendList:Lu,legendItem:$u,legendColor:Tu,legendIcon:Mu,legendLabel:Bu,legendType:Pu,objectInfo:Eu,objectInfoHeader:Ou,navigateBtn:Au},Du=()=>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"})]}),as=()=>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"})}),Ru=()=>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"})]}),Fu=()=>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"})]}),Wu=()=>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"})]}),Gu=()=>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"})]}),qu=()=>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"})]}),et=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 4L4 12M4 4l8 8",strokeLinecap:"round"})}),rs=()=>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"})]}),is=()=>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"})]}),Vu=()=>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"})]}),Uu=()=>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"})]}),Hu={entrance:"door",elevator:"elevator",stairs:"stairs",exit:"bell",poi:"map-pin",parking:"map-pin"};function Ot(t){return t.icon??Hu[t.type]??"map-pin"}function Yu(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function Zu(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Xu(t){if(t<60)return"<1 min";const s=Math.round(t/60);if(s<60)return`${s} min`;const n=Math.floor(s/60),o=s%60;return`${n}h ${o}min`}const Ku=({document:t,initialFloorId:s,showNavigation:n=!0,showMinimap:o=!0,showFloorSelector:a=!0,showSearch:r=!0,showLayersPanel:i=!0,showLegend:l=!0,enableRoutePlanning:h=!0,referencePoints:b=[],onObjectClick:d,onRouteCalculated:x,currentLocation:v,theme:y="light",className:_,virtualRendering:f,virtualRenderingThreshold:p=200,debugVirtualRendering:C=!1})=>{var at;const[L,I]=u.useState(s??((at=t.floors[0])==null?void 0:at.id)??""),[k,c]=u.useState({zoom:1,pan:{x:0,y:0}}),[g,m]=u.useState(""),[j,E]=u.useState([]),[F,de]=u.useState(null),[ee,xe]=u.useState(null),[ue,ae]=u.useState(null),[X,le]=u.useState(null),[ze,De]=u.useState(!1),[Ce,Me]=u.useState(!1),[Be,T]=u.useState(!1),[U,me]=u.useState(new Map),[Le,Oe]=u.useState({width:1e3,height:600}),be=u.useRef(null),Pe=u.useRef(null),ke=u.useRef(!1),we=u.useRef({x:0,y:0}),je=u.useMemo(()=>{const w=t.floors.find(S=>S.id===L);return w?w.layers.reduce((S,M)=>{var J;return S+(((J=M.objects)==null?void 0:J.length)??0)},0):0},[t.floors,L]),he=f??xo(je,p),ne=u.useMemo(()=>{if(!he)return null;const w=t.floors.find(M=>M.id===L);if(!w)return null;const S=[];for(const M of w.layers)if(!(M.type==="zones"||M.type==="grid"||M.type==="background"))for(const J of M.objects??[]){const q=J.position??{x:0,y:0},ce=J.size??{width:20,height:20};S.push({id:J.id,position:q,size:ce,data:{object:J,layerId:M.id}})}return go(S)},[t.floors,L,he]),Re=u.useMemo(()=>yo(k,Le,100),[k,Le]),Ne=u.useMemo(()=>!he||!ne?null:ne.query(Re),[he,ne,Re]),ye=u.useMemo(()=>!C||!he?null:bo(je,(Ne==null?void 0:Ne.length)??je,k),[C,he,je,Ne,k]);u.useEffect(()=>{const w=Pe.current;if(!w)return;const S=new ResizeObserver(M=>{for(const J of M)Oe({width:J.contentRect.width,height:J.contentRect.height})});return S.observe(w),()=>S.disconnect()},[]),u.useEffect(()=>{const w=t.floors.find(S=>S.id===L);if(w){const S=new Map;for(const M of w.layers)S.set(M.id,U.get(M.id)??!0);me(S)}},[L,t.floors]);const re=u.useCallback(w=>{me(S=>{const M=new Map(S);return M.set(w,!S.get(w)),M})},[]),pe=u.useCallback(w=>U.get(w)!==!1,[U]),Q=u.useMemo(()=>t.floors.find(w=>w.id===L)??t.floors[0],[t.floors,L]),We=u.useMemo(()=>{if(!Q)return[];const w=[],S=Q.layers.find(q=>q.type==="zones");if(S){const q=new Map;for(const ce of S.objects){const _e=ce.metadata,$e=(_e==null?void 0:_e.zoneType)??ce.type??"zone";q.has($e)||q.set($e,(_e==null?void 0:_e.fill)??"var(--nice-primary, #3b82f6)")}for(const[ce,_e]of q)w.push({id:`zone-${ce}`,label:ce.charAt(0).toUpperCase()+ce.slice(1).replace(/-/g," "),color:_e,type:"zone"})}const M=new Map;for(const q of Q.layers)if(!(q.type==="zones"||q.type==="grid"||q.type==="background"))for(const ce of q.objects){const _e=ce.type??"object",$e=M.get(_e);$e?$e.count++:M.set(_e,{count:1,color:"var(--nice-text-secondary, #64748b)"})}for(const[q,ce]of M)w.push({id:`obj-${q}`,label:`${q.charAt(0).toUpperCase()+q.slice(1).replace(/-/g," ")} (${ce.count})`,color:ce.color,type:"object"});const J=new Map;for(const q of b.filter(ce=>ce.floorId===L))J.has(q.type)||J.set(q.type,Ot(q));for(const[q,ce]of J)w.push({id:`ref-${q}`,label:q.charAt(0).toUpperCase()+q.slice(1),color:"var(--nice-primary, #3b82f6)",icon:ce,type:"reference"});return w},[Q,b,L]),Ee=u.useCallback((w,S)=>{var J;const M=(J=be.current)==null?void 0:J.getBoundingClientRect();return M?{x:(w-M.left-k.pan.x)/k.zoom,y:(S-M.top-k.pan.y)/k.zoom}:{x:0,y:0}},[k]);u.useEffect(()=>{if(!g.trim()){E([]);return}const w=g.toLowerCase(),S=[];for(const M of t.floors)for(const J of M.layers)for(const q of J.objects){const ce=(q.name??q.id).toLowerCase(),_e=(q.description??"").toLowerCase();(ce.includes(w)||_e.includes(w))&&S.push(q)}E(S.slice(0,10))},[g,t.floors]);const Ke=u.useCallback((w,S)=>{const M=Yu(w,S);return{id:`route-${Date.now()}`,startPoint:w,endPoint:S,path:[w,S],floorTransitions:[],totalDistance:M,estimatedTime:M/1.4,instructions:[{type:"straight",distance:M,direction:"forward"},{type:"arrive"}]}},[]);u.useEffect(()=>{if(ee&&ue){const w=Ke(ee,ue);le(w),x==null||x(w)}else le(null),x==null||x(null)},[ee,ue,Ke,x]);const Ge=u.useCallback(w=>{(w.button===1||w.button===0&&w.altKey)&&(ke.current=!0,we.current={x:w.clientX,y:w.clientY},w.preventDefault())},[]),ot=u.useCallback(w=>{if(ke.current){const S=w.clientX-we.current.x,M=w.clientY-we.current.y;we.current={x:w.clientX,y:w.clientY},c(J=>({...J,pan:{x:J.pan.x+S,y:J.pan.y+M}}))}},[]),Je=u.useCallback(()=>{ke.current=!1},[]),fe=u.useCallback(w=>{var ce;w.preventDefault();const S=w.deltaY>0?.9:1.1,M=(ce=be.current)==null?void 0:ce.getBoundingClientRect();if(!M)return;const J=w.clientX-M.left,q=w.clientY-M.top;c(_e=>{const $e=Math.min(Math.max(_e.zoom*S,.1),10),rt=$e/_e.zoom;return{zoom:$e,pan:{x:J-(J-_e.pan.x)*rt,y:q-(q-_e.pan.y)*rt}}})},[]),Ae=u.useCallback(w=>{if(h&&w.ctrlKey){const S=Ee(w.clientX,w.clientY);ee?ue?(xe(S),ae(null)):ae(S):xe(S)}},[h,ee,ue,Ee]),qe=u.useCallback(()=>{c(w=>({...w,zoom:Math.min(w.zoom*1.25,10)}))},[]),vt=u.useCallback(()=>{c(w=>({...w,zoom:Math.max(w.zoom/1.25,.1)}))},[]),jt=u.useCallback(()=>{c({zoom:1,pan:{x:0,y:0}})},[]),wt=u.useCallback(w=>{de(w);for(const M of t.floors)for(const J of M.layers)if(J.objects.find(q=>q.id===w.id)){I(M.id);break}const S=w.position??{x:0,y:0};c(M=>({...M,pan:{x:-(S.x*M.zoom)+400,y:-(S.y*M.zoom)+300}})),m(""),E([]),d==null||d(w)},[t.floors,d]),Nt=u.useCallback(()=>{xe(null),ae(null),le(null)},[]),kt=u.useCallback(()=>{const S=[];for(let M=-2e3;M<=2e3;M+=50)S.push(e.jsx("line",{x1:M,y1:-2e3,x2:M,y2:2e3,className:$.gridLine},`v-${M}`));for(let M=-2e3;M<=2e3;M+=50)S.push(e.jsx("line",{x1:-2e3,y1:M,x2:2e3,y2:M,className:$.gridLine},`h-${M}`));return e.jsx("g",{className:$.grid,children:S})},[]),It=u.useCallback(()=>{if(!Q)return null;const w=Q.layers.find(S=>S.type==="zones");return!w||!pe(w.id)?null:e.jsx("g",{className:$.zonesLayer,children:w.objects.map(S=>{const M=S.metadata;if(!(M!=null&&M.points)||M.points.length<3)return null;const J=`M${M.points.map(ce=>`${ce.x},${ce.y}`).join(" L")} Z`,q=(F==null?void 0:F.id)===S.id;return e.jsxs("g",{className:`${$.zone} ${q?$.zoneSelected:""}`,onClick:()=>{de(S),d==null||d(S)},children:[e.jsx("path",{d:J,fill:M.fill??"var(--nice-primary, #3b82f6)",fillOpacity:.2,stroke:M.fill??"var(--nice-primary, #3b82f6)",strokeWidth:q?2:1}),S.name&&e.jsx("text",{x:M.points[0].x+10,y:M.points[0].y+20,className:$.zoneLabel,children:S.name})]},S.id)})})},[Q,F,d,pe]),Ct=u.useCallback(()=>Q?he&&Ne?e.jsx("g",{className:$.objectsLayer,children:Ne.map(w=>{const{object:S,layerId:M}=w.data;if(!pe(M))return null;const J=S.position??{x:0,y:0},q=S.size??{width:20,height:20},ce=(F==null?void 0:F.id)===S.id;return e.jsxs("g",{className:`${$.object} ${ce?$.objectSelected:""}`,transform:`translate(${J.x}, ${J.y})`,onClick:_e=>{_e.stopPropagation(),de(S),d==null||d(S)},children:[e.jsx("rect",{x:-q.width/2,y:-q.height/2,width:q.width,height:q.height,rx:4,fill:ce?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:ce?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),S.name&&e.jsx("text",{y:q.height/2+14,textAnchor:"middle",className:$.objectLabel,children:S.name})]},S.id)})}):e.jsx("g",{className:$.objectsLayer,children:Q.layers.map(w=>w.type==="zones"||w.type==="grid"||w.type==="background"||!pe(w.id)?null:w.objects.map(S=>{const M=S.position??{x:0,y:0},J=S.size??{width:20,height:20},q=(F==null?void 0:F.id)===S.id;return e.jsxs("g",{className:`${$.object} ${q?$.objectSelected:""}`,transform:`translate(${M.x}, ${M.y})`,onClick:ce=>{ce.stopPropagation(),de(S),d==null||d(S)},children:[e.jsx("rect",{x:-J.width/2,y:-J.height/2,width:J.width,height:J.height,rx:4,fill:q?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:q?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),S.name&&e.jsx("text",{y:J.height/2+14,textAnchor:"middle",className:$.objectLabel,children:S.name})]},S.id)}))}):null,[Q,F,d,pe,he,Ne]),St=u.useCallback(()=>{const w=b.filter(S=>S.floorId===L);return e.jsx("g",{className:$.referencePoints,children:w.map(S=>e.jsxs("g",{className:$.referencePoint,transform:`translate(${S.position.x}, ${S.position.y})`,onClick:()=>{h&&(ee?ae(S.position):xe(S.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(z.NiceIcon,{name:Ot(S),size:16})}),e.jsx("text",{y:30,textAnchor:"middle",className:$.refLabel,children:S.name})]},S.id))})},[b,L,h,ee]),Ve=u.useCallback(()=>{if(!X)return null;const w=`M${X.path.map(S=>`${S.x},${S.y}`).join(" L")}`;return e.jsxs("g",{className:$.routeLayer,children:[e.jsx("path",{d:w,fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:$.routePath}),e.jsx("circle",{cx:X.startPoint.x,cy:X.startPoint.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:X.endPoint.x,cy:X.endPoint.y,r:8,fill:"var(--nice-danger, #ef4444)",stroke:"white",strokeWidth:2})]})},[X]),zt=u.useCallback(()=>v?e.jsxs("g",{className:$.currentLocation,children:[e.jsx("circle",{cx:v.x,cy:v.y,r:12,fill:"var(--nice-primary, #3b82f6)",fillOpacity:.3,className:$.locationPulse}),e.jsx("circle",{cx:v.x,cy:v.y,r:6,fill:"var(--nice-primary, #3b82f6)",stroke:"white",strokeWidth:2})]}):null,[v]),Lt=u.useCallback(()=>e.jsx("g",{className:$.routeMarkers,children:ee&&!X&&e.jsx("circle",{cx:ee.x,cy:ee.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2})}),[ee,X]);return e.jsxs("div",{ref:Pe,className:`${$.viewer} ${$[`theme_${y}`]} ${_??""}`,children:[C&&ye&&e.jsxs("div",{className:$.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:$.topBar,children:[r&&e.jsxs("div",{className:$.searchContainer,children:[e.jsxs("div",{className:$.searchInput,children:[e.jsx(Du,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:g,onChange:w=>m(w.target.value)}),g&&e.jsx("button",{className:$.clearBtn,onClick:()=>m(""),children:e.jsx(et,{})})]}),j.length>0&&e.jsx("div",{className:$.searchResults,children:j.map(w=>e.jsxs("button",{className:$.searchResultItem,onClick:()=>wt(w),children:[e.jsx(Ru,{}),e.jsxs("div",{className:$.searchResultInfo,children:[e.jsx("span",{className:$.searchResultName,children:w.name??w.id}),w.description&&e.jsx("span",{className:$.searchResultDesc,children:w.description})]})]},w.id))})]}),a&&t.floors.length>1&&e.jsxs("div",{className:$.floorSelector,children:[e.jsx(Fu,{}),e.jsx("select",{value:L,onChange:w=>I(w.target.value),children:t.floors.map(w=>e.jsx("option",{value:w.id,children:w.name??`Piętro ${w.level}`},w.id))})]}),n&&e.jsxs("button",{className:`${$.navBtn} ${ze?$.active:""}`,onClick:()=>De(!ze),children:[e.jsx(as,{}),e.jsx("span",{children:"Nawigacja"})]}),i&&e.jsxs("button",{className:`${$.layersBtn} ${Ce?$.active:""}`,onClick:()=>Me(!Ce),children:[e.jsx(rs,{}),e.jsx("span",{children:"Warstwy"})]}),l&&e.jsxs("button",{className:`${$.legendBtn} ${Be?$.active:""}`,onClick:()=>T(!Be),children:[e.jsx(is,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:$.content,children:[ze&&e.jsxs("div",{className:$.navPanel,children:[e.jsxs("div",{className:$.navPanelHeader,children:[e.jsx(Wu,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>De(!1),children:e.jsx(et,{})})]}),e.jsxs("div",{className:$.routeInputs,children:[e.jsxs("div",{className:$.routeInput,children:[e.jsx("div",{className:$.routeMarker,style:{background:"var(--nice-success, #10b981)"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:ee?`${ee.x.toFixed(0)}, ${ee.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:$.routeInput,children:[e.jsx("div",{className:$.routeMarker,style:{background:"var(--nice-danger, #ef4444)"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:ue?`${ue.x.toFixed(0)}, ${ue.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:$.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),X&&e.jsxs("div",{className:$.routeInfo,children:[e.jsxs("div",{className:$.routeStat,children:[e.jsx("span",{className:$.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:$.routeStatValue,children:Zu(X.totalDistance)})]}),e.jsxs("div",{className:$.routeStat,children:[e.jsx("span",{className:$.routeStatLabel,children:"Czas"}),e.jsx("span",{className:$.routeStatValue,children:Xu(X.estimatedTime)})]})]}),(ee||ue)&&e.jsx("button",{className:$.clearRouteBtn,onClick:Nt,children:"Wyczyść trasę"}),b.length>0&&e.jsxs("div",{className:$.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),b.filter(w=>w.floorId===L).map(w=>e.jsxs("button",{className:$.refPointItem,onClick:()=>{ee?ae(w.position):xe(w.position)},children:[e.jsx("span",{className:$.refPointIcon,children:e.jsx(z.NiceIcon,{name:Ot(w),size:16})}),e.jsx("span",{children:w.name})]},w.id))]})]}),Ce&&Q&&e.jsxs("div",{className:$.layersPanel,children:[e.jsxs("div",{className:$.layersPanelHeader,children:[e.jsx(rs,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>Me(!1),children:e.jsx(et,{})})]}),e.jsx("div",{className:$.layersList,children:Q.layers.map(w=>{const S=pe(w.id);return e.jsxs("div",{className:$.layerItem,children:[e.jsx("button",{className:$.layerToggle,onClick:()=>re(w.id),title:S?"Ukryj warstwę":"Pokaż warstwę",children:S?e.jsx(Vu,{}):e.jsx(Uu,{})}),e.jsx("span",{className:$.layerName,children:w.name??w.id}),e.jsxs("span",{className:$.layerType,children:["(",w.type,")"]})]},w.id)})})]}),e.jsxs("div",{className:$.canvasWrapper,children:[e.jsx("svg",{ref:be,className:$.canvas,onMouseDown:Ge,onMouseMove:ot,onMouseUp:Je,onMouseLeave:Je,onWheel:fe,onClick:Ae,children:e.jsxs("g",{transform:`translate(${k.pan.x}, ${k.pan.y}) scale(${k.zoom})`,children:[kt(),It(),Ct(),St(),Lt(),Ve(),zt()]})}),e.jsxs("div",{className:$.zoomControls,children:[e.jsx("button",{onClick:qe,title:"Powiększ",children:e.jsx(Gu,{})}),e.jsx("button",{onClick:vt,title:"Pomniejsz",children:e.jsx(qu,{})}),e.jsx("button",{onClick:jt,title:"Resetuj widok",children:e.jsx(z.NiceIcon,{name:"refresh",size:16})})]}),o&&e.jsx("div",{className:$.minimap,children:e.jsx("div",{className:$.minimapContent,children:e.jsx("div",{className:$.minimapViewport})})}),Be&&We.length>0&&e.jsxs("div",{className:$.legendPanel,children:[e.jsxs("div",{className:$.legendPanelHeader,children:[e.jsx(is,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>T(!1),children:e.jsx(et,{})})]}),e.jsx("div",{className:$.legendList,children:We.map(w=>e.jsxs("div",{className:$.legendItem,children:[w.icon?e.jsx("span",{className:$.legendIcon,children:e.jsx(z.NiceIcon,{name:w.icon,size:16})}):e.jsx("span",{className:$.legendColor,style:{background:w.color}}),e.jsx("span",{className:$.legendLabel,children:w.label}),e.jsx("span",{className:$.legendType,children:w.type==="zone"?"strefa":w.type==="object"?"obiekt":"punkt ref."})]},w.id))})]})]})]}),F&&e.jsxs("div",{className:$.objectInfo,children:[e.jsxs("div",{className:$.objectInfoHeader,children:[e.jsx("h4",{children:F.name??F.id}),e.jsx("button",{onClick:()=>de(null),children:e.jsx(et,{})})]}),F.description&&e.jsx("p",{children:F.description}),h&&e.jsxs("button",{className:$.navigateBtn,onClick:()=>{const w=F.position??{x:0,y:0};ee?ae(w):xe(w)},children:[e.jsx(as,{}),ee?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Ju(t={}){var ue;const{initialDocument:s,defaultMode:n="floor-plan",gridSize:o=20,snapEnabled:a=!0,onChange:r}=t,i={mode:n,tool:"select",document:s??null,activeFloorId:((ue=s==null?void 0:s.floors[0])==null?void 0:ue.id)??null,layers:[],selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:o,snapEnabled:a,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}},[l,h]=u.useReducer((ae,X)=>({...ae,...X}),i),b=u.useCallback(ae=>{h({mode:ae})},[]),d=u.useCallback(ae=>{h({tool:ae})},[]),x=u.useCallback((ae="Untitled")=>{var le;const X=_s(ae,"floor-plan");h({document:X,activeFloorId:((le=X.floors[0])==null?void 0:le.id)??null}),r==null||r(X)},[r]),v=u.useCallback(ae=>{var X;h({document:ae,activeFloorId:((X=ae.floors[0])==null?void 0:X.id)??null}),r==null||r(ae)},[r]),y=u.useCallback(ae=>{h({viewport:{...l.viewport,zoom:Math.max(.1,Math.min(10,l.viewport.zoom*(1+ae*.1)))}})},[l.viewport]),_=u.useCallback(ae=>{h({viewport:{...l.viewport,pan:{x:l.viewport.pan.x+ae.x,y:l.viewport.pan.y+ae.y}}})},[l.viewport]),f=u.useCallback(()=>{h({viewport:{...l.viewport,zoom:1,pan:{x:0,y:0}}})},[l.viewport]),p=u.useCallback(()=>{h({viewport:{...l.viewport,showGrid:!l.viewport.showGrid}})},[l.viewport]),C=u.useCallback(()=>{h({viewport:{...l.viewport,snapEnabled:!l.viewport.snapEnabled}})},[l.viewport]),L=u.useCallback(ae=>{h({viewport:{...l.viewport,gridSize:ae}})},[l.viewport]),I=u.useCallback((ae,X)=>{h({layers:l.layers.map(le=>le.type===ae?{...le,visible:X}:le)})},[l.layers]),k=u.useCallback((ae,X)=>{h({layers:l.layers.map(le=>le.type===ae?{...le,locked:X}:le)})},[l.layers]),c=u.useCallback(ae=>{h({selection:{objectIds:ae,bounds:null,locked:!1}})},[]),g=u.useCallback(()=>{h({selection:{objectIds:[],bounds:null,locked:!1}})},[]),m=u.useCallback(()=>{},[]),j=u.useCallback(()=>{},[]),E=l.history.past.length>0,F=l.history.future.length>0,de=u.useCallback(()=>{},[]),ee=u.useCallback(ae=>{},[]),xe=u.useCallback(()=>{},[]);return{state:l,setMode:b,setTool:d,newDocument:x,loadDocument:v,zoom:y,pan:_,resetView:f,toggleGrid:p,toggleSnap:C,setGridSize:L,setLayerVisible:I,setLayerLocked:k,select:c,clearSelection:g,undo:m,redo:j,canUndo:E,canRedo:F,copy:de,paste:ee,cut:xe}}function Qu(t={}){const{gridSize:s=20,enabled:n=!0,snapModes:o=["grid","endpoint","midpoint"],objects:a=[],threshold:r=10}=t,i=u.useMemo(()=>({...Mn,cellSize:s,snapModes:o,snapThreshold:r}),[s,o,r]),l=u.useMemo(()=>a.map((y,_)=>({id:`obj-${_}`,bounds:y})),[a]),h=u.useCallback(y=>n?Ft(y,i):y,[n,i]),b=u.useCallback(y=>n?Bn(y,s):y,[n,s]),d=u.useCallback(y=>{if(!n||l.length===0)return[];const _={x:y.x,y:y.y,width:0,height:0};return ps(_,l,r)},[n,l,r]),x=u.useCallback(y=>{if(!n)return{point:y,snapped:!1,guides:[]};const _=An(y,l,i);return{point:_.position,snapped:_.snapped,guides:_.guides??[]}},[n,i,l]),v=u.useCallback((y,_)=>{const f=[];for(let p=0;p<=y;p+=s)f.push({x1:p,y1:0,x2:p,y2:_});for(let p=0;p<=_;p+=s)f.push({x1:0,y1:p,x2:y,y2:p});return f},[s]);return{snap:h,snap3D:b,getGuides:d,performAdvancedSnap:x,generateGridLines:v}}function eh(t={}){const{unitSystem:s="metric",lengthUnit:n="m",areaUnit:o="m2",angleUnit:a="deg",scale:r=100}=t,[i,l]=u.useState(null),[h,b]=u.useState([]),d=u.useCallback(g=>g/r,[r]),x=u.useCallback(g=>{l(g),b([])},[]),v=u.useCallback((g,m=!1)=>{b(j=>[...j,{position:g,snapped:m}])},[]),y=u.useCallback(()=>{l(null),b([])},[]),_=u.useCallback(()=>{if(!i||h.length<2)return null;const g=h.map(m=>m.position);if(i==="distance"&&h.length===2){const m=tt(g[0],g[1]),j=d(m);return{type:"distance",value:j,formatted:dt(j,s).formatted,points:g}}if(i==="angle"&&h.length===3){const m=Tt(g[0],g[1],g[2]);return{type:"angle",value:m,formatted:Bt(m,a).formatted,points:g}}if(i==="area"&&h.length>=3){const j=Mt(g)/(r*r);return{type:"area",value:j,formatted:Pt(j,s).formatted,points:g}}return null},[i,h,r,s,a,d]),f=h.length>=2&&i==="distance"?dt(d(tt(h[0].position,h[h.length-1].position)),s).formatted:null,p=h.length>=3&&i==="angle"?Bt(Tt(h[0].position,h[1].position,h[2].position),a).formatted:null,C=h.length>=3&&i==="area"?Pt(Mt(h.map(g=>g.position))/(r*r),s).formatted:null,L=u.useCallback((g,m)=>{const j=tt(g,m),E=d(j);return{value:E,formatted:dt(E,s).formatted}},[d,s]),I=u.useCallback((g,m,j)=>{const E=Tt(g,m,j);return{value:E,formatted:Bt(E,a).formatted}},[a]),k=u.useCallback(g=>{const j=Mt(g)/(r*r);return{value:j,formatted:Pt(j,s).formatted}},[r,s]),c=u.useCallback(g=>{const m=Gn(g),j=d(m);return{value:j,formatted:dt(j,s).formatted}},[d,s]);return{startMeasurement:x,addPoint:v,clearMeasurement:y,finishMeasurement:_,measurementType:i,points:h,liveDistance:f,liveAngle:p,liveArea:C,getDistance:L,getAngle:I,getArea:k,getLength:c}}const th="_root_1rgf7_3",sh="_dark_1rgf7_25",nh="_header_1rgf7_37",oh="_buildingInfo_1rgf7_51",ah="_buildingName_1rgf7_59",rh="_buildingAddress_1rgf7_81",ih="_modeSelector_1rgf7_95",ch="_modeBtn_1rgf7_107",lh="_modeBtnActive_1rgf7_145",dh="_weather_1rgf7_159",uh="_weatherTemp_1rgf7_173",hh="_weatherDesc_1rgf7_193",mh="_statsRow_1rgf7_205",ph="_statsCard_1rgf7_217",_h="_statsHeader_1rgf7_247",fh="_statsIcon_1rgf7_261",gh="_statsLabel_1rgf7_269",yh="_statsValue_1rgf7_283",xh="_statsSub_1rgf7_305",bh="_zoneGrid_1rgf7_319",vh="_zoneCard_1rgf7_333",jh="_zoneOccupied_1rgf7_381",wh="_zoneCardHeader_1rgf7_389",Nh="_zoneCardIcon_1rgf7_403",kh="_zoneCardTitles_1rgf7_411",Ih="_zoneCardName_1rgf7_421",Ch="_zoneCardArea_1rgf7_449",Sh="_occupancyBadge_1rgf7_459",zh="_occupancyBadgeOn_1rgf7_477",Lh="_sensorRow_1rgf7_489",$h="_sensorChip_1rgf7_503",Th="_sensorWarn_1rgf7_521",Mh="_deviceList_1rgf7_535",Bh="_deviceChip_1rgf7_547",Ph="_deviceChipOn_1rgf7_585",Eh="_deviceChipName_1rgf7_597",Oh="_deviceChipVal_1rgf7_611",Ah="_moreBtn_1rgf7_621",Dh="_scenesBar_1rgf7_651",Rh="_sceneBarLabel_1rgf7_681",Fh="_sceneList_1rgf7_699",Wh="_sceneBtn_1rgf7_711",Gh="_sceneBtnActive_1rgf7_741",H={root:th,dark:sh,header:nh,buildingInfo:oh,buildingName:ah,buildingAddress:rh,modeSelector:ih,modeBtn:ch,modeBtnActive:lh,weather:dh,weatherTemp:uh,weatherDesc:hh,statsRow:mh,statsCard:ph,statsHeader:_h,statsIcon:fh,statsLabel:gh,statsValue:yh,statsSub:xh,zoneGrid:bh,zoneCard:vh,zoneOccupied:jh,zoneCardHeader:wh,zoneCardIcon:Nh,zoneCardTitles:kh,zoneCardName:Ih,zoneCardArea:Ch,occupancyBadge:Sh,occupancyBadgeOn:zh,sensorRow:Lh,sensorChip:$h,sensorWarn:Th,deviceList:Mh,deviceChip:Bh,deviceChipOn:Ph,deviceChipName:Eh,deviceChipVal:Oh,moreBtn:Ah,scenesBar:Dh,sceneBarLabel:Rh,sceneList:Fh,sceneBtn:Wh,sceneBtnActive:Gh},ws={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 qh(t){return ws[t]??"home"}function Vh(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(z.NiceIcon,{name:"lock",size:14}):null}const Ns=({zone:t,devices:s=[],expanded:n=!1,onExpand:o,onDeviceControl:a,onClick:r,theme:i="light",className:l,style:h})=>{const b=t.occupancy!=null&&t.occupancy>0,d=n?s:s.slice(0,4);return e.jsxs("div",{className:`${H.zoneCard} ${i==="dark"?H.dark:""} ${b?H.zoneOccupied:""} ${l??""}`,style:h,onClick:r,children:[e.jsxs("div",{className:H.zoneCardHeader,children:[e.jsx("span",{className:H.zoneCardIcon,children:e.jsx(z.NiceIcon,{name:qh(t.type),size:18})}),e.jsxs("div",{className:H.zoneCardTitles,children:[e.jsx("span",{className:H.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:H.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${H.occupancyBadge} ${b?H.occupancyBadgeOn:""}`,children:[e.jsx(z.NiceIcon,{name:"users",size:14})," ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:H.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:H.sensorChip,children:[e.jsx(z.NiceIcon,{name:"thermometer",size:14})," ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:H.sensorChip,children:[e.jsx(z.NiceIcon,{name:"droplet",size:14})," ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${H.sensorChip} ${t.co2>1e3?H.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),d.length>0&&e.jsxs("div",{className:H.deviceList,children:[d.map(x=>{const v=x.state,y=(v==null?void 0:v.on)===!0||(v==null?void 0:v.locked)===!1;return e.jsxs("button",{className:`${H.deviceChip} ${y?H.deviceChipOn:""}`,onClick:_=>{_.stopPropagation(),a==null||a(x.id,{on:!y})},title:x.name,children:[e.jsx("span",{children:e.jsx(z.NiceIcon,{name:ws[x.type]??"monitor",size:14})}),e.jsx("span",{className:H.deviceChipName,children:x.name}),e.jsx("span",{className:H.deviceChipVal,children:Vh(x)})]},x.id)}),s.length>4&&e.jsx("button",{className:H.moreBtn,onClick:x=>{x.stopPropagation(),o==null||o()},children:n?"−":`+${s.length-4}`})]})]})},At={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"},cs={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"},Uh=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:H.weather,children:[e.jsxs("span",{className:H.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:H.weatherDesc,children:s})]}):null,ft=({label:t,value:s,sub:n,icon:o,accent:a})=>e.jsxs("div",{className:H.statsCard,style:a?{borderTopColor:a}:void 0,children:[e.jsxs("div",{className:H.statsHeader,children:[o&&e.jsx("span",{className:H.statsIcon,children:e.jsx(z.NiceIcon,{name:o,size:16})}),e.jsx("span",{className:H.statsLabel,children:t})]}),e.jsx("div",{className:H.statsValue,children:s}),n&&e.jsx("div",{className:H.statsSub,children:n})]}),Hh=({building:t,state:s,onModeChange:n,onDeviceControl:o,onSceneActivate:a,onZoneClick:r,className:i,style:l,theme:h="light",weather:b})=>{var I,k,c;const[d,x]=u.useState(null);t.floors[0];const v=t.floors.flatMap(g=>g.zones??[]).filter(g=>g.type!=="hallway"&&g.type!=="corridor"),y=((I=s==null?void 0:s.activeAlerts)==null?void 0:I.length)??0,_=(k=s==null?void 0:s.energy)==null?void 0:k.currentPowerW,f=(c=s==null?void 0:s.energy)==null?void 0:c.todayKwh,p=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 C=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],L=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${H.root} ${h==="dark"?H.dark:""} ${i??""}`,style:l,children:[e.jsxs("div",{className:H.header,children:[e.jsxs("div",{className:H.buildingInfo,children:[e.jsx("h2",{className:H.buildingName,children:t.name}),t.address&&e.jsx("p",{className:H.buildingAddress,children:t.address})]}),e.jsx("div",{className:H.modeSelector,children:C.map(g=>e.jsxs("button",{title:At[g],className:`${H.modeBtn} ${L===g?H.modeBtnActive:""}`,onClick:()=>n==null?void 0:n(g),children:[e.jsx(z.NiceIcon,{name:cs[g],size:16}),e.jsx("span",{children:At[g]})]},g))}),e.jsx(Uh,{temperature:b==null?void 0:b.temperature,description:b==null?void 0:b.description})]}),e.jsxs("div",{className:H.statsRow,children:[_!=null&&e.jsx(ft,{icon:"zap",label:"Moc",value:_>=1e3?`${(_/1e3).toFixed(2)} kW`:`${_} W`,sub:f!=null?`Dziś: ${f.toFixed(2)} kWh`:void 0,accent:"var(--nice-warning, #f59e0b)"}),p!=null&&e.jsx(ft,{icon:"users",label:"Obecność",value:`${p} os.`,sub:`${v.length} stref`,accent:"var(--nice-success, #22c55e)"}),y>0&&e.jsx(ft,{icon:"bell",label:"Alarmy",value:e.jsx("span",{style:{color:"var(--nice-danger, #ef4444)"},children:y}),sub:"aktywnych",accent:"var(--nice-danger, #ef4444)"}),e.jsx(ft,{icon:cs[L],label:"Tryb",value:At[L],accent:"var(--nice-accent, #8b5cf6)"})]}),e.jsx("div",{className:H.zoneGrid,children:v.map(g=>{const m=t.floors.flatMap(j=>(j.zones??[]).find(E=>E.id===g.id)?t.devices??[]:[]).filter(j=>j.zoneId===g.id);return e.jsx(Ns,{zone:g,devices:m,expanded:d===g.id,onExpand:()=>x(d===g.id?null:g.id),onDeviceControl:o,onClick:()=>r==null?void 0:r(g.id),theme:h},g.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:H.scenesBar,children:[e.jsx("span",{className:H.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:H.sceneList,children:t.scenes.map(g=>{var m;return e.jsxs("button",{className:`${H.sceneBtn} ${(m=s==null?void 0:s.activeScenes)!=null&&m.includes(g.id)?H.sceneBtnActive:""}`,onClick:()=>a==null?void 0:a(g.id),children:[e.jsx(z.NiceIcon,{name:g.icon??"video",size:14})," ",g.name]},g.id)})})]})]})},Yh="_deviceControl_9sx64_3",Zh="_dark_9sx64_23",Xh="_compact_9sx64_35",Kh="_offline_9sx64_43",Jh="_offlineBanner_9sx64_51",Qh="_toggleControl_9sx64_75",em="_toggleLabel_9sx64_89",tm="_toggleBtn_9sx64_109",sm="_toggleOn_9sx64_135",nm="_blindControl_9sx64_149",om="_blindLabel_9sx64_159",am="_blindActions_9sx64_173",rm="_blindBtn_9sx64_181",im="_blindSlider_9sx64_205",cm="_blindPct_9sx64_213",lm="_lockControl_9sx64_227",dm="_lockLabel_9sx64_239",um="_lockBtn_9sx64_253",hm="_lockLocked_9sx64_273",mm="_lockUnlocked_9sx64_281",pm="_cameraControl_9sx64_295",_m="_cameraLabel_9sx64_305",fm="_cameraSnapshot_9sx64_319",gm="_cameraPlaceholder_9sx64_331",ym="_cameraStatus_9sx64_355",xm="_cameraDot_9sx64_369",bm="_cameraOnline_9sx64_379",vm="_cameraOffline_9sx64_385",jm="_sensorControl_9sx64_395",wm="_sensorLabel_9sx64_405",Nm="_sensorValues_9sx64_419",km="_sensorRow_9sx64_429",Im="_sensorKey_9sx64_443",Cm="_sensorVal_9sx64_419",Sm="_thermostat_9sx64_467",zm="_thermostatTitle_9sx64_481",Lm="_thermostatDial_9sx64_503",$m="_dialTempCurrent_9sx64_513",Tm="_dialTempLabel_9sx64_533",Mm="_dialTempTarget_9sx64_543",Bm="_dialHumidity_9sx64_563",Pm="_thermostatAdjust_9sx64_573",Em="_adjustBtn_9sx64_585",Om="_adjustTemp_9sx64_631",Am="_hvacModes_9sx64_655",Dm="_hvacModeBtn_9sx64_669",Rm="_hvacModeBtnActive_9sx64_697",Fm="_hvacAction_9sx64_709",Wm="_hvacActionDot_9sx64_725",Gm="_lightControl_9sx64_739",qm="_lightHeader_9sx64_751",Vm="_lightIcon_9sx64_763",Um="_lightName_9sx64_771",Hm="_lightToggle_9sx64_799",Ym="_lightToggleOn_9sx64_827",Zm="_sliderRow_9sx64_839",Xm="_sliderIcon_9sx64_853",Km="_slider_9sx64_839",Jm="_sliderVal_9sx64_877",Qm="_colorRow_9sx64_889",ep="_colorSwatch_9sx64_903",tp="_colorPicker_9sx64_919",sp="_colorPresets_9sx64_935",np="_colorPreset_9sx64_935",op="_lightOff_9sx64_961",B={deviceControl:Yh,dark:Zh,compact:Xh,offline:Kh,offlineBanner:Jh,toggleControl:Qh,toggleLabel:em,toggleBtn:tm,toggleOn:sm,blindControl:nm,blindLabel:om,blindActions:am,blindBtn:rm,blindSlider:im,blindPct:cm,lockControl:lm,lockLabel:dm,lockBtn:um,lockLocked:hm,lockUnlocked:mm,cameraControl:pm,cameraLabel:_m,cameraSnapshot:fm,cameraPlaceholder:gm,cameraStatus:ym,cameraDot:xm,cameraOnline:bm,cameraOffline:vm,sensorControl:jm,sensorLabel:wm,sensorValues:Nm,sensorRow:km,sensorKey:Im,sensorVal:Cm,thermostat:Sm,thermostatTitle:zm,thermostatDial:Lm,dialTempCurrent:$m,dialTempLabel:Tm,dialTempTarget:Mm,dialHumidity:Bm,thermostatAdjust:Pm,adjustBtn:Em,adjustTemp:Om,hvacModes:Am,hvacModeBtn:Dm,hvacModeBtnActive:Rm,hvacAction:Fm,hvacActionDot:Wm,lightControl:Gm,lightHeader:qm,lightIcon:Vm,lightName:Um,lightToggle:Hm,lightToggleOn:Ym,sliderRow:Zm,sliderIcon:Xm,slider:Km,sliderVal:Jm,colorRow:Qm,colorSwatch:ep,colorPicker:tp,colorPresets:sp,colorPreset:np,lightOff:op};function ls(t){const s=Math.max(0,Math.min(1,(t-2700)/3800)),n=Math.round(255-s*80),o=Math.round(200+s*30),a=Math.round(100+s*155);return`rgb(${n},${o},${a})`}function ap(t,s,n){return"#"+[t,s,n].map(o=>o.toString(16).padStart(2,"0")).join("")}function ds(t){const s=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return[s,n,o]}const ks=({device:t,onControl:s,compact:n=!1,theme:o="light",className:a,style:r})=>{var L,I,k;const i=t.state,l=(i==null?void 0:i.on)??!1,h=(i==null?void 0:i.brightness)??100,b=(i==null?void 0:i.colorTemperature)??4e3,d=i==null?void 0:i.rgbColor,[x,v]=u.useState(!1),y=u.useCallback(c=>{s==null||s(t.id,c)},[t.id,s]),_=d?ap(d[0],d[1],d[2]):"var(--nice-bg, #fff)",f=((L=t.capabilities)==null?void 0:L.includes("dimming"))??h!==void 0,p=(I=t.capabilities)==null?void 0:I.includes("color_temperature"),C=((k=t.capabilities)==null?void 0:k.includes("color"))||t.type==="rgb_light";return e.jsxs("div",{className:`${B.lightControl} ${n?B.compact:""} ${o==="dark"?B.dark:""} ${a??""}`,style:r,children:[e.jsxs("div",{className:B.lightHeader,children:[e.jsx("span",{className:B.lightIcon,style:{opacity:l?1:.4},children:e.jsx(z.NiceIcon,{name:"lightbulb",size:16})}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${l?B.lightToggleOn:""}`,"aria-label":l?"Włączone":"Wyłączone",onClick:()=>y({on:!l}),children:e.jsx(z.NiceIcon,{name:l?"check":"close",size:14})})]}),l&&e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(z.NiceIcon,{name:"lightbulb",size:16})}),e.jsx("input",{type:"range",min:1,max:100,value:h,className:B.slider,style:{"--pct":`${h}%`},onChange:c=>y({brightness:+c.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[h,"%"]})]}),p&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(z.NiceIcon,{name:"thermometer",size:16})}),e.jsx("input",{type:"range",min:2700,max:6500,step:100,value:b,className:B.slider,style:{background:`linear-gradient(to right, ${ls(2700)}, ${ls(6500)})`},onChange:c=>y({colorTemperature:+c.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(b/100)*100,"K"]})]}),C&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:e.jsx(z.NiceIcon,{name:"palette",size:16})}),e.jsx("button",{className:B.colorSwatch,style:{background:_},onClick:()=>v(c=>!c)}),x&&e.jsx("input",{type:"color",value:_,className:B.colorPicker,onChange:c=>{const[g,m,j]=ds(c.target.value);y({rgbColor:[g,m,j]})}}),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(c=>e.jsx("button",{className:B.colorPreset,style:{background:c},onClick:()=>{const[g,m,j]=ds(c);y({rgbColor:[g,m,j]})}},c))})]})]}),!l&&!n&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},us={heat:"Grzanie",cool:"Chłodzenie",auto:"Auto",off:"Wyłącz",fan_only:"Wentylacja",dry:"Osuszanie"},rp={heat:"zap",cool:"thermometer",auto:"refresh",off:"stop",fan_only:"wifi",dry:"droplet"},ip={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 hs(t,s,n,o,a){const r=x=>(x-90)*(Math.PI/180),i=t+n*Math.cos(r(o)),l=s+n*Math.sin(r(o)),h=t+n*Math.cos(r(a)),b=s+n*Math.sin(r(a)),d=a-o>180?1:0;return`M${i.toFixed(2)},${l.toFixed(2)} A${n},${n} 0 ${d},1 ${h.toFixed(2)},${b.toFixed(2)}`}const st=5,yt=35,xt=-140,Is=140;function ms(t){return xt+(t-st)/(yt-st)*(Is-xt)}const Cs=({device:t,onControl:s,compact:n=!1,theme:o="light",className:a,style:r})=>{const i=t.state,l=(i==null?void 0:i.temperature)??20,h=(i==null?void 0:i.targetTemperature)??21,b=i==null?void 0:i.humidity,d=(i==null?void 0:i.mode)??"auto",x=(i==null?void 0:i.hvacAction)??"idle",v=80,y=80,_=60,f=hs(v,y,_,xt,Is),p=ms(Math.min(Math.max(l,st),yt)),C=ms(Math.min(Math.max(h,st),yt)),L=hs(v,y,_,xt,Math.min(p,C)),I=ip[x]??"var(--nice-text-muted, #94a3b8)",k=u.useCallback(g=>{const m=Math.round((h+g)*2)/2;m>=st&&m<=yt&&(s==null||s(t.id,{targetTemperature:m}))},[h,t.id,s]),c=u.useCallback(g=>{s==null||s(t.id,{mode:g})},[t.id,s]);return e.jsxs("div",{className:`${B.thermostat} ${n?B.compact:""} ${o==="dark"?B.dark:""} ${a??""}`,style:r,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:f,fill:"none",stroke:"var(--nice-border, #e2e8f0)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:L,fill:"none",stroke:I,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:v+_*Math.cos((C-90)*(Math.PI/180)),cy:y+_*Math.sin((C-90)*(Math.PI/180)),r:7,fill:I,stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsxs("text",{x:v,y:y-6,textAnchor:"middle",className:B.dialTempCurrent,children:[l.toFixed(1),"°"]}),e.jsx("text",{x:v,y:y+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:v,y:y+32,textAnchor:"middle",className:B.dialTempTarget,children:[h.toFixed(1),"°"]}),b!=null&&e.jsxs("text",{x:v,y:y+48,textAnchor:"middle",className:B.dialHumidity,children:[b,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>k(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[h.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>k(.5),children:"+"})]}),!n&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(g=>e.jsx("button",{title:us[g],"aria-label":us[g],className:`${B.hvacModeBtn} ${d===g?B.hvacModeBtnActive:""}`,onClick:()=>c(g),children:e.jsx(z.NiceIcon,{name:rp[g],size:16})},g))}),e.jsxs("div",{className:B.hvacAction,style:{color:I},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:I}}),x]})]})},cp=({device:t,onControl:s})=>{const n=t.state,o=(n==null?void 0:n.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"})]})},lp=({device:t,onControl:s})=>{const n=t.state,o=typeof(n==null?void 0:n.position)=="number"?n.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(z.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(z.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(z.NiceIcon,{name:"arrow-down",size:16})})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,className:B.blindSlider,onChange:a=>s==null?void 0:s(t.id,{position:+a.target.value})}),e.jsxs("span",{className:B.blindPct,children:[o,"%"]})]})},dp=({device:t,onControl:s})=>{const n=t.state,o=(n==null?void 0:n.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(z.NiceIcon,{name:"lock",size:14})," ",o?"Zablokowany":"Odblokowany"]})]})},up=({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(z.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]})]})},hp=({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(([n,o])=>o!=null&&e.jsxs("div",{className:B.sensorRow,children:[e.jsx("span",{className:B.sensorKey,children:n}),e.jsx("span",{className:B.sensorVal,children:String(o)})]},n))})]})},mp=({device:t,onControl:s,compact:n=!1,className:o,style:a,theme:r="light"})=>{const i=t.type,l=["light","dimmer","rgb_light","led_strip"].includes(i)?e.jsx(ks,{device:t,onControl:s,compact:n,theme:r}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(i)?e.jsx(Cs,{device:t,onControl:s,compact:n,theme:r}):["blind","shutter","curtain","awning","garage_door"].includes(i)?e.jsx(lp,{device:t,onControl:s}):["lock","door"].includes(i)?e.jsx(dp,{device:t,onControl:s}):["camera","doorbell"].includes(i)?e.jsx(up,{device:t}):i.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(i)?e.jsx(hp,{device:t}):e.jsx(cp,{device:t,onControl:s});return e.jsxs("div",{className:`${B.deviceControl} ${r==="dark"?B.dark:""} ${n?B.compact:""} ${t.status==="offline"?B.offline:""} ${o??""}`,style:a,children:[l,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},pp="_root_1aqqe_3",_p="_shell_1aqqe_29",fp="_dark_1aqqe_37",gp="_listPanel_1aqqe_51",yp="_listHeader_1aqqe_79",xp="_listTitle_1aqqe_103",bp="_addBtn_1aqqe_121",vp="_list_1aqqe_51",jp="_listItem_1aqqe_159",wp="_listItemActive_1aqqe_199",Np="_listItemName_1aqqe_213",kp="_listItemMeta_1aqqe_241",Ip="_enableToggle_1aqqe_255",Cp="_enableOn_1aqqe_273",Sp="_detailPanel_1aqqe_283",zp="_detailHeader_1aqqe_295",Lp="_nameInput_1aqqe_309",$p="_deleteBtn_1aqqe_343",Tp="_section_1aqqe_373",Mp="_sectionHeader_1aqqe_381",Bp="_sectionTitle_1aqqe_395",Pp="_sectionAddBtn_1aqqe_411",Ep="_ruleBlock_1aqqe_441",Op="_ruleBlockHeader_1aqqe_467",Ap="_typeSelect_1aqqe_481",Dp="_removeBtn_1aqqe_513",Rp="_ruleFields_1aqqe_551",Fp="_input_1aqqe_587",Wp="_textarea_1aqqe_619",Gp="_dayPicker_1aqqe_655",qp="_dayBtn_1aqqe_667",Vp="_dayBtnActive_1aqqe_687",Up="_noSelection_1aqqe_701",Hp="_emptyHint_1aqqe_703",R={root:pp,shell:_p,dark:fp,listPanel:gp,listHeader:yp,listTitle:xp,addBtn:bp,list:vp,listItem:jp,listItemActive:wp,listItemName:Np,listItemMeta:kp,enableToggle:Ip,enableOn:Cp,detailPanel:Sp,detailHeader:zp,nameInput:Lp,deleteBtn:$p,section:Tp,sectionHeader:Mp,sectionTitle:Bp,sectionAddBtn:Pp,ruleBlock:Ep,ruleBlockHeader:Op,typeSelect:Ap,removeBtn:Dp,ruleFields:Rp,input:Fp,textarea:Wp,dayPicker:Gp,dayBtn:qp,dayBtnActive:Vp,noSelection:Up,emptyHint:Hp},Yp=[{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"}],Te=(t,s,n="")=>{const o=t[s];return typeof o=="string"?o:n},Rt=(t,s,n=0)=>{const o=t[s];return typeof o=="number"?o:n},Zp=(t,s,n)=>{const o=t[s];return Array.isArray(o)?o:n},Xp=(t,s)=>{const n=t[s];return n&&typeof n=="object"?n:{}},Kp=({trigger:t,devices:s,onChange:n,onRemove:o})=>{const a=r=>n({...t,...r});return e.jsxs("div",{className:R.ruleBlock,children:[e.jsxs("div",{className:R.ruleBlockHeader,children:[e.jsxs("select",{className:R.typeSelect,value:t.type,onChange:r=>n({type:r.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:R.removeBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(z.NiceIcon,{name:"close",size:14})})]}),t.type==="time"&&e.jsxs("div",{className:R.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:R.input,value:Te(t,"time","08:00"),onChange:r=>a({time:r.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:R.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((r,i)=>{const l=Zp(t,"days",[0,1,2,3,4]),h=l.includes(i);return e.jsx("button",{className:`${R.dayBtn} ${h?R.dayBtnActive:""}`,onClick:()=>a({days:h?l.filter(b=>b!==i):[...l,i]}),children:r},i)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:R.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:R.input,min:-120,max:120,step:5,value:Rt(t,"offsetMinutes",0),onChange:r=>a({offsetMinutes:+r.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:R.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:R.input,value:Te(t,"deviceId",""),onChange:r=>a({deviceId:r.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]})]}),t.type==="sensor_threshold"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Atrybut",e.jsx("input",{className:R.input,value:Te(t,"attribute",""),onChange:r=>a({attribute:r.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:R.input,value:Te(t,"operator","above"),onChange:r=>a({operator:r.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:R.input,value:Rt(t,"threshold",0),onChange:r=>a({threshold:+r.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:R.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:R.input,value:Te(t,"webhookId",""),onChange:r=>a({webhookId:r.target.value})})]})})]})},Jp=({action:t,devices:s,onChange:n,onRemove:o})=>{const a=r=>n({...t,...r});return e.jsxs("div",{className:R.ruleBlock,children:[e.jsxs("div",{className:R.ruleBlockHeader,children:[e.jsxs("select",{className:R.typeSelect,value:t.type,onChange:r=>n({type:r.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:R.removeBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(z.NiceIcon,{name:"close",size:14})})]}),t.type==="device_control"&&e.jsxs("div",{className:R.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:R.input,value:Te(t,"deviceId",""),onChange:r=>a({deviceId:r.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]})]}),e.jsxs("label",{children:["Stan (JSON)",e.jsx("textarea",{className:R.textarea,rows:3,value:JSON.stringify(Xp(t,"state"),null,2),onChange:r=>{try{a({state:JSON.parse(r.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:R.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:R.input,value:Te(t,"channel","push"),onChange:r=>a({channel:r.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:R.input,value:Te(t,"message",""),onChange:r=>a({message:r.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:R.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:R.input,min:1,value:Rt(t,"delaySeconds",60),onChange:r=>a({delaySeconds:+r.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:R.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:R.input,value:Te(t,"url",""),onChange:r=>a({url:r.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:R.input,value:Te(t,"method","POST"),onChange:r=>a({method:r.target.value}),children:[e.jsx("option",{children:"GET"}),e.jsx("option",{children:"POST"}),e.jsx("option",{children:"PUT"}),e.jsx("option",{children:"PATCH"})]})]})]})]})},Qp=({automations:t,defaultAutomations:s,devices:n=[],onAutomationsChange:o,readOnly:a=!1,className:r,style:i,theme:l="light",tutorial:h})=>{var k;const[b,d]=z.useControllableState({value:t,defaultValue:s,fallbackValue:[],onChange:o,componentName:"NiceAutomationEditor"}),[x,v]=u.useState(null),y=x!==null&&b.some(c=>c.id===x)?x:((k=b[0])==null?void 0:k.id)??null,_=b.find(c=>c.id===y)??null,f=u.useCallback(c=>{_&&d(b.map(g=>g.id===_.id?{...g,...c}:g))},[_,b,d]),p=u.useCallback(()=>{const c={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};d([...b,c]),v(c.id)},[b,d]),C=u.useCallback(c=>{var g;d(b.filter(m=>m.id!==c)),y===c&&v(((g=b.find(m=>m.id!==c))==null?void 0:g.id)??null)},[b,y,d]),L=e.jsxs("div",{className:R.listPanel,children:[e.jsxs("div",{className:R.listHeader,children:[e.jsx("span",{className:R.listTitle,children:"Automatyzacje"}),!a&&e.jsx("button",{className:R.addBtn,onClick:p,children:"+ Dodaj"})]}),e.jsxs("div",{className:R.list,children:[b.map(c=>e.jsxs("div",{className:`${R.listItem} ${y===c.id?R.listItemActive:""}`,onClick:()=>v(c.id),children:[e.jsx("div",{className:R.listItemName,children:c.name}),e.jsxs("div",{className:R.listItemMeta,children:[c.triggers.length," wyzw · ",c.actions.length," akcji"]}),e.jsx("button",{className:`${R.enableToggle} ${c.enabled?R.enableOn:""}`,onClick:g=>{g.stopPropagation(),f({enabled:!c.enabled})},title:c.enabled?"Wyłącz":"Włącz","aria-label":c.enabled?"Wyłącz":"Włącz",children:e.jsx(z.NiceIcon,{name:c.enabled?"check":"close",size:14})})]},c.id)),b.length===0&&e.jsx("div",{className:R.emptyHint,children:"Brak automatyzacji"})]})]}),I=e.jsx("div",{className:R.detailPanel,children:_?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:R.detailHeader,children:[e.jsx("input",{className:R.nameInput,value:_.name,onChange:c=>f({name:c.target.value}),readOnly:a}),!a&&e.jsx("button",{className:R.deleteBtn,onClick:()=>C(_.id),children:"Usuń"})]}),e.jsxs("section",{className:R.section,children:[e.jsxs("div",{className:R.sectionHeader,children:[e.jsx("span",{className:R.sectionTitle,children:"Wyzwalacze"}),!a&&e.jsx("button",{className:R.sectionAddBtn,onClick:()=>f({triggers:[..._.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),_.triggers.map((c,g)=>e.jsx(Kp,{trigger:c,devices:n,onChange:m=>f({triggers:_.triggers.map((j,E)=>E===g?m:j)}),onRemove:()=>f({triggers:_.triggers.filter((m,j)=>j!==g)})},g)),_.triggers.length===0&&e.jsx("div",{className:R.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:R.section,children:[e.jsxs("div",{className:R.sectionHeader,children:[e.jsx("span",{className:R.sectionTitle,children:"Akcje"}),!a&&e.jsx("button",{className:R.sectionAddBtn,onClick:()=>f({actions:[..._.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),_.actions.map((c,g)=>e.jsx(Jp,{action:c,devices:n,onChange:m=>f({actions:_.actions.map((j,E)=>E===g?m:j)}),onRemove:()=>f({actions:_.actions.filter((m,j)=>j!==g)})},g)),_.actions.length===0&&e.jsx("div",{className:R.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:R.noSelection,children:"Wybierz automatyzację lub dodaj nową"})});return e.jsxs("div",{className:`nice-building-automation-editor ${R.root} ${l==="dark"?R.dark:""} ${r??""}`,style:{position:"relative",...i},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(z.NiceTutorialButton,{steps:z.resolveTutorial(h,Yp)})}),e.jsx(z.NiceAppShell,{flush:!0,className:R.shell,sidebar:L,children:I})]})},e_="_root_iuuw6_3",t_="_shell_iuuw6_29",s_="_dark_iuuw6_37",n_="_gridPanel_iuuw6_51",o_="_gridHeader_iuuw6_79",a_="_gridTitle_iuuw6_103",r_="_addBtn_iuuw6_119",i_="_sceneGrid_iuuw6_147",c_="_sceneCard_iuuw6_165",l_="_sceneCardActive_iuuw6_193",d_="_sceneCardSelected_iuuw6_199",u_="_sceneCardIcon_iuuw6_207",h_="_sceneCardName_iuuw6_217",m_="_sceneCardDevices_iuuw6_235",p_="_activeBadge_iuuw6_253",__="_activateBtn_iuuw6_263",f_="_emptyGrid_iuuw6_307",g_="_detailPanel_iuuw6_325",y_="_metaRow_iuuw6_343",x_="_iconPicker_iuuw6_355",b_="_currentIcon_iuuw6_363",v_="_iconGrid_iuuw6_381",j_="_iconOpt_iuuw6_397",w_="_iconOptActive_iuuw6_423",N_="_metaFields_iuuw6_433",k_="_nameInput_iuuw6_447",I_="_descInput_iuuw6_481",C_="_colorPicker_iuuw6_517",S_="_colorOpt_iuuw6_527",z_="_colorOptActive_iuuw6_543",L_="_targetsSection_iuuw6_553",$_="_targetsSectionHeader_iuuw6_565",T_="_addTargetBtn_iuuw6_587",M_="_targetRow_iuuw6_615",B_="_targetSelect_iuuw6_645",P_="_targetState_iuuw6_677",E_="_targetField_iuuw6_691",O_="_tempInput_iuuw6_717",A_="_removeTargetBtn_iuuw6_735",D_="_noTargets_iuuw6_775",R_="_detailActions_iuuw6_795",F_="_activateFullBtn_iuuw6_809",W_="_deleteBtn_iuuw6_841",Y={root:e_,shell:t_,dark:s_,gridPanel:n_,gridHeader:o_,gridTitle:a_,addBtn:r_,sceneGrid:i_,sceneCard:c_,sceneCardActive:l_,sceneCardSelected:d_,sceneCardIcon:u_,sceneCardName:h_,sceneCardDevices:m_,activeBadge:p_,activateBtn:__,emptyGrid:f_,detailPanel:g_,metaRow:y_,iconPicker:x_,currentIcon:b_,iconGrid:v_,iconOpt:j_,iconOptActive:w_,metaFields:N_,nameInput:k_,descInput:I_,colorPicker:C_,colorOpt:S_,colorOptActive:z_,targetsSection:L_,targetsSectionHeader:$_,addTargetBtn:T_,targetRow:M_,targetSelect:B_,targetState:P_,targetField:E_,tempInput:O_,removeTargetBtn:A_,noTargets:D_,detailActions:R_,activateFullBtn:F_,deleteBtn:W_},G_=[{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"}],nt=t=>t&&typeof t=="object"?t:{},q_=(t,s,n=!1)=>{const o=nt(t)[s];return typeof o=="boolean"?o:n},Dt=(t,s,n=0)=>{const o=nt(t)[s];return typeof o=="number"?o:n},V_=["video","eye-off","lightbulb","gamepad","briefcase","utensils","music","droplet","rocket","home","thermometer","lock","star","gift","heart","settings"],U_=["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"],H_=({target:t,devices:s,onChange:n,onRemove:o})=>{const a=s.find(r=>r.id===t.deviceId);return e.jsxs("div",{className:Y.targetRow,children:[e.jsxs("select",{className:Y.targetSelect,value:t.deviceId,onChange:r=>n({...t,deviceId:r.target.value}),children:[e.jsx("option",{value:"",children:"— urządzenie —"}),s.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),a&&e.jsxs("div",{className:Y.targetState,children:[e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:q_(t.state,"on",!1),onChange:r=>n({...t,state:{...nt(t.state),on:r.target.checked}})})]}),(a.type==="dimmer"||a.type==="light"||a.type==="rgb_light"||a.type==="led_strip")&&e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:Dt(t.state,"brightness",100),onChange:r=>n({...t,state:{...nt(t.state),brightness:+r.target.value}})}),e.jsxs("span",{children:[Dt(t.state,"brightness",100),"%"]})]}),(a.type==="thermostat"||a.type==="air_conditioner")&&e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:Y.tempInput,min:10,max:30,step:.5,value:Dt(t.state,"targetTemperature",20),onChange:r=>n({...t,state:{...nt(t.state),targetTemperature:+r.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:Y.removeTargetBtn,onClick:o,title:"Usuń","aria-label":"Usuń",children:e.jsx(z.NiceIcon,{name:"close",size:14})})]})},Y_=({scenes:t,defaultScenes:s,devices:n=[],activeSceneIds:o=[],onScenesChange:a,onActivate:r,readOnly:i=!1,className:l,style:h,theme:b="light",tutorial:d})=>{var m;const[x,v]=z.useControllableState({value:t,defaultValue:s,fallbackValue:[],onChange:a,componentName:"NiceSceneEditor"}),[y,_]=u.useState(null),f=y!==null&&x.some(j=>j.id===y)?y:((m=x[0])==null?void 0:m.id)??null,p=x.find(j=>j.id===f)??null,C=u.useCallback(j=>{p&&v(x.map(E=>E.id===p.id?{...E,...j}:E))},[p,x,v]),L=u.useCallback(()=>{const j={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"video",color:"var(--nice-primary-bg, #e0f2fe)"};v([...x,j]),_(j.id)},[x,v]),I=u.useCallback(j=>{var E;v(x.filter(F=>F.id!==j)),f===j&&_(((E=x.find(F=>F.id!==j))==null?void 0:E.id)??null)},[x,f,v]),k=()=>{if(!p)return;const j={deviceId:"",state:{on:!0},transitionMs:1e3};C({deviceTargets:[...p.deviceTargets,j]})},c=e.jsxs("div",{className:Y.gridPanel,children:[e.jsxs("div",{className:Y.gridHeader,children:[e.jsx("span",{className:Y.gridTitle,children:"Sceny"}),!i&&e.jsx("button",{className:Y.addBtn,onClick:L,children:"+ Nowa"})]}),e.jsxs("div",{className:Y.sceneGrid,children:[x.map(j=>{const E=o.includes(j.id),F=f===j.id;return e.jsxs("div",{className:`${Y.sceneCard} ${E?Y.sceneCardActive:""} ${F?Y.sceneCardSelected:""}`,style:{background:j.color??"var(--nice-bg-secondary, #f8fafc)"},onClick:()=>_(j.id),children:[e.jsx("div",{className:Y.sceneCardIcon,children:e.jsx(z.NiceIcon,{name:j.icon??"video",size:20})}),e.jsx("div",{className:Y.sceneCardName,children:j.name}),e.jsxs("div",{className:Y.sceneCardDevices,children:[j.deviceTargets.length," urządzeń",E&&e.jsx("span",{className:Y.activeBadge,children:e.jsx(z.NiceIcon,{name:"check",size:12})})]}),e.jsx("button",{className:Y.activateBtn,"aria-label":"Aktywuj",onClick:de=>{de.stopPropagation(),r==null||r(j.id)},children:e.jsx(z.NiceIcon,{name:"play",size:14})})]},j.id)}),x.length===0&&e.jsx("div",{className:Y.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),g=p?e.jsxs("div",{className:Y.detailPanel,children:[e.jsxs("div",{className:Y.metaRow,children:[e.jsxs("div",{className:Y.iconPicker,children:[e.jsx("span",{className:Y.currentIcon,children:e.jsx(z.NiceIcon,{name:p.icon??"video",size:20})}),e.jsx("div",{className:Y.iconGrid,children:V_.map(j=>e.jsx("button",{className:`${Y.iconOpt} ${p.icon===j?Y.iconOptActive:""}`,"aria-label":j,onClick:()=>C({icon:j}),children:e.jsx(z.NiceIcon,{name:j,size:16})},j))})]}),e.jsxs("div",{className:Y.metaFields,children:[e.jsx("input",{className:Y.nameInput,value:p.name,readOnly:i,onChange:j=>C({name:j.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:Y.descInput,value:p.description??"",readOnly:i,onChange:j=>C({description:j.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!i&&e.jsx("div",{className:Y.colorPicker,children:U_.map(j=>e.jsx("button",{className:`${Y.colorOpt} ${p.color===j?Y.colorOptActive:""}`,style:{background:j},onClick:()=>C({color:j})},j))}),e.jsxs("div",{className:Y.targetsSection,children:[e.jsxs("div",{className:Y.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!i&&e.jsx("button",{className:Y.addTargetBtn,onClick:k,children:"+ Dodaj"})]}),p.deviceTargets.map((j,E)=>e.jsx(H_,{target:j,devices:n,onChange:F=>C({deviceTargets:p.deviceTargets.map((de,ee)=>ee===E?F:de)}),onRemove:()=>C({deviceTargets:p.deviceTargets.filter((F,de)=>de!==E)})},E)),p.deviceTargets.length===0&&e.jsx("div",{className:Y.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:Y.detailActions,children:[e.jsxs("button",{className:Y.activateFullBtn,onClick:()=>r==null?void 0:r(p.id),children:[e.jsx(z.NiceIcon,{name:"play",size:14})," Aktywuj scenę"]}),!i&&e.jsx("button",{className:Y.deleteBtn,onClick:()=>I(p.id),children:"Usuń"})]})]}):void 0;return e.jsxs("div",{className:`nice-scene-editor ${Y.root} ${b==="dark"?Y.dark:""} ${l??""}`,style:{position:"relative",...h},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(z.NiceTutorialButton,{steps:z.resolveTutorial(d,G_)})}),e.jsx(z.NiceAppShell,{flush:!0,className:Y.shell,sidebar:c,children:g})]})};exports.LayerPanel=xs;exports.Minimap=bs;exports.NiceAutomationEditor=Qp;exports.NiceBuildingDashboard=Hh;exports.NiceDeviceControl=mp;exports.NiceFloorPlanEditor=Tn;exports.NiceLightControl=ks;exports.NiceSceneEditor=Y_;exports.NiceSpatialEditor=_d;exports.NiceSpatialViewer=Ku;exports.NiceThermostatControl=Cs;exports.NiceZoneCard=Ns;exports.ObjectLibrary=vs;exports.PropertiesPanel=js;exports.useMeasurement=eh;exports.useSnapToGrid=Qu;exports.useSpatialEditor=Ju;
|