@cjlapao/ui-kit 0.2.19 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -643,6 +643,7 @@ __export(src_exports, {
643
643
  radarPath: () => radarPath,
644
644
  readAccessor: () => readAccessor,
645
645
  registerEasing: () => registerEasing,
646
+ registerIcons: () => registerIcons,
646
647
  relLuminance: () => relLuminance,
647
648
  renderIcon: () => renderIcon,
648
649
  resetI18nProviderWarns: () => resetI18nProviderWarns,
@@ -5287,6 +5288,55 @@ var iconRegistry = {
5287
5288
  Windows
5288
5289
  };
5289
5290
 
5291
+ // src/icons/customRegistry.ts
5292
+ var customIcons = /* @__PURE__ */ new Map();
5293
+ var listeners = /* @__PURE__ */ new Set();
5294
+ var revision = 0;
5295
+ var notify = () => {
5296
+ revision += 1;
5297
+ listeners.forEach((listener) => listener());
5298
+ };
5299
+ var subscribeIcons = (listener) => {
5300
+ listeners.add(listener);
5301
+ return () => {
5302
+ listeners.delete(listener);
5303
+ };
5304
+ };
5305
+ var getIconRevision = () => revision;
5306
+ var getServerIconRevision = () => 0;
5307
+ function resolveIcon(name) {
5308
+ const registrations = customIcons.get(name);
5309
+ return registrations?.[registrations.length - 1]?.component ?? (Object.prototype.hasOwnProperty.call(iconRegistry, name) ? iconRegistry[name] : void 0);
5310
+ }
5311
+ function registerIcons(icons, options = {}) {
5312
+ const entries = Object.entries(icons);
5313
+ for (const [name, component] of entries) {
5314
+ if (!name.trim() || !component) throw new Error("An icon needs a name and SVG component.");
5315
+ if (!options.override && (customIcons.has(name) || Object.prototype.hasOwnProperty.call(iconRegistry, name))) {
5316
+ throw new Error(`Icon already registered: ${name}. Use { override: true } to replace it.`);
5317
+ }
5318
+ }
5319
+ const registrations = entries.map(([name, component]) => {
5320
+ const registration = { component };
5321
+ customIcons.set(name, [...customIcons.get(name) ?? [], registration]);
5322
+ return { name, registration };
5323
+ });
5324
+ if (entries.length) notify();
5325
+ let disposed = false;
5326
+ return () => {
5327
+ if (disposed) return;
5328
+ disposed = true;
5329
+ let changed = false;
5330
+ for (const { name, registration } of registrations) {
5331
+ const remaining = customIcons.get(name)?.filter((entry) => entry !== registration);
5332
+ if (remaining?.length) customIcons.set(name, remaining);
5333
+ else customIcons.delete(name);
5334
+ changed = true;
5335
+ }
5336
+ if (changed) notify();
5337
+ };
5338
+ }
5339
+
5290
5340
  // src/components/CustomIcon.tsx
5291
5341
  var import_jsx_runtime145 = require("react/jsx-runtime");
5292
5342
  var SIZE_CLASS_MAP = {
@@ -5313,7 +5363,8 @@ var CustomIcon = ({
5313
5363
  style,
5314
5364
  ...rest
5315
5365
  }) => {
5316
- const IconComponent = iconRegistry[icon];
5366
+ (0, import_react145.useSyncExternalStore)(subscribeIcons, getIconRevision, getServerIconRevision);
5367
+ const IconComponent = typeof icon === "string" ? resolveIcon(icon) : icon;
5317
5368
  const dimension = (0, import_react145.useMemo)(() => {
5318
5369
  if (!customSize) return void 0;
5319
5370
  return typeof customSize === "number" ? `${customSize}px` : customSize;
@@ -5351,9 +5402,9 @@ var CustomIcon = ({
5351
5402
  // The fallback used to drop every computed class, so a missing icon had no
5352
5403
  // size at all unless `customSize` was given — it collapsed the layout
5353
5404
  // around it.
5354
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("span", { className: "grid h-full w-full place-items-center rounded bg-neutral-100 text-[0.6em] font-bold uppercase text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400", children: icon?.charAt(0) || "?" })
5405
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("span", { className: "grid h-full w-full place-items-center rounded bg-neutral-100 text-[0.6em] font-bold uppercase text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400", children: typeof icon === "string" ? icon.charAt(0) || "?" : "?" })
5355
5406
  );
5356
- if (!IconComponent && icon && !warned.has(icon)) {
5407
+ if (!IconComponent && typeof icon === "string" && icon && !warned.has(icon)) {
5357
5408
  warned.add(icon);
5358
5409
  console.warn(`Icon not found in registry: ${icon}`);
5359
5410
  }
@@ -8572,8 +8623,8 @@ function deriveMonths(locale, short) {
8572
8623
  if (cached !== void 0) return cached;
8573
8624
  let names = null;
8574
8625
  try {
8575
- const format2 = new Intl.DateTimeFormat(locale, { month: short ? "short" : "long" });
8576
- names = Array.from({ length: 12 }, (_, i) => format2.format(new Date(2026, i, 15)));
8626
+ const format3 = new Intl.DateTimeFormat(locale, { month: short ? "short" : "long" });
8627
+ names = Array.from({ length: 12 }, (_, i) => format3.format(new Date(2026, i, 15)));
8577
8628
  } catch {
8578
8629
  names = null;
8579
8630
  }
@@ -8586,11 +8637,11 @@ function deriveWeekdays(locale, short) {
8586
8637
  if (cached !== void 0) return cached;
8587
8638
  let names = null;
8588
8639
  try {
8589
- const format2 = new Intl.DateTimeFormat(locale, { weekday: short ? "short" : "long" });
8640
+ const format3 = new Intl.DateTimeFormat(locale, { weekday: short ? "short" : "long" });
8590
8641
  const start = firstSundayOf(new Date(2026, 8, 1));
8591
8642
  names = Array.from(
8592
8643
  { length: 7 },
8593
- (_, i) => format2.format(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i))
8644
+ (_, i) => format3.format(new Date(start.getFullYear(), start.getMonth(), start.getDate() + i))
8594
8645
  );
8595
8646
  } catch {
8596
8647
  names = null;
@@ -10752,7 +10803,7 @@ function createI18n(config) {
10752
10803
  if (!available.has(locale)) locale = "en";
10753
10804
  let isRTL = isRTLLocale(locale);
10754
10805
  let version = 0;
10755
- const listeners = /* @__PURE__ */ new Set();
10806
+ const listeners2 = /* @__PURE__ */ new Set();
10756
10807
  const messageCache = /* @__PURE__ */ new Map();
10757
10808
  const renderMessage = (key, source, values) => {
10758
10809
  const cacheKey = `${locale}\0${source}`;
@@ -10816,7 +10867,7 @@ function createI18n(config) {
10816
10867
  locale = resolved;
10817
10868
  isRTL = isRTLLocale(locale);
10818
10869
  version += 1;
10819
- for (const listener of [...listeners]) listener();
10870
+ for (const listener of [...listeners2]) listener();
10820
10871
  },
10821
10872
  formatNumber(value, options) {
10822
10873
  try {
@@ -10853,9 +10904,9 @@ function createI18n(config) {
10853
10904
  return isRTL;
10854
10905
  },
10855
10906
  subscribe(listener) {
10856
- listeners.add(listener);
10907
+ listeners2.add(listener);
10857
10908
  return () => {
10858
- listeners.delete(listener);
10909
+ listeners2.delete(listener);
10859
10910
  };
10860
10911
  },
10861
10912
  getVersion() {
@@ -26860,7 +26911,7 @@ function computeRadarGeometry(input) {
26860
26911
  };
26861
26912
  }
26862
26913
  function computeRadarGrid(input) {
26863
- const { axes, cx, cy, R, rings, domainMax, format: format2 } = input;
26914
+ const { axes, cx, cy, R, rings, domainMax, format: format3 } = input;
26864
26915
  const n = axes.length;
26865
26916
  const ringValues = [];
26866
26917
  const ringPaths = [];
@@ -26888,7 +26939,7 @@ function computeRadarGrid(input) {
26888
26939
  const tickLabels = ringValues.map((v, k) => ({
26889
26940
  x: cx - 7,
26890
26941
  y: cy - R * (k + 1) / rings + 4,
26891
- text: format2 ? format2(v) : String(Math.round(v * 10) / 10)
26942
+ text: format3 ? format3(v) : String(Math.round(v * 10) / 10)
26892
26943
  }));
26893
26944
  return { cx, cy, R, ringValues, ringPaths, spokes, tickLabels };
26894
26945
  }
@@ -27116,7 +27167,7 @@ function framePolarSweep(geometry, progress, input) {
27116
27167
  return { ...geometry, segments };
27117
27168
  }
27118
27169
  function computePolarGrid(input) {
27119
- const { categories, cx, cy, R, rings, domainMax, shape: shape2, format: format2, innerR = 0 } = input;
27170
+ const { categories, cx, cy, R, rings, domainMax, shape: shape2, format: format3, innerR = 0 } = input;
27120
27171
  const n = categories.length;
27121
27172
  const ringValues = [];
27122
27173
  const ringPaths = [];
@@ -27129,7 +27180,7 @@ function computePolarGrid(input) {
27129
27180
  tickLabels.push({
27130
27181
  x: cx - 7,
27131
27182
  y: cy - r + 4,
27132
- text: format2 ? format2(v) : String(Math.round(v * 10) / 10)
27183
+ text: format3 ? format3(v) : String(Math.round(v * 10) / 10)
27133
27184
  });
27134
27185
  if (shape2 === "circle") {
27135
27186
  ringPaths.push(
@@ -33291,8 +33342,8 @@ function ticksFor(xScale, props) {
33291
33342
  }
33292
33343
  const cont = xScale;
33293
33344
  const ticks = cont.ticks(props.tickCount);
33294
- const format2 = props.format ?? (cont.type === "time" ? timeTickFormat(cont) : (t) => formatSI(Number(t)));
33295
- return ticks.map((t) => ({ x: cont.map(t), label: format2(t) }));
33345
+ const format3 = props.format ?? (cont.type === "time" ? timeTickFormat(cont) : (t) => formatSI(Number(t)));
33346
+ return ticks.map((t) => ({ x: cont.map(t), label: format3(t) }));
33296
33347
  }
33297
33348
  function edgeAnchor(label, x, left, right) {
33298
33349
  const half = label.length * 6.1 / 2;
@@ -33455,7 +33506,7 @@ function YAxis(props = {}) {
33455
33506
  return;
33456
33507
  }
33457
33508
  const ticks2 = scale.ticks(props.tickCount ?? 5);
33458
- const format3 = props.format ?? ((t) => formatSI(t));
33509
+ const format4 = props.format ?? ((t) => formatSI(t));
33459
33510
  const left2 = onRight ? area2.x + area2.width : area2.x;
33460
33511
  if (props.grid !== false && !onRight) {
33461
33512
  const spec = resolveGrid(props, theme.gridColor);
@@ -33488,7 +33539,7 @@ function YAxis(props = {}) {
33488
33539
  for (const t of ticks2) {
33489
33540
  const y = scale.map(t);
33490
33541
  c.textAlign = onRight ? "left" : "right";
33491
- c.fillText(format3(Number(t)), onRight ? left2 + 8 : left2 - 8, y);
33542
+ c.fillText(format4(Number(t)), onRight ? left2 + 8 : left2 - 8, y);
33492
33543
  }
33493
33544
  }
33494
33545
  };
@@ -33526,7 +33577,7 @@ function YAxis(props = {}) {
33526
33577
  ] });
33527
33578
  }
33528
33579
  const ticks = scale.ticks(props.tickCount ?? 5);
33529
- const format2 = props.format ?? ((t) => formatSI(t));
33580
+ const format3 = props.format ?? ((t) => formatSI(t));
33530
33581
  return /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)("g", { "data-chart-feature": `yaxis-${onRight ? "right" : "left"}`, children: [
33531
33582
  (() => {
33532
33583
  const spec = resolveGrid(props, theme.gridColor);
@@ -33565,7 +33616,7 @@ function YAxis(props = {}) {
33565
33616
  dominantBaseline: "middle",
33566
33617
  fontSize: 11,
33567
33618
  fill: theme.textColor,
33568
- children: format2(Number(t))
33619
+ children: format3(Number(t))
33569
33620
  },
33570
33621
  i
33571
33622
  )),
@@ -39605,7 +39656,7 @@ var DatePicker = (0, import_react235.forwardRef)(
39605
39656
  value: valueProp,
39606
39657
  defaultValue,
39607
39658
  onChange,
39608
- format: format2 = DEFAULT_DATE_FORMAT,
39659
+ format: format3 = DEFAULT_DATE_FORMAT,
39609
39660
  minDate,
39610
39661
  maxDate,
39611
39662
  disabledDays,
@@ -39677,10 +39728,10 @@ var DatePicker = (0, import_react235.forwardRef)(
39677
39728
  );
39678
39729
  const syncText = (0, import_react235.useCallback)(
39679
39730
  (next) => {
39680
- setText(formatValue(next, format2));
39731
+ setText(formatValue(next, format3));
39681
39732
  setTextInvalid(false);
39682
39733
  },
39683
- [format2]
39734
+ [format3]
39684
39735
  );
39685
39736
  const [viewDate, setViewDate] = (0, import_react235.useState)(
39686
39737
  () => getViewDate(initialValue, constraints)
@@ -39711,7 +39762,7 @@ var DatePicker = (0, import_react235.forwardRef)(
39711
39762
  setViewDate(getViewDate(currentValue, constraints));
39712
39763
  }
39713
39764
  }, [currentValue, constraints]);
39714
- const [text2, setText] = (0, import_react235.useState)(() => formatValue(initialValue, format2));
39765
+ const [text2, setText] = (0, import_react235.useState)(() => formatValue(initialValue, format3));
39715
39766
  const [textInvalid, setTextInvalid] = (0, import_react235.useState)(false);
39716
39767
  const [focused, setFocused] = (0, import_react235.useState)(false);
39717
39768
  const focusedRef = (0, import_react235.useRef)(false);
@@ -39721,10 +39772,10 @@ var DatePicker = (0, import_react235.forwardRef)(
39721
39772
  onInvalidRef.current = onInvalidInputChange;
39722
39773
  (0, import_react235.useEffect)(() => {
39723
39774
  if (!focusedRef.current) {
39724
- setText(formatValue(currentValue, format2));
39775
+ setText(formatValue(currentValue, format3));
39725
39776
  setTextInvalid(false);
39726
39777
  }
39727
- }, [currentValue, format2]);
39778
+ }, [currentValue, format3]);
39728
39779
  const isParseValid = (0, import_react235.useCallback)(
39729
39780
  (parsed) => {
39730
39781
  if (Array.isArray(parsed)) {
@@ -39748,7 +39799,7 @@ var DatePicker = (0, import_react235.forwardRef)(
39748
39799
  const parsed = parseValueText(
39749
39800
  next,
39750
39801
  selectionMode,
39751
- format2,
39802
+ format3,
39752
39803
  /* @__PURE__ */ new Date(),
39753
39804
  i18n.parseNames(i18n.locale)
39754
39805
  );
@@ -39764,7 +39815,7 @@ var DatePicker = (0, import_react235.forwardRef)(
39764
39815
  const handleBlur = (event) => {
39765
39816
  focusedRef.current = false;
39766
39817
  setFocused(false);
39767
- setText(formatValue(currentValueRef.current, format2));
39818
+ setText(formatValue(currentValueRef.current, format3));
39768
39819
  setTextInvalid(false);
39769
39820
  onBlur?.(event);
39770
39821
  };
@@ -39870,7 +39921,7 @@ var DatePicker = (0, import_react235.forwardRef)(
39870
39921
  const parsed = parseValueText(
39871
39922
  text2,
39872
39923
  selectionMode,
39873
- format2,
39924
+ format3,
39874
39925
  /* @__PURE__ */ new Date(),
39875
39926
  i18n.parseNames(i18n.locale)
39876
39927
  );
@@ -40789,13 +40840,13 @@ var createToastStore = (options = {}) => {
40789
40840
  let viewportCount = 0;
40790
40841
  let nextViewportHandle = 1;
40791
40842
  let warnedNoViewport = false;
40792
- const listeners = /* @__PURE__ */ new Set();
40843
+ const listeners2 = /* @__PURE__ */ new Set();
40793
40844
  const closeHandlers = /* @__PURE__ */ new Set();
40794
40845
  const lifeHandlers = /* @__PURE__ */ new Set();
40795
40846
  const lifeTimers = /* @__PURE__ */ new Map();
40796
40847
  const emit = () => {
40797
40848
  snapshot = { messages: [...messages] };
40798
- for (const listener of listeners) listener();
40849
+ for (const listener of listeners2) listener();
40799
40850
  };
40800
40851
  const find = (id) => messages.find((m) => m.id === id);
40801
40852
  const inGroup = (m, group) => m.group === group;
@@ -40955,8 +41006,8 @@ var createToastStore = (options = {}) => {
40955
41006
  };
40956
41007
  return {
40957
41008
  subscribe(listener) {
40958
- listeners.add(listener);
40959
- return () => listeners.delete(listener);
41009
+ listeners2.add(listener);
41010
+ return () => listeners2.delete(listener);
40960
41011
  },
40961
41012
  getSnapshot: () => snapshot,
40962
41013
  show,
@@ -67934,6 +67985,215 @@ function reorderDragSubtree(rows, dragKey) {
67934
67985
  return out;
67935
67986
  }
67936
67987
 
67988
+ // ../common/gantt/crossings.ts
67989
+ var BUCKET_HEIGHT = 44;
67990
+ var MIN_JUMP_RADIUS = 2.5;
67991
+ var SAMPLE_STEPS = 6;
67992
+ var format2 = (value) => Number(value.toFixed(2)).toString();
67993
+ var cornerRadii = (points, radius) => points.map((point, index) => {
67994
+ if (index === 0 || index === points.length - 1) return 0;
67995
+ const previous = points[index - 1];
67996
+ const next = points[index + 1];
67997
+ return Math.min(
67998
+ radius,
67999
+ Math.hypot(point[0] - previous[0], point[1] - previous[1]) / 2,
68000
+ Math.hypot(next[0] - point[0], next[1] - point[1]) / 2
68001
+ );
68002
+ });
68003
+ var bucketRange = (segment) => {
68004
+ const low = Math.floor(Math.min(segment.a[1], segment.b[1]) / BUCKET_HEIGHT);
68005
+ const high = Math.floor(Math.max(segment.a[1], segment.b[1]) / BUCKET_HEIGHT);
68006
+ const buckets = [];
68007
+ for (let bucket = low; bucket <= high; bucket += 1) buckets.push(bucket);
68008
+ return buckets;
68009
+ };
68010
+ var pushJump = (jumps, route, jump) => {
68011
+ const current = jumps.get(route);
68012
+ if (current) current.push(jump);
68013
+ else jumps.set(route, [jump]);
68014
+ };
68015
+ var packJumps = (jumps) => {
68016
+ const bySegment = /* @__PURE__ */ new Map();
68017
+ for (const jump of jumps) {
68018
+ const current = bySegment.get(jump.segment);
68019
+ if (current) current.push(jump);
68020
+ else bySegment.set(jump.segment, [jump]);
68021
+ }
68022
+ const packed = [];
68023
+ for (const segment of bySegment.values()) {
68024
+ segment.sort((a, b) => a.at - b.at);
68025
+ const unique = segment.filter(
68026
+ (jump, index) => index === 0 || Math.abs(jump.at - segment[index - 1].at) > 0.01
68027
+ );
68028
+ for (let index = 0; index < unique.length; index += 1) {
68029
+ const jump = unique[index];
68030
+ const before = index === 0 ? Infinity : (jump.at - unique[index - 1].at) / 2 - 0.5;
68031
+ const after = index === unique.length - 1 ? Infinity : (unique[index + 1].at - jump.at) / 2 - 0.5;
68032
+ const radius = Math.min(jump.radius, before, after);
68033
+ if (radius >= 1) packed.push({ ...jump, radius });
68034
+ }
68035
+ }
68036
+ return packed;
68037
+ };
68038
+ var jumpsBySegment = (jumps) => {
68039
+ const result = /* @__PURE__ */ new Map();
68040
+ for (const jump of jumps) {
68041
+ const current = result.get(jump.segment);
68042
+ if (current) current.push(jump);
68043
+ else result.set(jump.segment, [jump]);
68044
+ }
68045
+ return result;
68046
+ };
68047
+ var pathWithJumps = (points, cornerRadius, jumps) => {
68048
+ if (points.length === 0) return "";
68049
+ if (points.length === 1) return `M ${format2(points[0][0])} ${format2(points[0][1])}`;
68050
+ const bySegment = jumpsBySegment(jumps);
68051
+ let d = `M ${format2(points[0][0])} ${format2(points[0][1])}`;
68052
+ for (let index = 1; index < points.length; index += 1) {
68053
+ const previous = points[index - 1];
68054
+ const current = points[index];
68055
+ if (previous[1] === current[1]) {
68056
+ const direction = current[0] >= previous[0] ? 1 : -1;
68057
+ const segmentJumps = (bySegment.get(index - 1) ?? []).slice().sort((a, b) => (a.at - b.at) * direction);
68058
+ for (const jump of segmentJumps) {
68059
+ d += ` L ${format2(jump.at - direction * jump.radius)} ${format2(current[1])}`;
68060
+ d += ` A ${format2(jump.radius)} ${format2(jump.radius)} 0 0 ${direction === 1 ? 0 : 1} ${format2(jump.at + direction * jump.radius)} ${format2(current[1])}`;
68061
+ }
68062
+ }
68063
+ if (index === points.length - 1) {
68064
+ d += ` L ${format2(current[0])} ${format2(current[1])}`;
68065
+ continue;
68066
+ }
68067
+ const next = points[index + 1];
68068
+ const incomingX = current[0] - previous[0];
68069
+ const incomingY = current[1] - previous[1];
68070
+ const outgoingX = next[0] - current[0];
68071
+ const outgoingY = next[1] - current[1];
68072
+ const incomingLength = Math.hypot(incomingX, incomingY);
68073
+ const outgoingLength = Math.hypot(outgoingX, outgoingY);
68074
+ if (incomingLength < 0.5 || outgoingLength < 0.5) {
68075
+ d += ` L ${format2(current[0])} ${format2(current[1])}`;
68076
+ continue;
68077
+ }
68078
+ const radius = Math.min(cornerRadius, incomingLength / 2, outgoingLength / 2);
68079
+ const before = [
68080
+ current[0] - incomingX / incomingLength * radius,
68081
+ current[1] - incomingY / incomingLength * radius
68082
+ ];
68083
+ const after = [
68084
+ current[0] + outgoingX / outgoingLength * radius,
68085
+ current[1] + outgoingY / outgoingLength * radius
68086
+ ];
68087
+ d += ` L ${format2(before[0])} ${format2(before[1])}`;
68088
+ d += ` Q ${format2(current[0])} ${format2(current[1])} ${format2(after[0])} ${format2(after[1])}`;
68089
+ }
68090
+ return d;
68091
+ };
68092
+ var hitPointsWithJumps = (points, jumps) => {
68093
+ if (points.length === 0) return [];
68094
+ const bySegment = jumpsBySegment(jumps);
68095
+ const result = [[...points[0]]];
68096
+ for (let index = 1; index < points.length; index += 1) {
68097
+ const previous = points[index - 1];
68098
+ const current = points[index];
68099
+ if (previous[1] === current[1]) {
68100
+ const direction = current[0] >= previous[0] ? 1 : -1;
68101
+ const segmentJumps = (bySegment.get(index - 1) ?? []).slice().sort((a, b) => (a.at - b.at) * direction);
68102
+ for (const jump of segmentJumps) {
68103
+ result.push(...sampleHop(jump, current[1], direction));
68104
+ }
68105
+ }
68106
+ result.push([...current]);
68107
+ }
68108
+ return result;
68109
+ };
68110
+ var sampleHop = (jump, y, direction) => {
68111
+ const points = [[jump.at - direction * jump.radius, y]];
68112
+ for (let step = 1; step < SAMPLE_STEPS; step += 1) {
68113
+ const progress = step / SAMPLE_STEPS;
68114
+ const theta = direction === 1 ? Math.PI * (1 - progress) : Math.PI * progress;
68115
+ points.push([
68116
+ jump.at + jump.radius * Math.cos(theta),
68117
+ y - jump.radius * Math.sin(theta)
68118
+ ]);
68119
+ }
68120
+ points.push([jump.at + direction * jump.radius, y]);
68121
+ return points;
68122
+ };
68123
+ var hopPointGroups = (points, jumps) => {
68124
+ const groups = [];
68125
+ for (const jump of jumps) {
68126
+ const start = points[jump.segment];
68127
+ const end = points[jump.segment + 1];
68128
+ const direction = end[0] >= start[0] ? 1 : -1;
68129
+ groups.push(sampleHop(jump, start[1], direction));
68130
+ }
68131
+ return groups;
68132
+ };
68133
+ function ganttCrossingPaths(routes, cornerRadius, jumpRadius = cornerRadius) {
68134
+ const radii = routes.map((route) => cornerRadii(route.points, cornerRadius));
68135
+ const horizontal = [];
68136
+ const verticalByBucket = /* @__PURE__ */ new Map();
68137
+ routes.forEach((route, routeIndex) => {
68138
+ for (let segmentIndex = 0; segmentIndex + 1 < route.points.length; segmentIndex += 1) {
68139
+ const segment = {
68140
+ route: routeIndex,
68141
+ segment: segmentIndex,
68142
+ a: route.points[segmentIndex],
68143
+ b: route.points[segmentIndex + 1]
68144
+ };
68145
+ if (segment.a[1] === segment.b[1] && segment.a[0] !== segment.b[0]) {
68146
+ horizontal.push(segment);
68147
+ } else if (segment.a[0] === segment.b[0] && segment.a[1] !== segment.b[1]) {
68148
+ for (const bucket of bucketRange(segment)) {
68149
+ const current = verticalByBucket.get(bucket);
68150
+ if (current) current.push(segment);
68151
+ else verticalByBucket.set(bucket, [segment]);
68152
+ }
68153
+ }
68154
+ }
68155
+ });
68156
+ const jumps = /* @__PURE__ */ new Map();
68157
+ const seen = /* @__PURE__ */ new Set();
68158
+ for (const h of horizontal) {
68159
+ const bucket = Math.floor(h.a[1] / BUCKET_HEIGHT);
68160
+ for (const v of verticalByBucket.get(bucket) ?? []) {
68161
+ if (h.route === v.route) continue;
68162
+ const key = `${h.route}:${h.segment}:${v.route}:${v.segment}`;
68163
+ if (seen.has(key)) continue;
68164
+ seen.add(key);
68165
+ const left = Math.min(h.a[0], h.b[0]);
68166
+ const right = Math.max(h.a[0], h.b[0]);
68167
+ const top = Math.min(v.a[1], v.b[1]);
68168
+ const bottom = Math.max(v.a[1], v.b[1]);
68169
+ const crossingX = v.a[0];
68170
+ const crossingY = h.a[1];
68171
+ if (crossingX <= left || crossingX >= right || crossingY <= top || crossingY >= bottom) {
68172
+ continue;
68173
+ }
68174
+ const hStartRoom = Math.abs(crossingX - h.a[0]) - radii[h.route][h.segment] - 1;
68175
+ const hEndRoom = Math.abs(crossingX - h.b[0]) - radii[h.route][h.segment + 1] - 1;
68176
+ const vStartRoom = Math.abs(crossingY - v.a[1]) - radii[v.route][v.segment] - 1;
68177
+ const vEndRoom = Math.abs(crossingY - v.b[1]) - radii[v.route][v.segment + 1] - 1;
68178
+ const radius = Math.min(jumpRadius, hStartRoom, hEndRoom);
68179
+ if (radius < MIN_JUMP_RADIUS || vStartRoom < 0 || vEndRoom < 0) continue;
68180
+ pushJump(jumps, h.route, { segment: h.segment, at: crossingX, radius });
68181
+ }
68182
+ }
68183
+ const result = /* @__PURE__ */ new Map();
68184
+ for (const [routeIndex, routeJumps] of jumps) {
68185
+ const packed = packJumps(routeJumps);
68186
+ if (packed.length === 0) continue;
68187
+ const route = routes[routeIndex];
68188
+ result.set(route.id, {
68189
+ d: pathWithJumps(route.points, cornerRadius, packed),
68190
+ hitPoints: hitPointsWithJumps(route.points, packed),
68191
+ hopPoints: hopPointGroups(route.points, packed)
68192
+ });
68193
+ }
68194
+ return result;
68195
+ }
68196
+
67937
68197
  // ../common/gantt/drag.ts
67938
68198
  var MIN_TASK_MS = 36e5;
67939
68199
  function applyDragDates(state, deltaX, pxPerDay, snap2) {
@@ -67971,6 +68231,7 @@ function progressFromPointer(pointerX, barLeft, barWidth) {
67971
68231
  }
67972
68232
  var LINK_PORT_R = 3.5;
67973
68233
  var LINK_PASS_PADDING = 6;
68234
+ var LINK_LANE_SPACING = 16;
67974
68235
  var LINK_ELBOW_R = 6;
67975
68236
  var LINK_HEAD = 7;
67976
68237
  var LINK_PORT_CLEAR = LINK_PORT_R + 2.5 + 2;
@@ -68150,6 +68411,7 @@ var LINK_FAN_MAX_SPREAD = 16;
68150
68411
  var LINK_FAN_INSET = 4;
68151
68412
  var LINK_HANDLE_OVERHANG = 4;
68152
68413
  var LINK_RIGHT_GUTTER = 24;
68414
+ var LINK_BOUNDS_PADDING = 8;
68153
68415
  function fanBarHeight(g) {
68154
68416
  return Math.min(g.height, LINK_BAR_HEIGHT);
68155
68417
  }
@@ -68216,7 +68478,7 @@ function fanHandleOffset(barHeight, taken) {
68216
68478
  for (const iv of free) if (iv[1] - iv[0] > best[1] - best[0]) best = iv;
68217
68479
  return (best[0] + best[1]) / 2;
68218
68480
  }
68219
- function alignVerticalChannels(routes, bars) {
68481
+ function allocateVerticalLanes(routes, bars) {
68220
68482
  const chans = [];
68221
68483
  routes.forEach((r, ri) => {
68222
68484
  for (const ch of r.channels) {
@@ -68229,7 +68491,8 @@ function alignVerticalChannels(routes, bars) {
68229
68491
  y1: Math.min(a[1], b[1]),
68230
68492
  y2: Math.max(a[1], b[1]),
68231
68493
  lo: ch.lo,
68232
- hi: ch.hi
68494
+ hi: ch.hi,
68495
+ orderKey: `${r.orderKey}:${ch.seg}`
68233
68496
  });
68234
68497
  }
68235
68498
  });
@@ -68254,36 +68517,23 @@ function alignVerticalChannels(routes, bars) {
68254
68517
  });
68255
68518
  for (const idxs of groups.values()) {
68256
68519
  if (idxs.length < 2) continue;
68257
- const runs = idxs.map((i) => chans[i]);
68258
- const yLo = Math.min(...runs.map((r) => r.y1));
68259
- const yHi = Math.max(...runs.map((r) => r.y2));
68260
- const interLo = Math.max(...runs.map((r) => r.lo));
68261
- const interHi = Math.min(...runs.map((r) => r.hi));
68262
- if (interLo >= interHi) continue;
68263
- if (Math.max(...runs.map((r) => r.x)) - Math.min(...runs.map((r) => r.x)) < 0.5) {
68264
- continue;
68265
- }
68266
- const blocked = blockedIntervals(bars, yLo, yHi, LINK_PASS_PADDING);
68267
- const meanX = runs.reduce((s, r) => s + r.x, 0) / runs.length;
68268
- const merged = clipMerge(interLo, interHi, blocked);
68269
- let targetX = null;
68270
- let bestDist = Infinity;
68271
- for (const [a, b] of merged) {
68272
- for (const cand of [a, b]) {
68273
- if (cand <= interLo || cand >= interHi) continue;
68274
- const d = Math.abs(cand - meanX);
68275
- if (d < bestDist) {
68276
- bestDist = d;
68277
- targetX = cand;
68278
- }
68279
- }
68280
- }
68281
- if (targetX == null) targetX = findClearX(interLo, interHi, meanX, merged);
68282
- if (targetX == null) continue;
68283
- for (const r of runs) {
68284
- const pts = routes[r.route].points;
68285
- pts[r.seg][0] = targetX;
68286
- pts[r.seg + 1][0] = targetX;
68520
+ const runs = idxs.map((i) => chans[i]).sort((a, b) => a.orderKey.localeCompare(b.orderKey));
68521
+ const allocated = [];
68522
+ for (const run of runs) {
68523
+ const barBlocks = blockedIntervals(bars, run.y1, run.y2, LINK_PASS_PADDING);
68524
+ const laneBlocks = allocated.filter((other) => Math.max(run.y1, other.y1) < Math.min(run.y2, other.y2)).map((other) => [
68525
+ other.x - LINK_LANE_SPACING,
68526
+ other.x + LINK_LANE_SPACING
68527
+ ]);
68528
+ const targetX = findClearX(run.lo, run.hi, run.x, [
68529
+ ...barBlocks,
68530
+ ...laneBlocks
68531
+ ]);
68532
+ if (targetX != null) run.x = targetX;
68533
+ const pts = routes[run.route].points;
68534
+ pts[run.seg][0] = run.x;
68535
+ pts[run.seg + 1][0] = run.x;
68536
+ allocated.push(run);
68287
68537
  }
68288
68538
  }
68289
68539
  }
@@ -68297,6 +68547,7 @@ function computeLinkPaths(links, bars, defaultColor) {
68297
68547
  const to = bars.get(link.target);
68298
68548
  if (!from || !to) continue;
68299
68549
  const type = link.type ?? "fs";
68550
+ const orderKey = link.id ?? `${link.source}\0${link.target}\0${type}`;
68300
68551
  const fanSrcY = fan.perLink[li].src;
68301
68552
  const fanTgtY = fan.perLink[li].tgt;
68302
68553
  const fr = from.left + from.width;
@@ -68313,6 +68564,8 @@ function computeLinkPaths(links, bars, defaultColor) {
68313
68564
  }
68314
68565
  const { points, channels, arrow } = routePoints(from, to, fanSrcY, fanTgtY, obstacles);
68315
68566
  routes.push({
68567
+ routeId: `${orderKey}\0${li}`,
68568
+ orderKey,
68316
68569
  link,
68317
68570
  points,
68318
68571
  channels,
@@ -68323,13 +68576,19 @@ function computeLinkPaths(links, bars, defaultColor) {
68323
68576
  type
68324
68577
  });
68325
68578
  }
68326
- alignVerticalChannels(routes, allBars);
68579
+ allocateVerticalLanes(routes, allBars);
68580
+ const crossings = ganttCrossingPaths(
68581
+ routes.map((route) => ({ id: route.routeId, points: route.points })),
68582
+ LINK_ELBOW_R
68583
+ );
68327
68584
  const paths = [];
68328
68585
  for (const r of routes) {
68586
+ const crossing = crossings.get(r.routeId);
68329
68587
  paths.push({
68330
68588
  link: r.link,
68331
- d: roundedPath2(r.points, LINK_ELBOW_R),
68332
- points: r.points,
68589
+ d: crossing?.d ?? roundedPath2(r.points, LINK_ELBOW_R),
68590
+ points: crossing?.hitPoints ?? r.points,
68591
+ hopPoints: crossing?.hopPoints,
68333
68592
  arrow: r.arrow,
68334
68593
  from: r.fromPt,
68335
68594
  to: r.toPt,
@@ -68339,6 +68598,27 @@ function computeLinkPaths(links, bars, defaultColor) {
68339
68598
  }
68340
68599
  return paths;
68341
68600
  }
68601
+ function ganttLinkLayerWidth(paths, timelineWidth) {
68602
+ let furthest = timelineWidth;
68603
+ for (const path of paths) {
68604
+ for (const point of path.points) furthest = Math.max(furthest, point[0]);
68605
+ furthest = Math.max(
68606
+ furthest,
68607
+ path.from.x + LINK_BOUNDS_PADDING,
68608
+ path.to.x + LINK_BOUNDS_PADDING
68609
+ );
68610
+ if (path.arrow) {
68611
+ const values = path.arrow.match(/-?\d+(?:\.\d+)?/g)?.map(Number) ?? [];
68612
+ for (let index = 0; index + 1 < values.length; index += 2) {
68613
+ furthest = Math.max(furthest, values[index]);
68614
+ }
68615
+ }
68616
+ }
68617
+ return Math.max(
68618
+ timelineWidth + LINK_RIGHT_GUTTER,
68619
+ furthest + LINK_BOUNDS_PADDING
68620
+ );
68621
+ }
68342
68622
  function rubberLinkPath(source, px, py, target, obstacles = [], fromOffset = 0) {
68343
68623
  if (target) {
68344
68624
  return linkPath(source, target, "fs", 0, 0, obstacles);
@@ -68386,6 +68666,18 @@ function linkDistance(points, x, y) {
68386
68666
  return best;
68387
68667
  }
68388
68668
  function pickLinkAt(paths, x, y, radius = LINK_HIT_RADIUS) {
68669
+ let hopBest = null;
68670
+ let hopBestDist = Infinity;
68671
+ for (const path of paths) {
68672
+ for (const hop of path.hopPoints ?? []) {
68673
+ const distance = linkDistance(hop, x, y);
68674
+ if (distance <= radius && distance < hopBestDist) {
68675
+ hopBestDist = distance;
68676
+ hopBest = path;
68677
+ }
68678
+ }
68679
+ }
68680
+ if (hopBest) return hopBest;
68389
68681
  let best = null;
68390
68682
  let bestDist = Infinity;
68391
68683
  for (const p of paths) {
@@ -68708,6 +69000,7 @@ var GanttLinkLayer = (0, import_react289.forwardRef)(
68708
69000
  "div",
68709
69001
  {
68710
69002
  ref,
69003
+ "data-gantt-link-layer": true,
68711
69004
  className: "pointer-events-none absolute top-0 z-10",
68712
69005
  style: { left: offsetLeft, width, height },
68713
69006
  children: [
@@ -70232,6 +70525,13 @@ var Gantt = ({
70232
70525
  () => computeLinkPaths(links, liveLinkBars, color),
70233
70526
  [links, liveLinkBars, color]
70234
70527
  );
70528
+ const linkLayerWidth = (0, import_react293.useMemo)(
70529
+ () => ganttLinkLayerWidth(linkPaths, timelineWidth),
70530
+ [linkPaths, timelineWidth]
70531
+ );
70532
+ (0, import_react293.useEffect)(() => {
70533
+ syncHeaderScale();
70534
+ }, [linkLayerWidth, syncHeaderScale]);
70235
70535
  const linkFan = (0, import_react293.useMemo)(() => computeLinkFanOffsets(links, bars), [links, bars]);
70236
70536
  return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
70237
70537
  Panel_default,
@@ -70394,7 +70694,7 @@ var Gantt = ({
70394
70694
  ref: scrollRef,
70395
70695
  className: `gantt-scroller min-h-0 flex-1 overflow-auto overscroll-contain [&::-webkit-scrollbar]:h-1.5 ${THIN_SCROLLBAR}`,
70396
70696
  onScroll: syncHeaderScale,
70397
- children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { style: { width: leftWidth + timelineWidth + LINK_RIGHT_GUTTER, minWidth: "100%" }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(GanttSkeleton, { rows: 12, rowHeight: rowHeight2, leftWidth }) : isEmpty2 ? /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { className: "flex items-center justify-center text-sm text-neutral-500", style: { height: bodyHeight || 160, width: leftWidth + timelineWidth }, children: emptyState ?? allLabels.empty }) : /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)("div", { className: "relative", style: { height: bodyHeight }, children: [
70697
+ children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { style: { width: leftWidth + linkLayerWidth, minWidth: "100%" }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(GanttSkeleton, { rows: 12, rowHeight: rowHeight2, leftWidth }) : isEmpty2 ? /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { className: "flex items-center justify-center text-sm text-neutral-500", style: { height: bodyHeight || 160, width: leftWidth + timelineWidth }, children: emptyState ?? allLabels.empty }) : /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)("div", { className: "relative", style: { height: bodyHeight }, children: [
70398
70698
  /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(
70399
70699
  "div",
70400
70700
  {
@@ -70489,7 +70789,7 @@ var Gantt = ({
70489
70789
  GanttLinkLayer,
70490
70790
  {
70491
70791
  ref: overlayRef,
70492
- width: timelineWidth + LINK_RIGHT_GUTTER,
70792
+ width: linkLayerWidth,
70493
70793
  height: bodyHeight,
70494
70794
  offsetLeft: leftWidth,
70495
70795
  paths: linkPaths,
@@ -70530,7 +70830,7 @@ var Gantt = ({
70530
70830
  style: {
70531
70831
  left: drag.clientX - (drag.grabOffset?.x ?? 0),
70532
70832
  top: drag.clientY - (drag.grabOffset?.y ?? 0),
70533
- width: leftWidth + timelineWidth + LINK_RIGHT_GUTTER
70833
+ width: leftWidth + linkLayerWidth
70534
70834
  },
70535
70835
  children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
70536
70836
  "div",
@@ -77395,6 +77695,7 @@ function NetworkGraph({
77395
77695
  radarPath,
77396
77696
  readAccessor,
77397
77697
  registerEasing,
77698
+ registerIcons,
77398
77699
  relLuminance,
77399
77700
  renderIcon,
77400
77701
  resetI18nProviderWarns,