@ohtaman/washi 0.8.2 → 0.9.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 (47) hide show
  1. package/README.md +3 -0
  2. package/dist/browser/solvers/{highs-__vite-browser-external-Dn-83hnF.js → highs-__vite-browser-external-xcxOpLMD.js} +1 -1
  3. package/dist/browser/solvers/{highs-browser-runtime-0Bgq5ksG.js → highs-browser-runtime-ccRmE4qj.js} +1 -1
  4. package/dist/browser/solvers/highs-inline.js +51 -0
  5. package/dist/{lib/solvers/loader-CDpPXN_F.js → browser/solvers/highs-loader-Csn3-0tq.js} +241 -149
  6. package/dist/browser/solvers/highs-worker.js +17 -16
  7. package/dist/browser/solvers/highs.js +295 -255
  8. package/dist/browser/solvers/pumpkin-inline.js +51 -0
  9. package/dist/{lib/solvers/loader-Ow74Fa1B.js → browser/solvers/pumpkin-loader-BI3n3dWO.js} +145 -55
  10. package/dist/browser/solvers/pumpkin-worker.js +24 -23
  11. package/dist/browser/solvers/pumpkin.js +307 -288
  12. package/dist/browser/washi.js +365 -316
  13. package/dist/browser/washi.min.js +4 -4
  14. package/dist/lib/solvers/embedded-wasm-CSFlLV5N.js +49 -0
  15. package/dist/lib/solvers/highs-node-runtime.js +1 -7
  16. package/dist/lib/solvers/highs-worker.js +19 -17
  17. package/dist/lib/solvers/highs.js +153 -112
  18. package/dist/{browser/solvers/highs-loader-BLY3wzDH.js → lib/solvers/loader-DCtyxsfF.js} +56 -36
  19. package/dist/{browser/solvers/pumpkin-loader-CvdaKxf4.js → lib/solvers/loader-b5PNpCmX.js} +58 -33
  20. package/dist/lib/solvers/pumpkin-worker.js +25 -23
  21. package/dist/lib/solvers/pumpkin.js +212 -192
  22. package/dist/lib/washi.js +365 -316
  23. package/dist/types/modeler/model.d.ts +7 -0
  24. package/dist/types/modeler/model.d.ts.map +1 -1
  25. package/dist/types/modeler/solvers/embedded-wasm.d.ts +36 -0
  26. package/dist/types/modeler/solvers/embedded-wasm.d.ts.map +1 -0
  27. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  28. package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
  29. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  30. package/dist/types/modeler/solvers/inline-pack.d.ts +6 -0
  31. package/dist/types/modeler/solvers/inline-pack.d.ts.map +1 -0
  32. package/dist/types/modeler/solvers/pumpkin/loader.d.ts +1 -1
  33. package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
  34. package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
  35. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
  36. package/dist/types/modeler/solvers/pumpkin/worker.d.ts +1 -0
  37. package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -1
  38. package/docs/getting-started/ai-agents.md +56 -1
  39. package/docs/getting-started/coding-agents.md +38 -5
  40. package/docs/getting-started/runtimes.md +63 -1
  41. package/docs/solvers/highs.md +2 -0
  42. package/docs/solvers/pumpkin.md +2 -0
  43. package/llms-full.txt +123 -2
  44. package/llms.txt +56 -1
  45. package/package.json +12 -1
  46. package/skills/washi/SKILL.md +75 -14
  47. package/skills/washi/references/single-html.md +330 -0
