@mp70/react-networks 0.1.4-alpha → 0.1.5-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/index.css +139 -1
- package/dist/index.d.mts +197 -5
- package/dist/index.d.ts +197 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ interface PortBlock {
|
|
|
39
39
|
* Network node types supported by the diagram
|
|
40
40
|
* @public
|
|
41
41
|
*/
|
|
42
|
-
type NetworkNodeType = 'rack' | 'switch' | 'router' | 'server' | 'fiber' | 'patch-panel' | 'device' | 'vertical-pdu';
|
|
42
|
+
type NetworkNodeType = 'rack' | 'switch' | 'router' | 'server' | 'fiber' | 'patch-panel' | 'device' | 'vertical-pdu' | 'splice' | 'splice-tray' | 'tube' | 'cable';
|
|
43
43
|
/**
|
|
44
44
|
* Device status states
|
|
45
45
|
* @public
|
|
@@ -118,6 +118,10 @@ interface NetworkNode {
|
|
|
118
118
|
uNumberingDirection?: UNumberingDirection;
|
|
119
119
|
/** Custom header text for rack nodes */
|
|
120
120
|
customHeaderText?: string;
|
|
121
|
+
/** Holder position within tray (1-12) for splice nodes */
|
|
122
|
+
holderPosition?: number;
|
|
123
|
+
/** Loss value in dB for splice nodes */
|
|
124
|
+
lossDb?: number;
|
|
121
125
|
/** Additional custom properties */
|
|
122
126
|
[key: string]: any;
|
|
123
127
|
};
|
|
@@ -126,7 +130,7 @@ interface NetworkNode {
|
|
|
126
130
|
* Network edge types
|
|
127
131
|
* @public
|
|
128
132
|
*/
|
|
129
|
-
type NetworkEdgeType = 'fiber' | 'ethernet' | 'power';
|
|
133
|
+
type NetworkEdgeType = 'fiber' | 'ethernet' | 'power' | 'smoothstep' | 'step';
|
|
130
134
|
/**
|
|
131
135
|
* Network edge data structure
|
|
132
136
|
* @public
|
|
@@ -242,6 +246,37 @@ interface FiberCable {
|
|
|
242
246
|
to: string;
|
|
243
247
|
};
|
|
244
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Splice configuration structure
|
|
251
|
+
* @public
|
|
252
|
+
*/
|
|
253
|
+
interface SpliceConfig {
|
|
254
|
+
/** Unique splice identifier */
|
|
255
|
+
id: string;
|
|
256
|
+
/** Splice display name */
|
|
257
|
+
name: string;
|
|
258
|
+
/** Holder position within tray (1-12) */
|
|
259
|
+
holder: number;
|
|
260
|
+
/** Loss value in dB */
|
|
261
|
+
lossDb?: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Splice tray configuration structure
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
interface SpliceTrayConfig {
|
|
268
|
+
/** Unique tray identifier */
|
|
269
|
+
id: string;
|
|
270
|
+
/** Tray display name */
|
|
271
|
+
name: string;
|
|
272
|
+
/** Tray position coordinates */
|
|
273
|
+
position: {
|
|
274
|
+
x: number;
|
|
275
|
+
y: number;
|
|
276
|
+
};
|
|
277
|
+
/** Splices in this tray */
|
|
278
|
+
splices: SpliceConfig[];
|
|
279
|
+
}
|
|
245
280
|
/**
|
|
246
281
|
* Network diagram component props
|
|
247
282
|
* @public
|
|
@@ -297,6 +332,10 @@ interface NetworkDiagramProps {
|
|
|
297
332
|
downloadButtonText?: string;
|
|
298
333
|
/** Download button styling options */
|
|
299
334
|
downloadButtonStyle?: React.CSSProperties;
|
|
335
|
+
/** Allow reconnecting existing edges from either end */
|
|
336
|
+
allowReconnectExisting?: boolean;
|
|
337
|
+
/** Use smoothstep edges for tube connections (both tube-to-cable and cable-to-tube). Default is fiber. */
|
|
338
|
+
useSmoothstepEdgesForTubes?: boolean;
|
|
300
339
|
}
|
|
301
340
|
|
|
302
341
|
declare const NetworkDiagram: React$1.FC<NetworkDiagramProps>;
|
|
@@ -310,7 +349,9 @@ declare const RackNode: React$1.FC<RackNodeProps>;
|
|
|
310
349
|
|
|
311
350
|
declare const FiberNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
312
351
|
|
|
313
|
-
declare const FiberEdge: React$1.FC<EdgeProps<NetworkEdge['data']
|
|
352
|
+
declare const FiberEdge: React$1.FC<EdgeProps<NetworkEdge['data']> & {
|
|
353
|
+
className?: string;
|
|
354
|
+
}>;
|
|
314
355
|
|
|
315
356
|
declare const PowerEdge: React$1.FC<EdgeProps>;
|
|
316
357
|
|
|
@@ -318,6 +359,30 @@ declare const DeviceNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
|
318
359
|
|
|
319
360
|
declare const VerticalPDU: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
320
361
|
|
|
362
|
+
declare const SpliceNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
363
|
+
|
|
364
|
+
declare const SpliceTrayNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* TubeNode
|
|
368
|
+
* - Rectangular node representing a buffer tube (horizontal orientation, rotated 180 degrees)
|
|
369
|
+
* - Renders 12 or 24 fiber handles on the top side with TIA-598 colors
|
|
370
|
+
* - Tube border tinted by tube index color (1..12 cycling)
|
|
371
|
+
* - startOn parameter controls handle positioning:
|
|
372
|
+
* - 'left-center' (default): handles centered on top, tube handle on bottom
|
|
373
|
+
* - 'left': handles on left side, tube handle on left
|
|
374
|
+
* - 'right': handles on right side with reversed colors, tube handle on right
|
|
375
|
+
*/
|
|
376
|
+
declare const TubeNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* CableNode
|
|
380
|
+
* - Visually mirrors TubeNode but represents an entire cable
|
|
381
|
+
* - Each colored handle corresponds to a tube within the cable
|
|
382
|
+
* - Displays cable summary text (fiber count + cable identifier)
|
|
383
|
+
*/
|
|
384
|
+
declare const CableNode: React$1.FC<NodeProps<NetworkNode['data']>>;
|
|
385
|
+
|
|
321
386
|
interface InventoryRackDTO {
|
|
322
387
|
id: string | number;
|
|
323
388
|
name: string;
|
|
@@ -461,6 +526,29 @@ declare const updateDeviceUPosition$1: (device: NetworkNode, rack: NetworkNode,
|
|
|
461
526
|
*/
|
|
462
527
|
declare const validateAndSnapDevice: (device: NetworkNode, rack: NetworkNode) => NetworkNode;
|
|
463
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Snap a splice to the nearest holder position within a tray
|
|
531
|
+
*/
|
|
532
|
+
declare const snapToSplicePosition: (splice: NetworkNode, tray: NetworkNode, newPosition: {
|
|
533
|
+
x: number;
|
|
534
|
+
y: number;
|
|
535
|
+
}, allNodes: NetworkNode[]) => {
|
|
536
|
+
x: number;
|
|
537
|
+
y: number;
|
|
538
|
+
holderPosition?: number;
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Find the next available holder position
|
|
542
|
+
*/
|
|
543
|
+
declare const findNextAvailableHolderPosition: (tray: NetworkNode, splice: NetworkNode, allNodes: NetworkNode[], startFrom?: number) => number;
|
|
544
|
+
/**
|
|
545
|
+
* Calculate splice position based on holder number within a tray
|
|
546
|
+
*/
|
|
547
|
+
declare const calculateSplicePositionFromNumber: (tray: NetworkNode, holderPosition: number) => {
|
|
548
|
+
x: number;
|
|
549
|
+
y: number;
|
|
550
|
+
};
|
|
551
|
+
|
|
464
552
|
/**
|
|
465
553
|
* Configuration options for building nodes from rack schema
|
|
466
554
|
*/
|
|
@@ -526,6 +614,66 @@ declare function addDeviceToRack(racks: RackConfig[], rackId: string, device: Ra
|
|
|
526
614
|
*/
|
|
527
615
|
declare function removeDeviceFromRack(racks: RackConfig[], rackId: string, deviceId: string): RackConfig[];
|
|
528
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Configuration options for building nodes from splice schema
|
|
619
|
+
*/
|
|
620
|
+
interface SpliceSchemaOptions {
|
|
621
|
+
/** How to handle splice placement conflicts */
|
|
622
|
+
conflictPolicy?: 'strict' | 'nearest';
|
|
623
|
+
/** Whether to validate all placements before creating nodes */
|
|
624
|
+
validatePlacements?: boolean;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Error thrown when splice placement conflicts occur in strict mode
|
|
628
|
+
*/
|
|
629
|
+
declare class SplicePlacementError extends Error {
|
|
630
|
+
trayId: string;
|
|
631
|
+
spliceId: string;
|
|
632
|
+
holder: number;
|
|
633
|
+
conflictWith?: string | undefined;
|
|
634
|
+
constructor(trayId: string, spliceId: string, holder: number, conflictWith?: string | undefined);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Validation result for splice placement
|
|
638
|
+
*/
|
|
639
|
+
interface SplicePlacementValidation {
|
|
640
|
+
isValid: boolean;
|
|
641
|
+
conflicts: Array<{
|
|
642
|
+
spliceId: string;
|
|
643
|
+
holder: number;
|
|
644
|
+
conflictWith: string;
|
|
645
|
+
}>;
|
|
646
|
+
outOfBounds: Array<{
|
|
647
|
+
spliceId: string;
|
|
648
|
+
holder: number;
|
|
649
|
+
max: number;
|
|
650
|
+
}>;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Validate splice placements within a tray schema
|
|
654
|
+
*/
|
|
655
|
+
declare function validateSplicePlacements(tray: SpliceTrayConfig, _options?: SpliceSchemaOptions): SplicePlacementValidation;
|
|
656
|
+
/**
|
|
657
|
+
* Build NetworkNode array from SpliceTrayConfig array with comprehensive validation
|
|
658
|
+
*/
|
|
659
|
+
declare function buildNodesFromSpliceConfig(trays: SpliceTrayConfig[], options?: SpliceSchemaOptions): NetworkNode[];
|
|
660
|
+
/**
|
|
661
|
+
* Create a SpliceTrayConfig from existing NetworkNode data (reverse operation)
|
|
662
|
+
*/
|
|
663
|
+
declare function createSpliceConfigFromNodes(nodes: NetworkNode[]): SpliceTrayConfig[];
|
|
664
|
+
/**
|
|
665
|
+
* Update splice holder position in a splice schema
|
|
666
|
+
*/
|
|
667
|
+
declare function updateSpliceHolderPosition(trays: SpliceTrayConfig[], trayId: string, spliceId: string, newHolder: number): SpliceTrayConfig[];
|
|
668
|
+
/**
|
|
669
|
+
* Add a splice to a tray schema
|
|
670
|
+
*/
|
|
671
|
+
declare function addSpliceToTray(trays: SpliceTrayConfig[], trayId: string, splice: SpliceConfig, options?: SpliceSchemaOptions): SpliceTrayConfig[];
|
|
672
|
+
/**
|
|
673
|
+
* Remove a splice from a tray schema
|
|
674
|
+
*/
|
|
675
|
+
declare function removeSpliceFromTray(trays: SpliceTrayConfig[], trayId: string, spliceId: string): SpliceTrayConfig[];
|
|
676
|
+
|
|
529
677
|
/**
|
|
530
678
|
* Power connector utilities for consistent styling across devices and PDUs
|
|
531
679
|
*/
|
|
@@ -577,6 +725,48 @@ declare function getDeviceConnectorType(deviceName: string): string;
|
|
|
577
725
|
*/
|
|
578
726
|
declare function getStatusColor(status: DeviceStatus | string): string;
|
|
579
727
|
|
|
728
|
+
/**
|
|
729
|
+
* TIA-598-C standard fiber optic color codes (12 base colors)
|
|
730
|
+
* Colors 1-12: Blue, Orange, Green, Brown, Slate, White, Red, Black, Yellow, Violet, Rose, Aqua
|
|
731
|
+
* @public
|
|
732
|
+
*/
|
|
733
|
+
declare const FIBER_COLORS_12: readonly ["#1f77b4", "#ff7f0e", "#2ca02c", "#8c564b", "#708090", "#ffffff", "#d62728", "#000000", "#ffdf00", "#8a2be2", "#ff69b4", "#00ffff"];
|
|
734
|
+
/**
|
|
735
|
+
* Fiber color ID type (1-24)
|
|
736
|
+
* @public
|
|
737
|
+
*/
|
|
738
|
+
type FiberColorId = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
|
|
739
|
+
/**
|
|
740
|
+
* Get the base color for a fiber color ID
|
|
741
|
+
* Colors 13-24 use the same base colors as 1-12
|
|
742
|
+
* @param id - Fiber color ID (1-24)
|
|
743
|
+
* @returns Hex color code
|
|
744
|
+
* @public
|
|
745
|
+
*/
|
|
746
|
+
declare function baseColorFor(id: FiberColorId | number): string;
|
|
747
|
+
/**
|
|
748
|
+
* Check if a fiber color ID uses a striped pattern (13-24)
|
|
749
|
+
* @param id - Fiber color ID (1-24)
|
|
750
|
+
* @returns True if the color should be striped
|
|
751
|
+
* @public
|
|
752
|
+
*/
|
|
753
|
+
declare function isStriped(id: FiberColorId | number): boolean;
|
|
754
|
+
/**
|
|
755
|
+
* Get CSS properties for a fiber color (solid or striped)
|
|
756
|
+
* Colors 13-24 use a black stripe pattern over the base color
|
|
757
|
+
* @param id - Fiber color ID (1-24)
|
|
758
|
+
* @returns CSS properties for the color
|
|
759
|
+
* @public
|
|
760
|
+
*/
|
|
761
|
+
declare function fiberSolidOrStriped(id: FiberColorId | number): React$1.CSSProperties;
|
|
762
|
+
/**
|
|
763
|
+
* Get the hex color code for a fiber color ID
|
|
764
|
+
* @param id - Fiber color ID (1-24)
|
|
765
|
+
* @returns Hex color code
|
|
766
|
+
* @public
|
|
767
|
+
*/
|
|
768
|
+
declare function getFiberColor(id: FiberColorId | number): string;
|
|
769
|
+
|
|
580
770
|
/**
|
|
581
771
|
* Calculate the bounding box of a rack node
|
|
582
772
|
* @param rack - The rack node
|
|
@@ -622,11 +812,13 @@ interface ReplaceEdgeOptions {
|
|
|
622
812
|
/** Connection parameters for the new edge */
|
|
623
813
|
connection: Connection;
|
|
624
814
|
/** Type of edge to create */
|
|
625
|
-
edgeType: 'power' | 'fiber';
|
|
815
|
+
edgeType: 'power' | 'fiber' | 'step' | 'smoothstep';
|
|
626
816
|
/** Function to calculate zIndex for the edge */
|
|
627
817
|
selectEdgeZIndex: (edge: NetworkEdge) => number;
|
|
628
818
|
/** Whether to find edge by source or target */
|
|
629
819
|
findBy: 'source' | 'target';
|
|
820
|
+
/** Optional edge data to set on the new edge */
|
|
821
|
+
data?: NetworkEdge['data'];
|
|
630
822
|
}
|
|
631
823
|
/**
|
|
632
824
|
* Replace an existing edge with a new connection
|
|
@@ -670,4 +862,4 @@ declare function useNetworkDiagram(store: NetworkDiagramStore): NetworkDiagramSt
|
|
|
670
862
|
declare function useNodes(store: NetworkDiagramStore): NetworkNode[];
|
|
671
863
|
declare function useEdges(store: NetworkDiagramStore): NetworkEdge[];
|
|
672
864
|
|
|
673
|
-
export { DeviceNode, DevicePlacementError, type DevicePlacementValidation, type FiberCable, FiberEdge, FiberNode, NetworkDiagram, type NetworkDiagramProps, type NetworkEdge, type NetworkNode, POWER_CONNECTORS, type Port, type PortBlock, PowerEdge, type RackConfig, type RackDevice, RackNode, type RackSchemaOptions, type ReplaceEdgeOptions, VerticalPDU, Width, addDeviceToRack, buildNodesFromRackConfig, calculateDevicePositionFromU, createNetworkDiagramStore, createRackConfigFromNodes, findNearestRack, findNextAvailableUPosition, generateLayout, getConnectorConfig, getDeviceConnectorType, getPDUPortType, getPowerPortStyle, getRackBounds, getStatusColor, inventoryCableToNetworkEdge, inventoryDeviceToNetworkNode, inventoryRackToNetworkNode, inventoryToNetworkDiagram, isHighPowerConnector, isPointInRack, isUPositionAvailable, removeDeviceFromRack, replaceEdge, snapToUPosition, updateDeviceUPosition$1 as updateDeviceUPosition, updateDeviceUPosition as updateDeviceUPositionInSchema, useEdges as useDiagramEdges, useNodes as useDiagramNodes, useNetworkDiagram, validateAndSnapDevice, validateRackDevicePlacements };
|
|
865
|
+
export { CableNode, DeviceNode, DevicePlacementError, type DevicePlacementValidation, FIBER_COLORS_12, type FiberCable, type FiberColorId, FiberEdge, FiberNode, NetworkDiagram, type NetworkDiagramProps, type NetworkEdge, type NetworkNode, POWER_CONNECTORS, type Port, type PortBlock, PowerEdge, type RackConfig, type RackDevice, RackNode, type RackSchemaOptions, type ReplaceEdgeOptions, type SpliceConfig, SpliceNode, SplicePlacementError, type SplicePlacementValidation, type SpliceSchemaOptions, type SpliceTrayConfig, SpliceTrayNode, TubeNode, VerticalPDU, Width, addDeviceToRack, addSpliceToTray, baseColorFor, buildNodesFromRackConfig, buildNodesFromSpliceConfig, calculateDevicePositionFromU, calculateSplicePositionFromNumber, createNetworkDiagramStore, createRackConfigFromNodes, createSpliceConfigFromNodes, fiberSolidOrStriped, findNearestRack, findNextAvailableHolderPosition, findNextAvailableUPosition, generateLayout, getConnectorConfig, getDeviceConnectorType, getFiberColor, getPDUPortType, getPowerPortStyle, getRackBounds, getStatusColor, inventoryCableToNetworkEdge, inventoryDeviceToNetworkNode, inventoryRackToNetworkNode, inventoryToNetworkDiagram, isHighPowerConnector, isPointInRack, isStriped, isUPositionAvailable, removeDeviceFromRack, removeSpliceFromTray, replaceEdge, snapToSplicePosition, snapToUPosition, updateDeviceUPosition$1 as updateDeviceUPosition, updateDeviceUPosition as updateDeviceUPositionInSchema, updateSpliceHolderPosition, useEdges as useDiagramEdges, useNodes as useDiagramNodes, useNetworkDiagram, validateAndSnapDevice, validateRackDevicePlacements, validateSplicePlacements };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var Lt=require('react'),reactflow=require('reactflow'),htmlToImage=require('html-to-image'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Lt__default=/*#__PURE__*/_interopDefault(Lt);var Pt=()=>"bottom-up",se=e=>e.data.uNumberingDirection||Pt(),xe=(e,o,t)=>t==="bottom-up"?o-e+1:e,Ne=(e,o,t)=>t==="bottom-up"?o-e+1:e;var Te=(e,o,t,i)=>{if(!e.parentId||e.parentId!==o.id)return t;let r=e.data.uHeight||1,a=o.data.uHeight||42,c=se(o),s=60,d=t.y-s,f=Math.round(d/20)+1,h;c==="bottom-up"?h=xe(f,a,c)-r+1:h=xe(f,a,c);let m=a-r+1,k=Math.max(1,Math.min(m,h));if(c==="top-down"&&h<=1&&(k=1),!Ie(o,e,k,i)){let P=ke(o,e,i,k);P!==k&&(k=P);}let v;if(c==="bottom-up"){let P=k+r-1,$=Ne(P,a,c);v=s+($-1)*20-1;}else {let P=Ne(k,a,c);v=s+(P-1)*20-1;}return {x:t.x,y:v,uPosition:k}},Ie=(e,o,t,i)=>{let r=o.data.uHeight||1,a=e.data.uHeight||42;if(t<1||t+r-1>a)return false;let c=i.filter(s=>s.type==="device"&&s.parentId===e.id&&s.id!==o.id);for(let s of c){let d=s.data.uPosition||1,f=s.data.uHeight||1,h=t,m=t+r-1,k=d,v=d+f-1;if(h<=v&&m>=k)return false}return true},ke=(e,o,t,i=1)=>{let r=o.data.uHeight||1,a=e.data.uHeight||42;for(let c=i;c<=a-r+1;c++)if(Ie(e,o,c,t))return c;return 1},ue=(e,o,t=1)=>{let i=60,r=se(e),a=e.data.uHeight||42,c=Ne(o,a,r),s;if(r==="bottom-up"){let d=o+t-1,f=Ne(d,a,r);s=i+(f-1)*20-1;}else s=i+(c-1)*20-1;return {x:0,y:s}},Qe=(e,o,t)=>{let i=e.data.uHeight||1,r=ue(o,t,i);return {...e,position:r,data:{...e.data,uPosition:t}}},Dt=(e,o)=>{let t=e.data.uPosition||1,i=e.data.uHeight||1,r=o.data.uHeight||42,a=Math.max(1,Math.min(r-i+1,t));return a!==t?Qe(e,o,a):e};function Z(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var Ue=({data:e,selected:o,id:t,onViewChange:i,onRackFaceChange:r,isDragOver:a=false})=>{let{label:c,ports:s=0,status:d="active",uHeight:f=42,face:h="front",customHeaderText:m}=e,{getNodes:k,setNodes:v}=reactflow.useReactFlow(),P=k(),[$,b]=Lt.useState(true),T=()=>{let D=se({data:e})==="bottom-up"?"top-down":"bottom-up";v(p=>p.map(l=>l.id===t?{...l,data:{...l.data,uNumberingDirection:D}}:l));},B=()=>{let u=h==="front"?"rear":"front";r?(r(t,u),i&&P.filter(p=>p.parentId===t).forEach(p=>{i(p.id,u);})):i?P.filter(p=>p.parentId===t).forEach(p=>{i(p.id,u);}):v(D=>D.map(p=>p.id===t?{...p,data:{...p.data,face:u}}:p.parentId===t?{...p,data:{...p.data,view:u}}:p));},M=()=>{let u=[],D=60,p=se({data:e});for(let l=1;l<=f;l++){let I=D+(l-1)*20-4,U=xe(l,f,p);u.push(jsxRuntime.jsx("div",{style:{position:"absolute",left:"-35px",top:`${I}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${20}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:U},l));}return u};return jsxRuntime.jsxs("div",{className:`rack-node ${o?"selected":""} ${a?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${Z(d)}`,borderRadius:"8px",padding:0,width:`${300}px`,height:`${60+f*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:a?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxRuntime.jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:c}),jsxRuntime.jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[m?jsxRuntime.jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:m}):jsxRuntime.jsxs("span",{children:[typeof s=="number"?s:0," ports"]})," \u2022 ",f,"U \u2022 ",h]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsxRuntime.jsx("button",{onPointerDown:u=>{u.stopPropagation();},onMouseDown:u=>{u.stopPropagation();},onClick:u=>{u.stopPropagation(),u.preventDefault(),b(!$);},style:{background:$?"#10b981":"#374151",color:$?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${$?"Hide":"Show"} U markers`,children:"U"}),jsxRuntime.jsx("button",{onPointerDown:u=>{u.stopPropagation();},onMouseDown:u=>{u.stopPropagation();},onClick:u=>{u.stopPropagation(),u.preventDefault(),T();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch U numbering to ${se({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:se({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsxRuntime.jsx("button",{onPointerDown:u=>{u.stopPropagation();},onMouseDown:u=>{u.stopPropagation();},onClick:u=>{u.stopPropagation(),u.preventDefault(),B();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${h==="front"?"rear":"front"} view`,children:h==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsxRuntime.jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${f*20}px`,overflow:"hidden"}}),$&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:M()})]})};var _e=({data:e,selected:o})=>{let{label:t,status:i="active"}=e;return jsxRuntime.jsxs("div",{className:`fiber-node ${o?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${Z(i)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Top}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Bottom}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right}),jsxRuntime.jsx("div",{style:{textAlign:"center"},children:jsxRuntime.jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:t})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:Z(i),borderRadius:"50%"}})]})};var Me=({id:e,sourceX:o,sourceY:t,targetX:i,targetY:r,sourcePosition:a,targetPosition:c,data:s,selected:d,style:f={}})=>{let[h,m,k]=reactflow.getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:i,targetY:r,targetPosition:c}),{bandwidth:v,length:P,color:$="#00FFFF"}=s||{},b={...f,stroke:$,strokeWidth:d?3:2,strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:h,style:b}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:d&&s&&(v||P)&&jsxRuntime.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${m}px,${k}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${$}`,pointerEvents:"none",zIndex:9999},children:[v&&jsxRuntime.jsx("div",{children:v}),P&&jsxRuntime.jsxs("div",{children:[P,"m"]})]})})]})};var ze=({id:e,sourceX:o,sourceY:t,targetX:i,targetY:r,sourcePosition:a,targetPosition:c,style:s={},data:d,markerEnd:f})=>{let[h]=reactflow.getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:i,targetY:r,targetPosition:c}),m=d?.connectorType||"C13";return jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:h,markerEnd:f,style:(()=>{let v={stroke:d?.color||"#f59e0b",strokeWidth:m==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...s};return m==="C19"?{...v,strokeDasharray:"none"}:{...v,strokeDasharray:"6,3"}})()})};var et=(t=>(t.FULL="full",t.HALF="half",t))(et||{});var Be={C13:{type:"C13",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C14:{type:"C14",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C19:{type:"C19",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1},C20:{type:"C20",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1}};function ge(e){let o=Be[e];if(!o)throw new Error(`Unknown connector type: ${e}`);let t=o.amperage===16,i=t?12:8,r=t?10:5,a=t?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:i,height:r,color:o.color,borderColor:o.borderColor,fontSize:t?"3px":"4px",...a}}function De(e){let o=Be[e];if(!o)throw new Error(`Unknown connector type: ${e}`);return o}function At(e){return De(e).amperage===16}function We(e){return e%10<8?"C13":"C19"}function Re(e){let o=e.toLowerCase();return o.includes("mx304")||o.includes("mx480")||o.includes("mx960")?"C20":"C14"}var Oe=({data:e,selected:o})=>{let{label:t,status:i="active",deviceType:r="server",manufacturer:a,role:c,uHeight:s=1,width:d="full",ports:f=[],rearPorts:h=[],view:m}=e,k=m||(h.length>0&&f.length===0?"rear":"front"),v={};v["net-top"]="front",v["net-bottom"]="front",f.length>0&&f.forEach(u=>{u.ports.forEach(D=>{let p=D.type?.includes("power")?D.label:`${u.name}-${D.label}`;v[p]="front";});}),v["pwr-left-1"]="rear",v["pwr-left-2"]="rear",v["net-right-1"]="rear",v["net-right-2"]="rear",h.length>0&&h.forEach(u=>{u.ports.forEach(D=>{let p=D.type?.includes("power")?D.label:`${u.name}-${D.label}`;v[p]="rear";});});let P=s*20,$=d==="half"?"150px":"304px",b=d==="half"?"150px":void 0,T=(u,D)=>{let p=[];if(u.length===0)return p;let l=Math.max(4,Math.floor(P*.4)),I=Math.max(2,Math.floor(P*.2));return u.forEach((U,C)=>{U.ports.forEach((y,R)=>{let G=!!y.type&&y.type.includes("power");if(D==="front"&&G)return;let A=G?`${y.label}`:`${U.name}-${y.label}`,ee=y.connected,E="#6b7280";if(ee)if(y.type?.includes("power"))E=y.type==="power_c19"?"#fbbf24":"#f59e0b";else if(y.type==="console"||y.type==="mgmt")E="#8b5cf6";else if(y.type==="usb")E="#10b981";else switch(y.cableType){case "smf":E="#fbbf24";break;case "cat6":E="#8b5cf6";break;case "om3":E="#06b6d4";break;case "om4":E="#8b5cf6";break;case "om5":E="#84cc16";break;case "cat5e":E="#3b82f6";break;case "cat6a":E="#ef4444";break;case "cat7":E="#f97316";break;case "fiber":E="#3b82f6";break;case "ethernet":E="#10b981";break;default:E="#10b981";}let W=reactflow.Position.Top,F={width:`${l}px`,height:`${I}px`,background:ee?E:"#6b7280",border:`1px solid ${ee?E:"#374151"}`,borderRadius:"1px",cursor:"pointer"};if(D==="front")R%2===0?(W=reactflow.Position.Top,F.transform="translateY(50%)",F.left=`${R/2*(l+2)}px`):(W=reactflow.Position.Bottom,F.transform="translateY(-50%)",F.left=`${(R-1)/2*(l+2)}px`);else if((r?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel")R%2===0?(W=reactflow.Position.Top,F.transform="translateY(50%)",F.left=`${R/2*(l+2)}px`):(W=reactflow.Position.Bottom,F.transform="translateY(-50%)",F.left=`${(R-1)/2*(l+2)}px`);else if(y.type?.includes("power")){W=reactflow.Position.Left,F.transform="translateX(50%)";let we=P<=20?10:20,de=P<=20?30:50;F.top=`${we+R*de}%`;let He=Re(t),ae=ge(He);F={...F,width:`${ae.width}px`,height:`${ae.height}px`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:ae.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:ae.borderRadius,clipPath:ae.clipPath};}else W=reactflow.Position.Right,F.transform="translateX(-50%)",F.top=`${25+R*50}%`;let ye=(r?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",oe;if(G)oe="target";else if(r==="switch"||r==="router")oe="source",p.push(jsxRuntime.jsx(reactflow.Handle,{id:`${A}-target`,type:"target",position:W,style:F,title:`${U.name} - ${y.label} (input) ${ee?"(connected)":"(disconnected)"}`},`${A}-target`));else if(ye){oe=D==="rear"?"source":"target";let ie=D==="rear"?"target":"source";p.push(jsxRuntime.jsx(reactflow.Handle,{id:`${A}-${ie}`,type:ie,position:W,style:F,title:`${U.name} - ${y.label} (${ie}) ${ee?"(connected)":"(disconnected)"}`},`${A}-${ie}`));}else oe=ee?"source":"target";p.push(jsxRuntime.jsx(reactflow.Handle,{id:A,type:oe,position:W,style:F,title:`${U.name} - ${y.label} ${ee?"(connected)":"(disconnected)"}`,children:G?R+1:void 0},A));});}),p},B=()=>{let u=[],D=Math.max(4,Math.floor(P*.4)),p=Math.max(2,Math.floor(P*.2));if(k==="front"){if(f.length>0)return T(f,"front");if(r==="switch"&&(t.toLowerCase().includes("agg")||t.toLowerCase().includes("core")||c==="agg"||c==="core"))return M();u.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-top",type:"target",position:reactflow.Position.Top,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(50%)"},title:"Network Port (Top)"},"net-top")),u.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-bottom",type:"target",position:reactflow.Position.Bottom,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(-50%)"},title:"Network Port (Bottom)"},"net-bottom"));}else if(k==="rear"){if(h.length>0)return T(h,"rear");let l=r==="switch",U=(r?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel";if(!U){let C=Re(t),y=De(C),R=ge(C),G=P<=20?"10%":"25%";u.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-1",type:"target",position:reactflow.Position.Left,style:{width:`${R.width}px`,height:`${R.height}px`,background:R.color,border:`1px solid ${R.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:G,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:R.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:R.borderRadius,clipPath:R.clipPath},title:`Power Port 1 (${y.type}) - ${y.voltage}V, ${y.amperage}A`,children:"1"},"pwr-1"));let A=P<=20?"50%":"75%";u.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-2",type:"target",position:reactflow.Position.Left,style:{width:`${R.width}px`,height:`${R.height}px`,background:R.color,border:`1px solid ${R.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:A,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:R.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:R.borderRadius,clipPath:R.clipPath},title:`Power Port 2 (${y.type}) - ${y.voltage}V, ${y.amperage}A`,children:"2"},"pwr-2"));}!l&&!U&&(u.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-1",type:"target",position:reactflow.Position.Right,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"25%"},title:"Network Port 1 (Right)"},"net-right-1")),u.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-2",type:"target",position:reactflow.Position.Right,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"75%"},title:"Network Port 2 (Right)"},"net-right-2")));}return u},M=()=>{let u=[],D=Math.max(10,Math.floor(P*.45)),p=Math.max(5,Math.floor(P*.25));for(let l=1;l<=16;l++){let I=jsxRuntime.jsx(reactflow.Handle,{id:`port-${l}`,type:"source",position:reactflow.Position.Top,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(50%)",zIndex:1e3,left:`${(l-1)*(D+2)}px`},title:`Port ${l}`},`port-${l}`);u.push(I);}for(let l=17;l<=32;l++){let I=l-16,U=jsxRuntime.jsx(reactflow.Handle,{id:`port-${l}`,type:"source",position:reactflow.Position.Bottom,style:{width:`${D}px`,height:`${p}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(-50%)",zIndex:1e3,left:`${(I-1)*(D+2)}px`},title:`Port ${l}`},`port-${l}`);u.push(U);}for(let l=1;l<=4;l++){let I=Math.max(4,Math.floor(P*.3)),U=Math.max(3,Math.floor(P*.15));u.push(jsxRuntime.jsx(reactflow.Handle,{id:`uplink-${l}`,type:"source",position:reactflow.Position.Right,style:{width:`${I}px`,height:`${U}px`,background:"#8b5cf6",border:"0.5px solid #7c3aed",borderRadius:"0.5px",cursor:"pointer",transform:"translateX(-50%)"},title:`Uplink ${l}`},`uplink-${l}`));}return u};return jsxRuntime.jsxs("div",{className:`device-node ${o?"selected":""}`,style:{background:"#1f2937",border:`1px solid ${Z(i)}`,borderRadius:"2px",padding:"0px",width:$,...b&&{left:b},height:`${P}px`,color:"white",fontFamily:"monospace",fontSize:"8px",boxShadow:o?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",cursor:"grab",marginBottom:"0px",boxSizing:"border-box",marginTop:"0px",marginLeft:"0px",marginRight:"0px"},children:[jsxRuntime.jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),s>1&&jsxRuntime.jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:a})]}),s>1&&jsxRuntime.jsxs("div",{style:{position:"absolute",bottom:"1px",right:"1px",background:"#374151",color:"#9ca3af",padding:"1px 2px",borderRadius:"1px",fontSize:"6px",lineHeight:"1"},children:[s,"U"]}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:Z(i),borderRadius:"50%"}}),B()]})};var Ve=({data:e,selected:o})=>{let{label:t,status:i="active",heightCm:r=100,powerPorts:a=36,widthPx:c=15,mgmt_unit:s}=e,d=r*4.2,f=()=>{let k=Math.ceil(a/10),v=Array(10).fill(0).map((p,l)=>l<8?"10A":"16A");for(let p=0,l=0;p<k;++p)for(let I=0;I<10&&l<a;++I,++l){v[I];}let T=[],B=15,D=(d-B-3)/(a-9)*.5;for(let p=0;p<a;p++){let l=B-2+D*p,I=`${p+1}`;if(s&&(s==="top"&&p===0||s==="middle"&&p===Math.floor(a/2)||s==="bottom"&&p===a-1)){T.push(h(l));continue}let C=We(p),y=ge(C),R=Math.round((c-y.width)/2-1);T.push(jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:I,style:{position:"absolute",left:`${R}px`,top:`${l-y.height/2}px`,width:`${y.width}px`,height:`${y.height}px`,background:y.color,border:`1px solid ${y.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:y.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:y.borderRadius,clipPath:y.clipPath},title:`Power Port ${p+1} (${C})`,children:p+1},`handle-${I}`));}return T},h=m=>jsxRuntime.jsxs("div",{style:{position:"absolute",left:`${(c-16)/2}px`,top:`${m-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxRuntime.jsxs("div",{className:`vertical-pdu-node ${o?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${Z(i)}`,borderRadius:"2px",padding:0,width:`${c}px`,height:`${d}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:t})}),jsxRuntime.jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${d-20}px`,overflow:"hidden"},children:f()})]})};function Mt(e,o){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let t=o.edges.some(b=>b.source===e.source&&b.sourceHandle===e.sourceHandle),i=o.edges.some(b=>b.target===e.target&&b.targetHandle===e.targetHandle);if(t)return {valid:false,reason:"Source port is already connected"};if(i)return {valid:false,reason:"Target port is already connected"};let r=e.sourceHandle,a=e.targetHandle,c=o.nodes.find(b=>b.id===e.source),s=o.nodes.find(b=>b.id===e.target),d=(b,T)=>{if(!b)return false;let B=b.startsWith("pwr")||b.startsWith("power"),M=T?.type==="vertical-pdu"&&b!=="mgmt-net-1";return B||M},f=(b,T)=>{if(!b)return false;if(T?.type==="vertical-pdu"&&b==="mgmt-net-1")return true;let B=b.startsWith("net-")||b.startsWith("port-")||b.startsWith("uplink-")||b.includes("Fiber")||b.includes("Ports"),M=/^[A-Z0-9]+-\d+$/.test(b)&&!b.startsWith("pwr")&&!b.startsWith("power");return B||M},h=d(r,c),m=d(a,s),k=f(r,c),v=f(a,s);if(h&&v||m&&k)return {valid:false,reason:"Cannot connect network cable to power port"};if(h&&!m||m&&!h)return {valid:false,reason:"Power ports must connect to power-compatible ports"};let P=c?.type==="vertical-pdu",$=s?.type==="vertical-pdu";if(h||m){let b=P?s:$?c:null,T=P?c:$?s:null;if(b&&T&&o.edges.filter(u=>{let D=d(u.sourceHandle||""),p=d(u.targetHandle||""),l=u.source===b.id||u.target===b.id;return (D||p)&&l}).some(u=>u.source===T.id||u.target===T.id))return {valid:false,reason:"Dual-feed required: connect second power to a different PDU"}}return {valid:true}}function zt(e,o){if(!o)return;let t=o.data??{},i=t.handleSideMap;if(i&&i[e])return i[e];if(e==="net-top"||e==="net-bottom")return "front";if(e==="pwr-left-1"||e==="pwr-left-2"||e==="net-right-1"||e==="net-right-2")return "rear";let r=Array.isArray(t.ports)?t.ports:[],a=Array.isArray(t.rearPorts)?t.rearPorts:[];if(e.startsWith("pwr")||e.includes("power"))return "rear";for(let s of r)for(let d of s.ports||[])if((!!d.type&&String(d.type).includes("power")?d.label:`${s.name}-${d.label}`)===e)return "front";for(let s of a)for(let d of s.ports||[])if((!!d.type&&String(d.type).includes("power")?d.label:`${s.name}-${d.label}`)===e)return "rear"}function je(e={},o={}){let t={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},i=new Set;return {getState:()=>t,setState:m=>{t={...t,...m},i.forEach(k=>k(t));},subscribe:m=>(i.add(m),()=>i.delete(m)),selectEdgeZIndex:m=>{let k=t.nodes.find(D=>D.id===m.target);if(!k||k.type!=="device")return 1e3;let v=k.data?.view||"front",P=zt(m.targetHandle||"",k);if(P)return v===P?1e3:500;let $=(m.targetHandle||"").toString(),b=$.toLowerCase(),T=b.startsWith("pwr")||b.startsWith("power"),B=b.startsWith("net-")||b.startsWith("port-")||b.startsWith("uplink-")||b.includes("fiber")||b.includes("ports"),M=/^[A-Z0-9]+-\d+$/i.test($)&&!b.startsWith("pwr")&&!b.startsWith("power"),u=B||M;return T?v==="rear"?1e3:500:u?v==="front"?1e3:500:1e3},validateConnection:m=>(o.validateConnection||Mt)(m,t),selectNodeById:m=>t.nodes.find(k=>k.id===m),selectConnectedEdges:m=>t.edges.filter(k=>k.source===m||k.target===m)}}function Bt(e){let o=r=>e.subscribe(r),t=()=>e.getState();return Lt.useSyncExternalStore(o,t,t)}function Xe(e){let o=i=>e.subscribe(i),t=()=>e.getState().nodes;return Lt.useSyncExternalStore(o,t,t)}function Ge(e){let o=i=>e.subscribe(i),t=()=>e.getState().edges;return Lt.useSyncExternalStore(o,t,t)}function nt(e){return e.selectEdgeZIndex}function it(e){let o=300,t=(e.data.uHeight||42)*20,i=e.position.x,r=e.position.x+o,a=e.position.y,c=e.position.y+t;return {left:i,right:r,top:a,bottom:c}}function Se(e,o){let t=it(o);return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function Ce(e,o){let t=null,i=1/0;for(let r of o){if(!Se(e,r))continue;let a=Math.sqrt(Math.pow(e.x-r.position.x,2)+Math.pow(e.y-r.position.y,2));a<i&&(i=a,t=r);}return t}function me(e){let{edges:o,connection:t,edgeType:i,selectEdgeZIndex:r,findBy:a}=e,c=a==="source"?t.sourceHandle:t.targetHandle,s=a==="source"?t.source:t.target;if(!c||!s)return null;let d=o.find(v=>a==="source"?v.source===s&&v.sourceHandle===c:v.target===s&&v.targetHandle===c);if(!d)return null;let f=o.filter(v=>v.id!==d.id),h=reactflow.addEdge(t,f),m=h[h.length-1],k={...m,type:i,zIndex:r({...t,id:m.id,type:i}),style:{...m.style,zIndex:r({...t,id:m.id,type:i})}};return [...h.slice(0,-1),k]}var eo=(e,o,t)=>({rack:i=>jsxRuntime.jsx(Ue,{...i,onViewChange:e,onRackFaceChange:o,isDragOver:t===i.id}),fiber:_e,device:Oe,"vertical-pdu":Ve}),to={fiber:Me,power:ze},oo=({nodes:e,edges:o,initialNodes:t,initialEdges:i,onNodesChange:r,onEdgesChange:a,store:c,debug:s,onNodeClick:d,onEdgeClick:f,onViewChange:h,onRackFaceChange:m,className:k,style:v,alignRacksToBottom:P,colorMode:$="dark",onInit:b,onFlowMethods:T,showDownloadButton:B=false,downloadButtonPosition:M="top-right",downloadButtonText:u="Download Image",downloadButtonStyle:D})=>{let p=Array.isArray(e)&&Array.isArray(o),l=Lt__default.default.useMemo(()=>c||je({nodes:p?e||[]:t||e||[],edges:p?o||[]:i||o||[],debug:s}),[c,p,s]),I=Xe(l),U=Ge(l),[C,y,R]=reactflow.useNodesState(I),[G,A,ee]=reactflow.useEdgesState(U),E=nt(l),W=Lt.useRef(null),{toObject:F,setViewport:Ee,setNodes:ye,setEdges:oe}=reactflow.useReactFlow();Lt.useEffect(()=>{T&&T({toObject:F,setViewport:Ee,setNodes:n=>{ye(n),l.setState({nodes:n});},setEdges:n=>{oe(n),l.setState({edges:n});},toImage:n=>W.current?htmlToImage.toPng(W.current,n):Promise.reject(new Error("ReactFlow wrapper not available"))});},[T,F,Ee,ye,oe,l]);let ie=Lt.useCallback(()=>{if(!W.current){s&&console.error("ReactFlow wrapper ref is not available");return}htmlToImage.toPng(W.current,{filter:n=>!(n?.classList?.contains("react-flow__minimap")||n?.classList?.contains("react-flow__controls")||n?.classList?.contains("react-flow__attribution")||n?.classList?.contains("download-button")||n?.tagName==="BUTTON"),backgroundColor:$==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(n=>{let g=document.createElement("a");g.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,g.href=n,g.click();}).catch(n=>{s&&console.error("Error downloading image:",n);});},[$,s]),[we,de]=Lt.useState(null),He=Lt.useMemo(()=>eo(h,m,we),[h,m,we]),ae=Lt.useMemo(()=>to,[]),re=Lt.useRef(C);Lt.useEffect(()=>{re.current=C;},[C]);let te=Lt.useRef(G);Lt.useEffect(()=>{te.current=G;},[G]),Lt.useEffect(()=>{y(I);},[I,y]),Lt.useEffect(()=>{A(U);},[U,A]),Lt.useEffect(()=>{p&&l.setState({nodes:e||[]});},[p,e,l]),Lt.useEffect(()=>{p&&l.setState({edges:o||[]});},[p,o,l]),Lt.useEffect(()=>{if(!P||!C||C.length===0)return;let n=C.filter(H=>H.type==="rack");if(n.length===0)return;let g=n.map(H=>{let le=H.data?.uHeight||42,$e=60+le*20;return (H.position?.y||0)+$e}),w=Math.min(...g),N=Math.max(...g);if(N-w<20)return;let x=N,V=C.map(H=>{if(H.type!=="rack")return H;let le=H.data?.uHeight||42,$e=60+le*20,vt=(H.position?.y||0)+$e,Je=x-vt;return Math.abs(Je)<5?H:{...H,position:{x:H.position?.x||0,y:(H.position?.y||0)+Je}}});V.some((H,_)=>H.position!==C[_].position)&&y(V);},[P,C,y]);let q=Lt.useCallback(n=>re.current.find(g=>g.id===n),[]);Lt.useEffect(()=>{A(n=>n.map(g=>{let w=E(g);return {...g,zIndex:w,style:{...g.style,zIndex:w}}}));},[C,A,E]),Lt.useEffect(()=>{let n=C.map(w=>{if(w.type==="device"&&w.parentId&&w.data.uPosition&&(!w.position||w.position.x===0&&w.position.y===0)){let N=q(w.parentId);if(N){let S=ue(N,w.data.uPosition);return {...w,position:S}}}return w});n.some((w,N)=>w.position!==C[N].position)&&y(n);},[C,y,q]);let ft=Lt.useCallback(n=>{let g=n.map(w=>{if(w.type==="position"&&w.position){let N=q(w.id);if(N&&N.type==="device"&&N.parentId){let S=q(N.parentId);if(S){let x=Te(N,S,w.position,re.current);if(x.uPosition!==void 0){let V={...N,data:{...N.data,uPosition:x.uPosition}};y(O=>O.map(H=>H.id===N.id?V:H));}return {...w,position:{x:x.x,y:x.y}}}}if(N&&N.type==="device"&&N.parentId){let S=q(N.parentId);if(S){let x=S;if(!Se(w.position,x)){let V=w.position.x+x.position.x,O=w.position.y+x.position.y,H={...N,parentId:void 0,extent:void 0,data:{...N.data,uPosition:void 0}};return y(_=>_.map(le=>le.id===N.id?H:le)),{...w,position:{x:V,y:O}}}}}}return w});R(g);},[R,y,q]),mt=Lt.useCallback((n,g)=>{de(null);},[]),ht=Lt.useCallback((n,g,w)=>{if(g.type==="device"&&!g.parentId){let N=re.current.filter(x=>x.type==="rack").map(x=>x),S=Ce(g.position,N);de(S?.id??null);}else de(null);},[]),bt=Lt.useCallback((n,g,w)=>{if(g.type==="device"&&!g.parentId){let N=re.current.filter(x=>x.type==="rack").map(x=>x),S=Ce(g.position,N);if(S){let x=g.position.x-S.position.x,V=g.position.y-S.position.y,O={...g,parentId:S.id,extent:"parent",position:{x,y:V},data:{...g.data,uPosition:1}},H=re.current.map(_=>_.id===g.id?O:_);y(H),p||l.setState({nodes:H});}}de(null);},[y,p,l]);Lt.useCallback(n=>{if(!n.source||!n.target||!n.sourceHandle||!n.targetHandle)return {valid:true};let g=n.sourceHandle,w=n.targetHandle,N=te.current.some(x=>x.source===n.source&&x.sourceHandle===g),S=te.current.some(x=>x.target===n.target&&x.targetHandle===w);return N?{valid:false,reason:"Source port is already connected"}:S?{valid:false,reason:"Target port is already connected"}:{valid:true}},[]);let yt=Lt.useCallback(n=>{let g=q(n.source),w=g?.type==="vertical-pdu",N=g?.data,S=g?.type==="device"&&N?.deviceType==="switch",x=!!n.targetHandle&&(n.targetHandle.startsWith("pwr")||n.targetHandle.startsWith("power")),V=!!n.targetHandle&&(n.targetHandle.startsWith("net-")||n.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(n.targetHandle));if(w&&x&&n.target&&n.targetHandle){let _=me({edges:te.current,connection:n,edgeType:"power",selectEdgeZIndex:E,findBy:"target"});if(_){A(_);return}}if(S&&V&&n.target&&n.targetHandle){let _=me({edges:te.current,connection:n,edgeType:"fiber",selectEdgeZIndex:E,findBy:"target"});if(_){A(_);return}}let O=l.validateConnection({source:n.source??null,target:n.target??null,sourceHandle:n.sourceHandle??null,targetHandle:n.targetHandle??null});if(!O.valid){if(w&&n.source&&n.sourceHandle){let _=me({edges:te.current,connection:n,edgeType:x?"power":"fiber",selectEdgeZIndex:E,findBy:"source"});if(_){A(_);return}}if(S&&n.source&&n.sourceHandle){let _=me({edges:te.current,connection:n,edgeType:"fiber",selectEdgeZIndex:E,findBy:"source"});if(_){A(_);return}}s&&console.warn(`Connection rejected: ${O.reason}`);return}let H={...n,type:w&&x?"power":"fiber",zIndex:E({...n,id:"temp-id"})};A(_=>reactflow.addEdge(H,_));},[A,l,E,q,s]),wt=Lt.useCallback((n,g)=>{if((n.metaKey||n.ctrlKey)&&g.type==="device"){let N=g.data||{},S=N.view||(Array.isArray(N.rearPorts)&&N.rearPorts.length>0?"rear":"front"),x=S==="front"?"rear":"front";s&&console.log(`Command+click: Toggling device ${g.id} from ${S} to ${x}`),h&&h(g.id,x),d&&d(g);}else d&&d(g);},[h,d,s]),xt=Lt.useCallback(()=>{},[]),Nt=Lt.useCallback((n,g)=>{f&&f(g);},[f]),[J,qe]=Lt.useState(null);reactflow.useOnSelectionChange({onChange:({nodes:n})=>{if(n&&n.length===1){let g=n[0];qe(g),d&&d(g);}else qe(null),d&&d(null);}});let kt=Lt.useCallback(()=>{if(!J)return;let n=q(J.id);if(n){if(n.type==="rack"){let N=((n.data||{}).face||"front")==="front"?"rear":"front";m?m(n.id,N):y(S=>S.map(x=>x.id===n.id?{...x,data:{...x.data,face:N}}:x.parentId===n.id?{...x,data:{...x.data,view:N}}:x));return}if(n.type==="device"){let g=n.data||{},w=Array.isArray(g.rearPorts)&&g.rearPorts.length>0,N=Array.isArray(g.ports)&&g.ports.length>0,x=(g.view||(w&&!N?"rear":"front"))==="front"?"rear":"front";h?h(n.id,x):y(V=>V.map(O=>O.id===n.id?{...O,data:{...O.data,view:x}}:O));}}},[J,q,m,h,y]);return jsxRuntime.jsxs("div",{ref:W,className:`${k||""} ${$==="light"?"react-flow-light":"react-flow-dark"}`,style:{width:"100%",height:"100%",...v},children:[jsxRuntime.jsxs(reactflow.ReactFlow,{nodes:C,edges:G,onNodesChange:n=>{ft(n),p?r&&r(re.current):l.setState({nodes:re.current});},onEdgesChange:n=>{ee(n),p?a&&a(te.current):l.setState({edges:te.current});},onConnect:yt,onNodeClick:wt,onNodeDoubleClick:xt,onNodeDragStart:mt,onNodeDrag:ht,onNodeDragStop:bt,onEdgeClick:Nt,onInit:b,nodeTypes:He,edgeTypes:ae,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:true,nodesConnectable:true,elementsSelectable:true,selectNodesOnDrag:false,fitView:true,proOptions:{hideAttribution:true},children:[jsxRuntime.jsx(reactflow.Background,{}),jsxRuntime.jsx(reactflow.Controls,{}),jsxRuntime.jsx(reactflow.MiniMap,{}),jsxRuntime.jsx(reactflow.Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsxRuntime.jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),B&&jsxRuntime.jsx("button",{className:"download-button",onClick:ie,style:{position:"absolute",top:M.includes("top")?"10px":"auto",bottom:M.includes("bottom")?"10px":"auto",right:M.includes("right")?"10px":"auto",left:M.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:"pointer",transition:"all 0.2s ease",...D},children:u}),J&&(J.type==="rack"||J.type==="device")&&jsxRuntime.jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsxRuntime.jsx("button",{onClick:n=>{n.preventDefault(),kt();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let n=J.data;if(J.type==="rack")return (n?.face||"front")==="front"?"Switch to rear":"Switch to front";{let g=Array.isArray(n?.rearPorts)&&n.rearPorts.length>0,w=Array.isArray(n?.ports)&&n.ports.length>0;return (n?.view||(g&&!w?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let n=J.data;if(J.type==="rack")return (n?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let g=Array.isArray(n?.rearPorts)&&n.rearPorts.length>0,w=Array.isArray(n?.ports)&&n.ports.length>0;return (n?.view||(g&&!w?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},ro=e=>jsxRuntime.jsx(reactflow.ReactFlowProvider,{children:jsxRuntime.jsx(oo,{...e})});var lt=e=>({id:`rack-${e.id}`,type:"rack",position:{x:0,y:0},data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,uHeight:e.u_height??e.units??42,inventoryId:e.id,inventoryType:"rack",facilityId:e.facility_id,serial:e.serial,assetTag:e.asset_tag,site:typeof e.site=="object"&&e.site?e.site.name:e.site,role:typeof e.role=="object"&&e.role?e.role.name:e.role,tenant:typeof e.tenant=="object"&&e.tenant?e.tenant.name:e.tenant}}),pt=e=>({id:`device-${e.id}`,type:"device",position:{x:0,y:0},parentId:e.rack?`rack-${typeof e.rack=="object"&&e.rack?e.rack.id:e.rack}`:void 0,extent:e.rack?"parent":void 0,data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,deviceType:e.device_type?.model??e.model,manufacturer:e.device_type?.manufacturer?.name??e.manufacturer,role:typeof e.device_role=="object"&&e.device_role?e.device_role.name:e.role,uHeight:e.device_type?.u_height??e.u_height??1,uPosition:e.position||1,view:e.face||"front",inventoryId:e.id,inventoryType:"device",primaryIp4:typeof e.primary_ip4=="object"&&e.primary_ip4?e.primary_ip4.address:e.primary_ip4,primaryIp6:typeof e.primary_ip6=="object"&&e.primary_ip6?e.primary_ip6.address:e.primary_ip6,site:typeof e.site=="object"&&e.site?e.site.name:e.site,rack:typeof e.rack=="object"&&e.rack?e.rack.name:e.rack}}),ut=e=>{let o=r=>{if(!r)return;if(typeof r=="string")return r;let a=r.device;return typeof a=="object"&&a?a.id:a},t=o(e.termination_a),i=o(e.termination_b);return {id:`cable-${e.id}`,source:`device-${t}`,target:`device-${i}`,type:"fiber",data:{bandwidth:e.type?.label??e.bandwidth,length:e.length||0,color:e.color,inventoryId:e.id,inventoryType:"cable",status:typeof e.status=="object"&&e.status?e.status.value:e.status,terminationA:typeof e.termination_a=="object"&&e.termination_a?e.termination_a.name:e.termination_a,terminationB:typeof e.termination_b=="object"&&e.termination_b?e.termination_b.name:e.termination_b}}},no=e=>{let o=[],t=[];return e.racks.forEach(i=>o.push(lt(i))),e.devices.forEach(i=>o.push(pt(i))),e.cables.forEach(i=>t.push(ut(i))),{nodes:o,edges:t}},io=e=>{let o=e.filter(r=>r.type==="rack"),t=e.filter(r=>r.type==="device"),i=e.filter(r=>!["rack","device"].includes(r.type));return o.forEach((r,a)=>{r.position={x:a*300,y:100};}),t.forEach(r=>{if(r.parentId){let a=o.find(c=>c.id===r.parentId);if(a){let c=r.data.uPosition||1,s=r.data.uHeight||1;r.position={x:a.position.x+50,y:a.position.y+c*20-s*10};}}else r.position={x:Math.random()*400+100,y:Math.random()*200+50};}),i.forEach((r,a)=>{r.position={x:a*150+100,y:300};}),e};var he=class extends Error{constructor(t,i,r,a,c){super(`Device placement conflict: ${i} at U${r}-${r+a-1} in rack ${t}${c?` conflicts with ${c}`:""}`);this.rackId=t;this.deviceId=i;this.uPosition=r;this.uHeight=a;this.conflictWith=c;this.name="DevicePlacementError";}};function Ke(e,o={}){let t=[],i=[];for(let r of e.devices)r.unit+r.height-1>e.units&&i.push({deviceId:r.id,uPosition:r.unit,uHeight:r.height,rackUHeight:e.units});for(let r=0;r<e.devices.length;r++){let a=e.devices[r],c=a.unit,s=a.unit+a.height-1;for(let d=r+1;d<e.devices.length;d++){let f=e.devices[d],h=f.unit,m=f.unit+f.height-1;c<=m&&s>=h&&t.push({deviceId:a.id,uPosition:a.unit,uHeight:a.height,conflictWith:f.id});}}return {isValid:t.length===0&&i.length===0,conflicts:t,outOfBounds:i}}function gt(e,o,t={}){let{deviceTypeMapping:i={}}=t,r=i[e.type]||"device",a=ue(o,e.unit,e.height);return {id:e.id,type:r,position:a,parentId:o.id,extent:"parent",data:{label:e.name,status:"active",deviceType:e.type,uHeight:e.height,uPosition:e.unit,width:e.width||"full",role:e.role,ports:e.ports,rearPorts:e.rearPorts,connections:e.connections}}}function ao(e){return {id:e.id,type:"rack",position:e.position,data:{label:e.name,status:"active",uHeight:e.units,uNumberingDirection:e.uNumberingDirection||"bottom-up",customHeaderText:e.customHeaderText,ports:[]}}}function so(e,o={}){let{conflictPolicy:t="strict",validatePlacements:i=true}=o,r=[],a=[];if(i)for(let c of e){let s=Ke(c,o);if(!s.isValid&&t==="strict"){let d=[];throw s.conflicts.forEach(f=>{d.push(`Device ${f.deviceId} at U${f.uPosition}-${f.uPosition+f.uHeight-1} conflicts with ${f.conflictWith}`);}),s.outOfBounds.forEach(f=>{d.push(`Device ${f.deviceId} at U${f.uPosition}-${f.uPosition+f.uHeight-1} exceeds rack height (${f.rackUHeight}U)`);}),new he(c.id,s.conflicts[0]?.deviceId||s.outOfBounds[0]?.deviceId||"unknown",s.conflicts[0]?.uPosition||s.outOfBounds[0]?.uPosition||1,s.conflicts[0]?.uHeight||s.outOfBounds[0]?.uHeight||1)}}for(let c of e){let s=ao(c);r.push(s);for(let d of c.devices)try{let f=gt(d,s,o);a.push(f);}catch(f){if(t==="strict")throw f;if(t==="nearest"){let h=ke(s,{id:d.id,data:{label:d.name,uHeight:d.height}},a,d.unit);if(h!==d.unit){console.warn(`Device ${d.id} moved from U${d.unit} to U${h} due to conflict`);let m={...d,unit:h},k=gt(m,s,o);a.push(k);}else throw new he(c.id,d.id,d.unit,d.height)}}}return r.push(...a),r}function co(e){let o=[],t=e.filter(i=>i.type==="rack");for(let i of t){let a=e.filter(c=>c.type==="device"&&c.parentId===i.id).map(c=>({id:c.id,name:c.data.label,unit:c.data.uPosition||1,height:c.data.uHeight||1,type:c.data.deviceType||"server",width:c.data.width,ports:c.data.ports,connections:c.data.connections}));o.push({id:i.id,name:i.data.label,position:i.position,units:i.data.uHeight||42,uNumberingDirection:i.data.uNumberingDirection||"bottom-up",customHeaderText:i.data.customHeaderText,devices:a});}return o}function lo(e,o,t,i){return e.map(r=>r.id!==o?r:{...r,devices:r.devices.map(a=>a.id!==t?a:{...a,unit:i})})}function po(e,o,t,i={}){let{conflictPolicy:r="strict"}=i;return e.map(a=>{if(a.id!==o)return a;if(r==="strict"&&!Ke({...a,devices:[...a.devices,t]},i).isValid)throw new he(o,t.id,t.unit,t.height);return {...a,devices:[...a.devices,t]}})}function uo(e,o,t){return e.map(i=>i.id!==o?i:{...i,devices:i.devices.filter(r=>r.id!==t)})}
|
|
2
|
-
exports.DeviceNode=
|
|
1
|
+
'use strict';var or=require('react'),reactflow=require('reactflow'),htmlToImage=require('html-to-image'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var or__default=/*#__PURE__*/_interopDefault(or);var _o=()=>"bottom-up",xe=e=>e.data.uNumberingDirection||_o(),Be=(e,r,o)=>o==="bottom-up"?r-e+1:e,Me=(e,r,o)=>o==="bottom-up"?r-e+1:e;var nt=(e,r,o,i)=>{if(!e.parentId||e.parentId!==r.id)return o;let n=e.data.uHeight||1,s=r.data.uHeight||42,c=xe(r),a=60,l=o.y-a,p=Math.round(l/20)+1,m;c==="bottom-up"?m=Be(p,s,c)-n+1:m=Be(p,s,c);let b=s-n+1,y=Math.max(1,Math.min(b,m));if(c==="top-down"&&m<=1&&(y=1),!it(r,e,y,i)){let v=Le(r,e,i,y);v!==y&&(y=v);}let H;if(c==="bottom-up"){let v=y+n-1,I=Me(v,s,c);H=a+(I-1)*20-1;}else {let v=Me(y,s,c);H=a+(v-1)*20-1;}return {x:o.x,y:H,uPosition:y}},it=(e,r,o,i)=>{let n=r.data.uHeight||1,s=e.data.uHeight||42;if(o<1||o+n-1>s)return false;let c=i.filter(a=>a.type==="device"&&a.parentId===e.id&&a.id!==r.id);for(let a of c){let l=a.data.uPosition||1,p=a.data.uHeight||1,m=o,b=o+n-1,y=l,H=l+p-1;if(m<=H&&b>=y)return false}return true},Le=(e,r,o,i=1)=>{let n=r.data.uHeight||1,s=e.data.uHeight||42;for(let c=i;c<=s-n+1;c++)if(it(e,r,c,o))return c;return 1},He=(e,r,o=1)=>{let i=60,n=xe(e),s=e.data.uHeight||42,c=Me(r,s,n),a;if(n==="bottom-up"){let l=r+o-1,p=Me(l,s,n);a=i+(p-1)*20-1;}else a=i+(c-1)*20-1;return {x:0,y:a}},Vt=(e,r,o)=>{let i=e.data.uHeight||1,n=He(r,o,i);return {...e,position:n,data:{...e.data,uPosition:o}}},Ao=(e,r)=>{let o=e.data.uPosition||1,i=e.data.uHeight||1,n=r.data.uHeight||42,s=Math.max(1,Math.min(n-i+1,o));return s!==o?Vt(e,r,s):e};function se(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var st=({data:e,selected:r,id:o,onViewChange:i,onRackFaceChange:n,isDragOver:s=false})=>{let{label:c,ports:a=0,status:l="active",uHeight:p=42,face:m="front",customHeaderText:b}=e,{getNodes:y,setNodes:H}=reactflow.useReactFlow(),v=y(),[I,w]=or.useState(true),_=()=>{let R=xe({data:e})==="bottom-up"?"top-down":"bottom-up";H(x=>x.map(N=>N.id===o?{...N,data:{...N.data,uNumberingDirection:R}}:N));},L=()=>{let h=m==="front"?"rear":"front";n?(n(o,h),i&&v.filter(x=>x.parentId===o).forEach(x=>{i(x.id,h);})):i?v.filter(x=>x.parentId===o).forEach(x=>{i(x.id,h);}):H(R=>R.map(x=>x.id===o?{...x,data:{...x.data,face:h}}:x.parentId===o?{...x,data:{...x.data,view:h}}:x));},z=()=>{let h=[],R=60,x=xe({data:e});for(let N=1;N<=p;N++){let $=R+(N-1)*20-4,T=Be(N,p,x);h.push(jsxRuntime.jsx("div",{style:{position:"absolute",left:"-35px",top:`${$}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${20}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:T},N));}return h};return jsxRuntime.jsxs("div",{className:`rack-node ${r?"selected":""} ${s?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${se(l)}`,borderRadius:"8px",padding:0,width:`${300}px`,height:`${60+p*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:s?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":r?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxRuntime.jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:c}),jsxRuntime.jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[b?jsxRuntime.jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:b}):jsxRuntime.jsxs("span",{children:[typeof a=="number"?a:0," ports"]})," \u2022 ",p,"U \u2022 ",m]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsxRuntime.jsx("button",{onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},onClick:h=>{h.stopPropagation(),h.preventDefault(),w(!I);},style:{background:I?"#10b981":"#374151",color:I?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${I?"Hide":"Show"} U markers`,children:"U"}),jsxRuntime.jsx("button",{onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},onClick:h=>{h.stopPropagation(),h.preventDefault(),_();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch U numbering to ${xe({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:xe({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsxRuntime.jsx("button",{onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},onClick:h=>{h.stopPropagation(),h.preventDefault(),L();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${m==="front"?"rear":"front"} view`,children:m==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsxRuntime.jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${p*20}px`,overflow:"hidden"}}),I&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:z()})]})};var at=({data:e,selected:r})=>{let{label:o,status:i="active"}=e;return jsxRuntime.jsxs("div",{className:`fiber-node ${r?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${se(i)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:r?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Top}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Bottom}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right}),jsxRuntime.jsx("div",{style:{textAlign:"center"},children:jsxRuntime.jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:o})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:se(i),borderRadius:"50%"}})]})};var ct=({id:e,sourceX:r,sourceY:o,targetX:i,targetY:n,sourcePosition:s,targetPosition:c,data:a,selected:l,style:p={},className:m})=>{let [b,y,H]=reactflow.getBezierPath({sourceX:r,sourceY:o,sourcePosition:s,targetX:i,targetY:n,targetPosition:c}),{bandwidth:v,length:I,color:w="#00FFFF",striped:_=false}=a||{};m?.includes("edge-connecting");let z={...p,stroke:w,strokeWidth:l?3:2,strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:b,style:z}),_&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-stripe`,path:b,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:l&&a&&(v||I)&&jsxRuntime.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${y}px,${H}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${w}`,pointerEvents:"none",zIndex:9999},children:[v&&jsxRuntime.jsx("div",{children:v}),I&&jsxRuntime.jsxs("div",{children:[I,"m"]})]})})]})};var lt=({id:e,sourceX:r,sourceY:o,targetX:i,targetY:n,sourcePosition:s,targetPosition:c,style:a={},data:l,markerEnd:p})=>{let[m]=reactflow.getBezierPath({sourceX:r,sourceY:o,sourcePosition:s,targetX:i,targetY:n,targetPosition:c}),b=l?.connectorType||"C13";return jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:m,markerEnd:p,style:(()=>{let H={stroke:l?.color||"#f59e0b",strokeWidth:b==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...a};return b==="C19"?{...H,strokeDasharray:"none"}:{...H,strokeDasharray:"6,3"}})()})};var jt=({data:e,selected:r,style:o={},...i})=>{let{color:n="#00FFFF"}=e||{},s={...o,stroke:n,strokeWidth:r?4:3};return jsxRuntime.jsx(reactflow.SmoothStepEdge,{...i,data:e,selected:r,style:s})};function Zo({sourceX:e,sourceY:r,targetX:o,targetY:i,sourcePosition:n,targetPosition:s}){let c=n===reactflow.Position.Left||n===reactflow.Position.Right,a;if(c){let l=(e+o)/2;a=`M ${e},${r} L ${l},${r} L ${l},${i} L ${o},${i}`;}else {let l=(r+i)/2;a=`M ${e},${r} L ${e},${l} L ${o},${l} L ${o},${i}`;}return a}var Kt=({id:e,sourceX:r,sourceY:o,targetX:i,targetY:n,sourcePosition:s,targetPosition:c,data:a,selected:l,style:p={},...m})=>{let{color:b="#00FFFF",striped:y=false}=a||{},H=Zo({sourceX:r,sourceY:o,sourcePosition:s,targetX:i,targetY:n,targetPosition:c}),v={...p,stroke:b,strokeWidth:l?3:2,strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:H,style:v}),y&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-stripe`,path:H,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var qt=(o=>(o.FULL="full",o.HALF="half",o))(qt||{});var pt={C13:{type:"C13",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C14:{type:"C14",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C19:{type:"C19",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1},C20:{type:"C20",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1}};function Ce(e){let r=pt[e];if(!r)throw new Error(`Unknown connector type: ${e}`);let o=r.amperage===16,i=o?12:8,n=o?10:5,s=o?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:i,height:n,color:r.color,borderColor:r.borderColor,fontSize:o?"3px":"4px",...s}}function Ge(e){let r=pt[e];if(!r)throw new Error(`Unknown connector type: ${e}`);return r}function Jo(e){return Ge(e).amperage===16}function ut(e){return e%10<8?"C13":"C19"}function Xe(e){let r=e.toLowerCase();return r.includes("mx304")||r.includes("mx480")||r.includes("mx960")?"C20":"C14"}var ft=({data:e,selected:r})=>{let{label:o,status:i="active",deviceType:n="server",manufacturer:s,role:c,uHeight:a=1,width:l="full",ports:p=[],rearPorts:m=[],view:b}=e,y=b||(m.length>0&&p.length===0?"rear":"front"),H={};H["net-top"]="front",H["net-bottom"]="front",p.length>0&&p.forEach(h=>{h.ports.forEach(R=>{let x=R.type?.includes("power")?R.label:`${h.name}-${R.label}`;H[x]="front";});}),H["pwr-left-1"]="rear",H["pwr-left-2"]="rear",H["net-right-1"]="rear",H["net-right-2"]="rear",m.length>0&&m.forEach(h=>{h.ports.forEach(R=>{let x=R.type?.includes("power")?R.label:`${h.name}-${R.label}`;H[x]="rear";});});let v=a*20,I=l==="half"?"150px":"304px",w=l==="half"?"150px":void 0,_=(h,R)=>{let x=[];if(h.length===0)return x;let N=Math.max(4,Math.floor(v*.4)),$=Math.max(2,Math.floor(v*.2));return h.forEach((T,M)=>{T.ports.forEach((C,P)=>{let F=!!C.type&&C.type.includes("power");if(R==="front"&&F)return;let Y=F?`${C.label}`:`${T.name}-${C.label}`,j=C.connected,D="#6b7280";if(j)if(C.type?.includes("power"))D=C.type==="power_c19"?"#fbbf24":"#f59e0b";else if(C.type==="console"||C.type==="mgmt")D="#8b5cf6";else if(C.type==="usb")D="#10b981";else switch(C.cableType){case "smf":D="#fbbf24";break;case "cat6":D="#8b5cf6";break;case "om3":D="#06b6d4";break;case "om4":D="#8b5cf6";break;case "om5":D="#84cc16";break;case "cat5e":D="#3b82f6";break;case "cat6a":D="#ef4444";break;case "cat7":D="#f97316";break;case "fiber":D="#3b82f6";break;case "ethernet":D="#10b981";break;default:D="#10b981";}let G=reactflow.Position.Top,E={width:`${N}px`,height:`${$}px`,background:j?D:"#6b7280",border:`1px solid ${j?D:"#374151"}`,borderRadius:"1px",cursor:"pointer"};if(R==="front")P%2===0?(G=reactflow.Position.Top,E.transform="translateY(50%)",E.left=`${P/2*(N+2)}px`):(G=reactflow.Position.Bottom,E.transform="translateY(-50%)",E.left=`${(P-1)/2*(N+2)}px`);else if((n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel")P%2===0?(G=reactflow.Position.Top,E.transform="translateY(50%)",E.left=`${P/2*(N+2)}px`):(G=reactflow.Position.Bottom,E.transform="translateY(-50%)",E.left=`${(P-1)/2*(N+2)}px`);else if(C.type?.includes("power")){G=reactflow.Position.Left,E.transform="translateX(50%)";let We=v<=20?10:20,Pe=v<=20?30:50;E.top=`${We+P*Pe}%`;let tt=Xe(o),fe=Ce(tt);E={...E,width:`${fe.width}px`,height:`${fe.height}px`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:fe.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:fe.borderRadius,clipPath:fe.clipPath};}else G=reactflow.Position.Right,E.transform="translateX(-50%)",E.top=`${25+P*50}%`;let Ae=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",ue;if(F)ue="target";else if(n==="switch"||n==="router")ue="source",x.push(jsxRuntime.jsx(reactflow.Handle,{id:`${Y}-target`,type:"target",position:G,style:E,title:`${T.name} - ${C.label} (input) ${j?"(connected)":"(disconnected)"}`},`${Y}-target`));else if(Ae){ue=R==="rear"?"source":"target";let ge=R==="rear"?"target":"source";x.push(jsxRuntime.jsx(reactflow.Handle,{id:`${Y}-${ge}`,type:ge,position:G,style:E,title:`${T.name} - ${C.label} (${ge}) ${j?"(connected)":"(disconnected)"}`},`${Y}-${ge}`));}else ue=j?"source":"target";x.push(jsxRuntime.jsx(reactflow.Handle,{id:Y,type:ue,position:G,style:E,title:`${T.name} - ${C.label} ${j?"(connected)":"(disconnected)"}`,children:F?P+1:void 0},Y));});}),x},L=()=>{let h=[],R=Math.max(4,Math.floor(v*.4)),x=Math.max(2,Math.floor(v*.2));if(y==="front"){if(p.length>0)return _(p,"front");if(n==="switch"&&(o.toLowerCase().includes("agg")||o.toLowerCase().includes("core")||c==="agg"||c==="core"))return z();h.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-top",type:"target",position:reactflow.Position.Top,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(50%)"},title:"Network Port (Top)"},"net-top")),h.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-bottom",type:"target",position:reactflow.Position.Bottom,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(-50%)"},title:"Network Port (Bottom)"},"net-bottom"));}else if(y==="rear"){if(m.length>0)return _(m,"rear");let N=n==="switch",T=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel";if(!T){let M=Xe(o),C=Ge(M),P=Ce(M),F=v<=20?"10%":"25%";h.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-1",type:"target",position:reactflow.Position.Left,style:{width:`${P.width}px`,height:`${P.height}px`,background:P.color,border:`1px solid ${P.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:F,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:P.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:P.borderRadius,clipPath:P.clipPath},title:`Power Port 1 (${C.type}) - ${C.voltage}V, ${C.amperage}A`,children:"1"},"pwr-1"));let Y=v<=20?"50%":"75%";h.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-2",type:"target",position:reactflow.Position.Left,style:{width:`${P.width}px`,height:`${P.height}px`,background:P.color,border:`1px solid ${P.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:Y,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:P.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:P.borderRadius,clipPath:P.clipPath},title:`Power Port 2 (${C.type}) - ${C.voltage}V, ${C.amperage}A`,children:"2"},"pwr-2"));}!N&&!T&&(h.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-1",type:"target",position:reactflow.Position.Right,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"25%"},title:"Network Port 1 (Right)"},"net-right-1")),h.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-2",type:"target",position:reactflow.Position.Right,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"75%"},title:"Network Port 2 (Right)"},"net-right-2")));}return h},z=()=>{let h=[],R=Math.max(10,Math.floor(v*.45)),x=Math.max(5,Math.floor(v*.25));for(let N=1;N<=16;N++){let $=jsxRuntime.jsx(reactflow.Handle,{id:`port-${N}`,type:"source",position:reactflow.Position.Top,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(50%)",zIndex:1e3,left:`${(N-1)*(R+2)}px`},title:`Port ${N}`},`port-${N}`);h.push($);}for(let N=17;N<=32;N++){let $=N-16,T=jsxRuntime.jsx(reactflow.Handle,{id:`port-${N}`,type:"source",position:reactflow.Position.Bottom,style:{width:`${R}px`,height:`${x}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(-50%)",zIndex:1e3,left:`${($-1)*(R+2)}px`},title:`Port ${N}`},`port-${N}`);h.push(T);}for(let N=1;N<=4;N++){let $=Math.max(4,Math.floor(v*.3)),T=Math.max(3,Math.floor(v*.15));h.push(jsxRuntime.jsx(reactflow.Handle,{id:`uplink-${N}`,type:"source",position:reactflow.Position.Right,style:{width:`${$}px`,height:`${T}px`,background:"#8b5cf6",border:"0.5px solid #7c3aed",borderRadius:"0.5px",cursor:"pointer",transform:"translateX(-50%)"},title:`Uplink ${N}`},`uplink-${N}`));}return h};return jsxRuntime.jsxs("div",{className:`device-node ${r?"selected":""}`,style:{background:"#1f2937",border:`1px solid ${se(i)}`,borderRadius:"2px",padding:"0px",width:I,...w&&{left:w},height:`${v}px`,color:"white",fontFamily:"monospace",fontSize:"8px",boxShadow:r?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",cursor:"grab",marginBottom:"0px",boxSizing:"border-box",marginTop:"0px",marginLeft:"0px",marginRight:"0px"},children:[jsxRuntime.jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),a>1&&jsxRuntime.jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:s})]}),a>1&&jsxRuntime.jsxs("div",{style:{position:"absolute",bottom:"1px",right:"1px",background:"#374151",color:"#9ca3af",padding:"1px 2px",borderRadius:"1px",fontSize:"6px",lineHeight:"1"},children:[a,"U"]}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:se(i),borderRadius:"50%"}}),L()]})};var bt=({data:e,selected:r})=>{let{label:o,status:i="active",heightCm:n=100,powerPorts:s=36,widthPx:c=15,mgmt_unit:a}=e,l=n*4.2,p=()=>{let y=Math.ceil(s/10),H=Array(10).fill(0).map((x,N)=>N<8?"10A":"16A");for(let x=0,N=0;x<y;++x)for(let $=0;$<10&&N<s;++$,++N){H[$];}let _=[],L=15,R=(l-L-3)/(s-9)*.5;for(let x=0;x<s;x++){let N=L-2+R*x,$=`${x+1}`;if(a&&(a==="top"&&x===0||a==="middle"&&x===Math.floor(s/2)||a==="bottom"&&x===s-1)){_.push(m(N));continue}let M=ut(x),C=Ce(M),P=Math.round((c-C.width)/2-1);_.push(jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:$,style:{position:"absolute",left:`${P}px`,top:`${N-C.height/2}px`,width:`${C.width}px`,height:`${C.height}px`,background:C.color,border:`1px solid ${C.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:C.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:C.borderRadius,clipPath:C.clipPath},title:`Power Port ${x+1} (${M})`,children:x+1},`handle-${$}`));}return _},m=b=>jsxRuntime.jsxs("div",{style:{position:"absolute",left:`${(c-16)/2}px`,top:`${b-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxRuntime.jsxs("div",{className:`vertical-pdu-node ${r?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${se(i)}`,borderRadius:"2px",padding:0,width:`${c}px`,height:`${l}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:r?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:o})}),jsxRuntime.jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${l-20}px`,overflow:"hidden"},children:p()})]})};var yt=({data:e,selected:r,id:o})=>{let{lossDb:i}=e||{},n=reactflow.useEdges(),s=n.find(y=>y.target===o&&y.targetHandle==="left"),c=n.find(y=>y.source===o&&y.sourceHandle==="right"),a=n.find(y=>y.target===o&&y.targetHandle==="right"),l=c||a,p=s?.data?.color||"#555",m=l?.data?.color||"#555",b=!!s&&!!l;return jsxRuntime.jsxs("div",{className:`splice-node ${r?"selected":""}`,style:{width:69,height:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:r?"0 0 0 2px #3b82f6":"none"},children:[jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{background:p}}),jsxRuntime.jsx("div",{style:{background:m}})]}),jsxRuntime.jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1}}),b&&jsxRuntime.jsx("div",{className:"splice-glow",style:{position:"absolute",left:"50%",top:0,bottom:0,width:"1px",background:"rgba(255, 255, 255, 0.6)",boxShadow:"0 0 2px rgba(255, 255, 255, 0.8), 0 0 4px rgba(255, 255, 255, 0.4)",pointerEvents:"none",zIndex:2}}),b&&typeof i=="number"&&jsxRuntime.jsx("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold"},children:`${i.toFixed(2)} dB`}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left,id:"left",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:p,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:m,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:m,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var he=20,we=32,oo=4,ye=12,er=69,wt=80,xt=(wt-er)/2;var kt=(e,r,o,i)=>{if(!e.parentId||e.parentId!==r.id)return o;let n=we,s=o.y-n,c=Math.round(s/he)+1,l=Math.max(1,Math.min(ye,c));if(!Nt(r,e,l,i)){let y=Ze(r,e,i,l);if(y!==l)return {x:xt,y:n+(y-1)*he+5,holderPosition:y}}let b=n+(l-1)*he+5;return {x:xt,y:b,holderPosition:l}},Nt=(e,r,o,i)=>!i.filter(s=>s.parentId===e.id&&s.type==="splice"&&s.id!==r.id).some(s=>s.data.holderPosition===o),Ze=(e,r,o,i=1)=>{for(let n=i;n<=ye;n++)if(Nt(e,r,n,o))return n;for(let n=i-1;n>=1;n--)if(Nt(e,r,n,o))return n;return 1},Fe=(e,r)=>{let n=we+(r-1)*he+5;return {x:xt,y:n}};var St=({data:e,selected:r})=>{let{label:o="Splice Tray",status:i="active"}=e||{},[n,s]=or.useState(false),c=()=>{if(!n)return null;let a=[],l=we;for(let p=1;p<=ye;p++){let m=l+(p-1)*he;a.push(jsxRuntime.jsxs("div",{style:{position:"absolute",left:"-35px",top:`${m}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${he}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",p]},p));}return a};return jsxRuntime.jsxs("div",{className:`splice-tray-node ${r?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${wt}px`,height:`${we+ye*he+oo}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:r?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${we}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:o}),jsxRuntime.jsx("button",{onPointerDown:a=>{a.stopPropagation();},onMouseDown:a=>{a.stopPropagation();},onClick:a=>{a.stopPropagation(),a.preventDefault(),s(!n);},style:{background:n?"#10b981":"#374151",color:n?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${n?"Hide":"Show"} holder markers`,children:"H"})]}),c(),jsxRuntime.jsx("div",{style:{position:"absolute",top:we,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var ro=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function ae(e){let r=(e-1)%12;return ro[r]}function no(e){return e>12}function _e(e){let r=ae(e);return no(e)?{background:r,backgroundImage:`repeating-linear-gradient(45deg, ${r} 0 6px, #000 6px 9px)`}:{background:r}}function Ht(e){return ae(e)}var Ct=({data:e,selected:r,id:o})=>{let{fibersPerTube:i=12,tubeIndex:n=1,startOn:s="left-center"}=e||{},c=Math.max(1,Math.min(24,Number(i)||12)),a=14,l=4,p=1,m=2,b=20,y=c*a+(c-1)*l,H=Math.max(60,y+p*2+m*2),v=ae((n-1)%12+1),I=`tube-${n}`,w=18,_={width:w,height:w,borderRadius:"50%",opacity:.25,pointerEvents:"auto",background:v,backgroundColor:v,border:`2px solid ${v}`,"--fiber-bg":v},L=()=>s==="left"?reactflow.Position.Left:s==="right"?reactflow.Position.Right:reactflow.Position.Bottom,z=()=>{let h=[],R=H-m*2-p*2,N,$,T=false;s==="left"?(N=p,$=reactflow.Position.Top):s==="right"?(N=p+R-y,$=reactflow.Position.Top,T=true):(N=p+(R-y)/2,$=reactflow.Position.Top);for(let M=0;M<c;M++){let C=T?c-M:M+1,P=_e(C),F=ae(C),Y=N+M*(a+l),j=p,D=P.backgroundImage?P.backgroundImage:F,G={position:"absolute",left:`${Y}px`,top:`${j}px`,width:a,height:a,borderRadius:"50%",border:"none",background:D,backgroundColor:F,zIndex:10,cursor:"pointer","--fiber-bg":F};P.backgroundImage&&(G["--fiber-bg-image"]=P.backgroundImage);let E=`fiber-${C}`;h.push(jsxRuntime.jsxs(or__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:E,type:"target",position:$,className:"tube-fiber-handle",isConnectable:true,style:G,"data-fiber-idx":C,"data-fiber-color":F}),jsxRuntime.jsx(reactflow.Handle,{id:E,type:"source",position:$,className:"tube-fiber-handle",isConnectable:true,style:G,"data-fiber-idx":C,"data-fiber-color":F})]},`fiber-${C}`));}return h};return jsxRuntime.jsxs("div",{style:{width:H,height:b,borderRadius:4,background:"#111827",border:`${m}px solid ${r?"#3b82f6":v}`,position:"relative",boxShadow:r?`0 0 0 ${m}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:p,boxSizing:"border-box"},children:[z(),jsxRuntime.jsx(reactflow.Handle,{id:I,type:"target",position:L(),isConnectable:true,style:_,"data-tube-idx":n,"data-tube-color":v}),jsxRuntime.jsx(reactflow.Handle,{id:I,type:"source",position:L(),isConnectable:true,style:_,"data-tube-idx":n,"data-tube-color":v})]})};var Rt=({data:e,selected:r})=>{let{tubeCount:o=12,fibersPerTube:i=12,fiberCount:n,cableId:s="CBL-002",label:c,tubeStartIndex:a=1,borderStyle:l="default"}=e||{},p=Math.max(1,Math.min(24,Number(o)||12)),m=Math.max(1,Number(a)||1),b=8,y=2,H=6,v=H+b+4,I=60,w=Math.max(120,p*(b+y)+H*2),_=n??p*(Number(i)||12),L=c??`${_}f Cable`,z=s?`Cable ID ${s}`:void 0,h=ae(m),R=r?"#3b82f6":h,x=false;l==="black"?R=r?"#3b82f6":"#000000":l==="black-yellow-striped"&&(R=r?"#3b82f6":"#000000",x=!r);let N=()=>{let M=[];for(let C=0;C<p;C++){let P=m+C,F=_e(P),Y=ae(P),j=H+C*(b+y),D=-4,G=F.backgroundImage?F.backgroundImage:Y,E={position:"absolute",left:`${j}px`,top:`${D}px`,width:b,height:b,borderRadius:"50%",border:"none",background:G,backgroundColor:Y,zIndex:10,cursor:"pointer","--fiber-bg":Y};F.backgroundImage&&(E["--fiber-bg-image"]=F.backgroundImage);let le=`tube-${P}`;M.push(jsxRuntime.jsxs(or__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:le,type:"target",position:reactflow.Position.Top,className:"tube-fiber-handle",isConnectable:true,style:E,"data-fiber-idx":P,"data-tube-idx":P,"data-tube-color":Y}),jsxRuntime.jsx(reactflow.Handle,{id:le,type:"source",position:reactflow.Position.Top,className:"tube-fiber-handle",isConnectable:true,style:E,"data-fiber-idx":P,"data-tube-idx":P,"data-tube-color":Y})]},`tube-${P}`));}return M},$=2,T=jsxRuntime.jsxs("div",{style:{width:"100%",height:"100%",borderRadius:x?2:4,background:"#111827",position:"relative",padding:H,paddingTop:v,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[N(),jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:L}),z&&jsxRuntime.jsx("div",{style:{fontSize:10,opacity:.8},children:z})]});return x?jsxRuntime.jsx("div",{style:{width:w,height:I,borderRadius:4,background:"repeating-linear-gradient(45deg, #000000 0 6px, #ffdf00 6px 9px)",padding:$,boxSizing:"border-box",position:"relative",boxShadow:r?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)"},children:T}):jsxRuntime.jsxs("div",{style:{width:w,height:I,borderRadius:4,background:"#111827",border:`${$}px solid ${R}`,position:"relative",boxShadow:r?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:H,paddingTop:v,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[N(),jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:L}),z&&jsxRuntime.jsx("div",{style:{fontSize:10,opacity:.8},children:z})]})};function nr(e,r){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let o=r.edges.some(w=>w.source===e.source&&w.sourceHandle===e.sourceHandle),i=r.edges.some(w=>w.target===e.target&&w.targetHandle===e.targetHandle);if(o)return {valid:false,reason:"Source port is already connected"};if(i)return {valid:false,reason:"Target port is already connected"};let n=e.sourceHandle,s=e.targetHandle,c=r.nodes.find(w=>w.id===e.source),a=r.nodes.find(w=>w.id===e.target),l=(w,_)=>{if(!w)return false;let L=w.startsWith("pwr")||w.startsWith("power"),z=_?.type==="vertical-pdu"&&w!=="mgmt-net-1";return L||z},p=(w,_)=>{if(!w)return false;if(_?.type==="vertical-pdu"&&w==="mgmt-net-1"||_?.type==="tube"&&w.startsWith("fiber-")||(_?.type==="tube"||_?.type==="cable")&&w.startsWith("tube-")||_?.type==="splice"&&(w==="left"||w==="right"))return true;let L=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("Fiber")||w.includes("Ports"),z=/^[A-Z0-9]+-\d+$/.test(w)&&!w.startsWith("pwr")&&!w.startsWith("power");return L||z},m=l(n,c),b=l(s,a),y=p(n,c),H=p(s,a);if(m&&H||b&&y)return {valid:false,reason:"Cannot connect network cable to power port"};if(m&&!b||b&&!m)return {valid:false,reason:"Power ports must connect to power-compatible ports"};let v=c?.type==="vertical-pdu",I=a?.type==="vertical-pdu";if(m||b){let w=v?a:I?c:null,_=v?c:I?a:null;if(w&&_&&r.edges.filter(h=>{let R=l(h.sourceHandle||""),x=l(h.targetHandle||""),N=h.source===w.id||h.target===w.id;return (R||x)&&N}).some(h=>h.source===_.id||h.target===_.id))return {valid:false,reason:"Dual-feed required: connect second power to a different PDU"}}return {valid:true}}function Je(e,r){if(!r)return;let o=typeof e=="string"?e.replace(/-(target|source)$/i,""):e,i=r.data??{},n=i.handleSideMap;if(n&&n[o])return n[o];if(o==="net-top"||o==="net-bottom")return "front";if(o==="pwr-left-1"||o==="pwr-left-2"||o==="net-right-1"||o==="net-right-2")return "rear";let s=Array.isArray(i.ports)?i.ports:[],c=Array.isArray(i.rearPorts)?i.rearPorts:[];if(o.startsWith("pwr")||o.includes("power"))return "rear";for(let l of s)for(let p of l.ports||[])if((!!p.type&&String(p.type).includes("power")?p.label:`${l.name}-${p.label}`)===o)return "front";for(let l of c)for(let p of l.ports||[])if((!!p.type&&String(p.type).includes("power")?p.label:`${l.name}-${p.label}`)===o)return "rear"}function Dt(e={},r={}){let o={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},i=new Set;return {getState:()=>o,setState:b=>{o={...o,...b},i.forEach(y=>y(o));},subscribe:b=>(i.add(b),()=>i.delete(b)),selectEdgeZIndex:b=>{let y=o.nodes.find(R=>R.id===b.target);if(!y||y.type!=="device")return 1e3;let H=y.data?.view||"front",v=Je(b.targetHandle||"",y);if(v)return H===v?1e3:500;let I=(b.targetHandle||"").toString(),w=I.toLowerCase(),_=w.startsWith("pwr")||w.startsWith("power"),L=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("fiber")||w.includes("ports"),z=/^[A-Z0-9]+-\d+$/i.test(I)&&!w.startsWith("pwr")&&!w.startsWith("power"),h=L||z;return _?H==="rear"?1e3:500:h?H==="front"?1e3:500:1e3},validateConnection:b=>(r.validateConnection||nr)(b,o),selectNodeById:b=>o.nodes.find(y=>y.id===b),selectConnectedEdges:b=>o.edges.filter(y=>y.source===b||y.target===b)}}function ir(e){let r=n=>e.subscribe(n),o=()=>e.getState();return or.useSyncExternalStore(r,o,o)}function It(e){let r=i=>e.subscribe(i),o=()=>e.getState().nodes;return or.useSyncExternalStore(r,o,o)}function $t(e){let r=i=>e.subscribe(i),o=()=>e.getState().edges;return or.useSyncExternalStore(r,o,o)}function co(e){return e.selectEdgeZIndex}function lo(e){let r=300,o=(e.data.uHeight||42)*20,i=e.position.x,n=e.position.x+r,s=e.position.y,c=e.position.y+o;return {left:i,right:n,top:s,bottom:c}}function Qe(e,r){let o=lo(r);return e.x>=o.left&&e.x<=o.right&&e.y>=o.top&&e.y<=o.bottom}function et(e,r){let o=null,i=1/0;for(let n of r){if(!Qe(e,n))continue;let s=Math.sqrt(Math.pow(e.x-n.position.x,2)+Math.pow(e.y-n.position.y,2));s<i&&(i=s,o=n);}return o}function q(e){let{edges:r,connection:o,edgeType:i,selectEdgeZIndex:n,findBy:s,data:c}=e,a=s==="source"?o.sourceHandle:o.targetHandle,l=s==="source"?o.source:o.target;if(!a||!l)return null;let p=r.find(I=>s==="source"?I.source===l&&I.sourceHandle===a:I.target===l&&I.targetHandle===a);if(!p)return null;let m=r.filter(I=>I.id!==p.id),b=reactflow.addEdge(o,m),y=b[b.length-1],H=n({...o,id:y.id,type:i}),v={...y,type:i,zIndex:H,style:{...y.style,zIndex:H},data:c!==void 0?c:y.data};return [...b.slice(0,-1),v]}var xr=(e,r,o)=>({rack:i=>jsxRuntime.jsx(st,{...i,onViewChange:e,onRackFaceChange:r,isDragOver:o?o()===i.id:false}),fiber:at,device:ft,"vertical-pdu":bt,splice:yt,"splice-tray":St,tube:Ct,cable:Rt}),Nr={fiber:ct,power:lt,smoothstep:jt,step:Kt},wr=({nodes:e,edges:r,initialNodes:o,initialEdges:i,onNodesChange:n,onEdgesChange:s,store:c,debug:a,onNodeClick:l,onEdgeClick:p,onViewChange:m,onRackFaceChange:b,className:y,style:H,alignRacksToBottom:v,colorMode:I="dark",onInit:w,onFlowMethods:_,showDownloadButton:L=false,downloadButtonPosition:z="top-right",downloadButtonText:h="Download Image",downloadButtonStyle:R,allowReconnectExisting:x=false,useSmoothstepEdgesForTubes:N=false})=>{let $=Array.isArray(e)&&Array.isArray(r),T=or__default.default.useMemo(()=>c||Dt({nodes:$?e||[]:o||e||[],edges:$?r||[]:i||r||[],debug:a}),[c,$,a]),M=It(T),C=$t(T),[P,F,Y]=reactflow.useNodesState(M),[j,D,G]=reactflow.useEdgesState(C),E=co(T),le=or.useRef(null),{toObject:Ae,setViewport:ue,setNodes:ge,setEdges:We,getNodes:Pe}=reactflow.useReactFlow();or.useEffect(()=>{_&&_({toObject:Ae,setViewport:ue,setNodes:t=>{ge(t),T.setState({nodes:t});},setEdges:t=>{We(t),T.setState({edges:t});},toImage:t=>le.current?htmlToImage.toPng(le.current,t):Promise.reject(new Error("ReactFlow wrapper not available"))});},[_,Ae,ue,ge,We,T]);let tt=or.useCallback(()=>{if(!le.current){a&&console.error("ReactFlow wrapper ref is not available");return}htmlToImage.toPng(le.current,{filter:t=>!(t?.classList?.contains("react-flow__minimap")||t?.classList?.contains("react-flow__controls")||t?.classList?.contains("react-flow__attribution")||t?.classList?.contains("download-button")||t?.tagName==="BUTTON"),backgroundColor:I==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(t=>{let d=document.createElement("a");d.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,d.href=t,d.click();}).catch(t=>{a&&console.error("Error downloading image:",t);});},[I,a]),[fe,Ue]=or.useState(null),Ut=or.useRef(null),zt=or.useRef(m),Ot=or.useRef(b);or.useEffect(()=>{zt.current=m;},[m]),or.useEffect(()=>{Ot.current=b;},[b]),or.useEffect(()=>{Ut.current=fe;},[fe]);let yo=or.useRef(()=>Ut.current),xo=or.useMemo(()=>xr((t,d)=>zt.current?.(t,d),(t,d)=>Ot.current?.(t,d),yo.current),[]),No=or.useMemo(()=>Nr,[]),pe=or.useRef(P);or.useEffect(()=>{pe.current=P;},[P]);let U=or.useRef(j);or.useEffect(()=>{U.current=j;},[j]),or.useEffect(()=>{F(M);},[M,F]),or.useEffect(()=>{D(C);},[C,D]),or.useEffect(()=>{$&&T.setState({nodes:e||[]});},[$,e,T]),or.useEffect(()=>{$&&T.setState({edges:r||[]});},[$,r,T]),or.useEffect(()=>{if(!v||!P||P.length===0)return;let t=P.filter(A=>A.type==="rack");if(t.length===0)return;let d=t.map(A=>{let ie=A.data?.uHeight||42,X=60+ie*20;return (A.position?.y||0)+X}),g=Math.min(...d),f=Math.max(...d);if(f-g<20)return;let u=f,W=P.map(A=>{if(A.type!=="rack")return A;let ie=A.data?.uHeight||42,X=60+ie*20,V=(A.position?.y||0)+X,Z=u-V;return Math.abs(Z)<5?A:{...A,position:{x:A.position?.x||0,y:(A.position?.y||0)+Z}}});W.some((A,ee)=>A.position!==P[ee].position)&&F(W);},[v,P,F]);let O=or.useCallback(t=>pe.current.find(d=>d.id===t),[]),ze=or.useCallback((t,d)=>{if(!t||!d)return;let g=O(t);if(!g)return;if(g.type==="tube"&&d.startsWith("fiber-")){let k=d.replace("fiber-",""),u=parseInt(k,10);if(u>=1&&u<=24){let W=Ht(u),B=u>12;return {color:W,striped:B}}}if((g.type==="cable"||g.type==="tube")&&d.startsWith("tube-")){let k=d.replace("tube-",""),u=parseInt(k,10);if(u>=1&&u<=24){let W=ae(u),B=u>12;return {color:W,striped:B}}}let f=g.data;if(f.color)return {color:f.color}},[O]);or.useEffect(()=>{D(t=>t.map(d=>{let g=E(d);return {...d,zIndex:g,style:{...d.style,zIndex:g}}}));},[P,D,E]),or.useEffect(()=>{let t=P.map(g=>{if(g.type==="splice"&&g.parentId&&g.data.holderPosition&&(!g.position||g.position.x===0&&g.position.y===0)){let f=O(g.parentId);if(f&&f.type==="splice-tray"){let k=Fe(f,g.data.holderPosition);return {...g,position:k}}}if(g.type==="device"&&g.parentId&&g.data.uPosition&&(!g.position||g.position.x===0&&g.position.y===0)){let f=O(g.parentId);if(f){let k=He(f,g.data.uPosition);return {...g,position:k}}}return g});t.some((g,f)=>g.position!==P[f].position)&&F(t);},[P,F,O]);let wo=or.useCallback(t=>{let d=t.map(g=>{if(g.type==="position"&&g.position){let f=O(g.id);if(f&&f.type==="splice"&&f.parentId){let k=O(f.parentId);if(k&&k.type==="splice-tray"){let u=kt(f,k,g.position,pe.current);if(u.holderPosition!==void 0){let W={...f,data:{...f.data,holderPosition:u.holderPosition}};F(B=>B.map(A=>A.id===f.id?W:A));}return {...g,position:{x:u.x,y:u.y}}}}if(f&&f.type==="device"&&f.parentId){let k=O(f.parentId);if(k){let u=nt(f,k,g.position,pe.current);if(u.uPosition!==void 0){let W={...f,data:{...f.data,uPosition:u.uPosition}};F(B=>B.map(A=>A.id===f.id?W:A));}return {...g,position:{x:u.x,y:u.y}}}}if(f&&f.type==="device"&&f.parentId){let k=O(f.parentId);if(k){let u=k;if(!Qe(g.position,u)){let W=g.position.x+u.position.x,B=g.position.y+u.position.y,A={...f,parentId:void 0,extent:void 0,data:{...f.data,uPosition:void 0}};return F(ee=>ee.map(ie=>ie.id===f.id?A:ie)),{...g,position:{x:W,y:B}}}}}}return g});Y(d);},[Y,F,O]),ko=or.useCallback((t,d)=>{Ue(null);},[]),vo=or.useCallback((t,d,g)=>{if(d.type==="device"&&!d.parentId){let f=pe.current.filter(u=>u.type==="rack").map(u=>u),k=et(d.position,f);Ue(k?.id??null);}else Ue(null);},[]),Po=or.useCallback((t,d,g)=>{if(d.type==="device"&&!d.parentId){let f=pe.current.filter(u=>u.type==="rack").map(u=>u),k=et(d.position,f);if(k){let u=d.position.x-k.position.x,W=d.position.y-k.position.y,B={...d,parentId:k.id,extent:"parent",position:{x:u,y:W},data:{...d.data,uPosition:1}},A=pe.current.map(ee=>ee.id===d.id?B:ee);F(A),$||T.setState({nodes:A});}}Ue(null);},[F,$,T]),So=or.useCallback(t=>{if(!t.source||!t.target||!t.sourceHandle||!t.targetHandle)return true;let d=O(t.source),g=O(t.target);if(d?.type==="tube"&&g?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&t.targetHandle.startsWith("fiber-"))return a&&console.log("Connection rejected: Cannot connect fibres within tubes",t),false;if(d?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&(g?.type==="cable"||g?.type==="tube")&&t.targetHandle.startsWith("tube-"))return a&&console.log("Connection rejected: Cannot connect individual fibre to cable/tube tube handle",t),false;if((d?.type==="cable"||d?.type==="tube")&&t.sourceHandle.startsWith("tube-")&&g?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return a&&console.log("Connection rejected: Cannot connect cable/tube tube handle to individual fibre",t),false;if(g?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right"))return U.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle||u.source===t.target&&u.sourceHandle===t.targetHandle)?(a&&console.log("Splice handle already connected, will replace",t),true):(a&&console.log("Allowing connection to splice handle",t),true);if(d?.type==="tube"&&t.sourceHandle.startsWith("fiber-"))return g?.type!=="splice"?(a&&console.log("Connection rejected: Tube fiber handles can only connect to splices",t),false):U.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(a&&console.log("Tube fiber handle already connected, will replace",t),true):(a&&console.log("Allowing connection from tube fiber handle to splice",t),true);if((d?.type==="cable"||d?.type==="tube")&&t.sourceHandle.startsWith("tube-"))return t.targetHandle.startsWith("tube-")?U.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(a&&console.log("Tube-level handle already connected, will replace",t),true):(a&&console.log("Allowing connection from tube-level handle to tube handle",t),true):(a&&console.log("Connection rejected: Tube handles can only connect to other tube handles",t),false);if(d?.type==="splice"&&t.sourceHandle==="right")return U.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle||u.target===t.source&&u.targetHandle===t.sourceHandle)&&a&&console.log("Splice source handle already connected, will replace",t),true;if(g?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return d?.type!=="splice"?(a&&console.log("Connection rejected: Tube fiber handles can only connect from splices",t),false):U.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(a&&console.log("Tube fiber target handle already connected, will replace",t),true):(a&&console.log("Allowing connection from splice to tube fiber handle",t),true);if((g?.type==="cable"||g?.type==="tube")&&t.targetHandle.startsWith("tube-"))return t.sourceHandle.startsWith("tube-")?U.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(a&&console.log("Tube-level target handle already connected, will replace",t),true):(a&&console.log("Allowing connection from tube handle to tube-level handle",t),true):(a&&console.log("Connection rejected: Tube handles can only connect from other tube handles",t),false);let f=T.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!f.valid&&x){if(t.source&&t.sourceHandle&&U.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle))return a&&console.log("Source handle has existing edge, will replace",t),true;if(t.target&&t.targetHandle&&U.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle))return a&&console.log("Target handle has existing edge, will replace",t),true}return a&&!f.valid&&console.log("Connection rejected by store validation:",f.reason,t),f.valid},[O,T,a,x]),Ho=or.useCallback(t=>{let d=O(t.source),g=O(t.target),f=d?.type==="vertical-pdu",k=d?.data,u=d?.type==="device"&&k?.deviceType==="switch",W=!!t.targetHandle&&(t.targetHandle.startsWith("pwr")||t.targetHandle.startsWith("power")),B=!!t.targetHandle&&(t.targetHandle.startsWith("net-")||t.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(t.targetHandle)),A=d?.type==="tube"&&g?.type==="cable",ee=d?.type==="cable"&&g?.type==="tube",ie=A||ee,X;f&&W?X="power":ie?X=N?"smoothstep":"fiber":X="fiber";let V;if((X==="fiber"||X==="smoothstep")&&!f){let S=ze(t.source,t.sourceHandle);S&&(V={color:S.color,striped:S.striped});}if(g?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right")&&t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}if(t.targetHandle==="right"&&(S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"source",data:V}),S)){D(S);return}}if(d?.type==="splice"&&t.sourceHandle==="right"&&t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}if(S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"target",data:V}),S){D(S);return}}if(d?.type==="tube"&&t.sourceHandle?.startsWith("fiber-")&&t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}}if(g?.type==="tube"&&t.targetHandle?.startsWith("fiber-")&&t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}}if((d?.type==="cable"||d?.type==="tube")&&t.sourceHandle?.startsWith("tube-")&&t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:X,selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}}if((g?.type==="cable"||g?.type==="tube")&&t.targetHandle?.startsWith("tube-")&&t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:X,selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}}if(f&&W&&t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:"power",selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}}if(u&&B&&t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}}let Z=T.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!Z.valid){if(x){if(t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:X,selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}}if(t.target&&t.targetHandle){let S=q({edges:U.current,connection:t,edgeType:X,selectEdgeZIndex:E,findBy:"target",data:V});if(S){D(S);return}}}if(f&&t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:W?"power":"fiber",selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}}if(u&&t.source&&t.sourceHandle){let S=q({edges:U.current,connection:t,edgeType:"fiber",selectEdgeZIndex:E,findBy:"source",data:V});if(S){D(S);return}}a&&console.warn(`Connection rejected: ${Z.reason}`);return}let Ie={...t,type:X,zIndex:E({...t,id:"temp-id"}),data:V};D(S=>{let Oe=reactflow.addEdge(Ie,S),oe=Oe[Oe.length-1];return oe&&(Mt(rt=>new Set(rt).add(oe.id)),setTimeout(()=>{Mt(rt=>{let Lt=new Set(rt);return Lt.delete(oe.id),Lt});},1e3)),Oe});},[D,T,E,O,a,ze,x,N]),Co=or.useCallback((t,d)=>{if(!d.source||!d.target||!d.sourceHandle||!d.targetHandle)return;let g=t.sourceHandle||"",f=t.targetHandle||"",k=d.sourceHandle||"",u=d.targetHandle||"";if(g.startsWith("tube-")&&k!==g){a&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:d});return}if(f.startsWith("tube-")&&u!==f){a&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:d});return}let W=O(d.source),B=O(d.target),A=W?.type==="vertical-pdu",ee=!!d.targetHandle&&(d.targetHandle.startsWith("pwr")||d.targetHandle.startsWith("power")),ie=W?.type==="tube"&&B?.type==="cable",X=W?.type==="cable"&&B?.type==="tube",V=ie||X,Z;A&&ee?Z="power":V?Z=N?"smoothstep":"fiber":Z="fiber";let Ie;if((Z==="fiber"||Z==="smoothstep")&&!A){let S=ze(d.source,d.sourceHandle);S&&(Ie={color:S.color,striped:S.striped});}D(S=>S.map(oe=>oe.id===t.id?{...oe,source:d.source,target:d.target,sourceHandle:d.sourceHandle,targetHandle:d.targetHandle,type:Z,data:Ie!==void 0?{...oe.data,...Ie}:oe.data,zIndex:E({...d,id:oe.id,type:Z}),style:{...oe.style,zIndex:E({...d,id:oe.id,type:Z})}}:oe));},[D,O,ze,E,N]),Eo=or.useCallback((t,d)=>{let g=t.metaKey||t.ctrlKey;if(d.type==="tube"&&d.parentId&&!g){let k=Pe().find(u=>u.id===d.parentId&&u.type==="cable");if(k){F(u=>u.map(W=>({...W,selected:W.id===k.id}))),l&&l(k);return}}if(g&&d.type==="device"){let f=d.data||{},k=f.view||(Array.isArray(f.rearPorts)&&f.rearPorts.length>0?"rear":"front"),u=k==="front"?"rear":"front";a&&console.log(`Command+click: Toggling device ${d.id} from ${k} to ${u}`),m&&m(d.id,u),l&&l(d);}else l&&l(d);},[m,l,a,Pe,F]),Ro=or.useCallback(()=>{},[]),Do=or.useCallback((t,d)=>{p&&p(d);},[p]),[ce,ot]=or.useState(null),[Bt,Mt]=or.useState(new Set);reactflow.useOnSelectionChange({onChange:({nodes:t})=>{if(t&&t.length===1){let d=t[0];if(d.type==="tube"&&d.parentId){let f=Pe().find(k=>k.id===d.parentId&&k.type==="cable");if(f){ot(f),F(k=>k.map(u=>({...u,selected:u.id===f.id}))),l&&l(f);return}}ot(d),l&&l(d);}else ot(null),l&&l(null);}});let To=or.useCallback((t,{nodeId:d,handleType:g})=>{a&&console.log("Connection started from",{nodeId:d,handleType:g});},[a]),Io=or.useCallback(t=>{a&&console.log("Connection ended",t);},[a]),$o=or.useCallback(()=>{if(!ce)return;let t=O(ce.id);if(t){if(t.type==="rack"){let f=((t.data||{}).face||"front")==="front"?"rear":"front";b?(b(t.id,f),m&&Pe().filter(u=>u.parentId===t.id).forEach(u=>{m(u.id,f);})):F(k=>k.map(u=>u.id===t.id?{...u,data:{...u.data,face:f}}:u.parentId===t.id?{...u,data:{...u.data,view:f}}:u));return}if(t.type==="device"){let d=t.data||{},g=Array.isArray(d.rearPorts)&&d.rearPorts.length>0,f=Array.isArray(d.ports)&&d.ports.length>0,u=(d.view||(g&&!f?"rear":"front"))==="front"?"rear":"front";m?m(t.id,u):F(W=>W.map(B=>B.id===t.id?{...B,data:{...B.data,view:u}}:B));}}},[ce,O,b,m,F]),Fo=or.useMemo(()=>j.map(t=>{let d=t,g=O(String(d.source)),f=O(String(d.target)),k=Je(d.sourceHandle||"",g),u=Je(d.targetHandle||"",f),W=g&&g.data?.view,B=f&&f.data?.view,A=g?.type==="device"&&W==="rear",ee=f?.type==="device"&&B==="rear",Z=A&&k!=="rear"&&(ee&&u!=="rear")?{...t.style,opacity:0,pointerEvents:"none",zIndex:0}:t.style;return {...t,style:Z,className:Bt.has(t.id)?"edge-connecting":t.className}}),[j,Bt,O]);return jsxRuntime.jsxs("div",{ref:le,className:`${y||""} ${I==="light"?"react-flow-light":"react-flow-dark"}`,style:{width:"100%",height:"100%",...H},children:[jsxRuntime.jsxs(reactflow.ReactFlow,{nodes:P,edges:Fo,onNodesChange:t=>{wo(t),$?n&&n(pe.current):T.setState({nodes:pe.current});},onEdgesChange:t=>{let d=t.filter(g=>{if(g.type==="remove"){let f=U.current.find(k=>k.id===g.id);if(f){let k=f.sourceHandle||"",u=f.targetHandle||"";if(k.startsWith("tube-")||u.startsWith("tube-"))return a&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",f),false}}return true});d.length>0&&(G(d),$?s&&s(U.current):T.setState({edges:U.current}));},onConnect:Ho,onConnectStart:To,onConnectEnd:Io,onEdgeUpdate:Co,isValidConnection:So,onNodeClick:Eo,onNodeDoubleClick:Ro,onNodeDragStart:ko,onNodeDrag:vo,onNodeDragStop:Po,onEdgeClick:Do,onInit:w,nodeTypes:xo,edgeTypes:No,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:true,nodesConnectable:true,elementsSelectable:true,selectNodesOnDrag:false,fitView:true,proOptions:{hideAttribution:true},children:[jsxRuntime.jsx(reactflow.Background,{color:I==="light"?"#e5e5e5":"#2a2a2a"}),jsxRuntime.jsx(reactflow.Controls,{}),jsxRuntime.jsx(reactflow.MiniMap,{}),jsxRuntime.jsx(reactflow.Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsxRuntime.jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),L&&jsxRuntime.jsx("button",{className:"download-button",onClick:tt,style:{position:"absolute",top:z.includes("top")?"10px":"auto",bottom:z.includes("bottom")?"10px":"auto",right:z.includes("right")?"10px":"auto",left:z.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:"pointer",transition:"all 0.2s ease",...R},children:h}),ce&&(ce.type==="rack"||ce.type==="device")&&jsxRuntime.jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsxRuntime.jsx("button",{onClick:t=>{t.preventDefault(),$o();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let t=ce.data;if(ce.type==="rack")return (t?.face||"front")==="front"?"Switch to rear":"Switch to front";{let d=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,g=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(d&&!g?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let t=ce.data;if(ce.type==="rack")return (t?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let d=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,g=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(d&&!g?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},kr=e=>jsxRuntime.jsx(reactflow.ReactFlowProvider,{children:jsxRuntime.jsx(wr,{...e})});var go=e=>({id:`rack-${e.id}`,type:"rack",position:{x:0,y:0},data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,uHeight:e.u_height??e.units??42,inventoryId:e.id,inventoryType:"rack",facilityId:e.facility_id,serial:e.serial,assetTag:e.asset_tag,site:typeof e.site=="object"&&e.site?e.site.name:e.site,role:typeof e.role=="object"&&e.role?e.role.name:e.role,tenant:typeof e.tenant=="object"&&e.tenant?e.tenant.name:e.tenant}}),fo=e=>({id:`device-${e.id}`,type:"device",position:{x:0,y:0},parentId:e.rack?`rack-${typeof e.rack=="object"&&e.rack?e.rack.id:e.rack}`:void 0,extent:e.rack?"parent":void 0,data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,deviceType:e.device_type?.model??e.model,manufacturer:e.device_type?.manufacturer?.name??e.manufacturer,role:typeof e.device_role=="object"&&e.device_role?e.device_role.name:e.role,uHeight:e.device_type?.u_height??e.u_height??1,uPosition:e.position||1,view:e.face||"front",inventoryId:e.id,inventoryType:"device",primaryIp4:typeof e.primary_ip4=="object"&&e.primary_ip4?e.primary_ip4.address:e.primary_ip4,primaryIp6:typeof e.primary_ip6=="object"&&e.primary_ip6?e.primary_ip6.address:e.primary_ip6,site:typeof e.site=="object"&&e.site?e.site.name:e.site,rack:typeof e.rack=="object"&&e.rack?e.rack.name:e.rack}}),bo=e=>{let r=n=>{if(!n)return;if(typeof n=="string")return n;let s=n.device;return typeof s=="object"&&s?s.id:s},o=r(e.termination_a),i=r(e.termination_b);return {id:`cable-${e.id}`,source:`device-${o}`,target:`device-${i}`,type:"fiber",data:{bandwidth:e.type?.label??e.bandwidth,length:e.length||0,color:e.color,inventoryId:e.id,inventoryType:"cable",status:typeof e.status=="object"&&e.status?e.status.value:e.status,terminationA:typeof e.termination_a=="object"&&e.termination_a?e.termination_a.name:e.termination_a,terminationB:typeof e.termination_b=="object"&&e.termination_b?e.termination_b.name:e.termination_b}}},vr=e=>{let r=[],o=[];return e.racks.forEach(i=>r.push(go(i))),e.devices.forEach(i=>r.push(fo(i))),e.cables.forEach(i=>o.push(bo(i))),{nodes:r,edges:o}},Pr=e=>{let r=e.filter(n=>n.type==="rack"),o=e.filter(n=>n.type==="device"),i=e.filter(n=>!["rack","device"].includes(n.type));return r.forEach((n,s)=>{n.position={x:s*300,y:100};}),o.forEach(n=>{if(n.parentId){let s=r.find(c=>c.id===n.parentId);if(s){let c=n.data.uPosition||1,a=n.data.uHeight||1;n.position={x:s.position.x+50,y:s.position.y+c*20-a*10};}}else n.position={x:Math.random()*400+100,y:Math.random()*200+50};}),i.forEach((n,s)=>{n.position={x:s*150+100,y:300};}),e};var De=class extends Error{constructor(o,i,n,s,c){super(`Device placement conflict: ${i} at U${n}-${n+s-1} in rack ${o}${c?` conflicts with ${c}`:""}`);this.rackId=o;this.deviceId=i;this.uPosition=n;this.uHeight=s;this.conflictWith=c;this.name="DevicePlacementError";}};function At(e,r={}){let o=[],i=[];for(let n of e.devices)n.unit+n.height-1>e.units&&i.push({deviceId:n.id,uPosition:n.unit,uHeight:n.height,rackUHeight:e.units});for(let n=0;n<e.devices.length;n++){let s=e.devices[n],c=s.unit,a=s.unit+s.height-1;for(let l=n+1;l<e.devices.length;l++){let p=e.devices[l],m=p.unit,b=p.unit+p.height-1;c<=b&&a>=m&&o.push({deviceId:s.id,uPosition:s.unit,uHeight:s.height,conflictWith:p.id});}}return {isValid:o.length===0&&i.length===0,conflicts:o,outOfBounds:i}}function mo(e,r,o={}){let{deviceTypeMapping:i={}}=o,n=i[e.type]||"device",s=He(r,e.unit,e.height);return {id:e.id,type:n,position:s,parentId:r.id,extent:"parent",data:{label:e.name,status:"active",deviceType:e.type,uHeight:e.height,uPosition:e.unit,width:e.width||"full",role:e.role,ports:e.ports,rearPorts:e.rearPorts,connections:e.connections}}}function Sr(e){return {id:e.id,type:"rack",position:e.position,data:{label:e.name,status:"active",uHeight:e.units,uNumberingDirection:e.uNumberingDirection||"bottom-up",customHeaderText:e.customHeaderText,ports:[]}}}function Hr(e,r={}){let{conflictPolicy:o="strict",validatePlacements:i=true}=r,n=[],s=[];if(i)for(let c of e){let a=At(c,r);if(!a.isValid&&o==="strict"){let l=[];throw a.conflicts.forEach(p=>{l.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} conflicts with ${p.conflictWith}`);}),a.outOfBounds.forEach(p=>{l.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} exceeds rack height (${p.rackUHeight}U)`);}),new De(c.id,a.conflicts[0]?.deviceId||a.outOfBounds[0]?.deviceId||"unknown",a.conflicts[0]?.uPosition||a.outOfBounds[0]?.uPosition||1,a.conflicts[0]?.uHeight||a.outOfBounds[0]?.uHeight||1)}}for(let c of e){let a=Sr(c);n.push(a);for(let l of c.devices)try{let p=mo(l,a,r);s.push(p);}catch(p){if(o==="strict")throw p;if(o==="nearest"){let m=Le(a,{id:l.id,data:{label:l.name,uHeight:l.height}},s,l.unit);if(m!==l.unit){console.warn(`Device ${l.id} moved from U${l.unit} to U${m} due to conflict`);let b={...l,unit:m},y=mo(b,a,r);s.push(y);}else throw new De(c.id,l.id,l.unit,l.height)}}}return n.push(...s),n}function Cr(e){let r=[],o=e.filter(i=>i.type==="rack");for(let i of o){let s=e.filter(c=>c.type==="device"&&c.parentId===i.id).map(c=>({id:c.id,name:c.data.label,unit:c.data.uPosition||1,height:c.data.uHeight||1,type:c.data.deviceType||"server",width:c.data.width,ports:c.data.ports,connections:c.data.connections}));r.push({id:i.id,name:i.data.label,position:i.position,units:i.data.uHeight||42,uNumberingDirection:i.data.uNumberingDirection||"bottom-up",customHeaderText:i.data.customHeaderText,devices:s});}return r}function Er(e,r,o,i){return e.map(n=>n.id!==r?n:{...n,devices:n.devices.map(s=>s.id!==o?s:{...s,unit:i})})}function Rr(e,r,o,i={}){let{conflictPolicy:n="strict"}=i;return e.map(s=>{if(s.id!==r)return s;if(n==="strict"&&!At({...s,devices:[...s.devices,o]},i).isValid)throw new De(r,o.id,o.unit,o.height);return {...s,devices:[...s.devices,o]}})}function Dr(e,r,o){return e.map(i=>i.id!==r?i:{...i,devices:i.devices.filter(n=>n.id!==o)})}var Te=class extends Error{constructor(o,i,n,s){super(`Splice placement conflict: ${i} at holder ${n} in tray ${o}${s?` conflicts with ${s}`:""}`);this.trayId=o;this.spliceId=i;this.holder=n;this.conflictWith=s;this.name="SplicePlacementError";}};function Wt(e,r={}){let o=[],i=[];for(let n of e.splices)(n.holder<1||n.holder>ye)&&i.push({spliceId:n.id,holder:n.holder,max:ye});for(let n=0;n<e.splices.length;n++){let s=e.splices[n];for(let c=n+1;c<e.splices.length;c++){let a=e.splices[c];s.holder===a.holder&&o.push({spliceId:s.id,holder:s.holder,conflictWith:a.id});}}return {isValid:o.length===0&&i.length===0,conflicts:o,outOfBounds:i}}function ho(e,r){let o=Fe(r,e.holder);return {id:e.id,type:"splice",position:o,parentId:r.id,extent:"parent",data:{label:e.name,holderPosition:e.holder,lossDb:e.lossDb}}}function Tr(e){return {id:e.id,type:"splice-tray",position:e.position,data:{label:e.name,status:"active"}}}function Ir(e,r={}){let{conflictPolicy:o="strict",validatePlacements:i=true}=r,n=[],s=[];if(i)for(let c of e){let a=Wt(c,r);if(!a.isValid&&o==="strict"){let l=[];throw a.conflicts.forEach(p=>{l.push(`Splice ${p.spliceId} at holder ${p.holder} conflicts with ${p.conflictWith}`);}),a.outOfBounds.forEach(p=>{l.push(`Splice ${p.spliceId} at holder ${p.holder} is out of bounds (max: ${p.max})`);}),new Te(c.id,a.conflicts[0]?.spliceId||a.outOfBounds[0]?.spliceId||"unknown",a.conflicts[0]?.holder||a.outOfBounds[0]?.holder||1)}}for(let c of e){let a=Tr(c);n.push(a);for(let l of c.splices)try{let p=ho(l,a);s.push(p);}catch(p){if(o==="strict")throw p;if(o==="nearest"){let m=[...n,...s],b=Ze(a,{id:l.id,data:{label:l.name,holderPosition:l.holder}},m,l.holder);if(b!==l.holder){console.warn(`Splice ${l.id} moved from holder ${l.holder} to holder ${b} due to conflict`);let y={...l,holder:b},H=ho(y,a);s.push(H);}else throw new Te(c.id,l.id,l.holder)}}}return n.push(...s),n}function $r(e){let r=[],o=e.filter(i=>i.type==="splice-tray");for(let i of o){let s=e.filter(c=>c.type==="splice"&&c.parentId===i.id).map(c=>({id:c.id,name:c.data.label,holder:c.data.holderPosition||1,lossDb:c.data.lossDb}));r.push({id:i.id,name:i.data.label,position:i.position,splices:s});}return r}function Fr(e,r,o,i){return e.map(n=>n.id!==r?n:{...n,splices:n.splices.map(s=>s.id!==o?s:{...s,holder:i})})}function _r(e,r,o,i={}){let{conflictPolicy:n="strict"}=i;return e.map(s=>{if(s.id!==r)return s;if(n==="strict"&&!Wt({...s,splices:[...s.splices,o]},i).isValid)throw new Te(r,o.id,o.holder);return {...s,splices:[...s.splices,o]}})}function Ar(e,r,o){return e.map(i=>i.id!==r?i:{...i,splices:i.splices.filter(n=>n.id!==o)})}
|
|
2
|
+
exports.CableNode=Rt;exports.DeviceNode=ft;exports.DevicePlacementError=De;exports.FIBER_COLORS_12=ro;exports.FiberEdge=ct;exports.FiberNode=at;exports.NetworkDiagram=kr;exports.POWER_CONNECTORS=pt;exports.PowerEdge=lt;exports.RackNode=st;exports.SpliceNode=yt;exports.SplicePlacementError=Te;exports.SpliceTrayNode=St;exports.TubeNode=Ct;exports.VerticalPDU=bt;exports.Width=qt;exports.addDeviceToRack=Rr;exports.addSpliceToTray=_r;exports.baseColorFor=ae;exports.buildNodesFromRackConfig=Hr;exports.buildNodesFromSpliceConfig=Ir;exports.calculateDevicePositionFromU=He;exports.calculateSplicePositionFromNumber=Fe;exports.createNetworkDiagramStore=Dt;exports.createRackConfigFromNodes=Cr;exports.createSpliceConfigFromNodes=$r;exports.fiberSolidOrStriped=_e;exports.findNearestRack=et;exports.findNextAvailableHolderPosition=Ze;exports.findNextAvailableUPosition=Le;exports.generateLayout=Pr;exports.getConnectorConfig=Ge;exports.getDeviceConnectorType=Xe;exports.getFiberColor=Ht;exports.getPDUPortType=ut;exports.getPowerPortStyle=Ce;exports.getRackBounds=lo;exports.getStatusColor=se;exports.inventoryCableToNetworkEdge=bo;exports.inventoryDeviceToNetworkNode=fo;exports.inventoryRackToNetworkNode=go;exports.inventoryToNetworkDiagram=vr;exports.isHighPowerConnector=Jo;exports.isPointInRack=Qe;exports.isStriped=no;exports.isUPositionAvailable=it;exports.removeDeviceFromRack=Dr;exports.removeSpliceFromTray=Ar;exports.replaceEdge=q;exports.snapToSplicePosition=kt;exports.snapToUPosition=nt;exports.updateDeviceUPosition=Vt;exports.updateDeviceUPositionInSchema=Er;exports.updateSpliceHolderPosition=Fr;exports.useDiagramEdges=$t;exports.useDiagramNodes=It;exports.useNetworkDiagram=ir;exports.validateAndSnapDevice=Ao;exports.validateRackDevicePlacements=At;exports.validateSplicePlacements=Wt;//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|