PageSourceSearch

https://www.vzome.com/modules/chunk-737R77QV.js

js vzome.com collected 2026-09-24 20:35:44 UTC 61,220 bytes, 2,116 lines download raw bytes

1import {
2  $PROXY,
3  $TRACK,
4  PerspectiveCamera,
5  Quaternion,
6  Vector3,
7  batch,
8  createComponent,
9  createContext,
10  createEffect,
11  createSignal,
12  getListener,
13  onCleanup,
14  useContext
15} from "./chunk-47C2ISC4.js";
16import {
17  decodeEntities,
18  fetchDesign,
19  generateUUID,
20  openTextContent,
21  requestExport
22} from "./chunk-J3RXXGCJ.js";
23
vendor: 14,883 bytes, lines 24-435
24// node_modules/solid-js/store/dist/store.js
25var $RAW = Symbol("store-raw");
26var $NODE = Symbol("store-node");
27var $HAS = Symbol("store-has");
28var $SELF = Symbol("store-self");
29function wrap$1(value) {
30  let p = value[$PROXY];
31  if (!p) {
32    Object.defineProperty(value, $PROXY, {
33      value: p = new Proxy(value, proxyTraps$1)
34    });
35    if (!Array.isArray(value)) {
36      const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
37      for (let i = 0, l = keys.length; i < l; i++) {
38        const prop = keys[i];
39        if (desc[prop].get) {
40          Object.defineProperty(value, prop, {
41            enumerable: desc[prop].enumerable,
42            get: desc[prop].get.bind(p)
43          });
44        }
45      }
46    }
47  }
48  return p;
49}
50function isWrappable(obj) {
51  let proto;
52  return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
53}
54function unwrap(item, set = /* @__PURE__ */ new Set()) {
55  let result, unwrapped, v, prop;
56  if (result = item != null && item[$RAW]) return result;
57  if (!isWrappable(item) || set.has(item)) return item;
58  if (Array.isArray(item)) {
59    if (Object.isFrozen(item)) item = item.slice(0);
60    else set.add(item);
61    for (let i = 0, l = item.length; i < l; i++) {
62      v = item[i];
63      if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
64    }
65  } else {
66    if (Object.isFrozen(item)) item = Object.assign({}, item);
67    else set.add(item);
68    const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
69    for (let i = 0, l = keys.length; i < l; i++) {
70      prop = keys[i];
71      if (desc[prop].get) continue;
72      v = item[prop];
73      if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
74    }
75  }
76  return item;
77}
78function getNodes(target, symbol) {
79  let nodes = target[symbol];
80  if (!nodes) Object.defineProperty(target, symbol, {
81    value: nodes = /* @__PURE__ */ Object.create(null)
82  });
83  return nodes;
84}
85function getNode(nodes, property, value) {
86  if (nodes[property]) return nodes[property];
87  const [s, set] = createSignal(value, {
88    equals: false,
89    internal: true
90  });
91  s.$ = set;
92  return nodes[property] = s;
93}
94function proxyDescriptor$1(target, property) {
95  const desc = Reflect.getOwnPropertyDescriptor(target, property);
96  if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE) return desc;
97  delete desc.value;
98  delete desc.writable;
99  desc.get = () => target[$PROXY][property];
100  return desc;
101}
102function trackSelf(target) {
103  getListener() && getNode(getNodes(target, $NODE), $SELF)();
104}
105function ownKeys(target) {
106  trackSelf(target);
107  return Reflect.ownKeys(target);
108}
109var proxyTraps$1 = {
110  get(target, property, receiver) {
111    if (property === $RAW) return target;
112    if (property === $PROXY) return receiver;
113    if (property === $TRACK) {
114      trackSelf(target);
115      return receiver;
116    }
117    const nodes = getNodes(target, $NODE);
118    const tracked = nodes[property];
119    let value = tracked ? tracked() : target[property];
120    if (property === $NODE || property === $HAS || property === "__proto__") return value;
121    if (!tracked) {
122      const desc = Object.getOwnPropertyDescriptor(target, property);
123      if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
124    }
125    return isWrappable(value) ? wrap$1(value) : value;
126  },
127  has(target, property) {
128    if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
129    getListener() && getNode(getNodes(target, $HAS), property)();
130    return property in target;
131  },
132  set() {
133    return true;
134  },
135  deleteProperty() {
136    return true;
137  },
138  ownKeys,
139  getOwnPropertyDescriptor: proxyDescriptor$1
140};
141function setProperty(state, property, value, deleting = false) {
142  if (!deleting && state[property] === value) return;
143  const prev = state[property], len = state.length;
144  if (value === void 0) {
145    delete state[property];
146    if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
147  } else {
148    state[property] = value;
149    if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
150  }
151  let nodes = getNodes(state, $NODE), node;
152  if (node = getNode(nodes, property, prev)) node.$(() => value);
153  if (Array.isArray(state) && state.length !== len) {
154    for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
155    (node = getNode(nodes, "length", len)) && node.$(state.length);
156  }
157  (node = nodes[$SELF]) && node.$();
158}
159function mergeStoreNode(state, value) {
160  const keys = Object.keys(value);
161  for (let i = 0; i < keys.length; i += 1) {
162    const key = keys[i];
163    setProperty(state, key, value[key]);
164  }
165}
166function updateArray(current, next) {
167  if (typeof next === "function") next = next(current);
168  next = unwrap(next);
169  if (Array.isArray(next)) {
170    if (current === next) return;
171    let i = 0, len = next.length;
172    for (; i < len; i++) {
173      const value = next[i];
174      if (current[i] !== value) setProperty(current, i, value);
175    }
176    setProperty(current, "length", len);
177  } else mergeStoreNode(current, next);
178}
179function updatePath(current, path, traversed = []) {
180  let part, prev = current;
181  if (path.length > 1) {
182    part = path.shift();
183    const partType = typeof part, isArray = Array.isArray(current);
184    if (Array.isArray(part)) {
185      for (let i = 0; i < part.length; i++) {
186        updatePath(current, [part[i]].concat(path), traversed);
187      }
188      return;
189    } else if (isArray && partType === "function") {
190      for (let i = 0; i < current.length; i++) {
191        if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
192      }
193      return;
194    } else if (isArray && partType === "object") {
195      const {
196        from = 0,
197        to = current.length - 1,
198        by = 1
199      } = part;
200      for (let i = from; i <= to; i += by) {
201        updatePath(current, [i].concat(path), traversed);
202      }
203      return;
204    } else if (path.length > 1) {
205      updatePath(current[part], path, [part].concat(traversed));
206      return;
207    }
208    prev = current[part];
209    traversed = [part].concat(traversed);
210  }
211  let value = path[0];
212  if (typeof value === "function") {
213    value = value(prev, traversed);
214    if (value === prev) return;
215  }
216  if (part === void 0 && value == void 0) return;
217  value = unwrap(value);
218  if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
219    mergeStoreNode(prev, value);
220  } else setProperty(current, part, value);
221}
222function createStore(...[store, options]) {
223  const unwrappedStore = unwrap(store || {});
224  const isArray = Array.isArray(unwrappedStore);
225  const wrappedStore = wrap$1(unwrappedStore);
226  function setStore(...args) {
227    batch(() => {
228      isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
229    });
230  }
231  return [wrappedStore, setStore];
232}
233function proxyDescriptor(target, property) {
234  const desc = Reflect.getOwnPropertyDescriptor(target, property);
235  if (!desc || desc.get || desc.set || !desc.configurable || property === $PROXY || property === $NODE) return desc;
236  delete desc.value;
237  delete desc.writable;
238  desc.get = () => target[$PROXY][property];
239  desc.set = (v) => target[$PROXY][property] = v;
240  return desc;
241}
242var proxyTraps = {
243  get(target, property, receiver) {
244    if (property === $RAW) return target;
245    if (property === $PROXY) return receiver;
246    if (property === $TRACK) {
247      trackSelf(target);
248      return receiver;
249    }
250    const nodes = getNodes(target, $NODE);
251    const tracked = nodes[property];
252    let value = tracked ? tracked() : target[property];
253    if (property === $NODE || property === $HAS || property === "__proto__") return value;
254    if (!tracked) {
255      const desc = Object.getOwnPropertyDescriptor(target, property);
256      const isFunction = typeof value === "function";
257      if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
258      else if (value != null && isFunction && value === Array.prototype[property]) {
259        return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
260      }
261    }
262    return isWrappable(value) ? wrap(value) : value;
263  },
264  has(target, property) {
265    if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
266    getListener() && getNode(getNodes(target, $HAS), property)();
267    return property in target;
268  },
269  set(target, property, value) {
270    batch(() => setProperty(target, property, unwrap(value)));
271    return true;
272  },
273  deleteProperty(target, property) {
274    batch(() => setProperty(target, property, void 0, true));
275    return true;
276  },
277  ownKeys,
278  getOwnPropertyDescriptor: proxyDescriptor
279};
280function wrap(value) {
281  let p = value[$PROXY];
282  if (!p) {
283    Object.defineProperty(value, $PROXY, {
284      value: p = new Proxy(value, proxyTraps)
285    });
286    const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
287    const proto = Object.getPrototypeOf(value);
288    const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
289    if (isClass) {
290      let curProto = proto;
291      while (curProto != null) {
292        const descriptors = Object.getOwnPropertyDescriptors(curProto);
293        keys.push(...Object.keys(descriptors));
294        Object.assign(desc, descriptors);
295        curProto = Object.getPrototypeOf(curProto);
296      }
297    }
298    for (let i = 0, l = keys.length; i < l; i++) {
299      const prop = keys[i];
300      if (isClass && prop === "constructor") continue;
301      if (desc[prop].get) {
302        const get = desc[prop].get.bind(p);
303        Object.defineProperty(value, prop, {
304          get,
305          configurable: true
306        });
307      }
308      if (desc[prop].set) {
309        const og = desc[prop].set, set = (v) => batch(() => og.call(p, v));
310        Object.defineProperty(value, prop, {
311          set,
312          configurable: true
313        });
314      }
315    }
316  }
317  return p;
318}
319function createMutable(state, options) {
320  const unwrappedStore = unwrap(state || {});
321  const wrappedStore = wrap(unwrappedStore);
322  return wrappedStore;
323}
324var $ROOT = Symbol("store-root");
325function applyState(target, parent, property, merge, key) {
326  const previous = parent[property];
327  if (target === previous) return;
328  const isArray = Array.isArray(target);
329  if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
330    setProperty(parent, property, target);
331    return;
332  }
333  if (isArray) {
334    if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
335      let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
336      for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start] && target[start] && previous[start][key] && previous[start][key] === target[start][key]); start++) {
337        applyState(target[start], previous, start, merge, key);
338      }
339      const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
340      for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[end] && target[newEnd] && previous[end][key] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
341        temp[newEnd] = previous[end];
342      }
343      if (start > newEnd || start > end) {
344        for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);
345        for (; j < target.length; j++) {
346          setProperty(previous, j, temp[j]);
347          applyState(target[j], previous, j, merge, key);
348        }
349        if (previous.length > target.length) setProperty(previous, "length", target.length);
350        return;
351      }
352      newIndicesNext = new Array(newEnd + 1);
353      for (j = newEnd; j >= start; j--) {
354        item = target[j];
355        keyVal = key && item ? item[key] : item;
356        i = newIndices.get(keyVal);
357        newIndicesNext[j] = i === void 0 ? -1 : i;
358        newIndices.set(keyVal, j);
359      }
360      for (i = start; i <= end; i++) {
361        item = previous[i];
362        keyVal = key && item ? item[key] : item;
363        j = newIndices.get(keyVal);
364        if (j !== void 0 && j !== -1) {
365          temp[j] = previous[i];
366          j = newIndicesNext[j];
367          newIndices.set(keyVal, j);
368        }
369      }
370      for (j = start; j < target.length; j++) {
371        if (j in temp) {
372          setProperty(previous, j, temp[j]);
373          applyState(target[j], previous, j, merge, key);
374        } else setProperty(previous, j, target[j]);
375      }
376    } else {
377      for (let i = 0, len = target.length; i < len; i++) {
378        applyState(target[i], previous, i, merge, key);
379      }
380    }
381    if (previous.length > target.length) setProperty(previous, "length", target.length);
382    return;
383  }
384  const targetKeys = Object.keys(target);
385  for (let i = 0, len = targetKeys.length; i < len; i++) {
386    applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
387  }
388  const previousKeys = Object.keys(previous);
389  for (let i = 0, len = previousKeys.length; i < len; i++) {
390    if (target[previousKeys[i]] === void 0) setProperty(previous, previousKeys[i], void 0);
391  }
392}
393function reconcile(value, options = {}) {
394  const {
395    merge,
396    key = "id"
397  } = options, v = unwrap(value);
398  return (state) => {
399    if (!isWrappable(state) || !isWrappable(v)) return v;
400    const res = applyState(v, {
401      [$ROOT]: state
402    }, $ROOT, merge, key);
403    return res === void 0 ? state : res;
404  };
405}
406var producers = /* @__PURE__ */ new WeakMap();
407var setterTraps = {
408  get(target, property) {
409    if (property === $RAW) return target;
410    const value = target[property];
411    let proxy;
412    return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;
413  },
414  set(target, property, value) {
415    setProperty(target, property, unwrap(value));
416    return true;
417  },
418  deleteProperty(target, property) {
419    setProperty(target, property, void 0, true);
420    return true;
421  }
422};
423function produce(fn) {
424  return (state) => {
425    if (isWrappable(state)) {
426      let proxy;
427      if (!(proxy = producers.get(state))) {
428        producers.set(state, proxy = new Proxy(state, setterTraps));
429      }
430      fn(proxy);
431    }
432    return state;
433  };
434}
435
vendor: 25,938 bytes, lines 436-1267
436// node_modules/@tweenjs/tween.js/dist/tween.esm.js
437var Easing = Object.freeze({
438  Linear: Object.freeze({
439    None: function(amount) {
440      return amount;
441    },
442    In: function(amount) {
443      return amount;
444    },
445    Out: function(amount) {
446      return amount;
447    },
448    InOut: function(amount) {
449      return amount;
450    }
451  }),
452  Quadratic: Object.freeze({
453    In: function(amount) {
454      return amount * amount;
455    },
456    Out: function(amount) {
457      return amount * (2 - amount);
458    },
459    InOut: function(amount) {
460      if ((amount *= 2) < 1) {
461        return 0.5 * amount * amount;
462      }
463      return -0.5 * (--amount * (amount - 2) - 1);
464    }
465  }),
466  Cubic: Object.freeze({
467    In: function(amount) {
468      return amount * amount * amount;
469    },
470    Out: function(amount) {
471      return --amount * amount * amount + 1;
472    },
473    InOut: function(amount) {
474      if ((amount *= 2) < 1) {
475        return 0.5 * amount * amount * amount;
476      }
477      return 0.5 * ((amount -= 2) * amount * amount + 2);
478    }
479  }),
480  Quartic: Object.freeze({
481    In: function(amount) {
482      return amount * amount * amount * amount;
483    },
484    Out: function(amount) {
485      return 1 - --amount * amount * amount * amount;
486    },
487    InOut: function(amount) {
488      if ((amount *= 2) < 1) {
489        return 0.5 * amount * amount * amount * amount;
490      }
491      return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
492    }
493  }),
494  Quintic: Object.freeze({
495    In: function(amount) {
496      return amount * amount * amount * amount * amount;
497    },
498    Out: function(amount) {
499      return --amount * amount * amount * amount * amount + 1;
500    },
501    InOut: function(amount) {
502      if ((amount *= 2) < 1) {
503        return 0.5 * amount * amount * amount * amount * amount;
504      }
505      return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
506    }
507  }),
508  Sinusoidal: Object.freeze({
509    In: function(amount) {
510      return 1 - Math.sin((1 - amount) * Math.PI / 2);
511    },
512    Out: function(amount) {
513      return Math.sin(amount * Math.PI / 2);
514    },
515    InOut: function(amount) {
516      return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
517    }
518  }),
519  Exponential: Object.freeze({
520    In: function(amount) {
521      return amount === 0 ? 0 : Math.pow(1024, amount - 1);
522    },
523    Out: function(amount) {
524      return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
525    },
526    InOut: function(amount) {
527      if (amount === 0) {
528        return 0;
529      }
530      if (amount === 1) {
531        return 1;
532      }
533      if ((amount *= 2) < 1) {
534        return 0.5 * Math.pow(1024, amount - 1);
535      }
536      return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
537    }
538  }),
539  Circular: Object.freeze({
540    In: function(amount) {
541      return 1 - Math.sqrt(1 - amount * amount);
542    },
543    Out: function(amount) {
544      return Math.sqrt(1 - --amount * amount);
545    },
546    InOut: function(amount) {
547      if ((amount *= 2) < 1) {
548        return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
549      }
550      return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
551    }
552  }),
553  Elastic: Object.freeze({
554    In: function(amount) {
555      if (amount === 0) {
556        return 0;
557      }
558      if (amount === 1) {
559        return 1;
560      }
561      return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
562    },
563    Out: function(amount) {
564      if (amount === 0) {
565        return 0;
566      }
567      if (amount === 1) {
568        return 1;
569      }
570      return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
571    },
572    InOut: function(amount) {
573      if (amount === 0) {
574        return 0;
575      }
576      if (amount === 1) {
577        return 1;
578      }
579      amount *= 2;
580      if (amount < 1) {
581        return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
582      }
583      return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
584    }
585  }),
586  Back: Object.freeze({
587    In: function(amount) {
588      var s = 1.70158;
589      return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
590    },
591    Out: function(amount) {
592      var s = 1.70158;
593      return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
594    },
595    InOut: function(amount) {
596      var s = 1.70158 * 1.525;
597      if ((amount *= 2) < 1) {
598        return 0.5 * (amount * amount * ((s + 1) * amount - s));
599      }
600      return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
601    }
602  }),
603  Bounce: Object.freeze({
604    In: function(amount) {
605      return 1 - Easing.Bounce.Out(1 - amount);
606    },
607    Out: function(amount) {
608      if (amount < 1 / 2.75) {
609        return 7.5625 * amount * amount;
610      } else if (amount < 2 / 2.75) {
611        return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
612      } else if (amount < 2.5 / 2.75) {
613        return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
614      } else {
615        return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
616      }
617    },
618    InOut: function(amount) {
619      if (amount < 0.5) {
620        return Easing.Bounce.In(amount * 2) * 0.5;
621      }
622      return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
623    }
624  }),
625  generatePow: function(power) {
626    if (power === void 0) {
627      power = 4;
628    }
629    power = power < Number.EPSILON ? Number.EPSILON : power;
630    power = power > 1e4 ? 1e4 : power;
631    return {
632      In: function(amount) {
633        return Math.pow(amount, power);
634      },
635      Out: function(amount) {
636        return 1 - Math.pow(1 - amount, power);
637      },
638      InOut: function(amount) {
639        if (amount < 0.5) {
640          return Math.pow(amount * 2, power) / 2;
641        }
642        return (1 - Math.pow(2 - amount * 2, power)) / 2 + 0.5;
643      }
644    };
645  }
646});
647var now = function() {
648  return performance.now();
649};
650var Group = (
651  /** @class */
652  (function() {
653    function Group2() {
654      var tweens = [];
655      for (var _i = 0; _i < arguments.length; _i++) {
656        tweens[_i] = arguments[_i];
657      }
658      this._tweens = {};
659      this._tweensAddedDuringUpdate = {};
660      this.add.apply(this, tweens);
661    }
662    Group2.prototype.getAll = function() {
663      var _this = this;
664      return Object.keys(this._tweens).map(function(tweenId) {
665        return _this._tweens[tweenId];
666      });
667    };
668    Group2.prototype.removeAll = function() {
669      this._tweens = {};
670    };
671    Group2.prototype.add = function() {
672      var _a;
673      var tweens = [];
674      for (var _i = 0; _i < arguments.length; _i++) {
675        tweens[_i] = arguments[_i];
676      }
677      for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
678        var tween = tweens_1[_b];
679        (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
680        tween._group = this;
681        this._tweens[tween.getId()] = tween;
682        this._tweensAddedDuringUpdate[tween.getId()] = tween;
683      }
684    };
685    Group2.prototype.remove = function() {
686      var tweens = [];
687      for (var _i = 0; _i < arguments.length; _i++) {
688        tweens[_i] = arguments[_i];
689      }
690      for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
691        var tween = tweens_2[_a];
692        tween._group = void 0;
693        delete this._tweens[tween.getId()];
694        delete this._tweensAddedDuringUpdate[tween.getId()];
695      }
696    };
697    Group2.prototype.allStopped = function() {
698      return this.getAll().every(function(tween) {
699        return !tween.isPlaying();
700      });
701    };
702    Group2.prototype.update = function(time, preserve) {
703      if (time === void 0) {
704        time = now();
705      }
706      if (preserve === void 0) {
707        preserve = true;
708      }
709      var tweenIds = Object.keys(this._tweens);
710      if (tweenIds.length === 0)
711        return;
712      while (tweenIds.length > 0) {
713        this._tweensAddedDuringUpdate = {};
714        for (var i = 0; i < tweenIds.length; i++) {
715          var tween = this._tweens[tweenIds[i]];
716          var autoStart = !preserve;
717          if (tween && tween.update(time, autoStart) === false && !preserve)
718            this.remove(tween);
719        }
720        tweenIds = Object.keys(this._tweensAddedDuringUpdate);
721      }
722    };
723    return Group2;
724  })()
725);
726var Interpolation = {
727  Linear: function(v, k) {
728    var m = v.length - 1;
729    var f = m * k;
730    var i = Math.floor(f);
731    var fn = Interpolation.Utils.Linear;
732    if (k < 0) {
733      return fn(v[0], v[1], f);
734    }
735    if (k > 1) {
736      return fn(v[m], v[m - 1], m - f);
737    }
738    return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
739  },
740  Bezier: function(v, k) {
741    var b = 0;
742    var n = v.length - 1;
743    var pw = Math.pow;
744    var bn = Interpolation.Utils.Bernstein;
745    for (var i = 0; i <= n; i++) {
746      b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
747    }
748    return b;
749  },
750  CatmullRom: function(v, k) {
751    var m = v.length - 1;
752    var f = m * k;
753    var i = Math.floor(f);
754    var fn = Interpolation.Utils.CatmullRom;
755    if (v[0] === v[m]) {
756      if (k < 0) {
757        i = Math.floor(f = m * (1 + k));
758      }
759      return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
760    } else {
761      if (k < 0) {
762        return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
763      }
764      if (k > 1) {
765        return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
766      }
767      return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
768    }
769  },
770  Utils: {
771    Linear: function(p0, p1, t) {
772      return (p1 - p0) * t + p0;
773    },
774    Bernstein: function(n, i) {
775      var fc = Interpolation.Utils.Factorial;
776      return fc(n) / fc(i) / fc(n - i);
777    },
778    Factorial: /* @__PURE__ */ (function() {
779      var a = [1];
780      return function(n) {
781        var s = 1;
782        if (a[n]) {
783          return a[n];
784        }
785        for (var i = n; i > 1; i--) {
786          s *= i;
787        }
788        a[n] = s;
789        return s;
790      };
791    })(),
792    CatmullRom: function(p0, p1, p2, p3, t) {
793      var v0 = (p2 - p0) * 0.5;
794      var v1 = (p3 - p1) * 0.5;
795      var t2 = t * t;
796      var t3 = t * t2;
797      return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
798    }
799  }
800};
801var Sequence = (
802  /** @class */
803  (function() {
804    function Sequence2() {
805    }
806    Sequence2.nextId = function() {
807      return Sequence2._nextId++;
808    };
809    Sequence2._nextId = 0;
810    return Sequence2;
811  })()
812);
813var mainGroup = new Group();
814var Tween = (
815  /** @class */
816  (function() {
817    function Tween2(object, group) {
818      this._isPaused = false;
819      this._pauseStart = 0;
820      this._valuesStart = {};
821      this._valuesEnd = {};
822      this._valuesStartRepeat = {};
823      this._duration = 1e3;
824      this._isDynamic = false;
825      this._initialRepeat = 0;
826      this._repeat = 0;
827      this._yoyo = false;
828      this._isPlaying = false;
829      this._reversed = false;
830      this._delayTime = 0;
831      this._startTime = 0;
832      this._easingFunction = Easing.Linear.None;
833      this._interpolationFunction = Interpolation.Linear;
834      this._chainedTweens = [];
835      this._onStartCallbackFired = false;
836      this._onEveryStartCallbackFired = false;
837      this._id = Sequence.nextId();
838      this._isChainStopped = false;
839      this._propertiesAreSetUp = false;
840      this._goToEnd = false;
841      this._object = object;
842      if (typeof group === "object") {
843        this._group = group;
844        group.add(this);
845      } else if (group === true) {
846        this._group = mainGroup;
847        mainGroup.add(this);
848      }
849    }
850    Tween2.prototype.getId = function() {
851      return this._id;
852    };
853    Tween2.prototype.isPlaying = function() {
854      return this._isPlaying;
855    };
856    Tween2.prototype.isPaused = function() {
857      return this._isPaused;
858    };
859    Tween2.prototype.getDuration = function() {
860      return this._duration;
861    };
862    Tween2.prototype.to = function(target, duration) {
863      if (duration === void 0) {
864        duration = 1e3;
865      }
866      if (this._isPlaying)
867        throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");
868      this._valuesEnd = target;
869      this._propertiesAreSetUp = false;
870      this._duration = duration < 0 ? 0 : duration;
871      return this;
872    };
873    Tween2.prototype.duration = function(duration) {
874      if (duration === void 0) {
875        duration = 1e3;
876      }
877      this._duration = duration < 0 ? 0 : duration;
878      return this;
879    };
880    Tween2.prototype.dynamic = function(dynamic) {
881      if (dynamic === void 0) {
882        dynamic = false;
883      }
884      this._isDynamic = dynamic;
885      return this;
886    };
887    Tween2.prototype.start = function(time, overrideStartingValues) {
888      if (time === void 0) {
889        time = now();
890      }
891      if (overrideStartingValues === void 0) {
892        overrideStartingValues = false;
893      }
894      if (this._isPlaying) {
895        return this;
896      }
897      this._repeat = this._initialRepeat;
898      if (this._reversed) {
899        this._reversed = false;
900        for (var property in this._valuesStartRepeat) {
901          this._swapEndStartRepeatValues(property);
902          this._valuesStart[property] = this._valuesStartRepeat[property];
903        }
904      }
905      this._isPlaying = true;
906      this._isPaused = false;
907      this._onStartCallbackFired = false;
908      this._onEveryStartCallbackFired = false;
909      this._isChainStopped = false;
910      this._startTime = time;
911      this._startTime += this._delayTime;
912      if (!this._propertiesAreSetUp || overrideStartingValues) {
913        this._propertiesAreSetUp = true;
914        if (!this._isDynamic) {
915          var tmp = {};
916          for (var prop in this._valuesEnd)
917            tmp[prop] = this._valuesEnd[prop];
918          this._valuesEnd = tmp;
919        }
920        this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
921      }
922      return this;
923    };
924    Tween2.prototype.startFromCurrentValues = function(time) {
925      return this.start(time, true);
926    };
927    Tween2.prototype._setupProperties = function(_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
928      for (var property in _valuesEnd) {
929        var startValue = _object[property];
930        var startValueIsArray = Array.isArray(startValue);
931        var propType = startValueIsArray ? "array" : typeof startValue;
932        var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
933        if (propType === "undefined" || propType === "function") {
934          continue;
935        }
936        if (isInterpolationList) {
937          var endValues = _valuesEnd[property];
938          if (endValues.length === 0) {
939            continue;
940          }
941          var temp = [startValue];
942          for (var i = 0, l = endValues.length; i < l; i += 1) {
943            var value = this._handleRelativeValue(startValue, endValues[i]);
944            if (isNaN(value)) {
945              isInterpolationList = false;
946              console.warn("Found invalid interpolation list. Skipping.");
947              break;
948            }
949            temp.push(value);
950          }
951          if (isInterpolationList) {
952            _valuesEnd[property] = temp;
953          }
954        }
955        if ((propType === "object" || startValueIsArray) && startValue && !isInterpolationList) {
956          _valuesStart[property] = startValueIsArray ? [] : {};
957          var nestedObject = startValue;
958          for (var prop in nestedObject) {
959            _valuesStart[property][prop] = nestedObject[prop];
960          }
961          _valuesStartRepeat[property] = startValueIsArray ? [] : {};
962          var endValues = _valuesEnd[property];
963          if (!this._isDynamic) {
964            var tmp = {};
965            for (var prop in endValues)
966              tmp[prop] = endValues[prop];
967            _valuesEnd[property] = endValues = tmp;
968          }
969          this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
970        } else {
971          if (typeof _valuesStart[property] === "undefined" || overrideStartingValues) {
972            _valuesStart[property] = startValue;
973          }
974          if (!startValueIsArray) {
975            _valuesStart[property] *= 1;
976          }
977          if (isInterpolationList) {
978            _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
979          } else {
980            _valuesStartRepeat[property] = _valuesStart[property] || 0;
981          }
982        }
983      }
984    };
985    Tween2.prototype.stop = function() {
986      if (!this._isChainStopped) {
987        this._isChainStopped = true;
988        this.stopChainedTweens();
989      }
990      if (!this._isPlaying) {
991        return this;
992      }
993      this._isPlaying = false;
994      this._isPaused = false;
995      if (this._onStopCallback) {
996        this._onStopCallback(this._object);
997      }
998      return this;
999    };
1000    Tween2.prototype.end = function() {
1001      this._goToEnd = true;
1002      this.update(this._startTime + this._duration);
1003      return this;
1004    };
1005    Tween2.prototype.pause = function(time) {
1006      if (time === void 0) {
1007        time = now();
1008      }
1009      if (this._isPaused || !this._isPlaying) {
1010        return this;
1011      }
1012      this._isPaused = true;
1013      this._pauseStart = time;
1014      return this;
1015    };
1016    Tween2.prototype.resume = function(time) {
1017      if (time === void 0) {
1018        time = now();
1019      }
1020      if (!this._isPaused || !this._isPlaying) {
1021        return this;
1022      }
1023      this._isPaused = false;
1024      this._startTime += time - this._pauseStart;
1025      this._pauseStart = 0;
1026      return this;
1027    };
1028    Tween2.prototype.stopChainedTweens = function() {
1029      for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
1030        this._chainedTweens[i].stop();
1031      }
1032      return this;
1033    };
1034    Tween2.prototype.group = function(group) {
1035      if (!group) {
1036        console.warn("tween.group() without args has been removed, use group.add(tween) instead.");
1037        return this;
1038      }
1039      group.add(this);
1040      return this;
1041    };
1042    Tween2.prototype.remove = function() {
1043      var _a;
1044      (_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
1045      return this;
1046    };
1047    Tween2.prototype.delay = function(amount) {
1048      if (amount === void 0) {
1049        amount = 0;
1050      }
1051      this._delayTime = amount;
1052      return this;
1053    };
1054    Tween2.prototype.repeat = function(times) {
1055      if (times === void 0) {
1056        times = 0;
1057      }
1058      this._initialRepeat = times;
1059      this._repeat = times;
1060      return this;
1061    };
1062    Tween2.prototype.repeatDelay = function(amount) {
1063      this._repeatDelayTime = amount;
1064      return this;
1065    };
1066    Tween2.prototype.yoyo = function(yoyo) {
1067      if (yoyo === void 0) {
1068        yoyo = false;
1069      }
1070      this._yoyo = yoyo;
1071      return this;
1072    };
1073    Tween2.prototype.easing = function(easingFunction) {
1074      if (easingFunction === void 0) {
1075        easingFunction = Easing.Linear.None;
1076      }
1077      this._easingFunction = easingFunction;
1078      return this;
1079    };
1080    Tween2.prototype.interpolation = function(interpolationFunction) {
1081      if (interpolationFunction === void 0) {
1082        interpolationFunction = Interpolation.Linear;
1083      }
1084      this._interpolationFunction = interpolationFunction;
1085      return this;
1086    };
1087    Tween2.prototype.chain = function() {
1088      var tweens = [];
1089      for (var _i = 0; _i < arguments.length; _i++) {
1090        tweens[_i] = arguments[_i];
1091      }
1092      this._chainedTweens = tweens;
1093      return this;
1094    };
1095    Tween2.prototype.onStart = function(callback) {
1096      this._onStartCallback = callback;
1097      return this;
1098    };
1099    Tween2.prototype.onEveryStart = function(callback) {
1100      this._onEveryStartCallback = callback;
1101      return this;
1102    };
1103    Tween2.prototype.onUpdate = function(callback) {
1104      this._onUpdateCallback = callback;
1105      return this;
1106    };
1107    Tween2.prototype.onRepeat = function(callback) {
1108      this._onRepeatCallback = callback;
1109      return this;
1110    };
1111    Tween2.prototype.onComplete = function(callback) {
1112      this._onCompleteCallback = callback;
1113      return this;
1114    };
1115    Tween2.prototype.onStop = function(callback) {
1116      this._onStopCallback = callback;
1117      return this;
1118    };
1119    Tween2.prototype.update = function(time, autoStart) {
1120      var _this = this;
1121      var _a;
1122      if (time === void 0) {
1123        time = now();
1124      }
1125      if (autoStart === void 0) {
1126        autoStart = Tween2.autoStartOnUpdate;
1127      }
1128      if (this._isPaused)
1129        return true;
1130      var property;
1131      if (!this._goToEnd && !this._isPlaying) {
1132        if (autoStart)
1133          this.start(time, true);
1134        else
1135          return false;
1136      }
1137      this._goToEnd = false;
1138      if (time < this._startTime) {
1139        return true;
1140      }
1141      if (this._onStartCallbackFired === false) {
1142        if (this._onStartCallback) {
1143          this._onStartCallback(this._object);
1144        }
1145        this._onStartCallbackFired = true;
1146      }
1147      if (this._onEveryStartCallbackFired === false) {
1148        if (this._onEveryStartCallback) {
1149          this._onEveryStartCallback(this._object);
1150        }
1151        this._onEveryStartCallbackFired = true;
1152      }
1153      var elapsedTime = time - this._startTime;
1154      var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
1155      var totalTime = this._duration + this._repeat * durationAndDelay;
1156      var calculateElapsedPortion = function() {
1157        if (_this._duration === 0)
1158          return 1;
1159        if (elapsedTime > totalTime) {
1160          return 1;
1161        }
1162        var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
1163        var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
1164        var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
1165        if (portion === 0 && elapsedTime === _this._duration) {
1166          return 1;
1167        }
1168        return portion;
1169      };
1170      var elapsed = calculateElapsedPortion();
1171      var value = this._easingFunction(elapsed);
1172      this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
1173      if (this._onUpdateCallback) {
1174        this._onUpdateCallback(this._object, elapsed);
1175      }
1176      if (this._duration === 0 || elapsedTime >= this._duration) {
1177        if (this._repeat > 0) {
1178          var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
1179          if (isFinite(this._repeat)) {
1180            this._repeat -= completeCount;
1181          }
1182          for (property in this._valuesStartRepeat) {
1183            if (!this._yoyo && typeof this._valuesEnd[property] === "string") {
1184              this._valuesStartRepeat[property] = // eslint-disable-next-line
1185              // @ts-ignore FIXME?
1186              this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
1187            }
1188            if (this._yoyo) {
1189              this._swapEndStartRepeatValues(property);
1190            }
1191            this._valuesStart[property] = this._valuesStartRepeat[property];
1192          }
1193          if (this._yoyo) {
1194            this._reversed = !this._reversed;
1195          }
1196          this._startTime += durationAndDelay * completeCount;
1197          if (this._onRepeatCallback) {
1198            this._onRepeatCallback(this._object);
1199          }
1200          this._onEveryStartCallbackFired = false;
1201          return true;
1202        } else {
1203          if (this._onCompleteCallback) {
1204            this._onCompleteCallback(this._object);
1205          }
1206          for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
1207            this._chainedTweens[i].start(this._startTime + this._duration, false);
1208          }
1209          this._isPlaying = false;
1210          return false;
1211        }
1212      }
1213      return true;
1214    };
1215    Tween2.prototype._updateProperties = function(_object, _valuesStart, _valuesEnd, value) {
1216      for (var property in _valuesEnd) {
1217        if (_valuesStart[property] === void 0) {
1218          continue;
1219        }
1220        var start = _valuesStart[property] || 0;
1221        var end = _valuesEnd[property];
1222        var startIsArray = Array.isArray(_object[property]);
1223        var endIsArray = Array.isArray(end);
1224        var isInterpolationList = !startIsArray && endIsArray;
1225        if (isInterpolationList) {
1226          _object[property] = this._interpolationFunction(end, value);
1227        } else if (typeof end === "object" && end) {
1228          this._updateProperties(_object[property], start, end, value);
1229        } else {
1230          end = this._handleRelativeValue(start, end);
1231          if (typeof end === "number") {
1232            _object[property] = start + (end - start) * value;
1233          }
1234        }
1235      }
1236    };
1237    Tween2.prototype._handleRelativeValue = function(start, end) {
1238      if (typeof end !== "string") {
1239        return end;
1240      }
1241      if (end.charAt(0) === "+" || end.charAt(0) === "-") {
1242        return start + parseFloat(end);
1243      }
1244      return parseFloat(end);
1245    };
1246    Tween2.prototype._swapEndStartRepeatValues = function(property) {
1247      var tmp = this._valuesStartRepeat[property];
1248      var endValue = this._valuesEnd[property];
1249      if (typeof endValue === "string") {
1250        this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
1251      } else {
1252        this._valuesStartRepeat[property] = this._valuesEnd[property];
1253      }
1254      this._valuesEnd[property] = tmp;
1255    };
1256    Tween2.autoStartOnUpdate = false;
1257    return Tween2;
1258  })()
1259);
1260var nextId = Sequence.nextId;
1261var TWEEN = mainGroup;
1262var getAll = TWEEN.getAll.bind(TWEEN);
1263var removeAll = TWEEN.removeAll.bind(TWEEN);
1264var add = TWEEN.add.bind(TWEEN);
1265var remove = TWEEN.remove.bind(TWEEN);
1266var update = TWEEN.update.bind(TWEEN);
1267
1268// src/viewer/context/camera.jsx
1269var METERS_PER_UNIT = 88e-4;
1270var INITIAL_DISTANCE = 108;
1271var NEAR_FACTOR = 0.1 / INITIAL_DISTANCE;
1272var FAR_FACTOR = 2;
1273var WIDTH_FACTOR = 0.45;
1274var defaultCamera = () => ({
1275  // zoom
1276  distance: INITIAL_DISTANCE,
1277  near: INITIAL_DISTANCE * NEAR_FACTOR,
1278  far: INITIAL_DISTANCE * FAR_FACTOR,
1279  width: INITIAL_DISTANCE * WIDTH_FACTOR,
1280  // pan
1281  lookAt: [0, 0, 0],
1282  // rotation
1283  up: [0, 1, 0],
1284  lookDir: [0, 0, -1],
1285  // other
1286  perspective: true,
1287  default: true
1288});
1289var defaultLighting = () => ({
1290  backgroundColor: "#8CC2E7",
1291  ambientColor: "#333333",
1292  directionalLights: [
1293    // These are the vZome defaults, for consistency
1294    {
1295      direction: [1, -1, -0.3],
1296      color: "#FDFDFD"
1297    },
1298    {
1299      direction: [-1, 0, -0.2],
1300      color: "#B5B5B5"
1301    },
1302    {
1303      direction: [0, 0, -1],
1304      color: "#303030"
1305    }
1306  ]
1307});
1308var defaultScene = () => ({
1309  camera: defaultCamera(),
1310  lighting: defaultLighting(),
1311  outlines: false,
1312  tweening: {
1313    duration: 500
1314  }
1315});
1316var toVector = (vector3) => {
1317  const {
1318    x,
1319    y,
1320    z
1321  } = vector3;
1322  return [x, y, z];
1323};
1324var fixedFrustum = (distance) => {
1325  const near = distance * NEAR_FACTOR;
1326  const far = distance * FAR_FACTOR;
1327  const width = distance * WIDTH_FACTOR;
1328  return {
1329    distance,
1330    far,
1331    near,
1332    width
1333  };
1334};
1335var extractCameraState = (camera, target) => {
1336  const up = toVector(camera.up);
1337  const position = toVector(camera.position);
1338  const lookAt = toVector(target);
1339  const [x, y, z] = lookAt.map((e, i) => e - position[i]);
1340  const distance = Math.sqrt(x * x + y * y + z * z);
1341  const lookDir = [x / distance, y / distance, z / distance];
1342  const {
1343    near,
1344    far,
1345    width
1346  } = fixedFrustum(distance);
1347  return {
1348    lookAt,
1349    up,
1350    lookDir,
1351    distance,
1352    width,
1353    far,
1354    near
1355  };
1356};
1357var cameraPosition = (cameraState) => {
1358  const {
1359    distance,
1360    lookAt,
1361    lookDir
1362  } = cameraState;
1363  return lookAt.map((e, i) => e - distance * lookDir[i]);
1364};
1365var cameraFieldOfViewY = (cameraState) => (aspectWtoH) => {
1366  const {
1367    width,
1368    distance
1369  } = cameraState;
1370  const halfX = width / 2;
1371  const halfY = halfX / aspectWtoH;
1372  return 360 * Math.atan(halfY / distance) / Math.PI;
1373};
1374var injectCameraState = (cameraState, camera) => {
1375  const {
1376    up,
1377    lookAt
1378  } = cameraState;
1379  camera.up.set(...up);
1380  camera.position.set(...cameraPosition(cameraState));
1381  camera.lookAt(...lookAt);
1382  camera.fov = cameraFieldOfViewY(cameraState)(1);
1383};
1384var createDefaultCameraStore = () => createStore({
1385  ...defaultScene()
1386});
1387var CameraContext = createContext({});
1388var CameraProvider = (props) => {
1389  const [state, setState] = createDefaultCameraStore();
1390  const globalScale = props.scale || METERS_PER_UNIT;
1391  if (!!props.distance) {
1392    setState("camera", fixedFrustum(props.distance));
1393  }
1394  if (props.outlines !== void 0) {
1395    setState("outlines", props.outlines);
1396  }
1397  if (!!props.lighting) {
1398    setState("lighting", props.lighting);
1399  }
1400  if (props.tweening?.duration !== void 0) {
1401    setState("tweening", "duration", props.tweening.duration);
1402  }
1403  const setCamera = (loadedCamera) => {
1404    setState("camera", loadedCamera);
1405    injectCameraState(state.camera, trackballCamera);
1406  };
1407  if (!!props.context) {
1408    createEffect(() => {
1409      const {
1410        backgroundColor
1411      } = props.context.state.lighting;
1412      setLighting({
1413        backgroundColor
1414      });
1415    });
1416    createEffect(() => {
1417      const {
1418        up,
1419        lookDir
1420      } = props.context.state.camera;
1421      setCamera({
1422        up,
1423        lookDir
1424      });
1425    });
1426  }
1427  const fov = cameraFieldOfViewY(state.camera);
1428  const [perspectiveProps, setPerspectiveProps] = createStore({
1429    fov
1430  });
1431  createEffect(() => {
1432    const position = cameraPosition(state.camera);
1433    const {
1434      near,
1435      far,
1436      up,
1437      lookAt,
1438      width
1439    } = state.camera;
1440    setPerspectiveProps({
1441      position,
1442      up,
1443      target: [...lookAt],
1444      near,
1445      far,
1446      width
1447    });
1448  });
1449  const trackballCamera = new PerspectiveCamera();
1450  injectCameraState(state.camera, trackballCamera);
1451  const sync = (target, name) => {
1452    const extractedCamera = extractCameraState(trackballCamera, target);
1453    const {
1454      up,
1455      lookDir
1456    } = extractedCamera;
1457    if (!!props.context) {
1458      props.context.setCamera({
1459        up,
1460        lookDir
1461      });
1462    } else {
1463      setState("camera", extractedCamera);
1464    }
1465  };
1466  const trackballProps = {
1467    camera: trackballCamera,
1468    sync
1469  };
1470  const mapViewToWorld = ([x, y, z]) => {
1471    const vec = new Vector3(x, y, z);
1472    vec.transformDirection(trackballCamera.matrixWorldInverse);
1473    return [vec.x, vec.y, vec.z];
1474  };
1475  const setDistance = (distance) => setCamera(fixedFrustum(distance));
1476  const setLighting = ({
1477    backgroundColor
1478  }) => setState("lighting", {
1479    backgroundColor
1480  });
1481  const togglePerspective = () => setState("camera", "perspective", (val) => !val);
1482  const toggleOutlines = () => setState("outlines", (val) => !val);
1483  const setTweenDuration = (duration) => setState("tweening", "duration", duration);
1484  const resetCamera = () => {
1485    setState("camera", defaultCamera());
1486    setState("lighting", defaultLighting());
1487  };
1488  const tweens = new Group();
1489  const animate = () => {
1490    requestAnimationFrame(animate);
1491    tweens.update();
1492  };
1493  animate();
1494  const cancelTweens = () => {
1495    tweens.getAll().map((tween) => tween.stop());
1496    tweens.removeAll();
1497  };
1498  const tweenCamera = (goalCamera) => {
1499    const {
1500      duration = 0
1501    } = state.tweening;
1502    if (!goalCamera) return Promise.resolve();
1503    if (duration <= 0) {
1504      setCamera(goalCamera);
1505      return Promise.resolve();
1506    }
1507    cancelTweens();
1508    const {
1509      distance,
1510      lookAt: [x, y, z]
1511    } = goalCamera;
1512    const tweenZoom = new Tween({
1513      distance: state.camera.distance
1514    });
1515    tweens.add(tweenZoom);
1516    tweenZoom.easing(Easing.Quadratic.InOut).to({
1517      distance
1518    }, duration).onUpdate(({
1519      distance: distance2
1520    }) => setDistance(distance2));
1521    const [cx, cy, cz] = state.camera.lookAt;
1522    const tweenPan = new Tween({
1523      x: cx,
1524      y: cy,
1525      z: cz
1526    });
1527    tweens.add(tweenPan);
1528    tweenPan.easing(Easing.Quadratic.InOut).to({
1529      x,
1530      y,
1531      z
1532    }, duration).onUpdate(({
1533      x: x2,
1534      y: y2,
1535      z: z2
1536    }) => setCamera({
1537      lookAt: toVector({
1538        x: x2,
1539        y: y2,
1540        z: z2
1541      })
1542    }));
1543    const sourceObject3D = new PerspectiveCamera();
1544    injectCameraState(state.camera, sourceObject3D);
1545    const goalObject3D = new PerspectiveCamera();
1546    injectCameraState(goalCamera, goalObject3D);
1547    const goalQuaternion = new Quaternion().copy(goalObject3D.quaternion);
1548    const tweenRotate = new Tween({
1549      t: 0
1550    });
1551    tweens.add(tweenRotate);
1552    return new Promise((resolve) => {
1553      tweenRotate.easing(Easing.Quadratic.InOut).to({
1554        t: 1
1555      }, duration).onUpdate(({
1556        t
1557      }) => {
1558        const sourceQuaternion = new Quaternion().copy(sourceObject3D.quaternion);
1559        sourceQuaternion.slerp(goalQuaternion, t);
1560        const up = toVector(new Vector3(0, 1, 0).applyQuaternion(sourceQuaternion));
1561        const lookDir = toVector(new Vector3(0, 0, -1).applyQuaternion(sourceQuaternion));
1562        setCamera({
1563          up,
1564          lookDir
1565        });
1566      }).onComplete(() => {
1567        resolve();
1568      }).onStop(() => {
1569        resolve();
1570      });
1571      requestAnimationFrame(() => tweens.getAll().map((tween) => tween.start()));
1572    });
1573  };
1574  const providerValue = {
1575    name: props.name,
1576    perspectiveProps,
1577    trackballProps,
1578    state,
1579    globalScale,
1580    resetCamera,
1581    setCamera,
1582    tweenCamera,
1583    cancelTweens,
1584    setLighting,
1585    togglePerspective,
1586    toggleOutlines,
1587    setDistance,
1588    mapViewToWorld,
1589    setTweenDuration
1590  };
1591  return createComponent(CameraContext.Provider, {
1592    value: providerValue,
1593    get children() {
1594      return props.children;
1595    }
1596  });
1597};
1598var useCamera = () => {
1599  return useContext(CameraContext);
1600};
1601var copyOfCamera = (camera) => {
1602  const {
1603    up,
1604    lookAt,
1605    lookDir,
1606    ...rest
1607  } = camera;
1608  return {
1609    ...rest,
1610    up: [...up],
1611    lookAt: [...lookAt],
1612    lookDir: [...lookDir]
1613  };
1614};
1615
1616// src/viewer/context/worker.jsx
1617var createWorker = () => {
1618  const workerPromise = import("./vzome-worker-static.js").then((module) => {
1619    const blob = new Blob([`import "${module.WORKER_ENTRY_FILE_URL}";`], {
1620      type: "text/javascript"
1621    });
1622    const worker = new Worker(URL.createObjectURL(blob), {
1623      type: "module"
1624    });
1625    return new Promise((resolve) => {
1626      worker.onmessage = ({
1627        data
1628      }) => {
1629        worker.onmessage = onWorkerMessage;
1630        resolve(worker);
1631      };
1632      worker.postMessage({
1633        type: "WORKER_PROBE"
1634      });
1635    });
1636  });
1637  const postMessage = (event) => {
1638    workerPromise.then((worker) => {
1639      worker.postMessage(event);
1640    }).catch((error) => {
1641      console.log(error);
1642      console.log("The worker is not available");
1643      onWorkerError("The worker is not available.  Module workers are supported in the latest versions of most browsers.  Please update your browser.");
1644    });
1645  };
1646  const requestPromises = {};
1647  const postRequest = (request) => {
1648    const requestId = generateUUID();
1649    return new Promise((resolve, reject) => {
1650      requestPromises[requestId] = {
1651        resolve,
1652        reject
1653      };
1654      postMessage({
1655        ...request,
1656        requestId
1657      });
1658    });
1659  };
1660  const subscribers = [];
1661  const subscribe = (subscriber) => subscribers.push(subscriber);
1662  const unsubscribe = (subscriber) => {
1663    const index = subscribers.indexOf(subscriber);
1664    if (index > -1) {
1665      subscribers.splice(index, 1);
1666    }
1667  };
1668  const subscribeFor = (type, callback) => {
1669    const subscriber = {
1670      onWorkerError: (error) => {
1671        console.log(error);
1672      },
1673      onWorkerMessage: (data) => {
1674        if (type === data.type) callback(data.payload);
1675      }
1676    };
1677    subscribe(subscriber);
1678    return () => unsubscribe(subscriber);
1679  };
1680  const onWorkerMessage = (message) => {
1681    const {
1682      requestId
1683    } = message.data;
1684    if (!!requestId) {
1685      requestPromises[requestId].resolve(message.data);
1686      return;
1687    }
1688    subscribers.forEach((subscriber) => subscriber.onWorkerMessage(message.data));
1689  };
1690  const onWorkerError = (message) => {
1691    const {
1692      requestId
1693    } = message;
1694    if (!!requestId) {
1695      requestPromises[requestId].reject(message);
1696      return;
1697    }
1698    subscribers.forEach((subscriber) => subscriber.onWorkerError(message));
1699  };
1700  const terminate = () => {
1701    workerPromise.then((worker) => worker.terminate()).catch(() => {
1702    });
1703    subscribers.length = 0;
1704  };
1705  return {
1706    postMessage,
1707    subscribe,
1708    subscribeFor,
1709    unsubscribe,
1710    postRequest,
1711    terminate
1712  };
1713};
1714var stubContext = {
1715  postMessage: () => {
1716    throw new Error("NO WORKER PROVIDER!");
1717  },
1718  postRequest: () => {
1719    throw new Error("NO WORKER PROVIDER!");
1720  },
1721  subscribe: () => {
1722    throw new Error("NO WORKER PROVIDER!");
1723  },
1724  subscribeFor: () => {
1725    throw new Error("NO WORKER PROVIDER!");
1726  }
1727};
1728var WorkerContext = createContext(stubContext);
1729var WorkerProvider = (props) => {
1730  const workerClient = createWorker();
1731  const [isWorkerReady, setReady] = createSignal(false);
1732  workerClient.subscribeFor("CONTROLLER_CREATED", () => setReady(true));
1733  onCleanup(() => workerClient.terminate());
1734  return createComponent(WorkerContext.Provider, {
1735    get value() {
1736      return {
1737        ...workerClient,
1738        isWorkerReady
1739      };
1740    },
1741    get children() {
1742      return props.children;
1743    }
1744  });
1745};
1746var useWorkerClient = () => {
1747  return useContext(WorkerContext);
1748};
1749
1750// src/viewer/context/viewer.jsx
1751var ViewerContext = createContext({
1752  scene: () => {
1753    console.log("NO ViewerProvider");
1754  },
1755  problem: () => null
1756});
1757var ViewerProvider = (props) => {
1758  const {
1759    url,
1760    labels: showLabels,
1761    camera: driveViewFromDesign = true
1762  } = props.config || {};
1763  const [reload, setReload] = createSignal(true);
1764  const [scenes, setScenes] = createStore([]);
1765  const [source, setSource] = createStore({});
1766  const [problem, setProblem] = createSignal("");
1767  const [waiting, setWaiting] = createSignal(false);
1768  const [labels, setLabels] = createSignal(showLabels);
1769  const {
1770    postMessage,
1771    subscribeFor
1772  } = useWorkerClient();
1773  const {
1774    state,
1775    setTweenDuration,
1776    tweenCamera,
1777    setLighting,
1778    mapViewToWorld
1779  } = useCamera();
1780  const indexResources = () => postMessage({
1781    type: "WINDOW_LOCATION",
1782    payload: window.location.toString()
1783  });
1784  const requestDesign = (url2, config) => {
1785    setWaiting(true);
1786    setProblem("");
1787    config.snapshot = -1;
1788    postMessage(fetchDesign(url2, config));
1789  };
1790  const openText = (name, contents) => {
1791    setWaiting(true);
1792    setProblem("");
1793    postMessage(openTextContent(name, contents));
1794  };
1795  url && postMessage(fetchDesign(url, props.config));
1796  let exportPromise = null;
1797  const exportAs = async (format, params = {}) => {
1798    const camera = unwrap(state.camera);
1799    camera.magnification = Math.log(camera.distance / INITIAL_DISTANCE);
1800    const lighting = unwrap(state.lighting);
1801    lighting.directionalLights.forEach((light) => light.worldDirection = mapViewToWorld(light.direction));
1802    return new Promise((resolve, reject) => {
1803      exportPromise = {
1804        resolve,
1805        reject
1806      };
1807      postMessage(requestExport(format, {
1808        ...params,
1809        camera,
1810        lighting,
1811        scenes: unwrap(scenes)
1812      }));
1813    });
1814  };
1815  subscribeFor("TEXT_EXPORTED", ({
1816    text
1817  }) => {
1818    if (exportPromise) {
1819      exportPromise.resolve(text);
1820      exportPromise = null;
1821    }
1822  });
1823  subscribeFor("SCENES_DISCOVERED", ({
1824    lighting,
1825    scenes: scenes2
1826  }) => {
1827    setWaiting(false);
1828    const newScenes = scenes2.map((scene) => ({
1829      ...scene,
1830      title: decodeEntities(scene.title),
1831      content: decodeEntities(scene.content || " ")
1832    }));
1833    setScenes(newScenes);
1834    if (!!lighting && driveViewFromDesign) {
1835      const {
1836        backgroundColor
1837      } = lighting;
1838      setLighting({
1839        ...state.lighting,
1840        backgroundColor
1841      });
1842    }
1843    const camera = scenes2[0].camera;
1844    if (!!camera && driveViewFromDesign)
1845      tweenCamera(camera);
1846  });
1847  subscribeFor("TEXT_FETCHED", (source2) => {
1848    setSource(source2);
1849  });
1850  subscribeFor("ALERT_RAISED", (problem2) => {
1851    if (exportPromise) {
1852      exportPromise.reject(problem2);
1853      exportPromise = null;
1854    } else {
1855      setProblem(problem2);
1856    }
1857    setWaiting(false);
1858  });
1859  const providerValue = {
1860    requestDesign,
1861    openText,
1862    scenes,
1863    source,
1864    setSource,
1865    problem,
1866    waiting,
1867    setWaiting,
1868    labels,
1869    reload,
1870    setReload,
1871    setScenes,
1872    resetScenes: () => setScenes([]),
1873    setProblem,
1874    clearProblem: () => setProblem(""),
1875    requestBOM: (scenes2) => postMessage({
1876      type: "BOM_REQUESTED",
1877      payload: scenes2
1878    }),
1879    setTweenDuration,
1880    useWorker: useWorkerClient,
1881    exportAs,
1882    indexResources
1883  };
1884  return createComponent(ViewerContext.Provider, {
1885    value: providerValue,
1886    get children() {
1887      return props.children;
1888    }
1889  });
1890};
1891var useViewer = () => {
1892  return useContext(ViewerContext);
1893};
1894var EXPORT_FORMATS = {
1895  // Key values are as defined in desktop vZome code.
1896  // 3D Rendering
1897  dae: {
1898    label: "Collada (DAE)",
1899    mime: "model/vnd.collada+xml"
1900  },
1901  gltf: {
1902    label: "glTF",
1903    mime: "model/gltf+json"
1904  },
1905  pov: {
1906    label: "POV-Ray",
1907    mime: "text/plain"
1908  },
1909  shapes: {
1910    label: "vZome Shapes JSON",
1911    mime: "application/json",
1912    ext: "shapes.json"
1913  },
1914  vrml: {
1915    label: "VRML",
1916    mime: "model/vrml"
1917  },
1918  // 3D Panels
1919  stl: {
1920    label: "StL (mm)",
1921    mime: "model/stl"
1922  },
1923  off: {
1924    label: "OFF",
1925    mime: "text/plain"
1926  },
1927  ply: {
1928    label: "PLY",
1929    mime: "text/plain"
1930  },
1931  step: {
1932    label: "STEP",
1933    mime: "application/STEP"
1934  },
1935  // 3D Points & Lines
1936  mesh: {
1937    label: "Simple Mesh JSON",
1938    mime: "application/json",
1939    ext: "mesh.json"
1940  },
1941  cmesh: {
1942    label: "Colored Mesh JSON",
1943    mime: "application/json",
1944    ext: "cmesh.json"
1945  },
1946  dxf: {
1947    label: "AutoCAD DXF",
1948    mime: "application/dxf"
1949  },
1950  // 3D Balls & Sticks
1951  scad: {
1952    label: "OpenSCAD",
1953    mime: "text/plain"
1954  },
1955  build123d: {
1956    label: "Build123d Python",
1957    mime: "text/x-python",
1958    ext: "py"
1959  },
1960  // 2D Vector Drawing
1961  svg: {
1962    label: "SVG",
1963    mime: "image/svg+xml"
1964  },
1965  pdf: {
1966    label: "PDF",
1967    mime: "application/pdf"
1968  },
1969  ps: {
1970    label: "Postscript",
1971    mime: "application/postscript"
1972  },
1973  // Image
1974  png: {
1975    image: true,
1976    label: "PNG",
1977    mime: "image/png"
1978  },
1979  jpg: {
1980    image: true,
1981    label: "JPG",
1982    mime: "image/jpeg"
1983  },
1984  webp: {
1985    image: true,
1986    label: "WEBP",
1987    mime: "image/webp"
1988  },
1989  bmp: {
1990    image: true,
1991    label: "BMP",
1992    mime: "image/bmp"
1993  }
1994};
1995
1996// src/viewer/util/files.js
1997var openFile = async (types) => {
1998  const supportsFileSystemAccess = "showOpenFilePicker" in window && (() => {
1999    try {
2000      return window.self === window.top;
2001    } catch {
2002      return false;
2003    }
2004  })();
2005  if (supportsFileSystemAccess) {
2006    let file = void 0;
2007    try {
2008      const handles = await showOpenFilePicker({ multiple: false, types });
2009      file = await handles[0].getFile();
2010      file.handle = handles[0];
2011    } catch (err) {
2012      if (err.name !== "AbortError") {
2013        console.error(err.name, err.message);
2014      }
2015    }
2016    return file;
2017  }
2018  return new Promise((resolve) => {
2019    const input = document.createElement("input");
2020    input.style.display = "none";
2021    input.type = "file";
2022    document.body.append(input);
2023    input.addEventListener("change", () => {
2024      input.remove();
2025      if (!input.files) {
2026        return;
2027      }
2028      resolve(input.files[0]);
2029    });
2030    if ("showPicker" in HTMLInputElement.prototype) {
2031      input.showPicker();
2032    } else {
2033      input.click();
2034    }
2035  });
2036};
2037var saveTextFile = async (handle, text, type) => {
2038  const blob = new Blob([text], { type });
2039  return saveFile(handle, blob);
2040};
2041var saveFile = async (handle, blob) => {
2042  try {
2043    const writable = await handle.createWritable();
2044    await writable.write(blob);
2045    await writable.close();
2046  } catch (err) {
2047    if (err.name !== "AbortError") {
2048      console.error(err.name, err.message);
2049    }
2050    return { success: false };
2051  }
2052  return { success: true };
2053};
2054var saveTextFileAs = async (suggestedName, text, type) => {
2055  const blob = new Blob([text], { type });
2056  return saveFileAs(suggestedName, blob);
2057};
2058var saveFileAs = async (suggestedName, blob) => {
2059  const supportsFileSystemAccess = "showSaveFilePicker" in window && (() => {
2060    try {
2061      return window.self === window.top;
2062    } catch {
2063      return false;
2064    }
2065  })();
2066  if (supportsFileSystemAccess) {
2067    try {
2068      const handle = await showSaveFilePicker({ suggestedName });
2069      const writable = await handle.createWritable();
2070      await writable.write(blob);
2071      await writable.close();
2072      return { handle, success: true };
2073    } catch (err) {
2074      if (err.name !== "AbortError") {
2075        console.error(err.name, err.message);
2076      }
2077      return { success: false };
2078    }
2079  }
2080  const blobURL = URL.createObjectURL(blob);
2081  const a = document.createElement("a");
2082  a.href = blobURL;
2083  a.download = suggestedName;
2084  a.style.display = "none";
2085  document.body.append(a);
2086  a.click();
2087  setTimeout(() => {
2088    URL.revokeObjectURL(blobURL);
2089    a.remove();
2090  }, 1e3);
2091  return { success: false };
2092};
2093
2094export {
2095  unwrap,
2096  createStore,
2097  createMutable,
2098  reconcile,
2099  produce,
2100  INITIAL_DISTANCE,
2101  defaultCamera,
2102  fixedFrustum,
2103  CameraProvider,
2104  useCamera,
2105  copyOfCamera,
2106  WorkerProvider,
2107  useWorkerClient,
2108  ViewerProvider,
2109  useViewer,
2110  EXPORT_FORMATS,
2111  openFile,
2112  saveTextFile,
2113  saveFile,
2114  saveTextFileAs,
2115  saveFileAs
2116};

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.