@@ -1,10 +1,10 @@
1
- import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./pumpkin-loader-CvdaKxf4.js";
1
+ import { a as e, c as t, d as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./pumpkin-loader-BI3n3dWO.js";
2
2
  //#region src/modeler/quad-expr.ts
3
- function d(e, t) {
3
+ function p(e, t) {
4
4
  let n = e.id, r = t.id;
5
5
  return n <= r ? `${n}:${r}` : `${r}:${n}`;
6
6
  }
7
- var f = class e {
7
+ var m = class e {
8
8
  kind = "quadratic";
9
9
  linearTerms;
10
10
  quadTerms;
@@ -14,7 +14,7 @@ var f = class e {
14
14
  this.linearTerms = new Map(e), this.quadTerms = /* @__PURE__ */ new Map();
15
15
  for (let [e, n] of t) this.quadTerms.set(e, { ...n });
16
16
  this.constant = n, this.nonlinearTerms = r.filter((e) => e.coeff !== 0).map((e) => ({
17
- atom: g(e.atom),
17
+ atom: v(e.atom),
18
18
  coeff: e.coeff
19
19
  }));
20
20
  }
@@ -25,11 +25,11 @@ var f = class e {
25
25
  return new e(this.linearTerms, this.quadTerms, this.constant, this.nonlinearTerms);
26
26
  }
27
27
  getQuadCoeff(e, t) {
28
- let n = d(e, t), r = this.quadTerms.get(n);
28
+ let n = p(e, t), r = this.quadTerms.get(n);
29
29
  return r ? r.coeff : 0;
30
30
  }
31
31
  add(t) {
32
- if (E(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
32
+ if (D(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
33
33
  let n = this.clone();
34
34
  if (typeof t == "number") return n.constant += t, n;
35
35
  if (t instanceof e) {
@@ -46,7 +46,7 @@ var f = class e {
46
46
  t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
47
47
  }
48
48
  if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
49
- atom: g(e.atom),
49
+ atom: v(e.atom),
50
50
  coeff: e.coeff
51
51
  });
52
52
  return n;
@@ -57,7 +57,7 @@ var f = class e {
57
57
  t === 0 ? n.linearTerms.delete(e) : n.linearTerms.set(e, t);
58
58
  }
59
59
  if (n.constant += t.constant, Array.isArray(t.nonlinearTerms)) for (let e of t.nonlinearTerms) e.coeff !== 0 && n.nonlinearTerms.push({
60
- atom: g(e.atom),
60
+ atom: v(e.atom),
61
61
  coeff: e.coeff
62
62
  });
63
63
  return n;
@@ -66,11 +66,11 @@ var f = class e {
66
66
  return i === 0 ? n.linearTerms.delete(r) : n.linearTerms.set(r, i), n;
67
67
  }
68
68
  sub(e) {
69
- if (E(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
69
+ if (D(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
70
70
  return typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
71
71
  }
72
72
  mul(t) {
73
- if (E(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
73
+ if (D(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
74
74
  if (typeof t == "number") {
75
75
  let n = this.linearTerms.size > 0 || this.quadTerms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
76
76
  if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
@@ -93,7 +93,7 @@ var f = class e {
93
93
  let n = e.coeff * t;
94
94
  if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
95
95
  n !== 0 && i.nonlinearTerms.push({
96
- atom: g(e.atom),
96
+ atom: v(e.atom),
97
97
  coeff: n
98
98
  });
99
99
  }
@@ -137,7 +137,7 @@ var f = class e {
137
137
  e += t.coeff * t.var1.value * t.var2.value;
138
138
  }
139
139
  for (let t of this.nonlinearTerms) {
140
- let n = v(t.atom);
140
+ let n = b(t.atom);
141
141
  if (n === null) return null;
142
142
  e += t.coeff * n;
143
143
  }
@@ -163,12 +163,12 @@ var f = class e {
163
163
  }
164
164
  toDiscreteComparison(e, t, n) {
165
165
  if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in discrete comparisons (${e}): quadratic terms are only allowed in objectives.`);
166
- let r = new x(this.linearTerms, this.constant, this.nonlinearTerms);
166
+ let r = new C(this.linearTerms, this.constant, this.nonlinearTerms);
167
167
  return e === "<" ? r.lt(t, n) : e === ">" ? r.gt(t, n) : r.ne(t, n);
168
168
  }
169
169
  toConstraint(e, t, n) {
170
170
  if (this.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${e}): quadratic terms are only allowed in objectives.`);
171
- let r = new x(this.linearTerms, this.constant, this.nonlinearTerms);
171
+ let r = new C(this.linearTerms, this.constant, this.nonlinearTerms);
172
172
  return e === "<=" ? r.le(t, n) : e === ">=" ? r.ge(t, n) : r.eq(t, n);
173
173
  }
174
174
  and(e) {
@@ -197,7 +197,7 @@ var f = class e {
197
197
  e.push(`${i}${o}${n.name}`), t = !1;
198
198
  }
199
199
  if (this.nonlinearTerms.length > 0) {
200
- let n = new x(/* @__PURE__ */ new Map(), 0, this.nonlinearTerms).toString();
200
+ let n = new C(/* @__PURE__ */ new Map(), 0, this.nonlinearTerms).toString();
201
201
  n !== "0" && (e.push(t ? n : n.startsWith("-") ? `- ${n.slice(2)}` : `+ ${n}`), t = !1);
202
202
  }
203
203
  if (this.constant !== 0 || e.length === 0) {
@@ -209,7 +209,7 @@ var f = class e {
209
209
  static fromProduct(t, n, r = 1) {
210
210
  let i = new e();
211
211
  if (r === 0) return i;
212
- let a = d(t, n);
212
+ let a = p(t, n);
213
213
  return i.quadTerms.set(a, {
214
214
  var1: t.id <= n.id ? t : n,
215
215
  var2: t.id <= n.id ? n : t,
@@ -239,7 +239,7 @@ var f = class e {
239
239
  return s;
240
240
  }
241
241
  static extractScalarDivisor(e, t) {
242
- if (E(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
242
+ if (D(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
243
243
  if (typeof e == "number") {
244
244
  if (e === 0) throw Error(`Division by zero in ${t}`);
245
245
  return e;
@@ -249,8 +249,8 @@ var f = class e {
249
249
  if (e.constant === 0) throw Error(`Division by zero in ${t}`);
250
250
  return e.constant;
251
251
  }
252
- }, p = 0;
253
- function m(e) {
252
+ }, h = 0;
253
+ function g(e) {
254
254
  if (e === void 0) return "Continuous";
255
255
  if (typeof e == "string") {
256
256
  let t = e.toLowerCase();
@@ -260,7 +260,7 @@ function m(e) {
260
260
  }
261
261
  throw Error(`Invalid variable type "${String(e)}": expected "Continuous", "Integer", or "Binary".`);
262
262
  }
263
- var h = class {
263
+ var _ = class {
264
264
  id;
265
265
  _name;
266
266
  prefix;
@@ -273,9 +273,9 @@ var h = class {
273
273
  value = null;
274
274
  reducedCost = null;
275
275
  constructor(e = {}) {
276
- this.id = ++p;
276
+ this.id = ++h;
277
277
  let t = typeof e.name == "string" ? e.name.trim() : "", n = typeof e.prefix == "string" ? e.prefix.trim() : "";
278
- this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = m(e.type), this._type === "Binary" ? (this._lb = 0, this._ub = 1) : (this._lb = e.lb === void 0 ? 0 : e.lb, this._ub = e.ub === void 0 ? Infinity : e.ub), this._initialValue = e.initialValue === void 0 ? void 0 : Object.is(e.initialValue, -0) ? 0 : e.initialValue, this._initialValue !== void 0 && ee(this);
278
+ this.prefix = n.length > 0 ? n : "x", this.hasExplicitName = t.length > 0, this._name = this.hasExplicitName ? t : `${this.prefix}_${this.id}`, this._type = g(e.type), this._type === "Binary" ? (this._lb = 0, this._ub = 1) : (this._lb = e.lb === void 0 ? 0 : e.lb, this._ub = e.ub === void 0 ? Infinity : e.ub), this._initialValue = e.initialValue === void 0 ? void 0 : Object.is(e.initialValue, -0) ? 0 : e.initialValue, this._initialValue !== void 0 && te(this);
279
279
  }
280
280
  get name() {
281
281
  return this._name;
@@ -284,60 +284,60 @@ var h = class {
284
284
  return this._type;
285
285
  }
286
286
  set type(e) {
287
- let t = m(e);
288
- this._type !== t && (this._type = t, C(this.ownerModel));
287
+ let t = g(e);
288
+ this._type !== t && (this._type = t, w(this.ownerModel));
289
289
  }
290
290
  get lb() {
291
291
  return this._lb;
292
292
  }
293
293
  set lb(e) {
294
- Object.is(this._lb, e) || (this._lb = e, C(this.ownerModel));
294
+ Object.is(this._lb, e) || (this._lb = e, w(this.ownerModel));
295
295
  }
296
296
  get ub() {
297
297
  return this._ub;
298
298
  }
299
299
  set ub(e) {
300
- Object.is(this._ub, e) || (this._ub = e, C(this.ownerModel));
300
+ Object.is(this._ub, e) || (this._ub = e, w(this.ownerModel));
301
301
  }
302
302
  get initialValue() {
303
303
  return this._initialValue;
304
304
  }
305
305
  set initialValue(e) {
306
306
  let t = e !== void 0 && Object.is(e, -0) ? 0 : e;
307
- Object.is(this._initialValue, t) || (this._initialValue = t, C(this.ownerModel));
307
+ Object.is(this._initialValue, t) || (this._initialValue = t, w(this.ownerModel));
308
308
  }
309
309
  _assignModelName(e) {
310
310
  this._name = e;
311
311
  }
312
312
  mul(e) {
313
- return typeof e == "number" ? new x(/* @__PURE__ */ new Map([[this, 1]]), 0).mul(e) : new f(/* @__PURE__ */ new Map([[this, 1]]), /* @__PURE__ */ new Map(), 0).mul(e);
313
+ return typeof e == "number" ? new C(/* @__PURE__ */ new Map([[this, 1]]), 0).mul(e) : new m(/* @__PURE__ */ new Map([[this, 1]]), /* @__PURE__ */ new Map(), 0).mul(e);
314
314
  }
315
315
  add(e) {
316
- return e instanceof f ? e.add(this) : new x(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
316
+ return e instanceof m ? e.add(this) : new C(/* @__PURE__ */ new Map([[this, 1]]), 0).add(e);
317
317
  }
318
318
  sub(e) {
319
- return e instanceof f ? e.neg().add(this) : new x(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
319
+ return e instanceof m ? e.neg().add(this) : new C(/* @__PURE__ */ new Map([[this, 1]]), 0).sub(e);
320
320
  }
321
321
  neg() {
322
322
  return this.mul(-1);
323
323
  }
324
324
  le(e, t) {
325
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
325
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).le(e, t);
326
326
  }
327
327
  ge(e, t) {
328
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
328
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).ge(e, t);
329
329
  }
330
330
  eq(e, t) {
331
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
331
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).eq(e, t);
332
332
  }
333
333
  lt(e, t) {
334
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).lt(e, t);
334
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).lt(e, t);
335
335
  }
336
336
  gt(e, t) {
337
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).gt(e, t);
337
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).gt(e, t);
338
338
  }
339
339
  ne(e, t) {
340
- return new x(/* @__PURE__ */ new Map([[this, 1]]), 0).ne(e, t);
340
+ return new C(/* @__PURE__ */ new Map([[this, 1]]), 0).ne(e, t);
341
341
  }
342
342
  toString() {
343
343
  return this.name;
@@ -345,7 +345,7 @@ var h = class {
345
345
  };
346
346
  //#endregion
347
347
  //#region src/modeler/expression.ts
348
- function g(e) {
348
+ function v(e) {
349
349
  switch (e.kind) {
350
350
  case "abs": return {
351
351
  kind: "abs",
@@ -367,7 +367,7 @@ function g(e) {
367
367
  };
368
368
  }
369
369
  }
370
- function _(e) {
370
+ function y(e) {
371
371
  switch (e.kind) {
372
372
  case "abs": return `abs(${e.arg.toString()})`;
373
373
  case "max": return `max(${e.args.map((e) => e.toString()).join(", ")})`;
@@ -375,7 +375,7 @@ function _(e) {
375
375
  case "at": return `at([${e.array.map((e) => e.toString()).join(", ")}], ${e.index.toString()})`;
376
376
  }
377
377
  }
378
- function v(e) {
378
+ function b(e) {
379
379
  switch (e.kind) {
380
380
  case "abs": {
381
381
  let t = e.arg.value;
@@ -407,21 +407,21 @@ function v(e) {
407
407
  }
408
408
  }
409
409
  }
410
- function y(e) {
411
- return e instanceof h || typeof e == "object" && !!e && !E(e) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
410
+ function x(e) {
411
+ return e instanceof _ || typeof e == "object" && !!e && !D(e) && typeof e.id == "number" && typeof e.name == "string" && typeof e.lb == "number" && typeof e.ub == "number" && typeof e.type == "string" && typeof e.mul == "function";
412
412
  }
413
- function b(e, t, n = /* @__PURE__ */ new Set()) {
413
+ function S(e, t, n = /* @__PURE__ */ new Set()) {
414
414
  if (typeof e == "number") {
415
415
  if (!Number.isSafeInteger(e)) throw Error(`${t} requires Integer or Binary variables and integer constants/coefficients, but received constant ${e}.`);
416
416
  return n;
417
417
  }
418
- if (E(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
419
- if (e instanceof f || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number") {
418
+ if (D(e)) throw Error(`${t} cannot accept a Constraint comparison.`);
419
+ if (e instanceof m || "quadTerms" in e && e.quadTerms instanceof Map && "linearTerms" in e && e.linearTerms instanceof Map && typeof e.constant == "number") {
420
420
  let r = e;
421
421
  if (r.quadTerms.size > 0) throw Error(`${t} does not support quadratic expressions.`);
422
- return b(new x(r.linearTerms, r.constant, r.nonlinearTerms ?? []), t, n);
422
+ return S(new C(r.linearTerms, r.constant, r.nonlinearTerms ?? []), t, n);
423
423
  }
424
- if (y(e)) {
424
+ if (x(e)) {
425
425
  if (e.type !== "Integer" && e.type !== "Binary") throw Error(`${t} requires Integer or Binary variables, but involves Continuous variable "${e.name}".`);
426
426
  return n.add(e), n;
427
427
  }
@@ -437,25 +437,25 @@ function b(e, t, n = /* @__PURE__ */ new Set()) {
437
437
  if (e.coeff === 0) continue;
438
438
  if (!Number.isSafeInteger(e.coeff)) throw Error(`${t} requires integer coefficients on nonlinear expressions, received ${e.coeff}.`);
439
439
  let r = e.atom;
440
- if (r.kind === "abs") b(r.arg, t, n);
441
- else if (r.kind === "max" || r.kind === "min") for (let e of r.args) b(e, t, n);
440
+ if (r.kind === "abs") S(r.arg, t, n);
441
+ else if (r.kind === "max" || r.kind === "min") for (let e of r.args) S(e, t, n);
442
442
  else if (r.kind === "at") {
443
- b(r.index, t, n);
444
- for (let e of r.array) b(e, t, n);
443
+ S(r.index, t, n);
444
+ for (let e of r.array) S(e, t, n);
445
445
  }
446
446
  }
447
447
  return n;
448
448
  }
449
449
  throw Error(`${t} expected an integer-valued scalar expression.`);
450
450
  }
451
- var x = class e {
451
+ var C = class e {
452
452
  kind = "linear";
453
453
  terms;
454
454
  constant;
455
455
  nonlinearTerms;
456
456
  constructor(e = /* @__PURE__ */ new Map(), t = 0, n = []) {
457
457
  this.terms = new Map(e), this.constant = t, this.nonlinearTerms = n.filter((e) => e.coeff !== 0).map((e) => ({
458
- atom: g(e.atom),
458
+ atom: v(e.atom),
459
459
  coeff: e.coeff
460
460
  }));
461
461
  }
@@ -473,8 +473,8 @@ var x = class e {
473
473
  return new e(this.terms, this.constant, this.nonlinearTerms);
474
474
  }
475
475
  add(e) {
476
- if (E(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
477
- if (e instanceof f) return e.add(this);
476
+ if (D(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
477
+ if (e instanceof m) return e.add(this);
478
478
  let t = this.clone();
479
479
  if (typeof e == "number") t.constant += e;
480
480
  else if ("terms" in e) {
@@ -483,7 +483,7 @@ var x = class e {
483
483
  e === 0 ? t.terms.delete(n) : t.terms.set(n, e);
484
484
  }
485
485
  if (t.constant += e.constant, Array.isArray(e.nonlinearTerms)) for (let n of e.nonlinearTerms) n.coeff !== 0 && t.nonlinearTerms.push({
486
- atom: g(n.atom),
486
+ atom: v(n.atom),
487
487
  coeff: n.coeff
488
488
  });
489
489
  } else {
@@ -493,11 +493,11 @@ var x = class e {
493
493
  return t;
494
494
  }
495
495
  sub(e) {
496
- if (E(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
497
- return e instanceof f ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
496
+ if (D(e)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
497
+ return e instanceof m ? e.neg().add(this) : typeof e == "number" ? this.add(-e) : this.add(e.mul(-1));
498
498
  }
499
499
  mul(t) {
500
- if (E(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
500
+ if (D(t)) throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
501
501
  if (typeof t == "number") {
502
502
  let n = this.terms.size > 0 || this.nonlinearTerms.length > 0, r = this.constant === 0 && n ? 0 : this.constant * t;
503
503
  if (this.constant !== 0 && t !== 0 && r === 0) throw Error("Constant multiplication underflows to zero.");
@@ -511,17 +511,17 @@ var x = class e {
511
511
  let n = e.coeff * t;
512
512
  if (e.coeff !== 0 && n === 0) throw Error("Coefficient multiplication underflows to zero.");
513
513
  n !== 0 && i.nonlinearTerms.push({
514
- atom: g(e.atom),
514
+ atom: v(e.atom),
515
515
  coeff: n
516
516
  });
517
517
  }
518
518
  return i;
519
519
  }
520
- if (t instanceof h || typeof t == "object" && t && "id" in t && !("terms" in t) && !("quadTerms" in t)) {
520
+ if (t instanceof _ || typeof t == "object" && t && "id" in t && !("terms" in t) && !("quadTerms" in t)) {
521
521
  if (this.hasNonlinearTerms()) throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
522
- return f.multiplyLinearTerms(this.constant, this.terms, 0, /* @__PURE__ */ new Map([[t, 1]]));
522
+ return m.multiplyLinearTerms(this.constant, this.terms, 0, /* @__PURE__ */ new Map([[t, 1]]));
523
523
  }
524
- if (t instanceof f) {
524
+ if (t instanceof m) {
525
525
  let e = t.linearTerms.size > 0 || t.quadTerms.size > 0 || t.hasNonlinearTerms();
526
526
  if (this.hasNonlinearTerms()) {
527
527
  if (!e) return this.mul(t.constant);
@@ -531,7 +531,7 @@ var x = class e {
531
531
  if (this.terms.size === 0) return t.mul(this.constant);
532
532
  throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
533
533
  }
534
- return this.terms.size === 0 ? t.mul(this.constant) : new f(this.terms, /* @__PURE__ */ new Map(), this.constant).mul(t);
534
+ return this.terms.size === 0 ? t.mul(this.constant) : new m(this.terms, /* @__PURE__ */ new Map(), this.constant).mul(t);
535
535
  }
536
536
  let n = Array.isArray(t.nonlinearTerms) && t.nonlinearTerms.length > 0;
537
537
  if (this.hasNonlinearTerms()) {
@@ -542,10 +542,10 @@ var x = class e {
542
542
  if (this.terms.size === 0) return t.mul(this.constant);
543
543
  throw Error("Cannot multiply nonlinear expression (max, min, abs, or at) by a variable expression: only scalar multiplication is supported.");
544
544
  }
545
- return this.terms.size === 0 ? t.mul(this.constant) : t.terms.size === 0 ? this.mul(t.constant) : f.multiplyLinearTerms(this.constant, this.terms, t.constant, t.terms);
545
+ return this.terms.size === 0 ? t.mul(this.constant) : t.terms.size === 0 ? this.mul(t.constant) : m.multiplyLinearTerms(this.constant, this.terms, t.constant, t.terms);
546
546
  }
547
547
  div(e) {
548
- let t = f.extractScalarDivisor(e, "LinExpr.div()");
548
+ let t = m.extractScalarDivisor(e, "LinExpr.div()");
549
549
  return this.mul(1 / t);
550
550
  }
551
551
  neg() {
@@ -558,7 +558,7 @@ var x = class e {
558
558
  e += n * t.value;
559
559
  }
560
560
  for (let t of this.nonlinearTerms) {
561
- let n = v(t.atom);
561
+ let n = b(t.atom);
562
562
  if (n === null) return null;
563
563
  e += t.coeff * n;
564
564
  }
@@ -583,9 +583,9 @@ var x = class e {
583
583
  return this.toDiscreteComparison("!=", e, t);
584
584
  }
585
585
  toDiscreteComparison(e, t, n) {
586
- if (t instanceof T || typeof t == "object" && t && "sense" in t && "lhs" in t) throw Error(`Cannot compare against a Constraint in (${e}): expected a finite integer, discrete Var, or discrete LinExpr.`);
586
+ if (t instanceof E || typeof t == "object" && t && "sense" in t && "lhs" in t) throw Error(`Cannot compare against a Constraint in (${e}): expected a finite integer, discrete Var, or discrete LinExpr.`);
587
587
  let r = `discrete ${e}`, i = /* @__PURE__ */ new Set();
588
- b(this, r, i), b(t, r, i);
588
+ S(this, r, i), S(t, r, i);
589
589
  let a = this.toConstraint(e === "<" ? "<=" : e === ">" ? ">=" : "!=", t, n);
590
590
  if (e === "<") {
591
591
  let e = a.rhs - 1;
@@ -601,14 +601,14 @@ var x = class e {
601
601
  toConstraint(t, n, r) {
602
602
  let i = this.clone(), a = 0;
603
603
  if (typeof n == "number") a = n;
604
- else if (n instanceof T || typeof n == "object" && n && "sense" in n && "lhs" in n) throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);
605
- else if (n instanceof f || typeof n == "object" && n && "quadTerms" in n) {
604
+ else if (n instanceof E || typeof n == "object" && n && "sense" in n && "lhs" in n) throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);
605
+ else if (n instanceof m || typeof n == "object" && n && "quadTerms" in n) {
606
606
  let r = n;
607
607
  if (r.quadTerms.size > 0) throw Error(`Quadratic expressions are not supported in linear constraints (${t}): quadratic terms are only allowed in objectives.`);
608
608
  i = i.sub(new e(r.linearTerms, 0, r.nonlinearTerms ?? [])), a = r.constant;
609
609
  } else "terms" in n ? (i = i.sub(new e(n.terms, 0, n.nonlinearTerms ?? [])), a = n.constant) : i = i.sub(n);
610
610
  let o = a - i.constant;
611
- return i.constant = 0, new T(i, t, o, r);
611
+ return i.constant = 0, new E(i, t, o, r);
612
612
  }
613
613
  and(e) {
614
614
  throw Error("Cannot use an arithmetic expression without a comparison operator (<=, >=, ==, !=, <, >) in logical 'and': expected a BoolVar, Constraint, or BoolOp.");
@@ -633,7 +633,7 @@ var x = class e {
633
633
  }
634
634
  for (let n of this.nonlinearTerms) {
635
635
  let r = n.coeff, i = r >= 0 ? t ? "" : "+ " : "- ", a = Math.abs(r), o = a === 1 ? "" : `${a} `;
636
- e.push(`${i}${o}${_(n.atom)}`), t = !1;
636
+ e.push(`${i}${o}${y(n.atom)}`), t = !1;
637
637
  }
638
638
  if (this.constant !== 0 || e.length === 0) {
639
639
  let n = this.constant >= 0 ? t ? "" : "+ " : "- ";
@@ -641,12 +641,12 @@ var x = class e {
641
641
  }
642
642
  return e.join(" ") || "0";
643
643
  }
644
- }, S = /* @__PURE__ */ new WeakMap();
645
- function C(e) {
646
- e && S.get(e)?.();
644
+ }, ee = /* @__PURE__ */ new WeakMap();
645
+ function w(e) {
646
+ e && ee.get(e)?.();
647
647
  }
648
- var w = 1e-6;
649
- function ee(e) {
648
+ var T = 1e-6;
649
+ function te(e) {
650
650
  if (typeof e.lb != "number" || Number.isNaN(e.lb)) throw Error(`Variable "${e.name}" has invalid lower bound: ${e.lb} (NaN or non-numeric bound is not allowed).`);
651
651
  if (e.lb === Infinity) throw Error(`Variable "${e.name}" has invalid lower bound: +Infinity is not allowed as a lower bound.`);
652
652
  if (typeof e.ub != "number" || Number.isNaN(e.ub)) throw Error(`Variable "${e.name}" has invalid upper bound: ${e.ub} (NaN or non-numeric bound is not allowed).`);
@@ -655,16 +655,16 @@ function ee(e) {
655
655
  if (e.initialValue !== void 0) {
656
656
  if (typeof e.initialValue != "number" || !Number.isFinite(e.initialValue)) throw Error(`Variable "${e.name}" has invalid initialValue: ${String(e.initialValue)} (initialValue must be a finite number).`);
657
657
  let t = e.type === "Binary" ? Math.max(0, e.lb) : e.lb, n = e.type === "Binary" ? Math.min(1, e.ub) : e.ub;
658
- if (e.initialValue < t - 1e-6 || e.initialValue > n + 1e-6) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${w}).`);
658
+ if (e.initialValue < t - 1e-6 || e.initialValue > n + 1e-6) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${T}).`);
659
659
  if (e.type === "Integer" || e.type === "Binary") {
660
660
  let r = Math.round(e.initialValue);
661
- if (Math.abs(e.initialValue - r) > 1e-6 || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${w} of an integer in [${t}, ${n}]).`);
661
+ if (Math.abs(e.initialValue - r) > 1e-6 || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${T} of an integer in [${t}, ${n}]).`);
662
662
  }
663
663
  }
664
664
  }
665
665
  //#endregion
666
666
  //#region src/modeler/constraint.ts
667
- var te = 0, T = class e {
667
+ var ne = 0, E = class e {
668
668
  kind = "constraint";
669
669
  id;
670
670
  _lhs;
@@ -679,13 +679,13 @@ var te = 0, T = class e {
679
679
  slack = null;
680
680
  dual = null;
681
681
  addTerm(e, t) {
682
- return t === 0 ? this : (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.addTerm(e, t), C(this.ownerModel), this);
682
+ return t === 0 ? this : (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.addTerm(e, t), w(this.ownerModel), this);
683
683
  }
684
684
  setTerm(e, t) {
685
- return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t), C(this.ownerModel), this;
685
+ return this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs.setTerm(e, t), w(this.ownerModel), this;
686
686
  }
687
687
  constructor(e, t, n, r) {
688
- this.id = ++te, this._lhs = e, this._sense = t, this._rhs = n;
688
+ this.id = ++ne, this._lhs = e, this._sense = t, this._rhs = n;
689
689
  let i = typeof r == "string" ? r.trim() : void 0;
690
690
  i && i.length > 0 ? (this._name = i, this.hasExplicitName = !0) : (this._name = `c_${this.id}`, this.hasExplicitName = !1);
691
691
  }
@@ -693,27 +693,27 @@ var te = 0, T = class e {
693
693
  return this._lhs;
694
694
  }
695
695
  set lhs(e) {
696
- this._lhs !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs = e, C(this.ownerModel));
696
+ this._lhs !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._lhs = e, w(this.ownerModel));
697
697
  }
698
698
  get sense() {
699
699
  return this._sense;
700
700
  }
701
701
  set sense(e) {
702
702
  if (e === "!=" && !Number.isSafeInteger(this._rhs)) throw Error(`Discrete "!=" in constraint "${this._name}" requires a safe integer RHS, received ${this._rhs}.`);
703
- this._sense !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._sense = e, C(this.ownerModel));
703
+ this._sense !== e && (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._sense = e, w(this.ownerModel));
704
704
  }
705
705
  get rhs() {
706
706
  return this._rhs;
707
707
  }
708
708
  set rhs(e) {
709
709
  if (this._sense === "!=" && !Number.isSafeInteger(e)) throw Error(`Discrete "!=" in constraint "${this._name}" requires a safe integer RHS, received ${e}.`);
710
- Object.is(this._rhs, e) || (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._rhs = e, C(this.ownerModel));
710
+ Object.is(this._rhs, e) || (this._indicatorOrigin = void 0, this._indicatorSnapshot = void 0, this._rhs = e, w(this.ownerModel));
711
711
  }
712
712
  get name() {
713
713
  return this._name;
714
714
  }
715
715
  set name(e) {
716
- this._name !== e && (this._name = e, C(this.ownerModel)), this.hasExplicitName = !0;
716
+ this._name !== e && (this._name = e, w(this.ownerModel)), this.hasExplicitName = !0;
717
717
  }
718
718
  get _indicatorMeta() {
719
719
  let e = this._indicatorOrigin, t = this._indicatorSnapshot;
@@ -757,19 +757,19 @@ var te = 0, T = class e {
757
757
  this._name = e, this.hasExplicitName = t;
758
758
  }
759
759
  and(e) {
760
- return new k("and", [this, e]);
760
+ return new A("and", [this, e]);
761
761
  }
762
762
  or(e) {
763
- return new k("or", [this, e]);
763
+ return new A("or", [this, e]);
764
764
  }
765
765
  implies(e) {
766
- return new k("implies", [this, e]);
766
+ return new A("implies", [this, e]);
767
767
  }
768
768
  xor(e) {
769
- return new k("xor", [this, e]);
769
+ return new A("xor", [this, e]);
770
770
  }
771
771
  not() {
772
- return new k("not", [this]);
772
+ return new A("not", [this]);
773
773
  }
774
774
  add(e) {
775
775
  throw Error("Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.");
@@ -819,53 +819,53 @@ var te = 0, T = class e {
819
819
  return `${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`;
820
820
  }
821
821
  };
822
- function E(e) {
823
- return e instanceof T || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
822
+ function D(e) {
823
+ return e instanceof E || typeof e == "object" && !!e && "sense" in e && "lhs" in e && "rhs" in e;
824
824
  }
825
825
  //#endregion
826
826
  //#region src/modeler/boolean-expr.ts
827
- var ne = 0;
828
- function D(e, t) {
829
- if (e instanceof O || e instanceof T) return e;
827
+ var re = 0;
828
+ function O(e, t) {
829
+ if (e instanceof k || e instanceof E) return e;
830
830
  throw typeof e == "object" && e && ("terms" in e || "quadTerms" in e) ? Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical operator "${t}". Use a comparison constraint such as expr\`\${x} <= 10\` or a BoolVar/BoolExpr.`) : typeof e == "object" && e && "id" in e && "name" in e && "lb" in e && "ub" in e && !("sense" in e) ? Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint, but received numeric variable "${e.name}". Use m.bool() for propositional variables, add a comparison such as expr\`\${x} == 1\`, or use m.indicator(binVar, constraint) for 0-1 Big-M indicator constraints.`) : Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint.`);
831
831
  }
832
- var O = class {
832
+ var k = class {
833
833
  and(e) {
834
- return new k("and", [this, D(e, "and")]);
834
+ return new A("and", [this, O(e, "and")]);
835
835
  }
836
836
  or(e) {
837
- return new k("or", [this, D(e, "or")]);
837
+ return new A("or", [this, O(e, "or")]);
838
838
  }
839
839
  implies(e) {
840
- return new k("implies", [this, D(e, "implies")]);
840
+ return new A("implies", [this, O(e, "implies")]);
841
841
  }
842
842
  xor(e) {
843
- return new k("xor", [this, D(e, "xor")]);
843
+ return new A("xor", [this, O(e, "xor")]);
844
844
  }
845
845
  not() {
846
- return new k("not", [this]);
846
+ return new A("not", [this]);
847
847
  }
848
- }, re = class extends O {
848
+ }, ie = class extends k {
849
849
  id;
850
850
  type = "Boolean";
851
851
  name;
852
852
  value = null;
853
853
  constructor(e) {
854
- super(), this.id = ++ne, this.name = e || `p_${this.id}`;
854
+ super(), this.id = ++re, this.name = e || `p_${this.id}`;
855
855
  }
856
856
  toString() {
857
857
  return this.name;
858
858
  }
859
- }, k = class extends O {
859
+ }, A = class extends k {
860
860
  op;
861
861
  children;
862
862
  constructor(e, t) {
863
- super(), this.op = e, this.children = t.map((t) => D(t, e));
863
+ super(), this.op = e, this.children = t.map((t) => O(t, e));
864
864
  }
865
865
  toString() {
866
866
  return this.op === "not" ? `not(${this.children[0].toString()})` : `(${this.children.map((e) => e.toString()).join(` ${this.op} `)})`;
867
867
  }
868
- }, ie = class extends O {
868
+ }, ae = class extends k {
869
869
  spec;
870
870
  discreteVars;
871
871
  constructor(e, t) {
@@ -882,7 +882,7 @@ var O = class {
882
882
  };
883
883
  //#endregion
884
884
  //#region src/modeler/types.ts
885
- function ae(e) {
885
+ function oe(e) {
886
886
  if (e === void 0) return "Minimize";
887
887
  if (typeof e == "string") {
888
888
  let t = e.toLowerCase();
@@ -893,16 +893,16 @@ function ae(e) {
893
893
  }
894
894
  //#endregion
895
895
  //#region src/modeler/solvers/registry.ts
896
- var A = Symbol.for("washi.solverRegistry"), j = globalThis;
897
- j[A] || (j[A] = /* @__PURE__ */ new Map());
898
- var oe = j[A];
899
- function se(e, t) {
900
- oe.set(e.toLowerCase(), t);
896
+ var j = Symbol.for("washi.solverRegistry"), M = globalThis;
897
+ M[j] || (M[j] = /* @__PURE__ */ new Map());
898
+ var se = M[j];
899
+ function ce(e, t) {
900
+ se.set(e.toLowerCase(), t);
901
901
  }
902
902
  //#endregion
903
903
  //#region \0washi-browser-pumpkin-worker-factory
904
- function M() {
905
- let e = u("pumpkin-worker.js"), t = typeof window.origin == "string" ? window.origin : window.location?.origin;
904
+ function N() {
905
+ let e = f("pumpkin-worker.js"), t = typeof window.origin == "string" ? window.origin : window.location?.origin;
906
906
  if (new URL(e).origin === t) return new Worker(e, { type: "module" });
907
907
  let n = URL.createObjectURL(new Blob(["import " + JSON.stringify(e) + ";"], { type: "text/javascript" }));
908
908
  try {
@@ -914,11 +914,11 @@ function M() {
914
914
  }
915
915
  //#endregion
916
916
  //#region src/modeler/solvers/pumpkin/worker-client.ts
917
- function N(e) {
917
+ function P(e) {
918
918
  if (e === "") throw Error("Invalid pumpkin.wasm URL: expected non-empty string or null (received empty string \"\").");
919
919
  if (e != null && typeof e != "string") throw Error(`Invalid pumpkin.wasm URL: expected string or null, got ${typeof e}.`);
920
920
  }
921
- function P(e) {
921
+ function F(e) {
922
922
  return {
923
923
  status: "Unknown",
924
924
  values: [],
@@ -926,7 +926,7 @@ function P(e) {
926
926
  runTime: Math.max((performance.now() - e) / 1e3, 1e-6)
927
927
  };
928
928
  }
929
- function F(e, t) {
929
+ function I(e, t) {
930
930
  let n = Math.max((performance.now() - e) / 1e3, 1e-6);
931
931
  return t ? {
932
932
  status: "Feasible",
@@ -944,29 +944,28 @@ function F(e, t) {
944
944
  runTime: n
945
945
  };
946
946
  }
947
- function I(e = {}) {
948
- let t = e.workerFactory ?? M, n = null, r = 1, i = null, a = [], o = /* @__PURE__ */ new Set(), s = !1;
949
- N(e.wasmUrl);
950
- let c = (e) => (N(e), typeof e == "string" ? e : "__bundled__"), u = (e) => {
951
- let t = c(e);
952
- for (o.delete(t), o.add(t); o.size > 4;) {
953
- let e = o.keys().next().value;
947
+ function L(e = {}) {
948
+ let t = e.workerFactory ?? N, n = null, r = 1, i = null, o = [], s = /* @__PURE__ */ new Set(), l = !1, u = !1;
949
+ P(e.wasmUrl);
950
+ let f = (e) => {
951
+ for (s.delete(e), s.add(e); s.size > 4;) {
952
+ let e = s.keys().next().value;
954
953
  if (e === void 0) break;
955
- o.delete(e);
954
+ s.delete(e);
956
955
  }
957
- }, d = () => {
958
- o.clear(), n &&= (n.onmessage = null, n.onerror = null, n.onmessageerror = null, n.terminate(), null);
959
- }, f = (e) => {
956
+ }, p = () => {
957
+ s.clear(), l = !1, n &&= (n.onmessage = null, n.onerror = null, n.onmessageerror = null, n.terminate(), null);
958
+ }, m = (e) => {
960
959
  i === e && (i = null), e.cleanupAbort?.();
961
- }, p = (e, t) => {
962
- f(e), e.resolve(t), y();
963
- }, m = (e, t) => {
964
- f(e), e.resolve(t), y();
965
960
  }, h = (e, t) => {
966
- f(e), e.reject(t), y();
967
- }, g = (e) => {
968
- e.type === "check" ? p(e, P(e.startTimeMs)) : m(e, F(e.startTimeMs, e.lastIncumbent));
969
- }, _ = (e, t, n) => {
961
+ m(e), e.resolve(t), x();
962
+ }, g = (e, t) => {
963
+ m(e), e.resolve(t), x();
964
+ }, _ = (e, t) => {
965
+ m(e), e.reject(t), x();
966
+ }, v = (e) => {
967
+ e.type === "check" ? h(e, F(e.startTimeMs)) : g(e, I(e.startTimeMs, e.lastIncumbent));
968
+ }, y = (e, t, n) => {
970
969
  if (typeof e != "string") throw Error("Pumpkin worker response is missing canonical responseJson string.");
971
970
  let r = JSON.parse(e);
972
971
  if (!r) throw Error("Pumpkin worker returned an empty success payload.");
@@ -975,7 +974,7 @@ function I(e = {}) {
975
974
  ...r,
976
975
  runTime: typeof t == "number" ? t : Math.max((performance.now() - n) / 1e3, 1e-6)
977
976
  };
978
- }, v = () => {
977
+ }, b = () => {
979
978
  if (n) return n;
980
979
  let e = t();
981
980
  return e.onmessage = (t) => {
@@ -996,96 +995,115 @@ function I(e = {}) {
996
995
  });
997
996
  }
998
997
  if (n !== e || i !== a) return;
999
- a.signal?.aborted && (d(), g(a));
998
+ a.signal?.aborted && (p(), v(a));
1000
999
  } catch (t) {
1001
- n === e && i === a && (d(), h(a, t));
1000
+ n === e && i === a && (p(), _(a, t));
1002
1001
  }
1003
1002
  return;
1004
1003
  }
1005
1004
  if (r.type === "CHECK_SUCCESS") {
1006
1005
  if (a.type !== "check") {
1007
- d(), h(a, /* @__PURE__ */ Error("Received \"CHECK_SUCCESS\" for a solve task."));
1006
+ p(), _(a, /* @__PURE__ */ Error("Received \"CHECK_SUCCESS\" for a solve task."));
1008
1007
  return;
1009
1008
  }
1010
1009
  try {
1011
- let e = _(r.responseJson, r.runTime, a.startTimeMs);
1012
- u(a.wasmUrl), p(a, e);
1010
+ let e = y(r.responseJson, r.runTime, a.startTimeMs);
1011
+ f(a.cacheKey), h(a, e);
1013
1012
  } catch (t) {
1014
- n === e && i === a && (d(), h(a, t));
1013
+ n === e && i === a && (p(), _(a, t));
1015
1014
  }
1016
1015
  return;
1017
1016
  }
1018
1017
  if (r.type === "SOLVE_SUCCESS") {
1019
1018
  if (a.type !== "solve") {
1020
- d(), h(a, /* @__PURE__ */ Error("Received \"SOLVE_SUCCESS\" for a check task."));
1019
+ p(), _(a, /* @__PURE__ */ Error("Received \"SOLVE_SUCCESS\" for a check task."));
1021
1020
  return;
1022
1021
  }
1023
1022
  try {
1024
- let e = _(r.responseJson, r.runTime, a.startTimeMs);
1025
- u(a.wasmUrl), m(a, e);
1023
+ let e = y(r.responseJson, r.runTime, a.startTimeMs);
1024
+ f(a.cacheKey), g(a, e);
1026
1025
  } catch (t) {
1027
- n === e && i === a && (d(), h(a, t));
1026
+ n === e && i === a && (p(), _(a, t));
1028
1027
  }
1029
1028
  return;
1030
1029
  }
1031
1030
  if (r.type === "SOLVER_ERROR") {
1032
1031
  let e = typeof r.error == "string" ? r.error : "Pumpkin worker execution failed.";
1033
- h(a, Error(e));
1032
+ _(a, Error(e));
1034
1033
  }
1035
1034
  }
1036
1035
  }, e.onerror = (t) => {
1037
1036
  if (n !== e) return;
1038
1037
  let r = i;
1039
- if (d(), r) {
1038
+ if (p(), r) {
1040
1039
  let e = t?.message || "Pumpkin Web Worker encountered an unexpected error.";
1041
- h(r, Error(e));
1040
+ _(r, Error(e));
1042
1041
  }
1043
1042
  }, e.onmessageerror = () => {
1044
1043
  if (n !== e) return;
1045
1044
  let t = i;
1046
- d(), t && h(t, /* @__PURE__ */ Error("Failed to deserialize message from Pumpkin Web Worker."));
1045
+ p(), t && _(t, /* @__PURE__ */ Error("Failed to deserialize message from Pumpkin Web Worker."));
1047
1046
  }, n = e, e;
1048
- }, y = () => {
1049
- if (!(i || s)) for (; a.length > 0;) {
1050
- let e = a.shift();
1047
+ }, x = () => {
1048
+ if (!(i || u)) for (; o.length > 0;) {
1049
+ let e = o.shift();
1051
1050
  if (e.signal?.aborted) {
1052
- e.type === "check" ? e.resolve(P(e.startTimeMs)) : e.resolve(F(e.startTimeMs, e.lastIncumbent));
1051
+ e.type === "check" ? e.resolve(F(e.startTimeMs)) : e.resolve(I(e.startTimeMs, e.lastIncumbent));
1053
1052
  continue;
1054
1053
  }
1055
1054
  if (i = e, e.startTimeMs = performance.now(), e.signal) {
1056
1055
  let t = () => {
1057
- i === e && (d(), g(e));
1056
+ i === e && (p(), v(e));
1058
1057
  };
1059
1058
  e.signal.addEventListener("abort", t, { once: !0 }), e.cleanupAbort = () => e.signal?.removeEventListener("abort", t);
1060
1059
  }
1061
1060
  try {
1062
- v().postMessage({
1061
+ let t = b(), n = {
1063
1062
  id: e.id,
1064
1063
  type: e.type,
1065
- requestJson: e.requestJson,
1066
- wasmUrl: e.wasmUrl
1067
- });
1064
+ requestJson: e.requestJson
1065
+ };
1066
+ e.wasmUrl !== void 0 && (n.wasmUrl = e.wasmUrl);
1067
+ let r = !1;
1068
+ e.embeddedWasmBinary !== null && !l && (n.embeddedWasmBinary = e.embeddedWasmBinary, r = !0), t.postMessage(n), r && (l = !0);
1068
1069
  } catch (t) {
1069
- i === e && (d(), h(e, t));
1070
+ i === e && (p(), _(e, t));
1070
1071
  }
1071
1072
  return;
1072
1073
  }
1073
- }, b = (t) => {
1074
- let n = t === void 0 ? e.wasmUrl === void 0 ? l() : e.wasmUrl : t;
1075
- return N(n), n ?? null;
1076
- }, x = (e) => new Promise((t, n) => {
1077
- a.push(e(t, n)), y();
1074
+ }, S = (t, n) => {
1075
+ let r = n ? c("pumpkin") : a("pumpkin"), i = r?.kind === "embedded" ? r.bytes : null, o = r ? r.kind === "embedded" ? "__embedded__" : "__bundled__" : null;
1076
+ if (t !== void 0) return P(t), {
1077
+ wasmUrl: t,
1078
+ embeddedWasmBinary: i,
1079
+ cacheKey: t === null ? o : `url:${t}`
1080
+ };
1081
+ if (e.wasmUrl !== void 0) return P(e.wasmUrl), {
1082
+ wasmUrl: e.wasmUrl,
1083
+ embeddedWasmBinary: i,
1084
+ cacheKey: e.wasmUrl === null ? o : `url:${e.wasmUrl}`
1085
+ };
1086
+ let s = d();
1087
+ return P(s), {
1088
+ wasmUrl: s,
1089
+ embeddedWasmBinary: i,
1090
+ cacheKey: s === null ? o : `url:${s}`
1091
+ };
1092
+ }, C = (e) => new Promise((t, n) => {
1093
+ o.push(e(t, n)), x();
1078
1094
  });
1079
1095
  return {
1080
1096
  check(e, t) {
1081
- if (s) return Promise.reject(/* @__PURE__ */ Error("[WaSHI] Pumpkin worker client has been disposed."));
1082
- if (t?.signal?.aborted) return Promise.resolve(P(performance.now()));
1083
- let n = b(e.wasmUrl);
1084
- return x((i, a) => ({
1097
+ if (u) return Promise.reject(/* @__PURE__ */ Error("[WaSHI] Pumpkin worker client has been disposed."));
1098
+ if (t?.signal?.aborted) return Promise.resolve(F(performance.now()));
1099
+ let n = S(e.wasmUrl, !0);
1100
+ return C((i, a) => ({
1085
1101
  id: r++,
1086
1102
  type: "check",
1087
1103
  requestJson: e.requestJson,
1088
- wasmUrl: n,
1104
+ wasmUrl: n.wasmUrl,
1105
+ embeddedWasmBinary: n.embeddedWasmBinary,
1106
+ cacheKey: n.cacheKey,
1089
1107
  signal: t?.signal,
1090
1108
  startTimeMs: performance.now(),
1091
1109
  lastIncumbent: null,
@@ -1094,14 +1112,16 @@ function I(e = {}) {
1094
1112
  }));
1095
1113
  },
1096
1114
  solve(e, t) {
1097
- if (s) return Promise.reject(/* @__PURE__ */ Error("[WaSHI] Pumpkin worker client has been disposed."));
1098
- if (t?.signal?.aborted) return Promise.resolve(F(performance.now(), null));
1099
- let n = b(e.wasmUrl);
1100
- return x((i, a) => ({
1115
+ if (u) return Promise.reject(/* @__PURE__ */ Error("[WaSHI] Pumpkin worker client has been disposed."));
1116
+ if (t?.signal?.aborted) return Promise.resolve(I(performance.now(), null));
1117
+ let n = S(e.wasmUrl, !0);
1118
+ return C((i, a) => ({
1101
1119
  id: r++,
1102
1120
  type: "solve",
1103
1121
  requestJson: e.requestJson,
1104
- wasmUrl: n,
1122
+ wasmUrl: n.wasmUrl,
1123
+ embeddedWasmBinary: n.embeddedWasmBinary,
1124
+ cacheKey: n.cacheKey,
1105
1125
  signal: t?.signal,
1106
1126
  onProgress: t?.onProgress,
1107
1127
  startTimeMs: performance.now(),
@@ -1111,11 +1131,13 @@ function I(e = {}) {
1111
1131
  }));
1112
1132
  },
1113
1133
  isWarmed(e) {
1114
- return !s && n !== null && o.has(c(b(e)));
1134
+ if (u || n === null) return !1;
1135
+ let { cacheKey: t } = S(e, !1);
1136
+ return t !== null && s.has(t);
1115
1137
  },
1116
1138
  dispose() {
1117
- for (s = !0, d(); a.length > 0;) {
1118
- let e = a.shift();
1139
+ for (u = !0, p(); o.length > 0;) {
1140
+ let e = o.shift();
1119
1141
  e.cleanupAbort?.(), e.reject(/* @__PURE__ */ Error("[WaSHI] Pumpkin worker client disposed."));
1120
1142
  }
1121
1143
  if (i) {
@@ -1125,24 +1147,21 @@ function I(e = {}) {
1125
1147
  }
1126
1148
  };
1127
1149
  }
1128
- var L = null;
1129
- function R() {
1130
- return L || (L = I(), e(() => {
1131
- L &&= (L.dispose(), null);
1132
- })), L;
1150
+ var R = null;
1151
+ function z() {
1152
+ return R || (R = L(), e(() => {
1153
+ R &&= (R.dispose(), null);
1154
+ })), R;
1133
1155
  }
1134
- function ce() {
1135
- L &&= (L.dispose(), null);
1156
+ function le() {
1157
+ R &&= (R.dispose(), null);
1136
1158
  }
1137
- function z(e = {}) {
1138
- return N(e.wasmUrl), e.useWorker ?? i() ? L !== null && L.isWarmed(e.wasmUrl) : a(e.wasmUrl);
1159
+ function B(e = {}) {
1160
+ return P(e.wasmUrl), e.useWorker ?? i() ? R !== null && R.isWarmed(e.wasmUrl) : o(e.wasmUrl);
1139
1161
  }
1140
- async function le(e = {}) {
1162
+ async function ue(e = {}) {
1141
1163
  let { signal: t } = e;
1142
- if (N(e.wasmUrl), t?.aborted) return { cached: !1 };
1143
- if (z(e)) return { cached: !0 };
1144
- let n = !!(e.useWorker ?? i()), a = e.wasmUrl === void 0 ? l() : e.wasmUrl;
1145
- return n ? (await R().check({
1164
+ return P(e.wasmUrl), t?.aborted ? { cached: !1 } : B(e) ? { cached: !0 } : e.useWorker ?? i() ? (await z().check({
1146
1165
  requestJson: JSON.stringify({
1147
1166
  vars: [],
1148
1167
  boolVars: [],
@@ -1151,25 +1170,25 @@ async function le(e = {}) {
1151
1170
  auxPropagators: [],
1152
1171
  timeLimitMs: null
1153
1172
  }),
1154
- wasmUrl: a
1155
- }, { signal: t }), { cached: !1 }) : t ? (await new Promise((e, n) => {
1156
- let i = !1, o = () => {
1157
- i || (i = !0, e());
1173
+ wasmUrl: e.wasmUrl
1174
+ }, { signal: t }), { cached: !1 }) : t ? (await new Promise((n, i) => {
1175
+ let a = !1, o = () => {
1176
+ a || (a = !0, n());
1158
1177
  };
1159
- t.addEventListener("abort", o, { once: !0 }), r(a).then(() => {
1160
- t.removeEventListener("abort", o), i || (i = !0, e());
1178
+ t.addEventListener("abort", o, { once: !0 }), r(e.wasmUrl).then(() => {
1179
+ t.removeEventListener("abort", o), a || (a = !0, n());
1161
1180
  }, (e) => {
1162
- t.removeEventListener("abort", o), i || (i = !0, n(e));
1181
+ t.removeEventListener("abort", o), a || (a = !0, i(e));
1163
1182
  });
1164
- }), { cached: !1 }) : (await r(a), { cached: !1 });
1183
+ }), { cached: !1 }) : (await r(e.wasmUrl), { cached: !1 });
1165
1184
  }
1166
1185
  //#endregion
1167
1186
  //#region src/modeler/solvers/pumpkin/solver.ts
1168
- var B = 1073741823, V = 2147483646, H = 1e-6;
1169
- function U(e) {
1187
+ var V = 1073741823, H = 2147483646, U = 1e-6;
1188
+ function W(e) {
1170
1189
  return Object.is(e, -0) || e === 0 ? 0 : e;
1171
1190
  }
1172
- function W(e, t, n) {
1191
+ function G(e, t, n) {
1173
1192
  Object.defineProperty(e, t, {
1174
1193
  value: n,
1175
1194
  writable: !0,
@@ -1177,15 +1196,15 @@ function W(e, t, n) {
1177
1196
  configurable: !0
1178
1197
  });
1179
1198
  }
1180
- function G(e, t) {
1199
+ function K(e, t) {
1181
1200
  if (typeof e != "number" || Number.isNaN(e)) throw Error(`PumpkinSolver encountered non-finite numeric value in ${t}.`);
1182
1201
  if (!Number.isFinite(e)) throw Error(`PumpkinSolver only supports bounded finite integers (${t}: got ${e}).`);
1183
1202
  if (!Number.isInteger(e)) throw Error(`PumpkinSolver only supports integer values (${t}: got ${e}).`);
1184
- let n = U(e);
1185
- if (n < -1073741823 || n > B) throw Error(`Value out of Pumpkin safe 32-bit integer range [-${B}, ${B}] (${t}: got ${n}).`);
1203
+ let n = W(e);
1204
+ if (n < -1073741823 || n > V) throw Error(`Value out of Pumpkin safe 32-bit integer range [-${V}, ${V}] (${t}: got ${n}).`);
1186
1205
  return n;
1187
1206
  }
1188
- function K(e) {
1207
+ function q(e) {
1189
1208
  if (e === void 0 || e === Infinity) return null;
1190
1209
  if (typeof e != "number" || Number.isNaN(e) || e < 0 || !Number.isFinite(e)) throw Error(`Invalid timeLimit (${String(e)}): expected a finite non-negative number of seconds.`);
1191
1210
  if (e === 0) return 0;
@@ -1193,18 +1212,18 @@ function K(e) {
1193
1212
  if (t > 2 ** 53 - 1) throw Error(`timeLimit (${e}s) exceeds safe millisecond range.`);
1194
1213
  return Math.max(1, t);
1195
1214
  }
1196
- function q(e) {
1197
- return e instanceof f || typeof e == "object" && !!e && "quadTerms" in e;
1215
+ function J(e) {
1216
+ return e instanceof m || typeof e == "object" && !!e && "quadTerms" in e;
1198
1217
  }
1199
- function J(e, t, n) {
1218
+ function Y(e, t, n) {
1200
1219
  if (e.initialValue === void 0) return;
1201
1220
  if (typeof e.initialValue != "number" || !Number.isFinite(e.initialValue)) throw Error(`Variable "${e.name}" has invalid initialValue: ${String(e.initialValue)} (initialValue must be a finite number).`);
1202
- if (e.initialValue < t - H || e.initialValue > n + H) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${H}).`);
1203
- let r = U(Math.round(e.initialValue));
1204
- if (Math.abs(e.initialValue - r) > H || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${H} of an integer in [${t}, ${n}]).`);
1205
- return G(r, `initialValue of variable "${e.name}"`);
1221
+ if (e.initialValue < t - U || e.initialValue > n + U) throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${U}).`);
1222
+ let r = W(Math.round(e.initialValue));
1223
+ if (Math.abs(e.initialValue - r) > U || r < t || r > n) throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${U} of an integer in [${t}, ${n}]).`);
1224
+ return K(r, `initialValue of variable "${e.name}"`);
1206
1225
  }
1207
- function ue(e) {
1226
+ function de(e) {
1208
1227
  let t = [], n = /* @__PURE__ */ new Map(), r = !1;
1209
1228
  for (let i = 0; i < e.length; i++) {
1210
1229
  let a = e[i], o = String(a.type).toLowerCase();
@@ -1213,7 +1232,7 @@ function ue(e) {
1213
1232
  if (typeof a.lb != "number" || Number.isNaN(a.lb) || typeof a.ub != "number" || Number.isNaN(a.ub)) throw Error(`PumpkinSolver encountered non-finite numeric value in bounds of variable "${a.name}".`);
1214
1233
  if (a.lb === Infinity || a.ub === -Infinity || a.lb > a.ub) throw Error(`Variable "${a.name}" has invalid bounds lb (${a.lb}) > ub (${a.ub}).`);
1215
1234
  if (Number.isFinite(a.lb) && !Number.isInteger(a.lb) || Number.isFinite(a.ub) && !Number.isInteger(a.ub)) throw Error(`PumpkinSolver only supports integer values (bounds of binary variable "${a.name}").`);
1216
- let e = a.lb === -Infinity ? 0 : Math.max(0, U(a.lb)), n = a.ub === Infinity ? 1 : Math.min(1, U(a.ub)), i = J(a, e, n);
1235
+ let e = a.lb === -Infinity ? 0 : Math.max(0, W(a.lb)), n = a.ub === Infinity ? 1 : Math.min(1, W(a.ub)), i = Y(a, e, n);
1217
1236
  e > n ? (r = !0, t.push({
1218
1237
  name: a.name,
1219
1238
  lb: 0,
@@ -1230,9 +1249,9 @@ function ue(e) {
1230
1249
  });
1231
1250
  continue;
1232
1251
  }
1233
- let s = G(a.lb, `lower bound of variable "${a.name}"`), c = G(a.ub, `upper bound of variable "${a.name}"`);
1252
+ let s = K(a.lb, `lower bound of variable "${a.name}"`), c = K(a.ub, `upper bound of variable "${a.name}"`);
1234
1253
  if (s > c) throw Error(`Variable "${a.name}" has invalid bounds lb (${s}) > ub (${c}).`);
1235
- let l = J(a, s, c);
1254
+ let l = Y(a, s, c);
1236
1255
  t.push(l === void 0 ? {
1237
1256
  name: a.name,
1238
1257
  lb: s,
@@ -1250,10 +1269,10 @@ function ue(e) {
1250
1269
  hasEmptyDomain: r
1251
1270
  };
1252
1271
  }
1253
- function de(e, t, n) {
1272
+ function fe(e, t, n) {
1254
1273
  let r = 0;
1255
1274
  function i(e, n, i) {
1256
- let a = G(e, `internal ${i} lb`), o = G(n, `internal ${i} ub`), s = t.length;
1275
+ let a = K(e, `internal ${i} lb`), o = K(n, `internal ${i} ub`), s = t.length;
1257
1276
  return t.push({
1258
1277
  name: `__pumpkin_${i}_${++r}`,
1259
1278
  lb: a,
@@ -1268,23 +1287,23 @@ function de(e, t, n) {
1268
1287
  if (n === void 0) throw Error(`Variable "${t.name}" in ${i} is not registered in the model.`);
1269
1288
  if (typeof r != "number" || !Number.isFinite(r)) throw Error(`Invalid non-finite coefficient for "${t.name}" in ${i}.`);
1270
1289
  if (!Number.isInteger(r)) throw Error(`PumpkinSolver only supports integer coefficients (variable "${t.name}" in ${i} has ${r}).`);
1271
- let o = (a.get(n) ?? 0) + U(r);
1290
+ let o = (a.get(n) ?? 0) + W(r);
1272
1291
  if (!Number.isSafeInteger(o)) throw Error(`Coefficient sum overflow for "${t.name}" in ${i}.`);
1273
1292
  a.set(n, o);
1274
1293
  }
1275
1294
  for (let e of r) {
1276
- let t = (a.get(e.varIndex) ?? 0) + U(e.coeff);
1295
+ let t = (a.get(e.varIndex) ?? 0) + W(e.coeff);
1277
1296
  if (!Number.isSafeInteger(t)) throw Error(`Coefficient sum overflow in ${i}.`);
1278
1297
  a.set(e.varIndex, t);
1279
1298
  }
1280
1299
  let o = [], s = 0;
1281
1300
  for (let [e, n] of a.entries()) {
1282
- let r = U(n);
1301
+ let r = W(n);
1283
1302
  if (r === 0) continue;
1284
1303
  let a = t[e];
1285
- G(r, `coefficient of "${a.name}" in ${i}`);
1304
+ K(r, `coefficient of "${a.name}" in ${i}`);
1286
1305
  let c = r * a.lb, l = r * a.ub;
1287
- if (G(c, `scaled lower bound of "${a.name}" in ${i}`), G(l, `scaled upper bound of "${a.name}" in ${i}`), s += Math.max(Math.abs(c), Math.abs(l)), s > V) throw Error(`Linear expression magnitude in ${i} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1306
+ if (K(c, `scaled lower bound of "${a.name}" in ${i}`), K(l, `scaled upper bound of "${a.name}" in ${i}`), s += Math.max(Math.abs(c), Math.abs(l)), s > H) throw Error(`Linear expression magnitude in ${i} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1288
1307
  o.push({
1289
1308
  varIndex: e,
1290
1309
  coeff: r
@@ -1302,8 +1321,8 @@ function de(e, t, n) {
1302
1321
  i += Math.min(r, o), a += Math.max(r, o);
1303
1322
  }
1304
1323
  return {
1305
- lb: G(U(i), `lower bound of ${r}`),
1306
- ub: G(U(a), `upper bound of ${r}`)
1324
+ lb: K(W(i), `lower bound of ${r}`),
1325
+ ub: K(W(a), `upper bound of ${r}`)
1307
1326
  };
1308
1327
  }
1309
1328
  function s(e, r, a) {
@@ -1350,16 +1369,16 @@ function de(e, t, n) {
1350
1369
  function c(e, t, n, r = !1) {
1351
1370
  if (typeof e.constant != "number" || !Number.isFinite(e.constant)) throw Error(`Invalid non-finite constant in ${n}.`);
1352
1371
  let i;
1353
- if (r) i = U(e.constant);
1372
+ if (r) i = W(e.constant);
1354
1373
  else {
1355
1374
  if (!Number.isInteger(e.constant)) throw Error(`PumpkinSolver only supports integer constants (${n}: got ${e.constant}).`);
1356
- i = G(U(e.constant), `constant of ${n}`);
1375
+ i = K(W(e.constant), `constant of ${n}`);
1357
1376
  }
1358
1377
  let o = [];
1359
1378
  if (Array.isArray(e.nonlinearTerms)) for (let r of e.nonlinearTerms) {
1360
1379
  if (r.coeff === 0) continue;
1361
1380
  if (typeof r.coeff != "number" || !Number.isFinite(r.coeff) || !Number.isInteger(r.coeff)) throw Error(`PumpkinSolver only supports safe integer coefficients in ${n} (got ${r.coeff}).`);
1362
- let e = G(U(r.coeff), `nonlinear coefficient in ${n}`), i = s(r.atom, t, n);
1381
+ let e = K(W(r.coeff), `nonlinear coefficient in ${n}`), i = s(r.atom, t, n);
1363
1382
  o.push({
1364
1383
  varIndex: i,
1365
1384
  coeff: e
@@ -1380,11 +1399,11 @@ function de(e, t, n) {
1380
1399
  let e = [...s, {
1381
1400
  varIndex: f,
1382
1401
  coeff: -1
1383
- }], i = G(U(-l), `linearEq RHS in ${a}`), o = e.reduce((e, n) => {
1402
+ }], i = K(W(-l), `linearEq RHS in ${a}`), o = e.reduce((e, n) => {
1384
1403
  let r = t[n.varIndex];
1385
1404
  return e + Math.max(Math.abs(n.coeff * r.lb), Math.abs(n.coeff * r.ub));
1386
1405
  }, 0);
1387
- if (Math.abs(i) + o > V) throw Error(`Linear expression magnitude in ${a} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1406
+ if (Math.abs(i) + o > H) throw Error(`Linear expression magnitude in ${a} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1388
1407
  n.push({
1389
1408
  kind: "linearEq",
1390
1409
  terms: e,
@@ -1397,8 +1416,8 @@ function de(e, t, n) {
1397
1416
  function u(e, t, n, r) {
1398
1417
  if (typeof t != "number" || !Number.isFinite(t)) throw Error(`Invalid non-finite RHS in ${r}.`);
1399
1418
  if (!Number.isInteger(t)) throw Error(`PumpkinSolver only supports integer RHS (${r}: got ${t}).`);
1400
- let { terms: i, constant: a, sumMaxAbs: o } = c(e, n, r), s = G(U(t - a), `RHS of ${r}`);
1401
- if (Math.abs(s) + o > V) throw Error(`Linear expression magnitude in ${r} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1419
+ let { terms: i, constant: a, sumMaxAbs: o } = c(e, n, r), s = K(W(t - a), `RHS of ${r}`);
1420
+ if (Math.abs(s) + o > H) throw Error(`Linear expression magnitude in ${r} exceeds Pumpkin safe 32-bit propagator overflow limit.`);
1402
1421
  return {
1403
1422
  terms: i,
1404
1423
  rhs: s
@@ -1410,8 +1429,8 @@ function de(e, t, n) {
1410
1429
  serializeConstraintSide: u
1411
1430
  };
1412
1431
  }
1413
- function Y(e, t, n, r, i) {
1414
- if (r.has(e) || e instanceof re || typeof e == "object" && e && "name" in e && "id" in e && !("op" in e) && !("lhs" in e) && !("spec" in e)) {
1432
+ function X(e, t, n, r, i) {
1433
+ if (r.has(e) || e instanceof ie || typeof e == "object" && e && "name" in e && "id" in e && !("op" in e) && !("lhs" in e) && !("spec" in e)) {
1415
1434
  let t = e, n = r.get(t);
1416
1435
  if (n === void 0) throw Error(`Boolean variable "${t.name}" in ${i} is not registered in the model.`);
1417
1436
  return {
@@ -1419,9 +1438,9 @@ function Y(e, t, n, r, i) {
1419
1438
  index: n
1420
1439
  };
1421
1440
  }
1422
- if (e instanceof T || "lhs" in e && "sense" in e && "rhs" in e) {
1441
+ if (e instanceof E || "lhs" in e && "sense" in e && "rhs" in e) {
1423
1442
  let r = e;
1424
- if (q(r.lhs)) throw Error(`PumpkinSolver does not support quadratic constraints inside ${i}.`);
1443
+ if (J(r.lhs)) throw Error(`PumpkinSolver does not support quadratic constraints inside ${i}.`);
1425
1444
  let { terms: a, rhs: o } = t.serializeConstraintSide(r.lhs, r.rhs, n, i);
1426
1445
  return {
1427
1446
  kind: "linear",
@@ -1430,7 +1449,7 @@ function Y(e, t, n, r, i) {
1430
1449
  rhs: o
1431
1450
  };
1432
1451
  }
1433
- if (e instanceof ie || typeof e == "object" && e && "spec" in e && typeof e.spec == "object") {
1452
+ if (e instanceof ae || typeof e == "object" && e && "spec" in e && typeof e.spec == "object") {
1434
1453
  let r = e.spec;
1435
1454
  switch (r.kind) {
1436
1455
  case "distinct": return {
@@ -1441,60 +1460,60 @@ function Y(e, t, n, r, i) {
1441
1460
  kind: "disjunctive",
1442
1461
  tasks: r.tasks.map((e, r) => ({
1443
1462
  startVar: t.materializeExprToVarIndex(e.start, n, `${i} disjoint()[${r}]`),
1444
- duration: G(e.duration, `duration of ${i} disjoint()[${r}]`)
1463
+ duration: K(e.duration, `duration of ${i} disjoint()[${r}]`)
1445
1464
  }))
1446
1465
  };
1447
1466
  case "cumulative": return {
1448
1467
  kind: "cumulative",
1449
1468
  tasks: r.tasks.map((e, r) => ({
1450
1469
  startVar: t.materializeExprToVarIndex(e.start, n, `${i} cumulative()[${r}]`),
1451
- duration: G(e.duration, `duration of ${i} cumulative()[${r}]`),
1452
- demand: G(e.demand, `demand of ${i} cumulative()[${r}]`)
1470
+ duration: K(e.duration, `duration of ${i} cumulative()[${r}]`),
1471
+ demand: K(e.demand, `demand of ${i} cumulative()[${r}]`)
1453
1472
  })),
1454
- capacity: G(r.capacity, `capacity of ${i} cumulative()`)
1473
+ capacity: K(r.capacity, `capacity of ${i} cumulative()`)
1455
1474
  };
1456
1475
  case "allowed": return {
1457
1476
  kind: "table",
1458
1477
  vars: r.vars.map((e, r) => t.materializeExprToVarIndex(e, n, `${i} allowed() vars[${r}]`)),
1459
- tuples: r.tuples.map((e, t) => e.map((e, n) => G(e, `tuple[${t}][${n}] in ${i}`)))
1478
+ tuples: r.tuples.map((e, t) => e.map((e, n) => K(e, `tuple[${t}][${n}] in ${i}`)))
1460
1479
  };
1461
1480
  }
1462
1481
  }
1463
- if (e instanceof k || "op" in e && "children" in e) {
1482
+ if (e instanceof A || "op" in e && "children" in e) {
1464
1483
  let a = e;
1465
1484
  switch (a.op) {
1466
1485
  case "and": return {
1467
1486
  kind: "and",
1468
- children: a.children.map((e) => Y(e, t, n, r, i))
1487
+ children: a.children.map((e) => X(e, t, n, r, i))
1469
1488
  };
1470
1489
  case "or": return {
1471
1490
  kind: "or",
1472
- children: a.children.map((e) => Y(e, t, n, r, i))
1491
+ children: a.children.map((e) => X(e, t, n, r, i))
1473
1492
  };
1474
1493
  case "not":
1475
1494
  if (a.children.length !== 1) throw Error(`Invalid 'not' operator arity in ${i}.`);
1476
1495
  return {
1477
1496
  kind: "not",
1478
- child: Y(a.children[0], t, n, r, i)
1497
+ child: X(a.children[0], t, n, r, i)
1479
1498
  };
1480
1499
  case "implies":
1481
1500
  if (a.children.length !== 2) throw Error(`Invalid 'implies' operator arity in ${i}.`);
1482
1501
  return {
1483
1502
  kind: "implies",
1484
- left: Y(a.children[0], t, n, r, i),
1485
- right: Y(a.children[1], t, n, r, i)
1503
+ left: X(a.children[0], t, n, r, i),
1504
+ right: X(a.children[1], t, n, r, i)
1486
1505
  };
1487
1506
  case "xor": return {
1488
1507
  kind: "xor",
1489
- children: a.children.map((e) => Y(e, t, n, r, i))
1508
+ children: a.children.map((e) => X(e, t, n, r, i))
1490
1509
  };
1491
1510
  default: throw Error(`Unsupported logical operator "${String(a.op)}" in ${i}.`);
1492
1511
  }
1493
1512
  }
1494
1513
  throw Error(`Unsupported logical constraint node in ${i}.`);
1495
1514
  }
1496
- function X(e) {
1497
- let { vars: t, varIndexMap: n, hasEmptyDomain: r } = ue(e.variables), i = [], a = de(n, t, i), o = e.boolVars ?? [], s = /* @__PURE__ */ new Map(), c = [];
1515
+ function Z(e) {
1516
+ let { vars: t, varIndexMap: n, hasEmptyDomain: r } = de(e.variables), i = [], a = fe(n, t, i), o = e.boolVars ?? [], s = /* @__PURE__ */ new Map(), c = [];
1498
1517
  for (let e = 0; e < o.length; e++) s.set(o[e], e), c.push(o[e].name);
1499
1518
  let l = [];
1500
1519
  for (let t = 0; t < e.constraints.length; t++) {
@@ -1518,7 +1537,7 @@ function X(e) {
1518
1537
  });
1519
1538
  continue;
1520
1539
  }
1521
- if (q(r.lhs)) throw Error(`PumpkinSolver does not support quadratic constraints (${i}).`);
1540
+ if (J(r.lhs)) throw Error(`PumpkinSolver does not support quadratic constraints (${i}).`);
1522
1541
  let { terms: s, rhs: c } = a.serializeConstraintSide(r.lhs, r.rhs, o, i);
1523
1542
  l.push({
1524
1543
  name: r.name,
@@ -1532,7 +1551,7 @@ function X(e) {
1532
1551
  let t = d[e], n = `logical constraint "${t.name}"`, r = {
1533
1552
  kind: "logic",
1534
1553
  index: e
1535
- }, i = Y(t.expr, a, r, s, n);
1554
+ }, i = X(t.expr, a, r, s, n);
1536
1555
  u.push({
1537
1556
  name: t.name,
1538
1557
  expr: i
@@ -1549,33 +1568,33 @@ function X(e) {
1549
1568
  hasEmptyDomain: r
1550
1569
  };
1551
1570
  }
1552
- function fe(e, t, n) {
1571
+ function pe(e, t, n) {
1553
1572
  let r = {};
1554
- if (e) for (let [t, n] of e) W(r, t, U(n));
1573
+ if (e) for (let [t, n] of e) G(r, t, W(n));
1555
1574
  let i;
1556
1575
  if (t && t.length > 0) {
1557
1576
  i = {};
1558
- for (let [e, a] of t) W(i, e, a), n && W(r, e, +!!a);
1577
+ for (let [e, a] of t) G(i, e, a), n && G(r, e, +!!a);
1559
1578
  }
1560
1579
  return {
1561
1580
  values: r,
1562
1581
  ...i === void 0 ? {} : { boolValues: i }
1563
1582
  };
1564
1583
  }
1565
- function pe(e, t) {
1584
+ function me(e, t) {
1566
1585
  let n = {};
1567
- if (e) for (let [t, r] of e) W(n, t, U(r));
1568
- if (t) for (let [e, r] of t) W(n, e, r);
1586
+ if (e) for (let [t, r] of e) G(n, t, W(r));
1587
+ if (t) for (let [e, r] of t) G(n, e, r);
1569
1588
  return n;
1570
1589
  }
1571
- var me = /* @__PURE__ */ new Set([
1590
+ var he = /* @__PURE__ */ new Set([
1572
1591
  "presolve",
1573
1592
  "relativeGap",
1574
1593
  "absoluteGap",
1575
1594
  "threads",
1576
1595
  "verbose",
1577
1596
  "outputFlag"
1578
- ]), he = /* @__PURE__ */ new Set([
1597
+ ]), ge = /* @__PURE__ */ new Set([
1579
1598
  "timeLimit",
1580
1599
  "wasmUrl",
1581
1600
  "useWorker",
@@ -1583,22 +1602,22 @@ var me = /* @__PURE__ */ new Set([
1583
1602
  "onProgress",
1584
1603
  "relax"
1585
1604
  ]);
1586
- function Z(e = {}) {
1605
+ function Q(e = {}) {
1587
1606
  if (e.relax !== void 0) {
1588
1607
  if (typeof e.relax != "boolean") throw Error(`Invalid Pumpkin option "relax": expected boolean, got ${typeof e.relax}.`);
1589
1608
  if (e.relax === !0) throw Error("PumpkinSolver does not support LP relaxation (relax: true). Use a simplex/IPM solver such as HiGHS or GLPK.");
1590
1609
  }
1591
- for (let t of me) if (e[t] !== void 0) throw Error(`PumpkinSolver does not support option "${t}".`);
1592
- for (let [t, n] of Object.entries(e)) if (n !== void 0 && !he.has(t)) throw Error(`PumpkinSolver does not support option "${t}".`);
1610
+ for (let t of he) if (e[t] !== void 0) throw Error(`PumpkinSolver does not support option "${t}".`);
1611
+ for (let [t, n] of Object.entries(e)) if (n !== void 0 && !ge.has(t)) throw Error(`PumpkinSolver does not support option "${t}".`);
1593
1612
  if (e.useWorker !== void 0 && typeof e.useWorker != "boolean") throw Error(`Invalid Pumpkin option "useWorker": expected boolean, got ${typeof e.useWorker}.`);
1594
1613
  if (e.onProgress !== void 0 && typeof e.onProgress != "function") throw Error(`Invalid Pumpkin option "onProgress": expected function, got ${typeof e.onProgress}.`);
1595
1614
  }
1596
- function Q(e) {
1615
+ function $(e) {
1597
1616
  if (e.wasmUrl !== void 0 && e.wasmUrl !== null && typeof e.wasmUrl != "string") throw Error(`Invalid pumpkin.wasm URL: expected string or null, got ${typeof e.wasmUrl}.`);
1598
1617
  if (e.wasmUrl === "") throw Error("Invalid pumpkin.wasm URL: expected non-empty string or null (received empty string \"\").");
1599
- return e.wasmUrl === void 0 ? l() : e.wasmUrl;
1618
+ return e.wasmUrl;
1600
1619
  }
1601
- var $ = class e {
1620
+ var _e = class e {
1602
1621
  static capabilities = {
1603
1622
  supportsMIP: !0,
1604
1623
  supportsQP: !1,
@@ -1619,8 +1638,8 @@ var $ = class e {
1619
1638
  ...this.options,
1620
1639
  ...t
1621
1640
  };
1622
- Z(n);
1623
- let a = Q(n), o = K(n.timeLimit), s = X(e);
1641
+ Q(n);
1642
+ let a = $(n), o = q(n.timeLimit), s = Z(e);
1624
1643
  if (n.signal?.aborted) return {
1625
1644
  status: "Unknown",
1626
1645
  values: {},
@@ -1641,7 +1660,7 @@ var $ = class e {
1641
1660
  auxPropagators: s.auxPropagators,
1642
1661
  timeLimitMs: o
1643
1662
  }), l = n.useWorker ?? i(), u;
1644
- if (l) u = await R().check({
1663
+ if (l) u = await z().check({
1645
1664
  requestJson: c,
1646
1665
  wasmUrl: a
1647
1666
  }, { signal: n.signal });
@@ -1658,7 +1677,7 @@ var $ = class e {
1658
1677
  let d = u.runTime ?? 0;
1659
1678
  if (u.status === "Sat") return {
1660
1679
  status: "Sat",
1661
- values: pe(u.values, u.boolValues),
1680
+ values: me(u.values, u.boolValues),
1662
1681
  runTime: d
1663
1682
  };
1664
1683
  if (u.status === "Unsat") {
@@ -1682,13 +1701,13 @@ var $ = class e {
1682
1701
  ...this.options,
1683
1702
  ...t
1684
1703
  };
1685
- Z(n);
1686
- let a = Q(n), o = K(n.timeLimit), s = ae(e.sense), c = X(e);
1687
- if (q(e.objective)) throw Error("PumpkinSolver does not support quadratic objective expressions (QuadExpr). Use a QP solver such as HiGHS.");
1704
+ Q(n);
1705
+ let a = $(n), o = q(n.timeLimit), s = oe(e.sense), c = Z(e);
1706
+ if (J(e.objective)) throw Error("PumpkinSolver does not support quadratic objective expressions (QuadExpr). Use a QP solver such as HiGHS.");
1688
1707
  let l = e.objective;
1689
1708
  if (typeof l.constant != "number" || !Number.isFinite(l.constant)) throw Error("Invalid non-finite objective constant.");
1690
- let u = U(l.constant), { terms: d, sumMaxAbs: f } = c.lowerer.lowerLinExpr(l, { kind: "objective" }, "objective expression", !0);
1691
- if (f > B) throw Error(`Objective expression magnitude (${f}) exceeds Pumpkin safe 32-bit integer range [-${B}, ${B}].`);
1709
+ let u = W(l.constant), { terms: d, sumMaxAbs: f } = c.lowerer.lowerLinExpr(l, { kind: "objective" }, "objective expression", !0);
1710
+ if (f > V) throw Error(`Objective expression magnitude (${f}) exceeds Pumpkin safe 32-bit integer range [-${V}, ${V}].`);
1692
1711
  if (n.signal?.aborted) return {
1693
1712
  status: "Unknown",
1694
1713
  terminationStatus: "Interrupted",
@@ -1718,7 +1737,7 @@ var $ = class e {
1718
1737
  }), m = n.useWorker ?? i(), h = n.onProgress, g = 0, _ = h ? (e) => {
1719
1738
  g++, h(e);
1720
1739
  } : void 0, v;
1721
- if (m) v = await R().solve({
1740
+ if (m) v = await z().solve({
1722
1741
  requestJson: p,
1723
1742
  wasmUrl: a
1724
1743
  }, {
@@ -1751,13 +1770,13 @@ var $ = class e {
1751
1770
  let u = Math.max((performance.now() - t) / 1e3, 1e-6);
1752
1771
  if (v = JSON.parse(l), v.runTime = u, v.error) throw Error(v.error);
1753
1772
  }
1754
- let y = v.status === "Optimal" || v.status === "Feasible", b = typeof v.objectiveValue == "number" ? U(v.objectiveValue) : null, x = v.runTime ?? 0;
1773
+ let y = v.status === "Optimal" || v.status === "Feasible", b = typeof v.objectiveValue == "number" ? W(v.objectiveValue) : null, x = v.runTime ?? 0;
1755
1774
  y && g === 0 && _ && _({
1756
1775
  elapsedTime: x,
1757
1776
  elapsedSeconds: x,
1758
1777
  ...b === null ? {} : { objectiveValue: b }
1759
1778
  });
1760
- let S = y ? fe(v.values, v.boolValues, !0) : { values: {} };
1779
+ let S = y ? pe(v.values, v.boolValues, !0) : { values: {} };
1761
1780
  return {
1762
1781
  status: v.status,
1763
1782
  terminationStatus: v.terminationStatus,
@@ -1769,9 +1788,9 @@ var $ = class e {
1769
1788
  };
1770
1789
  }
1771
1790
  };
1772
- function ge(e) {
1773
- se("pumpkin", (t) => new $(t ?? e));
1791
+ function ve(e) {
1792
+ ce("pumpkin", (t) => new _e(t ?? e));
1774
1793
  }
1775
- ge();
1794
+ ve();
1776
1795
  //#endregion
1777
- export { $ as PumpkinSolver, M as createPumpkinWorker, I as createPumpkinWorkerClient, ce as disposeSharedPumpkinWorkerClient, u as getAssetUrl, n as getBundledPumpkinWasmUrl, l as getPumpkinWasmUrl, R as getSharedPumpkinWorkerClient, a as isPumpkinRuntimeCached, z as isPumpkinWarmed, s as isValidWasmHeader, r as loadPumpkinRuntime, ge as registerPumpkinSolver, e as registerPumpkinWorkerResetHook, o as resetPumpkinLoader, c as resolvePumpkinWasmUrl, t as setPumpkinWasmUrl, i as shouldUseWorker, le as warmupPumpkin };
1796
+ export { _e as PumpkinSolver, N as createPumpkinWorker, L as createPumpkinWorkerClient, le as disposeSharedPumpkinWorkerClient, f as getAssetUrl, n as getBundledPumpkinWasmUrl, d as getPumpkinWasmUrl, z as getSharedPumpkinWorkerClient, o as isPumpkinRuntimeCached, B as isPumpkinWarmed, l as isValidWasmHeader, r as loadPumpkinRuntime, ve as registerPumpkinSolver, e as registerPumpkinWorkerResetHook, s as resetPumpkinLoader, u as resolvePumpkinWasmUrl, t as setPumpkinWasmUrl, i as shouldUseWorker, ue as warmupPumpkin };