perfboard-designer-mcp 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +47 -1
  2. package/dist/server.js +1573 -853
  3. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -34,9 +34,9 @@ var __export = (target, all) => {
34
34
  };
35
35
  var __copyProps = (to, from, except, desc) => {
36
36
  if (from && typeof from === "object" || typeof from === "function") {
37
- for (let key5 of __getOwnPropNames(from))
38
- if (!__hasOwnProp.call(to, key5) && key5 !== except)
39
- __defProp(to, key5, { get: () => from[key5], enumerable: !(desc = __getOwnPropDesc(from, key5)) || desc.enumerable });
37
+ for (let key6 of __getOwnPropNames(from))
38
+ if (!__hasOwnProp.call(to, key6) && key6 !== except)
39
+ __defProp(to, key6, { get: () => from[key6], enumerable: !(desc = __getOwnPropDesc(from, key6)) || desc.enumerable });
40
40
  }
41
41
  return to;
42
42
  };
@@ -203,9 +203,9 @@ function assertNever(_x) {
203
203
  }
204
204
  function assert(_2) {
205
205
  }
206
- function getEnumValues(entries) {
207
- const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
208
- const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
206
+ function getEnumValues(entries2) {
207
+ const numericValues = Object.values(entries2).filter((v2) => typeof v2 === "number");
208
+ const values = Object.entries(entries2).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
209
209
  return values;
210
210
  }
211
211
  function joinValues(array2, separator = "|") {
@@ -235,9 +235,9 @@ function floatSafeRemainder(val, step) {
235
235
  return 0;
236
236
  return ratio - roundedRatio;
237
237
  }
238
- function defineLazy(object3, key5, getter) {
238
+ function defineLazy(object3, key6, getter) {
239
239
  let value = void 0;
240
- Object.defineProperty(object3, key5, {
240
+ Object.defineProperty(object3, key6, {
241
241
  get() {
242
242
  if (value === EVALUATING) {
243
243
  return void 0;
@@ -249,7 +249,7 @@ function defineLazy(object3, key5, getter) {
249
249
  return value;
250
250
  },
251
251
  set(v2) {
252
- Object.defineProperty(object3, key5, {
252
+ Object.defineProperty(object3, key6, {
253
253
  value: v2
254
254
  // configurable: true,
255
255
  });
@@ -275,47 +275,47 @@ function rawShape(def) {
275
275
  function sourceShape(schema) {
276
276
  return rawShape(schema._zod.def) ?? schema._zod.def.shape;
277
277
  }
278
- function deferProp(target, key5, getter) {
279
- Object.defineProperty(target, key5, {
278
+ function deferProp(target, key6, getter) {
279
+ Object.defineProperty(target, key6, {
280
280
  get() {
281
281
  const value = getter();
282
- assignProp(this, key5, value);
282
+ assignProp(this, key6, value);
283
283
  return value;
284
284
  },
285
285
  enumerable: true,
286
286
  configurable: true
287
287
  });
288
288
  }
289
- function putProp(target, key5, value) {
290
- if (key5 in target)
291
- assignProp(target, key5, value);
289
+ function putProp(target, key6, value) {
290
+ if (key6 in target)
291
+ assignProp(target, key6, value);
292
292
  else
293
- target[key5] = value;
293
+ target[key6] = value;
294
294
  }
295
295
  function mirrorShape(target, source, keys, wrap) {
296
296
  const raw = sourceShape(source);
297
- for (const key5 of keys) {
298
- const desc = Object.getOwnPropertyDescriptor(raw, key5);
297
+ for (const key6 of keys) {
298
+ const desc = Object.getOwnPropertyDescriptor(raw, key6);
299
299
  if (!desc.enumerable)
300
300
  continue;
301
301
  if (desc.get) {
302
- deferProp(target, key5, () => {
303
- const value = source._zod.def.shape[key5];
304
- return wrap ? wrap(value, key5) : value;
302
+ deferProp(target, key6, () => {
303
+ const value = source._zod.def.shape[key6];
304
+ return wrap ? wrap(value, key6) : value;
305
305
  });
306
306
  } else
307
- putProp(target, key5, wrap ? wrap(desc.value, key5) : desc.value);
307
+ putProp(target, key6, wrap ? wrap(desc.value, key6) : desc.value);
308
308
  }
309
309
  }
310
310
  function mirrorProps(target, source) {
311
- for (const key5 of Reflect.ownKeys(source)) {
312
- const desc = Object.getOwnPropertyDescriptor(source, key5);
311
+ for (const key6 of Reflect.ownKeys(source)) {
312
+ const desc = Object.getOwnPropertyDescriptor(source, key6);
313
313
  if (!desc.enumerable)
314
314
  continue;
315
315
  if (desc.get)
316
- deferProp(target, key5, () => source[key5]);
316
+ deferProp(target, key6, () => source[key6]);
317
317
  else
318
- putProp(target, key5, desc.value);
318
+ putProp(target, key6, desc.value);
319
319
  }
320
320
  }
321
321
  function mergeDefs(...defs) {
@@ -332,11 +332,11 @@ function cloneDef(schema) {
332
332
  function getElementAtPath(obj, path) {
333
333
  if (!path)
334
334
  return obj;
335
- return path.reduce((acc, key5) => acc?.[key5], obj);
335
+ return path.reduce((acc, key6) => acc?.[key6], obj);
336
336
  }
337
337
  function promiseAllObject(promisesObj) {
338
338
  const keys = Object.keys(promisesObj);
339
- const promises = keys.map((key5) => promisesObj[key5]);
339
+ const promises = keys.map((key6) => promisesObj[key6]);
340
340
  return Promise.all(promises).then((results) => {
341
341
  const resolvedObj = {};
342
342
  for (let i = 0; i < keys.length; i++) {
@@ -391,8 +391,8 @@ function shallowClone(o) {
391
391
  }
392
392
  function numKeys(data) {
393
393
  let keyCount = 0;
394
- for (const key5 in data) {
395
- if (Object.prototype.hasOwnProperty.call(data, key5)) {
394
+ for (const key6 in data) {
395
+ if (Object.prototype.hasOwnProperty.call(data, key6)) {
396
396
  keyCount++;
397
397
  }
398
398
  }
@@ -482,12 +482,12 @@ function pick(schema, mask) {
482
482
  function maskedKeys(schema, mask) {
483
483
  const raw = sourceShape(schema);
484
484
  const keys = [];
485
- for (const key5 of Reflect.ownKeys(mask)) {
486
- if (!Object.getOwnPropertyDescriptor(raw, key5)?.enumerable) {
487
- throw new Error(`Unrecognized key: "${String(key5)}"`);
485
+ for (const key6 of Reflect.ownKeys(mask)) {
486
+ if (!Object.getOwnPropertyDescriptor(raw, key6)?.enumerable) {
487
+ throw new Error(`Unrecognized key: "${String(key6)}"`);
488
488
  }
489
- if (mask[key5])
490
- keys.push(key5);
489
+ if (mask[key6])
490
+ keys.push(key6);
491
491
  }
492
492
  return keys;
493
493
  }
@@ -500,7 +500,7 @@ function omit(schema, mask) {
500
500
  }
501
501
  const omitted = new Set(maskedKeys(schema, mask));
502
502
  const newShape = {};
503
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key5) => !omitted.has(key5)));
503
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key6) => !omitted.has(key6)));
504
504
  return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
505
505
  }
506
506
  function extend(schema, shape) {
@@ -511,8 +511,8 @@ function extend(schema, shape) {
511
511
  const hasChecks = checks && checks.length > 0;
512
512
  if (hasChecks) {
513
513
  const existingShape = sourceShape(schema);
514
- for (const key5 of Reflect.ownKeys(shape)) {
515
- if (Object.getOwnPropertyDescriptor(existingShape, key5) !== void 0) {
514
+ for (const key6 of Reflect.ownKeys(shape)) {
515
+ if (Object.getOwnPropertyDescriptor(existingShape, key6) !== void 0) {
516
516
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
517
517
  }
518
518
  }
@@ -559,15 +559,15 @@ function partial(Class2, schema, mask, name = "partial") {
559
559
  }
560
560
  const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
561
561
  const newShape = {};
562
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key5) => selected && !selected.has(key5) ? value : new Class2({ type: "optional", innerType: value })));
562
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key6) => selected && !selected.has(key6) ? value : new Class2({ type: "optional", innerType: value })));
563
563
  return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
564
564
  }
565
565
  function required(Class2, schema, mask) {
566
566
  const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
567
567
  const newShape = {};
568
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key5) => (
568
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key6) => (
569
569
  // overwrite with non-optional
570
- selected && !selected.has(key5) ? value : new Class2({ type: "nonoptional", innerType: value })
570
+ selected && !selected.has(key6) ? value : new Class2({ type: "nonoptional", innerType: value })
571
571
  ));
572
572
  return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
573
573
  }
@@ -749,46 +749,46 @@ function uint8ArrayToHex(bytes) {
749
749
  return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
750
750
  }
751
751
  function members(proto, table) {
752
- for (const key5 in table) {
753
- const desc = Object.getOwnPropertyDescriptor(table, key5);
752
+ for (const key6 in table) {
753
+ const desc = Object.getOwnPropertyDescriptor(table, key6);
754
754
  if (desc.get)
755
- Object.defineProperty(proto, key5, { ...desc, enumerable: false });
755
+ Object.defineProperty(proto, key6, { ...desc, enumerable: false });
756
756
  else
757
- defineBound(proto, key5, desc.value);
757
+ defineBound(proto, key6, desc.value);
758
758
  }
759
759
  }
760
- function own(inst, key5, value, enumerable = true) {
761
- Object.defineProperty(inst, key5, { configurable: true, writable: true, enumerable, value });
760
+ function own(inst, key6, value, enumerable = true) {
761
+ Object.defineProperty(inst, key6, { configurable: true, writable: true, enumerable, value });
762
762
  return value;
763
763
  }
764
- function hide(inst, key5, value) {
765
- return own(inst, key5, value, false);
764
+ function hide(inst, key6, value) {
765
+ return own(inst, key6, value, false);
766
766
  }
767
767
  // @__NO_SIDE_EFFECTS__
768
768
  function derived(computes, table) {
769
- for (const key5 in computes) {
770
- const compute = computes[key5];
771
- Object.defineProperty(table, key5, {
769
+ for (const key6 in computes) {
770
+ const compute = computes[key6];
771
+ Object.defineProperty(table, key6, {
772
772
  configurable: true,
773
773
  enumerable: true,
774
774
  get() {
775
- return own(this, key5, compute(this));
775
+ return own(this, key6, compute(this));
776
776
  },
777
777
  set(value) {
778
- own(this, key5, value);
778
+ own(this, key6, value);
779
779
  }
780
780
  });
781
781
  }
782
782
  return table;
783
783
  }
784
- function defineBound(proto, key5, fn) {
785
- Object.defineProperty(proto, key5, {
784
+ function defineBound(proto, key6, fn) {
785
+ Object.defineProperty(proto, key6, {
786
786
  configurable: true,
787
787
  get() {
788
- return this == null ? fn : own(this, key5, fn.bind(this));
788
+ return this == null ? fn : own(this, key6, fn.bind(this));
789
789
  },
790
790
  set(value) {
791
- own(this, key5, value);
791
+ own(this, key6, value);
792
792
  }
793
793
  });
794
794
  }
@@ -796,53 +796,53 @@ function claim(inst, sentinel) {
796
796
  const proto = Object.getPrototypeOf(inst);
797
797
  return sentinel in proto ? void 0 : proto;
798
798
  }
799
- function defineLazyInternal(inst, key5, compute) {
799
+ function defineLazyInternal(inst, key6, compute) {
800
800
  const proto = Object.getPrototypeOf(inst._zod);
801
- if (key5 in proto && installing !== inst._zod) {
801
+ if (key6 in proto && installing !== inst._zod) {
802
802
  installing = void 0;
803
803
  return;
804
804
  }
805
805
  installing = inst._zod;
806
- Object.defineProperty(proto, key5, {
806
+ Object.defineProperty(proto, key6, {
807
807
  configurable: true,
808
808
  get() {
809
- Object.defineProperty(this, key5, breaker);
809
+ Object.defineProperty(this, key6, breaker);
810
810
  const outer = broke;
811
811
  broke = false;
812
812
  try {
813
813
  const value = compute(this);
814
814
  if (broke)
815
- delete this[key5];
815
+ delete this[key6];
816
816
  else
817
- Object.defineProperty(this, key5, { configurable: true, writable: true, value });
817
+ Object.defineProperty(this, key6, { configurable: true, writable: true, value });
818
818
  broke = broke || outer;
819
819
  return value;
820
820
  } catch (err) {
821
- delete this[key5];
821
+ delete this[key6];
822
822
  broke = broke || outer;
823
823
  throw err;
824
824
  }
825
825
  },
826
826
  set(value) {
827
- Object.defineProperty(this, key5, { configurable: true, writable: true, value });
827
+ Object.defineProperty(this, key6, { configurable: true, writable: true, value });
828
828
  }
829
829
  });
830
830
  }
831
- function installLazyProp(inst, key5, make, enumerable) {
832
- const proto = claim(inst, key5);
831
+ function installLazyProp(inst, key6, make, enumerable) {
832
+ const proto = claim(inst, key6);
833
833
  if (!proto)
834
834
  return;
835
- Object.defineProperty(proto, key5, {
835
+ Object.defineProperty(proto, key6, {
836
836
  configurable: true,
837
837
  get() {
838
838
  const desc = { configurable: true, writable: true, enumerable, value: void 0 };
839
- Object.defineProperty(this, key5, desc);
839
+ Object.defineProperty(this, key6, desc);
840
840
  desc.value = make(this);
841
- Object.defineProperty(this, key5, desc);
841
+ Object.defineProperty(this, key6, desc);
842
842
  return desc.value;
843
843
  },
844
844
  set(value) {
845
- Object.defineProperty(this, key5, { configurable: true, writable: true, enumerable, value });
845
+ Object.defineProperty(this, key6, { configurable: true, writable: true, enumerable, value });
846
846
  }
847
847
  });
848
848
  }
@@ -1110,15 +1110,15 @@ function _getMessage() {
1110
1110
  function _setMessage(value) {
1111
1111
  this._zod.message = value;
1112
1112
  }
1113
- function node(obj, key5, make) {
1114
- if (!Object.prototype.hasOwnProperty.call(obj, key5)) {
1115
- if (key5 === "__proto__") {
1116
- Object.defineProperty(obj, key5, { value: make(), writable: true, enumerable: true, configurable: true });
1113
+ function node(obj, key6, make) {
1114
+ if (!Object.prototype.hasOwnProperty.call(obj, key6)) {
1115
+ if (key6 === "__proto__") {
1116
+ Object.defineProperty(obj, key6, { value: make(), writable: true, enumerable: true, configurable: true });
1117
1117
  } else {
1118
- obj[key5] = make();
1118
+ obj[key6] = make();
1119
1119
  }
1120
1120
  }
1121
- return obj[key5];
1121
+ return obj[key6];
1122
1122
  }
1123
1123
  function flattenError(error62, mapper = (issue2) => issue2.message) {
1124
1124
  const fieldErrors = {};
@@ -2095,22 +2095,22 @@ var init_checks = __esm({
2095
2095
  hide(inst, Symbol.iterator, function* () {
2096
2096
  yield inst;
2097
2097
  });
2098
- let entries;
2098
+ let entries2;
2099
2099
  inst._zod.check = (payload) => {
2100
2100
  if (payload.value == null) {
2101
2101
  payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
2102
2102
  return void 0;
2103
2103
  }
2104
- entries ?? (entries = Reflect.ownKeys(def.shape).map((key5) => [key5, def.shape[key5]]));
2104
+ entries2 ?? (entries2 = Reflect.ownKeys(def.shape).map((key6) => [key6, def.shape[key6]]));
2105
2105
  const input2 = payload.value;
2106
2106
  let proms;
2107
- for (const [key5, schema] of entries) {
2108
- const result = schema._zod.run({ value: input2[key5], issues: [] }, {});
2107
+ for (const [key6, schema] of entries2) {
2108
+ const result = schema._zod.run({ value: input2[key6], issues: [] }, {});
2109
2109
  if (result instanceof Promise) {
2110
2110
  proms ?? (proms = []);
2111
- proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key5)));
2111
+ proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key6)));
2112
2112
  } else {
2113
- handleCheckPropertyResult(result, payload, key5);
2113
+ handleCheckPropertyResult(result, payload, key6);
2114
2114
  }
2115
2115
  }
2116
2116
  if (proms)
@@ -2391,8 +2391,8 @@ function handleArrayResult(result, final, index) {
2391
2391
  }
2392
2392
  final.value[index] = result.value;
2393
2393
  }
2394
- function handlePropertyResult(result, final, key5, input2, optin, optout) {
2395
- const isPresent = key5 in input2;
2394
+ function handlePropertyResult(result, final, key6, input2, optin, optout) {
2395
+ const isPresent = key6 in input2;
2396
2396
  const isOptionalOut = optout === "optional";
2397
2397
  if (!isPresent && isOptionalOut && optin === "optional") {
2398
2398
  return;
@@ -2401,7 +2401,7 @@ function handlePropertyResult(result, final, key5, input2, optin, optout) {
2401
2401
  if (optin !== void 0 && isOptionalOut && !isPresent) {
2402
2402
  return;
2403
2403
  }
2404
- final.issues.push(...prefixIssues(key5, result.issues));
2404
+ final.issues.push(...prefixIssues(key6, result.issues));
2405
2405
  }
2406
2406
  if (!isPresent && optin === void 0) {
2407
2407
  if (!result.issues.length) {
@@ -2409,17 +2409,17 @@ function handlePropertyResult(result, final, key5, input2, optin, optout) {
2409
2409
  code: "invalid_type",
2410
2410
  expected: "nonoptional",
2411
2411
  input: void 0,
2412
- path: [key5]
2412
+ path: [key6]
2413
2413
  });
2414
2414
  }
2415
2415
  return;
2416
2416
  }
2417
2417
  if (result.value === void 0) {
2418
2418
  if (isPresent || optin === "defaulted" && !isOptionalOut) {
2419
- final.value[key5] = void 0;
2419
+ final.value[key6] = void 0;
2420
2420
  }
2421
2421
  } else {
2422
- final.value[key5] = result.value;
2422
+ final.value[key6] = result.value;
2423
2423
  }
2424
2424
  }
2425
2425
  function normalizeDef(def) {
@@ -2451,28 +2451,28 @@ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
2451
2451
  const optin = _catchall.optin;
2452
2452
  const optout = _catchall.optout;
2453
2453
  let seen = 0;
2454
- for (const key5 in input2) {
2454
+ for (const key6 in input2) {
2455
2455
  if (abortEarly && payload.issues.length !== seen) {
2456
2456
  if (aborted(payload, seen))
2457
2457
  break;
2458
2458
  seen = payload.issues.length;
2459
2459
  }
2460
- if (keySet.has(key5))
2460
+ if (keySet.has(key6))
2461
2461
  continue;
2462
- if (key5 === "__proto__") {
2462
+ if (key6 === "__proto__") {
2463
2463
  if (t === "never")
2464
- unrecognized.push(key5);
2464
+ unrecognized.push(key6);
2465
2465
  continue;
2466
2466
  }
2467
2467
  if (t === "never") {
2468
- unrecognized.push(key5);
2468
+ unrecognized.push(key6);
2469
2469
  continue;
2470
2470
  }
2471
- const r2 = _catchall.run({ value: input2[key5], issues: [] }, ctx);
2471
+ const r2 = _catchall.run({ value: input2[key6], issues: [] }, ctx);
2472
2472
  if (r2 instanceof Promise) {
2473
- proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key5, input2, optin, optout)));
2473
+ proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key6, input2, optin, optout)));
2474
2474
  } else {
2475
- handlePropertyResult(r2, payload, key5, input2, optin, optout);
2475
+ handlePropertyResult(r2, payload, key6, input2, optin, optout);
2476
2476
  }
2477
2477
  }
2478
2478
  if (unrecognized.length) {
@@ -2579,21 +2579,21 @@ function mergeValues(a, b) {
2579
2579
  }
2580
2580
  if (isPlainObject(a) && isPlainObject(b)) {
2581
2581
  const bKeys = Object.keys(b);
2582
- const sharedKeys = Object.keys(a).filter((key5) => bKeys.indexOf(key5) !== -1);
2582
+ const sharedKeys = Object.keys(a).filter((key6) => bKeys.indexOf(key6) !== -1);
2583
2583
  const newObj = { ...a, ...b };
2584
2584
  if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
2585
2585
  delete newObj.__proto__;
2586
- for (const key5 of sharedKeys) {
2587
- if (key5 === "__proto__")
2586
+ for (const key6 of sharedKeys) {
2587
+ if (key6 === "__proto__")
2588
2588
  continue;
2589
- const sharedValue = mergeValues(a[key5], b[key5]);
2589
+ const sharedValue = mergeValues(a[key6], b[key6]);
2590
2590
  if (!sharedValue.valid) {
2591
2591
  return {
2592
2592
  valid: false,
2593
- mergeErrorPath: [key5, ...sharedValue.mergeErrorPath]
2593
+ mergeErrorPath: [key6, ...sharedValue.mergeErrorPath]
2594
2594
  };
2595
2595
  }
2596
- newObj[key5] = sharedValue.data;
2596
+ newObj[key6] = sharedValue.data;
2597
2597
  }
2598
2598
  return { valid: true, data: newObj };
2599
2599
  }
@@ -2669,9 +2669,9 @@ function handleIntersectionResults(result, left, right) {
2669
2669
  result.value = merged.data;
2670
2670
  return result;
2671
2671
  }
2672
- function getTupleOptStart(items, key5) {
2672
+ function getTupleOptStart(items, key6) {
2673
2673
  for (let i = items.length - 1; i >= 0; i--) {
2674
- const omittable = key5 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
2674
+ const omittable = key6 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
2675
2675
  if (!omittable)
2676
2676
  return i + 1;
2677
2677
  }
@@ -2709,10 +2709,10 @@ function handleTupleResults(itemResults, final, items, input2, optoutStart) {
2709
2709
  }
2710
2710
  return final;
2711
2711
  }
2712
- function handleMapResult(keyResult, valueResult, final, key5, input2, inst, ctx) {
2712
+ function handleMapResult(keyResult, valueResult, final, key6, input2, inst, ctx) {
2713
2713
  if (keyResult.issues.length) {
2714
- if (propertyKeyTypes.has(typeof key5)) {
2715
- final.issues.push(...prefixIssues(key5, keyResult.issues));
2714
+ if (propertyKeyTypes.has(typeof key6)) {
2715
+ final.issues.push(...prefixIssues(key6, keyResult.issues));
2716
2716
  } else {
2717
2717
  final.issues.push({
2718
2718
  code: "invalid_key",
@@ -2724,15 +2724,15 @@ function handleMapResult(keyResult, valueResult, final, key5, input2, inst, ctx)
2724
2724
  }
2725
2725
  }
2726
2726
  if (valueResult.issues.length) {
2727
- if (propertyKeyTypes.has(typeof key5)) {
2728
- final.issues.push(...prefixIssues(key5, valueResult.issues));
2727
+ if (propertyKeyTypes.has(typeof key6)) {
2728
+ final.issues.push(...prefixIssues(key6, valueResult.issues));
2729
2729
  } else {
2730
2730
  final.issues.push({
2731
2731
  origin: "map",
2732
2732
  code: "invalid_element",
2733
2733
  input: input2,
2734
2734
  inst,
2735
- key: key5,
2735
+ key: key6,
2736
2736
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
2737
2737
  });
2738
2738
  }
@@ -3556,16 +3556,16 @@ var init_schemas = __esm({
3556
3556
  defineLazyInternal(inst, "propValues", (zod) => {
3557
3557
  const shape = zod.def.shape;
3558
3558
  const propValues = {};
3559
- for (const key5 in shape) {
3560
- const field = shape[key5]._zod;
3559
+ for (const key6 in shape) {
3560
+ const field = shape[key6]._zod;
3561
3561
  if (field.values) {
3562
- if (!Object.prototype.hasOwnProperty.call(propValues, key5)) {
3563
- assignProp(propValues, key5, /* @__PURE__ */ new Set());
3562
+ if (!Object.prototype.hasOwnProperty.call(propValues, key6)) {
3563
+ assignProp(propValues, key6, /* @__PURE__ */ new Set());
3564
3564
  }
3565
3565
  for (const v2 of field.values)
3566
- propValues[key5].add(v2);
3566
+ propValues[key6].add(v2);
3567
3567
  if (field.optin !== void 0)
3568
- propValues[key5].add(void 0);
3568
+ propValues[key6].add(void 0);
3569
3569
  }
3570
3570
  }
3571
3571
  return propValues;
@@ -3592,22 +3592,22 @@ var init_schemas = __esm({
3592
3592
  const shape = value.shape;
3593
3593
  const abortEarly = ctx?.abortEarly;
3594
3594
  let seen = payload.issues.length;
3595
- for (const key5 of value.allKeys) {
3595
+ for (const key6 of value.allKeys) {
3596
3596
  if (abortEarly && payload.issues.length !== seen) {
3597
3597
  if (aborted(payload, seen))
3598
3598
  break;
3599
3599
  seen = payload.issues.length;
3600
3600
  }
3601
- if (key5 === "__proto__")
3601
+ if (key6 === "__proto__")
3602
3602
  continue;
3603
- const el = shape[key5];
3603
+ const el = shape[key6];
3604
3604
  const optin = el._zod.optin;
3605
3605
  const optout = el._zod.optout;
3606
- const r2 = el._zod.run({ value: input2[key5], issues: [] }, ctx);
3606
+ const r2 = el._zod.run({ value: input2[key6], issues: [] }, ctx);
3607
3607
  if (r2 instanceof Promise) {
3608
- proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key5, input2, optin, optout)));
3608
+ proms.push(r2.then((r3) => handlePropertyResult(r3, payload, key6, input2, optin, optout)));
3609
3609
  } else {
3610
- handlePropertyResult(r2, payload, key5, input2, optin, optout);
3610
+ handlePropertyResult(r2, payload, key6, input2, optin, optout);
3611
3611
  }
3612
3612
  }
3613
3613
  if (!catchall) {
@@ -3641,17 +3641,17 @@ var init_schemas = __esm({
3641
3641
  doc.write(`const input = payload.value;`);
3642
3642
  const ids = /* @__PURE__ */ Object.create(null);
3643
3643
  let counter = 0;
3644
- for (const key5 of normalized.allKeys) {
3645
- ids[key5] = `key_${counter++}`;
3644
+ for (const key6 of normalized.allKeys) {
3645
+ ids[key6] = `key_${counter++}`;
3646
3646
  }
3647
3647
  doc.write(memo2 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
3648
- for (const key5 of normalized.allKeys) {
3649
- if (key5 === "__proto__")
3648
+ for (const key6 of normalized.allKeys) {
3649
+ if (key6 === "__proto__")
3650
3650
  continue;
3651
- const id = ids[key5];
3652
- const k2 = typeof key5 === "symbol" ? `syms[${syms.indexOf(key5)}]` : esc(key5);
3651
+ const id = ids[key6];
3652
+ const k2 = typeof key6 === "symbol" ? `syms[${syms.indexOf(key6)}]` : esc(key6);
3653
3653
  const isPresent = `${k2} in input`;
3654
- const schema = shape[key5];
3654
+ const schema = shape[key6];
3655
3655
  const optin = schema?._zod?.optin;
3656
3656
  const isOptionalIn = optin !== void 0;
3657
3657
  const isOptionalOut = schema?._zod?.optout === "optional";
@@ -4000,12 +4000,12 @@ var init_schemas = __esm({
4000
4000
  if (values && !def.partial) {
4001
4001
  payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
4002
4002
  const recordKeys = /* @__PURE__ */ new Set();
4003
- for (const key5 of values) {
4004
- if (typeof key5 === "string" || typeof key5 === "number" || typeof key5 === "symbol") {
4005
- recordKeys.add(typeof key5 === "number" ? key5.toString() : key5);
4006
- if (key5 === "__proto__")
4003
+ for (const key6 of values) {
4004
+ if (typeof key6 === "string" || typeof key6 === "number" || typeof key6 === "symbol") {
4005
+ recordKeys.add(typeof key6 === "number" ? key6.toString() : key6);
4006
+ if (key6 === "__proto__")
4007
4007
  continue;
4008
- const keyResult = def.keyType._zod.run({ value: key5, issues: [] }, ctx);
4008
+ const keyResult = def.keyType._zod.run({ value: key6, issues: [] }, ctx);
4009
4009
  if (keyResult instanceof Promise) {
4010
4010
  throw new Error("Async schemas not supported in object keys currently");
4011
4011
  }
@@ -4014,8 +4014,8 @@ var init_schemas = __esm({
4014
4014
  code: "invalid_key",
4015
4015
  origin: "record",
4016
4016
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
4017
- input: key5,
4018
- path: [key5],
4017
+ input: key6,
4018
+ path: [key6],
4019
4019
  inst
4020
4020
  });
4021
4021
  continue;
@@ -4023,32 +4023,32 @@ var init_schemas = __esm({
4023
4023
  const outKey = keyResult.value;
4024
4024
  if (outKey === "__proto__")
4025
4025
  continue;
4026
- const result = def.valueType._zod.run({ value: input2[key5], issues: [] }, ctx);
4026
+ const result = def.valueType._zod.run({ value: input2[key6], issues: [] }, ctx);
4027
4027
  if (result instanceof Promise) {
4028
4028
  proms.push(result.then((result2) => {
4029
4029
  if (result2.issues.length) {
4030
- payload.issues.push(...prefixIssues(key5, result2.issues));
4030
+ payload.issues.push(...prefixIssues(key6, result2.issues));
4031
4031
  }
4032
4032
  payload.value[outKey] = result2.value;
4033
4033
  }));
4034
4034
  } else {
4035
4035
  if (result.issues.length) {
4036
- payload.issues.push(...prefixIssues(key5, result.issues));
4036
+ payload.issues.push(...prefixIssues(key6, result.issues));
4037
4037
  }
4038
4038
  payload.value[outKey] = result.value;
4039
4039
  }
4040
4040
  }
4041
4041
  }
4042
4042
  let unrecognized;
4043
- for (const key5 in input2) {
4044
- if (!recordKeys.has(key5)) {
4043
+ for (const key6 in input2) {
4044
+ if (!recordKeys.has(key6)) {
4045
4045
  if (def.mode === "loose") {
4046
- if (key5 === "__proto__")
4046
+ if (key6 === "__proto__")
4047
4047
  continue;
4048
- payload.value[key5] = input2[key5];
4048
+ payload.value[key6] = input2[key6];
4049
4049
  } else {
4050
4050
  unrecognized = unrecognized ?? [];
4051
- unrecognized.push(key5);
4051
+ unrecognized.push(key6);
4052
4052
  }
4053
4053
  }
4054
4054
  }
@@ -4064,18 +4064,18 @@ var init_schemas = __esm({
4064
4064
  } else {
4065
4065
  payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
4066
4066
  let unrecognized;
4067
- for (const key5 of Reflect.ownKeys(input2)) {
4068
- if (key5 === "__proto__")
4067
+ for (const key6 of Reflect.ownKeys(input2)) {
4068
+ if (key6 === "__proto__")
4069
4069
  continue;
4070
- if (!Object.prototype.propertyIsEnumerable.call(input2, key5))
4070
+ if (!Object.prototype.propertyIsEnumerable.call(input2, key6))
4071
4071
  continue;
4072
- let keyResult = def.keyType._zod.run({ value: key5, issues: [] }, ctx);
4072
+ let keyResult = def.keyType._zod.run({ value: key6, issues: [] }, ctx);
4073
4073
  if (keyResult instanceof Promise) {
4074
4074
  throw new Error("Async schemas not supported in object keys currently");
4075
4075
  }
4076
- const checkNumericKey = typeof key5 === "string" && number.test(key5) && keyResult.issues.length;
4076
+ const checkNumericKey = typeof key6 === "string" && number.test(key6) && keyResult.issues.length;
4077
4077
  if (checkNumericKey) {
4078
- const retryResult = def.keyType._zod.run({ value: Number(key5), issues: [] }, ctx);
4078
+ const retryResult = def.keyType._zod.run({ value: Number(key6), issues: [] }, ctx);
4079
4079
  if (retryResult instanceof Promise) {
4080
4080
  throw new Error("Async schemas not supported in object keys currently");
4081
4081
  }
@@ -4085,17 +4085,17 @@ var init_schemas = __esm({
4085
4085
  }
4086
4086
  if (keyResult.issues.length) {
4087
4087
  if (def.mode === "loose") {
4088
- payload.value[key5] = input2[key5];
4088
+ payload.value[key6] = input2[key6];
4089
4089
  } else if (values) {
4090
4090
  unrecognized = unrecognized ?? [];
4091
- unrecognized.push(key5);
4091
+ unrecognized.push(key6);
4092
4092
  } else {
4093
4093
  payload.issues.push({
4094
4094
  code: "invalid_key",
4095
4095
  origin: "record",
4096
4096
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
4097
- input: key5,
4098
- path: [key5],
4097
+ input: key6,
4098
+ path: [key6],
4099
4099
  inst
4100
4100
  });
4101
4101
  }
@@ -4104,17 +4104,17 @@ var init_schemas = __esm({
4104
4104
  const outKey = keyResult.value;
4105
4105
  if (outKey === "__proto__")
4106
4106
  continue;
4107
- const result = def.valueType._zod.run({ value: input2[key5], issues: [] }, ctx);
4107
+ const result = def.valueType._zod.run({ value: input2[key6], issues: [] }, ctx);
4108
4108
  if (result instanceof Promise) {
4109
4109
  proms.push(result.then((result2) => {
4110
4110
  if (result2.issues.length) {
4111
- payload.issues.push(...prefixIssues(key5, result2.issues));
4111
+ payload.issues.push(...prefixIssues(key6, result2.issues));
4112
4112
  }
4113
4113
  payload.value[outKey] = result2.value;
4114
4114
  }));
4115
4115
  } else {
4116
4116
  if (result.issues.length) {
4117
- payload.issues.push(...prefixIssues(key5, result.issues));
4117
+ payload.issues.push(...prefixIssues(key6, result.issues));
4118
4118
  }
4119
4119
  payload.value[outKey] = result.value;
4120
4120
  }
@@ -4154,20 +4154,20 @@ var init_schemas = __esm({
4154
4154
  payload.value = memo2 ? memo2.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
4155
4155
  const abortEarly = ctx?.abortEarly;
4156
4156
  let seen = payload.issues.length;
4157
- for (const [key5, value] of input2) {
4157
+ for (const [key6, value] of input2) {
4158
4158
  if (abortEarly && payload.issues.length !== seen) {
4159
4159
  if (aborted(payload, seen))
4160
4160
  break;
4161
4161
  seen = payload.issues.length;
4162
4162
  }
4163
- const keyResult = def.keyType._zod.run({ value: key5, issues: [] }, ctx);
4163
+ const keyResult = def.keyType._zod.run({ value: key6, issues: [] }, ctx);
4164
4164
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
4165
4165
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
4166
4166
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
4167
- handleMapResult(keyResult2, valueResult2, payload, key5, input2, inst, ctx);
4167
+ handleMapResult(keyResult2, valueResult2, payload, key6, input2, inst, ctx);
4168
4168
  }));
4169
4169
  } else {
4170
- handleMapResult(keyResult, valueResult, payload, key5, input2, inst, ctx);
4170
+ handleMapResult(keyResult, valueResult, payload, key6, input2, inst, ctx);
4171
4171
  }
4172
4172
  }
4173
4173
  if (proms.length)
@@ -4688,8 +4688,8 @@ function isRecursive(inst, stack, resolve) {
4688
4688
  };
4689
4689
  const shape = (sh, spread) => {
4690
4690
  let answer = NONE;
4691
- for (const key5 of Reflect.ownKeys(sh)) {
4692
- const desc = Object.getOwnPropertyDescriptor(sh, key5);
4691
+ for (const key6 of Reflect.ownKeys(sh)) {
4692
+ const desc = Object.getOwnPropertyDescriptor(sh, key6);
4693
4693
  if (spread && !desc.enumerable)
4694
4694
  continue;
4695
4695
  const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
@@ -4785,8 +4785,8 @@ function isRecursive(inst, stack, resolve) {
4785
4785
  break;
4786
4786
  default: {
4787
4787
  kind;
4788
- for (const key5 in def) {
4789
- const desc = Object.getOwnPropertyDescriptor(def, key5);
4788
+ for (const key6 in def) {
4789
+ const desc = Object.getOwnPropertyDescriptor(def, key6);
4790
4790
  if (!desc || desc.get)
4791
4791
  continue;
4792
4792
  const value = desc.value;
@@ -13558,11 +13558,11 @@ function generatePropertiesChecks(doc, ctx, def, accessor) {
13558
13558
  }
13559
13559
  doc.write(`if (${accessor} == null) return INVALID;`);
13560
13560
  const shape = def.shape;
13561
- for (const key5 of Reflect.ownKeys(shape)) {
13562
- const keyExpr = typeof key5 === "symbol" ? addConstant(ctx, key5) : esc(key5);
13561
+ for (const key6 of Reflect.ownKeys(shape)) {
13562
+ const keyExpr = typeof key6 === "symbol" ? addConstant(ctx, key6) : esc(key6);
13563
13563
  const inputVar = newVar(ctx);
13564
13564
  doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
13565
- compileChild(doc, ctx, shape[key5], inputVar, false);
13565
+ compileChild(doc, ctx, shape[key6], inputVar, false);
13566
13566
  }
13567
13567
  }
13568
13568
  function generatePropertyCheck(doc, ctx, def, accessor) {
@@ -13929,9 +13929,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
13929
13929
  throw new ZodCompileUnsupportedError('object shape key "__proto__"');
13930
13930
  }
13931
13931
  const propOutputs = /* @__PURE__ */ new Map();
13932
- for (const key5 of allKeys) {
13933
- const propSchema = propShape[key5];
13934
- const kx = keyExpr(key5);
13932
+ for (const key6 of allKeys) {
13933
+ const propSchema = propShape[key6];
13934
+ const kx = keyExpr(key6);
13935
13935
  const inputVar = newVar(ctx);
13936
13936
  doc.write(`const ${inputVar} = ${accessor}[${kx}];`);
13937
13937
  if (propSchema._zod.optin !== void 0) {
@@ -13952,14 +13952,14 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
13952
13952
  } else {
13953
13953
  doc.write(`if (${outputVar2} === INVALID) return INVALID;`);
13954
13954
  }
13955
- propOutputs.set(key5, outputVar2);
13955
+ propOutputs.set(key6, outputVar2);
13956
13956
  } else {
13957
13957
  if (requiresPresenceCheck(propSchema)) {
13958
13958
  doc.write(`if (!(${kx} in ${accessor})) return INVALID;`);
13959
13959
  }
13960
13960
  const outputAccessor = compileChild(doc, ctx, propSchema, inputVar, buildsValue);
13961
13961
  if (outputAccessor !== null)
13962
- propOutputs.set(key5, outputAccessor);
13962
+ propOutputs.set(key6, outputAccessor);
13963
13963
  }
13964
13964
  }
13965
13965
  const catchall = def.catchall;
@@ -14380,9 +14380,9 @@ function generateTupleCheck(doc, ctx, schema, accessor) {
14380
14380
  }
14381
14381
  return outputVar;
14382
14382
  }
14383
- function getTupleOptStart2(items, key5) {
14383
+ function getTupleOptStart2(items, key6) {
14384
14384
  for (let i = items.length - 1; i >= 0; i--) {
14385
- const omittable = key5 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
14385
+ const omittable = key6 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
14386
14386
  if (!omittable)
14387
14387
  return i + 1;
14388
14388
  }
@@ -14512,16 +14512,16 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
14512
14512
  const keyValues = recordDef.partial ? void 0 : def.keyType._zod.values;
14513
14513
  if (keyValues) {
14514
14514
  const inputKeys = [];
14515
- for (const key5 of keyValues) {
14516
- if (!(typeof key5 === "string" || typeof key5 === "number" || typeof key5 === "symbol")) {
14517
- throw new ZodCompileUnsupportedError(`record key value ${String(key5)}`);
14515
+ for (const key6 of keyValues) {
14516
+ if (!(typeof key6 === "string" || typeof key6 === "number" || typeof key6 === "symbol")) {
14517
+ throw new ZodCompileUnsupportedError(`record key value ${String(key6)}`);
14518
14518
  }
14519
- const inputKey = typeof key5 === "number" ? key5.toString() : key5;
14519
+ const inputKey = typeof key6 === "number" ? key6.toString() : key6;
14520
14520
  if (inputKey === "__proto__") {
14521
14521
  throw new ZodCompileUnsupportedError('record key "__proto__"');
14522
14522
  }
14523
14523
  inputKeys.push(inputKey);
14524
- const keyConst = addConstant(ctx, key5);
14524
+ const keyConst = addConstant(ctx, key6);
14525
14525
  const outKey = generateCheck(doc, ctx, def.keyType, keyConst);
14526
14526
  const valueVar = newVar(ctx);
14527
14527
  doc.write(`const ${valueVar} = ${accessor}[${literalPropertyKey(ctx, inputKey)}];`);
@@ -14599,10 +14599,10 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
14599
14599
  });
14600
14600
  doc.write(`}`);
14601
14601
  }
14602
- function literalPropertyKey(ctx, key5) {
14603
- if (typeof key5 === "string")
14604
- return esc(key5);
14605
- return addConstant(ctx, key5);
14602
+ function literalPropertyKey(ctx, key6) {
14603
+ if (typeof key6 === "string")
14604
+ return esc(key6);
14605
+ return addConstant(ctx, key6);
14606
14606
  }
14607
14607
  function generateMapCheck(doc, ctx, schema, accessor) {
14608
14608
  const def = schema._zod.def;
@@ -15613,18 +15613,18 @@ function _set(Class2, valueType, params) {
15613
15613
  }
15614
15614
  // @__NO_SIDE_EFFECTS__
15615
15615
  function _enum(Class2, values, params) {
15616
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
15616
+ const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
15617
15617
  return new Class2({
15618
15618
  type: "enum",
15619
- entries,
15619
+ entries: entries2,
15620
15620
  ...normalizeParams(params)
15621
15621
  });
15622
15622
  }
15623
15623
  // @__NO_SIDE_EFFECTS__
15624
- function _nativeEnum(Class2, entries, params) {
15624
+ function _nativeEnum(Class2, entries2, params) {
15625
15625
  return new Class2({
15626
15626
  type: "enum",
15627
- entries,
15627
+ entries: entries2,
15628
15628
  ...normalizeParams(params)
15629
15629
  });
15630
15630
  }
@@ -15906,9 +15906,9 @@ var init_api = __esm({
15906
15906
  // node_modules/zod/v4/core/to-json-schema.js
15907
15907
  function assignProps(target, ...sources) {
15908
15908
  for (const source of sources) {
15909
- for (const key5 of Reflect.ownKeys(source)) {
15910
- if (Object.prototype.propertyIsEnumerable.call(source, key5)) {
15911
- assignProp(target, key5, source[key5]);
15909
+ for (const key6 of Reflect.ownKeys(source)) {
15910
+ if (Object.prototype.propertyIsEnumerable.call(source, key6)) {
15911
+ assignProp(target, key6, source[key6]);
15912
15912
  }
15913
15913
  }
15914
15914
  }
@@ -16054,8 +16054,8 @@ function extractDefs(ctx, schema) {
16054
16054
  if (defId)
16055
16055
  seen.defId = defId;
16056
16056
  const schema2 = seen.schema;
16057
- for (const key5 in schema2) {
16058
- delete schema2[key5];
16057
+ for (const key6 in schema2) {
16058
+ delete schema2[key6];
16059
16059
  }
16060
16060
  schema2.$ref = ref;
16061
16061
  };
@@ -16134,8 +16134,8 @@ function foldObjects(members2) {
16134
16134
  for (const member of members2) {
16135
16135
  if (typeof member !== "object" || member.type !== "object")
16136
16136
  return null;
16137
- for (const key5 in member) {
16138
- if (!FOLDABLE_KEYS.has(key5))
16137
+ for (const key6 in member) {
16138
+ if (!FOLDABLE_KEYS.has(key6))
16139
16139
  return null;
16140
16140
  }
16141
16141
  objects.push(member);
@@ -16143,22 +16143,22 @@ function foldObjects(members2) {
16143
16143
  const properties = {};
16144
16144
  const required2 = /* @__PURE__ */ new Set();
16145
16145
  for (const object3 of objects) {
16146
- for (const key5 in object3.properties) {
16147
- if (Object.prototype.hasOwnProperty.call(properties, key5))
16146
+ for (const key6 in object3.properties) {
16147
+ if (Object.prototype.hasOwnProperty.call(properties, key6))
16148
16148
  continue;
16149
16149
  const parts = [];
16150
16150
  for (const other of objects) {
16151
- const part = other.properties?.[key5] ?? undeclaredConstraint(other);
16151
+ const part = other.properties?.[key6] ?? undeclaredConstraint(other);
16152
16152
  if (part === null || part === void 0)
16153
16153
  continue;
16154
16154
  if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))
16155
16155
  parts.push(part);
16156
16156
  }
16157
16157
  const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
16158
- assignProp(properties, key5, merged);
16158
+ assignProp(properties, key6, merged);
16159
16159
  }
16160
- for (const key5 of object3.required ?? [])
16161
- required2.add(key5);
16160
+ for (const key6 of object3.required ?? [])
16161
+ required2.add(key6);
16162
16162
  }
16163
16163
  const folded = { type: "object", properties };
16164
16164
  if (required2.size)
@@ -16183,8 +16183,8 @@ function foldIntersection(json3) {
16183
16183
  const allOf = json3.allOf;
16184
16184
  if (!Array.isArray(allOf) || allOf.length < 2)
16185
16185
  return;
16186
- for (const key5 of FOLDABLE_KEYS)
16187
- if (key5 in json3)
16186
+ for (const key6 of FOLDABLE_KEYS)
16187
+ if (key6 in json3)
16188
16188
  return;
16189
16189
  const unions = allOf.filter((m2) => UNION_KEYS.some((k2) => Array.isArray(m2[k2])));
16190
16190
  let folded = null;
@@ -16231,20 +16231,20 @@ function finalize(ctx, schema) {
16231
16231
  assignProps(schema2, _cached);
16232
16232
  const isParentRef = zodSchema._zod.parent === ref;
16233
16233
  if (isParentRef) {
16234
- for (const key5 in schema2) {
16235
- if (key5 === "$ref" || key5 === "allOf")
16234
+ for (const key6 in schema2) {
16235
+ if (key6 === "$ref" || key6 === "allOf")
16236
16236
  continue;
16237
- if (!(key5 in _cached)) {
16238
- delete schema2[key5];
16237
+ if (!(key6 in _cached)) {
16238
+ delete schema2[key6];
16239
16239
  }
16240
16240
  }
16241
16241
  }
16242
16242
  if (refSchema.$ref && refSeen.def) {
16243
- for (const key5 in schema2) {
16244
- if (key5 === "$ref" || key5 === "allOf")
16243
+ for (const key6 in schema2) {
16244
+ if (key6 === "$ref" || key6 === "allOf")
16245
16245
  continue;
16246
- if (key5 in refSeen.def && JSON.stringify(schema2[key5]) === JSON.stringify(refSeen.def[key5])) {
16247
- delete schema2[key5];
16246
+ if (key6 in refSeen.def && JSON.stringify(schema2[key6]) === JSON.stringify(refSeen.def[key6])) {
16247
+ delete schema2[key6];
16248
16248
  }
16249
16249
  }
16250
16250
  }
@@ -16256,11 +16256,11 @@ function finalize(ctx, schema) {
16256
16256
  if (parentSeen?.schema.$ref) {
16257
16257
  schema2.$ref = parentSeen.schema.$ref;
16258
16258
  if (parentSeen.def) {
16259
- for (const key5 in schema2) {
16260
- if (key5 === "$ref" || key5 === "allOf")
16259
+ for (const key6 in schema2) {
16260
+ if (key6 === "$ref" || key6 === "allOf")
16261
16261
  continue;
16262
- if (key5 in parentSeen.def && JSON.stringify(schema2[key5]) === JSON.stringify(parentSeen.def[key5])) {
16263
- delete schema2[key5];
16262
+ if (key6 in parentSeen.def && JSON.stringify(schema2[key6]) === JSON.stringify(parentSeen.def[key6])) {
16263
+ delete schema2[key6];
16264
16264
  }
16265
16265
  }
16266
16266
  }
@@ -16393,8 +16393,8 @@ function isTransforming(_schema, _ctx) {
16393
16393
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
16394
16394
  }
16395
16395
  if (def.type === "object") {
16396
- for (const key5 in def.shape) {
16397
- if (isTransforming(def.shape[key5], ctx))
16396
+ for (const key6 in def.shape) {
16397
+ if (isTransforming(def.shape[key6], ctx))
16398
16398
  return true;
16399
16399
  }
16400
16400
  return false;
@@ -16574,9 +16574,9 @@ function toJSONSchema(input2, params) {
16574
16574
  };
16575
16575
  ctx2.external = external;
16576
16576
  for (const entry of registry2._idmap.entries()) {
16577
- const [key5, schema] = entry;
16577
+ const [key6, schema] = entry;
16578
16578
  extractDefs(ctx2, schema);
16579
- assignProp(schemas, key5, finalize(ctx2, schema));
16579
+ assignProp(schemas, key6, finalize(ctx2, schema));
16580
16580
  }
16581
16581
  if (Object.keys(defs).length > 0) {
16582
16582
  const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
@@ -16601,13 +16601,13 @@ var init_json_schema_processors = __esm({
16601
16601
  init_schemas();
16602
16602
  init_to_json_schema();
16603
16603
  init_util();
16604
- narrowMin = (agg, key5, value) => {
16605
- if (agg[key5] === void 0 || value > agg[key5])
16606
- agg[key5] = value;
16604
+ narrowMin = (agg, key6, value) => {
16605
+ if (agg[key6] === void 0 || value > agg[key6])
16606
+ agg[key6] = value;
16607
16607
  };
16608
- narrowMax = (agg, key5, value) => {
16609
- if (agg[key5] === void 0 || value < agg[key5])
16610
- agg[key5] = value;
16608
+ narrowMax = (agg, key6, value) => {
16609
+ if (agg[key6] === void 0 || value < agg[key6])
16610
+ agg[key6] = value;
16611
16611
  };
16612
16612
  narrowBoth = (agg, value) => {
16613
16613
  narrowMin(agg, "minimum", value);
@@ -16907,17 +16907,17 @@ var init_json_schema_processors = __esm({
16907
16907
  }
16908
16908
  json3.type = "object";
16909
16909
  json3.properties = {};
16910
- for (const key5 in shape) {
16911
- assignProp(json3.properties, key5, processSchema(shape[key5], ctx, {
16910
+ for (const key6 in shape) {
16911
+ assignProp(json3.properties, key6, processSchema(shape[key6], ctx, {
16912
16912
  ...params,
16913
- path: [...params.path, "properties", key5]
16913
+ path: [...params.path, "properties", key6]
16914
16914
  }));
16915
16915
  }
16916
16916
  const requiredKeys = [];
16917
- for (const key5 of Object.keys(shape)) {
16918
- const field = def.shape[key5];
16917
+ for (const key6 of Object.keys(shape)) {
16918
+ const field = def.shape[key6];
16919
16919
  if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) {
16920
- requiredKeys.push(key5);
16920
+ requiredKeys.push(key6);
16921
16921
  }
16922
16922
  }
16923
16923
  if (requiredKeys.length > 0) {
@@ -17688,17 +17688,17 @@ var init_checks2 = __esm({
17688
17688
  });
17689
17689
 
17690
17690
  // node_modules/zod/v4/classic/errors.js
17691
- function _lazyMethod(proto, key5, make) {
17692
- Object.defineProperty(proto, key5, {
17691
+ function _lazyMethod(proto, key6, make) {
17692
+ Object.defineProperty(proto, key6, {
17693
17693
  configurable: true,
17694
17694
  enumerable: false,
17695
17695
  get() {
17696
17696
  const value = make(this);
17697
- Object.defineProperty(this, key5, { value, configurable: true, writable: true });
17697
+ Object.defineProperty(this, key6, { value, configurable: true, writable: true });
17698
17698
  return value;
17699
17699
  },
17700
17700
  set(value) {
17701
- Object.defineProperty(this, key5, { value, configurable: true, writable: true });
17701
+ Object.defineProperty(this, key6, { value, configurable: true, writable: true });
17702
17702
  }
17703
17703
  });
17704
17704
  }
@@ -18238,17 +18238,17 @@ function set(valueType, params) {
18238
18238
  });
18239
18239
  }
18240
18240
  function _enum2(values, params) {
18241
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
18241
+ const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
18242
18242
  return new ZodEnum({
18243
18243
  type: "enum",
18244
- entries,
18244
+ entries: entries2,
18245
18245
  ...util_exports.normalizeParams(params)
18246
18246
  });
18247
18247
  }
18248
- function nativeEnum(entries, params) {
18248
+ function nativeEnum(entries2, params) {
18249
18249
  return new ZodEnum({
18250
18250
  type: "enum",
18251
- entries,
18251
+ entries: entries2,
18252
18252
  ...util_exports.normalizeParams(params)
18253
18253
  });
18254
18254
  }
@@ -19528,11 +19528,11 @@ function resolveRef(ref, ctx) {
19528
19528
  }
19529
19529
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19530
19530
  if (path[0] === defsKey) {
19531
- const key5 = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
19532
- if (!key5 || !ctx.defs[key5]) {
19531
+ const key6 = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
19532
+ if (!key6 || !ctx.defs[key6]) {
19533
19533
  throw new Error(`Reference not found: ${ref}`);
19534
19534
  }
19535
- return ctx.defs[key5];
19535
+ return ctx.defs[key6];
19536
19536
  }
19537
19537
  throw new Error(`Reference not found: ${ref}`);
19538
19538
  }
@@ -19567,16 +19567,16 @@ function checkObjectGuards(objectSchema, guards) {
19567
19567
  });
19568
19568
  }
19569
19569
  if (guards.keySchema) {
19570
- for (const key5 of keys) {
19571
- const result = guards.keySchema.safeParse(key5);
19570
+ for (const key6 of keys) {
19571
+ const result = guards.keySchema.safeParse(key6);
19572
19572
  if (result.success)
19573
19573
  continue;
19574
19574
  payload.issues.push({
19575
19575
  code: "invalid_key",
19576
19576
  origin: "record",
19577
19577
  issues: result.error.issues,
19578
- input: key5,
19579
- path: [key5],
19578
+ input: key6,
19579
+ path: [key6],
19580
19580
  continue: true
19581
19581
  });
19582
19582
  }
@@ -19601,20 +19601,20 @@ function canonicalKey(value, seen) {
19601
19601
  if (Array.isArray(value)) {
19602
19602
  const parts2 = [];
19603
19603
  for (const item of value) {
19604
- const key5 = canonicalKey(item, seen);
19605
- if (key5 === null)
19604
+ const key6 = canonicalKey(item, seen);
19605
+ if (key6 === null)
19606
19606
  return null;
19607
- parts2.push(key5);
19607
+ parts2.push(key6);
19608
19608
  }
19609
19609
  return `a${parts2.length}:[${parts2.join(",")}]`;
19610
19610
  }
19611
19611
  const keys = Object.keys(value).sort();
19612
19612
  const parts = [];
19613
19613
  for (const k2 of keys) {
19614
- const key5 = canonicalKey(value[k2], seen);
19615
- if (key5 === null)
19614
+ const key6 = canonicalKey(value[k2], seen);
19615
+ if (key6 === null)
19616
19616
  return null;
19617
- parts.push(`${k2.length}:${k2}=${key5}`);
19617
+ parts.push(`${k2.length}:${k2}=${key6}`);
19618
19618
  }
19619
19619
  return `o${parts.length}:{${parts.join(",")}}`;
19620
19620
  } finally {
@@ -19628,10 +19628,10 @@ function containsRef(value) {
19628
19628
  return value.some(containsRef);
19629
19629
  if (typeof value.$ref === "string")
19630
19630
  return true;
19631
- return Object.entries(value).some(([key5, sub]) => {
19632
- if (SCHEMA_KEYWORDS.has(key5))
19631
+ return Object.entries(value).some(([key6, sub]) => {
19632
+ if (SCHEMA_KEYWORDS.has(key6))
19633
19633
  return containsRef(sub);
19634
- if (!SCHEMA_MAP_KEYWORDS.has(key5) || typeof sub !== "object" || sub === null)
19634
+ if (!SCHEMA_MAP_KEYWORDS.has(key6) || typeof sub !== "object" || sub === null)
19635
19635
  return false;
19636
19636
  return Object.values(sub).some(containsRef);
19637
19637
  });
@@ -19647,12 +19647,12 @@ function checkArrayGuards(arraySchema, guards) {
19647
19647
  if (guards.uniqueItems === true) {
19648
19648
  const firstSeen = /* @__PURE__ */ new Map();
19649
19649
  for (let i = 0; i < items.length; i++) {
19650
- const key5 = canonicalKey(items[i], /* @__PURE__ */ new Set());
19651
- if (key5 === null)
19650
+ const key6 = canonicalKey(items[i], /* @__PURE__ */ new Set());
19651
+ if (key6 === null)
19652
19652
  continue;
19653
- const first = firstSeen.get(key5);
19653
+ const first = firstSeen.get(key6);
19654
19654
  if (first === void 0) {
19655
- firstSeen.set(key5, i);
19655
+ firstSeen.set(key6, i);
19656
19656
  continue;
19657
19657
  }
19658
19658
  payload.issues.push({
@@ -19890,9 +19890,9 @@ function convertBaseSchema(schema, ctx) {
19890
19890
  const properties = schema.properties || {};
19891
19891
  const requiredSet = new Set(schema.required || []);
19892
19892
  const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
19893
- for (const [key5, propSchema] of Object.entries(properties)) {
19893
+ for (const [key6, propSchema] of Object.entries(properties)) {
19894
19894
  const propZodSchema = convertSchema(propSchema, ctx);
19895
- assignProp(shape, key5, requiredSet.has(key5) ? propZodSchema : propZodSchema.optional());
19895
+ assignProp(shape, key6, requiredSet.has(key6) ? propZodSchema : propZodSchema.optional());
19896
19896
  }
19897
19897
  if (schema.patternProperties) {
19898
19898
  const patternProps = schema.patternProperties;
@@ -19927,12 +19927,12 @@ function convertBaseSchema(schema, ctx) {
19927
19927
  if (!isPlainObject(payload.value))
19928
19928
  return;
19929
19929
  const unrecognized = [];
19930
- for (const key5 of Object.keys(payload.value)) {
19931
- if (propertyKeys.includes(key5))
19930
+ for (const key6 of Object.keys(payload.value)) {
19931
+ if (propertyKeys.includes(key6))
19932
19932
  continue;
19933
- if (patterns.some((regex) => regex.test(key5)))
19933
+ if (patterns.some((regex) => regex.test(key6)))
19934
19934
  continue;
19935
- unrecognized.push(key5);
19935
+ unrecognized.push(key6);
19936
19936
  }
19937
19937
  if (unrecognized.length) {
19938
19938
  payload.issues.push({
@@ -20063,38 +20063,38 @@ function convertSchema(schema, ctx) {
20063
20063
  }
20064
20064
  const extraMeta = {};
20065
20065
  const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
20066
- for (const key5 of coreMetadataKeys) {
20067
- if (key5 in schema) {
20068
- extraMeta[key5] = schema[key5];
20066
+ for (const key6 of coreMetadataKeys) {
20067
+ if (key6 in schema) {
20068
+ extraMeta[key6] = schema[key6];
20069
20069
  }
20070
20070
  }
20071
20071
  const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
20072
- for (const key5 of contentMetadataKeys) {
20073
- if (key5 in schema) {
20074
- extraMeta[key5] = schema[key5];
20072
+ for (const key6 of contentMetadataKeys) {
20073
+ if (key6 in schema) {
20074
+ extraMeta[key6] = schema[key6];
20075
20075
  }
20076
20076
  }
20077
20077
  if (schema.type === "object" && schema.$ref === void 0) {
20078
20078
  if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
20079
20079
  extraMeta.propertyNames = schema.propertyNames;
20080
20080
  }
20081
- for (const key5 of ["minProperties", "maxProperties"]) {
20082
- if (schema[key5] !== void 0)
20083
- extraMeta[key5] = schema[key5];
20081
+ for (const key6 of ["minProperties", "maxProperties"]) {
20082
+ if (schema[key6] !== void 0)
20083
+ extraMeta[key6] = schema[key6];
20084
20084
  }
20085
20085
  }
20086
20086
  if (schema.type === "array" && schema.$ref === void 0) {
20087
20087
  if (schema.contains !== void 0 && !containsRef(schema.contains)) {
20088
20088
  extraMeta.contains = schema.contains;
20089
20089
  }
20090
- for (const key5 of ["uniqueItems", "minContains", "maxContains"]) {
20091
- if (schema[key5] !== void 0)
20092
- extraMeta[key5] = schema[key5];
20090
+ for (const key6 of ["uniqueItems", "minContains", "maxContains"]) {
20091
+ if (schema[key6] !== void 0)
20092
+ extraMeta[key6] = schema[key6];
20093
20093
  }
20094
20094
  }
20095
- for (const key5 of Object.keys(schema)) {
20096
- if (!RECOGNIZED_KEYS.has(key5)) {
20097
- assignProp(extraMeta, key5, schema[key5]);
20095
+ for (const key6 of Object.keys(schema)) {
20096
+ if (!RECOGNIZED_KEYS.has(key6)) {
20097
+ assignProp(extraMeta, key6, schema[key6]);
20098
20098
  }
20099
20099
  }
20100
20100
  if (Object.keys(extraMeta).length > 0) {
@@ -20949,15 +20949,15 @@ var require_code = __commonJS({
20949
20949
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
20950
20950
  }
20951
20951
  exports.safeStringify = safeStringify;
20952
- function getProperty(key5) {
20953
- return typeof key5 == "string" && exports.IDENTIFIER.test(key5) ? new _Code(`.${key5}`) : _2`[${key5}]`;
20952
+ function getProperty(key6) {
20953
+ return typeof key6 == "string" && exports.IDENTIFIER.test(key6) ? new _Code(`.${key6}`) : _2`[${key6}]`;
20954
20954
  }
20955
20955
  exports.getProperty = getProperty;
20956
- function getEsmExportName(key5) {
20957
- if (typeof key5 == "string" && exports.IDENTIFIER.test(key5)) {
20958
- return new _Code(`${key5}`);
20956
+ function getEsmExportName(key6) {
20957
+ if (typeof key6 == "string" && exports.IDENTIFIER.test(key6)) {
20958
+ return new _Code(`${key6}`);
20959
20959
  }
20960
- throw new Error(`CodeGen: invalid export name: ${key5}, use explicit $id name mapping`);
20960
+ throw new Error(`CodeGen: invalid export name: ${key6}, use explicit $id name mapping`);
20961
20961
  }
20962
20962
  exports.getEsmExportName = getEsmExportName;
20963
20963
  function regexpCode(rx) {
@@ -21590,11 +21590,11 @@ var require_codegen = __commonJS({
21590
21590
  // returns code for object literal for the passed argument list of key-value pairs
21591
21591
  object(...keyValues) {
21592
21592
  const code = ["{"];
21593
- for (const [key5, value] of keyValues) {
21593
+ for (const [key6, value] of keyValues) {
21594
21594
  if (code.length > 1)
21595
21595
  code.push(",");
21596
- code.push(key5);
21597
- if (key5 !== value || this.opts.es5) {
21596
+ code.push(key6);
21597
+ if (key6 !== value || this.opts.es5) {
21598
21598
  code.push(":");
21599
21599
  (0, code_1.addCodeArg)(code, value);
21600
21600
  }
@@ -21872,17 +21872,17 @@ var require_util = __commonJS({
21872
21872
  if (typeof schema === "boolean")
21873
21873
  return;
21874
21874
  const rules = self.RULES.keywords;
21875
- for (const key5 in schema) {
21876
- if (!rules[key5])
21877
- checkStrictMode(it, `unknown keyword: "${key5}"`);
21875
+ for (const key6 in schema) {
21876
+ if (!rules[key6])
21877
+ checkStrictMode(it, `unknown keyword: "${key6}"`);
21878
21878
  }
21879
21879
  }
21880
21880
  exports.checkUnknownRules = checkUnknownRules;
21881
21881
  function schemaHasRules(schema, rules) {
21882
21882
  if (typeof schema == "boolean")
21883
21883
  return !schema;
21884
- for (const key5 in schema)
21885
- if (rules[key5])
21884
+ for (const key6 in schema)
21885
+ if (rules[key6])
21886
21886
  return true;
21887
21887
  return false;
21888
21888
  }
@@ -21890,8 +21890,8 @@ var require_util = __commonJS({
21890
21890
  function schemaHasRulesButRef(schema, RULES) {
21891
21891
  if (typeof schema == "boolean")
21892
21892
  return !schema;
21893
- for (const key5 in schema)
21894
- if (key5 !== "$ref" && RULES.all[key5])
21893
+ for (const key6 in schema)
21894
+ if (key6 !== "$ref" && RULES.all[key6])
21895
21895
  return true;
21896
21896
  return false;
21897
21897
  }
@@ -22490,8 +22490,8 @@ var require_defaults = __commonJS({
22490
22490
  function assignDefaults(it, ty) {
22491
22491
  const { properties, items } = it.schema;
22492
22492
  if (ty === "object" && properties) {
22493
- for (const key5 in properties) {
22494
- assignDefault(it, key5, properties[key5].default);
22493
+ for (const key6 in properties) {
22494
+ assignDefault(it, key6, properties[key6].default);
22495
22495
  }
22496
22496
  } else if (ty === "array" && Array.isArray(items)) {
22497
22497
  items.forEach((sch, i) => assignDefault(it, i, sch.default));
@@ -22887,8 +22887,8 @@ var require_fast_deep_equal = __commonJS({
22887
22887
  for (i = length; i-- !== 0; )
22888
22888
  if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
22889
22889
  for (i = length; i-- !== 0; ) {
22890
- var key5 = keys[i];
22891
- if (!equal(a[key5], b[key5])) return false;
22890
+ var key6 = keys[i];
22891
+ if (!equal(a[key6], b[key6])) return false;
22892
22892
  }
22893
22893
  return true;
22894
22894
  }
@@ -22963,20 +22963,20 @@ var require_json_schema_traverse = __commonJS({
22963
22963
  function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
22964
22964
  if (schema && typeof schema == "object" && !Array.isArray(schema)) {
22965
22965
  pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
22966
- for (var key5 in schema) {
22967
- var sch = schema[key5];
22966
+ for (var key6 in schema) {
22967
+ var sch = schema[key6];
22968
22968
  if (Array.isArray(sch)) {
22969
- if (key5 in traverse.arrayKeywords) {
22969
+ if (key6 in traverse.arrayKeywords) {
22970
22970
  for (var i = 0; i < sch.length; i++)
22971
- _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key5 + "/" + i, rootSchema, jsonPtr, key5, schema, i);
22971
+ _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key6 + "/" + i, rootSchema, jsonPtr, key6, schema, i);
22972
22972
  }
22973
- } else if (key5 in traverse.propsKeywords) {
22973
+ } else if (key6 in traverse.propsKeywords) {
22974
22974
  if (sch && typeof sch == "object") {
22975
22975
  for (var prop in sch)
22976
- _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key5 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key5, schema, prop);
22976
+ _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key6 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key6, schema, prop);
22977
22977
  }
22978
- } else if (key5 in traverse.keywords || opts.allKeys && !(key5 in traverse.skipKeywords)) {
22979
- _traverse(opts, pre, post, sch, jsonPtr + "/" + key5, rootSchema, jsonPtr, key5, schema);
22978
+ } else if (key6 in traverse.keywords || opts.allKeys && !(key6 in traverse.skipKeywords)) {
22979
+ _traverse(opts, pre, post, sch, jsonPtr + "/" + key6, rootSchema, jsonPtr, key6, schema);
22980
22980
  }
22981
22981
  }
22982
22982
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
@@ -23036,10 +23036,10 @@ var require_resolve = __commonJS({
23036
23036
  "$dynamicAnchor"
23037
23037
  ]);
23038
23038
  function hasRef(schema) {
23039
- for (const key5 in schema) {
23040
- if (REF_KEYWORDS.has(key5))
23039
+ for (const key6 in schema) {
23040
+ if (REF_KEYWORDS.has(key6))
23041
23041
  return true;
23042
- const sch = schema[key5];
23042
+ const sch = schema[key6];
23043
23043
  if (Array.isArray(sch) && sch.some(hasRef))
23044
23044
  return true;
23045
23045
  if (typeof sch == "object" && hasRef(sch))
@@ -23049,14 +23049,14 @@ var require_resolve = __commonJS({
23049
23049
  }
23050
23050
  function countKeys(schema) {
23051
23051
  let count = 0;
23052
- for (const key5 in schema) {
23053
- if (key5 === "$ref")
23052
+ for (const key6 in schema) {
23053
+ if (key6 === "$ref")
23054
23054
  return Infinity;
23055
23055
  count++;
23056
- if (SIMPLE_INLINED.has(key5))
23056
+ if (SIMPLE_INLINED.has(key6))
23057
23057
  continue;
23058
- if (typeof schema[key5] == "object") {
23059
- (0, util_1.eachItem)(schema[key5], (sch) => count += countKeys(sch));
23058
+ if (typeof schema[key6] == "object") {
23059
+ (0, util_1.eachItem)(schema[key6], (sch) => count += countKeys(sch));
23060
23060
  }
23061
23061
  if (count === Infinity)
23062
23062
  return Infinity;
@@ -23248,8 +23248,8 @@ var require_validate = __commonJS({
23248
23248
  function schemaCxtHasRules({ schema, self }) {
23249
23249
  if (typeof schema == "boolean")
23250
23250
  return !schema;
23251
- for (const key5 in schema)
23252
- if (self.RULES.all[key5])
23251
+ for (const key6 in schema)
23252
+ if (self.RULES.all[key6])
23253
23253
  return true;
23254
23254
  return false;
23255
23255
  }
@@ -25312,7 +25312,7 @@ var require_core = __commonJS({
25312
25312
  }
25313
25313
  }
25314
25314
  // Adds schema to the instance
25315
- addSchema(schema, key5, _meta, _validateSchema = this.opts.validateSchema) {
25315
+ addSchema(schema, key6, _meta, _validateSchema = this.opts.validateSchema) {
25316
25316
  if (Array.isArray(schema)) {
25317
25317
  for (const sch of schema)
25318
25318
  this.addSchema(sch, void 0, _meta, _validateSchema);
@@ -25326,15 +25326,15 @@ var require_core = __commonJS({
25326
25326
  throw new Error(`schema ${schemaId} must be string`);
25327
25327
  }
25328
25328
  }
25329
- key5 = (0, resolve_1.normalizeId)(key5 || id);
25330
- this._checkUnique(key5);
25331
- this.schemas[key5] = this._addSchema(schema, _meta, key5, _validateSchema, true);
25329
+ key6 = (0, resolve_1.normalizeId)(key6 || id);
25330
+ this._checkUnique(key6);
25331
+ this.schemas[key6] = this._addSchema(schema, _meta, key6, _validateSchema, true);
25332
25332
  return this;
25333
25333
  }
25334
25334
  // Add schema that will be used to validate other schemas
25335
25335
  // options in META_IGNORE_OPTIONS are alway set to false
25336
- addMetaSchema(schema, key5, _validateSchema = this.opts.validateSchema) {
25337
- this.addSchema(schema, key5, true, _validateSchema);
25336
+ addMetaSchema(schema, key6, _validateSchema = this.opts.validateSchema) {
25337
+ this.addSchema(schema, key6, true, _validateSchema);
25338
25338
  return this;
25339
25339
  }
25340
25340
  // Validate schema against its meta-schema
@@ -25418,8 +25418,8 @@ var require_core = __commonJS({
25418
25418
  }
25419
25419
  }
25420
25420
  // add "vocabulary" - a collection of keywords
25421
- addVocabulary(definitions) {
25422
- for (const def of definitions)
25421
+ addVocabulary(definitions2) {
25422
+ for (const def of definitions2)
25423
25423
  this.addKeyword(def);
25424
25424
  return this;
25425
25425
  }
@@ -25490,14 +25490,14 @@ var require_core = __commonJS({
25490
25490
  let keywords = metaSchema;
25491
25491
  for (const seg of segments)
25492
25492
  keywords = keywords[seg];
25493
- for (const key5 in rules) {
25494
- const rule = rules[key5];
25493
+ for (const key6 in rules) {
25494
+ const rule = rules[key6];
25495
25495
  if (typeof rule != "object")
25496
25496
  continue;
25497
25497
  const { $data } = rule.definition;
25498
- const schema = keywords[key5];
25498
+ const schema = keywords[key6];
25499
25499
  if ($data && schema)
25500
- keywords[key5] = schemaOrData(schema);
25500
+ keywords[key6] = schemaOrData(schema);
25501
25501
  }
25502
25502
  }
25503
25503
  return metaSchema;
@@ -25570,10 +25570,10 @@ var require_core = __commonJS({
25570
25570
  Ajv2.MissingRefError = ref_error_1.default;
25571
25571
  exports.default = Ajv2;
25572
25572
  function checkOptions(checkOpts, options, msg, log = "error") {
25573
- for (const key5 in checkOpts) {
25574
- const opt = key5;
25573
+ for (const key6 in checkOpts) {
25574
+ const opt = key6;
25575
25575
  if (opt in options)
25576
- this.logger[log](`${msg}: option ${key5}. ${checkOpts[opt]}`);
25576
+ this.logger[log](`${msg}: option ${key6}. ${checkOpts[opt]}`);
25577
25577
  }
25578
25578
  }
25579
25579
  function getSchEnv(keyRef) {
@@ -25587,8 +25587,8 @@ var require_core = __commonJS({
25587
25587
  if (Array.isArray(optsSchemas))
25588
25588
  this.addSchema(optsSchemas);
25589
25589
  else
25590
- for (const key5 in optsSchemas)
25591
- this.addSchema(optsSchemas[key5], key5);
25590
+ for (const key6 in optsSchemas)
25591
+ this.addSchema(optsSchemas[key6], key6);
25592
25592
  }
25593
25593
  function addInitialFormats() {
25594
25594
  for (const name in this.opts.formats) {
@@ -26702,11 +26702,11 @@ var require_dependencies = __commonJS({
26702
26702
  function splitDependencies({ schema }) {
26703
26703
  const propertyDeps = {};
26704
26704
  const schemaDeps = {};
26705
- for (const key5 in schema) {
26706
- if (key5 === "__proto__")
26705
+ for (const key6 in schema) {
26706
+ if (key6 === "__proto__")
26707
26707
  continue;
26708
- const deps = Array.isArray(schema[key5]) ? propertyDeps : schemaDeps;
26709
- deps[key5] = schema[key5];
26708
+ const deps = Array.isArray(schema[key6]) ? propertyDeps : schemaDeps;
26709
+ deps[key6] = schema[key6];
26710
26710
  }
26711
26711
  return [propertyDeps, schemaDeps];
26712
26712
  }
@@ -26786,13 +26786,13 @@ var require_propertyNames = __commonJS({
26786
26786
  if ((0, util_1.alwaysValidSchema)(it, schema))
26787
26787
  return;
26788
26788
  const valid = gen.name("valid");
26789
- gen.forIn("key", data, (key5) => {
26790
- cxt.setParams({ propertyName: key5 });
26789
+ gen.forIn("key", data, (key6) => {
26790
+ cxt.setParams({ propertyName: key6 });
26791
26791
  cxt.subschema({
26792
26792
  keyword: "propertyNames",
26793
- data: key5,
26793
+ data: key6,
26794
26794
  dataTypes: ["string"],
26795
- propertyName: key5,
26795
+ propertyName: key6,
26796
26796
  compositeRule: true
26797
26797
  }, valid);
26798
26798
  gen.if((0, codegen_1.not)(valid), () => {
@@ -26844,38 +26844,38 @@ var require_additionalProperties = __commonJS({
26844
26844
  checkAdditionalProperties();
26845
26845
  cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
26846
26846
  function checkAdditionalProperties() {
26847
- gen.forIn("key", data, (key5) => {
26847
+ gen.forIn("key", data, (key6) => {
26848
26848
  if (!props.length && !patProps.length)
26849
- additionalPropertyCode(key5);
26849
+ additionalPropertyCode(key6);
26850
26850
  else
26851
- gen.if(isAdditional(key5), () => additionalPropertyCode(key5));
26851
+ gen.if(isAdditional(key6), () => additionalPropertyCode(key6));
26852
26852
  });
26853
26853
  }
26854
- function isAdditional(key5) {
26854
+ function isAdditional(key6) {
26855
26855
  let definedProp;
26856
26856
  if (props.length > 8) {
26857
26857
  const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
26858
- definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key5);
26858
+ definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key6);
26859
26859
  } else if (props.length) {
26860
- definedProp = (0, codegen_1.or)(...props.map((p2) => (0, codegen_1._)`${key5} === ${p2}`));
26860
+ definedProp = (0, codegen_1.or)(...props.map((p2) => (0, codegen_1._)`${key6} === ${p2}`));
26861
26861
  } else {
26862
26862
  definedProp = codegen_1.nil;
26863
26863
  }
26864
26864
  if (patProps.length) {
26865
- definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p2) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p2)}.test(${key5})`));
26865
+ definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p2) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p2)}.test(${key6})`));
26866
26866
  }
26867
26867
  return (0, codegen_1.not)(definedProp);
26868
26868
  }
26869
- function deleteAdditional(key5) {
26870
- gen.code((0, codegen_1._)`delete ${data}[${key5}]`);
26869
+ function deleteAdditional(key6) {
26870
+ gen.code((0, codegen_1._)`delete ${data}[${key6}]`);
26871
26871
  }
26872
- function additionalPropertyCode(key5) {
26872
+ function additionalPropertyCode(key6) {
26873
26873
  if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
26874
- deleteAdditional(key5);
26874
+ deleteAdditional(key6);
26875
26875
  return;
26876
26876
  }
26877
26877
  if (schema === false) {
26878
- cxt.setParams({ additionalProperty: key5 });
26878
+ cxt.setParams({ additionalProperty: key6 });
26879
26879
  cxt.error();
26880
26880
  if (!allErrors)
26881
26881
  gen.break();
@@ -26884,22 +26884,22 @@ var require_additionalProperties = __commonJS({
26884
26884
  if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
26885
26885
  const valid = gen.name("valid");
26886
26886
  if (opts.removeAdditional === "failing") {
26887
- applyAdditionalSchema(key5, valid, false);
26887
+ applyAdditionalSchema(key6, valid, false);
26888
26888
  gen.if((0, codegen_1.not)(valid), () => {
26889
26889
  cxt.reset();
26890
- deleteAdditional(key5);
26890
+ deleteAdditional(key6);
26891
26891
  });
26892
26892
  } else {
26893
- applyAdditionalSchema(key5, valid);
26893
+ applyAdditionalSchema(key6, valid);
26894
26894
  if (!allErrors)
26895
26895
  gen.if((0, codegen_1.not)(valid), () => gen.break());
26896
26896
  }
26897
26897
  }
26898
26898
  }
26899
- function applyAdditionalSchema(key5, valid, errors) {
26899
+ function applyAdditionalSchema(key6, valid, errors) {
26900
26900
  const subschema = {
26901
26901
  keyword: "additionalProperties",
26902
- dataProp: key5,
26902
+ dataProp: key6,
26903
26903
  dataPropType: util_1.Type.Str
26904
26904
  };
26905
26905
  if (errors === false) {
@@ -27030,19 +27030,19 @@ var require_patternProperties = __commonJS({
27030
27030
  }
27031
27031
  }
27032
27032
  function validateProperties(pat) {
27033
- gen.forIn("key", data, (key5) => {
27034
- gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key5})`, () => {
27033
+ gen.forIn("key", data, (key6) => {
27034
+ gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key6})`, () => {
27035
27035
  const alwaysValid = alwaysValidPatterns.includes(pat);
27036
27036
  if (!alwaysValid) {
27037
27037
  cxt.subschema({
27038
27038
  keyword: "patternProperties",
27039
27039
  schemaProp: pat,
27040
- dataProp: key5,
27040
+ dataProp: key6,
27041
27041
  dataPropType: util_2.Type.Str
27042
27042
  }, valid);
27043
27043
  }
27044
27044
  if (it.opts.unevaluated && props !== true) {
27045
- gen.assign((0, codegen_1._)`${props}[${key5}]`, true);
27045
+ gen.assign((0, codegen_1._)`${props}[${key6}]`, true);
27046
27046
  } else if (!alwaysValid && !it.allErrors) {
27047
27047
  gen.if((0, codegen_1.not)(valid), () => gen.break());
27048
27048
  }
@@ -29916,9 +29916,9 @@ var util;
29916
29916
  };
29917
29917
  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
29918
29918
  const keys = [];
29919
- for (const key5 in object3) {
29920
- if (Object.prototype.hasOwnProperty.call(object3, key5)) {
29921
- keys.push(key5);
29919
+ for (const key6 in object3) {
29920
+ if (Object.prototype.hasOwnProperty.call(object3, key6)) {
29921
+ keys.push(key6);
29922
29922
  }
29923
29923
  }
29924
29924
  return keys;
@@ -30328,10 +30328,10 @@ var ParseStatus = class _ParseStatus {
30328
30328
  static async mergeObjectAsync(status, pairs) {
30329
30329
  const syncPairs = [];
30330
30330
  for (const pair of pairs) {
30331
- const key5 = await pair.key;
30331
+ const key6 = await pair.key;
30332
30332
  const value = await pair.value;
30333
30333
  syncPairs.push({
30334
- key: key5,
30334
+ key: key6,
30335
30335
  value
30336
30336
  });
30337
30337
  }
@@ -30340,17 +30340,17 @@ var ParseStatus = class _ParseStatus {
30340
30340
  static mergeObjectSync(status, pairs) {
30341
30341
  const finalObject = {};
30342
30342
  for (const pair of pairs) {
30343
- const { key: key5, value } = pair;
30344
- if (key5.status === "aborted")
30343
+ const { key: key6, value } = pair;
30344
+ if (key6.status === "aborted")
30345
30345
  return INVALID2;
30346
30346
  if (value.status === "aborted")
30347
30347
  return INVALID2;
30348
- if (key5.status === "dirty")
30348
+ if (key6.status === "dirty")
30349
30349
  status.dirty();
30350
30350
  if (value.status === "dirty")
30351
30351
  status.dirty();
30352
- if (key5.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
30353
- finalObject[key5.value] = value.value;
30352
+ if (key6.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
30353
+ finalObject[key6.value] = value.value;
30354
30354
  }
30355
30355
  }
30356
30356
  return { status: status.value, value: finalObject };
@@ -30383,12 +30383,12 @@ var errorUtil;
30383
30383
 
30384
30384
  // node_modules/zod/v3/types.js
30385
30385
  var ParseInputLazyPath = class {
30386
- constructor(parent, value, path, key5) {
30386
+ constructor(parent, value, path, key6) {
30387
30387
  this._cachedPath = [];
30388
30388
  this.parent = parent;
30389
30389
  this.data = value;
30390
30390
  this._path = path;
30391
- this._key = key5;
30391
+ this._key = key6;
30392
30392
  }
30393
30393
  get path() {
30394
30394
  if (!this._cachedPath.length) {
@@ -32133,9 +32133,9 @@ ZodArray2.create = (schema, params) => {
32133
32133
  function deepPartialify(schema) {
32134
32134
  if (schema instanceof ZodObject2) {
32135
32135
  const newShape = {};
32136
- for (const key5 in schema.shape) {
32137
- const fieldSchema = schema.shape[key5];
32138
- newShape[key5] = ZodOptional2.create(deepPartialify(fieldSchema));
32136
+ for (const key6 in schema.shape) {
32137
+ const fieldSchema = schema.shape[key6];
32138
+ newShape[key6] = ZodOptional2.create(deepPartialify(fieldSchema));
32139
32139
  }
32140
32140
  return new ZodObject2({
32141
32141
  ...schema._def,
@@ -32186,29 +32186,29 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32186
32186
  const { shape, keys: shapeKeys } = this._getCached();
32187
32187
  const extraKeys = [];
32188
32188
  if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
32189
- for (const key5 in ctx.data) {
32190
- if (!shapeKeys.includes(key5)) {
32191
- extraKeys.push(key5);
32189
+ for (const key6 in ctx.data) {
32190
+ if (!shapeKeys.includes(key6)) {
32191
+ extraKeys.push(key6);
32192
32192
  }
32193
32193
  }
32194
32194
  }
32195
32195
  const pairs = [];
32196
- for (const key5 of shapeKeys) {
32197
- const keyValidator = shape[key5];
32198
- const value = ctx.data[key5];
32196
+ for (const key6 of shapeKeys) {
32197
+ const keyValidator = shape[key6];
32198
+ const value = ctx.data[key6];
32199
32199
  pairs.push({
32200
- key: { status: "valid", value: key5 },
32201
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key5)),
32202
- alwaysSet: key5 in ctx.data
32200
+ key: { status: "valid", value: key6 },
32201
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key6)),
32202
+ alwaysSet: key6 in ctx.data
32203
32203
  });
32204
32204
  }
32205
32205
  if (this._def.catchall instanceof ZodNever2) {
32206
32206
  const unknownKeys = this._def.unknownKeys;
32207
32207
  if (unknownKeys === "passthrough") {
32208
- for (const key5 of extraKeys) {
32208
+ for (const key6 of extraKeys) {
32209
32209
  pairs.push({
32210
- key: { status: "valid", value: key5 },
32211
- value: { status: "valid", value: ctx.data[key5] }
32210
+ key: { status: "valid", value: key6 },
32211
+ value: { status: "valid", value: ctx.data[key6] }
32212
32212
  });
32213
32213
  }
32214
32214
  } else if (unknownKeys === "strict") {
@@ -32225,15 +32225,15 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32225
32225
  }
32226
32226
  } else {
32227
32227
  const catchall = this._def.catchall;
32228
- for (const key5 of extraKeys) {
32229
- const value = ctx.data[key5];
32228
+ for (const key6 of extraKeys) {
32229
+ const value = ctx.data[key6];
32230
32230
  pairs.push({
32231
- key: { status: "valid", value: key5 },
32231
+ key: { status: "valid", value: key6 },
32232
32232
  value: catchall._parse(
32233
- new ParseInputLazyPath(ctx, value, ctx.path, key5)
32233
+ new ParseInputLazyPath(ctx, value, ctx.path, key6)
32234
32234
  //, ctx.child(key), value, getParsedType(value)
32235
32235
  ),
32236
- alwaysSet: key5 in ctx.data
32236
+ alwaysSet: key6 in ctx.data
32237
32237
  });
32238
32238
  }
32239
32239
  }
@@ -32241,10 +32241,10 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32241
32241
  return Promise.resolve().then(async () => {
32242
32242
  const syncPairs = [];
32243
32243
  for (const pair of pairs) {
32244
- const key5 = await pair.key;
32244
+ const key6 = await pair.key;
32245
32245
  const value = await pair.value;
32246
32246
  syncPairs.push({
32247
- key: key5,
32247
+ key: key6,
32248
32248
  value,
32249
32249
  alwaysSet: pair.alwaysSet
32250
32250
  });
@@ -32369,8 +32369,8 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32369
32369
  // }) as any;
32370
32370
  // return merged;
32371
32371
  // }
32372
- setKey(key5, schema) {
32373
- return this.augment({ [key5]: schema });
32372
+ setKey(key6, schema) {
32373
+ return this.augment({ [key6]: schema });
32374
32374
  }
32375
32375
  // merge<Incoming extends AnyZodObject>(
32376
32376
  // merging: Incoming
@@ -32401,9 +32401,9 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32401
32401
  }
32402
32402
  pick(mask) {
32403
32403
  const shape = {};
32404
- for (const key5 of util.objectKeys(mask)) {
32405
- if (mask[key5] && this.shape[key5]) {
32406
- shape[key5] = this.shape[key5];
32404
+ for (const key6 of util.objectKeys(mask)) {
32405
+ if (mask[key6] && this.shape[key6]) {
32406
+ shape[key6] = this.shape[key6];
32407
32407
  }
32408
32408
  }
32409
32409
  return new _ZodObject({
@@ -32413,9 +32413,9 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32413
32413
  }
32414
32414
  omit(mask) {
32415
32415
  const shape = {};
32416
- for (const key5 of util.objectKeys(this.shape)) {
32417
- if (!mask[key5]) {
32418
- shape[key5] = this.shape[key5];
32416
+ for (const key6 of util.objectKeys(this.shape)) {
32417
+ if (!mask[key6]) {
32418
+ shape[key6] = this.shape[key6];
32419
32419
  }
32420
32420
  }
32421
32421
  return new _ZodObject({
@@ -32431,12 +32431,12 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32431
32431
  }
32432
32432
  partial(mask) {
32433
32433
  const newShape = {};
32434
- for (const key5 of util.objectKeys(this.shape)) {
32435
- const fieldSchema = this.shape[key5];
32436
- if (mask && !mask[key5]) {
32437
- newShape[key5] = fieldSchema;
32434
+ for (const key6 of util.objectKeys(this.shape)) {
32435
+ const fieldSchema = this.shape[key6];
32436
+ if (mask && !mask[key6]) {
32437
+ newShape[key6] = fieldSchema;
32438
32438
  } else {
32439
- newShape[key5] = fieldSchema.optional();
32439
+ newShape[key6] = fieldSchema.optional();
32440
32440
  }
32441
32441
  }
32442
32442
  return new _ZodObject({
@@ -32446,16 +32446,16 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
32446
32446
  }
32447
32447
  required(mask) {
32448
32448
  const newShape = {};
32449
- for (const key5 of util.objectKeys(this.shape)) {
32450
- if (mask && !mask[key5]) {
32451
- newShape[key5] = this.shape[key5];
32449
+ for (const key6 of util.objectKeys(this.shape)) {
32450
+ if (mask && !mask[key6]) {
32451
+ newShape[key6] = this.shape[key6];
32452
32452
  } else {
32453
- const fieldSchema = this.shape[key5];
32453
+ const fieldSchema = this.shape[key6];
32454
32454
  let newField = fieldSchema;
32455
32455
  while (newField instanceof ZodOptional2) {
32456
32456
  newField = newField._def.innerType;
32457
32457
  }
32458
- newShape[key5] = newField;
32458
+ newShape[key6] = newField;
32459
32459
  }
32460
32460
  }
32461
32461
  return new _ZodObject({
@@ -32699,18 +32699,18 @@ function mergeValues2(a, b) {
32699
32699
  return { valid: true, data: a };
32700
32700
  } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
32701
32701
  const bKeys = util.objectKeys(b);
32702
- const sharedKeys = util.objectKeys(a).filter((key5) => bKeys.indexOf(key5) !== -1);
32702
+ const sharedKeys = util.objectKeys(a).filter((key6) => bKeys.indexOf(key6) !== -1);
32703
32703
  const newObj = { ...a, ...b };
32704
32704
  if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
32705
32705
  delete newObj.__proto__;
32706
- for (const key5 of sharedKeys) {
32707
- if (key5 === "__proto__")
32706
+ for (const key6 of sharedKeys) {
32707
+ if (key6 === "__proto__")
32708
32708
  continue;
32709
- const sharedValue = mergeValues2(a[key5], b[key5]);
32709
+ const sharedValue = mergeValues2(a[key6], b[key6]);
32710
32710
  if (!sharedValue.valid) {
32711
32711
  return { valid: false };
32712
32712
  }
32713
- newObj[key5] = sharedValue.data;
32713
+ newObj[key6] = sharedValue.data;
32714
32714
  }
32715
32715
  return { valid: true, data: newObj };
32716
32716
  } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
@@ -32874,11 +32874,11 @@ var ZodRecord2 = class _ZodRecord extends ZodType2 {
32874
32874
  const pairs = [];
32875
32875
  const keyType = this._def.keyType;
32876
32876
  const valueType = this._def.valueType;
32877
- for (const key5 in ctx.data) {
32877
+ for (const key6 in ctx.data) {
32878
32878
  pairs.push({
32879
- key: keyType._parse(new ParseInputLazyPath(ctx, key5, ctx.path, key5)),
32880
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key5], ctx.path, key5)),
32881
- alwaysSet: key5 in ctx.data
32879
+ key: keyType._parse(new ParseInputLazyPath(ctx, key6, ctx.path, key6)),
32880
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key6], ctx.path, key6)),
32881
+ alwaysSet: key6 in ctx.data
32882
32882
  });
32883
32883
  }
32884
32884
  if (ctx.common.async) {
@@ -32926,9 +32926,9 @@ var ZodMap2 = class extends ZodType2 {
32926
32926
  }
32927
32927
  const keyType = this._def.keyType;
32928
32928
  const valueType = this._def.valueType;
32929
- const pairs = [...ctx.data.entries()].map(([key5, value], index) => {
32929
+ const pairs = [...ctx.data.entries()].map(([key6, value], index) => {
32930
32930
  return {
32931
- key: keyType._parse(new ParseInputLazyPath(ctx, key5, ctx.path, [index, "key"])),
32931
+ key: keyType._parse(new ParseInputLazyPath(ctx, key6, ctx.path, [index, "key"])),
32932
32932
  value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
32933
32933
  };
32934
32934
  });
@@ -32936,30 +32936,30 @@ var ZodMap2 = class extends ZodType2 {
32936
32936
  const finalMap = /* @__PURE__ */ new Map();
32937
32937
  return Promise.resolve().then(async () => {
32938
32938
  for (const pair of pairs) {
32939
- const key5 = await pair.key;
32939
+ const key6 = await pair.key;
32940
32940
  const value = await pair.value;
32941
- if (key5.status === "aborted" || value.status === "aborted") {
32941
+ if (key6.status === "aborted" || value.status === "aborted") {
32942
32942
  return INVALID2;
32943
32943
  }
32944
- if (key5.status === "dirty" || value.status === "dirty") {
32944
+ if (key6.status === "dirty" || value.status === "dirty") {
32945
32945
  status.dirty();
32946
32946
  }
32947
- finalMap.set(key5.value, value.value);
32947
+ finalMap.set(key6.value, value.value);
32948
32948
  }
32949
32949
  return { status: status.value, value: finalMap };
32950
32950
  });
32951
32951
  } else {
32952
32952
  const finalMap = /* @__PURE__ */ new Map();
32953
32953
  for (const pair of pairs) {
32954
- const key5 = pair.key;
32954
+ const key6 = pair.key;
32955
32955
  const value = pair.value;
32956
- if (key5.status === "aborted" || value.status === "aborted") {
32956
+ if (key6.status === "aborted" || value.status === "aborted") {
32957
32957
  return INVALID2;
32958
32958
  }
32959
- if (key5.status === "dirty" || value.status === "dirty") {
32959
+ if (key6.status === "dirty" || value.status === "dirty") {
32960
32960
  status.dirty();
32961
32961
  }
32962
- finalMap.set(key5.value, value.value);
32962
+ finalMap.set(key6.value, value.value);
32963
32963
  }
32964
32964
  return { status: status.value, value: finalMap };
32965
32965
  }
@@ -34118,19 +34118,19 @@ var getRefs = (options) => {
34118
34118
  init_define_COMPONENT_ICONS();
34119
34119
  init_define_EXAMPLE_PROJECTS();
34120
34120
  init_define_PNG_FONTS();
34121
- function addErrorMessage(res, key5, errorMessage2, refs) {
34121
+ function addErrorMessage(res, key6, errorMessage2, refs) {
34122
34122
  if (!refs?.errorMessages)
34123
34123
  return;
34124
34124
  if (errorMessage2) {
34125
34125
  res.errorMessage = {
34126
34126
  ...res.errorMessage,
34127
- [key5]: errorMessage2
34127
+ [key6]: errorMessage2
34128
34128
  };
34129
34129
  }
34130
34130
  }
34131
- function setResponseValueAndErrors(res, key5, value, errorMessage2, refs) {
34132
- res[key5] = value;
34133
- addErrorMessage(res, key5, errorMessage2, refs);
34131
+ function setResponseValueAndErrors(res, key6, value, errorMessage2, refs) {
34132
+ res[key6] = value;
34133
+ addErrorMessage(res, key6, errorMessage2, refs);
34134
34134
  }
34135
34135
 
34136
34136
  // node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
@@ -34784,11 +34784,11 @@ function parseRecordDef(def, refs) {
34784
34784
  return {
34785
34785
  type: "object",
34786
34786
  required: def.keyType._def.values,
34787
- properties: def.keyType._def.values.reduce((acc, key5) => ({
34787
+ properties: def.keyType._def.values.reduce((acc, key6) => ({
34788
34788
  ...acc,
34789
- [key5]: parseDef(def.valueType._def, {
34789
+ [key6]: parseDef(def.valueType._def, {
34790
34790
  ...refs,
34791
- currentPath: [...refs.currentPath, "properties", key5]
34791
+ currentPath: [...refs.currentPath, "properties", key6]
34792
34792
  }) ?? parseAnyDef(refs)
34793
34793
  }), {}),
34794
34794
  additionalProperties: refs.rejectedAdditionalProperties
@@ -34858,10 +34858,10 @@ init_define_EXAMPLE_PROJECTS();
34858
34858
  init_define_PNG_FONTS();
34859
34859
  function parseNativeEnumDef(def) {
34860
34860
  const object3 = def.values;
34861
- const actualKeys = Object.keys(def.values).filter((key5) => {
34862
- return typeof object3[object3[key5]] !== "number";
34861
+ const actualKeys = Object.keys(def.values).filter((key6) => {
34862
+ return typeof object3[object3[key6]] !== "number";
34863
34863
  });
34864
- const actualValues = actualKeys.map((key5) => object3[key5]);
34864
+ const actualValues = actualKeys.map((key6) => object3[key6]);
34865
34865
  const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
34866
34866
  return {
34867
34867
  type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
@@ -35404,7 +35404,7 @@ init_define_EXAMPLE_PROJECTS();
35404
35404
  init_define_PNG_FONTS();
35405
35405
  var zodToJsonSchema = (schema, options) => {
35406
35406
  const refs = getRefs(options);
35407
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
35407
+ let definitions2 = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
35408
35408
  ...acc,
35409
35409
  [name2]: parseDef(schema2._def, {
35410
35410
  ...refs,
@@ -35421,11 +35421,11 @@ var zodToJsonSchema = (schema, options) => {
35421
35421
  main.title = title;
35422
35422
  }
35423
35423
  if (refs.flags.hasReferencedOpenAiAnyType) {
35424
- if (!definitions) {
35425
- definitions = {};
35424
+ if (!definitions2) {
35425
+ definitions2 = {};
35426
35426
  }
35427
- if (!definitions[refs.openAiAnyTypeName]) {
35428
- definitions[refs.openAiAnyTypeName] = {
35427
+ if (!definitions2[refs.openAiAnyTypeName]) {
35428
+ definitions2[refs.openAiAnyTypeName] = {
35429
35429
  // Skipping "object" as no properties can be defined and additionalProperties must be "false"
35430
35430
  type: ["string", "number", "integer", "boolean", "array", "null"],
35431
35431
  items: {
@@ -35438,9 +35438,9 @@ var zodToJsonSchema = (schema, options) => {
35438
35438
  };
35439
35439
  }
35440
35440
  }
35441
- const combined = name === void 0 ? definitions ? {
35441
+ const combined = name === void 0 ? definitions2 ? {
35442
35442
  ...main,
35443
- [refs.definitionPath]: definitions
35443
+ [refs.definitionPath]: definitions2
35444
35444
  } : main : {
35445
35445
  $ref: [
35446
35446
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
@@ -35448,7 +35448,7 @@ var zodToJsonSchema = (schema, options) => {
35448
35448
  name
35449
35449
  ].join("/"),
35450
35450
  [refs.definitionPath]: {
35451
- ...definitions,
35451
+ ...definitions2,
35452
35452
  [name]: main
35453
35453
  }
35454
35454
  };
@@ -36467,8 +36467,8 @@ function isPlainObject2(value) {
36467
36467
  }
36468
36468
  function mergeCapabilities(base, additional) {
36469
36469
  const result = { ...base };
36470
- for (const key5 in additional) {
36471
- const k2 = key5;
36470
+ for (const key6 in additional) {
36471
+ const k2 = key6;
36472
36472
  const addValue = additional[k2];
36473
36473
  if (addValue === void 0)
36474
36474
  continue;
@@ -37295,12 +37295,12 @@ function toolInputElementCount(value, max) {
37295
37295
  stack.push(child);
37296
37296
  }
37297
37297
  } else {
37298
- for (const key5 in node2) {
37299
- if (!Object.prototype.hasOwnProperty.call(node2, key5))
37298
+ for (const key6 in node2) {
37299
+ if (!Object.prototype.hasOwnProperty.call(node2, key6))
37300
37300
  continue;
37301
37301
  if (++count > max)
37302
37302
  return count;
37303
- const child = node2[key5];
37303
+ const child = node2[key6];
37304
37304
  if (child !== null && typeof child === "object")
37305
37305
  stack.push(child);
37306
37306
  }
@@ -38129,7 +38129,7 @@ Rules: holes are [column, row] from the top-left hole, from 0, 2.54 mm apart. A
38129
38129
  The full guide, with more on all this and on changing a board the user shares (read_share_link): the resource perfboard://docs/guide.`;
38130
38130
  var GUIDE = `# Designing a board with Perfboard Designer
38131
38131
 
38132
- Perfboard Designer (https://perfboarddesigner.com) is a browser editor for perfboard and stripboard layouts. With these tools you design a board as a project file (JSON, format version 3, or 4 when a wire bends) and give the user a link that opens it in the editor, where they can see and change it. The goal is a board that's electrically right, looks neat and is easy to solder by hand: the user will build it.
38132
+ Perfboard Designer (https://perfboarddesigner.com) is a browser editor for perfboard and stripboard layouts. With these tools you design a board as a project file (JSON through version 8) and give the user a link that opens it in the editor. Parts may carry an instanceId; version 8 adds optional requirements (independent intended nets, unused pins, component snapshots and a validate flag). Preserve these when editing. Requirement connections never derive from the board's wiring. When requirements.validate is true, validation also reports missing components/pins, missing or unexpected connections, and incomplete pin coverage. Unspecified pins are unchecked, not assumed disconnected; this differs from the existing complete-list expectNets contract. New parts join the requirement inventory unconnected; board changes must never overwrite intended nets. The goal is a board that's electrically right, looks neat and is easy to solder by hand: the user will build it.
38133
38133
 
38134
38134
  ## Workflow
38135
38135
 
@@ -38156,6 +38156,8 @@ Wires are insulated jumpers: a wire joins only the holes at its two ends, never
38156
38156
 
38157
38157
  A wire can bend: add_wire's "via" lists the holes it bends at on its way, in order, and the file keeps them as the wire's "via" (format version 4). A bend joins nothing, like a hole a wire passes over: the wire is one piece of wire, soldered only at its two ends. update_wire's "via" replaces a wire's bends ([] straightens it). add_wire's "path" is different: each corner of a path is the end of one wire and the start of the next, so it joins whatever is in that hole; use it only when a corner should connect.
38158
38158
 
38159
+ A solder path is the other way to connect holes: a trail of solder bridging pad to pad on the copper side, which many people use instead of short jumpers. add_wire with "solder": true makes one ("from"/"to" with "via", or a "path", which here makes one solder path bending at its corners); the file marks it "kind": "solder" (format version 5), with no color or width. Unlike a jumper it's bare metal: it joins every hole it runs over, its ends, its bends and each hole between, and any solder path it touches, so run it only over holes that belong to one net, and never across another net's pins or solder path. Keep them short and straight, along a row or column between neighbouring parts; use jumper wires for longer runs and wherever a connection has to cross another. In render_board's text a solder path's holes show as "=", and its wire list says "solder path".
38160
+
38159
38161
  ## Laying it out well
38160
38162
 
38161
38163
  A board that's right isn't done until it looks neat and someone can easily solder it. Prefer a readable, compact, physically practical layout, like one a person would lay out by hand, over the shortest total wire length:
@@ -38169,9 +38171,19 @@ A board that's right isn't done until it looks neat and someone can easily solde
38169
38171
  - On a stripboard, let the strips do the connecting: place parts so pins that share a net sit on one strip, and use wires and cuts only where strips can't.
38170
38172
  - Look at the board as you go: render_board shows free space as text; with format "png" you see it as the user will. Tidy it up before you give the user the link: fewer crossings, fewer bends, straighter rows. Never break a connection to make it look better.
38171
38173
 
38174
+ ## Parts the catalog doesn't have
38175
+
38176
+ When list_parts has nothing for a part, make it with add_part, then place more of it with \`part\` and its name (\`{"op": "add_part", "part": "BC337", "at": [8, 2]}\`). Don't stand in a catalog part with the wrong pinout. Three kinds:
38177
+
38178
+ - A part in a package the catalog has, with its own name and pinout: a BC337 or 2N3906 is a TO-92 transistor, an IRLZ44N or LM7812 a TO-220. \`custom\` with \`shape\`, the catalog part's id, and the pin names in its pin order (get_part gives the package's pins): \`{"op": "add_part", "custom": {"name": "BC337", "shape": "transistor", "pins": [{"label": "C"}, {"label": "B"}, {"label": "E"}]}, "at": [2, 2]}\`. Check the pinout in the part's datasheet: they differ from part to part. It's drawn as the package, and its refs follow it (Q1).
38179
+ - A module or anything else with pins anywhere: \`custom\` with every pin's hole \`at\` within its body, from the body's top-left hole, pin 1 first; \`cols\` and \`rows\` (the body's size, else just big enough for its pins), \`color\` and \`refPrefix\` (default M) are optional. An HC-SR04's four pins along the bottom of an 8\xD74 body: \`{"name": "HC-SR04", "cols": 8, "rows": 4, "pins": [{"at": [2, 3], "label": "VCC"}, {"at": [3, 3], "label": "TRIG"}, {"at": [4, 3], "label": "ECHO"}, {"at": [5, 3], "label": "GND"}]}\`. add_part's \`at\` is pin 1's hole on the board; the body reaches from there as the pins say.
38180
+ - A dual-row chip or dev board: \`chip\` with \`pinsPerSide\`, \`width\` (columns from one pin row to the other, both included: 4 for a narrow DIP), \`pins\` (names in DIP order: down the left row from pin 1 at the top left, then up the right row) and \`board: true\` for a dev board. add_part's \`at\` is its top-left pin.
38181
+
38182
+ Name pins: wires and expectNets can then use the names ("M1.VCC", "Q1.B"), and get_nets shows them. The project file keeps each custom part whole in its placed part's "custom" (version 6) and each chip in "customIcs", so the user's editor adds them to its parts list when they open the board. A name already in the catalog is refused: use the catalog's part.
38183
+
38172
38184
  ## More
38173
38185
 
38174
- get_project returns the whole file. Kept projects don't last forever (on your computer, only while the server runs; hosted, 30 days unused); a whole project file works in place of a projectId everywhere. To change a board the user shares with you, read it with read_share_link: it returns a projectId to edit. The format is documented in the resource perfboard://docs/project-file, links in perfboard://docs/share-links, and the whole parts catalog is perfboard://parts.
38186
+ get_project returns the whole file. Kept projects don't last forever (on your computer, only while the server runs; hosted, 30 days unused); a whole project file works in place of a projectId everywhere. To change a board the user shares with you, read it with read_share_link: it returns a projectId to edit. Such a board may hold the user's own parts, made in the editor: custom ICs and dev boards (the file's customIcs, placed as placedIcs) and custom modules (format version 6: a placedAdvancedComponents entry with definitionId "custom" carrying the whole part in "custom": its size, its pins' holes and names, and with "shape" a built-in part's package it takes, such as "transistor" for a TO-92 BC337). Wire to their pins by name like any part's ("M1.VCC" or "M1.1"), place more of them by name, and keep them as they are (see Parts the catalog doesn't have). The format is documented in the resource perfboard://docs/project-file, links in perfboard://docs/share-links, and the whole parts catalog is perfboard://parts.
38175
38187
  `;
38176
38188
 
38177
38189
  // src/tools/catalog-tools.ts
@@ -38215,15 +38227,21 @@ function holesAlong(px) {
38215
38227
  init_define_COMPONENT_ICONS();
38216
38228
  init_define_EXAMPLE_PROJECTS();
38217
38229
  init_define_PNG_FONTS();
38218
- var PROJECT_FILE_VERSION = 4;
38230
+ var PROJECT_FILE_VERSION = 8;
38219
38231
  function fileVersionFor(project) {
38220
- return project.wires.some((wire) => wire.via?.length) ? PROJECT_FILE_VERSION : 3;
38232
+ if (project.requirements) return PROJECT_FILE_VERSION;
38233
+ if (project.placedAdvancedComponents.some((part) => part.custom)) return 6;
38234
+ if (project.wires.some((wire) => wire.kind === "solder")) return 5;
38235
+ return project.wires.some((wire) => wire.via?.length) ? 4 : 3;
38221
38236
  }
38222
38237
 
38223
38238
  // ../src/project-file/wire-path.ts
38224
38239
  init_define_COMPONENT_ICONS();
38225
38240
  init_define_EXAMPLE_PROJECTS();
38226
38241
  init_define_PNG_FONTS();
38242
+ function isSolderPath(wire) {
38243
+ return wire.kind === "solder";
38244
+ }
38227
38245
  function wirePoints(wire) {
38228
38246
  return [wire.from, ...wire.via ?? [], wire.to];
38229
38247
  }
@@ -38231,6 +38249,41 @@ function wireLegs(wire) {
38231
38249
  const points = wirePoints(wire);
38232
38250
  return points.slice(1).map((to, i) => ({ from: points[i], to }));
38233
38251
  }
38252
+ var key = ([c, r2]) => `${c},${r2}`;
38253
+ var gcd = (a, b) => b ? gcd(b, a % b) : a;
38254
+ function holesAlong2(leg) {
38255
+ const [x1, y1] = leg.from;
38256
+ const [x2, y2] = leg.to;
38257
+ const steps = gcd(Math.abs(x2 - x1), Math.abs(y2 - y1));
38258
+ const holes = [];
38259
+ for (let k2 = 1; k2 < steps; k2++) holes.push({ at: [x1 + (x2 - x1) / steps * k2, y1 + (y2 - y1) / steps * k2], along: k2 / steps });
38260
+ return holes;
38261
+ }
38262
+ function solderPathHoles(wire) {
38263
+ const holes = /* @__PURE__ */ new Map();
38264
+ for (const leg of wireLegs(wire)) {
38265
+ for (const at of [leg.from, ...holesAlong2(leg).map((hole2) => hole2.at), leg.to]) {
38266
+ if (!holes.has(key(at))) holes.set(key(at), at);
38267
+ }
38268
+ }
38269
+ return [...holes.values()];
38270
+ }
38271
+ function legsMeet(a, b) {
38272
+ const [ax, ay] = a.from;
38273
+ const [bx, by] = b.from;
38274
+ const rx = a.to[0] - ax, ry = a.to[1] - ay;
38275
+ const sx = b.to[0] - bx, sy = b.to[1] - by;
38276
+ let denom = rx * sy - ry * sx;
38277
+ if (denom === 0) return void 0;
38278
+ let tNum = (bx - ax) * sy - (by - ay) * sx;
38279
+ let uNum = (bx - ax) * ry - (by - ay) * rx;
38280
+ if (denom < 0) [denom, tNum, uNum] = [-denom, -tNum, -uNum];
38281
+ if (tNum < 0 || tNum > denom || uNum < 0 || uNum > denom) return void 0;
38282
+ const t = tNum === 0 ? 0 : tNum === denom ? 1 : tNum / denom;
38283
+ const u2 = uNum === 0 ? 0 : uNum === denom ? 1 : uNum / denom;
38284
+ const at = t === 0 ? [ax, ay] : t === 1 ? [a.to[0], a.to[1]] : [ax + t * rx, ay + t * ry];
38285
+ return { at, t, u: u2 };
38286
+ }
38234
38287
 
38235
38288
  // ../src/project-file/read-project-file.ts
38236
38289
  init_define_COMPONENT_ICONS();
@@ -38268,6 +38321,22 @@ function getComponentDefinition(id) {
38268
38321
  function isLed(definitionId) {
38269
38322
  return getComponentDefinition(definitionId)?.led === true;
38270
38323
  }
38324
+ var LED_COLORS = [
38325
+ { id: "red", label: "Red", paint: "#ef4444" },
38326
+ { id: "green", label: "Green", paint: "#22c55e" },
38327
+ { id: "blue", label: "Blue", paint: "#3b82f6" },
38328
+ { id: "yellow", label: "Yellow", paint: "#facc15" },
38329
+ { id: "rgb", label: "RGB" }
38330
+ ];
38331
+ function ledPaint(color) {
38332
+ const known = LED_COLORS.find((c) => c.id === color);
38333
+ return known && "paint" in known ? known.paint : void 0;
38334
+ }
38335
+
38336
+ // ../src/parts/custom-parts.ts
38337
+ init_define_COMPONENT_ICONS();
38338
+ init_define_EXAMPLE_PROJECTS();
38339
+ init_define_PNG_FONTS();
38271
38340
 
38272
38341
  // ../src/parts/advanced-component-definitions.ts
38273
38342
  init_define_COMPONENT_ICONS();
@@ -38984,6 +39053,98 @@ function getAdvancedComponentDefinition(id) {
38984
39053
  return ADVANCED_COMPONENT_DEFINITIONS.find((def) => def.id === id);
38985
39054
  }
38986
39055
 
39056
+ // ../src/parts/custom-parts.ts
39057
+ var CUSTOM_PART_ID = "custom";
39058
+ var CUSTOM_REF_PREFIX = "M";
39059
+ var MAX_CUSTOM_PART_SIDE = 40;
39060
+ var BODY_MARGIN = 0.45;
39061
+ function isShapeable(def) {
39062
+ return !def.gridSizable && !def.perPinIcon;
39063
+ }
39064
+ var CUSTOM_PART_SHAPES = ADVANCED_COMPONENT_DEFINITIONS.filter(isShapeable);
39065
+ function customPartShape(id) {
39066
+ const def = id ? getAdvancedComponentDefinition(id) : void 0;
39067
+ return def && isShapeable(def) ? def : void 0;
39068
+ }
39069
+ function shapeHoles(shape) {
39070
+ const holes = [...shape.pinOffsets, ...shape.shadedOffsets ?? []];
39071
+ const left = Math.min(...holes.map((h2) => h2.dx)), top = Math.min(...holes.map((h2) => h2.dy));
39072
+ const right = Math.max(...holes.map((h2) => h2.dx)), bottom = Math.max(...holes.map((h2) => h2.dy));
39073
+ return {
39074
+ cols: right - left + 1,
39075
+ rows: bottom - top + 1,
39076
+ pins: shape.pinOffsets.map((pin) => [pin.dx - left, pin.dy - top])
39077
+ };
39078
+ }
39079
+ function shapedPartSpec(shape, fields) {
39080
+ const { cols, rows, pins } = shapeHoles(shape);
39081
+ return {
39082
+ ...fields.id ? { id: fields.id } : {},
39083
+ name: fields.name,
39084
+ ...fields.refPrefix ? { refPrefix: fields.refPrefix } : {},
39085
+ cols,
39086
+ rows,
39087
+ pins: pins.map((at, i) => {
39088
+ const label = fields.labels[i]?.trim();
39089
+ return { at, ...label ? { label } : {} };
39090
+ }),
39091
+ shape: shape.id
39092
+ };
39093
+ }
39094
+ var definitions = /* @__PURE__ */ new WeakMap();
39095
+ function customPartDefinition(spec) {
39096
+ const cached2 = definitions.get(spec);
39097
+ if (cached2) return cached2;
39098
+ const shape = customPartShape(spec.shape);
39099
+ const definition = shape ? shapedDefinition(spec, shape) : moduleDefinition(spec);
39100
+ definitions.set(spec, definition);
39101
+ return definition;
39102
+ }
39103
+ function shapedDefinition(spec, shape) {
39104
+ return {
39105
+ ...shape,
39106
+ id: CUSTOM_PART_ID,
39107
+ name: spec.name,
39108
+ keywords: void 0,
39109
+ refPrefix: spec.refPrefix || shape.refPrefix,
39110
+ // The package's artwork, which the shape names by its own id.
39111
+ iconFile: getIconFile(shape),
39112
+ pinLabels: shape.pinOffsets.map((_2, i) => spec.pins[i]?.label?.trim() ?? "")
39113
+ };
39114
+ }
39115
+ function moduleDefinition(spec) {
39116
+ const [ax, ay] = spec.pins[0]?.at ?? [0, 0];
39117
+ const offset2 = ([col, row]) => ({ dx: col - ax, dy: row - ay });
39118
+ const pinHoles = new Set(spec.pins.map((pin) => `${pin.at[0]},${pin.at[1]}`));
39119
+ const covered = [];
39120
+ for (let row = 0; row < spec.rows; row++) {
39121
+ for (let col = 0; col < spec.cols; col++) {
39122
+ if (!pinHoles.has(`${col},${row}`)) covered.push(offset2([col, row]));
39123
+ }
39124
+ }
39125
+ const left = -ax - BODY_MARGIN, top = -ay - BODY_MARGIN;
39126
+ const right = spec.cols - 1 - ax + BODY_MARGIN, bottom = spec.rows - 1 - ay + BODY_MARGIN;
39127
+ return {
39128
+ id: CUSTOM_PART_ID,
39129
+ category: "modules.custom",
39130
+ name: spec.name,
39131
+ refPrefix: spec.refPrefix || CUSTOM_REF_PREFIX,
39132
+ fallbackLabel: spec.name,
39133
+ pinOffsets: spec.pins.map((pin) => offset2(pin.at)),
39134
+ // A pin without a label is drawn with its number, and names no net.
39135
+ pinLabels: spec.pins.map((pin) => pin.label?.trim() ?? ""),
39136
+ shadedOffsets: covered,
39137
+ bodyOutline: [{ dx: left, dy: top }, { dx: right, dy: top }, { dx: right, dy: bottom }, { dx: left, dy: bottom }],
39138
+ // Its name in the middle of the body.
39139
+ iconOffset: { dx: (spec.cols - 1) / 2 - ax, dy: (spec.rows - 1) / 2 - ay },
39140
+ noIcon: true,
39141
+ ...spec.color ? { bodyColor: spec.color } : {}
39142
+ };
39143
+ }
39144
+ function advancedDefinitionFor(part) {
39145
+ return part.custom ? customPartDefinition(part.custom) : getAdvancedComponentDefinition(part.definitionId);
39146
+ }
39147
+
38987
39148
  // ../src/project-file/part-refs.ts
38988
39149
  var IC_REF_PREFIX = "U";
38989
39150
  var UNKNOWN_PART_REF_PREFIX = "X";
@@ -38993,7 +39154,7 @@ function isValidRef(ref) {
38993
39154
  }
38994
39155
  function refPrefixFor(part) {
38995
39156
  if (part.kind === "ic") return IC_REF_PREFIX;
38996
- const definition = part.kind === "standard-component" ? getComponentDefinition(part.definitionId ?? "") : getAdvancedComponentDefinition(part.definitionId ?? "");
39157
+ const definition = part.kind === "standard-component" ? getComponentDefinition(part.definitionId ?? "") : advancedDefinitionFor({ definitionId: part.definitionId ?? "", custom: part.custom });
38997
39158
  return definition?.refPrefix ?? UNKNOWN_PART_REF_PREFIX;
38998
39159
  }
38999
39160
  var BoardRefs = class {
@@ -39017,6 +39178,530 @@ var BoardRefs = class {
39017
39178
  }
39018
39179
  };
39019
39180
 
39181
+ // ../src/project-file/component-ids.ts
39182
+ init_define_COMPONENT_ICONS();
39183
+ init_define_EXAMPLE_PROJECTS();
39184
+ init_define_PNG_FONTS();
39185
+ function componentId() {
39186
+ return crypto.randomUUID();
39187
+ }
39188
+ function ensureComponentIds(project, migrate = false) {
39189
+ const parts = [
39190
+ ...project.placedIcs,
39191
+ ...project.placedStandardComponents,
39192
+ ...project.placedAdvancedComponents
39193
+ ];
39194
+ const reserved = new Set(parts.map((part) => part.instanceId));
39195
+ const seen = /* @__PURE__ */ new Set();
39196
+ let sequence = 0;
39197
+ for (const part of parts) {
39198
+ if (!part.instanceId || !/^[\w-]{1,100}$/.test(part.instanceId) || ["__proto__", "constructor", "prototype"].includes(part.instanceId) || seen.has(part.instanceId)) {
39199
+ let next;
39200
+ do {
39201
+ next = migrate ? `legacy-${++sequence}` : componentId();
39202
+ } while (reserved.has(next));
39203
+ part.instanceId = next;
39204
+ reserved.add(next);
39205
+ }
39206
+ seen.add(part.instanceId);
39207
+ }
39208
+ }
39209
+
39210
+ // ../src/project-file/requirements.ts
39211
+ init_define_COMPONENT_ICONS();
39212
+ init_define_EXAMPLE_PROJECTS();
39213
+ init_define_PNG_FONTS();
39214
+
39215
+ // ../src/project-file/pin-positions.ts
39216
+ init_define_COMPONENT_ICONS();
39217
+ init_define_EXAMPLE_PROJECTS();
39218
+ init_define_PNG_FONTS();
39219
+
39220
+ // ../src/parts/part-geometry.ts
39221
+ init_define_COMPONENT_ICONS();
39222
+ init_define_EXAMPLE_PROJECTS();
39223
+ init_define_PNG_FONTS();
39224
+
39225
+ // ../src/parts/rotate-offset.ts
39226
+ init_define_COMPONENT_ICONS();
39227
+ init_define_EXAMPLE_PROJECTS();
39228
+ init_define_PNG_FONTS();
39229
+ function rotateOffset(dx, dy, angle) {
39230
+ switch (angle) {
39231
+ case 90:
39232
+ return { x: -dy, y: dx };
39233
+ case 180:
39234
+ return { x: -dx, y: -dy };
39235
+ case 270:
39236
+ return { x: dy, y: -dx };
39237
+ default:
39238
+ return { x: dx, y: dy };
39239
+ }
39240
+ }
39241
+
39242
+ // ../src/parts/part-geometry.ts
39243
+ var BODY_PAD = 0.32;
39244
+ function boxAround(points, pad) {
39245
+ const xs = points.map((p2) => p2.x);
39246
+ const ys = points.map((p2) => p2.y);
39247
+ return { left: Math.min(...xs) - pad, top: Math.min(...ys) - pad, right: Math.max(...xs) + pad, bottom: Math.max(...ys) + pad };
39248
+ }
39249
+ function advancedPinOffsets(def, rows, cols) {
39250
+ if (!def.gridSizable) return def.pinOffsets;
39251
+ const offsets = [];
39252
+ for (let row = 0; row < rows; row++) {
39253
+ for (let col = 0; col < cols; col++) offsets.push({ dx: col, dy: row });
39254
+ }
39255
+ return offsets;
39256
+ }
39257
+ function advancedPartShape(def, part) {
39258
+ const place = (offsets) => offsets.map(({ dx, dy }) => {
39259
+ const r2 = rotateOffset(dx, dy, part.rotation);
39260
+ return { x: part.at[0] + r2.x, y: part.at[1] + r2.y };
39261
+ });
39262
+ const pins = place(advancedPinOffsets(def, part.rows, part.cols));
39263
+ const covered = place(def.shadedOffsets ?? []);
39264
+ let outline = [];
39265
+ if (def.gridSizable) {
39266
+ const left = -PIN_TILE_HALF, top = -PIN_TILE_HALF;
39267
+ const right = part.cols - 1 + PIN_TILE_HALF, bottom = part.rows - 1 + PIN_TILE_HALF;
39268
+ outline = place([{ dx: left, dy: top }, { dx: right, dy: top }, { dx: right, dy: bottom }, { dx: left, dy: bottom }]);
39269
+ } else if (def.bodyOutline) {
39270
+ outline = place(def.bodyOutline);
39271
+ }
39272
+ let iconAnchor;
39273
+ if (def.iconOffset) {
39274
+ iconAnchor = place([def.iconOffset])[0];
39275
+ } else {
39276
+ const box = boxAround(pins, 0);
39277
+ iconAnchor = { x: (box.left + box.right) / 2, y: (box.top + box.bottom) / 2 };
39278
+ }
39279
+ const body = outline.length >= 3 ? boxAround(outline, 0) : boxAround([...pins, ...covered], BODY_PAD);
39280
+ return { pins, covered, outline, iconAnchor, body };
39281
+ }
39282
+ function icPins(ic) {
39283
+ const [left, top] = ic.at;
39284
+ const pins = [];
39285
+ if (ic.rotation === 0 || ic.rotation === 180) {
39286
+ const perSide = ic.heightPin;
39287
+ const right = left + ic.widthPin - 1;
39288
+ for (let i = 0; i < perSide; i++) {
39289
+ pins.push({ pin: ic.rotation === 0 ? i + 1 : perSide + 1 + i, at: [left, top + i], side: "left" });
39290
+ pins.push({ pin: ic.rotation === 0 ? perSide * 2 - i : perSide - i, at: [right, top + i], side: "right" });
39291
+ }
39292
+ } else {
39293
+ const perSide = ic.widthPin;
39294
+ const bottom = top + ic.heightPin - 1;
39295
+ for (let i = 0; i < perSide; i++) {
39296
+ pins.push({ pin: ic.rotation === 90 ? perSide - i : perSide * 2 - i, at: [left + i, top], side: "top" });
39297
+ pins.push({ pin: ic.rotation === 90 ? perSide + 1 + i : i + 1, at: [left + i, bottom], side: "bottom" });
39298
+ }
39299
+ }
39300
+ return pins.sort((a, b) => a.pin - b.pin);
39301
+ }
39302
+
39303
+ // ../src/project-file/pin-positions.ts
39304
+ var hole = (p2) => [Math.round(p2.x), Math.round(p2.y)];
39305
+ function partPins(project) {
39306
+ const parts = [];
39307
+ for (const ic of project.placedIcs) {
39308
+ const pins = icPins(ic).map(({ pin, at }) => ({ pin, ...ic.pinDescription[pin] ? { label: ic.pinDescription[pin] } : {}, at }));
39309
+ const isPin = new Set(pins.map((p2) => `${p2.at[0]},${p2.at[1]}`));
39310
+ const coveredHoles = [];
39311
+ for (let col = ic.at[0]; col < ic.at[0] + ic.widthPin; col++) {
39312
+ for (let row = ic.at[1]; row < ic.at[1] + ic.heightPin; row++) {
39313
+ if (!isPin.has(`${col},${row}`)) coveredHoles.push([col, row]);
39314
+ }
39315
+ }
39316
+ parts.push({
39317
+ ref: ic.ref,
39318
+ kind: "ic",
39319
+ part: ic.name,
39320
+ known: true,
39321
+ pins,
39322
+ coveredHoles,
39323
+ body: boxAround(pins.map((p2) => ({ x: p2.at[0], y: p2.at[1] })), BODY_PAD)
39324
+ });
39325
+ }
39326
+ for (const part of project.placedStandardComponents) {
39327
+ const def = getComponentDefinition(part.definitionId);
39328
+ const lead = (pin, at) => ({ pin, ...def?.leadLabels ? { label: def.leadLabels[pin - 1] } : {}, at });
39329
+ parts.push({
39330
+ ref: part.ref,
39331
+ kind: "standard-component",
39332
+ part: part.definitionId,
39333
+ known: !!def,
39334
+ pins: [lead(1, part.from), lead(2, part.to)],
39335
+ coveredHoles: []
39336
+ });
39337
+ }
39338
+ for (const part of project.placedAdvancedComponents) {
39339
+ const def = advancedDefinitionFor(part);
39340
+ if (!def) {
39341
+ parts.push({ ref: part.ref, kind: "advanced-component", part: part.definitionId, known: false, pins: [{ pin: 1, at: part.at }], coveredHoles: [] });
39342
+ continue;
39343
+ }
39344
+ const shape = advancedPartShape(def, part);
39345
+ parts.push({
39346
+ ref: part.ref,
39347
+ kind: "advanced-component",
39348
+ part: part.custom?.name ?? part.definitionId,
39349
+ known: true,
39350
+ pins: shape.pins.map((p2, i) => ({ pin: i + 1, ...!def.gridSizable && def.pinLabels?.[i] ? { label: def.pinLabels[i] } : {}, at: hole(p2) })),
39351
+ coveredHoles: shape.covered.map(hole),
39352
+ body: shape.body
39353
+ });
39354
+ }
39355
+ return parts;
39356
+ }
39357
+
39358
+ // ../src/project-file/nets.ts
39359
+ init_define_COMPONENT_ICONS();
39360
+ init_define_EXAMPLE_PROJECTS();
39361
+ init_define_PNG_FONTS();
39362
+ var key2 = ([c, r2]) => `${c},${r2}`;
39363
+ var POWER_NAME = /^([ADP]?GND|V(CC|DD|SS|EE|IN|BAT|BUS)\d*|V[+-]|[+-]?\d+(\.\d+)?V|\d+V\d+)$/i;
39364
+ var isPowerName = (name) => POWER_NAME.test(name);
39365
+ var MORE = "\u2026";
39366
+ function isPowerNet(net) {
39367
+ return !!net.name && net.name.split("/").every((name) => name === MORE || isPowerName(name));
39368
+ }
39369
+ function comparePins(a, b) {
39370
+ return a.ref.localeCompare(b.ref, void 0, { numeric: true, sensitivity: "base" }) || a.pin - b.pin;
39371
+ }
39372
+ function pinId(pin) {
39373
+ return pin.kind === "standard-component" && pin.label ? `${pin.ref}.${pin.label}` : `${pin.ref}.${pin.pin}`;
39374
+ }
39375
+ function pinName(pin) {
39376
+ return pin.label && pin.kind !== "standard-component" ? `${pinId(pin)} ${pin.label}` : pinId(pin);
39377
+ }
39378
+ var POLARITY_MARK = /^[+\-−]$/;
39379
+ function netName(pins) {
39380
+ const names = pins.filter((p2) => p2.kind !== "standard-component").map((p2) => p2.label?.trim() ?? "").filter((name) => name && !POLARITY_MARK.test(name));
39381
+ const distinct = names.filter((name, i) => names.findIndex((n) => n.toLowerCase() === name.toLowerCase()) === i);
39382
+ const power = distinct.filter(isPowerName);
39383
+ const shown = power.length ? power : distinct;
39384
+ if (!shown.length) return void 0;
39385
+ return shown.length > 3 ? `${shown.slice(0, 3).join("/")}/${MORE}` : shown.join("/");
39386
+ }
39387
+ function boardPins(project) {
39388
+ return partPins(project).flatMap((part) => part.pins.map(({ pin, label, at }) => ({ ref: part.ref, kind: part.kind, pin, ...label ? { label } : {}, at })));
39389
+ }
39390
+ function computeNets(project) {
39391
+ const board = project.board;
39392
+ const cuts = new Set(board.type === "stripboard" ? board.cuts.map(key2) : []);
39393
+ const parent = /* @__PURE__ */ new Map();
39394
+ const find = (node2) => {
39395
+ let root = node2;
39396
+ for (let up = parent.get(root); up !== void 0 && up !== root; up = parent.get(root)) root = up;
39397
+ parent.set(node2, root);
39398
+ return root;
39399
+ };
39400
+ const union2 = (a, b) => {
39401
+ const ra = find(a);
39402
+ const rb = find(b);
39403
+ if (ra !== rb) parent.set(ra, rb);
39404
+ };
39405
+ let isolated = 0;
39406
+ const nodeAt = (at) => cuts.has(key2(at)) ? `cut#${isolated++}` : key2(at);
39407
+ if (board.type === "stripboard") {
39408
+ const horizontal = board.strips === "horizontal";
39409
+ const along = horizontal ? board.cols : board.rows;
39410
+ const across = horizontal ? board.rows : board.cols;
39411
+ for (let line = 0; line < across; line++) {
39412
+ for (let i = 1; i < along; i++) {
39413
+ const prev = horizontal ? [i - 1, line] : [line, i - 1];
39414
+ const here = horizontal ? [i, line] : [line, i];
39415
+ if (!cuts.has(key2(prev)) && !cuts.has(key2(here))) union2(key2(prev), key2(here));
39416
+ }
39417
+ }
39418
+ }
39419
+ const solderHoles = project.wires.map((wire) => isSolderPath(wire) ? solderPathHoles(wire).filter((at) => !cuts.has(key2(at))) : []);
39420
+ const wireNodes = project.wires.map((wire, i) => {
39421
+ if (isSolderPath(wire)) {
39422
+ const node2 = `solder#${i}`;
39423
+ parent.set(node2, node2);
39424
+ for (const at of solderHoles[i]) union2(node2, key2(at));
39425
+ return node2;
39426
+ }
39427
+ const from = nodeAt(wire.from);
39428
+ union2(from, nodeAt(wire.to));
39429
+ return from;
39430
+ });
39431
+ const solderPaths = project.wires.flatMap((wire, i) => isSolderPath(wire) ? [{ i, legs: wireLegs(wire) }] : []);
39432
+ for (let a = 0; a < solderPaths.length; a++) {
39433
+ for (let b = a + 1; b < solderPaths.length; b++) {
39434
+ const touch = solderPaths[a].legs.some((legA) => solderPaths[b].legs.some((legB) => legsMeet(legA, legB)));
39435
+ if (touch) union2(wireNodes[solderPaths[a].i], wireNodes[solderPaths[b].i]);
39436
+ }
39437
+ }
39438
+ const pinNodes = boardPins(project).map((pin) => ({ pin, node: nodeAt(pin.at) }));
39439
+ const byRoot = /* @__PURE__ */ new Map();
39440
+ const netFor = (node2) => {
39441
+ const root = find(node2);
39442
+ let net = byRoot.get(root);
39443
+ if (!net) byRoot.set(root, net = { pins: [], wires: [], holes: [] });
39444
+ return net;
39445
+ };
39446
+ const holeSeen = /* @__PURE__ */ new Set();
39447
+ const addHole = (net, at) => {
39448
+ if (cuts.has(key2(at)) || holeSeen.has(key2(at))) return;
39449
+ holeSeen.add(key2(at));
39450
+ net.holes.push(at);
39451
+ };
39452
+ for (const { pin, node: node2 } of pinNodes) {
39453
+ const net = netFor(node2);
39454
+ net.pins.push(pin);
39455
+ addHole(net, pin.at);
39456
+ }
39457
+ project.wires.forEach((wire, i) => {
39458
+ const net = netFor(wireNodes[i]);
39459
+ net.wires.push(i);
39460
+ for (const at of isSolderPath(wire) ? solderHoles[i] : [wire.from, wire.to]) addHole(net, at);
39461
+ });
39462
+ const nets = [...byRoot.values()];
39463
+ for (const net of nets) {
39464
+ net.pins.sort(comparePins);
39465
+ const name = netName(net.pins);
39466
+ if (name) net.name = name;
39467
+ }
39468
+ const rank = (net) => !net.pins.length ? 2 : isPowerNet(net) ? 0 : 1;
39469
+ nets.sort((a, b) => rank(a) - rank(b) || (a.pins.length && b.pins.length ? comparePins(a.pins[0], b.pins[0]) : a.wires[0] - b.wires[0]));
39470
+ return {
39471
+ nets,
39472
+ netAt(at) {
39473
+ if (cuts.has(key2(at)) || !parent.has(key2(at))) return void 0;
39474
+ return byRoot.get(find(key2(at)));
39475
+ }
39476
+ };
39477
+ }
39478
+
39479
+ // ../src/project-file/requirements.ts
39480
+ var requiredPinKey = (pin) => `${pin.componentId}:${pin.pin}`;
39481
+ var entries = (project) => [
39482
+ ...project.placedIcs,
39483
+ ...project.placedStandardComponents,
39484
+ ...project.placedAdvancedComponents
39485
+ ];
39486
+ function requiredComponents(project) {
39487
+ const ids = new Map(
39488
+ entries(project).map((part) => [part.ref, part.instanceId ?? part.ref])
39489
+ );
39490
+ return partPins(project).map((part) => ({
39491
+ id: ids.get(part.ref),
39492
+ ref: part.ref,
39493
+ name: part.part,
39494
+ pins: part.pins.map(({ pin, label }) => ({
39495
+ pin,
39496
+ ...label ? { label } : {}
39497
+ }))
39498
+ }));
39499
+ }
39500
+ function includeRequiredComponents(requirements, project) {
39501
+ const current = requiredComponents(project);
39502
+ const byId = new Map(current.map((part) => [part.id, part]));
39503
+ const known = new Set(requirements.components.map((part) => part.id));
39504
+ const added = current.filter((part) => !known.has(part.id));
39505
+ const components = requirements.components.map((part) => {
39506
+ const present = byId.get(part.id);
39507
+ if (!present) return part;
39508
+ const pins = present.pins.filter(
39509
+ (pin) => !part.pins.some((previous) => previous.pin === pin.pin)
39510
+ );
39511
+ return pins.length ? { ...part, pins: [...part.pins, ...pins] } : part;
39512
+ });
39513
+ return added.length || components.some((part, index) => part !== requirements.components[index]) ? { ...requirements, components: [...components, ...added] } : requirements;
39514
+ }
39515
+ function requirementPinName(project, pin) {
39516
+ const saved = entries(project).find(
39517
+ (part) => (part.instanceId ?? part.ref) === pin.componentId
39518
+ );
39519
+ const remembered = project.requirements?.components.find(
39520
+ (part) => part.id === pin.componentId
39521
+ );
39522
+ return `${saved?.ref ?? remembered?.ref ?? pin.componentId}.${pin.pin}`;
39523
+ }
39524
+ function validateRequirements(project, actual) {
39525
+ const requirements = project.requirements;
39526
+ if (!requirements?.validate)
39527
+ return {
39528
+ status: "disabled",
39529
+ issues: [],
39530
+ unspecified: [],
39531
+ checked: 0,
39532
+ total: 0
39533
+ };
39534
+ actual ??= computeNets(project).nets;
39535
+ const components = requiredComponents(project);
39536
+ const byId = new Map(components.map((part) => [part.id, part]));
39537
+ const byRef = new Map(components.map((part) => [part.ref, part.id]));
39538
+ const identity = (pin) => ({
39539
+ componentId: byRef.get(pin.ref),
39540
+ pin: pin.pin
39541
+ });
39542
+ const netOf = new Map(
39543
+ actual.flatMap(
39544
+ (net) => net.pins.map((pin) => [requiredPinKey(identity(pin)), net])
39545
+ )
39546
+ );
39547
+ const issues = [];
39548
+ const named = (pins) => pins.map((pin) => requirementPinName(project, pin)).join(", ");
39549
+ for (const expected of requirements.components) {
39550
+ const current = byId.get(expected.id);
39551
+ if (!current) {
39552
+ issues.push({
39553
+ kind: "missing-component",
39554
+ message: `Missing component: ${expected.ref} (${expected.name}) is required but no longer on the board.`,
39555
+ pins: expected.pins.map((pin) => ({
39556
+ componentId: expected.id,
39557
+ pin: pin.pin
39558
+ }))
39559
+ });
39560
+ } else {
39561
+ const missing = expected.pins.filter((pin) => !current.pins.some((item) => item.pin === pin.pin)).map((pin) => ({ componentId: expected.id, pin: pin.pin }));
39562
+ if (missing.length)
39563
+ issues.push({
39564
+ kind: "missing-pin",
39565
+ message: `Missing terminals: ${named(missing)}.`,
39566
+ pins: missing
39567
+ });
39568
+ }
39569
+ }
39570
+ const groupOf = /* @__PURE__ */ new Map();
39571
+ for (const net of requirements.nets) {
39572
+ for (const pin of net.pins) groupOf.set(requiredPinKey(pin), net.id);
39573
+ const groups = new Set(
39574
+ net.pins.map((pin) => netOf.get(requiredPinKey(pin))).filter(Boolean)
39575
+ );
39576
+ if (groups.size > 1)
39577
+ issues.push({
39578
+ kind: "missing-connection",
39579
+ message: `Missing connection: ${named(
39580
+ net.pins
39581
+ )} should be one net, but the board separates them into ${groups.size} groups.`,
39582
+ pins: net.pins
39583
+ });
39584
+ }
39585
+ const unused = new Set(requirements.unused.map(requiredPinKey));
39586
+ for (const pin of requirements.unused)
39587
+ groupOf.set(requiredPinKey(pin), `unused:${requiredPinKey(pin)}`);
39588
+ for (const net of actual) {
39589
+ if (net.pins.length < 2) continue;
39590
+ const pins = net.pins.map(identity);
39591
+ const groups = new Set(
39592
+ pins.map((pin) => groupOf.get(requiredPinKey(pin))).filter(Boolean)
39593
+ );
39594
+ const hasUnused = pins.some((pin) => unused.has(requiredPinKey(pin)));
39595
+ if (groups.size > 1 || hasUnused)
39596
+ issues.push({
39597
+ kind: "unexpected-connection",
39598
+ message: hasUnused ? `Unexpected connection: ${named(
39599
+ pins
39600
+ )} includes a terminal marked unused.` : `Unexpected connection: ${named(
39601
+ pins
39602
+ )} joins separate required nets.`,
39603
+ pins
39604
+ });
39605
+ }
39606
+ const all = components.flatMap(
39607
+ (part) => part.pins.map((pin) => ({ componentId: part.id, pin: pin.pin }))
39608
+ );
39609
+ const unspecified = all.filter((pin) => !groupOf.has(requiredPinKey(pin)));
39610
+ return {
39611
+ status: issues.length ? "mismatch" : unspecified.length || !all.length ? "incomplete" : "match",
39612
+ issues,
39613
+ unspecified,
39614
+ checked: all.length - unspecified.length,
39615
+ total: all.length
39616
+ };
39617
+ }
39618
+ function readRequirements(value) {
39619
+ if (value === void 0) return;
39620
+ const invalid = () => {
39621
+ throw new Error(
39622
+ "The requirements are malformed. They were not discarded; fix their components, pin assignments or nets before importing."
39623
+ );
39624
+ };
39625
+ const object3 = (entry) => {
39626
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
39627
+ return invalid();
39628
+ return entry;
39629
+ };
39630
+ const list = (entry) => {
39631
+ if (!Array.isArray(entry) || entry.length > 2e4) return invalid();
39632
+ return entry;
39633
+ };
39634
+ const id = (entry) => {
39635
+ if (typeof entry !== "string" || !/^[\w-]{1,100}$/.test(entry) || ["__proto__", "constructor", "prototype"].includes(entry))
39636
+ return invalid();
39637
+ return entry;
39638
+ };
39639
+ const text2 = (entry) => {
39640
+ if (typeof entry !== "string" || !entry.trim() || entry.length > 200)
39641
+ return invalid();
39642
+ return entry;
39643
+ };
39644
+ const number4 = (entry) => {
39645
+ if (typeof entry !== "number" || !Number.isInteger(entry) || entry < 1 || entry > 2e4)
39646
+ return invalid();
39647
+ return entry;
39648
+ };
39649
+ const raw = object3(value);
39650
+ if (typeof raw.validate !== "boolean") return invalid();
39651
+ const componentIds = /* @__PURE__ */ new Set();
39652
+ const terminals = /* @__PURE__ */ new Set();
39653
+ const components = list(raw.components).map((entry) => {
39654
+ const part = object3(entry);
39655
+ const componentId2 = id(part.id);
39656
+ if (componentIds.has(componentId2)) return invalid();
39657
+ componentIds.add(componentId2);
39658
+ const pins = list(part.pins).map((entry2) => {
39659
+ const pin = object3(entry2);
39660
+ const pinNumber = number4(pin.pin);
39661
+ const key6 = requiredPinKey({ componentId: componentId2, pin: pinNumber });
39662
+ if (terminals.has(key6) || terminals.size >= 2e4) return invalid();
39663
+ terminals.add(key6);
39664
+ return {
39665
+ pin: pinNumber,
39666
+ ...pin.label === void 0 || pin.label === "" ? {} : { label: text2(pin.label) }
39667
+ };
39668
+ });
39669
+ if (!pins.length) return invalid();
39670
+ return {
39671
+ id: componentId2,
39672
+ ref: text2(part.ref),
39673
+ name: text2(part.name),
39674
+ pins
39675
+ };
39676
+ });
39677
+ const assigned = /* @__PURE__ */ new Set();
39678
+ const readPin = (entry) => {
39679
+ const raw2 = object3(entry);
39680
+ const pin = { componentId: id(raw2.componentId), pin: number4(raw2.pin) };
39681
+ const key6 = requiredPinKey(pin);
39682
+ if (!terminals.has(key6) || assigned.has(key6)) return invalid();
39683
+ assigned.add(key6);
39684
+ return pin;
39685
+ };
39686
+ const netIds = /* @__PURE__ */ new Set();
39687
+ const nets = list(raw.nets).map((entry) => {
39688
+ const net = object3(entry);
39689
+ const netId = id(net.id);
39690
+ if (netIds.has(netId)) return invalid();
39691
+ netIds.add(netId);
39692
+ const pins = list(net.pins).map(readPin);
39693
+ if (pins.length < 2) return invalid();
39694
+ return { id: netId, pins };
39695
+ });
39696
+ const unused = list(raw.unused).map(readPin);
39697
+ return {
39698
+ validate: raw.validate,
39699
+ components,
39700
+ nets,
39701
+ unused
39702
+ };
39703
+ }
39704
+
39020
39705
  // ../src/project-file/read-project-file.ts
39021
39706
  var ProjectFileError = class extends Error {
39022
39707
  };
@@ -39043,9 +39728,9 @@ function pinLabels(value) {
39043
39728
  const labels = {};
39044
39729
  const entry = asEntry(value);
39045
39730
  if (!entry) return labels;
39046
- for (const key5 of Object.keys(entry)) {
39047
- const pin = Number(key5);
39048
- const label = entry[key5];
39731
+ for (const key6 of Object.keys(entry)) {
39732
+ const pin = Number(key6);
39733
+ const label = entry[key6];
39049
39734
  if (Number.isInteger(pin) && pin > 0 && typeof label === "string") labels[pin] = label;
39050
39735
  }
39051
39736
  return labels;
@@ -39064,6 +39749,49 @@ function readCustomIc(entry) {
39064
39749
  ...typeof entry.category === "string" ? { category: entry.category } : {}
39065
39750
  };
39066
39751
  }
39752
+ var REF_PREFIX = /^[A-Za-z]{1,4}$/;
39753
+ var MAX_LABEL_LENGTH = 24;
39754
+ function readCustomPart(value) {
39755
+ const entry = asEntry(value);
39756
+ if (!entry) return void 0;
39757
+ const refPrefix = typeof entry.refPrefix === "string" && REF_PREFIX.test(entry.refPrefix) ? entry.refPrefix.toUpperCase() : void 0;
39758
+ const id = text(entry.id)?.slice(0, 64);
39759
+ const name = text(entry.name)?.trim().slice(0, 60);
39760
+ const shapeId = text(entry.shape)?.trim().slice(0, 64);
39761
+ const shape = customPartShape(shapeId);
39762
+ if (shape) {
39763
+ const labels = Array.isArray(entry.pins) ? entry.pins.map((item) => text(asEntry(item)?.label)?.trim().slice(0, MAX_LABEL_LENGTH) ?? "") : [];
39764
+ return shapedPartSpec(shape, { ...id ? { id } : {}, name: name || shape.name, ...refPrefix ? { refPrefix } : {}, labels });
39765
+ }
39766
+ const cols = wholeCount(entry.cols);
39767
+ const rows = wholeCount(entry.rows);
39768
+ if (!cols || !rows || cols > MAX_CUSTOM_PART_SIDE || rows > MAX_CUSTOM_PART_SIDE || !Array.isArray(entry.pins)) return void 0;
39769
+ const pins = [];
39770
+ const taken = /* @__PURE__ */ new Set();
39771
+ for (const item of entry.pins) {
39772
+ const pin = asEntry(item);
39773
+ const at = pin && Array.isArray(pin.at) && pin.at.length === 2 ? pin.at : void 0;
39774
+ const [col, row] = at ?? [];
39775
+ if (!Number.isInteger(col) || !Number.isInteger(row) || col < 0 || row < 0 || col >= cols || row >= rows) return void 0;
39776
+ if (taken.has(`${col},${row}`)) return void 0;
39777
+ taken.add(`${col},${row}`);
39778
+ const label = text(pin?.label)?.trim().slice(0, MAX_LABEL_LENGTH);
39779
+ pins.push({ at: [col, row], ...label ? { label } : {} });
39780
+ }
39781
+ if (!pins.length) return void 0;
39782
+ const color = text(entry.color)?.trim().slice(0, 32);
39783
+ return {
39784
+ ...id ? { id } : {},
39785
+ name: name || "Custom Module",
39786
+ ...refPrefix ? { refPrefix } : {},
39787
+ cols,
39788
+ rows,
39789
+ pins,
39790
+ ...color ? { color } : {},
39791
+ // A package this build doesn't have: drawn as a plain module, and kept for one that has it.
39792
+ ...shapeId ? { shape: shapeId } : {}
39793
+ };
39794
+ }
39067
39795
  var Reader = class {
39068
39796
  constructor(cols, rows) {
39069
39797
  this.cols = cols;
@@ -39153,15 +39881,16 @@ var Reader = class {
39153
39881
  this.skipped++;
39154
39882
  continue;
39155
39883
  }
39156
- const key5 = `${at[0]},${at[1]}`;
39157
- if (seen.has(key5)) continue;
39158
- seen.add(key5);
39884
+ const key6 = `${at[0]},${at[1]}`;
39885
+ if (seen.has(key6)) continue;
39886
+ seen.add(key6);
39159
39887
  cuts.push(at);
39160
39888
  }
39161
39889
  return cuts;
39162
39890
  }
39163
39891
  result(board, project) {
39164
39892
  giveEveryPartARef(project);
39893
+ ensureComponentIds(project, true);
39165
39894
  return { project: { version: fileVersionFor(project), board, ...project }, skipped: this.skipped };
39166
39895
  }
39167
39896
  };
@@ -39169,14 +39898,14 @@ function giveEveryPartARef(project) {
39169
39898
  const parts = [
39170
39899
  ...project.placedIcs.map((entry) => ({ entry, kind: "ic", definitionId: void 0 })),
39171
39900
  ...project.placedStandardComponents.map((entry) => ({ entry, kind: "standard-component", definitionId: entry.definitionId })),
39172
- ...project.placedAdvancedComponents.map((entry) => ({ entry, kind: "advanced-component", definitionId: entry.definitionId }))
39901
+ ...project.placedAdvancedComponents.map((entry) => ({ entry, kind: "advanced-component", definitionId: entry.definitionId, custom: entry.custom }))
39173
39902
  ];
39174
39903
  const refs = new BoardRefs();
39175
39904
  const unnamed = parts.filter(({ entry }) => !refs.claim(entry.ref));
39176
39905
  for (const part of unnamed) part.entry.ref = refs.claimNext(refPrefixFor(part));
39177
39906
  }
39178
- function optional2(key5, value) {
39179
- return value === void 0 ? {} : { [key5]: value };
39907
+ function optional2(key6, value) {
39908
+ return value === void 0 ? {} : { [key6]: value };
39180
39909
  }
39181
39910
  function readGridFile(data, version2) {
39182
39911
  const boardEntry = asEntry(data.board);
@@ -39194,6 +39923,7 @@ function readGridFile(data, version2) {
39194
39923
  if (!via) return void 0;
39195
39924
  const last = via[via.length - 1];
39196
39925
  if (last && last[0] === to[0] && last[1] === to[1]) via.pop();
39926
+ if (version2 >= 5 && entry.kind === "solder") return { from, to, ...via.length ? { via } : {}, kind: "solder" };
39197
39927
  return {
39198
39928
  from,
39199
39929
  to,
@@ -39208,6 +39938,7 @@ function readGridFile(data, version2) {
39208
39938
  const heightPin = wholeCount(entry.heightPin);
39209
39939
  if (!at || !widthPin || !heightPin) return void 0;
39210
39940
  return {
39941
+ instanceId: text(entry.instanceId),
39211
39942
  ref: text(entry.ref) ?? "",
39212
39943
  name: text(entry.name) ?? "Component",
39213
39944
  widthPin,
@@ -39223,24 +39954,35 @@ function readGridFile(data, version2) {
39223
39954
  const from = r2.gridPos(entry.from);
39224
39955
  const to = r2.gridPos(entry.to);
39225
39956
  if (!definitionId || !from || !to) return void 0;
39226
- return { ref: text(entry.ref) ?? "", definitionId, from, to, ...optional2("value", text(entry.value)), ...optional2("color", text(entry.color)) };
39957
+ return { instanceId: text(entry.instanceId), ref: text(entry.ref) ?? "", definitionId, from, to, ...optional2("value", text(entry.value)), ...optional2("color", text(entry.color)) };
39227
39958
  });
39228
39959
  const placedAdvancedComponents = r2.list(data.placedAdvancedComponents, (entry) => {
39229
39960
  const definitionId = text(entry.definitionId);
39230
39961
  const at = r2.gridPos(entry.at);
39231
39962
  if (!definitionId || !at) return void 0;
39963
+ const isCustom = version2 >= 6 && (entry.custom !== void 0 || definitionId === CUSTOM_PART_ID);
39964
+ const custom2 = isCustom ? readCustomPart(entry.custom) : void 0;
39965
+ if (isCustom && !custom2) return void 0;
39232
39966
  return {
39967
+ instanceId: text(entry.instanceId),
39233
39968
  ref: text(entry.ref) ?? "",
39234
- definitionId,
39969
+ definitionId: custom2 ? CUSTOM_PART_ID : definitionId,
39235
39970
  at,
39236
39971
  rotation: rotation(entry.rotation),
39237
39972
  rows: wholeCount(entry.rows) ?? 1,
39238
39973
  cols: wholeCount(entry.cols) ?? 1,
39239
- ...optional2("value", text(entry.value))
39974
+ ...optional2("value", text(entry.value)),
39975
+ ...custom2 ? { custom: custom2 } : {}
39240
39976
  };
39241
39977
  });
39242
39978
  const customIcs = r2.list(data.customIcs, readCustomIc);
39243
- return r2.result(board, { pads, wires, placedIcs, placedStandardComponents, placedAdvancedComponents, customIcs });
39979
+ let requirements;
39980
+ try {
39981
+ requirements = readRequirements(data.requirements);
39982
+ } catch (error62) {
39983
+ throw new ProjectFileError(error62 instanceof Error ? error62.message : "Invalid requirements.");
39984
+ }
39985
+ return r2.result(board, { pads, wires, placedIcs, placedStandardComponents, placedAdvancedComponents, customIcs, ...requirements ? { requirements } : {} });
39244
39986
  }
39245
39987
  function readV1(data) {
39246
39988
  const canvas = asEntry(data.canvas);
@@ -39309,7 +40051,7 @@ function readProjectFile(raw) {
39309
40051
  const data = asEntry(raw);
39310
40052
  if (!data) throw new ProjectFileError(NOT_A_PROJECT);
39311
40053
  if (data.version === void 0) return asEntry(data.board) ? readGridFile(data, PROJECT_FILE_VERSION) : readV1(data);
39312
- if (data.version === 2 || data.version === 3 || data.version === 4) return readGridFile(data, data.version);
40054
+ if (data.version === 2 || data.version === 3 || data.version === 4 || data.version === 5 || data.version === 6 || data.version === 7 || data.version === 8) return readGridFile(data, data.version);
39313
40055
  if (typeof data.version === "number" && data.version > PROJECT_FILE_VERSION) {
39314
40056
  throw new ProjectFileError(
39315
40057
  "This project was saved by a newer version of Perfboard Designer. Reload the page to get the latest version, then open it again."
@@ -39333,271 +40075,11 @@ function isModulePart(category, name) {
39333
40075
  return category !== void 0 ? isModuleCategory(category) : isModuleName(name);
39334
40076
  }
39335
40077
 
39336
- // ../src/project-file/pin-positions.ts
39337
- init_define_COMPONENT_ICONS();
39338
- init_define_EXAMPLE_PROJECTS();
39339
- init_define_PNG_FONTS();
39340
-
39341
- // ../src/parts/part-geometry.ts
39342
- init_define_COMPONENT_ICONS();
39343
- init_define_EXAMPLE_PROJECTS();
39344
- init_define_PNG_FONTS();
39345
-
39346
- // ../src/parts/rotate-offset.ts
39347
- init_define_COMPONENT_ICONS();
39348
- init_define_EXAMPLE_PROJECTS();
39349
- init_define_PNG_FONTS();
39350
- function rotateOffset(dx, dy, angle) {
39351
- switch (angle) {
39352
- case 90:
39353
- return { x: -dy, y: dx };
39354
- case 180:
39355
- return { x: -dx, y: -dy };
39356
- case 270:
39357
- return { x: dy, y: -dx };
39358
- default:
39359
- return { x: dx, y: dy };
39360
- }
39361
- }
39362
-
39363
- // ../src/parts/part-geometry.ts
39364
- var BODY_PAD = 0.32;
39365
- function boxAround(points, pad) {
39366
- const xs = points.map((p2) => p2.x);
39367
- const ys = points.map((p2) => p2.y);
39368
- return { left: Math.min(...xs) - pad, top: Math.min(...ys) - pad, right: Math.max(...xs) + pad, bottom: Math.max(...ys) + pad };
39369
- }
39370
- function advancedPinOffsets(def, rows, cols) {
39371
- if (!def.gridSizable) return def.pinOffsets;
39372
- const offsets = [];
39373
- for (let row = 0; row < rows; row++) {
39374
- for (let col = 0; col < cols; col++) offsets.push({ dx: col, dy: row });
39375
- }
39376
- return offsets;
39377
- }
39378
- function advancedPartShape(def, part) {
39379
- const place = (offsets) => offsets.map(({ dx, dy }) => {
39380
- const r2 = rotateOffset(dx, dy, part.rotation);
39381
- return { x: part.at[0] + r2.x, y: part.at[1] + r2.y };
39382
- });
39383
- const pins = place(advancedPinOffsets(def, part.rows, part.cols));
39384
- const covered = place(def.shadedOffsets ?? []);
39385
- let outline = [];
39386
- if (def.gridSizable) {
39387
- const left = -PIN_TILE_HALF, top = -PIN_TILE_HALF;
39388
- const right = part.cols - 1 + PIN_TILE_HALF, bottom = part.rows - 1 + PIN_TILE_HALF;
39389
- outline = place([{ dx: left, dy: top }, { dx: right, dy: top }, { dx: right, dy: bottom }, { dx: left, dy: bottom }]);
39390
- } else if (def.bodyOutline) {
39391
- outline = place(def.bodyOutline);
39392
- }
39393
- let iconAnchor;
39394
- if (def.iconOffset) {
39395
- iconAnchor = place([def.iconOffset])[0];
39396
- } else {
39397
- const box = boxAround(pins, 0);
39398
- iconAnchor = { x: (box.left + box.right) / 2, y: (box.top + box.bottom) / 2 };
39399
- }
39400
- const body = outline.length >= 3 ? boxAround(outline, 0) : boxAround([...pins, ...covered], BODY_PAD);
39401
- return { pins, covered, outline, iconAnchor, body };
39402
- }
39403
- function icPins(ic) {
39404
- const [left, top] = ic.at;
39405
- const pins = [];
39406
- if (ic.rotation === 0 || ic.rotation === 180) {
39407
- const perSide = ic.heightPin;
39408
- const right = left + ic.widthPin - 1;
39409
- for (let i = 0; i < perSide; i++) {
39410
- pins.push({ pin: ic.rotation === 0 ? i + 1 : perSide * 2 - i, at: [left, top + i], side: "left" });
39411
- pins.push({ pin: ic.rotation === 0 ? perSide * 2 - i : i + 1, at: [right, top + i], side: "right" });
39412
- }
39413
- } else {
39414
- const perSide = ic.widthPin;
39415
- const bottom = top + ic.heightPin - 1;
39416
- for (let i = 0; i < perSide; i++) {
39417
- pins.push({ pin: ic.rotation === 90 ? i + 1 : perSide * 2 - i, at: [left + i, top], side: "top" });
39418
- pins.push({ pin: ic.rotation === 90 ? perSide * 2 - i : i + 1, at: [left + i, bottom], side: "bottom" });
39419
- }
39420
- }
39421
- return pins.sort((a, b) => a.pin - b.pin);
39422
- }
39423
-
39424
- // ../src/project-file/pin-positions.ts
39425
- var hole = (p2) => [Math.round(p2.x), Math.round(p2.y)];
39426
- function partPins(project) {
39427
- const parts = [];
39428
- for (const ic of project.placedIcs) {
39429
- const pins = icPins(ic).map(({ pin, at }) => ({ pin, ...ic.pinDescription[pin] ? { label: ic.pinDescription[pin] } : {}, at }));
39430
- const isPin = new Set(pins.map((p2) => `${p2.at[0]},${p2.at[1]}`));
39431
- const coveredHoles = [];
39432
- for (let col = ic.at[0]; col < ic.at[0] + ic.widthPin; col++) {
39433
- for (let row = ic.at[1]; row < ic.at[1] + ic.heightPin; row++) {
39434
- if (!isPin.has(`${col},${row}`)) coveredHoles.push([col, row]);
39435
- }
39436
- }
39437
- parts.push({
39438
- ref: ic.ref,
39439
- kind: "ic",
39440
- part: ic.name,
39441
- known: true,
39442
- pins,
39443
- coveredHoles,
39444
- body: boxAround(pins.map((p2) => ({ x: p2.at[0], y: p2.at[1] })), BODY_PAD)
39445
- });
39446
- }
39447
- for (const part of project.placedStandardComponents) {
39448
- const def = getComponentDefinition(part.definitionId);
39449
- const lead = (pin, at) => ({ pin, ...def?.leadLabels ? { label: def.leadLabels[pin - 1] } : {}, at });
39450
- parts.push({
39451
- ref: part.ref,
39452
- kind: "standard-component",
39453
- part: part.definitionId,
39454
- known: !!def,
39455
- pins: [lead(1, part.from), lead(2, part.to)],
39456
- coveredHoles: []
39457
- });
39458
- }
39459
- for (const part of project.placedAdvancedComponents) {
39460
- const def = getAdvancedComponentDefinition(part.definitionId);
39461
- if (!def) {
39462
- parts.push({ ref: part.ref, kind: "advanced-component", part: part.definitionId, known: false, pins: [{ pin: 1, at: part.at }], coveredHoles: [] });
39463
- continue;
39464
- }
39465
- const shape = advancedPartShape(def, part);
39466
- parts.push({
39467
- ref: part.ref,
39468
- kind: "advanced-component",
39469
- part: part.definitionId,
39470
- known: true,
39471
- pins: shape.pins.map((p2, i) => ({ pin: i + 1, ...!def.gridSizable && def.pinLabels?.[i] ? { label: def.pinLabels[i] } : {}, at: hole(p2) })),
39472
- coveredHoles: shape.covered.map(hole),
39473
- body: shape.body
39474
- });
39475
- }
39476
- return parts;
39477
- }
39478
-
39479
- // ../src/project-file/nets.ts
39480
- init_define_COMPONENT_ICONS();
39481
- init_define_EXAMPLE_PROJECTS();
39482
- init_define_PNG_FONTS();
39483
- var key = ([c, r2]) => `${c},${r2}`;
39484
- var POWER_NAME = /^([ADP]?GND|V(CC|DD|SS|EE|IN|BAT|BUS)\d*|V[+-]|[+-]?\d+(\.\d+)?V|\d+V\d+)$/i;
39485
- var isPowerName = (name) => POWER_NAME.test(name);
39486
- var MORE = "\u2026";
39487
- function isPowerNet(net) {
39488
- return !!net.name && net.name.split("/").every((name) => name === MORE || isPowerName(name));
39489
- }
39490
- function comparePins(a, b) {
39491
- return a.ref.localeCompare(b.ref, void 0, { numeric: true, sensitivity: "base" }) || a.pin - b.pin;
39492
- }
39493
- function pinId(pin) {
39494
- return pin.kind === "standard-component" && pin.label ? `${pin.ref}.${pin.label}` : `${pin.ref}.${pin.pin}`;
39495
- }
39496
- function pinName(pin) {
39497
- return pin.label && pin.kind !== "standard-component" ? `${pinId(pin)} ${pin.label}` : pinId(pin);
39498
- }
39499
- var POLARITY_MARK = /^[+\-−]$/;
39500
- function netName(pins) {
39501
- const names = pins.filter((p2) => p2.kind !== "standard-component").map((p2) => p2.label?.trim() ?? "").filter((name) => name && !POLARITY_MARK.test(name));
39502
- const distinct = names.filter((name, i) => names.findIndex((n) => n.toLowerCase() === name.toLowerCase()) === i);
39503
- const power = distinct.filter(isPowerName);
39504
- const shown = power.length ? power : distinct;
39505
- if (!shown.length) return void 0;
39506
- return shown.length > 3 ? `${shown.slice(0, 3).join("/")}/${MORE}` : shown.join("/");
39507
- }
39508
- function boardPins(project) {
39509
- return partPins(project).flatMap((part) => part.pins.map(({ pin, label, at }) => ({ ref: part.ref, kind: part.kind, pin, ...label ? { label } : {}, at })));
39510
- }
39511
- function computeNets(project) {
39512
- const board = project.board;
39513
- const cuts = new Set(board.type === "stripboard" ? board.cuts.map(key) : []);
39514
- const parent = /* @__PURE__ */ new Map();
39515
- const find = (node2) => {
39516
- let root = node2;
39517
- for (let up = parent.get(root); up !== void 0 && up !== root; up = parent.get(root)) root = up;
39518
- parent.set(node2, root);
39519
- return root;
39520
- };
39521
- const union2 = (a, b) => {
39522
- const ra = find(a);
39523
- const rb = find(b);
39524
- if (ra !== rb) parent.set(ra, rb);
39525
- };
39526
- let isolated = 0;
39527
- const nodeAt = (at) => cuts.has(key(at)) ? `cut#${isolated++}` : key(at);
39528
- if (board.type === "stripboard") {
39529
- const horizontal = board.strips === "horizontal";
39530
- const along = horizontal ? board.cols : board.rows;
39531
- const across = horizontal ? board.rows : board.cols;
39532
- for (let line = 0; line < across; line++) {
39533
- for (let i = 1; i < along; i++) {
39534
- const prev = horizontal ? [i - 1, line] : [line, i - 1];
39535
- const here = horizontal ? [i, line] : [line, i];
39536
- if (!cuts.has(key(prev)) && !cuts.has(key(here))) union2(key(prev), key(here));
39537
- }
39538
- }
39539
- }
39540
- const wireNodes = project.wires.map((wire) => {
39541
- const from = nodeAt(wire.from);
39542
- union2(from, nodeAt(wire.to));
39543
- return from;
39544
- });
39545
- const pinNodes = boardPins(project).map((pin) => ({ pin, node: nodeAt(pin.at) }));
39546
- const byRoot = /* @__PURE__ */ new Map();
39547
- const netFor = (node2) => {
39548
- const root = find(node2);
39549
- let net = byRoot.get(root);
39550
- if (!net) byRoot.set(root, net = { pins: [], wires: [], holes: [] });
39551
- return net;
39552
- };
39553
- const holeSeen = /* @__PURE__ */ new Set();
39554
- const addHole = (net, at) => {
39555
- if (cuts.has(key(at)) || holeSeen.has(key(at))) return;
39556
- holeSeen.add(key(at));
39557
- net.holes.push(at);
39558
- };
39559
- for (const { pin, node: node2 } of pinNodes) {
39560
- const net = netFor(node2);
39561
- net.pins.push(pin);
39562
- addHole(net, pin.at);
39563
- }
39564
- project.wires.forEach((wire, i) => {
39565
- const net = netFor(wireNodes[i]);
39566
- net.wires.push(i);
39567
- addHole(net, wire.from);
39568
- addHole(net, wire.to);
39569
- });
39570
- const nets = [...byRoot.values()];
39571
- for (const net of nets) {
39572
- net.pins.sort(comparePins);
39573
- const name = netName(net.pins);
39574
- if (name) net.name = name;
39575
- }
39576
- const rank = (net) => !net.pins.length ? 2 : isPowerNet(net) ? 0 : 1;
39577
- nets.sort((a, b) => rank(a) - rank(b) || (a.pins.length && b.pins.length ? comparePins(a.pins[0], b.pins[0]) : a.wires[0] - b.wires[0]));
39578
- return {
39579
- nets,
39580
- netAt(at) {
39581
- if (cuts.has(key(at)) || !parent.has(key(at))) return void 0;
39582
- return byRoot.get(find(key(at)));
39583
- }
39584
- };
39585
- }
39586
-
39587
40078
  // ../src/project-file/wire-crossings.ts
39588
40079
  init_define_COMPONENT_ICONS();
39589
40080
  init_define_EXAMPLE_PROJECTS();
39590
40081
  init_define_PNG_FONTS();
39591
- var key2 = ([c, r2]) => `${c},${r2}`;
39592
- var gcd = (a, b) => b ? gcd(b, a % b) : a;
39593
- function holesAlong2(leg) {
39594
- const [x1, y1] = leg.from;
39595
- const [x2, y2] = leg.to;
39596
- const steps = gcd(Math.abs(x2 - x1), Math.abs(y2 - y1));
39597
- const holes = [];
39598
- for (let k2 = 1; k2 < steps; k2++) holes.push({ at: [x1 + (x2 - x1) / steps * k2, y1 + (y2 - y1) / steps * k2], along: k2 / steps });
39599
- return holes;
39600
- }
40082
+ var key3 = ([c, r2]) => `${c},${r2}`;
39601
40083
  function measuredLegs(wire) {
39602
40084
  let start = 0;
39603
40085
  return wireLegs(wire).map((leg) => {
@@ -39607,30 +40089,15 @@ function measuredLegs(wire) {
39607
40089
  return measured;
39608
40090
  });
39609
40091
  }
39610
- function legsMeet(a, b) {
39611
- const [ax, ay] = a.from;
39612
- const [bx, by] = b.from;
39613
- const rx = a.to[0] - ax, ry = a.to[1] - ay;
39614
- const sx = b.to[0] - bx, sy = b.to[1] - by;
39615
- let denom = rx * sy - ry * sx;
39616
- if (denom === 0) return void 0;
39617
- let tNum = (bx - ax) * sy - (by - ay) * sx;
39618
- let uNum = (bx - ax) * ry - (by - ay) * rx;
39619
- if (denom < 0) [denom, tNum, uNum] = [-denom, -tNum, -uNum];
39620
- if (tNum < 0 || tNum > denom || uNum < 0 || uNum > denom) return void 0;
39621
- const t = tNum === 0 ? 0 : tNum === denom ? 1 : tNum / denom;
39622
- const u2 = uNum === 0 ? 0 : uNum === denom ? 1 : uNum / denom;
39623
- const at = t === 0 ? [ax, ay] : t === 1 ? [a.to[0], a.to[1]] : [ax + t * rx, ay + t * ry];
39624
- return { at, t, u: u2 };
39625
- }
39626
40092
  function layoutWires(wires, pinHoles) {
39627
- const pins = new Set(pinHoles.map(key2));
40093
+ const pins = new Set(pinHoles.map(key3));
39628
40094
  const ends2 = /* @__PURE__ */ new Map();
39629
- for (const wire of wires) {
39630
- for (const end of [wire.from, wire.to]) ends2.set(key2(end), (ends2.get(key2(end)) ?? 0) + 1);
40095
+ const jumper = (i) => !isSolderPath(wires[i]);
40096
+ for (const wire of wires.filter((_2, i) => jumper(i))) {
40097
+ for (const end of [wire.from, wire.to]) ends2.set(key3(end), (ends2.get(key3(end)) ?? 0) + 1);
39631
40098
  }
39632
- const holds = (at) => pins.has(key2(at)) || ends2.has(key2(at));
39633
- const legs = wires.map(measuredLegs);
40099
+ const holds = (at) => pins.has(key3(at)) || ends2.has(key3(at));
40100
+ const legs = wires.map((wire, i) => jumper(i) ? measuredLegs(wire) : []);
39634
40101
  const hops = [];
39635
40102
  legs.forEach((legsOfWire, i) => {
39636
40103
  legsOfWire.forEach(({ leg, start, length }, l) => {
@@ -39641,15 +40108,15 @@ function layoutWires(wires, pinHoles) {
39641
40108
  });
39642
40109
  });
39643
40110
  for (let i = 0; i < wires.length; i++) {
39644
- const endsOfI = /* @__PURE__ */ new Set([key2(wires[i].from), key2(wires[i].to)]);
40111
+ const endsOfI = /* @__PURE__ */ new Set([key3(wires[i].from), key3(wires[i].to)]);
39645
40112
  for (let j2 = i + 1; j2 < wires.length; j2++) {
39646
- const isEnd = (at) => endsOfI.has(key2(at)) || key2(at) === key2(wires[j2].from) || key2(at) === key2(wires[j2].to);
40113
+ const isEnd = (at) => endsOfI.has(key3(at)) || key3(at) === key3(wires[j2].from) || key3(at) === key3(wires[j2].to);
39647
40114
  const seen = /* @__PURE__ */ new Set();
39648
40115
  for (const a of legs[i]) {
39649
40116
  legs[j2].forEach((b, l) => {
39650
40117
  const meet = legsMeet(a.leg, b.leg);
39651
- if (!meet || isEnd(meet.at) || seen.has(key2(meet.at))) return;
39652
- seen.add(key2(meet.at));
40118
+ if (!meet || isEnd(meet.at) || seen.has(key3(meet.at))) return;
40119
+ seen.add(key3(meet.at));
39653
40120
  const leg = meet.u === 1 ? l + 1 : l;
39654
40121
  hops.push({ wire: j2, leg, at: meet.at, over: "wire", under: i, along: b.start + meet.u * b.length });
39655
40122
  });
@@ -39815,6 +40282,7 @@ var COPPER_COLOR = "#b7733b";
39815
40282
  var HOLE_COLOR = "#0a170b";
39816
40283
  var SOLDER_COLOR = "#d6dbe1";
39817
40284
  var SOLDER_EDGE = "#1e293b";
40285
+ var SOLDER_PATH_WIDTH = 9;
39818
40286
  var SELECTION_COLOR = "#38bdf8";
39819
40287
  var DEFAULT_WIRE_WIDTH = 4;
39820
40288
  var DEFAULT_WIRE_COLOR = "#777676";
@@ -39926,15 +40394,14 @@ var SOLDER_SHINE = "#ffffff";
39926
40394
  var CUT_COLOR = "#ef4444";
39927
40395
  var PIN1_COLOR = "#fbbf24";
39928
40396
  var REF_FONT = { family: "sans", size: 11, weight: 700 };
39929
- var key3 = ([col, row]) => `${col},${row}`;
40397
+ var key4 = ([col, row]) => `${col},${row}`;
39930
40398
  function solderJoints(project) {
39931
40399
  const joints = /* @__PURE__ */ new Map();
39932
40400
  for (const part of partPins(project)) {
39933
- for (const pin of part.pins) joints.set(key3(pin.at), pin.at);
40401
+ for (const pin of part.pins) joints.set(key4(pin.at), pin.at);
39934
40402
  }
39935
40403
  for (const wire of project.wires) {
39936
- joints.set(key3(wire.from), wire.from);
39937
- joints.set(key3(wire.to), wire.to);
40404
+ for (const at of isSolderPath(wire) ? solderPathHoles(wire) : [wire.from, wire.to]) joints.set(key4(at), at);
39938
40405
  }
39939
40406
  return [...joints.values()];
39940
40407
  }
@@ -39987,7 +40454,7 @@ var HOVER_RING_COLOR = "#e2e8f0";
39987
40454
  var NOTE_FONT = { family: "sans", size: 10 };
39988
40455
  var NOTE_COLOR = "#a4a0a0";
39989
40456
  var NOTE_PREVIEW_LENGTH = 5;
39990
- var key4 = ([col, row]) => `${col},${row}`;
40457
+ var key5 = ([col, row]) => `${col},${row}`;
39991
40458
  var SOLDER_FILL = {
39992
40459
  id: "solder-fill",
39993
40460
  radius: HOLE_RADIUS + 2,
@@ -40001,11 +40468,11 @@ function drawHoles(painter, project, look, hidden, view) {
40001
40468
  const holes = [];
40002
40469
  for (let col = 0; col < cols; col++) {
40003
40470
  for (let row = 0; row < rows; row++) {
40004
- if (!hidden.has(key4([col, row]))) holes.push({ x: gridToPx(col), y: gridToPx(row) });
40471
+ if (!hidden.has(key5([col, row]))) holes.push({ x: gridToPx(col), y: gridToPx(row) });
40005
40472
  }
40006
40473
  }
40007
40474
  painter.stamp(look.hole, holes);
40008
- painter.stamp(SOLDER_FILL, solderJoints(project).filter((at) => !hidden.has(key4(at))).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) })));
40475
+ painter.stamp(SOLDER_FILL, solderJoints(project).filter((at) => !hidden.has(key5(at))).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) })));
40009
40476
  drawHoleRings(painter, view, cols, rows);
40010
40477
  for (const pad of project.pads) {
40011
40478
  const hovered = isHovered(view, { kind: "hole", at: pad.at });
@@ -40051,12 +40518,16 @@ var JUNCTION_FILL = "#d1d5db";
40051
40518
  var JUNCTION_EDGE = "#374151";
40052
40519
  var JUNCTION_RADIUS = 6;
40053
40520
  var BEND_HANDLE_FILL = "#ffffff";
40521
+ var SOLDER_BEAD_RADIUS = PAD_RADIUS - 0.5;
40522
+ var SOLDER_SHINE2 = "#ffffff";
40054
40523
  var THROUGH_PART_OPACITY = 0.45;
40055
40524
  var BEND_RADIUS = 14;
40056
40525
  var BEND_STEPS = 6;
40057
40526
  var widthOf = (wire) => wire.width || DEFAULT_WIRE_WIDTH;
40527
+ var drawnWidthOf = (wire) => isSolderPath(wire) ? SOLDER_PATH_WIDTH : widthOf(wire);
40058
40528
  function wireLine(wire) {
40059
- return roundedWireLine(wirePoints(wire).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) })));
40529
+ const points = wirePoints(wire).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) }));
40530
+ return isSolderPath(wire) ? points : roundedWireLine(points);
40060
40531
  }
40061
40532
  function roundedWireLine(points) {
40062
40533
  if (points.length < 3) return points;
@@ -40085,6 +40556,7 @@ function drawWires(painter, wires, hops, view) {
40085
40556
  const hopsByWire = /* @__PURE__ */ new Map();
40086
40557
  for (const hop of hops) hopsByWire.set(hop.wire, [...hopsByWire.get(hop.wire) ?? [], hop]);
40087
40558
  wires.forEach((wire, index) => {
40559
+ if (isSolderPath(wire)) return;
40088
40560
  const line = wireLine(wire);
40089
40561
  const ends2 = [line[0], line[line.length - 1]];
40090
40562
  const width = widthOf(wire);
@@ -40100,6 +40572,34 @@ function drawWires(painter, wires, hops, view) {
40100
40572
  if (isSameItem(view.selected, item)) drawBendHandles(painter, wire);
40101
40573
  });
40102
40574
  }
40575
+ function drawSolderPaths(painter, wires, view) {
40576
+ wires.forEach((wire, index) => {
40577
+ if (!isSolderPath(wire)) return;
40578
+ const line = wireLine(wire);
40579
+ const item = { kind: "wire", index };
40580
+ const selected = isSameItem(view.selected, item);
40581
+ if (selected) {
40582
+ painter.line(line, { paint: SELECTION_COLOR, width: SOLDER_PATH_WIDTH + 8, cap: "round", join: "round" });
40583
+ } else if (isHovered(view, item)) {
40584
+ painter.line(line, { paint: HOVER_COLOR, width: SOLDER_PATH_WIDTH + 6, cap: "round", join: "round" });
40585
+ }
40586
+ drawSolderPath(painter, wire);
40587
+ if (selected) {
40588
+ for (const end of [line[0], line[line.length - 1]]) {
40589
+ painter.circle(end.x, end.y, widthOf(wire) + 3, { fill: SELECTION_COLOR, stroke: { paint: BEND_HANDLE_FILL, width: 1.5 } });
40590
+ }
40591
+ drawBendHandles(painter, wire);
40592
+ }
40593
+ });
40594
+ }
40595
+ function drawSolderPath(painter, wire) {
40596
+ const line = wireLine(wire);
40597
+ const beads = solderPathHoles(wire).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) }));
40598
+ painter.line(line, { paint: SOLDER_EDGE, width: SOLDER_PATH_WIDTH + 3, cap: "round", join: "round" });
40599
+ for (const bead of beads) painter.circle(bead.x, bead.y, SOLDER_BEAD_RADIUS, { fill: SOLDER_COLOR, stroke: { paint: SOLDER_EDGE, width: 1.5 } });
40600
+ painter.line(line, { paint: SOLDER_COLOR, width: SOLDER_PATH_WIDTH, cap: "round", join: "round" });
40601
+ for (const bead of beads) painter.circle(bead.x - 2.5, bead.y - 2.5, 2.2, { fill: SOLDER_SHINE2 });
40602
+ }
40103
40603
  function drawBendHandles(painter, wire) {
40104
40604
  const points = wirePoints(wire).map(([col, row]) => ({ x: gridToPx(col), y: gridToPx(row) }));
40105
40605
  const width = widthOf(wire);
@@ -40151,6 +40651,10 @@ function sliceLine(line, from, to) {
40151
40651
  function drawWiresThroughParts(painter, wires) {
40152
40652
  painter.group({ opacity: THROUGH_PART_OPACITY }, () => {
40153
40653
  for (const wire of wires) {
40654
+ if (isSolderPath(wire)) painter.line(wireLine(wire), { paint: SOLDER_COLOR, width: SOLDER_PATH_WIDTH, cap: "round", join: "round" });
40655
+ }
40656
+ for (const wire of wires) {
40657
+ if (isSolderPath(wire)) continue;
40154
40658
  painter.line(wireLine(wire), { paint: wire.color || DEFAULT_WIRE_COLOR, width: widthOf(wire), cap: "round", join: "round" });
40155
40659
  }
40156
40660
  });
@@ -40166,7 +40670,7 @@ var NET_HIGHLIGHT_COLOR = "#e879f9";
40166
40670
  function drawNetHighlight(painter, highlight) {
40167
40671
  painter.group({ opacity: 0.55 }, () => {
40168
40672
  for (const wire of highlight.wires) {
40169
- painter.line(wireLine(wire), { paint: NET_HIGHLIGHT_COLOR, width: (wire.width || DEFAULT_WIRE_WIDTH) + 8, cap: "round", join: "round" });
40673
+ painter.line(wireLine(wire), { paint: NET_HIGHLIGHT_COLOR, width: drawnWidthOf(wire) + 8, cap: "round", join: "round" });
40170
40674
  }
40171
40675
  });
40172
40676
  for (const [col, row] of highlight.holes) {
@@ -40202,7 +40706,7 @@ function boundingRect(points, pad = 0) {
40202
40706
  }
40203
40707
  var toPx = (p2) => ({ x: gridToPx(p2.x), y: gridToPx(p2.y) });
40204
40708
  function advancedPartGeometry(part) {
40205
- const def = getAdvancedComponentDefinition(part.definitionId);
40709
+ const def = advancedDefinitionFor(part);
40206
40710
  if (!def) return void 0;
40207
40711
  const shape = advancedPartShape(def, part);
40208
40712
  const { left, top, right, bottom } = shape.body;
@@ -40280,34 +40784,37 @@ function drawBody(painter, g, rotation3, look) {
40280
40784
  g.pins.forEach((pin, i) => {
40281
40785
  painter.circle(pin.x, pin.y, i === 0 ? PIN1_MARKER_RADIUS : PIN_MARKER_RADIUS, { fill: i === 0 ? PIN1_COLOR2 : PIN_COLOR });
40282
40786
  });
40283
- const icon = getIconFile(def);
40284
- const iconAvailable = painter.iconSize(icon) !== void 0;
40787
+ const icon = def.noIcon ? void 0 : getIconFile(def);
40788
+ const iconAvailable = icon !== void 0 && painter.iconSize(icon) !== void 0;
40285
40789
  const skipBody = def.iconFillsBody && iconAvailable;
40286
40790
  if (!skipBody) {
40287
40791
  drawBodyShape(painter, g, {
40288
- fill: look.selected ? BODY_COLOR_SELECTED : BODY_COLOR,
40792
+ fill: def.bodyColor ?? (look.selected ? BODY_COLOR_SELECTED : BODY_COLOR),
40289
40793
  stroke: { paint: look.selected ? SELECTION_COLOR : BORDER_COLOR, width: look.selected ? 3 : 2, ...look.ghost ? { dash: GHOST_DASH } : {} }
40290
40794
  });
40291
40795
  }
40292
- const quarterTurned = rotation3 === 90 || rotation3 === 270;
40293
- const { w: w2, h: h2 } = iconBox(painter, g, g.bodyRect, quarterTurned);
40294
40796
  let drawn = false;
40295
- painter.group({ translate: [g.iconAnchor.x, g.iconAnchor.y], rotate: rotation3 * Math.PI / 180 }, () => {
40296
- drawn = painter.image(icon, -w2 / 2, -h2 / 2, w2, h2);
40297
- });
40797
+ if (icon) {
40798
+ const { w: w2, h: h2 } = iconBox(painter, g, g.bodyRect, rotation3 === 90 || rotation3 === 270);
40799
+ painter.group({ translate: [g.iconAnchor.x, g.iconAnchor.y], rotate: rotation3 * Math.PI / 180 }, () => {
40800
+ drawn = painter.image(icon, -w2 / 2, -h2 / 2, w2, h2);
40801
+ });
40802
+ }
40298
40803
  if (!drawn) {
40299
40804
  painter.text(def.fallbackLabel, g.iconAnchor.x, g.iconAnchor.y, {
40300
- font: { family: "sans", size: 11, weight: 700 },
40805
+ font: { family: "sans", size: def.noIcon ? 13 : 11, weight: 700 },
40301
40806
  color: "#ffffff",
40302
40807
  align: "center",
40303
- baseline: "middle"
40808
+ baseline: "middle",
40809
+ // A user-made part's name is as long as its maker wrote it: kept within the body.
40810
+ ...def.noIcon ? { maxWidth: Math.max(10, g.bodyRect.w - 8), halo: LABEL_HALO } : {}
40304
40811
  });
40305
40812
  }
40306
40813
  if (skipBody && look.selected) drawBodyShape(painter, g, { stroke: { paint: SELECTION_COLOR, width: 3 } });
40307
40814
  const offset2 = def.pinLabelOffset ?? PIN_LABEL_OFFSET;
40308
40815
  const shift = rotateOffset(offset2.dx, offset2.dy, rotation3);
40309
40816
  g.pins.forEach((pin, i) => {
40310
- painter.text(def.pinLabels?.[i] ?? String(i + 1), pin.x + shift.x * GRID_PITCH_PX, pin.y + shift.y * GRID_PITCH_PX, {
40817
+ painter.text(def.pinLabels?.[i] || String(i + 1), pin.x + shift.x * GRID_PITCH_PX, pin.y + shift.y * GRID_PITCH_PX, {
40311
40818
  font: PIN_LABEL_FONT,
40312
40819
  color: PIN_LABEL_COLOR,
40313
40820
  align: "center",
@@ -40513,19 +41020,19 @@ var SvgPainter = class {
40513
41020
  return inner;
40514
41021
  }
40515
41022
  // The id of a def, writing it the first time it's asked for.
40516
- defineOnce(key5, write) {
40517
- let id = this.ids.get(key5);
41023
+ defineOnce(key6, write) {
41024
+ let id = this.ids.get(key6);
40518
41025
  if (!id) {
40519
41026
  id = `${this.options.idPrefix ?? "b"}${this.nextId++}`;
40520
- this.ids.set(key5, id);
41027
+ this.ids.set(key6, id);
40521
41028
  this.defs.push(write(id));
40522
41029
  }
40523
41030
  return id;
40524
41031
  }
40525
41032
  paint(paint) {
40526
41033
  if (typeof paint === "string") return safeColor(paint);
40527
- const key5 = `grad:${JSON.stringify(paint)}`;
40528
- return `url(#${this.defineOnce(key5, (id) => `<linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="${num(paint.x1)}" y1="${num(paint.y1)}" x2="${num(paint.x2)}" y2="${num(paint.y2)}">` + paint.stops.map((s) => `<stop offset="${num(s.offset)}" stop-color="${safeColor(s.color)}"/>`).join("") + `</linearGradient>`)})`;
41034
+ const key6 = `grad:${JSON.stringify(paint)}`;
41035
+ return `url(#${this.defineOnce(key6, (id) => `<linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="${num(paint.x1)}" y1="${num(paint.y1)}" x2="${num(paint.x2)}" y2="${num(paint.y2)}">` + paint.stops.map((s) => `<stop offset="${num(s.offset)}" stop-color="${safeColor(s.color)}"/>`).join("") + `</linearGradient>`)})`;
40529
41036
  }
40530
41037
  styleAttrs({ fill, stroke }) {
40531
41038
  let attrs = ` fill="${fill ? this.paint(fill) : "none"}"`;
@@ -41100,12 +41607,6 @@ var RESISTOR_BODY_PATH = "M7 62c-5.5-6-5.5-18 0-24 8-7 77-7 85 0 5.5 6 5.5 18 0
41100
41607
  var CERAMIC_CODE_COLOR = "#3a2410";
41101
41608
  var CERAMIC_CODE_FONT_RATIO = 0.4;
41102
41609
  var LED_BODY_PATH = "M6 23.47A48 48 0 1 1 6 76.53Z";
41103
- var LED_SOLID_COLORS = {
41104
- red: "#ef4444",
41105
- green: "#22c55e",
41106
- blue: "#3b82f6",
41107
- yellow: "#facc15"
41108
- };
41109
41610
  var LED_RGB_STRIPE_COLORS = ["#ef4444", "#22c55e", "#3b82f6"];
41110
41611
  function inIconUnits(painter, bodyStart, bodySize, clip, draw) {
41111
41612
  painter.group({ translate: [bodyStart, -bodySize / 2], scale: bodySize / 100, clip }, draw);
@@ -41138,7 +41639,7 @@ var ledColor = (painter, part, bodyStart, bodySize) => {
41138
41639
  const stripe = 100 / LED_RGB_STRIPE_COLORS.length;
41139
41640
  LED_RGB_STRIPE_COLORS.forEach((stripeColor, i) => painter.rect(0, i * stripe, 100, stripe, { fill: stripeColor }));
41140
41641
  } else {
41141
- painter.rect(0, 0, 100, 100, { fill: LED_SOLID_COLORS[color] ?? color });
41642
+ painter.rect(0, 0, 100, 100, { fill: ledPaint(color) ?? color });
41142
41643
  }
41143
41644
  });
41144
41645
  };
@@ -41315,6 +41816,7 @@ function drawBoard(painter, project, view = PLAIN_VIEW) {
41315
41816
  if (view.holeLabels) drawHoleLabels(painter, project.board, width, height);
41316
41817
  drawLayer("under-board");
41317
41818
  drawHoles(painter, project, look, holesUnderChips(project), view);
41819
+ drawSolderPaths(painter, project.wires, view);
41318
41820
  drawWires(painter, project.wires, wireLayout.hops, view);
41319
41821
  drawLayer("over-wires");
41320
41822
  drawWiresThroughParts(painter, project.wires);
@@ -41347,6 +41849,7 @@ function drawSolderSide(painter, project, holeLabels) {
41347
41849
  painter.group({ opacity: GHOST_PARTS }, () => drawLayer("under-board"));
41348
41850
  painter.group({ opacity: GHOST_WIRES }, () => drawWires(painter, project.wires, [], PLAIN_VIEW));
41349
41851
  painter.group({ opacity: GHOST_PARTS }, () => drawLayer("over-wires"));
41852
+ for (const wire of project.wires) if (isSolderPath(wire)) drawSolderPath(painter, wire);
41350
41853
  });
41351
41854
  if (holeLabels) drawHoleLabels(painter, project.board, width, height, true);
41352
41855
  if (project.board.type === "stripboard") drawCutMarks(painter, project.board.cuts, width);
@@ -41894,9 +42397,9 @@ function json2(value, indent = "") {
41894
42397
  if (Array.isArray(value)) return `[
41895
42398
  ${value.map((item) => inner + json2(item, inner)).join(",\n")}
41896
42399
  ${indent}]`;
41897
- const entries = Object.entries(value).filter(([, item]) => item !== void 0);
42400
+ const entries2 = Object.entries(value).filter(([, item]) => item !== void 0);
41898
42401
  return `{
41899
- ${entries.map(([key5, item]) => `${inner}${JSON.stringify(key5)}: ${json2(item, inner)}`).join(",\n")}
42402
+ ${entries2.map(([key6, item]) => `${inner}${JSON.stringify(key6)}: ${json2(item, inner)}`).join(",\n")}
41900
42403
  ${indent}}`;
41901
42404
  }
41902
42405
  var textReply = (text2) => ({ content: [{ type: "text", text: text2 }] });
@@ -42051,7 +42554,7 @@ var offBoard = (cols, rows) => `off the ${cols}\xD7${rows} board (columns 0-${co
42051
42554
  var errorMessage = (err) => err instanceof Error ? err.message : String(err);
42052
42555
 
42053
42556
  // src/project-source.ts
42054
- var projectInput = union([record(string2(), unknown()), string2()]).optional().describe("The whole project file: a version 3 or 4 project object, or its JSON text (see the perfboard://docs/project-file resource). Give this or projectId.");
42557
+ var projectInput = union([record(string2(), unknown()), string2()]).optional().describe("The whole project file (through version 8), or its JSON text (see perfboard://docs/project-file). Give this or projectId. Preserve instanceId and optional requirements fields.");
42055
42558
  var projectIdInput = string2().optional().describe("The id of a project kept here (from new_project, validate_project, edit_project or read_share_link), instead of sending the whole project.");
42056
42559
  var holeInput = array(number2().int()).length(2).describe("A hole, [column, row].");
42057
42560
  var expectNetsInput = array(array(string2())).optional().describe(`The nets the board should make: each a list of pins written REF.pin, e.g. [["U1.8", "U1.4", "R1.1", "J1.1"], ["U1.2", "U1.6", "C1.+"]]. A pin can also be named by its label ("U1.VCC", "D1.K") or as get_nets writes it ("U1.8 VCC"). List every net of two or more pins: a pin in none of them should connect to nothing. With a projectId it's remembered for that project, so later checks use it too; [] forgets it.`);
@@ -42085,10 +42588,31 @@ function expectedNets(given, held) {
42085
42588
  var wireEnd = union([array(number2().int()).length(2), string2()]).describe('A hole [column, row], or a pin by name: "U1.7", "U1.DISCH", "D1.K", "R2.1" (the hole that pin is in).');
42086
42589
  var rotation2 = union([literal(0), literal(90), literal(180), literal(270)]);
42087
42590
  var wireSelector = union([number2().int().min(0), array(holeInput).length(2)]).describe("A wire by its index in wires, or by its two end holes [[c, r], [c, r]] (either way round).");
42591
+ var customPart = object({
42592
+ name: string2().describe('What it is, e.g. "HC-SR04", "BC337". Later add_part ops can place more of it by this name.'),
42593
+ shape: string2().optional().describe(`The id of a fixed-pin part from list_parts whose package this part comes in, e.g. "transistor" (TO-92) for a BC337 or "mosfet" (TO-220) for an IRLZ44N: its pins, outline and look, with this part's name and pin names. Any fixed-pin part but header-pins. Leave out for a body of your own with pins anywhere.`),
42594
+ pins: array(object({
42595
+ at: holeInput.optional().describe("Without shape: the pin's hole [column, row] within the body, from its top-left hole. With shape: leave out, the package decides."),
42596
+ label: string2().optional().describe('Its name, e.g. "VCC", "TRIG", "B". Wire to it by name ("M1.VCC").')
42597
+ })).optional().describe("In pin order, pin 1 first; pin 1 is the hole add_part's `at` places it by. Without shape: every pin with its `at`. With shape: just their names, in the package's pin order (get_part gives it), as many as it has pins."),
42598
+ cols: number2().int().min(1).optional().describe("Without shape: the body's width in holes. Default: just wide enough for its pins."),
42599
+ rows: number2().int().min(1).optional().describe("Without shape: the body's height in holes. Default: just tall enough for its pins."),
42600
+ refPrefix: string2().optional().describe(`Letters of its refs: "Q" makes Q1, Q2. Default: the package's, else "M".`),
42601
+ color: string2().optional().describe(`Without shape: the body's colour, "#rrggbb", e.g. a blue module board "#1d4ed8".`)
42602
+ });
42603
+ var customChip = object({
42604
+ name: string2().describe('What it is, e.g. "LM358", "ESP32 DevKit". Later add_part ops can place more of it by this name.'),
42605
+ pinsPerSide: number2().int().min(2).describe("Pins in each of its two rows."),
42606
+ width: number2().int().min(2).describe(`Columns from one pin row to the other, both included: 4 for a narrow (0.3") DIP, 7 for a wide (0.6") one; a dev board's row spacing in holes plus one.`),
42607
+ pins: array(string2()).optional().describe('Pin names in DIP order: pin 1 at the top of the left row (at rotation 0), down the left row, then up the right row, so the last pin is at the top right. "" for a pin without a name.'),
42608
+ board: boolean2().optional().describe("true: a dev board or module (drawn as a board, listed under Modules); else a DIP chip.")
42609
+ });
42088
42610
  var editOp = discriminatedUnion("op", [
42089
42611
  object({
42090
42612
  op: literal("add_part"),
42091
- part: string2().describe(`The part's id from list_parts ("resistor", "ne555", "header-pins"), or the name of one of the project's customIcs.`),
42613
+ part: string2().optional().describe('The part\'s id from list_parts ("resistor", "ne555", "header-pins"), or the name of a custom part or chip the project already has. Give this, `custom` or `chip`.'),
42614
+ custom: customPart.optional().describe("Instead of `part`, a new part of your own for one the catalog doesn't have, placed by `at` and `rotation`."),
42615
+ chip: customChip.optional().describe("Instead of `part`, a new dual-row chip or dev board of your own, placed by `at` (its top-left pin) and `rotation`."),
42092
42616
  ref: string2().optional().describe("Its reference designator. The next free one (R1, R2...) when left out."),
42093
42617
  from: holeInput.optional().describe("Two-lead parts: the hole of lead 1. On a polarized part get_part's leadLabels say which that is: K for a diode or LED, - for an electrolytic."),
42094
42618
  to: holeInput.optional().describe("Two-lead parts: the hole of lead 2."),
@@ -42120,6 +42644,7 @@ var editOp = discriminatedUnion("op", [
42120
42644
  to: wireEnd.optional(),
42121
42645
  via: array(holeInput).optional().describe("With from/to: the holes the wire bends at on its way, in order, to route it around things as one wire. A bend joins nothing, like a hole the wire passes over, so it's soldered only at its two ends."),
42122
42646
  path: array(wireEnd).min(2).optional().describe("Instead of from/to: holes (or pins) to run through in order, made into one wire per leg. Each corner is a wire end, so it joins whatever is in that hole. For corners that only bend, use from/to with via."),
42647
+ solder: boolean2().optional().describe("true: a solder path instead of a jumper wire, a trail of solder on the copper side, made as one path (a `path`'s corners and any `via` are its bends). Bare solder joins every hole it runs over, ends, bends and all, and every solder path it touches: run it only over holes it should connect. No color or width."),
42123
42648
  color: string2().optional(),
42124
42649
  width: number2().positive().optional()
42125
42650
  }),
@@ -42261,6 +42786,8 @@ function applyEdits(project, ops) {
42261
42786
  throw err;
42262
42787
  }
42263
42788
  });
42789
+ ensureComponentIds(draft);
42790
+ if (draft.requirements) draft.requirements = includeRequiredComponents(draft.requirements, draft);
42264
42791
  draft.version = fileVersionFor(draft);
42265
42792
  const refs = new Set(allParts(draft).map((part) => part.ref));
42266
42793
  return { project: draft, changes, placed: [...placed].filter((ref) => refs.has(ref)) };
@@ -42299,10 +42826,22 @@ function pinsOf(project, refs) {
42299
42826
  return result;
42300
42827
  }
42301
42828
  function addPart(project, op, placed) {
42302
- const part = findPart(op.part);
42303
- const custom2 = part ? void 0 : project.customIcs.find((ic) => ic.name.toLowerCase() === op.part.trim().toLowerCase());
42304
- if (!part && !custom2) throw new OpError(`${noSuchPart(op.part)} Use list_parts to find one.`);
42305
- if (part?.kind === "standard-component") {
42829
+ const given = [op.part, op.custom, op.chip].filter((field) => field !== void 0).length;
42830
+ if (given !== 1) {
42831
+ throw new OpError("Give one of `part` (a catalog id, or the name of a custom part or chip the project has), `custom` (a new part of your own) or `chip` (a new chip or dev board of your own).");
42832
+ }
42833
+ if (op.custom) return placeCustomPart(project, op, makeCustomPart(project, op.custom), true, placed);
42834
+ if (op.chip) return placeChip(project, op, makeChip(project, op.chip), true, placed);
42835
+ const name = op.part;
42836
+ const part = findPart(name);
42837
+ if (!part) {
42838
+ const chip = findCustomChip(project, name);
42839
+ if (chip) return placeChip(project, op, chip, false, placed);
42840
+ const custom2 = findCustomPart(project, name);
42841
+ if (custom2) return placeCustomPart(project, op, structuredClone(custom2), false, placed);
42842
+ throw new OpError(`${noSuchPart(name)} Use list_parts to find one, or make it with \`custom\` or \`chip\`.`);
42843
+ }
42844
+ if (part.kind === "standard-component") {
42306
42845
  notFor(`a two-lead part (${part.id})`, op, ["at", "rotation", "rows", "cols"]);
42307
42846
  if (!op.from || !op.to) throw new OpError(`${part.id} is a two-lead part: give \`from\` and \`to\`, the holes of its two leads.`);
42308
42847
  checkOnBoard(project, op.from, "`from`");
@@ -42319,20 +42858,15 @@ function addPart(project, op, placed) {
42319
42858
  placed.add(ref2);
42320
42859
  return `Added ${ref2} (${part.name}${op.value ? ` ${op.value}` : ""}) from ${showHole(op.from)} to ${showHole(op.to)}.`;
42321
42860
  }
42322
- notFor("a part placed by `at`", op, ["from", "to", "color"]);
42323
- if (!op.at) throw new OpError("Give `at`: the hole of pin 1 (a chip's or pin block's top-left pin).");
42324
- checkOnBoard(project, op.at, "`at`");
42325
- const at = toGridPos(op.at);
42326
- const rotation3 = op.rotation ?? 0;
42327
- const turned = rotation3 ? `, turned ${rotation3}\xB0` : "";
42328
- if (part?.kind === "advanced-component") {
42861
+ const { at, turned } = placedBy(project, op);
42862
+ if (part.kind === "advanced-component") {
42329
42863
  if (!part.sizable) notFor(`${part.id} (not a pin block)`, op, ["rows", "cols"]);
42330
42864
  const ref2 = claimRef(project, op.ref, part.refPrefix);
42331
42865
  project.placedAdvancedComponents.push({
42332
42866
  ref: ref2,
42333
42867
  definitionId: part.id,
42334
42868
  at,
42335
- rotation: rotation3,
42869
+ rotation: op.rotation ?? 0,
42336
42870
  rows: op.rows ?? 1,
42337
42871
  cols: op.cols ?? 1,
42338
42872
  ...op.value ? { value: op.value } : {}
@@ -42342,24 +42876,167 @@ function addPart(project, op, placed) {
42342
42876
  }
42343
42877
  notFor("a chip", op, ["rows", "cols", "value"]);
42344
42878
  const ref = claimRef(project, op.ref, "U");
42345
- if (part?.kind === "ic") {
42346
- project.placedIcs.push(icEntry(part, at, rotation3, ref));
42879
+ project.placedIcs.push(icEntry(part, at, op.rotation ?? 0, ref));
42880
+ placed.add(ref);
42881
+ return `Added ${ref} (${part.name}) with its top-left pin at ${showHole(at)}${turned}.`;
42882
+ }
42883
+ function placedBy(project, op) {
42884
+ notFor("a part placed by `at`", op, ["from", "to", "color"]);
42885
+ if (!op.at) throw new OpError("Give `at`: the hole of pin 1 (a chip's or pin block's top-left pin).");
42886
+ checkOnBoard(project, op.at, "`at`");
42887
+ return { at: toGridPos(op.at), turned: op.rotation ? `, turned ${op.rotation}\xB0` : "" };
42888
+ }
42889
+ var REF_LETTERS = /^[A-Z]{1,4}$/;
42890
+ var MAX_NAME = 60;
42891
+ var MAX_PIN_NAME = 24;
42892
+ function findCustomPart(project, name) {
42893
+ const wanted = name.trim().toLowerCase();
42894
+ return project.placedAdvancedComponents.find((part) => part.custom?.name.toLowerCase() === wanted)?.custom;
42895
+ }
42896
+ function findCustomChip(project, name) {
42897
+ const wanted = name.trim().toLowerCase();
42898
+ return project.customIcs.find((ic) => ic.name.toLowerCase() === wanted);
42899
+ }
42900
+ function newPartName(given, what) {
42901
+ const name = given.trim();
42902
+ if (!name) throw new OpError(`\`${what}.name\` is empty: name the part, e.g. "BC337".`);
42903
+ if (name.length > MAX_NAME) throw new OpError(`\`${what}.name\` is longer than ${MAX_NAME} characters.`);
42904
+ const catalog = findPart(name);
42905
+ if (catalog) throw new OpError(`"${name}" is already the catalog's ${catalog.name} (id ${catalog.id}): place that with \`part\`, or give yours another name.`);
42906
+ return name;
42907
+ }
42908
+ function checkedPinName(label, i, what) {
42909
+ const name = label?.trim() ?? "";
42910
+ if (name.length > MAX_PIN_NAME) throw new OpError(`${what} pin ${i + 1}'s name is longer than ${MAX_PIN_NAME} characters.`);
42911
+ return name;
42912
+ }
42913
+ function makeCustomPart(project, custom2) {
42914
+ const name = newPartName(custom2.name, "custom");
42915
+ if (findCustomChip(project, name)) throw new OpError(`The project already has a custom chip named "${name}": give this part another name.`);
42916
+ const existing = findCustomPart(project, name);
42917
+ const refPrefix = custom2.refPrefix?.trim().toUpperCase();
42918
+ if (refPrefix !== void 0 && !REF_LETTERS.test(refPrefix)) throw new OpError("`custom.refPrefix` is 1 to 4 letters, such as M or Q.");
42919
+ const pins = custom2.pins ?? [];
42920
+ const labels = pins.map((pin, i) => checkedPinName(pin.label, i, "`custom.pins`:"));
42921
+ let spec;
42922
+ if (custom2.shape !== void 0) {
42923
+ const shape = customPartShape(custom2.shape);
42924
+ if (!shape) {
42925
+ const part = findPart(custom2.shape);
42926
+ throw new OpError(part ? `${part.id} can't be a custom part's \`shape\`: give a fixed-pin part from list_parts other than header-pins, such as "transistor" (TO-92) or "mosfet" (TO-220).` : `${noSuchPart(custom2.shape)} \`custom.shape\` is the id of a fixed-pin part from list_parts, such as "transistor" (TO-92) or "mosfet" (TO-220).`);
42927
+ }
42928
+ const holes = ["cols", "rows", "color"].filter((field) => custom2[field] !== void 0);
42929
+ if (pins.some((pin) => pin.at)) holes.push("pins[].at");
42930
+ if (holes.length) throw new OpError(`With \`shape\` the package decides the part's holes and look: leave out ${holes.map((f2) => `\`custom.${f2}\``).join(", ")}.`);
42931
+ if (labels.length > shape.pinOffsets.length) {
42932
+ throw new OpError(`${shape.name} has ${plural2(shape.pinOffsets.length, "pin")}, but \`custom.pins\` names ${labels.length}.`);
42933
+ }
42934
+ spec = shapedPartSpec(shape, { name, ...refPrefix ? { refPrefix } : {}, labels });
42347
42935
  } else {
42348
- const ic = custom2;
42349
- const sideways = rotation3 === 90 || rotation3 === 270;
42350
- project.placedIcs.push({
42351
- ref,
42352
- name: ic.name,
42353
- at,
42354
- rotation: rotation3,
42355
- widthPin: sideways ? ic.heightPin : ic.widthPin,
42356
- heightPin: sideways ? ic.widthPin : ic.heightPin,
42357
- pinDescription: { ...ic.pinDescription },
42358
- ...ic.category ? { category: ic.category } : {}
42359
- });
42936
+ if (!pins.length) {
42937
+ throw new OpError("`custom.pins` needs every pin's hole `at` within the body, pin 1 first. Or give `custom.shape` to take a catalog part's package.");
42938
+ }
42939
+ const holes = pins.map((pin, i) => {
42940
+ if (!pin.at) throw new OpError(`\`custom.pins[${i}]\` has no \`at\`: without \`shape\`, give each pin's hole within the body.`);
42941
+ if (pin.at[0] < 0 || pin.at[1] < 0) throw new OpError(`\`custom.pins[${i}].at\` ${showHole(pin.at)} is outside the body: holes count from its top-left one, [0, 0].`);
42942
+ return toGridPos(pin.at);
42943
+ });
42944
+ const cols = custom2.cols ?? Math.max(...holes.map((at) => at[0])) + 1;
42945
+ const rows = custom2.rows ?? Math.max(...holes.map((at) => at[1])) + 1;
42946
+ if (cols > MAX_CUSTOM_PART_SIDE || rows > MAX_CUSTOM_PART_SIDE) {
42947
+ throw new OpError(`The body is ${cols}\xD7${rows} holes; a custom part is at most ${MAX_CUSTOM_PART_SIDE} holes a side.`);
42948
+ }
42949
+ holes.forEach((at, i) => {
42950
+ if (at[0] >= cols || at[1] >= rows) throw new OpError(`\`custom.pins[${i}].at\` ${showHole(at)} is outside a body of ${cols}\xD7${rows} holes.`);
42951
+ const first = holes.findIndex((other) => sameHole(other, at));
42952
+ if (first < i) throw new OpError(`Pins ${first + 1} and ${i + 1} are both at ${showHole(at)}: each pin needs its own hole.`);
42953
+ });
42954
+ const color = custom2.color?.trim();
42955
+ spec = {
42956
+ name,
42957
+ ...refPrefix ? { refPrefix } : {},
42958
+ cols,
42959
+ rows,
42960
+ pins: holes.map((at, i) => ({ at, ...labels[i] ? { label: labels[i] } : {} })),
42961
+ ...color ? { color } : {}
42962
+ };
42963
+ }
42964
+ const read = readCustomPart(spec);
42965
+ if (!read) throw new OpError("That custom part can't be saved: check its pins and size.");
42966
+ if (existing && JSON.stringify({ ...existing, id: void 0 }) !== JSON.stringify({ ...read, id: void 0 })) {
42967
+ throw new OpError(`The board already has a different custom part named "${name}": place that one with \`part\`, or give this one another name.`);
42360
42968
  }
42969
+ return read;
42970
+ }
42971
+ function placeCustomPart(project, op, spec, isNew, placed) {
42972
+ notFor("a custom part", op, ["rows", "cols"]);
42973
+ const { at, turned } = placedBy(project, op);
42974
+ const ref = claimRef(project, op.ref, customPartDefinition(spec).refPrefix);
42975
+ project.placedAdvancedComponents.push({
42976
+ ref,
42977
+ definitionId: CUSTOM_PART_ID,
42978
+ at,
42979
+ rotation: op.rotation ?? 0,
42980
+ rows: 1,
42981
+ cols: 1,
42982
+ ...op.value ? { value: op.value } : {},
42983
+ custom: spec
42984
+ });
42361
42985
  placed.add(ref);
42362
- return `Added ${ref} (${part?.name ?? custom2.name}) with its top-left pin at ${showHole(at)}${turned}.`;
42986
+ const shape = customPartShape(spec.shape);
42987
+ const what = shape ? `in the ${shape.name} package` : `${spec.cols}\xD7${spec.rows} holes, ${plural2(spec.pins.length, "pin")}`;
42988
+ return `Added ${ref} (${spec.name}, ${isNew ? "a new custom part" : "custom"}, ${what}) with pin 1 at ${showHole(at)}${turned}.`;
42989
+ }
42990
+ function makeChip(project, chip) {
42991
+ const name = newPartName(chip.name, "chip");
42992
+ if (findCustomPart(project, name)) throw new OpError(`The board already has a custom part named "${name}": give this chip another name.`);
42993
+ const total = chip.pinsPerSide * 2;
42994
+ const names = chip.pins ?? [];
42995
+ if (names.length > total) throw new OpError(`A chip with ${chip.pinsPerSide} pins a side has ${total} pins, but \`chip.pins\` names ${names.length}.`);
42996
+ const pinDescription = {};
42997
+ names.forEach((label, i) => {
42998
+ const pin = checkedPinName(label, i, "`chip.pins`:");
42999
+ if (pin) pinDescription[i + 1] = pin;
43000
+ });
43001
+ const entry = {
43002
+ name,
43003
+ widthPin: chip.width,
43004
+ heightPin: chip.pinsPerSide,
43005
+ pinDescription,
43006
+ category: chip.board ? "modules.custom" : "ics.custom"
43007
+ };
43008
+ const existing = findCustomChip(project, name);
43009
+ if (existing) {
43010
+ const same = existing.widthPin === entry.widthPin && existing.heightPin === entry.heightPin && JSON.stringify(existing.pinDescription) === JSON.stringify(entry.pinDescription) && (existing.category ?? "ics.custom") === entry.category;
43011
+ if (!same) throw new OpError(`The project already has a different custom chip named "${name}": place that one with \`part\`, or give this one another name.`);
43012
+ return existing;
43013
+ }
43014
+ project.customIcs.push({ id: 1e3 + hashOf(JSON.stringify(entry)), ...entry });
43015
+ return project.customIcs[project.customIcs.length - 1];
43016
+ }
43017
+ function placeChip(project, op, chip, isNew, placed) {
43018
+ notFor("a chip", op, ["rows", "cols", "value"]);
43019
+ const { at, turned } = placedBy(project, op);
43020
+ const rotation3 = op.rotation ?? 0;
43021
+ const ref = claimRef(project, op.ref, "U");
43022
+ const sideways = rotation3 === 90 || rotation3 === 270;
43023
+ project.placedIcs.push({
43024
+ ref,
43025
+ name: chip.name,
43026
+ at,
43027
+ rotation: rotation3,
43028
+ widthPin: sideways ? chip.heightPin : chip.widthPin,
43029
+ heightPin: sideways ? chip.widthPin : chip.heightPin,
43030
+ pinDescription: { ...chip.pinDescription },
43031
+ ...chip.category ? { category: chip.category } : {}
43032
+ });
43033
+ placed.add(ref);
43034
+ return `Added ${ref} (${chip.name}${isNew ? ", a new custom chip" : ""}) with its top-left pin at ${showHole(at)}${turned}.`;
43035
+ }
43036
+ function hashOf(text2) {
43037
+ let hash2 = 2166136261;
43038
+ for (let i = 0; i < text2.length; i++) hash2 = Math.imul(hash2 ^ text2.charCodeAt(i), 16777619);
43039
+ return (hash2 >>> 0) % 1e9;
42363
43040
  }
42364
43041
  function updatePart(project, op, placed) {
42365
43042
  const found = findRef(project, op.ref);
@@ -42459,6 +43136,7 @@ function notFor(kind, op, fields) {
42459
43136
  }
42460
43137
  function addWire(project, op) {
42461
43138
  if (op.path && (op.from || op.to)) throw new OpError("Give either `path` or `from` and `to`, not both.");
43139
+ if (op.solder) return addSolderPath(project, op);
42462
43140
  if (op.path && op.via) throw new OpError("`via` goes with `from` and `to`; a `path`'s corners are wire ends instead.");
42463
43141
  if (op.via && op.from && op.to) return addBentWire(project, op, op.from, op.to, op.via);
42464
43142
  const given = op.path ?? (op.from && op.to ? [op.from, op.to] : void 0);
@@ -42491,6 +43169,22 @@ function addBentWire(project, op, fromEnd, toEnd, via) {
42491
43169
  project.wires.push(wire);
42492
43170
  return `Added wires[${project.wires.length - 1}] from ${from.said} to ${to.said}${bendsSaid(wire)}.`;
42493
43171
  }
43172
+ function addSolderPath(project, op) {
43173
+ if (op.color !== void 0 || op.width !== void 0) throw new OpError("A solder path is bare solder: it takes no `color` or `width`.");
43174
+ if (op.path && op.via) throw new OpError("Give a solder path's bends as `path` or as `via` with `from` and `to`, not both.");
43175
+ const given = op.path ?? (op.from && op.to ? [op.from, ...op.via ?? [], op.to] : void 0);
43176
+ if (!given) throw new OpError("A solder path needs `from` and `to`, or a `path` of two or more holes.");
43177
+ const points = given.map((end, i) => wireEndAt(project, end, op.path ? `path[${i}]` : i === 0 ? "`from`" : i === given.length - 1 ? "`to`" : `via[${i - 1}]`));
43178
+ const [from, to] = [points[0], points[points.length - 1]];
43179
+ const wire = {
43180
+ from: from.at,
43181
+ to: to.at,
43182
+ ...withBends(project, from.at, to.at, points.slice(1, -1).map((point) => point.at)),
43183
+ kind: "solder"
43184
+ };
43185
+ project.wires.push(wire);
43186
+ return `Added wires[${project.wires.length - 1}], a solder path from ${from.said} to ${to.said}${bendsSaid(wire)}.`;
43187
+ }
42494
43188
  function withBends(project, from, to, via) {
42495
43189
  via.forEach((at, k2) => checkOnBoard(project, at, `via[${k2}]`));
42496
43190
  const points = [from, ...via.map(toGridPos), to].filter((at, i, all) => i === 0 || !sameHole(at, all[i - 1]));
@@ -42503,6 +43197,9 @@ function updateWire(project, op) {
42503
43197
  const i = findWire(project, op.wire);
42504
43198
  const from = op.from === void 0 ? void 0 : wireEndAt(project, op.from, "`from`");
42505
43199
  const to = op.to === void 0 ? void 0 : wireEndAt(project, op.to, "`to`");
43200
+ if (isSolderPath(project.wires[i]) && (op.color !== void 0 || op.width !== void 0)) {
43201
+ throw new OpError(`wires[${i}] is a solder path: it has no \`color\` or \`width\`.`);
43202
+ }
42506
43203
  const updated = {
42507
43204
  ...project.wires[i],
42508
43205
  ...from ? { from: from.at } : {},
@@ -42678,12 +43375,16 @@ function validateProject(raw, expectNets) {
42678
43375
  const bent = (Array.isArray(data.wires) ? data.wires : []).flatMap((wire, i) => asEntry2(wire)?.via !== void 0 ? [wireName(i)] : []);
42679
43376
  if (bent.length) report.warn(`${joinList(bent)} ${bent.length === 1 ? "has" : "have"} "via" corners, which version ${data.version} files don't have, so ${bent.length === 1 ? "it was" : "they were"} read as straight. Set "version": ${PROJECT_FILE_VERSION} to keep the bends.`);
42680
43377
  }
42681
- const entries = readEntriesAlone(data, project);
42682
- report.problems.push(...entries.unreadable);
42683
- const unnamed = skipped - entries.unreadable.length;
43378
+ if (typeof data.version === "number" && data.version < 5) {
43379
+ const solder = (Array.isArray(data.wires) ? data.wires : []).flatMap((wire, i) => asEntry2(wire)?.kind === "solder" ? [wireName(i)] : []);
43380
+ if (solder.length) report.warn(`${joinList(solder)} ${solder.length === 1 ? "is" : "are"} "kind": "solder", which version ${data.version} files don't have, so ${solder.length === 1 ? "it was" : "they were"} read as jumper wires. Set "version": ${PROJECT_FILE_VERSION} to keep solder paths.`);
43381
+ }
43382
+ const entries2 = readEntriesAlone(data, project);
43383
+ report.problems.push(...entries2.unreadable);
43384
+ const unnamed = skipped - entries2.unreadable.length;
42684
43385
  if (unnamed > 0) report.warn(`${unnamed} more entr${unnamed === 1 ? "y" : "ies"} couldn't be read and ${unnamed === 1 ? "was" : "were"} left out.`);
42685
- reportRenamedRefs(data, project, entries.kept, report);
42686
- const wireIndex = (i) => entries.kept.wires?.[i] ?? i;
43386
+ reportRenamedRefs(data, project, entries2.kept, report);
43387
+ const wireIndex = (i) => entries2.kept.wires?.[i] ?? i;
42687
43388
  const parts = partPins(project);
42688
43389
  const board = {
42689
43390
  project,
@@ -42701,11 +43402,17 @@ function validateProject(raw, expectNets) {
42701
43402
  if (project.board.type === "stripboard") checkStrips(board);
42702
43403
  checkConnections(board);
42703
43404
  if (expectNets) checkExpectedNets(board.nets, expectNets, report.error);
43405
+ if (project.requirements?.validate) {
43406
+ const required2 = validateRequirements(project, board.nets.nets);
43407
+ for (const issue2 of required2.issues) report.error(`Requirements: ${issue2.message}`);
43408
+ if (required2.unspecified.length || !required2.total) report.warn(`Requirements incomplete: ${required2.checked}/${required2.total} pins specified; unspecified pins are unchecked.`);
43409
+ else if (required2.status === "match") report.note(`Requirements match: all ${required2.total} board pins checked.`);
43410
+ }
42704
43411
  return {
42705
43412
  ok: report.ok,
42706
43413
  project,
42707
43414
  leftOut: skipped,
42708
- unreadable: entries.unreadable,
43415
+ unreadable: entries2.unreadable,
42709
43416
  wireIndex,
42710
43417
  problems: report.problems,
42711
43418
  notes: report.notes
@@ -42789,7 +43496,9 @@ function checkParts({ project, parts, report }) {
42789
43496
  const { cols, rows } = project.board;
42790
43497
  const onBoard = ([c, r2]) => c >= 0 && c < cols && r2 >= 0 && r2 < rows;
42791
43498
  for (const part of parts) {
42792
- if (!part.known) {
43499
+ if (!part.known && part.part === CUSTOM_PART_ID) {
43500
+ report.error(`${part.ref}: definitionId "custom" is a custom part, which needs its "custom" spec in a version ${PROJECT_FILE_VERSION} file.`);
43501
+ } else if (!part.known) {
42793
43502
  const like = partsLike(part.part);
42794
43503
  report.error(`${part.ref}: unknown definitionId "${part.part}"${like ? ` (did you mean ${like}?)` : ""}. Use list_parts for valid ids.`);
42795
43504
  }
@@ -42817,8 +43526,11 @@ function checkHoles({ parts, holes, report }) {
42817
43526
  }
42818
43527
  function checkWireEnds({ project, parts, holes, wireIndex, report, badEnds }) {
42819
43528
  const pinHoles = new Set(parts.flatMap((part) => part.pins.map((pin) => holeKey(pin.at))));
42820
- const wireEnds = /* @__PURE__ */ new Map();
42821
- for (const wire of project.wires) for (const end of [wire.from, wire.to]) wireEnds.set(holeKey(end), (wireEnds.get(holeKey(end)) ?? 0) + 1);
43529
+ const wireConnections = /* @__PURE__ */ new Map();
43530
+ for (const wire of project.wires) {
43531
+ const connectedHoles = isSolderPath(wire) ? solderPathHoles(wire) : [wire.from, wire.to];
43532
+ for (const hole2 of connectedHoles) wireConnections.set(holeKey(hole2), (wireConnections.get(holeKey(hole2)) ?? 0) + 1);
43533
+ }
42822
43534
  const runs = /* @__PURE__ */ new Map();
42823
43535
  project.wires.forEach((wire, i) => {
42824
43536
  const name = wireName(wireIndex(i));
@@ -42830,12 +43542,13 @@ function checkWireEnds({ project, parts, holes, wireIndex, report, badEnds }) {
42830
43542
  const first = runs.get(run);
42831
43543
  if (first === void 0) runs.set(run, i);
42832
43544
  else if (holeKey(wire.from) !== holeKey(wire.to)) report.warn(`${name} runs between the same holes as ${wireName(wireIndex(first))}, ${showHole(wire.from)} and ${showHole(wire.to)}: remove one.`);
43545
+ if (isSolderPath(wire)) return;
42833
43546
  for (const end of [wire.from, wire.to]) {
42834
43547
  const body = holes.get(holeKey(end))?.find((user) => user.body);
42835
43548
  if (body) {
42836
43549
  report.error(`${name} ends at ${showHole(end)}, which is under ${body.what}.`);
42837
43550
  badEnds.add(i);
42838
- } else if (project.board.type === "perfboard" && !pinHoles.has(holeKey(end)) && (wireEnds.get(holeKey(end)) ?? 0) < 2) {
43551
+ } else if (project.board.type === "perfboard" && !pinHoles.has(holeKey(end)) && (wireConnections.get(holeKey(end)) ?? 0) < 2) {
42839
43552
  report.warn(`${name} ends at ${showHole(end)}, which has no pin and no other wire: that end connects to nothing.`);
42840
43553
  badEnds.add(i);
42841
43554
  }
@@ -43027,7 +43740,7 @@ function registerProjectTools(server) {
43027
43740
  });
43028
43741
  server.registerTool("get_project", {
43029
43742
  title: "Get project",
43030
- description: "The whole project file of a project kept here, as the editor would save it (version 3, or 4 once a wire bends), one entry per line.",
43743
+ description: "The whole project file of a project kept here, as the editor would save it (through version 8, preserving component identities and optional requirements), one entry per line.",
43031
43744
  inputSchema: { projectId: string2() },
43032
43745
  annotations: { readOnlyHint: true, openWorldHint: false }
43033
43746
  }, async ({ projectId }) => {
@@ -43038,7 +43751,7 @@ function registerProjectTools(server) {
43038
43751
  }
43039
43752
  function blankProject(cols, rows, strips) {
43040
43753
  return {
43041
- version: fileVersionFor({ wires: [] }),
43754
+ version: fileVersionFor({ wires: [], placedAdvancedComponents: [] }),
43042
43755
  board: strips ? { type: "stripboard", cols, rows, strips, cuts: [] } : { type: "perfboard", cols, rows },
43043
43756
  pads: [],
43044
43757
  wires: [],
@@ -43051,6 +43764,10 @@ function blankProject(cols, rows, strips) {
43051
43764
  function checkedProject(held) {
43052
43765
  const { project, expectNets } = held;
43053
43766
  const { ok, problems, notes } = validateProject(project, expectNets);
43767
+ const checkedAgainst = [
43768
+ expectNets ? `expectNets (${plural2(expectNets.length, "net")})` : void 0,
43769
+ project.requirements?.validate ? "saved requirements" : void 0
43770
+ ].filter(Boolean).join("; ");
43054
43771
  const nets = ok ? netsReport(project, computeNets(project), layoutProjectWires(project), (i) => i) : void 0;
43055
43772
  return {
43056
43773
  projectId: held.id,
@@ -43059,7 +43776,7 @@ function checkedProject(held) {
43059
43776
  parts: partCount(project),
43060
43777
  wires: project.wires.length,
43061
43778
  ok,
43062
- ...expectNets ? { checkedAgainst: `expectNets (${plural2(expectNets.length, "net")})` } : {},
43779
+ ...checkedAgainst ? { checkedAgainst } : {},
43063
43780
  problems,
43064
43781
  ...notes.length ? { notes: `${plural2(notes.length, "note")} (wires crossing and the like): validate_project lists them.` } : {},
43065
43782
  ...nets ? { nets: nets.nets, unconnected: nets.unconnected, ...nets.strayWires ? { strayWires: nets.strayWires } : {} } : { nets: "Left out while the board has errors: fix them, or call get_nets." }
@@ -43092,6 +43809,7 @@ var KEY_TEXT = [
43092
43809
  "- | \\ / ~ wire passing over (not joined)",
43093
43810
  "% wire bending over (not joined)",
43094
43811
  "+ wires passing over each other",
43812
+ "= solder path (joins every hole it covers)",
43095
43813
  "x strip cut",
43096
43814
  "@ hole with a note"
43097
43815
  ].join(", ");
@@ -43113,6 +43831,7 @@ function renderBoard(project, area) {
43113
43831
  set2(at, before && before !== "@" && before !== mark ? "+" : mark);
43114
43832
  };
43115
43833
  project.wires.forEach((wire) => {
43834
+ if (isSolderPath(wire)) return;
43116
43835
  for (const leg of wireLegs(wire)) {
43117
43836
  const mark = runMark([leg.to[0] - leg.from[0], leg.to[1] - leg.from[1]]);
43118
43837
  for (const { at } of holesAlong2(leg)) overRun(at, mark);
@@ -43120,8 +43839,9 @@ function renderBoard(project, area) {
43120
43839
  for (const corner of wire.via ?? []) overRun(corner, "%");
43121
43840
  });
43122
43841
  for (const part of parts) part.coveredHoles.forEach((at) => set2(at, "#"));
43842
+ for (const wire of project.wires) if (isSolderPath(wire)) solderPathHoles(wire).forEach((at) => set2(at, "="));
43123
43843
  if (board.type === "stripboard") board.cuts.forEach((at) => set2(at, "x"));
43124
- for (const wire of project.wires) [wire.from, wire.to].forEach((at) => set2(at, "o"));
43844
+ for (const wire of project.wires) if (!isSolderPath(wire)) [wire.from, wire.to].forEach((at) => set2(at, "o"));
43125
43845
  layout.junctions.forEach((at) => set2(at, "*"));
43126
43846
  parts.forEach((part, i) => part.pins.forEach((pin) => set2(pin.at, `${partKey(i)}${pin.pin}`)));
43127
43847
  const width = Math.max(...[...cells.values(), String(right)].map((text2) => text2.length)) + 1;
@@ -43167,7 +43887,7 @@ function renderBoard(project, area) {
43167
43887
  out.push("", "Wires (index: ends, net):");
43168
43888
  for (const { wire, i } of shownWires) {
43169
43889
  const bends = wire.via?.length ? ` bending at ${wire.via.map(showHole).join(", ")}` : "";
43170
- out.push(`${i}: ${showHole(wire.from)}-${showHole(wire.to)}${bends}, ${netText(netOf.get(i))}`);
43890
+ out.push(`${i}: ${isSolderPath(wire) ? "solder path " : ""}${showHole(wire.from)}-${showHole(wire.to)}${bends}, ${netText(netOf.get(i))}`);
43171
43891
  }
43172
43892
  }
43173
43893
  return out.join("\n");
@@ -43829,7 +44549,7 @@ var MIN_READABLE_HOLE_PX = 20;
43829
44549
  function registerBoardTools(server) {
43830
44550
  server.registerTool("validate_project", {
43831
44551
  title: "Validate project",
43832
- description: "Checks a project file and lists every problem with where it is: entries the editor would leave out, unknown parts, pins off the board, two parts' pins or leads in one hole, overlapping parts, wires that connect nothing (a loose end, or no pins on their net), duplicate wires, a two-lead part with both leads on one net (shorted out), a wire passing over a pin or lead without ending there (so not joined to it), IC pins and two-lead parts' leads connected to nothing, supply rails shorted together, and on a stripboard, pins shorted by a strip or sitting in a cut hole. With expectNets, every connection missing from the board or extra on it is an error. Wires crossing each other are fine (insulated jumpers) and only listed in notes. Fix all errors before making a link. A project sent whole is kept here: the reply's projectId stands for it in every other tool.",
44552
+ description: "Checks a project file and lists every problem with where it is: entries the editor would leave out, unknown parts, pins off the board, two parts' pins or leads in one hole, overlapping parts, wires that connect nothing (a loose end, or no pins on their net), duplicate wires, a two-lead part with both leads on one net (shorted out), a wire passing over a pin or lead without ending there (so not joined to it), IC pins and two-lead parts' leads connected to nothing, supply rails shorted together, and on a stripboard, pins shorted by a strip or sitting in a cut hole. With expectNets, every connection missing from the board or extra on it is an error. Enabled saved requirements also check intended connections, missing components/pins and unused pins; unspecified pins produce an incomplete-coverage warning, not a full match. Wires crossing each other are fine (insulated jumpers) and only listed in notes. Fix all errors before making a link. A project sent whole is kept here: the reply's projectId stands for it in every other tool.",
43833
44553
  inputSchema: { project: projectInput, projectId: projectIdInput, expectNets: expectNetsInput },
43834
44554
  annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
43835
44555
  }, async ({ project, projectId, expectNets }) => {
@@ -44002,7 +44722,7 @@ function registerShareLinkTools(server, DEFAULT_EDITOR_URL, imageUrl2, storage)
44002
44722
  "Turns a project into a link that opens it in Perfboard Designer: the project travels inside the link, so it works without any server. Give the link to the user.",
44003
44723
  ...imageUrl2 ? ["Also returns `image`, the address of an SVG picture of the board (as the editor draws it), for showing it where images from links display, e.g. in Markdown (not in Claude or ChatGPT, which don't load them: show_board shows the board there)."] : [],
44004
44724
  ...storage ? ["With store, the project is also stored on the Perfboard Designer server under a short id, and `stored` gives a short link to it, its file and its pictures (SVG and PNG): give the user both links."] : [],
44005
- "The project is validated first (against expectNets too, given or remembered for its projectId); a project with errors gets the list of problems instead of a link, unless allowErrors is set."
44725
+ "The project is validated first (against enabled saved requirements and expectNets too, given or remembered for its projectId); a project with errors gets the list of problems instead of a link, unless allowErrors is set."
44006
44726
  ].join(" "),
44007
44727
  // Without storage, store and storeAs aren't offered, so they never come.
44008
44728
  inputSchema: storage ? inputs : baseInputs,
@@ -44040,7 +44760,7 @@ function registerShareLinkTools(server, DEFAULT_EDITOR_URL, imageUrl2, storage)
44040
44760
  });
44041
44761
  server.registerTool("read_share_link", {
44042
44762
  title: "Read share link",
44043
- description: "Reads the project out of a Perfboard Designer share link (any of its forms: z=, json= or src=, which is downloaded; a stored project's short link too), so you can look at or change a board the user shared. Returns the project as a project file (version 3, or 4 when a wire bends), kept here under the projectId it returns: change it with edit_project.",
44763
+ description: "Reads the project out of a Perfboard Designer share link (z=, json=, downloaded src=, or a stored short link). Returns a project file through version 8, preserving component identities and optional requirements, kept under the returned projectId: change it with edit_project.",
44044
44764
  inputSchema: {
44045
44765
  link: string2().describe("The whole link, or just the part after #.")
44046
44766
  },
@@ -44198,7 +44918,7 @@ function registerShowBoardTool(server, DEFAULT_EDITOR_URL) {
44198
44918
  description: "The page show_board shows the board in.",
44199
44919
  // The picture is a data: image, and the page loads nothing else.
44200
44920
  _meta: { ui: { prefersBorder: false } }
44201
- }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: p, text: '<!doctype html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Perfboard board</title>\n<style>\n :root { color-scheme: light dark; font-family: system-ui, sans-serif; font-size: 14px; }\n body { margin: 0; background: transparent; color: CanvasText; }\n figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }\n img { display: block; width: 100%; height: auto; border-radius: 6px; }\n img:not([src]) { display: none; }\n figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }\n #caption { opacity: 0.75; }\n button { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid #1f7a3a; background: #1f7a3a; color: #fff; cursor: pointer; }\n button:hover { background: #18602e; }\n button[hidden] { display: none; }\n</style>\n</head>\n<body>\n<figure>\n <img id="board" alt="">\n <figcaption>\n <span id="caption">Drawing the board\u2026</span>\n <button id="open" type="button" hidden>Open in Perfboard Designer</button>\n </figcaption>\n</figure>\n<script type="module">var f="2026-01-26",r=document.getElementById("board"),a=document.getElementById("caption"),u=document.getElementById("open"),i,g=1,s=new Map,o=t=>window.parent.postMessage({jsonrpc:"2.0",...t},"*");function m(t,e){let n=g++;return o({id:n,method:t,params:e}),new Promise(p=>s.set(n,p))}function h(t){let e=t._meta?.board;if(t.isError||!e){a.textContent=t.content?.find(n=>n.type==="text")?.text??"The board couldn\'t be shown.";return}r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.svg)}`,r.alt=e.caption,a.textContent=e.caption,i=e.link,u.hidden=!i}window.addEventListener("message",({source:t,data:e})=>{t!==window.parent||e?.jsonrpc!=="2.0"||(e.method===void 0?(s.get(e.id)?.(e.result),s.delete(e.id)):e.method==="ui/notifications/tool-result"?h(e.params??{}):e.id!==void 0&&o({id:e.id,result:{}}))});u.addEventListener("click",()=>{i&&m("ui/open-link",{url:i})});var c=0,l=0;function d(){let t=document.documentElement,e=Math.ceil(t.getBoundingClientRect().height),n=Math.ceil(window.innerWidth);n===c&&e===l||(c=n,l=e,o({method:"ui/notifications/size-changed",params:{width:n,height:e}}))}await m("ui/initialize",{protocolVersion:f,appInfo:{name:"Perfboard Designer board",version:"0.2.0"},appCapabilities:{}});o({method:"ui/notifications/initialized",params:{}});new ResizeObserver(()=>requestAnimationFrame(d)).observe(document.body);r.addEventListener("load",d);d();\n</script>\n</body>\n</html>\n', _meta: { ui: { prefersBorder: false } } }] }));
44921
+ }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: p, text: '<!doctype html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Perfboard board</title>\n<style>\n :root { color-scheme: light dark; font-family: system-ui, sans-serif; font-size: 14px; }\n body { margin: 0; background: transparent; color: CanvasText; }\n figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }\n img { display: block; width: 100%; height: auto; border-radius: 6px; }\n img:not([src]) { display: none; }\n figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }\n #caption { opacity: 0.75; }\n button { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid #1f7a3a; background: #1f7a3a; color: #fff; cursor: pointer; }\n button:hover { background: #18602e; }\n button[hidden] { display: none; }\n</style>\n</head>\n<body>\n<figure>\n <img id="board" alt="">\n <figcaption>\n <span id="caption">Drawing the board\u2026</span>\n <button id="open" type="button" hidden>Open in Perfboard Designer</button>\n </figcaption>\n</figure>\n<script type="module">var f="2026-01-26",r=document.getElementById("board"),a=document.getElementById("caption"),u=document.getElementById("open"),i,g=1,s=new Map,o=t=>window.parent.postMessage({jsonrpc:"2.0",...t},"*");function m(t,e){let n=g++;return o({id:n,method:t,params:e}),new Promise(p=>s.set(n,p))}function h(t){let e=t._meta?.board;if(t.isError||!e){a.textContent=t.content?.find(n=>n.type==="text")?.text??"The board couldn\'t be shown.";return}r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.svg)}`,r.alt=e.caption,a.textContent=e.caption,i=e.link,u.hidden=!i}window.addEventListener("message",({source:t,data:e})=>{t!==window.parent||e?.jsonrpc!=="2.0"||(e.method===void 0?(s.get(e.id)?.(e.result),s.delete(e.id)):e.method==="ui/notifications/tool-result"?h(e.params??{}):e.id!==void 0&&o({id:e.id,result:{}}))});u.addEventListener("click",()=>{i&&m("ui/open-link",{url:i})});var c=0,l=0;function d(){let t=document.documentElement,e=Math.ceil(t.getBoundingClientRect().height),n=Math.ceil(window.innerWidth);n===c&&e===l||(c=n,l=e,o({method:"ui/notifications/size-changed",params:{width:n,height:e}}))}await m("ui/initialize",{protocolVersion:f,appInfo:{name:"Perfboard Designer board",version:"0.4.0"},appCapabilities:{}});o({method:"ui/notifications/initialized",params:{}});new ResizeObserver(()=>requestAnimationFrame(d)).observe(document.body);r.addEventListener("load",d);d();\n</script>\n</body>\n</html>\n', _meta: { ui: { prefersBorder: false } } }] }));
44202
44922
  K3(server, "show_board", {
44203
44923
  title: "Show board",
44204
44924
  description: "Shows the user a picture of the board right in the conversation, as the editor draws it, with a button that opens it in Perfboard Designer. Only in clients that show MCP Apps (e.g. Claude, ChatGPT); elsewhere the user sees nothing, so give them make_share_link's link too. The picture goes to the user, not to you: to look at the board yourself, use render_board.",
@@ -44239,14 +44959,14 @@ function registerResources(server) {
44239
44959
  }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/markdown", text: GUIDE }] }));
44240
44960
  server.registerResource("project-file-format", "perfboard://docs/project-file", {
44241
44961
  title: "Project file format",
44242
- description: "The project file format (version 4), field by field, as the TypeScript types that define it.",
44962
+ description: "The project file format (version 8), including component identities and optional circuit requirements, as TypeScript types.",
44243
44963
  mimeType: "text/plain"
44244
- }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/plain", text: 'import {GridPos} from "./grid";\n\n// The project file format, version 4. Positions are grid [column, row] pairs counted from the\n// top-left hole (column = left to right, row = top to bottom), not pixels, and only holes with a\n// note are listed. Older files are still read, see read-project-file.ts:\n// - version 3: the same, minus bent wires (a wire\'s `via`).\n// - version 2: the same as 3, minus the board type (always a perfboard) and part refs.\n// - version 1 (no `version` field): pixel coordinates, every hole listed, the whole IC catalog.\nexport const PROJECT_FILE_VERSION = 4;\n\n// A file says the oldest version that holds everything in it: 3 unless a wire bends. So a board\n// without bends still opens in editors and tools from before version 4.\nexport type FileVersion = 3 | typeof PROJECT_FILE_VERSION;\n\nexport function fileVersionFor(project: Pick<ProjectFile, "wires">): FileVersion {\n return project.wires.some(wire => wire.via?.length) ? PROJECT_FILE_VERSION : 3;\n}\n\nexport type Rotation = 0 | 90 | 180 | 270;\n\n// A perfboard has a separate copper pad around every hole: nothing is connected until it\'s wired.\n// A stripboard has long copper strips instead, each connecting a whole line of holes.\nexport type BoardType = "perfboard" | "stripboard";\n\n// Which way a stripboard\'s strips run. "horizontal": every hole in the same row is on one strip.\n// "vertical": every hole in the same column is.\nexport type StripDirection = "horizontal" | "vertical";\n\nexport interface SavedPerfboard {\n type: "perfboard";\n cols: number;\n rows: number;\n}\n\nexport interface SavedStripboard {\n type: "stripboard";\n cols: number;\n rows: number;\n strips: StripDirection;\n // Holes where the strip is cut (drilled through). A cut splits its strip in two, and the cut\n // hole itself connects to neither side: a lead in it is connected to nothing.\n cuts: GridPos[];\n}\n\nexport type SavedBoard = SavedPerfboard | SavedStripboard;\n\n// A hole with a note on it ("+9V", "GND", "to battery"). Purely a label: it says nothing about\n// what\'s connected. (Files from before notes were the only mark may give a hole a `color` too;\n// it\'s ignored.)\nexport interface SavedPad {\n at: GridPos;\n note: string;\n}\n\n// An insulated jumper wire. It joins the holes at its two ends and nothing else: not the holes it\n// passes over, and not its corners.\nexport interface SavedWire {\n from: GridPos;\n to: GridPos;\n // Where it bends on its way from `from` to `to`, in order (version 4): it runs straight from\n // hole to hole through these. A corner is a bend over a hole, never a joint. Absent: straight.\n via?: GridPos[];\n color?: string;\n width?: number;\n}\n\n// Every placed part has a `ref`: its reference designator (R1, C2, U1...), unique on the board\n// ignoring case. See part-refs.ts.\n\nexport interface SavedIc {\n ref: string;\n name: string;\n // Pin columns and rows as placed, i.e. already swapped by any 90/270 rotation.\n widthPin: number;\n heightPin: number;\n rotation: Rotation;\n pinDescription: Record<number, string>;\n // Top-left pin.\n at: GridPos;\n // The catalog category the chip was placed from; "modules\u2026" parts are drawn as boards. Absent in\n // files from before this was recorded.\n category?: string;\n}\n\nexport interface SavedStandardComponent {\n ref: string;\n definitionId: string;\n from: GridPos;\n to: GridPos;\n value?: string;\n color?: string;\n}\n\nexport interface SavedAdvancedComponent {\n ref: string;\n definitionId: string;\n // The anchor pin (the definition\'s pins[0]), or a grid-sizable block\'s top-left pin.\n at: GridPos;\n rotation: Rotation;\n rows: number;\n cols: number;\n value?: string;\n}\n\n// A user-made IC catalog entry. Loading a file adds these to the catalog (keyed by id) rather\n// than replacing it.\nexport interface SavedCustomIc {\n id?: number;\n name: string;\n widthPin: number;\n heightPin: number;\n pinDescription: Record<number, string>;\n // Where the part is listed in the Components panel; absent in files from before the catalog.\n category?: string;\n}\n\nexport interface ProjectFile {\n version: FileVersion;\n board: SavedBoard;\n pads: SavedPad[];\n wires: SavedWire[];\n // One array per kind, each in stacking order (see PartState.parts).\n placedIcs: SavedIc[];\n placedStandardComponents: SavedStandardComponent[];\n placedAdvancedComponents: SavedAdvancedComponent[];\n customIcs: SavedCustomIc[];\n}\n' }] }));
44964
+ }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/plain", text: 'import {GridPos} from "./grid";\nimport type {CustomPartSpec} from "../parts/custom-parts";\nimport type {CircuitRequirements} from "./requirements";\n\n// The project file format, version 8. Positions are grid [column, row] pairs counted from the\n// top-left hole (column = left to right, row = top to bottom), not pixels, and only holes with a\n// note are listed. Older files are still read, see read-project-file.ts:\n// - version 7: the same, minus circuit requirements (`requirements`).\n// - version 6: the same as 7, minus part identities (a placed part\'s `instanceId`).\n// - version 5: the same as 6, minus custom parts (a fixed-pin part\'s `custom`).\n// - version 4: the same as 5, minus solder paths (a wire\'s `kind`).\n// - version 3: the same as 4, minus bent wires (a wire\'s `via`).\n// - version 2: the same as 3, minus the board type (always a perfboard) and part refs.\n// - version 1 (no `version` field): pixel coordinates, every hole listed, the whole IC catalog.\nexport const PROJECT_FILE_VERSION = 8;\n\n// A file says the oldest version that holds everything in it: 8 with requirements, else 6 with a\n// custom part, else 5 with a solder path, else 4 if a wire bends, else 3. So a board without them\n// still opens in editors and tools from before. Part identities (version 7) don\'t raise it: older\n// readers skip the field, and identities only matter to requirements, which are version 8.\nexport type FileVersion = 3 | 4 | 5 | 6 | typeof PROJECT_FILE_VERSION;\n\nexport function fileVersionFor(project: Pick<ProjectFile, "wires" | "placedAdvancedComponents" | "requirements">): FileVersion {\n if (project.requirements) return PROJECT_FILE_VERSION;\n if (project.placedAdvancedComponents.some(part => part.custom)) return 6;\n if (project.wires.some(wire => wire.kind === "solder")) return 5;\n return project.wires.some(wire => wire.via?.length) ? 4 : 3;\n}\n\nexport type Rotation = 0 | 90 | 180 | 270;\n\n// A perfboard has a separate copper pad around every hole: nothing is connected until it\'s wired.\n// A stripboard has long copper strips instead, each connecting a whole line of holes.\nexport type BoardType = "perfboard" | "stripboard";\n\n// Which way a stripboard\'s strips run. "horizontal": every hole in the same row is on one strip.\n// "vertical": every hole in the same column is.\nexport type StripDirection = "horizontal" | "vertical";\n\nexport interface SavedPerfboard {\n type: "perfboard";\n cols: number;\n rows: number;\n}\n\nexport interface SavedStripboard {\n type: "stripboard";\n cols: number;\n rows: number;\n strips: StripDirection;\n // Holes where the strip is cut (drilled through). A cut splits its strip in two, and the cut\n // hole itself connects to neither side: a lead in it is connected to nothing.\n cuts: GridPos[];\n}\n\nexport type SavedBoard = SavedPerfboard | SavedStripboard;\n\n// A hole with a note on it ("+9V", "GND", "to battery"). Purely a label: it says nothing about\n// what\'s connected. (Files from before notes were the only mark may give a hole a `color` too;\n// it\'s ignored.)\nexport interface SavedPad {\n at: GridPos;\n note: string;\n}\n\n// What a wire is made of (version 5):\n// - "jumper": an insulated jumper wire on the component side. It joins the holes at its two ends\n// and nothing else: not the holes it passes over, and not its corners.\n// - "solder": a solder path, a trail of solder bridging pad to pad on the copper side. Bare metal,\n// so it joins every hole it runs over: its ends, its corners and each hole along the way\n// (solderPathHoles() in wire-path.ts), and any solder path it touches. A cut hole on a\n// stripboard has no copper for it to join, so whatever is in one stays unconnected.\nexport type WireKind = "jumper" | "solder";\n\n// A wire: a jumper unless `kind` says otherwise.\nexport interface SavedWire {\n from: GridPos;\n to: GridPos;\n // Where it bends on its way from `from` to `to`, in order (version 4): it runs straight from\n // hole to hole through these. A jumper\'s corner is a bend over a hole, never a joint; a solder\n // path\'s joins that hole like the rest of its holes. Absent: straight.\n via?: GridPos[];\n // Absent: "jumper". Only solder paths say it.\n kind?: WireKind;\n // A jumper\'s insulation colour and thickness (drawing px). A solder path has neither.\n color?: string;\n width?: number;\n}\n\n// Every placed part has a `ref`: its reference designator (R1, C2, U1...), unique on the board\n// ignoring case. See part-refs.ts.\n\nexport interface SavedIc {\n instanceId?: string;\n ref: string;\n name: string;\n // Pin columns and rows as placed, i.e. already swapped by any 90/270 rotation.\n widthPin: number;\n heightPin: number;\n rotation: Rotation;\n pinDescription: Record<number, string>;\n // Top-left pin.\n at: GridPos;\n // The catalog category the chip was placed from; "modules\u2026" parts are drawn as boards. Absent in\n // files from before this was recorded.\n category?: string;\n}\n\nexport interface SavedStandardComponent {\n instanceId?: string;\n ref: string;\n definitionId: string;\n from: GridPos;\n to: GridPos;\n value?: string;\n color?: string;\n}\n\nexport interface SavedAdvancedComponent {\n instanceId?: string;\n ref: string;\n definitionId: string;\n // The anchor pin (the definition\'s pins[0]), or a grid-sizable block\'s top-left pin.\n at: GridPos;\n rotation: Rotation;\n rows: number;\n cols: number;\n value?: string;\n // A user-made part (version 6, definitionId "custom"): its whole definition, so the board needs\n // nothing else to draw it and know its pins (src/parts/custom-parts.ts): `name`, `cols` x `rows`\n // holes of body, its `pins` in order, each `at` a [column, row] within the body from its top-left\n // hole with an optional `label`, and optionally `refPrefix`, `color` (the body\'s) and `id` (its\n // entry in the editor\'s catalog). `at` above is pin 1\'s hole. With `shape`, the id of a built-in\n // fixed-pin part (e.g. "transistor", a TO-92), it\'s that part\'s package with its own name and pin\n // names: the package decides its pins\' holes (`cols`, `rows` and each `at` are written to match,\n // so a reader without shapes still finds the same pins) and how it\'s drawn; `color` is unused.\n custom?: CustomPartSpec;\n}\n\n// A user-made IC catalog entry. Loading a file adds these to the catalog (keyed by id) rather\n// than replacing it.\nexport interface SavedCustomIc {\n id?: number;\n name: string;\n widthPin: number;\n heightPin: number;\n pinDescription: Record<number, string>;\n // Where the part is listed in the Components panel; absent in files from before the catalog.\n category?: string;\n}\n\nexport interface ProjectFile {\n requirements?: CircuitRequirements;\n version: FileVersion;\n board: SavedBoard;\n pads: SavedPad[];\n wires: SavedWire[];\n // One array per kind, each in stacking order (see PartState.parts).\n placedIcs: SavedIc[];\n placedStandardComponents: SavedStandardComponent[];\n placedAdvancedComponents: SavedAdvancedComponent[];\n customIcs: SavedCustomIc[];\n}\n\nimport type { ProjectFile } from "./project-file";\nimport { partPins } from "./pin-positions";\nimport { computeNets, Net, NetPin } from "./nets";\n\nexport interface RequiredPin {\n componentId: string;\n pin: number;\n}\n\nexport interface RequiredComponent {\n id: string;\n ref: string;\n name: string;\n pins: { pin: number; label?: string }[];\n}\n\nexport interface RequiredNet {\n id: string;\n pins: RequiredPin[];\n}\n\nexport interface CircuitRequirements {\n validate: boolean;\n components: RequiredComponent[];\n nets: RequiredNet[];\n unused: RequiredPin[];\n}\n\nexport interface RequirementIssue {\n kind:\n | "missing-component"\n | "missing-pin"\n | "missing-connection"\n | "unexpected-connection";\n message: string;\n pins: RequiredPin[];\n}\n\nexport interface RequirementValidation {\n status: "disabled" | "incomplete" | "mismatch" | "match";\n issues: RequirementIssue[];\n unspecified: RequiredPin[];\n checked: number;\n total: number;\n}\n\n' }] }));
44245
44965
  server.registerResource("share-links", "perfboard://docs/share-links", {
44246
44966
  title: "Share links",
44247
44967
  description: "How a share link carries a project, and what happens when the user opens one.",
44248
44968
  mimeType: "text/markdown"
44249
- }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/markdown", text: '# Share links\n\nA share link opens a board in Perfboard Designer for whoever clicks it. The whole project travels\ninside the link itself, so there\'s no account, no upload and no server. In the editor, use\n**\u{1F517} Share** (or **File \u2192 Share Link...**) to make one. The same dialog can also make a **short\nlink** to a copy of the board stored on Perfboard Designer\'s server (`p`, below).\n\nThis page is the link format, written so that people and programs can make links too, including\nAI agents that design a board and hand the user a link to open it. The code is\n[`src/project-file/share-link.ts`](../src/project-file/share-link.ts). An agent that can use MCP\ncan skip most of this page: the [MCP server](../mcp/README.md) looks up parts, checks the project\nand makes the link for it.\n\n## What happens when a link is opened\n\n- The project is added to the receiver\'s projects (kept in their browser) as a **new project**,\n and opened. Whatever they had open stays as it was. The link is a snapshot: later changes by the\n sender aren\'t in it.\n- It\'s named after the link\'s `name`, or "Shared project". If a project with that name exists,\n the new one is numbered: "LED demo 2".\n- The link is then removed from the address bar, so reloading doesn\'t add the project again.\n- The project is checked like an imported file. Entries that can\'t be read are left out, and the\n user is told how many. A link that can\'t be read at all leaves everything untouched and says why.\n\n## Format\n\n```\nhttps://perfboarddesigner.com/app/#<fragment>\n```\n\nThe project goes in the URL **fragment** (after `#`), which browsers never send to a server. The\nfragment holds `key=value` parameters joined with `&`, like a query string:\n\n| Parameter | Value |\n| --- | --- |\n| `name` | Optional. The project\'s name, percent-encoded. |\n| `z` | The project file, compressed (see below). This is what the editor makes. |\n| `json` | The project file as plain JSON, percent-encoded. Must be the **last** parameter. |\n| `src` | The `https://` address of a project file hosted somewhere else, percent-encoded. |\n| `p` | The id of a project stored on Perfboard Designer\'s server: a short link. |\n\nUse exactly one of `z`, `json`, `src` and `p`. If several are present, `json` wins, then `z`, then\n`src`, then `p`.\n\n### `z`: compressed (shortest)\n\n1. Write the project file as JSON (minified is best).\n2. Compress its UTF-8 bytes with **raw DEFLATE** (no zlib or gzip header).\n3. Encode the result as **base64url** (`-` and `_` instead of `+` and `/`) with no `=` padding.\n\nThe reader is forgiving about what programs commonly produce instead. It also accepts zlib- or\ngzip-wrapped data, plain base64 with `+`, `/` and `=` padding, and line breaks in the base64 text.\n\nPython:\n\n```python\nimport base64, json, urllib.parse, zlib\n\ndef share_link(project: dict, name: str = "") -> str:\n data = json.dumps(project, separators=(",", ":")).encode("utf-8")\n deflate = zlib.compressobj(9, zlib.DEFLATED, -15) # -15: raw DEFLATE, no header\n z = base64.urlsafe_b64encode(deflate.compress(data) + deflate.flush()).rstrip(b"=").decode()\n name_param = f"name={urllib.parse.quote(name, safe=\'\')}&" if name else ""\n return f"https://perfboarddesigner.com/app/#{name_param}z={z}"\n```\n\nNode.js:\n\n```js\nconst zlib = require("zlib");\n\nfunction shareLink(project, name = "") {\n const z = zlib.deflateRawSync(Buffer.from(JSON.stringify(project))).toString("base64url");\n const nameParam = name ? `name=${encodeURIComponent(name)}&` : "";\n return `https://perfboarddesigner.com/app/#${nameParam}z=${z}`;\n}\n```\n\n### `json`: plain JSON (no tools needed)\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20demo&json=<percent-encoded project file JSON>\n```\n\nThis is for writers that can\'t compress, such as a language model writing the link directly.\nThese links are 3 to 7 times longer than `z` links. Rules:\n\n- `json` must be the **last parameter**: everything after `json=` is the project.\n- Percent-encode the JSON, as `encodeURIComponent` or Python\'s\n `urllib.parse.quote(text, safe="")` do. Encode at least spaces (`%20`), `#` (`%23`, which\n starts every color), `%` (`%25`) and `+` (`%2B`). A `+` is kept as a plus sign, never read as\n a space. Unencoded links may survive in a browser\'s address bar but are often broken by the chat\n apps and editors that turn text into links.\n- The reader tolerates a stray `%` that doesn\'t start an escape, such as a note saying `50%`.\n\n### `src`: a file hosted elsewhere\n\n```\nhttps://perfboarddesigner.com/app/#src=https%3A%2F%2Fexample.com%2Fmy-board.json\n```\n\n- The address must be `http://` or `https://`, and the site must allow other websites to read\n the file (CORS). Raw GitHub Gist and raw GitHub file addresses\n (`gist.githubusercontent.com`, `raw.githubusercontent.com`) do. A gist\'s normal page does not.\n- The user is asked before anything is downloaded, since fetching the file shows that site the\n visit.\n- Without a `name`, the project is named after the file (`my-board.json` \u2192 "my-board").\n- There\'s no size limit to worry about here, so this suits large boards and programs that can\n publish files.\n\n### `p`: a stored project (short link)\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20blinker&p=led-blinker\n```\n\n- The project is stored on Perfboard Designer\'s own server, `https://projects.perfboarddesigner.com`\n (below), and the link names it by its id. It\'s fetched without asking, since it\'s the site\'s own.\n- Without a `name`, the project is named after its id.\n- A stored project never changes, and it\'s deleted after a year unopened. Anyone with the link\n can open it. Unlike the other forms, it needs the server: the Share dialog offers the full link\n beside it, which works without one.\n\n### Stored projects\n\n`https://projects.perfboarddesigner.com` keeps projects for short links. Anyone can store one:\n\n| Request | Answer |\n| --- | --- |\n| `POST /projects` with `{"project": {\u2026}, "id": "led-blinker", "name": "LED blinker"}` (`id` and `name` optional) | `{id, link, file, image, png}`: the id it got, a short link, the file\'s address and its pictures\' |\n| `GET /<id>.json` | the project file |\n| `GET /<id>.png`, `GET /<id>.svg` | pictures of the board |\n\n- **Ids** are lowercase letters, digits and dashes, at most 40 characters, made from the wanted\n `id` or else the `name` (`"M\xE1gneses kapcsol\xF3!"` \u2192 `magneses-kapcsolo`). If another board has\n that id, a few characters of the board\'s SHA-256 are added (`led-blinker-08196a`); storing the\n same board under the same id again gives the same id back. With neither, the id is the hash.\n- Only valid project files are stored, as the editor reads them, up to 1 MB.\n- Every site may call it (CORS). There\'s no sign-in.\n- It\'s the [MCP server\'s](../mcp/README.md) Cloudflare Worker, which agents store through too.\n\n### Limits\n\n- The project file may be at most 5 MB once unpacked, and a board at most 500 holes on a side.\n- Links longer than about 8,000 characters may be cut off by some chat apps and mail clients; the\n Share dialog warns about these. For scale, the boards in [`examples/`](../examples) make `z`\n links of 0.8k to 2.7k characters.\n\n## The project file\n\nA share link carries the same project file as **File \u2192 Save Project to File**. Every version\nopens, but write the current one, version 4 (version 3 is the same without bent wires, and is\nfine for a board without them). It\'s documented field by field in\n[`src/project-file/project-file.ts`](../src/project-file/project-file.ts). In short:\n\n- Positions are `[column, row]` grid holes counted from the **top-left hole**, both starting at 0.\n Neighbouring holes are 2.54 mm (0.1 in) apart.\n- `board`: `{"type": "perfboard", "cols": 12, "rows": 8}`, or a stripboard with\n `"strips": "horizontal" | "vertical"` and `"cuts": [[col, row], ...]`.\n- `pads`: holes with a `note` (like `+9V` or `GND`), as `{"at": [c, r], "note": "+9V"}`. Purely\n a label: it doesn\'t connect anything.\n- `wires`: `{"from": [c, r], "to": [c, r]}`, with optional `color` (`"#rrggbb"`) and `width`. A\n wire joins only its two end holes. With `"via": [[c, r], ...]` (version 4) it bends at those\n holes on its way, in order; a bend joins nothing.\n- `placedStandardComponents`: two-lead parts placed between two holes: `definitionId`, `from`,\n `to`, optional `value` (`"10k"`, `"100n"`) and `color` (LEDs). On polarized parts, `from` is\n an LED\'s cathode, a diode\'s anode and an electrolytic capacitor\'s \u2212 lead (`leadLabels` in the\n definitions).\n- `placedAdvancedComponents`: fixed-footprint parts: `definitionId`, the anchor pin `at`,\n `rotation` (0, 90, 180 or 270), `rows` and `cols` (1 except for sizable parts such as header\n pins), optional `value`.\n- `placedIcs`: DIP chips and dual-row modules: `name`, `at` (top-left pin), `widthPin` (columns\n including both pin rows, 4 for a 0.3" DIP), `heightPin` (pins per side), `rotation`, and\n `pinDescription` (`{"1": "GND", "2": "TRIG", ...}`, numbered counter-clockwise from pin 1).\n- `customIcs`: user-made catalog entries. `[]` is fine.\n- Every part should have a unique `ref` (R1, C2, U1...). Missing or duplicate refs are numbered\n automatically.\n\nThe reader is forgiving: empty lists can be left out, a file without `version` that has a `board`\nis read as version 4, and entries it can\'t read are skipped (and counted) instead of failing the\nwhole project.\n\nThe `definitionId`s, with each part\'s pins, are in\n[`component-definitions.ts`](../src/parts/component-definitions.ts)\n(two-lead parts such as `resistor`, `ceramic-capacitor`, `electrolytic-capacitor`, `led` and\n`diode`) and\n[`advanced-component-definitions.ts`](../src/parts/advanced-component-definitions.ts)\n(fixed-footprint parts such as `transistor`, `potentiometer` and `header-pins`). Built-in chips are\nin [`ic-definitions.ts`](../src/parts/ic-definitions.ts), and footprints are described in\n[component-footprints.md](component-footprints.md). Check ids against these files: a part with an\nunknown `definitionId` isn\'t skipped, it stays on the board as an unrecognised part with an `X` ref.\n\n## Example\n\nA 9 V LED circuit on a 12 \xD7 8 perfboard:\n\n```json\n{\n "version": 3,\n "board": {"type": "perfboard", "cols": 12, "rows": 8},\n "pads": [{"at": [1, 1], "note": "+9V"}, {"at": [1, 6], "note": "GND"}],\n "wires": [\n {"from": [1, 1], "to": [3, 1], "color": "#ef4444"},\n {"from": [8, 4], "to": [8, 6]},\n {"from": [8, 6], "to": [1, 6]}\n ],\n "placedIcs": [],\n "placedStandardComponents": [\n {"ref": "R1", "definitionId": "resistor", "from": [3, 1], "to": [8, 1], "value": "470"},\n {"ref": "D1", "definitionId": "led", "from": [8, 2], "to": [8, 4], "color": "#22c55e"}\n ],\n "placedAdvancedComponents": [\n {"ref": "J1", "definitionId": "header-pins", "at": [0, 1], "rotation": 0, "rows": 6, "cols": 1}\n ],\n "customIcs": []\n}\n```\n\nAs a `json` link (the start of it):\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20demo&json=%7B%22version%22%3A3%2C%22board%22%3A%7B%22type%22%3A%22perfboard%22%2C...\n```\n' }] }));
44969
+ }, async (uri) => ({ contents: [{ uri: uri.href, mimeType: "text/markdown", text: '# Share links\n\nA share link opens a board in Perfboard Designer for whoever clicks it. The whole project travels\ninside the link itself, so there\'s no account, no upload and no server. In the editor, use\n**\u{1F517} Share** (or **File \u2192 Share Link...**) to make one. The same dialog can also make a **short\nlink** to a copy of the board stored on Perfboard Designer\'s server (`p`, below).\n\nThis page is the link format, written so that people and programs can make links too, including\nAI agents that design a board and hand the user a link to open it. The code is\n[`src/project-file/share-link.ts`](../src/project-file/share-link.ts). An agent that can use MCP\ncan skip most of this page: the [MCP server](../mcp/README.md) looks up parts, checks the project\nand makes the link for it.\n\n## What happens when a link is opened\n\n- The project is added to the receiver\'s projects (kept in their browser) as a **new project**,\n and opened. Whatever they had open stays as it was. The link is a snapshot: later changes by the\n sender aren\'t in it.\n- It\'s named after the link\'s `name`, or "Shared project". If a project with that name exists,\n the new one is numbered: "LED demo 2".\n- The link is then removed from the address bar, so reloading doesn\'t add the project again.\n- The project is checked like an imported file. Entries that can\'t be read are left out, and the\n user is told how many. A link that can\'t be read at all leaves everything untouched and says why.\n\n## Format\n\n```\nhttps://perfboarddesigner.com/app/#<fragment>\n```\n\nThe project goes in the URL **fragment** (after `#`), which browsers never send to a server. The\nfragment holds `key=value` parameters joined with `&`, like a query string:\n\n| Parameter | Value |\n| --- | --- |\n| `name` | Optional. The project\'s name, percent-encoded. |\n| `z` | The project file, compressed (see below). This is what the editor makes. |\n| `json` | The project file as plain JSON, percent-encoded. Must be the **last** parameter. |\n| `src` | The `https://` address of a project file hosted somewhere else, percent-encoded. |\n| `p` | The id of a project stored on Perfboard Designer\'s server: a short link. |\n\nUse exactly one of `z`, `json`, `src` and `p`. If several are present, `json` wins, then `z`, then\n`src`, then `p`.\n\n### `z`: compressed (shortest)\n\n1. Write the project file as JSON (minified is best).\n2. Compress its UTF-8 bytes with **raw DEFLATE** (no zlib or gzip header).\n3. Encode the result as **base64url** (`-` and `_` instead of `+` and `/`) with no `=` padding.\n\nThe reader is forgiving about what programs commonly produce instead. It also accepts zlib- or\ngzip-wrapped data, plain base64 with `+`, `/` and `=` padding, and line breaks in the base64 text.\n\nPython:\n\n```python\nimport base64, json, urllib.parse, zlib\n\ndef share_link(project: dict, name: str = "") -> str:\n data = json.dumps(project, separators=(",", ":")).encode("utf-8")\n deflate = zlib.compressobj(9, zlib.DEFLATED, -15) # -15: raw DEFLATE, no header\n z = base64.urlsafe_b64encode(deflate.compress(data) + deflate.flush()).rstrip(b"=").decode()\n name_param = f"name={urllib.parse.quote(name, safe=\'\')}&" if name else ""\n return f"https://perfboarddesigner.com/app/#{name_param}z={z}"\n```\n\nNode.js:\n\n```js\nconst zlib = require("zlib");\n\nfunction shareLink(project, name = "") {\n const z = zlib.deflateRawSync(Buffer.from(JSON.stringify(project))).toString("base64url");\n const nameParam = name ? `name=${encodeURIComponent(name)}&` : "";\n return `https://perfboarddesigner.com/app/#${nameParam}z=${z}`;\n}\n```\n\n### `json`: plain JSON (no tools needed)\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20demo&json=<percent-encoded project file JSON>\n```\n\nThis is for writers that can\'t compress, such as a language model writing the link directly.\nThese links are 3 to 7 times longer than `z` links. Rules:\n\n- `json` must be the **last parameter**: everything after `json=` is the project.\n- Percent-encode the JSON, as `encodeURIComponent` or Python\'s\n `urllib.parse.quote(text, safe="")` do. Encode at least spaces (`%20`), `#` (`%23`, which\n starts every color), `%` (`%25`) and `+` (`%2B`). A `+` is kept as a plus sign, never read as\n a space. Unencoded links may survive in a browser\'s address bar but are often broken by the chat\n apps and editors that turn text into links.\n- The reader tolerates a stray `%` that doesn\'t start an escape, such as a note saying `50%`.\n\n### `src`: a file hosted elsewhere\n\n```\nhttps://perfboarddesigner.com/app/#src=https%3A%2F%2Fexample.com%2Fmy-board.json\n```\n\n- The address must be `http://` or `https://`, and the site must allow other websites to read\n the file (CORS). Raw GitHub Gist and raw GitHub file addresses\n (`gist.githubusercontent.com`, `raw.githubusercontent.com`) do. A gist\'s normal page does not.\n- The user is asked before anything is downloaded, since fetching the file shows that site the\n visit.\n- Without a `name`, the project is named after the file (`my-board.json` \u2192 "my-board").\n- There\'s no size limit to worry about here, so this suits large boards and programs that can\n publish files.\n\n### `p`: a stored project (short link)\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20blinker&p=led-blinker\n```\n\n- The project is stored on Perfboard Designer\'s own server, `https://projects.perfboarddesigner.com`\n (below), and the link names it by its id. It\'s fetched without asking, since it\'s the site\'s own.\n- Without a `name`, the project is named after its id.\n- A stored project never changes, and it\'s deleted after a year unopened. Anyone with the link\n can open it. Unlike the other forms, it needs the server: the Share dialog offers the full link\n beside it, which works without one.\n\n### Stored projects\n\n`https://projects.perfboarddesigner.com` keeps projects for short links. Anyone can store one:\n\n| Request | Answer |\n| --- | --- |\n| `POST /projects` with `{"project": {\u2026}, "id": "led-blinker", "name": "LED blinker"}` (`id` and `name` optional) | `{id, link, file, image, png}`: the id it got, a short link, the file\'s address and its pictures\' |\n| `GET /<id>.json` | the project file |\n| `GET /<id>.png`, `GET /<id>.svg` | pictures of the board |\n\n- **Ids** are lowercase letters, digits and dashes, at most 40 characters, made from the wanted\n `id` or else the `name` (`"M\xE1gneses kapcsol\xF3!"` \u2192 `magneses-kapcsolo`). If another board has\n that id, a few characters of the board\'s SHA-256 are added (`led-blinker-08196a`); storing the\n same board under the same id again gives the same id back. With neither, the id is the hash.\n- Only valid project files are stored, as the editor reads them, up to 1 MB.\n- Every site may call it (CORS). There\'s no sign-in.\n- It\'s the [MCP server\'s](../mcp/README.md) Cloudflare Worker, which agents store through too.\n\n### Limits\n\n- The project file may be at most 5 MB once unpacked, and a board at most 500 holes on a side.\n- Links longer than about 8,000 characters may be cut off by some chat apps and mail clients; the\n Share dialog warns about these. For scale, the boards in [`examples/`](../examples) make `z`\n links of 0.8k to 2.7k characters.\n\n## The project file\n\nVersion 8 adds optional `requirements`: independent intended `nets` containing\n`{componentId, pin}` terminals, an explicit `unused` terminal list, component/pin snapshots\n(`components`) and an opt-in `validate` flag.\nAll terminals refer to stable component identities, not editable reference names. Snapshots\nkeep missing components/pins reportable; unspecified terminals are unchecked rather than unused.\nInvalid or overlapping requirement assignments reject the import instead of silently dropping\nconstraints. Board edits must preserve intended nets; adding a component extends the shared\ninventory without assigning new connections.\n\nVersion 7 adds a project-scoped `instanceId` to each placed part. Older readers skip it, so it\ndoesn\'t need a newer version on its own. A top-level `schematic` field, written by older editors,\nis ignored.\n\nA share link carries the same project file as **File \u2192 Save Project to File**. Every version\nopens, but write the oldest one that holds your board: version 8 with requirements,\nelse version 6 with a custom module, else 5\nwith a solder path, else 4 if a wire bends, else 3 (the same without any of them), which older\neditors open too. It\'s documented field by field in\n[`src/project-file/project-file.ts`](../src/project-file/project-file.ts). In short:\n\n- Positions are `[column, row]` grid holes counted from the **top-left hole**, both starting at 0.\n Neighbouring holes are 2.54 mm (0.1 in) apart.\n- `board`: `{"type": "perfboard", "cols": 12, "rows": 8}`, or a stripboard with\n `"strips": "horizontal" | "vertical"` and `"cuts": [[col, row], ...]`.\n- `pads`: holes with a `note` (like `+9V` or `GND`), as `{"at": [c, r], "note": "+9V"}`. Purely\n a label: it doesn\'t connect anything.\n- `wires`: `{"from": [c, r], "to": [c, r]}`, with optional `color` (`"#rrggbb"`) and `width`. A\n wire joins only its two end holes. With `"via": [[c, r], ...]` (version 4) it bends at those\n holes on its way, in order; a bend joins nothing. With `"kind": "solder"` (version 5) it\'s a\n solder path instead: a trail of solder on the copper side, with no `color` or `width`, that\n joins every hole it runs over (ends, bends and the holes between) and any solder path it\n touches.\n- `placedStandardComponents`: two-lead parts placed between two holes: `definitionId`, `from`,\n `to`, optional `value` (`"10k"`, `"100n"`) and `color` (LEDs). On polarized parts, `from` is\n an LED\'s cathode, a diode\'s anode and an electrolytic capacitor\'s \u2212 lead (`leadLabels` in the\n definitions).\n- `placedAdvancedComponents`: fixed-footprint parts: `definitionId`, the anchor pin `at`,\n `rotation` (0, 90, 180 or 270), `rows` and `cols` (1 except for sizable parts such as header\n pins), optional `value`. A user-made module has `"definitionId": "custom"` and carries the\n whole part in `custom` (version 6): `name`, optional `refPrefix`, its size in holes `cols` and\n `rows`, its `pins` in order as `{"at": [c, r], "label": "VCC"}` (holes within the body from its\n top-left hole; pin 1 is the anchor `at`) and an optional `color`. With `"shape"`, the id of a\n built-in fixed-pin part (e.g. `"transistor"` for a TO-92), it\'s that package with its own `name`\n and pin names (`pins` in the package\'s pin order, each `{"label": "B"}`): the package decides its\n holes, and `cols`, `rows` and each `at` are written to match it.\n- `placedIcs`: DIP chips and dual-row modules: `name`, `at` (top-left pin), `widthPin` (columns\n including both pin rows, 4 for a 0.3" DIP), `heightPin` (pins per side), `rotation`, and\n `pinDescription` (`{"1": "GND", "2": "TRIG", ...}`, numbered counter-clockwise from pin 1).\n- `customIcs`: user-made catalog entries. `[]` is fine.\n- Every part should have a unique `ref` (R1, C2, U1...). Missing or duplicate refs are numbered\n automatically.\n\nThe reader is forgiving: empty lists can be left out, a file without `version` that has a `board`\nis read as version 8, and board entries it can\'t read are skipped (and counted) instead of failing the\nwhole project.\n\nThe `definitionId`s, with each part\'s pins, are in\n[`component-definitions.ts`](../src/parts/component-definitions.ts)\n(two-lead parts such as `resistor`, `ceramic-capacitor`, `electrolytic-capacitor`, `led` and\n`diode`) and\n[`advanced-component-definitions.ts`](../src/parts/advanced-component-definitions.ts)\n(fixed-footprint parts such as `transistor`, `potentiometer` and `header-pins`). Built-in chips are\nin [`ic-definitions.ts`](../src/parts/ic-definitions.ts), and footprints are described in\n[component-footprints.md](component-footprints.md). Check ids against these files: a part with an\nunknown `definitionId` isn\'t skipped, it stays on the board as an unrecognised part with an `X` ref.\n\n## Example\n\nA 9 V LED circuit on a 12 \xD7 8 perfboard:\n\n```json\n{\n "version": 3,\n "board": {"type": "perfboard", "cols": 12, "rows": 8},\n "pads": [{"at": [1, 1], "note": "+9V"}, {"at": [1, 6], "note": "GND"}],\n "wires": [\n {"from": [1, 1], "to": [3, 1], "color": "#ef4444"},\n {"from": [8, 4], "to": [8, 6]},\n {"from": [8, 6], "to": [1, 6]}\n ],\n "placedIcs": [],\n "placedStandardComponents": [\n {"ref": "R1", "definitionId": "resistor", "from": [3, 1], "to": [8, 1], "value": "470"},\n {"ref": "D1", "definitionId": "led", "from": [8, 2], "to": [8, 4], "color": "#22c55e"}\n ],\n "placedAdvancedComponents": [\n {"ref": "J1", "definitionId": "header-pins", "at": [0, 1], "rotation": 0, "rows": 6, "cols": 1}\n ],\n "customIcs": []\n}\n```\n\nAs a `json` link (the start of it):\n\n```\nhttps://perfboarddesigner.com/app/#name=LED%20demo&json=%7B%22version%22%3A3%2C%22board%22%3A%7B%22type%22%3A%22perfboard%22%2C...\n```\n' }] }));
44250
44970
  server.registerResource("parts", "perfboard://parts", {
44251
44971
  title: "Parts catalog",
44252
44972
  description: "Every part a project can place, with pins and pin labels, as JSON.",
@@ -44263,7 +44983,7 @@ function registerResources(server) {
44263
44983
 
44264
44984
  // src/create-server.ts
44265
44985
  function createServer({ editorUrl, imageUrl: imageUrl2, storage }) {
44266
- const server = new McpServer({ name: "perfboard-designer", version: "0.2.0" }, { instructions: INSTRUCTIONS });
44986
+ const server = new McpServer({ name: "perfboard-designer", version: "0.4.0" }, { instructions: INSTRUCTIONS });
44267
44987
  registerCatalogTools(server);
44268
44988
  registerProjectTools(server);
44269
44989
  registerBoardTools(server);