@almadar/ui 2.17.0 → 2.18.0

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React8 = require('react');
3
+ var React7 = require('react');
4
4
  var fiber = require('@react-three/fiber');
5
5
  var THREE6 = require('three');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
32
32
  return Object.freeze(n);
33
33
  }
34
34
 
35
- var React8__default = /*#__PURE__*/_interopDefault(React8);
35
+ var React7__default = /*#__PURE__*/_interopDefault(React7);
36
36
  var THREE6__namespace = /*#__PURE__*/_interopNamespace(THREE6);
37
37
 
38
38
  var __defProp = Object.defineProperty;
@@ -40,8 +40,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
40
40
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
41
  function Scene3D({ background = "#1a1a2e", fog, children }) {
42
42
  const { scene } = fiber.useThree();
43
- const initializedRef = React8.useRef(false);
44
- React8.useEffect(() => {
43
+ const initializedRef = React7.useRef(false);
44
+ React7.useEffect(() => {
45
45
  if (initializedRef.current) return;
46
46
  initializedRef.current = true;
47
47
  if (background.startsWith("#") || background.startsWith("rgb")) {
@@ -62,7 +62,7 @@ function Scene3D({ background = "#1a1a2e", fog, children }) {
62
62
  }, [scene, background, fog]);
63
63
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
64
64
  }
65
- var Camera3D = React8.forwardRef(
65
+ var Camera3D = React7.forwardRef(
66
66
  ({
67
67
  mode = "isometric",
68
68
  position = [10, 10, 10],
@@ -75,10 +75,10 @@ var Camera3D = React8.forwardRef(
75
75
  onChange
76
76
  }, ref) => {
77
77
  const { camera, set, viewport } = fiber.useThree();
78
- const controlsRef = React8.useRef(null);
79
- const initialPosition = React8.useRef(new THREE6__namespace.Vector3(...position));
80
- const initialTarget = React8.useRef(new THREE6__namespace.Vector3(...target));
81
- React8.useEffect(() => {
78
+ const controlsRef = React7.useRef(null);
79
+ const initialPosition = React7.useRef(new THREE6__namespace.Vector3(...position));
80
+ const initialTarget = React7.useRef(new THREE6__namespace.Vector3(...target));
81
+ React7.useEffect(() => {
82
82
  let newCamera;
83
83
  if (mode === "isometric") {
84
84
  const aspect = viewport.aspect;
@@ -109,7 +109,7 @@ var Camera3D = React8.forwardRef(
109
109
  onChange(camera);
110
110
  }
111
111
  });
112
- React8.useImperativeHandle(ref, () => ({
112
+ React7.useImperativeHandle(ref, () => ({
113
113
  getCamera: () => camera,
114
114
  setPosition: (x, y, z) => {
115
115
  camera.position.set(x, y, z);
@@ -250,7 +250,7 @@ function Canvas3DLoadingState({
250
250
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "canvas-3d-loading__background", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg__grid" }) })
251
251
  ] });
252
252
  }
253
- var Canvas3DErrorBoundary = class extends React8.Component {
253
+ var Canvas3DErrorBoundary = class extends React7.Component {
254
254
  constructor(props) {
255
255
  super(props);
256
256
  __publicField(this, "handleReset", () => {
@@ -329,12 +329,12 @@ function detectAssetRoot(modelUrl) {
329
329
  return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
330
330
  }
331
331
  function useGLTFModel(url, resourceBasePath) {
332
- const [state, setState] = React8.useState({
332
+ const [state, setState] = React7.useState({
333
333
  model: null,
334
334
  isLoading: false,
335
335
  error: null
336
336
  });
337
- React8.useEffect(() => {
337
+ React7.useEffect(() => {
338
338
  if (!url) {
339
339
  setState({ model: null, isLoading: false, error: null });
340
340
  return;
@@ -383,7 +383,7 @@ function ModelLoader({
383
383
  resourceBasePath
384
384
  }) {
385
385
  const { model: loadedModel, isLoading, error } = useGLTFModel(url, resourceBasePath);
386
- const model = React8.useMemo(() => {
386
+ const model = React7.useMemo(() => {
387
387
  if (!loadedModel) return null;
388
388
  const cloned = loadedModel.clone();
389
389
  cloned.traverse((child) => {
@@ -394,13 +394,13 @@ function ModelLoader({
394
394
  });
395
395
  return cloned;
396
396
  }, [loadedModel, castShadow, receiveShadow]);
397
- const scaleArray = React8.useMemo(() => {
397
+ const scaleArray = React7.useMemo(() => {
398
398
  if (typeof scale === "number") {
399
399
  return [scale, scale, scale];
400
400
  }
401
401
  return scale;
402
402
  }, [scale]);
403
- const rotationRad = React8.useMemo(() => {
403
+ const rotationRad = React7.useMemo(() => {
404
404
  return [
405
405
  rotation[0] * Math.PI / 180,
406
406
  rotation[1] * Math.PI / 180,
@@ -486,8 +486,8 @@ function PhysicsObject3D({
486
486
  onGroundHit,
487
487
  onCollision
488
488
  }) {
489
- const groupRef = React8.useRef(null);
490
- const physicsStateRef = React8.useRef({
489
+ const groupRef = React7.useRef(null);
490
+ const physicsStateRef = React7.useRef({
491
491
  id: entityId,
492
492
  x: initialPosition[0],
493
493
  y: initialPosition[1],
@@ -504,8 +504,8 @@ function PhysicsObject3D({
504
504
  mass,
505
505
  state: "Active"
506
506
  });
507
- const groundHitRef = React8.useRef(false);
508
- React8.useEffect(() => {
507
+ const groundHitRef = React7.useRef(false);
508
+ React7.useEffect(() => {
509
509
  if (groupRef.current) {
510
510
  groupRef.current.position.set(
511
511
  initialPosition[0],
@@ -786,21 +786,21 @@ var DEFAULT_OPTIONS = {
786
786
  };
787
787
  function useThree3(options = {}) {
788
788
  const opts = { ...DEFAULT_OPTIONS, ...options };
789
- const containerRef = React8.useRef(null);
790
- const canvasRef = React8.useRef(null);
791
- const rendererRef = React8.useRef(null);
792
- const sceneRef = React8.useRef(null);
793
- const cameraRef = React8.useRef(null);
794
- const controlsRef = React8.useRef(null);
795
- const gridHelperRef = React8.useRef(null);
796
- const rafRef = React8.useRef(0);
797
- const [isReady, setIsReady] = React8.useState(false);
798
- const [dimensions, setDimensions] = React8.useState({ width: 0, height: 0 });
799
- const initialCameraPosition = React8.useMemo(
789
+ const containerRef = React7.useRef(null);
790
+ const canvasRef = React7.useRef(null);
791
+ const rendererRef = React7.useRef(null);
792
+ const sceneRef = React7.useRef(null);
793
+ const cameraRef = React7.useRef(null);
794
+ const controlsRef = React7.useRef(null);
795
+ const gridHelperRef = React7.useRef(null);
796
+ const rafRef = React7.useRef(0);
797
+ const [isReady, setIsReady] = React7.useState(false);
798
+ const [dimensions, setDimensions] = React7.useState({ width: 0, height: 0 });
799
+ const initialCameraPosition = React7.useMemo(
800
800
  () => new THREE6__namespace.Vector3(...opts.cameraPosition),
801
801
  []
802
802
  );
803
- React8.useEffect(() => {
803
+ React7.useEffect(() => {
804
804
  if (!containerRef.current) return;
805
805
  const container = containerRef.current;
806
806
  const { clientWidth, clientHeight } = container;
@@ -893,7 +893,7 @@ function useThree3(options = {}) {
893
893
  scene.clear();
894
894
  };
895
895
  }, []);
896
- React8.useEffect(() => {
896
+ React7.useEffect(() => {
897
897
  if (!cameraRef.current || !containerRef.current) return;
898
898
  const container = containerRef.current;
899
899
  const { clientWidth, clientHeight } = container;
@@ -928,20 +928,20 @@ function useThree3(options = {}) {
928
928
  animate();
929
929
  }
930
930
  }, [opts.cameraMode]);
931
- const setCameraPosition = React8.useCallback((x, y, z) => {
931
+ const setCameraPosition = React7.useCallback((x, y, z) => {
932
932
  if (cameraRef.current) {
933
933
  cameraRef.current.position.set(x, y, z);
934
934
  controlsRef.current?.update();
935
935
  }
936
936
  }, []);
937
- const lookAt = React8.useCallback((x, y, z) => {
937
+ const lookAt = React7.useCallback((x, y, z) => {
938
938
  if (cameraRef.current) {
939
939
  cameraRef.current.lookAt(x, y, z);
940
940
  controlsRef.current?.target.set(x, y, z);
941
941
  controlsRef.current?.update();
942
942
  }
943
943
  }, []);
944
- const resetCamera = React8.useCallback(() => {
944
+ const resetCamera = React7.useCallback(() => {
945
945
  if (cameraRef.current) {
946
946
  cameraRef.current.position.copy(initialCameraPosition);
947
947
  cameraRef.current.lookAt(0, 0, 0);
@@ -951,7 +951,7 @@ function useThree3(options = {}) {
951
951
  }
952
952
  }
953
953
  }, [initialCameraPosition]);
954
- const fitView = React8.useCallback(
954
+ const fitView = React7.useCallback(
955
955
  (bounds) => {
956
956
  if (!cameraRef.current) return;
957
957
  const centerX = (bounds.minX + bounds.maxX) / 2;
@@ -982,20 +982,20 @@ function useThree3(options = {}) {
982
982
  }
983
983
  function useAssetLoader(options = {}) {
984
984
  const { preloadUrls = [], loader: customLoader } = options;
985
- const loaderRef = React8.useRef(customLoader || new AssetLoader());
986
- const [state, setState] = React8.useState({
985
+ const loaderRef = React7.useRef(customLoader || new AssetLoader());
986
+ const [state, setState] = React7.useState({
987
987
  isLoading: false,
988
988
  progress: 0,
989
989
  loaded: 0,
990
990
  total: 0,
991
991
  errors: []
992
992
  });
993
- React8.useEffect(() => {
993
+ React7.useEffect(() => {
994
994
  if (preloadUrls.length > 0) {
995
995
  preload(preloadUrls);
996
996
  }
997
997
  }, []);
998
- const updateProgress = React8.useCallback((loaded, total) => {
998
+ const updateProgress = React7.useCallback((loaded, total) => {
999
999
  setState((prev) => ({
1000
1000
  ...prev,
1001
1001
  loaded,
@@ -1003,7 +1003,7 @@ function useAssetLoader(options = {}) {
1003
1003
  progress: total > 0 ? Math.round(loaded / total * 100) : 0
1004
1004
  }));
1005
1005
  }, []);
1006
- const loadModel = React8.useCallback(
1006
+ const loadModel = React7.useCallback(
1007
1007
  async (url) => {
1008
1008
  setState((prev) => ({ ...prev, isLoading: true }));
1009
1009
  try {
@@ -1026,7 +1026,7 @@ function useAssetLoader(options = {}) {
1026
1026
  },
1027
1027
  []
1028
1028
  );
1029
- const loadOBJ = React8.useCallback(
1029
+ const loadOBJ = React7.useCallback(
1030
1030
  async (url) => {
1031
1031
  setState((prev) => ({ ...prev, isLoading: true }));
1032
1032
  try {
@@ -1049,7 +1049,7 @@ function useAssetLoader(options = {}) {
1049
1049
  },
1050
1050
  []
1051
1051
  );
1052
- const loadTexture = React8.useCallback(
1052
+ const loadTexture = React7.useCallback(
1053
1053
  async (url) => {
1054
1054
  setState((prev) => ({ ...prev, isLoading: true }));
1055
1055
  try {
@@ -1072,7 +1072,7 @@ function useAssetLoader(options = {}) {
1072
1072
  },
1073
1073
  []
1074
1074
  );
1075
- const preload = React8.useCallback(
1075
+ const preload = React7.useCallback(
1076
1076
  async (urls) => {
1077
1077
  setState((prev) => ({
1078
1078
  ...prev,
@@ -1111,27 +1111,27 @@ function useAssetLoader(options = {}) {
1111
1111
  },
1112
1112
  [updateProgress]
1113
1113
  );
1114
- const hasModel = React8.useCallback((url) => {
1114
+ const hasModel = React7.useCallback((url) => {
1115
1115
  return loaderRef.current.hasModel(url);
1116
1116
  }, []);
1117
- const hasTexture = React8.useCallback((url) => {
1117
+ const hasTexture = React7.useCallback((url) => {
1118
1118
  return loaderRef.current.hasTexture(url);
1119
1119
  }, []);
1120
- const getModel = React8.useCallback((url) => {
1120
+ const getModel = React7.useCallback((url) => {
1121
1121
  try {
1122
1122
  return loaderRef.current.getModel(url);
1123
1123
  } catch {
1124
1124
  return void 0;
1125
1125
  }
1126
1126
  }, []);
1127
- const getTexture = React8.useCallback((url) => {
1127
+ const getTexture = React7.useCallback((url) => {
1128
1128
  try {
1129
1129
  return loaderRef.current.getTexture(url);
1130
1130
  } catch {
1131
1131
  return void 0;
1132
1132
  }
1133
1133
  }, []);
1134
- const clearCache = React8.useCallback(() => {
1134
+ const clearCache = React7.useCallback(() => {
1135
1135
  loaderRef.current.clearCache();
1136
1136
  setState({
1137
1137
  isLoading: false,
@@ -1155,25 +1155,25 @@ function useAssetLoader(options = {}) {
1155
1155
  };
1156
1156
  }
1157
1157
  function useSceneGraph() {
1158
- const nodesRef = React8.useRef(/* @__PURE__ */ new Map());
1159
- const addNode = React8.useCallback((node) => {
1158
+ const nodesRef = React7.useRef(/* @__PURE__ */ new Map());
1159
+ const addNode = React7.useCallback((node) => {
1160
1160
  const existing = nodesRef.current.get(node.id);
1161
1161
  if (existing) {
1162
1162
  existing.mesh.removeFromParent();
1163
1163
  }
1164
1164
  nodesRef.current.set(node.id, node);
1165
1165
  }, []);
1166
- const removeNode = React8.useCallback((id) => {
1166
+ const removeNode = React7.useCallback((id) => {
1167
1167
  const node = nodesRef.current.get(id);
1168
1168
  if (node) {
1169
1169
  node.mesh.removeFromParent();
1170
1170
  nodesRef.current.delete(id);
1171
1171
  }
1172
1172
  }, []);
1173
- const getNode = React8.useCallback((id) => {
1173
+ const getNode = React7.useCallback((id) => {
1174
1174
  return nodesRef.current.get(id);
1175
1175
  }, []);
1176
- const updateNodePosition = React8.useCallback(
1176
+ const updateNodePosition = React7.useCallback(
1177
1177
  (id, x, y, z) => {
1178
1178
  const node = nodesRef.current.get(id);
1179
1179
  if (node) {
@@ -1183,7 +1183,7 @@ function useSceneGraph() {
1183
1183
  },
1184
1184
  []
1185
1185
  );
1186
- const updateNodeGridPosition = React8.useCallback(
1186
+ const updateNodeGridPosition = React7.useCallback(
1187
1187
  (id, gridX, gridZ) => {
1188
1188
  const node = nodesRef.current.get(id);
1189
1189
  if (node) {
@@ -1192,7 +1192,7 @@ function useSceneGraph() {
1192
1192
  },
1193
1193
  []
1194
1194
  );
1195
- const getNodeAtGrid = React8.useCallback(
1195
+ const getNodeAtGrid = React7.useCallback(
1196
1196
  (x, z, type) => {
1197
1197
  return Array.from(nodesRef.current.values()).find((node) => {
1198
1198
  const matchesGrid = node.gridPosition.x === x && node.gridPosition.z === z;
@@ -1201,10 +1201,10 @@ function useSceneGraph() {
1201
1201
  },
1202
1202
  []
1203
1203
  );
1204
- const getNodesByType = React8.useCallback((type) => {
1204
+ const getNodesByType = React7.useCallback((type) => {
1205
1205
  return Array.from(nodesRef.current.values()).filter((node) => node.type === type);
1206
1206
  }, []);
1207
- const getNodesInBounds = React8.useCallback(
1207
+ const getNodesInBounds = React7.useCallback(
1208
1208
  (minX, maxX, minZ, maxZ) => {
1209
1209
  return Array.from(nodesRef.current.values()).filter((node) => {
1210
1210
  const { x, z } = node.gridPosition;
@@ -1213,13 +1213,13 @@ function useSceneGraph() {
1213
1213
  },
1214
1214
  []
1215
1215
  );
1216
- const clearNodes = React8.useCallback(() => {
1216
+ const clearNodes = React7.useCallback(() => {
1217
1217
  nodesRef.current.forEach((node) => {
1218
1218
  node.mesh.removeFromParent();
1219
1219
  });
1220
1220
  nodesRef.current.clear();
1221
1221
  }, []);
1222
- const countNodes = React8.useCallback((type) => {
1222
+ const countNodes = React7.useCallback((type) => {
1223
1223
  if (!type) {
1224
1224
  return nodesRef.current.size;
1225
1225
  }
@@ -1241,9 +1241,9 @@ function useSceneGraph() {
1241
1241
  }
1242
1242
  function useRaycaster(options) {
1243
1243
  const { camera, canvas, cellSize = 1, offsetX = 0, offsetZ = 0 } = options;
1244
- const raycaster = React8.useRef(new THREE6__namespace.Raycaster());
1245
- const mouse = React8.useRef(new THREE6__namespace.Vector2());
1246
- const clientToNDC = React8.useCallback(
1244
+ const raycaster = React7.useRef(new THREE6__namespace.Raycaster());
1245
+ const mouse = React7.useRef(new THREE6__namespace.Vector2());
1246
+ const clientToNDC = React7.useCallback(
1247
1247
  (clientX, clientY) => {
1248
1248
  if (!canvas) {
1249
1249
  return { x: 0, y: 0 };
@@ -1256,7 +1256,7 @@ function useRaycaster(options) {
1256
1256
  },
1257
1257
  [canvas]
1258
1258
  );
1259
- const isWithinCanvas = React8.useCallback(
1259
+ const isWithinCanvas = React7.useCallback(
1260
1260
  (clientX, clientY) => {
1261
1261
  if (!canvas) return false;
1262
1262
  const rect = canvas.getBoundingClientRect();
@@ -1264,7 +1264,7 @@ function useRaycaster(options) {
1264
1264
  },
1265
1265
  [canvas]
1266
1266
  );
1267
- const getIntersection = React8.useCallback(
1267
+ const getIntersection = React7.useCallback(
1268
1268
  (clientX, clientY, objects) => {
1269
1269
  if (!camera || !canvas) return null;
1270
1270
  const ndc = clientToNDC(clientX, clientY);
@@ -1287,7 +1287,7 @@ function useRaycaster(options) {
1287
1287
  },
1288
1288
  [camera, canvas, clientToNDC]
1289
1289
  );
1290
- const getAllIntersections = React8.useCallback(
1290
+ const getAllIntersections = React7.useCallback(
1291
1291
  (clientX, clientY, objects) => {
1292
1292
  if (!camera || !canvas) return [];
1293
1293
  const ndc = clientToNDC(clientX, clientY);
@@ -1306,7 +1306,7 @@ function useRaycaster(options) {
1306
1306
  },
1307
1307
  [camera, canvas, clientToNDC]
1308
1308
  );
1309
- const getGridCoordinates = React8.useCallback(
1309
+ const getGridCoordinates = React7.useCallback(
1310
1310
  (clientX, clientY) => {
1311
1311
  if (!camera || !canvas) return null;
1312
1312
  const ndc = clientToNDC(clientX, clientY);
@@ -1324,7 +1324,7 @@ function useRaycaster(options) {
1324
1324
  },
1325
1325
  [camera, canvas, cellSize, offsetX, offsetZ, clientToNDC]
1326
1326
  );
1327
- const getTileAtPosition = React8.useCallback(
1327
+ const getTileAtPosition = React7.useCallback(
1328
1328
  (clientX, clientY, scene) => {
1329
1329
  if (!camera || !canvas) return null;
1330
1330
  const tileMeshes = [];
@@ -1373,7 +1373,7 @@ function useRaycaster(options) {
1373
1373
  isWithinCanvas
1374
1374
  };
1375
1375
  }
1376
- var EventBusContext = React8.createContext(null);
1376
+ var EventBusContext = React7.createContext(null);
1377
1377
 
1378
1378
  // hooks/useEventBus.ts
1379
1379
  function getGlobalEventBus() {
@@ -1443,12 +1443,12 @@ var fallbackEventBus = {
1443
1443
  }
1444
1444
  };
1445
1445
  function useEventBus() {
1446
- const context = React8.useContext(EventBusContext);
1446
+ const context = React7.useContext(EventBusContext);
1447
1447
  return context ?? getGlobalEventBus() ?? fallbackEventBus;
1448
1448
  }
1449
1449
  function useEmitEvent() {
1450
1450
  const eventBus = useEventBus();
1451
- return React8.useCallback(
1451
+ return React7.useCallback(
1452
1452
  (type, payload) => {
1453
1453
  eventBus.emit(type, payload);
1454
1454
  },
@@ -1475,9 +1475,9 @@ function useGameCanvas3DEvents(options) {
1475
1475
  onUnitAnimation
1476
1476
  } = options;
1477
1477
  const emit = useEmitEvent();
1478
- const optionsRef = React8.useRef(options);
1478
+ const optionsRef = React7.useRef(options);
1479
1479
  optionsRef.current = options;
1480
- const handleTileClick = React8.useCallback(
1480
+ const handleTileClick = React7.useCallback(
1481
1481
  (tile, event) => {
1482
1482
  if (tileClickEvent) {
1483
1483
  emit(tileClickEvent, {
@@ -1493,7 +1493,7 @@ function useGameCanvas3DEvents(options) {
1493
1493
  },
1494
1494
  [tileClickEvent, emit]
1495
1495
  );
1496
- const handleUnitClick = React8.useCallback(
1496
+ const handleUnitClick = React7.useCallback(
1497
1497
  (unit, event) => {
1498
1498
  if (unitClickEvent) {
1499
1499
  emit(unitClickEvent, {
@@ -1512,7 +1512,7 @@ function useGameCanvas3DEvents(options) {
1512
1512
  },
1513
1513
  [unitClickEvent, emit]
1514
1514
  );
1515
- const handleFeatureClick = React8.useCallback(
1515
+ const handleFeatureClick = React7.useCallback(
1516
1516
  (feature, event) => {
1517
1517
  if (featureClickEvent) {
1518
1518
  emit(featureClickEvent, {
@@ -1527,7 +1527,7 @@ function useGameCanvas3DEvents(options) {
1527
1527
  },
1528
1528
  [featureClickEvent, emit]
1529
1529
  );
1530
- const handleCanvasClick = React8.useCallback(
1530
+ const handleCanvasClick = React7.useCallback(
1531
1531
  (event) => {
1532
1532
  if (canvasClickEvent) {
1533
1533
  emit(canvasClickEvent, {
@@ -1540,7 +1540,7 @@ function useGameCanvas3DEvents(options) {
1540
1540
  },
1541
1541
  [canvasClickEvent, emit]
1542
1542
  );
1543
- const handleTileHover = React8.useCallback(
1543
+ const handleTileHover = React7.useCallback(
1544
1544
  (tile, event) => {
1545
1545
  if (tile) {
1546
1546
  if (tileHoverEvent) {
@@ -1560,7 +1560,7 @@ function useGameCanvas3DEvents(options) {
1560
1560
  },
1561
1561
  [tileHoverEvent, tileLeaveEvent, emit]
1562
1562
  );
1563
- const handleUnitAnimation = React8.useCallback(
1563
+ const handleUnitAnimation = React7.useCallback(
1564
1564
  (unitId, state) => {
1565
1565
  if (unitAnimationEvent) {
1566
1566
  emit(unitAnimationEvent, {
@@ -1573,7 +1573,7 @@ function useGameCanvas3DEvents(options) {
1573
1573
  },
1574
1574
  [unitAnimationEvent, emit]
1575
1575
  );
1576
- const handleCameraChange = React8.useCallback(
1576
+ const handleCameraChange = React7.useCallback(
1577
1577
  (position) => {
1578
1578
  if (cameraChangeEvent) {
1579
1579
  emit(cameraChangeEvent, {
@@ -1619,17 +1619,17 @@ function TileRenderer({
1619
1619
  validMoves = [],
1620
1620
  attackTargets = []
1621
1621
  }) {
1622
- const meshRef = React8.useRef(null);
1623
- const geometry = React8.useMemo(() => {
1622
+ const meshRef = React7.useRef(null);
1623
+ const geometry = React7.useMemo(() => {
1624
1624
  return new THREE6__namespace.BoxGeometry(cellSize * 0.95, 0.2, cellSize * 0.95);
1625
1625
  }, [cellSize]);
1626
- const material = React8.useMemo(() => {
1626
+ const material = React7.useMemo(() => {
1627
1627
  return new THREE6__namespace.MeshStandardMaterial({
1628
1628
  roughness: 0.8,
1629
1629
  metalness: 0.1
1630
1630
  });
1631
1631
  }, []);
1632
- const { positions, colors, tileMap } = React8.useMemo(() => {
1632
+ const { positions, colors, tileMap } = React7.useMemo(() => {
1633
1633
  const pos = [];
1634
1634
  const cols = [];
1635
1635
  const map = /* @__PURE__ */ new Map();
@@ -1659,7 +1659,7 @@ function TileRenderer({
1659
1659
  });
1660
1660
  return { positions: pos, colors: cols, tileMap: map };
1661
1661
  }, [tiles, cellSize, offsetX, offsetZ, terrainColors, selectedTileIds, validMoves, attackTargets]);
1662
- React8.useEffect(() => {
1662
+ React7.useEffect(() => {
1663
1663
  if (!meshRef.current || !useInstancing) return;
1664
1664
  const mesh = meshRef.current;
1665
1665
  mesh.count = positions.length;
@@ -1763,10 +1763,10 @@ function TileRenderer({
1763
1763
  return /* @__PURE__ */ jsxRuntime.jsx("group", { children: renderIndividualTiles() });
1764
1764
  }
1765
1765
  function UnitVisual({ unit, position, isSelected, onClick }) {
1766
- const groupRef = React8.useRef(null);
1767
- const [animationState, setAnimationState] = React8.useState("idle");
1768
- const [isHovered, setIsHovered] = React8.useState(false);
1769
- const teamColor = React8.useMemo(() => {
1766
+ const groupRef = React7.useRef(null);
1767
+ const [animationState, setAnimationState] = React7.useState("idle");
1768
+ const [isHovered, setIsHovered] = React7.useState(false);
1769
+ const teamColor = React7.useMemo(() => {
1770
1770
  if (unit.faction === "player" || unit.team === "player") return 4491519;
1771
1771
  if (unit.faction === "enemy" || unit.team === "enemy") return 16729156;
1772
1772
  if (unit.faction === "neutral" || unit.team === "neutral") return 16777028;
@@ -1778,11 +1778,11 @@ function UnitVisual({ unit, position, isSelected, onClick }) {
1778
1778
  groupRef.current.position.y = y;
1779
1779
  }
1780
1780
  });
1781
- const healthPercent = React8.useMemo(() => {
1781
+ const healthPercent = React7.useMemo(() => {
1782
1782
  if (unit.health === void 0 || unit.maxHealth === void 0) return 1;
1783
1783
  return Math.max(0, Math.min(1, unit.health / unit.maxHealth));
1784
1784
  }, [unit.health, unit.maxHealth]);
1785
- const healthColor = React8.useMemo(() => {
1785
+ const healthColor = React7.useMemo(() => {
1786
1786
  if (healthPercent > 0.5) return "#44aa44";
1787
1787
  if (healthPercent > 0.25) return "#aaaa44";
1788
1788
  return "#ff4444";
@@ -1843,7 +1843,7 @@ function UnitRenderer({
1843
1843
  onAnimationStateChange,
1844
1844
  animationSpeed = 1
1845
1845
  }) {
1846
- const handleUnitClick = React8__default.default.useCallback(
1846
+ const handleUnitClick = React7__default.default.useCallback(
1847
1847
  (unit) => {
1848
1848
  onUnitClick?.(unit);
1849
1849
  },
@@ -2056,10 +2056,10 @@ function detectAssetRoot3(modelUrl) {
2056
2056
  return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
2057
2057
  }
2058
2058
  function useGLTFModel2(url) {
2059
- const [model, setModel] = React8.useState(null);
2060
- const [isLoading, setIsLoading] = React8.useState(false);
2061
- const [error, setError] = React8.useState(null);
2062
- React8.useEffect(() => {
2059
+ const [model, setModel] = React7.useState(null);
2060
+ const [isLoading, setIsLoading] = React7.useState(false);
2061
+ const [error, setError] = React7.useState(null);
2062
+ React7.useEffect(() => {
2063
2063
  if (!url) {
2064
2064
  setModel(null);
2065
2065
  return;
@@ -2091,9 +2091,9 @@ function FeatureModel({
2091
2091
  onClick,
2092
2092
  onHover
2093
2093
  }) {
2094
- const groupRef = React8.useRef(null);
2094
+ const groupRef = React7.useRef(null);
2095
2095
  const { model: loadedModel, isLoading } = useGLTFModel2(feature.assetUrl);
2096
- const model = React8.useMemo(() => {
2096
+ const model = React7.useMemo(() => {
2097
2097
  if (!loadedModel) return null;
2098
2098
  const cloned = loadedModel.clone();
2099
2099
  cloned.scale.setScalar(0.3);
@@ -2211,7 +2211,7 @@ function CameraController({
2211
2211
  onCameraChange
2212
2212
  }) {
2213
2213
  const { camera } = fiber.useThree();
2214
- React8.useEffect(() => {
2214
+ React7.useEffect(() => {
2215
2215
  if (onCameraChange) {
2216
2216
  onCameraChange({
2217
2217
  x: camera.position.x,
@@ -2222,7 +2222,7 @@ function CameraController({
2222
2222
  }, [camera.position, onCameraChange]);
2223
2223
  return null;
2224
2224
  }
2225
- var GameCanvas3D = React8.forwardRef(
2225
+ var GameCanvas3D = React7.forwardRef(
2226
2226
  ({
2227
2227
  tiles = [],
2228
2228
  units = [],
@@ -2267,10 +2267,10 @@ var GameCanvas3D = React8.forwardRef(
2267
2267
  selectedUnitId = null,
2268
2268
  children
2269
2269
  }, ref) => {
2270
- const containerRef = React8.useRef(null);
2271
- const controlsRef = React8.useRef(null);
2272
- const [hoveredTile, setHoveredTile] = React8.useState(null);
2273
- const [internalError, setInternalError] = React8.useState(null);
2270
+ const containerRef = React7.useRef(null);
2271
+ const controlsRef = React7.useRef(null);
2272
+ const [hoveredTile, setHoveredTile] = React7.useState(null);
2273
+ const [internalError, setInternalError] = React7.useState(null);
2274
2274
  const { isLoading: assetsLoading, progress, loaded, total } = useAssetLoader({
2275
2275
  preloadUrls: preloadAssets,
2276
2276
  loader: customAssetLoader
@@ -2291,7 +2291,7 @@ var GameCanvas3D = React8.forwardRef(
2291
2291
  onTileHover,
2292
2292
  onUnitAnimation
2293
2293
  });
2294
- const gridBounds = React8.useMemo(() => {
2294
+ const gridBounds = React7.useMemo(() => {
2295
2295
  if (tiles.length === 0) {
2296
2296
  return { minX: 0, maxX: 10, minZ: 0, maxZ: 10 };
2297
2297
  }
@@ -2304,14 +2304,14 @@ var GameCanvas3D = React8.forwardRef(
2304
2304
  maxZ: Math.max(...zs)
2305
2305
  };
2306
2306
  }, [tiles]);
2307
- const cameraTarget = React8.useMemo(() => {
2307
+ const cameraTarget = React7.useMemo(() => {
2308
2308
  return [
2309
2309
  (gridBounds.minX + gridBounds.maxX) / 2,
2310
2310
  0,
2311
2311
  (gridBounds.minZ + gridBounds.maxZ) / 2
2312
2312
  ];
2313
2313
  }, [gridBounds]);
2314
- const gridConfig = React8.useMemo(
2314
+ const gridConfig = React7.useMemo(
2315
2315
  () => ({
2316
2316
  ...DEFAULT_GRID_CONFIG,
2317
2317
  offsetX: -(gridBounds.maxX - gridBounds.minX) / 2,
@@ -2319,7 +2319,7 @@ var GameCanvas3D = React8.forwardRef(
2319
2319
  }),
2320
2320
  [gridBounds]
2321
2321
  );
2322
- const gridToWorld2 = React8.useCallback(
2322
+ const gridToWorld2 = React7.useCallback(
2323
2323
  (x, z, y = 0) => {
2324
2324
  const worldX = (x - gridBounds.minX) * gridConfig.cellSize;
2325
2325
  const worldZ = (z - gridBounds.minZ) * gridConfig.cellSize;
@@ -2327,7 +2327,7 @@ var GameCanvas3D = React8.forwardRef(
2327
2327
  },
2328
2328
  [gridBounds, gridConfig]
2329
2329
  );
2330
- React8.useImperativeHandle(ref, () => ({
2330
+ React7.useImperativeHandle(ref, () => ({
2331
2331
  getCameraPosition: () => {
2332
2332
  if (controlsRef.current) {
2333
2333
  const pos = controlsRef.current.object.position;
@@ -2365,19 +2365,19 @@ var GameCanvas3D = React8.forwardRef(
2365
2365
  features
2366
2366
  })
2367
2367
  }));
2368
- const handleTileClick = React8.useCallback(
2368
+ const handleTileClick = React7.useCallback(
2369
2369
  (tile, event) => {
2370
2370
  eventHandlers.handleTileClick(tile, event);
2371
2371
  },
2372
2372
  [eventHandlers]
2373
2373
  );
2374
- const handleUnitClick = React8.useCallback(
2374
+ const handleUnitClick = React7.useCallback(
2375
2375
  (unit, event) => {
2376
2376
  eventHandlers.handleUnitClick(unit, event);
2377
2377
  },
2378
2378
  [eventHandlers]
2379
2379
  );
2380
- const handleFeatureClick = React8.useCallback(
2380
+ const handleFeatureClick = React7.useCallback(
2381
2381
  (feature, event) => {
2382
2382
  if (event) {
2383
2383
  eventHandlers.handleFeatureClick(feature, event);
@@ -2385,7 +2385,7 @@ var GameCanvas3D = React8.forwardRef(
2385
2385
  },
2386
2386
  [eventHandlers]
2387
2387
  );
2388
- const handleTileHover = React8.useCallback(
2388
+ const handleTileHover = React7.useCallback(
2389
2389
  (tile, event) => {
2390
2390
  setHoveredTile(tile);
2391
2391
  if (event) {
@@ -2394,7 +2394,7 @@ var GameCanvas3D = React8.forwardRef(
2394
2394
  },
2395
2395
  [eventHandlers]
2396
2396
  );
2397
- const cameraConfig = React8.useMemo(() => {
2397
+ const cameraConfig = React7.useMemo(() => {
2398
2398
  const size = Math.max(
2399
2399
  gridBounds.maxX - gridBounds.minX,
2400
2400
  gridBounds.maxZ - gridBounds.minZ
@@ -2419,7 +2419,7 @@ var GameCanvas3D = React8.forwardRef(
2419
2419
  };
2420
2420
  }
2421
2421
  }, [cameraMode, gridBounds]);
2422
- const DefaultTileRenderer = React8.useCallback(
2422
+ const DefaultTileRenderer = React7.useCallback(
2423
2423
  ({ tile, position }) => {
2424
2424
  const isSelected = tile.id ? selectedTileIds.includes(tile.id) : false;
2425
2425
  const isHovered = hoveredTile?.id === tile.id;
@@ -2457,7 +2457,7 @@ var GameCanvas3D = React8.forwardRef(
2457
2457
  },
2458
2458
  [selectedTileIds, hoveredTile, validMoves, attackTargets, handleTileClick, handleTileHover]
2459
2459
  );
2460
- const DefaultUnitRenderer = React8.useCallback(
2460
+ const DefaultUnitRenderer = React7.useCallback(
2461
2461
  ({ unit, position }) => {
2462
2462
  const isSelected = selectedUnitId === unit.id;
2463
2463
  const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
@@ -2515,7 +2515,7 @@ var GameCanvas3D = React8.forwardRef(
2515
2515
  },
2516
2516
  [selectedUnitId, handleUnitClick]
2517
2517
  );
2518
- const DefaultFeatureRenderer = React8.useCallback(
2518
+ const DefaultFeatureRenderer = React7.useCallback(
2519
2519
  ({
2520
2520
  feature,
2521
2521
  position
@@ -2822,7 +2822,7 @@ var positionStyles = {
2822
2822
  fixed: "fixed",
2823
2823
  sticky: "sticky"
2824
2824
  };
2825
- var Box = React8__default.default.forwardRef(
2825
+ var Box = React7__default.default.forwardRef(
2826
2826
  ({
2827
2827
  padding,
2828
2828
  paddingX,
@@ -2851,20 +2851,20 @@ var Box = React8__default.default.forwardRef(
2851
2851
  ...rest
2852
2852
  }, ref) => {
2853
2853
  const eventBus = useEventBus();
2854
- const handleClick = React8.useCallback((e) => {
2854
+ const handleClick = React7.useCallback((e) => {
2855
2855
  if (action) {
2856
2856
  e.stopPropagation();
2857
2857
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
2858
2858
  }
2859
2859
  onClick?.(e);
2860
2860
  }, [action, actionPayload, eventBus, onClick]);
2861
- const handleMouseEnter = React8.useCallback((e) => {
2861
+ const handleMouseEnter = React7.useCallback((e) => {
2862
2862
  if (hoverEvent) {
2863
2863
  eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
2864
2864
  }
2865
2865
  onMouseEnter?.(e);
2866
2866
  }, [hoverEvent, eventBus, onMouseEnter]);
2867
- const handleMouseLeave = React8.useCallback((e) => {
2867
+ const handleMouseLeave = React7.useCallback((e) => {
2868
2868
  if (hoverEvent) {
2869
2869
  eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
2870
2870
  }