floor-editor-ts 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60868,19 +60868,6 @@ function LayersPanel($$anchor, $$props) {
60868
60868
  delegate(["click", "keydown"]);
60869
60869
  //#endregion
60870
60870
  //#region src/lib/utils/furnitureIcons.ts
60871
- /**
60872
- * Architectural top-down furniture renderers for 2D canvas.
60873
- * Each function draws within a normalized rect: (-w/2, -d/2) to (w/2, d/2)
60874
- * where w = width*zoom, d = depth*zoom. Context is already translated & rotated.
60875
- */
60876
- function getHeatColor(value) {
60877
- switch (value) {
60878
- case 1: return "rgba(255, 220, 0, 0.25)";
60879
- case 2: return "rgba(255, 140, 0, 0.4)";
60880
- case 3: return "rgba(255, 60, 0, 0.6)";
60881
- default: return "rgba(0,0,0,0)";
60882
- }
60883
- }
60884
60871
  function roundRect(ctx, x, y, w, h, r) {
60885
60872
  r = Math.min(r, w / 2, h / 2);
60886
60873
  ctx.beginPath();
@@ -61688,103 +61675,122 @@ var drawSymGasLine = (ctx, w, d, color) => {
61688
61675
  ctx.fillText("G", 0, 0);
61689
61676
  };
61690
61677
  var persons = [];
61691
- var personGlow = null;
61692
61678
  var lastSpawnTime = 0;
61693
61679
  var SPAWN_INTERVAL = 1e3;
61694
61680
  var MAX_PERSONS = 20;
61695
- var drawCamera = (ctx, w, d, color, heatmapMatrix, hasPerson) => {
61681
+ var getHeatmapColor = (t, alpha = 1) => {
61682
+ t = Math.max(0, Math.min(t, 1));
61683
+ let r, g, b;
61684
+ if (t < .35) {
61685
+ const k = t / .35;
61686
+ r = 0;
61687
+ g = Math.round(120 + 135 * k);
61688
+ b = Math.round(255 - 180 * k);
61689
+ } else if (t < .7) {
61690
+ const k = (t - .35) / .35;
61691
+ r = Math.round(255 * k);
61692
+ g = 255;
61693
+ b = 0;
61694
+ } else {
61695
+ const k = (t - .7) / .3;
61696
+ r = 255;
61697
+ g = Math.round(255 - 255 * k);
61698
+ b = 0;
61699
+ }
61700
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
61701
+ };
61702
+ var drawCamera = (ctx, w, d, color, heatmapMatrix, hasPerson = false, showHeatmap = false) => {
61696
61703
  const bodyRadius = 4;
61697
61704
  const lensR = Math.min(w, d) * .25;
61698
61705
  const range = Math.max(w, d) * 6;
61699
61706
  const fov = Math.PI / 2;
61700
- ctx.save();
61701
- const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, range);
61702
- gradient.addColorStop(0, color + "66");
61703
- gradient.addColorStop(.5, color + "33");
61704
- gradient.addColorStop(1, color + "00");
61705
- ctx.fillStyle = gradient;
61706
- ctx.beginPath();
61707
- ctx.moveTo(0, 0);
61708
- ctx.arc(0, 0, range, -fov / 2, fov / 2);
61709
- ctx.closePath();
61710
- ctx.globalCompositeOperation = "lighter";
61711
- ctx.fill();
61712
- ctx.restore();
61713
- if (heatmapMatrix) {
61714
- const rows = heatmapMatrix.length;
61715
- const cols = heatmapMatrix[0].length;
61716
- const cellSize = Math.max(w, d) * .3;
61707
+ if (showHeatmap) {
61708
+ var _heatmapMatrix$;
61717
61709
  ctx.save();
61718
- ctx.translate(0, 0);
61710
+ const coneGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, range);
61711
+ coneGradient.addColorStop(0, color + "55");
61712
+ coneGradient.addColorStop(.45, color + "22");
61713
+ coneGradient.addColorStop(1, color + "00");
61714
+ ctx.fillStyle = coneGradient;
61719
61715
  ctx.globalCompositeOperation = "lighter";
61720
- ctx.filter = "blur(8px)";
61721
- const paths = {
61722
- 1: new Path2D(),
61723
- 2: new Path2D(),
61724
- 3: new Path2D(),
61725
- 4: new Path2D()
61726
- };
61727
- for (let y = 0; y < rows; y++) for (let x = 0; x < cols; x++) {
61728
- const value = heatmapMatrix[y][x];
61729
- if (value === 0) continue;
61730
- const angle = -fov / 2 + x / (cols - 1) * fov;
61731
- const r = y / rows * range;
61732
- const px = Math.cos(angle) * r;
61733
- const py = Math.sin(angle) * r;
61734
- paths[value].moveTo(px, py);
61735
- paths[value].arc(px, py, cellSize * .4, 0, Math.PI * 2);
61736
- }
61737
- Object.keys(paths).forEach((v) => {
61738
- ctx.fillStyle = getHeatColor(Number(v));
61739
- ctx.fill(paths[v]);
61740
- });
61716
+ ctx.beginPath();
61717
+ ctx.moveTo(0, 0);
61718
+ ctx.arc(0, 0, range, -fov / 2, fov / 2);
61719
+ ctx.closePath();
61720
+ ctx.fill();
61741
61721
  ctx.restore();
61742
- }
61743
- {
61744
- const now = Date.now();
61745
- const range = Math.max(w, d) * 6;
61746
- const fov = Math.PI / 2;
61747
- if (persons.length < MAX_PERSONS && now - lastSpawnTime > SPAWN_INTERVAL) {
61748
- lastSpawnTime = now;
61749
- persons.push({
61750
- startTime: now,
61751
- duration: 2e3 + Math.random() * 1e3,
61752
- direction: Math.random() > .5 ? "far-to-near" : "near-to-far",
61753
- angle: (Math.random() - .5) * fov * .8
61754
- });
61722
+ if ((heatmapMatrix === null || heatmapMatrix === void 0 ? void 0 : heatmapMatrix.length) && ((_heatmapMatrix$ = heatmapMatrix[0]) === null || _heatmapMatrix$ === void 0 ? void 0 : _heatmapMatrix$.length)) {
61723
+ const rows = heatmapMatrix.length;
61724
+ const cols = heatmapMatrix[0].length;
61725
+ const maxValue = Math.max(...heatmapMatrix.flat());
61726
+ if (maxValue > 0) {
61727
+ ctx.save();
61728
+ ctx.globalCompositeOperation = "lighter";
61729
+ ctx.filter = "blur(10px)";
61730
+ const radius = range / rows * 1.8;
61731
+ for (let y = 0; y < rows; y++) for (let x = 0; x < cols; x++) {
61732
+ const value = heatmapMatrix[y][x];
61733
+ if (!value || value <= 0) continue;
61734
+ const intensity = Math.min(value / maxValue, 1);
61735
+ const angle = -fov / 2 + (cols === 1 ? .5 : x / (cols - 1)) * fov;
61736
+ const r = (y + .5) / rows * range;
61737
+ const px = Math.cos(angle) * r;
61738
+ const py = Math.sin(angle) * r;
61739
+ const gradient = ctx.createRadialGradient(px, py, 0, px, py, radius);
61740
+ const alpha = .12 + intensity * .75;
61741
+ gradient.addColorStop(0, getHeatmapColor(intensity, alpha));
61742
+ gradient.addColorStop(.45, getHeatmapColor(intensity, alpha * .45));
61743
+ gradient.addColorStop(1, getHeatmapColor(intensity, 0));
61744
+ ctx.fillStyle = gradient;
61745
+ ctx.beginPath();
61746
+ ctx.arc(px, py, radius, 0, Math.PI * 2);
61747
+ ctx.fill();
61748
+ }
61749
+ ctx.restore();
61750
+ }
61755
61751
  }
61756
- persons = persons.filter((p) => {
61757
- let t = (now - p.startTime) / p.duration;
61758
- if (t >= 1) return false;
61759
- t = Math.max(0, Math.min(t, 1));
61760
- let r;
61761
- if (p.direction === "far-to-near") r = range * (.9 - t * .8);
61762
- else r = range * (.1 + t * .8);
61763
- const x = Math.cos(p.angle) * r;
61764
- const y = Math.sin(p.angle) * r;
61765
- ctx.save();
61766
- ctx.translate(x, y);
61767
- ctx.globalCompositeOperation = "lighter";
61768
- const scale = .5 + (1 - r / range);
61769
- ctx.scale(scale, scale);
61770
- ctx.globalAlpha = 1 - t;
61771
- if (!personGlow) {
61772
- personGlow = ctx.createRadialGradient(0, 0, 0, 0, 0, 20);
61773
- personGlow.addColorStop(0, "rgba(255,0,0,0.8)");
61774
- personGlow.addColorStop(1, "rgba(255,0,0,0)");
61752
+ if (hasPerson) {
61753
+ const now = Date.now();
61754
+ if (persons.length < MAX_PERSONS && now - lastSpawnTime > SPAWN_INTERVAL) {
61755
+ lastSpawnTime = now;
61756
+ persons.push({
61757
+ startTime: now,
61758
+ duration: 2e3 + Math.random() * 1e3,
61759
+ direction: Math.random() > .5 ? "far-to-near" : "near-to-far",
61760
+ angle: (Math.random() - .5) * fov * .8
61761
+ });
61775
61762
  }
61776
- ctx.fillStyle = personGlow;
61777
- ctx.beginPath();
61778
- ctx.arc(0, 0, 20, 0, Math.PI * 2);
61779
- ctx.fill();
61780
- ctx.beginPath();
61781
- ctx.arc(0, 0, 6, 0, Math.PI * 2);
61782
- ctx.fillStyle = "red";
61783
- ctx.fill();
61784
- ctx.restore();
61785
- return true;
61786
- });
61787
- }
61763
+ persons = persons.filter((p) => {
61764
+ let t = (now - p.startTime) / p.duration;
61765
+ if (t >= 1) return false;
61766
+ t = Math.max(0, Math.min(t, 1));
61767
+ let r;
61768
+ if (p.direction === "far-to-near") r = range * (.9 - t * .8);
61769
+ else r = range * (.1 + t * .8);
61770
+ const x = Math.cos(p.angle) * r;
61771
+ const y = Math.sin(p.angle) * r;
61772
+ ctx.save();
61773
+ ctx.translate(x, y);
61774
+ ctx.globalCompositeOperation = "lighter";
61775
+ const scale = .5 + (1 - r / range);
61776
+ ctx.scale(scale, scale);
61777
+ ctx.globalAlpha = 1 - t;
61778
+ const glow = ctx.createRadialGradient(0, 0, 0, 0, 0, 20);
61779
+ glow.addColorStop(0, "rgba(255,0,0,0.8)");
61780
+ glow.addColorStop(1, "rgba(255,0,0,0)");
61781
+ ctx.fillStyle = glow;
61782
+ ctx.beginPath();
61783
+ ctx.arc(0, 0, 20, 0, Math.PI * 2);
61784
+ ctx.fill();
61785
+ ctx.beginPath();
61786
+ ctx.arc(0, 0, 6, 0, Math.PI * 2);
61787
+ ctx.fillStyle = "red";
61788
+ ctx.fill();
61789
+ ctx.restore();
61790
+ return true;
61791
+ });
61792
+ } else persons = [];
61793
+ } else persons = [];
61788
61794
  ctx.fillStyle = color + "40";
61789
61795
  ctx.strokeStyle = color;
61790
61796
  ctx.lineWidth = 1;
@@ -61879,12 +61885,12 @@ var iconDrawers = {
61879
61885
  * @param w - pixel width (catalogWidth * zoom)
61880
61886
  * @param d - pixel depth (catalogDepth * zoom)
61881
61887
  */
61882
- function drawFurnitureIcon(ctx, catalogId, w, d, color, strokeColor, heatmapMatrix, hasPerson = false) {
61888
+ function drawFurnitureIcon(ctx, catalogId, w, d, color, strokeColor, heatmapMatrix, hasPerson = false, showHeatmap = false) {
61883
61889
  ctx.fillStyle = color + "60";
61884
61890
  ctx.strokeStyle = strokeColor;
61885
61891
  ctx.lineWidth = 1;
61886
61892
  const drawer = iconDrawers[catalogId];
61887
- if (drawer) drawer(ctx, w, d, color, heatmapMatrix, hasPerson);
61893
+ if (drawer) drawer(ctx, w, d, color, heatmapMatrix, hasPerson, showHeatmap);
61888
61894
  else {
61889
61895
  roundRect(ctx, -w / 2, -d / 2, w, d, 2);
61890
61896
  ctx.fill();
@@ -63276,7 +63282,7 @@ function drawFurnitureItem(cs, item, selected) {
63276
63282
  const itemColor = (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : cat.color;
63277
63283
  const strokeColor = selected ? "#3b82f6" : itemColor;
63278
63284
  ctx.lineWidth = selected ? 2 : 1;
63279
- drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, item.heatmapMatrix);
63285
+ drawFurnitureIcon(ctx, item.catalogId, w, d, itemColor, strokeColor, item.heatmapMatrix, item.hasPerson, item.showHeatmap);
63280
63286
  const fontSize = Math.max(8, Math.min(12, Math.min(w, d) * .2));
63281
63287
  if (Math.min(w, d) > 20) {
63282
63288
  ctx.fillStyle = "#374151";
@@ -64371,7 +64377,7 @@ var root_20 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -tr
64371
64377
  var root_21 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-emerald-600 text-white px-3 py-1 rounded-full text-xs shadow">Click to place text label · Esc to cancel</div>`);
64372
64378
  var root_22 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-indigo-600 text-white px-3 py-1 rounded-full text-xs shadow"> </div>`);
64373
64379
  var root_1$5 = /* @__PURE__ */ from_html(`<!> <!> <!> <!> <div class="absolute bottom-2 right-2 bg-white/80 rounded px-2 py-1 text-xs text-gray-500 flex gap-3"><!> <!> <!> <span> </span> <button class="hover:text-gray-700" title="Zoom to Fit (F)">⊞ Fit</button> <button class="hover:text-gray-700" title="Toggle Grid (G)"> </button> <button class="hover:text-gray-700" title="Toggle Snap to Grid (S)"> </button> <button class="hover:text-gray-700" title="Toggle Furniture"> </button> <button class="hover:text-gray-700" title="Layer Visibility">🗂 Layers</button> <button class="hover:text-gray-700" title="Toggle Rulers"> </button> <button class="hover:text-gray-700" title="Toggle Mini-map"> </button></div> <!> <!> <!> <!> <!> <!> <!> <div class="absolute bottom-3 left-3 z-20 flex items-center gap-1 bg-white rounded-lg shadow-lg border border-gray-200 px-1 py-0.5"><button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom Out (−)" aria-label="Zoom out">−</button> <button class="min-w-[3.5rem] h-7 flex items-center justify-center rounded hover:bg-gray-100 text-xs font-medium text-gray-600 hover:text-gray-800 tabular-nums" title="Reset to 100%" aria-label="Zoom to 100%"> </button> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom In (+)" aria-label="Zoom in">+</button> <div class="w-px h-5 bg-gray-200"></div> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-500 hover:text-gray-700 text-sm" title="Zoom to Fit (F)" aria-label="Zoom to fit">⊞</button></div> <!>`, 1);
64374
- var root = /* @__PURE__ */ from_html(`<div class="w-full h-full relative overflow-hidden" role="application"><canvas aria-label="Floor plan editor canvas"></canvas> <!></div>`);
64380
+ var root = /* @__PURE__ */ from_html(`<div class="w-full h-full relative overflow-hidden" role="application"><div><canvas aria-label="Floor plan editor canvas"></canvas></div> <!></div>`);
64375
64381
  function FloorPlanCanvas($$anchor, $$props) {
64376
64382
  push($$props, true);
64377
64383
  const $panMode = () => store_get(panMode, "$panMode", $$stores);
@@ -64384,22 +64390,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64384
64390
  let camX = /* @__PURE__ */ state(0);
64385
64391
  let camY = /* @__PURE__ */ state(0);
64386
64392
  let zoom = /* @__PURE__ */ state(1);
64387
- function createRandomMatrix(size = 20, clusterCount = 1) {
64388
- const matrix = Array.from({ length: size }, () => Array(size).fill(0));
64389
- for (let c = 0; c < clusterCount; c++) {
64390
- const cx = Math.random() * size;
64391
- const cy = Math.random() * size;
64392
- const sigma = size * .15;
64393
- for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
64394
- const dx = x - cx;
64395
- const dy = y - cy;
64396
- const value = Math.exp(-(dx * dx + dy * dy) / (2 * sigma * sigma));
64397
- const level = Math.floor(value * 4);
64398
- matrix[y][x] = Math.max(matrix[y][x], level);
64399
- }
64400
- }
64401
- return matrix;
64402
- }
64393
+ let needsFitToCanvas = true;
64403
64394
  let canvasDirty = true;
64404
64395
  function markDirty() {
64405
64396
  canvasDirty = true;
@@ -64822,9 +64813,7 @@ function FloorPlanCanvas($$anchor, $$props) {
64822
64813
  canvas.height = get(height);
64823
64814
  }
64824
64815
  markDirty();
64825
- if ($$props.viewOnly) requestAnimationFrame(() => {
64826
- zoomToFit();
64827
- });
64816
+ needsFitToCanvas = true;
64828
64817
  }
64829
64818
  function drawGrid() {
64830
64819
  if (!ctx || !get(showGrid)) return;
@@ -65250,195 +65239,6 @@ function FloorPlanCanvas($$anchor, $$props) {
65250
65239
  function drawColumn$1(col, selected) {
65251
65240
  drawColumn(getCS(), col, selected);
65252
65241
  }
65253
- function rulerLabel(worldCm, tickStep, isImperial) {
65254
- if (isImperial) {
65255
- const inches = worldCm / 2.54;
65256
- const ft = inches / 12;
65257
- if (tickStep / 2.54 >= 12) return `${ft % 1 === 0 ? ft.toFixed(0) : ft.toFixed(1)}'`;
65258
- return `${Math.round(inches)}"`;
65259
- }
65260
- if (tickStep >= 100) {
65261
- const m = worldCm / 100;
65262
- return `${worldCm % 100 === 0 ? m.toFixed(0) : m.toFixed(1)}m`;
65263
- }
65264
- return `${Math.round(worldCm)}`;
65265
- }
65266
- function drawRulers() {
65267
- if (!ctx || !get(showRulers) || $$props.viewOnly) return;
65268
- const R = RULER_SIZE;
65269
- const fontSize = 9;
65270
- const isImperial = get(dimSettings).units === "imperial";
65271
- ctx.save();
65272
- let tickStep;
65273
- let minorDiv;
65274
- let minorStep;
65275
- if (isImperial) {
65276
- const inchCm = 2.54;
65277
- const niceStepsCm = [
65278
- 1,
65279
- 2,
65280
- 6,
65281
- 12,
65282
- 24,
65283
- 60,
65284
- 120,
65285
- 240,
65286
- 600,
65287
- 1200,
65288
- 2400
65289
- ].map((i) => i * inchCm);
65290
- tickStep = niceStepsCm[niceStepsCm.length - 1];
65291
- for (const s of niceStepsCm) if (s * get(zoom) >= 40) {
65292
- tickStep = s;
65293
- break;
65294
- }
65295
- const tickInches = tickStep / inchCm;
65296
- minorDiv = tickInches >= 12 ? 6 : tickInches >= 6 ? 3 : 2;
65297
- minorStep = tickStep / minorDiv;
65298
- } else {
65299
- const niceSteps = [
65300
- 1,
65301
- 2,
65302
- 5,
65303
- 10,
65304
- 20,
65305
- 50,
65306
- 100,
65307
- 200,
65308
- 500,
65309
- 1e3,
65310
- 2e3,
65311
- 5e3
65312
- ];
65313
- tickStep = niceSteps[niceSteps.length - 1];
65314
- for (const s of niceSteps) if (s * get(zoom) >= 40) {
65315
- tickStep = s;
65316
- break;
65317
- }
65318
- minorDiv = tickStep >= 100 ? 5 : tickStep >= 10 ? 5 : 2;
65319
- minorStep = tickStep / minorDiv;
65320
- }
65321
- ctx.fillStyle = "#f1f3f5";
65322
- ctx.fillRect(R, 0, get(width) - R, R);
65323
- ctx.strokeStyle = "#d1d5db";
65324
- ctx.lineWidth = 1;
65325
- ctx.beginPath();
65326
- ctx.moveTo(R, R);
65327
- ctx.lineTo(get(width), R);
65328
- ctx.stroke();
65329
- const worldLeft = screenToWorld(R, 0).x;
65330
- const worldRight = screenToWorld(get(width), 0).x;
65331
- const startTick = Math.floor(worldLeft / minorStep) * minorStep;
65332
- ctx.fillStyle = "#6b7280";
65333
- ctx.font = `${fontSize}px sans-serif`;
65334
- ctx.textAlign = "center";
65335
- ctx.textBaseline = "top";
65336
- for (let wx = startTick; wx <= worldRight; wx += minorStep) {
65337
- const sx = worldToScreen(wx, 0).x;
65338
- if (sx < R) continue;
65339
- const isMajor = Math.abs(wx % tickStep) < .01;
65340
- const isMid = !isMajor && Math.abs(wx % (tickStep / 2)) < .01 && minorDiv >= 4;
65341
- const tickH = isMajor ? R * .7 : isMid ? R * .45 : R * .25;
65342
- const isOrigin = Math.abs(wx) < .01;
65343
- ctx.strokeStyle = isOrigin ? "#ef4444" : isMajor ? "#9ca3af" : "#d1d5db";
65344
- ctx.lineWidth = isOrigin ? 1.5 : isMajor ? 1 : .5;
65345
- ctx.beginPath();
65346
- ctx.moveTo(sx, R);
65347
- ctx.lineTo(sx, R - tickH);
65348
- ctx.stroke();
65349
- if (isMajor) {
65350
- ctx.fillStyle = isOrigin ? "#ef4444" : "#6b7280";
65351
- const label = isOrigin ? "0" : rulerLabel(wx, tickStep, isImperial);
65352
- ctx.fillText(label, sx, 2);
65353
- ctx.fillStyle = "#6b7280";
65354
- }
65355
- }
65356
- ctx.fillStyle = "#f1f3f5";
65357
- ctx.fillRect(0, R, R, get(height) - R);
65358
- ctx.strokeStyle = "#d1d5db";
65359
- ctx.lineWidth = 1;
65360
- ctx.beginPath();
65361
- ctx.moveTo(R, R);
65362
- ctx.lineTo(R, get(height));
65363
- ctx.stroke();
65364
- const worldTop = screenToWorld(0, R).y;
65365
- const worldBottom = screenToWorld(0, get(height)).y;
65366
- const startTickY = Math.floor(worldTop / minorStep) * minorStep;
65367
- ctx.textAlign = "right";
65368
- ctx.textBaseline = "middle";
65369
- for (let wy = startTickY; wy <= worldBottom; wy += minorStep) {
65370
- const sy = worldToScreen(0, wy).y;
65371
- if (sy < R) continue;
65372
- const isMajor = Math.abs(wy % tickStep) < .01;
65373
- const isMid = !isMajor && Math.abs(wy % (tickStep / 2)) < .01 && minorDiv >= 4;
65374
- const tickH = isMajor ? R * .7 : isMid ? R * .45 : R * .25;
65375
- const isOrigin = Math.abs(wy) < .01;
65376
- ctx.strokeStyle = isOrigin ? "#ef4444" : isMajor ? "#9ca3af" : "#d1d5db";
65377
- ctx.lineWidth = isOrigin ? 1.5 : isMajor ? 1 : .5;
65378
- ctx.beginPath();
65379
- ctx.moveTo(R, sy);
65380
- ctx.lineTo(R - tickH, sy);
65381
- ctx.stroke();
65382
- if (isMajor) {
65383
- const label = isOrigin ? "0" : rulerLabel(wy, tickStep, isImperial);
65384
- ctx.save();
65385
- ctx.translate(R - 3, sy);
65386
- ctx.rotate(-Math.PI / 2);
65387
- ctx.textAlign = "center";
65388
- ctx.textBaseline = "bottom";
65389
- ctx.fillStyle = isOrigin ? "#ef4444" : "#6b7280";
65390
- ctx.font = `${fontSize}px sans-serif`;
65391
- ctx.fillText(label, 0, 0);
65392
- ctx.restore();
65393
- }
65394
- }
65395
- ctx.fillStyle = "#e5e7eb";
65396
- ctx.fillRect(0, 0, R, R);
65397
- ctx.strokeStyle = "#d1d5db";
65398
- ctx.lineWidth = 1;
65399
- ctx.strokeRect(0, 0, R, R);
65400
- ctx.strokeStyle = "#ef4444";
65401
- ctx.lineWidth = 1;
65402
- const cx = R / 2, cy = R / 2;
65403
- ctx.beginPath();
65404
- ctx.moveTo(cx - 4, cy);
65405
- ctx.lineTo(cx + 4, cy);
65406
- ctx.moveTo(cx, cy - 4);
65407
- ctx.lineTo(cx, cy + 4);
65408
- ctx.stroke();
65409
- const mScreen = worldToScreen(get(mousePos).x, get(mousePos).y);
65410
- if (mScreen.x > R) {
65411
- ctx.strokeStyle = "rgba(59,130,246,0.5)";
65412
- ctx.lineWidth = 1;
65413
- ctx.beginPath();
65414
- ctx.moveTo(mScreen.x, 0);
65415
- ctx.lineTo(mScreen.x, R);
65416
- ctx.stroke();
65417
- ctx.fillStyle = "#3b82f6";
65418
- ctx.beginPath();
65419
- ctx.moveTo(mScreen.x, R);
65420
- ctx.lineTo(mScreen.x - 3, R - 6);
65421
- ctx.lineTo(mScreen.x + 3, R - 6);
65422
- ctx.closePath();
65423
- ctx.fill();
65424
- }
65425
- if (mScreen.y > R) {
65426
- ctx.strokeStyle = "rgba(59,130,246,0.5)";
65427
- ctx.lineWidth = 1;
65428
- ctx.beginPath();
65429
- ctx.moveTo(0, mScreen.y);
65430
- ctx.lineTo(R, mScreen.y);
65431
- ctx.stroke();
65432
- ctx.fillStyle = "#3b82f6";
65433
- ctx.beginPath();
65434
- ctx.moveTo(R, mScreen.y);
65435
- ctx.lineTo(R - 6, mScreen.y - 3);
65436
- ctx.lineTo(R - 6, mScreen.y + 3);
65437
- ctx.closePath();
65438
- ctx.fill();
65439
- }
65440
- ctx.restore();
65441
- }
65442
65242
  function drawBackgroundImage() {
65443
65243
  var _$$get2;
65444
65244
  if (!get(bgImage) || !((_$$get2 = get(currentFloor)) === null || _$$get2 === void 0 ? void 0 : _$$get2.backgroundImage)) return;
@@ -65453,6 +65253,40 @@ function FloorPlanCanvas($$anchor, $$props) {
65453
65253
  ctx.drawImage(get(bgImage), -sw / 2, -sh / 2, sw, sh);
65454
65254
  ctx.restore();
65455
65255
  }
65256
+ function getFloorWallBounds(floor = get(currentFloor)) {
65257
+ var _floor$walls;
65258
+ if (!(floor === null || floor === void 0 || (_floor$walls = floor.walls) === null || _floor$walls === void 0 ? void 0 : _floor$walls.length)) return null;
65259
+ let minX = Infinity;
65260
+ let maxX = -Infinity;
65261
+ let minY = Infinity;
65262
+ let maxY = -Infinity;
65263
+ for (const wall of floor.walls) {
65264
+ minX = Math.min(minX, wall.start.x, wall.end.x);
65265
+ maxX = Math.max(maxX, wall.start.x, wall.end.x);
65266
+ minY = Math.min(minY, wall.start.y, wall.end.y);
65267
+ maxY = Math.max(maxY, wall.start.y, wall.end.y);
65268
+ if (wall.curvePoint) {
65269
+ minX = Math.min(minX, wall.curvePoint.x);
65270
+ maxX = Math.max(maxX, wall.curvePoint.x);
65271
+ minY = Math.min(minY, wall.curvePoint.y);
65272
+ maxY = Math.max(maxY, wall.curvePoint.y);
65273
+ }
65274
+ }
65275
+ const width = maxX - minX;
65276
+ const height = maxY - minY;
65277
+ if (width <= 0 || height <= 0) return null;
65278
+ return {
65279
+ minX,
65280
+ minY,
65281
+ maxX,
65282
+ maxY,
65283
+ width,
65284
+ height
65285
+ };
65286
+ }
65287
+ function getCanvasFrameStyle() {
65288
+ return "width: 100%; height: 100%";
65289
+ }
65456
65290
  function draw() {
65457
65291
  if (!ctx) return;
65458
65292
  if (!canvasDirty) {
@@ -65462,7 +65296,7 @@ function FloorPlanCanvas($$anchor, $$props) {
65462
65296
  canvasDirty = false;
65463
65297
  ctx.clearRect(0, 0, get(width), get(height));
65464
65298
  ctx.fillStyle = "#f8f9fa";
65465
- ctx.fillRect(0, 0, get(width), get(height));
65299
+ ctx.fillRect(0, 0, $$props.floorMaxWidth, $$props.floorMaxHeight);
65466
65300
  drawGrid();
65467
65301
  if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
65468
65302
  drawBackgroundImage();
@@ -65471,6 +65305,10 @@ function FloorPlanCanvas($$anchor, $$props) {
65471
65305
  requestAnimationFrame(draw);
65472
65306
  return;
65473
65307
  }
65308
+ if (needsFitToCanvas) {
65309
+ zoomToFit();
65310
+ needsFitToCanvas = false;
65311
+ }
65474
65312
  if (get(wallStart) || get(draggingFurnitureId) || get(draggingDoorId) || get(draggingWindowId) || get(draggingStairId) || get(draggingColumnId) || get(draggingWallEndpoint) || get(draggingWallParallel) || get(draggingCurveHandle) || get(draggingHandle) || get(draggingMultiSelect) || get(draggingRoomId) || get(draggingRoomLabelId) || get(draggingTextAnnotationId) || get(draggingGuideId) || get(measuring) || get(annotating) || get(currentPlacingId) || get(isPlacingStair) || get(isPlacingColumn) || get(marqueeStart) || get(isPanning)) canvasDirty = true;
65475
65313
  updateDetectedRooms();
65476
65314
  const selId = get(currentSelectedId);
@@ -66101,7 +65939,6 @@ function FloorPlanCanvas($$anchor, $$props) {
66101
65939
  ctx.setLineDash([]);
66102
65940
  ctx.restore();
66103
65941
  }
66104
- drawRulers();
66105
65942
  drawMinimap$1();
66106
65943
  requestAnimationFrame(draw);
66107
65944
  }
@@ -66116,14 +65953,10 @@ function FloorPlanCanvas($$anchor, $$props) {
66116
65953
  const unsub1 = activeFloor.subscribe((f) => {
66117
65954
  set(currentFloor, f, true);
66118
65955
  markDirty();
66119
- if ($$props.viewOnly && f) requestAnimationFrame(() => {
66120
- zoomToFit();
66121
- });
65956
+ if ($$props.viewOnly && f) needsFitToCanvas = true;
66122
65957
  if (!initialFitDone && f && f.walls.length > 0) {
66123
65958
  initialFitDone = true;
66124
- requestAnimationFrame(() => {
66125
- zoomToFit();
66126
- });
65959
+ needsFitToCanvas = true;
66127
65960
  }
66128
65961
  });
66129
65962
  const unsub2 = selectedElementId.subscribe((id) => {
@@ -66257,151 +66090,1206 @@ function FloorPlanCanvas($$anchor, $$props) {
66257
66090
  };
66258
66091
  });
66259
66092
  user_effect(() => {
66093
+ if (!get(currentFloor)) return;
66260
66094
  setInterval(() => {
66261
66095
  markDirty();
66262
- const heatmapMatrix = createRandomMatrix(20);
66263
- set(currentFloor, {
66264
- ...get(currentFloor),
66265
- furniture: get(currentFloor).furniture.map((item) => {
66266
- if (item.catalogId === "camera") return {
66267
- ...item,
66268
- heatmapMatrix
66269
- };
66270
- return item;
66271
- })
66272
- }, true);
66273
- console.log("currentFloor", get(currentFloor));
66274
- }, 5e3);
66275
- });
66276
- /** Compute world bounding box of all elements */
66277
- function getWorldBBox() {
66278
- if (!get(currentFloor)) return null;
66279
- let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
66280
- let found = false;
66281
- function expand(x, y) {
66282
- if (x < minX) minX = x;
66283
- if (x > maxX) maxX = x;
66284
- if (y < minY) minY = y;
66285
- if (y > maxY) maxY = y;
66286
- found = true;
66287
- }
66288
- for (const w of get(currentFloor).walls) {
66289
- expand(w.start.x, w.start.y);
66290
- expand(w.end.x, w.end.y);
66291
- if (w.curvePoint) expand(w.curvePoint.x, w.curvePoint.y);
66292
- }
66293
- for (const fi of get(currentFloor).furniture) {
66294
- var _fi$width, _fi$depth;
66295
- const cat = getCatalogItem(fi.catalogId);
66296
- if (!cat) continue;
66297
- const r = Math.hypot(((_fi$width = fi.width) !== null && _fi$width !== void 0 ? _fi$width : cat.width) / 2, ((_fi$depth = fi.depth) !== null && _fi$depth !== void 0 ? _fi$depth : cat.depth) / 2);
66298
- expand(fi.position.x - r, fi.position.y - r);
66299
- expand(fi.position.x + r, fi.position.y + r);
66300
- }
66301
- if (get(currentFloor).stairs) for (const st of get(currentFloor).stairs) {
66302
- expand(st.position.x - st.width / 2, st.position.y - st.depth / 2);
66303
- expand(st.position.x + st.width / 2, st.position.y + st.depth / 2);
66304
- }
66305
- if (get(currentFloor).columns) for (const col of get(currentFloor).columns) {
66306
- const r = col.diameter / 2;
66307
- expand(col.position.x - r, col.position.y - r);
66308
- expand(col.position.x + r, col.position.y + r);
66309
- }
66310
- if (!found) return null;
66311
- const pad = 50;
66312
- return {
66313
- minX: minX - pad,
66314
- minY: minY - pad,
66315
- maxX: maxX + pad,
66316
- maxY: maxY + pad
66317
- };
66318
- }
66319
- function drawMinimap$1() {
66320
- if (!get(showMinimap) || !minimapCanvas || !get(currentFloor)) return;
66321
- drawMinimap(getCS(), minimapCanvas, get(currentFloor), getWorldBBox);
66322
- }
66323
- function onMinimapClick(e) {
66324
- if (!minimapCanvas || !get(currentFloor)) return;
66325
- const rect = minimapCanvas.getBoundingClientRect();
66326
- const mx = e.clientX - rect.left;
66327
- const my = e.clientY - rect.top;
66328
- const mw = minimapCanvas.width;
66329
- const mh = minimapCanvas.height;
66330
- const bbox = getWorldBBox();
66331
- if (!bbox) return;
66332
- const bw = bbox.maxX - bbox.minX;
66333
- const bh = bbox.maxY - bbox.minY;
66334
- if (bw < 1 || bh < 1) return;
66335
- const scale = Math.min((mw - 8) / bw, (mh - 8) / bh);
66336
- const ox = (mw - bw * scale) / 2;
66337
- const oy = (mh - bh * scale) / 2;
66338
- set(camX, bbox.minX + (mx - ox) / scale);
66339
- set(camY, bbox.minY + (my - oy) / scale);
66340
- }
66341
- function zoomToFit() {
66342
- if (!get(currentFloor) || get(currentFloor).walls.length === 0 && get(currentFloor).furniture.length === 0) {
66343
- set(camX, 0);
66344
- set(camY, 0);
66345
- set(zoom, 1);
66346
- return;
66347
- }
66348
- let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
66349
- function expand(x, y) {
66350
- if (x < minX) minX = x;
66351
- if (x > maxX) maxX = x;
66352
- if (y < minY) minY = y;
66353
- if (y > maxY) maxY = y;
66354
- }
66355
- for (const w of get(currentFloor).walls) {
66356
- expand(w.start.x, w.start.y);
66357
- expand(w.end.x, w.end.y);
66358
- if (w.curvePoint) expand(w.curvePoint.x, w.curvePoint.y);
66359
- }
66360
- for (const fi of get(currentFloor).furniture) {
66361
- var _fi$width2, _fi$depth2;
66362
- const cat = getCatalogItem(fi.catalogId);
66363
- if (!cat) continue;
66364
- const hw = ((_fi$width2 = fi.width) !== null && _fi$width2 !== void 0 ? _fi$width2 : cat.width) / 2;
66365
- const hd = ((_fi$depth2 = fi.depth) !== null && _fi$depth2 !== void 0 ? _fi$depth2 : cat.depth) / 2;
66366
- const r = Math.hypot(hw, hd);
66367
- expand(fi.position.x - r, fi.position.y - r);
66368
- expand(fi.position.x + r, fi.position.y + r);
66369
- }
66370
- for (const d of get(currentFloor).doors) {
66371
- const w = get(currentFloor).walls.find((wl) => wl.id === d.wallId);
66372
- if (w) {
66373
- const pt = wallPointAt(w, d.position);
66374
- expand(pt.x, pt.y);
66375
- }
66376
- }
66377
- for (const win of get(currentFloor).windows) {
66378
- const w = get(currentFloor).walls.find((wl) => wl.id === win.wallId);
66379
- if (w) {
66380
- const pt = wallPointAt(w, win.position);
66381
- expand(pt.x, pt.y);
66382
- }
66383
- }
66384
- if (get(currentFloor).stairs) for (const st of get(currentFloor).stairs) {
66385
- expand(st.position.x - st.width / 2, st.position.y - st.depth / 2);
66386
- expand(st.position.x + st.width / 2, st.position.y + st.depth / 2);
66387
- }
66388
- if (get(currentFloor).columns) for (const col of get(currentFloor).columns) {
66389
- const r = col.diameter / 2;
66390
- expand(col.position.x - r, col.position.y - r);
66391
- expand(col.position.x + r, col.position.y + r);
66096
+ const heatmapMatrix = [
66097
+ [
66098
+ 0,
66099
+ 0,
66100
+ 0,
66101
+ 0,
66102
+ 0,
66103
+ 0,
66104
+ 0,
66105
+ 0,
66106
+ 0,
66107
+ 0,
66108
+ 0,
66109
+ 0,
66110
+ 0,
66111
+ 0,
66112
+ 0,
66113
+ 0,
66114
+ 0,
66115
+ 0,
66116
+ 0,
66117
+ 0,
66118
+ 0,
66119
+ 0,
66120
+ 0,
66121
+ 0,
66122
+ 0,
66123
+ 0,
66124
+ 0,
66125
+ 0,
66126
+ 0,
66127
+ 0,
66128
+ 0,
66129
+ 0
66130
+ ],
66131
+ [
66132
+ 0,
66133
+ 0,
66134
+ 0,
66135
+ 0,
66136
+ 0,
66137
+ 0,
66138
+ 0,
66139
+ 0,
66140
+ 0,
66141
+ 0,
66142
+ 0,
66143
+ 0,
66144
+ 0,
66145
+ 0,
66146
+ 0,
66147
+ 0,
66148
+ 0,
66149
+ 0,
66150
+ 0,
66151
+ 0,
66152
+ 0,
66153
+ 0,
66154
+ 0,
66155
+ 0,
66156
+ 0,
66157
+ 0,
66158
+ 0,
66159
+ 0,
66160
+ 0,
66161
+ 0,
66162
+ 0,
66163
+ 0
66164
+ ],
66165
+ [
66166
+ 0,
66167
+ 0,
66168
+ 0,
66169
+ 0,
66170
+ 0,
66171
+ 0,
66172
+ 0,
66173
+ 0,
66174
+ 0,
66175
+ 0,
66176
+ 0,
66177
+ 0,
66178
+ 0,
66179
+ 0,
66180
+ 0,
66181
+ 0,
66182
+ 0,
66183
+ 0,
66184
+ 0,
66185
+ 0,
66186
+ 0,
66187
+ 0,
66188
+ 0,
66189
+ 0,
66190
+ 0,
66191
+ 0,
66192
+ 0,
66193
+ 0,
66194
+ 0,
66195
+ 0,
66196
+ 0,
66197
+ 0
66198
+ ],
66199
+ [
66200
+ 0,
66201
+ 0,
66202
+ 0,
66203
+ 0,
66204
+ 0,
66205
+ 0,
66206
+ 0,
66207
+ 0,
66208
+ 0,
66209
+ 0,
66210
+ 0,
66211
+ 0,
66212
+ 0,
66213
+ 0,
66214
+ 0,
66215
+ 0,
66216
+ 0,
66217
+ 0,
66218
+ 0,
66219
+ 0,
66220
+ 0,
66221
+ 0,
66222
+ 0,
66223
+ 0,
66224
+ 0,
66225
+ 0,
66226
+ 0,
66227
+ 0,
66228
+ 0,
66229
+ 0,
66230
+ 0,
66231
+ 0
66232
+ ],
66233
+ [
66234
+ 0,
66235
+ 0,
66236
+ 0,
66237
+ 0,
66238
+ 0,
66239
+ 0,
66240
+ 0,
66241
+ 0,
66242
+ 0,
66243
+ 0,
66244
+ 0,
66245
+ 0,
66246
+ 0,
66247
+ 0,
66248
+ 0,
66249
+ 0,
66250
+ 0,
66251
+ 0,
66252
+ 0,
66253
+ 0,
66254
+ 0,
66255
+ 0,
66256
+ 0,
66257
+ 0,
66258
+ 0,
66259
+ 0,
66260
+ 0,
66261
+ 0,
66262
+ 0,
66263
+ 0,
66264
+ 0,
66265
+ 0
66266
+ ],
66267
+ [
66268
+ 0,
66269
+ 0,
66270
+ 0,
66271
+ 0,
66272
+ 0,
66273
+ 0,
66274
+ 0,
66275
+ 0,
66276
+ 0,
66277
+ 0,
66278
+ 0,
66279
+ 0,
66280
+ 0,
66281
+ 0,
66282
+ 0,
66283
+ 0,
66284
+ 0,
66285
+ 0,
66286
+ 0,
66287
+ 0,
66288
+ 0,
66289
+ 0,
66290
+ 0,
66291
+ 0,
66292
+ 0,
66293
+ 0,
66294
+ 0,
66295
+ 0,
66296
+ 0,
66297
+ 0,
66298
+ 0,
66299
+ 0
66300
+ ],
66301
+ [
66302
+ 0,
66303
+ 0,
66304
+ 0,
66305
+ 0,
66306
+ 0,
66307
+ 0,
66308
+ 0,
66309
+ 0,
66310
+ 0,
66311
+ 0,
66312
+ 0,
66313
+ 0,
66314
+ 0,
66315
+ 0,
66316
+ 0,
66317
+ 0,
66318
+ 0,
66319
+ 0,
66320
+ 0,
66321
+ 0,
66322
+ 0,
66323
+ 0,
66324
+ 0,
66325
+ 0,
66326
+ 0,
66327
+ 0,
66328
+ 0,
66329
+ 0,
66330
+ 0,
66331
+ 0,
66332
+ 0,
66333
+ 0
66334
+ ],
66335
+ [
66336
+ 0,
66337
+ 0,
66338
+ 0,
66339
+ 0,
66340
+ 0,
66341
+ 0,
66342
+ 0,
66343
+ 0,
66344
+ 0,
66345
+ 0,
66346
+ 0,
66347
+ 0,
66348
+ .3159328774204405,
66349
+ 1.4656853131421907,
66350
+ 2.2380465832282233,
66351
+ 1.4656853131421907,
66352
+ .3159328774204405,
66353
+ 0,
66354
+ 0,
66355
+ 0,
66356
+ 0,
66357
+ 0,
66358
+ 0,
66359
+ 0,
66360
+ 0,
66361
+ 0,
66362
+ 0,
66363
+ 0,
66364
+ 0,
66365
+ 0,
66366
+ 0,
66367
+ 0
66368
+ ],
66369
+ [
66370
+ 0,
66371
+ 0,
66372
+ 0,
66373
+ 0,
66374
+ 0,
66375
+ 0,
66376
+ 0,
66377
+ 0,
66378
+ 0,
66379
+ 0,
66380
+ 0,
66381
+ 0,
66382
+ 1.7489495878144512,
66383
+ 7.010252524548629,
66384
+ 10.597011258282999,
66385
+ 7.010252524548629,
66386
+ 1.7489495878144512,
66387
+ 0,
66388
+ 0,
66389
+ 0,
66390
+ 0,
66391
+ 0,
66392
+ 0,
66393
+ 0,
66394
+ 0,
66395
+ 0,
66396
+ 0,
66397
+ 0,
66398
+ 0,
66399
+ 0,
66400
+ 0,
66401
+ 0
66402
+ ],
66403
+ [
66404
+ 0,
66405
+ 0,
66406
+ 0,
66407
+ 0,
66408
+ 0,
66409
+ 0,
66410
+ 0,
66411
+ 0,
66412
+ 0,
66413
+ 0,
66414
+ 0,
66415
+ 0,
66416
+ 3.3289241086779624,
66417
+ 13.46177725998435,
66418
+ 20.235236701064228,
66419
+ 13.590541779525635,
66420
+ 3.4380594435639265,
66421
+ .00915612667564332,
66422
+ 0,
66423
+ 0,
66424
+ 0,
66425
+ 0,
66426
+ 0,
66427
+ 0,
66428
+ 0,
66429
+ 0,
66430
+ 0,
66431
+ 0,
66432
+ 0,
66433
+ 0,
66434
+ 0,
66435
+ 0
66436
+ ],
66437
+ [
66438
+ 0,
66439
+ 0,
66440
+ 0,
66441
+ 0,
66442
+ 0,
66443
+ 0,
66444
+ 0,
66445
+ 0,
66446
+ 0,
66447
+ 0,
66448
+ 0,
66449
+ 0,
66450
+ 3.2148496888753932,
66451
+ 13.320879325153319,
66452
+ 21.57578250930066,
66453
+ 16.342286624307704,
66454
+ 5.569414220457003,
66455
+ .6079740421039851,
66456
+ 0,
66457
+ 0,
66458
+ 0,
66459
+ 0,
66460
+ 0,
66461
+ 0,
66462
+ 0,
66463
+ 0,
66464
+ 0,
66465
+ 0,
66466
+ 0,
66467
+ 0,
66468
+ 0,
66469
+ 0
66470
+ ],
66471
+ [
66472
+ 0,
66473
+ 0,
66474
+ 0,
66475
+ 0,
66476
+ 0,
66477
+ 0,
66478
+ 0,
66479
+ 0,
66480
+ 0,
66481
+ 0,
66482
+ 0,
66483
+ 0,
66484
+ 1.471089931923573,
66485
+ 8.2191207324426,
66486
+ 17.838951126796992,
66487
+ 19.032501579269645,
66488
+ 10.168729572784246,
66489
+ 2.183833478003975,
66490
+ 0,
66491
+ 0,
66492
+ 0,
66493
+ 0,
66494
+ 0,
66495
+ 0,
66496
+ 0,
66497
+ 0,
66498
+ 0,
66499
+ 0,
66500
+ 0,
66501
+ 0,
66502
+ 0,
66503
+ 0
66504
+ ],
66505
+ [
66506
+ 0,
66507
+ 0,
66508
+ 0,
66509
+ 0,
66510
+ 0,
66511
+ 0,
66512
+ 0,
66513
+ 0,
66514
+ 0,
66515
+ 0,
66516
+ 0,
66517
+ 0,
66518
+ .30224323366570666,
66519
+ 4.469359740497559,
66520
+ 14.670431219686673,
66521
+ 20.333387296969498,
66522
+ 13.054592947321611,
66523
+ 3.1902302512972374,
66524
+ 0,
66525
+ 0,
66526
+ 0,
66527
+ 0,
66528
+ 0,
66529
+ 0,
66530
+ 0,
66531
+ 0,
66532
+ 0,
66533
+ 0,
66534
+ 0,
66535
+ 0,
66536
+ 0,
66537
+ 0
66538
+ ],
66539
+ [
66540
+ 0,
66541
+ 0,
66542
+ 0,
66543
+ 0,
66544
+ 0,
66545
+ 0,
66546
+ 0,
66547
+ .8712958885928778,
66548
+ 4.101109796621668,
66549
+ 7.049595450791787,
66550
+ 6.013717307819157,
66551
+ 2.4950259463993585,
66552
+ .44436828921160365,
66553
+ 2.3964385376201838,
66554
+ 8.995383597734405,
66555
+ 13.185675552510842,
66556
+ 8.716708041551543,
66557
+ 2.1623510704265803,
66558
+ 0,
66559
+ 0,
66560
+ 0,
66561
+ 0,
66562
+ 0,
66563
+ 0,
66564
+ 0,
66565
+ 0,
66566
+ 0,
66567
+ 0,
66568
+ 0,
66569
+ 0,
66570
+ 0,
66571
+ 0
66572
+ ],
66573
+ [
66574
+ 0,
66575
+ 0,
66576
+ 0,
66577
+ 0,
66578
+ 0,
66579
+ 0,
66580
+ 0,
66581
+ 3.62130425013895,
66582
+ 16.246445581668944,
66583
+ 28.185625524032776,
66584
+ 24.0135529219635,
66585
+ 9.834207494427838,
66586
+ 1.5755845092412992,
66587
+ .7273170478700652,
66588
+ 2.61589141718046,
66589
+ 3.749571783336128,
66590
+ 2.426392038976114,
66591
+ .5824057586549773,
66592
+ 0,
66593
+ 0,
66594
+ 0,
66595
+ 0,
66596
+ 0,
66597
+ 0,
66598
+ 0,
66599
+ 0,
66600
+ .5421635625869271,
66601
+ 2.2065200861983407,
66602
+ 3.342547381956746,
66603
+ 2.2065200861983407,
66604
+ .5421635625869271,
66605
+ 0
66606
+ ],
66607
+ [
66608
+ 0,
66609
+ 0,
66610
+ 0,
66611
+ 0,
66612
+ 0,
66613
+ 0,
66614
+ 0,
66615
+ 5.549901318362378,
66616
+ 24.32853931235515,
66617
+ 42.36138150541803,
66618
+ 35.94102328030143,
66619
+ 14.818839539693103,
66620
+ 2.3194161353148814,
66621
+ .05101033364693949,
66622
+ .16491621404182252,
66623
+ .1777607033571859,
66624
+ .12032812505256472,
66625
+ .017569266904996134,
66626
+ 0,
66627
+ 0,
66628
+ 0,
66629
+ 0,
66630
+ 0,
66631
+ 0,
66632
+ 0,
66633
+ 0,
66634
+ 2.9576258950346093,
66635
+ 11.84562175292669,
66636
+ 17.787556061594508,
66637
+ 11.84562175292669,
66638
+ 2.9576258950346093,
66639
+ 0
66640
+ ],
66641
+ [
66642
+ 0,
66643
+ 0,
66644
+ 0,
66645
+ 0,
66646
+ 0,
66647
+ 0,
66648
+ 0,
66649
+ 3.62130425013895,
66650
+ 16.246445581668944,
66651
+ 28.185625524032776,
66652
+ 24.0135529219635,
66653
+ 9.834207494427838,
66654
+ 1.5309964202520414,
66655
+ 0,
66656
+ 0,
66657
+ 0,
66658
+ 0,
66659
+ 0,
66660
+ 0,
66661
+ 0,
66662
+ 0,
66663
+ 0,
66664
+ 0,
66665
+ 0,
66666
+ 0,
66667
+ 0,
66668
+ 6.348491293238841,
66669
+ 25.309150516517526,
66670
+ 37.96250650263207,
66671
+ 25.309150516517526,
66672
+ 6.348491293238841,
66673
+ 0
66674
+ ],
66675
+ [
66676
+ 0,
66677
+ 0,
66678
+ 0,
66679
+ 0,
66680
+ .32082320386030533,
66681
+ 1.2199857338206974,
66682
+ 1.8460462046420483,
66683
+ 2.1325554284523793,
66684
+ 4.379383234527166,
66685
+ 7.049595450791787,
66686
+ 6.013717307819157,
66687
+ 2.4950259463993585,
66688
+ .3886331779750314,
66689
+ 0,
66690
+ 0,
66691
+ 0,
66692
+ 0,
66693
+ 0,
66694
+ 0,
66695
+ 0,
66696
+ 0,
66697
+ 0,
66698
+ 0,
66699
+ 0,
66700
+ 0,
66701
+ 0,
66702
+ 6.723278406098134,
66703
+ 26.889274492038524,
66704
+ 40.34693760289919,
66705
+ 26.889274492038524,
66706
+ 6.723278406098134,
66707
+ 0
66708
+ ],
66709
+ [
66710
+ 0,
66711
+ 0,
66712
+ 0,
66713
+ 0,
66714
+ 2.2804956914871695,
66715
+ 8.96059158937199,
66716
+ 13.408676109914708,
66717
+ 8.96059158937199,
66718
+ 2.2804956914871695,
66719
+ 0,
66720
+ 0,
66721
+ 0,
66722
+ 0,
66723
+ 0,
66724
+ 0,
66725
+ 0,
66726
+ 0,
66727
+ 0,
66728
+ 0,
66729
+ 0,
66730
+ 0,
66731
+ 0,
66732
+ 0,
66733
+ 0,
66734
+ 0,
66735
+ 0,
66736
+ 3.610311889272976,
66737
+ 14.18903058720386,
66738
+ 21.35656319734618,
66739
+ 15.52310871608614,
66740
+ 8.830853849884093,
66741
+ 7.821632516665724
66742
+ ],
66743
+ [
66744
+ 0,
66745
+ 0,
66746
+ 0,
66747
+ 0,
66748
+ 5.861518314504249,
66749
+ 23.379493778146163,
66750
+ 35.09863018520233,
66751
+ 23.379493778146163,
66752
+ 5.861518314504249,
66753
+ 0,
66754
+ 0,
66755
+ 0,
66756
+ 0,
66757
+ 0,
66758
+ 0,
66759
+ 0,
66760
+ 0,
66761
+ 0,
66762
+ 0,
66763
+ 0,
66764
+ 0,
66765
+ 0,
66766
+ 0,
66767
+ 0,
66768
+ 0,
66769
+ 0,
66770
+ .7400359281404749,
66771
+ 3.0082191313345596,
66772
+ 4.511243556428142,
66773
+ 8.25225708991524,
66774
+ 21.61113659978852,
66775
+ 31.371979438413785
66776
+ ],
66777
+ [
66778
+ 0,
66779
+ 0,
66780
+ 0,
66781
+ 0,
66782
+ 7.243115248642567,
66783
+ 28.906850697487346,
66784
+ 43.39219038599119,
66785
+ 28.906850697487346,
66786
+ 7.243115248642567,
66787
+ 0,
66788
+ 0,
66789
+ 0,
66790
+ 0,
66791
+ 0,
66792
+ 0,
66793
+ 0,
66794
+ 0,
66795
+ 0,
66796
+ 0,
66797
+ 0,
66798
+ 0,
66799
+ 0,
66800
+ 0,
66801
+ 0,
66802
+ 0,
66803
+ 0,
66804
+ 0,
66805
+ 0,
66806
+ 0,
66807
+ 7.821632516665724,
66808
+ 31.371979438413785,
66809
+ 46.96473075085739
66810
+ ],
66811
+ [
66812
+ 0,
66813
+ 0,
66814
+ 0,
66815
+ 0,
66816
+ 4.32482477999109,
66817
+ 17.186780480887943,
66818
+ 25.8249366255257,
66819
+ 17.186780480887943,
66820
+ 4.32482477999109,
66821
+ 0,
66822
+ 0,
66823
+ 0,
66824
+ 0,
66825
+ 0,
66826
+ 0,
66827
+ 0,
66828
+ 0,
66829
+ 0,
66830
+ 0,
66831
+ 0,
66832
+ 0,
66833
+ 0,
66834
+ 0,
66835
+ 0,
66836
+ 0,
66837
+ 0,
66838
+ 0,
66839
+ 0,
66840
+ 0,
66841
+ 5.226011941752098,
66842
+ 20.827286571029607,
66843
+ 31.371979438413785
66844
+ ],
66845
+ [
66846
+ 0,
66847
+ 0,
66848
+ 0,
66849
+ 0,
66850
+ 1.0111655316014927,
66851
+ 3.9864631299897444,
66852
+ 5.981469083020068,
66853
+ 3.9864631299897444,
66854
+ 1.0111655316014927,
66855
+ 0,
66856
+ 0,
66857
+ 0,
66858
+ 0,
66859
+ 0,
66860
+ 0,
66861
+ 0,
66862
+ 0,
66863
+ 0,
66864
+ 0,
66865
+ 0,
66866
+ 0,
66867
+ 0,
66868
+ 0,
66869
+ 0,
66870
+ 0,
66871
+ 0,
66872
+ 0,
66873
+ 0,
66874
+ 0,
66875
+ 1.386066255607005,
66876
+ 5.226011941752098,
66877
+ 7.821632516665724
66878
+ ],
66879
+ [
66880
+ 0,
66881
+ 0,
66882
+ 0,
66883
+ 0,
66884
+ 0,
66885
+ 0,
66886
+ 0,
66887
+ 0,
66888
+ 0,
66889
+ 0,
66890
+ 0,
66891
+ 0,
66892
+ 0,
66893
+ 0,
66894
+ 0,
66895
+ 0,
66896
+ 0,
66897
+ 0,
66898
+ 0,
66899
+ 0,
66900
+ 0,
66901
+ 0,
66902
+ 0,
66903
+ 0,
66904
+ 0,
66905
+ 0,
66906
+ 0,
66907
+ 0,
66908
+ 0,
66909
+ 0,
66910
+ 0,
66911
+ 0
66912
+ ],
66913
+ [
66914
+ 0,
66915
+ 0,
66916
+ 0,
66917
+ 0,
66918
+ 0,
66919
+ 0,
66920
+ 0,
66921
+ 0,
66922
+ 0,
66923
+ .05458070912699062,
66924
+ .15528137571229708,
66925
+ .15187574183847025,
66926
+ .06974200470241036,
66927
+ 0,
66928
+ 0,
66929
+ 0,
66930
+ 0,
66931
+ 0,
66932
+ 0,
66933
+ 0,
66934
+ 0,
66935
+ 0,
66936
+ 0,
66937
+ 0,
66938
+ 0,
66939
+ 0,
66940
+ 0,
66941
+ 0,
66942
+ 0,
66943
+ 0,
66944
+ 0,
66945
+ 0
66946
+ ],
66947
+ [
66948
+ 0,
66949
+ 0,
66950
+ 0,
66951
+ 0,
66952
+ 0,
66953
+ 0,
66954
+ 0,
66955
+ 0,
66956
+ .05458070912699062,
66957
+ .2755754209878876,
66958
+ .5707063337010662,
66959
+ .5838714443792508,
66960
+ .31029220828859827,
66961
+ .06974200470241036,
66962
+ 0,
66963
+ 0,
66964
+ 0,
66965
+ 0,
66966
+ .02805561155784787,
66967
+ .8189018232615914,
66968
+ 2.5324966794862513,
66969
+ 3.4377154290206784,
66970
+ 2.1308395665461624,
66971
+ .4650594240098488,
66972
+ 0,
66973
+ 0,
66974
+ 0,
66975
+ 0,
66976
+ 0,
66977
+ 0,
66978
+ 0,
66979
+ 0
66980
+ ],
66981
+ [
66982
+ 0,
66983
+ 0,
66984
+ 0,
66985
+ 0,
66986
+ 0,
66987
+ 0,
66988
+ 0,
66989
+ 0,
66990
+ .08553937100988673,
66991
+ .41228986725093814,
66992
+ .8529789776313961,
66993
+ .8882858218170526,
66994
+ .46357739910366025,
66995
+ .0972950327114796,
66996
+ 0,
66997
+ 0,
66998
+ 0,
66999
+ 0,
67000
+ .3532485267308754,
67001
+ 3.499619222062779,
67002
+ 10.427637306724009,
67003
+ 13.795863309244472,
67004
+ 8.56406987933662,
67005
+ 2.084587966363261,
67006
+ 0,
67007
+ 0,
67008
+ 0,
67009
+ 0,
67010
+ 0,
67011
+ 0,
67012
+ 0,
67013
+ 0
67014
+ ],
67015
+ [
67016
+ 0,
67017
+ 0,
67018
+ 0,
67019
+ 0,
67020
+ 0,
67021
+ 0,
67022
+ 0,
67023
+ 0,
67024
+ .05458070912699062,
67025
+ .2755754209878876,
67026
+ .5707063337010662,
67027
+ .5838714443792508,
67028
+ .31029220828859827,
67029
+ .06974200470241036,
67030
+ 0,
67031
+ 0,
67032
+ 0,
67033
+ .049318035756509136,
67034
+ 1.0607933641418696,
67035
+ 6.758563725967109,
67036
+ 17.660755342385897,
67037
+ 21.973928874871856,
67038
+ 13.201476985075344,
67039
+ 3.101022144002237,
67040
+ 0,
67041
+ 0,
67042
+ 0,
67043
+ 0,
67044
+ 0,
67045
+ 0,
67046
+ 0,
67047
+ 0
67048
+ ],
67049
+ [
67050
+ 0,
67051
+ 0,
67052
+ 0,
67053
+ 0,
67054
+ 0,
67055
+ 0,
67056
+ 0,
67057
+ 0,
67058
+ 0,
67059
+ .05458070912699062,
67060
+ .15528137571229708,
67061
+ .15187574183847025,
67062
+ .06974200470241036,
67063
+ 0,
67064
+ 0,
67065
+ 0,
67066
+ .08786109582645688,
67067
+ .7046356886390628,
67068
+ 3.0107989977663894,
67069
+ 9.51274060076616,
67070
+ 17.749511390220455,
67071
+ 18.26171939391789,
67072
+ 9.630263523792657,
67073
+ 2.084587966363261,
67074
+ 0,
67075
+ 0,
67076
+ 0,
67077
+ 0,
67078
+ 0,
67079
+ 0,
67080
+ 0,
67081
+ 0
67082
+ ],
67083
+ [
67084
+ 0,
67085
+ 0,
67086
+ 0,
67087
+ 0,
67088
+ 0,
67089
+ 0,
67090
+ 0,
67091
+ 0,
67092
+ 0,
67093
+ 0,
67094
+ 0,
67095
+ 0,
67096
+ 1.7382367811803743,
67097
+ 6.78625235876699,
67098
+ 10.215056932817292,
67099
+ 7.28439193353878,
67100
+ 3.243933616660711,
67101
+ 3.1636969367350174,
67102
+ 6.726890242944553,
67103
+ 11.793933219797037,
67104
+ 14.018480108478876,
67105
+ 9.836469200652415,
67106
+ 3.565238303086889,
67107
+ .4650594240098488,
67108
+ 0,
67109
+ 0,
67110
+ 0,
67111
+ 0,
67112
+ 0,
67113
+ 0,
67114
+ 0,
67115
+ 0
67116
+ ],
67117
+ [
67118
+ 0,
67119
+ 0,
67120
+ 0,
67121
+ 0,
67122
+ 0,
67123
+ 0,
67124
+ 0,
67125
+ 0,
67126
+ 0,
67127
+ 0,
67128
+ 0,
67129
+ 0,
67130
+ 6.6983617356443,
67131
+ 26.99436500222664,
67132
+ 41.353519873356255,
67133
+ 29.282163948524662,
67134
+ 11.3741195154941,
67135
+ 7.413346519620399,
67136
+ 10.283468040894338,
67137
+ 11.90128859290927,
67138
+ 9.570529949946668,
67139
+ 4.526681935693334,
67140
+ .8914940911015187,
67141
+ 0,
67142
+ 0,
67143
+ 0,
67144
+ 0,
67145
+ 0,
67146
+ 0,
67147
+ 0,
67148
+ 0,
67149
+ 0
67150
+ ],
67151
+ [
67152
+ 0,
67153
+ 0,
67154
+ 0,
67155
+ 0,
67156
+ 0,
67157
+ 0,
67158
+ 0,
67159
+ 0,
67160
+ 0,
67161
+ 0,
67162
+ 0,
67163
+ 0,
67164
+ 10.047028886051624,
67165
+ 40.69152763227778,
67166
+ 61.87097958316954,
67167
+ 44.034938408633856,
67168
+ 16.762310030892145,
67169
+ 9.760527430556891,
67170
+ 11.69769115898553,
67171
+ 11.007073791008297,
67172
+ 7.176097387403954,
67173
+ 2.7361326724525514,
67174
+ .505476251361877,
67175
+ 0,
67176
+ 0,
67177
+ 0,
67178
+ 0,
67179
+ 0,
67180
+ 0,
67181
+ 0,
67182
+ 0,
67183
+ 0
67184
+ ]
67185
+ ];
67186
+ set(currentFloor, {
67187
+ ...get(currentFloor),
67188
+ furniture: get(currentFloor).furniture.map((item) => {
67189
+ if (item.catalogId === "camera") return {
67190
+ ...item,
67191
+ heatmapMatrix
67192
+ };
67193
+ return item;
67194
+ })
67195
+ }, true);
67196
+ }, 5e3);
67197
+ });
67198
+ /** Compute world bounding box of all elements */
67199
+ function getWorldBBox() {
67200
+ if (!get(currentFloor)) return null;
67201
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
67202
+ let found = false;
67203
+ function expand(x, y) {
67204
+ if (x < minX) minX = x;
67205
+ if (x > maxX) maxX = x;
67206
+ if (y < minY) minY = y;
67207
+ if (y > maxY) maxY = y;
67208
+ found = true;
67209
+ }
67210
+ for (const w of get(currentFloor).walls) {
67211
+ expand(w.start.x, w.start.y);
67212
+ expand(w.end.x, w.end.y);
67213
+ if (w.curvePoint) expand(w.curvePoint.x, w.curvePoint.y);
67214
+ }
67215
+ for (const fi of get(currentFloor).furniture) {
67216
+ var _fi$width, _fi$depth;
67217
+ const cat = getCatalogItem(fi.catalogId);
67218
+ if (!cat) continue;
67219
+ const r = Math.hypot(((_fi$width = fi.width) !== null && _fi$width !== void 0 ? _fi$width : cat.width) / 2, ((_fi$depth = fi.depth) !== null && _fi$depth !== void 0 ? _fi$depth : cat.depth) / 2);
67220
+ expand(fi.position.x - r, fi.position.y - r);
67221
+ expand(fi.position.x + r, fi.position.y + r);
67222
+ }
67223
+ if (get(currentFloor).stairs) for (const st of get(currentFloor).stairs) {
67224
+ expand(st.position.x - st.width / 2, st.position.y - st.depth / 2);
67225
+ expand(st.position.x + st.width / 2, st.position.y + st.depth / 2);
67226
+ }
67227
+ if (get(currentFloor).columns) for (const col of get(currentFloor).columns) {
67228
+ const r = col.diameter / 2;
67229
+ expand(col.position.x - r, col.position.y - r);
67230
+ expand(col.position.x + r, col.position.y + r);
67231
+ }
67232
+ if (!found) return null;
67233
+ const pad = 50;
67234
+ return {
67235
+ minX: minX - pad,
67236
+ minY: minY - pad,
67237
+ maxX: maxX + pad,
67238
+ maxY: maxY + pad
67239
+ };
67240
+ }
67241
+ function drawMinimap$1() {
67242
+ if (!get(showMinimap) || !minimapCanvas || !get(currentFloor)) return;
67243
+ drawMinimap(getCS(), minimapCanvas, get(currentFloor), getWorldBBox);
67244
+ }
67245
+ function onMinimapClick(e) {
67246
+ if (!minimapCanvas || !get(currentFloor)) return;
67247
+ const rect = minimapCanvas.getBoundingClientRect();
67248
+ const mx = e.clientX - rect.left;
67249
+ const my = e.clientY - rect.top;
67250
+ const mw = minimapCanvas.width;
67251
+ const mh = minimapCanvas.height;
67252
+ const bbox = getWorldBBox();
67253
+ if (!bbox) return;
67254
+ const bw = bbox.maxX - bbox.minX;
67255
+ const bh = bbox.maxY - bbox.minY;
67256
+ if (bw < 1 || bh < 1) return;
67257
+ const scale = Math.min((mw - 8) / bw, (mh - 8) / bh);
67258
+ const ox = (mw - bw * scale) / 2;
67259
+ const oy = (mh - bh * scale) / 2;
67260
+ set(camX, bbox.minX + (mx - ox) / scale);
67261
+ set(camY, bbox.minY + (my - oy) / scale);
67262
+ }
67263
+ function zoomToFit() {
67264
+ if (!get(currentFloor)) {
67265
+ set(camX, 0);
67266
+ set(camY, 0);
67267
+ set(zoom, 1);
67268
+ return;
66392
67269
  }
66393
- if (minX === Infinity) {
67270
+ const bounds = getFloorWallBounds(get(currentFloor));
67271
+ if (!bounds) {
66394
67272
  set(camX, 0);
66395
67273
  set(camY, 0);
66396
67274
  set(zoom, 1);
66397
67275
  return;
66398
67276
  }
66399
- const padding = 80;
66400
- const contentW = maxX - minX + padding * 2;
66401
- const contentH = maxY - minY + padding * 2;
66402
- set(camX, (minX + maxX) / 2);
66403
- set(camY, (minY + maxY) / 2);
66404
- set(zoom, Math.min(get(width) / contentW, get(height) / contentH, 3), true);
67277
+ const domWidth = (canvas === null || canvas === void 0 ? void 0 : canvas.clientWidth) || get(width);
67278
+ const domHeight = (canvas === null || canvas === void 0 ? void 0 : canvas.clientHeight) || get(height);
67279
+ if (domWidth > 0 && domHeight > 0) {
67280
+ set(width, domWidth, true);
67281
+ set(height, domHeight, true);
67282
+ if (canvas) {
67283
+ canvas.width = get(width);
67284
+ canvas.height = get(height);
67285
+ }
67286
+ }
67287
+ const padding = 0;
67288
+ const contentW = bounds.width + padding * 2;
67289
+ const contentH = bounds.height + padding * 2;
67290
+ set(camX, (bounds.minX + bounds.maxX) / 2);
67291
+ set(camY, (bounds.minY + bounds.maxY) / 2);
67292
+ set(zoom, Math.max(get(width) / contentW, get(height) / contentH), true);
66405
67293
  set(zoom, Math.max(get(zoom), .1), true);
66406
67294
  markDirty();
66407
67295
  }
@@ -67925,10 +68813,12 @@ function FloorPlanCanvas($$anchor, $$props) {
67925
68813
  var div = root();
67926
68814
  event("keydown", $window, onKeyDown);
67927
68815
  event("keyup", $window, onKeyUp);
67928
- var canvas_1 = child(div);
68816
+ var div_1 = child(div);
68817
+ var canvas_1 = child(div_1);
67929
68818
  let classes;
67930
68819
  bind_this(canvas_1, ($$value) => canvas = $$value, () => canvas);
67931
- var node = sibling(canvas_1, 2);
68820
+ reset(div_1);
68821
+ var node = sibling(div_1, 2);
67932
68822
  var consequent_20 = ($$anchor) => {
67933
68823
  var fragment = root_1$5();
67934
68824
  var node_1 = first_child(fragment);
@@ -68038,8 +68928,8 @@ function FloorPlanCanvas($$anchor, $$props) {
68038
68928
  if_block(node_4, ($$render) => {
68039
68929
  if (get(showMinimap) && get(currentFloor) && get(currentFloor).walls.length > 0) $$render(consequent_3);
68040
68930
  });
68041
- var div_2 = sibling(node_4, 2);
68042
- var node_5 = child(div_2);
68931
+ var div_3 = sibling(node_4, 2);
68932
+ var node_5 = child(div_3);
68043
68933
  var consequent_4 = ($$anchor) => {
68044
68934
  var fragment_1 = root_6();
68045
68935
  var span = first_child(fragment_1);
@@ -68154,11 +69044,11 @@ function FloorPlanCanvas($$anchor, $$props) {
68154
69044
  var text_13 = child(button_6);
68155
69045
  text_13.nodeValue = "🗺 Map";
68156
69046
  reset(button_6);
68157
- reset(div_2);
68158
- var node_11 = sibling(div_2, 2);
69047
+ reset(div_3);
69048
+ var node_11 = sibling(div_3, 2);
68159
69049
  var consequent_10 = ($$anchor) => {
68160
- var div_3 = root_12();
68161
- var node_12 = sibling(child(div_3), 2);
69050
+ var div_4 = root_12();
69051
+ var node_12 = sibling(child(div_4), 2);
68162
69052
  each(node_12, 16, () => [
68163
69053
  ["walls", "Walls"],
68164
69054
  ["doors", "Doors"],
@@ -68199,10 +69089,10 @@ function FloorPlanCanvas($$anchor, $$props) {
68199
69089
  remove_input_defaults(input_4);
68200
69090
  next(2);
68201
69091
  reset(label_3);
68202
- reset(div_3);
69092
+ reset(div_4);
68203
69093
  bind_checked(input_3, () => get(showRoomLabels), ($$value) => set(showRoomLabels, $$value));
68204
69094
  bind_checked(input_4, () => get(showDimensions), ($$value) => set(showDimensions, $$value));
68205
- append($$anchor, div_3);
69095
+ append($$anchor, div_4);
68206
69096
  };
68207
69097
  if_block(node_11, ($$render) => {
68208
69098
  if (get(showLayerPanel)) $$render(consequent_10);
@@ -68243,8 +69133,8 @@ function FloorPlanCanvas($$anchor, $$props) {
68243
69133
  var fragment_4 = comment();
68244
69134
  var node_14 = first_child(fragment_4);
68245
69135
  var consequent_13 = ($$anchor) => {
68246
- var div_4 = root_15();
68247
- var button_7 = child(div_4);
69136
+ var div_5 = root_15();
69137
+ var button_7 = child(div_5);
68248
69138
  var node_15 = sibling(button_7, 2);
68249
69139
  var consequent_11 = ($$anchor) => {
68250
69140
  var button_8 = root_16();
@@ -68270,10 +69160,10 @@ function FloorPlanCanvas($$anchor, $$props) {
68270
69160
  if (get(el).type === "wall" && get(currentSelectedId) && get(currentSelectedIds).size === 0) $$render(consequent_12);
68271
69161
  });
68272
69162
  var button_10 = sibling(node_16, 4);
68273
- reset(div_4);
69163
+ reset(div_5);
68274
69164
  template_effect(() => {
68275
69165
  var _$$get$pos$x;
68276
- return set_style(div_4, `left: ${(_$$get$pos$x = get(el).pos.x) !== null && _$$get$pos$x !== void 0 ? _$$get$pos$x : ""}px; top: ${get(el).pos.y - 44}px; transform: translateX(-50%);`);
69166
+ return set_style(div_5, `left: ${(_$$get$pos$x = get(el).pos.x) !== null && _$$get$pos$x !== void 0 ? _$$get$pos$x : ""}px; top: ${get(el).pos.y - 44}px; transform: translateX(-50%);`);
68277
69167
  });
68278
69168
  delegated("click", button_7, () => {
68279
69169
  if (!get(currentSelectedId) || !get(currentFloor)) return;
@@ -68296,7 +69186,7 @@ function FloorPlanCanvas($$anchor, $$props) {
68296
69186
  selectedElementId.set(null);
68297
69187
  }
68298
69188
  });
68299
- append($$anchor, div_4);
69189
+ append($$anchor, div_5);
68300
69190
  };
68301
69191
  if_block(node_14, ($$render) => {
68302
69192
  if (get(el)) $$render(consequent_13);
@@ -68315,15 +69205,15 @@ function FloorPlanCanvas($$anchor, $$props) {
68315
69205
  });
68316
69206
  var node_18 = sibling(node_17, 2);
68317
69207
  var consequent_16 = ($$anchor) => {
68318
- var div_6 = root_19();
68319
- var text_15 = child(div_6);
68320
- reset(div_6);
69208
+ var div_7 = root_19();
69209
+ var text_15 = child(div_7);
69210
+ reset(div_7);
68321
69211
  template_effect(() => {
68322
69212
  var _$$get13;
68323
69213
  return set_text(text_15, `Click to place · Scroll or R to rotate (${(_$$get13 = get(currentPlacingRotation)) !== null && _$$get13 !== void 0 ? _$$get13 : ""}°) · Esc
68324
69214
  to cancel`);
68325
69215
  });
68326
- append($$anchor, div_6);
69216
+ append($$anchor, div_7);
68327
69217
  };
68328
69218
  if_block(node_18, ($$render) => {
68329
69219
  if (get(currentPlacingId) && get(currentTool) === "furniture") $$render(consequent_16);
@@ -68344,24 +69234,24 @@ function FloorPlanCanvas($$anchor, $$props) {
68344
69234
  });
68345
69235
  var node_21 = sibling(node_20, 2);
68346
69236
  var consequent_19 = ($$anchor) => {
68347
- var div_9 = root_22();
68348
- var text_16 = child(div_9);
68349
- reset(div_9);
69237
+ var div_10 = root_22();
69238
+ var text_16 = child(div_10);
69239
+ reset(div_10);
68350
69240
  template_effect(() => set_text(text_16, `${get(annotationStart) ? "Click second point to create annotation" : "Click first point"} · N to exit · Esc to cancel`));
68351
- append($$anchor, div_9);
69241
+ append($$anchor, div_10);
68352
69242
  };
68353
69243
  if_block(node_21, ($$render) => {
68354
69244
  if (get(annotating)) $$render(consequent_19);
68355
69245
  });
68356
- var div_10 = sibling(node_21, 2);
68357
- var button_11 = child(div_10);
69246
+ var div_11 = sibling(node_21, 2);
69247
+ var button_11 = child(div_11);
68358
69248
  var button_12 = sibling(button_11, 2);
68359
69249
  var text_17 = child(button_12);
68360
69250
  reset(button_12);
68361
69251
  var button_13 = sibling(button_12, 2);
68362
69252
  var button_14 = sibling(button_13, 4);
68363
- reset(div_10);
68364
- ContextMenu(sibling(div_10, 2), {
69253
+ reset(div_11);
69254
+ ContextMenu(sibling(div_11, 2), {
68365
69255
  get x() {
68366
69256
  return get(ctxMenuX);
68367
69257
  },
@@ -68436,12 +69326,18 @@ function FloorPlanCanvas($$anchor, $$props) {
68436
69326
  if (!$$props.viewOnly) $$render(consequent_20);
68437
69327
  });
68438
69328
  reset(div);
68439
- template_effect(() => {
68440
- var _$$get14;
69329
+ template_effect(($0) => {
69330
+ set_style(div_1, $0);
68441
69331
  classes = set_class(canvas_1, 1, "block w-full h-full", null, classes, { "pointer-events-none": $$props.viewOnly });
68442
69332
  set_attribute(canvas_1, "tabindex", $$props.viewOnly ? -1 : 0);
68443
- set_style(canvas_1, `cursor: ${(_$$get14 = get(cursorStyle)) !== null && _$$get14 !== void 0 ? _$$get14 : ""}`);
68444
- });
69333
+ set_style(canvas_1, `
69334
+ cursor: ${get(cursorStyle)};
69335
+ max-width: ${$$props.viewOnly ? `${$$props.floorMaxWidth}px` : "unset"};
69336
+ max-height: ${$$props.viewOnly ? `${$$props.floorMaxHeight}px` : "unset"};
69337
+ min-width: ${$$props.viewOnly ? `${$$props.floorMaxWidth}px` : "unset"};
69338
+ min-height: ${$$props.viewOnly ? `${$$props.floorMaxHeight}px` : "unset"};
69339
+ `);
69340
+ }, [() => getCanvasFrameStyle()]);
68445
69341
  delegated("mousedown", canvas_1, onMouseDown);
68446
69342
  delegated("mousemove", canvas_1, onMouseMove);
68447
69343
  delegated("mouseup", canvas_1, onMouseUp);
@@ -69436,7 +70332,11 @@ function App($$anchor, $$props) {
69436
70332
  push($$props, true);
69437
70333
  let showLayers = /* @__PURE__ */ state(false);
69438
70334
  let floorData = /* @__PURE__ */ state(null);
69439
- let config = /* @__PURE__ */ state(proxy({ viewOnly: false }));
70335
+ let config = /* @__PURE__ */ state(proxy({
70336
+ viewOnly: false,
70337
+ floorMaxWidth: 600,
70338
+ floorMaxHeight: 400
70339
+ }));
69440
70340
  (_$$props$stores = $$props.stores) === null || _$$props$stores === void 0 || _$$props$stores.floorData.subscribe((v) => set(floorData, v, true));
69441
70341
  (_$$props$stores2 = $$props.stores) === null || _$$props$stores2 === void 0 || _$$props$stores2.config.subscribe((v) => set(config, v, true));
69442
70342
  let commandPaletteOpen = /* @__PURE__ */ state(false);
@@ -69538,9 +70438,25 @@ function App($$anchor, $$props) {
69538
70438
  var _$$get2;
69539
70439
  return (_$$get2 = get(config)) === null || _$$get2 === void 0 ? void 0 : _$$get2.viewOnly;
69540
70440
  });
69541
- FloorPlanCanvas(node_4, { get viewOnly() {
69542
- return get($0);
69543
- } });
70441
+ let $1 = /* @__PURE__ */ user_derived(() => {
70442
+ var _$$get3;
70443
+ return (_$$get3 = get(config)) === null || _$$get3 === void 0 ? void 0 : _$$get3.floorMaxWidth;
70444
+ });
70445
+ let $2 = /* @__PURE__ */ user_derived(() => {
70446
+ var _$$get4;
70447
+ return (_$$get4 = get(config)) === null || _$$get4 === void 0 ? void 0 : _$$get4.floorMaxHeight;
70448
+ });
70449
+ FloorPlanCanvas(node_4, {
70450
+ get viewOnly() {
70451
+ return get($0);
70452
+ },
70453
+ get floorMaxWidth() {
70454
+ return get($1);
70455
+ },
70456
+ get floorMaxHeight() {
70457
+ return get($2);
70458
+ }
70459
+ });
69544
70460
  }
69545
70461
  var node_5 = sibling(node_4, 2);
69546
70462
  var consequent_2 = ($$anchor) => {