PageSourceSearch

https://www.vzome.com/modules/chunk-CQATDKLG.js

js vzome.com collected 2026-10-02 07:05:00 UTC 144,391 bytes, 4,008 lines download raw bytes

1import {
2  AbstractSymmetry,
3  AlgebraicField,
4  AlgebraicMatrix,
5  AlgebraicVector,
6  AlgebraicVectors,
7  Construction,
8  DomUtils,
9  Fields,
10  Permutation,
11  RealVector,
12  Symmetry,
13  java,
14  javaemul
15} from "./chunk-5PFIPZES.js";
16
17// src/worker/legacy/from-java/com/vzome/core/construction/Color.ts
18var Color = class _Color {
19  static BLACK_$LI$() {
20    if (_Color.BLACK == null) {
21      _Color.BLACK = new _Color(0, 0, 0);
22    }
23    return _Color.BLACK;
24  }
25  static WHITE_$LI$() {
26    if (_Color.WHITE == null) {
27      _Color.WHITE = new _Color(255, 255, 255);
28    }
29    return _Color.WHITE;
30  }
31  static GREY_TRANSPARENT_$LI$() {
32    if (_Color.GREY_TRANSPARENT == null) {
33      _Color.GREY_TRANSPARENT = new _Color(25, 25, 25, 50);
34    }
35    return _Color.GREY_TRANSPARENT;
36  }
37  constructor(r, g, b, a) {
38    if ((typeof r === "number" || r === null) && (typeof g === "number" || g === null) && (typeof b === "number" || b === null) && (typeof a === "number" || a === null)) {
39      let __args = arguments;
40      if (this.red === void 0) {
41        this.red = 0;
42      }
43      if (this.green === void 0) {
44        this.green = 0;
45      }
46      if (this.blue === void 0) {
47        this.blue = 0;
48      }
49      if (this.alpha === void 0) {
50        this.alpha = 0;
51      }
52      this.red = r >
52 255 ? 255 : r < 0 ? 0 : r;
53      this.green = g > 255 ? 255 : g < 0 ? 0 : g;
54      this.blue = b > 255 ? 255 : b < 0 ? 0 : b;
55      this.alpha = a > 255 ? 255 : a < 0 ? 0 : a;
56    } else if ((typeof r === "number" || r === null) && (typeof g === "number" || g === null) && (typeof b === "number" || b === null) && a === void 0) {
57      let __args = arguments;
58      {
59        let __args2 = arguments;
60        let a2 = 255;
61        if (this.red === void 0) {
62          this.red = 0;
63        }
64        if (this.green === void 0) {
65          this.green = 0;
66        }
67        if (this.blue === void 0) {
68          this.blue = 0;
69        }
70        if (this.alpha === void 0) {
71          this.alpha = 0;
72        }
73        this.red = r > 255 ? 255 : r < 0 ? 0 : r;
74        this.green = g > 255 ? 255 : g < 0 ? 0 : g;
75        this.blue = b > 255 ? 255 : b < 0 ? 0 : b;
76        this.alpha = a2 > 255 ? 255 : a2 < 0 ? 0 : a2;
77      }
78    } else if ((typeof r === "string" || r === null) && g === void 0 && b === void 0 && a === void 0) {
79      let __args = arguments;
80      let rgbaHex = __args[0];
81      if (this.red === void 0) {
82        this.red = 0;
83      }
84      if (this.green === void 0) {
85        this.green = 0;
86      }
87      if (this.blue === void 0) {
88        this.blue = 0;
89      }
90      if (this.alpha === void 0) {
91        this.alpha = 0;
92      }
93      const padded = "00000000" + rgbaHex;
94      rgbaHex = padded.substring(padded.length - 8);
95      const r2 = javaemul.internal.IntegerHelper.parseInt(rgbaHex.substring(0, 2), 16);
96      const g2 = javaemul.internal.IntegerHelper.parseInt(rgbaHex.substring(2, 4), 16);
97      const b2 = javaemul.internal.IntegerHelper.parseInt(rgbaHex.substring(4, 6), 16);
98      const a2 = javaemul.internal.IntegerHelper.parseInt(rgbaHex.substring(6, 8), 16);
99      this.red = r2 > 255 ? 255 : r2 < 0 ? 0 : r2;
100      this.green = g2 > 255 ? 255 : g2 < 0 ? 0 : g2;
101      this.blue = b2 > 255 ? 255 : b2 < 0 ? 0 : b2;
102      this.alpha = a2 > 255 ? 255 : a2 < 0 ? 0 : a2;
103    } else if ((typeof r === "number" || r === null) && g === void 0 && b === void 0 && a === void 0) {
104      let __args = arguments;
105      let rgb = __args[0];
106      {
107        let __args2 = arguments;
108        let r2 = rgb >> 16 & 255;
109        let g2 = rgb >> 8 & 255;
110        let b2 = rgb & 255;
111        {
112          let __args3 = arguments;
113          let a2 = 255;
114          if (this.red === void 0) {
115            this.red = 0;
116          }
117          if (this.green === void 0) {
118            this.green = 0;
119          }
120          if (this.blue === void 0) {
121            this.blue = 0;
122          }
123          if (this.alpha === void 0) {
124            this.alpha = 0;
125          }
126          this.red = r2 > 255 ? 255 : r2 < 0 ? 0 : r2;
127          this.green = g2 > 255 ? 255 : g2 < 0 ? 0 : g2;
128          this.blue = b2 > 255 ? 255 : b2 < 0 ? 0 : b2;
129          this.alpha = a2 > 255 ? 255 : a2 < 0 ? 0 : a2;
130        }
131      }
132    } else throw new Error("invalid overload");
133  }
134  getRGBColorComponents(rgb) {
135    const len = rgb.length;
136    if (len < 3 || len > 4) {
137      throw new java.lang.IllegalArgumentException("Expected rgb.length to be 3 or 4. Found " + len + ".");
138    }
139    rgb[0] = Math.fround(this.red / 255);
140    rgb[1] = Math.fround(this.green / 255);
141    rgb[2] = Math.fround(this.blue / 255);
142    if (len === 4) {
143      rgb[3] = Math.fround(this.alpha / 255);
144    }
145    return rgb;
146  }
147  /**
148   * 
149   * @return {number}
150   */
151  hashCode() {
152    return this.getRGBA();
153  }
154  /**
155   * 
156   * @param {*} other
157   * @return {boolean}
158   */
159  equals(other) {
160    if (this === other) return true;
161    if (other == null) return true;
162    if (!(other != null && other instanceof _Color)) return false;
163    const c = other;
164    return this.red === c.red && this.green === c.green && this.blue === c.blue && this.alpha === c.alpha;
165  }
166  getPastel() {
167    const r = this.red + ((255 - this.red) / 2 | 0);
168    const g = this.green + ((255 - this.green) / 2 | 0);
169    const b = this.blue + ((255 - this.blue) / 2 | 0);
170    return new _Color(r, g, b, this.alpha);
171  }
172  /**
173   * @return
174   * @return {number}
175   */
176  getRGBA() {
177    return this.red * 16777216 + this.green * 65536 + this.blue * 256 + this.alpha;
178  }
179  getRGB() {
180    return this.red * 65536 + this.green * 256 + this.blue;
181  }
182  /**
183   * 
184   * @return {string}
185   */
186  toString() {
187    return this.red + "," + this.green + "," + this.blue + (this.alpha < 255 ? "," + this.alpha : "");
188  }
189  toWebString() {
190    return javaemul.internal.StringHelper.format("#%02X%02X%02X", this.red, this.green, this.blue);
191  }
192  static parseColor(str) {
193    const toks = new java.util.StringTokenizer(str, ",");
194    const red = toks.nextToken();
195    const green = toks.nextToken();
196    const blue = toks.nextToken();
197    return new _Color(javaemul.internal.IntegerHelper.parseInt(red), javaemul.internal.IntegerHelper.parseInt(green), javaemul.internal.IntegerHelper.parseInt(blue));
198  }
199  static parseWebColor(colorStr) {
200    return new _Color(
201      /* intValue */
202      javaemul.internal.IntegerHelper.valueOf(colorStr.substring(1, 3), 16) | 0,
203      /* intValue */
204      javaemul.internal.IntegerHelper.valueOf(colorStr.substring(3, 5), 16) | 0,
205      /* intValue */
206      javaemul.internal.IntegerHelper.valueOf(colorStr.substring(5, 7), 16) | 0
207    );
208  }
209  getRed() {
210    return this.red;
211  }
212  getGreen() {
213    return this.green;
214  }
215  getBlue() {
216    return this.blue;
217  }
218  getAlpha() {
219    return this.alpha;
220  }
221  static getComplement(color) {
222    return color == null ? null : new _Color((128 + color.red) % 256, (128 + color.green) % 256, (128 + color.blue) % 256, color.alpha);
223  }
224  static getInverted(color) {
225    return color == null ? null : new _Color(255 - color.red, 255 - color.green, 255 - color.blue, color.alpha);
226  }
227  /**
228   * @param {Color} color color to be modified.
229   * @param {number}
229 scale0to1 is adjusted internally to be between 0 and 1.
230   * @return {Color} The original color maximized then having each component
231   * multiplied by the specified scale (between 0 and 1).
232   * Multiplying by 0 returns BLACK.
233   * Multiplying by 1 returns the maximized color.
234   */
235  static getScaledTo(color, scale0to1) {
236    if (color == null) {
237      return null;
238    }
239    const maxColor = _Color.getMaximum(color);
240    const scale = Math.min(Math.max(0, scale0to1), 1);
241    if (scale === 0) return _Color.BLACK_$LI$();
242    if (scale === 1) return maxColor;
243    const red = maxColor.getRed() * scale;
244    const green = maxColor.getGreen() * scale;
245    const blue = maxColor.getBlue() * scale;
246    return new _Color(
247      /* intValue */
248      red | 0,
249      /* intValue */
250      green | 0,
251      /* intValue */
252      blue | 0,
253      color.getAlpha()
254    );
255  }
256  /**
257   * @param {Color} color
258   * @return {Color} A new color where each of the RGB components are proportional to the parameter
259   * but scaled so that the component with the highest value becomes 0xFF.
260   * Other components are scaled proportionally. The alpha component is unchanged.
261   * If the color is null or BLACK (0,0,0) or if one or more elements are already at 0xFF
262   * then the original value is returned unchanged.
263   */
264  static getMaximum(color) {
265    if (color == null) {
266      return null;
267    }
268    const most = Math.max(Math.max(color.red, color.green), color.blue);
269    return most === 0 || most === 255 ? color : new _Color(255 * color.red / most | 0, 255 * color.green / most | 0, 255 * color.blue / most | 0, color.alpha);
270  }
271  static getPastel(color) {
272    return color == null ? null : color.getPastel();
273  }
274};
275Color["__class"] = "com.vzome.core.construction.Color";
276
277// src/worker/legacy/from-java/java/beans/ChangeListenerMap.ts
278var ChangeListenerMap = class {
279  add(name, listener) {
280    if (this.map == null) {
281      this.map = new java.util.HashMap();
282    }
283    const array = this.map.get(name);
284    const size = array != null ? array.length : 0;
285    const clone = this.newArray(size + 1);
286    clone[size] = listener;
287    if (array != null) {
288      java.lang.System.arraycopy(array, 0, clone, 0, size);
289    }
290    this.map.put(name, clone);
291  }
292  remove(name, listener) {
293    if (this.map != null) {
294      const array = this.map.get(name);
295      if (array != null) {
296        for (let i = 0; i < array.length; i++) {
297          {
298            if (listener.equals(array[i])) {
299              const size = array.length - 1;
300              if (size > 0) {
301                const clone = this.newArray(size);
302                java.lang.System.arraycopy(array, 0, clone, 0, i);
303                java.lang.System.arraycopy(array, i + 1, clone, i, size - i);
304                this.map.put(name, clone);
305              } else {
306                this.map.remove(name);
307                if (this.map.isEmpty()) {
308                  this.map = null;
309                }
310              }
311              break;
312            }
313          }
314          ;
315        }
316      }
317    }
318  }
319  /**
320   * Returns the list of listeners for the specified property.
321   * 
322   * @param {string} name
323   * the name of the property
324   * @return {L[]} the corresponding list of listeners
325   */
326  get(name) {
327    return this.map != null ? this.map.get(name) : null;
328  }
329  /**
330   * Sets new list of listeners for the specified property.
331   * 
332   * @param {string} name
333   * the name of the property
334   * @param {L[]} listeners
335   * new list of listeners
336   */
337  set(name, listeners) {
338    if (listeners != null) {
339      if (this.map == null) {
340        this.map = new java.util.HashMap();
341      }
342      this.map.put(name, listeners);
343    } else if (this.map != null) {
344      this.map.remove(name);
345      if (this.map.isEmpty()) {
346        this.map = null;
347      }
348    }
349  }
350  getListeners$() {
351    if (this.map == null) {
352      return this.newArray(0);
353    }
354    const list = new java.util.ArrayList();
355    const listeners = this.map.get(null);
356    if (listeners != null) {
357      for (let index = 0; index < listeners.length; index++) {
358        let listener = listeners[index];
359        {
360          list.add(listener);
361        }
362      }
363    }
364    for (let index = this.map.entrySet().iterator(); index.hasNext(); ) {
365      let entry = index.next();
366      {
367        const name = entry.getKey();
368        if (name != null) {
369          {
370            let array = entry.getValue();
371            for (let index2 = 0; index2 < array.length; index2++) {
372              let listener = array[index2];
373              {
374                list.add(this.newProxy(name, listener));
375              }
376            }
377          }
378        }
379      }
380    }
381    return list.toArray(this.newArray(list.size()));
382  }
383  getListeners$java_lang_String(name) {
384    if (name != null) {
385      const listeners = this.get(name);
386      if (listeners != null) {
387        return listeners.slice(0);
388      }
389    }
390    return this.newArray(0);
391  }
392  /**
393   * Returns listeners that have been associated with the named property.
394   * 
395   * @param {string} name
396   * the name of the property
397   * @return {L[]} an array of listeners for the named property
398   */
399  getListeners(name) {
400    if (typeof name === "string" || name === null) {
401      return this.getListeners$java_lang_String(name);
402    } else if (name === void 0) {
403      return this.getListeners$();
404    } else throw new Error("invalid overload");
405  }
406  /**
407   * Indicates whether the map contains at least one listener to be notified.
408   * 
409   * @param {string} name
410   * the name of the property
411   * @return {boolean} {@code true} if at least one listener exists or {@code false}
412   * otherwise
413   */
414  hasListeners(name) {
415    if (this.map == null) {
416      return false;
417    }
418    const array = this.map.get(null);
419    return array != null || name != null && null != this.map.get(name);
420  }
421  /**
422   * Returns a set of entries from the map. Each entry is a pair consisted of
423   * the property name and the corresponding list of listeners.
424   * 
425   * @return {*} a set of entries from the map
426   */
427  getEntries() {
428    return this.map != null ? this.map.entrySet() : java.util.Collections.emptySet();
429  }
430  constructor() {
431    if (this.map === void 0) {
432      this.map = null;
433    }
434  }
435};
436ChangeListenerMap["__class"] = "java.beans.ChangeListenerMap";
437
438// src/worker/legacy/from-java/java/beans/PropertyChangeEvent.ts
439var PropertyChangeEvent = class extends java.util.EventObject {
440  static {
441    this.__java_beans_PropertyChangeEvent_serialVersionUID = 7042693688939648e3;
442  }
443  constructor(source, propertyName, oldValue, newValue) {
444    super(source);
445    if (this.propertyName === void 0) {
446      this.propertyName = null;
447    }
448    if (this.newValue === void 0) {
449      this.newValue = null;
450    }
451    if (this.oldValue === void 0) {
452      this.oldValue = null;
453    }
454    if (this.propagationId === void 0) {
455      this.propagationId = null;
456    }
457    this.propertyName = propertyName;
458    this.newValue = newValue;
459    this.oldValue = oldValue;
460  }
461  getPropertyName() {
462    return this.propertyName;
463  }
464  getNewValue() {
465    return this.newValue;
466  }
467  getOldValue() {
468    return this.oldValue;
469  }
470  setPropagationId(propagationId) {
471    this.propagationId = propagationId;
472  }
473  getPropagationId() {
474    return this.propagationId;
475  }
476  toString() {
477    const sb = new java.lang.StringBuilder(
478      /* getName */
479      ((c) => typeof c === "string" ? c : c["__class"] ? c["__class"] : c["name"])(this.constructor)
480    );
481    sb.append("[propertyName=").append(this.getPropertyName());
482    this.appendTo(sb);
483    sb.append("; oldValue=").append(this.getOldValue());
484    sb.append("; newValue=").append(this.getNewValue());
485    sb.append("; propagationId=").append(this.getPropagationId());
486    sb.append("; source=").append(this.getSource());
487    return sb.append("]").toString();
488  }
489  appendTo(sb) {
490  }
491};
492PropertyChangeEvent["__class"] = "java.beans.PropertyChangeEvent";
493PropertyChangeEvent["__interfaces"] = ["java.io.Serializable"];
494
495// src/worker/legacy/from-java/java/beans/IndexedPropertyChangeEvent.ts
496var IndexedPropertyChangeEvent = class extends PropertyChangeEvent {
497  static {
498    this.serialVersionUID = -320227448495806850;
499  }
500  constructor(source, propertyName, oldValue, newValue, index) {
501    super(source, propertyName, oldValue, newValue);
502    if (this.index === void 0) {
503      this.index = 0;
504    }
505    this.index = index;
506  }
507  /**
508   * Gets the index of the property that was changed.
509   * 
510   * @return {number} The index specifying the property element that was
511   * changed.
512   */
513  getIndex() {
514    return this.index;
515  }
516  appendTo(sb) {
517    sb.append("; index=").append(this.getIndex());
518  }
519};
520IndexedPropertyChangeEvent["__class"] = "java.beans.IndexedPropertyChangeEvent";
521IndexedPropertyChangeEvent["__interfaces"] = ["java.io.Serializable"];
522
523// src/worker/legacy/from-java/java/beans/PropertyChangeListenerProxy.ts
524var PropertyChangeListenerProxy = class extends java.util.EventListenerProxy {
525  constructor(propertyName, listener) {
526    super(listener);
527    if (this.propertyName === void 0) {
528      this.propertyName = null;
529    }
530    this.propertyName = propertyName;
531  }
532  /**
533   * Forwards the property change event to the listener delegate.
534   * 
535   * @param {PropertyChangeEvent} event  the property change event
536   */
537  propertyChange(event) {
538    this.getListener().propertyChange(event);
539  }
540  /**
541   * Returns the name of the named property associated with the listener.
542   * 
543   * @return {string} the name of the named property associated with the listener
544   */
545  getPropertyName() {
546    return this.propertyName;
547  }
548};
549PropertyChangeListenerProxy["__class"] = "java.beans.PropertyChangeListenerProxy";
550PropertyChangeListenerProxy["__interfaces"] = ["java.util.EventListener", "java.beans.PropertyChangeListener"];
551
552// src/worker/legacy/from-java/java/beans/PropertyChangeSupport.ts
553var PropertyChangeSupport = class _PropertyChangeSupport {
554  constructor(sourceBean) {
555    this.map = new _PropertyChangeSupport.PropertyChangeListenerMap();
556    if (this.source === void 0) {
557      this.source = null;
558    }
559    if (sourceBean == null) {
560      throw new java.lang.NullPointerException();
561    }
562    this.source = sourceBean;
563  }
564  addPropertyChangeListener$java_beans_PropertyChangeListener(listener) {
565    if (listener == null) {
566      return;
567    }
568    if (listener != null && listener instanceof PropertyChangeListenerProxy) {
569      const proxy = listener;
570      this.addPropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(proxy.getPropertyName(), proxy.getListener());
571    } else {
572      this.map.add(null, listener);
573    }
574  }
575  removePropertyChangeListener$java_beans_PropertyChangeListener(listener) {
576    if (listener == null) {
577      return;
578    }
579    if (listener != null && listener instanceof PropertyChangeListenerProxy) {
580      const proxy = listener;
581      this.removePropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(proxy.getPropertyName(), proxy.getListener());
582    } else {
583      this.map.remove(null, listener);
584    }
585  }
586  getPropertyChangeListeners$() {
587    return this.map.getListeners$();
588  }
589  addPropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(propertyName, listener) {
590    if (listener == null || propertyName == null) {
591      return;
592    }
593    listener = this.map.extract$java_beans_PropertyChangeListener(listener);
594    if (listener != null) {
595      this.map.add(propertyName, listener);
596    }
597  }
598  addPropertyChangeListener(propertyName, listener) {
599    if ((typeof propertyName === "string" || propertyName === null) && (listener != null && (listener.constructor != null && listener.constructor["__interfaces"] != null && listener.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || listener === null)) {
600      return this.addPropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(propertyName, listener);
601    } else if ((propertyName != null && (propertyName.constructor != null && propertyName.constructor["__interfaces"] != null && propertyName.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || propertyName === null) && listener === void 0) {
602      return this.addPropertyChangeListener$java_beans_PropertyChangeListener(propertyName);
603    } else throw new Error("invalid overload");
604  }
605  removePropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(propertyName, listener) {
606    if (listener == null || propertyName == null) {
607      return;
608    }
609    listener = this.map.extract$java_beans_PropertyChangeListener(listener);
610    if (listener != null) {
611      this.map.remove(propertyName, listener);
612    }
613  }
614  removePropertyChangeListener(propertyName, listener) {
615    if ((typeof propertyName === "string" || propertyName === null) && (listener != null && (listener.constructor != null && listener.constructor["__interfaces"] != null && listener.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || listener === null)) {
616      return this.removePropertyChangeListener$java_lang_String$java_beans_PropertyChangeListener(propertyName, listener);
617    } else if ((propertyName != null && (propertyName.constructor != null && propertyName.constructor["__interfaces"] != null && propertyName.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || propertyName === null) && listener === void 0) {
618      return this.removePropertyChangeListener$java_beans_PropertyChangeListener(propertyName);
619    } else throw new Error("invalid overload");
620  }
621  getPropertyChangeListeners$java_lang_String(propertyName) {
622    return this.map.getListeners$java_lang_String(propertyName);
623  }
624  getPropertyChangeListeners(propertyName) {
625    if (typeof propertyName === "string" || propertyName === null) {
626      return this.getPropertyChangeListeners$java_lang_String(propertyName);
627    } else if (propertyName === void 0) {
628      return this.getPropertyChangeListeners$();
629    } else throw new Error("invalid overload");
630  }
631  firePropertyChange$java_lang_String$java_lang_Object$java_lang_Object(propertyName, oldValue, newValue) {
632    if (oldValue == null || newValue == null || !/* equals */
633    ((o1, o2) => o1 && o1.equals ? o1.equals(o2) : o1 === o2)(oldValue, newValue)) {
634      this.firePropertyChange$java_beans_PropertyChangeEvent(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
635    }
636  }
637  firePropertyChange$java_lang_String$int$int(propertyName, oldValue, newValue) {
638    if (oldValue !== newValue) {
639      this.firePropertyChange$java_lang_String$java_lang_Object$java_lang_Object(propertyName, javaemul.internal.IntegerHelper.valueOf(oldValue), javaemul.internal.IntegerHelper.valueOf(newValue));
640    }
641  }
642  firePropertyChange(propertyName, oldValue, newValue) {
643    if ((typeof propertyName === "string" || propertyName === null) && (typeof oldValue === "number" || oldValue === null) && (typeof newValue === "number" || newValue === null)) {
644      return this.firePropertyChange$java_lang_String$int$int(propertyName, oldValue, newValue);
645    } else if ((typeof propertyName === "string" || propertyName === null) && (typeof oldValue === "boolean" || oldValue === null) && (typeof newValue === "boolean" || newValue === null)) {
646      return this.firePropertyChange$java_lang_String$boolean$boolean(propertyName, oldValue, newValue);
647    } else if ((typeof propertyName === "string" || propertyName === null) && (oldValue != null || oldValue === null) && (newValue != null || newValue === null)) {
648      return this.firePropertyChange$java_lang_String$java_lang_Object$java_lang_Object(propertyName, oldValue, newValue);
649    } else if ((propertyName != null && propertyName instanceof PropertyChangeEvent || propertyName === null) && oldValue === void 0 && newValue === void 0) {
650      return this.firePropertyChange$java_beans_PropertyChangeEvent(propertyName);
651    } else throw new Error("invalid overload");
652  }
653  firePropertyChange$java_lang_String$boolean$boolean(propertyName, oldValue, newValue) {
654    if (oldValue !== newValue) {
655      this.firePropertyChange$java_lang_String$java_lang_Object$java_lang_Object(propertyName, javaemul.internal.BooleanHelper.valueOf(oldValue), javaemul.internal.BooleanHelper.valueOf(newValue));
656    }
657  }
658  firePropertyChange$java_beans_PropertyChangeEvent(event) {
659    const oldValue = event.getOldValue();
660    const newValue = event.getNewValue();
661    if (oldValue == null || newValue == null || !/* equals */
662    ((o1, o2) => o1 && o1.equals ? o1.equals(o2) : o1 === o2)(oldValue, newValue)) {
663      const name = event.getPropertyName();
664      const common = this.map.get(null);
665      const named = name != null ? this.map.get(name) : null;
666      _PropertyChangeSupport.fire(common, event);
667      _PropertyChangeSupport.fire(named, event);
668    }
669  }
670  static fire(listeners, event) {
671    if (listeners != null) {
672      for (let index = 0; index < listeners.length; index++) {
673        let listener = listeners[index];
674        {
675          listener.propertyChange(event);
676        }
677      }
678    }
679  }
680  fireIndexedPropertyChange$java_lang_String$int$java_lang_Object$java_lang_Object(propertyName, index, oldValue, newValue) {
681    if (oldValue == null || newValue == null || !/* equals */
682    ((o1, o2) => o1 && o1.equals ? o1.equals(o2) : o1 === o2)(oldValue, newValue)) {
683      this.firePropertyChange$java_beans_PropertyChangeEvent(new IndexedPropertyChangeEvent(this.source, propertyName, oldValue, newValue, index));
684    }
685  }
686  fireIndexedPropertyChange$java_lang_String$int$int$int(propertyName, index, oldValue, newValue) {
687    if (oldValue !== newValue) {
688      this.fireIndexedPropertyChange$java_lang_String$int$java_lang_Object$java_lang_Object(propertyName, index, javaemul.internal.IntegerHelper.valueOf(oldValue), javaemul.internal.IntegerHelper.valueOf(newValue));
689    }
690  }
691  fireIndexedPropertyChange(propertyName, index, oldValue, newValue) {
692    if ((typeof propertyName === "string" || propertyName === null) && (typeof index === "number" || index === null) && (typeof oldValue === "number" || oldValue === null) && (typeof newValue === "number" || newValue === null)) {
693      return this.fireIndexedPropertyChange$java_lang_String$int$int$int(propertyName, index, oldValue, newValue);
694    } else if ((typeof propertyName === "string" || propertyName === null) && (typeof index === "number" || index === null) && (typeof oldValue === "boolean" || oldValue === null) && (typeof newValue === "boolean" || newValue === null)) {
695      return this.fireIndexedPropertyChange$java_lang_String$int$boolean$boolean(propertyName, index, oldValue, newValue);
696    } else if ((typeof propertyName === "string" || propertyName === null) && (typeof index === "number" || index === null) && (oldValue != null || oldValue === null) && (newValue != null || newValue === null)) {
697      return this.fireIndexedPropertyChange$java_lang_String$int$java_lang_Object$java_lang_Object(propertyName, index, oldValue, newValue);
698    } else throw new Error("invalid overload");
699  }
700  fireIndexedPropertyChange$java_lang_String$int$boolean$boolean(propertyName, index, oldValue, newValue) {
701    if (oldValue !== newValue) {
702      this.fireIndexedPropertyChange$java_lang_String$int$java_lang_Object$java_lang_Object(propertyName, index, javaemul.internal.BooleanHelper.valueOf(oldValue), javaemul.internal.BooleanHelper.valueOf(newValue));
703    }
704  }
705  hasListeners(propertyName) {
706    return this.map.hasListeners(propertyName);
707  }
708  static {
709    this.serialVersionUID = 6401253773779952e3;
710  }
711};
712PropertyChangeSupport["__class"] = "java.beans.PropertyChangeSupport";
713((PropertyChangeSupport2) => {
714  class PropertyChangeListenerMap extends ChangeListenerMap {
715    static EMPTY_$LI$() {
716      if (PropertyChangeListenerMap.EMPTY == null) {
717        PropertyChangeListenerMap.EMPTY = [];
718      }
719      return PropertyChangeListenerMap.EMPTY;
720    }
721    /**
722     * 
723     * @param {number} length
724     * @return {PropertyChangeListener[]}
725     */
726    newArray(length) {
727      return 0 < length ? ((s) => {
728        let a = [];
729        while (s-- > 0) a.push(null);
730        return a;
731      })(length) : PropertyChangeListenerMap.EMPTY_$LI$();
732    }
733    newProxy$java_lang_String$java_beans_PropertyChangeListener(name, listener) {
734      return new PropertyChangeListenerProxy(name, listener);
735    }
736    /**
737     * 
738     * @param {string} name
739     * @param {*} listener
740     * @return {*}
741     */
742    newProxy(name, listener) {
743      if ((typeof name === "string" || name === null) && (listener != null && (listener.constructor != null && listener.constructor["__interfaces"] != null && listener.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || listener === null)) {
744        return this.newProxy$java_lang_String$java_beans_PropertyChangeListener(name, listener);
745      } else if ((typeof name === "string" || name === null) && (listener != null || listener === null)) {
746        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
747      } else throw new Error("invalid overload");
748    }
749    extract$java_beans_PropertyChangeListener(listener) {
750      while (listener != null && listener instanceof PropertyChangeListenerProxy) {
751        {
752          listener = listener.getListener();
753        }
754      }
755      ;
756      return listener;
757    }
758    extract(listener) {
759      if (listener != null && (listener.constructor != null && listener.constructor["__interfaces"] != null && listener.constructor["__interfaces"].indexOf("java.beans.PropertyChangeListener") >= 0) || listener === null) {
760        return this.extract$java_beans_PropertyChangeListener(listener);
761      } else if (listener != null || listener === null) {
762        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
763      } else throw new Error("invalid overload");
764    }
765    constructor() {
766      super();
767    }
768  }
769  PropertyChangeSupport2.PropertyChangeListenerMap = PropertyChangeListenerMap;
770  PropertyChangeListenerMap["__class"] = "java.beans.PropertyChangeSupport.PropertyChangeListenerMap";
771})(PropertyChangeSupport || (PropertyChangeSupport = {}));
772
773// src/worker/legacy/from-java/com/vzome/core/construction/Polygon.ts
774var Polygon = class extends Construction {
775  /**
776   * 
777   * @return {string}
778   */
779  toString() {
780    return "polygon " + java.util.Arrays.toString(this.mVertices);
781  }
782  constructor(field) {
783    super(field);
784    if (this.mVertices === void 0) {
785      this.mVertices = null;
786    }
787    this.STRING_COMPARATOR = (s1, s2) => (
788      /* compareTo */
789      s1.localeCompare(s2)
790    );
791  }
792  getSignature() {
793    const strArray = java.util.Arrays.stream(this.mVertices).map((av) => av.projectTo3d(true).toString()).toArray((arg0) => {
794      return new Array(arg0);
795    });
796    java.util.Arrays.sort(strArray, 0, strArray.length, ((funcInst) => {
797      if (funcInst == null || typeof funcInst == "function") {
798        return funcInst;
799      }
800      return (arg0, arg1) => (funcInst["compare"] ? funcInst["compare"] : funcInst).call(funcInst, arg0, arg1);
801    })(this.STRING_COMPARATOR));
802    return java.util.Arrays.toString(strArray);
803  }
804  setStateVariable(vertices, impossible) {
805    if (impossible) {
806      if (this.isImpossible()) return false;
807      this.setImpossible(true);
808      return true;
809    }
810    this.mVertices = vertices;
811    this.setImpossible(false);
812    return true;
813  }
814  getXml$org_w3c_dom_Document(doc) {
815    const result = doc.createElement("polygon");
816    this.getXml$org_w3c_dom_Element$java_lang_String(result, "vertex");
817    return result;
818  }
819  getXml$org_w3c_dom_Element$java_lang_String(result, vertexChildName) {
820    for (let index = 0; index < this.mVertices.length; index++) {
821      let vertex = this.mVertices[index];
822      {
823        const child = result.getOwnerDocument().createElement(vertexChildName);
824        DomUtils.addAttribute(child, "at", vertex.getVectorExpression$int(AlgebraicField.ZOMIC_FORMAT));
825        result.appendChild(child);
826      }
827    }
828  }
829  getXml(result, vertexChildName) {
830    if ((result != null && (result.constructor != null && result.constructor["__interfaces"] != null && result.constructor["__interfaces"].indexOf("org.w3c.dom.Element") >= 0) || result === null) && (typeof vertexChildName === "string" || vertexChildName === null)) {
831      return this.getXml$org_w3c_dom_Element$java_lang_String(result, vertexChildName);
832    } else if ((result != null && (result.constructor != null && result.constructor["__interfaces"] != null && result.constructor["__interfaces"].indexOf("org.w3c.dom.Document") >= 0) || result === null) && vertexChildName === void 0) {
833      return this.getXml$org_w3c_dom_Document(result);
834    } else throw new Error("invalid overload");
835  }
836  /**
837   * 
838   * @return {boolean}
839   */
840  is3d() {
841    for (let index = 0; index < this.mVertices.length; index++) {
842      let algebraicVector = this.mVertices[index];
843      {
844        if (algebraicVector.dimension() !== 3) return false;
845      }
846    }
847    return true;
848  }
849  getVertexCount() {
850    return this.mVertices.length;
851  }
852  getVertex(i) {
853    return this.mVertices[i];
854  }
855  getNormal() {
856    return AlgebraicVectors.getNormal$com_vzome_core_algebra_AlgebraicVector$com_vzome_core_algebra_AlgebraicVector$com_vzome_core_algebra_AlgebraicVector(this.mVertices[0], this.mVertices[1], this.mVertices[2]);
857  }
858  getCentroid() {
859    return AlgebraicVectors.getCentroid(this.mVertices);
860  }
861  getVertices() {
862    return java.util.Arrays.copyOf(this.mVertices, this.mVertices.length);
863  }
864};
865Polygon["__class"] = "com.vzome.core.construction.Polygon";
866
867// src/worker/legacy/from-java/com/vzome/core/commands/Command.ts
868var Command;
869((Command2) => {
870  Command2.LOADING_FROM_FILE = "org.vorthmann.zome.editor.Command.LOADING_FROM_FILE";
871  Command2.FIELD_ATTR_NAME = "org.vorthmann.zome.commands.Command.ALGEBRAIC_FIELD";
872  Command2.GENERIC_PARAM_NAME = "org.vorthmann.zome.editor.Command.GENERIC_PARAM";
873})(Command || (Command = {}));
874((Command2) => {
875  class Failure extends Error {
876    static logger_$LI$() {
877      if (Failure.logger == null) {
878        Failure.logger = java.util.logging.Logger.getLogger("org.vorthmann.zome.commands");
879      }
880      return Failure.logger;
881    }
882    constructor(message, cause) {
883      if ((typeof message === "string" || message === null) && (cause != null && cause instanceof Error || cause === null)) {
884        let __args = arguments;
885        super(message);
886        this.message = message;
887        Failure.logger_$LI$().log(java.util.logging.Level.INFO, "command failure: " + message, cause);
888      } else if ((typeof message === "string" || message === null) && cause === void 0) {
889        let __args = arguments;
890        super(message);
891        this.message = message;
892        if (Failure.logger_$LI$().isLoggable(java.util.logging.Level.FINE)) Failure.logger_$LI$().log(java.util.logging.Level.FINE, "command failure: " + message);
893      } else if ((message != null && message instanceof Error || message === null) && cause === void 0) {
894        let __args = arguments;
895        let cause2 = __args[0];
896        super(cause2);
897        this.message = cause2;
898        Failure.logger_$LI$().log(java.util.logging.Level.INFO, "command failure", cause2);
899      } else if (message === void 0 && cause === void 0) {
900        let __args = arguments;
901        super();
902      } else throw new Error("invalid overload");
903    }
904  }
905  Command2.Failure = Failure;
906  Failure["__class"] = "com.vzome.core.commands.Command.Failure";
907  Failure["__interfaces"] = ["java.io.Serializable"];
908})(Command || (Command = {}));
909
910// src/worker/legacy/from-java/com/vzome/core/generic/FilteredIterator.ts
911var FilteredIterator = class {
912  /**
913   * Elements must match this filter before conversion
914   * @param {*} element
915   * @return {boolean}
916   */
917  preFilter(element) {
918    return this.__preFilter == null ? true : ((target) => typeof target === "function" ? target(element) : target.test(element))(this.__preFilter);
919  }
920  /**
921   * Elements must match this filter after conversion
922   * @param {*} element
923   * @return {boolean}
924   */
925  postFilter(element) {
926    return this.__postFilter == null ? true : ((target) => typeof target === "function" ? target(element) : target.test(element))(this.__postFilter);
927  }
928  constructor(preTest, iterable, postTest) {
929    if (this.wrappedIterator === void 0) {
930      this.wrappedIterator = null;
931    }
932    if (this.__preFilter === void 0) {
933      this.__preFilter = null;
934    }
935    if (this.__postFilter === void 0) {
936      this.__postFilter = null;
937    }
938    this.nextElement = null;
939    this.__hasNext = null;
940    this.wrappedIterator = iterable.iterator();
941    this.__preFilter = ((funcInst) => {
942      if (funcInst == null || typeof funcInst == "function") {
943        return funcInst;
944      }
945      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
946    })(preTest);
947    this.__postFilter = ((funcInst) => {
948      if (funcInst == null || typeof funcInst == "function") {
949        return funcInst;
950      }
951      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
952    })(postTest);
953  }
954  /**
955   * 
956   * @return {*}
957   */
958  iterator() {
959    return this;
960  }
961  /**
962   * 
963   * @return {boolean}
964   */
965  hasNext() {
966    if (this.__hasNext == null) {
967      this.nextMatch();
968    }
969    return this.__hasNext;
970  }
971  /**
972   * 
973   * @return {*}
974   */
975  next() {
976    if (this.__hasNext == null) {
977      this.nextMatch();
978    }
979    if (!this.__hasNext) {
980      throw new java.util.NoSuchElementException();
981    }
982    return this.nextMatch();
983  }
984  nextMatch() {
985    const lastMatch = this.nextElement;
986    while (this.wrappedIterator.hasNext()) {
987      {
988        const next = this.wrappedIterator.next();
989        if (this.preFilter(next)) {
990          const converted = this.apply(next);
991          if (this.postFilter(converted)) {
992            this.nextElement = converted;
993            this.__hasNext = true;
994            return lastMatch;
995          }
996        }
997      }
998    }
999    ;
1000    this.__hasNext = false;
1001    return lastMatch;
1002  }
1003  /**
1004   * 
1005   */
1006  remove() {
1007    this.wrappedIterator.remove();
1008  }
1009};
1010FilteredIterator["__class"] = "com.vzome.core.generic.FilteredIterator";
1011FilteredIterator["__interfaces"] = ["java.util.Iterator", "java.lang.Iterable"];
1012((FilteredIterator2) => {
1013  class Filters {
1014    constructor() {
1015    }
1016    /**
1017     * A static convenience function that may be passed as a preFilter parameter
1018     * @param <T>
1019     * @param {*} element
1020     * @return {boolean} {@code true} if element is not null
1021     */
1022    static elementNotNull(element) {
1023      return element != null;
1024    }
1025    /**
1026     * A static convenience function that may be passed as a postFilter parameter
1027     * @param <R>
1028     * @param {*} result
1029     * @return {boolean} {@code true} if result is not null
1030     */
1031    static resultNotNull(result) {
1032      return result != null;
1033    }
1034    /**
1035     * A static convenience function that may be used with another predicate
1036     * to be passed as a preFilter or postFilter parameter
1037     * @param <B>
1038     * @param {*} predicate The predicate to be negated.
1039     * @param {*} arg The parameter to be passed to the predicate.
1040     * @return {boolean} The opposite of what the predicate returns.
1041     */
1042    static not(predicate, arg) {
1043      return ((target) => typeof target === "function" ? target(arg) : target.test(arg))(((target) => typeof target === "function" ? target() : target.negate())(predicate));
1044    }
1045    /**
1046     * A static convenience function that may be used to combine two other predicates
1047     * to be passed as a preFilter or postFilter parameter
1048     * @param <B>
1049     * @param {*} check1 The 1st predicate to be evaluated.
1050     * @param {*} check2 The 2nd predicate to be evaluated.
1051     * @param {*} arg The parameter to be passed to the predicates.
1052     * @return {boolean} {@code true} only if both predicates are true.
1053     */
1054    static and(check1, check2, arg) {
1055      return ((target) => typeof target === "function" ? target(arg) : target.test(arg))(((target) => typeof target === "function" ? target(check2) : target.and(check2))(check1));
1056    }
1057    /**
1058     * A static convenience function that may be used to combine two other predicates
1059     * to be passed as a preFilter or postFilter parameter
1060     * @param <B>
1061     * @param {*} check1 The 1st predicate to be evaluated.
1062     * @param {*} check2 The 2nd predicate to be evaluated.
1063     * @param {*} arg The parameter to be passed to the predicates.
1064     * @return {boolean} {@code true} if either predicate is true.
1065     */
1066    static or(check1, check2, arg) {
1067      return ((target) => typeof target === "function" ? target(arg) : target.test(arg))(((target) => typeof target === "function" ? target(check2) : target.or(check2))(check1));
1068    }
1069  }
1070  FilteredIterator2.Filters = Filters;
1071  Filters["__class"] = "com.vzome.core.generic.FilteredIterator.Filters";
1072})(FilteredIterator || (FilteredIterator = {}));
1073
1074// src/worker/legacy/from-java/com/vzome/core/editor/api/Manifestations.ts
1075var Manifestations = class _Manifestations {
1076  static visibleManifestations$java_lang_Iterable(manifestations) {
1077    return new _Manifestations.ManifestationIterator((man) => {
1078      return _Manifestations.Filters.isVisible(man);
1079    }, manifestations, ((funcInst) => {
1080      if (funcInst == null || typeof funcInst == "function") {
1081        return funcInst;
1082      }
1083      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1084    })(null));
1085  }
1086  static visibleManifestations$java_util_function_Predicate$java_lang_Iterable(preTest, manifestations) {
1087    return new _Manifestations.ManifestationIterator(((funcInst) => {
1088      if (funcInst == null || typeof funcInst == "function") {
1089        return funcInst;
1090      }
1091      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1092    })(preTest), manifestations, (man) => {
1093      return _Manifestations.Filters.isVisible(man);
1094    });
1095  }
1096  static visibleManifestations(preTest, manifestations) {
1097    if ((typeof preTest === "function" && preTest.length === 1 || preTest === null) && (manifestations != null && (manifestations.constructor != null && manifestations.constructor["__interfaces"] != null && manifestations.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || manifestations === null)) {
1098      return _Manifestations.visibleManifestations$java_util_function_Predicate$java_lang_Iterable(preTest, manifestations);
1099    } else if ((preTest != null && (preTest.constructor != null && preTest.constructor["__interfaces"] != null && preTest.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preTest === null) && (typeof manifestations === "function" && manifestations.length === 1 || manifestations === null)) {
1100      return _Manifestations.visibleManifestations$java_lang_Iterable$java_util_function_Predicate(preTest, manifestations);
1101    } else if ((preTest != null && (preTest.constructor != null && preTest.constructor["__interfaces"] != null && preTest.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preTest === null) && manifestations === void 0) {
1102      return _Manifestations.visibleManifestations$java_lang_Iterable(preTest);
1103    } else throw new Error("invalid overload");
1104  }
1105  static visibleManifestations$java_lang_Iterable$java_util_function_Predicate(manifestations, postTest) {
1106    return new _Manifestations.ManifestationIterator((man) => {
1107      return _Manifestations.Filters.isVisible(man);
1108    }, manifestations, ((funcInst) => {
1109      if (funcInst == null || typeof funcInst == "function") {
1110        return funcInst;
1111      }
1112      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1113    })(postTest));
1114  }
1115  static getConnectors$java_lang_Iterable(manifestations) {
1116    return new _Manifestations.ConnectorIterator(((funcInst) => {
1117      if (funcInst == null || typeof funcInst == "function") {
1118        return funcInst;
1119      }
1120      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1121    })(null), manifestations, ((funcInst) => {
1122      if (funcInst == null || typeof funcInst == "function") {
1123        return funcInst;
1124      }
1125      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1126    })(null));
1127  }
1128  static getConnectors$java_lang_Iterable$java_util_function_Predicate(manifestations, postFilter) {
1129    return new _Manifestations.ConnectorIterator(((funcInst) => {
1130      if (funcInst == null || typeof funcInst == "function") {
1131        return funcInst;
1132      }
1133      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1134    })(null), manifestations, ((funcInst) => {
1135      if (funcInst == null || typeof funcInst == "function") {
1136        return funcInst;
1137      }
1138      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1139    })(postFilter));
1140  }
1141  static getConnectors$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter) {
1142    return new _Manifestations.ConnectorIterator(((funcInst) => {
1143      if (funcInst == null || typeof funcInst == "function") {
1144        return funcInst;
1145      }
1146      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1147    })(preFilter), manifestations, ((funcInst) => {
1148      if (funcInst == null || typeof funcInst == "function") {
1149        return funcInst;
1150      }
1151      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1152    })(postFilter));
1153  }
1154  static getConnectors(preFilter, manifestations, postFilter) {
1155    if ((typeof preFilter === "function" && preFilter.length === 1 || preFilter === null) && (manifestations != null && (manifestations.constructor != null && manifestations.constructor["__interfaces"] != null && manifestations.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || manifestations === null) && (typeof postFilter === "function" && postFilter.length === 1 || postFilter === null)) {
1156      return _Manifestations.getConnectors$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter);
1157    }
1157 else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && (typeof manifestations === "function" && manifestations.length === 1 || manifestations === null) && postFilter === void 0) {
1158      return _Manifestations.getConnectors$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations);
1159    } else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && manifestations === void 0 && postFilter === void 0) {
1160      return _Manifestations.getConnectors$java_lang_Iterable(preFilter);
1161    } else throw new Error("invalid overload");
1162  }
1163  static getVisibleConnectors(manifestations, postFilter = null) {
1164    return new _Manifestations.ConnectorIterator((man) => {
1165      return _Manifestations.Filters.isVisible(man);
1166    }, manifestations, ((funcInst) => {
1167      if (funcInst == null || typeof funcInst == "function") {
1168        return funcInst;
1169      }
1170      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1171    })(postFilter));
1172  }
1173  static getHiddenConnectors(manifestations, postFilter = null) {
1174    return new _Manifestations.ConnectorIterator((man) => {
1175      return _Manifestations.Filters.isHidden(man);
1176    }, manifestations, ((funcInst) => {
1177      if (funcInst == null || typeof funcInst == "function") {
1178        return funcInst;
1179      }
1180      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1181    })(postFilter));
1182  }
1183  static getStruts$java_lang_Iterable(manifestations) {
1184    return new _Manifestations.StrutIterator(((funcInst) => {
1185      if (funcInst == null || typeof funcInst == "function") {
1186        return funcInst;
1187      }
1188      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1189    })(null), manifestations, ((funcInst) => {
1190      if (funcInst == null || typeof funcInst == "function") {
1191        return funcInst;
1192      }
1193      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1194    })(null));
1195  }
1196  static getStruts$java_lang_Iterable$java_util_function_Predicate(manifestations, postFilter) {
1197    return new _Manifestations.StrutIterator(((funcInst) => {
1198      if (funcInst == null || typeof funcInst == "function") {
1199        return funcInst;
1200      }
1201      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1202    })(null), manifestations, ((funcInst) => {
1203      if (funcInst == null || typeof funcInst == "function") {
1204        return funcInst;
1205      }
1206      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1207    })(postFilter));
1208  }
1209  static getStruts$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter) {
1210    return new _Manifestations.StrutIterator(((funcInst) => {
1211      if (funcInst == null || typeof funcInst == "function") {
1212        return funcInst;
1213      }
1214      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1215    })(preFilter), manifestations, ((funcInst) => {
1216      if (funcInst == null || typeof funcInst == "function") {
1217        return funcInst;
1218      }
1219      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1220    })(postFilter));
1221  }
1222  static getStruts(preFilter, manifestations, postFilter) {
1223    if ((typeof preFilter === "function" && preFilter.length === 1 || preFilter === null) && (manifestations != null && (manifestations.constructor != null && manifestations.constructor["__interfaces"] != null && manifestations.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || manifestations === null) && (typeof postFilter === "function" && postFilter.length === 1 || postFilter === null)) {
1224      return _Manifestations.getStruts$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter);
1225    }
1225 else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && (typeof manifestations === "function" && manifestations.length === 1 || manifestations === null) && postFilter === void 0) {
1226      return _Manifestations.getStruts$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations);
1227    } else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && manifestations === void 0 && postFilter === void 0) {
1228      return _Manifestations.getStruts$java_lang_Iterable(preFilter);
1229    } else throw new Error("invalid overload");
1230  }
1231  static getVisibleStruts(manifestations, postFilter = null) {
1232    return new _Manifestations.StrutIterator((man) => {
1233      return _Manifestations.Filters.isVisible(man);
1234    }, manifestations, ((funcInst) => {
1235      if (funcInst == null || typeof funcInst == "function") {
1236        return funcInst;
1237      }
1238      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1239    })(postFilter));
1240  }
1241  static getHiddenStruts(manifestations, postFilter = null) {
1242    return new _Manifestations.StrutIterator((man) => {
1243      return _Manifestations.Filters.isHidden(man);
1244    }, manifestations, ((funcInst) => {
1245      if (funcInst == null || typeof funcInst == "function") {
1246        return funcInst;
1247      }
1248      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1249    })(postFilter));
1250  }
1251  static getPanels$java_lang_Iterable(manifestations) {
1252    return new _Manifestations.PanelIterator(((funcInst) => {
1253      if (funcInst == null || typeof funcInst == "function") {
1254        return funcInst;
1255      }
1256      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1257    })(null), manifestations, ((funcInst) => {
1258      if (funcInst == null || typeof funcInst == "function") {
1259        return funcInst;
1260      }
1261      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1262    })(null));
1263  }
1264  static getPanels$java_lang_Iterable$java_util_function_Predicate(manifestations, postFilter) {
1265    return new _Manifestations.PanelIterator(((funcInst) => {
1266      if (funcInst == null || typeof funcInst == "function") {
1267        return funcInst;
1268      }
1269      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1270    })(null), manifestations, ((funcInst) => {
1271      if (funcInst == null || typeof funcInst == "function") {
1272        return funcInst;
1273      }
1274      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1275    })(postFilter));
1276  }
1277  static getPanels$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter) {
1278    return new _Manifestations.PanelIterator(((funcInst) => {
1279      if (funcInst == null || typeof funcInst == "function") {
1280        return funcInst;
1281      }
1282      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1283    })(preFilter), manifestations, ((funcInst) => {
1284      if (funcInst == null || typeof funcInst == "function") {
1285        return funcInst;
1286      }
1287      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1288    })(postFilter));
1289  }
1290  static getPanels(preFilter, manifestations, postFilter) {
1291    if ((typeof preFilter === "function" && preFilter.length === 1 || preFilter === null) && (manifestations != null && (manifestations.constructor != null && manifestations.constructor["__interfaces"] != null && manifestations.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || manifestations === null) && (typeof postFilter === "function" && postFilter.length === 1 || postFilter === null)) {
1292      return _Manifestations.getPanels$java_util_function_Predicate$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations, postFilter);
1293    }
1293 else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && (typeof manifestations === "function" && manifestations.length === 1 || manifestations === null) && postFilter === void 0) {
1294      return _Manifestations.getPanels$java_lang_Iterable$java_util_function_Predicate(preFilter, manifestations);
1295    } else if ((preFilter != null && (preFilter.constructor != null && preFilter.constructor["__interfaces"] != null && preFilter.constructor["__interfaces"].indexOf("java.lang.Iterable") >= 0) || preFilter === null) && manifestations === void 0 && postFilter === void 0) {
1296      return _Manifestations.getPanels$java_lang_Iterable(preFilter);
1297    } else throw new Error("invalid overload");
1298  }
1299  static getVisiblePanels(manifestations, postFilter = null) {
1300    return new _Manifestations.PanelIterator((man) => {
1301      return _Manifestations.Filters.isVisible(man);
1302    }, manifestations, ((funcInst) => {
1303      if (funcInst == null || typeof funcInst == "function") {
1304        return funcInst;
1305      }
1306      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1307    })(postFilter));
1308  }
1309  static getHiddenPanels(manifestations, postFilter = null) {
1310    return new _Manifestations.PanelIterator((man) => {
1311      return _Manifestations.Filters.isHidden(man);
1312    }, manifestations, ((funcInst) => {
1313      if (funcInst == null || typeof funcInst == "function") {
1314        return funcInst;
1315      }
1316      return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1317    })(postFilter));
1318  }
1319  /**
1320   * 
1321   * @param {*} manifestations
1322   * @param {*} output
1323   * @return {AlgebraicVector} last selected Connector location, or last selected Strut location, or last vertex of last selected Panel
1324   */
1325  static sortVertices(manifestations, output) {
1326    let lastBall = null;
1327    let lastVertex = null;
1328    for (let index = manifestations.iterator(); index.hasNext(); ) {
1329      let man = index.next();
1330      {
1331        if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) {
1332          lastBall = man.getLocation();
1333          output.add(lastBall);
1334        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) {
1335          lastVertex = man.getLocation();
1336          output.add(lastVertex);
1337          output.add(man.getEnd());
1338        } else if (man != null && (man.constructor != null && man.constructor["__interfaces"] != null && man.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) {
1339          for (let index2 = man.iterator(); index2.hasNext(); ) {
1340            let vertex = index2.next();
1341            {
1342              lastVertex = vertex;
1343              output.add(vertex);
1344            }
1345          }
1346        }
1347      }
1348    }
1349    return lastBall != null ? lastBall : lastVertex;
1350  }
1351};
1352Manifestations["__class"] = "com.vzome.core.editor.api.Manifestations";
1353((Manifestations2) => {
1354  class ManifestationIterator extends FilteredIterator {
1355    constructor(preTest, manifestations, postTest) {
1356      super(((funcInst) => {
1357        if (funcInst == null || typeof funcInst == "function") {
1358          return funcInst;
1359        }
1360        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1361      })(preTest), manifestations, ((funcInst) => {
1362        if (funcInst == null || typeof funcInst == "function") {
1363          return funcInst;
1364        }
1365        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1366      })(postTest));
1367    }
1368    apply$com_vzome_core_model_Manifestation(element) {
1369      return element;
1370    }
1371    /**
1372     * 
1373     * @param {*} element
1374     * @return {*}
1375     */
1376    apply(element) {
1377      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1378        return this.apply$com_vzome_core_model_Manifestation(element);
1379      } else if (element != null || element === null) {
1380        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
1381      } else throw new Error("invalid overload");
1382    }
1383  }
1384  Manifestations2.ManifestationIterator = ManifestationIterator;
1385  ManifestationIterator["__class"] = "com.vzome.core.editor.api.Manifestations.ManifestationIterator";
1386  ManifestationIterator["__interfaces"] = ["java.util.Iterator", "java.lang.Iterable"];
1387  class ConnectorIterator extends FilteredIterator {
1388    preFilter$com_vzome_core_model_Manifestation(element) {
1389      return element != null && (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Connector") >= 0)) ? super.preFilter(element) : false;
1390    }
1391    /**
1392     * 
1393     * @param {*} element
1394     * @return {boolean}
1395     */
1396    preFilter(element) {
1397      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1398        return this.preFilter$com_vzome_core_model_Manifestation(element);
1399      } else if (element != null || element === null) {
1400        return super.preFilter(element);
1401      } else throw new Error("invalid overload");
1402    }
1403    apply$com_vzome_core_model_Manifestation(element) {
1404      return element;
1405    }
1406    /**
1407     * 
1408     * @param {*} element
1409     * @return {*}
1410     */
1411    apply(element) {
1412      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1413        return this.apply$com_vzome_core_model_Manifestation(element);
1414      } else if (element != null || element === null) {
1415        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
1416      } else throw new Error("invalid overload");
1417    }
1418    constructor(preFilter, manifestations, postFilter) {
1419      super(((funcInst) => {
1420        if (funcInst == null || typeof funcInst == "function") {
1421          return funcInst;
1422        }
1423        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1424      })(preFilter), manifestations, ((funcInst) => {
1425        if (funcInst == null || typeof funcInst == "function") {
1426          return funcInst;
1427        }
1428        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1429      })(postFilter));
1430    }
1431  }
1432  Manifestations2.ConnectorIterator = ConnectorIterator;
1433  ConnectorIterator["__class"] = "com.vzome.core.editor.api.Manifestations.ConnectorIterator";
1434  ConnectorIterator["__interfaces"] = ["java.util.Iterator", "java.lang.Iterable"];
1435  class StrutIterator extends FilteredIterator {
1436    preFilter$com_vzome_core_model_Manifestation(element) {
1437      return element != null && (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Strut") >= 0)) ? super.preFilter(element) : false;
1438    }
1439    /**
1440     * 
1441     * @param {*} element
1442     * @return {boolean}
1443     */
1444    preFilter(element) {
1445      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1446        return this.preFilter$com_vzome_core_model_Manifestation(element);
1447      } else if (element != null || element === null) {
1448        return super.preFilter(element);
1449      } else throw new Error("invalid overload");
1450    }
1451    apply$com_vzome_core_model_Manifestation(element) {
1452      return element;
1453    }
1454    /**
1455     * 
1456     * @param {*} element
1457     * @return {*}
1458     */
1459    apply(element) {
1460      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1461        return this.apply$com_vzome_core_model_Manifestation(element);
1462      } else if (element != null || element === null) {
1463        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
1464      } else throw new Error("invalid overload");
1465    }
1466    constructor(preFilter, manifestations, postFilter) {
1467      super(((funcInst) => {
1468        if (funcInst == null || typeof funcInst == "function") {
1469          return funcInst;
1470        }
1471        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1472      })(preFilter), manifestations, ((funcInst) => {
1473        if (funcInst == null || typeof funcInst == "function") {
1474          return funcInst;
1475        }
1476        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1477      })(postFilter));
1478    }
1479  }
1480  Manifestations2.StrutIterator = StrutIterator;
1481  StrutIterator["__class"] = "com.vzome.core.editor.api.Manifestations.StrutIterator";
1482  StrutIterator["__interfaces"] = ["java.util.Iterator", "java.lang.Iterable"];
1483  class PanelIterator extends FilteredIterator {
1484    preFilter$com_vzome_core_model_Manifestation(element) {
1485      return element != null && (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Panel") >= 0)) ? super.preFilter(element) : false;
1486    }
1487    /**
1488     * 
1489     * @param {*} element
1490     * @return {boolean}
1491     */
1492    preFilter(element) {
1493      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1494        return this.preFilter$com_vzome_core_model_Manifestation(element);
1495      } else if (element != null || element === null) {
1496        return super.preFilter(element);
1497      } else throw new Error("invalid overload");
1498    }
1499    apply$com_vzome_core_model_Manifestation(element) {
1500      return element;
1501    }
1502    /**
1503     * 
1504     * @param {*} element
1505     * @return {*}
1506     */
1507    apply(element) {
1508      if (element != null && (element.constructor != null && element.constructor["__interfaces"] != null && element.constructor["__interfaces"].indexOf("com.vzome.core.model.Manifestation") >= 0) || element === null) {
1509        return this.apply$com_vzome_core_model_Manifestation(element);
1510      } else if (element != null || element === null) {
1511        throw new Error("cannot invoke abstract overloaded method... check your argument(s) type(s)");
1512      } else throw new Error("invalid overload");
1513    }
1514    constructor(preFilter, manifestations, postFilter) {
1515      super(((funcInst) => {
1516        if (funcInst == null || typeof funcInst == "function") {
1517          return funcInst;
1518        }
1519        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1520      })(preFilter), manifestations, ((funcInst) => {
1521        if (funcInst == null || typeof funcInst == "function") {
1522          return funcInst;
1523        }
1524        return (arg0) => (funcInst["test"] ? funcInst["test"] : funcInst).call(funcInst, arg0);
1525      })(postFilter));
1526    }
1527  }
1528  Manifestations2.PanelIterator = PanelIterator;
1529  PanelIterator["__class"] = "com.vzome.core.editor.api.Manifestations.PanelIterator";
1530  PanelIterator["__interfaces"] = ["java.util.Iterator", "java.lang.Iterable"];
1531  class Filters {
1532    constructor() {
1533    }
1534    static isRendered(man) {
1535      return man.isRendered();
1536    }
1537    static isVisible(man) {
1538      return !man.isHidden();
1539    }
1540    static isHidden(man) {
1541      return man.isHidden();
1542    }
1543    static is(man) {
1544      return true;
1545    }
1546  }
1547  Manifestations2.Filters = Filters;
1548  Filters["__class"] = "com.vzome.core.editor.api.Manifestations.Filters";
1549})(Manifestations || (Manifestations = {}));
1550
1551// src/worker/legacy/from-java/com/vzome/xml/ResourceLoader.ts
1552var ResourceLoader = class _ResourceLoader {
1553  static RESOURCE_LOADER_$LI$() {
1554    if (_ResourceLoader.RESOURCE_LOADER == null) {
1555      _ResourceLoader.RESOURCE_LOADER = new _ResourceLoader();
1556    }
1557    return _ResourceLoader.RESOURCE_LOADER;
1558  }
1559  static logger_$LI$() {
1560    if (_ResourceLoader.logger == null) {
1561      _ResourceLoader.logger = java.util.logging.Logger.getLogger("com.vzome.xml.ResourceLoader");
1562    }
1563    return _ResourceLoader.logger;
1564  }
1565  static setResourceLoader(loader) {
1566    _ResourceLoader.RESOURCE_LOADER = loader;
1567  }
1568  static loadStringResource(path) {
1569    return _ResourceLoader.RESOURCE_LOADER_$LI$().loadTextResource(path);
1570  }
1571  loadTextResource(path) {
1572    try {
1573      const input = _ResourceLoader.getClassLoader().getResourceAsStream(path);
1574      if (input == null) return null;
1575      const out = new java.io.ByteArrayOutputStream();
1576      const buf = ((s) => {
1577        let a = [];
1578        while (s-- > 0) a.push(0);
1579        return a;
1580      })(1024);
1581      let num;
1582      while ((num = input.read(buf, 0, 1024)) > 0) {
1583        out.write(buf, 0, num);
1584      }
1585      ;
1586      input.close();
1587      return new String(out.toByteArray());
1588    } catch (e) {
1589      if (_ResourceLoader.logger_$LI$().isLoggable(java.util.logging.Level.FINE)) _ResourceLoader.logger_$LI$().fine("problem loading resource: " + path);
1590      return null;
1591    }
1592  }
1593};
1594ResourceLoader["__class"] = "com.vzome.xml.ResourceLoader";
1595
1596// src/worker/legacy/from-java/java/io/File.ts
1597var File = class {
1598  constructor(parent, name) {
1599  }
1600  exists() {
1601    return false;
1602  }
1603  getAbsolutePath() {
1604    return null;
1605  }
1606  getName() {
1607    return null;
1608  }
1609  getParentFile() {
1610    return null;
1611  }
1612};
1613File["__class"] = "java.io.File";
1614
1615// src/worker/legacy/from-java/com/vzome/core/algebra/AlgebraicSeries.ts
1616var AlgebraicSeries = class {
1617  constructor(field, power) {
1618    if (this.series === void 0) {
1619      this.series = null;
1620    }
1621    let sequence = new java.util.ArrayList();
1622    sequence.add(0);
1623    let divisor = field.getUnitTerm(1);
1624    divisor = divisor["times$com_vzome_core_algebra_AlgebraicNumber"](divisor);
1625    for (let i = 0; i < power + 2; i++) {
1626      {
1627        sequence = field.recurrence(sequence);
1628      }
1629      ;
1630    }
1631    this.series = ((s) => {
1632      let a = [];
1633      while (s-- > 0) a.push(null);
1634      return a;
1635    })(sequence.size() + 1);
1636    this.series[0] = field.zero();
1637    let prevIndex = 0;
1638    for (let index = sequence.iterator(); index.hasNext(); ) {
1639      let integer = index.next();
1640      {
1641        const prev = this.series[prevIndex++];
1642        const step = field.getUnitTerm(integer).dividedBy(divisor);
1643        this.series[prevIndex] = prev["plus$com_vzome_core_algebra_AlgebraicNumber"](step);
1644      }
1645    }
1646  }
1647  nearestAlgebraicNumber(target) {
1648    const negative = target < 0;
1649    if (negative) target = -target;
1650    const positive = this.checkRange(0, this.series.length - 1, target);
1651    if (negative) return positive.negate();
1652    else return positive;
1653  }
1654  /*private*/
1655  checkRange(minIndex, maxIndex, target) {
1656    if (minIndex >= maxIndex) return this.series[maxIndex];
1657    else {
1658      const lowDiff = target - this.series[minIndex].evaluate();
1659      const highDiff = this.series[maxIndex].evaluate() - target;
1660      if (maxIndex === minIndex + 1) {
1661        return highDiff < lowDiff ? this.series[maxIndex] : this.series[minIndex];
1662      } else {
1663        const midIndex = Math.floor((maxIndex + minIndex) / 2 | 0) | 0;
1664        return highDiff < lowDiff ? this.checkRange(midIndex, maxIndex, target) : this.checkRange(minIndex, midIndex, target);
1665      }
1666    }
1667  }
1668  /**
1669   * 
1670   * @return {string}
1671   */
1672  toString() {
1673    let result = "";
1674    for (let index = 0; index < this.series.length; index++) {
1675      let algebraicNumber = this.series[index];
1676      {
1677        result += algebraicNumber.toString(AlgebraicField.DEFAULT_FORMAT) + ", ";
1678      }
1679    }
1680    return result;
1681  }
1682};
1683AlgebraicSeries["__class"] = "com.vzome.core.algebra.AlgebraicSeries";
1684
1685// src/worker/legacy/from-java/com/vzome/core/algebra/AbstractAlgebraicField.ts
1686var AbstractAlgebraicField = class _AbstractAlgebraicField {
1687  /* Default method injected from AlgebraicField */
1688  supportsSubfield(fieldName) {
1689    if (fieldName === this.getName()) return true;
1690    return fieldName === "golden" && this.getGoldenRatio() != null;
1691  }
1692  /**
1693   * The integers should be the same indices used by getUnitTerm().
1694   * Subclasses must override to usefully participate in the generation
1695   * of AlgebraicSeries.
1696   * @param {*} input
1697   * @return
1698   * @return {*}
1699   */
1700  recurrence(input) {
1701    return input;
1702  }
1703  normalize(factors) {
1704  }
1705  /**
1706   * 
1707   * @return {number}
1708   */
1709  getOrder() {
1710    return this.order;
1711  }
1712  /**
1713   * 
1714   * @return {number}
1715   */
1716  getNumIrrationals() {
1717    return this.order - 1;
1718  }
1719  /**
1720   * 
1721   * @return {boolean}
1722   */
1723  scale4dRoots() {
1724    return false;
1725  }
1726  /**
1727   * 
1728   * @return {boolean}
1729   */
1730  doubleFrameVectors() {
1731    return false;
1732  }
1733  /**
1734   * 
1735   * @param {string} name
1736   * @return {*}
1737   */
1738  getNumberByName(name) {
1739    switch (name) {
1740      case "zero":
1741        return this.zero();
1742      case "one":
1743        return this.one();
1744      case "phi":
1745      case "\u03C6":
1746        return this.getGoldenRatio();
1747      case "\u221A5":
1748      case "root5":
1749      case "sqrt5":
1750        {
1751          const n = this.getGoldenRatio();
1752          return n == null ? null : n["plus$com_vzome_core_algebra_AlgebraicNumber"](n)["minus$com_vzome_core_algebra_AlgebraicNumber"](this.one());
1753        }
1754        ;
1755      case "\u221A8":
1756      case "root8":
1757      case "sqrt8":
1758        {
1759          const n = this.getNumberByName("sqrt2");
1760          return n == null ? null : n["times$com_vzome_core_algebra_AlgebraicNumber"](this.createRational$long(2));
1761        }
1762        ;
1763      default:
1764        for (let format = AlgebraicField.DEFAULT_FORMAT; format <= AlgebraicField.EXPRESSION_FORMAT; format++) {
1765          {
1766            for (let i = 1; i < this.getOrder(); i++) {
1767              {
1768                if (this["getIrrational$int$int"](i, format) === name) {
1769                  return this.getUnitTerm(i);
1770                }
1771              }
1772              ;
1773            }
1774          }
1775          ;
1776        }
1777    }
1778    return null;
1779  }
1780  getIrrational$int(i) {
1781    return this["getIrrational$int$int"](i, AlgebraicField.DEFAULT_FORMAT);
1782  }
1783  static {
1784    this.SMALL_SERIES_THRESHOLD = 30;
1785  }
1786  constructor(name, order, factory) {
1787    if (this.name === void 0) {
1788      this.name = null;
1789    }
1790    if (this.order === void 0) {
1791      this.order = 0;
1792    }
1793    if (this.__hashCode === void 0) {
1794      this.__hashCode = null;
1795    }
1796    if (this.__one === void 0) {
1797      this.__one = null;
1798    }
1799    if (this.__zero === void 0) {
1800      this.__zero = null;
1801    }
1802    if (this.positivePowers === void 0) {
1803      this.positivePowers = null;
1804    }
1805    if (this.negativePowers === void 0) {
1806      this.negativePowers = null;
1807    }
1808    if (this.smallSeries === void 0) {
1809      this.smallSeries = null;
1810    }
1811    if (this.numberFactory === void 0) {
1812      this.numberFactory = null;
1813    }
1814    this.name = name;
1815    this.order = order;
1816    this.numberFactory = factory;
1817    this.__zero = this.numberFactory.createRational(this, 0, 1);
1818    this.__one = this.numberFactory.createRational(this, 1, 1);
1819    this.positivePowers = ((s) => {
1820      let a = [];
1821      while (s-- > 0) a.push(null);
1822      return a;
1823    })(order - 1);
1824    this.negativePowers = ((s) => {
1825      let a = [];
1826      while (s-- > 0) a.push(null);
1827      return a;
1828    })(order - 1);
1829  }
1830  /*private*/
1831  initSmallSeries() {
1832    if (this.smallSeries == null) {
1833      this.smallSeries = this.generateSeries(_AbstractAlgebraicField.SMALL_SERIES_THRESHOLD);
1834    }
1835  }
1836  nearestAlgebraicNumber(target) {
1837    this.initSmallSeries();
1838    return this.smallSeries.nearestAlgebraicNumber(target);
1839  }
1840  /**
1841   * 
1842   * @param {RealVector} target
1843   * @return {AlgebraicVector}
1844   */
1845  nearestAlgebraicVector(target) {
1846    this.initSmallSeries();
1847    return new AlgebraicVector(this.smallSeries.nearestAlgebraicNumber(target.x), this.smallSeries.nearestAlgebraicNumber(target.y), this.smallSeries.nearestAlgebraicNumber(target.z));
1848  }
1849  /**
1850   * 
1851   * @return {string}
1852   */
1853  getName() {
1854    return this.name;
1855  }
1856  /**
1857   * 
1858   * @return {string}
1859   */
1860  toString() {
1861    return this.getName();
1862  }
1863  /**
1864   * 
1865   * @return {number}
1866   */
1867  hashCode() {
1868    if (this.__hashCode == null) {
1869      const prime = 43;
1870      this.__hashCode = 7;
1871      const coefficients = this.getCoefficients();
1872      for (let i = 0; i < coefficients.length; i++) {
1873        {
1874          const coefficient = coefficients[i];
1875          this.__hashCode = prime * this.__hashCode + /* hashCode */
1876          ((o) => {
1877            if (o.hashCode) {
1878              return o.hashCode();
1879            } else {
1880              return o.toString().split("").reduce((prevHash, currVal) => (prevHash << 5) - prevHash + currVal.charCodeAt(0) | 0, 0);
1881            }
1882          })(coefficient);
1883        }
1884        ;
1885      }
1886    }
1887    return this.__hashCode;
1888  }
1889  /**
1890   * With the use of parameterized fields, it's possible for two fields
1891   * of different classes to be equal
1892   * or for two fields of the same class to not be equal.
1893   * For example RootTwoField equals SqrtField(2)
1894   * but SqrtField(2) does not equal SqrtField(3).
1895   * Similarly, PolygonField(4) equals SqrtField(2)
1896   * and PolygonField(6) equals SqrtField(3).
1897   * 
1898   * @param {*} obj
1899   * @return {boolean}
1900   */
1901  equals(obj) {
1902    if (this === obj) {
1903      return true;
1904    }
1905    if (obj == null) {
1906      return false;
1907    }
1908    if (!(obj != null && obj instanceof _AbstractAlgebraicField)) {
1909      return false;
1910    }
1911    const that = obj;
1912    if (this.getName() === that.getName()) {
1913      return true;
1914    }
1915    if (this.getOrder() !== that.getOrder()) {
1916      return false;
1917    }
1918    const thisCoefficients = this.getCoefficients();
1919    const thatCoefficients = that.getCoefficients();
1920    for (let i = 0; i < thisCoefficients.length; i++) {
1921      {
1922        if (thisCoefficients[i] - thatCoefficients[i] !== 0) {
1923          return false;
1924        }
1925      }
1926      ;
1927    }
1928    return true;
1929  }
1930  /**
1931   * This method is intended to allow subclasses to intercept a 4 element int array
1932   * representing the numerators and denominators of a pair of terms (units and phis)
1933   * from the golden field and remap them as needed for that field.
1934   * Otherwise, the terms are returned unchanged.
1935   * @param terms
1936   * @return
1937   * @param {long[]} pairs
1938   * @return {long[]}
1939   */
1940  convertGoldenNumberPairs(pairs) {
1941    if (pairs.length === 2 * this.order) return pairs;
1942    else {
1943      const newPairs = ((s) => {
1944        let a = [];
1945        while (s-- > 0) a.push(0);
1946        return a;
1947      })(2 * this.order);
1948      for (let i = 0; i < this.order; i++) {
1949        {
1950          newPairs[2 * i + 0] = i >= 2 ? 0 : pairs[2 * i + 0];
1951          newPairs[2 * i + 1] = i >= 2 ? 1 : pairs[2 * i + 1];
1952        }
1953        ;
1954      }
1955      return newPairs;
1956    }
1957  }
1958  createAlgebraicNumber$int_A(terms) {
1959    return this.numberFactory.createAlgebraicNumber(this, terms, 1);
1960  }
1961  /**
1962   * TODO: BigInteger.longValue() may silently lose precision here.
1963   * That's why it's deprecated.
1964   * I'm going to live with that possibility for now to avoid the overhead
1965   * of calling a BigInt version of convertGoldenNumberPairs().
1966   * @param {BigRational[]} trailingDivisorForm
1967   * @return {*}
1968   */
1969  createAlgebraicNumberFromTD(trailingDivisorForm) {
1970    const terms = trailingDivisorForm.length - 1;
1971    if (terms === 2 && this.getOrder() > 2 && this.getGoldenRatio() != null) {
1972      let pairs = ((s) => {
1973        let a = [];
1974        while (s-- > 0) a.push(0);
1975        return a;
1976      })(2 * terms);
1977      const divisor = trailingDivisorForm[terms].getNumerator().longValue();
1978      for (let i = 0; i < terms; i++) {
1979        {
1980          pairs[2 * i + 0] = trailingDivisorForm[i].getNumerator().longValue();
1981          pairs[2 * i + 1] = divisor;
1982        }
1983        ;
1984      }
1985      pairs = this.convertGoldenNumberPairs(pairs);
1986      return this.numberFactory.createAlgebraicNumberFromPairs(this, pairs);
1987    }
1988    return this.numberFactory.createAlgebraicNumberFromTD(this, trailingDivisorForm);
1989  }
1990  createAlgebraicNumber$int_A$int(numerators, denominator) {
1991    return this.numberFactory.createAlgebraicNumber(this, numerators, denominator);
1992  }
1993  createAlgebraicNumber$int$int$int$int(ones, irrat, denominator, scalePower) {
1994    const factors = ((s) => {
1995      let a = [];
1996      while (s-- > 0) a.push(0);
1997      return a;
1998    })(this.order);
1999    factors[0] = ones;
2000    factors[1] = irrat;
2001    for (let i = 2; i < factors.length; i++) {
2002      {
2003        factors[i] = 0;
2004      }
2005      ;
2006    }
2007    const result = this.numberFactory.createAlgebraicNumber(this, factors, denominator);
2008    if (scalePower !== 0) {
2009      const multiplier = this.createPower$int(scalePower);
2010      return result["times$com_vzome_core_algebra_AlgebraicNumber"](multiplier);
2011    } else return result;
2012  }
2013  /**
2014   * 
2015   * @param {number} ones
2016   * @param {number} irrat
2017   * @param {number} denominator
2018   * @param {number} scalePower
2019   * @return {*}
2020   */
2021  createAlgebraicNumber(ones, irrat, denominator, scalePower) {
2022    if ((typeof ones === "number" || ones === null) && (typeof irrat === "number" || irrat === null) && (typeof denominator === "number" || denominator === null) && (typeof scalePower === "number" || scalePower === null)) {
2023      return this.createAlgebraicNumber$int$int$int$int(ones, irrat, denominator, scalePower);
2024    } else if ((ones != null && ones instanceof Array && (ones.length == 0 || ones[0] == null || typeof ones[0] === "
2024number") || ones === null) && (typeof irrat === "number" || irrat === null) && denominator === void 0 && scalePower === void 0) {
2025      return this.createAlgebraicNumber$int_A$int(ones, irrat);
2026    } else if ((ones != null && ones instanceof Array && (ones.length == 0 || ones[0] == null || typeof ones[0] === "number") || ones === null) && irrat === void 0 && denominator === void 0 && scalePower === void 0) {
2027      return this.createAlgebraicNumber$int_A(ones);
2028    } else throw new Error("invalid overload");
2029  }
2030  /**
2031   * The golden ratio (and thus icosahedral symmetry and related tools)
2032   * can be generated by some fields even though it's not one of their irrational coefficients.
2033   * For example, SqrtField(5) and PolygonField(10) can both generate the golden ratio
2034   * so they can support icosa symmetry and related tools.
2035   * In some such cases, the resulting AlgebraicNumber
2036   * may have multiple terms and/or factors other than one.
2037   * 
2038   * @return {*} An AlgebraicNumber which evaluates to the golden ratio, or null if not possible in this field.
2039   */
2040  getGoldenRatio() {
2041    return null;
2042  }
2043  createPower$int(power) {
2044    return this.createPower$int$int(power, 1);
2045  }
2046  createPower$int$int(power, irr) {
2047    const one = this.one();
2048    if (power === 0 || irr === 0) return one;
2049    irr -= 1;
2050    if (power > 0) {
2051      if (this.positivePowers[irr] == null) this.positivePowers[irr] = new java.util.ArrayList(8);
2052      if (power >= this.positivePowers[irr].size()) {
2053        if (this.positivePowers[irr].isEmpty()) {
2054          this.positivePowers[irr].add(one);
2055          this.positivePowers[irr].add(this.getUnitTerm(irr + 1));
2056        }
2057        const size = this.positivePowers[irr].size();
2058        const irrat = this.positivePowers[irr].get(1);
2059        let last = this.positivePowers[irr].get(size - 1);
2060        for (let i = size; i <= power; i++) {
2061          {
2062            const next = last["times$com_vzome_core_algebra_AlgebraicNumber"](irrat);
2063            this.positivePowers[irr].add(next);
2064            last = next;
2065          }
2066          ;
2067        }
2068      }
2069      return this.positivePowers[irr].get(power);
2070    } else {
2071      power = -power;
2072      if (this.negativePowers[irr] == null) this.negativePowers[irr] = new java.util.ArrayList(8);
2073      if (power >= this.negativePowers[irr].size()) {
2074        if (this.negativePowers[irr].isEmpty()) {
2075          this.negativePowers[irr].add(one);
2076          this.negativePowers[irr].add(this.getUnitTerm(irr + 1).reciprocal());
2077        }
2078        const size = this.negativePowers[irr].size();
2079        const irrat = this.negativePowers[irr].get(1);
2080        let last = this.negativePowers[irr].get(size - 1);
2081        for (let i = size; i <= power; i++) {
2082          {
2083            const next = last["times$com_vzome_core_algebra_AlgebraicNumber"](irrat);
2084            this.negativePowers[irr].add(next);
2085            last = next;
2086          }
2087          ;
2088        }
2089      }
2090      return this.negativePowers[irr].get(power);
2091    }
2092  }
2093  /**
2094   * 
2095   * @param {number} power
2096   * @param {number} irr
2097   * @return {*}
2098   */
2099  createPower(power, irr) {
2100    if ((typeof power === "number" || power === null) && (typeof irr === "number" || irr === null)) {
2101      return this.createPower$int$int(power, irr);
2102    } else if ((typeof power === "number" || power === null) && irr === void 0) {
2103      return this.createPower$int(power);
2104    } else throw new Error("invalid overload");
2105  }
2106  createRational$long(wholeNumber) {
2107    return this.numberFactory.createRational(this, wholeNumber, 1);
2108  }
2109  createRational$long$long(numerator, denominator) {
2110    return this.numberFactory.createRational(this, numerator, denominator);
2111  }
2112  /**
2113   * @param {number} numerator
2114   * @param {number} denominator
2115   * @return {*} AlgebraicNumber
2116   */
2117  createRational(numerator, denominator) {
2118    if ((typeof numerator === "number" || numerator === null) && (typeof denominator === "number" || denominator === null)) {
2119      return this.createRational$long$long(numerator, denominator);
2120    } else if ((typeof numerator === "number" || numerator === null) && denominator === void 0) {
2121      return this.createRational$long(numerator);
2122    } else throw new Error("invalid overload");
2123  }
2124  /**
2125   * @param {number} n specifies the ordinal of the term in the AlgebraicNumber which will be set to one.
2126   * When {@code n == 0}, the result is the same as {@code createRational(1)}.
2127   * When {@code n == 1}, the result is the same as {@code createPower(1)}.
2128   * When {@code n < 0}, the result will be {@code zero()}.
2129   * When {@code n >= getOrder()}, an IndexOutOfBoundsException will be thrown.
2130   * @return {*} an AlgebraicNumber with the factor specified by {@code n} set to one.
2131   */
2132  getUnitTerm(n) {
2133    if (n < 0) {
2134      return this.zero();
2135    }
2136    const numerators = ((s) => {
2137      let a = [];
2138      while (s-- > 0) a.push(0);
2139      return a;
2140    })(this.getOrder());
2141    for (let i = 0; i < numerators.length; i++) {
2142      {
2143        numerators[i] = 0;
2144      }
2145      ;
2146    }
2147    numerators[n] = 1;
2148    return this.numberFactory.createAlgebraicNumber(this, numerators, 1);
2149  }
2150  /**
2151   * Drop one coordinate from the 4D vector. If wFirst (the usual), then drop
2152   * the first coordinate, taking the "imaginary part" of the vector. If
2153   * !wFirst (for old VEF import, etc.), drop the last coordinate.
2154   * 
2155   * @param {AlgebraicVector} source
2156   * @param {boolean} wFirst
2157   * @return
2158   * @return {AlgebraicVector}
2159   */
2160  projectTo3d(source, wFirst) {
2161    if (source.dimension() === 3) return source;
2162    else {
2163      const result = this.origin(3);
2164      for (let i = 0; i < 3; i++) {
2165        result.setComponent(i, source.getComponent(wFirst ? i + 1 : i));
2166      }
2167      return result;
2168    }
2169  }
2170  /**
2171   * 
2172   * @param {number} dims
2173   * @return {AlgebraicVector}
2174   */
2175  origin(dims) {
2176    return new AlgebraicVector(this, dims);
2177  }
2178  /**
2179   * 
2180   * @param {number} dims
2181   * @param {number} axis
2182   * @return {AlgebraicVector}
2183   */
2184  basisVector(dims, axis) {
2185    const result = this.origin(dims);
2186    return result.setComponent(axis, this.one());
2187  }
2188  reciprocal(fieldElement) {
2189    const length = fieldElement.length;
2190    const representation = (function(dims) {
2191      let allocate = function(dims2) {
2192        if (dims2.length === 0) {
2193          return null;
2194        } else {
2195          let array = [];
2196          for (let i = 0; i < dims2[0]; i++) {
2197            array.push(allocate(dims2.slice(1)));
2198          }
2199          return array;
2200        }
2201      };
2202      return allocate(dims);
2203    })([length, length]);
2204    let isZero = true;
2205    for (let i = 0; i < length; i++) {
2206      {
2207        isZero = isZero && fieldElement[i].isZero();
2208        representation[0][i] = fieldElement[i];
2209      }
2210      ;
2211    }
2212    if (isZero) throw new java.lang.RuntimeException("Denominator is zero");
2213    for (let j = 1; j < length; j++) {
2214      {
2215        const column = this.scaleBy(fieldElement, j);
2216        java.lang.System.arraycopy(column, 0, representation[j], 0, length);
2217      }
2218      ;
2219    }
2220    const reciprocal = (function(dims) {
2221      let allocate = function(dims2) {
2222        if (dims2.length === 0) {
2223          return null;
2224        } else {
2225          let array = [];
2226          for (let i = 0; i < dims2[0]; i++) {
2227            array.push(allocate(dims2.slice(1)));
2228          }
2229          return array;
2230        }
2231      };
2232      return allocate(dims);
2233    })([length, length]);
2234    for (let j = 0; j < length; j++) {
2235      {
2236        for (let i = 0; i < length; i++) {
2237          {
2238            reciprocal[j][i] = i === j ? this.numberFactory.one() : this.numberFactory.zero();
2239          }
2240          ;
2241        }
2242      }
2243      ;
2244    }
2245    const rank = Fields.gaussJordanReduction$com_vzome_core_algebra_Fields_Element_A_A$com_vzome_core_algebra_Fields_Element_A_A(representation, reciprocal);
2246    const reciprocalFactors = ((s) => {
2247      let a = [];
2248      while (s-- > 0) a.push(null);
2249      return a;
2250    })(length);
2251    java.lang.System.arraycopy(reciprocal[0], 0, reciprocalFactors, 0, length);
2252    return rank === length ? reciprocalFactors : this.onReciprocalRankDeficient(rank, reciprocal, reciprocalFactors);
2253  }
2254  /**
2255   * Subclasses can overloading this method to handle special cases. (e.g. SqrtField of a perfect square)
2256   * @param {number} rank
2257   * @param {BigRational[][]} reciprocal
2258   * @param {BigRational[]} reciprocalFactors
2259   * @throws IllegalStateException
2260   * @return {BigRational[]}
2261   */
2262  onReciprocalRankDeficient(rank, reciprocal, reciprocalFactors) {
2263    const msg = this.getName() + " expects reciprocal matrix to be full rank (" + reciprocal.length + "), but it is " + rank + ".";
2264    console.error(msg);
2265    throw new java.lang.IllegalStateException(msg);
2266  }
2267  /**
2268   * 
2269   * @return {*}
2270   */
2271  zero() {
2272    return this.__zero;
2273  }
2274  /**
2275   * 
2276   * @return {*}
2277   */
2278  one() {
2279    return this.__one;
2280  }
2281  /**
2282   * 
2283   * @param {int[][]} nums is an array of integer arrays: One array of coordinate terms per dimension.
2284   * Initially, this is designed to simplify migration of order 2 golden directions
2285   * to new fields of higher order having golden subfields as their first two factors.
2286   * {@code
2287   * field.createVector( new int[]  {  0,1,2,3,   4,5,6,7,   8,9,0,1  } );   // older code like this...
2288   * field.createVector( new int[][]{ {0,1,2,3}, {4,5,6,7}, {8,9,0,1} } );   // should be replaced by this.
2289   * }
2290   * The older code shown in the first example requires an order 2 field.
2291   * The second example will work with any field of order 2 or greater.
2292   * This new overload has the advantage that the internal arrays representing the individual dimensions are more clearly delineated and controlled.
2293   * Inner arrays require an even number of elements since they represent a sequence of numerator/denominator pairs.
2294   * 
2295   * createVector is currently limited to int valued vectors, not long, and definitely not BigInteger
2296   * In most cases, this is adequate, but in the case where it's called by XmlSaveFormat.parseAlgebraicObject(),
2297   * it seems possible that a value larger than Integer.MAX_VALUE could be saved to the XML which could not subsequently be parsed.
2298   * TODO: Consider refactoring createVector to use long[][] instead of int[][] if this becomes an issue.
2299   * 
2300   * @return {AlgebraicVector} an AlgebraicVector
2301   */
2302  createVector(nums) {
2303    const dims = nums.length;
2304    const coords = ((s) => {
2305      let a = [];
2306      while (s-- > 0) a.push(null);
2307      return a;
2308    })(dims);
2309    for (let c = 0; c < coords.length; c++) {
2310      {
2311        const coordLength = nums[c].length;
2312        if (coordLength % 2 !== 0) {
2313          throw new java.lang.IllegalStateException("Vector dimension " + c + " has " + coordLength + " components. An even number is required.");
2314        }
2315        const nTerms = coordLength / 2 | 0;
2316        if (nTerms > this.getOrder()) {
2317          throw new java.lang.IllegalStateException("Vector dimension " + c + " has " + (coordLength / 2 | 0) + " terms. Each dimension of the " + this.getName() + " field is limited to " + this.getOrder() + " terms. Each term consists of a numerator and a denominator.");
2318        }
2319        let pairs = ((s) => {
2320          let a = [];
2321          while (s-- > 0) a.push(0);
2322          return a;
2323        })(nums[c].length);
2324        for (let i = 0; i < pairs.length; i++) {
2325          {
2326            pairs[i] = nums[c][i];
2327          }
2328          ;
2329        }
2330        if (pairs.length === 4 && this.getOrder() > 2 && this.getGoldenRatio() != null) {
2331          pairs = this.convertGoldenNumberPairs(pairs);
2332        }
2333        coords[c] = this.numberFactory.createAlgebraicNumberFromPairs(this, pairs);
2334      }
2335      ;
2336    }
2337    return new AlgebraicVector(coords);
2338  }
2339  createVectorFromTDs(nums) {
2340    const dims = nums.length;
2341    const coords = ((s) => {
2342      let a = [];
2343      while (s-- > 0) a.push(null);
2344      return a;
2345    })(dims);
2346    for (let c = 0; c < coords.length; c++) {
2347      {
2348        coords[c] = this.createAlgebraicNumberFromTD(nums[c]);
2349      }
2350      ;
2351    }
2352    return new AlgebraicVector(coords);
2353  }
2354  /**
2355   * Generates an AlgebraicVector with all AlgebraicNumber terms being integers (having unit denominators).
2356   * Contrast this with {@code createVector(int[][] nums)} which requires all denominators to be specified.
2357   * @param {int[][]} nums is a 2 dimensional integer array. The length of nums becomes the number of dimensions in the resulting AlgebraicVector.
2358   * For example, {@code (new PentagonField()).createIntegerVector( new int[][]{ {0,-1}, {2,3}, {4,5} } ); }
2359   * generates the 3 dimensional vector (-φ, 2 +3φ, 4 +5φ) having all integer terms.
2360   * @return {AlgebraicVector} an AlgebraicVector
2361   */
2362  createIntegerVector(nums) {
2363    const dims = nums.length;
2364    const result = this.origin(dims);
2365    for (let dim = 0; dim < dims; dim++) {
2366      {
2367        result.setComponent(dim, this.createAlgebraicNumber$int_A(nums[dim]));
2368      }
2369      ;
2370    }
2371    return result;
2372  }
2373  /**
2374   * Create a 3x3 square matrix from integer data.
2375   * TODO: Generalize this method to create a matrix with dimensions matching the dimensions of the data array
2376   * Sample input data for an order-4 field:
2377   * {{{7,5,0,1,-4,5,0,1},{-2,5,0,1,4,5,0,1},{0,1,-8,5,0,1,6,5}},
2378   * {{-2,5,0,1,4,5,0,1},{7,5,0,1,-4,5,0,1},{0,1,8,5,0,1,-6,5}},
2379   * {{0,1,-8,5,0,1,6,5},{0,1,8,5,0,1,-6,5},{-9,5,0,1,8,5,0,1}}}
2380   * @param field
2381   * @param {int[][][]} data integer coordinates, in row-major order, complete with denominators.
2382   * @return
2383   * @return {AlgebraicMatrix}
2384   */
2385  createMatrix(data) {
2386    const col1 = this.createVector([data[0][0], data[1][0], data[2][0]]);
2387    const col2 = this.createVector([data[0][1], data[1][1], data[2][1]]);
2388    const col3 = this.createVector([data[0][2], data[1][2], data[2][2]]);
2389    return new AlgebraicMatrix(col1, col2, col3);
2390  }
2391  /**
2392   * 
2393   * @param {java.lang.StringBuffer} buf
2394   * @param {BigRational[]} factors
2395   * @param {number} format must be one of the following values.
2396   * The result is formatted as follows:
2397   * <br>
2398   * {@code DEFAULT_FORMAT    // 4 + 3φ}<br>
2399   * {@code EXPRESSION_FORMAT // 4 +3*phi}<br>
2400   * {@code ZOMIC_FORMAT      // 4 3}<br>
2401   * {@code VEF_FORMAT        // (3,4)}
2402   * {@code MATHML_FORMAT     // Use getMathML()}
2403   * {@code MATH_FORMAT       // Originally used in JavaScript parts panel, not in Java}
2404   */
2405  getNumberExpression(buf, factors, format) {
2406    switch (format) {
2407      case 2:
2408        for (let i = 0; i < factors.length; i++) {
2409          {
2410            if (i > 0) buf.append(" ");
2411            buf.append(factors[i].toString());
2412          }
2413          ;
2414        }
2415        break;
2416      case 3:
2417        buf.append("(");
2418        for (let i = factors.length; i > 0; i--) {
2419          {
2420            buf.append(factors[i - 1].toString());
2421            if (i > 1) buf.append(",");
2422          }
2423          ;
2424        }
2425        buf.append(")");
2426        break;
2427      case 4:
2428        buf.append(this.getMathML(factors));
2429        break;
2430      default:
2431        let first = 0;
2432        for (let i = 0; i < factors.length; i++) {
2433          {
2434            let factor = factors[i];
2435            if (factor.isZero()) {
2436              ++first;
2437              continue;
2438            }
2439            if (i > first) {
2440              buf.append(" ");
2441            }
2442            if (factor.isNegative()) {
2443              factor = factor.negate();
2444              buf.append("-");
2445            } else if (i > first) {
2446              buf.append("+");
2447            }
2448            if (i === 0) buf.append(factor.toString());
2449            else {
2450              if (!factor.isOne()) {
2451                buf.append(factor.toString());
2452                if (format === AlgebraicField.EXPRESSION_FORMAT) buf.append("*");
2453              }
2454              const fmt = format === AlgebraicField.EXPRESSION_FORMAT ? AlgebraicField.EXPRESSION_FORMAT : AlgebraicField.DEFAULT_FORMAT;
2455              const multiplier = this["getIrrational$int$int"](i, fmt);
2456              buf.append(multiplier);
2457            }
2458          }
2459          ;
2460        }
2461        if (first === factors.length) buf.append("0");
2462        break;
2463    }
2464  }
2465  /**
2466   * 
2467   * @param {string} val
2468   * @return {*}
2469   */
2470  parseLegacyNumber(val) {
2471    throw new java.lang.IllegalStateException("This field does not support vZome 2.x files.");
2472  }
2473  /**
2474   * 
2475   * @param {string} string
2476   * @para
2476m {boolean} isRational
2477   * @return {*}
2478   */
2479  parseVefNumber(string, isRational) {
2480    const fractions = ((s) => {
2481      let a = [];
2482      while (s-- > 0) a.push(null);
2483      return a;
2484    })(this.getOrder());
2485    for (let i = 0; i < this.getOrder(); i++) {
2486      {
2487        fractions[i] = "0/1";
2488      }
2489      ;
2490    }
2491    if (!isRational && /* startsWith */
2492    ((str, searchString, position = 0) => str.substr(position, searchString.length) === searchString)(string, "(") && /* endsWith */
2493    ((str, searchString) => {
2494      let pos = str.length - searchString.length;
2495      let lastIndex = str.indexOf(searchString, pos);
2496      return lastIndex !== -1 && lastIndex === pos;
2497    })(string, ")")) {
2498      const tokens = new java.util.StringTokenizer(string.substring(1, string.length - 1), ",");
2499      const numStack = new java.util.Stack();
2500      const denomStack = new java.util.Stack();
2501      while (tokens.hasMoreTokens()) {
2502        {
2503          if (numStack.size() >= this.getOrder()) {
2504            throw new java.lang.RuntimeException('VEF format error: "' + string + '" has too many factors for ' + this.getName() + " field");
2505          }
2506          const parts = tokens.nextToken().split("/");
2507          numStack.push(parts[0]);
2508          denomStack.push(parts.length > 1 ? parts[1] : "1");
2509        }
2510      }
2511      ;
2512      let i = 0;
2513      while (!numStack.empty()) {
2514        {
2515          fractions[i++] = numStack.pop() + "/" + denomStack.pop();
2516        }
2517      }
2518      ;
2519      if (i === 2 && this.getOrder() > 2 && this.getGoldenRatio() != null) {
2520        const fractionParts = [fractions[0].split("/"), fractions[1].split("/")];
2521        let pairs = [javaemul.internal.LongHelper.parseLong(fractionParts[0][0]), javaemul.internal.LongHelper.parseLong(fractionParts[0][1]), javaemul.internal.LongHelper.parseLong(fractionParts[1][0]), javaemul.internal.LongHelper.parseLong(fractionParts[1][1])];
2522        pairs = this.convertGoldenNumberPairs([pairs[0], pairs[1], pairs[2], pairs[3]]);
2523        return this.numberFactory.createAlgebraicNumberFromPairs(this, pairs);
2524      }
2525    } else {
2526      const parts = string.split("/");
2527      fractions[0] = parts[0] + "/" + (parts.length > 1 ? parts[1] : "1");
2528    }
2529    return this.parseNumberStrs(fractions);
2530  }
2531  parseNumber$java_lang_String(nums) {
2532    const tokens = new java.util.StringTokenizer(nums, " ");
2533    return this.parseNumber$java_util_StringTokenizer(tokens);
2534  }
2535  /**
2536   * 
2537   * @param {string} nums
2538   * @return {*}
2539   */
2540  parseNumber(nums) {
2541    if (typeof nums === "string" || nums === null) {
2542      return this.parseNumber$java_lang_String(nums);
2543    } else if (nums != null && nums instanceof java.util.StringTokenizer || nums === null) {
2544      return this.parseNumber$java_util_StringTokenizer(nums);
2545    } else throw new Error("invalid overload");
2546  }
2547  /*private*/
2548  parseNumber$java_util_StringTokenizer(tokens) {
2549    const order = this.getOrder();
2550    const bigs = ((s) => {
2551      let a = [];
2552      while (s-- > 0) a.push(null);
2553      return a;
2554    })(order);
2555    for (let i = 0; i < order; i++) {
2556      {
2557        const digit = tokens.nextToken();
2558        bigs[i] = this.numberFactory.parseBigRational(digit);
2559      }
2560      ;
2561    }
2562    return this.numberFactory.createAlgebraicNumberFromBRs(this, bigs);
2563  }
2564  /*private*/
2565  parseNumberStrs(numStrs) {
2566    const order = this.getOrder();
2567    if (numStrs.length !== order) {
2568      throw new java.lang.IllegalStateException("Field order (" + order + ") does not match token count: " + numStrs.length);
2569    }
2570    const bigs = ((s) => {
2571      let a = [];
2572      while (s-- > 0) a.push(null);
2573      return a;
2574    })(order);
2575    for (let i = 0; i < order; i++) {
2576      {
2577        bigs[i] = this.numberFactory.parseBigRational(numStrs[i]);
2578      }
2579      ;
2580    }
2581    return this.numberFactory.createAlgebraicNumberFromBRs(this, bigs);
2582  }
2583  /**
2584   * 
2585   * @param {string} nums
2586   * @return {AlgebraicVector}
2587   */
2588  parseVector(nums) {
2589    const tokens = new java.util.StringTokenizer(nums, " ");
2590    const numToks = tokens.countTokens();
2591    if (numToks % this.getOrder() !== 0) throw new java.lang.IllegalStateException("Field order (" + this.getOrder() + ") does not divide token count: " + numToks + ", for '" + nums + "'");
2592    const dims = numToks / this.getOrder() | 0;
2593    const coords = ((s) => {
2594      let a = [];
2595      while (s-- > 0) a.push(null);
2596      return a;
2597    })(dims);
2598    for (let i = 0; i < dims; i++) {
2599      {
2600        coords[i] = this.parseNumber$java_util_StringTokenizer(tokens);
2601      }
2602      ;
2603    }
2604    return new AlgebraicVector(coords);
2605  }
2606  /**
2607   * 
2608   * @param {number} dims
2609   * @return {AlgebraicMatrix}
2610   */
2611  identityMatrix(dims) {
2612    const columns = ((s) => {
2613      let a = [];
2614      while (s-- > 0) a.push(null);
2615      return a;
2616    })(dims);
2617    for (let i = 0; i < columns.length; i++) {
2618      {
2619        columns[i] = this.basisVector(dims, i);
2620      }
2621      ;
2622    }
2623    return new AlgebraicMatrix(columns);
2624  }
2625  /**
2626   * @return {number} the number of independent multipliers in this field.
2627   * These are the primitive elements of the field.
2628   * The value should be less than or equal to getNumIrrationals.
2629   * It will be less whenever the irrationals are dependent.
2630   * For example, in the field for sqrt(phi), there is only one
2631   * multiplier, since the other irrational is just the square of that one.
2632   */
2633  getNumMultipliers() {
2634    return this.getNumIrrationals();
2635  }
2636  generateSeries(threshold) {
2637    const multiplier = this.createPower$int$int(1, this.getNumIrrationals());
2638    let cover = this.one();
2639    let power = 0;
2640    while (cover.evaluate() < threshold) {
2641      {
2642        cover = cover["times$com_vzome_core_algebra_AlgebraicNumber"](multiplier);
2643        ++power;
2644      }
2645    }
2646    ;
2647    return new AlgebraicSeries(this, power);
2648  }
2649  getMathML(factors) {
2650    const buf = new java.lang.StringBuffer();
2651    let first = 0;
2652    for (let i = 0; i < factors.length; i++) {
2653      {
2654        let factor = factors[i];
2655        if (factor.isZero()) {
2656          ++first;
2657          continue;
2658        }
2659        if (factor.isNegative()) {
2660          factor = factor.negate();
2661          buf.append("<mo>-</mo>");
2662        } else if (i > first) {
2663          buf.append("<mo>+</mo>");
2664        }
2665        if (i === 0) buf.append(factor.getMathML());
2666        else {
2667          if (!factor.isOne()) {
2668            buf.append(factor.getMathML());
2669          }
2670          const multiplier = this["getIrrational$int$int"](i, AlgebraicField.DEFAULT_FORMAT);
2671          buf.append("<mi>");
2672          buf.append(multiplier);
2673          buf.append("</mi>");
2674        }
2675      }
2676      ;
2677    }
2678    if (first === factors.length) return "<mn>0</mn>";
2679    else if (factors.length - first > 1) return "<mrow>" + buf.toString() + "</mrow>";
2680    else return buf.toString();
2681  }
2682  /**
2683   * 
2684   * @param {string} script
2685   * @param {string} language
2686   * @param {Point} offset
2687   * @param {*} symmetry
2688   * @param {*} effects
2689   */
2690  interpretScript(script, language, offset, symmetry, effects) {
2691    throw new Error("Scripts are only supported in the golden field.");
2692  }
2693};
2694AbstractAlgebraicField["__class"] = "com.vzome.core.algebra.AbstractAlgebraicField";
2695AbstractAlgebraicField["__interfaces"] = ["com.vzome.core.algebra.AlgebraicField"];
2696
2697// src/worker/legacy/from-java/com/vzome/core/algebra/ParameterizedField.ts
2698var ParameterizedField = class _ParameterizedField extends AbstractAlgebraicField {
2699  constructor(name, order, factory) {
2700    super(name, order, factory);
2701    if (this.coefficients === void 0) {
2702      this.coefficients = null;
2703    }
2704    if (this.multiplicationTensor === void 0) {
2705      this.multiplicationTensor = null;
2706    }
2707    if (this.irrationalLabels === void 0) {
2708      this.irrationalLabels = null;
2709    }
2710    this.normalizer = (field, factors) => {
2711      return _ParameterizedField.doNothing(field, factors);
2712    };
2713    this.coefficients = ((s) => {
2714      let a = [];
2715      while (s-- > 0) a.push(0);
2716      return a;
2717    })(order);
2718    this.multiplicationTensor = (function(dims) {
2719      let allocate = function(dims2) {
2720        if (dims2.length === 0) {
2721          return 0;
2722        } else {
2723          let array = [];
2724          for (let i = 0; i < dims2[0]; i++) {
2725            array.push(allocate(dims2.slice(1)));
2726          }
2727          return array;
2728        }
2729      };
2730      return allocate(dims);
2731    })([order, order, order]);
2732    this.irrationalLabels = (function(dims) {
2733      let allocate = function(dims2) {
2734        if (dims2.length === 0) {
2735          return null;
2736        } else {
2737          let array = [];
2738          for (let i = 0; i < dims2[0]; i++) {
2739            array.push(allocate(dims2.slice(1)));
2740          }
2741          return array;
2742        }
2743      };
2744      return allocate(dims);
2745    })([order, 2]);
2746    this.irrationalLabels[0] = [" ", " "];
2747  }
2748  /**
2749   * doNothing is the default normalizer method.
2750   * @param {BigRational[]} factors
2751   * @param {*} field
2752   */
2753  static doNothing(field, factors) {
2754  }
2755  /**
2756   * 
2757   * @param {BigRational[]} factors
2758   */
2759  normalize(factors) {
2760    ((target) => typeof target === "function" ? target(this, factors) : target.accept(this, factors))(this.normalizer);
2761  }
2762  initialize() {
2763    this.initializeNormalizer();
2764    this.initializeMultiplicationTensor();
2765    this.initializeCoefficients();
2766    this.initializeLabels();
2767  }
2768  initializeNormalizer() {
2769    this.normalizer = (field, factors) => {
2770      return _ParameterizedField.doNothing(field, factors);
2771    };
2772  }
2773  /**
2774   * 
2775   * @param {BigRational[]} v1
2776   * @param {BigRational[]} v2
2777   * @return {BigRational[]}
2778   */
2779  multiply(v1, v2) {
2780    const order = this.getOrder();
2781    const result = ((s) => {
2782      let a = [];
2783      while (s-- > 0) a.push(null);
2784      return a;
2785    })(order);
2786    for (let i = 0; i < order; i++) {
2787      {
2788        result[i] = this.numberFactory.zero();
2789        for (let j = 0; j < order; j++) {
2790          {
2791            for (let k = 0; k < order; k++) {
2792              {
2793                const multiplier = this.multiplicationTensor[i][j][k];
2794                if (multiplier !== 0) {
2795                  let product = v1[j].times(v2[k]);
2796                  if (multiplier !== 1) {
2797                    product = product.timesInt(multiplier);
2798                  }
2799                  result[i] = result[i].plus(product);
2800                }
2801              }
2802              ;
2803            }
2804          }
2805          ;
2806        }
2807      }
2808      ;
2809    }
2810    return result;
2811  }
2812  /**
2813   * 
2814   * @param {BigRational[]} factors
2815   * @param {number} whichIrrational
2816   * @return {BigRational[]}
2817   */
2818  scaleBy(factors, whichIrrational) {
2819    if (whichIrrational === 0) {
2820      return factors;
2821    }
2822    const order = this.getOrder();
2823    const result = ((s) => {
2824      let a = [];
2825      while (s-- > 0) a.push(null);
2826      return a;
2827    })(order);
2828    for (let i = 0; i < order; i++) {
2829      {
2830        result[i] = this.numberFactory.zero();
2831        for (let j = 0; j < order; j++) {
2832          {
2833            const multiplier = this.multiplicationTensor[i][j][whichIrrational];
2834            if (multiplier !== 0) {
2835              if (multiplier === 1) {
2836                result[i] = result[i].plus(factors[j]);
2837              } else {
2838                result[i] = result[i].plus(factors[j].timesInt(multiplier));
2839              }
2840            }
2841          }
2842          ;
2843        }
2844      }
2845      ;
2846    }
2847    this.normalize(result);
2848    return result;
2849  }
2850  /**
2851   * 
2852   * @param {BigRational[]} factors
2853   * @return {number}
2854   */
2855  evaluateNumber(factors) {
2856    let result = 0;
2857    const order = this.getOrder();
2858    for (let i = 0; i < order; i++) {
2859      {
2860        result += factors[i].evaluate() * this.coefficients[i];
2861      }
2862      ;
2863    }
2864    return result;
2865  }
2866  getIrrational$int$int(i, format) {
2867    return this.irrationalLabels[i][format];
2868  }
2869  /**
2870   * 
2871   * @param {number} i
2872   * @param {number} format
2873   * @return {string}
2874   */
2875  getIrrational(i, format) {
2876    if ((typeof i === "number" || i === null) && (typeof format === "number" || format === null)) {
2877      return this.getIrrational$int$int(i, format);
2878    } else if ((typeof i === "number" || i === null) && format === void 0) {
2879      return this.getIrrational$int(i);
2880    } else throw new Error("invalid overload");
2881  }
2882  getCoefficient(i) {
2883    return this.coefficients[i];
2884  }
2885};
2886ParameterizedField["__class"] = "com.vzome.core.algebra.ParameterizedField";
2887ParameterizedField["__interfaces"] = ["com.vzome.core.algebra.AlgebraicField"];
2888
2889// src/worker/legacy/from-java/com/vzome/core/algebra/PolygonField.ts
2890var PolygonField = class _PolygonField extends ParameterizedField {
2891  static {
2892    this.PI = 3.141592653589793;
2893  }
2894  /**
2895   * 
2896   * @param {number} nSides
2897   * @return {double[]} the coefficients of a PolygonField given the same parameter.
2898   * This can be used to determine when two fields have compatible coefficients
2899   * without having to generate an instance of the class.
2900   */
2901  static getFieldCoefficients(nSides) {
2902    const order = _PolygonField.getOrder(nSides);
2903    const coefficients = ((s) => {
2904      let a = [];
2905      while (s-- > 0) a.push(0);
2906      return a;
2907    })(order);
2908    const diagLengths = _PolygonField.getDiagonalLengths(nSides);
2909    for (let i = 0; i < order; i++) {
2910      {
2911        coefficients[i] = diagLengths[i];
2912      }
2913      ;
2914    }
2915    return coefficients;
2916  }
2917  /**
2918   * 
2919   * @param {number} nSides
2920   * @return {double[]} an array with the unique lengths in increasing order
2921   * of the diagonals of a regular N-gon having a unit edge length.
2922   */
2923  static getDiagonalLengths(nSides) {
2924    const count = _PolygonField.diagonalCount(nSides);
2925    const diagLengths = ((s) => {
2926      let a = [];
2927      while (s-- > 0) a.push(0);
2928      return a;
2929    })(count);
2930    const unitLength = Math.sin(_PolygonField.PI / nSides);
2931    diagLengths[0] = 1;
2932    for (let i = 1; i < count; i++) {
2933      {
2934        diagLengths[i] = Math.sin((i + 1) * _PolygonField.PI / nSides) / unitLength;
2935      }
2936      ;
2937    }
2938    switch (nSides) {
2939      case 6:
2940        diagLengths[2] = 2;
2941        diagLengths[1] = Math.sqrt(3);
2942        break;
2943      case 5:
2944        diagLengths[1] = (1 + Math.sqrt(5)) / 2;
2945        break;
2946    }
2947    return diagLengths;
2948  }
2949  static {
2950    this.FIELD_PREFIX = "polygon";
2951  }
2952  static getOrder(nSides) {
2953    return _PolygonField.primaryDiagonalCount(nSides);
2954  }
2955  static diagonalCount(nSides) {
2956    return nSides / 2 | 0;
2957  }
2958  static primaryDiagonalCount(nSides) {
2959    return ((n) => n < 0 ? Math.ceil(n) : Math.floor(n))(_PolygonField.eulerTotient(2 * nSides) / 2) | 0;
2960  }
2961  static secondaryDiagonalCount(nSides) {
2962    return _PolygonField.diagonalCount(nSides) - _PolygonField.primaryDiagonalCount(nSides);
2963  }
2964  static eulerTotient(n) {
2965    let result = n;
2966    for (let i = 2; i * i <= n; i++) {
2967      {
2968        if (n % i === 0) result -= ((n2) => n2 < 0 ? Math.ceil(n2) : Math.floor(n2))(result / i);
2969        while (n % i === 0) {
2970          {
2971            n = ((n2) => n2 < 0 ? Math.ceil(n2) : Math.floor(n2))(n / i);
2972          }
2973        }
2974        ;
2975      }
2976      ;
2977    }
2978    if (n > 1) {
2979      result -= ((n2) => n2 < 0 ? Math.ceil(n2) : Math.floor(n2))(result / n);
2980    }
2981    return result;
2982  }
2983  static isPowerOfTwo(n) {
2984    return n !== 0 && (n & -n) === n;
2985  }
2986  isPrime(n) {
2987    return this.numberFactory.isPrime(n);
2988  }
2989  /*private*/
2990  distinctPrimeFactors(n) {
2991    const factors = new java.util.ArrayList();
2992    for (let prime = 2; prime <= n; prime = this.numberFactory.nextPrime(prime)) {
2993      {
2994        if (n % prime === 0) {
2995          factors.add(prime);
2996        }
2997        while (n % prime === 0) {
2998          {
2999            n = ((n2) => n2 < 0 ? Math.ceil(n2) : Math.floor(n2))(n / prime);
3000          }
3001        }
3002        ;
3003      }
3004      ;
3005    }
3006    return factors;
3007  }
3008  getNormalizedMultiplicationTensor(nSides) {
3009    const tensor = _PolygonField.getExtendedMultiplicationTensor(nSides);
3010    if (this.isPrime(nSides) || _PolygonField.isPowerOfTwo(nSides)) {
3011      return tensor;
3012    }
3013    const length = _PolygonField.primaryDiagonalCount(nSides);
3014    const result = (function(dims) {
3015      let allocate = function(dims2) {
3016        if (dims2.length === 0) {
3017          return 0;
3018        } else {
3019          let array = [];
3020          for (let i = 0; i < dims2[0]; i++) {
3021            array.push(allocate(dims2.slice(1)));
3022          }
3023          return array;
3024        }
3025      };
3026      return allocate(dims);
3027    })([length, length, length]);
3028    for (let i = 0; i < length; i++) {
3029      {
3030        for (let j = 0; j < length; j++) {
3031          {
3032            for (let k = 0; k < length; k++) {
3033              {
3034                result[i][j][k] = tensor[i][j][k];
3035              }
3036              ;
3037            }
3038          }
3039          ;
3040        }
3041      }
3042      ;
3043    }
3044    const normalizerMatrix = this.getNormalizerMatrix(nSides);
3045    let n = 0;
3046    for (let term = length; term < _PolygonField.diagonalCount(nSides); term++) {
3047      {
3048        for (let r = 0; r < length; r++) {
3049          {
3050            for (let c = 0; c < length; c++) {
3051              {
3052                const omit = tensor[term][r][c];
3053                if (omit !== 0) {
3054                  for (let t = 0; t < length; t++) {
3055                    {
3056                      const alt = normalizerMatrix[n][t];
3057                      if (alt !== 0) {
3058                        const adjust = omit * alt;
3059                        result[t][r][c] = result[t][r][c] + adjust | 0;
3060                      }
3061                    }
3062                    ;
3063                  }
3064                }
3065              }
3066              ;
3067            }
3068          }
3069          ;
3070        }
3071        n++;
3072      }
3073      ;
3074    }
3075    return result;
3076  }
3077  getNormalizerMatrix(nSides) {
3078    if (nSides < _PolygonField.MIN_SIDES) {
3079      throw new java.lang.IllegalArgumentException("nSides = " + nSides + " but must be greater than or equal to " + _PolygonField.MIN_SIDES);
3080    }
3081    const nSecondaryDiags = _PolygonField.secondaryDiagonalCount(nSides);
3082    if (nSecondaryDiags === 0) {
3083      return null;
3084    }
3085    const nPrimaryDiags = _PolygonField.primaryDiagonalCount(nSides);
3086    const nDiags = nPrimaryDiags + nSecondaryDiags;
3087    const primeFactors = this.distinctPrimeFactors(nSides);
3088    if (primeFactors.get(0) === 2) {
3089      primeFactors.remove(0);
3090    }
3091    let nEquations = 0;
3092    for (let index = primeFactors.iterator(); index.hasNext(); ) {
3093      let prime = index.next();
3094      {
3095        nEquations += nDiags / /* intValue */
3096        (prime | 0) | 0;
3097      }
3098    }
3099    const primaryDiags = (function(dims) {
3100      let allocate = function(dims2) {
3101        if (dims2.length === 0) {
3102          return null;
3103        } else {
3104          let array = [];
3105          for (let i = 0; i < dims2[0]; i++) {
3106            array.push(allocate(dims2.slice(1)));
3107          }
3108          return array;
3109        }
3110      };
3111      return allocate(dims);
3112    })([nEquations, nPrimaryDiags]);
3113    const secondaryDiags = (function(dims) {
3114      let allocate = function(dims2) {
3115        if (dims2.length === 0) {
3116          return null;
3117        } else {
3118          let array = [];
3119          for (let i = 0; i < dims2[0]; i++) {
3120            array.push(allocate(dims2.slice(1)));
3121          }
3122          return array;
3123        }
3124      };
3125      return allocate(dims);
3126    }
3126)([nEquations, nSecondaryDiags]);
3127    let equationRow = 0;
3128    for (let index = primeFactors.iterator(); index.hasNext(); ) {
3129      let factor = index.next();
3130      {
3131        const period = nSides / factor | 0;
3132        const steps = period / 2 | 0;
3133        const parity = period % 2;
3134        for (let step = 0; step < steps; step++) {
3135          {
3136            let n = step === 0 && parity === 0 ? 2 : 1;
3137            if (nSides % 2 === parity) {
3138              n *= -1;
3139            }
3140            const terms = ((s) => {
3141              let a = [];
3142              while (s-- > 0) a.push(0);
3143              return a;
3144            })(nDiags);
3145            terms[step] = 1;
3146            for (let mid = period - parity; mid < nDiags; mid += period) {
3147              {
3148                terms[mid + step + parity] = terms[mid - step] = n;
3149                n *= -1;
3150              }
3151              ;
3152            }
3153            primaryDiags[equationRow] = ((s) => {
3154              let a = [];
3155              while (s-- > 0) a.push(null);
3156              return a;
3157            })(nPrimaryDiags);
3158            secondaryDiags[equationRow] = ((s) => {
3159              let a = [];
3160              while (s-- > 0) a.push(null);
3161              return a;
3162            })(nSecondaryDiags);
3163            for (let t = 0; t < terms.length; t++) {
3164              {
3165                let term = terms[t];
3166                if (t < nSecondaryDiags) {
3167                  secondaryDiags[equationRow][t] = this.numberFactory.createBigRational(term, 1);
3168                } else {
3169                  term *= -1;
3170                  primaryDiags[equationRow][t - nSecondaryDiags] = this.numberFactory.createBigRational(term, 1);
3171                }
3172              }
3173              ;
3174            }
3175            equationRow++;
3176          }
3177          ;
3178        }
3179      }
3180    }
3181    const rank = Fields.gaussJordanReduction$com_vzome_core_algebra_Fields_Element_A_A$com_vzome_core_algebra_Fields_Element_A_A(secondaryDiags, primaryDiags);
3182    if (rank !== nSecondaryDiags) {
3183      throw new java.lang.IllegalStateException("System of equations has unexpected rank: " + rank);
3184    }
3185    for (let r = rank; r < primaryDiags.length; r++) {
3186      {
3187        for (let c = 0; c < primaryDiags[0].length; c++) {
3188          {
3189            if (!primaryDiags[r][c].isZero()) {
3190              throw new java.lang.IllegalStateException("System of equations is inconsistent. Rank = " + rank);
3191            }
3192          }
3193          ;
3194        }
3195      }
3196      ;
3197    }
3198    const results = (function(dims) {
3199      let allocate = function(dims2) {
3200        if (dims2.length === 0) {
3201          return 0;
3202        } else {
3203          let array = [];
3204          for (let i = 0; i < dims2[0]; i++) {
3205            array.push(allocate(dims2.slice(1)));
3206          }
3207          return array;
3208        }
3209      };
3210      return allocate(dims);
3211    })([rank, nPrimaryDiags]);
3212    for (let r = 0; r < rank; r++) {
3213      {
3214        for (let c = nPrimaryDiags - 1; c >= 0; c--) {
3215          {
3216            const bigTerm = primaryDiags[rank - 1 - r][nPrimaryDiags - 1 - c];
3217            results[r][c] = /* shortValue */
3218            javaemul.internal.DoubleHelper.valueOf(bigTerm.evaluate()) | 0;
3219          }
3220          ;
3221        }
3222      }
3223      ;
3224    }
3225    return results;
3226  }
3227  static getExtendedMultiplicationTensor(nSides) {
3228    const nDiags = _PolygonField.diagonalCount(nSides);
3229    const tensor = (function(dims) {
3230      let allocate = function(dims2) {
3231        if (dims2.length === 0) {
3232          return 0;
3233        } else {
3234          let array = [];
3235          for (let i = 0; i < dims2[0]; i++) {
3236            array.push(allocate(dims2.slice(1)));
3237          }
3238          return array;
3239        }
3240      };
3241      return allocate(dims);
3242    })([nDiags, nDiags, nDiags]);
3243    for (let i = 0; i < nDiags; i++) {
3244      {
3245        for (let j = 0; j < nDiags; j++) {
3246          {
3247            for (let k = 0; k < nDiags; k++) {
3248              {
3249                tensor[i][j][k] = 0;
3250              }
3251              ;
3252            }
3253          }
3254          ;
3255        }
3256      }
3257      ;
3258    }
3259    for (let layer = 0; layer < nDiags; layer++) {
3260      {
3261        const midWay = layer / 2 | 0;
3262        for (let bx = layer, by = 0; bx > midWay || bx === by; bx--, by++) {
3263          {
3264            for (let x = bx, y = by; x < nDiags && y < nDiags; x++, y++) {
3265              {
3266                tensor[layer][y][x] += 1;
3267                if (x !== y) {
3268                  tensor[layer][x][y] += 1;
3269                }
3270              }
3271              ;
3272            }
3273          }
3274          ;
3275        }
3276      }
3277      ;
3278    }
3279    const box = nSides - 2;
3280    const parity = (nSides + 1) % 2;
3281    for (let layer = 0; layer < nDiags - parity; layer++) {
3282      {
3283        const base = box - layer;
3284        for (let xb = base, yb = 0; xb >= 0; xb--, yb++) {
3285          {
3286            let x = xb;
3287            let y = yb;
3288            while (x < nDiags && y < nDiags) {
3289              {
3290                tensor[layer][y][x] += 1;
3291                x++;
3292                y++;
3293              }
3294            }
3295            ;
3296          }
3297          ;
3298        }
3299      }
3300      ;
3301    }
3302    return tensor;
3303  }
3304  static subscriptString(i) {
3305    return (
3306      /* replace */
3307      /* replace */
3308      /* replace */
3309      /* replace */
3310      /* replace */
3311      /* replace */
3312      /* replace */
3313      /* replace */
3314      /* replace */
3315      /* replace */
3316      /* replace */
3317      /* replace */
3318      /* toString */
3319      ("" + i).split("0").join("\u2080").split("1").join("\u2081").split("2").join("\u2082").split("3").join("\u2083").split("4").join("\u2084").split("5").join("\u2085").split("6").join("\u2086").split("7").join("\u2087").split("8").join("\u2088").split("9").join("\u2089").split("+").join("\u208A").split("-").join("\u208B")
3320    );
3321  }
3322  static {
3323    this.MIN_SIDES = 4;
3324  }
3325  constructor(name, polygonSides, factory) {
3326    if ((typeof name === "string" || name === null) && (typeof pol
3326ygonSides === "number" || polygonSides === null) && (factory != null && (factory.constructor != null && factory.constructor["__interfaces"] != null && factory.constructor["__interfaces"].indexOf("com.vzome.core.algebra.AlgebraicNumberFactory") >= 0) || factory === null)) {
3327      let __args = arguments;
3328      super(name, _PolygonField.getOrder(polygonSides), factory);
3329      if (this.__isEven === void 0) {
3330        this.__isEven = false;
3331      }
3332      if (this.goldenRatio === void 0) {
3333        this.goldenRatio = null;
3334      }
3335      if (this.__polygonSides === void 0) {
3336        this.__polygonSides = 0;
3337      }
3338      if (this.normalizerMatrix === void 0) {
3339        this.normalizerMatrix = null;
3340      }
3341      this.__polygonSides = polygonSides;
3342      this.validate();
3343      this.initialize();
3344      this.__isEven = polygonSides % 2 === 0;
3345      this.goldenRatio = this.getDiagonalRatio$int(5);
3346    } else if ((typeof name === "number" || name === null) && (polygonSides != null && (polygonSides.constructor != null && polygonSides.constructor["__interfaces"] != null && polygonSides.constructor["__interfaces"].indexOf("com.vzome.core.algebra.AlgebraicNumberFactory") >= 0) || polygonSides === null) && factory === void 0) {
3347      let __args = arguments;
3348      let polygonSides2 = __args[0];
3349      let factory2 = __args[1];
3350      {
3351        let __args2 = arguments;
3352        let name2 = _PolygonField.FIELD_PREFIX + __args2[1];
3353        super(name2, _PolygonField.getOrder(polygonSides2), factory2);
3354        if (this.__isEven === void 0) {
3355          this.__isEven = false;
3356        }
3357        if (this.goldenRatio === void 0) {
3358          this.goldenRatio = null;
3359        }
3360        if (this.__polygonSides === void 0) {
3361          this.__polygonSides = 0;
3362        }
3363        if (this.normalizerMatrix === void 0) {
3364          this.normalizerMatrix = null;
3365        }
3366        this.__polygonSides = polygonSides2;
3367        this.validate();
3368        this.initialize();
3369        this.__isEven = polygonSides2 % 2 === 0;
3370        this.goldenRatio = this.getDiagonalRatio$int(5);
3371      }
3372    } else throw new Error("invalid overload");
3373  }
3374  /**
3375   * 
3376   * u = units numerator
3377   * U = units denominator
3378   * p = phis numerator
3379   * P = phis denominator
3380   * ____ = 0,1
3381   * COMBO ... see comments inline below
3382   * Remapping the 4 element pairs array [u,U, p,P]
3383   * looks like this based on polygonSides:
3384   * 5  [  u, U,   p, P] // unchanged
3385   * 10  [ COMBO,  ____,   p, P    ... // the two units elements comb
3385ine all of the input pairs
3386   * 15  [  u, U,  -p,-P,   ____,   p, P    ...
3387   * 20  [  u, U,   ____,  -p,-P,   ____,   p, P    ...
3388   * 25  [  u, U,   ____,   ____,  -p,-P,   ____,   p, P    ...
3389   * 30  [  u, U,   ____,   ____,   ____,  -p,-P,   ____,   p, P    ...
3390   * 35  [  u, U,   ____,   ____,   ____,   ____,  -p,-P,   ____,   p, P    ...
3391   * 40  [  u, U,   ____,   ____,   ____,   ____,   ____,  -p,-P,   ____,   p, P    ...
3392   * 45  [  u, U,   ____,   ____,   ____,   ____,   ____,   ____,  -p,-P,   ____,   p, P    ...
3393   * index   0  1    2  3    4  5    6  7    8  9   10 11   12 13   14 15   16 17   18 19
3394   * @param {long[]} pairs
3395   * @return {long[]}
3396   */
3397  convertGoldenNumberPairs(pairs) {
3398    if (this.__polygonSides % 5 === 0 && pairs.length === 4 && this.getOrder() > 2) {
3399      const u = pairs[0];
3400      const U = pairs[1];
3401      const p = pairs[2];
3402      const P = pairs[3];
3403      const remapped = ((s) => {
3404        let a = [];
3405        while (s-- > 0) a.push(0);
3406        return a;
3407      })(2 * this.getOrder());
3408      for (let den = 1; den < remapped.length; den += 2) {
3409        {
3410          remapped[den] = 1;
3411        }
3412        ;
3413      }
3414      const i = (this.__polygonSides / 5 | 0) * 2;
3415      remapped[i - 4] = -p;
3416      remapped[i - 3] = P;
3417      remapped[i + 0] = p;
3418      remapped[i + 1] = P;
3419      if (this.__polygonSides === 10) {
3420        remapped[0] = _PolygonField.safeSubtract(u * P, U * p);
3421        remapped[1] = U * P;
3422      } else {
3423        remapped[0] = u;
3424        remapped[1] = U;
3425      }
3426      return remapped;
3427    }
3428    return pairs;
3429  }
3430  /**
3431   * @param {number} j
3432   * @param {number} k
3433   * @return {number} a long that equals j - k
3434   * @throws ArithmeticException if the subtraction causes an integer overflow
3435   */
3436  static safeSubtract(j, k) {
3437    const result = j - k;
3438    if (k > 0 && result >= j || k < 0 && result <= j) {
3439      throw new java.lang.ArithmeticException("Arithmetic Overflow: " + j + " - " + k + " = " + result + ". Result exceeds the size of a long.");
3440    }
3441    return result;
3442  }
3443  diagonalCount() {
3444    return _PolygonField.diagonalCount(this.polygonSides());
3445  }
3446  /**
3447   * 
3448   * @return {double[]}
3449   */
3450  getCoefficients() {
3451    return _PolygonField.getFieldCoefficients(this.polygonSides());
3452  }
3453  validate() {
3454    if (this.polygonSides() < _PolygonField.MIN_SIDES) {
3455      const msg = "polygon sides = " + this.polygonSides() + ". It must be at least " + _PolygonField.MIN_SIDES + ".";
3456      throw new java.lang.IllegalArgumentException(msg);
3457    }
3458  }
3459  /**
3460   * 
3461   */
3462  initializeLabels() {
3463    const nSides = this.polygonSides();
3464    if (this.irrationalLabels.length !== _PolygonField.diagonalCount(nSides)) {
3465      const unitLabels = this.irrationalLabels[0];
3466      this.irrationalLabels = (function(dims) {
3467        let allocate = function(dims2) {
3468          if (dims2.length === 0) {
3469            return null;
3470          } else {
3471            let array = [];
3472            for (let i = 0; i < dims2[0]; i++) {
3473              array.push(allocate(dims2.slice(1)));
3474            }
3475            return array;
3476          }
3477        };
3478        return allocate(dims);
3479      })([_PolygonField.diagonalCount(nSides), unitLabels.length]);
3480      this.irrationalLabels[0] = unitLabels;
3481    }
3482    switch (this.polygonSides()) {
3483      case 4:
3484        this.irrationalLabels[1] = ["\u221A2", "sqrtTwo"];
3485        break;
3486      case 5:
3487        this.irrationalLabels[1] = ["\u03C6", "phi"];
3488        break;
3489      case 6:
3490        this.irrationalLabels[1] = ["\u221A3", "sqrtThree"];
3491        this.irrationalLabels[2] = ["\u03B2", "beta"];
3492        break;
3493      case 7:
3494        this.irrationalLabels[1] = ["\u03C1", "rho"];
3495        this.irrationalLabels[2] = ["\u03C3", "sigma"];
3496        break;
3497      case 9:
3498        this.irrationalLabels[1] = ["\u03B1", "alpha"];
3499        this.irrationalLabels[2] = ["\u03B2", "beta"];
3500        this.irrationalLabels[3] = ["\u03B3", "gamma"];
3501        break;
3502      case 11:
3503        this.irrationalLabels[1] = ["\u03B8", "theta"];
3504        this.irrationalLabels[2] = ["\u03BA", "kappa"];
3505        this.irrationalLabels[3] = ["\u03BB", "lambda"];
3506        this.irrationalLabels[4] = ["\u03BC", "mu"];
3507        break;
3508      case 13:
3509        this.irrationalLabels[1] = ["\u03B1", "alpha"];
3510        this.irrationalLabels[2] = ["\u03B2", "beta"];
3511        this.irrationalLabels[3] = ["\u03B3", "gamma"];
3512        this.irrationalLabels[4] = ["\u03B4", "delta"];
3513        this.irrationalLabels[5] = ["\u03B5", "epsilon"];
3514        break;
3515      default:
3516        const alphabet = "abcdefghijklmnopqrstuvwxyz";
3517        const length = this.irrationalLabels.length;
3518        if (length - 1 <= alphabet.length) {
3519          for (let i = 1; i < length; i++) {
3520            {
3521              const name = alphabet.substring(i - 1, i);
3522              this.irrationalLabels[i] = [name, "d[" + i + "]"];
3523            }
3524            ;
3525          }
3526        } else {
3527          for (let i = 1; i < this.irrationalLabels.length; i++) {
3528            {
3529              this.irrationalLabels[i] = ["d" + _PolygonField.subscriptString(i), "d[" + i + "]"];
3530            }
3531            ;
3532          }
3533        }
3534        break;
3535    }
3536  }
3537  /**
3538   * getUnitTerm(n) expects n < getOrder().
3539   * This method handles normalized diagonal lengths
3540   * where getOrder() <= n < diagonalCount()
3541   * In these cases, the resulting AlgebraicNumber will not have just the nth term set to 1,
3542   * but rather, will have the normalized equivalent.
3543   * For example, since a normalized PolygonField(6) is of order 2, but diagonalCount() == 3,
3544   * PolygonField(6).getUnitTerm(2) would return an AlgebraicNumber with terms of {2,0} rather than {0,0,1}.
3545   * @param {number} n
3546   * @return {*}
3547   */
3548  getUnitDiagonal(n) {
3549    if (n >= this.getOrder() && n < this.diagonalCount()) {
3550      const numerators = ((s) => {
3551        let a = [];
3552        while (s-- > 0) a.push(0);
3553        return a;
3554      })(this.getOrder());
3555      const row = n - this.getOrder();
3556      for (let i = 0; i < numerators.length; i++) {
3557        {
3558          numerators[i] = this.normalizerMatrix[row][i];
3559        }
3560        ;
3561      }
3562      return this.numberFactory.createAlgebraicNumber(this, numerators, 1);
3563    }
3564    return super.getUnitTerm(n);
3565  }
3566  /**
3567   * 
3568   * @return {*}
3569   */
3570  getGoldenRatio() {
3571    return this.goldenRatio;
3572  }
3573  /**
3574   * 
3575   * @param {string} name
3576   * @return {*}
3577   */
3578  getNumberByName(name) {
3579    switch (name) {
3580      case "\u221A2":
3581      case "root2":
3582      case "sqrt2":
3583        return this.getRoot2();
3584      case "\u221A3":
3585      case "root3":
3586      case "sqrt3":
3587        return this.getRoot3();
3588      case "\u221A5":
3589      case "root5":
3590      case "sqrt5":
3591        return super.getNumberByName("root5");
3592      case "\u221A6":
3593      case "root6":
3594      case "sqrt6":
3595        return this.getRoot6();
3596      case "\u221A7":
3597      case "root7":
3598      case "sqrt7":
3599        return this.getRoot7();
3600      case "\u221A8":
3601      case "root8":
3602      case "sqrt8":
3603        return super.getNumberByName("root8");
3604      case "\u221A10":
3605      case "root10":
3606      case "sqrt10":
3607        return this.getRoot10();
3608      case "rho":
3609        return this.getDiagonalRatio$int(7);
3610      case "sigma":
3611        return this.getDiagonalRatio$int$int(7, 3);
3612      case "alpha":
3613        return this.getDiagonalRatio$int$int(this.__polygonSides % 9 === 0 ? 9 : 13, 2);
3614      case "beta":
3615        return this.getDiagonalRatio$int$int(this.__polygonSides % 9 === 0 ? 9 : 13, 3);
3616      case "gamma":
3617        return this.getDiagonalRatio$int$int(this.__polygonSides % 9 === 0 ? 9 : 13, 4);
3618      case "delta":
3619        return this.getDiagonalRatio$int$int(13, 5);
3620      case "epsilon":
3621        return this.getDiagonalRatio$int$int(13, 6);
3622      case "theta":
3623        return this.getDiagonalRatio$int$int(11, 2);
3624      case "kappa":
3625        return this.getDiagonalRatio$int$int(11, 3);
3626      case "lambda":
3627        return this.getDiagonalRatio$int$int(11, 4);
3628      case "mu":
3629        return this.getDiagonalRatio$int$int(11, 5);
3630    }
3631    return super.getNumberByName(name);
3632  }
3633  /*private*/
3634  getRoot2() {
3635    return this.getDiagonalRatio$int(4);
3636  }
3637  /*private*/
3638  getRoot3() {
3639    return this.getDiagonalRatio$int(6);
3640  }
3641  /*private*/
3642  getRoot6() {
3643    const r3 = this.getNumberByName("root3");
3644    if (r3 != null) {
3645      const r2 = this.getNumberByName("root2");
3646      return r2 == null ? null : r2["times$com_vzome_core_algebra_AlgebraicNumber"](r3);
3647    }
3648    return null;
3649  }
3650  /*private*/
3651  getRoot7() {
3652    if (this.__polygonSides % 14 === 0) {
3653      const n = this.__polygonSides / 14 | 0;
3654      const d0 = this.getUnitDiagonal(1 * n - 1).negate();
3655      const d1 = this.getUnitDiagonal(2 * n - 1);
3656      const d2 = this.getUnitDiagonal(3 * n - 1);
3657      const d3 = this.getUnitDiagonal(4 * n - 1);
3658      const d4 = this.getUnitDiagonal(5 * n - 1);
3659      const d5 = this.getUnitDiagonal(6 * n - 1);
3660      const cotA = d4.dividedBy(d1);
3661      const cotB = d2.dividedBy(d3);
3662      const cotC = d0.dividedBy(d5);
3663      return cotA["plus$com_vzome_core_algebra_AlgebraicNumber"](cotB)["plus$com_vzome_core_algebra_AlgebraicNumber"](cotC);
3664    }
3665    return null;
3666  }
3667  /*private*/
3668  getRoot10() {
3669    const r5 = this.getNumberByName("root5");
3670    if (r5 != null) {
3671      const r2 = this.getNumberByName("root2");
3672      return r2 == null ? null : r2["times$com_vzome_core_algebra_AlgebraicNumber"](r5);
3673    }
3674    return null;
3675  }
3676  /*private*/
3677  getDiagonalRatio$int(divisor) {
3678    return this.getDiagonalRatio$int$int(divisor, 2);
3679  }
3680  getDiagonalRatio$int$int(divisor, step) {
3681    if (this.__polygonSides % divisor === 0 && step > 1 && step * 2 <= this.__polygonSides) {
3682      const n = this.__polygonSides / divisor | 0;
3683      const denominator = this.getUnitDiagonal(n - 1);
3684      const numerator = this.getUnitDiagonal(step * n - 1);
3685      return numerator.dividedBy(denominator);
3686    }
3687    return null;
3688  }
3689  getDiagonalRatio(divisor, step) {
3690    if ((typeof divisor === "number" || divisor === null) && (typeof step === "number" || step === null)) {
3691      return this.getDiagonalRatio$int$int(divisor, step);
3692    } else if ((typeof divisor === "number" || divisor === null) && step === void 0) {
3693      return this.getDiagonalRatio$int(divisor);
3694    } else throw new Error("invalid overload");
3695  }
3696  /**
3697   * 
3698   */
3699  initializeCoefficients() {
3700    const temp = this.getCoefficients();
3701    for (let i = 0; i < this.coefficients.length; i++) {
3702      {
3703        this.coefficients[i] = temp[i];
3704      }
3705      ;
3706    }
3707  }
3708  /**
3709   * 
3710   */
3711  initializeMultiplicationTensor() {
3712    this.multiplicationTensor = this.getNormalizedMultiplicationTensor(this.polygonSides());
3713  }
3714  /**
3715   * 
3716   */
3717  initializeNormalizer() {
3718    this.normalizerMatrix = this.getNormalizerMatrix(this.polygonSides());
3719  }
3720  polygonSides() {
3721    return this.__polygonSides;
3722  }
3723  isEven() {
3724    return this.__isEven;
3725  }
3726  isOdd() {
3727    return !this.__isEven;
3728  }
3729};
3730PolygonField["__class"] = "com.vzome.core.algebra.PolygonField";
3731PolygonField["__interfaces"] = ["com.vzome.core.algebra.AlgebraicField"];
3732
3733// src/worker/legacy/from-java/com/vzome/core/math/symmetry/AntiprismSymmetry.ts
3734var AntiprismSymmetry = class extends AbstractSymmetry {
3735  constructor(field) {
3736    super(field.polygonSides() * 2, field, "blue", field.isEven() ? null : new AlgebraicMatrix(field.basisVector(3, AlgebraicVector.X), field.basisVector(3, AlgebraicVector.Y), field.basisVector(3, AlgebraicVector.Z).negate()));
3737    if (this.preferredAxis === void 0) {
3738      this.preferredAxis = null;
3739    }
3740    if (this.useShear === void 0) {
3741      this.useShear = false;
3742    }
3743    if (this.shearTransform === void 0) {
3744      this.shearTransform = null;
3745    }
3746    this.rotationMatrix = null;
3747    const nSides = field.polygonSides();
3748    let m10 = 0;
3749    let m11 = 1;
3750    this.useShear = field.isOdd();
3751    if (this.useShear) {
3752      m10 = field.getUnitDiagonal(field.diagonalCount() - 1).reciprocal().evaluate() / 2;
3753      m11 = Math.cos(Math.PI / (2 * nSides));
3754    }
3755    this.shearTransform = [new RealVector(1, m10, 0), new RealVector(0, m11, 0), new RealVector(0, 0, 1)];
3756  }
3757  /**
3758   * 
3759   * @return {PolygonField}
3760   */
3761  getField() {
3762    return super.getField();
3763  }
3764  /**
3765   * Called by the super constructor.
3766   */
3767  createInitialPermutations() {
3768    const nSides = this.getField().polygonSides();
3769    this.mOrientations[0] = new Permutation(this, null);
3770    const map1 = ((s) => {
3771      let a = [];
3772      while (s-- > 0) a.push(0);
3773      return a;
3774    })(nSides * 2);
3775    for (let i = 0; i < nSides; i++) {
3776      {
3777        map1[i] = (i + 1) % nSides;
3778        map1[i + nSides] = map1[i] + nSides;
3779      }
3780      ;
3781    }
3782    this.mOrientations[1] = new Permutation(this, map1);
3783    const map2 = ((s) => {
3784      let a = [];
3785      while (s-- > 0) a.push(0);
3786      return a;
3787    })(map1.length);
3788    let n = nSides * 2;
3789    for (let i = 0; i < map2.length; i++) {
3790      {
3791        n--;
3792        map2[i] = map1[n];
3793      }
3794      ;
3795    }
3796    this.mOrientations[nSides] = new Permutation(this, map2);
3797  }
3798  /**
3799   * 
3800   * @param {string} frameColor
3801   */
3802  createFrameOrbit(frameColor) {
3803    const field = this.getField();
3804    const nSides = field.polygonSides();
3805    const nDiags = field.diagonalCount();
3806    const rotationMatrix = this.getRotationMatrix();
3807    let vX = field.basisVector(3, AlgebraicVector.X);
3808    let vY = field.basisVector(3, AlgebraicVector.Y);
3809    let vZ = field.basisVector(3, AlgebraicVector.Z);
3810    for (let i = 0; i < nSides * 2; i++) {
3811      {
3812        if (i === nSides) {
3813          vY = vY.negate();
3814          if (field.isOdd()) {
3815            vY = vY.setComponent(AlgebraicVector.X, field.getUnitDiagonal(nDiags - 1).reciprocal());
3816          }
3817          vZ = vZ.negate();
3818        }
3819        this.mMatrices[i] = new AlgebraicMatrix(vX, vY, vZ);
3820        vX = rotationMatrix.timesColumn(vX);
3821        vY = rotationMatrix.timesColumn(vY);
3822      }
3823      ;
3824    }
3825  }
3826  getRotationMatrix() {
3827    if (this.rotationMatrix == null) {
3828      const field = this.getField();
3829      const diagCount = field.diagonalCount();
3830      const p_x = field.getUnitDiagonal(diagCount - 3);
3831      const q_y = field.getUnitDiagonal(diagCount - (field.isEven() ? 3 : 2));
3832      const den = field.getUnitDiagonal(diagCount - 1);
3833      const num = field.getUnitDiagonal(1);
3834      const p = field.origin(3).setComponent(AlgebraicVector.X, p_x.dividedBy(den)).setComponent(AlgebraicVector.Y, num.dividedBy(den));
3835      const q = field.origin(3).setComponent(AlgebraicVector.X, num.dividedBy(den).negate()).setComponent(AlgebraicVector.Y, q_y.dividedBy(den));
3836      const zAxis = field.basisVector(3, AlgebraicVector.Z);
3837      this.rotationMatrix = new AlgebraicMatrix(p, q, zAxis);
3838    }
3839    return this.rotationMatrix;
3840  }
3841  /**
3842   * 
3843   */
3844  createOtherOrbits() {
3845  }
3846  createStandardOrbits(frameColor) {
3847    const redOrbit = this.createZoneOrbit$java_lang_String$int$int$com_vzome_core_algebra_AlgebraicVector$boolean("red", 0, 1, this.mField.basisVector(3, AlgebraicVector.Z), true);
3848    this.preferredAxis = redOrbit.getAxis$int$int(Symmetry.PLUS, 0);
3849    const blueFrameVector = this.mField.basisVector(3, AlgebraicVector.X);
3850    const nSides = this.getField().polygonSides();
3851    const blueOrbit = this.createZoneOrbit$java_lang_String$int$int$com_vzome_core_algebra_AlgebraicVector$boolean(frameColor, 0, nSides, blueFrameVector, true);
3852    let greenVector;
3853    if (this.getField().isOdd()) {
3854      const blueRotatedVector = blueOrbit.getAxis$int$int(Symmetry.PLUS, (nSides + 1) / 2 | 0).normal();
3855      greenVector = blueFrameVector.minus(blueRotatedVector);
3856    } else {
3857      const blueRotatedVector = blueOrbit.getAxis$int$int(Symmetry.PLUS, 1).normal();
3858      greenVector = blueFrameVector.plus(blueRotatedVector);
3859    }
3860    this.createZoneOrbit$java_lang_String$int$int$com_vzome_core_algebra_AlgebraicVector$boolean("green", 0, nSides, greenVector, false);
3861    const yellowVector = greenVector.plus(redOrbit.getAxis$int$int(Symmetry.PLUS, 1).normal());
3862    this.createZoneOrbit$java_lang_String$int$int$com_vzome_core_algebra_AlgebraicVector$boolean("yellow", 0, nSides, yellowVector, false);
3863    return this;
3864  }
3865  /**
3866   * 
3867   * @return {Axis}
3868   */
3869  getPreferredAxis() {
3870    return this.preferredAxis;
3871  }
3872  /**
3873   * 
3874   * @param {AlgebraicVector} v
3875   * @return {RealVector}
3876   */
3877  embedInR3(v) {
3878    const rv = super.embedInR3(v);
3879    if (this.useShear) {
3880      const sums = [0, 0, 0];
3881      for (let i = 0; i < this.shearTransform.length; i++) {
3882        {
3883          sums[i] += Math.fround(this.shearTransform[i].x * rv.x);
3884          sums[i] += Math.fround(this.shearTransform[i].y * rv.y);
3885          sums[i] += Math.fround(this.shearTransform[i].z * rv.z);
3886        }
3887        ;
3888      }
3889      return new RealVector(sums[0], sums[1], sums[2]);
3890    }
3891    return rv;
3892  }
3893  /**
3894   * 
3895   * @param {AlgebraicVector} v
3896   * @return {double[]}
3897   */
3898  embedInR3Double(v) {
3899    const dv = super.embedInR3Double(v);
3900    if (this.useShear) {
3901      const sums = [0, 0, 0];
3902      for (let i = 0; i < this.shearTransform.length; i++) {
3903        {
3904          sums[i] += this.shearTransform[i].x * dv[0];
3905          sums[i] += this.shearTransform[i].y * dv[1];
3906          sums[i] += this.shearTransform[i].z * dv[2];
3907        }
3908        ;
3909      }
3910      return sums;
3911    }
3912    return dv;
3913  }
3914  /**
3915   * 
3916   * @return {boolean}
3917   */
3918  isTrivial() {
3919    return !this.useShear;
3920  }
3921  /**
3922   * 
3923   * @return {string}
3924   */
3925  getName() {
3926    return "antiprism" + this.getField().polygonSides();
3927  }
3928  /**
3929   * 
3930   * @param {string} name
3931   * @return {int[]}
3932   */
3933  subgroup(name) {
3934    return null;
3935  }
3936  /**
3937   * These three vertices represent the corners of the canonical orbit triangle.
3938   * They must correspond to the three "special" orbits returned by getSpecialOrbit().
3939   * All other canonical direction prototype vectors
3940   * must intersect this plane at a unique point within the triangle.
3941   * 
3942   * OrbitDotLocator will use the three vectors to locate the dots in this order:
3943   * AlgebraicVector[] triangle = getOrbitTriangle();
3944   * triangle[0] .. // SpecialOrbit.BLUE   = orthoVertex
3945   * triangle[1] .. // SpecialOrbit.RED    = sideVertex
3946   * triangle[2] .. // SpecialOrbit.YELLOW = topVertex
3947   * 
3948   * These variable names and their position in the array
3949   * correspond to the positions where they will be shown in the orbit triangle
3950   * rather than any specific colors.
3951   * The SpecialOrbit names originally matched the color position in the icosa orbit triangle
3952   * but other symmetries don't necessarily have any such corellation.
3953   * 
3954   * top
3955   * @
3956   * | `\
3957   * |    `\
3958   * @-------`@
3959   * ortho     side
3960   * 
3961   * AntiprismTrackball also uses these 3 vertices to locate the trackball orbit triangle hints.
3962   * @return {AlgebraicVector[]}
3963   */
3964  getOrbitTriangle() {
3965    const field = this.getField();
3966    const diagCount = field.diagonalCount();
3967    const sideVertex = field.basisVector(3, AlgebraicVector.Z);
3968    const blueOrbit = this.getSpecialOrbit(0 /* BLUE */);
3969    const topVertex = blueOrbit.getAxis$int$int(Symmetry.PLUS, diagCount).normal();
3970    const bottomVert = blueOrbit.getAxis$int$int(Symmetry.PLUS, diagCount + 1).normal();
3971    const orthoVertex = AlgebraicVectors.getCentroid([topVertex, bottomVert]);
3972    return [orthoVertex, sideVertex, topVertex];
3973  }
3974  /**
3975   * 
3976   * @param {SpecialOrbit} which
3977   * @return {Direction}
3978   */
3979  getSpecialOrbit(which) {
3980    switch (which) {
3981      case 0 /* BLUE */:
3982        return this.getDirection("blue");
3983      case 1 /* RED */:
3984        return this.getDirection("red");
3985      case 2 /* YELLOW */:
3986        return this.getDirection(this.getField().isEven() ? "green" : "blue");
3987      default:
3988        return null;
3989    }
3990  }
3991};
3992AntiprismSymmetry["__class"] = "com.vzome.core.math.symmetry.AntiprismSymmetry";
3993AntiprismSymmetry["__interfaces"] = ["com.vzome.core.math.symmetry.Symmetry", "com.vzome.core.math.symmetry.Embedding"];
3994
3995export {
3996  PropertyChangeEvent,
3997  PropertyChangeSupport,
3998  Polygon,
3999  Command,
4000  Manifestations,
4001  Color,
4002  ResourceLoader,
4003  AbstractAlgebraicField,
4004  ParameterizedField,
4005  File,
4006  PolygonField,
4007  AntiprismSymmetry
4008};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.