Skip to content

CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.

2.8 MB
Raw Blame
const Dt = (o) => typeof o == "string", Pu = () => {
  let o, e;
  const t = new Promise((r, n) => {
    o = r, e = n;
  });
  return t.resolve = o, t.reject = e, t;
}, s0 = (o) => o == null ? "" : "" + o, yF = (o, e, t) => {
  o.forEach((r) => {
    e[r] && (t[r] = e[r]);
  });
}, bF = /###/g, l0 = (o) => o && o.indexOf("###") > -1 ? o.replace(bF, ".") : o, c0 = (o) => !o || Dt(o), uA = (o, e, t) => {
  const r = Dt(e) ? e.split(".") : e;
  let n = 0;
  for (; n < r.length - 1; ) {
    if (c0(o)) return {};
    const i = l0(r[n]);
    !o[i] && t && (o[i] = new t()), Object.prototype.hasOwnProperty.call(o, i) ? o = o[i] : o = {}, ++n;
  }
  return c0(o) ? {} : {
    obj: o,
    k: l0(r[n])
  };
}, u0 = (o, e, t) => {
  const {
    obj: r,
    k: n
  } = uA(o, e, Object);
  if (r !== void 0 || e.length === 1) {
    r[n] = t;
    return;
  }
  let i = e[e.length - 1], a = e.slice(0, e.length - 1), s = uA(o, a, Object);
  for (; s.obj === void 0 && a.length; )
    i = `${a[a.length - 1]}.${i}`, a = a.slice(0, a.length - 1), s = uA(o, a, Object), s?.obj && typeof s.obj[`${s.k}.${i}`] < "u" && (s.obj = void 0);
  s.obj[`${s.k}.${i}`] = t;
}, vF = (o, e, t, r) => {
  const {
    obj: n,
    k: i
  } = uA(o, e, Object);
  n[i] = n[i] || [], n[i].push(t);
}, dh = (o, e) => {
  const {
    obj: t,
    k: r
  } = uA(o, e);
  if (t && Object.prototype.hasOwnProperty.call(t, r))
    return t[r];
}, wF = (o, e, t) => {
  const r = dh(o, t);
  return r !== void 0 ? r : dh(e, t);
}, VB = (o, e, t) => {
  for (const r in e)
    r !== "__proto__" && r !== "constructor" && (r in o ? Dt(o[r]) || o[r] instanceof String || Dt(e[r]) || e[r] instanceof String ? t && (o[r] = e[r]) : VB(o[r], e[r], t) : o[r] = e[r]);
  return o;
}, sc = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var xF = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': "&quot;",
  "'": "&#39;",
  "/": "&#x2F;"
};
const kF = (o) => Dt(o) ? o.replace(/[&<>"'\/]/g, (e) => xF[e]) : o;
class CF {
  constructor(e) {
    this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
  }
  getRegExp(e) {
    const t = this.regExpMap.get(e);
    if (t !== void 0)
      return t;
    const r = new RegExp(e);
    return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, r), this.regExpQueue.push(e), r;
  }
}
const SF = [" ", ",", "?", "!", ";"], BF = new CF(20), EF = (o, e, t) => {
  e = e || "", t = t || "";
  const r = SF.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
  if (r.length === 0) return !0;
  const n = BF.getRegExp(`(${r.map((a) => a === "?" ? "\\?" : a).join("|")})`);
  let i = !n.test(o);
  if (!i) {
    const a = o.indexOf(t);
    a > 0 && !n.test(o.substring(0, a)) && (i = !0);
  }
  return i;
}, Ky = (o, e, t = ".") => {
  if (!o) return;
  if (o[e])
    return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
  const r = e.split(t);
  let n = o;
  for (let i = 0; i < r.length; ) {
    if (!n || typeof n != "object")
      return;
    let a, s = "";
    for (let l = i; l < r.length; ++l)
      if (l !== i && (s += t), s += r[l], a = n[s], a !== void 0) {
        if (["string", "number", "boolean"].indexOf(typeof a) > -1 && l < r.length - 1)
          continue;
        i += l - i + 1;
        break;
      }
    n = a;
  }
  return n;
}, EA = (o) => o?.replace("_", "-"), jF = {
  type: "logger",
  log(o) {
    this.output("log", o);
  },
  warn(o) {
    this.output("warn", o);
  },
  error(o) {
    this.output("error", o);
  },
  output(o, e) {
    console?.[o]?.apply?.(console, e);
  }
};
class ph {
  constructor(e, t = {}) {
    this.init(e, t);
  }
  init(e, t = {}) {
    this.prefix = t.prefix || "i18next:", this.logger = e || jF, this.options = t, this.debug = t.debug;
  }
  log(...e) {
    return this.forward(e, "log", "", !0);
  }
  warn(...e) {
    return this.forward(e, "warn", "", !0);
  }
  error(...e) {
    return this.forward(e, "error", "");
  }
  deprecate(...e) {
    return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
  }
  forward(e, t, r, n) {
    return n && !this.debug ? null : (Dt(e[0]) && (e[0] = `${r}${this.prefix} ${e[0]}`), this.logger[t](e));
  }
  create(e) {
    return new ph(this.logger, {
      prefix: `${this.prefix}:${e}:`,
      ...this.options
    });
  }
  clone(e) {
    return e = e || this.options, e.prefix = e.prefix || this.prefix, new ph(this.logger, e);
  }
}
var sa = new ph();
class Rh {
  constructor() {
    this.observers = {};
  }
  on(e, t) {
    return e.split(" ").forEach((r) => {
      this.observers[r] || (this.observers[r] = /* @__PURE__ */ new Map());
      const n = this.observers[r].get(t) || 0;
      this.observers[r].set(t, n + 1);
    }), this;
  }
  off(e, t) {
    if (this.observers[e]) {
      if (!t) {
        delete this.observers[e];
        return;
      }
      this.observers[e].delete(t);
    }
  }
  emit(e, ...t) {
    this.observers[e] && Array.from(this.observers[e].entries()).forEach(([n, i]) => {
      for (let a = 0; a < i; a++)
        n(...t);
    }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, i]) => {
      for (let a = 0; a < i; a++)
        n.apply(n, [e, ...t]);
    });
  }
}
class A0 extends Rh {
  constructor(e, t = {
    ns: ["translation"],
    defaultNS: "translation"
  }) {
    super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
  }
  addNamespaces(e) {
    this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
  }
  removeNamespaces(e) {
    const t = this.options.ns.indexOf(e);
    t > -1 && this.options.ns.splice(t, 1);
  }
  getResource(e, t, r, n = {}) {
    const i = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, a = n.ignoreJSONStructure !== void 0 ? n.ignoreJSONStructure : this.options.ignoreJSONStructure;
    let s;
    e.indexOf(".") > -1 ? s = e.split(".") : (s = [e, t], r && (Array.isArray(r) ? s.push(...r) : Dt(r) && i ? s.push(...r.split(i)) : s.push(r)));
    const l = dh(this.data, s);
    return !l && !t && !r && e.indexOf(".") > -1 && (e = s[0], t = s[1], r = s.slice(2).join(".")), l || !a || !Dt(r) ? l : Ky(this.data?.[e]?.[t], r, i);
  }
  addResource(e, t, r, n, i = {
    silent: !1
  }) {
    const a = i.keySeparator !== void 0 ? i.keySeparator : this.options.keySeparator;
    let s = [e, t];
    r && (s = s.concat(a ? r.split(a) : r)), e.indexOf(".") > -1 && (s = e.split("."), n = t, t = s[1]), this.addNamespaces(t), u0(this.data, s, n), i.silent || this.emit("added", e, t, r, n);
  }
  addResources(e, t, r, n = {
    silent: !1
  }) {
    for (const i in r)
      (Dt(r[i]) || Array.isArray(r[i])) && this.addResource(e, t, i, r[i], {
        silent: !0
      });
    n.silent || this.emit("added", e, t, r);
  }
  addResourceBundle(e, t, r, n, i, a = {
    silent: !1,
    skipCopy: !1
  }) {
    let s = [e, t];
    e.indexOf(".") > -1 && (s = e.split("."), n = r, r = t, t = s[1]), this.addNamespaces(t);
    let l = dh(this.data, s) || {};
    a.skipCopy || (r = JSON.parse(JSON.stringify(r))), n ? VB(l, r, i) : l = {
      ...l,
      ...r
    }, u0(this.data, s, l), a.silent || this.emit("added", e, t, r);
  }
  removeResourceBundle(e, t) {
    this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
  }
  hasResourceBundle(e, t) {
    return this.getResource(e, t) !== void 0;
  }
  getResourceBundle(e, t) {
    return t || (t = this.options.defaultNS), this.getResource(e, t);
  }
  getDataByLanguage(e) {
    return this.data[e];
  }
  hasLanguageSomeTranslations(e) {
    const t = this.getDataByLanguage(e);
    return !!(t && Object.keys(t) || []).find((n) => t[n] && Object.keys(t[n]).length > 0);
  }
  toJSON() {
    return this.data;
  }
}
var DB = {
  processors: {},
  addPostProcessor(o) {
    this.processors[o.name] = o;
  },
  handle(o, e, t, r, n) {
    return o.forEach((i) => {
      e = this.processors[i]?.process(e, t, r, n) ?? e;
    }), e;
  }
};
const HB = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
function LF() {
  const o = [], e = /* @__PURE__ */ Object.create(null);
  let t;
  return e.get = (r, n) => (t?.revoke?.(), n === HB ? o : (o.push(n), t = Proxy.revocable(r, e), t.proxy)), Proxy.revocable(/* @__PURE__ */ Object.create(null), e).proxy;
}
function $y(o, e) {
  const {
    [HB]: t
  } = o(LF());
  return t.join(e?.keySeparator ?? ".");
}
const d0 = {}, t_ = (o) => !Dt(o) && typeof o != "boolean" && typeof o != "number";
class hh extends Rh {
  constructor(e, t = {}) {
    super(), yF(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = sa.create("translator");
  }
  changeLanguage(e) {
    e && (this.language = e);
  }
  exists(e, t = {
    interpolation: {}
  }) {
    const r = {
      ...t
    };
    if (e == null) return !1;
    const n = this.resolve(e, r);
    if (n?.res === void 0) return !1;
    const i = t_(n.res);
    return !(r.returnObjects === !1 && i);
  }
  extractFromKey(e, t) {
    let r = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
    r === void 0 && (r = ":");
    const n = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
    let i = t.ns || this.options.defaultNS || [];
    const a = r && e.indexOf(r) > -1, s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !EF(e, r, n);
    if (a && !s) {
      const l = e.match(this.interpolator.nestingRegexp);
      if (l && l.length > 0)
        return {
          key: e,
          namespaces: Dt(i) ? [i] : i
        };
      const c = e.split(r);
      (r !== n || r === n && this.options.ns.indexOf(c[0]) > -1) && (i = c.shift()), e = c.join(n);
    }
    return {
      key: e,
      namespaces: Dt(i) ? [i] : i
    };
  }
  translate(e, t, r) {
    let n = typeof t == "object" ? {
      ...t
    } : t;
    if (typeof n != "object" && this.options.overloadTranslationOptionHandler && (n = this.options.overloadTranslationOptionHandler(arguments)), typeof n == "object" && (n = {
      ...n
    }), n || (n = {}), e == null) return "";
    typeof e == "function" && (e = $y(e, {
      ...this.options,
      ...n
    })), Array.isArray(e) || (e = [String(e)]);
    const i = n.returnDetails !== void 0 ? n.returnDetails : this.options.returnDetails, a = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, {
      key: s,
      namespaces: l
    } = this.extractFromKey(e[e.length - 1], n), c = l[l.length - 1];
    let u = n.nsSeparator !== void 0 ? n.nsSeparator : this.options.nsSeparator;
    u === void 0 && (u = ":");
    const A = n.lng || this.language, p = n.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
    if (A?.toLowerCase() === "cimode")
      return p ? i ? {
        res: `${c}${u}${s}`,
        usedKey: s,
        exactUsedKey: s,
        usedLng: A,
        usedNS: c,
        usedParams: this.getUsedParamsDetails(n)
      } : `${c}${u}${s}` : i ? {
        res: s,
        usedKey: s,
        exactUsedKey: s,
        usedLng: A,
        usedNS: c,
        usedParams: this.getUsedParamsDetails(n)
      } : s;
    const d = this.resolve(e, n);
    let g = d?.res;
    const _ = d?.usedKey || s, f = d?.exactUsedKey || s, m = ["[object Number]", "[object Function]", "[object RegExp]"], b = n.joinArrays !== void 0 ? n.joinArrays : this.options.joinArrays, v = !this.i18nFormat || this.i18nFormat.handleAsObject, w = n.count !== void 0 && !Dt(n.count), C = hh.hasDefaultValue(n), E = w ? this.pluralResolver.getSuffix(A, n.count, n) : "", T = n.ordinal && w ? this.pluralResolver.getSuffix(A, n.count, {
      ordinal: !1
    }) : "", F = w && !n.ordinal && n.count === 0, B = F && n[`defaultValue${this.options.pluralSeparator}zero`] || n[`defaultValue${E}`] || n[`defaultValue${T}`] || n.defaultValue;
    let P = g;
    v && !g && C && (P = B);
    const S = t_(P), L = Object.prototype.toString.apply(P);
    if (v && P && S && m.indexOf(L) < 0 && !(Dt(b) && Array.isArray(P))) {
      if (!n.returnObjects && !this.options.returnObjects) {
        this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
        const U = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(_, P, {
          ...n,
          ns: l
        }) : `key '${s} (${this.language})' returned an object instead of string.`;
        return i ? (d.res = U, d.usedParams = this.getUsedParamsDetails(n), d) : U;
      }
      if (a) {
        const U = Array.isArray(P), O = U ? [] : {}, K = U ? f : _;
        for (const te in P)
          if (Object.prototype.hasOwnProperty.call(P, te)) {
            const Y = `${K}${a}${te}`;
            C && !g ? O[te] = this.translate(Y, {
              ...n,
              defaultValue: t_(B) ? B[te] : void 0,
              joinArrays: !1,
              ns: l
            }) : O[te] = this.translate(Y, {
              ...n,
              joinArrays: !1,
              ns: l
            }), O[te] === Y && (O[te] = P[te]);
          }
        g = O;
      }
    } else if (v && Dt(b) && Array.isArray(g))
      g = g.join(b), g && (g = this.extendTranslation(g, e, n, r));
    else {
      let U = !1, O = !1;
      !this.isValidLookup(g) && C && (U = !0, g = B), this.isValidLookup(g) || (O = !0, g = s);
      const te = (n.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && O ? void 0 : g, Y = C && B !== g && this.options.updateMissing;
      if (O || U || Y) {
        if (this.logger.log(Y ? "updateKey" : "missingKey", A, c, s, Y ? B : g), a) {
          const ae = this.resolve(s, {
            ...n,
            keySeparator: !1
          });
          ae && ae.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
        }
        let ee = [];
        const oe = this.languageUtils.getFallbackCodes(this.options.fallbackLng, n.lng || this.language);
        if (this.options.saveMissingTo === "fallback" && oe && oe[0])
          for (let ae = 0; ae < oe.length; ae++)
            ee.push(oe[ae]);
        else this.options.saveMissingTo === "all" ? ee = this.languageUtils.toResolveHierarchy(n.lng || this.language) : ee.push(n.lng || this.language);
        const de = (ae, I, G) => {
          const H = C && G !== g ? G : te;
          this.options.missingKeyHandler ? this.options.missingKeyHandler(ae, c, I, H, Y, n) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(ae, c, I, H, Y, n), this.emit("missingKey", ae, c, I, g);
        };
        this.options.saveMissing && (this.options.saveMissingPlurals && w ? ee.forEach((ae) => {
          const I = this.pluralResolver.getSuffixes(ae, n);
          F && n[`defaultValue${this.options.pluralSeparator}zero`] && I.indexOf(`${this.options.pluralSeparator}zero`) < 0 && I.push(`${this.options.pluralSeparator}zero`), I.forEach((G) => {
            de([ae], s + G, n[`defaultValue${G}`] || B);
          });
        }) : de(ee, s, B));
      }
      g = this.extendTranslation(g, e, n, d, r), O && g === s && this.options.appendNamespaceToMissingKey && (g = `${c}${u}${s}`), (O || U) && this.options.parseMissingKeyHandler && (g = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${c}${u}${s}` : s, U ? g : void 0, n));
    }
    return i ? (d.res = g, d.usedParams = this.getUsedParamsDetails(n), d) : g;
  }
  extendTranslation(e, t, r, n, i) {
    if (this.i18nFormat?.parse)
      e = this.i18nFormat.parse(e, {
        ...this.options.interpolation.defaultVariables,
        ...r
      }, r.lng || this.language || n.usedLng, n.usedNS, n.usedKey, {
        resolved: n
      });
    else if (!r.skipInterpolation) {
      r.interpolation && this.interpolator.init({
        ...r,
        interpolation: {
          ...this.options.interpolation,
          ...r.interpolation
        }
      });
      const l = Dt(e) && (r?.interpolation?.skipOnVariables !== void 0 ? r.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
      let c;
      if (l) {
        const A = e.match(this.interpolator.nestingRegexp);
        c = A && A.length;
      }
      let u = r.replace && !Dt(r.replace) ? r.replace : r;
      if (this.options.interpolation.defaultVariables && (u = {
        ...this.options.interpolation.defaultVariables,
        ...u
      }), e = this.interpolator.interpolate(e, u, r.lng || this.language || n.usedLng, r), l) {
        const A = e.match(this.interpolator.nestingRegexp), p = A && A.length;
        c < p && (r.nest = !1);
      }
      !r.lng && n && n.res && (r.lng = this.language || n.usedLng), r.nest !== !1 && (e = this.interpolator.nest(e, (...A) => i?.[0] === A[0] && !r.context ? (this.logger.warn(`It seems you are nesting recursively key: ${A[0]} in key: ${t[0]}`), null) : this.translate(...A, t), r)), r.interpolation && this.interpolator.reset();
    }
    const a = r.postProcess || this.options.postProcess, s = Dt(a) ? [a] : a;
    return e != null && s?.length && r.applyPostProcessor !== !1 && (e = DB.handle(s, e, t, this.options && this.options.postProcessPassResolved ? {
      i18nResolved: {
        ...n,
        usedParams: this.getUsedParamsDetails(r)
      },
      ...r
    } : r, this)), e;
  }
  resolve(e, t = {}) {
    let r, n, i, a, s;
    return Dt(e) && (e = [e]), e.forEach((l) => {
      if (this.isValidLookup(r)) return;
      const c = this.extractFromKey(l, t), u = c.key;
      n = u;
      let A = c.namespaces;
      this.options.fallbackNS && (A = A.concat(this.options.fallbackNS));
      const p = t.count !== void 0 && !Dt(t.count), d = p && !t.ordinal && t.count === 0, g = t.context !== void 0 && (Dt(t.context) || typeof t.context == "number") && t.context !== "", _ = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
      A.forEach((f) => {
        this.isValidLookup(r) || (s = f, !d0[`${_[0]}-${f}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (d0[`${_[0]}-${f}`] = !0, this.logger.warn(`key "${n}" for languages "${_.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), _.forEach((m) => {
          if (this.isValidLookup(r)) return;
          a = m;
          const b = [u];
          if (this.i18nFormat?.addLookupKeys)
            this.i18nFormat.addLookupKeys(b, u, m, f, t);
          else {
            let w;
            p && (w = this.pluralResolver.getSuffix(m, t.count, t));
            const C = `${this.options.pluralSeparator}zero`, E = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
            if (p && (t.ordinal && w.indexOf(E) === 0 && b.push(u + w.replace(E, this.options.pluralSeparator)), b.push(u + w), d && b.push(u + C)), g) {
              const T = `${u}${this.options.contextSeparator || "_"}${t.context}`;
              b.push(T), p && (t.ordinal && w.indexOf(E) === 0 && b.push(T + w.replace(E, this.options.pluralSeparator)), b.push(T + w), d && b.push(T + C));
            }
          }
          let v;
          for (; v = b.pop(); )
            this.isValidLookup(r) || (i = v, r = this.getResource(m, f, v, t));
        }));
      });
    }), {
      res: r,
      usedKey: n,
      exactUsedKey: i,
      usedLng: a,
      usedNS: s
    };
  }
  isValidLookup(e) {
    return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
  }
  getResource(e, t, r, n = {}) {
    return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, r, n) : this.resourceStore.getResource(e, t, r, n);
  }
  getUsedParamsDetails(e = {}) {
    const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], r = e.replace && !Dt(e.replace);
    let n = r ? e.replace : e;
    if (r && typeof e.count < "u" && (n.count = e.count), this.options.interpolation.defaultVariables && (n = {
      ...this.options.interpolation.defaultVariables,
      ...n
    }), !r) {
      n = {
        ...n
      };
      for (const i of t)
        delete n[i];
    }
    return n;
  }
  static hasDefaultValue(e) {
    const t = "defaultValue";
    for (const r in e)
      if (Object.prototype.hasOwnProperty.call(e, r) && t === r.substring(0, t.length) && e[r] !== void 0)
        return !0;
    return !1;
  }
}
class p0 {
  constructor(e) {
    this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = sa.create("languageUtils");
  }
  getScriptPartFromCode(e) {
    if (e = EA(e), !e || e.indexOf("-") < 0) return null;
    const t = e.split("-");
    return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
  }
  getLanguagePartFromCode(e) {
    if (e = EA(e), !e || e.indexOf("-") < 0) return e;
    const t = e.split("-");
    return this.formatLanguageCode(t[0]);
  }
  formatLanguageCode(e) {
    if (Dt(e) && e.indexOf("-") > -1) {
      let t;
      try {
        t = Intl.getCanonicalLocales(e)[0];
      } catch {
      }
      return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
    }
    return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
  }
  isSupportedCode(e) {
    return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
  }
  getBestMatchFromCodes(e) {
    if (!e) return null;
    let t;
    return e.forEach((r) => {
      if (t) return;
      const n = this.formatLanguageCode(r);
      (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
    }), !t && this.options.supportedLngs && e.forEach((r) => {
      if (t) return;
      const n = this.getScriptPartFromCode(r);
      if (this.isSupportedCode(n)) return t = n;
      const i = this.getLanguagePartFromCode(r);
      if (this.isSupportedCode(i)) return t = i;
      t = this.options.supportedLngs.find((a) => {
        if (a === i) return a;
        if (!(a.indexOf("-") < 0 && i.indexOf("-") < 0) && (a.indexOf("-") > 0 && i.indexOf("-") < 0 && a.substring(0, a.indexOf("-")) === i || a.indexOf(i) === 0 && i.length > 1))
          return a;
      });
    }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
  }
  getFallbackCodes(e, t) {
    if (!e) return [];
    if (typeof e == "function" && (e = e(t)), Dt(e) && (e = [e]), Array.isArray(e)) return e;
    if (!t) return e.default || [];
    let r = e[t];
    return r || (r = e[this.getScriptPartFromCode(t)]), r || (r = e[this.formatLanguageCode(t)]), r || (r = e[this.getLanguagePartFromCode(t)]), r || (r = e.default), r || [];
  }
  toResolveHierarchy(e, t) {
    const r = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), n = [], i = (a) => {
      a && (this.isSupportedCode(a) ? n.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
    };
    return Dt(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : Dt(e) && i(this.formatLanguageCode(e)), r.forEach((a) => {
      n.indexOf(a) < 0 && i(this.formatLanguageCode(a));
    }), n;
  }
}
const h0 = {
  zero: 0,
  one: 1,
  two: 2,
  few: 3,
  many: 4,
  other: 5
}, g0 = {
  select: (o) => o === 1 ? "one" : "other",
  resolvedOptions: () => ({
    pluralCategories: ["one", "other"]
  })
};
class TF {
  constructor(e, t = {}) {
    this.languageUtils = e, this.options = t, this.logger = sa.create("pluralResolver"), this.pluralRulesCache = {};
  }
  clearCache() {
    this.pluralRulesCache = {};
  }
  getRule(e, t = {}) {
    const r = EA(e === "dev" ? "en" : e), n = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
      cleanedCode: r,
      type: n
    });
    if (i in this.pluralRulesCache)
      return this.pluralRulesCache[i];
    let a;
    try {
      a = new Intl.PluralRules(r, {
        type: n
      });
    } catch {
      if (!Intl)
        return this.logger.error("No Intl support, please use an Intl polyfill!"), g0;
      if (!e.match(/-|_/)) return g0;
      const l = this.languageUtils.getLanguagePartFromCode(e);
      a = this.getRule(l, t);
    }
    return this.pluralRulesCache[i] = a, a;
  }
  needsPlural(e, t = {}) {
    let r = this.getRule(e, t);
    return r || (r = this.getRule("dev", t)), r?.resolvedOptions().pluralCategories.length > 1;
  }
  getPluralFormsOfKey(e, t, r = {}) {
    return this.getSuffixes(e, r).map((n) => `${t}${n}`);
  }
  getSuffixes(e, t = {}) {
    let r = this.getRule(e, t);
    return r || (r = this.getRule("dev", t)), r ? r.resolvedOptions().pluralCategories.sort((n, i) => h0[n] - h0[i]).map((n) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${n}`) : [];
  }
  getSuffix(e, t, r = {}) {
    const n = this.getRule(e, r);
    return n ? `${this.options.prepend}${r.ordinal ? `ordinal${this.options.prepend}` : ""}${n.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, r));
  }
}
const _0 = (o, e, t, r = ".", n = !0) => {
  let i = wF(o, e, t);
  return !i && n && Dt(t) && (i = Ky(o, t, r), i === void 0 && (i = Ky(e, t, r))), i;
}, r_ = (o) => o.replace(/\$/g, "$$$$");
class f0 {
  constructor(e = {}) {
    this.logger = sa.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((t) => t), this.init(e);
  }
  init(e = {}) {
    e.interpolation || (e.interpolation = {
      escapeValue: !0
    });
    const {
      escape: t,
      escapeValue: r,
      useRawValueToEscape: n,
      prefix: i,
      prefixEscaped: a,
      suffix: s,
      suffixEscaped: l,
      formatSeparator: c,
      unescapeSuffix: u,
      unescapePrefix: A,
      nestingPrefix: p,
      nestingPrefixEscaped: d,
      nestingSuffix: g,
      nestingSuffixEscaped: _,
      nestingOptionsSeparator: f,
      maxReplaces: m,
      alwaysFormat: b
    } = e.interpolation;
    this.escape = t !== void 0 ? t : kF, this.escapeValue = r !== void 0 ? r : !0, this.useRawValueToEscape = n !== void 0 ? n : !1, this.prefix = i ? sc(i) : a || "{{", this.suffix = s ? sc(s) : l || "}}", this.formatSeparator = c || ",", this.unescapePrefix = u ? "" : A || "-", this.unescapeSuffix = this.unescapePrefix ? "" : u || "", this.nestingPrefix = p ? sc(p) : d || sc("$t("), this.nestingSuffix = g ? sc(g) : _ || sc(")"), this.nestingOptionsSeparator = f || ",", this.maxReplaces = m || 1e3, this.alwaysFormat = b !== void 0 ? b : !1, this.resetRegExp();
  }
  reset() {
    this.options && this.init(this.options);
  }
  resetRegExp() {
    const e = (t, r) => t?.source === r ? (t.lastIndex = 0, t) : new RegExp(r, "g");
    this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
  }
  interpolate(e, t, r, n) {
    let i, a, s;
    const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (d) => {
      if (d.indexOf(this.formatSeparator) < 0) {
        const m = _0(t, l, d, this.options.keySeparator, this.options.ignoreJSONStructure);
        return this.alwaysFormat ? this.format(m, void 0, r, {
          ...n,
          ...t,
          interpolationkey: d
        }) : m;
      }
      const g = d.split(this.formatSeparator), _ = g.shift().trim(), f = g.join(this.formatSeparator).trim();
      return this.format(_0(t, l, _, this.options.keySeparator, this.options.ignoreJSONStructure), f, r, {
        ...n,
        ...t,
        interpolationkey: _
      });
    };
    this.resetRegExp();
    const u = n?.missingInterpolationHandler || this.options.missingInterpolationHandler, A = n?.interpolation?.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
    return [{
      regex: this.regexpUnescape,
      safeValue: (d) => r_(d)
    }, {
      regex: this.regexp,
      safeValue: (d) => this.escapeValue ? r_(this.escape(d)) : r_(d)
    }].forEach((d) => {
      for (s = 0; i = d.regex.exec(e); ) {
        const g = i[1].trim();
        if (a = c(g), a === void 0)
          if (typeof u == "function") {
            const f = u(e, i, n);
            a = Dt(f) ? f : "";
          } else if (n && Object.prototype.hasOwnProperty.call(n, g))
            a = "";
          else if (A) {
            a = i[0];
            continue;
          } else
            this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`), a = "";
        else !Dt(a) && !this.useRawValueToEscape && (a = s0(a));
        const _ = d.safeValue(a);
        if (e = e.replace(i[0], _), A ? (d.regex.lastIndex += a.length, d.regex.lastIndex -= i[0].length) : d.regex.lastIndex = 0, s++, s >= this.maxReplaces)
          break;
      }
    }), e;
  }
  nest(e, t, r = {}) {
    let n, i, a;
    const s = (l, c) => {
      const u = this.nestingOptionsSeparator;
      if (l.indexOf(u) < 0) return l;
      const A = l.split(new RegExp(`${u}[ ]*{`));
      let p = `{${A[1]}`;
      l = A[0], p = this.interpolate(p, a);
      const d = p.match(/'/g), g = p.match(/"/g);
      ((d?.length ?? 0) % 2 === 0 && !g || g.length % 2 !== 0) && (p = p.replace(/'/g, '"'));
      try {
        a = JSON.parse(p), c && (a = {
          ...c,
          ...a
        });
      } catch (_) {
        return this.logger.warn(`failed parsing options string in nesting for key ${l}`, _), `${l}${u}${p}`;
      }
      return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, l;
    };
    for (; n = this.nestingRegexp.exec(e); ) {
      let l = [];
      a = {
        ...r
      }, a = a.replace && !Dt(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
      const c = /{.*}/.test(n[1]) ? n[1].lastIndexOf("}") + 1 : n[1].indexOf(this.formatSeparator);
      if (c !== -1 && (l = n[1].slice(c).split(this.formatSeparator).map((u) => u.trim()).filter(Boolean), n[1] = n[1].slice(0, c)), i = t(s.call(this, n[1].trim(), a), a), i && n[0] === e && !Dt(i)) return i;
      Dt(i) || (i = s0(i)), i || (this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`), i = ""), l.length && (i = l.reduce((u, A) => this.format(u, A, r.lng, {
        ...r,
        interpolationkey: n[1].trim()
      }), i.trim())), e = e.replace(n[0], i), this.regexp.lastIndex = 0;
    }
    return e;
  }
}
const PF = (o) => {
  let e = o.toLowerCase().trim();
  const t = {};
  if (o.indexOf("(") > -1) {
    const r = o.split("(");
    e = r[0].toLowerCase().trim();
    const n = r[1].substring(0, r[1].length - 1);
    e === "currency" && n.indexOf(":") < 0 ? t.currency || (t.currency = n.trim()) : e === "relativetime" && n.indexOf(":") < 0 ? t.range || (t.range = n.trim()) : n.split(";").forEach((a) => {
      if (a) {
        const [s, ...l] = a.split(":"), c = l.join(":").trim().replace(/^'+|'+$/g, ""), u = s.trim();
        t[u] || (t[u] = c), c === "false" && (t[u] = !1), c === "true" && (t[u] = !0), isNaN(c) || (t[u] = parseInt(c, 10));
      }
    });
  }
  return {
    formatName: e,
    formatOptions: t
  };
}, m0 = (o) => {
  const e = {};
  return (t, r, n) => {
    let i = n;
    n && n.interpolationkey && n.formatParams && n.formatParams[n.interpolationkey] && n[n.interpolationkey] && (i = {
      ...i,
      [n.interpolationkey]: void 0
    });
    const a = r + JSON.stringify(i);
    let s = e[a];
    return s || (s = o(EA(r), n), e[a] = s), s(t);
  };
}, FF = (o) => (e, t, r) => o(EA(t), r)(e);
class UF {
  constructor(e = {}) {
    this.logger = sa.create("formatter"), this.options = e, this.init(e);
  }
  init(e, t = {
    interpolation: {}
  }) {
    this.formatSeparator = t.interpolation.formatSeparator || ",";
    const r = t.cacheInBuiltFormats ? m0 : FF;
    this.formats = {
      number: r((n, i) => {
        const a = new Intl.NumberFormat(n, {
          ...i
        });
        return (s) => a.format(s);
      }),
      currency: r((n, i) => {
        const a = new Intl.NumberFormat(n, {
          ...i,
          style: "currency"
        });
        return (s) => a.format(s);
      }),
      datetime: r((n, i) => {
        const a = new Intl.DateTimeFormat(n, {
          ...i
        });
        return (s) => a.format(s);
      }),
      relativetime: r((n, i) => {
        const a = new Intl.RelativeTimeFormat(n, {
          ...i
        });
        return (s) => a.format(s, i.range || "day");
      }),
      list: r((n, i) => {
        const a = new Intl.ListFormat(n, {
          ...i
        });
        return (s) => a.format(s);
      })
    };
  }
  add(e, t) {
    this.formats[e.toLowerCase().trim()] = t;
  }
  addCached(e, t) {
    this.formats[e.toLowerCase().trim()] = m0(t);
  }
  format(e, t, r, n = {}) {
    const i = t.split(this.formatSeparator);
    if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((s) => s.indexOf(")") > -1)) {
      const s = i.findIndex((l) => l.indexOf(")") > -1);
      i[0] = [i[0], ...i.splice(1, s)].join(this.formatSeparator);
    }
    return i.reduce((s, l) => {
      const {
        formatName: c,
        formatOptions: u
      } = PF(l);
      if (this.formats[c]) {
        let A = s;
        try {
          const p = n?.formatParams?.[n.interpolationkey] || {}, d = p.locale || p.lng || n.locale || n.lng || r;
          A = this.formats[c](s, d, {
            ...u,
            ...n,
            ...p
          });
        } catch (p) {
          this.logger.warn(p);
        }
        return A;
      } else
        this.logger.warn(`there was no format function for ${c}`);
      return s;
    }, e);
  }
}
const NF = (o, e) => {
  o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
};
class IF extends Rh {
  constructor(e, t, r, n = {}) {
    super(), this.backend = e, this.store = t, this.services = r, this.languageUtils = r.languageUtils, this.options = n, this.logger = sa.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(r, n.backend, n);
  }
  queueLoad(e, t, r, n) {
    const i = {}, a = {}, s = {}, l = {};
    return e.forEach((c) => {
      let u = !0;
      t.forEach((A) => {
        const p = `${c}|${A}`;
        !r.reload && this.store.hasResourceBundle(c, A) ? this.state[p] = 2 : this.state[p] < 0 || (this.state[p] === 1 ? a[p] === void 0 && (a[p] = !0) : (this.state[p] = 1, u = !1, a[p] === void 0 && (a[p] = !0), i[p] === void 0 && (i[p] = !0), l[A] === void 0 && (l[A] = !0)));
      }), u || (s[c] = !0);
    }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
      pending: a,
      pendingCount: Object.keys(a).length,
      loaded: {},
      errors: [],
      callback: n
    }), {
      toLoad: Object.keys(i),
      pending: Object.keys(a),
      toLoadLanguages: Object.keys(s),
      toLoadNamespaces: Object.keys(l)
    };
  }
  loaded(e, t, r) {
    const n = e.split("|"), i = n[0], a = n[1];
    t && this.emit("failedLoading", i, a, t), !t && r && this.store.addResourceBundle(i, a, r, void 0, void 0, {
      skipCopy: !0
    }), this.state[e] = t ? -1 : 2, t && r && (this.state[e] = 0);
    const s = {};
    this.queue.forEach((l) => {
      vF(l.loaded, [i], a), NF(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((c) => {
        s[c] || (s[c] = {});
        const u = l.loaded[c];
        u.length && u.forEach((A) => {
          s[c][A] === void 0 && (s[c][A] = !0);
        });
      }), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback());
    }), this.emit("loaded", s), this.queue = this.queue.filter((l) => !l.done);
  }
  read(e, t, r, n = 0, i = this.retryTimeout, a) {
    if (!e.length) return a(null, {});
    if (this.readingCalls >= this.maxParallelReads) {
      this.waitingReads.push({
        lng: e,
        ns: t,
        fcName: r,
        tried: n,
        wait: i,
        callback: a
      });
      return;
    }
    this.readingCalls++;
    const s = (c, u) => {
      if (this.readingCalls--, this.waitingReads.length > 0) {
        const A = this.waitingReads.shift();
        this.read(A.lng, A.ns, A.fcName, A.tried, A.wait, A.callback);
      }
      if (c && u && n < this.maxRetries) {
        setTimeout(() => {
          this.read.call(this, e, t, r, n + 1, i * 2, a);
        }, i);
        return;
      }
      a(c, u);
    }, l = this.backend[r].bind(this.backend);
    if (l.length === 2) {
      try {
        const c = l(e, t);
        c && typeof c.then == "function" ? c.then((u) => s(null, u)).catch(s) : s(null, c);
      } catch (c) {
        s(c);
      }
      return;
    }
    return l(e, t, s);
  }
  prepareLoading(e, t, r = {}, n) {
    if (!this.backend)
      return this.logger.warn("No backend was added via i18next.use. Will not load resources."), n && n();
    Dt(e) && (e = this.languageUtils.toResolveHierarchy(e)), Dt(t) && (t = [t]);
    const i = this.queueLoad(e, t, r, n);
    if (!i.toLoad.length)
      return i.pending.length || n(), null;
    i.toLoad.forEach((a) => {
      this.loadOne(a);
    });
  }
  load(e, t, r) {
    this.prepareLoading(e, t, {}, r);
  }
  reload(e, t, r) {
    this.prepareLoading(e, t, {
      reload: !0
    }, r);
  }
  loadOne(e, t = "") {
    const r = e.split("|"), n = r[0], i = r[1];
    this.read(n, i, "read", void 0, void 0, (a, s) => {
      a && this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`, a), !a && s && this.logger.log(`${t}loaded namespace ${i} for language ${n}`, s), this.loaded(e, a, s);
    });
  }
  saveMissing(e, t, r, n, i, a = {}, s = () => {
  }) {
    if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
      this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
      return;
    }
    if (!(r == null || r === "")) {
      if (this.backend?.create) {
        const l = {
          ...a,
          isUpdate: i
        }, c = this.backend.create.bind(this.backend);
        if (c.length < 6)
          try {
            let u;
            c.length === 5 ? u = c(e, t, r, n, l) : u = c(e, t, r, n), u && typeof u.then == "function" ? u.then((A) => s(null, A)).catch(s) : s(null, u);
          } catch (u) {
            s(u);
          }
        else
          c(e, t, r, n, s, l);
      }
      !e || !e[0] || this.store.addResource(e[0], t, r, n);
    }
  }
}
const o_ = () => ({
  debug: !1,
  initAsync: !0,
  ns: ["translation"],
  defaultNS: ["translation"],
  fallbackLng: ["dev"],
  fallbackNS: !1,
  supportedLngs: !1,
  nonExplicitSupportedLngs: !1,
  load: "all",
  preload: !1,
  simplifyPluralSuffix: !0,
  keySeparator: ".",
  nsSeparator: ":",
  pluralSeparator: "_",
  contextSeparator: "_",
  partialBundledLanguages: !1,
  saveMissing: !1,
  updateMissing: !1,
  saveMissingTo: "fallback",
  saveMissingPlurals: !0,
  missingKeyHandler: !1,
  missingInterpolationHandler: !1,
  postProcess: !1,
  postProcessPassResolved: !1,
  returnNull: !1,
  returnEmptyString: !0,
  returnObjects: !1,
  joinArrays: !1,
  returnedObjectHandler: !1,
  parseMissingKeyHandler: !1,
  appendNamespaceToMissingKey: !1,
  appendNamespaceToCIMode: !1,
  overloadTranslationOptionHandler: (o) => {
    let e = {};
    if (typeof o[1] == "object" && (e = o[1]), Dt(o[1]) && (e.defaultValue = o[1]), Dt(o[2]) && (e.tDescription = o[2]), typeof o[2] == "object" || typeof o[3] == "object") {
      const t = o[3] || o[2];
      Object.keys(t).forEach((r) => {
        e[r] = t[r];
      });
    }
    return e;
  },
  interpolation: {
    escapeValue: !0,
    format: (o) => o,
    prefix: "{{",
    suffix: "}}",
    formatSeparator: ",",
    unescapePrefix: "-",
    nestingPrefix: "$t(",
    nestingSuffix: ")",
    nestingOptionsSeparator: ",",
    maxReplaces: 1e3,
    skipOnVariables: !0
  },
  cacheInBuiltFormats: !0
}), y0 = (o) => (Dt(o.ns) && (o.ns = [o.ns]), Dt(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), Dt(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), o.supportedLngs?.indexOf?.("cimode") < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o), Xd = () => {
}, MF = (o) => {
  Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
    typeof o[t] == "function" && (o[t] = o[t].bind(o));
  });
};
class AA extends Rh {
  constructor(e = {}, t) {
    if (super(), this.options = y0(e), this.services = {}, this.logger = sa, this.modules = {
      external: []
    }, MF(this), t && !this.isInitialized && !e.isClone) {
      if (!this.options.initAsync)
        return this.init(e, t), this;
      setTimeout(() => {
        this.init(e, t);
      }, 0);
    }
  }
  init(e = {}, t) {
    this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (Dt(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
    const r = o_();
    this.options = {
      ...r,
      ...this.options,
      ...y0(e)
    }, this.options.interpolation = {
      ...r.interpolation,
      ...this.options.interpolation
    }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = r.overloadTranslationOptionHandler);
    const n = (c) => c ? typeof c == "function" ? new c() : c : null;
    if (!this.options.isClone) {
      this.modules.logger ? sa.init(n(this.modules.logger), this.options) : sa.init(null, this.options);
      let c;
      this.modules.formatter ? c = this.modules.formatter : c = UF;
      const u = new p0(this.options);
      this.store = new A0(this.options.resources, this.options);
      const A = this.services;
      A.logger = sa, A.resourceStore = this.store, A.languageUtils = u, A.pluralResolver = new TF(u, {
        prepend: this.options.pluralSeparator,
        simplifyPluralSuffix: this.options.simplifyPluralSuffix
      }), this.options.interpolation.format && this.options.interpolation.format !== r.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), c && (!this.options.interpolation.format || this.options.interpolation.format === r.interpolation.format) && (A.formatter = n(c), A.formatter.init && A.formatter.init(A, this.options), this.options.interpolation.format = A.formatter.format.bind(A.formatter)), A.interpolator = new f0(this.options), A.utils = {
        hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
      }, A.backendConnector = new IF(n(this.modules.backend), A.resourceStore, A, this.options), A.backendConnector.on("*", (d, ...g) => {
        this.emit(d, ...g);
      }), this.modules.languageDetector && (A.languageDetector = n(this.modules.languageDetector), A.languageDetector.init && A.languageDetector.init(A, this.options.detection, this.options)), this.modules.i18nFormat && (A.i18nFormat = n(this.modules.i18nFormat), A.i18nFormat.init && A.i18nFormat.init(this)), this.translator = new hh(this.services, this.options), this.translator.on("*", (d, ...g) => {
        this.emit(d, ...g);
      }), this.modules.external.forEach((d) => {
        d.init && d.init(this);
      });
    }
    if (this.format = this.options.interpolation.format, t || (t = Xd), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
      const c = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
      c.length > 0 && c[0] !== "dev" && (this.options.lng = c[0]);
    }
    !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((c) => {
      this[c] = (...u) => this.store[c](...u);
    }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((c) => {
      this[c] = (...u) => (this.store[c](...u), this);
    });
    const s = Pu(), l = () => {
      const c = (u, A) => {
        this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), s.resolve(A), t(u, A);
      };
      if (this.languages && !this.isInitialized) return c(null, this.t.bind(this));
      this.changeLanguage(this.options.lng, c);
    };
    return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), s;
  }
  loadResources(e, t = Xd) {
    let r = t;
    const n = Dt(e) ? e : this.language;
    if (typeof e == "function" && (r = e), !this.options.resources || this.options.partialBundledLanguages) {
      if (n?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return r();
      const i = [], a = (s) => {
        if (!s || s === "cimode") return;
        this.services.languageUtils.toResolveHierarchy(s).forEach((c) => {
          c !== "cimode" && i.indexOf(c) < 0 && i.push(c);
        });
      };
      n ? a(n) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => a(l)), this.options.preload?.forEach?.((s) => a(s)), this.services.backendConnector.load(i, this.options.ns, (s) => {
        !s && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), r(s);
      });
    } else
      r(null);
  }
  reloadResources(e, t, r) {
    const n = Pu();
    return typeof e == "function" && (r = e, e = void 0), typeof t == "function" && (r = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), r || (r = Xd), this.services.backendConnector.reload(e, t, (i) => {
      n.resolve(), r(i);
    }), n;
  }
  use(e) {
    if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
    if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
    return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && DB.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
  }
  setResolvedLanguage(e) {
    if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
      for (let t = 0; t < this.languages.length; t++) {
        const r = this.languages[t];
        if (!(["cimode", "dev"].indexOf(r) > -1) && this.store.hasLanguageSomeTranslations(r)) {
          this.resolvedLanguage = r;
          break;
        }
      }
      !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
    }
  }
  changeLanguage(e, t) {
    this.isLanguageChangingTo = e;
    const r = Pu();
    this.emit("languageChanging", e);
    const n = (s) => {
      this.language = s, this.languages = this.services.languageUtils.toResolveHierarchy(s), this.resolvedLanguage = void 0, this.setResolvedLanguage(s);
    }, i = (s, l) => {
      l ? this.isLanguageChangingTo === e && (n(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, r.resolve((...c) => this.t(...c)), t && t(s, (...c) => this.t(...c));
    }, a = (s) => {
      !e && !s && this.services.languageDetector && (s = []);
      const l = Dt(s) ? s : s && s[0], c = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes(Dt(s) ? [s] : s);
      c && (this.language || n(c), this.translator.language || this.translator.changeLanguage(c), this.services.languageDetector?.cacheUserLanguage?.(c)), this.loadResources(c, (u) => {
        i(u, c);
      });
    };
    return !e && this.services.languageDetector && !this.services.languageDetector.async ? a(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(a) : this.services.languageDetector.detect(a) : a(e), r;
  }
  getFixedT(e, t, r) {
    const n = (i, a, ...s) => {
      let l;
      typeof a != "object" ? l = this.options.overloadTranslationOptionHandler([i, a].concat(s)) : l = {
        ...a
      }, l.lng = l.lng || n.lng, l.lngs = l.lngs || n.lngs, l.ns = l.ns || n.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || r || n.keyPrefix);
      const c = this.options.keySeparator || ".";
      let u;
      return l.keyPrefix && Array.isArray(i) ? u = i.map((A) => (typeof A == "function" && (A = $y(A, {
        ...this.options,
        ...a
      })), `${l.keyPrefix}${c}${A}`)) : (typeof i == "function" && (i = $y(i, {
        ...this.options,
        ...a
      })), u = l.keyPrefix ? `${l.keyPrefix}${c}${i}` : i), this.t(u, l);
    };
    return Dt(e) ? n.lng = e : n.lngs = e, n.ns = t, n.keyPrefix = r, n;
  }
  t(...e) {
    return this.translator?.translate(...e);
  }
  exists(...e) {
    return this.translator?.exists(...e);
  }
  setDefaultNamespace(e) {
    this.options.defaultNS = e;
  }
  hasLoadedNamespace(e, t = {}) {
    if (!this.isInitialized)
      return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
    if (!this.languages || !this.languages.length)
      return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
    const r = t.lng || this.resolvedLanguage || this.languages[0], n = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
    if (r.toLowerCase() === "cimode") return !0;
    const a = (s, l) => {
      const c = this.services.backendConnector.state[`${s}|${l}`];
      return c === -1 || c === 0 || c === 2;
    };
    if (t.precheck) {
      const s = t.precheck(this, a);
      if (s !== void 0) return s;
    }
    return !!(this.hasResourceBundle(r, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(r, e) && (!n || a(i, e)));
  }
  loadNamespaces(e, t) {
    const r = Pu();
    return this.options.ns ? (Dt(e) && (e = [e]), e.forEach((n) => {
      this.options.ns.indexOf(n) < 0 && this.options.ns.push(n);
    }), this.loadResources((n) => {
      r.resolve(), t && t(n);
    }), r) : (t && t(), Promise.resolve());
  }
  loadLanguages(e, t) {
    const r = Pu();
    Dt(e) && (e = [e]);
    const n = this.options.preload || [], i = e.filter((a) => n.indexOf(a) < 0 && this.services.languageUtils.isSupportedCode(a));
    return i.length ? (this.options.preload = n.concat(i), this.loadResources((a) => {
      r.resolve(), t && t(a);
    }), r) : (t && t(), Promise.resolve());
  }
  dir(e) {
    if (e || (e = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language)), !e) return "rtl";
    try {
      const n = new Intl.Locale(e);
      if (n && n.getTextInfo) {
        const i = n.getTextInfo();
        if (i && i.direction) return i.direction;
      }
    } catch {
    }
    const t = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], r = this.services?.languageUtils || new p0(o_());
    return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(r.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
  }
  static createInstance(e = {}, t) {
    const r = new AA(e, t);
    return r.createInstance = AA.createInstance, r;
  }
  cloneInstance(e = {}, t = Xd) {
    const r = e.forkResourceStore;
    r && delete e.forkResourceStore;
    const n = {
      ...this.options,
      ...e,
      isClone: !0
    }, i = new AA(n);
    if ((e.debug !== void 0 || e.prefix !== void 0) && (i.logger = i.logger.clone(e)), ["store", "services", "language"].forEach((s) => {
      i[s] = this[s];
    }), i.services = {
      ...this.services
    }, i.services.utils = {
      hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
    }, r) {
      const s = Object.keys(this.store.data).reduce((l, c) => (l[c] = {
        ...this.store.data[c]
      }, l[c] = Object.keys(l[c]).reduce((u, A) => (u[A] = {
        ...l[c][A]
      }, u), l[c]), l), {});
      i.store = new A0(s, n), i.services.resourceStore = i.store;
    }
    if (e.interpolation) {
      const l = {
        ...o_().interpolation,
        ...this.options.interpolation,
        ...e.interpolation
      }, c = {
        ...n,
        interpolation: l
      };
      i.services.interpolator = new f0(c);
    }
    return i.translator = new hh(i.services, n), i.translator.on("*", (s, ...l) => {
      i.emit(s, ...l);
    }), i.init(n, t), i.translator.options = n, i.translator.backendConnector.services.utils = {
      hasLoadedNamespace: i.hasLoadedNamespace.bind(i)
    }, i;
  }
  toJSON() {
    return {
      options: this.options,
      store: this.store,
      language: this.language,
      languages: this.languages,
      resolvedLanguage: this.resolvedLanguage
    };
  }
}
const dn = AA.createInstance();
dn.createInstance;
dn.dir;
dn.init;
dn.loadResources;
dn.reloadResources;
dn.use;
dn.changeLanguage;
dn.getFixedT;
dn.t;
dn.exists;
dn.setDefaultNamespace;
dn.hasLoadedNamespace;
dn.loadNamespaces;
dn.loadLanguages;
function RF(o) {
  switch (o) {
    case "./locale/lang.af.js":
      return Promise.resolve().then(() => V9);
    case "./locale/lang.ar.js":
      return Promise.resolve().then(() => H9);
    case "./locale/lang.az.js":
      return Promise.resolve().then(() => K9);
    case "./locale/lang.be.js":
      return Promise.resolve().then(() => W9);
    case "./locale/lang.bg.js":
      return Promise.resolve().then(() => Y9);
    case "./locale/lang.ca.js":
      return Promise.resolve().then(() => J9);
    case "./locale/lang.cs.js":
      return Promise.resolve().then(() => tK);
    case "./locale/lang.cy.js":
      return Promise.resolve().then(() => oK);
    case "./locale/lang.da.js":
      return Promise.resolve().then(() => iK);
    case "./locale/lang.de.js":
      return Promise.resolve().then(() => sK);
    case "./locale/lang.el.js":
      return Promise.resolve().then(() => cK);
    case "./locale/lang.en.js":
      return Promise.resolve().then(() => AK);
    case "./locale/lang.es.js":
      return Promise.resolve().then(() => pK);
    case "./locale/lang.et.js":
      return Promise.resolve().then(() => gK);
    case "./locale/lang.fa.js":
      return Promise.resolve().then(() => fK);
    case "./locale/lang.fi.js":
      return Promise.resolve().then(() => yK);
    case "./locale/lang.fr.js":
      return Promise.resolve().then(() => vK);
    case "./locale/lang.fy.js":
      return Promise.resolve().then(() => xK);
    case "./locale/lang.ga.js":
      return Promise.resolve().then(() => CK);
    case "./locale/lang.gl.js":
      return Promise.resolve().then(() => BK);
    case "./locale/lang.he.js":
      return Promise.resolve().then(() => jK);
    case "./locale/lang.hi.js":
      return Promise.resolve().then(() => TK);
    case "./locale/lang.hr.js":
      return Promise.resolve().then(() => FK);
    case "./locale/lang.hu.js":
      return Promise.resolve().then(() => NK);
    case "./locale/lang.hy.js":
      return Promise.resolve().then(() => MK);
    case "./locale/lang.id.js":
      return Promise.resolve().then(() => OK);
    case "./locale/lang.is.js":
      return Promise.resolve().then(() => qK);
    case "./locale/lang.it.js":
      return Promise.resolve().then(() => VK);
    case "./locale/lang.ja.js":
      return Promise.resolve().then(() => HK);
    case "./locale/lang.ko.js":
      return Promise.resolve().then(() => KK);
    case "./locale/lang.lt.js":
      return Promise.resolve().then(() => WK);
    case "./locale/lang.lv.js":
      return Promise.resolve().then(() => YK);
    case "./locale/lang.mk.js":
      return Promise.resolve().then(() => JK);
    case "./locale/lang.ms.js":
      return Promise.resolve().then(() => t$);
    case "./locale/lang.mt.js":
      return Promise.resolve().then(() => o$);
    case "./locale/lang.nl.js":
      return Promise.resolve().then(() => i$);
    case "./locale/lang.no.js":
      return Promise.resolve().then(() => s$);
    case "./locale/lang.pl.js":
      return Promise.resolve().then(() => c$);
    case "./locale/lang.pt-BR.js":
      return Promise.resolve().then(() => A$);
    case "./locale/lang.pt-PT.js":
      return Promise.resolve().then(() => p$);
    case "./locale/lang.ro.js":
      return Promise.resolve().then(() => g$);
    case "./locale/lang.ru.js":
      return Promise.resolve().then(() => f$);
    case "./locale/lang.sk.js":
      return Promise.resolve().then(() => y$);
    case "./locale/lang.sl.js":
      return Promise.resolve().then(() => v$);
    case "./locale/lang.sq.js":
      return Promise.resolve().then(() => x$);
    case "./locale/lang.sr.js":
      return Promise.resolve().then(() => C$);
    case "./locale/lang.sv.js":
      return Promise.resolve().then(() => B$);
    case "./locale/lang.sw.js":
      return Promise.resolve().then(() => j$);
    case "./locale/lang.test.js":
      return Promise.resolve().then(() => T$);
    case "./locale/lang.th.js":
      return Promise.resolve().then(() => F$);
    case "./locale/lang.tl.js":
      return Promise.resolve().then(() => N$);
    case "./locale/lang.tr.js":
      return Promise.resolve().then(() => M$);
    case "./locale/lang.uk.js":
      return Promise.resolve().then(() => O$);
    case "./locale/lang.vi.js":
      return Promise.resolve().then(() => q$);
    case "./locale/lang.yi.js":
      return Promise.resolve().then(() => V$);
    case "./locale/lang.zh-CN.js":
      return Promise.resolve().then(() => H$);
    case "./locale/lang.zh-HK.js":
      return Promise.resolve().then(() => K$);
    case "./locale/lang.zh-TW.js":
      return Promise.resolve().then(() => W$);
    default:
      return new Promise(function(e, t) {
        (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
          t.bind(null, new Error("Unknown variable dynamic import: " + o))
        );
      });
  }
}
let ta;
const OF = async function(o, e) {
  o ? ta = o : navigator.userLanguage ? ta = navigator.userLanguage : navigator.language && (ta = navigator.language), !e.includes(ta) && ta !== "test" && (ta = "en");
  const t = await RF(`./locale/lang.${encodeURIComponent(ta)}.js`);
  return dn.init({
    lng: ta,
    debug: !1,
    resources: {
      [ta]: {
        translation: t.default
      }
    }
  }), { langParam: ta, i18next: dn };
}, no = function(o) {
  return dn.t(o);
}, zB = document.createElement("template");
zB.innerHTML = `
  <style>
  @keyframes btnHover {
    from {
      background-color: var(--main-bg-color);
    }

    to {
      background-color: var(--icon-bg-color-hover);
    }
  }
  :host(:hover) :not(.disabled)
  {
    animation: btnHover 0.2s forwards;
  }
  div
  {
    height: 24px;
    width: 24px;
    margin: 4px 1px 4px;
    padding: 3px;
    background-color: var(--icon-bg-color);
    cursor: pointer;
    border-radius: 3px;
  }
  .small {
    width: 14px;
    height: 14px;
    padding: 1px;
    border-radius: 1px;
  }
  img {
    border: none;
    width: 100%;
    height: 100%;
  }
  .pressed {
    background-color: var(--icon-bg-color-hover);
  }
  .disabled {
    opacity: 0.3;
    cursor: default;
  }
  </style>
  <div title="title">
    <img alt="icon">
  </div>
`;
class QF extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(zB.content.cloneNode(!0)), this.$div = this._shadowRoot.querySelector("div"), this.$img = this._shadowRoot.querySelector("img"), this.imgPath = svgEditor.configObj.curConfig.imgPath;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["title", "src", "pressed", "disabled", "size", "style"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          {
            const n = this.getAttribute("shortcut");
            this.$div.setAttribute("title", `${no(r)} ${n ? `[${no(n)}]` : ""}`);
          }
          break;
        case "style":
          this.$div.style = r;
          break;
        case "src":
          r.indexOf("data:") !== -1 ? this.$img.setAttribute("src", r) : this.$img.setAttribute("src", this.imgPath + "/" + r);
          break;
        case "pressed":
          r === null ? this.$div.classList.remove("pressed") : this.$div.classList.add("pressed");
          break;
        case "size":
          r === "small" ? this.$div.classList.add("small") : this.$div.classList.remove("small");
          break;
        case "disabled":
          r ? this.$div.classList.add("disabled") : this.$div.classList.remove("disabled");
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get pressed() {
    return this.hasAttribute("pressed");
  }
  /**
   * @function set
   * @returns {void}
   */
  set pressed(e) {
    e ? this.setAttribute("pressed", "true") : this.removeAttribute("pressed");
  }
  /**
   * @function get
   * @returns {any}
   */
  get disabled() {
    return this.hasAttribute("disabled");
  }
  /**
   * @function set
   * @returns {void}
   */
  set disabled(e) {
    e ? this.setAttribute("disabled", "true") : this.removeAttribute("disabled");
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get size() {
    return this.getAttribute("size");
  }
  /**
   * @function set
   * @returns {void}
   */
  set size(e) {
    this.setAttribute("size", e);
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    const e = this.getAttribute("shortcut");
    e && document.addEventListener("keydown", (t) => {
      if (t.target.nodeName !== "BODY") return;
      const r = `${t.metaKey ? "meta+" : ""}${t.ctrlKey ? "ctrl+" : ""}${t.key.toUpperCase()}`;
      e === r && (this.click(), t.preventDefault());
    });
  }
}
customElements.define("se-button", QF);
class qF extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this.imgPath = svgEditor.configObj.curConfig.imgPath, this.template = this.createTemplate(this.imgPath), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(this.template.content.cloneNode(!0)), this.$button = this._shadowRoot.querySelector(".menu-button"), this.$handle = this._shadowRoot.querySelector(".handle"), this.$overall = this._shadowRoot.querySelector(".overall"), this.$img = this._shadowRoot.querySelector("img"), this.$menu = this._shadowRoot.querySelector(".menu"), this.$elements = this.$menu.lastElementChild.assignedElements(), document.addEventListener("click", (e) => {
      this.opened && (this.opened = !1);
    });
  }
  /**
   * @function createTemplate
   * @param {string} imgPath
   * @returns {any} template
   */
  createTemplate(e) {
    const t = document.createElement("template");
    return t.innerHTML = `
      <style>
        :host {
          position:relative;
        }
        @keyframes btnHover {
          from {
            background-color: transparent;
          }

          to {
            background-color: var(--icon-bg-color-hover);
          }
        }
        .overall .menu-button:hover {
          animation: btnHover 0.2s forwards;
        }
        img {
          border: none;
          width: 24px;
          height: 24px;
        }
        .overall.pressed .button-icon,
        .overall.pressed .handle {
          background-color: var(--icon-bg-color-hover) !important;
        }
        .overall.pressed .menu-button {
          background-color: var(--icon-bg-color-hover) !important;
        }
        .disabled {
          opacity: 0.3;
          cursor: default;
        }
        .menu-button {
          height: 24px;
          width: 24px;
          margin: 2px 1px 4px;
          padding: 3px;
          background-color: var(--icon-bg-color);
          cursor: pointer;
          position: relative;
          border-radius: 3px;
          overflow: hidden;
        }
        .handle {
          height: 8px;
          width: 8px;
          background-image: url(${e}/handle.svg);
          position:absolute;
          bottom: 0px;
          right: 0px;
        }
        .button-icon {
        }
        .menu {
          position: fixed;
          background: none !important;
          display:none;
          margin-left: 34px;
        }
        .open {
          display: flex;
        }
        .menu-item {
          align-content: flex-start;
          height: 24px;
          width: 24px;
          top:0px;
          left:0px;
        }
        .overall {
          background: none !important;
        }
      </style>

      <div class="overall">
        <div class="menu">
          <slot></slot>
        </div>
        <div class="menu-button">
          <img class="button-icon" src="logo.svg" alt="icon">
          <div class="handle"></div>
        </div>
      </div>`, t;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["title", "pressed", "disabled", "opened"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          {
            const n = this.getAttribute("shortcut");
            this.$button.setAttribute("title", `${no(r)} ${n ? `[${no(n)}]` : ""}`);
          }
          break;
        case "pressed":
          r ? this.$overall.classList.add("pressed") : this.$overall.classList.remove("pressed");
          break;
        case "opened":
          r ? this.$menu.classList.add("open") : this.$menu.classList.remove("open");
          break;
        case "disabled":
          r ? this.$overall.classList.add("disabled") : this.$overall.classList.remove("disabled");
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get pressed() {
    return this.hasAttribute("pressed");
  }
  /**
   * @function set
   * @returns {void}
   */
  set pressed(e) {
    e ? this.setAttribute("pressed", "true") : (this.removeAttribute("pressed", ""), this.removeAttribute("opened"));
  }
  /**
   * @function get
   * @returns {any}
   */
  get opened() {
    return this.hasAttribute("opened");
  }
  /**
   * @function set
   * @returns {void}
   */
  set opened(e) {
    e ? this.setAttribute("opened", "opened") : this.removeAttribute("opened");
  }
  /**
   * @function get
   * @returns {any}
   */
  get disabled() {
    return this.hasAttribute("disabled");
  }
  /**
   * @function set
   * @returns {void}
   */
  set disabled(e) {
    e ? this.setAttribute("disabled", "true") : this.removeAttribute("disabled", "");
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    this.activeSlot = this.shadowRoot.querySelector("slot").assignedElements()[0], this.$img.setAttribute("src", this.imgPath + "/" + this.activeSlot.getAttribute("src"));
    const e = (t) => {
      switch (t.stopPropagation(), t.target.nodeName) {
        case "SE-FLYINGBUTTON":
          this.pressed ? this.setAttribute("opened", "opened") : (this.activeSlot.click(), this.setAttribute("pressed", "pressed"));
          break;
        case "SE-BUTTON":
          this.$img.setAttribute("src", this.imgPath + "/" + t.target.getAttribute("src")), this.activeSlot = t.target, this.setAttribute("pressed", "pressed"), this.$menu.classList.remove("open");
          break;
        case "DIV":
          if (this.opened)
            this.removeAttribute("opened");
          else {
            this.setAttribute("opened", "opened");
            const r = this.getBoundingClientRect();
            this.$menu.style.top = r.top + "px";
          }
          break;
        default:
          console.error("unkonw nodeName for:", t.target, t.target.className);
      }
    };
    svgEditor.$click(this, e), svgEditor.$click(this.$handle, e);
  }
}
customElements.define("se-flyingbutton", qF);
class GF extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this.imgPath = svgEditor.configObj.curConfig.imgPath, this.template = this.createTemplate(this.imgPath), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(this.template.content.cloneNode(!0)), this.$button = this._shadowRoot.querySelector(".menu-button"), this.$overall = this._shadowRoot.querySelector(".overall"), this.$img = this._shadowRoot.querySelector(".menu-button img"), this.$menu = this._shadowRoot.querySelector(".menu"), this.$handle = this._shadowRoot.querySelector(".handle"), this.$lib = this._shadowRoot.querySelector(".image-lib"), this.files = [], this.request = new XMLHttpRequest(), this.imgPath = svgEditor.configObj.curConfig.imgPath, document.getElementById("workarea").addEventListener("click", (t) => {
      this.$menu.classList.remove("open"), this.$lib.classList.remove("open-lib");
    });
  }
  /**
   * @function createTemplate
   * @param {string} imgPath
   * @returns {any} template
   */
  createTemplate(e) {
    const t = document.createElement("template");
    return t.innerHTML = `
    <style>
    :host {
      position:relative;
    }
    .menu-button:hover, se-button:hover, .menu-item:hover
    {
      background-color: var(--icon-bg-color-hover);
    }
    img {
      border: none;
      width: 24px;
      height: 24px;
    }
    .overall.pressed .button-icon,
    .overall.pressed,
    .menu-item.pressed {
      background-color: var(--icon-bg-color-hover) !important;
    }
    .overall.pressed .menu-button {
      background-color: var(--icon-bg-color-hover) !important;
    }
    .disabled {
      opacity: 0.3;
      cursor: default;
    }
    .menu-button {
      height: 24px;
      width: 24px;
      margin: 2px 1px 4px;
      padding: 3px;
      background-color: var(--icon-bg-color);
      cursor: pointer;
      position: relative;
      border-radius: 3px;
      overflow: hidden;
    }
    .handle {
      height: 8px;
      width: 8px;
      background-image: url(${e}/handle.svg);
      position:absolute;
      bottom: 0px;
      right: 0px;
    }
    .button-icon {
    }
    .menu {
      position: fixed;
      margin-left: 34px;
      background: none !important;
      display:none;
      top: 30%;
      left: 171px;
    }
    .image-lib {
      position: fixed;
      left: 34px;
      top: 30%;
      background: #E8E8E8;
      display: none;
      flex-wrap: wrap;
      flex-direction: row;
      width: 170px;
    }
    .menu-item {
      line-height: 1em;
      padding: 0.5em;
      border: 1px solid #5a6162;
      background: #E8E8E8;
      margin-bottom: -1px;
      white-space: nowrap;
    }
    .open-lib {
      display: inline-flex;
    }
    .open {
      display: block;
    }
    .overall {
      background: none !important;
    }
    </style>
  
    <div class="overall">
      <div class="menu-button">
        <img class="button-icon" src="explorer.svg" alt="icon">
        <div class="handle"></div>
      </div>
      <div class="image-lib"">
        <se-button></se-button>
     </div>
      <div class="menu">
        <div class="menu-item">menu</div>
     </div>
    </div>`, t;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["title", "pressed", "disabled", "lib", "src"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  async attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          {
            const n = this.getAttribute("shortcut");
            this.$button.setAttribute("title", `${r} [${n}]`);
          }
          break;
        case "pressed":
          r ? this.$overall.classList.add("pressed") : this.$overall.classList.remove("pressed");
          break;
        case "disabled":
          r ? this.$overall.classList.add("disabled") : this.$overall.classList.remove("disabled");
          break;
        case "lib":
          try {
            const i = await (await fetch(`${r}index.json`)).json(), { lib: a } = i;
            this.$menu.innerHTML = a.map((s, l) => `<div data-menu="${s}" class="menu-item ${l === 0 ? "pressed" : ""} ">${s}</div>`).join(""), await this.updateLib(a[0]);
          } catch (n) {
            console.error(n);
          }
          break;
        case "src":
          this.$img.setAttribute("src", this.imgPath + "/" + r);
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get pressed() {
    return this.hasAttribute("pressed");
  }
  /**
   * @function set
   * @returns {void}
   */
  set pressed(e) {
    e ? this.setAttribute("pressed", "true") : this.removeAttribute("pressed", "");
  }
  /**
   * @function get
   * @returns {any}
   */
  get disabled() {
    return this.hasAttribute("disabled");
  }
  /**
   * @function set
   * @returns {void}
   */
  set disabled(e) {
    e ? this.setAttribute("disabled", "true") : this.removeAttribute("disabled", "");
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    const e = (t) => {
      switch (t.stopPropagation(), t.target.nodeName) {
        case "SE-EXPLORERBUTTON":
          this.$menu.classList.toggle("open"), this.$lib.classList.toggle("open-lib");
          break;
        case "SE-BUTTON":
          this.currentAction = t.target, this.$img.setAttribute("src", this.currentAction.getAttribute("src")), this.dataset.draw = this.data[this.currentAction.dataset.shape], this._shadowRoot.querySelectorAll(".image-lib [pressed]").forEach((r) => {
            r.pressed = !1;
          }), this.currentAction.setAttribute("pressed", "pressed"), this.$menu.classList.remove("open"), this.$lib.classList.remove("open-lib");
          break;
        case "DIV":
          t.target.classList[0] === "handle" ? (this.$menu.classList.toggle("open"), this.$lib.classList.toggle("open-lib")) : (this._shadowRoot.querySelectorAll(".menu > .pressed").forEach((r) => {
            r.classList.remove("pressed");
          }), t.target.classList.add("pressed"), this.updateLib(t.target.dataset.menu));
          break;
        default:
          console.error("unknown nodeName for:", t.target, t.target.className);
      }
    };
    svgEditor.$click(this, e), svgEditor.$click(this.$menu, e), svgEditor.$click(this.$lib, e), svgEditor.$click(this.$handle, e);
  }
  /**
   * @function updateLib
   * @param {string} lib
   * @returns {void}
   */
  async updateLib(e) {
    const t = this.getAttribute("lib");
    try {
      const n = await (await fetch(`${t}${e}.json`)).json();
      this.data = n.data;
      const i = n.size ?? 300, a = n.fill ? "#333" : "none", s = i * 0.05, l = [-s, -s, i + s * 2, i + s * 2].join(" "), c = n.fill ? 0 : i / 30;
      this.$lib.innerHTML = Object.entries(this.data).map(([u, A]) => {
        const p = btoa(`
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">
          <svg viewBox="${l}"><path fill="${a}" stroke="#f8bb00" stroke-width="${c}" d="${A}"></path></svg>
        </svg>`);
        return `<se-button data-shape="${u}"src="data:image/svg+xml;base64,${p}"></se-button>`;
      }).join("");
    } catch (r) {
      console.error(`could not read file:${t}${e}.json`, r);
    }
  }
}
customElements.define("se-explorerbutton", GF);
const KB = document.createElement("template");
KB.innerHTML = `
  <style>
  input{
    border:unset;
    background-color:var(--input-color);
    min-width:unset;
    width:40px;
    height:23px;
    padding:1px 2px;
    border:2px;
    font: inherit;
    margin: 2px 1px 0px 2px;
    box-sizing:border-box;
    text-align: center;
    border-radius: 3px 0px 0px 3px;
  }
  #tool-wrapper{
    height:20px;
    display:flex;
    align-items:center;
  }
  #icon{
    margin-bottom:1px
  }
  #spinner{
    display:flex;
    flex-direction:column;
  }
  #spinner > div {
    height: 11px;
    width: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    border-left:solid 1px transparent;
    border-right:solid 1px transparent;
    background-color:var(--input-color);
  }
  #arrow-up{
    height:9px;
    margin-top: 2px;
    margin-bottom: 1px;
  }
  #arrow-up, #arrow-down {
    user-select: none;
  }
  @keyframes hover-arrows {
    from {
      background: transparent;
      color: var(--icon-bg-color-hover);
    }

    to {
      background: var(--icon-bg-color-hover);
      color: var(--orange-color);
    }
  }
  #arrow-up:hover, #arrow-down:hover {
    animation: hover-arrows 0.2s forwards;
  }
  #down{
    width:18px;
    height:23px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color:var(--input-color);
    border-radius: 0px 3px 3px 0px;
    margin: 2px 5px 0px 1px;
  }
  #down > img {
    margin-top: 2px;
  }
  #options-container {
    position:fixed
    display:flex;
    flex-direction:column;
    background-color:var(--icon-bg-color);
    border:solid 1px white;
    box-shadow:0 0px 10px rgb(0 0 0 / 50%);
  }
  ::slotted(*) {
    margin:2px;
    padding:3px;
    color:white;
  }
  ::slotted(*:hover) {
    background-color: rgb(43, 60, 69);
  }
  </style>
  <div id="tool-wrapper">
    <img id="icon" alt="icon" width="18" height="18"/>
    <input/>
    <div id="spinner">
      <div id="arrow-up">▲</div>
      <div id="arrow-down">▼</div>
    </div>
    <div id="down">
      <img width="16" height="8" src="arrow_down.svg" alt="Zoom dropdown"/>
    </div>
  </div>
  <div id="options-container" style="display:none">
    <slot></slot>
  </div>
`;
class VF extends HTMLElement {
  constructor() {
    super(), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), this.initPopup = this.initPopup.bind(this), this.handleInput = this.handleInput.bind(this), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(KB.content.cloneNode(!0)), this.slotElement = this._shadowRoot.querySelector("slot"), this.slotElement.addEventListener(
      "slotchange",
      this.handleOptionsChange.bind(this)
    ), this.inputElement = this._shadowRoot.querySelector("input"), this.inputElement.addEventListener("click", this.handleClick.bind(this)), this.inputElement.addEventListener("change", this.handleInput), this.inputElement.addEventListener("keydown", this.handleKeyDown), this.clickArea = this._shadowRoot.querySelector("#down"), this.clickArea.addEventListener("click", this.handleClick.bind(this)), this.imgPath = svgEditor.configObj.curConfig.imgPath, this.downImageElement = this.clickArea.querySelector("img"), this.downImageElement.setAttribute(
      "src",
      this.imgPath + "/" + this.downImageElement.getAttribute("src")
    ), this.imageElement = this._shadowRoot.querySelector("img"), this.imageElement.setAttribute(
      "src",
      this.imgPath + "/" + this.getAttribute("src")
    ), this.arrowUp = this._shadowRoot.querySelector("#arrow-up"), this.arrowUp.addEventListener("click", this.increment.bind(this)), this.arrowUp.addEventListener(
      "mousedown",
      (e) => this.handleMouseDown("up", !0)
    ), this.arrowUp.addEventListener("mouseleave", (e) => this.handleMouseUp("up")), this.arrowUp.addEventListener("mouseup", (e) => this.handleMouseUp("up")), this.arrowDown = this._shadowRoot.querySelector("#arrow-down"), this.arrowDown.addEventListener("click", this.decrement.bind(this)), this.arrowDown.addEventListener(
      "mousedown",
      (e) => this.handleMouseDown("down", !0)
    ), this.arrowDown.addEventListener(
      "mouseleave",
      (e) => this.handleMouseUp("down")
    ), this.arrowDown.addEventListener("mouseup", (e) => this.handleMouseUp("down")), this.optionsContainer = this._shadowRoot.querySelector(
      "#options-container"
    ), document.addEventListener("click", (e) => this.handleClose(e)), this.changedTimeout = null;
  }
  static get observedAttributes() {
    return ["value"];
  }
  /**
   * @function get
   * @returns {any}
   */
  get value() {
    return this.getAttribute("value");
  }
  /**
   * @function set
   * @returns {void}
   */
  set value(e) {
    this.setAttribute("value", e);
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t === r) {
      e === "value" && parseInt(this.inputElement.value) !== r && (this.inputElement.value = r);
      return;
    }
    e === "value" && (this.inputElement.value = r, this.dispatchEvent(
      new CustomEvent("change", { detail: { value: r } })
    ));
  }
  /**
   * @function handleOptionsChange
   * @returns {void}
   */
  handleOptionsChange() {
    this.slotElement.assignedElements().length > 0 && (this.options = this.slotElement.assignedElements(), this.selectedValue = this.options[0].textContent, this.initPopup(), this.options.forEach((e) => {
      e.addEventListener("click", (t) => this.handleSelect(t));
    }));
  }
  /**
   * @function handleClick
   * @returns {void}
   */
  handleClick() {
    this.optionsContainer.style.display = "flex", this.inputElement.select(), this.initPopup();
  }
  /**
   * @function handleSelect
   * @param {Event} e
   * @returns {void}
   */
  handleSelect(e) {
    this.value = e.target.getAttribute("value"), this.title = e.target.getAttribute("text");
  }
  /**
   * @function handleShow
   * @returns {void}
   * initialises the popup menu position
   */
  initPopup() {
    const e = this.getBoundingClientRect(), t = this.optionsContainer.getBoundingClientRect(), r = e.top - t.height, n = e.left;
    this.optionsContainer.style.position = "fixed", this.optionsContainer.style.top = `${r}px`, this.optionsContainer.style.left = `${n}px`;
  }
  /**
   * @function handleClose
   * @param {Event} e
   * @returns {void}
   * Close the popup menu
   */
  handleClose(e) {
    e.target !== this && (this.optionsContainer.style.display = "none", this.inputElement.blur());
  }
  /**
   * @function handleInput
   * @returns {void}
   */
  handleInput() {
    this.changedTimeout && clearTimeout(this.changedTimeout), this.changedTimeout = setTimeout(this.triggerInputChanged.bind(this), 500);
  }
  /**
   * @function triggerInputChanged
   * @returns {void}
   */
  triggerInputChanged() {
    const e = this.inputElement.value;
    this.value = e;
  }
  /**
   * @function increment
   * @returns {void}
   */
  increment() {
    this.value = parseInt(this.value) + 10;
  }
  /**
   * @function decrement
   * @returns {void}
   */
  decrement() {
    this.value - 10 <= 0 ? this.value = 10 : this.value = parseInt(this.value) - 10;
  }
  /**
   * @function handleMouseDown
   * @param {string} dir
   * @param {boolean} isFirst
   * @returns {void}
   * Increment/Decrement on mouse held down, if its the first call add a delay before starting
   */
  handleMouseDown(e, t) {
    e === "up" ? (this.incrementHold = !0, !t && this.increment(), setTimeout(
      () => {
        this.incrementHold && this.handleMouseDown(e, !1);
      },
      t ? 500 : 50
    )) : e === "down" && (this.decrementHold = !0, !t && this.decrement(), setTimeout(
      () => {
        this.decrementHold && this.handleMouseDown(e, !1);
      },
      t ? 500 : 50
    ));
  }
  /**
   * @function handleMouseUp
   * @param {string} dir
   * @returns {void}
   */
  handleMouseUp(e) {
    e === "up" ? this.incrementHold = !1 : this.decrementHold = !1;
  }
  /**
   * @function handleKeyDown
   * @param {Event} e
   * @returns {void}
   */
  handleKeyDown(e) {
    e.key === "ArrowUp" ? this.increment() : e.key === "ArrowDown" && this.decrement();
  }
}
customElements.define("se-zoom", VF);
const kr = {
  html(o, ...e) {
    return Ja.html(o, ...e).content;
  }
}, Ja = {
  html(o, ...e) {
    const t = document.createElement("template");
    return t.innerHTML = String.raw(o, ...e), t;
  }
}, Hp = /* @__PURE__ */ Symbol("defaultState"), $B = /* @__PURE__ */ Symbol("delegatesFocus"), vl = /* @__PURE__ */ Symbol("firstRender"), Av = /* @__PURE__ */ Symbol("focusTarget"), Wy = /* @__PURE__ */ Symbol("hasDynamicTemplate"), WB = /* @__PURE__ */ Symbol("ids"), zp = /* @__PURE__ */ Symbol("nativeInternals"), vc = /* @__PURE__ */ Symbol("raiseChangeEvents"), Ls = /* @__PURE__ */ Symbol("render"), Kp = /* @__PURE__ */ Symbol("renderChanges"), Wu = /* @__PURE__ */ Symbol("rendered"), dA = /* @__PURE__ */ Symbol("rendering"), Xy = /* @__PURE__ */ Symbol("setState"), pA = /* @__PURE__ */ Symbol("shadowRoot"), Yy = /* @__PURE__ */ Symbol("shadowRootMode"), Zy = /* @__PURE__ */ Symbol("state"), hA = /* @__PURE__ */ Symbol("stateEffects"), XB = /* @__PURE__ */ Symbol("template"), b0 = {
  tabindex: "tabIndex"
}, v0 = {
  tabIndex: "tabindex"
};
function DF(o) {
  class e extends o {
    /**
     * Handle a change to the attribute with the given name.
     *
     * @ignore
     * @param {string} attributeName
     * @param {string} oldValue
     * @param {string} newValue
     */
    attributeChangedCallback(r, n, i) {
      if (super.attributeChangedCallback && super.attributeChangedCallback(r, n, i), i !== n && !this[dA]) {
        const a = HF(r);
        if (a in this) {
          const s = ZB[r] ? jA(r, i) : i;
          this[a] = s;
        }
      }
    }
    // Because maintaining the mapping of attributes to properties is tedious,
    // this provides a default implementation for `observedAttributes` that
    // assumes that your component will want to expose all public properties in
    // your component's API as properties.
    //
    // You can override this default implementation of `observedAttributes`. For
    // example, if you have a system that can statically analyze which
    // properties are available to your component, you could hand-author or
    // programmatically generate a definition for `observedAttributes` that
    // avoids the minor run-time performance cost of inspecting the component
    // prototype to determine your component's public properties.
    static get observedAttributes() {
      return YB(this);
    }
  }
  return e;
}
function YB(o) {
  if (o === HTMLElement)
    return [];
  const e = Object.getPrototypeOf(o.prototype).constructor;
  let t = e.observedAttributes;
  t || (t = YB(e));
  const a = Object.getOwnPropertyNames(o.prototype).filter((l) => {
    const c = Object.getOwnPropertyDescriptor(
      o.prototype,
      l
    );
    return c && typeof c.set == "function";
  }).map(
    (l) => zF(l)
  ).filter(
    (l) => t.indexOf(l) < 0
  );
  return t.concat(a);
}
function HF(o) {
  let e = b0[o];
  if (!e) {
    const t = /-([a-z])/g;
    e = o.replace(
      t,
      (r) => r[1].toUpperCase()
    ), b0[o] = e;
  }
  return e;
}
function jA(o, e) {
  return typeof e == "boolean" ? e : typeof e == "string" ? e === "" || o.toLowerCase() === e.toLowerCase() : !1;
}
function zF(o) {
  let e = v0[o];
  if (!e) {
    const t = /([A-Z])/g;
    e = o.replace(t, "-$1").toLowerCase(), v0[o] = e;
  }
  return e;
}
const ZB = {
  checked: !0,
  defer: !0,
  disabled: !0,
  hidden: !0,
  ismap: !0,
  multiple: !0,
  noresize: !0,
  readonly: !0,
  selected: !0
}, $p = /* @__PURE__ */ Symbol("state"), n_ = /* @__PURE__ */ Symbol(
  "raiseChangeEventsInNextRender"
), lc = /* @__PURE__ */ Symbol("changedSinceLastRender");
function KF(o) {
  class e extends o {
    constructor() {
      super(), this[vl] = void 0, this[vc] = !1, this[lc] = null, this[Xy](this[Hp]);
    }
    // When the component is attached to the document (or upgraded), we will
    // generally render the component for the first time. That operation will
    // include rendering of the default state and any state changes that
    // happened between constructor time and this connectedCallback.
    connectedCallback() {
      super.connectedCallback && super.connectedCallback(), this[Kp]();
    }
    /**
     * The default state for the component. This can be extended by mixins and
     * classes to provide additional default state.
     *
     * @type {PlainObject}
     */
    // @ts-ignore
    get [Hp]() {
      return super[Hp] || {};
    }
    /**
     * Render the indicated changes in state to the DOM.
     *
     * The default implementation of this method does nothing. Override this
     * method in your component to update your component's host element and
     * any shadow elements to reflect the component's new state. See the
     * [rendering example](ReactiveMixin#rendering).
     *
     * Be sure to call `super` in your method implementation so that your
     * component's base classes and mixins have a chance to perform their own
     * render work.
     *
     * @param {ChangedFlags} changed - dictionary of flags indicating which state
     * members have changed since the last render
     */
    [Ls](n) {
      super[Ls] && super[Ls](n);
    }
    /**
     * Render any pending component changes to the DOM.
     *
     * This method does nothing if the state has not changed since the last
     * render call.
     *
     * ReactiveMixin will invoke this method following a `setState` call;
     * you should not need to invoke this method yourself.
     *
     * This method invokes the internal `render` method, then invokes the
     * `rendered` method.
     */
    [Kp]() {
      this[vl] === void 0 && (this[vl] = !0);
      const n = this[lc];
      if (this[vl] || n) {
        const i = this[vc];
        this[vc] = this[n_], this[n_] = !1, this[dA] = !0, this[Ls](n), this[dA] = !1, this[lc] = null, this[Wu](n), this[vl] = !1, this[vc] = i;
      }
    }
    /**
     * Perform any work that must happen after state changes have been rendered
     * to the DOM.
     *
     * The default implementation of this method does nothing. Override this
     * method in your component to perform work that requires the component to
     * be fully rendered, such as setting focus on a shadow element or
     * inspecting the computed style of an element. If such work should result
     * in a change in component state, you can safely call `setState` during the
     * `rendered` method.
     *
     * Be sure to call `super` in your method implementation so that your
     * component's base classes and mixins have a chance to perform their own
     * post-render work.
     *
     * @param {ChangedFlags} changed
     */
    [Wu](n) {
      super[Wu] && super[Wu](n);
    }
    /**
     * Update the component's state by merging the specified changes on
     * top of the existing state. If the component is connected to the document,
     * and the new state has changed, this returns a promise to asynchronously
     * render the component. Otherwise, this returns a resolved promise.
     *
     * @param {PlainObject} changes - the changes to apply to the element's state
     * @returns {Promise} - resolves when the new state has been rendered
     */
    async [Xy](n) {
      this[dA] && console.warn(
        `${this.constructor.name} called [setState] during rendering, which you should avoid.
See https://elix.org/documentation/ReactiveMixin.`
      );
      const { state: i, changed: a } = $F(this, n);
      if (this[$p] && Object.keys(a).length === 0)
        return;
      Object.freeze(i), this[$p] = i, this[vc] && (this[n_] = !0);
      const s = this[vl] === void 0 || this[lc] !== null;
      this[lc] = Object.assign(
        this[lc] || {},
        a
      ), this.isConnected && !s && (await Promise.resolve(), this[Kp]());
    }
    /**
     * The component's current state.
     *
     * The returned state object is immutable. To update it, invoke
     * `internal.setState`.
     *
     * It's extremely useful to be able to inspect component state while
     * debugging. If you append `?elixdebug=true` to a page's URL, then
     * ReactiveMixin will conditionally expose a public `state` property that
     * returns the component's state. You can then access the state in your
     * browser's debug console.
     *
     * @type {PlainObject}
     */
    get [Zy]() {
      return this[$p];
    }
    /**
     * Ask the component whether a state with a set of recently-changed fields
     * implies that additional second-order changes should be applied to that
     * state to make it consistent.
     *
     * This method is invoked during a call to `internal.setState` to give all
     * of a component's mixins and classes a chance to respond to changes in
     * state. If one mixin/class updates state that it controls, another
     * mixin/class may want to respond by updating some other state member that
     * *it* controls.
     *
     * This method should return a dictionary of changes that should be applied
     * to the state. If the dictionary object is not empty, the
     * `internal.setState` method will apply the changes to the state, and
     * invoke this `stateEffects` method again to determine whether there are
     * any third-order effects that should be applied. This process repeats
     * until all mixins/classes report that they have no additional changes to
     * make.
     *
     * See an example of how `ReactiveMixin` invokes the `stateEffects` to
     * [ensure state consistency](ReactiveMixin#ensuring-state-consistency).
     *
     * @param {PlainObject} state - a proposal for a new state
     * @param {ChangedFlags} changed - the set of fields changed in this
     * latest proposal for the new state
     * @returns {PlainObject}
     */
    [hA](n, i) {
      return super[hA] ? super[hA](n, i) : {};
    }
  }
  return new URLSearchParams(location.search).get("elixdebug") === "true" && Object.defineProperty(e.prototype, "state", {
    get() {
      return this[Zy];
    }
  }), e;
}
function $F(o, e) {
  const t = Object.assign({}, o[$p]), r = {};
  let n = e;
  for (; ; ) {
    const i = XF(t, n);
    if (Object.keys(i).length === 0)
      break;
    Object.assign(t, n), Object.assign(r, i), n = o[hA](t, i);
  }
  return { state: t, changed: r };
}
function WF(o, e) {
  return o instanceof Date && e instanceof Date ? o.getTime() === e.getTime() : o === e;
}
function XF(o, e) {
  const t = {};
  for (const r in e)
    WF(e[r], o[r]) || (t[r] = !0);
  return t;
}
const w0 = /* @__PURE__ */ new Map(), i_ = /* @__PURE__ */ Symbol("shadowIdProxy"), JB = /* @__PURE__ */ Symbol("proxyElement"), YF = {
  get(o, e) {
    const r = o[JB][pA];
    return r && typeof e == "string" ? r.getElementById(e) : null;
  }
};
function ZF(o) {
  class e extends o {
    /**
     * A convenient shortcut for looking up an element by ID in the component's
     * Shadow DOM subtree.
     *
     * Example: if component's template contains a shadow element `<button
     * id="foo">`, you can use the reference `this[ids].foo` to obtain
     * the corresponding button in the component instance's shadow tree. The
     * `ids` property is simply a shorthand for `getElementById`, so
     * `this[ids].foo` is the same as
     * `this[shadowRoot].getElementById('foo')`.
     *
     * @type {object} - a dictionary mapping shadow element IDs to elements
     */
    get [WB]() {
      if (!this[i_]) {
        const r = {
          // Give the proxy a means of refering to this element via the target.
          [JB]: this
        };
        this[i_] = new Proxy(r, YF);
      }
      return this[i_];
    }
    /*
     * If the component defines a template, a shadow root will be created on the
     * component instance, and the template stamped into it.
     */
    [Ls](r) {
      if (super[Ls] && super[Ls](r), this[pA] === void 0) {
        const n = JF(this);
        if (n) {
          const i = this.attachShadow({
            delegatesFocus: this[$B],
            mode: this[Yy]
          }), a = document.importNode(n.content, !0);
          i.append(a), this[pA] = i;
        } else
          this[pA] = null;
      }
    }
    /**
     * @type {ShadowRootMode}
     * @default "open"
     */
    get [Yy]() {
      return "open";
    }
  }
  return e;
}
function JF(o) {
  let e = o[Wy] ? void 0 : w0.get(o.constructor);
  if (e === void 0) {
    if (e = o[XB], e && !(e instanceof HTMLTemplateElement))
      throw `Warning: the [template] property for ${o.constructor.name} must return an HTMLTemplateElement.`;
    o[Wy] || w0.set(o.constructor, e || null);
  }
  return e;
}
const es = DF(
  KF(ZF(HTMLElement))
), Jy = /* @__PURE__ */ Symbol("checkSize"), Tl = /* @__PURE__ */ Symbol("closestAvailableItemIndex"), eb = /* @__PURE__ */ Symbol("contentSlot"), $e = Hp, gh = /* @__PURE__ */ Symbol("defaultTabIndex"), dv = $B, eU = /* @__PURE__ */ Symbol("effectEndTarget"), jo = vl, tb = Av, Xu = /* @__PURE__ */ Symbol("getItemText"), Ri = /* @__PURE__ */ Symbol("goDown"), Qa = /* @__PURE__ */ Symbol("goEnd"), Ic = /* @__PURE__ */ Symbol("goFirst"), Mc = /* @__PURE__ */ Symbol("goLast"), Ts = /* @__PURE__ */ Symbol("goLeft"), Ms = /* @__PURE__ */ Symbol("goNext"), Rs = /* @__PURE__ */ Symbol("goPrevious"), Ps = /* @__PURE__ */ Symbol("goRight"), qa = /* @__PURE__ */ Symbol("goStart"), Rc = /* @__PURE__ */ Symbol("goToItemWithPrefix"), Oi = /* @__PURE__ */ Symbol("goUp"), tU = Wy, bt = WB, wn = /* @__PURE__ */ Symbol("inputDelegate"), rU = /* @__PURE__ */ Symbol("itemsDelegate"), xr = /* @__PURE__ */ Symbol("keydown"), oU = /* @__PURE__ */ Symbol("mouseenter"), nU = /* @__PURE__ */ Symbol("mouseleave"), Ao = zp, ut = vc, lt = Ls, iU = Kp, aU = /* @__PURE__ */ Symbol("renderDataToElement"), Rt = Wu, Yc = dA, ii = /* @__PURE__ */ Symbol("scrollTarget"), At = Xy, Cn = pA, sU = Yy, e5 = /* @__PURE__ */ Symbol("startEffect"), Ae = Zy, sr = hA, lU = /* @__PURE__ */ Symbol("swipeDown"), cU = /* @__PURE__ */ Symbol("swipeDownComplete"), uU = /* @__PURE__ */ Symbol("swipeLeft"), AU = /* @__PURE__ */ Symbol("swipeLeftTransitionEnd"), dU = /* @__PURE__ */ Symbol("swipeRight"), pU = /* @__PURE__ */ Symbol("swipeRightTransitionEnd"), hU = /* @__PURE__ */ Symbol("swipeUp"), gU = /* @__PURE__ */ Symbol("swipeUpComplete"), _U = /* @__PURE__ */ Symbol("swipeStart"), fU = /* @__PURE__ */ Symbol("swipeTarget"), zc = /* @__PURE__ */ Symbol("tap"), Ut = XB, mU = /* @__PURE__ */ Symbol("toggleSelectedFlag"), yU = new URLSearchParams(location.search).get("elixdebug");
yU === "true" && (window.elix = {
  internal: {
    checkSize: Jy,
    closestAvailableItemIndex: Tl,
    contentSlot: eb,
    defaultState: $e,
    defaultTabIndex: gh,
    delegatesFocus: dv,
    effectEndTarget: eU,
    firstRender: jo,
    focusTarget: tb,
    getItemText: Xu,
    goDown: Ri,
    goEnd: Qa,
    goFirst: Ic,
    goLast: Mc,
    goLeft: Ts,
    goNext: Ms,
    goPrevious: Rs,
    goRight: Ps,
    goStart: qa,
    goToItemWithPrefix: Rc,
    goUp: Oi,
    hasDynamicTemplate: tU,
    ids: bt,
    inputDelegate: wn,
    itemsDelegate: rU,
    keydown: xr,
    mouseenter: oU,
    mouseleave: nU,
    nativeInternals: Ao,
    event,
    raiseChangeEvents: ut,
    render: lt,
    renderChanges: iU,
    renderDataToElement: aU,
    rendered: Rt,
    rendering: Yc,
    scrollTarget: ii,
    setState: At,
    shadowRoot: Cn,
    shadowRootMode: sU,
    startEffect: e5,
    state: Ae,
    stateEffects: sr,
    swipeDown: lU,
    swipeDownComplete: cU,
    swipeLeft: uU,
    swipeLeftTransitionEnd: AU,
    swipeRight: dU,
    swipeRightTransitionEnd: pU,
    swipeUp: hU,
    swipeUpComplete: gU,
    swipeStart: _U,
    swipeTarget: fU,
    tap: zc,
    template: Ut,
    toggleSelectedFlag: mU
  }
});
function pv(o) {
  class e extends o {
    // Forward any ARIA label to the input element.
    get ariaLabel() {
      return this[Ae].ariaLabel;
    }
    set ariaLabel(r) {
      this[Ae].removingAriaAttribute || this[At]({
        ariaLabel: String(r)
      });
    }
    // Forward ARIA labelledby as an aria-label to the input element.
    // Note the lowercase "b" in the name, necessary to support the actual
    // attribute name "aria-labelledby", which has no hyphen before the "by".
    get ariaLabelledby() {
      return this[Ae].ariaLabelledby;
    }
    set ariaLabelledby(r) {
      this[Ae].removingAriaAttribute || this[At]({
        ariaLabelledby: String(r)
      });
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        ariaLabel: null,
        ariaLabelledby: null,
        inputLabel: null,
        removingAriaAttribute: !1
      });
    }
    [lt](r) {
      if (super[lt] && super[lt](r), this[jo] && this.addEventListener("focus", () => {
        this[ut] = !0;
        const n = s_(this, this[Ae]);
        this[At]({ inputLabel: n }), this[ut] = !1;
      }), r.inputLabel) {
        const { inputLabel: n } = this[Ae];
        n ? this[wn].setAttribute("aria-label", n) : this[wn].removeAttribute("aria-label");
      }
    }
    [Rt](r) {
      super[Rt] && super[Rt](r), this[jo] && (window.requestIdleCallback || setTimeout)(() => {
        const s = s_(this, this[Ae]);
        this[At]({ inputLabel: s });
      });
      const { ariaLabel: n, ariaLabelledby: i } = this[Ae];
      r.ariaLabel && !this[Ae].removingAriaAttribute && this.getAttribute("aria-label") && (this.setAttribute("delegated-label", n), this[At]({ removingAriaAttribute: !0 }), this.removeAttribute("aria-label")), r.ariaLabelledby && !this[Ae].removingAriaAttribute && this.getAttribute("aria-labelledby") && (this.setAttribute("delegated-labelledby", i), this[At]({ removingAriaAttribute: !0 }), this.removeAttribute("aria-labelledby")), r.removingAriaAttribute && this[Ae].removingAriaAttribute && this[At]({ removingAriaAttribute: !1 });
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      if (n.ariaLabel && r.ariaLabel || n.selectedText && r.ariaLabelledby && this.matches(":focus-within")) {
        const a = s_(this, r);
        Object.assign(i, { inputLabel: a });
      }
      return i;
    }
  }
  return e;
}
function a_(o) {
  if ("selectedText" in o)
    return o.selectedText;
  if ("value" in o && "options" in o) {
    const e = o.value, t = o.options.find((r) => r.value === e);
    return t ? t.innerText : "";
  } else return "value" in o ? o.value : o.innerText;
}
function s_(o, e) {
  const { ariaLabel: t, ariaLabelledby: r } = e, n = o.isConnected ? o.getRootNode() : null;
  let i = null;
  if (r && n)
    i = r.split(" ").map((l) => {
      const c = n.getElementById(l);
      return c ? c === o && e.value !== null ? e.selectedText : a_(c) : "";
    }).join(" ");
  else if (t)
    i = t;
  else if (n) {
    const a = o.id;
    if (a) {
      const s = n.querySelector(`[for="${a}"]`);
      s instanceof HTMLElement && (i = a_(s));
    }
    if (i === null) {
      const s = o.closest("label");
      s && (i = a_(s));
    }
  }
  return i && (i = i.trim()), i;
}
const Yd = /* @__PURE__ */ Symbol("mousedownListener");
function t5(o) {
  for (const e of n5(o)) {
    const t = e[Av] || e, r = t;
    if (t instanceof HTMLElement && t.tabIndex >= 0 && !r.disabled && !(t instanceof HTMLSlotElement))
      return t;
  }
  return null;
}
function* bU(o) {
  let e = o;
  for (; e = e instanceof HTMLElement && e.assignedSlot ? e.assignedSlot : e instanceof ShadowRoot ? e.host : e.parentNode, e; )
    yield e;
}
function Ks(o, e) {
  let t = e;
  for (; t; ) {
    const r = t.assignedSlot || t.parentNode || t.host;
    if (r === o)
      return !0;
    t = r;
  }
  return !1;
}
function _h(o) {
  const e = 'a[href],area[href],button:not([disabled]),details,iframe,input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[contentEditable="true"],[tabindex]', t = i5(
    o,
    (n) => n instanceof HTMLElement && n.matches(e) && n.tabIndex >= 0
  ), { value: r } = t.next();
  return r instanceof HTMLElement ? r : null;
}
function x0(o, e) {
  o[Yd] && o.removeEventListener("mousedown", o[Yd]), e && (o[Yd] = (t) => {
    if (t.button !== 0)
      return;
    const r = e[Av] || e, n = t5(r);
    n && (n.focus(), t.preventDefault());
  }, o.addEventListener("mousedown", o[Yd]));
}
function r5(o, e) {
  return Array.prototype.findIndex.call(
    o,
    (t) => t === e || Ks(t, e)
  );
}
function o5(o, e) {
  const r = e.composedPath()[0];
  return o === r || Ks(o, r);
}
function* n5(o) {
  o && (yield o, yield* bU(o));
}
function LA(o, e, t) {
  if (o.toggleAttribute(e, t), o[zp] && o[zp].states) {
    const r = o[zp].states, n = `--${e}`;
    t ? r.add(n) : r.delete(n);
  }
}
function vU(o, e) {
  const t = [...e], r = o.childNodes.length, n = t.length, i = Math.max(r, n);
  for (let a = 0; a < i; a++) {
    const s = o.childNodes[a], l = t[a];
    a >= r ? o.append(l) : a >= n ? o.removeChild(o.childNodes[n]) : s !== l && (t.indexOf(s, a) >= a ? o.insertBefore(l, s) : o.replaceChild(l, s));
  }
}
function* i5(o, e) {
  e(o) && (yield o);
  let t;
  if (o instanceof HTMLElement && o.shadowRoot)
    t = o.shadowRoot.children;
  else {
    const r = o instanceof HTMLSlotElement ? o.assignedNodes({ flatten: !0 }) : [];
    t = r.length > 0 ? (
      // Walk light DOM nodes assigned to this slot.
      r
    ) : (
      // Walk light DOM children.
      o.childNodes
    );
  }
  if (t)
    for (let r = 0; r < t.length; r++)
      yield* i5(t[r], e);
}
let Oc = !1;
const Fu = /* @__PURE__ */ Symbol("focusVisibleChangedListener");
function Oh(o) {
  return class extends o {
    constructor() {
      super(), this.addEventListener("focusout", (t) => {
        Promise.resolve().then(() => {
          const n = t.relatedTarget || document.activeElement, i = this === n, a = Ks(this, n);
          !i && !a && (this[At]({
            focusVisible: !1
          }), document.removeEventListener(
            "focusvisiblechange",
            this[Fu]
          ), this[Fu] = null);
        });
      }), this.addEventListener("focusin", () => {
        Promise.resolve().then(() => {
          this[Ae].focusVisible !== Oc && this[At]({
            focusVisible: Oc
          }), this[Fu] || (this[Fu] = () => wU(this), document.addEventListener(
            "focusvisiblechange",
            this[Fu]
          ));
        });
      });
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        focusVisible: !1
      });
    }
    [lt](t) {
      if (super[lt] && super[lt](t), t.focusVisible) {
        const { focusVisible: r } = this[Ae];
        this.toggleAttribute("focus-visible", r);
      }
    }
    get [Ut]() {
      const t = super[Ut] || Ja.html``;
      return t.content.append(kr.html`
        <style>
          :host {
            outline: none;
          }

          :host([focus-visible]:focus-within) {
            outline-color: Highlight; /* Firefox */
            outline-color: -webkit-focus-ring-color; /* All other browsers */
            outline-style: auto;
          }
        </style>
      `), t;
    }
  };
}
function wU(o) {
  o[At]({
    focusVisible: Oc
  });
}
function a5(o) {
  if (Oc !== o) {
    Oc = o;
    const e = new CustomEvent("focusvisiblechange", {
      detail: {
        focusVisible: Oc
      }
    });
    document.dispatchEvent(e);
  }
}
window.addEventListener(
  "keydown",
  () => {
    a5(!0);
  },
  { capture: !0 }
);
window.addEventListener(
  "mousedown",
  () => {
    a5(!1);
  },
  { capture: !0 }
);
function s5(o) {
  class e extends o {
    constructor() {
      super();
      const r = this;
      !this[Ao] && r.attachInternals && (this[Ao] = r.attachInternals());
    }
    checkValidity() {
      return this[Ao].checkValidity();
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        name: "",
        validationMessage: "",
        valid: !0
      });
    }
    // Uncomment for debugging only
    get internals() {
      return this[Ao];
    }
    static get formAssociated() {
      return !0;
    }
    /**
     * The ID of the `form` element with which this element is associated,
     * or `null` if the element is not associated with any form. This is provided
     * for consistency with the native HTML
     * [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form)
     * property.
     *
     * @type {string}
     */
    get form() {
      return this[Ao].form;
    }
    /**
     * The name of the form field that will be filled with this element's
     * `value`. This is an analogue of the standard HTML
     * [name](https://developer.mozilla.org/en-US/docs/Web/API/Element/name)
     * property.
     *
     * @type {string}
     */
    get name() {
      return this[Ae] ? this[Ae].name : "";
    }
    set name(r) {
      const n = String(r);
      "name" in o.prototype && (super.name = n), this[At]({
        name: n
      });
    }
    [lt](r) {
      if (super[lt] && super[lt](r), r.name) {
        const { name: n } = this[Ae];
        n ? this.setAttribute("name", n) : this.removeAttribute("name");
      }
      if (this[Ao] && this[Ao].setValidity && (r.valid || r.validationMessage)) {
        const { valid: n, validationMessage: i } = this[Ae];
        n ? this[Ao].setValidity({}) : this[Ao].setValidity(
          {
            customError: !0
          },
          i
        );
      }
    }
    [Rt](r) {
      super[Rt] && super[Rt](r), r.value && this[Ao] && this[Ao].setFormValue && this[Ao].setFormValue(this[Ae].value, this[Ae]);
    }
    reportValidity() {
      return this[Ao].reportValidity();
    }
    /**
     * The "type" of the form field, provided for consistency with the
     * native HTML
     * [type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#type)
     * property.
     *
     * If a base class provides a `type` property, that will be returned. (If
     * this mixin is applied to a class defined by WrappedStandardElement, this
     * will return the `type` of the inner standard element.) Otherwise, the
     * default value of this property will be the same as the HTML tag name
     * registered for the custom element.
     *
     * @type {string}
     */
    get type() {
      return super.type || this.localName;
    }
    get validationMessage() {
      return this[Ae].validationMessage;
    }
    get validity() {
      return this[Ao].validity;
    }
    get willValidate() {
      return this[Ao].willValidate;
    }
  }
  return e;
}
function xU(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        selectionEnd: 0,
        selectionStart: 0
      });
    }
    [lt](r) {
      if (super[lt] && super[lt](r), this[jo]) {
        const n = (() => {
          setTimeout(() => {
            this[ut] = !0, k0(this), this[ut] = !1;
          }, 10);
        }).bind(this);
        this.addEventListener("keydown", n), this.addEventListener("mousedown", n), this.addEventListener("touchend", n);
      }
    }
    [Rt](r) {
      super[Rt](r), r.value && k0(this);
    }
  }
  return e;
}
function k0(o) {
  const e = o.inner, { selectionEnd: t, selectionStart: r } = e;
  o[At]({
    selectionEnd: t,
    selectionStart: r
  });
}
function Qh(o) {
  class e extends o {
    /**
     * Returns true if the component is delegating its focus.
     *
     * A component using `DelegateFocusMixin` will always have this property be
     * true unless a class takes measures to override it.
     *
     * @type {boolean}
     * @default true
     */
    get [dv]() {
      return !0;
    }
    /**
     * If someone tries to put the focus on us, delegate the focus to the first
     * focusable element in the composed tree below our shadow root.
     *
     * @ignore
     * @param {FocusOptions=} focusOptions
     */
    focus(r) {
      const n = this[tb];
      n && n.focus(r);
    }
    get [tb]() {
      return _h(this[Cn]);
    }
  }
  return e;
}
const C0 = /* @__PURE__ */ Symbol("extends"), rb = /* @__PURE__ */ Symbol("delegatedPropertySetters"), kU = {
  a: !0,
  area: !0,
  button: !0,
  details: !0,
  iframe: !0,
  input: !0,
  select: !0,
  textarea: !0
}, CU = {
  address: ["scroll"],
  blockquote: ["scroll"],
  caption: ["scroll"],
  center: ["scroll"],
  dd: ["scroll"],
  dir: ["scroll"],
  div: ["scroll"],
  dl: ["scroll"],
  dt: ["scroll"],
  fieldset: ["scroll"],
  form: ["reset", "scroll"],
  frame: ["load"],
  h1: ["scroll"],
  h2: ["scroll"],
  h3: ["scroll"],
  h4: ["scroll"],
  h5: ["scroll"],
  h6: ["scroll"],
  iframe: ["load"],
  img: ["abort", "error", "load"],
  input: ["abort", "change", "error", "select", "load"],
  li: ["scroll"],
  link: ["load"],
  menu: ["scroll"],
  object: ["error", "scroll"],
  ol: ["scroll"],
  p: ["scroll"],
  script: ["error", "load"],
  select: ["change", "scroll"],
  tbody: ["scroll"],
  tfoot: ["scroll"],
  thead: ["scroll"],
  textarea: ["change", "select", "scroll"]
}, SU = [
  "click",
  "dblclick",
  "mousedown",
  "mouseenter",
  "mouseleave",
  "mousemove",
  "mouseout",
  "mouseover",
  "mouseup",
  "wheel"
], BU = {
  abort: !0,
  change: !0,
  reset: !0
}, EU = [
  "address",
  "article",
  "aside",
  "blockquote",
  "canvas",
  "dd",
  "div",
  "dl",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "header",
  "hgroup",
  "hr",
  "li",
  "main",
  "nav",
  "noscript",
  "ol",
  "output",
  "p",
  "pre",
  "section",
  "table",
  "tfoot",
  "ul",
  "video"
], S0 = [
  "accept-charset",
  "autoplay",
  "buffered",
  "challenge",
  "codebase",
  "colspan",
  "contenteditable",
  "controls",
  "crossorigin",
  "datetime",
  "dirname",
  "for",
  "formaction",
  "http-equiv",
  "icon",
  "ismap",
  "itemprop",
  "keytype",
  "language",
  "loop",
  "manifest",
  "maxlength",
  "minlength",
  "muted",
  "novalidate",
  "preload",
  "radiogroup",
  "readonly",
  "referrerpolicy",
  "rowspan",
  "scoped",
  "usemap"
], jU = Qh(es);
class qh extends jU {
  constructor() {
    super();
    const e = this;
    !this[Ao] && e.attachInternals && (this[Ao] = e.attachInternals());
  }
  /**
   *
   * Wrapped standard elements need to forward some attributes to the inner
   * element in cases where the attribute does not have a corresponding
   * property. These attributes include those prefixed with "aria-", and some
   * unusual standard attributes like contenteditable. To handle those, this
   * class defines its own attributeChangedCallback.
   *
   * @ignore
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   */
  attributeChangedCallback(e, t, r) {
    if (S0.indexOf(e) >= 0) {
      const i = Object.assign({}, this[Ae].innerAttributes, {
        [e]: r
      });
      this[At]({ innerAttributes: i });
    } else
      super.attributeChangedCallback(e, t, r);
  }
  // Delegate method defined by HTMLElement.
  blur() {
    this.inner.blur();
  }
  // One HTMLElement we *don't* delegate is `click`. Generally speaking, a click
  // on the outer wrapper should behave the same as a click on the inner
  // element. Also, we want to ensure outside event listeners get a click event
  // when the click method is invoked. But a click on the inner element will
  // raise a click event that won't be re-raised by default across the shadow
  // boundary. The precise behavior seems to be slightly different in Safari
  // than other browsers, but it seems safer to not delegate click.
  //
  // click() {}
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      innerAttributes: {}
    });
  }
  get [gh]() {
    return kU[this.extends] ? 0 : -1;
  }
  /**
   * The tag name of the standard HTML element extended by this class.
   *
   * @returns {string}
   */
  get extends() {
    return this.constructor[C0];
  }
  /**
   * Returns a reference to the inner standard HTML element.
   *
   * @type {HTMLElement}
   */
  get inner() {
    const e = this[bt] && this[bt].inner;
    return e || console.warn(
      "Attempted to get an inner standard element before it was instantiated."
    ), e;
  }
  static get observedAttributes() {
    return [...super.observedAttributes, ...S0];
  }
  [lt](e) {
    super[lt](e);
    const t = this.inner;
    if (this[jo] && ((CU[this.extends] || []).forEach((n) => {
      t.addEventListener(n, () => {
        const i = new Event(n, {
          bubbles: BU[n] || !1
        });
        this.dispatchEvent(i);
      });
    }), "disabled" in t && SU.forEach((n) => {
      this.addEventListener(n, (i) => {
        /** @type {any} */
        t.disabled && i.stopImmediatePropagation();
      });
    })), e.tabIndex && (t.tabIndex = this[Ae].tabIndex), e.innerAttributes) {
      const { innerAttributes: r } = this[Ae];
      for (const n in r)
        LU(t, n, r[n]);
    }
    this.constructor[rb].forEach((r) => {
      if (e[r]) {
        const n = this[Ae][r];
        (r === "selectionEnd" || r === "selectionStart") && n === null || (t[r] = n);
      }
    });
  }
  [Rt](e) {
    if (super[Rt](e), e.disabled) {
      const { disabled: t } = this[Ae];
      t !== void 0 && LA(this, "disabled", t);
    }
  }
  /**
   * The template copied into the shadow tree of new instances of this element.
   *
   * The default value of this property is a template that includes an instance
   * the standard element being wrapped, with a `<slot>` element inside that
   * to pick up the element's light DOM content. For example, if you wrap an
   * `<a>` element, then the default template will look like:
   *
   *     <template>
   *       <style>
   *       :host {
   *         display: inline-block;
   *       }
   *       </style>
   *       <a id="inner">
   *         <slot></slot>
   *       </a>
   *     </template>
   *
   * The `display` styling applied to the host will be `block` for elements that
   * are block elements by default, and `inline-block` (not `inline`) for other
   * elements.
   *
   * If you'd like the template to include other elements, then override this
   * property and return a template of your own. The template should include an
   * instance of the standard HTML element you are wrapping, and the ID of that
   * element should be "inner".
   *
   * @type {(string|HTMLTemplateElement)}
   */
  get [Ut]() {
    const e = EU.includes(this.extends) ? "block" : "inline-block", t = this.extends;
    return Ja.html`
      <style>
        :host {
          display: ${e}
        }
        
        [part~="inner"] {
          box-sizing: border-box;
          height: 100%;
          width: 100%;
        }
      </style>
      <${t} id="inner" part="inner ${t}">
        <slot></slot>
      </${t}>
    `;
  }
  /**
   * Creates a class that wraps a standard HTML element.
   *
   * Note that the resulting class is a subclass of WrappedStandardElement, not
   * the standard class being wrapped. E.g., if you call
   * `WrappedStandardElement.wrap('a')`, you will get a class whose shadow tree
   * will include an anchor element, but the class will *not* inherit from
   * HTMLAnchorElement.
   *
   * @static
   * @param {string} extendsTag - the standard HTML element tag to extend
   */
  static wrap(e) {
    class t extends qh {
    }
    t[C0] = e;
    const r = document.createElement(e);
    return UU(t, Object.getPrototypeOf(r)), t;
  }
}
function LU(o, e, t) {
  ZB[e] ? typeof t == "string" ? o.setAttribute(e, "") : t === null && o.removeAttribute(e) : t != null ? o.setAttribute(e, t.toString()) : o.removeAttribute(e);
}
function TU(o, e) {
  if (typeof e.value == "function") {
    if (o !== "constructor")
      return PU(o, e);
  } else if (typeof e.get == "function" || typeof e.set == "function")
    return FU(o, e);
  return null;
}
function PU(o, e) {
  const t = function(...n) {
    this.inner[o](...n);
  };
  return {
    configurable: e.configurable,
    enumerable: e.enumerable,
    value: t,
    writable: e.writable
  };
}
function FU(o, e) {
  const t = {
    configurable: e.configurable,
    enumerable: e.enumerable
  };
  return e.get && (t.get = function() {
    return NU(
      /** @type {any} */
      this,
      o
    );
  }), e.set && (t.set = function(r) {
    IU(
      /** @type {any} */
      this,
      o,
      r
    );
  }), e.writable && (t.writable = e.writable), t;
}
function UU(o, e) {
  const t = Object.getOwnPropertyNames(e);
  o[rb] = [], t.forEach((r) => {
    const n = Object.getOwnPropertyDescriptor(e, r);
    if (!n)
      return;
    const i = TU(r, n);
    i && (Object.defineProperty(o.prototype, r, i), i.set && o[rb].push(r));
  });
}
function NU(o, e) {
  return o[Ae][e] || o[Cn] && o.inner[e];
}
function IU(o, e, t) {
  o[Ae][e] !== t && o[At]({ [e]: t });
}
const MU = pv(
  Oh(
    s5(
      xU(qh.wrap("input"))
    )
  )
);
class RU extends MU {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      value: ""
    });
  }
  get [wn]() {
    return this.inner;
  }
  [lt](e) {
    super[lt](e), this[jo] && this[bt].inner.addEventListener("input", () => {
      this[ut] = !0;
      const t = this[bt].inner;
      this[At]({ value: t.value }), this[ut] = !1;
    });
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(kr.html`
      <style>
        [part~="input"] {
          font: inherit;
          outline: none;
          text-align: inherit;
        }
      </style>
    `), e;
  }
  get value() {
    return this[Ae].value;
  }
  set value(e) {
    this[At]({
      value: String(e)
    });
  }
}
function OU(o) {
  return class extends o {
    get [Ut]() {
      const t = super[Ut];
      return t.content.append(kr.html`
        <style>
          :host {
            background: white;
            border: 1px solid gray;
            box-sizing: border-box;
          }

          [part~="input"] {
            background: transparent;
            border-color: transparent;
          }
        </style>
      `), t;
    }
  };
}
class l5 extends OU(RU) {
}
class QU extends l5 {
}
customElements.define("elix-input", QU);
const c5 = document.createElement("template");
c5.innerHTML = `
  <style>
  div {
    height: 24px;
    margin: 5px 1px;
    padding: 3px;
  }
  img {
    top: 2px;
    left: 4px;
    position: relative;
  }
  span {
    bottom: 1px;
    right: -4px;
    position: relative;
    margin-right: 4px;
    color: #fff;
  }
  elix-input {
    background-color: var(--input-color);
    border-radius: 3px;
    height: 24px;
  }
  </style>
  <div>
  <img alt="icon" width="12" height="12" />
  <span id="label">label</span>
  <elix-input></elix-input>
  </div>
`;
class qU extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(c5.content.cloneNode(!0)), this.$div = this._shadowRoot.querySelector("div"), this.$img = this._shadowRoot.querySelector("img"), this.$label = this.shadowRoot.getElementById("label"), this.$event = new CustomEvent("change"), this.$input = this._shadowRoot.querySelector("elix-input");
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["value", "label", "src", "size", "title"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          this.$div.setAttribute("title", `${no(r)}`);
          break;
        case "src":
          this.$img.setAttribute("src", r), this.$label.remove();
          break;
        case "size":
          this.$input.setAttribute("size", r);
          break;
        case "label":
          this.$label.textContent = no(r), this.$img.remove();
          break;
        case "value":
          this.$input.value = r;
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get label() {
    return this.getAttribute("label");
  }
  /**
   * @function set
   * @returns {void}
   */
  set label(e) {
    this.setAttribute("label", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get value() {
    return this.$input.value;
  }
  /**
   * @function set
   * @returns {void}
   */
  set value(e) {
    this.$input.value = e;
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get size() {
    return this.getAttribute("size");
  }
  /**
   * @function set
   * @returns {void}
   */
  set size(e) {
    this.setAttribute("size", e);
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    this.$input.addEventListener("change", (e) => {
      e.preventDefault(), this.value = e.target.value, this.dispatchEvent(this.$event);
    }), this.$input.addEventListener("keyup", (e) => {
      e.preventDefault(), this.value = e.target.value, this.dispatchEvent(this.$event);
    });
  }
}
customElements.define("se-input", qU);
const u5 = document.createElement("div");
u5.attachShadow({ mode: "open", delegatesFocus: !0 });
const GU = u5.shadowRoot, VU = GU.delegatesFocus;
function DU(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        composeFocus: !VU
      });
    }
    [lt](r) {
      super[lt] && super[lt](r), this[jo] && this.addEventListener("mousedown", (n) => {
        if (this[Ae].composeFocus && n.button === 0 && n.target instanceof Element) {
          const i = t5(n.target);
          i && (i.focus(), n.preventDefault());
        }
      });
    }
  }
  return e;
}
const HU = DU(
  pv(
    Oh(qh.wrap("button"))
  )
);
class A5 extends HU {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      role: "button"
    });
  }
  get [wn]() {
    return this[bt].inner;
  }
  // Respond to a simulated click.
  [zc]() {
    const e = new MouseEvent("click", {
      bubbles: !0,
      cancelable: !0
    });
    this.dispatchEvent(e);
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          :host {
            display: inline-flex;
            outline: none;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
          }

          [part~="button"] {
            align-items: center;
            background: none;
            border: none;
            color: inherit;
            flex: 1;
            font: inherit;
            outline: none;
            padding: 0;
          }
        </style>
      `
    ), e;
  }
}
class d5 extends MouseEvent {
}
function zU(o) {
  return class extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        repeatDelayDuration: 500,
        // In ms. Wait a bit before starting repeats.
        repeatInterval: null,
        repeatIntervalDuration: 50,
        // In ms. Once repeats start, they go fast.
        repeatTimeout: null
      });
    }
    [lt](t) {
      super[lt] && super[lt](t), this[jo] && (this.addEventListener("mousedown", (r) => {
        !(r instanceof d5) && r.button === 0 && (this[ut] = !0, B0(this), this[ut] = !1);
      }), this.addEventListener("mouseup", (r) => {
        r.button === 0 && (this[ut] = !0, l_(this), this[ut] = !1);
      }), this.addEventListener("mouseleave", (r) => {
        r.button === 0 && (this[ut] = !0, l_(this), this[ut] = !1);
      }), this.addEventListener("touchstart", () => {
        this[ut] = !0, B0(this), this[ut] = !1;
      }), this.addEventListener("touchend", () => {
        this[ut] = !0, l_(this), this[ut] = !1;
      }));
    }
    [sr](t, r) {
      const n = super[sr] ? super[sr](t, r) : {};
      return r.disabled && t.disabled && (p5(this), Object.assign(n, {
        repeatInterval: null,
        repeatTimeout: null
      })), n;
    }
  };
}
function p5(o) {
  o[Ae].repeatTimeout && clearTimeout(o[Ae].repeatTimeout), o[Ae].repeatInterval && clearInterval(o[Ae].repeatInterval);
}
function B0(o) {
  const { repeatIntervalDuration: e, repeatDelayDuration: t } = o[Ae], r = setTimeout(() => {
    const n = setInterval(() => {
      KU(o);
    }, e);
    o[At]({ repeatInterval: n });
  }, t - e);
  o[At]({ repeatTimeout: r });
}
function l_(o) {
  p5(o), o[At]({
    repeatTimeout: null,
    repeatInterval: null
  });
}
function KU(o) {
  const e = new d5("mousedown", {
    bubbles: !0,
    button: 0,
    cancelable: !0,
    clientX: 0,
    clientY: 0
  });
  o.dispatchEvent(e);
}
class $U extends zU(A5) {
}
function h5(o) {
  return class extends o {
    get [Ut]() {
      const t = super[Ut];
      return t.content.append(kr.html`
        <style>
          :host([disabled]) ::slotted(*) {
            opacity: 0.5;
          }

          [part~="button"] {
            display: inline-flex;
            justify-content: center;
            margin: 0;
            position: relative;
          }
        </style>
      `), t;
    }
  };
}
class WU extends h5($U) {
}
function XU(o) {
  return class extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        buttonPartType: WU,
        inputPartType: l5
      });
    }
    get [Ut]() {
      const t = super[Ut], r = t.content.getElementById("upButton");
      r.textContent = "▲";
      const n = t.content.getElementById("downButton");
      return n.textContent = "▼", t.content.append(kr.html`
        <style>
          :host {
            background: white;
            border: 1px solid gray;
            box-sizing: border-box;
          }

          [part~="input"] {
            background: transparent;
            border: none;
            width: 4em;
          }

          [part~="spin-button"] {
            background: transparent;
            border: 1px solid gray;
            box-sizing: border-box;
            font-size: 0.6em;
            padding: 2px;
          }

          [part~="up-button"] {
            border-right: none;
            border-top: none;
          }

          [part~="down-button"] {
            border-bottom: none;
            border-right: none;
            border-top: none;
          }
        </style>
      `), t;
    }
  };
}
const E0 = /* @__PURE__ */ new Map();
function g5(o) {
  if (typeof o == "function") {
    let e;
    try {
      e = new o();
    } catch (t) {
      if (t.name === "TypeError")
        YU(o), e = new o();
      else
        throw t;
    }
    return e;
  } else
    return document.createElement(o);
}
function YU(o) {
  let e;
  const t = /^[A-Za-z][A-Za-z0-9_$]*$/, r = o.name && o.name.match(t);
  if (r) {
    const a = r[0], s = /([A-Z])/g;
    e = a.replace(
      s,
      (c, u, A) => A > 0 ? `-${u}` : u
    ).toLowerCase();
  } else
    e = "custom-element";
  let n = E0.get(e) || 0, i;
  for (; i = `${e}-${n}`, !!customElements.get(i); n++)
    ;
  customElements.define(
    i,
    /** @type {any} */
    o
  ), E0.set(e, n + 1);
}
function ob(o, e) {
  const t = o.parentNode;
  if (!t)
    throw "An element must have a parent before it can be substituted.";
  return (o instanceof HTMLElement || o instanceof SVGElement) && (e instanceof HTMLElement || e instanceof SVGElement) && (Array.prototype.forEach.call(
    o.attributes,
    (r) => {
      !e.getAttribute(r.name) && r.name !== "class" && r.name !== "style" && e.setAttribute(r.name, r.value);
    }
  ), Array.prototype.forEach.call(
    o.classList,
    (r) => {
      e.classList.add(r);
    }
  ), Array.prototype.forEach.call(
    o.style,
    (r) => {
      e.style[r] || (e.style[r] = o.style[r]);
    }
  )), e.append(...o.childNodes), t.replaceChild(e, o), e;
}
function qs(o, e) {
  if (typeof e == "function" && o.constructor === e || typeof e == "string" && o instanceof Element && o.localName === e)
    return o;
  {
    const t = g5(e);
    return ob(o, t), t;
  }
}
function ZU(o) {
  class e extends o {
    /**
     * Selects all the text.
     *
     * See the standard [select](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select)
     * documentation for details.
     */
    select() {
      this[wn].select();
    }
    /**
     * The end index of the selected text.
     *
     * See the standard [input](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement)
     * element documentation for details.
     */
    get selectionEnd() {
      return this[wn].selectionEnd;
    }
    set selectionEnd(r) {
      this[wn].selectionEnd = r;
    }
    /**
     * The beginning index of the selected text.
     *
     * See the standard [input](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement)
     * element documentation for details.
     */
    get selectionStart() {
      return this[wn].selectionStart;
    }
    set selectionStart(r) {
      this[wn].selectionStart = r;
    }
    /**
     * Replaces a range of text.
     *
     * See the standard [setRangeText](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setRangeText)
     * documentation for details.
     */
    setRangeText(...r) {
      this[wn].setRangeText(...r);
    }
    /**
     * Sets the start and end positions of the current text selection.
     *
     * See the standard [setSelectionRange](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange)
     * documentation for details.
     */
    setSelectionRange(...r) {
      this[wn].setSelectionRange(...r), document.createElement("input").select;
    }
  }
  return e;
}
function Gh(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        disabled: !1
      });
    }
    /**
     * True if the component is disabled, false (the default) if not.
     *
     * The value of this property will be reflected to the `disabled` attribute
     * so that it can be referenced in CSS. Note that this non-native
     * implementation of the `disabled` attribute will *not* trigger the
     * `:disabled` CSS pseudo-class, so your style rules will have to reference
     * the presence or absence of the `disabled` attribute. That is, instead
     * of writing
     *
     *     my-component:disabled { ... }
     *
     * write this instead
     *
     *     my-component[disabled] { ... }
     *
     * Like the native `disabled` attribute, this attribute is boolean. That
     * means that it's *existence* in markup sets the attribute, even if set to
     * an empty string or a string like "false".
     *
     * @type {boolean}
     * @default false
     */
    get disabled() {
      return this[Ae].disabled;
    }
    // AttributeMarshallingMixin should parse this as a boolean attribute for us.
    set disabled(r) {
      this[At]({ disabled: r });
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), r.disabled && (this.toggleAttribute("disabled", this.disabled), this[ut])) {
        const n = new CustomEvent("disabledchange", {
          bubbles: !0
        });
        this.dispatchEvent(n);
      }
    }
  }
  return e;
}
function _5(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e], {
        handleBubblingDirectionKeys: !1
      });
    }
    /**
     * Invoked when the user wants to go/navigate down.
     * The default implementation of this method does nothing.
     */
    [Ri]() {
      if (super[Ri])
        return super[Ri]();
    }
    /**
     * Invoked when the user wants to go/navigate to the end (e.g., of a list).
     * The default implementation of this method does nothing.
     */
    [Qa]() {
      if (super[Qa])
        return super[Qa]();
    }
    /**
     * Invoked when the user wants to go/navigate left.
     * The default implementation of this method does nothing.
     */
    [Ts]() {
      if (super[Ts])
        return super[Ts]();
    }
    /**
     * Invoked when the user wants to go/navigate right.
     * The default implementation of this method does nothing.
     */
    [Ps]() {
      if (super[Ps])
        return super[Ps]();
    }
    /**
     * Invoked when the user wants to go/navigate to the start (e.g., of a
     * list). The default implementation of this method does nothing.
     */
    [qa]() {
      if (super[qa])
        return super[qa]();
    }
    /**
     * Invoked when the user wants to go/navigate up.
     * The default implementation of this method does nothing.
     */
    [Oi]() {
      if (super[Oi])
        return super[Oi]();
    }
    [xr](r) {
      let n = !1;
      if (this[Ae].handleBubblingDirectionKeys || r.target === this) {
        const i = this[Ae].orientation || "both", a = i === "horizontal" || i === "both", s = i === "vertical" || i === "both";
        switch (r.key) {
          case "ArrowDown":
            s && (n = r.altKey ? this[Qa]() : this[Ri]());
            break;
          case "ArrowLeft":
            a && !r.metaKey && !r.altKey && (n = this[Ts]());
            break;
          case "ArrowRight":
            a && !r.metaKey && !r.altKey && (n = this[Ps]());
            break;
          case "ArrowUp":
            s && (n = r.altKey ? this[qa]() : this[Oi]());
            break;
          case "End":
            n = this[Qa]();
            break;
          case "Home":
            n = this[qa]();
            break;
        }
      }
      return n || super[xr] && super[xr](r) || !1;
    }
  }
  return e;
}
function GA(o) {
  class e extends o {
    constructor() {
      super(), this.addEventListener("keydown", async (r) => {
        this[ut] = !0, this[Ae].focusVisible || this[At]({
          focusVisible: !0
        }), this[xr](r) && (r.preventDefault(), r.stopImmediatePropagation()), await Promise.resolve(), this[ut] = !1;
      });
    }
    attributeChangedCallback(r, n, i) {
      if (r === "tabindex") {
        let a;
        i === null ? a = -1 : (a = Number(i), isNaN(a) && (a = this[gh] ? this[gh] : 0)), this.tabIndex = a;
      } else
        super.attributeChangedCallback(r, n, i);
    }
    // @ts-ignore
    get [$e]() {
      const r = this[dv] ? -1 : 0;
      return Object.assign(super[$e] || {}, {
        tabIndex: r
      });
    }
    /**
     * See the [symbols](internal#internal.keydown) documentation for details.
     */
    [xr](r) {
      return super[xr] ? super[xr](r) : !1;
    }
    [lt](r) {
      super[lt] && super[lt](r), r.tabIndex && (this.tabIndex = this[Ae].tabIndex);
    }
    // Record our own notion of the state of the tabIndex property so we can
    // rerender if necessary.
    get tabIndex() {
      return super.tabIndex;
    }
    set tabIndex(r) {
      super.tabIndex !== r && (super.tabIndex = r), this[Yc] || this[At]({
        tabIndex: r
      });
    }
  }
  return e;
}
const JU = Qh(
  pv(
    ZU(
      Gh(
        Oh(
          s5(
            _5(GA(es))
          )
        )
      )
    )
  )
);
class eN extends JU {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      buttonPartType: "button",
      canGoDown: !0,
      canGoUp: !0,
      inputPartType: "input",
      orientation: "vertical",
      step: 1,
      stepSelect: !1,
      value: ""
    });
  }
  [Ri]() {
    return super[Ri] && super[Ri](), this.stepDown(), !0;
  }
  [Oi]() {
    return super[Oi] && super[Oi](), this.stepUp(), !0;
  }
  get [wn]() {
    return this[bt].input;
  }
  [lt](e) {
    if (super[lt](e), tN(this[Cn], this[Ae], e), e.buttonPartType && (this[bt].downButton.addEventListener("mousedown", () => {
      this[ut] = !0, this.stepDown(), this[ut] = !1;
    }), this[bt].upButton.addEventListener("mousedown", () => {
      this[ut] = !0, this.stepUp(), this[ut] = !1;
    })), e.inputPartType && this[bt].input.addEventListener("input", () => {
      this[ut] = !0, this.value = /** @type {any} */
      this[bt].input.value, this[ut] = !1;
    }), e.buttonPartType || e.inputPartType) {
      const n = this[bt].input, i = this[bt].downButton;
      i instanceof HTMLElement && n instanceof HTMLElement && x0(i, n);
      const a = this[bt].upButton;
      a instanceof HTMLElement && n instanceof HTMLElement && x0(a, n);
    }
    const { disabled: t, value: r } = this[Ae];
    if (e.canGoUp || e.canGoDown || e.disabled) {
      const { canGoUp: n, canGoDown: i } = this[Ae];
      if ("disabled" in this[bt].input && (this[bt].input.disabled = t), "disabled" in this[bt].downButton) {
        const a = t || !n;
        this[bt].upButton.disabled = a;
      }
      if ("disabled" in this[bt].upButton) {
        const a = t || !i;
        this[bt].downButton.disabled = a;
      }
    }
    e.value && (this[bt].input.value = r);
  }
  [Rt](e) {
    super[Rt](e);
    const { stepSelect: t, value: r } = this[Ae];
    if (e.value && t) {
      const n = this[bt].input, i = r.length;
      n.selectionStart = i, n.selectionEnd = i, this[At]({ stepSelect: !1 });
    }
    if (e.value && this[ut]) {
      const n = new CustomEvent("change", {
        bubbles: !0,
        detail: { value: r }
      });
      this.dispatchEvent(n);
    }
  }
  stepDown() {
    this[At]({ stepSelect: !0 });
  }
  stepUp() {
    this[At]({ stepSelect: !0 });
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(kr.html`
      <style>
        :host {
          display: inline-grid;
        }

        [part~="input"] {
          grid-row-end: 3;
          grid-row-start: 1;
          outline: none;
          text-align: right;
        }

        [part~="spin-button"] {
          grid-column: 2;
          user-select: none;
        }
      </style>
      <div id="input" part="input"></div>
      <div id="upButton" part="spin-button up-button" tabindex="-1"></div>
      <div id="downButton" part="spin-button down-button" tabindex="-1"></div>
    `), e;
  }
  /**
   * The text entered in the spin box.
   *
   * @type {string}
   * @default ""
   */
  get value() {
    return this[Ae].value;
  }
  set value(e) {
    this[At]({
      value: String(e)
    });
  }
}
function tN(o, e, t) {
  if (!t || t.inputPartType) {
    const { buttonPartType: r } = e;
    o.querySelectorAll('[part~="spin-button"]').forEach((i) => {
      qs(i, r);
    });
  }
  if (!t || t.inputPartType) {
    const { inputPartType: r } = e, n = o.getElementById("input");
    n && qs(n, r);
  }
}
class rN extends eN {
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    e === "max" ? this.max = parseFloat(r) : e === "min" ? this.min = parseFloat(r) : e === "step" ? this.step = parseFloat(r) : super.attributeChangedCallback(e, t, r);
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  get [$e]() {
    return Object.assign(super[$e], {
      max: null,
      min: null,
      step: 1
    });
  }
  /**
   * @function formatValue
   * Format the numeric value as a string.
   *
   * This is used after incrementing/decrementing the value to reformat the
   * value as a string.
   *
   * @param {number} value
   * @param {number} precision
   * @returns {number}
   */
  formatValue(e, t) {
    return Number(e).toFixed(t);
  }
  /**
   * The maximum allowable value of the `value` property.
   *
   * @type {number|null}
   * @default 1
   */
  get max() {
    return this[Ae].max;
  }
  /**
   * The maximum allowable value of the `value` property.
   *
   * @type {number|null}
   * @default 1
   */
  set max(e) {
    this[At]({
      max: e
    });
  }
  /**
   * The minimum allowable value of the `value` property.
   *
   * @type {number|null}
   * @default 1
   */
  get min() {
    return this[Ae].min;
  }
  /**
   * @function set
   * @returns {void}
   */
  set min(e) {
    this[At]({
      min: e
    });
  }
  /**
   * @function parseValue
   * @param {number} value
   * @param {number} precision
   * @returns {int}
   */
  parseValue(e, t) {
    const r = t === 0 ? parseInt(e) : parseFloat(e);
    return isNaN(r) ? 0 : r;
  }
  /**
   * @function stateEffects
   * @param {any} state
   * @param {any} changed
   * @returns {any}
   */
  [sr](e, t) {
    const r = super[sr];
    if (t.step) {
      const {
        step: n
      } = e, a = /\.(\d)+$/.exec(String(n)), s = a && a[1] ? a[1].length : 0;
      Object.assign(r, {
        precision: s
      });
    }
    if (t.max || t.min || t.value) {
      const {
        max: n,
        min: i,
        precision: a,
        value: s
      } = e, l = parseInt(s, a);
      s !== "" && isNaN(l) ? Object.assign(r, {
        valid: !1,
        validationMessage: "Value must be a number"
      }) : n === null || l <= n ? i === null || l >= i ? Object.assign(r, {
        valid: !0,
        validationMessage: ""
      }) : Object.assign(r, {
        valid: !1,
        validationMessage: `Value must be greater than or equal to ${i}.`
      }) : Object.assign(r, {
        valid: !1,
        validationMessage: `Value must be less than or equal to ${n}.`
      }), Object.assign(r, {
        canGoUp: isNaN(l) || e.max === null || l <= e.max
      }), Object.assign(r, {
        canGoDown: isNaN(l) || e.min === null || l >= e.min
      });
    }
    return r;
  }
  /**
   * @function get
   * @returns {any}
   */
  get step() {
    return this[Ae].step;
  }
  /**
   * @function set
   * @returns {void}
   */
  set step(e) {
    isNaN(e) || this[At]({
      step: e
    });
  }
  /**
   * @function stepDown
   * @returns {void}
   */
  stepDown() {
    super.stepDown();
    const {
      max: e,
      precision: t,
      value: r
    } = this[Ae];
    let n = this.parseValue(r, t) - this.step;
    e !== null && (n = Math.min(n, e));
    const {
      min: i
    } = this[Ae];
    (i === null || n >= i) && (this.value = this.formatValue(n, t));
  }
  /**
   * @function stepUp
   * @returns {void}
   */
  stepUp() {
    super.stepUp();
    const {
      min: e,
      precision: t,
      value: r
    } = this[Ae];
    let n = this.parseValue(r, t) + this.step;
    e !== null && (n = Math.max(n, e));
    const {
      max: i
    } = this[Ae];
    (i === null || n <= i) && (this.value = this.formatValue(n, t));
  }
}
class oN extends XU(rN) {
}
class nN extends oN {
}
customElements.define("elix-number-spin-box", nN);
const f5 = document.createElement("template");
f5.innerHTML = `
  <style>
  div {
    height: 24px;
    margin: 5px 1px;
    padding: 3px;
  }
  div.imginside {
    width: var(--global-se-spin-input-width);
  }
  img {
    position: relative;
    right: -4px;
    top: 2px;
  }
  span {
    bottom: -0.5em;
    right: -4px;
    position: relative;
    margin-left: -4px;
    margin-right: 1px;
    color: #fff;
  }
  elix-number-spin-box {
    background-color: var(--input-color);
    border-radius: 3px;
    height: 20px;
    margin-top: 1px;
    vertical-align: top;
  }
  elix-number-spin-box::part(spin-button) {
    padding: 0px;
  }
  elix-number-spin-box::part(input) {
    width: 3em;
  }
  elix-number-spin-box{
    width: 54px;
    height: 24px;
  }
  </style>
  <div>
  <img alt="icon" width="24" height="24" aria-labelledby="label" />
  <span id="label">label</span>
  <elix-number-spin-box min="1" step="1"></elix-number-spin-box>
  </div>
`;
class iN extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(f5.content.cloneNode(!0)), this.$div = this._shadowRoot.querySelector("div"), this.$img = this._shadowRoot.querySelector("img"), this.$label = this._shadowRoot.getElementById("label"), this.$event = new CustomEvent("change"), this.$input = this._shadowRoot.querySelector("elix-number-spin-box"), this.imgPath = svgEditor.configObj.curConfig.imgPath;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["value", "label", "src", "size", "min", "max", "step", "title"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          {
            const n = this.getAttribute("shortcut");
            this.$div.setAttribute("title", `${no(r)} ${n ? `[${no(n)}]` : ""}`);
          }
          break;
        case "src":
          this.$img.setAttribute("src", this.imgPath + "/" + r), this.$label.remove(), this.$div.classList.add("imginside");
          break;
        case "size":
          this.$input.shadowRoot.getElementById("input").size = r, this.$input.shadowRoot.getElementById("input").style.width = "unset";
          break;
        case "step":
          this.$input.setAttribute("step", r);
          break;
        case "min":
          this.$input.setAttribute("min", r);
          break;
        case "max":
          this.$input.setAttribute("max", r);
          break;
        case "label":
          this.$label.textContent = no(r), this.$img.remove();
          break;
        case "value":
          this.$input.value = r;
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get label() {
    return this.getAttribute("label");
  }
  /**
   * @function set
   * @returns {void}
   */
  set label(e) {
    this.setAttribute("label", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get value() {
    return this.$input.value;
  }
  /**
   * @function set
   * @returns {void}
   */
  set value(e) {
    this.$input.value = e;
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get size() {
    return this.getAttribute("size");
  }
  /**
   * @function set
   * @returns {void}
   */
  set size(e) {
    this.setAttribute("size", e);
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    const e = this.$input.shadowRoot;
    Array.from(e.childNodes).forEach((r) => {
      r?.id === "input" && r.addEventListener("keyup", (n) => {
        n.preventDefault(), isNaN(n.target.value) || (this.value = n.target.value, this.dispatchEvent(this.$event));
      });
    }), this.$input.addEventListener("change", (r) => {
      r.preventDefault(), this.value = r.target.value, this.dispatchEvent(this.$event);
    }), svgEditor.$click(this.$input, (r) => {
      r.preventDefault(), this.value = r.target.value, this.dispatchEvent(this.$event);
    });
  }
}
customElements.define("se-spin-input", iN);
const aN = [
  // Todo: Make into configuration item?
  "none",
  "#000000",
  "#3f3f3f",
  "#7f7f7f",
  "#bfbfbf",
  "#ffffff",
  "#ff0000",
  "#ff7f00",
  "#ffff00",
  "#7fff00",
  "#00ff00",
  "#00ff7f",
  "#00ffff",
  "#007fff",
  "#0000ff",
  "#7f00ff",
  "#ff00ff",
  "#ff007f",
  "#7f0000",
  "#7f3f00",
  "#7f7f00",
  "#3f7f00",
  "#007f00",
  "#007f3f",
  "#007f7f",
  "#003f7f",
  "#00007f",
  "#3f007f",
  "#7f007f",
  "#7f003f",
  "#ffaaaa",
  "#ffd4aa",
  "#ffffaa",
  "#d4ffaa",
  "#aaffaa",
  "#aaffd4",
  "#aaffff",
  "#aad4ff",
  "#aaaaff",
  "#d4aaff",
  "#ffaaff",
  "#ffaad4"
], m5 = document.createElement("template");
m5.innerHTML = `
  <style>
  .square {
    height: 15px;
    width: 15px;
    float: left;
  }
  #palette_holder {
    overflow: hidden;
    padding: 4px;
    background: #f0f0f0;
    border-radius: 3px;
    z-index: 2;
  }
  
  #js-se-palette {
    float: left;
    min-width: 30px;
    height: 15px;
    overflow: hidden;
  }
  
  div.palette_item {
    height: 15px;
    width: 15px;
    float: left;
  }
  
  div.palette_item:first-child {
    background: white;
  }

  .palette_expand_btn {
    background: none;
    border: none;
    width: 14px;
    height: 14px;
    font-size: 12px;
    cursor: pointer;
    user-select:none;
  }

  #palette_popup {
    padding: 4px;
    margin-left: 24px;
    background: white;
    min-width: 180px;
    max-width: 360px;
    min-height: 14px;
    flex-wrap: wrap;
    border-radius: 4px;

    position: absolute;
    bottom: 36px;
    right: 30px;
  }
  
  </style>
  <div id="palette_holder" title="">
    <div id="js-se-palette">
    </div>
  </div>
  <button class="palette_expand_btn" title="Show whole palette">▼</button>
  <!-- hidden div -->
  <div id="palette_popup" style="display:none"/>
`;
class sN extends HTMLElement {
  /**
   * @function constructor
   */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(m5.content.cloneNode(!0)), this.$strip = this._shadowRoot.querySelector("#js-se-palette"), this.expand_btn = this._shadowRoot.querySelector(
      "button.palette_expand_btn"
    ), this.popUp = this._shadowRoot.getElementById("palette_popup"), svgEditor.$click(this.expand_btn, (e) => {
      e.stopPropagation();
      const { display: t } = this.popUp.style;
      t === "none" ? this.showPopUp() : this.hidePopUp();
    }), svgEditor.svgCanvas.container.addEventListener(
      "click",
      () => this.hidePopUp()
    ), aN.forEach((e) => {
      const t = document.createElement("div");
      if (t.classList.add("square"), e === "none") {
        const i = document.createElement("img");
        i.src = "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgY2xhc3M9InN2Z19pY29uIj48c3ZnIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgICA8bGluZSBmaWxsPSJub25lIiBzdHJva2U9IiNkNDAwMDAiIGlkPSJzdmdfOTAiIHkyPSIyNCIgeDI9IjI0IiB5MT0iMCIgeDE9IjAiLz4KICAgIDxsaW5lIGlkPSJzdmdfOTIiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2Q0MDAwMCIgeTI9IjI0IiB4Mj0iMCIgeTE9IjAiIHgxPSIyNCIvPgogIDwvc3ZnPjwvc3ZnPg==", i.style.width = "15px", i.style.height = "15px", i.alt = "No color", t.append(i);
      } else
        t.style.backgroundColor = e;
      t.dataset.rgb = e;
      const r = (i) => {
        i.preventDefault();
        const a = i.shiftKey || i.button === 2 ? "stroke" : "fill";
        let s = t.dataset.rgb;
        (s === "none" || s === "transparent" || s === "initial") && (s = "none");
        const l = new CustomEvent("change", {
          detail: { picker: a, color: s },
          bubbles: !1
        });
        this.dispatchEvent(l);
      };
      svgEditor.$click(t, r), this.$strip.append(t);
      const n = t.cloneNode(!0);
      svgEditor.$click(n, r), this.popUp.append(n);
    });
  }
  /**
   * @function init
   * @param {any} name
   * @returns {void}
   */
  init(e) {
    this.setAttribute("ui-palette_info", e.t("ui.palette_info"));
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["ui-palette_info"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    let n;
    e === "ui-palette_info" && (n = this._shadowRoot.querySelector("#palette_holder"), n.setAttribute("title", r));
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
  }
  /**
   * Shows popUp window with the whole palette
   */
  showPopUp() {
    this.popUp.style.display = "flex", this.expand_btn.textContent = "▲", this.expand_btn.setAttribute("title", "Hide palette window");
  }
  hidePopUp() {
    this.popUp.style.display = "none", this.expand_btn.textContent = "▼", this.expand_btn.setAttribute("title", "Show palette window");
  }
}
customElements.define("se-palette", sN);
function lN(o) {
  return class extends o {
    constructor() {
      super();
      const t = this;
      !this[Ao] && t.attachInternals && (this[Ao] = t.attachInternals());
    }
    attributeChangedCallback(t, r, n) {
      if (t === "current") {
        const i = jA(t, n);
        this.current !== i && (this.current = i);
      } else
        super.attributeChangedCallback(t, r, n);
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        current: !1
      });
    }
    [lt](t) {
      if (super[lt](t), t.current) {
        const { current: r } = this[Ae];
        LA(this, "current", r);
      }
    }
    [Rt](t) {
      if (super[Rt] && super[Rt](t), t.current) {
        const { current: r } = this[Ae], n = new CustomEvent("currentchange", {
          bubbles: !0,
          detail: { current: r }
        });
        this.dispatchEvent(n);
      }
    }
    /**
     * True if the element is currently current.
     *
     * @type {boolean}
     * @default false
     */
    get current() {
      return this[Ae].current;
    }
    set current(t) {
      this[At]({ current: t });
    }
  };
}
function cN(o) {
  return class extends o {
    constructor() {
      super();
      const t = this;
      !this[Ao] && t.attachInternals && (this[Ao] = t.attachInternals());
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        selected: !1
      });
    }
    [lt](t) {
      if (super[lt](t), t.selected) {
        const { selected: r } = this[Ae];
        LA(this, "selected", r);
      }
    }
    [Rt](t) {
      if (super[Rt] && super[Rt](t), t.selected) {
        const { selected: r } = this[Ae], n = new CustomEvent("selectedchange", {
          bubbles: !0,
          detail: { selected: r }
        });
        this.dispatchEvent(n);
      }
    }
    /**
     * True if the element is currently selected.
     *
     * @type {boolean}
     * @default false
     */
    get selected() {
      return this[Ae].selected;
    }
    set selected(t) {
      this[At]({ selected: t });
    }
  };
}
class uN extends lN(
  Gh(cN(es))
) {
}
class AN extends uN {
  get [Ut]() {
    return Ja.html`
      <style>
        :host {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
          font-size: 10pt;
          white-space: nowrap;
        }

        :host([disabled]) {
          opacity: 0.5;
        }

        #checkmark {
          height: 1em;
          visibility: hidden;
          width: 1em;
        }

        :host([selected]) #checkmark {
          visibility: visible;
        }
      </style>
      <svg id="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="4 6 18 12">
        <path d="M0 0h24v24H0V0z" fill="none"/>
        <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"/>
      </svg>
      <slot></slot>
    `;
  }
}
class dN extends AN {
}
customElements.define("elix-menu-item", dN);
const pN = {
  a: "link",
  article: "region",
  button: "button",
  h1: "sectionhead",
  h2: "sectionhead",
  h3: "sectionhead",
  h4: "sectionhead",
  h5: "sectionhead",
  h6: "sectionhead",
  hr: "sectionhead",
  iframe: "region",
  link: "link",
  menu: "menu",
  ol: "list",
  option: "option",
  output: "liveregion",
  progress: "progressbar",
  select: "select",
  table: "table",
  td: "td",
  textarea: "textbox",
  th: "th",
  ul: "list"
};
function hN(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      const r = super[$e];
      return Object.assign(r, {
        itemRole: r.itemRole || "menuitem",
        role: r.role || "menu"
      });
    }
    get itemRole() {
      return this[Ae].itemRole;
    }
    set itemRole(r) {
      this[At]({ itemRole: r });
    }
    [lt](r) {
      super[lt] && super[lt](r);
      const n = this[Ae].items;
      if ((r.items || r.itemRole) && n) {
        const { itemRole: i } = this[Ae];
        n.forEach((a) => {
          i === pN[a.localName] ? a.removeAttribute("role") : a.setAttribute("role", i);
        });
      }
      if (r.role) {
        const { role: i } = this[Ae];
        this.setAttribute("role", i);
      }
    }
    // Setting the standard role attribute will invoke this property setter,
    // which will allow us to update our state.
    get role() {
      return super.role;
    }
    set role(r) {
      super.role = r, this[Yc] || this[At]({ role: r });
    }
  }
  return e;
}
function gN(o) {
  class e extends o {
    attributeChangedCallback(r, n, i) {
      if (r === "current-index")
        this.currentIndex = Number(i);
      else if (r === "current-item-required") {
        const a = jA(r, i);
        this.currentItemRequired !== a && (this.currentItemRequired = a);
      } else if (r === "cursor-operations-wrap") {
        const a = jA(r, i);
        this.cursorOperationsWrap !== a && (this.cursorOperationsWrap = a);
      } else
        super.attributeChangedCallback(r, n, i);
    }
    /**
     * The index of the current item, or -1 if no item is current.
     *
     * @type {number}
     */
    get currentIndex() {
      const { items: r, currentIndex: n } = this[Ae];
      return r && r.length > 0 ? n : -1;
    }
    set currentIndex(r) {
      isNaN(r) || this[At]({ currentIndex: r });
    }
    /**
     * The current item, or null if no item is current.
     *
     * @type {Element}
     */
    get currentItem() {
      const { items: r, currentIndex: n } = this[Ae];
      return r && r[n];
    }
    set currentItem(r) {
      const { items: n } = this[Ae];
      if (!n)
        return;
      const i = n.indexOf(r);
      this[At]({ currentIndex: i });
    }
    /**
     * True if the list should always have a current item (if it has items).
     *
     * @type {boolean}
     * @default false
     */
    get currentItemRequired() {
      return this[Ae].currentItemRequired;
    }
    set currentItemRequired(r) {
      this[At]({ currentItemRequired: r });
    }
    /**
     * True if cursor operations wrap from last to first, and vice versa.
     *
     * @type {boolean}
     * @default false
     */
    get cursorOperationsWrap() {
      return this[Ae].cursorOperationsWrap;
    }
    set cursorOperationsWrap(r) {
      this[At]({ cursorOperationsWrap: r });
    }
    /**
     * Moves to the first item in the list.
     *
     * @returns {Boolean} True if the current item changed, false if not.
     */
    goFirst() {
      return super.goFirst && super.goFirst(), this[Ic]();
    }
    /**
     * Move to the last item in the list.
     *
     * @returns {Boolean} True if the current item changed
     */
    goLast() {
      return super.goLast && super.goLast(), this[Mc]();
    }
    /**
     * Move to the next item in the list.
     *
     * If the list has no current item, the first item will become current.
     *
     * @returns {Boolean} True if the current item changed
     */
    goNext() {
      return super.goNext && super.goNext(), this[Ms]();
    }
    /**
     * Moves to the previous item in the list.
     *
     * If the list has no current item, the last item will become current.
     *
     * @returns {Boolean} True if the current item changed
     */
    goPrevious() {
      return super.goPrevious && super.goPrevious(), this[Rs]();
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), r.currentIndex && this[ut]) {
        const { currentIndex: n } = this[Ae], i = new CustomEvent("currentindexchange", {
          bubbles: !0,
          detail: { currentIndex: n }
        });
        this.dispatchEvent(i);
      }
    }
  }
  return e;
}
function y5(o) {
  const e = o[Cn], t = e && e.querySelector("slot:not([name])");
  return t && t.parentNode instanceof Element && fN(t.parentNode) || o;
}
function _N(o) {
  const e = getComputedStyle(o), t = e.overflowX, r = e.overflowY;
  return t === "scroll" || t === "auto" || r === "scroll" || r === "auto";
}
function fN(o) {
  for (const e of n5(o))
    if (e instanceof HTMLElement && _N(e))
      return e;
  return null;
}
function mN(o) {
  class e extends o {
    [Rt](r) {
      super[Rt] && super[Rt](r), r.currentItem && this.scrollCurrentItemIntoView();
    }
    /**
     * Scroll the current item completely into view, minimizing the degree of
     * scrolling performed.
     *
     * Blink has a `scrollIntoViewIfNeeded()` function that does something
     * similar, but unfortunately it's non-standard, and in any event often ends
     * up scrolling more than is absolutely necessary.
     *
     * This scrolls the containing element defined by the `scrollTarget`
     * property. By default, it will scroll the element itself.
     */
    scrollCurrentItemIntoView() {
      super.scrollCurrentItemIntoView && super.scrollCurrentItemIntoView();
      const { currentItem: r, items: n } = this[Ae];
      if (!r || !n)
        return;
      const i = this[ii].getBoundingClientRect(), a = r.getBoundingClientRect(), s = a.bottom - i.bottom, l = a.left - i.left, c = a.right - i.right, u = a.top - i.top, A = this[Ae].orientation || "both";
      (A === "horizontal" || A === "both") && (c > 0 ? this[ii].scrollLeft += c : l < 0 && (this[ii].scrollLeft += Math.ceil(l))), (A === "vertical" || A === "both") && (s > 0 ? this[ii].scrollTop += s : u < 0 && (this[ii].scrollTop += Math.ceil(u)));
    }
    /**
     * The element that should be scrolled to get the selected item into view.
     *
     * By default, this uses the [defaultScrollTarget](defaultScrollTarget)
     * helper to find the most likely candidate for scrolling. You can override
     * this property to directly identify which element should be scrolled.
     *
     * See also [scrollTarget](internal#internal.scrollTarget).
     */
    get [ii]() {
      return super[ii] || y5(this);
    }
  }
  return e;
}
function yN(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        canGoDown: null,
        canGoLeft: null,
        canGoRight: null,
        canGoUp: null
      });
    }
    /**
     * Interprets `goDown` to mean "move to the next item".
     */
    [Ri]() {
      return super[Ri] && super[Ri](), this[Ms]();
    }
    /**
     * Interprets `goEnd` to mean "move to the last item".
     */
    [Qa]() {
      return super[Qa] && super[Qa](), this[Mc]();
    }
    /**
     * Interprets `goLeft` to mean "move to the previous item".
     *
     * If the element has a `rightToLeft` property and it is true, then this
     * moves to the _next_ item.
     */
    [Ts]() {
      return super[Ts] && super[Ts](), this[Ae] && this[Ae].rightToLeft ? this[Ms]() : this[Rs]();
    }
    /**
     * Interprets `goRight` to mean "move to the next item".
     *
     * If the element has a `rightToLeft` property and it is true, then this
     * moves to the _previous_ item.
     */
    [Ps]() {
      return super[Ps] && super[Ps](), this[Ae] && this[Ae].rightToLeft ? this[Rs]() : this[Ms]();
    }
    /**
     * Interprets `goStart` to mean "move to the first item".
     */
    [qa]() {
      return super[qa] && super[qa](), this[Ic]();
    }
    /**
     * Interprets `goUp` to mean "move to the previous item".
     */
    [Oi]() {
      return super[Oi] && super[Oi](), this[Rs]();
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      if (n.canGoNext || n.canGoPrevious || n.languageDirection || n.orientation || n.rightToLeft) {
        const { canGoNext: a, canGoPrevious: s, orientation: l, rightToLeft: c } = r, u = l === "horizontal" || l === "both", A = l === "vertical" || l === "both";
        Object.assign(i, {
          canGoDown: A && a,
          canGoLeft: u ? c ? a : s : !1,
          canGoRight: u ? c ? s : a : !1,
          canGoUp: A && s
        });
      }
      return i;
    }
  }
  return e;
}
function bN(o) {
  class e extends o {
    /**
     * The current set of items drawn from the element's current state.
     *
     * @type {ListItemElement[]} the element's current items
     */
    get items() {
      return this[Ae] ? this[Ae].items : null;
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), !this[jo] && r.items && this[ut]) {
        const n = new CustomEvent("itemschange", {
          bubbles: !0
        });
        this.dispatchEvent(n);
      }
    }
  }
  return e;
}
function vN(o) {
  class e extends o {
    /**
     * Look for an item which is available in the given state..
     *
     * The `options` parameter can accept options for:
     *
     * * `direction`: 1 to move forward, -1 to move backward
     * * `index`: the index to start at, defaults to `state.currentIndex`
     * * `wrap`: whether to wrap around the ends of the `items` array, defaults
     *   to `state.cursorOperationsWrap`.
     *
     * If an available item was found, this returns its index. If no item was
     * found, this returns -1.
     *
     * @param {PlainObject} state
     * @param {PlainObject} options
     * @returns {number}
     */
    [Tl](r, n = {}) {
      const i = n.direction !== void 0 ? n.direction : 1, a = n.index !== void 0 ? n.index : r.currentIndex, s = n.wrap !== void 0 ? n.wrap : r.cursorOperationsWrap, { items: l } = r, c = l ? l.length : 0;
      if (c === 0)
        return -1;
      if (s) {
        let u = (a % c + c) % c;
        const A = ((u - i) % c + c) % c;
        for (; u !== A; ) {
          if (r.availableItemFlags ? r.availableItemFlags[u] : !0)
            return u;
          u = ((u + i) % c + c) % c;
        }
      } else
        for (let u = a; u >= 0 && u < c; u += i)
          if (r.availableItemFlags ? r.availableItemFlags[u] : !0)
            return u;
      return -1;
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        currentIndex: -1,
        desiredCurrentIndex: null,
        currentItem: null,
        currentItemRequired: !1,
        cursorOperationsWrap: !1
      });
    }
    /**
     * Move to the first item in the set.
     *
     * @protected
     * @returns {Boolean} True if the current item changed, false if not.
     */
    [Ic]() {
      return super[Ic] && super[Ic](), Zd(this, 0, 1);
    }
    /**
     * Move to the last item in the set.
     *
     * @protected
     * @returns {Boolean} True if the current item changed, false if not.
     */
    [Mc]() {
      return super[Mc] && super[Mc](), Zd(this, this[Ae].items.length - 1, -1);
    }
    /**
     * Move to the next item in the set.
     *
     * If no item is current, move to the first item.
     *
     * @protected
     * @returns {Boolean} True if the current item changed, false if not.
     */
    [Ms]() {
      super[Ms] && super[Ms]();
      const { currentIndex: r, items: n } = this[Ae], i = r < 0 && n ? 0 : r + 1;
      return Zd(this, i, 1);
    }
    /**
     * Move to the previous item in the set.
     *
     * If no item is current, move to the last item.
     *
     * @protected
     * @returns {Boolean} True if the current item changed, false if not.
     */
    [Rs]() {
      super[Rs] && super[Rs]();
      const { currentIndex: r, items: n } = this[Ae], i = r < 0 && n ? n.length - 1 : r - 1;
      return Zd(this, i, -1);
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      if (n.availableItemFlags || n.items || n.currentIndex || n.currentItemRequired) {
        const {
          currentIndex: a,
          desiredCurrentIndex: s,
          currentItem: l,
          currentItemRequired: c,
          items: u
        } = r, A = u ? u.length : 0;
        let p = s;
        if (n.items && !n.currentIndex && l && A > 0 && u[a] !== l) {
          const _ = u.indexOf(l);
          _ >= 0 && (p = _);
        } else n.currentIndex && (a < 0 && l !== null || a >= 0 && (A === 0 || u[a] !== l) || s === null) && (p = a);
        c && p < 0 && (p = 0);
        let d;
        p < 0 ? (p = -1, d = -1) : A === 0 ? d = -1 : (d = Math.max(Math.min(A - 1, p), 0), d = this[Tl](r, {
          direction: 1,
          index: d,
          wrap: !1
        }), d < 0 && (d = this[Tl](r, {
          direction: -1,
          index: d - 1,
          wrap: !1
        })));
        const g = u && u[d] || null;
        Object.assign(i, {
          currentIndex: d,
          desiredCurrentIndex: p,
          currentItem: g
        });
      }
      return i;
    }
  }
  return e;
}
function Zd(o, e, t) {
  const r = o[Tl](o[Ae], {
    direction: t,
    index: e
  });
  if (r < 0)
    return !1;
  const n = o[Ae].currentIndex !== r;
  return n && o[At]({
    currentIndex: r
  }), n;
}
const wN = [
  "applet",
  // deprecated
  "basefont",
  // deprecated
  "embed",
  "font",
  // deprecated
  "frame",
  // deprecated
  "frameset",
  // deprecated
  "isindex",
  // deprecated
  "keygen",
  // deprecated
  "link",
  "multicol",
  // deprecated
  "nextid",
  // deprecated
  "noscript",
  "object",
  "param",
  "script",
  "style",
  "template",
  "noembed"
  // deprecated
];
function xN(o) {
  return o.getAttribute("aria-label") || o.getAttribute("alt") || /** @type {any} */
  o.innerText || o.textContent || "";
}
function kN(o) {
  return o instanceof Element && (!o.localName || wN.indexOf(o.localName) < 0);
}
function CN(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        texts: null
      });
    }
    /**
     * Extract the text from the given item.
     *
     * The default implementation returns an item's `aria-label`, `alt`
     * attribute, `innerText`, or `textContent`, in that order. You can override
     * this to return the text that should be used.
     *
     * @param {Element} item
     * @returns {string}
     */
    [Xu](r) {
      return super[Xu] ? super[Xu](r) : xN(r);
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      if (n.items) {
        const { items: a } = r, s = SN(a, this[Xu]);
        s && (Object.freeze(s), Object.assign(i, { texts: s }));
      }
      return i;
    }
  }
  return e;
}
function SN(o, e) {
  return o ? Array.from(o, (t) => e(t)) : null;
}
function BN(o) {
  class e extends o {
    [xr](r) {
      let n = !1;
      if (this.orientation !== "horizontal")
        switch (r.key) {
          case "PageDown":
            n = this.pageDown();
            break;
          case "PageUp":
            n = this.pageUp();
            break;
        }
      return n || super[xr] && super[xr](r);
    }
    // Default orientation implementation defers to super,
    // but if not found, looks in state.
    get orientation() {
      return super.orientation || this[Ae] && this[Ae].orientation || "both";
    }
    /**
     * Scroll down one page.
     */
    pageDown() {
      return super.pageDown && super.pageDown(), L0(this, !0);
    }
    /**
     * Scroll up one page.
     */
    pageUp() {
      return super.pageUp && super.pageUp(), L0(this, !1);
    }
    /**
     * The element that will be scrolled when the user presses Page Up or
     * Page Down. The default value is calculated by
     * [defaultScrollTarget](defaultScrollTarget#defaultScrollTarget).
     *
     * See [scrollTarget](internal#internal.scrollTarget).
     *
     * @type {HTMLElement}
     */
    get [ii]() {
      const r = this;
      return super[ii] || y5(r);
    }
  }
  return e;
}
function j0(o, e, t) {
  const r = o[Ae].items, n = t ? 0 : r.length - 1, i = t ? r.length : 0, a = t ? 1 : -1;
  let s, l = null, c;
  const { availableItemFlags: u } = o[Ae];
  for (s = n; s !== i; s += a)
    if ((u ? u[s] : !0) && (c = r[s].getBoundingClientRect(), c.top <= e && e <= c.bottom)) {
      l = r[s];
      break;
    }
  if (!l || !c)
    return null;
  const A = getComputedStyle(l), p = A.paddingTop ? parseFloat(A.paddingTop) : 0, d = A.paddingBottom ? parseFloat(A.paddingBottom) : 0, g = c.top + p, _ = g + l.clientHeight - p - d;
  return t && g <= e || !t && _ >= e ? s : s - a;
}
function L0(o, e) {
  const t = o[Ae].items, r = o[Ae].currentIndex, n = o[ii].getBoundingClientRect(), i = e ? n.bottom : n.top, a = j0(o, i, e);
  let s;
  if (a && r === a) {
    const u = t[r].getBoundingClientRect(), A = o[ii].clientHeight, p = e ? u.bottom + A : u.top - A;
    s = j0(o, p, e);
  } else
    s = a;
  if (!s) {
    const c = e ? t.length - 1 : 0;
    s = o[Tl] ? o[Tl](o[Ae], {
      direction: e ? -1 : 1,
      index: c
    }) : c;
  }
  const l = s !== r;
  if (l) {
    const c = o[ut];
    o[ut] = !0, o[At]({
      currentIndex: s
    }), o[ut] = c;
  }
  return l;
}
const EN = 1e3, Ga = /* @__PURE__ */ Symbol("typedPrefix"), Wp = /* @__PURE__ */ Symbol("prefixTimeout");
function jN(o) {
  class e extends o {
    constructor() {
      super(), nb(this);
    }
    /**
     * Go to the first item whose text content begins with the given prefix.
     *
     * @param {string} prefix - The prefix string to search for
     * @returns {boolean}
     */
    [Rc](r) {
      if (super[Rc] && super[Rc](r), r == null || r.length === 0)
        return !1;
      const n = r.toLowerCase(), a = this[Ae].texts.findIndex(
        (s) => s.substr(0, r.length).toLowerCase() === n
      );
      if (a >= 0) {
        const s = this[Ae].currentIndex;
        return this[At]({ currentIndex: a }), this[Ae].currentIndex !== s;
      } else
        return !1;
    }
    [xr](r) {
      let n;
      switch (r.key) {
        case "Backspace":
          LN(this), n = !0;
          break;
        case "Escape":
          nb(this);
          break;
        default:
          !r.ctrlKey && !r.metaKey && !r.altKey && r.key.length === 1 && TN(this, r.key);
      }
      return n || super[xr] && super[xr](r);
    }
  }
  return e;
}
function LN(o) {
  const e = o, t = e[Ga] ? e[Ga].length : 0;
  t > 0 && (e[Ga] = e[Ga].substr(0, t - 1)), o[Rc](e[Ga]), v5(o);
}
function TN(o, e) {
  const t = o, r = t[Ga] || "";
  t[Ga] = r + e, o[Rc](t[Ga]), v5(o);
}
function b5(o) {
  const e = o;
  e[Wp] && (clearTimeout(e[Wp]), e[Wp] = !1);
}
function nb(o) {
  o[Ga] = "", b5(o);
}
function v5(o) {
  b5(o), o[Wp] = setTimeout(() => {
    nb(o);
  }, EN);
}
function w5(o) {
  return class extends o {
    // The only way to get text direction is to wait for the component to
    // connect and then inspect the computed style on its root element. We set
    // state before calling super so the new state will be included when
    // ReactiveMixin calls render.
    connectedCallback() {
      const n = getComputedStyle(this).direction === "rtl";
      this[At]({ rightToLeft: n }), super.connectedCallback();
    }
  };
}
function PN(o) {
  return class extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        items: null
      });
    }
    [sr](t, r) {
      const n = super[sr] ? super[sr](t, r) : {};
      if (r.content) {
        const i = t.content, a = i ? Array.prototype.filter.call(
          i,
          (s) => kN(s)
        ) : null;
        a && Object.freeze(a), Object.assign(n, { items: a });
      }
      return n;
    }
  };
}
function x5(o) {
  class e extends o {
    /**
     * See [contentSlot](internal#internal.contentSlot).
     */
    get [eb]() {
      const r = this[Cn] && this[Cn].querySelector("slot:not([name])");
      return (!this[Cn] || !r) && console.warn(
        `SlotContentMixin expects ${this.constructor.name} to define a shadow tree that includes a default (unnamed) slot.
See https://elix.org/documentation/SlotContentMixin.`
      ), r;
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        content: null
      });
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), this[jo]) {
        const n = this[eb];
        n && n.addEventListener("slotchange", async () => {
          this[ut] = !0;
          const i = n.assignedNodes({ flatten: !0 });
          Object.freeze(i), this[At]({ content: i }), await Promise.resolve(), this[ut] = !1;
        });
      }
    }
  }
  return e;
}
function FN(o) {
  return PN(x5(o));
}
function UN(o) {
  return class extends o {
    constructor() {
      super(), this.addEventListener("mousedown", (t) => {
        t.button === 0 && (this[ut] = !0, this[zc](t), this[ut] = !1);
      });
    }
    [lt](t) {
      super[lt] && super[lt](t), this[jo] && Object.assign(this.style, {
        touchAction: "manipulation",
        // for iOS Safari
        mozUserSelect: "none",
        msUserSelect: "none",
        webkitUserSelect: "none",
        userSelect: "none"
      });
    }
    [zc](t) {
      const r = t.composedPath ? t.composedPath()[0] : t.target, { items: n, currentItemRequired: i } = this[Ae];
      if (n && r instanceof Node) {
        const a = r5(n, r), s = a >= 0 ? n[a] : null;
        (s && !s.disabled || !s && !i) && (this[At]({
          currentIndex: a
        }), t.stopPropagation());
      }
    }
  };
}
const NN = hN(
  gN(
    mN(
      Qh(
        yN(
          bN(
            vN(
              CN(
                _5(
                  GA(
                    BN(
                      jN(
                        w5(
                          FN(UN(es))
                        )
                      )
                    )
                  )
                )
              )
            )
          )
        )
      )
    )
  )
);
class k5 extends NN {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      availableItemFlags: null,
      handleBubblingDirectionKeys: !0,
      highlightCurrentItem: !0,
      orientation: "vertical",
      currentItemFocused: !1
    });
  }
  /**
   * Flash the current item.
   *
   * By default, this uses a heuristic to guess whether the menu was closed by a
   * keyboard or mouse (on desktop). If so, the menu flashes the current item
   * off then back on, emulating the menu item selection effect in macOS.
   * Otherwise, it does nothing.
   */
  async flashCurrentItem() {
    const e = this[Ae].focusVisible, t = matchMedia("(pointer: fine)").matches;
    (e || t) && (this[At]({ highlightCurrentItem: !1 }), await new Promise((n) => setTimeout(n, 75)), this[At]({ highlightCurrentItem: !0 }), await new Promise((n) => setTimeout(n, 75)));
  }
  [lt](e) {
    super[lt](e), this[jo] && (this.addEventListener("disabledchange", (n) => {
      this[ut] = !0;
      const i = n.target, { items: a } = this[Ae], s = a === null ? -1 : a.indexOf(i);
      if (s >= 0) {
        const l = this[Ae].availableItemFlags.slice();
        l[s] = !i.disabled, this[At]({ availableItemFlags: l });
      }
      this[ut] = !1;
    }), "PointerEvent" in window ? this.addEventListener("pointerdown", (n) => this[zc](n)) : this.addEventListener("touchstart", (n) => this[zc](n)), this.removeAttribute("tabindex"));
    const { currentIndex: t, items: r } = this[Ae];
    if ((e.items || e.currentIndex || e.highlightCurrentItem) && r) {
      const { highlightCurrentItem: n } = this[Ae];
      r.forEach((i, a) => {
        i.toggleAttribute(
          "current",
          n && a === t
        );
      });
    }
    (e.items || e.currentIndex || e.currentItemFocused || e.focusVisible) && r && r.forEach((n, i) => {
      const a = i === t, s = t < 0 && i === 0;
      this[Ae].currentItemFocused ? a || s || n.removeAttribute("tabindex") : (a || s) && (n.tabIndex = 0);
    });
  }
  [Rt](e) {
    if (super[Rt](e), !this[jo] && e.currentIndex && !this[Ae].currentItemFocused) {
      const { currentItem: t } = this[Ae];
      (t instanceof HTMLElement ? t : this).focus(), this[At]({
        currentItemFocused: !0
      });
    }
  }
  // @ts-ignore
  get [ii]() {
    return this[bt].content;
  }
  [sr](e, t) {
    const r = super[sr](e, t);
    if (t.currentIndex && Object.assign(r, {
      currentItemFocused: !1
    }), t.items) {
      const { items: n } = e, i = n === null ? null : n.map((a) => !a.disabled);
      Object.assign(r, { availableItemFlags: i });
    }
    return r;
  }
  get [Ut]() {
    return Ja.html`
      <style>
        :host {
          box-sizing: border-box;
          cursor: default;
          display: inline-flex;
          -webkit-tap-highlight-color: transparent;
          touch-action: manipulation;
        }

        #content {
          display: flex;
          flex: 1;
          flex-direction: column;
          max-height: 100%;
          overflow-x: hidden;
          overflow-y: auto;
          -webkit-overflow-scrolling: touch; /* for momentum scrolling */
        }
        
        ::slotted(*) {
          flex-shrink: 0;
          outline: none;
          touch-action: manipulation;
        }

        ::slotted(option) {
          font: inherit;
          min-height: inherit;
        }
      </style>
      <div id="content" role="none">
        <slot></slot>
      </div>
    `;
  }
}
const cc = /* @__PURE__ */ Symbol("documentMouseupListener");
function IN(o) {
  class e extends o {
    connectedCallback() {
      super.connectedCallback(), c_(this);
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        dragSelect: !0
      });
    }
    disconnectedCallback() {
      super.disconnectedCallback && super.disconnectedCallback(), c_(this);
    }
    [Rt](r) {
      super[Rt](r), r.opened && c_(this);
    }
    [sr](r, n) {
      const i = super[sr](r, n);
      return n.opened && r.opened && Object.assign(i, {
        // Until we get a mouseup, we're doing a drag-select.
        dragSelect: !0
      }), i;
    }
  }
  return e;
}
async function MN(o) {
  const e = this, t = e[Cn].elementsFromPoint(
    o.clientX,
    o.clientY
  );
  if (e.opened) {
    const r = t.indexOf(e[bt].source) >= 0, n = e[bt].popup, i = t.indexOf(n) >= 0, a = n.frame && t.indexOf(n.frame) >= 0;
    r ? e[Ae].dragSelect && (e[ut] = !0, e[At]({
      dragSelect: !1
    }), e[ut] = !1) : i || a || (e[ut] = !0, await e.close(), e[ut] = !1);
  }
}
function c_(o) {
  o[Ae].opened && o.isConnected ? o[cc] || (o[cc] = MN.bind(o), document.addEventListener("mouseup", o[cc])) : o[cc] && (document.removeEventListener(
    "mouseup",
    o[cc]
  ), o[cc] = null);
}
function T0(o, e, t, r) {
  const n = C5(o, t, r);
  let i = 0, a = 0;
  const s = t === "above" || t === "below";
  switch (t) {
    case "above":
      i = n.y - e.top;
      break;
    case "below":
      i = e.bottom - n.y;
      break;
    case "left":
      a = n.x - e.left;
      break;
    case "right":
      a = e.right - n.x;
      break;
  }
  switch (r) {
    case "bottom":
      i = n.y - e.top;
      break;
    case "center":
      s ? a = e.width : i = e.height;
      break;
    case "stretch":
      s ? a = o.width : i = o.height;
      break;
    case "left":
      a = e.right - n.x;
      break;
    case "right":
      a = n.x - e.left;
      break;
    case "top":
      i = e.bottom - n.y;
      break;
  }
  return i = Math.max(0, i), a = Math.max(0, a), { height: i, width: a };
}
function RN(o, e, t, r, n) {
  const i = T0(
    t,
    n,
    o.direction,
    o.align
  ), a = T0(
    t,
    n,
    e.direction,
    e.align
  ), s = r.width <= i.width, l = r.height <= i.height, c = s || l, u = s && l, A = r.width <= a.width, p = r.height <= a.height, d = A || p, g = A && p, _ = i.width * i.height, f = a.width * a.height;
  return u && g ? 0 : u ? -1 : g ? 1 : c && !d ? -1 : d && !c ? 1 : c && _ > f ? -1 : d && f > _ ? 1 : _ > f ? -1 : f > _ ? 1 : 0;
}
function ON(o, e, t, r, n) {
  const i = C5(o, r, n);
  let {
    x: a,
    y: s,
    bottom: l,
    right: c
  } = t, u = 0, A = 0, p = e.height, d = e.width;
  const g = r === "above" || r === "below";
  switch (r) {
    case "above":
      A = i.y - e.height, l = i.y;
      break;
    case "below":
      A = i.y, s = i.y;
      break;
    case "left":
      u = i.x - e.width, c = i.x;
      break;
    case "right":
      u = i.x, a = i.x;
      break;
  }
  switch (n) {
    case "bottom":
      A = i.y - e.height, l = i.y;
      break;
    case "left":
      u = i.x, a = i.x;
      break;
    case "center":
      g ? u = i.x - e.width / 2 : A = i.y - e.height / 2;
      break;
    case "right":
      u = i.x - e.width, c = i.x;
      break;
    case "stretch":
      g ? (u = i.x, d = o.width) : (A = i.y, p = o.height);
      break;
    case "top":
      A = i.y, s = i.y;
      break;
  }
  return u = Math.max(u, a), A = Math.max(A, s), d = Math.min(d, c - u), p = Math.min(p, l - A), new DOMRect(u, A, d, p);
}
function C5(o, e, t) {
  let r = 0, n = 0;
  const i = e === "above" || e === "below";
  switch (e) {
    case "above":
      n = o.top;
      break;
    case "below":
      n = o.bottom;
      break;
    case "left":
    case "right":
      r = o[e];
      break;
  }
  switch (t) {
    case "bottom":
    case "top":
      n = o[t];
      break;
    case "left":
    case "right":
      r = o[t];
      break;
    case "center":
      i ? r = o.left + o.width / 2 : n = o.top + o.height / 2;
      break;
    case "stretch":
      i ? r = o.left : n = o.top;
      break;
  }
  return { x: r, y: n };
}
function QN(o, e, t, r) {
  const n = qN(r), i = GN(n.direction, n.align);
  i.sort(
    (s, l) => RN(s, l, o, e, t)
  );
  const a = i[0];
  return a.rect = ON(
    o,
    e,
    t,
    a.direction,
    a.align
  ), a;
}
function qN(o) {
  const {
    align: e,
    direction: t,
    rightToLeft: r
  } = o, i = {
    above: "above",
    below: "below",
    column: "below",
    "column-reverse": "above",
    left: "left",
    right: "right",
    row: r ? "left" : "right",
    "row-reverse": r ? "right" : "left"
  }[t] || "below", a = {
    above: "horizontal",
    below: "horizontal",
    left: "vertical",
    right: "vertical"
  }[i], s = {
    horizontal: "left",
    vertical: "top"
  }[a];
  return {
    align: {
      horizontal: {
        center: "center",
        end: r ? "left" : "right",
        left: "left",
        right: "right",
        start: r ? "right" : "left",
        stretch: "stretch"
      },
      vertical: {
        bottom: "bottom",
        center: "center",
        end: "bottom",
        start: "top",
        stretch: "stretch",
        top: "top"
      }
    }[a][e] || s,
    direction: i,
    rightToLeft: r
  };
}
function GN(o, e) {
  const t = {
    above: "below",
    below: "above",
    left: "right",
    right: "left"
  }, r = {
    top: "bottom",
    bottom: "top",
    left: "right",
    right: "left"
  }, n = [
    { align: e, direction: o }
  ];
  return e === "center" || e === "stretch" ? n.push({
    align: e,
    direction: t[o]
  }) : (n.push({
    align: r[e],
    direction: o
  }), n.push({
    align: e,
    direction: t[o]
  }), n.push({
    align: r[e],
    direction: t[o]
  })), n;
}
const Jd = /* @__PURE__ */ Symbol("closePromise"), u_ = /* @__PURE__ */ Symbol("closeResolve");
function S5(o) {
  class e extends o {
    attributeChangedCallback(r, n, i) {
      if (r === "opened") {
        const a = jA(r, i);
        this.opened !== a && (this.opened = a);
      } else
        super.attributeChangedCallback(r, n, i);
    }
    /**
     * Close the component (if not already closed).
     *
     * Some components like [AlertDialog](AlertDialog) want to indicate why or
     * how they were closed. To support such scenarios, you can supply a value
     * to the optional `closeResult` parameter. This closeResult will be made
     * available in the `whenClosed` promise and the `state.closeResult` member.
     *
     * @param {object} [closeResult] - an indication of how or why the element closed
     */
    async close(r) {
      super.close && await super.close(), this[At]({ closeResult: r }), await this.toggle(!1);
    }
    /**
     * True if the element is currently closed.
     *
     * This read-only property is provided as a convenient inverse of `opened`.
     *
     * @type {boolean}
     */
    get closed() {
      return this[Ae] && !this[Ae].opened;
    }
    /**
     * True if the element has completely closed.
     *
     * For components not using asynchronous open/close effects, this property
     * returns the same value as the `closed` property. For elements that have a
     * true value of `state.openCloseEffects` (e.g., elements using
     * [TransitionEffectMixin](TransitionEffectMixin)), this property returns
     * true only if `state.effect` is "close" and `state.effectPhase` is
     * "after".
     *
     * @type {boolean}
     */
    get closeFinished() {
      return this[Ae].closeFinished;
    }
    get closeResult() {
      return this[Ae].closeResult;
    }
    // @ts-ignore
    get [$e]() {
      const r = {
        closeResult: void 0,
        opened: !1
      };
      return this[e5] && Object.assign(r, {
        closeFinished: !0,
        effect: "close",
        effectPhase: "after",
        openCloseEffects: !0
      }), Object.assign(super[$e] || {}, r);
    }
    /**
     * Open the element (if not already opened).
     */
    async open() {
      super.open && await super.open(), await this.toggle(!0);
    }
    /**
     * True if the element is currently opened.
     *
     * This property can be set as a boolean attribute
     *
     * @type {boolean}
     * @default false
     */
    get opened() {
      return this[Ae] && this[Ae].opened;
    }
    set opened(r) {
      this[At]({ closeResult: void 0 }), this.toggle(r);
    }
    [lt](r) {
      if (super[lt](r), r.opened) {
        const { opened: n } = this[Ae];
        LA(this, "opened", n);
      }
      if (r.closeFinished) {
        const { closeFinished: n } = this[Ae];
        LA(this, "closed", n);
      }
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), r.opened && this[ut]) {
        const i = new CustomEvent("openedchange", {
          bubbles: !0,
          detail: {
            closeResult: this[Ae].closeResult,
            opened: this[Ae].opened
          }
        });
        if (this.dispatchEvent(i), this[Ae].opened) {
          const a = new CustomEvent("opened", {
            bubbles: !0
          });
          this.dispatchEvent(a);
          const s = new CustomEvent("open", {
            bubbles: !0
          });
          this.dispatchEvent(s);
        } else {
          const a = new CustomEvent("closed", {
            bubbles: !0,
            detail: {
              closeResult: this[Ae].closeResult
            }
          });
          this.dispatchEvent(a);
          const s = new CustomEvent("close", {
            bubbles: !0,
            detail: {
              closeResult: this[Ae].closeResult
            }
          });
          this.dispatchEvent(s);
        }
      }
      const n = this[u_];
      this.closeFinished && n && (this[u_] = null, this[Jd] = null, n(this[Ae].closeResult));
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      if (n.opened && r.opened && Object.assign(i, {
        closeResult: void 0
      }), n.openCloseEffects || n.effect || n.effectPhase || n.opened) {
        const { effect: a, effectPhase: s, openCloseEffects: l, opened: c } = r;
        Object.assign(i, { closeFinished: l ? a === "close" && s === "after" : !c });
      }
      return i;
    }
    /**
     * Toggle the open/close state of the element.
     *
     * @param {boolean} [opened] - true if the element should be opened, false
     * if closed.
     */
    async toggle(r = !this.opened) {
      if (super.toggle && await super.toggle(r), r !== this[Ae].opened) {
        const i = { opened: r };
        this[Ae].openCloseEffects && (i.effect = r ? "open" : "close", this[Ae].effectPhase === "after" && (i.effectPhase = "before")), await this[At](i);
      }
    }
    /**
     * This method can be used as an alternative to listening to the
     * "openedchange" event, particularly in situations where you want to only
     * handle the next time the component is closed.
     *
     * @returns {Promise} A promise that resolves when the element has
     * completely closed, including the completion of any asynchronous opening
     * effect.
     */
    whenClosed() {
      return this[Jd] || (this[Jd] = new Promise((r) => {
        this[u_] = r;
      })), this[Jd];
    }
  }
  return e;
}
function VN(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        role: null
      });
    }
    [lt](r) {
      if (super[lt] && super[lt](r), r.role) {
        const { role: n } = this[Ae];
        n ? this.setAttribute("role", n) : this.removeAttribute("role");
      }
    }
    // Setting the standard role attribute will invoke this property setter,
    // which will allow us to update our state.
    get role() {
      return super.role;
    }
    set role(r) {
      const n = String(r);
      super.role = n, this[Yc] || this[At]({ s: n });
    }
  }
  return e;
}
const DN = VN(es);
class hv extends DN {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      role: "none"
    });
  }
  get [Ut]() {
    return Ja.html`
      <style>
        :host {
          display: inline-block;
          height: 100%;
          left: 0;
          position: fixed;
          top: 0;
          touch-action: manipulation;
          width: 100%;
        }
      </style>
      <slot></slot>
    `;
  }
}
class B5 extends es {
  get [Ut]() {
    return Ja.html`
      <style>
        :host {
          display: inline-block;
          position: relative;
        }
      </style>
      <slot></slot>
    `;
  }
}
const A_ = /* @__PURE__ */ Symbol("appendedToDocument"), Yu = /* @__PURE__ */ Symbol("assignedZIndex"), hl = /* @__PURE__ */ Symbol("restoreFocusToElement");
function HN(o) {
  class e extends o {
    // TODO: Document
    get autoFocus() {
      return this[Ae].autoFocus;
    }
    set autoFocus(r) {
      this[At]({ autoFocus: r });
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        autoFocus: !0,
        persistent: !1
      });
    }
    async open() {
      !this[Ae].persistent && !this.isConnected && (this[A_] = !0, document.body.append(this)), super.open && await super.open();
    }
    [lt](r) {
      super[lt] && super[lt](r), this[jo] && this.addEventListener("blur", (n) => {
        const i = n.relatedTarget || document.activeElement, a = this;
        i instanceof HTMLElement && (Ks(a, i) || (this.opened ? this[hl] = i : (i.focus(), this[hl] = null)));
      }), (r.effectPhase || r.opened || r.persistent) && (this[Ae].persistent || ((typeof this.closeFinished > "u" ? this.closed : this.closeFinished) ? this[Yu] && (this.style.zIndex = "", this[Yu] = null) : this[Yu] ? this.style.zIndex = this[Yu] : ib(this) || P0(this)));
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), this[jo] && this[Ae].persistent && !ib(this) && P0(this), r.opened && this[Ae].autoFocus)
        if (this[Ae].opened) {
          !this[hl] && document.activeElement !== document.body && (this[hl] = document.activeElement);
          const n = _h(this);
          n && n.focus();
        } else
          this[hl] && (this[hl].focus(), this[hl] = null);
      !this[jo] && !this[Ae].persistent && this.closeFinished && this[A_] && (this[A_] = !1, this.parentNode && this.parentNode.removeChild(this));
    }
    get [Ut]() {
      const r = super[Ut] || Ja.html``;
      return r.content.append(kr.html`
        <style>
          :host([closed]) {
            display: none;
          }
        </style>
      `), r;
    }
  }
  return e;
}
function P0(o) {
  const e = zN() + 1;
  o[Yu] = e, o.style.zIndex = e.toString();
}
function ib(o) {
  const e = getComputedStyle(o).zIndex, t = o.style.zIndex, r = !isNaN(parseInt(t));
  if (e === "auto")
    return r;
  if (e === "0" && !r) {
    const n = o.assignedSlot || (o instanceof ShadowRoot ? o.host : o.parentNode);
    if (!(n instanceof HTMLElement))
      return !0;
    if (!ib(n))
      return !1;
  }
  return !0;
}
function zN() {
  const o = document.body.querySelectorAll("*"), e = Array.from(o, (t) => {
    const r = getComputedStyle(t);
    let n = 0;
    if (r.position !== "static" && r.zIndex !== "auto") {
      const i = r.zIndex ? parseInt(r.zIndex) : 0;
      n = isNaN(i) ? 0 : i;
    }
    return n;
  });
  return Math.max(...e);
}
const KN = S5(HN(x5(es)));
class E5 extends KN {
  get backdrop() {
    return this[bt] && this[bt].backdrop;
  }
  /**
   * The class or tag used for the `backdrop` part - the optional
   * element shown behind the overlay.
   *
   * This can help focus the user's attention on the overlay content.
   * Additionally, a backdrop can be used to absorb clicks on background page
   * elements. For example, [Dialog](Dialog) uses [ModalBackdrop](ModalBackdrop)
   * as an overlay backdrop in such a way.
   *
   * @type {PartDescriptor}
   * @default Backdrop
   */
  get backdropPartType() {
    return this[Ae].backdropPartType;
  }
  set backdropPartType(e) {
    this[At]({ backdropPartType: e });
  }
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      backdropPartType: hv,
      framePartType: B5
    });
  }
  get frame() {
    return this[bt].frame;
  }
  /**
   * The class or tag used to create the `frame` part – the overlay's
   * primary content.
   *
   * The frame element can be used to provide a border around the overlay
   * content, and to provide visual effects such as a drop-shadow to help
   * distinguish overlay content from background page elements.
   *
   * @type {PartDescriptor}
   * @default OverlayFrame
   */
  get framePartType() {
    return this[Ae].framePartType;
  }
  set framePartType(e) {
    this[At]({ framePartType: e });
  }
  [lt](e) {
    super[lt](e), F0(this[Cn], this[Ae], e);
  }
  [Rt](e) {
    super[Rt](e), e.opened && this[Ae].content && this[Ae].content.forEach((t) => {
      t[Jy] && t[Jy]();
    });
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(kr.html`
      <style>
        :host {
          max-height: 100vh;
          max-width: 100vw;
          outline: none;
          position: fixed;
          -webkit-tap-highlight-color: transparent;
        }

        [part~="frame"] {
          box-sizing: border-box;
          display: grid;
          overflow: hidden;
          overscroll-behavior: contain;
          pointer-events: initial;
          position: relative;
        }
      </style>
      <div id="backdrop" part="backdrop" tabindex="-1"></div>
      <div id="frame" part="frame" role="none">
        <slot></slot>
      </div>
    `), F0(e.content, this[Ae]), e;
  }
}
function F0(o, e, t) {
  if (!t || t.backdropPartType) {
    const { backdropPartType: r } = e, n = o.getElementById("backdrop");
    n && qs(n, r);
  }
  if (!t || t.framePartType) {
    const { framePartType: r } = e, n = o.getElementById("frame");
    n && qs(n, r);
  }
}
const Va = /* @__PURE__ */ Symbol("implicitCloseListener"), gv = new URLSearchParams(location.search).get("elixdebugpopup") === "true";
function $N(o) {
  class e extends o {
    /**
     * True if the popup should close if the user resizes the window.
     *
     * @type {boolean}
     * @default true
     */
    get closeOnWindowResize() {
      return this[Ae].closeOnWindowResize;
    }
    set closeOnWindowResize(r) {
      this[At]({ closeOnWindowResize: r });
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        closeOnWindowResize: !0,
        role: "alert"
      });
    }
    // Close on Esc key.
    [xr](r) {
      let n = !1;
      return r.key === "Escape" && (this.close({
        canceled: "Escape"
      }), n = !0), n || super.keydown && super.keydown(r) || !1;
    }
    [lt](r) {
      if (super[lt] && super[lt](r), this[jo] && (gv || this.addEventListener("blur", YN.bind(this))), r.role) {
        const { role: n } = this[Ae];
        this.setAttribute("role", n);
      }
    }
    [Rt](r) {
      super[Rt] && super[Rt](r), r.opened && (this.opened ? ("requestIdleCallback" in window ? window.requestIdleCallback : setTimeout)(() => {
        this.opened && WN(this);
      }) : XN(this));
    }
    // Setting the standard role attribute will invoke this property setter,
    // which will allow us to update our state.
    get role() {
      return super.role;
    }
    set role(r) {
      super.role = r, this[Yc] || this[At]({ role: r });
    }
  }
  return e;
}
function WN(o) {
  o[Va] = ZN.bind(o), gv || window.addEventListener("blur", o[Va]), window.addEventListener("resize", o[Va]), window.addEventListener("scroll", o[Va]);
}
function XN(o) {
  o[Va] && (gv || window.removeEventListener("blur", o[Va]), window.removeEventListener("resize", o[Va]), window.removeEventListener("scroll", o[Va]), o[Va] = null);
}
async function YN(o) {
  const e = this, t = (
    /** @type {any} */
    o.relatedTarget || document.activeElement
  );
  t instanceof Element && !Ks(e, t) && (e[ut] = !0, await e.close({ canceled: "window blur" }), e[ut] = !1);
}
async function ZN(o) {
  const e = this, t = o.type !== "resize" || e[Ae].closeOnWindowResize;
  !o5(e, o) && t && (e[ut] = !0, await e.close({
    canceled: `window ${o.type}`
  }), e[ut] = !1);
}
const JN = GA($N(E5));
class j5 extends JN {
  [lt](e) {
    super[lt](e), e.backdropPartType && (this[bt].backdrop.addEventListener(
      "mousedown",
      U0.bind(this)
    ), "PointerEvent" in window || this[bt].backdrop.addEventListener("touchend", U0));
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          :host {
            display: grid;
            grid-template: minmax(0, max-content) / minmax(0, max-content);
          }
        </style>
      `
    ), e;
  }
}
async function U0(o) {
  const e = this;
  e[ut] = !0, await e.close({
    canceled: "mousedown outside"
  }), e[ut] = !1, o.preventDefault(), o.stopPropagation();
}
const gA = /* @__PURE__ */ Symbol("resizeListener"), e4 = Gh(
  Oh(w5(S5(es)))
);
class t4 extends e4 {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      ariaHasPopup: "true",
      popupAlign: "start",
      popupDirection: "column",
      popupLayout: null,
      popupPartType: j5,
      sourcePartType: "div"
    });
  }
  // By default, assume that the source part is an input-like element that will
  // get the foucs.
  get [wn]() {
    return this[bt].source;
  }
  get frame() {
    return (
      /** @type {any} */
      this[bt].popup.frame
    );
  }
  /**
   * The alignment of the popup with respect to the source button.
   *
   * * `bottom`: popup and source are bottom-aligned
   * * `end`: popup and source are aligned on the trailing edge according to the
   *   text direction
   * * `left`: popup and source are left-aligned
   * * `right`: popup and source are right-aligned
   * * `start`: popup and source are aligned on the leading edge according to
   *   the text direction
   * * `stretch`: both left and right edges are aligned
   * * `top`: popup and source are top-aligned
   *
   * @type {('bottom'|'end'|'left'|'right'|'start'|'stretch'|'top')}
   * @default 'start'
   */
  get popupAlign() {
    return this[Ae].popupAlign;
  }
  set popupAlign(e) {
    this[At]({ popupAlign: e });
  }
  /**
   * The preferred direction for the popup.
   *
   * * `above`: popup appears above the source
   * * `below`: popup appears below the source
   * * `column-reverse`: popup appears before the source in the block axis
   * * `column`: popup appears after the source in the block axis
   * * `left`: popup appears to the left of the source
   * * `right`: popup appears to the right of the source
   * * `row-reverse`: popup appears before the source in the inline axis
   * * `row`: popup appears after the source in the inline axis
   *
   * @type {('above'|'below'|'column-reverse'|'column'|'left'|'right'|'row-reverse'|'row')}
   * @default 'column'
   */
  get popupDirection() {
    return this[Ae].popupDirection;
  }
  set popupDirection(e) {
    this[At]({ popupDirection: e });
  }
  /**
   * The class or tag used to create the `popup` part – the element
   * responsible for displaying the popup and handling overlay behavior.
   *
   * @type {PartDescriptor}
   * @default Popup
   */
  get popupPartType() {
    return this[Ae].popupPartType;
  }
  set popupPartType(e) {
    this[At]({ popupPartType: e });
  }
  [lt](e) {
    if (super[lt](e), N0(this[Cn], this[Ae], e), this[jo] || e.ariaHasPopup) {
      const { ariaHasPopup: t } = this[Ae];
      t === null ? this[wn].removeAttribute("aria-haspopup") : this[wn].setAttribute(
        "aria-haspopup",
        this[Ae].ariaHasPopup
      );
    }
    if (e.popupPartType && (this[bt].popup.addEventListener("open", () => {
      this.opened || (this[ut] = !0, this.open(), this[ut] = !1);
    }), this[bt].popup.addEventListener("close", (t) => {
      if (!this.closed) {
        this[ut] = !0;
        const n = t.detail.closeResult;
        this.close(n), this[ut] = !1;
      }
    })), e.opened || e.popupLayout) {
      const { opened: t, popupLayout: r } = this[Ae], n = {
        height: "",
        left: "",
        opacity: "",
        top: "",
        width: ""
      };
      if (t) if (!r)
        n.opacity = 0;
      else {
        const { align: i, direction: a, rect: s } = r, l = i === "stretch", c = a === "above" || a === "below";
        Object.assign(n, {
          gridTemplateColumns: c && l ? "minmax(0, 1fr)" : "",
          gridTemplateRows: !c && l ? "minmax(0, 1fr)" : "",
          height: `${s.height}px`,
          left: `${s.left}px`,
          top: `${s.top}px`,
          width: `${s.width}px`
        });
      }
      Object.assign(this[bt].popup.style, n);
    }
    if (e.opened) {
      const { opened: t } = this[Ae];
      this[bt].popup.opened = t;
    }
    if (e.disabled && "disabled" in this[bt].source) {
      const { disabled: t } = this[Ae];
      this[bt].source.disabled = t;
    }
    if (e.popupLayout) {
      const { popupLayout: t } = this[Ae];
      if (t) {
        const { align: r, direction: n } = t, i = this[bt].popup;
        "position" in i && (i.position = n), "align" in i && (i.align = r);
      }
    }
  }
  [Rt](e) {
    super[Rt](e);
    const { opened: t } = this[Ae];
    e.opened ? t ? i4(this) : o4(this) : e.popupLayout && this[Ae].opened && !this[Ae].popupLayout && _v(this);
  }
  /**
   * The class or tag used to create the `source` part - the button
   * (or other element) the user can tap/click to invoke the popup.
   *
   * @type {PartDescriptor}
   * @default 'button'
   */
  get sourcePartType() {
    return this[Ae].sourcePartType;
  }
  set sourcePartType(e) {
    this[At]({ sourcePartType: e });
  }
  [sr](e, t) {
    const r = super[sr](e, t);
    return (t.opened && !e.opened || e.opened && (t.popupAlign || t.popupDirection || t.rightToLeft)) && Object.assign(r, {
      popupLayout: null
    }), r;
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(kr.html`
      <style>
        :host {
          display: inline-block;
          position: relative;
        }

        [part~="source"] {
          height: 100%;
          -webkit-tap-highlight-color: transparent;
          touch-action: manipulation;
          width: 100%;
        }

        [part~="popup"] {
          outline: none;
          position: fixed;
        }
      </style>
      <div id="source" part="source">
        <slot name="source"></slot>
      </div>
      <div id="popup" part="popup" exportparts="backdrop, frame" role="none">
        <slot></slot>
      </div>
    `), N0(e.content, this[Ae]), e;
  }
}
function r4(o) {
  const e = o;
  e[gA] = () => {
    _v(o);
  }, (window.visualViewport || window).addEventListener("resize", e[gA]);
}
function _v(o) {
  const { popupAlign: e, popupDirection: t, rightToLeft: r } = o[Ae], n = o[bt].source.getBoundingClientRect(), i = o[bt].popup.getBoundingClientRect();
  /** @type {any} */
  o[bt].popup.frame && (i.height = o[bt].popup[bt].frame.scrollHeight, i.width = o[bt].popup[bt].frame.scrollWidth);
  const s = n4(), l = QN(n, i, s, {
    align: e,
    direction: t,
    rightToLeft: r
  });
  o[At]({ popupLayout: l });
}
function o4(o) {
  const e = o;
  e[gA] && ((window.visualViewport || window).removeEventListener("resize", e[gA]), e[gA] = null);
}
function N0(o, e, t) {
  if (!t || t.popupPartType) {
    const { popupPartType: r } = e, n = o.getElementById("popup");
    n && qs(n, r);
  }
  if (!t || t.sourcePartType) {
    const { sourcePartType: r } = e, n = o.getElementById("source");
    n && qs(n, r);
  }
}
function n4() {
  const o = window.visualViewport;
  return o ? new DOMRect(
    o.offsetLeft,
    o.offsetTop,
    o.width,
    o.height
  ) : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
}
function i4(o) {
  setTimeout(() => {
    o[Ae].opened && (_v(o), r4(o));
  });
}
const a4 = new URLSearchParams(location.search).get("elixdebugpopup") === "true", s4 = Qh(
  GA(IN(t4))
);
class l4 extends s4 {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      sourcePartType: "button"
    });
  }
  [xr](e) {
    let t;
    switch (e.key) {
      // Space or Up/Down arrow keys open the popup.
      case " ":
      case "ArrowDown":
      case "ArrowUp":
        this.closed && (this.open(), t = !0);
        break;
      // Enter opens popup.
      case "Enter":
        this.opened || (this.open(), t = !0);
        break;
      // If popup is open, pressing Esc should close popup.
      // This code exists to handle cases where the popup does not take the
      // focus (autoFocus is false). In cases where the popup takes focus, it
      // will be up to the popup to handle closing when Esc is pressed.
      case "Escape":
        this.opened && (this.close({
          canceled: "Escape"
        }), t = !0);
        break;
    }
    if (t = super[xr] && super[xr](e), !t && this.opened && !e.metaKey && !e.altKey)
      switch (e.key) {
        case "ArrowDown":
        case "ArrowLeft":
        case "ArrowRight":
        case "ArrowUp":
        case "End":
        case "Home":
        case "PageDown":
        case "PageUp":
        case " ":
          t = !0;
      }
    return t;
  }
  [lt](e) {
    if (super[lt](e), this[jo] && (a4 || this.addEventListener("blur", c4.bind(this)), this[bt].source.addEventListener("focus", async (t) => {
      const r = o5(this[bt].popup, t), n = this[Ae].popupHeight !== null;
      !r && this.opened && n && (this[ut] = !0, await this.close(), this[ut] = !1);
    })), e.opened) {
      const { opened: t } = this[Ae];
      this.toggleAttribute("opened", t);
    }
    e.sourcePartType && this[bt].source.addEventListener("mousedown", (r) => {
      if (this.disabled) {
        r.preventDefault();
        return;
      }
      const n = r;
      n.button && n.button !== 0 || (setTimeout(() => {
        this.opened || (this[ut] = !0, this.open(), this[ut] = !1);
      }), r.stopPropagation());
    }), e.popupPartType && this[bt].popup.removeAttribute("tabindex");
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          [part~="source"] {
            cursor: default;
            outline: none;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-user-select: none;
            user-select: none;
          }

          :host([opened][focus-visible]) {
            outline: none;
          }
        </style>
      `
    ), e;
  }
}
async function c4(o) {
  const e = this, t = (
    /** @type {any} */
    o.relatedTarget || document.activeElement
  );
  t instanceof Element && !Ks(e, t) && (e[ut] = !0, await e.close({ canceled: "blur" }), e[ut] = !1);
}
const uc = /* @__PURE__ */ Symbol("documentMousemoveListener");
function u4(o) {
  class e extends o {
    connectedCallback() {
      super.connectedCallback(), d_(this);
    }
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        currentIndex: -1,
        hasHoveredOverItemSinceOpened: !1,
        popupList: null
      });
    }
    disconnectedCallback() {
      super.disconnectedCallback && super.disconnectedCallback(), d_(this);
    }
    [xr](r) {
      let n = !1;
      return r.key === "Enter" && this.opened && (I0(this), n = !0), n || super[xr] && super[xr](r) || !1;
    }
    [lt](r) {
      if (super[lt] && super[lt](r), r.popupList) {
        const { popupList: n } = this[Ae];
        n && (n.addEventListener("mouseup", async (i) => {
          const a = this[Ae].currentIndex;
          this[Ae].dragSelect || a >= 0 ? (i.stopPropagation(), this[ut] = !0, await I0(this), this[ut] = !1) : i.stopPropagation();
        }), n.addEventListener("currentindexchange", (i) => {
          this[ut] = !0;
          const a = i;
          this[At]({
            currentIndex: a.detail.currentIndex
          }), this[ut] = !1;
        }));
      }
      if (r.currentIndex || r.popupList) {
        const { currentIndex: n, popupList: i } = this[Ae];
        i && "currentIndex" in i && (i.currentIndex = n);
      }
    }
    [Rt](r) {
      if (super[Rt] && super[Rt](r), r.opened) {
        if (this[Ae].opened) {
          const { popupList: n } = this[Ae];
          n.scrollCurrentItemIntoView && setTimeout(() => {
            n.scrollCurrentItemIntoView();
          });
        }
        d_(this);
      }
    }
    [sr](r, n) {
      const i = super[sr] ? super[sr](r, n) : {};
      return n.opened && r.opened && Object.assign(i, {
        hasHoveredOverItemSinceOpened: !1
      }), i;
    }
  }
  return e;
}
function A4(o) {
  const e = this, { hasHoveredOverItemSinceOpened: t, opened: r } = e[Ae];
  if (r) {
    const n = o.composedPath ? o.composedPath()[0] : o.target, i = e.items;
    if (n && n instanceof Node && i) {
      const a = r5(i, n), s = i[a], l = s && !s.disabled ? a : -1;
      (t || l >= 0) && l !== e[Ae].currentIndex && (e[ut] = !0, e[At]({ currentIndex: l }), l >= 0 && !t && e[At]({ hasHoveredOverItemSinceOpened: !0 }), e[ut] = !1);
    }
  }
}
function d_(o) {
  o[Ae].opened && o.isConnected ? o[uc] || (o[uc] = A4.bind(o), document.addEventListener(
    "mousemove",
    o[uc]
  )) : o[uc] && (document.removeEventListener(
    "mousemove",
    o[uc]
  ), o[uc] = null);
}
async function I0(o) {
  const e = o[ut], t = o[Ae].currentIndex >= 0, r = o.items;
  if (r) {
    const n = t ? r[o[Ae].currentIndex] : void 0, i = o[Ae].popupList;
    t && "flashCurrentItem" in i && await i.flashCurrentItem();
    const a = o[ut];
    o[ut] = e, await o.close(n), o[ut] = a;
  }
}
const d4 = u4(l4);
class p4 extends d4 {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      menuPartType: k5
    });
  }
  get items() {
    const e = this[bt] && this[bt].menu;
    return e ? e.items : null;
  }
  /**
   * The class or tag used to define the `menu` part – the element
   * presenting the menu items and handling navigation between them.
   *
   * @type {PartDescriptor}
   * @default Menu
   */
  get menuPartType() {
    return this[Ae].menuPartType;
  }
  set menuPartType(e) {
    this[At]({ menuPartType: e });
  }
  [lt](e) {
    if (super[lt](e), M0(this[Cn], this[Ae], e), e.menuPartType && (this[bt].menu.addEventListener("blur", async (t) => {
      const n = t.relatedTarget || document.activeElement;
      this.opened && !Ks(this[bt].menu, n) && (this[ut] = !0, await this.close(), this[ut] = !1);
    }), this[bt].menu.addEventListener("mousedown", (t) => {
      /** @type {MouseEvent} */
      t.button === 0 && this.opened && (t.stopPropagation(), t.preventDefault());
    })), e.opened) {
      const { opened: t } = this[Ae];
      this[bt].source.setAttribute("aria-expanded", t.toString());
    }
  }
  [Rt](e) {
    super[Rt](e), e.menuPartType && this[At]({
      popupList: this[bt].menu
    });
  }
  [sr](e, t) {
    const r = super[sr](e, t);
    return t.opened && !e.opened && Object.assign(r, {
      currentIndex: -1
    }), r;
  }
  get [Ut]() {
    const e = super[Ut], t = e.content.querySelector("slot:not([name])");
    return t && t.replaceWith(kr.html`
        <div id="menu" part="menu">
          <slot></slot>
        </div>
      `), M0(e.content, this[Ae]), e.content.append(kr.html`
      <style>
        [part~="menu"] {
          max-height: 100%;
        }
      </style>
    `), e;
  }
}
function M0(o, e, t) {
  if (!t || t.menuPartType) {
    const { menuPartType: r } = e, n = o.getElementById("menu");
    n && qs(n, r);
  }
}
const h4 = Gh(es);
class L5 extends h4 {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      direction: "down"
    });
  }
  /**
   * Indicates which direction the element should point to.
   *
   * @type {'down'|'up'}
   * @default 'down'
   */
  get direction() {
    return this[Ae].direction;
  }
  set direction(e) {
    this[At]({ direction: e });
  }
  [lt](e) {
    if (super[lt](e), e.direction) {
      const { direction: t } = this[Ae];
      this[bt].downIcon.style.display = t === "down" ? "block" : "none", this[bt].upIcon.style.display = t === "up" ? "block" : "none";
    }
  }
  get [Ut]() {
    return Ja.html`
      <style>
        :host {
          display: inline-block;
        }
      </style>
      <div id="downIcon" part="toggle-icon down-icon">
        <slot name="down-icon"></slot>
      </div>
      <div id="upIcon" part="toggle-icon up-icon">
        <slot name="up-icon"></slot>
      </div>
    `;
  }
}
function g4(o) {
  class e extends o {
    // @ts-ignore
    get [$e]() {
      return Object.assign(super[$e] || {}, {
        popupTogglePartType: L5
      });
    }
    /**
     * The class or tag used to create the `popup-toggle` part – the
     * element that lets the user know they can open the popup.
     *
     * @type {PartDescriptor}
     * @default UpDownToggle
     */
    get popupTogglePartType() {
      return this[Ae].popupTogglePartType;
    }
    set popupTogglePartType(r) {
      this[At]({ popupTogglePartType: r });
    }
    [lt](r) {
      if (super[lt](r), R0(this[Cn], this[Ae], r), r.popupDirection || r.popupTogglePartType) {
        const { popupDirection: n } = this[Ae], i = n === "above" || n === "column-reverse" ? "up" : "down", a = this[bt].popupToggle;
        "direction" in a && (a.direction = i);
      }
      if (r.disabled) {
        const { disabled: n } = this[Ae];
        this[bt].popupToggle.disabled = n;
      }
    }
    get [Ut]() {
      const r = super[Ut], n = r.content.querySelector('[part~="source"]');
      return n && n.append(kr.html`
          <div
            id="popupToggle"
            part="popup-toggle"
            exportparts="toggle-icon, down-icon, up-icon"
            tabindex="-1"
          ></div>
      `), R0(r.content, this[Ae]), r.content.append(kr.html`
      <style>
        [part~="popup-toggle"] {
          outline: none;
        }

        [part~="source"] {
          align-items: center;
          display: flex;
        }
      </style>
    `), r;
    }
  }
  return e;
}
function R0(o, e, t) {
  if (!t || t.popupTogglePartType) {
    const { popupTogglePartType: r } = e, n = o.getElementById("popupToggle");
    n && qs(n, r);
  }
}
class T5 extends h5(A5) {
}
class P5 extends T5 {
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          [part~="button"] {
            background: #eee;
            border: 1px solid #ccc;
            padding: 0.25em 0.5em;
          }
        </style>
      `
    ), e;
  }
}
class F5 extends k5 {
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          :host ::slotted(*) {
            padding: 0.25em 1em;
          }
          
          :host ::slotted([current]) {
            background: highlight;
            color: highlighttext;
          }

          @media (pointer: coarse) {
            ::slotted(*) {
              padding: 1em;
            }
          }
        </style>
      `
    ), e;
  }
}
class _4 extends L5 {
  get [Ut]() {
    const e = super[Ut], t = e.content.getElementById("downIcon"), r = kr.html`
      <svg
        id="downIcon"
        part="toggle-icon down-icon"
        xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 10 5"
      >
        <path d="M 0 0 l5 5 5 -5 z" />
      </svg>
    `.firstElementChild;
    t && r && ob(t, r);
    const n = e.content.getElementById("upIcon"), i = kr.html`
      <svg
        id="upIcon"
        part="toggle-icon up-icon"
        xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 10 5"
      >
        <path d="M 0 5 l5 -5 5 5 z" />
      </svg>
    `.firstElementChild;
    return n && i && ob(n, i), e.content.append(
      kr.html`
        <style>
          :host {
            align-items: center;
            display: inline-flex;
            padding: 2px;
          }

          :host(:not([disabled])):hover {
            background: #eee;
          }

          [part~="toggle-icon"] {
            fill: currentColor;
            height: 10px;
            margin: 0.25em;
            width: 10px;
          }
        </style>
      `
    ), e;
  }
}
class f4 extends hv {
}
class U5 extends B5 {
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          :host {
            background: white;
            border: 1px solid rgba(0, 0, 0, 0.2);
            box-shadow: 0 0px 10px rgba(0, 0, 0, 0.5);
            box-sizing: border-box;
          }
        </style>
      `
    ), e;
  }
}
class m4 extends j5 {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      backdropPartType: f4,
      framePartType: U5
    });
  }
}
class y4 extends g4(p4) {
  // @ts-ignore
  get [$e]() {
    return Object.assign(super[$e], {
      menuPartType: F5,
      popupPartType: m4,
      popupTogglePartType: _4,
      sourcePartType: P5
    });
  }
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          [part~="menu"] {
            background: window;
            border: none;
            padding: 0.5em 0;
          }
        </style>
      `
    ), e;
  }
}
class b4 extends T5 {
  /**
    * @function get
    * @returns {PlainObject}
  */
  get [Ut]() {
    const e = super[Ut];
    return e.content.append(
      kr.html`
        <style>
          [part~="button"] {
            background: var(--main-bg-color);
            border: 1px solid #ccc;
          }
        </style>
      `
    ), e;
  }
}
class v4 extends y4 {
  /**
    * @function get
    * @returns {PlainObject}
  */
  get [$e]() {
    return Object.assign(super[$e], {
      sourcePartType: b4
    });
  }
}
customElements.define("elix-menu-button", v4);
const N5 = document.createElement("template");
N5.innerHTML = `
  <style>
  :host {
    padding: 0px;
  }
  elix-menu-button::part(menu) {
    background-color: var(--icon-bg-color) !important;
    color: #fff;
  }
  elix-menu-button::part(popup-toggle) {
    padding: 0.25em 0.30em !important
  }
  :host ::slotted([current]){
    background-color: var(--icon-bg-color-hover) !important;
    color: #fff;
  }
  :host ::slotted(*){
    padding: 0.25em 1.25em 0.25em 0.25em !important;
    margin: 2px;
  }
  </style>

  <elix-menu-button id="MenuButton" aria-label="Main Menu">
    <slot></slot>
  </elix-menu-button>

`;
class w4 extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(N5.content.cloneNode(!0)), this.$menu = this._shadowRoot.querySelector("elix-menu-button"), this.$label = this.$menu.shadowRoot.querySelector("#popupToggle").shadowRoot, this.imgPath = svgEditor.configObj.curConfig.imgPath;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["label", "src"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    const n = new Image();
    if (t !== r)
      switch (e) {
        case "src":
          n.src = this.imgPath + "/" + r, n.width = 24, n.height = 24, n.alt = "logo", this.$label.prepend(n);
          break;
        case "label":
          this.$label.prepend(r);
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get label() {
    return this.getAttribute("label");
  }
  /**
   * @function set
   * @returns {void}
   */
  set label(e) {
    this.setAttribute("label", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
}
customElements.define("se-menu", w4);
class x4 extends F5 {
}
customElements.define("elix-menu", x4);
const I5 = document.createElement("template");
I5.innerHTML = `
  <style>
  </style>
  <elix-menu-item>
    <div style="display:flex; align-items: center;">
      <img src="logo.svg" alt="icon" style="display:none;" width="24"/>
      <span style="margin-left: 7px;"></span>
    </div>
  </elix-menu-item>
`;
class k4 extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(I5.content.cloneNode(!0)), this.$img = this._shadowRoot.querySelector("img"), this.$label = this._shadowRoot.querySelector("span"), this.$menuitem = this._shadowRoot.querySelector("elix-menu-item"), this.$svg = this.$menuitem.shadowRoot.querySelector("#checkmark"), this.$svg.setAttribute("style", "display: none;"), this.imgPath = svgEditor.configObj.curConfig.imgPath;
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["label", "src"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    let n = "";
    if (t !== r)
      switch (e) {
        case "src":
          this.$img.style.display = "inline-block", this.$img.setAttribute("src", this.imgPath + "/" + r);
          break;
        case "label":
          n = this.getAttribute("shortcut"), this.$label.textContent = `${no(r)} ${n ? `(${n})` : ""}`;
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get label() {
    return this.getAttribute("label");
  }
  /**
   * @function set
   * @returns {void}
   */
  set label(e) {
    this.setAttribute("label", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    const e = this.getAttribute("shortcut");
    e && document.addEventListener("keydown", (t) => {
      if (t.target.nodeName !== "BODY") return;
      const r = `${t.metaKey ? "meta+" : ""}${t.ctrlKey ? "ctrl+" : ""}${t.shiftKey ? "shift+" : ""}${t.key.toUpperCase()}`;
      e === r && (this.id && document.getElementById(this.id).click(), t.preventDefault());
    });
  }
}
customElements.define("se-menu-item", k4);
const M5 = document.createElement("template");
M5.innerHTML = `
<style>
#select-container {
  margin-top: 10px;
  display: inline-block;
}

#select-container:hover {
  background-color: var(--icon-bg-color-hover);
}

#select-container::part(value) {
  background-color: var(--main-bg-color);
}

#select-container::part(popup-toggle) {
  display: none;
}
::slotted(*) {
  padding:0;
  width:100%;
}

.closed {
  display: none;
}

#options-container {
  position: fixed;
}

</style>
  <label>Label</label>
  <div id="select-container" tabindex="0">
    <div id="selected-value"></div>
    <div id="options-container">
      <slot></slot>
    </div>
  </div>

`;
class C4 extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(M5.content.cloneNode(!0)), this.$dropdown = this._shadowRoot.querySelector("#select-container"), this.$label = this._shadowRoot.querySelector("label"), this.$selection = this.$dropdown.querySelector("#selected-value"), this.items = this.querySelectorAll("se-list-item"), this.imgPath = svgEditor.configObj.curConfig.imgPath, this.$optionsContainer = this._shadowRoot.querySelector("#options-container"), this.$optionsContainer.classList.add("closed"), this.$selection.addEventListener("click", this.toggleList), this.updateSelectedValue(this.items[0].getAttribute("value")), this.isDropdownOpen = !1;
  }
  toggleList = (e) => {
    this.isDropdownOpen ? this.closeDropdown() : (this.openDropdown(), this.setDropdownListPosition());
  };
  updateSelectedValue = (e) => {
    Array.from(this.items).forEach((t) => {
      if (t.getAttribute("value") === e)
        if (t.setAttribute("selected", !0), t.hasAttribute("src")) {
          for (; this.$selection.firstChild; )
            this.$selection.removeChild(this.$selection.firstChild);
          const r = document.createElement("img");
          r.src = this.imgPath + "/" + t.getAttribute("src"), r.style.height = t.getAttribute("img-height"), r.setAttribute("title", no(t.getAttribute("title"))), this.$selection.append(r);
        } else
          this.$selection.textContent = no(t.getAttribute("option"));
      else
        t.setAttribute("selected", !1);
    });
  };
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["label", "width", "height", "title", "value"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "title":
          this.$dropdown.setAttribute("title", no(r));
          break;
        case "label":
          this.$label.textContent = no(r);
          break;
        case "height":
          this.$dropdown.style.height = r;
          break;
        case "width":
          this.$dropdown.style.width = r;
          break;
        case "value":
          this.updateSelectedValue(r);
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get label() {
    return this.getAttribute("label");
  }
  /**
   * @function set
   * @returns {void}
   */
  set label(e) {
    this.setAttribute("label", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get width() {
    return this.getAttribute("width");
  }
  /**
   * @function set
   * @returns {void}
   */
  set width(e) {
    this.setAttribute("width", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get height() {
    return this.getAttribute("height");
  }
  /**
   * @function set
   * @returns {void}
   */
  set height(e) {
    this.setAttribute("height", e);
  }
  openDropdown = () => {
    this.isDropdownOpen = !0, this.$optionsContainer.classList.remove("closed");
  };
  closeDropdown = () => {
    this.isDropdownOpen = !1, this.$optionsContainer.classList.add("closed");
  };
  setDropdownListPosition = () => {
    const e = window.innerHeight, t = this.$selection.getBoundingClientRect(), r = this.$optionsContainer.getBoundingClientRect();
    t.bottom + r.height > e ? (this.$optionsContainer.style.top = t.top - r.height + "px", this.$optionsContainer.style.left = t.left + "px") : (this.$optionsContainer.style.top = t.bottom + "px", this.$optionsContainer.style.left = t.left + "px");
  };
  /**
   * @function connectedCallback
   * @returns {void}
   */
  connectedCallback() {
    const e = this;
    this.$dropdown.addEventListener("selectedindexchange", (t) => {
      if (t?.detail?.selectedItem !== void 0) {
        const r = t.detail.selectedItem, n = new CustomEvent("change", { detail: { value: r } });
        e.dispatchEvent(n), e.value = r, e.setAttribute("value", r);
      }
    }), this.$dropdown.addEventListener("focusout", (t) => {
      this.closeDropdown();
    }), window.addEventListener("mousedown", (t) => {
      this.isDropdownOpen && (t.target.closest("se-list") || (t.stopPropagation(), this.closeDropdown()));
    }, { capture: !0 });
  }
}
customElements.define("se-list", C4);
const R5 = document.createElement("template");
R5.innerHTML = `
  <style>
  [aria-label="option"]{
    padding:0.25rem 0.125rem !important;
    background-color: var(--icon-bg-color);
  }
  [aria-label="option"]:hover{
    background-color: var(--icon-bg-color-hover);
  }

  .selected {
    background-color: var(--icon-bg-color-hover);
  }

  </style>
  <div aria-label="option">
    <img alt="icon" />
    <slot></slot>
  </div>
`;
class S4 extends HTMLElement {
  /**
    * @function constructor
    */
  constructor() {
    super(), this._shadowRoot = this.attachShadow({ mode: "open" }), this._shadowRoot.append(R5.content.cloneNode(!0)), this.$menuitem = this._shadowRoot.querySelector("[aria-label=option]"), this.$img = this._shadowRoot.querySelector("img"), this.$img.setAttribute("style", "display: none;"), this.imgPath = svgEditor.configObj.curConfig.imgPath, this.$menuitem.addEventListener("mousedown", (e) => {
      this.$menuitem.dispatchEvent(new CustomEvent("selectedindexchange", {
        bubbles: !0,
        composed: !0,
        detail: { selectedItem: this.getAttribute("value") }
      }));
    });
  }
  /**
   * @function observedAttributes
   * @returns {any} observed
   */
  static get observedAttributes() {
    return ["option", "src", "title", "img-height", "selected"];
  }
  /**
   * @function attributeChangedCallback
   * @param {string} name
   * @param {string} oldValue
   * @param {string} newValue
   * @returns {void}
   */
  attributeChangedCallback(e, t, r) {
    if (t !== r)
      switch (e) {
        case "option":
          this.$menuitem.setAttribute("option", r), this.$menuitem.textContent = no(r);
          break;
        case "src":
          this.$img.setAttribute("style", "display: block;"), this.$img.setAttribute("src", this.imgPath + "/" + r);
          break;
        case "title":
          this.$img.setAttribute("title", no(r));
          break;
        case "img-height":
          this.$img.setAttribute("height", r);
          break;
        case "selected":
          r === "true" ? this.$menuitem.classList.add("selected") : this.$menuitem.classList.remove("selected");
          break;
        default:
          console.error(`unknown attribute: ${e}`);
          break;
      }
  }
  /**
   * @function get
   * @returns {any}
   */
  get option() {
    return this.getAttribute("option");
  }
  /**
   * @function set
   * @returns {void}
   */
  set option(e) {
    this.setAttribute("option", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get title() {
    return this.getAttribute("title");
  }
  /**
   * @function set
   * @returns {void}
   */
  set title(e) {
    this.setAttribute("title", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get imgHeight() {
    return this.getAttribute("img-height");
  }
  /**
   * @function set
   * @returns {void}
   */
  set imgHeight(e) {
    this.setAttribute("img-height", e);
  }
  /**
   * @function get
   * @returns {any}
   */
  get src() {
    return this.getAttribute("src");
  }
  /**
   * @function set
   * @returns {void}
   */
  set src(e) {
    this.setAttribute("src", e);
  }
}
customElements.define("se-list-item", S4);
(function() {
  typeof window > "u" || ("SVGPathSeg" in window || (window.SVGPathSeg = function(o, e, t) {
    this.pathSegType = o, this.pathSegTypeAsLetter = e, this._owningPathSegList = t;
  }, window.SVGPathSeg.prototype.classname = "SVGPathSeg", window.SVGPathSeg.PATHSEG_UNKNOWN = 0, window.SVGPathSeg.PATHSEG_CLOSEPATH = 1, window.SVGPathSeg.PATHSEG_MOVETO_ABS = 2, window.SVGPathSeg.PATHSEG_MOVETO_REL = 3, window.SVGPathSeg.PATHSEG_LINETO_ABS = 4, window.SVGPathSeg.PATHSEG_LINETO_REL = 5, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9, window.SVGPathSeg.PATHSEG_ARC_ABS = 10, window.SVGPathSeg.PATHSEG_ARC_REL = 11, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19, window.SVGPathSeg.prototype._segmentChanged = function() {
    this._owningPathSegList && this._owningPathSegList.segmentChanged(this);
  }, window.SVGPathSegClosePath = function(o) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CLOSEPATH, "z", o);
  }, window.SVGPathSegClosePath.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegClosePath.prototype.toString = function() {
    return "[object SVGPathSegClosePath]";
  }, window.SVGPathSegClosePath.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter;
  }, window.SVGPathSegClosePath.prototype.clone = function() {
    return new window.SVGPathSegClosePath(void 0);
  }, window.SVGPathSegMovetoAbs = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_ABS, "M", o), this._x = e, this._y = t;
  }, window.SVGPathSegMovetoAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegMovetoAbs.prototype.toString = function() {
    return "[object SVGPathSegMovetoAbs]";
  }, window.SVGPathSegMovetoAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegMovetoAbs.prototype.clone = function() {
    return new window.SVGPathSegMovetoAbs(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegMovetoRel = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_REL, "m", o), this._x = e, this._y = t;
  }, window.SVGPathSegMovetoRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegMovetoRel.prototype.toString = function() {
    return "[object SVGPathSegMovetoRel]";
  }, window.SVGPathSegMovetoRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegMovetoRel.prototype.clone = function() {
    return new window.SVGPathSegMovetoRel(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegMovetoRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegMovetoRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoAbs = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_ABS, "L", o), this._x = e, this._y = t;
  }, window.SVGPathSegLinetoAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoAbs.prototype.toString = function() {
    return "[object SVGPathSegLinetoAbs]";
  }, window.SVGPathSegLinetoAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegLinetoAbs.prototype.clone = function() {
    return new window.SVGPathSegLinetoAbs(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoRel = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_REL, "l", o), this._x = e, this._y = t;
  }, window.SVGPathSegLinetoRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoRel.prototype.toString = function() {
    return "[object SVGPathSegLinetoRel]";
  }, window.SVGPathSegLinetoRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegLinetoRel.prototype.clone = function() {
    return new window.SVGPathSegLinetoRel(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegLinetoRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegLinetoRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoCubicAbs = function(o, e, t, r, n, i, a) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, "C", o), this._x = e, this._y = t, this._x1 = r, this._y1 = n, this._x2 = i, this._y2 = a;
  }, window.SVGPathSegCurvetoCubicAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoCubicAbs.prototype.toString = function() {
    return "[object SVGPathSegCurvetoCubicAbs]";
  }, window.SVGPathSegCurvetoCubicAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoCubicAbs.prototype.clone = function() {
    return new window.SVGPathSegCurvetoCubicAbs(void 0, this._x, this._y, this._x1, this._y1, this._x2, this._y2);
  }, Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "x1", { get: function() {
    return this._x1;
  }, set: function(o) {
    this._x1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "y1", { get: function() {
    return this._y1;
  }, set: function(o) {
    this._y1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "x2", { get: function() {
    return this._x2;
  }, set: function(o) {
    this._x2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, "y2", { get: function() {
    return this._y2;
  }, set: function(o) {
    this._y2 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoCubicRel = function(o, e, t, r, n, i, a) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, "c", o), this._x = e, this._y = t, this._x1 = r, this._y1 = n, this._x2 = i, this._y2 = a;
  }, window.SVGPathSegCurvetoCubicRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoCubicRel.prototype.toString = function() {
    return "[object SVGPathSegCurvetoCubicRel]";
  }, window.SVGPathSegCurvetoCubicRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoCubicRel.prototype.clone = function() {
    return new window.SVGPathSegCurvetoCubicRel(void 0, this._x, this._y, this._x1, this._y1, this._x2, this._y2);
  }, Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "x1", { get: function() {
    return this._x1;
  }, set: function(o) {
    this._x1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "y1", { get: function() {
    return this._y1;
  }, set: function(o) {
    this._y1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "x2", { get: function() {
    return this._x2;
  }, set: function(o) {
    this._x2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, "y2", { get: function() {
    return this._y2;
  }, set: function(o) {
    this._y2 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoQuadraticAbs = function(o, e, t, r, n) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, "Q", o), this._x = e, this._y = t, this._x1 = r, this._y1 = n;
  }, window.SVGPathSegCurvetoQuadraticAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoQuadraticAbs.prototype.toString = function() {
    return "[object SVGPathSegCurvetoQuadraticAbs]";
  }, window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoQuadraticAbs.prototype.clone = function() {
    return new window.SVGPathSegCurvetoQuadraticAbs(void 0, this._x, this._y, this._x1, this._y1);
  }, Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, "x1", { get: function() {
    return this._x1;
  }, set: function(o) {
    this._x1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, "y1", { get: function() {
    return this._y1;
  }, set: function(o) {
    this._y1 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoQuadraticRel = function(o, e, t, r, n) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, "q", o), this._x = e, this._y = t, this._x1 = r, this._y1 = n;
  }, window.SVGPathSegCurvetoQuadraticRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoQuadraticRel.prototype.toString = function() {
    return "[object SVGPathSegCurvetoQuadraticRel]";
  }, window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoQuadraticRel.prototype.clone = function() {
    return new window.SVGPathSegCurvetoQuadraticRel(void 0, this._x, this._y, this._x1, this._y1);
  }, Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, "x1", { get: function() {
    return this._x1;
  }, set: function(o) {
    this._x1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, "y1", { get: function() {
    return this._y1;
  }, set: function(o) {
    this._y1 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegArcAbs = function(o, e, t, r, n, i, a, s) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_ABS, "A", o), this._x = e, this._y = t, this._r1 = r, this._r2 = n, this._angle = i, this._largeArcFlag = a, this._sweepFlag = s;
  }, window.SVGPathSegArcAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegArcAbs.prototype.toString = function() {
    return "[object SVGPathSegArcAbs]";
  }, window.SVGPathSegArcAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._r1 + " " + this._r2 + " " + this._angle + " " + (this._largeArcFlag ? "1" : "0") + " " + (this._sweepFlag ? "1" : "0") + " " + this._x + " " + this._y;
  }, window.SVGPathSegArcAbs.prototype.clone = function() {
    return new window.SVGPathSegArcAbs(void 0, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag);
  }, Object.defineProperty(window.SVGPathSegArcAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "r1", { get: function() {
    return this._r1;
  }, set: function(o) {
    this._r1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "r2", { get: function() {
    return this._r2;
  }, set: function(o) {
    this._r2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "angle", { get: function() {
    return this._angle;
  }, set: function(o) {
    this._angle = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "largeArcFlag", { get: function() {
    return this._largeArcFlag;
  }, set: function(o) {
    this._largeArcFlag = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcAbs.prototype, "sweepFlag", { get: function() {
    return this._sweepFlag;
  }, set: function(o) {
    this._sweepFlag = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegArcRel = function(o, e, t, r, n, i, a, s) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_REL, "a", o), this._x = e, this._y = t, this._r1 = r, this._r2 = n, this._angle = i, this._largeArcFlag = a, this._sweepFlag = s;
  }, window.SVGPathSegArcRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegArcRel.prototype.toString = function() {
    return "[object SVGPathSegArcRel]";
  }, window.SVGPathSegArcRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._r1 + " " + this._r2 + " " + this._angle + " " + (this._largeArcFlag ? "1" : "0") + " " + (this._sweepFlag ? "1" : "0") + " " + this._x + " " + this._y;
  }, window.SVGPathSegArcRel.prototype.clone = function() {
    return new window.SVGPathSegArcRel(void 0, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag);
  }, Object.defineProperty(window.SVGPathSegArcRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "r1", { get: function() {
    return this._r1;
  }, set: function(o) {
    this._r1 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "r2", { get: function() {
    return this._r2;
  }, set: function(o) {
    this._r2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "angle", { get: function() {
    return this._angle;
  }, set: function(o) {
    this._angle = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "largeArcFlag", { get: function() {
    return this._largeArcFlag;
  }, set: function(o) {
    this._largeArcFlag = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegArcRel.prototype, "sweepFlag", { get: function() {
    return this._sweepFlag;
  }, set: function(o) {
    this._sweepFlag = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoHorizontalAbs = function(o, e) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, "H", o), this._x = e;
  }, window.SVGPathSegLinetoHorizontalAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoHorizontalAbs.prototype.toString = function() {
    return "[object SVGPathSegLinetoHorizontalAbs]";
  }, window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x;
  }, window.SVGPathSegLinetoHorizontalAbs.prototype.clone = function() {
    return new window.SVGPathSegLinetoHorizontalAbs(void 0, this._x);
  }, Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoHorizontalRel = function(o, e) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, "h", o), this._x = e;
  }, window.SVGPathSegLinetoHorizontalRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoHorizontalRel.prototype.toString = function() {
    return "[object SVGPathSegLinetoHorizontalRel]";
  }, window.SVGPathSegLinetoHorizontalRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x;
  }, window.SVGPathSegLinetoHorizontalRel.prototype.clone = function() {
    return new window.SVGPathSegLinetoHorizontalRel(void 0, this._x);
  }, Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoVerticalAbs = function(o, e) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, "V", o), this._y = e;
  }, window.SVGPathSegLinetoVerticalAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoVerticalAbs.prototype.toString = function() {
    return "[object SVGPathSegLinetoVerticalAbs]";
  }, window.SVGPathSegLinetoVerticalAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._y;
  }, window.SVGPathSegLinetoVerticalAbs.prototype.clone = function() {
    return new window.SVGPathSegLinetoVerticalAbs(void 0, this._y);
  }, Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegLinetoVerticalRel = function(o, e) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, "v", o), this._y = e;
  }, window.SVGPathSegLinetoVerticalRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegLinetoVerticalRel.prototype.toString = function() {
    return "[object SVGPathSegLinetoVerticalRel]";
  }, window.SVGPathSegLinetoVerticalRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._y;
  }, window.SVGPathSegLinetoVerticalRel.prototype.clone = function() {
    return new window.SVGPathSegLinetoVerticalRel(void 0, this._y);
  }, Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoCubicSmoothAbs = function(o, e, t, r, n) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, "S", o), this._x = e, this._y = t, this._x2 = r, this._y2 = n;
  }, window.SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function() {
    return "[object SVGPathSegCurvetoCubicSmoothAbs]";
  }, window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function() {
    return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0, this._x, this._y, this._x2, this._y2);
  }, Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, "x2", { get: function() {
    return this._x2;
  }, set: function(o) {
    this._x2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, "y2", { get: function() {
    return this._y2;
  }, set: function(o) {
    this._y2 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoCubicSmoothRel = function(o, e, t, r, n) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, "s", o), this._x = e, this._y = t, this._x2 = r, this._y2 = n;
  }, window.SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function() {
    return "[object SVGPathSegCurvetoCubicSmoothRel]";
  }, window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function() {
    return new window.SVGPathSegCurvetoCubicSmoothRel(void 0, this._x, this._y, this._x2, this._y2);
  }, Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, "x2", { get: function() {
    return this._x2;
  }, set: function(o) {
    this._x2 = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, "y2", { get: function() {
    return this._y2;
  }, set: function(o) {
    this._y2 = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoQuadraticSmoothAbs = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, "T", o), this._x = e, this._y = t;
  }, window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function() {
    return "[object SVGPathSegCurvetoQuadraticSmoothAbs]";
  }, window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function() {
    return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathSegCurvetoQuadraticSmoothRel = function(o, e, t) {
    window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, "t", o), this._x = e, this._y = t;
  }, window.SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype), window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function() {
    return "[object SVGPathSegCurvetoQuadraticSmoothRel]";
  }, window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function() {
    return this.pathSegTypeAsLetter + " " + this._x + " " + this._y;
  }, window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function() {
    return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0, this._x, this._y);
  }, Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, "x", { get: function() {
    return this._x;
  }, set: function(o) {
    this._x = o, this._segmentChanged();
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, "y", { get: function() {
    return this._y;
  }, set: function(o) {
    this._y = o, this._segmentChanged();
  }, enumerable: !0 }), window.SVGPathElement.prototype.createSVGPathSegClosePath = function() {
    return new window.SVGPathSegClosePath(void 0);
  }, window.SVGPathElement.prototype.createSVGPathSegMovetoAbs = function(o, e) {
    return new window.SVGPathSegMovetoAbs(void 0, o, e);
  }, window.SVGPathElement.prototype.createSVGPathSegMovetoRel = function(o, e) {
    return new window.SVGPathSegMovetoRel(void 0, o, e);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoAbs = function(o, e) {
    return new window.SVGPathSegLinetoAbs(void 0, o, e);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoRel = function(o, e) {
    return new window.SVGPathSegLinetoRel(void 0, o, e);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function(o, e, t, r, n, i) {
    return new window.SVGPathSegCurvetoCubicAbs(void 0, o, e, t, r, n, i);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function(o, e, t, r, n, i) {
    return new window.SVGPathSegCurvetoCubicRel(void 0, o, e, t, r, n, i);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function(o, e, t, r) {
    return new window.SVGPathSegCurvetoQuadraticAbs(void 0, o, e, t, r);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function(o, e, t, r) {
    return new window.SVGPathSegCurvetoQuadraticRel(void 0, o, e, t, r);
  }, window.SVGPathElement.prototype.createSVGPathSegArcAbs = function(o, e, t, r, n, i, a) {
    return new window.SVGPathSegArcAbs(void 0, o, e, t, r, n, i, a);
  }, window.SVGPathElement.prototype.createSVGPathSegArcRel = function(o, e, t, r, n, i, a) {
    return new window.SVGPathSegArcRel(void 0, o, e, t, r, n, i, a);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function(o) {
    return new window.SVGPathSegLinetoHorizontalAbs(void 0, o);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function(o) {
    return new window.SVGPathSegLinetoHorizontalRel(void 0, o);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function(o) {
    return new window.SVGPathSegLinetoVerticalAbs(void 0, o);
  }, window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function(o) {
    return new window.SVGPathSegLinetoVerticalRel(void 0, o);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function(o, e, t, r) {
    return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0, o, e, t, r);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function(o, e, t, r) {
    return new window.SVGPathSegCurvetoCubicSmoothRel(void 0, o, e, t, r);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function(o, e) {
    return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0, o, e);
  }, window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function(o, e) {
    return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0, o, e);
  }, "getPathSegAtLength" in window.SVGPathElement.prototype || (window.SVGPathElement.prototype.getPathSegAtLength = function(o) {
    if (o === void 0 || !isFinite(o))
      throw "Invalid arguments.";
    var e = document.createElementNS("http://www.w3.org/2000/svg", "path");
    e.setAttribute("d", this.getAttribute("d"));
    var t = e.pathSegList.numberOfItems - 1;
    if (t <= 0)
      return 0;
    do {
      if (e.pathSegList.removeItem(t), o > e.getTotalLength())
        break;
      t--;
    } while (t > 0);
    return t;
  })), (!("SVGPathSegList" in window) || !("appendItem" in window.SVGPathSegList.prototype)) && (window.SVGPathSegList = function(o) {
    this._pathElement = o, this._list = this._parsePath(this._pathElement.getAttribute("d")), this._mutationObserverConfig = { attributes: !0, attributeFilter: ["d"] }, this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)), this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);
  }, window.SVGPathSegList.prototype.classname = "SVGPathSegList", Object.defineProperty(window.SVGPathSegList.prototype, "numberOfItems", {
    get: function() {
      return this._checkPathSynchronizedToList(), this._list.length;
    },
    enumerable: !0
  }), Object.defineProperty(window.SVGPathSegList.prototype, "length", {
    get: function() {
      return this._checkPathSynchronizedToList(), this._list.length;
    },
    enumerable: !0
  }), Object.defineProperty(window.SVGPathElement.prototype, "pathSegList", {
    get: function() {
      return this._pathSegList || (this._pathSegList = new window.SVGPathSegList(this)), this._pathSegList;
    },
    enumerable: !0
  }), Object.defineProperty(window.SVGPathElement.prototype, "normalizedPathSegList", { get: function() {
    return this.pathSegList;
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathElement.prototype, "animatedPathSegList", { get: function() {
    return this.pathSegList;
  }, enumerable: !0 }), Object.defineProperty(window.SVGPathElement.prototype, "animatedNormalizedPathSegList", { get: function() {
    return this.pathSegList;
  }, enumerable: !0 }), window.SVGPathSegList.prototype._checkPathSynchronizedToList = function() {
    this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords());
  }, window.SVGPathSegList.prototype._updateListFromPathMutations = function(o) {
    if (this._pathElement) {
      var e = !1;
      o.forEach(function(t) {
        t.attributeName == "d" && (e = !0);
      }), e && (this._list = this._parsePath(this._pathElement.getAttribute("d")));
    }
  }, window.SVGPathSegList.prototype._writeListToPath = function() {
    this._pathElementMutationObserver.disconnect(), this._pathElement.setAttribute("d", window.SVGPathSegList._pathSegArrayAsString(this._list)), this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);
  }, window.SVGPathSegList.prototype.segmentChanged = function(o) {
    this._writeListToPath();
  }, window.SVGPathSegList.prototype.clear = function() {
    this._checkPathSynchronizedToList(), this._list.forEach(function(o) {
      o._owningPathSegList = null;
    }), this._list = [], this._writeListToPath();
  }, window.SVGPathSegList.prototype.initialize = function(o) {
    return this._checkPathSynchronizedToList(), this._list = [o], o._owningPathSegList = this, this._writeListToPath(), o;
  }, window.SVGPathSegList.prototype._checkValidIndex = function(o) {
    if (isNaN(o) || o < 0 || o >= this.numberOfItems)
      throw "INDEX_SIZE_ERR";
  }, window.SVGPathSegList.prototype.getItem = function(o) {
    return this._checkPathSynchronizedToList(), this._checkValidIndex(o), this._list[o];
  }, window.SVGPathSegList.prototype.insertItemBefore = function(o, e) {
    return this._checkPathSynchronizedToList(), e > this.numberOfItems && (e = this.numberOfItems), o._owningPathSegList && (o = o.clone()), this._list.splice(e, 0, o), o._owningPathSegList = this, this._writeListToPath(), o;
  }, window.SVGPathSegList.prototype.replaceItem = function(o, e) {
    return this._checkPathSynchronizedToList(), o._owningPathSegList && (o = o.clone()), this._checkValidIndex(e), this._list[e] = o, o._owningPathSegList = this, this._writeListToPath(), o;
  }, window.SVGPathSegList.prototype.removeItem = function(o) {
    this._checkPathSynchronizedToList(), this._checkValidIndex(o);
    var e = this._list[o];
    return this._list.splice(o, 1), this._writeListToPath(), e;
  }, window.SVGPathSegList.prototype.appendItem = function(o) {
    return this._checkPathSynchronizedToList(), o._owningPathSegList && (o = o.clone()), this._list.push(o), o._owningPathSegList = this, this._writeListToPath(), o;
  }, window.SVGPathSegList._pathSegArrayAsString = function(o) {
    var e = "", t = !0;
    return o.forEach(function(r) {
      t ? (t = !1, e += r._asPathString()) : e += " " + r._asPathString();
    }), e;
  }, window.SVGPathSegList.prototype._parsePath = function(o) {
    if (!o || o.length == 0)
      return [];
    var e = this, t = function() {
      this.pathSegList = [];
    };
    t.prototype.appendSegment = function(s) {
      this.pathSegList.push(s);
    };
    var r = function(s) {
      this._string = s, this._currentIndex = 0, this._endIndex = this._string.length, this._previousCommand = window.SVGPathSeg.PATHSEG_UNKNOWN, this._skipOptionalSpaces();
    };
    r.prototype._isCurrentSpace = function() {
      var s = this._string[this._currentIndex];
      return s <= " " && (s == " " || s == `
` || s == "	" || s == "\r" || s == "\f");
    }, r.prototype._skipOptionalSpaces = function() {
      for (; this._currentIndex < this._endIndex && this._isCurrentSpace(); )
        this._currentIndex++;
      return this._currentIndex < this._endIndex;
    }, r.prototype._skipOptionalSpacesOrDelimiter = function() {
      return this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) != "," ? !1 : (this._skipOptionalSpaces() && this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == "," && (this._currentIndex++, this._skipOptionalSpaces()), this._currentIndex < this._endIndex);
    }, r.prototype.hasMoreData = function() {
      return this._currentIndex < this._endIndex;
    }, r.prototype.peekSegmentType = function() {
      var s = this._string[this._currentIndex];
      return this._pathSegTypeFromChar(s);
    }, r.prototype._pathSegTypeFromChar = function(s) {
      switch (s) {
        case "Z":
        case "z":
          return window.SVGPathSeg.PATHSEG_CLOSEPATH;
        case "M":
          return window.SVGPathSeg.PATHSEG_MOVETO_ABS;
        case "m":
          return window.SVGPathSeg.PATHSEG_MOVETO_REL;
        case "L":
          return window.SVGPathSeg.PATHSEG_LINETO_ABS;
        case "l":
          return window.SVGPathSeg.PATHSEG_LINETO_REL;
        case "C":
          return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;
        case "c":
          return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;
        case "Q":
          return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
        case "q":
          return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
        case "A":
          return window.SVGPathSeg.PATHSEG_ARC_ABS;
        case "a":
          return window.SVGPathSeg.PATHSEG_ARC_REL;
        case "H":
          return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
        case "h":
          return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
        case "V":
          return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
        case "v":
          return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
        case "S":
          return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
        case "s":
          return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
        case "T":
          return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
        case "t":
          return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
        default:
          return window.SVGPathSeg.PATHSEG_UNKNOWN;
      }
    }, r.prototype._nextCommandHelper = function(s, l) {
      return (s == "+" || s == "-" || s == "." || s >= "0" && s <= "9") && l != window.SVGPathSeg.PATHSEG_CLOSEPATH ? l == window.SVGPathSeg.PATHSEG_MOVETO_ABS ? window.SVGPathSeg.PATHSEG_LINETO_ABS : l == window.SVGPathSeg.PATHSEG_MOVETO_REL ? window.SVGPathSeg.PATHSEG_LINETO_REL : l : window.SVGPathSeg.PATHSEG_UNKNOWN;
    }, r.prototype.initialCommandIsMoveTo = function() {
      if (!this.hasMoreData())
        return !0;
      var s = this.peekSegmentType();
      return s == window.SVGPathSeg.PATHSEG_MOVETO_ABS || s == window.SVGPathSeg.PATHSEG_MOVETO_REL;
    }, r.prototype._parseNumber = function() {
      var s = 0, l = 0, c = 1, u = 0, A = 1, p = 1, d = this._currentIndex;
      if (this._skipOptionalSpaces(), this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == "+" ? this._currentIndex++ : this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == "-" && (this._currentIndex++, A = -1), !(this._currentIndex == this._endIndex || (this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9") && this._string.charAt(this._currentIndex) != ".")) {
        for (var g = this._currentIndex; this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9"; )
          this._currentIndex++;
        if (this._currentIndex != g)
          for (var _ = this._currentIndex - 1, f = 1; _ >= g; )
            l += f * (this._string.charAt(_--) - "0"), f *= 10;
        if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == ".") {
          if (this._currentIndex++, this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9")
            return;
          for (; this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9"; )
            c *= 10, u += (this._string.charAt(this._currentIndex) - "0") / c, this._currentIndex += 1;
        }
        if (this._currentIndex != d && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) == "e" || this._string.charAt(this._currentIndex) == "E") && this._string.charAt(this._currentIndex + 1) != "x" && this._string.charAt(this._currentIndex + 1) != "m") {
          if (this._currentIndex++, this._string.charAt(this._currentIndex) == "+" ? this._currentIndex++ : this._string.charAt(this._currentIndex) == "-" && (this._currentIndex++, p = -1), this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9")
            return;
          for (; this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9"; )
            s *= 10, s += this._string.charAt(this._currentIndex) - "0", this._currentIndex++;
        }
        var m = l + u;
        if (m *= A, s && (m *= Math.pow(10, p * s)), d != this._currentIndex)
          return this._skipOptionalSpacesOrDelimiter(), m;
      }
    }, r.prototype._parseArcFlag = function() {
      if (!(this._currentIndex >= this._endIndex)) {
        var s = !1, l = this._string.charAt(this._currentIndex++);
        if (l == "0")
          s = !1;
        else if (l == "1")
          s = !0;
        else
          return;
        return this._skipOptionalSpacesOrDelimiter(), s;
      }
    }, r.prototype.parseSegment = function() {
      var s = this._string[this._currentIndex], l = this._pathSegTypeFromChar(s);
      if (l == window.SVGPathSeg.PATHSEG_UNKNOWN) {
        if (this._previousCommand == window.SVGPathSeg.PATHSEG_UNKNOWN || (l = this._nextCommandHelper(s, this._previousCommand), l == window.SVGPathSeg.PATHSEG_UNKNOWN))
          return null;
      } else
        this._currentIndex++;
      switch (this._previousCommand = l, l) {
        case window.SVGPathSeg.PATHSEG_MOVETO_REL:
          return new window.SVGPathSegMovetoRel(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_MOVETO_ABS:
          return new window.SVGPathSegMovetoAbs(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_REL:
          return new window.SVGPathSegLinetoRel(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_ABS:
          return new window.SVGPathSegLinetoAbs(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
          return new window.SVGPathSegLinetoHorizontalRel(e, this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
          return new window.SVGPathSegLinetoHorizontalAbs(e, this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
          return new window.SVGPathSegLinetoVerticalRel(e, this._parseNumber());
        case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
          return new window.SVGPathSegLinetoVerticalAbs(e, this._parseNumber());
        case window.SVGPathSeg.PATHSEG_CLOSEPATH:
          return this._skipOptionalSpaces(), new window.SVGPathSegClosePath(e);
        case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoCubicRel(e, c.x, c.y, c.x1, c.y1, c.x2, c.y2);
        case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoCubicAbs(e, c.x, c.y, c.x1, c.y1, c.x2, c.y2);
        case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
          var c = { x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoCubicSmoothRel(e, c.x, c.y, c.x2, c.y2);
        case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
          var c = { x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoCubicSmoothAbs(e, c.x, c.y, c.x2, c.y2);
        case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoQuadraticRel(e, c.x, c.y, c.x1, c.y1);
        case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegCurvetoQuadraticAbs(e, c.x, c.y, c.x1, c.y1);
        case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
          return new window.SVGPathSegCurvetoQuadraticSmoothRel(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
          return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e, this._parseNumber(), this._parseNumber());
        case window.SVGPathSeg.PATHSEG_ARC_REL:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegArcRel(e, c.x, c.y, c.x1, c.y1, c.arcAngle, c.arcLarge, c.arcSweep);
        case window.SVGPathSeg.PATHSEG_ARC_ABS:
          var c = { x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber() };
          return new window.SVGPathSegArcAbs(e, c.x, c.y, c.x1, c.y1, c.arcAngle, c.arcLarge, c.arcSweep);
        default:
          throw "Unknown path seg type.";
      }
    };
    var n = new t(), i = new r(o);
    if (!i.initialCommandIsMoveTo())
      return [];
    for (; i.hasMoreData(); ) {
      var a = i.parseSegment();
      if (!a)
        return [];
      n.appendSegment(a);
    }
    return n.pathSegList;
  }));
})();
class Ii {
  static #t(e) {
    const t = Number(e);
    return Number.isFinite(t) ? Math.min(100, Math.max(0, t)) : 100;
  }
  static #e(e) {
    if (e == null) return null;
    const t = String(e).trim();
    return t ? t === "none" ? "none" : t.startsWith("#") ? t.slice(1) : t : null;
  }
  static #r(e) {
    if (!e) return null;
    const t = String(e).trim();
    if (!t) return null;
    if (t.startsWith("#")) return t.slice(1);
    const r = t.match(/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/);
    if (r?.[1]) return r[1];
    const n = t.lastIndexOf("#");
    return n >= 0 && n < t.length - 1 ? t.slice(n + 1) : null;
  }
  static #o(e) {
    if (!e?.cloneNode) return null;
    const t = e.ownerDocument || document, r = /* @__PURE__ */ new Set(), n = e.cloneNode(!0);
    let i = Ii.#r(
      n.getAttribute("href") || n.getAttribute("xlink:href")
    );
    for (; i && !r.has(i); ) {
      r.add(i);
      const a = t.getElementById(i);
      if (!a?.getAttribute) break;
      const s = String(n.tagName || "").toLowerCase(), l = String(a.tagName || "").toLowerCase();
      if (!["lineargradient", "radialgradient"].includes(l) || l !== s)
        break;
      for (const c of a.attributes || []) {
        const u = c.name;
        if (u === "id" || u === "href" || u === "xlink:href") continue;
        const A = n.getAttribute(u);
        (A === null || A === "") && n.setAttribute(u, c.value);
      }
      if (n.querySelectorAll("stop").length === 0)
        for (const c of a.querySelectorAll?.("stop") || [])
          n.append(c.cloneNode(!0));
      i = Ii.#r(
        a.getAttribute("href") || a.getAttribute("xlink:href")
      );
    }
    return n.removeAttribute("href"), n.removeAttribute("xlink:href"), n;
  }
  /**
   * @param {module:jGraduate.jGraduatePaintOptions} [opt]
   */
  constructor(e) {
    const t = e || {};
    if (this.alpha = Ii.#t(t.alpha), t.copy)
      switch (this.type = t.copy.type, this.alpha = Ii.#t(t.copy.alpha), this.solidColor = null, this.linearGradient = null, this.radialGradient = null, this.type) {
        case "none":
          break;
        case "solidColor":
          this.solidColor = Ii.#e(t.copy.solidColor);
          break;
        case "linearGradient":
          this.linearGradient = t.copy.linearGradient?.cloneNode ? t.copy.linearGradient.cloneNode(!0) : null;
          break;
        case "radialGradient":
          this.radialGradient = t.copy.radialGradient?.cloneNode ? t.copy.radialGradient.cloneNode(!0) : null;
          break;
      }
    else t.linearGradient ? (this.type = "linearGradient", this.solidColor = null, this.radialGradient = null, this.linearGradient = Ii.#o(t.linearGradient)) : t.radialGradient ? (this.type = "radialGradient", this.solidColor = null, this.linearGradient = null, this.radialGradient = Ii.#o(t.radialGradient)) : t.solidColor ? (this.type = "solidColor", this.solidColor = Ii.#e(t.solidColor)) : (this.type = "none", this.solidColor = null, this.linearGradient = null, this.radialGradient = null);
  }
}
const B4 = {
  prefix: "[SVGCanvas]"
}, O5 = (o, e = "") => {
  const t = e ? ` [${e}]` : "";
  return `${B4.prefix}${t} ${o}`;
}, Zc = (o, e, t = "") => {
  console.error(O5(o, t)), e && console.error(e);
}, xn = (o, e, t = "") => {
  console.warn(O5(o, t)), e !== void 0 && console.warn(e);
}, O0 = "http://www.w3.org/2000/svg", Q5 = ["x", "x1", "cx", "rx", "width"], q5 = ["y", "y1", "cy", "ry", "height"], E4 = ["r", "radius", ...Q5, ...q5];
let Kc, VA = {};
const j4 = (o) => {
  Kc = o;
  const e = document.createElementNS(O0, "svg");
  document.body.append(e);
  const t = document.createElementNS(O0, "rect");
  t.setAttribute("width", "1em"), t.setAttribute("height", "1ex"), t.setAttribute("x", "1in"), e.append(t);
  const r = t.getBBox();
  e.remove();
  const n = r.x;
  VA = {
    em: r.width,
    ex: r.height,
    in: n,
    cm: n / 2.54,
    mm: n / 25.4,
    pt: n / 72,
    pc: n / 6,
    px: 1,
    "%": 0
  };
}, fv = () => VA, ai = (o) => {
  const e = Kc.getRoundDigits();
  return isNaN(o) ? Array.isArray(o) ? `${ai(o[0])},${ai(o[1])}` : Number.parseFloat(o).toFixed(e) - 0 : Number(Number(o).toFixed(e));
}, fh = (o, e) => (e = e || Kc.getBaseUnit(), ai(o / VA[e])), L4 = (o, e, t) => {
  o.setAttribute(e, t);
}, Xr = (o, e) => {
  if (!isNaN(e))
    return e - 0;
  if (e.substr(-1) === "%") {
    const r = e.substr(0, e.length - 1) / 100, n = Kc.getWidth(), i = Kc.getHeight();
    return Q5.includes(o) ? r * n : q5.includes(o) ? r * i : r * Math.sqrt(n * n + i * i) / Math.sqrt(2);
  }
  const t = e.slice(-2);
  return e.slice(0, -2) * VA[t];
}, T4 = (o, e, t) => {
  if (E4.includes(o))
    return isNaN(e) ? (e = e.toLowerCase(), Object.keys(VA).some((r) => new RegExp(`^-?[\\d\\.]+${r}$`).test(e))) : !0;
  if (o === "id") {
    let r = !1;
    try {
      const n = Kc.getElement(e);
      r = !n || n === t;
    } catch (n) {
      Zc("Error getting element by ID", n, "units");
    }
    return r;
  }
  return !0;
}, vt = {
  HTML: "http://www.w3.org/1999/xhtml",
  MATH: "http://www.w3.org/1998/Math/MathML",
  SE: "http://svg-edit.googlecode.com",
  SVG: "http://www.w3.org/2000/svg",
  XLINK: "http://www.w3.org/1999/xlink",
  OI: "http://www.optimistik.fr/namespace/svg/OIdata",
  XML: "http://www.w3.org/XML/1998/namespace",
  XMLNS: "http://www.w3.org/2000/xmlns/"
  // see http://www.w3.org/TR/REC-xml-names/#xmlReserved
  // SODIPODI: 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
  // INKSCAPE: 'http://www.inkscape.org/namespaces/inkscape',
  // RDF: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
  // OSB: 'http://www.openswatchbook.org/uri/2009/osb',
  // CC: 'http://creativecommons.org/ns#',
  // DC: 'http://purl.org/dc/elements/1.1/'
}, G5 = () => {
  const o = {};
  for (const [e, t] of Object.entries(vt))
    o[t] = e.toLowerCase();
  return o;
}, wl = 1e-10, Qi = document.createElementNS(vt.SVG, "svg"), Q0 = (o) => {
  const e = (t) => {
    const r = Qi.createSVGMatrix();
    return Object.assign(r, {
      a: t.a,
      b: t.b,
      c: t.c,
      d: t.d,
      e: t.e,
      f: t.f
    }), r;
  };
  try {
    return Qi.createSVGTransformFromMatrix(o);
  } catch {
    const t = Qi.createSVGTransform();
    try {
      return t.setMatrix(o), t;
    } catch {
      try {
        return Qi.createSVGTransformFromMatrix(e(o));
      } catch {
        return t.setMatrix(e(o)), t;
      }
    }
  }
}, cr = (o, e, t) => ({
  x: t.a * o + t.c * e + t.e,
  y: t.b * o + t.d * e + t.f
}), hr = (o) => {
  if (o.transform?.baseVal)
    return o.transform.baseVal;
  if (o.gradientTransform?.baseVal)
    return o.gradientTransform.baseVal;
  if (o.patternTransform?.baseVal)
    return o.patternTransform.baseVal;
  xn("No transform list found. Check browser compatibility.", o, "math");
}, V5 = (o) => Math.abs(o.a - 1) < wl && Math.abs(o.b) < wl && Math.abs(o.c) < wl && Math.abs(o.d - 1) < wl && Math.abs(o.e) < wl && Math.abs(o.f) < wl, Ro = (...o) => {
  if (o.length === 0)
    return Qi.createSVGMatrix();
  const e = (r) => {
    const n = ["a", "b", "c", "d", "e", "f"];
    for (const i of n)
      Math.abs(r[i]) < wl && (r[i] = 0);
    return r;
  };
  if (typeof DOMMatrix == "function" && typeof DOMMatrix.fromMatrix == "function") {
    const r = o.reduce(
      (i, a) => i.multiply(DOMMatrix.fromMatrix(a)),
      new DOMMatrix()
    ), n = Qi.createSVGMatrix();
    return Object.assign(n, {
      a: r.a,
      b: r.b,
      c: r.c,
      d: r.d,
      e: r.e,
      f: r.f
    }), e(n);
  }
  let t = Qi.createSVGMatrix();
  for (const r of o) {
    const n = Qi.createSVGMatrix();
    Object.assign(n, {
      a: t.a * r.a + t.c * r.b,
      b: t.b * r.a + t.d * r.b,
      c: t.a * r.c + t.c * r.d,
      d: t.b * r.c + t.d * r.d,
      e: t.a * r.e + t.c * r.f + t.e,
      f: t.b * r.e + t.d * r.f + t.f
    }), t = n;
  }
  return e(t);
}, Ml = (o) => {
  if (!o) return !1;
  for (let e = 0; e < o.numberOfItems; e++) {
    const t = o.getItem(e);
    if (t.type === SVGTransform.SVG_TRANSFORM_MATRIX && !V5(t.matrix))
      return !0;
  }
  return !1;
}, mv = (o, e, t, r, n) => {
  const i = cr(o, e, n), a = cr(o + t, e, n), s = cr(o, e + r, n), l = cr(o + t, e + r, n), c = Math.min(i.x, a.x, s.x, l.x), u = Math.max(i.x, a.x, s.x, l.x), A = Math.min(i.y, a.y, s.y, l.y), p = Math.max(i.y, a.y, s.y, l.y);
  return {
    tl: i,
    tr: a,
    bl: s,
    br: l,
    aabox: {
      x: c,
      y: A,
      width: u - c,
      height: p - A
    }
  };
}, lr = (o, e = 0, t = null) => {
  if (!o)
    return Q0(Qi.createSVGMatrix());
  const r = Number.parseInt(e, 10), n = Number.parseInt(t ?? o.numberOfItems - 1, 10), [i, a] = [Math.min(r, n), Math.max(r, n)], s = [];
  for (let u = i; u <= a; u++) {
    const A = u >= 0 && u < o.numberOfItems ? o.getItem(u).matrix : Qi.createSVGMatrix();
    s.push(A);
  }
  const l = Ro(...s), c = Qi.createSVGMatrix();
  return Object.assign(c, {
    a: l.a,
    b: l.b,
    c: l.c,
    d: l.d,
    e: l.e,
    f: l.f
  }), Q0(c);
}, D5 = (o) => {
  const e = hr(o);
  return lr(e).matrix;
}, ab = (o, e, t, r) => {
  const n = Math.PI / 4, i = t - o, a = r - e, s = Math.atan2(a, i), l = Math.hypot(i, a), c = Math.round(s / n) * n;
  return {
    x: o + l * Math.cos(c),
    y: e + l * Math.sin(c),
    a: c
  };
}, H5 = (o, e) => e.x < o.x + o.width && e.x + e.width > o.x && e.y < o.y + o.height && e.y + e.height > o.y, P4 = (o) => {
  let e = 0, t = 0;
  if (o?.offsetParent) {
    let r = o;
    do
      e += r.offsetLeft, t += r.offsetTop, r = r.offsetParent;
    while (r);
  }
  return { left: e, top: t };
}, p_ = (o) => o && typeof o == "object" && !Array.isArray(o), DA = (o, e) => {
  const t = { ...o };
  if (p_(o) && p_(e))
    for (const r of Object.keys(e))
      p_(e[r]) ? t[r] = r in o ? DA(o[r], e[r]) : e[r] : t[r] = e[r];
  return t;
}, HA = (o, e) => {
  if (o?.closest)
    try {
      return o.closest(e);
    } catch {
    }
  const t = {
    ".": (i, a) => i.classList?.contains(a.slice(1)),
    "#": (i, a) => i.id === a.slice(1),
    "[": (i, a) => {
      const [s, l] = a.slice(1, -1).split("=").map((c) => c.replace(/["']/g, ""));
      return l ? i.getAttribute(s) === l : i.hasAttribute(s);
    },
    tag: (i, a) => i.tagName?.toLowerCase() === a
  }, r = e.charAt(0), n = t[r] || t.tag;
  for (let i = o; i && i !== document && i.nodeType === 1; i = i.parentNode)
    if (n(i, e)) return i;
  return null;
}, zA = (o, e) => {
  const t = [], r = {
    ".": (a, s) => a.classList?.contains(s.slice(1)),
    "#": (a, s) => a.id === s.slice(1),
    "[": (a, s) => a.hasAttribute(s.slice(1, -1)),
    tag: (a, s) => a.tagName?.toLowerCase() === s
  }, n = e?.charAt(0), i = e ? r[n] || r.tag : null;
  for (let a = o; a && a !== document; a = a.parentNode)
    (!e || i(a, e)) && t.push(a);
  return t.length > 0 ? t : null;
}, F4 = (o, e, t) => {
  const r = [], n = {
    ".": (s, l) => s.classList?.contains(l.slice(1)),
    "#": (s, l) => s.id === l.slice(1),
    "[": (s, l) => s.hasAttribute(l.slice(1, -1)),
    tag: (s, l) => s.tagName?.toLowerCase() === l
  }, i = (s) => {
    if (!s) return null;
    const l = s.charAt(0);
    return n[l] || n.tag;
  }, a = i(e);
  i(t);
  for (let s = o; s && s !== document && !a?.(s, e); s = s.parentNode)
    r.push(s);
  return r.length > 0 ? r : null;
}, U4 = "a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath", N4 = U4.split(",");
let $a = null, z5 = null;
const I4 = (o) => {
  $a = o, z5 = o.getSvgRoot();
}, _A = (o) => {
  const e = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#x27;"
    // Note: `&apos;` is XML only
  };
  return o.replace(/[&<>"']/g, (t) => e[t]);
}, K5 = (o) => {
  const e = O4(o);
  return window.btoa(e);
}, $5 = (o) => R4(window.atob(o)), M4 = (o) => {
  if (o.length === 0) return 0;
  let e = 0;
  for (let t = 0; t < o.length; t++) {
    const r = o.charCodeAt(t);
    e = (e << 5) - e + r | 0;
  }
  return e;
}, R4 = (o) => decodeURIComponent(escape(o)), O4 = (o) => unescape(encodeURIComponent(o)), Q4 = (o) => !o || typeof URL > "u" || !URL.createObjectURL ? "" : URL.createObjectURL(o), q4 = (() => {
  if (typeof Blob > "u")
    return "";
  const o = new Blob(
    ["<html><head><title>SVG-edit</title></head><body>&nbsp;</body></html>"],
    { type: "text/html" }
  );
  return Q4(o);
})(), yv = (o) => {
  let e = o;
  e.includes("<svg:svg") && (e = e.replace(/<(\/?)svg:/g, "<$1").replace("xmlns:svg", "xmlns"));
  let t;
  try {
    t = new DOMParser(), t.async = !1;
  } catch {
    throw new Error("XML Parser could not be instantiated");
  }
  try {
    return t.parseFromString(e, "text/xml");
  } catch (r) {
    throw new Error(`Error parsing XML string: ${r.message}`);
  }
}, G4 = ({ x: o, y: e, width: t, height: r }) => ({ x: o, y: e, width: t, height: r }), Wa = (o, e) => {
  if (o?.nodeType === 1) {
    e(o);
    let t = o.childNodes.length;
    for (; t--; )
      Wa(o.childNodes.item(t), e);
  }
}, V4 = (o, e) => {
  if (o?.nodeType === 1) {
    let t = o.childNodes.length;
    for (; t--; )
      Wa(o.childNodes.item(t), e);
    e(o);
  }
}, TA = (o) => {
  if (!o?.startsWith("url(")) return null;
  const e = [
    { start: 'url("', end: '"', offset: 5 },
    { start: "url('", end: "'", offset: 5 },
    { start: "url(", end: ")", offset: 4 }
  ];
  for (const { start: t, end: r, offset: n } of e)
    if (o.startsWith(t)) {
      const i = o.indexOf(r, n + 1);
      return i > 0 ? o.substring(n, i) : null;
    }
  return null;
};
let ca = (o) => o.getAttribute("href") ?? o.getAttributeNS(vt.XLINK, "href"), vi = (o, e) => {
  o.setAttribute("href", e);
};
const Dn = () => {
  const o = $a.getSvgContent(), e = o.getElementsByTagNameNS(vt.SVG, "defs");
  if (e.length > 0)
    return e[0];
  const t = o.ownerDocument.createElementNS(vt.SVG, "defs"), r = o.firstChild?.nextSibling;
  return r ? o.insertBefore(t, r) : o.append(t), t;
}, so = (o) => {
  const e = o ?? $a.getSelectedElements()[0];
  if (o.nodeType !== 1) return null;
  const t = e.nodeName;
  let r = null;
  switch (t) {
    case "text":
      e.textContent === "" ? (e.textContent = "a", r = e.getBBox(), e.textContent = "") : e.getBBox && (r = e.getBBox());
      break;
    case "path":
    case "g":
    case "a":
      e.getBBox && (r = e.getBBox());
      break;
    default:
      if (t === "use")
        r = e.getBBox();
      else if (N4.includes(t))
        if (e)
          try {
            r = e.getBBox();
          } catch {
            const n = e.getExtentOfChar(0), i = e.getComputedTextLength();
            r = {
              x: n.x,
              y: n.y,
              width: i,
              height: n.height
            };
          }
        else {
          const n = HA(e.parentNode, "foreignObject");
          n.length && n[0].getBBox && (r = n[0].getBBox());
        }
  }
  if (r) {
    if (r.width === 0 && r.height === 0) {
      const n = t.toLowerCase(), i = (s, l = 0) => Number.parseFloat(e.getAttribute(s) ?? l), a = (() => {
        switch (n) {
          case "path": {
            const s = ((e.getAttribute("d") || "").match(/-?\d*\.?\d+/g) || []).map(Number).filter((l) => !Number.isNaN(l));
            if (s.length >= 2) {
              const l = s.filter((u, A) => A % 2 === 0), c = s.filter((u, A) => A % 2 === 1);
              return {
                x: Math.min(...l),
                y: Math.min(...c),
                width: Math.max(...l) - Math.min(...l),
                height: Math.max(...c) - Math.min(...c)
              };
            }
            break;
          }
          case "rect":
            return { x: i("x"), y: i("y"), width: i("width"), height: i("height") };
          case "line": {
            const s = i("x1"), l = i("x2"), c = i("y1"), u = i("y2");
            return { x: Math.min(s, l), y: Math.min(c, u), width: Math.abs(l - s), height: Math.abs(u - c) };
          }
          case "g": {
            const s = Array.from(e.children || []).map((l) => so(l)).filter(Boolean);
            if (s.length) {
              const l = Math.min(...s.map((p) => p.x)), c = Math.min(...s.map((p) => p.y)), u = Math.max(...s.map((p) => p.x + p.width)), A = Math.max(...s.map((p) => p.y + p.height));
              return { x: l, y: c, width: u - l, height: A - c };
            }
            break;
          }
        }
      })();
      a && (r = a);
    }
    r = G4(r);
  }
  return r;
}, q0 = (o) => o.map(([e, t]) => {
  const r = [];
  for (let n = 0; n < t.length; n += 2)
    r.push(`${t[n]},${t[n + 1]}`);
  return e + r.join(" ");
}).join(" "), W5 = (o) => {
  let e = 1.81, t, r, n;
  switch (o.tagName) {
    case "ellipse":
    case "circle": {
      r = Number(o.getAttribute("rx")), n = Number(o.getAttribute("ry"));
      const i = Number(o.getAttribute("cx")), a = Number(o.getAttribute("cy"));
      o.tagName === "circle" && o.hasAttribute("r") && (n = Number(o.getAttribute("r")), r = n), t = q0([
        ["M", [i - r, a]],
        ["C", [i - r, a - n / e, i - r / e, a - n, i, a - n]],
        ["C", [i + r / e, a - n, i + r, a - n / e, i + r, a]],
        ["C", [i + r, a + n / e, i + r / e, a + n, i, a + n]],
        ["C", [i - r / e, a + n, i - r, a + n / e, i - r, a]],
        ["Z", []]
      ]);
      break;
    }
    case "path":
      t = o.getAttribute("d");
      break;
    case "line": {
      const i = o.getAttribute("x1"), a = o.getAttribute("y1"), s = o.getAttribute("x2"), l = o.getAttribute("y2");
      t = `M${i},${a}L${s},${l}`;
      break;
    }
    case "polyline":
      t = `M${o.getAttribute("points")}`;
      break;
    case "polygon":
      t = `M${o.getAttribute("points")} Z`;
      break;
    case "rect": {
      r = Number(o.getAttribute("rx")), n = Number(o.getAttribute("ry"));
      const i = o.getBBox(), { x: a, y: s } = i, l = i.width, c = i.height;
      e = 4 - e, t = q0(!r && !n ? [
        ["M", [a, s]],
        ["L", [a + l, s]],
        ["L", [a + l, s + c]],
        ["L", [a, s + c]],
        ["L", [a, s]],
        ["Z", []]
      ] : [
        ["M", [a, s + n]],
        ["C", [a, s + n / e, a + r / e, s, a + r, s]],
        ["L", [a + l - r, s]],
        ["C", [a + l - r / e, s, a + l, s + n / e, a + l, s + n]],
        ["L", [a + l, s + c - n]],
        [
          "C",
          [
            a + l,
            s + c - n / e,
            a + l - r / e,
            s + c,
            a + l - r,
            s + c
          ]
        ],
        ["L", [a + r, s + c]],
        ["C", [a + r / e, s + c, a, s + c - n / e, a, s + c - n]],
        ["L", [a, s + n]],
        ["Z", []]
      ]);
      break;
    }
  }
  return t;
}, X5 = (o) => ["marker-start", "marker-end", "marker-mid", "filter", "clip-path"].reduce((e, t) => {
  const r = o.getAttribute(t);
  return r && (e[t] = r), e;
}, {}), sb = (o, e, t) => {
  const r = e({
    element: "path",
    attr: X5(o)
  }), n = o.getAttribute("transform");
  n && r.setAttribute("transform", n);
  const { parentNode: i } = o;
  o.nextSibling ? o.before(r) : i.append(r);
  const a = W5(o);
  a ? r.setAttribute("d", a) : r.remove(), t.resetOrientation(r);
  let s = !1;
  try {
    s = r.getBBox();
  } catch {
  }
  if (s && s.width === 0 && s.height === 0) {
    const l = ((r.getAttribute("d") || "").match(/-?\d*\.?\d+/g) || []).map(Number).filter((c) => !Number.isNaN(c));
    if (l.length >= 2) {
      const c = l.filter((A, p) => p % 2 === 0), u = l.filter((A, p) => p % 2 === 1);
      s = {
        x: Math.min(...c),
        y: Math.min(...u),
        width: Math.max(...c) - Math.min(...c),
        height: Math.max(...u) - Math.min(...u)
      };
    }
  }
  return r.remove(), s;
}, D4 = (o, e, t) => {
  const r = new t.history.BatchCommand("Convert element to Path");
  e = DA(e, X5(o));
  const n = t.addSVGElementsFromJson({
    element: "path",
    attr: e
  }), i = o.getAttribute("transform");
  i && n.setAttribute("transform", i);
  const { id: a } = o, { parentNode: s } = o;
  o.nextSibling ? o.before(n) : s.append(n);
  const l = W5(o);
  if (l) {
    if (n.setAttribute("d", l), i) {
      const u = hr(n);
      Ml(u) && t.pathActions.resetOrientation(n);
    }
    const { nextSibling: c } = o;
    return r.addSubCommand(
      new t.history.RemoveElementCommand(
        o,
        c,
        o.parentNode
      )
    ), t.clearSelection(), o.remove(), r.addSubCommand(new t.history.InsertElementCommand(n)), n.setAttribute("id", a), n.removeAttribute("visibility"), t.addToSelection([n], !0), t.addCommandToHistory(r), n;
  }
  return n.remove(), null;
}, H4 = (o, e) => {
  const t = o % 90, r = t < -89.99 || t > 89.99, n = t > -1e-3 && t < 1e-3;
  return e || !(n || r);
}, G0 = (o, e, t) => {
  let r = so(o);
  if (!r) return null;
  const n = o.getAttribute?.("transform") ?? "", i = n.includes("matrix(");
  if (n.includes("rotate(") && !i) {
    const c = n.match(/-?\d*\.?\d+/g)?.map(Number) || [], [u = 0, A = 0, p = 0] = c, d = u * Math.PI / 180, g = Math.cos(d), _ = Math.sin(d), f = o.tagName?.toLowerCase();
    let m = [];
    if (f === "path") {
      const b = ((o.getAttribute("d") || "").match(/-?\d*\.?\d+/g) || []).map(Number).filter((v) => !Number.isNaN(v));
      for (let v = 0; v < b.length; v += 2)
        m.push({ x: b[v], y: b[v + 1] ?? 0 });
    } else if (f === "rect") {
      const b = Number(o.getAttribute("x") ?? 0), v = Number(o.getAttribute("y") ?? 0), w = Number(o.getAttribute("width") ?? 0), C = Number(o.getAttribute("height") ?? 0);
      m = [
        { x: b, y: v },
        { x: b + w, y: v },
        { x: b, y: v + C },
        { x: b + w, y: v + C }
      ];
    }
    if (m.length) {
      const b = m.map((F) => {
        const B = F.x - A, P = F.y - p;
        return {
          x: A + (B * g - P * _),
          y: p + (B * _ + P * g)
        };
      }), v = b.map((F) => F.x), w = b.map((F) => F.y);
      let C = {
        x: Math.min(...v),
        y: Math.min(...w),
        width: Math.max(...v) - Math.min(...v),
        height: Math.max(...w) - Math.min(...w)
      };
      const E = n.match(/matrix\(([^)]+)\)/);
      if (E) {
        const F = E[1].split(/[,\s]+/).filter(Boolean).map(Number), B = F[4] ?? 0, P = F[5] ?? 0;
        C = { ...C, x: C.x + B, y: C.y + P };
      }
      const T = Math.abs(u % 90) < 1e-3;
      return f !== "path" && T && typeof e == "function" && e({ element: "path", attr: {} }), C;
    }
  }
  const a = hr(o), s = Z5(a), l = Ml(a);
  if (s || l) {
    let c = !1;
    if (H4(s, l)) {
      if (["ellipse", "path", "line", "polyline", "polygon"].includes(o.tagName)) {
        const u = sb(
          o,
          e,
          t
        );
        u && !(u.width === 0 && u.height === 0) && (c = u, r = u);
      } else if (o.tagName === "rect") {
        const u = Number(o.getAttribute("rx")), A = Number(o.getAttribute("ry"));
        if (u || A) {
          const p = sb(
            o,
            e,
            t
          );
          p && !(p.width === 0 && p.height === 0) && (c = p, r = p);
        }
      }
    }
    if (!c) {
      const { matrix: u } = lr(a);
      r = mv(r.x, r.y, r.width, r.height, u).aabox;
    }
  }
  return r;
}, V0 = (o) => {
  const e = o.getAttribute("stroke-width");
  return !isNaN(e) && o.getAttribute("stroke") !== "none" ? e / 2 : 0;
}, Y5 = (o, e, t) => {
  if (!o || !o.length)
    return !1;
  let r;
  if (o.forEach((l) => {
    r || l.parentNode && (r = G0(l, e, t));
  }), !r)
    return null;
  let n = r.x + r.width, i = r.y + r.height, a = r.x, s = r.y;
  if (o.length === 1) {
    const l = V0(o[0]);
    a -= l, s -= l, n += l, i += l;
  } else
    o.forEach((l) => {
      const c = G0(
        l,
        e,
        t
      );
      if (c) {
        const u = V0(l);
        a = Math.min(a, c.x - u), s = Math.min(s, c.y - u), l.nodeType === 1 && (n = Math.max(n, c.x + c.width + u), i = Math.max(i, c.y + c.height + u));
      }
    });
  return r.x = ai(a), r.y = ai(s), r.width = ai(n - a), r.height = ai(i - s), r;
}, KA = (o) => {
  if (!o) {
    const t = $a.getSvgContent();
    for (let r = 0; r < t.children.length; r++)
      if (t.children[r].getBBox) {
        const n = t.children[r].getBBox();
        if (n.width !== 0 && n.height !== 0 && n.width !== 0 && n.height !== 0) {
          o = t.children[r];
          break;
        }
      }
  }
  const e = [];
  if (o) {
    const t = o.children;
    Array.from(t, (r) => {
      r.getBBox && e.push(r);
    });
  }
  return e.reverse();
}, bi = (o) => (o || (o = KA()), Y5(
  o,
  $a.addSVGElementsFromJson,
  $a.pathActions
)), Z5 = (o, e) => {
  if (!o)
    return 0;
  for (let t = 0; t < o.numberOfItems; ++t) {
    const r = o.getItem(t);
    if (r.type === 4)
      return e ? r.angle * Math.PI / 180 : r.angle;
  }
  return 0;
};
let en = (o, e) => {
  const t = o || $a.getSelectedElements()[0], r = hr(t);
  return Z5(r, e);
};
const Gs = (o) => {
  if (!o) return null;
  const e = TA(o);
  if (!e) return null;
  const t = e[0] === "#" ? e.slice(1) : e;
  return wr(t);
}, lb = (o) => {
  if (o?.firstChild?.tagName === "feGaussianBlur")
    return o.firstChild;
  {
    const e = o.children;
    for (const [t, r] of Object.entries(e))
      if (r.tagName === "feGaussianBlur")
        return r;
  }
  return null;
}, wr = (o) => z5.querySelector(`#${o}`), br = (o, e, t, r) => {
  for (const [n, i] of Object.entries(e)) {
    const a = n.startsWith("xml:") ? vt.XML : n.startsWith("xlink:") ? vt.XLINK : null;
    if (i === void 0) {
      a ? o.removeAttributeNS(a, n) : o.removeAttribute(n);
      continue;
    }
    a ? o.setAttributeNS(a, n, i) : r ? L4(o, n, i) : o.setAttribute(n, i);
  }
}, Vh = (o) => {
  const e = {
    "fill-opacity": 1,
    "stop-opacity": 1,
    opacity: 1,
    stroke: "none",
    "stroke-dasharray": "none",
    "stroke-linejoin": "miter",
    "stroke-linecap": "butt",
    "stroke-opacity": 1,
    "stroke-width": 1,
    rx: 0,
    ry: 0
  };
  o.nodeName === "ellipse" && (delete e.rx, delete e.ry), Object.entries(e).forEach(([t, r]) => {
    o.getAttribute(t) === String(r) && o.removeAttribute(t);
  });
}, ar = (o) => {
  const e = $a.getBaseUnit();
  let t = $a.getSnappingStep();
  return e !== "px" && (t *= fv()[e]), o = Math.round(o / t) * t, o;
}, bv = (o) => {
  mh(o, (e) => {
    e.preventDefault();
  });
}, J5 = (o) => new DOMParser().parseFromString(o, "text/html").body.firstChild, z4 = (o, e, t = 0) => {
  const r = J5(e);
  t >= o.children.length ? o.appendChild(r) : o.insertBefore(r, o.children[t]);
}, eE = (o) => document.getElementById(o), tE = (o) => document.querySelector(o), rE = (o) => [...document.querySelectorAll(o)], mh = (o, e) => {
  o.addEventListener("click", e), o.addEventListener("touchend", e);
}, Zu = {
  BEFORE_APPLY: "before_apply",
  AFTER_APPLY: "after_apply",
  BEFORE_UNAPPLY: "before_unapply",
  AFTER_UNAPPLY: "after_unapply"
};
class Jc {
  /**
  * @returns {string}
  */
  getText() {
    return this.text;
  }
  /**
   * @param {module:history.HistoryEventHandler} handler
   * @param {callback} applyFunction
   * @returns {void}
  */
  apply(e, t) {
    e && e.handleHistoryEvent(Zu.BEFORE_APPLY, this), t(e), e && e.handleHistoryEvent(Zu.AFTER_APPLY, this);
  }
  /**
   * @param {module:history.HistoryEventHandler} handler
   * @param {callback} unapplyFunction
   * @returns {void}
  */
  unapply(e, t) {
    e && e.handleHistoryEvent(Zu.BEFORE_UNAPPLY, this), t(), e && e.handleHistoryEvent(Zu.AFTER_UNAPPLY, this);
  }
  /**
   * @returns {Element[]} Array with element associated with this command
   * This function needs to be surcharged if multiple elements are returned.
  */
  elements() {
    return [this.elem];
  }
  /**
    * @returns {string} String with element associated with this command
  */
  type() {
    return this.constructor.name;
  }
}
let oE = class extends Jc {
  /**
  * @param {Element} elem - The DOM element that was moved
  * @param {Element} oldNextSibling - The element's next sibling before it was moved
  * @param {Element} oldParent - The element's parent before it was moved
  * @param {string} [text] - An optional string visible to user related to this change
  */
  constructor(o, e, t, r) {
    super(), this.elem = o, this.text = r ? `Move ${o.tagName} to ${r}` : `Move ${o.tagName}`, this.oldNextSibling = e, this.oldParent = t, this.newNextSibling = o.nextSibling, this.newParent = o.parentNode;
  }
  /**
   * Re-positions the element.
   * @param {module:history.HistoryEventHandler} handler
   * @fires module:history~Command#event:history
   * @returns {void}
  */
  apply(o) {
    super.apply(o, () => {
      const e = this.newNextSibling && this.newNextSibling.parentNode === this.newParent ? this.newNextSibling : null;
      this.elem = this.newParent.insertBefore(this.elem, e);
    });
  }
  /**
   * Positions the element back to its original location.
   * @param {module:history.HistoryEventHandler} handler
   * @fires module:history~Command#event:history
   * @returns {void}
  */
  unapply(o) {
    super.unapply(o, () => {
      const e = this.oldNextSibling && this.oldNextSibling.parentNode === this.oldParent ? this.oldNextSibling : null;
      this.elem = this.oldParent.insertBefore(this.elem, e);
    });
  }
}, nE = class extends Jc {
  /**
   * @param {Element} elem - The newly added DOM element
   * @param {string} text - An optional string visible to user related to this change
  */
  constructor(o, e) {
    super(), this.elem = o, this.text = e || `Create ${o.tagName}`, this.parent = o.parentNode, this.nextSibling = this.elem.nextSibling;
  }
  /**
  * Re-inserts the new element.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  apply(o) {
    super.apply(o, () => {
      const e = this.nextSibling && this.nextSibling.parentNode === this.parent ? this.nextSibling : null;
      this.elem = this.parent.insertBefore(this.elem, e);
    });
  }
  /**
  * Removes the element.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  unapply(o) {
    super.unapply(o, () => {
      this.parent = this.elem.parentNode, this.elem.remove();
    });
  }
}, iE = class extends Jc {
  /**
  * @param {Element} elem - The removed DOM element
  * @param {Node} oldNextSibling - The DOM element's nextSibling when it was in the DOM
  * @param {Element} oldParent - The DOM element's parent
  * @param {string} [text] - An optional string visible to user related to this change
  */
  constructor(o, e, t, r) {
    super(), this.elem = o, this.text = r || `Delete ${o.tagName}`, this.nextSibling = e, this.parent = t;
  }
  /**
  * Re-removes the new element.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  apply(o) {
    super.apply(o, () => {
      this.parent = this.elem.parentNode, this.elem.remove();
    });
  }
  /**
  * Re-adds the new element.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  unapply(o) {
    super.unapply(o, () => {
      const e = this.nextSibling && this.nextSibling.parentNode === this.parent ? this.nextSibling : null;
      this.parent.insertBefore(this.elem, e);
    });
  }
}, eu = class extends Jc {
  /**
  * @param {Element} elem - The DOM element that was changed
  * @param {module:history.CommandAttributes} attrs - Attributes to be changed with the values they had *before* the change
  * @param {string} text - An optional string visible to user related to this change
   */
  constructor(o, e, t) {
    super(), this.elem = o, this.text = t ? `Change ${o.tagName} ${t}` : `Change ${o.tagName}`, this.newValues = {}, this.oldValues = e;
    for (const r in e)
      r === "#text" ? this.newValues[r] = o ? o.textContent : "" : r === "#href" ? this.newValues[r] = ca(o) : this.newValues[r] = o.getAttribute(r);
  }
  /**
  * Performs the stored change action.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  apply(o) {
    super.apply(o, () => {
      let e = !1;
      if (Object.entries(this.newValues).forEach(([t, r]) => {
        const n = r == null || r === "";
        t === "#text" ? this.elem.textContent = r == null ? "" : String(r) : t === "#href" ? n ? (this.elem.removeAttribute("href"), this.elem.removeAttributeNS(vt.XLINK, "href")) : vi(this.elem, String(r)) : n ? (this.elem.setAttribute(t, ""), this.elem.removeAttribute(t)) : this.elem.setAttribute(t, r), t === "transform" && (e = !0);
      }), !e) {
        const t = en(this.elem);
        if (t) {
          const r = so(this.elem);
          if (!r) return;
          const n = r.x + r.width / 2, i = r.y + r.height / 2, a = ["rotate(", t, " ", n, ",", i, ")"].join("");
          a !== this.elem.getAttribute("transform") && this.elem.setAttribute("transform", a);
        }
      }
    });
  }
  /**
  * Reverses the stored change action.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  unapply(o) {
    super.unapply(o, () => {
      let e = !1;
      if (Object.entries(this.oldValues).forEach(([t, r]) => {
        const n = r == null || r === "";
        t === "#text" ? this.elem.textContent = r == null ? "" : String(r) : t === "#href" ? n ? (this.elem.removeAttribute("href"), this.elem.removeAttributeNS(vt.XLINK, "href")) : vi(this.elem, String(r)) : n ? this.elem.removeAttribute(t) : this.elem.setAttribute(t, r), t === "transform" && (e = !0);
      }), !e) {
        const t = en(this.elem);
        if (t) {
          const r = so(this.elem);
          if (!r) return;
          const n = r.x + r.width / 2, i = r.y + r.height / 2, a = ["rotate(", t, " ", n, ",", i, ")"].join("");
          a !== this.elem.getAttribute("transform") && this.elem.setAttribute("transform", a);
        }
      }
    });
  }
}, $A = class extends Jc {
  /**
  * @param {string} [text] - An optional string visible to user related to this change
  */
  constructor(o) {
    super(), this.text = o || "Batch Command", this.stack = [];
  }
  /**
  * Runs "apply" on all subcommands.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  apply(o) {
    super.apply(o, () => {
      this.stack.forEach((e) => {
        console.assert(e, "stack item should not be null"), e && e.apply(o);
      });
    });
  }
  /**
  * Runs "unapply" on all subcommands.
  * @param {module:history.HistoryEventHandler} handler
  * @fires module:history~Command#event:history
  * @returns {void}
  */
  unapply(o) {
    super.unapply(o, () => {
      [...this.stack].reverse().forEach((e) => {
        console.assert(e, "stack item should not be null"), e && e.unapply(o);
      });
    });
  }
  /**
  * Iterate through all our subcommands.
  * @returns {Element[]} All the elements we are changing
  */
  elements() {
    const o = [];
    let e = this.stack.length;
    for (; e--; ) {
      if (!this.stack[e]) continue;
      const t = this.stack[e].elements();
      let r = t.length;
      for (; r--; )
        o.includes(t[r]) || o.push(t[r]);
    }
    return o;
  }
  /**
  * Adds a given command to the history stack.
  * @param {Command} cmd - The undo command object to add
  * @returns {void}
  */
  addSubCommand(o) {
    console.assert(o !== null, "cmd should not be null"), this.stack.push(o);
  }
  /**
  * @returns {boolean} Indicates whether or not the batch command is empty
  */
  isEmpty() {
    return !this.stack.length;
  }
}, K4 = class {
  /**
  * @param {module:history.HistoryEventHandler} historyEventHandler
  */
  constructor(o) {
    this.handler_ = o || null, this.undoStackPointer = 0, this.undoStack = [], this.undoChangeStackPointer = -1, this.undoableChangeStack = [];
  }
  /**
  * Resets the undo stack, effectively clearing the undo/redo history.
  * @returns {void}
  */
  resetUndoStack() {
    this.undoStack = [], this.undoStackPointer = 0;
  }
  /**
  * @returns {Integer} Current size of the undo history stack
  */
  getUndoStackSize() {
    return this.undoStackPointer;
  }
  /**
  * @returns {Integer} Current size of the redo history stack
  */
  getRedoStackSize() {
    return this.undoStack.length - this.undoStackPointer;
  }
  /**
  * @returns {string} String associated with the next undo command
  */
  getNextUndoCommandText() {
    return this.undoStackPointer > 0 ? this.undoStack[this.undoStackPointer - 1].getText() : "";
  }
  /**
  * @returns {string} String associated with the next redo command
  */
  getNextRedoCommandText() {
    return this.undoStackPointer < this.undoStack.length ? this.undoStack[this.undoStackPointer].getText() : "";
  }
  /**
  * Performs an undo step.
  * @returns {void}
  */
  undo() {
    this.undoStackPointer > 0 && this.undoStack[--this.undoStackPointer].unapply(this.handler_);
  }
  /**
  * Performs a redo step.
  * @returns {void}
  */
  redo() {
    this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0 && this.undoStack[this.undoStackPointer++].apply(this.handler_);
  }
  /**
  * Adds a command object to the undo history stack.
  * @param {Command} cmd - The command object to add
  * @returns {void}
  */
  addCommandToHistory(o) {
    this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0 && (this.undoStack = this.undoStack.splice(0, this.undoStackPointer)), this.undoStack.push(o), this.undoStackPointer = this.undoStack.length;
  }
  /**
  * This function tells the canvas to remember the old values of the
  * `attrName` attribute for each element sent in.  The elements and values
  * are stored on a stack, so the next call to `finishUndoableChange()` will
  * pop the elements and old values off the stack, gets the current values
  * from the DOM and uses all of these to construct the undo-able command.
  * @param {string} attrName - The name of the attribute being changed
  * @param {Element[]} elems - Array of DOM elements being changed
  * @returns {void}
  */
  beginUndoableChange(o, e) {
    const t = ++this.undoChangeStackPointer;
    let r = e.length;
    const n = new Array(r), i = new Array(r);
    for (; r--; ) {
      const a = e[r];
      a && (i[r] = a, n[r] = a.getAttribute(o));
    }
    this.undoableChangeStack[t] = {
      attrName: o,
      oldValues: n,
      elements: i
    };
  }
  /**
  * This function returns a `BatchCommand` object which summarizes the
  * change since `beginUndoableChange` was called.  The command can then
  * be added to the command history.
  * @returns {BatchCommand} Batch command object with resulting changes
  */
  finishUndoableChange() {
    const o = this.undoChangeStackPointer--, e = this.undoableChangeStack[o], { attrName: t } = e, r = new $A(`Change ${t}`);
    let n = e.elements.length;
    for (; n--; ) {
      const i = e.elements[n];
      if (!i)
        continue;
      const a = {};
      a[t] = e.oldValues[n], a[t] !== i.getAttribute(t) && r.addSubCommand(new eu(i, a, t));
    }
    return this.undoableChangeStack[o] = null, r;
  }
};
const Gl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  BatchCommand: $A,
  ChangeElementCommand: eu,
  Command: Jc,
  HistoryEventTypes: Zu,
  InsertElementCommand: nE,
  MoveElementCommand: oE,
  RemoveElementCommand: iE,
  UndoManager: K4
}, Symbol.toStringTag, { value: "Module" })), aE = {
  1: "Z",
  2: "M",
  3: "m",
  4: "L",
  5: "l",
  6: "C",
  7: "c",
  8: "Q",
  9: "q",
  10: "A",
  11: "a",
  12: "H",
  13: "h",
  14: "V",
  15: "v",
  16: "S",
  17: "s",
  18: "T",
  19: "t"
}, D0 = Object.fromEntries(
  Object.entries(aE).map(([o, e]) => [e, Number(o)])
);
class $4 {
  constructor(e) {
    this.elem = e;
  }
  _getData() {
    return this.elem.getPathData();
  }
  _setData(e) {
    this.elem.setPathData(e);
  }
  get numberOfItems() {
    return this._getData().length;
  }
  _entryToSeg(e) {
    const { type: t, values: r = [] } = e, n = { pathSegType: D0[t] || D0[t?.toUpperCase?.()] };
    switch (String(t).toUpperCase()) {
      case "H":
        [n.x] = r;
        break;
      case "V":
        [n.y] = r;
        break;
      case "M":
      case "L":
      case "T":
        [n.x, n.y] = r;
        break;
      case "S":
        [n.x2, n.y2, n.x, n.y] = r;
        break;
      case "C":
        [n.x1, n.y1, n.x2, n.y2, n.x, n.y] = r;
        break;
      case "Q":
        [n.x1, n.y1, n.x, n.y] = r;
        break;
      case "A":
        [
          n.r1,
          n.r2,
          n.angle,
          n.largeArcFlag,
          n.sweepFlag,
          n.x,
          n.y
        ] = r;
        break;
    }
    return n;
  }
  _segToEntry(e) {
    const t = aE[e.pathSegType] || e.type;
    if (!t)
      return { type: "Z", values: [] };
    const r = String(t).toUpperCase();
    let n = [];
    switch (r) {
      case "H":
        n = [e.x];
        break;
      case "V":
        n = [e.y];
        break;
      case "M":
      case "L":
      case "T":
        n = [e.x, e.y];
        break;
      case "S":
        n = [e.x2, e.y2, e.x, e.y];
        break;
      case "C":
        n = [e.x1, e.y1, e.x2, e.y2, e.x, e.y];
        break;
      case "Q":
        n = [e.x1, e.y1, e.x, e.y];
        break;
      case "A":
        n = [
          e.r1,
          e.r2,
          e.angle,
          Number(e.largeArcFlag),
          Number(e.sweepFlag),
          e.x,
          e.y
        ];
        break;
      default:
        n = [];
    }
    return { type: t, values: n };
  }
  getItem(e) {
    const t = this._getData()[e];
    return t ? this._entryToSeg(t) : null;
  }
  replaceItem(e, t) {
    const r = this._getData();
    return r[t] = this._segToEntry(e), this._setData(r), e;
  }
  insertItemBefore(e, t) {
    const r = this._getData();
    return r.splice(t, 0, this._segToEntry(e)), this._setData(r), e;
  }
  appendItem(e) {
    const t = this._getData();
    return t.push(this._segToEntry(e)), this._setData(t), e;
  }
  removeItem(e) {
    const t = this._getData();
    t.splice(e, 1), this._setData(t);
  }
  clear() {
    this._setData([]);
  }
}
typeof SVGPathElement < "u" && typeof SVGPathElement.prototype.getPathData == "function" && typeof SVGPathElement.prototype.setPathData == "function" && !("pathSegList" in SVGPathElement.prototype) && Object.defineProperty(SVGPathElement.prototype, "pathSegList", {
  get() {
    return this._pathSegListShim || (this._pathSegListShim = new $4(this)), this._pathSegListShim;
  }
});
let Co = null;
const W4 = (o) => {
  Co = o;
}, yh = (o, e) => Co.getSegData()[o].map((t) => e[t]), Rl = (o, e) => {
  const { path: t } = o;
  let r = {
    x: e ? e.x : o.item.x,
    y: e ? e.y : o.item.y
  };
  t.matrix && (r = cr(r.x, r.y, t.matrix));
  const n = Co.getZoom();
  return r.x *= n, r.y *= n, r;
}, sE = (o, e) => {
  const t = {
    x: o.x,
    y: o.y
  };
  e.matrix && (o = cr(t.x, t.y, e.imatrix), t.x = o.x, t.y = o.y);
  const r = Co.getZoom();
  return t.x /= r, t.y /= r, t;
}, Vl = () => {
  let o = wr("pathpointgrip_container");
  if (!o) {
    const e = wr("selectorParentGroup");
    o = document.createElementNS(vt.SVG, "g"), e.append(o), o.id = "pathpointgrip_container";
  }
  return o;
}, vv = (o, e, t) => {
  const r = Vl();
  let n = wr(`pathpointgrip_${o}`);
  if (!n) {
    n = document.createElementNS(vt.SVG, "circle");
    const i = {
      id: `pathpointgrip_${o}`,
      display: "none",
      r: 4,
      fill: "#0FF",
      stroke: "#00F",
      "stroke-width": 2,
      cursor: "move",
      style: "pointer-events:all"
    }, a = Co.getUIStrings();
    "pathNodeTooltip" in a && (i["xlink:title"] = a.pathNodeTooltip), br(n, i), r.append(n), document.getElementById("pathpointgrip_" + o)?.addEventListener("dblclick", () => {
      const s = Co.getPathObj();
      s && s.setSegType();
    });
  }
  return e && t && br(n, {
    cx: e,
    cy: t,
    display: "inline"
  }), n;
}, wv = (o) => {
  let e = wr("ctrlpointgrip_" + o);
  if (e)
    return e;
  e = document.createElementNS(vt.SVG, "circle");
  const t = {
    id: "ctrlpointgrip_" + o,
    display: "none",
    r: 4,
    fill: "#0FF",
    stroke: "#55F",
    "stroke-width": 1,
    cursor: "move",
    style: "pointer-events:all"
  }, r = Co.getUIStrings();
  return "pathCtrlPtTooltip" in r && (t["xlink:title"] = r.pathCtrlPtTooltip), br(e, t), Vl().append(e), e;
}, xv = (o) => {
  let e = wr("ctrlLine_" + o);
  return e || (e = document.createElementNS(vt.SVG, "line"), br(e, {
    id: "ctrlLine_" + o,
    stroke: "#555",
    "stroke-width": 1,
    style: "pointer-events:none"
  }), Vl().append(e), e);
}, lE = (o, e) => {
  const { index: t } = o, r = vv(t);
  if (e) {
    const n = Rl(o);
    br(r, {
      cx: n.x,
      cy: n.y,
      display: "inline"
    });
  }
  return r;
}, Xp = (o) => {
  const { item: e, index: t } = o;
  if (!("x1" in e) || !("x2" in e))
    return null;
  const r = {};
  Vl();
  const n = [Co.getPathObj().segs[t - 1].item, e];
  for (let i = 1; i < 3; i++) {
    const a = t + "c" + i, s = r[`c${i}_line`] = xv(a), l = Rl(o, { x: e["x" + i], y: e["y" + i] }), c = Rl(o, { x: n[i - 1].x, y: n[i - 1].y });
    br(s, {
      x1: l.x,
      y1: l.y,
      x2: c.x,
      y2: c.y,
      display: "inline"
    }), r[`c${i}_line`] = s;
    const u = r[`c${i}`] = wv(a);
    br(u, {
      cx: l.x,
      cy: l.y,
      display: "inline"
    }), r["c" + i] = u;
  }
  return r;
}, Vn = (o, e, t, r) => {
  const n = Co.getPathObj(), i = r || n.elem, a = "createSVGPathSeg" + Co.getPathFuncs()[o], s = Co.getSegData?.(), l = s?.[o] || s?.[o - 1];
  if (l && t.length < l.length) {
    const u = i.pathSegList?.getItem?.(e);
    u && (t = l.map((A, p) => t[p] !== void 0 ? t[p] : u[A]));
  }
  let c;
  if (typeof i[a] == "function")
    c = i[a](...t);
  else {
    const u = l || [];
    c = { pathSegType: o }, u.forEach((A, p) => {
      c[A] = t[p];
    });
  }
  i.pathSegList.replaceItem(c, e);
}, cb = (o, e) => {
  const { index: t } = o;
  let r = wr(`segline_${t}`);
  if (!r) {
    const n = Vl();
    r = document.createElementNS(vt.SVG, "path"), br(r, {
      id: `segline_${t}`,
      display: "none",
      fill: "none",
      stroke: "#0FF",
      "stroke-width": 2,
      style: "pointer-events:none",
      d: "M0,0 0,0"
    }), n.append(r);
  }
  if (e) {
    const { prev: n } = o;
    if (!n)
      return r.setAttribute("display", "none"), r;
    const i = Rl(n);
    Vn(2, 0, [i.x, i.y], r);
    const a = yh(o.type, o.item);
    for (let s = 0; s < a.length; s += 2) {
      const l = Rl(o, { x: a[s], y: a[s + 1] });
      a[s] = l.x, a[s + 1] = l.y;
    }
    Vn(o.type, 1, a, r);
  }
  return r;
};
class X4 {
  /**
  * @param {Integer} index
  * @param {SVGPathSeg} item
  * @todo Is `item` be more constrained here?
  */
  constructor(e, t) {
    this.selected = !1, this.index = e, this.item = t, this.type = t.pathSegType, this.ctrlpts = null, this.ptgrip = null, this.segsel = null;
  }
  /**
   * @param {boolean} y
   * @returns {void}
   */
  showCtrlPts(e) {
    for (const t in this.ctrlpts)
      ({}).hasOwnProperty.call(this.ctrlpts, t) && this.ctrlpts[t].setAttribute("display", e ? "inline" : "none");
  }
  /**
   * @param {boolean} y
   * @returns {void}
   */
  selectCtrls(e) {
    document.getElementById(`ctrlpointgrip_${this.index}c1`)?.setAttribute("fill", e ? "#0FF" : "#EEE"), document.getElementById(`ctrlpointgrip_${this.index}c2`)?.setAttribute("fill", e ? "#0FF" : "#EEE");
  }
  /**
   * @param {boolean} y
   * @returns {void}
   */
  show(e) {
    this.ptgrip && (this.ptgrip.setAttribute("display", e ? "inline" : "none"), this.segsel.setAttribute("display", e ? "inline" : "none"), this.showCtrlPts(e));
  }
  /**
   * @param {boolean} y
   * @returns {void}
   */
  select(e) {
    this.ptgrip && (this.ptgrip.setAttribute("stroke", e ? "#0FF" : "#00F"), this.segsel.setAttribute("display", e ? "inline" : "none"), this.ctrlpts && this.selectCtrls(e), this.selected = e);
  }
  /**
   * @returns {void}
   */
  addGrip() {
    this.ptgrip = lE(this, !0), this.ctrlpts = Xp(this), this.segsel = cb(this, !0);
  }
  /**
   * @param {boolean} full
   * @returns {void}
   */
  update(e) {
    if (this.ptgrip) {
      const t = Rl(this);
      if (br(this.ptgrip, {
        cx: t.x,
        cy: t.y
      }), cb(this, !0), this.ctrlpts) {
        if (e) {
          const r = Co.getPathObj();
          this.item = r.elem.pathSegList.getItem(this.index), this.type = this.item.pathSegType;
        }
        Xp(this);
      }
    }
  }
  /**
   * @param {Integer} dx
   * @param {Integer} dy
   * @returns {void}
   */
  move(e, t) {
    const { item: r } = this;
    r.x += e, r.y += t, "x2" in r && (r.x2 += e), "y2" in r && (r.y2 += t), Vn(
      this.type,
      this.index,
      yh(this.type, r)
    );
    const n = this.next?.item;
    if (n && "x1" in n && "y1" in n && (n.x1 += e, n.y1 += t, Vn(this.next.type, this.next.index, yh(this.next.type, n))), this.mate) {
      const { item: i } = this.mate, a = [i.x += e, i.y += t];
      Vn(this.mate.type, this.mate.index, a);
    }
    this.update(!0), this.next && this.next.update(!0);
  }
  /**
   * @param {Integer} num
   * @returns {void}
   */
  setLinked(e) {
    let t, r, n;
    if (e === 2) {
      if (r = 1, t = this.next, !t)
        return;
      n = this.item;
    } else {
      if (r = 2, t = this.prev, !t)
        return;
      n = t.item;
    }
    const { item: i } = t;
    i["x" + r] = n.x + (n.x - this.item["x" + e]), i["y" + r] = n.y + (n.y - this.item["y" + e]);
    const a = [
      i.x,
      i.y,
      i.x1,
      i.y1,
      i.x2,
      i.y2
    ];
    Vn(t.type, t.index, a), t.update(!0);
  }
  /**
   * @param {Integer} num
   * @param {Integer} dx
   * @param {Integer} dy
   * @returns {void}
   */
  moveCtrl(e, t, r) {
    const { item: n } = this;
    n["x" + e] += t, n["y" + e] += r;
    const i = [
      n.x,
      n.y,
      n.x1,
      n.y1,
      n.x2,
      n.y2
    ];
    Vn(this.type, this.index, i), this.update(!0);
  }
  /**
   * @param {Integer} newType Possible values set during {@link module:path.init}
   * @param {ArgumentsArray} pts
   * @returns {void}
   */
  setType(e, t) {
    Vn(e, this.index, t), this.type = e;
    const r = Co.getPathObj();
    this.item = r.elem.pathSegList.getItem(this.index), this.showCtrlPts(e === 6), this.ctrlpts = Xp(this), this.update(!0);
  }
}
class kv {
  /**
  * @param {SVGPathElement} elem
  * @throws {Error} If constructed without a path element
  */
  constructor(e) {
    if (!e || e.tagName !== "path")
      throw new Error("svgedit.path.Path constructed without a <path> element");
    this.elem = e, this.segs = [], this.selected_pts = [], Co.setPathObj(this), this.init();
  }
  setPathContext() {
    Co.setPathObj(this);
  }
  /**
  * Reset path data.
  * @returns {module:path.Path}
  */
  init() {
    const e = Vl().querySelectorAll("*");
    Array.prototype.forEach.call(e, function(a) {
      a.setAttribute("display", "none");
    });
    const t = this.elem.pathSegList, r = t.numberOfItems;
    this.segs = [], this.selected_pts = [], this.first_seg = null;
    for (let a = 0; a < r; a++) {
      const s = t.getItem(a), l = new X4(a, s);
      l.path = this, this.segs.push(l);
    }
    const { segs: n } = this;
    let i = null;
    for (let a = 0; a < r; a++) {
      const s = n[a], l = a + 1 >= r ? null : n[a + 1], c = a - 1 < 0 ? null : n[a - 1];
      if (s.type === 2) {
        if (c && c.type !== 1) {
          const u = n[i];
          u.next = n[i + 1], u.next.prev = u, u.addGrip();
        }
        i = a;
      } else if (l?.type === 1)
        s.next = n[i + 1], s.next.prev = s, s.mate = n[i], s.addGrip(), this.first_seg || (this.first_seg = s);
      else if (l)
        s.type !== 1 && (s.addGrip(), l && l.type !== 2 && (s.next = l, s.next.prev = s));
      else if (s.type !== 1) {
        const u = n[i];
        u.next = n[i + 1], u.next.prev = u, u.addGrip(), s.addGrip(), this.first_seg || (this.first_seg = n[i]);
      }
    }
    return this;
  }
  /**
  * @callback module:path.PathEachSegCallback
  * @this module:path.Segment
  * @param {Integer} i The index of the seg being iterated
  * @returns {boolean|void} Will stop execution of `eachSeg` if returns `false`
  */
  /**
  * @param {module:path.PathEachSegCallback} fn
  * @returns {void}
  */
  eachSeg(e) {
    const t = this.segs.length;
    for (let r = 0; r < t && e.call(this.segs[r], r) !== !1; r++)
      ;
  }
  /**
  * @param {Integer} index
  * @returns {void}
  */
  addSeg(e) {
    const t = this.segs[e];
    if (!t.prev)
      return;
    const { prev: r } = t;
    let n, i, a;
    switch (t.item.pathSegType) {
      case 4: {
        i = (t.item.x + r.item.x) / 2, a = (t.item.y + r.item.y) / 2, n = this.elem.createSVGPathSegLinetoAbs(i, a);
        break;
      }
      case 6: {
        const s = (r.item.x + t.item.x1) / 2, l = (t.item.x1 + t.item.x2) / 2, c = (t.item.x2 + t.item.x) / 2, u = (s + l) / 2, A = (l + c) / 2;
        i = (u + A) / 2;
        const p = (r.item.y + t.item.y1) / 2, d = (t.item.y1 + t.item.y2) / 2, g = (t.item.y2 + t.item.y) / 2, _ = (p + d) / 2, f = (d + g) / 2;
        a = (_ + f) / 2, n = this.elem.createSVGPathSegCurvetoCubicAbs(i, a, s, p, u, _);
        const m = [t.item.x, t.item.y, A, f, c, g];
        Vn(t.type, e, m);
        break;
      }
    }
    this.elem.pathSegList.insertItemBefore(n, e);
  }
  /**
  * @param {Integer} index
  * @returns {void}
  */
  deleteSeg(e) {
    const t = this.segs[e], r = this.elem.pathSegList;
    t.show(!1);
    const { next: n } = t;
    if (t.mate) {
      const i = [n.item.x, n.item.y];
      Vn(2, n.index, i), Vn(4, t.index, i), r.removeItem(t.mate.index);
    } else if (t.prev)
      r.removeItem(e);
    else {
      const i = [n.item.x, n.item.y];
      Vn(2, t.next.index, i), r.removeItem(e);
    }
  }
  /**
  * @param {Integer} index
  * @returns {void}
  */
  removePtFromSelection(e) {
    const t = this.selected_pts.indexOf(e);
    t !== -1 && (this.segs[e].select(!1), this.selected_pts.splice(t, 1));
  }
  /**
  * @returns {void}
  */
  clearSelection() {
    this.eachSeg(function() {
      this.select(!1);
    }), this.selected_pts = [];
  }
  /**
  * @returns {void}
  */
  storeD() {
    this.last_d = this.elem.getAttribute("d");
  }
  /**
  * @param {Integer} y
  * @returns {Path}
  */
  show(e) {
    return this.eachSeg(function() {
      this.show(e);
    }), e && this.selectPt(this.first_seg.index), this;
  }
  /**
  * Move selected points.
  * @param {Integer} dx
  * @param {Integer} dy
  * @returns {void}
  */
  movePts(e, t) {
    let r = this.selected_pts.length;
    for (; r--; )
      this.segs[this.selected_pts[r]].move(e, t);
  }
  /**
  * @param {Integer} dx
  * @param {Integer} dy
  * @returns {void}
  */
  moveCtrl(e, t) {
    const r = this.segs[this.selected_pts[0]];
    r.moveCtrl(this.dragctrl, e, t), Co.getLinkControlPts() && r.setLinked(this.dragctrl);
  }
  /**
  * @param {?Integer} newType See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}
  * @returns {void}
  */
  setSegType(e) {
    this.storeD();
    let t = this.selected_pts.length, r;
    for (; t--; ) {
      const n = this.selected_pts[t], i = this.segs[n], { prev: a } = i;
      if (!a)
        continue;
      e || (r = "Toggle Path Segment Type", e = i.type === 6 ? 4 : 6), e = Number(e);
      const s = i.item.x, l = i.item.y, c = a.item.x, u = a.item.y;
      let A;
      switch (e) {
        case 6: {
          if (i.olditem) {
            const p = i.olditem;
            A = [s, l, p.x1, p.y1, p.x2, p.y2];
          } else {
            const p = s - c, d = l - u, g = c + p / 3, _ = u + d / 3, f = s - p / 3, m = l - d / 3;
            A = [s, l, g, _, f, m];
          }
          break;
        }
        case 4: {
          A = [s, l], i.olditem = i.item;
          break;
        }
      }
      i.setType(e, A);
    }
    Co.getPathObj().endChanges(r);
  }
  /**
  * @param {Integer} pt
  * @param {Integer} ctrlNum
  * @returns {void}
  */
  selectPt(e, t) {
    this.clearSelection(), e || this.eachSeg(function(r) {
      this.prev && (e = r);
    }), this.addPtsToSelection(e), t && (this.dragctrl = t, Co.getLinkControlPts() && this.segs[e].setLinked(t));
  }
  /**
  * Update position of all points.
  * @returns {Path}
  */
  update() {
    const { elem: e } = this;
    return en(e) ? (this.matrix = D5(e), this.imatrix = this.matrix.inverse()) : (this.matrix = null, this.imatrix = null), this.eachSeg(function(t) {
      this.item = e.pathSegList.getItem(t), this.update();
    }), this;
  }
  /**
  * @param {string} text
  * @returns {void}
  */
  endChanges(e) {
    const t = new eu(this.elem, { d: this.last_d }, e);
    Co.endChanges({ cmd: t, elem: this.elem });
  }
  /**
  * @param {Integer|Integer[]} indexes
  * @returns {void}
  */
  addPtsToSelection(e) {
    Array.isArray(e) || (e = [e]), e.forEach((i) => {
      this.segs[i].ptgrip && !this.selected_pts.includes(i) && i >= 0 && this.selected_pts.push(i);
    }), this.selected_pts.sort();
    let t = this.selected_pts.length;
    const r = [];
    for (r.length = t; t--; ) {
      const i = this.selected_pts[t], a = this.segs[i];
      a.select(!0), r[t] = a.ptgrip;
    }
    const n = kv.subpathIsClosed(this.selected_pts[0]);
    Co.addPtsToSelection({ grips: r, closedSubpath: n });
  }
  // STATIC
  /**
  * @param {Integer} index
  * @returns {boolean}
  */
  static subpathIsClosed(e) {
    let t = !1;
    return Co.getPathObj().eachSeg(function(r) {
      return r <= e ? !0 : this.type === 2 ? !1 : this.type === 1 ? (t = !0, !1) : !0;
    }), t;
  }
}
let st = null, Ye = null;
const Y4 = (o) => {
  st = o;
}, Z4 = (o, e) => {
  const { pathSegList: t } = o, r = t.numberOfItems;
  let n = 0, i = 0, a = "", s = null;
  for (let l = 0; l < r; ++l) {
    const c = t.getItem(l);
    let u = c.x || 0, A = c.y || 0, p = c.x1 || 0, d = c.y1 || 0, g = c.x2 || 0, _ = c.y2 || 0, f = c.pathSegTypeAsLetter;
    switch (f) {
      case "z":
      // z,Z closepath (Z/z)
      case "Z":
        a += "z", s && (n = s[0], i = s[1]);
        break;
      case "H":
        u -= n;
      // Fallthrough
      case "h":
        e ? (A = 0, n += u, f = "l") : (A = i, u += n, n = u, f = "L"), a += gl(f, [[u, A]]);
        break;
      case "V":
        A -= i;
      // Fallthrough
      case "v":
        e ? (u = 0, i += A, f = "l") : (u = n, A += i, i = A, f = "L"), a += gl(f, [[u, A]]);
        break;
      case "M":
      // absolute move (M)
      case "L":
      // absolute line (L)
      case "T":
        u -= n, A -= i;
      // Fallthrough
      case "l":
      // relative line (l)
      case "m":
      // relative move (m)
      case "t":
        e ? (n += u, i += A, f = f.toLowerCase()) : (u += n, A += i, n = u, i = A, f = f.toUpperCase()), (f === "m" || f === "M") && (s = [n, i]), a += gl(f, [[u, A]]);
        break;
      case "C":
        u -= n, p -= n, g -= n, A -= i, d -= i, _ -= i;
      // Fallthrough
      case "c":
        e ? (n += u, i += A, f = "c") : (u += n, p += n, g += n, A += i, d += i, _ += i, n = u, i = A, f = "C"), a += gl(f, [[p, d], [g, _], [u, A]]);
        break;
      case "Q":
        u -= n, p -= n, A -= i, d -= i;
      // Fallthrough
      case "q":
        e ? (n += u, i += A, f = "q") : (u += n, p += n, A += i, d += i, n = u, i = A, f = "Q"), a += gl(f, [[p, d], [u, A]]);
        break;
      case "A":
        u -= n, A -= i;
      // fallthrough
      case "a":
        e ? (n += u, i += A, f = "a") : (u += n, A += i, n = u, i = A, f = "A"), a += gl(f, [[c.r1, c.r2]], [
          c.angle,
          c.largeArcFlag ? 1 : 0,
          c.sweepFlag ? 1 : 0
        ], [u, A]);
        break;
      case "S":
        u -= n, g -= n, A -= i, _ -= i;
      // Fallthrough
      case "s":
        e ? (n += u, i += A, f = "s") : (u += n, g += n, A += i, _ += i, n = u, i = A, f = "S"), a += gl(f, [[g, _], [u, A]]);
        break;
    }
  }
  return a;
}, gl = (o, e, t, r) => [
  o + e.map((n) => ai(n)).join(" "),
  t ? t.join(" ") : null,
  r ? ai(r) : null
].filter(Boolean).join(" ");
class J4 {
  #t = !1;
  #e = null;
  #r = null;
  #o = null;
  #a = !1;
  /**
  * This function converts a polyline (created by the fh_path tool) into
  * a path element and coverts every three line segments into a single bezier
  * curve in an attempt to smooth out the free-hand.
  * @function smoothPolylineIntoPath
  * @param {Element} element
  * @returns {Element}
  * @private
  */
  #n = (e) => {
    const { points: t } = e, r = t.numberOfItems;
    if (r >= 4) {
      let n = t.getItem(0), i = null, a = [];
      a.push(`M${n.x},${n.y} C`);
      let s;
      for (s = 1; s <= r - 4; s += 3) {
        let l = t.getItem(s);
        const c = t.getItem(s + 1), u = t.getItem(s + 2);
        if (i) {
          const A = st.smoothControlPoints(i, l, n);
          if (A?.length === 2) {
            const p = a[a.length - 1].split(",");
            p[2] = A[0].x, p[3] = A[0].y, a[a.length - 1] = p.join(","), l = A[1];
          }
        }
        a.push([l.x, l.y, c.x, c.y, u.x, u.y].join(",")), n = u, i = c;
      }
      for (a.push("L"); s < r; ) {
        const l = t.getItem(s);
        a.push([l.x, l.y].join(",")), s++;
      }
      a = a.join(" "), e = st.addSVGElementsFromJson({
        element: "path",
        curStyles: !0,
        attr: {
          id: st.getId(),
          d: a,
          fill: "none"
        }
      });
    }
    return e;
  };
  /**
  * @param {MouseEvent} evt
  * @param {Element} mouseTarget
  * @param {Float} startX
  * @param {Float} startY
  * @returns {boolean|void}
  */
  mouseDown(e, t, r, n) {
    let i;
    if (st.getCurrentMode() === "path") {
      let s = r, l = n;
      const c = st.getZoom();
      let u = s / c, A = l / c, p = wr("path_stretch_line");
      this.#e = [u, A], st.getGridSnapping() && (u = ar(u), A = ar(A), s = ar(s), l = ar(l)), p || (p = document.createElementNS(vt.SVG, "path"), br(p, {
        id: "path_stretch_line",
        stroke: "#22C",
        "stroke-width": "0.5",
        fill: "none"
      }), wr("selectorParentGroup").append(p)), p.setAttribute("display", "inline");
      let d = null, g;
      const _ = st.getDrawnPath();
      if (_) {
        const f = _.pathSegList;
        let m = f.numberOfItems;
        const b = 6 / c;
        let v = !1;
        for (; m; ) {
          m--;
          const F = f.getItem(m), B = F.x, P = F.y;
          if (u >= B - b && u <= B + b && A >= P - b && A <= P + b) {
            v = !0;
            break;
          }
        }
        i = st.getId(), st.removePath_(i);
        const w = wr(i);
        let C, E;
        const T = f.numberOfItems;
        if (v) {
          if (m <= 1 && T >= 2) {
            const F = f.getItem(0).x, B = f.getItem(0).y;
            E = p.pathSegList.getItem(1), C = E.pathSegType === 4 ? _.createSVGPathSegLinetoAbs(F, B) : _.createSVGPathSegCurvetoCubicAbs(F, B, E.x1 / c, E.y1 / c, F, B);
            const P = _.createSVGPathSegClosePath();
            f.appendItem(C), f.appendItem(P);
          } else if (T < 3)
            return d = !1, d;
          if (p.remove(), st.setDrawnPath(null), st.setStarted(!1), this.#t) {
            Ye.matrix && st.remapElement(w, {}, Ye.matrix.inverse());
            const F = w.getAttribute("d"), B = Ye.elem.getAttribute("d");
            return Ye.elem.setAttribute("d", B + F), w.parentNode.removeChild(w), Ye.matrix && st.recalcRotatedPath(), na.toEditMode(Ye.elem), Ye.selectPt(), !1;
          }
        } else {
          if (!(st.getContainer() !== st.getMouseTarget(e) && st.getContainer().contains(
            st.getMouseTarget(e)
          )))
            return !1;
          const F = _.pathSegList.numberOfItems, B = _.pathSegList.getItem(F - 1), P = B.x, S = B.y;
          e.shiftKey && ({ x: u, y: A } = ab(P, S, u, A)), E = p.pathSegList.getItem(1), C = E.pathSegType === 4 ? _.createSVGPathSegLinetoAbs(st.round(u), st.round(A)) : _.createSVGPathSegCurvetoCubicAbs(
            st.round(u),
            st.round(A),
            E.x1 / c,
            E.y1 / c,
            E.x2 / c,
            E.y2 / c
          ), _.pathSegList.appendItem(C), u *= c, A *= c, p.setAttribute("d", ["M", u, A, u, A].join(" ")), g = F, this.#t && (g += Ye.segs.length), st.addPointGrip(g, u, A);
        }
      } else {
        const f = `M${u},${A} `;
        st.setDrawnPath(st.addSVGElementsFromJson({
          element: "path",
          curStyles: !0,
          attr: {
            d: f,
            id: st.getNextId(),
            opacity: st.getOpacity() / 2
          }
        })), p.setAttribute("d", `M${s} ${l} ${s} ${l}`), g = this.#t ? Ye.segs.length : 0, st.addPointGrip(g, s, l);
      }
      return;
    }
    if (!Ye)
      return;
    Ye.storeD(), { id: i } = e.target;
    let a;
    if (i.startsWith("pathpointgrip_")) {
      a = Ye.cur_pt = Number.parseInt(i.slice(14)), Ye.dragging = [r, n];
      const s = Ye.segs[a];
      e.shiftKey ? s.selected ? Ye.removePtFromSelection(a) : Ye.addPtsToSelection(a) : ((Ye.selected_pts.length <= 1 || !s.selected) && Ye.clearSelection(), Ye.addPtsToSelection(a));
    } else if (i.startsWith("ctrlpointgrip_")) {
      Ye.dragging = [r, n];
      const s = i.split("_")[1].split("c");
      a = Number(s[0]);
      const l = Number(s[1]);
      Ye.selectPt(a, l);
    }
    if (!Ye.dragging) {
      let s = st.getRubberBox();
      s || (s = st.setRubberBox(
        st.selectorManager.getRubberBandBox()
      ));
      const l = st.getZoom();
      br(s, {
        x: r * l,
        y: n * l,
        width: 0,
        height: 0,
        display: "inline"
      });
    }
  }
  /**
    * @param {Float} mouseX
    * @param {Float} mouseY
    * @returns {void}
    */
  mouseMove(e, t) {
    const r = st.getZoom();
    this.#a = !0;
    const n = st.getDrawnPath();
    if (st.getCurrentMode() === "path") {
      if (!n)
        return;
      const i = n.pathSegList, a = i.numberOfItems - 1;
      if (this.#e) {
        const s = st.addCtrlGrip("1c1"), l = st.addCtrlGrip("0c2");
        s.setAttribute("cx", e), s.setAttribute("cy", t), s.setAttribute("display", "inline");
        const c = this.#e[0], u = this.#e[1], A = e / r, p = t / r, d = c + (c - A), g = u + (u - p);
        l.setAttribute("cx", d * r), l.setAttribute("cy", g * r), l.setAttribute("display", "inline");
        const _ = st.getCtrlLine(1);
        if (br(_, {
          x1: e,
          y1: t,
          x2: d * r,
          y2: g * r,
          display: "inline"
        }), a === 0)
          this.#r = [e, t];
        else {
          const f = i.getItem(a - 1);
          let m = f.x, b = f.y;
          f.pathSegType === 6 ? (m += m - f.x2, b += b - f.y2) : this.#r && (m = this.#r[0] / r, b = this.#r[1] / r), st.replacePathSeg(6, a, [c, u, m, b, d, g], n);
        }
      } else {
        const s = wr("path_stretch_line");
        if (s) {
          const l = i.getItem(a);
          if (l.pathSegType === 6) {
            const c = l.x + (l.x - l.x2), u = l.y + (l.y - l.y2);
            st.replacePathSeg(
              6,
              1,
              [e, t, c * r, u * r, e, t],
              s
            );
          } else this.#r ? st.replacePathSeg(6, 1, [e, t, this.#r[0], this.#r[1], e, t], s) : st.replacePathSeg(4, 1, [e, t], s);
        }
      }
      return;
    }
    if (Ye.dragging) {
      const i = st.getPointFromGrip({
        x: Ye.dragging[0],
        y: Ye.dragging[1]
      }, Ye), a = st.getPointFromGrip({
        x: e,
        y: t
      }, Ye), s = a.x - i.x, l = a.y - i.y;
      Ye.dragging = [e, t], Ye.dragctrl ? Ye.moveCtrl(s, l) : Ye.movePts(s, l);
    } else
      Ye.selected_pts = [], Ye.eachSeg(function(i) {
        const a = this;
        if (!a.next && !a.prev) return;
        const s = st.getRubberBox(), l = so(s), c = st.getGripPt(a), u = {
          x: c.x,
          y: c.y,
          width: 0,
          height: 0
        }, A = H5(l, u);
        this.select(A), A && Ye.selected_pts.push(a.index);
      });
  }
  /**
     * @typedef module:path.keepElement
     * @type {PlainObject}
     * @property {boolean} keep
     * @property {Element} element
     */
  /**
    * @param {Event} evt
    * @param {Element} element
    * @param {Float} _mouseX
    * @param {Float} _mouseY
    * @returns {module:path.keepElement|void}
    */
  mouseUp(e, t, r, n) {
    const i = st.getDrawnPath();
    if (st.getCurrentMode() === "path")
      return this.#e = null, i || (t = wr(st.getId()), st.setStarted(!1), this.#r = null), {
        keep: !0,
        element: t
      };
    const a = st.getRubberBox();
    if (Ye.dragging) {
      const s = Ye.cur_pt;
      Ye.dragging = !1, Ye.dragctrl = !1, Ye.update(), this.#a && Ye.endChanges("Move path point(s)"), !e.shiftKey && !this.#a && Ye.selectPt(s);
    } else a?.getAttribute("display") !== "none" ? (a.setAttribute("display", "none"), a.getAttribute("width") <= 2 && a.getAttribute("height") <= 2 && na.toSelectMode(e.target)) : na.toSelectMode(e.target);
    this.#a = !1;
  }
  /**
    * @param {Element} element
    * @returns {void}
    */
  toEditMode(e) {
    Ye = st.getPath_(e), st.setCurrentMode("pathedit"), st.clearSelection(), Ye.setPathContext(), Ye.show(!0).update(), Ye.oldbbox = so(Ye.elem), this.#t = !1;
  }
  /**
    * @param {Element} elem
    * @fires module:svgcanvas.SvgCanvas#event:selected
    * @returns {void}
    */
  toSelectMode(e) {
    const t = e === Ye.elem;
    st.setCurrentMode("select"), Ye.setPathContext(), Ye.show(!1), this.#o = !1, st.clearSelection(), Ye.matrix && st.recalcRotatedPath(), t && (st.call("selected", [e]), st.addToSelection([e], !0));
  }
  /**
    * @param {boolean} on
    * @returns {void}
    */
  addSubPath(e) {
    e ? (st.setCurrentMode("path"), this.#t = !0) : (na.clear(!0), na.toEditMode(Ye.elem));
  }
  /**
    * @param {Element} target
    * @returns {void}
    */
  select(e) {
    this.#o === e ? (na.toEditMode(e), st.setCurrentMode("pathedit")) : this.#o = e;
  }
  /**
    * @fires module:svgcanvas.SvgCanvas#event:changed
    * @returns {void}
    */
  reorient() {
    const e = st.getSelectedElements()[0];
    if (!e || e.nodeName !== "path" || en(e) === 0)
      return;
    const t = new $A("Reorient path"), r = {
      d: e.getAttribute("d"),
      transform: e.getAttribute("transform")
    };
    t.addSubCommand(new eu(e, r)), st.clearSelection(), this.resetOrientation(e), st.addCommandToHistory(t), st.getPath_(e).show(!1).matrix = null, this.clear(), st.addToSelection([e], !0), st.call("changed", st.getSelectedElements());
  }
  /**
    * @param {boolean} remove Not in use
    * @returns {void}
    */
  clear() {
    const e = st.getDrawnPath();
    if (this.#o = null, e) {
      const t = wr(st.getId()), r = wr("path_stretch_line");
      r.parentNode.removeChild(r), t.parentNode.removeChild(t);
      const n = wr("pathpointgrip_container").querySelectorAll("*");
      for (const i of n)
        i.setAttribute("display", "none");
      this.#r = null, st.setDrawnPath(null), st.setStarted(!1);
    } else st.getCurrentMode() === "pathedit" && this.toSelectMode();
    Ye && Ye.init().show(!1);
  }
  /**
    * @param {?(Element|SVGPathElement)} pth
    * @returns {false|void}
    */
  resetOrientation(e) {
    if (e?.nodeName !== "path")
      return !1;
    const t = hr(e), r = lr(t).matrix;
    t.clear(), e.removeAttribute("transform");
    const n = e.pathSegList, i = n.numberOfItems;
    for (let a = 0; a < i; ++a) {
      const s = n.getItem(a), l = s.pathSegType;
      if (l === 1)
        continue;
      const c = [];
      for (const u of ["", 1, 2]) {
        const A = s["x" + u], p = s["y" + u];
        if (A !== void 0 && p !== void 0) {
          const d = cr(A, p, r);
          c.push(d.x, d.y);
        }
      }
      st.replacePathSeg(l, a, c, e);
    }
    st.reorientGrads(e, r);
  }
  /**
    * @returns {void}
    */
  zoomChange() {
    st.getCurrentMode() === "pathedit" && Ye.update();
  }
  /**
    * @typedef {PlainObject} module:path.NodePoint
    * @property {Float} x
    * @property {Float} y
    * @property {Integer} type
    */
  /**
    * @returns {module:path.NodePoint}
    */
  getNodePoint() {
    const e = Ye.selected_pts.length ? Ye.selected_pts[0] : 1, t = Ye.segs[e];
    return {
      x: t.item.x,
      y: t.item.y,
      type: t.type
    };
  }
  /**
    * @param {boolean} linkPoints
    * @returns {void}
    */
  linkControlPoints(e) {
    st.setLinkControlPoints(e);
  }
  /**
    * @returns {void}
    */
  clonePathNode() {
    Ye.storeD();
    const e = Ye.selected_pts;
    let t = e.length;
    const r = [];
    for (; t--; ) {
      const n = e[t];
      Ye.addSeg(n), r.push(n + t), r.push(n + t + 1);
    }
    Ye.init().addPtsToSelection(r), Ye.endChanges("Clone path node(s)");
  }
  /**
    * @returns {void}
    */
  opencloseSubPath() {
    const e = Ye.selected_pts;
    if (e.length !== 1)
      return;
    const { elem: t } = Ye, r = t.pathSegList, n = e[0];
    let i = null, a = null;
    if (Ye.eachSeg(function(A) {
      return this.type === 2 && A <= n && (a = this.item), A <= n ? !0 : this.type === 2 ? (i = A, !1) : this.type === 1 ? (i = !1, !1) : !0;
    }), i || (i = Ye.segs.length - 1), i !== !1) {
      const A = t.createSVGPathSegLinetoAbs(a.x, a.y), p = t.createSVGPathSegClosePath();
      i === Ye.segs.length - 1 ? (r.appendItem(A), r.appendItem(p)) : (r.insertItemBefore(p, i), r.insertItemBefore(A, i)), Ye.init().selectPt(i + 1);
      return;
    }
    if (Ye.segs[n].mate) {
      r.removeItem(n), r.removeItem(n), Ye.init().selectPt(n - 1);
      return;
    }
    let s, l;
    for (let A = 0; A < r.numberOfItems; A++) {
      const p = r.getItem(A);
      if (p.pathSegType === 2)
        s = A;
      else if (A === n)
        r.removeItem(s);
      else if (p.pathSegType === 1 && n < A) {
        l = A - 1, r.removeItem(A);
        break;
      }
    }
    let c = n - s - 1;
    for (; c--; )
      r.insertItemBefore(r.getItem(s), l);
    const u = r.getItem(s);
    st.replacePathSeg(2, s, [u.x, u.y]), Ye.init().selectPt(0);
  }
  /**
    * @returns {void}
    */
  deletePathNode() {
    if (!na.canDeleteNodes)
      return;
    Ye.storeD();
    const e = Ye.selected_pts;
    let t = e.length;
    for (; t--; ) {
      const n = e[t];
      Ye.deleteSeg(n);
    }
    const r = () => {
      const n = Ye.elem.pathSegList;
      let i = n.numberOfItems;
      const a = (s, l) => {
        for (; l--; )
          n.removeItem(s);
      };
      if (i <= 1)
        return !0;
      for (; i--; ) {
        const s = n.getItem(i);
        if (s.pathSegType === 1) {
          const l = n.getItem(i - 1), c = n.getItem(i - 2);
          if (l.pathSegType === 2) {
            a(i - 1, 2), r();
            break;
          } else if (c.pathSegType === 2) {
            a(i - 2, 3), r();
            break;
          }
        } else if (s.pathSegType === 2 && i > 0) {
          const l = n.getItem(i - 1).pathSegType;
          if (l === 2) {
            a(i - 1, 1), r();
            break;
          } else if (l === 1 && n.numberOfItems - 1 === i) {
            a(i, 1), r();
            break;
          }
        }
      }
      return !1;
    };
    if (r(), Ye.elem.pathSegList.numberOfItems <= 1) {
      na.toSelectMode(Ye.elem), st.canvas.deleteSelectedElements();
      return;
    }
    Ye.init(), Ye.clearSelection(), window.opera && Ye.elem.setAttribute("d", Ye.elem.getAttribute("d")), Ye.endChanges("Delete path node(s)");
  }
  // Can't seem to use `@borrows` here, so using `@see`
  /**
  * Smooth polyline into path.
  * @function module:path.pathActions.smoothPolylineIntoPath
  * @see module:path~smoothPolylineIntoPath
  */
  smoothPolylineIntoPath(e) {
    return this.#n(e);
  }
  /* eslint-enable  */
  /**
  * @param {?Integer} v See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}
  * @returns {void}
  */
  setSegType(e) {
    Ye?.setSegType(e);
  }
  /**
  * @param {string} attr
  * @param {Float} newValue
  * @returns {void}
  */
  moveNode(e, t) {
    const r = Ye.selected_pts;
    if (!r.length)
      return;
    Ye.storeD();
    const n = Ye.segs[r[0]], i = { x: 0, y: 0 };
    i[e] = t - n.item[e], n.move(i.x, i.y), Ye.endChanges("Move path point");
  }
  /**
  * @param {Element} elem
  * @returns {void}
  */
  fixEnd(e) {
    const t = e.pathSegList, r = t.numberOfItems;
    let n;
    for (let i = 0; i < r; ++i) {
      const a = t.getItem(i);
      if (a.pathSegType === 2 && (n = a), a.pathSegType === 1) {
        const s = t.getItem(i - 1);
        if (s.x !== n.x || s.y !== n.y) {
          const l = e.createSVGPathSegLinetoAbs(n.x, n.y);
          t.insertItemBefore(l, i), na.fixEnd(e);
          break;
        }
      }
    }
  }
  // Can't seem to use `@borrows` here, so using `@see`
  /**
  * Convert a path to one with only absolute or relative values.
  * @function module:path.pathActions.convertPath
  * @see module:path.convertPath
  */
  convertPath(e, t) {
    return Z4(e, t);
  }
}
const na = new J4(), cE = {
  2: ["x", "y"],
  // PATHSEG_MOVETO_ABS
  4: ["x", "y"],
  // PATHSEG_LINETO_ABS
  6: ["x", "y", "x1", "y1", "x2", "y2"],
  // PATHSEG_CURVETO_CUBIC_ABS
  8: ["x", "y", "x1", "y1"],
  // PATHSEG_CURVETO_QUADRATIC_ABS
  10: ["x", "y", "r1", "r2", "angle", "largeArcFlag", "sweepFlag"],
  // PATHSEG_ARC_ABS
  12: ["x"],
  // PATHSEG_LINETO_HORIZONTAL_ABS
  14: ["y"],
  // PATHSEG_LINETO_VERTICAL_ABS
  16: ["x", "y", "x2", "y2"],
  // PATHSEG_CURVETO_CUBIC_SMOOTH_ABS
  18: ["x", "y"]
  // PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS
};
let oo;
const uE = {}, AE = (o) => {
  Object.assign(uE, o.ui);
};
let ep = [], dE = !0, PA = {};
const pE = (o) => {
  dE = o;
};
let FA = null;
const hE = (o) => {
  oo = o, oo.replacePathSeg = Vn, oo.addPointGrip = vv, oo.removePath_ = Cv, oo.getPath_ = mE, oo.addCtrlGrip = wv, oo.getCtrlLine = xv, oo.getGripPt = gE, oo.getPointFromGrip = sE, oo.setLinkControlPoints = pE, oo.reorientGrads = vE, oo.recalcRotatedPath = yE, oo.getSegData = () => cE, oo.getUIStrings = () => uE, oo.getPathObj = () => FA, oo.setPathObj = (e) => {
    FA = e;
  }, oo.getPathFuncs = () => ep, oo.getLinkControlPts = () => dE, ep = [0, "ClosePath"], [
    "Moveto",
    "Lineto",
    "CurvetoCubic",
    "CurvetoQuadratic",
    "Arc",
    "LinetoHorizontal",
    "LinetoVertical",
    "CurvetoCubicSmooth",
    "CurvetoQuadraticSmooth"
  ].forEach((e) => {
    ep.push(e + "Abs"), ep.push(e + "Rel");
  }), Y4(oo), W4(oo);
}, eI = yh, gE = Rl, tI = sE, rI = vv, oI = Vl, nI = wv, iI = xv, aI = lE, sI = Xp, _E = Vn, lI = cb, fE = (o, e, t) => {
  const r = o.x - t.x, n = o.y - t.y, i = e.x - t.x, a = e.y - t.y;
  if ((r !== 0 || n !== 0) && (i !== 0 || a !== 0)) {
    const s = Math.sqrt(r * r + n * n), l = Math.sqrt(i * i + a * a), c = oo.getSvgRoot().createSVGPoint(), u = oo.getSvgRoot().createSVGPoint();
    let A = Math.atan2(n, r), p = Math.atan2(a, i);
    A < 0 && (A += 2 * Math.PI), p < 0 && (p += 2 * Math.PI);
    const d = Math.abs(A - p), g = Math.abs(Math.PI - d) / 2;
    let _, f;
    return A - p > 0 ? (_ = d < Math.PI ? A + g : A - g, f = d < Math.PI ? p - g : p + g) : (_ = d < Math.PI ? A - g : A + g, f = d < Math.PI ? p + g : p - g), c.x = s * Math.cos(_) + t.x, c.y = s * Math.sin(_) + t.y, u.x = l * Math.cos(f) + t.x, u.y = l * Math.sin(f) + t.y, [c, u];
  }
}, mE = (o) => {
  let e = PA[o.id];
  return e || (e = PA[o.id] = new kv(o)), e;
}, Cv = (o) => {
  o in PA && delete PA[o];
};
let Lc, Tc, fA, mA, Pc;
const h_ = (o, e) => {
  let t = o - fA, r = e - mA, n = Math.sqrt(t * t + r * r), i = Math.atan2(r, t) + Pc;
  return t = n * Math.cos(i) + fA, r = n * Math.sin(i) + mA, t -= Lc, r -= Tc, n = Math.sqrt(t * t + r * r), i = Math.atan2(r, t) - Pc, {
    x: n * Math.cos(i) + Lc,
    y: n * Math.sin(i) + Tc
  };
}, yE = () => {
  const o = FA?.elem;
  if (!o || (Pc = en(o, !0), !Pc))
    return;
  const e = FA.oldbbox;
  if (!e)
    return;
  fA = e.x + e.width / 2, mA = e.y + e.height / 2;
  const t = so(o);
  if (!t)
    return;
  Lc = t.x + t.width / 2, Tc = t.y + t.height / 2;
  const r = Lc - fA, n = Tc - mA, i = Math.sqrt(r * r + n * n), a = Math.atan2(n, r) + Pc;
  Lc = i * Math.cos(a) + fA, Tc = i * Math.sin(a) + mA;
  const s = o.pathSegList;
  if (!s)
    return;
  let l = s.numberOfItems;
  for (; l; ) {
    l -= 1;
    const A = s.getItem(l), p = A.pathSegType;
    if (p === 1)
      continue;
    const d = cE[p];
    if (!d)
      continue;
    const g = {};
    if (A.x !== null && A.x !== void 0 && A.y !== null && A.y !== void 0) {
      const f = h_(A.x, A.y);
      g.x = f.x, g.y = f.y;
    }
    if (A.x1 !== null && A.x1 !== void 0 && A.y1 !== null && A.y1 !== void 0) {
      const f = h_(A.x1, A.y1);
      g.x1 = f.x, g.y1 = f.y;
    }
    if (A.x2 !== null && A.x2 !== void 0 && A.y2 !== null && A.y2 !== void 0) {
      const f = h_(A.x2, A.y2);
      g.x2 = f.x, g.y2 = f.y;
    }
    const _ = d.map((f) => Object.prototype.hasOwnProperty.call(g, f) ? g[f] : A[f] ?? 0);
    _E(p, l, _);
  }
  so(o);
  const c = oo.getSvgRoot().createSVGTransform(), u = hr(o);
  u && (c.setRotate(Pc * 180 / Math.PI, Lc, Tc), u.numberOfItems ? typeof u.replaceItem == "function" ? u.replaceItem(c, 0) : (u.removeItem(0), u.insertItemBefore(c, 0)) : u.appendItem(c));
}, bE = () => {
  PA = {};
}, vE = (o, e) => {
  const t = so(o);
  for (let r = 0; r < 2; r++) {
    const n = r === 0 ? "fill" : "stroke", i = o.getAttribute(n);
    if (i && i.startsWith("url(")) {
      const a = Gs(i);
      if (a.tagName === "linearGradient") {
        let s = a.getAttribute("x1") || 0, l = a.getAttribute("y1") || 0, c = a.getAttribute("x2") || 1, u = a.getAttribute("y2") || 0;
        s = t.width * s + t.x, l = t.height * l + t.y, c = t.width * c + t.x, u = t.height * u + t.y;
        const A = cr(s, l, e), p = cr(c, u, e), d = {
          x1: (A.x - t.x) / t.width,
          y1: (A.y - t.y) / t.height,
          x2: (p.x - t.x) / t.width,
          y2: (p.y - t.y) / t.height
        }, g = a.cloneNode(!0);
        for (const [_, f] of Object.entries(d))
          g.setAttribute(_, f);
        g.id = oo.getNextId(), Dn().append(g), o.setAttribute(n, `url(#${g.id})`);
      }
    }
  }
}, cI = [
  0,
  "z",
  "M",
  "m",
  "L",
  "l",
  "C",
  "c",
  "Q",
  "q",
  "A",
  "a",
  "H",
  "h",
  "V",
  "v",
  "S",
  "s",
  "T",
  "t"
], uI = (o, e) => {
  const { pathSegList: t } = o, r = t.numberOfItems;
  let n = 0, i = 0, a = "", s = null;
  for (let l = 0; l < r; ++l) {
    const c = t.getItem(l);
    let u = c.x || 0, A = c.y || 0, p = c.x1 || 0, d = c.y1 || 0, g = c.x2 || 0, _ = c.y2 || 0;
    const f = c.pathSegType;
    let m = cI[f][e ? "toLowerCase" : "toUpperCase"]();
    switch (f) {
      case 1:
        a += "z", s && (n = s[0], i = s[1]);
        break;
      case 12:
        u -= n;
      // Fallthrough
      case 13:
        e ? (A = 0, n += u, m = "l") : (A = i, u += n, n = u, m = "L"), a += _l(m, [[u, A]]);
        break;
      case 14:
        A -= i;
      // Fallthrough
      case 15:
        e ? (u = 0, i += A, m = "l") : (u = n, A += i, i = A, m = "L"), a += _l(m, [[u, A]]);
        break;
      case 2:
      // absolute move (M)
      case 4:
      // absolute line (L)
      case 18:
      // absolute smooth quad (T)
      case 10:
        u -= n, A -= i;
      // Fallthrough
      case 5:
      // relative line (l)
      case 3:
      // relative move (m)
      case 19:
        e ? (n += u, i += A) : (u += n, A += i, n = u, i = A), (f === 2 || f === 3) && (s = [n, i]), a += _l(m, [[u, A]]);
        break;
      case 6:
        u -= n, p -= n, g -= n, A -= i, d -= i, _ -= i;
      // Fallthrough
      case 7:
        e ? (n += u, i += A) : (u += n, p += n, g += n, A += i, d += i, _ += i, n = u, i = A), a += _l(m, [[p, d], [g, _], [u, A]]);
        break;
      case 8:
        u -= n, p -= n, A -= i, d -= i;
      // Fallthrough
      case 9:
        e ? (n += u, i += A) : (u += n, p += n, A += i, d += i, n = u, i = A), a += _l(m, [[p, d], [u, A]]);
        break;
      // Fallthrough
      case 11:
        e ? (n += u, i += A) : (u += n, A += i, n = u, i = A), a += _l(m, [[c.r1, c.r2]], [
          c.angle,
          c.largeArcFlag ? 1 : 0,
          c.sweepFlag ? 1 : 0
        ], [u, A]);
        break;
      case 16:
        u -= n, g -= n, A -= i, _ -= i;
      // Fallthrough
      case 17:
        e ? (n += u, i += A) : (u += n, g += n, A += i, _ += i, n = u, i = A), a += _l(m, [[g, _], [u, A]]);
        break;
    }
  }
  return a;
}, _l = (o, e, t, r) => {
  e.forEach((i, a) => {
    e[a] = ai(i);
  });
  let n = o + e.join(" ");
  return t && (n += ` ${t.join(" ")}`), r && (n += ` ${ai(r)}`), n;
}, AI = na, wE = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  addCtrlGrip: nI,
  addPointGrip: rI,
  clearData: bE,
  convertPath: uI,
  getControlPoints: sI,
  getCtrlLine: iI,
  getGripContainer: oI,
  getGripPt: gE,
  getPath_: mE,
  getPointFromGrip: tI,
  getPointGrip: aI,
  getSegSelector: lI,
  init: hE,
  get path() {
    return FA;
  },
  pathActions: AI,
  ptObjToArr: eI,
  recalcRotatedPath: yE,
  removePath_: Cv,
  reorientGrads: vE,
  replacePathSeg: _E,
  setLinkControlPoints: pE,
  setUiStrings: AE,
  smoothControlPoints: fE
}, Symbol.toStringTag, { value: "Module" }));
class si {
  /**
  * @param {string} name - Layer name
  * @param {SVGGElement|null} group - An existing SVG group element or null.
  *     If group and no svgElem, use group for this layer.
  *     If group and svgElem, create a new group element and insert it in the DOM after group.
  *     If no group and svgElem, create a new group element and insert it in the DOM as the last layer.
  * @param {SVGGElement} [svgElem] - The SVG DOM element. If defined, use this to add
  *     a new layer to the document.
  */
  constructor(e, t, r) {
    if (this.name_ = e, this.group_ = r ? null : t, r) {
      const n = r.ownerDocument;
      this.group_ = n.createElementNS(vt.SVG, "g");
      const i = n.createElementNS(vt.SVG, "title");
      i.textContent = e, this.group_.append(i), t ? t.insertAdjacentElement("afterend", this.group_) : r.append(this.group_);
    }
    dI(this.group_), Wa(this.group_, function(n) {
      n.style.pointerEvents = "inherit";
    }), this.group_.style.pointerEvents = r ? "all" : "none";
  }
  /**
   * Get the layer's name.
   * @returns {string} The layer name
   */
  getName() {
    return this.name_;
  }
  /**
   * Get the group element for this layer.
   * @returns {SVGGElement} The layer SVG group
   */
  getGroup() {
    return this.group_;
  }
  /**
   * Active this layer so it takes pointer events.
   * @returns {void}
   */
  activate() {
    this.group_.style.pointerEvents = "all";
  }
  /**
   * Deactive this layer so it does NOT take pointer events.
   * @returns {void}
   */
  deactivate() {
    this.group_.style.pointerEvents = "none";
  }
  /**
   * Set this layer visible or hidden based on 'visible' parameter.
   * @param {boolean} visible - If true, make visible; otherwise, hide it.
   * @returns {void}
   */
  setVisible(e) {
    const t = e === void 0 || e ? "inline" : "none";
    this.group_.getAttribute("display") !== t && this.group_.setAttribute("display", t);
  }
  /**
   * Is this layer visible?
   * @returns {boolean} True if visible.
   */
  isVisible() {
    return this.group_.getAttribute("display") !== "none";
  }
  /**
   * Get layer opacity.
   * @returns {Float} Opacity value.
   */
  getOpacity() {
    const e = this.group_.getAttribute("opacity");
    return e ? Number.parseFloat(e) : 1;
  }
  /**
   * Sets the opacity of this layer. If opacity is not a value between 0.0 and 1.0,
   * nothing happens.
   * @param {Float} opacity - A float value in the range 0.0-1.0
   * @returns {void}
   */
  setOpacity(e) {
    typeof e == "number" && e >= 0 && e <= 1 && this.group_.setAttribute("opacity", e);
  }
  /**
   * Append children to this layer.
   * @param {SVGGElement} children - The children to append to this layer.
   * @returns {void}
   */
  appendChildren(e) {
    for (const t of e)
      this.group_.append(t);
  }
  /**
  * @returns {SVGTitleElement|null}
  */
  getTitleElement() {
    const e = this.group_.childNodes.length;
    for (let t = 0; t < e; ++t) {
      const r = this.group_.childNodes.item(t);
      if (r?.tagName === "title")
        return r;
    }
    return null;
  }
  /**
   * Set the name of this layer.
   * @param {string} name - The new name.
   * @param {module:history.HistoryRecordingService} hrService - History recording service
   * @returns {string|null} The new name if changed; otherwise, null.
   */
  setName(e, t) {
    const r = this.name_;
    e = _A(e);
    const n = this.getTitleElement();
    if (n) {
      for (; n.firstChild; )
        n.removeChild(n.firstChild);
      return n.textContent = e, this.name_ = e, t && t.changeElement(n, { "#text": r }), this.name_;
    }
    return null;
  }
  /**
   * Remove this layer's group from the DOM. No more functions on group can be called after this.
   * @returns {SVGGElement} The layer SVG group that was just removed.
   */
  removeGroup() {
    const e = this.group_;
    return this.group_.remove(), this.group_ = void 0, e;
  }
  /**
   * Test whether an element is a layer or not.
   * @param {SVGGElement} elem - The SVGGElement to test.
   * @returns {boolean} True if the element is a layer
   */
  static isLayer(e) {
    return e && e.tagName === "g" && si.CLASS_REGEX.test(e.getAttribute("class"));
  }
}
si.CLASS_NAME = "layer";
si.CLASS_REGEX = new RegExp(`(\\s|^)${si.CLASS_NAME}(\\s|$)`);
const dI = (o) => {
  const e = o.getAttribute("class");
  !e || !e.length ? o.setAttribute("class", si.CLASS_NAME) : si.CLASS_REGEX.test(e) || o.setAttribute("class", `${e} ${si.CLASS_NAME}`);
};
class ub {
  /**
  * @param {history.UndoManager|null} undoManager - The undo manager.
  *     A value of `null` is valid for cases where no history recording is required.
  *     See singleton: {@link module:history.HistoryRecordingService.HistoryRecordingService.NO_HISTORY}
  */
  constructor(e) {
    this.undoManager_ = e, this.currentBatchCommand_ = null, this.batchCommandStack_ = [];
  }
  /**
   * Start a batch command so multiple commands can recorded as a single history command.
   * Requires a corresponding call to endBatchCommand. Start and end commands can be nested.
   *
   * @param {string} text - Optional string describing the batch command.
   * @returns {module:history.HistoryRecordingService}
   */
  startBatchCommand(e) {
    return this.undoManager_ ? (this.currentBatchCommand_ = new $A(e), this.batchCommandStack_.push(this.currentBatchCommand_), this) : this;
  }
  /**
   * End a batch command and add it to the history or a parent batch command.
   * @returns {module:history.HistoryRecordingService}
   */
  endBatchCommand() {
    if (!this.undoManager_)
      return this;
    if (this.currentBatchCommand_) {
      const e = this.currentBatchCommand_;
      this.batchCommandStack_.pop();
      const { length: t } = this.batchCommandStack_;
      this.currentBatchCommand_ = t ? this.batchCommandStack_[t - 1] : null, e.isEmpty() || this.addCommand_(e);
    }
    return this;
  }
  /**
   * Add a `MoveElementCommand` to the history or current batch command.
   * @param {Element} elem - The DOM element that was moved
   * @param {Element} oldNextSibling - The element's next sibling before it was moved
   * @param {Element} oldParent - The element's parent before it was moved
   * @param {string} [text] - An optional string visible to user related to this change
   * @returns {module:history.HistoryRecordingService}
   */
  moveElement(e, t, r, n) {
    return this.undoManager_ ? (this.addCommand_(new oE(e, t, r, n)), this) : this;
  }
  /**
   * Add an `InsertElementCommand` to the history or current batch command.
   * @param {Element} elem - The DOM element that was added
   * @param {string} [text] - An optional string visible to user related to this change
   * @returns {module:history.HistoryRecordingService}
   */
  insertElement(e, t) {
    return this.undoManager_ ? (this.addCommand_(new nE(e, t)), this) : this;
  }
  /**
   * Add a `RemoveElementCommand` to the history or current batch command.
   * @param {Element} elem - The DOM element that was removed
   * @param {Element} oldNextSibling - The element's next sibling before it was removed
   * @param {Element} oldParent - The element's parent before it was removed
   * @param {string} [text] - An optional string visible to user related to this change
   * @returns {module:history.HistoryRecordingService}
   */
  removeElement(e, t, r, n) {
    return this.undoManager_ ? (this.addCommand_(new iE(e, t, r, n)), this) : this;
  }
  /**
   * Add a `ChangeElementCommand` to the history or current batch command.
   * @param {Element} elem - The DOM element that was changed
   * @param {module:history.CommandAttributes} attrs - An object with the attributes to be changed and the values they had *before* the change
   * @param {string} [text] - An optional string visible to user related to this change
   * @returns {module:history.HistoryRecordingService}
   */
  changeElement(e, t, r) {
    return this.undoManager_ ? (this.addCommand_(new eu(e, t, r)), this) : this;
  }
  /**
   * Private function to add a command to the history or current batch command.
   * @private
   * @param {Command} cmd
   * @returns {module:history.HistoryRecordingService|void}
   */
  addCommand_(e) {
    if (!this.undoManager_)
      return this;
    this.currentBatchCommand_ ? this.currentBatchCommand_.addSubCommand(e) : this.undoManager_.addCommandToHistory(e);
  }
}
ub.NO_HISTORY = new ub(null);
class pI {
  #t = /* @__PURE__ */ new WeakMap();
  /**
   * Checks if the provided element is a valid WeakMap key.
   * @param {any} element - The element to validate
   * @returns {boolean} True if the element can be used as a WeakMap key
   * @private
   */
  #e = (e) => e !== null && (typeof e == "object" || typeof e == "function");
  /**
   * Stores data associated with an element.
   * @param {Object|Function} element - The element to store data for
   * @param {string} key - The key to store the data under
   * @param {any} obj - The data to store
   * @returns {void}
   */
  put(e, t, r) {
    if (!this.#e(e))
      return;
    let n = this.#t.get(e);
    n || (n = /* @__PURE__ */ new Map(), this.#t.set(e, n)), n.set(t, r);
  }
  /**
   * Retrieves data associated with an element.
   * @param {Object|Function} element - The element to retrieve data for
   * @param {string} key - The key the data was stored under
   * @returns {any|undefined} The stored data, or undefined if not found
   */
  get(e, t) {
    if (this.#e(e))
      return this.#t.get(e)?.get(t);
  }
  /**
   * Checks if an element has data stored under a specific key.
   * @param {Object|Function} element - The element to check
   * @param {string} key - The key to check for
   * @returns {boolean} True if the element has data stored under the key
   */
  has(e, t) {
    return this.#e(e) ? this.#t.get(e)?.has(t) === !0 : !1;
  }
  /**
   * Removes data associated with an element.
   * @param {Object|Function} element - The element to remove data from
   * @param {string} key - The key the data was stored under
   * @returns {boolean} True if the data was removed, false otherwise
   */
  remove(e, t) {
    if (!this.#e(e))
      return !1;
    const r = this.#t.get(e);
    if (!r)
      return !1;
    const n = r.delete(t);
    return r.size === 0 && this.#t.delete(e), n;
  }
}
const Ma = new pI(), xE = (o, e) => {
  const t = o?.ownerDocument || document, r = t.createElementNS(o.namespaceURI, o.nodeName);
  if (Array.from(o.attributes).forEach((n) => {
    n.namespaceURI ? r.setAttributeNS(n.namespaceURI, n.name, n.value) : r.setAttribute(n.name, n.value);
  }), r.removeAttribute("id"), r.id = e(), o.childNodes.forEach((n) => {
    switch (n.nodeType) {
      case 1:
        r.append(xE(n, e));
        break;
      case 3:
      // text node
      case 4:
        r.append(t.createTextNode(n.nodeValue ?? ""));
        break;
    }
  }), Ma.has(o, "gsvg")) {
    const n = r.firstElementChild || r.firstChild;
    n && Ma.put(r, "gsvg", n);
  }
  return Ma.has(o, "symbol") && Ma.put(r, "symbol", Ma.get(o, "symbol")), Ma.has(o, "ref") && Ma.put(r, "ref", Ma.get(o, "ref")), r.tagName === "image" && bv(r), r;
}, hI = "a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(
  ","
), Sl = {
  LET_DOCUMENT_DECIDE: 0,
  ALWAYS_RANDOMIZE: 1,
  NEVER_RANDOMIZE: 2
};
let yA = Sl.LET_DOCUMENT_DECIDE, Yp = [];
const WA = (o) => o || new ub(Qt.undoMgr), gI = (o) => {
  const e = o.querySelector("title");
  return e ? e.textContent : "";
}, _I = (o) => o.classList.contains("layer"), g_ = (o) => {
  let e = 1;
  for (; o.includes(`Layer ${e}`); )
    e++;
  return `Layer ${e}`;
};
class Ab {
  /**
   * @param {SVGSVGElement} svgElem - The SVG DOM Element that this JS object
   *     encapsulates.  If the svgElem has a se:nonce attribute on it, then
   *     IDs will use the nonce as they are generated.
   * @param {string} [optIdPrefix=svg_] - The ID prefix to use.
   * @throws {Error} If not initialized with an SVG element
   */
  constructor(e, t) {
    if (!e || !e.tagName || !e.namespaceURI || e.tagName !== "svg" || e.namespaceURI !== vt.SVG)
      throw new Error(
        "Error: svgedit.draw.Drawing instance initialized without a <svg> element"
      );
    this.svgElem_ = e, this.obj_num = 0, this.idPrefix = t || "svg_", this.releasedNums = [], this.all_layers = [], this.layer_map = {}, this.current_layer = null, this.nonce_ = "";
    const r = this.svgElem_.getAttributeNS(vt.SE, "nonce");
    r && yA !== Sl.NEVER_RANDOMIZE ? this.nonce_ = r : yA === Sl.ALWAYS_RANDOMIZE && this.setNonce(Math.floor(Math.random() * 100001));
  }
  /**
   * @param {string} id Element ID to retrieve
   * @returns {Element} SVG element within the root SVGSVGElement
   */
  getElem_(e) {
    return this.svgElem_.querySelector ? this.svgElem_.querySelector(`#${e}`) : this.svgElem_.querySelector(`[id=${e}]`);
  }
  /**
   * @returns {SVGSVGElement}
   */
  getSvgElem() {
    return this.svgElem_;
  }
  /**
   * @returns {!(string|Integer)} The previously set nonce
   */
  getNonce() {
    return this.nonce_;
  }
  /**
   * @param {!(string|Integer)} n The nonce to set
   * @returns {void}
   */
  setNonce(e) {
    this.svgElem_.setAttributeNS(vt.XMLNS, "xmlns:se", vt.SE), this.svgElem_.setAttributeNS(vt.SE, "se:nonce", e), this.nonce_ = e;
  }
  /**
   * Clears any previously set nonce.
   * @returns {void}
   */
  clearNonce() {
    this.nonce_ = "";
  }
  /**
   * Returns the latest object id as a string.
   * @returns {string} The latest object Id.
   */
  getId() {
    return this.nonce_ ? `${this.idPrefix}${this.nonce_}_${this.obj_num}` : this.idPrefix + this.obj_num;
  }
  /**
   * Returns the next object Id as a string.
   * @returns {string} The next object Id to use.
   */
  getNextId() {
    const e = this.obj_num;
    let t = !1;
    this.releasedNums.length > 0 ? (this.obj_num = this.releasedNums.pop(), t = !0) : this.obj_num++;
    let r = this.getId();
    for (; this.getElem_(r); )
      t && (this.obj_num = e, t = !1), this.obj_num++, r = this.getId();
    return t && (this.obj_num = e), r;
  }
  /**
   * Releases the object Id, letting it be used as the next id in getNextId().
   * This method DOES NOT remove any elements from the DOM, it is expected
   * that client code will do this.
   * @param {string} id - The id to release.
   * @returns {boolean} True if the id was valid to be released, false otherwise.
   */
  releaseId(e) {
    const t = `${this.idPrefix}${this.nonce_ ? `${this.nonce_}_` : ""}`;
    if (typeof e != "string" || !e.startsWith(t))
      return !1;
    const r = e.slice(t.length);
    if (!/^[0-9]+$/.test(r))
      return !1;
    const n = Number.parseInt(r);
    return typeof n != "number" || n <= 0 || this.releasedNums.includes(n) ? !1 : (this.releasedNums.push(n), !0);
  }
  /**
   * Returns the number of layers in the current drawing.
   * @returns {Integer} The number of layers in the current drawing.
   */
  getNumLayers() {
    return this.all_layers.length;
  }
  /**
   * Check if layer with given name already exists.
   * @param {string} name - The layer name to check
   * @returns {boolean}
   */
  hasLayer(e) {
    return this.layer_map[e] !== void 0;
  }
  /**
   * Returns the name of the ith layer. If the index is out of range, an empty string is returned.
   * @param {Integer} i - The zero-based index of the layer you are querying.
   * @returns {string} The name of the ith layer (or the empty string if none found)
   */
  getLayerName(e) {
    return e >= 0 && e < this.getNumLayers() ? this.all_layers[e].getName() : "";
  }
  /**
   * @returns {SVGGElement|null} The SVGGElement representing the current layer.
   */
  getCurrentLayer() {
    return this.current_layer ? this.current_layer.getGroup() : null;
  }
  /**
   * Get a layer by name.
   * @param {string} name
   * @returns {SVGGElement} The SVGGElement representing the named layer or null.
   */
  getLayerByName(e) {
    const t = this.layer_map[e];
    return t ? t.getGroup() : null;
  }
  /**
   * Returns the name of the currently selected layer. If an error occurs, an empty string
   * is returned.
   * @returns {string} The name of the currently active layer (or the empty string if none found).
   */
  getCurrentLayerName() {
    return this.current_layer ? this.current_layer.getName() : "";
  }
  /**
   * Set the current layer's name.
   * @param {string} name - The new name.
   * @param {module:history.HistoryRecordingService} hrService - History recording service
   * @returns {string|null} The new name if changed; otherwise, null.
   */
  setCurrentLayerName(e, t) {
    let r = null;
    if (this.current_layer) {
      const n = this.current_layer.getName();
      r = this.current_layer.setName(e, t), r && (delete this.layer_map[n], this.layer_map[r] = this.current_layer);
    }
    return r;
  }
  /**
   * Set the current layer's position.
   * @param {Integer} newpos - The zero-based index of the new position of the layer. Range should be 0 to layers-1
   * @returns {{title: SVGGElement, previousName: string}|null} If the name was changed, returns {title:SVGGElement, previousName:string}; otherwise null.
   */
  setCurrentLayerPosition(e) {
    const t = this.getNumLayers();
    if (!this.current_layer || e < 0 || e >= t)
      return null;
    const r = this.indexCurrentLayer();
    if (r === -1 || r === e)
      return null;
    const n = this.current_layer.getGroup(), i = n.nextSibling;
    let a = null;
    return e > r ? e < t - 1 && (a = this.all_layers[e + 1].getGroup()) : a = this.all_layers[e].getGroup(), this.svgElem_.insertBefore(n, a), this.identifyLayers(), this.setCurrentLayer(this.getLayerName(e)), {
      currentGroup: n,
      oldNextSibling: i
    };
  }
  /**
   * @param {module:history.HistoryRecordingService} hrService
   * @returns {void}
   */
  mergeLayer(e) {
    const t = this.current_layer.getGroup(), r = t.previousElementSibling;
    if (!r)
      return;
    e.startBatchCommand("Merge Layer");
    const n = t.nextSibling;
    for (e.removeElement(t, n, this.svgElem_); t.firstChild; ) {
      const a = t.firstChild;
      if (a.localName === "title") {
        e.removeElement(a, a.nextSibling, t), a.remove();
        continue;
      }
      const s = a.nextSibling;
      r.append(a), e.moveElement(a, s, t);
    }
    this.current_layer.removeGroup();
    const i = this.indexCurrentLayer();
    if (i > 0) {
      const a = this.current_layer.getName();
      this.current_layer = this.all_layers[i - 1], this.all_layers.splice(i, 1), delete this.layer_map[a];
    }
    e.endBatchCommand();
  }
  /**
   * @param {module:history.HistoryRecordingService} hrService
   * @returns {void}
   */
  mergeAllLayers(e) {
    for (this.current_layer = this.all_layers[this.all_layers.length - 1], e.startBatchCommand("Merge all Layers"); this.all_layers.length > 1; )
      this.mergeLayer(e);
    e.endBatchCommand();
  }
  /**
   * Sets the current layer. If the name is not a valid layer name, then this
   * function returns `false`. Otherwise it returns `true`. This is not an
   * undo-able action.
   * @param {string} name - The name of the layer you want to switch to.
   * @returns {boolean} `true` if the current layer was switched, otherwise `false`
   */
  setCurrentLayer(e) {
    const t = this.layer_map[e];
    return t ? (this.current_layer && this.current_layer.deactivate(), this.current_layer = t, this.current_layer.activate(), !0) : !1;
  }
  /**
   * Sets the current layer. If the name is not a valid layer name, then this
   * function returns `false`. Otherwise it returns `true`. This is not an
   * undo-able action.
   * @param {string} name - The name of the layer you want to switch to.
   * @returns {boolean} `true` if the current layer was switched, otherwise `false`
   */
  indexCurrentLayer() {
    return this.all_layers.indexOf(this.current_layer);
  }
  /**
   * Deletes the current layer from the drawing and then clears the selection.
   * This function then calls the 'changed' handler.  This is an undoable action.
   * @todo Does this actually call the 'changed' handler?
   * @returns {SVGGElement} The SVGGElement of the layer removed or null.
   */
  deleteCurrentLayer() {
    if (this.current_layer && this.getNumLayers() > 1) {
      const e = this.current_layer.removeGroup();
      return this.identifyLayers(), e;
    }
    return null;
  }
  /**
   * Updates layer system and sets the current layer to the
   * top-most layer (last `<g>` child of this drawing).
   * @returns {void}
   */
  identifyLayers() {
    this.all_layers = [], this.layer_map = {};
    const e = this.svgElem_.childNodes.length, t = [], r = [];
    let n = null, i = !1;
    for (let a = 0; a < e; ++a) {
      const s = this.svgElem_.childNodes.item(a);
      if (s?.nodeType === 1)
        if (s.tagName === "g")
          if (i = !0, _I(s)) {
            const l = gI(s);
            r.push(l), n = new si(l, s), this.all_layers.push(n), this.layer_map[l] = n;
          } else
            t.push(s);
        else hI.includes(s.nodeName) && t.push(s);
    }
    if (t.length > 0 || !i) {
      const a = g_(r);
      n = new si(a, null, this.svgElem_), n.appendChildren(t), this.all_layers.push(n), this.layer_map[a] = n;
    } else
      n.activate();
    this.current_layer = n;
  }
  /**
   * Creates a new top-level layer in the drawing with the given name and
   * makes it the current layer.
   * @param {string} name - The given name. If the layer name exists, a new name will be generated.
   * @param {module:history.HistoryRecordingService} hrService - History recording service
   * @returns {SVGGElement} The SVGGElement of the new layer, which is
   *     also the current layer of this drawing.
   */
  createLayer(e, t) {
    this.current_layer && this.current_layer.deactivate(), (e == null || e === "" || this.layer_map[e]) && (e = g_(Object.keys(this.layer_map)));
    const r = new si(e, null, this.svgElem_);
    return t && (t.startBatchCommand("Create Layer"), t.insertElement(r.getGroup()), t.endBatchCommand()), this.all_layers.push(r), this.layer_map[e] = r, this.current_layer = r, r.getGroup();
  }
  /**
   * Creates a copy of the current layer with the given name and makes it the current layer.
   * @param {string} name - The given name. If the layer name exists, a new name will be generated.
   * @param {module:history.HistoryRecordingService} hrService - History recording service
   * @returns {SVGGElement} The SVGGElement of the new layer, which is
   *     also the current layer of this drawing.
   */
  cloneLayer(e, t) {
    if (!this.current_layer)
      return null;
    this.current_layer.deactivate(), (e == null || e === "" || this.layer_map[e]) && (e = g_(Object.keys(this.layer_map)));
    const r = this.current_layer.getGroup(), n = new si(e, r, this.svgElem_), i = n.getGroup();
    [...r.childNodes].forEach((s) => {
      if (s.nodeType !== 1) {
        i.append(s.cloneNode(!0));
        return;
      }
      s.localName !== "title" && i.append(this.copyElem(s));
    }), t && (t.startBatchCommand("Duplicate Layer"), t.insertElement(i), t.endBatchCommand());
    const a = this.indexCurrentLayer();
    return a >= 0 ? this.all_layers.splice(a + 1, 0, n) : this.all_layers.push(n), this.layer_map[e] = n, this.current_layer = n, i;
  }
  /**
   * Returns whether the layer is visible.  If the layer name is not valid,
   * then this function returns `false`.
   * @param {string} layerName - The name of the layer which you want to query.
   * @returns {boolean} The visibility state of the layer, or `false` if the layer name was invalid.
   */
  getLayerVisibility(e) {
    const t = this.layer_map[e];
    return t ? t.isVisible() : !1;
  }
  /**
   * Sets the visibility of the layer. If the layer name is not valid, this
   * function returns `null`, otherwise it returns the `SVGElement` representing
   * the layer. This is an undo-able action.
   * @param {string} layerName - The name of the layer to change the visibility
   * @param {boolean} bVisible - Whether the layer should be visible
   * @returns {?SVGGElement} The SVGGElement representing the layer if the
   *   `layerName` was valid, otherwise `null`.
   */
  setLayerVisibility(e, t) {
    if (typeof t != "boolean")
      return null;
    const r = this.layer_map[e];
    return r ? (r.setVisible(t), r.getGroup()) : null;
  }
  /**
   * Returns the opacity of the given layer.  If the input name is not a layer, `null` is returned.
   * @param {string} layerName - name of the layer on which to get the opacity
   * @returns {?Float} The opacity value of the given layer.  This will be a value between 0.0 and 1.0, or `null`
   * if `layerName` is not a valid layer
   */
  getLayerOpacity(e) {
    const t = this.layer_map[e];
    return t ? t.getOpacity() : null;
  }
  /**
   * Sets the opacity of the given layer.  If the input name is not a layer,
   * nothing happens. If opacity is not a value between 0.0 and 1.0, then
   * nothing happens.
   * NOTE: this function exists solely to apply a highlighting/de-emphasis
   * effect to a layer. When it is possible for a user to affect the opacity
   * of a layer, we will need to allow this function to produce an undo-able
   * action.
   * @param {string} layerName - Name of the layer on which to set the opacity
   * @param {Float} opacity - A float value in the range 0.0-1.0
   * @returns {void}
   */
  setLayerOpacity(e, t) {
    if (typeof t != "number" || t < 0 || t > 1)
      return;
    const r = this.layer_map[e];
    r && r.setOpacity(t);
  }
  /**
   * Create a clone of an element, updating its ID and its children's IDs when needed.
   * @param {Element} el - DOM element to clone
   * @returns {Element}
   */
  copyElem(e) {
    return xE(e, () => this.getNextId());
  }
}
const H0 = (o, e) => {
  yA = o === !1 ? Sl.NEVER_RANDOMIZE : Sl.ALWAYS_RANDOMIZE, yA === Sl.ALWAYS_RANDOMIZE && !e.getNonce() ? e.setNonce(Math.floor(Math.random() * 100001)) : yA === Sl.NEVER_RANDOMIZE && e.getNonce() && e.clearNonce();
};
let Qt;
const fI = (o) => {
  Qt = o;
}, bA = () => {
  $s(), Qt.getCurrentDrawing().identifyLayers();
}, mI = () => Qt.getCurrentDrawing().indexCurrentLayer(), yI = (o, e) => {
  const t = Qt.getCurrentDrawing().createLayer(o, WA(e));
  Qt.clearSelection(), Qt.call("changed", [t]);
}, bI = (o, e) => {
  const t = Qt.getCurrentDrawing().cloneLayer(o, WA(e));
  if (!t) {
    xn("cloneLayer: no layer returned", null, "draw");
    return;
  }
  Qt.clearSelection(), $s(), Qt.call("changed", [t]);
}, vI = () => {
  const { BatchCommand: o, RemoveElementCommand: e } = Qt.history, t = Qt.getCurrentDrawing().getCurrentLayer();
  if (!t)
    return xn("deleteCurrentLayer: no current layer", null, "draw"), !1;
  const { nextSibling: r } = t, n = t.parentNode, i = Qt.getCurrentDrawing().deleteCurrentLayer();
  if (i && n) {
    const a = new o("Delete Layer");
    return a.addSubCommand(
      new e(i, r, n)
    ), Qt.addCommandToHistory(a), Qt.clearSelection(), Qt.call("changed", [n]), !0;
  }
  return !1;
}, wI = (o) => {
  const e = Qt.getCurrentDrawing().setCurrentLayer(_A(o));
  return e && Qt.clearSelection(), e;
}, xI = (o) => {
  const e = Qt.getCurrentDrawing(), t = e.getCurrentLayer();
  return t && e.setCurrentLayerName(
    o,
    WA()
  ) ? (Qt.call("changed", [t]), !0) : !1;
}, kI = (o) => {
  const { MoveElementCommand: e } = Qt.history, t = Qt.getCurrentDrawing().setCurrentLayerPosition(o);
  return t ? (Qt.addCommandToHistory(
    new e(
      t.currentGroup,
      t.oldNextSibling,
      Qt.getSvgContent()
    )
  ), !0) : !1;
}, CI = (o, e) => {
  const { ChangeElementCommand: t } = Qt.history, r = Qt.getCurrentDrawing(), n = r.getLayerByName(o);
  if (!n)
    return xn("setLayerVisibility: layer not found", o, "draw"), !1;
  const i = n.getAttribute("display"), a = r.setLayerVisibility(o, e);
  return a ? (Qt.addCommandToHistory(
    new t(a, { display: i }, "Layer Visibility")
  ), a === r.getCurrentLayer() && (Qt.clearSelection(), Qt.pathActions.clear()), !0) : !1;
}, SI = (o) => {
  const { BatchCommand: e, MoveElementCommand: t } = Qt.history, r = Qt.getCurrentDrawing().getLayerByName(o);
  if (!r)
    return !1;
  const n = new e("Move Elements to Layer"), i = Qt.getSelectedElements();
  let a = i.length;
  for (; a--; ) {
    const s = i[a], l = s?.parentNode;
    if (!s || !l || l === r)
      continue;
    const c = s.nextSibling;
    r.append(s), n.addSubCommand(
      new t(s, c, l)
    );
  }
  return n.isEmpty() ? (xn("moveSelectedToLayer: no elements moved", null, "draw"), !1) : (Qt.addCommandToHistory(n), !0);
}, BI = (o) => {
  Qt.getCurrentDrawing().mergeLayer(WA(o)), Qt.clearSelection(), $s(), Qt.changeSvgContent();
}, EI = (o) => {
  Qt.getCurrentDrawing().mergeAllLayers(WA(o)), Qt.clearSelection(), $s(), Qt.changeSvgContent();
}, $s = () => {
  const o = Yp.length, e = Qt.getDataStorage();
  if (o) {
    for (let t = 0; t < o; t++) {
      const r = Yp[t], n = e.get(r, "orig_opac");
      n == null ? r.removeAttribute("opacity") : r.setAttribute("opacity", n), r.setAttribute("style", "pointer-events: inherit"), e.remove(r, "orig_opac");
    }
    Yp = [], Qt.clearSelection(!0), Qt.call("contextset", null);
  }
  Qt.setCurrentGroup(null);
}, kE = (o) => {
  const e = Qt.getDataStorage();
  if ($s(), typeof o == "string") {
    const n = o;
    try {
      o = wr(n);
    } catch {
      o = null;
    }
    if (!o && typeof document < "u") {
      const i = document.getElementById(n), a = Qt.getSvgContent?.();
      o = i && (!a || a.contains(i)) ? i : null;
    }
  }
  if (!o)
    return;
  Qt.setCurrentGroup(o);
  const t = F4(o, "#svgcontent");
  if (!t)
    return;
  const r = [];
  t.forEach(function(n) {
    n?.parentNode && Array.prototype.filter.call(
      n.parentNode.children,
      function(i) {
        return i !== n;
      }
    ).forEach(function(i) {
      r.push(i);
    });
  }), r.forEach(function(n) {
    const i = n.getAttribute("opacity");
    e.put(n, "orig_opac", i);
    const a = Number.parseFloat(i), s = Number.isFinite(a) ? a : 1;
    n.setAttribute("opacity", s * 0.33), n.setAttribute("style", "pointer-events: none"), Yp.push(n);
  }), Qt.clearSelection(), Qt.call("contextset", Qt.getCurrentGroup());
}, {
  InsertElementCommand: jI,
  BatchCommand: LI
} = Gl;
let pi = null;
const TI = (o) => {
  pi = o;
}, PI = (o, e, t) => {
  const r = sessionStorage.getItem(pi.getClipboardID());
  let n;
  try {
    n = JSON.parse(r);
  } catch {
    return;
  }
  if (!Array.isArray(n) || !n.length) return;
  const i = [], a = new LI("Paste elements"), s = {}, l = (A) => {
    A.attr?.id && (s[A.attr.id] = pi.getNextId(), A.attr.id = s[A.attr.id]), A.children && A.children.forEach((p) => l(p));
  };
  n.forEach((A) => l(A));
  const c = (A) => {
    const p = A?.attr;
    if (p)
      for (const [d, g] of Object.entries(p)) {
        if (typeof g != "string" || !g) continue;
        if ((d === "href" || d === "xlink:href") && g.startsWith("#")) {
          const f = g.slice(1);
          f in s && (p[d] = `#${s[f]}`);
        }
        const _ = TA(g);
        if (_) {
          const f = _.slice(1);
          f in s && (p[d] = g.replace(_, `#${s[f]}`));
        }
      }
    A.children && A.children.forEach((d) => c(d));
  };
  n.forEach((A) => c(A)), pi.runExtensions(
    "IDsUpdated",
    /** @type {module:svgcanvas.SvgCanvas#event:ext_IDsUpdated} */
    { elems: n, changes: s },
    !0
  ).forEach(function(A) {
    !A || !("remove" in A) || A.remove.forEach(function(p) {
      n = n.filter(function(d) {
        return d?.attr?.id !== p;
      });
    });
  });
  let u = n.length;
  if (u) {
    for (; u--; ) {
      const A = n[u];
      if (!A)
        continue;
      const p = pi.addSVGElementsFromJson(A);
      i.push(p), a.addSubCommand(new jI(p)), pi.restoreRefElements(p);
    }
    if (i.length) {
      if (pi.selectOnly(i), o !== "in_place") {
        let A, p;
        o ? o === "point" && (A = e, p = t) : (A = pi.getLastClickPoint("x"), p = pi.getLastClickPoint("y"));
        const d = bi(i);
        if (d && Number.isFinite(A) && Number.isFinite(p)) {
          const g = A - (d.x + d.width / 2), _ = p - (d.y + d.height / 2), f = [], m = [];
          i.forEach(function(v) {
            f.push(g), m.push(_);
          });
          const b = pi.moveSelectedElements(f, m, !1);
          b && a.addSubCommand(b);
        }
      }
      pi.addCommandToHistory(a), pi.call("changed", i);
    }
  }
}, tp = (o) => {
  o.preventDefault();
  const { changedTouches: e } = o, t = e[0];
  let r = "";
  switch (o.type) {
    case "touchstart":
      r = "mousedown";
      break;
    case "touchmove":
      r = "mousemove";
      break;
    case "touchend":
      r = "mouseup";
      break;
    default:
      return;
  }
  const { screenX: n, screenY: i, clientX: a, clientY: s } = t, l = new MouseEvent(r, {
    // Event interface
    bubbles: !0,
    cancelable: !0,
    // UIEvent interface
    view: window,
    detail: 1,
    // click count
    // MouseEvent interface (customized)
    screenX: n,
    screenY: i,
    clientX: a,
    clientY: s,
    // MouseEvent interface (defaults) - these could be removed
    ctrlKey: !1,
    altKey: !1,
    shiftKey: !1,
    metaKey: !1,
    button: 0,
    // main button (usually left)
    relatedTarget: null
  });
  e.length < 2 && t.target.dispatchEvent(l);
}, FI = (o) => {
  o.svgroot.addEventListener("touchstart", tp), o.svgroot.addEventListener("touchmove", tp), o.svgroot.addEventListener("touchend", tp), o.svgroot.addEventListener("touchcancel", tp);
}, UI = (o, e) => o.importNode(
  yv(
    `<svg id="svgroot" xmlns="${vt.SVG}" xlinkns="${vt.XLINK}" width="${e[0]}" 
        height="${e[1]}" x="${e[0]}" y="${e[1]}" overflow="visible">
        <defs>
          <filter id="canvashadow" filterUnits="objectBoundingBox">
            <feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
            <feOffset in="blur" dx="5" dy="5" result="offsetBlur"/>
            <feMerge>
              <feMergeNode in="offsetBlur"/>
              <feMergeNode in="SourceGraphic"/>
            </feMerge>
          </filter>
        </defs>
      </svg>`
  ).documentElement,
  !0
), __ = "http://www.w3.org/2000/svg";
class NI {
  #t = navigator.userAgent;
  #e = /* @__PURE__ */ new Map();
  /**
   * Detects if the browser is WebKit-based
   * @returns {boolean}
   */
  get isWebkit() {
    return this.#e.has("isWebkit") || this.#e.set("isWebkit", this.#t.includes("AppleWebKit")), this.#e.get("isWebkit");
  }
  /**
   * Detects if the browser is Gecko-based
   * @returns {boolean}
   */
  get isGecko() {
    return this.#e.has("isGecko") || this.#e.set("isGecko", this.#t.includes("Gecko/")), this.#e.get("isGecko");
  }
  /**
   * Detects if the browser is Chrome
   * @returns {boolean}
   */
  get isChrome() {
    return this.#e.has("isChrome") || this.#e.set("isChrome", this.#t.includes("Chrome/")), this.#e.get("isChrome");
  }
  /**
   * Detects if the platform is macOS
   * @returns {boolean}
   */
  get isMac() {
    return this.#e.has("isMac") || this.#e.set("isMac", this.#t.includes("Macintosh")), this.#e.get("isMac");
  }
  /**
   * Tests if the browser supports accurate text character positioning
   * @returns {boolean}
   */
  get supportsGoodTextCharPos() {
    return this.#e.has("supportsGoodTextCharPos") || this.#e.set("supportsGoodTextCharPos", this.#r()), this.#e.get("supportsGoodTextCharPos");
  }
  /**
   * Private method to test text character positioning support
   * @returns {boolean}
   */
  #r() {
    const e = document.createElementNS(__, "svg"), t = document.createElementNS(__, "svg");
    document.documentElement.append(e), t.setAttribute("x", 5), e.append(t);
    const r = document.createElementNS(__, "text");
    r.textContent = "a", t.append(r);
    try {
      return r.getStartPositionOfChar(0).x === 0;
    } catch {
      return !1;
    } finally {
      e.remove();
    }
  }
}
const Dh = new NI(), CE = () => Dh.isWebkit, Pl = () => Dh.isGecko, II = () => Dh.isChrome, MI = () => Dh.supportsGoodTextCharPos, {
  UndoManager: RI,
  HistoryEventTypes: OI
} = Gl;
let fr = null;
const QI = (o) => {
  fr = o, o.undoMgr = qI();
}, qI = () => new RI({
  /**
   * @param {string} eventType One of the HistoryEvent types
   * @param {module:history.HistoryCommand} cmd Fulfills the HistoryCommand interface
   * @fires module:undo.SvgCanvas#event:changed
   * @returns {void}
   */
  handleHistoryEvent(o, e) {
    const t = OI;
    if (o === t.BEFORE_UNAPPLY || o === t.BEFORE_APPLY)
      fr.clearSelection();
    else if (o === t.AFTER_APPLY || o === t.AFTER_UNAPPLY) {
      const r = e.type(), n = o === t.AFTER_APPLY;
      if (r === "ChangeElementCommand" && e.elem === fr.getSvgContent()) {
        const a = n ? e.newValues : e.oldValues;
        if (a.width !== null && a.width !== void 0 && a.width !== "") {
          const s = Number(a.width);
          Number.isFinite(s) && s > 0 && (fr.contentW = s);
        }
        if (a.height !== null && a.height !== void 0 && a.height !== "") {
          const s = Number(a.height);
          Number.isFinite(s) && s > 0 && (fr.contentH = s);
        }
      }
      const i = e.elements();
      if (fr.pathActions.clear(), fr.call("changed", i), r === "MoveElementCommand")
        (n ? e.newParent : e.oldParent) === fr.getSvgContent() && bA();
      else if (r === "InsertElementCommand" || r === "RemoveElementCommand")
        e.parent === fr.getSvgContent() && bA(), r === "InsertElementCommand" ? n && fr.restoreRefElements(e.elem) : n || fr.restoreRefElements(e.elem), e.elem?.tagName === "use" && fr.setUseData(e.elem);
      else if (r === "ChangeElementCommand") {
        e.elem.tagName === "title" && e.elem.parentNode.parentNode === fr.getSvgContent() && bA();
        const a = n ? e.newValues : e.oldValues;
        if (a.stdDeviation && fr.setBlurOffsets(e.elem.parentNode, a.stdDeviation), e.elem.tagName === "text") {
          const [s, l] = [
            e.newValues.x - e.oldValues.x,
            e.newValues.y - e.oldValues.y
          ], c = e.elem.children;
          for (let u = 0; u < c.length; u++) {
            let A = Number(c[u].getAttribute("x")), p = Number(c[u].getAttribute("y"));
            const d = o === t.AFTER_UNAPPLY;
            A = d ? A - s : A + s, p = d ? p - l : p + l, c[u].setAttribute("x", A), c[u].setAttribute("y", p);
          }
        }
      }
    }
  }
}), z0 = (o) => {
  if (!Pl())
    return o;
  const e = o.cloneNode(!0);
  return o.before(e), o.remove(), fr.selectorManager.releaseSelector(o), fr.setSelectedElements(0, e), fr.selectorManager.requestSelector(e).showGrips(!0), e;
}, SE = (o, e, t) => {
  if (o === "id") {
    const s = t[0], l = s.id;
    l !== e && (fr.clearSelection(), s.id = e, fr.addToSelection([s], !0), fr.call("elementRenamed", { elem: s, oldId: l, newId: e }));
    return;
  }
  const r = fr.getSelectedElements(), n = fr.getZoom();
  fr.getCurrentMode() === "pathedit" && fr.pathActions.moveNode(o, e), t = t ?? r;
  let i = t.length;
  const a = ["g", "polyline", "path"];
  for (; i--; ) {
    let s = t[i];
    if (!s)
      continue;
    if ((o === "x" || o === "y") && a.includes(s.tagName)) {
      const c = bi([s]), u = o === "x" ? parseFloat(e) - c.x : 0, A = o === "y" ? parseFloat(e) - c.y : 0;
      fr.moveSelectedElements(u * n, A * n, !0);
      continue;
    }
    let l = o === "#text" ? s.textContent : s.getAttribute(o);
    if (l || (l = ""), l !== String(e)) {
      o === "#text" ? (s.textContent = e, /rotate/.test(s.getAttribute("transform")) && (s = z0(s))) : o === "#href" ? vi(s, e) : e ? s.setAttribute(o, isNaN(parseFloat(e)) ? e : parseFloat(e)) : typeof e == "number" ? s.setAttribute(o, e) : s.removeAttribute(o), fr.getCurrentMode() === "textedit" && o !== "#text" && s.textContent.length && fr.textActions.toSelectMode(s), Pl() && s.nodeName === "text" && /rotate/.test(s.getAttribute("transform")) && (String(e).startsWith("url") || ["font-size", "font-family", "x", "y"].includes(o) && s.textContent) && (s = z0(s)), r.includes(s) && setTimeout(function() {
        s.parentNode && fr.selectorManager.requestSelector(s).resize();
      }, 0);
      const c = en(s);
      if (c !== 0 && o !== "transform") {
        const u = hr(s);
        let A = u.numberOfItems;
        for (; A--; )
          if (u.getItem(A).type === 4) {
            u.removeItem(A);
            const p = so(s), d = cr(
              p.x + p.width / 2,
              p.y + p.height / 2,
              lr(u).matrix
            ), g = d.x, _ = d.y, f = fr.getSvgRoot().createSVGTransform();
            f.setRotate(c, g, _), u.insertItemBefore(f, A);
            break;
          }
      }
    }
  }
}, GI = (o, e, t) => {
  const r = fr.getSelectedElements();
  t = t || r, fr.undoMgr.beginUndoableChange(o, t), SE(o, e, t);
  const n = fr.undoMgr.finishUndoableChange();
  n.isEmpty() || fr.undoMgr.addCommandToHistory(n);
}, { BatchCommand: VI } = Gl;
let It = null;
const DI = (o) => {
  It = o, It.getMouseTarget = KI, It.clearSelection = HI, It.addToSelection = zI, It.getIntersectionList = XI, It.runExtensions = $I, It.groupSvgElem = YI, It.prepareSvg = ZI, It.recalculateAllSelectedDimensions = eM, It.setRotationAngle = JI;
}, HI = (o) => {
  It.getSelectedElements().forEach((e) => {
    e && It.selectorManager.releaseSelector(e);
  }), It?.setEmptySelectedElements(), o || It.call("selected", It.getSelectedElements());
}, zI = (o, e) => {
  const t = It.getSelectedElements();
  if (!o.length)
    return;
  let r = 0;
  for (; r < t.length && t[r] !== null; )
    ++r;
  let n = o.length;
  for (; n--; ) {
    let i = o[n];
    if (!(!i || !i.getBBox) && (i.tagName === "a" && i.childNodes.length === 1 && (i = i.firstChild), !t.includes(i))) {
      t[r] = i, r++;
      const a = It.selectorManager.requestSelector(i);
      t.length > 1 && a.showGrips(!1);
    }
  }
  if (t.length)
    for (It.call("selected", t), t.length === 1 && It.selectorManager.requestSelector(t[0]).showGrips(e), t.sort((i, a) => i && a && i.compareDocumentPosition ? 3 - (a.compareDocumentPosition(i) & 6) : i ? 0 : 1); !t[0]; )
      t.shift(0);
}, KI = (o) => {
  if (!o)
    return null;
  let e = o.target;
  if (e.correspondingUseElement && (e = e.correspondingUseElement), [vt.MATH, vt.HTML].includes(e.namespaceURI) && e.id !== "svgcanvas") {
    for (; e.nodeName !== "foreignObject"; )
      if (e = e.parentNode, !e)
        return It.getSvgRoot();
  }
  const t = It.getCurrentDrawing().getCurrentLayer(), r = It.getSvgRoot(), n = It.getDOMContainer(), i = It.getSvgContent();
  if ([r, n, i, t].includes(e))
    return It.getSvgRoot();
  if (HA(e.parentNode, "#selectorParentGroup"))
    return It.selectorManager.selectorParentGroup;
  for (; !e?.parentNode?.isSameNode(
    It.getCurrentGroup() || t
  ); )
    e = e.parentNode;
  return e;
}, $I = (o, e, t) => {
  let r = t ? [] : !1;
  for (const [n, i] of Object.entries(It.getExtensions()))
    if (typeof e == "function" && (e = e(n)), i.eventBased) {
      const a = new CustomEvent("svgedit", {
        detail: {
          action: o,
          vars: e
        }
      });
      document.dispatchEvent(a);
    } else i[o] && (t ? r.push(i[o](e)) : r = i[o](e));
  return r;
}, WI = (o) => {
  o || (o = It.getSvgContent().children);
  const e = [], t = o.children;
  return Array.from(t).forEach((r) => {
    r.getBBox && e.push({ elem: r, bbox: bi([r]) });
  }), e.reverse();
}, XI = (o) => {
  const e = It.getZoom();
  if (!It.getRubberBox())
    return null;
  const t = It.getCurrentGroup() || It.getCurrentDrawing().getCurrentLayer();
  let r;
  if (o)
    r = It.getSvgContent().createSVGRect(), r.x = o.x, r.y = o.y, r.width = o.width, r.height = o.height;
  else {
    r = so(It.getRubberBox());
    const a = It.getSvgContent().createSVGRect();
    ["x", "y", "width", "height", "top", "right", "bottom", "left"].forEach(
      (s) => {
        a[s] = r[s] / e;
      }
    ), r = a;
  }
  const n = [];
  It.getCurBBoxes().length === 0 && It.setCurBBoxes(WI(t));
  let i = It.getCurBBoxes().length;
  for (; i--; ) {
    const a = It.getCurBBoxes();
    r.width && a[i].bbox && H5(r, a[i].bbox) && n.push(a[i].elem);
  }
  return n;
}, YI = (o) => {
  const e = It.getDataStorage(), t = document.createElementNS(vt.SVG, "g");
  o.replaceWith(t), t.appendChild(o), e.put(t, "gsvg", o), t.id = It.getNextId();
}, ZI = (o) => {
  It.sanitizeSvg(o.documentElement), [...o.getElementsByTagNameNS(vt.SVG, "path")].forEach((e) => {
    const t = It.pathActions.convertPath(e);
    e.setAttribute("d", t), It.pathActions.fixEnd(e);
  });
}, JI = (o, e) => {
  const t = It.getSelectedElements();
  o = Number.parseFloat(o);
  const r = t[0], n = r.getAttribute("transform"), i = so(r), a = i.x + i.width / 2, s = i.y + i.height / 2, l = hr(r);
  if (l.numberOfItems > 0 && l.getItem(0).type === 4 && l.removeItem(0), o !== 0) {
    const c = cr(
      a,
      s,
      lr(l).matrix
    ), u = Number.isFinite(c.x) ? c.x : a, A = Number.isFinite(c.y) ? c.y : s, p = It.getSvgRoot().createSVGTransform();
    p.setRotate(o, u, A), l.numberOfItems ? l.insertItemBefore(p, 0) : l.appendItem(p);
  } else l.numberOfItems === 0 && r.removeAttribute("transform");
  if (!e) {
    let c = r.getAttribute("transform");
    if (c && c.startsWith("rotate(")) {
      const u = c.match(/^rotate\(([\d.\-e]+)\s+([\d.\-e]+)\s+([\d.\-e]+)\)(.*)/);
      if (u) {
        const A = Number.parseFloat(u[1]), p = (f) => Math.round(Number(f) + Number.EPSILON), d = p(u[2]), g = p(u[3]), _ = u[4] || "";
        c = `rotate(${A} ${d} ${g})${_}`;
      }
    }
    n ? r.setAttribute("transform", n) : r.removeAttribute("transform"), It.changeSelectedAttribute(
      "transform",
      c,
      t
    ), It.call("changed", t);
  }
  It.selectorManager.requestSelector(
    t[0]
  ).resize(), It.getSelector().updateGripCursors(o);
}, eM = () => {
  const o = It.getCurrentResizeMode() === "none" ? "position" : "size", e = new VI(o), t = It.getSelectedElements();
  t.forEach((r) => {
    const n = It.recalculateDimensions(r);
    n && e.addSubCommand(n);
  }), e.isEmpty() || (It.addCommandToHistory(e), It.call("changed", t));
};
let Dr = null;
const tM = (o) => {
  Dr = o;
};
class rM {
  #t = null;
  #e = null;
  #r = null;
  #o = null;
  #a = null;
  #n = [];
  #i = null;
  // , transbb;
  #l = null;
  #d = null;
  #p = null;
  #h = !1;
  /**
   * Get the accumulated transformation matrix from the element up to the SVG content element.
   * This includes transforms from all parent groups, fixing the issue where text cursor
   * appears in the wrong position when editing text inside a transformed group.
   * @param {Element} elem - The element to get the accumulated matrix for
   * @returns {SVGMatrix|null} The accumulated transformation matrix, or null if none
   * @private
   */
  #b = (e) => {
    const t = Dr.getSvgContent(), r = [];
    let n = e;
    for (; n && n !== t && n.nodeType === 1; ) {
      const i = hr(n);
      if (i && i.numberOfItems > 0) {
        const a = lr(i).matrix;
        r.unshift(a);
      }
      n = n.parentNode;
    }
    return r.length === 0 ? null : r.length === 1 ? r[0] : Ro(...r);
  };
  /**
   *
   * @param {Integer} index
   * @returns {void}
   * @private
   */
  #u = (e = void 0) => {
    const t = this.#e.value === "";
    if (this.#e.focus(), e === void 0)
      if (t)
        e = 0;
      else {
        if (this.#e.selectionEnd !== this.#e.selectionStart)
          return;
        e = this.#e.selectionEnd;
      }
    const r = this.#n[e];
    t || this.#e.setSelectionRange(e, e), this.#r = wr("text_cursor"), this.#r || (this.#r = document.createElementNS(vt.SVG, "line"), br(this.#r, {
      id: "text_cursor",
      stroke: "#333",
      "stroke-width": 1
    }), wr("selectorParentGroup").append(this.#r)), this.#a || (this.#a = setInterval(() => {
      const a = this.#r.getAttribute("display") === "none";
      this.#r.setAttribute("display", a ? "inline" : "none");
    }, 600));
    const n = this.#s(r.x, this.#i.y), i = this.#s(r.x, this.#i.y + this.#i.height);
    br(this.#r, {
      x1: n.x,
      y1: n.y,
      x2: i.x,
      y2: i.y,
      visibility: "visible",
      display: "inline"
    }), this.#o && this.#o.setAttribute("d", "");
  };
  /**
   *
   * @param {Integer} start
   * @param {Integer} end
   * @param {boolean} skipInput
   * @returns {void}
   * @private
   */
  #A = (e, t, r) => {
    if (e === t) {
      this.#u(t);
      return;
    }
    r || this.#e.setSelectionRange(e, t), this.#o = wr("text_selectblock"), this.#o || (this.#o = document.createElementNS(vt.SVG, "path"), br(this.#o, {
      id: "text_selectblock",
      fill: "green",
      opacity: 0.5,
      style: "pointer-events:none"
    }), wr("selectorParentGroup").append(this.#o));
    const n = this.#n[e], i = this.#n[t];
    this.#r.setAttribute("visibility", "hidden");
    const a = this.#s(n.x, this.#i.y), s = this.#s(n.x + (i.x - n.x), this.#i.y), l = this.#s(n.x, this.#i.y + this.#i.height), c = this.#s(
      n.x + (i.x - n.x),
      this.#i.y + this.#i.height
    ), u = "M" + a.x + "," + a.y + " L" + s.x + "," + s.y + " " + c.x + "," + c.y + " " + l.x + "," + l.y + "z";
    br(this.#o, {
      d: u,
      display: "inline"
    });
  };
  /**
   *
   * @param {Float} mouseX
   * @param {Float} mouseY
   * @returns {Integer}
   * @private
   */
  #g = (e, t) => {
    const r = Dr.getSvgRoot().createSVGPoint();
    if (r.x = e, r.y = t, this.#n.length === 1)
      return 0;
    let n = this.#t.getCharNumAtPosition(r);
    n < 0 ? (n = this.#n.length - 2, e <= this.#n[0].x && (n = 0)) : n >= this.#n.length - 2 && (n = this.#n.length - 2);
    const i = this.#n[n], a = i.x + i.width / 2;
    return e > a && n++, n;
  };
  /**
   *
   * @param {Float} mouseX
   * @param {Float} mouseY
   * @returns {void}
   * @private
   */
  #f = (e, t) => {
    this.#u(this.#g(e, t));
  };
  /**
   *
   * @param {Float} x
   * @param {Float} y
   * @param {boolean} apply
   * @returns {void}
   * @private
   */
  #m = (e, t, r) => {
    const n = this.#e.selectionStart, i = this.#g(e, t), a = Math.min(n, i), s = Math.max(n, i);
    this.#A(a, s, !r);
  };
  /**
   *
   * @param {Float} xIn
   * @param {Float} yIn
   * @returns {module:math.XYObject}
   * @private
   */
  #c = (e, t) => {
    const r = {
      x: e,
      y: t
    }, n = Dr.getZoom();
    if (r.x /= n, r.y /= n, this.#l) {
      const i = cr(r.x, r.y, this.#l.inverse());
      r.x = i.x, r.y = i.y;
    }
    return r;
  };
  /**
   *
   * @param {Float} xIn
   * @param {Float} yIn
   * @returns {module:math.XYObject}
   * @private
   */
  #s = (e, t) => {
    const r = {
      x: e,
      y: t
    };
    if (this.#l) {
      const i = cr(r.x, r.y, this.#l);
      r.x = i.x, r.y = i.y;
    }
    const n = Dr.getZoom();
    return r.x *= n, r.y *= n, r;
  };
  /**
   *
   * @param {Event} evt
   * @returns {void}
   * @private
   */
  #_ = (e) => {
    this.#A(0, this.#t.textContent.length), e.target.removeEventListener("click", this.#_);
  };
  /**
   *
   * @param {Event} evt
   * @returns {void}
   * @private
   */
  #y = (e) => {
    if (!this.#h || !this.#t)
      return;
    const t = Dr.getZoom(), r = cr(e.pageX, e.pageY, Dr.getrootSctm()), n = r.x * t, i = r.y * t, a = this.#c(n, i), s = this.#g(a.x, a.y), l = this.#t.textContent, c = l.slice(0, s).replace(/[a-z\d]+$/i, "").length, u = l.slice(s).match(/^[a-z\d]+/i), A = (u ? u[0].length : 0) + s;
    this.#A(c, A), Dr.$click(e.target, this.#_), setTimeout(() => {
      e.target.removeEventListener("click", this.#_);
    }, 300);
  };
  /**
   * @param {Element} target
   * @param {Float} x
   * @param {Float} y
   * @returns {void}
   */
  select(e, t, r) {
    this.#t = e, Dr.textActions.toEditMode(t, r);
  }
  /**
   * @param {Element} elem
   * @returns {void}
   */
  start(e) {
    this.#t = e, Dr.textActions.toEditMode();
  }
  /**
   * @param {external:MouseEvent} evt
   * @param {Element} mouseTarget
   * @param {Float} startX
   * @param {Float} startY
   * @returns {void}
   */
  mouseDown(e, t, r, n) {
    const i = this.#c(r, n);
    this.#e.focus(), this.#f(i.x, i.y), this.#d = r, this.#p = n;
  }
  /**
   * @param {Float} mouseX
   * @param {Float} mouseY
   * @returns {void}
   */
  mouseMove(e, t) {
    const r = this.#c(e, t);
    this.#m(r.x, r.y);
  }
  /**
   * @param {external:MouseEvent} evt
   * @param {Float} mouseX
   * @param {Float} mouseY
   * @returns {void}
   */
  mouseUp(e, t, r) {
    const n = this.#c(t, r);
    this.#m(n.x, n.y, !0), e.target !== this.#t && t < this.#d + 2 && t > this.#d - 2 && r < this.#p + 2 && r > this.#p - 2 && Dr.textActions.toSelectMode(!0);
  }
  /**
   * @param {Integer} index
   * @returns {void}
   */
  setCursor(e) {
    this.#u(e);
  }
  /**
   * @param {Float} x
   * @param {Float} y
   * @returns {void}
   */
  toEditMode(e, t) {
    if (this.#h = !1, Dr.setCurrentMode("textedit"), Dr.selectorManager.requestSelector(this.#t).showGrips(!1), Dr.selectorManager.requestSelector(this.#t), Dr.textActions.init(), this.#t.style.cursor = "text", arguments.length === 0)
      this.#u();
    else {
      const r = this.#c(e, t);
      this.#f(r.x, r.y);
    }
    setTimeout(() => {
      this.#h = !0;
    }, 300);
  }
  /**
   * @param {boolean|Element} selectElem
   * @fires module:svgcanvas.SvgCanvas#event:selected
   * @returns {void}
   */
  toSelectMode(e) {
    Dr.setCurrentMode("select"), clearInterval(this.#a), this.#a = null, this.#o && this.#o.setAttribute("display", "none"), this.#r && this.#r.setAttribute("visibility", "hidden"), this.#t.style.cursor = "move", e && (Dr.clearSelection(), this.#t.style.cursor = "move", Dr.call("selected", [this.#t]), Dr.addToSelection([this.#t], !0)), this.#t?.textContent.length || Dr.deleteSelectedElements(), this.#e.blur(), this.#t = !1;
  }
  /**
   * @param {Element} elem
   * @returns {void}
   */
  setInputElem(e) {
    this.#e = e;
  }
  /**
   * @returns {void}
   */
  clear() {
    Dr.getCurrentMode() === "textedit" && Dr.textActions.toSelectMode();
  }
  /**
   * @param {Element} _inputElem Not in use
   * @returns {void}
   */
  init(e) {
    if (!this.#t)
      return;
    let t, r;
    if (!this.#t.parentNode) {
      const i = Dr.getSelectedElements();
      this.#t = i[0], Dr.selectorManager.requestSelector(this.#t).showGrips(!1);
    }
    const n = this.#t.textContent.length;
    for (this.#i = so(this.#t), this.#l = this.#b(this.#t), this.#n = [], this.#n.length = n, this.#e.focus(), this.#t.removeEventListener("dblclick", this.#y), this.#t.addEventListener("dblclick", this.#y), n || (r = { x: this.#i.x + this.#i.width / 2, width: 0 }), t = 0; t < n; t++) {
      const i = this.#t.getStartPositionOfChar(t);
      if (r = this.#t.getEndPositionOfChar(t), !MI()) {
        const a = Dr.getZoom(), s = Dr.contentW * a;
        i.x -= s, r.x -= s, i.x /= a, r.x /= a;
      }
      this.#n[t] = {
        x: i.x,
        y: this.#i.y,
        // start.y?
        width: r.x - i.x,
        height: this.#i.height
      };
    }
    this.#n.push({
      x: r.x,
      width: 0
    }), this.#A(this.#e.selectionStart, this.#e.selectionEnd, !0);
  }
}
const oM = new rM(), {
  InsertElementCommand: nM,
  BatchCommand: iM,
  ChangeElementCommand: K0
} = Gl;
let N = null, Zp = !1;
const aM = (o) => {
  N = o, N.mouseDownEvent = dM, N.mouseMoveEvent = lM, N.dblClickEvent = AM, N.mouseUpEvent = uM, N.mouseOutEvent = cM, N.DOMMouseScrollEvent = pM;
}, $0 = (o) => {
  const e = { x: 0, y: 0 }, t = { x: N.getControllPoint2("x"), y: N.getControllPoint2("y") }, r = { x: N.getControllPoint1("x"), y: N.getControllPoint1("y") }, n = { x: N.getStart("x"), y: N.getStart("y") }, i = { x: N.getEnd("x"), y: N.getEnd("y") }, a = 1 / 6, s = o * o, l = s * o, c = [
    [-1, 3, -3, 1],
    [3, -6, 3, 0],
    [-3, 0, 3, 0],
    [1, 4, 1, 0]
  ];
  return e.x = a * ((t.x * c[0][0] + r.x * c[0][1] + n.x * c[0][2] + i.x * c[0][3]) * l + (t.x * c[1][0] + r.x * c[1][1] + n.x * c[1][2] + i.x * c[1][3]) * s + (t.x * c[2][0] + r.x * c[2][1] + n.x * c[2][2] + i.x * c[2][3]) * o + (t.x * c[3][0] + r.x * c[3][1] + n.x * c[3][2] + i.x * c[3][3])), e.y = a * ((t.y * c[0][0] + r.y * c[0][1] + n.y * c[0][2] + i.y * c[0][3]) * l + (t.y * c[1][0] + r.y * c[1][1] + n.y * c[1][2] + i.y * c[1][3]) * s + (t.y * c[2][0] + r.y * c[2][1] + n.y * c[2][2] + i.y * c[2][3]) * o + (t.y * c[3][0] + r.y * c[3][1] + n.y * c[3][2] + i.y * c[3][3])), {
    x: e.x,
    y: e.y
  };
}, sM = (o, e, t, r) => {
  const n = o.createSVGTransform();
  n.setTranslate(t, r);
  const i = hr(e);
  i && (i.numberOfItems ? i.getItem(0).type === 2 ? i.replaceItem(n, 0) : i.insertItemBefore(n, 0) : i.appendItem(n));
}, lM = (o) => {
  if (!N.getStarted() || o.button === 1 || N.spaceKey)
    return;
  N.textActions.init(), o.preventDefault();
  const e = N.getSelectedElements(), t = N.getZoom(), r = N.getSvgRoot(), n = e[0];
  let i, a, s, l, c, u, A, p, d;
  const g = cr(o.clientX, o.clientY, N.getrootSctm()), _ = g.x * t, f = g.y * t, m = wr(N.getId());
  let b = _ / t, v = b, w = f / t, C = w;
  N.getCurConfig().gridSnapping && (v = ar(v), C = ar(C));
  let E;
  switch (N.getCurrentMode()) {
    case "select": {
      if (!N.hasDragStartTransform && e.length > 0) {
        N.dragStartTransforms = /* @__PURE__ */ new Map();
        for (const T of e) {
          if (!T)
            continue;
          N.dragStartTransforms.set(T, T.getAttribute("transform") || "");
          const F = hr(T);
          F && (F.numberOfItems ? F.insertItemBefore(r.createSVGTransform(), 0) : F.appendItem(r.createSVGTransform()));
        }
        N.hasDragStartTransform = !0;
      }
      if (n) {
        c = v - N.getStartX(), u = C - N.getStartY(), N.getCurConfig().gridSnapping && (c = ar(c), u = ar(u));
        const T = 4, F = Math.abs(c) > T || Math.abs(u) > T;
        Zp = Zp || F, Zp && (e.forEach((B) => {
          B && (sM(r, B, c, u), N.selectorManager.requestSelector(B).resize());
        }), N.call("transition", e));
      }
      break;
    }
    case "multiselect": {
      b *= t, w *= t, br(N.getRubberBox(), {
        x: Math.min(N.getRStartX(), b),
        y: Math.min(N.getRStartY(), w),
        width: Math.abs(b - N.getRStartX()),
        height: Math.abs(w - N.getRStartY())
      });
      const T = e.slice(), F = [], B = N.getIntersectionList();
      for (A = B.length, i = 0; i < A; ++i) {
        const P = B[i];
        e.includes(P) || F.push(P);
        const S = T.indexOf(P);
        S !== -1 && T.splice(S, 1);
      }
      T.length > 0 && N.removeFromSelection(T), F.length > 0 && N.addToSelection(F);
      break;
    }
    case "resize": {
      if (E = hr(n), !E)
        break;
      const T = Ml(E);
      d = T ? N.getInitBbox() : so(n);
      let F = d.x, B = d.y, { width: P, height: S } = d;
      if (c = v - N.getStartX(), u = C - N.getStartY(), N.getCurConfig().gridSnapping && (c = ar(c), u = ar(u), S = ar(S), P = ar(P)), p = en(n), p) {
        const oe = Math.sqrt(c * c + u * u), de = Math.atan2(u, c) - p * Math.PI / 180;
        c = oe * Math.cos(de), u = oe * Math.sin(de);
      }
      !N.getCurrentResizeMode().includes("n") && !N.getCurrentResizeMode().includes("s") && (u = 0), !N.getCurrentResizeMode().includes("e") && !N.getCurrentResizeMode().includes("w") && (c = 0);
      let L = 0, U = 0, O = S ? (S + u) / S : 1, K = P ? (P + c) / P : 1;
      N.getCurrentResizeMode().includes("n") && (O = S ? (S - u) / S : 1, U = S), N.getCurrentResizeMode().includes("w") && (K = P ? (P - c) / P : 1, L = P);
      const te = r.createSVGTransform(), Y = r.createSVGTransform(), ee = r.createSVGTransform();
      if (N.getCurConfig().gridSnapping && (F = ar(F), L = ar(L), B = ar(B), U = ar(U)), te.setTranslate(-(F + L), -(B + U)), (n.tagName !== "image" && o.shiftKey || n.tagName === "image" && !o.shiftKey) && (K === 1 ? K = O : O = K), Y.setScale(K, O), ee.setTranslate(F + L, B + U), T) {
        const oe = p ? 1 : 0;
        E.replaceItem(te, 2 + oe), E.replaceItem(Y, 1 + oe), E.replaceItem(ee, Number(oe));
      } else {
        const oe = E.numberOfItems;
        E.replaceItem(ee, oe - 3), E.replaceItem(Y, oe - 2), E.replaceItem(te, oe - 1);
      }
      N.selectorManager.requestSelector(n).resize(), N.call("transition", e);
      break;
    }
    case "zoom": {
      b *= t, w *= t, br(N.getRubberBox(), {
        x: Math.min(N.getRStartX() * t, b),
        y: Math.min(N.getRStartY() * t, w),
        width: Math.abs(b - N.getRStartX() * t),
        height: Math.abs(w - N.getRStartY() * t)
      });
      break;
    }
    case "text": {
      br(m, {
        x: v,
        y: C
      });
      break;
    }
    case "line": {
      N.getCurConfig().gridSnapping && (v = ar(v), C = ar(C));
      let T = v, F = C;
      o.shiftKey && (a = ab(N.getStartX(), N.getStartY(), T, F), T = a.x, F = a.y), m.setAttribute("x2", T), m.setAttribute("y2", F);
      break;
    }
    case "foreignObject":
    // fall through
    case "square":
    case "rect":
    case "image": {
      const T = N.getCurrentMode() === "square" || N.getCurrentMode() === "image" && !o.shiftKey || N.getCurrentMode() !== "image" && o.shiftKey;
      let F = Math.abs(v - N.getStartX()), B = Math.abs(C - N.getStartY()), P, S;
      T ? (F = B = Math.max(F, B), P = N.getStartX() < v ? N.getStartX() : N.getStartX() - F, S = N.getStartY() < C ? N.getStartY() : N.getStartY() - B) : (P = Math.min(N.getStartX(), v), S = Math.min(N.getStartY(), C)), N.getCurConfig().gridSnapping && (F = ar(F), B = ar(B), P = ar(P), S = ar(S)), br(m, {
        width: F,
        height: B,
        x: P,
        y: S
      });
      break;
    }
    case "circle": {
      s = Number(m.getAttribute("cx")), l = Number(m.getAttribute("cy"));
      let T = Math.sqrt((v - s) * (v - s) + (C - l) * (C - l));
      N.getCurConfig().gridSnapping && (T = ar(T)), m.setAttribute("r", T);
      break;
    }
    case "ellipse": {
      s = Number(m.getAttribute("cx")), l = Number(m.getAttribute("cy")), N.getCurConfig().gridSnapping && (v = ar(v), s = ar(s), C = ar(C), l = ar(l)), m.setAttribute("rx", Math.abs(v - s));
      const T = Math.abs(o.shiftKey ? v - s : C - l);
      m.setAttribute("ry", T);
      break;
    }
    case "fhellipse":
    case "fhrect":
      N.setFreehand("minx", Math.min(b, N.getFreehand("minx"))), N.setFreehand("maxx", Math.max(b, N.getFreehand("maxx"))), N.setFreehand("miny", Math.min(w, N.getFreehand("miny"))), N.setFreehand("maxy", Math.max(w, N.getFreehand("maxy")));
    // Fallthrough
    case "fhpath": {
      if (N.setEnd("x", b), N.setEnd("y", w), N.getControllPoint2("x") && N.getControllPoint2("y")) {
        for (i = 0; i < N.getStepCount() - 1; i++)
          if (N.setParameter(i / N.getStepCount()), N.setNextParameter((i + 1) / N.getStepCount()), N.setbSpline($0(N.getNextParameter())), N.setNextPos({ x: N.getbSpline("x"), y: N.getbSpline("y") }), N.setbSpline($0(N.getParameter())), N.setSumDistance(
            N.getSumDistance() + Math.sqrt((N.getNextPos("x") - N.getbSpline("x")) * (N.getNextPos("x") - N.getbSpline("x")) + (N.getNextPos("y") - N.getbSpline("y")) * (N.getNextPos("y") - N.getbSpline("y")))
          ), N.getSumDistance() > N.getThreSholdDist()) {
            N.setSumDistance(N.getSumDistance() - N.getThreSholdDist());
            const T = N.getSvgContent().createSVGPoint();
            T.x = N.getbSpline("x"), T.y = N.getbSpline("y"), m.points.appendItem(T);
          }
      }
      N.setControllPoint2("x", N.getControllPoint1("x")), N.setControllPoint2("y", N.getControllPoint1("y")), N.setControllPoint1("x", N.getStart("x")), N.setControllPoint1("y", N.getStart("y")), N.setStart({ x: N.getEnd("x"), y: N.getEnd("y") });
      break;
    }
    case "path":
    // fall through
    case "pathedit": {
      if (v *= t, C *= t, N.getCurConfig().gridSnapping && (v = ar(v), C = ar(C), N.setStartX(ar(N.getStartX())), N.setStartY(ar(N.getStartY()))), o.shiftKey) {
        const { path: T } = wE;
        let F, B;
        T ? (F = T.dragging ? T.dragging[0] : N.getStartX(), B = T.dragging ? T.dragging[1] : N.getStartY()) : (F = N.getStartX(), B = N.getStartY()), a = ab(F, B, v, C), { x: v, y: C } = a;
      }
      N.getRubberBox()?.getAttribute("display") !== "none" && (b *= t, w *= t, br(N.getRubberBox(), {
        x: Math.min(N.getRStartX() * t, b),
        y: Math.min(N.getRStartY() * t, w),
        width: Math.abs(b - N.getRStartX() * t),
        height: Math.abs(w - N.getRStartY() * t)
      })), N.pathActions.mouseMove(v, C);
      break;
    }
    case "textedit": {
      v *= t, C *= t, N.textActions.mouseMove(_, f);
      break;
    }
    case "rotate": {
      d = so(n), s = d.x + d.width / 2, l = d.y + d.height / 2;
      const T = D5(n), F = cr(s, l, T);
      s = F.x, l = F.y, p = (Math.atan2(l - C, s - v) * (180 / Math.PI) - 90) % 360, N.getCurConfig().gridSnapping && (p = ar(p)), o.shiftKey && (p = Math.round(p / 45) * 45), N.setRotationAngle(p < -180 ? 360 + p : p, !0), N.call("transition", e);
      break;
    }
  }
  N.runExtensions(
    "mouseMove",
    /** @type {module:svgcanvas.SvgCanvas#event:ext_mouseMove} */
    {
      event: o,
      mouse_x: _,
      mouse_y: f,
      selected: n
    }
  );
}, cM = (o) => {
  const { $id: e } = N;
  if (N.getCurrentMode() !== "select" && N.getStarted()) {
    const t = new MouseEvent("mouseup", {
      bubbles: !0,
      cancelable: !0,
      clientX: o?.clientX ?? 0,
      clientY: o?.clientY ?? 0,
      button: o?.button ?? 0,
      buttons: o?.buttons ?? 0,
      altKey: o?.altKey ?? !1,
      ctrlKey: o?.ctrlKey ?? !1,
      metaKey: o?.metaKey ?? !1,
      shiftKey: o?.shiftKey ?? !1
    });
    e("svgcanvas").dispatchEvent(t);
  }
}, uM = (o) => {
  if (o.preventDefault(), Zp = !1, o.button === 2 || !N.getStarted())
    return;
  N.textActions.init();
  const e = N.getSelectedElements(), t = N.getZoom(), r = N.getJustSelected();
  N.setJustSelected(null);
  const n = cr(o.clientX, o.clientY, N.getrootSctm()), i = n.x * t, a = n.y * t, s = i / t, l = a / t;
  let c = wr(N.getId()), u = !1;
  const A = s, p = l;
  N.setStarted(!1);
  let d;
  switch (N.getCurrentMode()) {
    // intentionally fall-through to select here
    case "resize":
    case "multiselect":
      N.getRubberBox() && (N.getRubberBox().setAttribute("display", "none"), N.setCurBBoxes([])), N.setCurrentMode("select");
    // Fallthrough
    case "select":
      if (e[0]) {
        if (!e[1]) {
          const _ = e[0];
          switch (_.tagName) {
            case "g":
            case "use":
            case "image":
            case "foreignObject":
              break;
            case "text":
              N.setCurText("font_size", _.getAttribute("font-size")), N.setCurText("font_family", _.getAttribute("font-family"));
            // fallthrough
            default:
              N.setCurProperties("fill", _.getAttribute("fill")), N.setCurProperties("fill_opacity", _.getAttribute("fill-opacity")), N.setCurProperties("stroke", _.getAttribute("stroke")), N.setCurProperties("stroke_opacity", _.getAttribute("stroke-opacity")), N.setCurProperties("stroke_width", _.getAttribute("stroke-width")), N.setCurProperties("stroke_dasharray", _.getAttribute("stroke-dasharray")), N.setCurProperties("stroke_linejoin", _.getAttribute("stroke-linejoin")), N.setCurProperties("stroke_linecap", _.getAttribute("stroke-linecap"));
          }
          N.selectorManager.requestSelector(_).showGrips(!0);
        }
        if (A !== N.getRStartX() || p !== N.getRStartY()) {
          const _ = new iM("position");
          e.forEach((m) => {
            if (!m) return;
            const b = hr(m);
            if (!b || b.numberOfItems === 0) return;
            const v = N.dragStartTransforms?.get(m) || "", w = b.getItem(0).type === 2, C = m.tagName === "g" || m.tagName === "a";
            if (b.numberOfItems > 1 && w || C && w) {
              const T = lr(b).matrix;
              for (; b.numberOfItems > 0; )
                b.removeItem(0);
              const F = N.getSvgRoot().createSVGTransform();
              F.setMatrix(T), b.appendItem(F), _.addSubCommand(new K0(m, { transform: v }));
              return;
            }
            const E = N.recalculateDimensions(m);
            E ? _.addSubCommand(E) : (m.getAttribute("transform") || "") !== v && _.addSubCommand(new K0(m, { transform: v }));
          }), _.isEmpty() || N.addCommandToHistory(_), N.dragStartTransforms = null, N.hasDragStartTransform = !1;
          const f = e.length;
          for (let m = 0; m < f && e[m]; ++m)
            N.selectorManager.requestSelector(e[m]).resize();
        } else
          d = o.target, e[0].nodeName === "path" && !e[1] ? N.pathActions.select(e[0]) : o.shiftKey && r !== d && N.removeFromSelection([d]);
        const g = e[0];
        g && (g.removeAttribute("style"), g.localName === "foreignObject" ? Wa(g, (_) => {
          _.style.removeProperty("pointer-events");
        }) : Wa(g, (_) => {
          _.removeAttribute("style");
        }));
      }
      return;
    case "zoom": {
      N.getRubberBox()?.setAttribute("display", "none");
      const g = o.shiftKey ? 0.5 : 2;
      N.call("zoomed", {
        x: Math.min(N.getRStartX(), A),
        y: Math.min(N.getRStartY(), p),
        width: Math.abs(A - N.getRStartX()),
        height: Math.abs(p - N.getRStartY()),
        factor: g
      });
      return;
    }
    case "fhpath": {
      N.setSumDistance(0), N.setControllPoint2("x", 0), N.setControllPoint2("y", 0), N.setControllPoint1("x", 0), N.setControllPoint1("y", 0), N.setStart({ x: 0, y: 0 }), N.setEnd("x", 0), N.setEnd("y", 0);
      const g = c.getAttribute("points"), _ = g.indexOf(",");
      u = _ >= 0 ? g.includes(",", _ + 1) : g.includes(" ", g.indexOf(" ") + 1), u && (c = N.pathActions.smoothPolylineIntoPath(c));
      break;
    }
    case "line":
      {
        const g = c.getAttribute("x1"), _ = c.getAttribute("y1"), f = c.getAttribute("x2"), m = c.getAttribute("y2");
        u = g !== f || _ !== m;
      }
      break;
    case "foreignObject":
    case "square":
    case "rect":
    case "image":
      {
        const g = c.getAttribute("width"), _ = c.getAttribute("height"), f = Number(g), m = Number(_);
        u = f >= 1 || m >= 1 || N.getCurrentMode() === "image";
      }
      break;
    case "circle":
      u = c.getAttribute("r") !== "0";
      break;
    case "ellipse":
      {
        const g = Number(c.getAttribute("rx")), _ = Number(c.getAttribute("ry"));
        u = g || _;
      }
      break;
    case "fhellipse":
      N.getFreehand("maxx") - N.getFreehand("minx") > 0 && N.getFreehand("maxy") - N.getFreehand("miny") > 0 && (c = N.addSVGElementsFromJson({
        element: "ellipse",
        curStyles: !0,
        attr: {
          cx: (N.getFreehand("minx") + N.getFreehand("maxx")) / 2,
          cy: (N.getFreehand("miny") + N.getFreehand("maxy")) / 2,
          rx: (N.getFreehand("maxx") - N.getFreehand("minx")) / 2,
          ry: (N.getFreehand("maxy") - N.getFreehand("miny")) / 2,
          id: N.getId()
        }
      }), N.call("changed", [c]), u = !0);
      break;
    case "fhrect":
      N.getFreehand("maxx") - N.getFreehand("minx") > 0 && N.getFreehand("maxy") - N.getFreehand("miny") > 0 && (c = N.addSVGElementsFromJson({
        element: "rect",
        curStyles: !0,
        attr: {
          x: N.getFreehand("minx"),
          y: N.getFreehand("miny"),
          width: N.getFreehand("maxx") - N.getFreehand("minx"),
          height: N.getFreehand("maxy") - N.getFreehand("miny"),
          id: N.getId()
        }
      }), N.call("changed", [c]), u = !0);
      break;
    case "text":
      u = !0, N.selectOnly([c]), N.textActions.start(c);
      break;
    case "path": {
      c = null, N.setStarted(!0);
      const g = N.pathActions.mouseUp(o, c, i, a);
      ({ element: c } = g), { keep: u } = g;
      break;
    }
    case "pathedit":
      u = !0, c = null, N.pathActions.mouseUp(o);
      break;
    case "textedit":
      u = !1, c = null, N.textActions.mouseUp(o, i, a);
      break;
    case "rotate": {
      N.hasDragStartTransform = !1, N.dragStartTransforms = null, u = !0, c = null, N.setCurrentMode("select");
      const g = N.undoMgr.finishUndoableChange();
      g.isEmpty() || N.addCommandToHistory(g), N.recalculateAllSelectedDimensions(), N.call("changed", e);
      break;
    }
    default:
      N.hasDragStartTransform = !1, N.dragStartTransforms = null;
      break;
  }
  if (N.hasDragStartTransform = !1, N.dragStartTransforms = null, N.runExtensions("mouseUp", {
    event: o,
    mouse_x: i,
    mouse_y: a
  }, !0).forEach((g) => {
    g && (u = g.keep || u, { element: c } = g, N.setStarted(g.started || N.getStarted()));
  }), !u && c) {
    for (N.getCurrentDrawing().releaseId(N.getId()), c.remove(), c = null, d = o.target; d?.parentNode?.parentNode?.tagName === "g"; )
      d = d.parentNode;
    (N.getCurrentMode() !== "path" || !N.getDrawnPath()) && d && d.parentNode?.id !== "selectorParentGroup" && d.id !== "svgcanvas" && d.id !== "svgroot" && (N.setMode("select"), N.selectOnly([d], !0));
  } else if (c) {
    N.addedNew = !0;
    let g = 0.2, _;
    const f = N.getStyle(), m = N.getOpacAni();
    if (m.beginElement && Number.parseFloat(c.getAttribute("opacity")) !== f.opacity) {
      _ = m.cloneNode(!0), _.setAttribute("to", f.opacity), _.setAttribute("dur", g), c.appendChild(_);
      try {
        _.beginElement();
      } catch {
      }
    } else
      g = 0;
    setTimeout(() => {
      _ && _.remove(), c.setAttribute("opacity", f.opacity), c.setAttribute("style", "pointer-events:inherit"), Vh(c), N.getCurrentMode() === "path" ? N.pathActions.toEditMode(c) : N.getCurConfig().selectNew && (["circle", "ellipse", "square", "rect", "fhpath", "line", "fhellipse", "fhrect", "star", "polygon", "shapelib"].indexOf(N.getCurrentMode()) !== -1 && !o.altKey && N.setMode("select"), N.selectOnly([c], !0)), N.addCommandToHistory(new nM(c)), N.call("changed", [c]);
    }, g * 1e3);
  }
  N.setStartTransform(null);
}, AM = (o) => {
  const e = N.getSelectedElements(), t = o.target.parentNode;
  let r = N.getMouseTarget(o);
  const { tagName: n } = r;
  if (n === "text" && N.getCurrentMode() !== "textedit") {
    const i = cr(o.clientX, o.clientY, N.getrootSctm());
    N.textActions.select(r, i.x, i.y);
  }
  t !== N.getCurrentGroup() && ((n === "g" || n === "a") && en(r) && (N.pushGroupProperties(r), r = e[0], N.clearSelection(!0)), N.getCurrentGroup() && $s(), !(t.tagName !== "g" && t.tagName !== "a" || t === N.getCurrentDrawing().getCurrentLayer() || r === N.selectorManager.selectorParentGroup) && kE(r));
}, dM = (o) => {
  const e = N.getDataStorage(), t = N.getSelectedElements(), r = N.getZoom(), n = N.getStyle(), i = N.getSvgRoot(), { $id: a } = N;
  if (N.spaceKey || o.button === 1)
    return;
  const s = o.button === 2;
  o.altKey && N.cloneSelectedElements(0, 0);
  const l = a("svgcontent")?.querySelector("g")?.getScreenCTM?.();
  if (!l)
    return;
  N.setRootSctm(l.inverse());
  const c = cr(o.clientX, o.clientY, N.getrootSctm()), u = c.x * r, A = c.y * r;
  if (o.preventDefault(), s) {
    if (N.getCurrentMode() === "path")
      return;
    N.setCurrentMode("select"), N.setLastClickPoint(c);
  }
  let p = u / r, d = A / r, g = N.getMouseTarget(o);
  g.tagName === "a" && g.childNodes.length === 1 && (g = g.firstChild);
  const _ = p;
  N.setStartX(p), N.setRStartX(p);
  const f = d;
  if (N.setStartY(d), N.setRStartY(d), N.getCurConfig().gridSnapping && (p = ar(p), d = ar(d), N.setStartX(ar(N.getStartX())), N.setStartY(ar(N.getStartY()))), g === N.selectorManager.selectorParentGroup && t[0]) {
    const b = o.target, v = e.get(b, "type");
    v === "rotate" ? N.setCurrentMode("rotate") : v === "resize" && (N.setCurrentMode("resize"), N.setCurrentResizeMode(e.get(b, "dir"))), g = t[0];
  }
  N.setStartTransform(g.getAttribute("transform"));
  const m = hr(g);
  if (m?.numberOfItems > 1 && g.tagName !== "g" && g.tagName !== "a") {
    const b = lr(m).matrix;
    for (; m.numberOfItems > 0; )
      m.removeItem(0);
    const v = N.getSvgRoot().createSVGTransform();
    v.setMatrix(b), m.appendItem(v);
  }
  switch (N.getCurrentMode()) {
    case "select":
      N.setStarted(!0), N.setCurrentResizeMode("none"), s && N.setStarted(!1), g !== i ? t.includes(g) || (o.shiftKey || N.clearSelection(!0), N.addToSelection([g]), N.setJustSelected(g), N.pathActions.clear()) : s || (N.clearSelection(), N.setCurrentMode("multiselect"), N.getRubberBox() || N.setRubberBox(N.selectorManager.getRubberBandBox()), N.setRStartX(N.getRStartX() * r), N.setRStartY(N.getRStartY() * r), br(N.getRubberBox(), {
        x: N.getRStartX(),
        y: N.getRStartY(),
        width: 0,
        height: 0,
        display: "inline"
      }));
      break;
    case "zoom":
      N.setStarted(!0), N.getRubberBox() || N.setRubberBox(N.selectorManager.getRubberBandBox()), br(N.getRubberBox(), {
        x: _ * r,
        y: f * r,
        width: 0,
        height: 0,
        display: "inline"
      });
      break;
    case "resize": {
      if (!m)
        break;
      N.setStarted(!0), N.setStartX(p), N.setStartY(d), N.setInitBbox(so(a("selectedBox0")));
      const b = {};
      for (const [w, C] of Object.entries(N.getInitBbox()))
        b[w] = C / r;
      N.setInitBbox(b);
      const v = en(g) ? 1 : 0;
      Ml(m) ? (m.insertItemBefore(i.createSVGTransform(), v), m.insertItemBefore(i.createSVGTransform(), v), m.insertItemBefore(i.createSVGTransform(), v)) : (m.appendItem(i.createSVGTransform()), m.appendItem(i.createSVGTransform()), m.appendItem(i.createSVGTransform()));
      break;
    }
    case "fhellipse":
    case "fhrect":
    case "fhpath":
      N.setStart({ x: _, y: f }), N.setControllPoint1("x", 0), N.setControllPoint1("y", 0), N.setControllPoint2("x", 0), N.setControllPoint2("y", 0), N.setStarted(!0), N.setDAttr(_ + "," + f + " "), N.addSVGElementsFromJson({
        element: "polyline",
        curStyles: !0,
        attr: {
          points: N.getDAttr(),
          id: N.getNextId(),
          fill: "none",
          opacity: n.opacity / 2,
          "stroke-linecap": "round",
          style: "pointer-events:none"
        }
      }), N.setFreehand("minx", _), N.setFreehand("maxx", _), N.setFreehand("miny", f), N.setFreehand("maxy", f);
      break;
    case "image": {
      N.setStarted(!0);
      const b = N.addSVGElementsFromJson({
        element: "image",
        attr: {
          x: p,
          y: d,
          width: 0,
          height: 0,
          id: N.getNextId(),
          opacity: n.opacity / 2,
          style: "pointer-events:inherit"
        }
      });
      vi(b, N.getLastGoodImgUrl()), bv(b);
      break;
    }
    case "square":
    // TODO: once we create the rect, we lose information that this was a square
    // (for resizing purposes this could be important)
    // Fallthrough
    case "rect":
      N.setStarted(!0), N.setStartX(p), N.setStartY(d), N.addSVGElementsFromJson({
        element: "rect",
        curStyles: !0,
        attr: {
          x: p,
          y: d,
          width: 0,
          height: 0,
          id: N.getNextId(),
          opacity: n.opacity / 2
        }
      });
      break;
    case "line": {
      N.setStarted(!0);
      const b = Number(n.stroke_width) === 0 ? 1 : n.stroke_width;
      N.addSVGElementsFromJson({
        element: "line",
        curStyles: !0,
        attr: {
          x1: p,
          y1: d,
          x2: p,
          y2: d,
          id: N.getNextId(),
          stroke: n.stroke,
          "stroke-width": b,
          "stroke-dasharray": n.stroke_dasharray,
          "stroke-linejoin": n.stroke_linejoin,
          "stroke-linecap": n.stroke_linecap,
          "stroke-opacity": n.stroke_opacity,
          fill: "none",
          opacity: n.opacity / 2,
          style: "pointer-events:none"
        }
      });
      break;
    }
    case "circle":
      N.setStarted(!0), N.addSVGElementsFromJson({
        element: "circle",
        curStyles: !0,
        attr: {
          cx: p,
          cy: d,
          r: 0,
          id: N.getNextId(),
          opacity: n.opacity / 2
        }
      });
      break;
    case "ellipse":
      N.setStarted(!0), N.addSVGElementsFromJson({
        element: "ellipse",
        curStyles: !0,
        attr: {
          cx: p,
          cy: d,
          rx: 0,
          ry: 0,
          id: N.getNextId(),
          opacity: n.opacity / 2
        }
      });
      break;
    case "text":
      N.setStarted(!0), N.addSVGElementsFromJson({
        element: "text",
        curStyles: !0,
        attr: {
          x: p,
          y: d,
          id: N.getNextId(),
          fill: N.getCurText("fill"),
          "stroke-width": N.getCurText("stroke_width"),
          "font-size": N.getCurText("font_size"),
          "font-family": N.getCurText("font_family"),
          "text-anchor": "middle",
          "xml:space": "preserve",
          opacity: n.opacity
        }
      });
      break;
    case "path":
    // Fall through
    case "pathedit":
      N.setStartX(N.getStartX() * r), N.setStartY(N.getStartY() * r), N.pathActions.mouseDown(o, g, N.getStartX(), N.getStartY()), N.setStarted(!0);
      break;
    case "textedit":
      N.setStartX(N.getStartX() * r), N.setStartY(N.getStartY() * r), N.textActions.mouseDown(o, g, N.getStartX(), N.getStartY()), N.setStarted(!0);
      break;
    case "rotate":
      N.setStarted(!0), N.undoMgr.beginUndoableChange("transform", t);
      break;
  }
  N.runExtensions("mouseDown", {
    event: o,
    start_x: N.getStartX(),
    start_y: N.getStartY(),
    selectedElements: t
  }, !0).forEach((b) => {
    b?.started && N.setStarted(!0);
  });
}, pM = (o) => {
  const e = N.getZoom(), { $id: t } = N;
  if (!o.shiftKey)
    return;
  o.preventDefault();
  const r = t("svgcontent")?.querySelector("g")?.getScreenCTM?.();
  if (!r)
    return;
  N.setRootSctm(r.inverse());
  const n = document.getElementById("workarea"), i = 15, a = N.getCurConfig().showRulers ? 16 : 0, s = cr(o.clientX, o.clientY, N.getrootSctm()), l = parseFloat(getComputedStyle(n, null).width.replace("px", "")), c = parseFloat(getComputedStyle(n, null).height.replace("px", "")), u = l - i - a, A = c - i - a, p = u * N.getrootSctm().a, d = A * N.getrootSctm().d, g = P4(n), _ = g.left + a, f = g.top + a, m = o.wheelDelta ? o.wheelDelta : o.detail ? -o.detail : 0;
  if (!m)
    return;
  let b = Math.max(3 / 4, Math.min(4 / 3, m)), v, w;
  b > 1 ? (v = Math.ceil(u / p * b * 100) / 100, w = Math.ceil(A / d * b * 100) / 100) : (v = Math.floor(u / p * b * 100) / 100, w = Math.floor(A / d * b * 100) / 100);
  let C = Math.min(v, w);
  if (C = Math.min(10, Math.max(0.01, C)), C === e)
    return;
  b = C / e;
  const E = cr(_, f, N.getrootSctm()), T = {
    x: s.x - (s.x - E.x) / b,
    y: s.y - (s.y - E.y) / b
  }, F = {
    x: T.x * C,
    y: T.y * C
  }, B = {
    x: F.x - a + l / 2,
    y: F.y - a + c / 2
  };
  N.setZoom(C), document.getElementById("zoom").value = (C * 100).toFixed(1), N.call("updateCanvas", { center: !1, newCtr: B }), N.call("zoomDone");
};
let Ju = null, wc = null;
const hM = (o) => {
  Ju = o, wc = o.getDOMDocument?.() || (typeof document < "u" ? document : null);
}, BE = (o) => {
  if (!o) return null;
  if (o.nodeType === 3 || o.nodeType === 4) return o.nodeValue;
  if (o.nodeType !== 1) return null;
  const e = {
    element: o.tagName,
    // namespace: nsMap[data.namespaceURI],
    attr: {},
    children: []
  }, t = o.attributes;
  if (t)
    for (let n = 0; n < t.length; n++) {
      const i = t[n];
      i && (e.attr[i.name] = i.value);
    }
  const r = o.childNodes;
  if (r)
    for (let n = 0; n < r.length; n++) {
      const i = r[n], a = BE(i);
      a != null && e.children.push(a);
    }
  return e;
}, EE = (o) => {
  if (!wc)
    return null;
  if (o == null) return wc.createTextNode("");
  if (typeof o == "string") return wc.createTextNode(o);
  const e = o.attr || {}, t = e.id;
  let r = null;
  if (typeof t == "string" && t) {
    try {
      r = wr(t);
    } catch {
    }
    if (!r) {
      const a = wc.getElementById?.(t), s = Ju?.getSvgRoot?.();
      a && (!s || s.contains(a)) && (r = a);
    }
  }
  const n = Ju?.getDrawing?.()?.getCurrentLayer?.();
  if (r && o.element !== r.tagName && (r.remove(), r = null), !r) {
    const a = o.namespace || vt.SVG;
    r = wc.createElementNS(a, o.element), n && (Ju.getCurrentGroup() || n).append(r);
  }
  const i = Ju.getCurShape?.() || {};
  if (o.curStyles) {
    const a = Number(i.opacity), s = Number.isFinite(a) ? a / 2 : 0.5;
    br(r, {
      fill: i.fill,
      stroke: i.stroke,
      "stroke-width": i.stroke_width,
      "stroke-dasharray": i.stroke_dasharray,
      "stroke-linejoin": i.stroke_linejoin,
      "stroke-linecap": i.stroke_linecap,
      "stroke-opacity": i.stroke_opacity,
      "fill-opacity": i.fill_opacity,
      opacity: s,
      style: "pointer-events:inherit"
    });
  }
  if (br(r, e), Vh(r), o.children) {
    for (; r.firstChild; )
      r.firstChild.remove();
    o.children.forEach((a) => {
      const s = EE(a);
      s && r.append(s);
    });
  }
  return r;
};
let pe = null;
const gM = (o) => {
  pe = o, pe.getBold = LM, pe.setBold = TM, pe.getItalic = NM, pe.setItalic = IM, pe.hasTextDecoration = PM, pe.addTextDecoration = FM, pe.removeTextDecoration = UM, pe.setTextAnchor = MM, pe.setLetterSpacing = RM, pe.setWordSpacing = OM, pe.setTextLength = QM, pe.setLengthAdjust = qM, pe.getFontFamily = GM, pe.setFontFamily = VM, pe.setFontColor = DM, pe.getFontColor = HM, pe.getFontSize = zM, pe.setFontSize = KM, pe.getText = $M, pe.setTextContent = WM, pe.setImageURL = XM, pe.setLinkURL = YM, pe.setRectRadius = ZM, pe.makeHyperlink = JM, pe.removeHyperlink = e3, pe.setSegType = t3, pe.setStrokeWidth = EM, pe.getResolution = _M, pe.getTitle = fM, pe.setGroupTitle = mM, pe.setStrokeAttr = jM, pe.setBackground = r3, pe.setDocumentTitle = yM, pe.getEditorNS = vM, pe.setResolution = bM, pe.setBBoxZoom = wM, pe.setCurrentZoom = xM, pe.setColor = kM, pe.setGradient = CM, pe.setPaint = BM;
}, _M = () => {
  const o = pe.getZoom(), e = pe.getSvgContent().getAttribute("width") / o, t = pe.getSvgContent().getAttribute("height") / o;
  return {
    w: e,
    h: t,
    zoom: o
  };
}, fM = (o) => {
  const e = pe.getSelectedElements(), t = pe.getDataStorage();
  if (o = o || e[0], !o)
    return;
  t.has(o, "gsvg") ? o = t.get(o, "gsvg") : t.has(o, "symbol") && (o = t.get(o, "symbol"));
  const r = o.childNodes;
  for (const n of r)
    if (n.nodeName === "title")
      return n.textContent;
  return "";
}, mM = (o) => {
  const {
    InsertElementCommand: e,
    RemoveElementCommand: t,
    ChangeElementCommand: r,
    BatchCommand: n
  } = pe.history, i = pe.getSelectedElements(), a = pe.getDataStorage();
  let s = i[0];
  if (!s || (a.has(s, "gsvg") ? s = a.get(s, "gsvg") : a.has(s, "symbol") && (s = a.get(s, "symbol")), !s))
    return;
  const l = new n("Set Label");
  let c = null;
  for (const u of s.childNodes)
    if (u.nodeName === "title") {
      c = u;
      break;
    }
  if (o.length === 0) {
    if (!c)
      return;
    const { nextSibling: u } = c;
    c.remove(), l.addSubCommand(new t(c, u, s));
  } else if (c) {
    const u = c.textContent;
    if (u === o)
      return;
    c.textContent = o, l.addSubCommand(new r(c, { "#text": u }));
  } else
    c = pe.getDOMDocument().createElementNS(vt.SVG, "title"), c.textContent = o, s.insertBefore(c, s.firstChild), l.addSubCommand(new e(c));
  l.isEmpty() || pe.addCommandToHistory(l);
}, yM = (o) => {
  const {
    InsertElementCommand: e,
    RemoveElementCommand: t,
    ChangeElementCommand: r,
    BatchCommand: n
  } = pe.history, i = pe.getSvgContent(), a = new n("Change Image Title");
  let s = null;
  for (const l of i.childNodes)
    if (l.nodeName === "title") {
      s = l;
      break;
    }
  if (s)
    if (o.length) {
      const l = s.textContent;
      if (l === o)
        return;
      s.textContent = o, a.addSubCommand(new r(s, { "#text": l }));
    } else {
      const { nextSibling: l } = s;
      s.remove(), a.addSubCommand(new t(s, l, i));
    }
  else {
    if (!o.length)
      return;
    s = pe.getDOMDocument().createElementNS(vt.SVG, "title"), s.textContent = o, i.insertBefore(s, i.firstChild), a.addSubCommand(new e(s));
  }
  a.isEmpty() || pe.addCommandToHistory(a);
}, bM = (o, e) => {
  const { ChangeElementCommand: t, BatchCommand: r } = pe.history, n = pe.getResolution(), { w: i, h: a } = n;
  let s;
  if (o === "fit") {
    const u = bi();
    if (u) {
      s = new r("Fit Canvas to Content");
      const A = KA();
      pe.addToSelection(A);
      const p = [], d = [];
      A.forEach((_, f) => {
        p.push(u.x * -1), d.push(u.y * -1);
      });
      const g = pe.moveSelectedElements(p, d, !1);
      g && s.addSubCommand(g), pe.clearSelection(), o = Math.round(u.width), e = Math.round(u.height);
    } else
      return !1;
  }
  const l = Xr("width", o), c = Xr("height", e);
  if (l !== i || c !== a) {
    s || (s = new r("Change Image Dimensions"));
    const u = pe.getSvgContent(), A = u.getAttribute("viewBox");
    u.setAttribute("width", l), u.setAttribute("height", c), pe.contentW = l, pe.contentH = c, u.setAttribute("viewBox", [0, 0, l, c].join(" ")), s.addSubCommand(new t(u, { width: i, height: a, viewBox: A })), pe.addCommandToHistory(s), pe.call("changed", [u]);
  }
  return !0;
}, vM = (o) => (o && pe.getSvgContent().setAttribute("xmlns:se", vt.SE), vt.SE), wM = (o, e, t) => {
  const r = pe.getZoom(), n = pe.getSelectedElements();
  let i = 0.85, a;
  const s = (l) => {
    if (!l || !Number.isFinite(e) || !Number.isFinite(t) || e <= 0 || t <= 0 || !Number.isFinite(l.width) || !Number.isFinite(l.height) || l.width <= 0 || l.height <= 0)
      return;
    const c = Math.round(e / l.width * 100 * i) / 100, u = Math.round(t / l.height * 100 * i) / 100, A = Math.min(c, u);
    if (!(!Number.isFinite(A) || A <= 0))
      return pe.setZoom(A), { zoom: A, bbox: l };
  };
  if (o && typeof o == "object") {
    if (a = o, a.width === 0 || a.height === 0) {
      let l = r;
      return Number.isFinite(a.zoom) && a.zoom > 0 ? l = a.zoom : Number.isFinite(a.factor) && a.factor > 0 && (l = r * a.factor), Number.isFinite(l) && l > 0 && pe.setZoom(l), { zoom: l, bbox: a };
    }
    return s(a);
  }
  switch (o) {
    case "selection": {
      if (!n[0])
        return;
      const l = n.filter(Boolean);
      a = bi(l);
      break;
    }
    case "canvas": {
      const l = pe.getResolution();
      i = 0.95, a = { width: l.w, height: l.h, x: 0, y: 0 };
      break;
    }
    case "content":
      a = bi();
      break;
    case "layer":
      a = bi(KA(pe.getCurrentDrawing().getCurrentLayer()));
      break;
    default:
      return;
  }
  return s(a);
}, xM = (o) => {
  if (!Number.isFinite(o) || o <= 0)
    return;
  const e = pe.getSelectedElements(), t = pe.getResolution(), r = t.w / o, n = t.h / o;
  !Number.isFinite(r) || !Number.isFinite(n) || r <= 0 || n <= 0 || (pe.getSvgContent().setAttribute("viewBox", `0 0 ${r} ${n}`), pe.setZoom(o), e.forEach((i) => {
    if (!i)
      return;
    const a = pe.selectorManager.requestSelector(i);
    a && a.resize();
  }), pe.pathActions.zoomChange(), pe.runExtensions("zoomChanged", o));
}, kM = (o, e, t) => {
  const r = pe.getSelectedElements();
  pe.setCurShape(o, e), pe.setCurProperties(`${o}_paint`, { type: "solidColor" });
  const n = [], i = (s) => {
    s.nodeName !== "g" && n.push(s);
  };
  let a = r.length;
  for (; a--; ) {
    const s = r[a];
    s && (s.tagName === "g" ? Wa(s, i) : o === "fill" ? s.tagName !== "polyline" && s.tagName !== "line" && n.push(s) : n.push(s));
  }
  n.length > 0 && (t ? pe.changeSelectedAttributeNoUndo(o, e, n) : (pe.changeSelectedAttribute(o, e, n), pe.call("changed", n)));
}, CM = (o) => {
  if (!pe.getCurProperties(`${o}_paint`) || pe.getCurProperties(`${o}_paint`).type === "solidColor")
    return;
  let e = pe[o + "Grad"];
  if (!e)
    return;
  const t = SM(e), r = Dn();
  t ? e = t : (e = pe.getDOMDocument().importNode(e, !0), r.append(e), e.id = pe.getNextId()), pe.setColor(o, `url(#${e.id})`);
}, SM = (o) => {
  if (!o || !["linearGradient", "radialGradient"].includes(o.tagName))
    return null;
  const e = Dn().querySelectorAll("linearGradient, radialGradient");
  let t = e.length;
  const r = ["r", "cx", "cy", "fx", "fy"];
  for (; t--; ) {
    const n = e[t];
    if (n.tagName !== o.tagName)
      continue;
    if (o.tagName === "linearGradient") {
      if (o.getAttribute("x1") !== n.getAttribute("x1") || o.getAttribute("y1") !== n.getAttribute("y1") || o.getAttribute("x2") !== n.getAttribute("x2") || o.getAttribute("y2") !== n.getAttribute("y2"))
        continue;
    } else {
      const l = {
        r: Number(o.getAttribute("r")),
        cx: Number(o.getAttribute("cx")),
        cy: Number(o.getAttribute("cy")),
        fx: Number(o.getAttribute("fx")),
        fy: Number(o.getAttribute("fy"))
      }, c = {
        r: Number(n.getAttribute("r")),
        cx: Number(n.getAttribute("cx")),
        cy: Number(n.getAttribute("cy")),
        fx: Number(n.getAttribute("fx")),
        fy: Number(n.getAttribute("fy"))
      };
      let u = !1;
      if (r.forEach((A) => {
        l[A] !== c[A] && (u = !0);
      }), u)
        continue;
    }
    const i = o.getElementsByTagNameNS(vt.SVG, "stop"), a = n.getElementsByTagNameNS(vt.SVG, "stop");
    if (i.length !== a.length)
      continue;
    let s = i.length;
    for (; s--; ) {
      const l = i[s], c = a[s];
      if (l.getAttribute("offset") !== c.getAttribute("offset") || l.getAttribute("stop-opacity") !== c.getAttribute("stop-opacity") || l.getAttribute("stop-color") !== c.getAttribute("stop-color"))
        break;
    }
    if (s === -1)
      return n;
  }
  return null;
}, BM = (o, e) => {
  const t = new Ii(e);
  switch (pe.setPaintOpacity(o, t.alpha / 100, !0), pe.setCurProperties(`${o}_paint`, t), t.type) {
    case "solidColor":
      pe.setColor(o, t.solidColor !== "none" ? `#${t.solidColor}` : "none");
      break;
    case "linearGradient":
    case "radialGradient":
      pe.setCanvas(o + "Grad", t[t.type]), pe.setGradient(o);
      break;
  }
}, EM = (o) => {
  const e = pe.getSelectedElements();
  if (o === 0 && ["line", "path"].includes(pe.getMode())) {
    pe.setStrokeWidth(1);
    return;
  }
  pe.setCurProperties("stroke_width", o);
  const t = [], r = (i) => {
    i.nodeName !== "g" && t.push(i);
  };
  let n = e.length;
  for (; n--; ) {
    const i = e[n];
    i && (i.tagName === "g" ? Wa(i, r) : t.push(i));
  }
  t.length > 0 && (pe.changeSelectedAttribute("stroke-width", o, t), pe.call("changed", e));
}, jM = (o, e) => {
  const t = pe.getSelectedElements();
  pe.setCurShape(o.replace("-", "_"), e);
  const r = [];
  let n = t.length;
  for (; n--; ) {
    const i = t[n];
    i && (i.tagName === "g" ? Wa(i, (a) => {
      a.nodeName !== "g" && r.push(a);
    }) : r.push(i));
  }
  r.length > 0 && (pe.changeSelectedAttribute(o, e, r), pe.call("changed", t));
}, LM = () => pe.getSelectedElements().filter((o) => o?.tagName === "text").every((o) => o.getAttribute("font-weight") === "bold"), TM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("font-weight", o ? "bold" : "normal", e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, PM = (o) => pe.getSelectedElements().filter((e) => e?.tagName === "text").every((e) => (e.getAttribute("text-decoration") || "").includes(o)), FM = (o) => {
  const { ChangeElementCommand: e, BatchCommand: t } = pe.history, r = pe.getSelectedElements().filter((i) => i?.tagName === "text"), n = new t();
  r.forEach((i) => {
    const a = i.getAttribute("text-decoration") || "";
    a.includes(o) || (n.addSubCommand(new e(i, { "text-decoration": a })), pe.changeSelectedAttributeNoUndo("text-decoration", `${a} ${o}`.trim(), [i]));
  }), n.isEmpty() || pe.undoMgr.addCommandToHistory(n), r.some((i) => i.textContent) || pe.textActions.setCursor();
}, UM = (o) => {
  const { ChangeElementCommand: e, BatchCommand: t } = pe.history, r = pe.getSelectedElements().filter((i) => i?.tagName === "text"), n = new t();
  r.forEach((i) => {
    const a = i.getAttribute("text-decoration") || "";
    n.addSubCommand(new e(i, { "text-decoration": a })), pe.changeSelectedAttributeNoUndo("text-decoration", a.replace(o, "").trim(), [i]);
  }), n.isEmpty() || pe.undoMgr.addCommandToHistory(n), r.some((i) => i.textContent) || pe.textActions.setCursor();
}, NM = () => pe.getSelectedElements().filter((o) => o?.tagName === "text").every((o) => o.getAttribute("font-style") === "italic"), IM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("font-style", o ? "italic" : "normal", e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, MM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("text-anchor", o, e);
}, RM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("letter-spacing", o, e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, OM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("word-spacing", o, e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, QM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("textLength", o, e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, qM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.changeSelectedAttribute("lengthAdjust", o, e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, GM = () => pe.getCurText("font_family"), VM = (o) => {
  const e = pe.getSelectedElements().filter((t) => t?.tagName === "text");
  pe.setCurText("font_family", o), pe.changeSelectedAttribute("font-family", o, e), e.some((t) => t.textContent) || pe.textActions.setCursor();
}, DM = (o) => {
  pe.setCurText("fill", o), pe.changeSelectedAttribute("fill", o);
}, HM = () => pe.getCurText("fill"), zM = () => pe.getCurText("font_size"), KM = (o) => {
  const e = pe.getSelectedElements();
  pe.setCurText("font_size", o), pe.changeSelectedAttribute("font-size", o), e[0]?.textContent || pe.textActions.setCursor();
}, $M = () => {
  const o = pe.getSelectedElements()[0];
  return o ? o.textContent : "";
}, WM = (o) => {
  pe.changeSelectedAttribute("#text", o), pe.textActions.init(o), pe.textActions.setCursor();
}, XM = (o) => {
  const { ChangeElementCommand: e, BatchCommand: t } = pe.history, r = pe.getSelectedElements()[0];
  if (!r)
    return;
  const n = {
    width: r.getAttribute("width"),
    height: r.getAttribute("height")
  }, i = !n.width || !n.height, a = ca(r), s = a !== o;
  if (!s && !i)
    return;
  const l = new t("Change Image URL");
  s && (vi(r, o), l.addSubCommand(new e(r, {
    "#href": a
  })));
  let c = !1;
  const u = () => {
    c || (c = !0, !l.isEmpty() && (pe.addCommandToHistory(l), pe.call("changed", [r])));
  }, A = new Image();
  A.onload = () => {
    const p = {
      width: r.getAttribute("width"),
      height: r.getAttribute("height")
    };
    r.setAttribute("width", A.width), r.setAttribute("height", A.height);
    const d = pe.selectorManager.requestSelector(r);
    d && d.resize(), l.addSubCommand(new e(r, p)), u();
  }, A.onerror = () => {
    u();
  }, A.src = o;
}, YM = (o) => {
  const { ChangeElementCommand: e, BatchCommand: t } = pe.history;
  let r = pe.getSelectedElements()[0];
  if (!r)
    return;
  if (r.tagName !== "a") {
    const a = zA(r.parentNode, "a");
    if (a?.length)
      r = a[0];
    else
      return;
  }
  const n = ca(r);
  if (n === o)
    return;
  const i = new t("Change Link URL");
  vi(r, o), i.addSubCommand(new e(r, {
    "#href": n
  })), pe.addCommandToHistory(i);
}, ZM = (o) => {
  const { ChangeElementCommand: e } = pe.history, t = pe.getSelectedElements()[0];
  if (t?.tagName !== "rect")
    return;
  const r = Number(o);
  if (!Number.isFinite(r) || r < 0)
    return;
  const n = t.getAttribute("rx"), i = t.getAttribute("ry"), a = Number(n), s = Number(i), l = n !== null && Number.isFinite(a), c = i !== null && Number.isFinite(s);
  r === 0 && n === null && i === null || l && c && a === r && s === r || (t.setAttribute("rx", r), t.setAttribute("ry", r), pe.addCommandToHistory(new e(t, { rx: n, ry: i }, "Radius")), pe.call("changed", [t]));
}, JM = (o) => {
  pe.groupSelectedElements("a", o);
}, e3 = () => {
  pe.ungroupSelectedElement();
}, t3 = (o) => {
  pe.pathActions.setSegType(o);
}, r3 = (o, e) => {
  const t = wr("canvasBackground");
  if (!t)
    return;
  const r = t.querySelector("rect");
  if (!r)
    return;
  let n = wr("background_image"), i = wr("background_pattern");
  if (r.setAttribute("fill", o === "chessboard" ? "#fff" : o), o === "chessboard") {
    if (!i) {
      i = pe.getDOMDocument().createElementNS(vt.SVG, "foreignObject"), pe.assignAttributes(i, {
        id: "background_pattern",
        width: "100%",
        height: "100%",
        preserveAspectRatio: "xMinYMin",
        style: "pointer-events:none"
      });
      const a = document.createElement("div");
      pe.assignAttributes(a, {
        style: "pointer-events:none;width:100%;height:100%;background-image:url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"
      }), i.append(a), t.append(i);
    }
  } else i && i.remove();
  e ? (n || (n = pe.getDOMDocument().createElementNS(vt.SVG, "image"), pe.assignAttributes(n, {
    id: "background_image",
    width: "100%",
    height: "100%",
    preserveAspectRatio: "xMinYMin",
    style: "pointer-events:none"
  })), vi(n, e), t.append(n)) : n && n.remove();
};
let xc = null;
const o3 = (o) => {
  if (o == null) return null;
  const e = String(o).trim();
  if (!e) return null;
  if (e.endsWith("%")) {
    const r = Number.parseFloat(e.slice(0, -1));
    return Number.isNaN(r) ? e : `${100 - r}%`;
  }
  const t = Number.parseFloat(e);
  return Number.isNaN(t) ? e : String(1 - t);
}, ys = (o, e) => {
  const t = o.getAttribute(e);
  if (t == null) return;
  const r = o3(t);
  r != null && o.setAttribute(e, r);
}, n3 = (o) => {
  xc = o;
}, W0 = [
  0,
  "z",
  "M",
  "m",
  "L",
  "l",
  "C",
  "c",
  "Q",
  "q",
  "A",
  "a",
  "H",
  "h",
  "V",
  "v",
  "S",
  "s",
  "T",
  "t"
], eA = (o, e, t) => {
  const r = (u, A) => cr(u, A, t), n = (u) => t.a * u, i = (u) => t.d * u, a = xc.getGridSnapping?.() && o?.parentNode?.parentNode?.localName === "svg", s = () => {
    if (a)
      for (const [u, A] of Object.entries(e))
        e[u] = ar(A);
    br(o, e, 1e3, !0);
  }, l = so(o);
  ["fill", "stroke"].forEach((u) => {
    const A = o.getAttribute(u);
    if (A?.startsWith("url(") && (t.a < 0 || t.d < 0)) {
      const p = Gs(A);
      if (!p) return;
      const d = (p.tagName || "").toLowerCase();
      if (!["lineargradient", "radialgradient"].includes(d) || p.getAttribute("gradientUnits") === "userSpaceOnUse") return;
      const g = p.cloneNode(!0);
      t.a < 0 && (d === "lineargradient" ? (ys(g, "x1"), ys(g, "x2")) : (ys(g, "cx"), ys(g, "fx"))), t.d < 0 && (d === "lineargradient" ? (ys(g, "y1"), ys(g, "y2")) : (ys(g, "cy"), ys(g, "fy")));
      const _ = (xc.getCurrentDrawing?.() || xc.getDrawing?.())?.getNextId?.() ?? (p.id ? `${p.id}-mirrored` : `mirrored-grad-${Date.now()}`);
      if (!_) {
        xn("Unable to mirror gradient: no drawing context available", null, "coords");
        return;
      }
      g.id = _, Dn().append(g), o.setAttribute(u, `url(#${g.id})`);
    }
  });
  const c = o.tagName;
  if (c !== "use")
    switch (c) {
      case "foreignObject":
      case "rect":
      case "image": {
        if (c === "image" && (t.a < 0 || t.d < 0)) {
          const u = hr(o), A = xc.getSvgRoot().createSVGTransform();
          A.setMatrix(Ro(lr(u).matrix, t)), u.clear(), u.appendItem(A);
        } else {
          const u = r(e.x, e.y);
          e.width = n(e.width), e.height = i(e.height), e.x = u.x + Math.min(0, e.width), e.y = u.y + Math.min(0, e.height), e.width = Math.abs(e.width), e.height = Math.abs(e.height);
        }
        s();
        break;
      }
      case "ellipse": {
        const u = r(e.cx, e.cy);
        e.cx = u.x, e.cy = u.y, e.rx = Math.abs(n(e.rx)), e.ry = Math.abs(i(e.ry)), s();
        break;
      }
      case "circle": {
        const u = r(e.cx, e.cy);
        e.cx = u.x, e.cy = u.y;
        const A = mv(l.x, l.y, l.width, l.height, t), p = A.tr.x - A.tl.x, d = A.bl.y - A.tl.y;
        e.r = Math.min(Math.abs(p / 2), Math.abs(d / 2)), s();
        break;
      }
      case "line": {
        const u = r(e.x1, e.y1), A = r(e.x2, e.y2);
        e.x1 = u.x, e.y1 = u.y, e.x2 = A.x, e.y2 = A.y, s();
        break;
      }
      case "text": {
        const u = r(e.x, e.y);
        e.x = u.x, e.y = u.y;
        let A = o.getAttribute("font-size");
        A || (A = window.getComputedStyle(o).fontSize);
        const p = parseFloat(A);
        isNaN(p) || (e["font-size"] = p * Math.abs(t.a)), s();
        const d = o.childNodes;
        for (let g = 0; g < d.length; g++) {
          const _ = d[g];
          if (_.nodeType === 1 && _.tagName === "tspan") {
            const f = {}, m = _.hasAttribute("x"), b = _.hasAttribute("y");
            if (m) {
              const C = Xr("x", _.getAttribute("x")), E = r(C, e.y).x;
              f.x = E;
            }
            if (b) {
              const C = Xr("y", _.getAttribute("y")), E = r(e.x, C).y;
              f.y = E;
            }
            let v = _.getAttribute("font-size");
            v || (v = window.getComputedStyle(_).fontSize);
            const w = parseFloat(v);
            isNaN(w) || (f["font-size"] = w * Math.abs(t.a)), (m || b || f["font-size"]) && br(_, f, 1e3, !0);
          }
        }
        break;
      }
      case "tspan": {
        const u = r(e.x, e.y);
        e.x = u.x, e.y = u.y;
        let A = o.getAttribute("font-size");
        A || (A = window.getComputedStyle(o).fontSize);
        const p = parseFloat(A);
        isNaN(p) || (e["font-size"] = p * Math.abs(t.a)), s();
        break;
      }
      case "g": {
        const u = xc.getDataStorage().get(o, "gsvg");
        u && br(u, e, 1e3, !0);
        break;
      }
      case "polyline":
      case "polygon": {
        e.points.forEach((A) => {
          const { x: p, y: d } = r(A.x, A.y);
          A.x = p, A.y = d;
        });
        const u = e.points.map((A) => `${A.x},${A.y}`).join(" ");
        o.setAttribute("points", u);
        break;
      }
      case "path": {
        const u = typeof o.getPathData == "function" && typeof o.setPathData == "function", A = u ? null : o.pathSegList, p = u ? o.getPathData().length : A.numberOfItems, d = t.a * t.d - t.b * t.c < 0;
        if (e.d = [], u) {
          const v = o.getPathData();
          for (let w = 0; w < p; ++w) {
            const C = v[w], E = C.type, T = W0.indexOf(E);
            if (T === -1) continue;
            const F = C.values || [], B = { type: T };
            switch (E.toUpperCase()) {
              case "M":
              case "L":
              case "T":
                [B.x, B.y] = F;
                break;
              case "H":
                [B.x] = F;
                break;
              case "V":
                [B.y] = F;
                break;
              case "C":
                [B.x1, B.y1, B.x2, B.y2, B.x, B.y] = F;
                break;
              case "S":
                [B.x2, B.y2, B.x, B.y] = F;
                break;
              case "Q":
                [B.x1, B.y1, B.x, B.y] = F;
                break;
              case "A":
                [
                  B.r1,
                  B.r2,
                  B.angle,
                  B.largeArcFlag,
                  B.sweepFlag,
                  B.x,
                  B.y
                ] = F;
                break;
            }
            e.d[w] = B;
          }
        } else
          for (let v = 0; v < p; ++v) {
            const w = A.getItem(v);
            e.d[v] = {
              type: w.pathSegType,
              x: w.x,
              y: w.y,
              x1: w.x1,
              y1: w.y1,
              x2: w.x2,
              y2: w.y2,
              r1: w.r1,
              r2: w.r2,
              angle: w.angle,
              largeArcFlag: w.largeArcFlag,
              sweepFlag: w.sweepFlag
            };
          }
        const g = e.d[0];
        let _;
        p > 0 && (_ = r(g.x, g.y), e.d[0].x = _.x, e.d[0].y = _.y);
        for (let v = 1; v < p; ++v) {
          const w = e.d[v], { type: C } = w;
          if (C % 2 === 0) {
            const E = w.x !== void 0 ? w.x : _.x, T = w.y !== void 0 ? w.y : _.y, F = r(E, T);
            if (w.x = F.x, w.y = F.y, w.x1 !== void 0 && w.y1 !== void 0) {
              const B = r(w.x1, w.y1);
              w.x1 = B.x, w.y1 = B.y;
            }
            if (w.x2 !== void 0 && w.y2 !== void 0) {
              const B = r(w.x2, w.y2);
              w.x2 = B.x, w.y2 = B.y;
            }
            C === 10 && (w.r1 = Math.abs(n(w.r1)), w.r2 = Math.abs(i(w.r2)), d && (w.sweepFlag = Number(w.sweepFlag) ? 0 : 1, typeof w.angle == "number" && (w.angle = -w.angle)));
          } else
            w.x !== void 0 && (w.x = n(w.x)), w.y !== void 0 && (w.y = i(w.y)), w.x1 !== void 0 && (w.x1 = n(w.x1)), w.y1 !== void 0 && (w.y1 = i(w.y1)), w.x2 !== void 0 && (w.x2 = n(w.x2)), w.y2 !== void 0 && (w.y2 = i(w.y2)), C === 11 && (w.r1 = Math.abs(n(w.r1)), w.r2 = Math.abs(i(w.r2)), d && (w.sweepFlag = Number(w.sweepFlag) ? 0 : 1, typeof w.angle == "number" && (w.angle = -w.angle)));
        }
        let f = "";
        const m = [];
        e.d.forEach((v) => {
          const { type: w } = v, C = W0[w];
          switch (f += C, w) {
            case 13:
            // relative horizontal line (h)
            case 12:
              f += `${v.x} `, m.push({ type: C, values: [v.x] });
              break;
            case 15:
            // relative vertical line (v)
            case 14:
              f += `${v.y} `, m.push({ type: C, values: [v.y] });
              break;
            case 3:
            // relative move (m)
            case 5:
            // relative line (l)
            case 19:
            // relative smooth quad (t)
            case 2:
            // absolute move (M)
            case 4:
            // absolute line (L)
            case 18:
              f += `${v.x},${v.y} `, m.push({ type: C, values: [v.x, v.y] });
              break;
            case 7:
            // relative cubic (c)
            case 6:
              f += `${v.x1},${v.y1} ${v.x2},${v.y2} ${v.x},${v.y} `, m.push({
                type: C,
                values: [v.x1, v.y1, v.x2, v.y2, v.x, v.y]
              });
              break;
            case 9:
            // relative quad (q)
            case 8:
              f += `${v.x1},${v.y1} ${v.x},${v.y} `, m.push({ type: C, values: [v.x1, v.y1, v.x, v.y] });
              break;
            case 11:
            // relative elliptical arc (a)
            case 10:
              f += v.r1 + "," + v.r2 + " " + v.angle + " " + Number(v.largeArcFlag) + " " + Number(v.sweepFlag) + " " + v.x + "," + v.y + " ", m.push({
                type: C,
                values: [
                  v.r1,
                  v.r2,
                  v.angle,
                  Number(v.largeArcFlag),
                  Number(v.sweepFlag),
                  v.x,
                  v.y
                ]
              });
              break;
            case 17:
            // relative smooth cubic (s)
            case 16:
              f += `${v.x2},${v.y2} ${v.x},${v.y} `, m.push({ type: C, values: [v.x2, v.y2, v.x, v.y] });
              break;
          }
        });
        const b = f.trim();
        if (o.setAttribute("d", b), u)
          try {
            o.setPathData(m);
          } catch {
          }
        break;
      }
    }
};
let xo;
const i3 = (o) => {
  xo = o;
}, db = (o, e, t, r) => {
  const n = Gs(o);
  if (!n) return;
  if (r && n.id) {
    const c = xo.getSvgContent?.();
    if (c) {
      const u = `[clip-path="url(#${n.id})"]`;
      if (c.querySelectorAll(u).length > 1) {
        const A = n.cloneNode(!0);
        return A.id = xo.getNextId(), Dn().append(A), r.setAttribute("clip-path", `url(#${A.id})`), db(`url(#${A.id})`, e, t);
      }
    }
  }
  const i = n.firstElementChild;
  if (!i) return o;
  const a = hr(i);
  if (!a) {
    const c = (i.tagName || "").toLowerCase();
    if (c === "rect") {
      const u = Xr("x", i.getAttribute("x") || 0) + e, A = Xr("y", i.getAttribute("y") || 0) + t;
      i.setAttribute("x", u), i.setAttribute("y", A);
    } else if (c === "circle" || c === "ellipse") {
      const u = Xr("cx", i.getAttribute("cx") || 0) + e, A = Xr("cy", i.getAttribute("cy") || 0) + t;
      i.setAttribute("cx", u), i.setAttribute("cy", A);
    } else if (c === "line")
      i.setAttribute("x1", Xr("x1", i.getAttribute("x1") || 0) + e), i.setAttribute("y1", Xr("y1", i.getAttribute("y1") || 0) + t), i.setAttribute("x2", Xr("x2", i.getAttribute("x2") || 0) + e), i.setAttribute("y2", Xr("y2", i.getAttribute("y2") || 0) + t);
    else if (c === "polyline" || c === "polygon") {
      const u = (i.getAttribute("points") || "").trim();
      if (u) {
        const A = u.split(/\s+/).map((p) => {
          const [d, g] = p.split(","), _ = Number(d) + e, f = Number(g) + t;
          return `${_},${f}`;
        });
        i.setAttribute("points", A.join(" "));
      }
    } else
      i.setAttribute("transform", `translate(${e},${t})`);
    return o;
  }
  if (a.numberOfItems) {
    const c = xo.getSvgRoot().createSVGMatrix();
    c.e = e, c.f = t;
    const u = Ro(lr(a).matrix, c), A = xo.getSvgRoot().createSVGTransform();
    return A.setMatrix(u), a.clear(), a.appendItem(A), o;
  }
  const s = (i.tagName || "").toLowerCase();
  if ((s === "polyline" || s === "polygon") && !i.points?.numberOfItems) {
    const c = (i.getAttribute("points") || "").trim();
    if (c) {
      const u = c.split(/\s+/).map((A) => {
        const [p, d] = A.split(","), g = Number(p) + e, _ = Number(d) + t;
        return `${g},${_}`;
      });
      i.setAttribute("points", u.join(" "));
    }
    return;
  }
  const l = xo.getSvgRoot().createSVGTransform();
  return l.setTranslate(e, t), a.appendItem(l), gi(i), o;
}, gi = (o) => {
  if (!o || o.tagName === "g" || o.tagName === "a" || o.getAttribute?.("clip-path") && o.querySelector?.("[clip-path]"))
    return null;
  const e = xo.getSvgRoot(), t = xo.getDataStorage(), r = hr(o);
  if (r?.numberOfItems > 0) {
    let A = r.numberOfItems;
    const p = A;
    for (; A--; ) {
      const d = r.getItem(A);
      if (d.type === SVGTransform.SVG_TRANSFORM_MATRIX) {
        if (V5(d.matrix)) {
          if (p === 1)
            return o.removeAttribute("transform"), null;
          r.removeItem(A);
        }
      } else (d.type === SVGTransform.SVG_TRANSFORM_ROTATE && d.angle === 0 || d.type === SVGTransform.SVG_TRANSFORM_TRANSLATE && d.matrix.e === 0 && d.matrix.f === 0) && r.removeItem(A);
    }
    if (r.numberOfItems === 1 && en(o))
      return null;
  }
  if (!r || r.numberOfItems === 0)
    return o.removeAttribute("transform"), null;
  if (o.tagName === "use")
    return null;
  const n = new $A("Transform");
  switch (o.tagName) {
    // Ignore these elements, as they can absorb the [M] transformation
    case "line":
    case "polyline":
    case "polygon":
    case "path":
      break;
    default:
      if (r.numberOfItems === 1 && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_MATRIX || r.numberOfItems === 2 && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_MATRIX && r.getItem(1).type === SVGTransform.SVG_TRANSFORM_ROTATE)
        return null;
  }
  const i = t.has(o, "gsvg") ? t.get(o, "gsvg") : void 0;
  let a = {}, s = null, l = [];
  switch (o.tagName) {
    case "line":
      l = ["x1", "y1", "x2", "y2"];
      break;
    case "circle":
      l = ["cx", "cy", "r"];
      break;
    case "ellipse":
      l = ["cx", "cy", "rx", "ry"];
      break;
    case "foreignObject":
    case "rect":
    case "image":
      l = ["width", "height", "x", "y"];
      break;
    case "text":
    case "tspan":
      l = ["x", "y"];
      break;
    case "polygon":
    case "polyline": {
      s = {}, s.points = o.getAttribute("points");
      const A = o.points, p = A.numberOfItems;
      a.points = new Array(p);
      for (let d = 0; d < p; ++d) {
        const g = A.getItem(d);
        a.points[d] = { x: g.x, y: g.y };
      }
      break;
    }
    case "path":
      s = {}, s.d = o.getAttribute("d"), a.d = o.getAttribute("d");
      break;
  }
  if (l.length ? l.forEach((A) => {
    a[A] = Xr(A, o.getAttribute(A));
  }) : i && (a = {
    x: Number(i.getAttribute("x")) || 0,
    y: Number(i.getAttribute("y")) || 0
  }), !s) {
    s = DA({}, a);
    for (const [A, p] of Object.entries(s))
      s[A] = Xr(A, p);
  }
  s.transform = xo.getStartTransform() || "";
  let c, u;
  if (o.tagName === "g" && !i || o.tagName === "a") {
    const A = so(o);
    c = { x: A.x + A.width / 2, y: A.y + A.height / 2 }, u = cr(
      A.x + A.width / 2,
      A.y + A.height / 2,
      lr(r).matrix
    );
    const p = en(o);
    if (p) {
      const v = p * Math.PI / 180, w = Math.abs(v) > 1e-10 ? Math.sin(v) / (1 - Math.cos(v)) : 2 / v;
      for (let C = 0; C < r.numberOfItems; ++C) {
        const E = r.getItem(C);
        if (E.type === SVGTransform.SVG_TRANSFORM_ROTATE) {
          const T = E.matrix;
          c.y = (w * T.e + T.f) / 2, c.x = (T.e - w * T.f) / 2, r.removeItem(C);
          break;
        }
      }
    }
    const d = r.numberOfItems;
    let g = 0, _ = 0, f = 0, m;
    d && (m = r.getItem(0).matrix);
    let b;
    if (d >= 3 && r.getItem(d - 2).type === SVGTransform.SVG_TRANSFORM_SCALE && r.getItem(d - 3).type === SVGTransform.SVG_TRANSFORM_TRANSLATE && r.getItem(d - 1).type === SVGTransform.SVG_TRANSFORM_TRANSLATE) {
      f = 3;
      const v = r.getItem(d - 3).matrix, w = r.getItem(d - 2).matrix, C = r.getItem(d - 1).matrix, E = o.childNodes;
      let T = E.length;
      for (; T--; ) {
        const F = E.item(T);
        if (F.nodeType !== 1) continue;
        const B = hr(F);
        if (!B) continue;
        const P = lr(B).matrix, S = en(F);
        if (b = xo.getStartTransform(), xo.setStartTransform(F.getAttribute("transform")), S || Ml(B)) {
          const U = e.createSVGTransform();
          U.setMatrix(Ro(v, w, C, P)), B.clear(), B.appendItem(U);
        } else {
          const U = Ro(P.inverse(), C, P), O = e.createSVGMatrix();
          O.e = -U.e, O.f = -U.f;
          const K = Ro(
            O.inverse(),
            P.inverse(),
            v,
            w,
            C,
            P,
            U.inverse()
          ), te = e.createSVGTransform(), Y = e.createSVGTransform(), ee = e.createSVGTransform();
          te.setTranslate(U.e, U.f), Y.setScale(K.a, K.d), ee.setTranslate(O.e, O.f), B.appendItem(ee), B.appendItem(Y), B.appendItem(te);
        }
        const L = gi(F);
        L && n.addSubCommand(L), xo.setStartTransform(b);
      }
      r.removeItem(d - 1), r.removeItem(d - 2), r.removeItem(d - 3);
    } else if (d >= 3 && r.getItem(d - 1).type === SVGTransform.SVG_TRANSFORM_MATRIX) {
      f = 3;
      const v = lr(r).matrix, w = e.createSVGTransform();
      w.setMatrix(v), r.clear(), r.appendItem(w);
    } else if ((d === 1 || d > 1 && r.getItem(1).type !== SVGTransform.SVG_TRANSFORM_SCALE) && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_TRANSLATE) {
      f = 2;
      const v = lr(r).matrix;
      r.removeItem(0);
      const w = lr(r).matrix.inverse(), C = Ro(w, v);
      if (g = C.e, _ = C.f, g !== 0 || _ !== 0) {
        const E = o.getAttribute?.("clip-path");
        E && db(E, g, _, o);
        const T = o.childNodes;
        let F = T.length;
        const B = [];
        for (; F--; ) {
          const P = T.item(F);
          if (P.nodeType !== 1) continue;
          const S = P.getAttribute("clip-path");
          if (S && !B.includes(S)) {
            const ee = db(S, g, _, P);
            B.push(ee || S);
          }
          const L = hr(P);
          if (!L) continue;
          b = xo.getStartTransform(), xo.setStartTransform(P.getAttribute("transform"));
          const U = e.createSVGTransform();
          U.setTranslate(g, _), L.numberOfItems ? L.insertItemBefore(U, 0) : L.appendItem(U);
          const O = gi(P);
          O && n.addSubCommand(O);
          const K = o.getElementsByTagNameNS(vt.SVG, "use"), te = `#${P.id}`;
          let Y = K.length;
          for (; Y--; ) {
            const ee = K.item(Y);
            if (te === ca(ee)) {
              const oe = e.createSVGTransform();
              oe.setTranslate(-g, -_), hr(ee)?.insertItemBefore(oe, 0);
              const de = gi(ee);
              de && n.addSubCommand(de);
            }
          }
          xo.setStartTransform(b);
        }
      }
    } else if (d === 1 && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_MATRIX && !p) {
      f = 1;
      const v = r.getItem(0).matrix, w = o.childNodes;
      let C = w.length;
      for (; C--; ) {
        const E = w.item(C);
        if (E.nodeType !== 1) continue;
        const T = hr(E);
        if (!T) continue;
        b = xo.getStartTransform(), xo.setStartTransform(E.getAttribute("transform"));
        const F = Ro(v, lr(T).matrix), B = e.createSVGTransform();
        B.setMatrix(F), T.clear(), T.appendItem(B);
        const P = gi(E);
        P && n.addSubCommand(P), xo.setStartTransform(b);
        const S = E.getAttribute("stroke-width");
        if (E.getAttribute("stroke") !== "none" && !Number.isNaN(Number(S))) {
          const L = (Math.abs(F.a) + Math.abs(F.d)) / 2;
          E.setAttribute("stroke-width", Number(S) * L);
        }
      }
      r.clear();
    } else {
      if (p) {
        const v = e.createSVGTransform();
        v.setRotate(p, u.x, u.y), r.numberOfItems ? r.insertItemBefore(v, 0) : r.appendItem(v);
      }
      return r.numberOfItems === 0 && o.removeAttribute("transform"), null;
    }
    if (f === 2) {
      if (p) {
        u = {
          x: c.x + m.e,
          y: c.y + m.f
        };
        const v = e.createSVGTransform();
        v.setRotate(p, u.x, u.y), r.numberOfItems ? r.insertItemBefore(v, 0) : r.appendItem(v);
      }
    } else if (f === 3) {
      const v = lr(r).matrix, w = e.createSVGTransform();
      w.setRotate(p, c.x, c.y);
      const C = w.matrix, E = e.createSVGTransform();
      E.setRotate(p, u.x, u.y);
      const T = E.matrix.inverse(), F = v.inverse(), B = Ro(F, T, C, v);
      if (g = B.e, _ = B.f, g !== 0 || _ !== 0) {
        const P = o.childNodes;
        let S = P.length;
        for (; S--; ) {
          const L = P.item(S);
          if (L.nodeType !== 1) continue;
          const U = hr(L);
          if (!U) continue;
          b = xo.getStartTransform(), xo.setStartTransform(L.getAttribute("transform"));
          const O = e.createSVGTransform();
          O.setTranslate(g, _), U.numberOfItems ? U.insertItemBefore(O, 0) : U.appendItem(O);
          const K = gi(L);
          K && n.addSubCommand(K), xo.setStartTransform(b);
        }
      }
      p && (r.numberOfItems ? r.insertItemBefore(E, 0) : r.appendItem(E));
    }
  } else {
    const A = so(o);
    if (!A && o.tagName !== "path") return null;
    let p, d = 0, g = 0;
    ["use", "image", "text", "tspan"].includes(o.tagName) && (d = Xr("x", o.getAttribute("x") || "0"), g = Xr("y", o.getAttribute("y") || "0"));
    const _ = en(o);
    if (_) {
      if (o.localName === "image") {
        const m = Xr("x", o.getAttribute("x") || "0"), b = Xr("y", o.getAttribute("y") || "0"), v = Xr("width", o.getAttribute("width") || "0"), w = Xr("height", o.getAttribute("height") || "0"), C = m + v / 2, E = b + w / 2;
        c = { x: C, y: E };
        const T = lr(r).matrix;
        u = cr(C, E, T);
      } else if (o.localName === "text") {
        const m = A.x + A.width / 2, b = A.y + A.height / 2;
        c = { x: m, y: b }, u = cr(m, b, lr(r).matrix);
      } else
        c = {
          x: A.x + A.width / 2 + d,
          y: A.y + A.height / 2 + g
        }, u = cr(
          A.x + A.width / 2 + d,
          A.y + A.height / 2 + g,
          lr(r).matrix
        );
      for (let m = 0; m < r.numberOfItems; ++m)
        if (r.getItem(m).type === SVGTransform.SVG_TRANSFORM_ROTATE) {
          r.removeItem(m);
          break;
        }
    }
    const f = r.numberOfItems;
    if (f >= 3 && r.getItem(f - 3).type === SVGTransform.SVG_TRANSFORM_TRANSLATE && r.getItem(f - 2).type === SVGTransform.SVG_TRANSFORM_SCALE && r.getItem(f - 1).type === SVGTransform.SVG_TRANSFORM_TRANSLATE) {
      if (p = lr(r, f - 3, f - 1).matrix, r.removeItem(f - 1), r.removeItem(f - 2), r.removeItem(f - 3), o.tagName === "use") {
        const m = lr(
          hr(o)
        ).matrix, b = Ro(m, p);
        r.clear();
        const v = e.createSVGTransform();
        v.setMatrix(b), r.appendItem(v);
      } else
        eA(o, a, p);
      if (_) {
        const m = lr(r).matrix, b = e.createSVGTransform();
        b.setRotate(_, c.x, c.y);
        const v = b.matrix, w = e.createSVGTransform();
        w.setRotate(_, u.x, u.y);
        const C = w.matrix.inverse(), E = m.inverse(), T = Ro(
          E,
          C,
          v,
          m
        );
        eA(o, a, T), r.numberOfItems ? r.insertItemBefore(w, 0) : r.appendItem(w);
      }
    } else if ((f === 1 || f > 1 && r.getItem(1).type !== SVGTransform.SVG_TRANSFORM_SCALE) && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_TRANSLATE) {
      const m = r.getItem(0).matrix, b = lr(r, 1).matrix, v = b.inverse();
      if (p = Ro(
        v,
        m,
        b
      ), r.removeItem(0), o.tagName === "use") {
        const w = lr(
          hr(o)
        ).matrix, C = Ro(w, p);
        r.clear();
        const E = e.createSVGTransform();
        E.setMatrix(C), r.appendItem(E);
      } else
        eA(o, a, p);
      if (_) {
        Ml(r) || (u = {
          x: c.x + p.e,
          y: c.y + p.f
        });
        const w = e.createSVGTransform();
        w.setRotate(_, u.x, u.y), r.numberOfItems ? r.insertItemBefore(w, 0) : r.appendItem(w);
      }
    } else if (f === 1 && r.getItem(0).type === SVGTransform.SVG_TRANSFORM_MATRIX && !_)
      if (p = lr(r).matrix, r.clear(), o.tagName === "use") {
        const m = lr(
          hr(o)
        ).matrix, b = Ro(m, p);
        r.clear();
        const v = e.createSVGTransform();
        v.setMatrix(b), r.appendItem(v);
      } else
        eA(o, a, p);
    else {
      if (_) {
        const m = e.createSVGTransform();
        m.setRotate(_, u.x, u.y), r.numberOfItems ? r.insertItemBefore(m, 0) : r.appendItem(m);
      }
      return r.numberOfItems === 0 && o.removeAttribute("transform"), null;
    }
  }
  return r.numberOfItems === 0 && o.removeAttribute("transform"), n.addSubCommand(new eu(o, s)), n;
}, {
  MoveElementCommand: XA,
  BatchCommand: Ws,
  InsertElementCommand: Sv,
  RemoveElementCommand: UA,
  ChangeElementCommand: bh
} = Gl;
let Te = null;
const a3 = (o) => {
  Te = o, Te.copySelectedElements = f3, Te.groupSelectedElements = m3, Te.pushGroupProperties = Ev, Te.ungroupSelectedElement = y3, Te.moveToTopSelectedElement = s3, Te.moveToBottomSelectedElement = l3, Te.moveUpDownSelected = c3, Te.moveSelectedElements = Bv, Te.cloneSelectedElements = u3, Te.alignSelectedElements = A3, Te.updateCanvas = b3, Te.cycleElement = v3, Te.deleteSelectedElements = g3, Te.flipSelectedElements = _3;
}, s3 = () => {
  const [o] = Te.getSelectedElements();
  if (o) {
    const e = o, t = e.parentNode, r = e.nextSibling;
    e.parentNode.append(e), r !== e.nextSibling && (Te.addCommandToHistory(
      new XA(e, r, t, "top")
    ), Te.call("changed", [e]));
  }
}, l3 = () => {
  const [o] = Te.getSelectedElements();
  if (o) {
    let e = o;
    const t = e.parentNode, r = e.nextSibling;
    let n = e.parentNode.firstElementChild;
    if (n?.tagName === "title" && (n = n.nextElementSibling), n?.tagName === "defs" && (n = n.nextElementSibling), !n)
      return;
    e = e.parentNode.insertBefore(e, n), r !== e.nextSibling && (Te.addCommandToHistory(
      new XA(e, r, t, "bottom")
    ), Te.call("changed", [e]));
  }
}, c3 = (o) => {
  const e = Te.getSelectedElements()[0];
  if (!e)
    return;
  Te.setCurBBoxes([]);
  let t, r;
  const n = Te.getIntersectionList(
    bi([e])
  );
  if (o === "Down" && n.reverse(), Array.prototype.forEach.call(n, (l) => r ? (t === void 0 && (t = l), !1) : (l === e && (r = !0), !0)), !t)
    return;
  const i = e, a = i.parentNode, s = i.nextSibling;
  o === "Down" ? t.insertAdjacentElement("beforebegin", i) : t.insertAdjacentElement("afterend", i), s !== i.nextSibling && (Te.addCommandToHistory(
    new XA(i, s, a, `Move ${o}`)
  ), Te.call("changed", [i]));
}, Bv = (o, e, t = !0) => {
  const r = Te.getSelectedElements(), n = Te.getZoom();
  Array.isArray(o) || (o /= n, e /= n);
  const i = new Ws("position");
  if (r.forEach((a, s) => {
    if (a) {
      const l = a.getAttribute("transform") || "", c = Te.getSvgRoot().createSVGTransform(), u = hr(a);
      Array.isArray(o) ? c.setTranslate(o[s], e[s]) : c.setTranslate(o, e), u.numberOfItems ? u.insertItemBefore(c, 0) : u.appendItem(c);
      const A = gi(a);
      A ? i.addSubCommand(A) : (a.getAttribute("transform") || "") !== l && i.addSubCommand(
        new bh(a, { transform: l })
      ), Te.gettingSelectorManager().requestSelector(a).resize();
    }
  }), !i.isEmpty())
    return t && Te.addCommandToHistory(i), Te.call("changed", r), i;
}, u3 = (o, e) => {
  const t = Te.getSelectedElements(), r = Te.getCurrentGroup();
  let n, i;
  const a = new Ws("Clone Elements"), s = t.length, l = (p) => {
    if (!p) return -1;
    let d = 0, g = p;
    do
      d++, g = g.previousElementSibling;
    while (g);
    return d;
  }, c = (p, d) => l(d) - l(p);
  for (t.sort(c), n = 0; n < s && (i = t[n], !!i); ++n)
    ;
  const u = t.slice(0, n);
  Te.clearSelection(!0);
  const A = Te.getDrawing();
  for (n = u.length; n--; )
    i = u[n] = A.copyElem(u[n]), (r || A.getCurrentLayer()).append(i), a.addSubCommand(new Sv(i));
  a.isEmpty() || (Te.addToSelection(u.reverse()), Bv(o, e, !1), Te.addCommandToHistory(a));
}, A3 = (o, e) => {
  const t = Te.getSelectedElements(), r = [], n = t.length;
  if (!n)
    return;
  let i = Number.MAX_VALUE, a = Number.MIN_VALUE, s = Number.MAX_VALUE, l = Number.MIN_VALUE;
  const c = (d) => ["l", "c", "r", "left", "center", "right"].includes(d), u = (d) => ["t", "m", "b", "top", "middle", "bottom"].includes(d);
  for (let d = 0; d < n && t[d]; ++d) {
    const g = t[d];
    r[d] = bi([g]);
  }
  switch (["smallest", "largest"].includes(e) && ["dh", "distrib_horiz", "dv", "distrib_verti"].includes(o) && (e = "selected"), e) {
    case "smallest":
      if (c(o) || u(o)) {
        const d = r.slice().sort((g, _) => g.width - _.width)[0];
        i = d.x, s = d.y, a = d.x + d.width, l = d.y + d.height;
      }
      break;
    case "largest":
      if (c(o) || u(o)) {
        const d = r.slice().sort((g, _) => g.width - _.width)[r.length - 1];
        i = d.x, s = d.y, a = d.x + d.width, l = d.y + d.height;
      }
      break;
    case "page":
      i = 0, s = 0, a = Te.getContentW(), l = Te.getContentH();
      break;
    default:
      i = Math.min(...r.map((d) => d.x)), s = Math.min(...r.map((d) => d.y)), a = Math.max(...r.map((d) => d.x + d.width)), l = Math.max(...r.map((d) => d.y + d.height));
      break;
  }
  let A = [], p = [];
  ["dh", "distrib_horiz"].includes(o) ? [A, p] = d3(e, t, r, i, a, s, l) : ["dv", "distrib_verti"].includes(o) ? [A, p] = p3(e, t, r, i, a, s, l) : [A, p] = h3(o, t, r, i, a, s, l), Bv(A, p);
}, d3 = (o, e, t, r, n, i, a) => {
  const s = [], l = [];
  for (let g = 0; g < e.length; g++)
    l[g] = 0;
  const c = t.slice().sort((g, _) => {
    const f = g.x + g.width, m = _.x + _.width;
    return f === m ? 0 : f > m ? 1 : -1;
  });
  o === "page" && (c.unshift({ x: 0, y: 0, width: 0, height: a }), c.push({ x: n, y: 0, width: 0, height: a }));
  const u = n - r, A = c.map((g) => g.width).reduce((g, _) => g + _, 0), p = (u - A) / (c.length - 1), d = [];
  for (let g = 0; g < c.length; ++g) {
    if (d[g] = 0, g === 0)
      continue;
    const _ = c[g].x;
    c[g].x = c[g - 1].x + c[g - 1].width + p, d[g] = c[g].x - _;
  }
  return c.forEach((g, _) => {
    const f = t.findIndex((m) => m === g);
    f !== -1 && (s[f] = d[_]);
  }), [s, l];
}, p3 = (o, e, t, r, n, i, a) => {
  const s = [], l = [];
  for (let g = 0; g < e.length; g++)
    s[g] = 0;
  const c = t.slice().sort((g, _) => {
    const f = g.y + g.height, m = _.y + _.height;
    return f === m ? 0 : f > m ? 1 : -1;
  });
  o === "page" && (c.unshift({ x: 0, y: 0, width: n, height: 0 }), c.push({ x: 0, y: a, width: n, height: 0 }));
  const u = a - i, A = c.map((g) => g.height).reduce((g, _) => g + _, 0), p = (u - A) / (c.length - 1), d = [];
  for (let g = 0; g < c.length; ++g) {
    if (d[g] = 0, g === 0)
      continue;
    const _ = c[g].y;
    c[g].y = c[g - 1].y + c[g - 1].height + p, d[g] = c[g].y - _;
  }
  return c.forEach((g, _) => {
    const f = t.findIndex((m) => m === g);
    f !== -1 && (l[f] = d[_]);
  }), [s, l];
}, h3 = (o, e, t, r, n, i, a) => {
  const s = e.length, l = new Array(s), c = new Array(s);
  for (let u = 0; u < s && e[u]; ++u) {
    const A = t[u];
    switch (l[u] = 0, c[u] = 0, o) {
      case "l":
      // left (horizontal)
      case "left":
        l[u] = r - A.x;
        break;
      case "c":
      // center (horizontal)
      case "center":
        l[u] = (r + n) / 2 - (A.x + A.width / 2);
        break;
      case "r":
      // right (horizontal)
      case "right":
        l[u] = n - (A.x + A.width);
        break;
      case "t":
      // top (vertical)
      case "top":
        c[u] = i - A.y;
        break;
      case "m":
      // middle (vertical)
      case "middle":
        c[u] = (i + a) / 2 - (A.y + A.height / 2);
        break;
      case "b":
      // bottom (vertical)
      case "bottom":
        c[u] = a - (A.y + A.height);
        break;
    }
  }
  return [l, c];
}, g3 = () => {
  const o = Te.getSelectedElements(), e = new Ws("Delete Elements"), t = [];
  o.forEach((r) => {
    if (r) {
      let n = r.parentNode, i = r;
      Te.gettingSelectorManager().releaseSelector(i), Cv(i.id), n.tagName === "a" && n.childNodes.length === 1 && (i = n, n = n.parentNode);
      const { nextSibling: a } = i;
      i.remove();
      const s = i;
      t.push(r), e.addSubCommand(new UA(s, a, n));
    }
  }), Te.setEmptySelectedElements(), e.isEmpty() || Te.addCommandToHistory(e), Te.call("changed", t), Te.clearSelection();
}, _3 = (o, e) => {
  const t = Te.getSelectedElements(), r = new Ws("Flip Elements"), n = Te.getSvgRoot();
  t.forEach((i) => {
    if (!i) return;
    const a = bi([i]);
    if (!a) return;
    const s = a.x + a.width / 2, l = a.y + a.height / 2, c = i.getAttribute("transform") || "", u = n.createSVGMatrix().translate(s, l).scaleNonUniform(o, e).translate(-s, -l), A = hr(i), p = Ro(
      lr(A).matrix,
      u
    ), d = n.createSVGTransform();
    d.setMatrix(p), A.clear(), A.appendItem(d);
    const g = Te.getStartTransform ? Te.getStartTransform() : null;
    Te.setStartTransform && Te.setStartTransform(c);
    const _ = gi(i);
    Te.setStartTransform && Te.setStartTransform(g), _ ? r.addSubCommand(_) : (i.getAttribute("transform") || "") !== c && r.addSubCommand(
      new bh(i, { transform: c })
    ), Te.gettingSelectorManager().requestSelector(i).resize();
  }), r.isEmpty() || (Te.addCommandToHistory(r), Te.call("changed", t.filter(Boolean)));
}, f3 = () => {
  const o = Te.getSelectedElements().filter(Boolean), e = JSON.stringify(
    o.map((t) => Te.getJsonFromSvgElements(t))
  );
  sessionStorage.setItem(Te.getClipboardID(), e), Te.flashStorage(), document.getElementById("se-cmenu_canvas")?.setAttribute("enablemenuitems", "#paste,#paste_in_place");
}, m3 = (o, e) => {
  const t = Te.getSelectedElements();
  o || (o = "g");
  let r = "", n;
  o === "a" ? (r = "Make hyperlink", n = e || "") : (o = "g", r = "Group Elements");
  const i = new Ws(r), a = Te.addSVGElementsFromJson({
    element: o,
    attr: {
      id: Te.getNextId()
    }
  });
  o === "a" && vi(a, n), i.addSubCommand(new Sv(a));
  let s = t.length;
  for (; s--; ) {
    let l = t[s];
    if (!l)
      continue;
    l.parentNode.tagName === "a" && l.parentNode.childNodes.length === 1 && (l = l.parentNode);
    const c = l.nextSibling, u = l.parentNode;
    a.append(l), i.addSubCommand(
      new XA(l, c, u)
    );
  }
  i.isEmpty() || Te.addCommandToHistory(i), Te.selectOnly([a], !0);
}, Ev = (o, e) => {
  const t = o.childNodes, r = t.length, n = o.getAttribute("transform"), i = hr(o), a = lr(i).matrix, s = new Ws("Push group properties"), l = en(o), c = {
    filter: o.getAttribute("filter"),
    opacity: o.getAttribute("opacity")
  };
  let u, A, p;
  const d = Te.getDrawing();
  for (let g = 0; g < r; g++) {
    const _ = t[g];
    if (_.nodeType !== 1)
      continue;
    if (c.opacity !== null && c.opacity !== 1) {
      const m = Math.round((_.getAttribute("opacity") || 1) * c.opacity * 100) / 100;
      Te.changeSelectedAttribute("opacity", m, [_]);
    }
    if (c.filter) {
      let m = Te.getBlur(_);
      const b = m;
      if (A || (A = Te.getBlur(o)), m ? m = Number(A) + Number(m) : m === 0 && (m = A), b)
        u = Gs(_.getAttribute("filter"));
      else if (!u)
        u = Gs(c.filter);
      else {
        u = d.copyElem(u), Dn().append(u);
        const w = lb(u)?.tagName === "feGaussianBlur" ? "blur" : "filter";
        u.id = `${_.id}_${w}`, Te.changeSelectedAttribute(
          "filter",
          `url(#${u.id})`,
          [_]
        );
      }
      const v = lb(u);
      m && (Te.changeSelectedAttribute("stdDeviation", m, [v]), Te.setBlurOffsets(u, m));
    }
    let f = hr(_);
    if (_.tagName.includes("Gradient") && (f = null), !!f && _.tagName !== "defs" && i.numberOfItems)
      if (l && i.numberOfItems === 1) {
        const m = i.getItem(0).matrix;
        let b = Te.getSvgRoot().createSVGMatrix();
        const v = en(_);
        v && (b = f.getItem(0).matrix);
        const w = so(_), C = lr(f).matrix, E = cr(
          w.x + w.width / 2,
          w.y + w.height / 2,
          C
        ), T = l + v, F = Te.getSvgRoot().createSVGTransform();
        F.setRotate(T, E.x, E.y);
        const B = Ro(m, b, F.matrix.inverse());
        if (v && f.removeItem(0), T && (f.numberOfItems ? f.insertItemBefore(F, 0) : f.appendItem(F)), B.e || B.f) {
          const P = Te.getSvgRoot().createSVGTransform();
          P.setTranslate(B.e, B.f), f.numberOfItems ? f.insertItemBefore(P, 0) : f.appendItem(P);
        }
      } else {
        const m = _.getAttribute("transform");
        p = {}, p.transform = m || "";
        const b = Te.getSvgRoot().createSVGTransform();
        b.setMatrix(a), f.numberOfItems ? f.insertItemBefore(b, 0) : f.appendItem(b), e && s.addSubCommand(new bh(_, p));
      }
  }
  if (n && (p = {}, p.transform = n, o.setAttribute("transform", ""), o.removeAttribute("transform"), s.addSubCommand(new bh(o, p))), e && !s.isEmpty())
    return s;
}, X0 = (o) => {
  const e = Te.getSelectedElements();
  o || (o = e[0]);
  const t = o, r = new Ws();
  let n;
  const i = Te.getDataStorage();
  if (i.has(t, "gsvg")) {
    const a = o.firstChild, s = {
      x: Number(a.getAttribute("x")),
      y: Number(a.getAttribute("y"))
    }, l = o.firstChild.firstChild;
    l && (l.outerHTML = l.innerHTML), i.remove(o, "gsvg");
    const c = hr(o), u = Te.getSvgRoot().createSVGTransform();
    u.setTranslate(s.x, s.y), c.appendItem(u), gi(o), Te.call("selected", [o]);
  } else if (i.has(t, "symbol")) {
    if (o = i.get(t, "symbol"), !o) {
      xn("Unable to convert <use>: missing symbol reference", null, "selected-elem");
      return;
    }
    n = t.getAttribute("transform") || "";
    const a = {
      x: Number(t.getAttribute("x")),
      y: Number(t.getAttribute("y"))
    }, s = o.getAttribute("viewBox");
    if (s) {
      const m = s.split(/[ ,]+/);
      a.x -= Number(m[0]), a.y -= Number(m[1]);
    }
    n += " translate(" + (a.x || 0) + "," + (a.y || 0) + ")";
    const l = t.parentNode, c = t.nextSibling;
    r.addSubCommand(
      new UA(
        t,
        c,
        l
      )
    ), t.remove();
    const u = Te.getSvgContent().querySelectorAll("use").length, A = Te.getDOMDocument().createElementNS(vt.SVG, "g"), p = o.childNodes;
    let d;
    for (d = 0; d < p.length; d++)
      A.append(p[d].cloneNode(!0));
    if (Pl()) {
      const m = Dn().querySelectorAll(
        "linearGradient,radialGradient,pattern"
      );
      for (let b = 0, v = m.length; v > b; b++)
        A.appendChild(m[b].cloneNode(!0));
    }
    n && A.setAttribute("transform", n);
    const g = o.parentNode;
    if (Te.uniquifyElems(A), Pl()) {
      const m = Dn(), b = A.querySelectorAll(
        "linearGradient,radialGradient,pattern"
      );
      for (let v = 0, w = b.length; w > v; v++)
        m.appendChild(b[v]);
    }
    if (A.id = Te.getNextId(), l && l.insertBefore(A, c), g) {
      if (!u) {
        const { nextSibling: m } = o;
        o.remove(), r.addSubCommand(
          new UA(o, m, g)
        );
      }
      r.addSubCommand(new Sv(A));
    }
    Te.setUseData(A), Pl() ? Te.convertGradients(Dn()) : Te.convertGradients(A), V4(A, (m) => {
      try {
        gi(m);
      } catch (b) {
        Zc("Error recalculating dimensions", b, "selected-elem");
      }
    });
    const _ = A.querySelectorAll(Te.getVisElems());
    Array.prototype.forEach.call(_, (m) => {
      m.id || (m.id = Te.getNextId());
    }), Te.selectOnly([A]);
    const f = Ev(A, !0);
    f && r.addSubCommand(f), Te.addCommandToHistory(r);
  } else
    xn("Unexpected element to ungroup:", o, "selected-elem");
}, y3 = () => {
  const o = Te.getSelectedElements(), e = Te.getDataStorage();
  let t = o[0];
  if (!t)
    return;
  if (e.has(t, "gsvg") || e.has(t, "symbol")) {
    X0(t);
    return;
  }
  if (t.tagName === "use") {
    const n = ca(t);
    if (!n || !n.startsWith("#")) {
      xn("Unexpected <use> without local reference:", t, "selected-elem");
      return;
    }
    const i = wr(n.slice(1));
    if (!i) {
      xn("Unexpected <use> without resolved reference:", t, "selected-elem");
      return;
    }
    e.put(t, "symbol", i), e.put(t, "ref", i), X0(t);
    return;
  }
  const r = zA(t.parentNode, "a");
  if (r?.length && (t = r[0]), t.tagName === "g" || t.tagName === "a") {
    const n = new Ws("Ungroup Elements"), i = Ev(t, !0);
    i && n.addSubCommand(i);
    const a = t.parentNode, s = t.nextSibling, l = new Array(t.childNodes.length);
    let c = 0;
    for (; t.firstChild; ) {
      const A = t.firstChild, p = A.nextSibling, d = A.parentNode;
      if (A.tagName === "title") {
        const { nextSibling: g } = A;
        n.addSubCommand(
          new UA(A, g, d)
        ), A.remove();
        continue;
      }
      l[c++] = a.insertBefore(A, s), n.addSubCommand(
        new XA(A, p, d)
      );
    }
    Te.clearSelection();
    const u = t.nextSibling;
    t.remove(), n.addSubCommand(new UA(t, u, a)), n.isEmpty() || Te.addCommandToHistory(n), Te.addToSelection(l);
  }
}, b3 = (o, e) => {
  Te.getSvgRoot().setAttribute("width", o), Te.getSvgRoot().setAttribute("height", e);
  const t = Te.getZoom(), r = document.getElementById("canvasBackground"), n = Number(Te.getSvgContent().getAttribute("x")), i = Number(Te.getSvgContent().getAttribute("y")), a = (o - Te.contentW * t) / 2, s = (e - Te.contentH * t) / 2;
  br(Te.getSvgContent(), {
    width: Te.contentW * t,
    height: Te.contentH * t,
    x: a,
    y: s,
    viewBox: `0 0 ${Te.contentW} ${Te.contentH}`
  }), br(r, {
    width: Te.getSvgContent().getAttribute("width"),
    height: Te.getSvgContent().getAttribute("height"),
    x: a,
    y: s
  });
  const l = wr("background_image");
  return l && br(l, {
    width: "100%",
    height: "100%"
  }), Te.selectorManager.selectorParentGroup.setAttribute(
    "transform",
    `translate(${a},${s})`
  ), Te.runExtensions(
    "canvasUpdated",
    /**
     * @type {module:svgcanvas.SvgCanvas#event:ext_canvasUpdated}
     */
    {
      new_x: a,
      new_y: s,
      old_x: n,
      old_y: i,
      d_x: a - n,
      d_y: s - i
    }
  ), { x: a, y: s, old_x: n, old_y: i, d_x: a - n, d_y: s - i };
}, v3 = (o) => {
  const e = Te.getSelectedElements(), t = Te.getCurrentGroup();
  let r;
  const n = e[0];
  let i = !1;
  const a = KA(
    t || Te.getCurrentDrawing().getCurrentLayer()
  );
  if (a.length) {
    if (!n)
      r = o ? a.length - 1 : 0, i = a[r];
    else {
      let s = a.length;
      for (; s--; )
        if (a[s] === n) {
          r = o ? s - 1 : s + 1, r >= a.length ? r = 0 : r < 0 && (r = a.length - 1), i = a[r];
          break;
        }
    }
    Te.selectOnly([i], !0), Te.call("selected", e);
  }
};
let tr = null;
const w3 = (o) => {
  tr = o;
}, jE = (o) => !o || o.nodeType !== 1 ? null : o.querySelector("feGaussianBlur") || o.firstElementChild, x3 = (o) => {
  const e = tr.getSelectedElements()[0];
  if (!e) return;
  let t = tr.getFilter();
  if (t || (t = tr.getElement(`${e.id}_blur`)), o === 0)
    tr.changeSelectedAttributeNoUndo("filter", ""), tr.setFilterHidden(!0);
  else {
    if (!t) {
      const n = tr.addSVGElementsFromJson({
        element: "feGaussianBlur",
        attr: {
          in: "SourceGraphic",
          stdDeviation: o
        }
      });
      t = tr.addSVGElementsFromJson({
        element: "filter",
        attr: {
          id: `${e.id}_blur`
        }
      }), t.append(n), tr.findDefs().append(t);
    }
    (tr.getFilterHidden() || !e.getAttribute("filter")) && (tr.changeSelectedAttributeNoUndo("filter", `url(#${t.id})`), tr.setFilterHidden(!1));
    const r = jE(t);
    if (!r)
      return;
    tr.changeSelectedAttributeNoUndo("stdDeviation", o, [r]), tr.setBlurOffsets(t, o);
  }
}, Y0 = () => {
  const o = tr.getCurCommand();
  if (!o) {
    tr.setCurCommand(null), tr.setFilter(null), tr.setFilterHidden(!1);
    return;
  }
  const e = tr.undoMgr.finishUndoableChange();
  e.isEmpty() || o.addSubCommand(e), o.isEmpty() || tr.addCommandToHistory(o), tr.setCurCommand(null), tr.setFilter(null), tr.setFilterHidden(!1);
}, k3 = (o, e) => {
  !o || o.nodeType !== 1 || (e = Number(e) || 0, e > 3 ? tr.assignAttributes(o, {
    x: "-50%",
    y: "-50%",
    width: "200%",
    height: "200%"
  }, 100) : (o.removeAttribute("x"), o.removeAttribute("y"), o.removeAttribute("width"), o.removeAttribute("height")));
}, C3 = (o, e) => {
  const {
    InsertElementCommand: t,
    ChangeElementCommand: r,
    BatchCommand: n
  } = tr.history, i = tr.getSelectedElements();
  if (tr.getCurCommand()) {
    Y0();
    return;
  }
  const a = i[0];
  if (!a)
    return;
  const s = a.id;
  let l = tr.getElement(`${s}_blur`);
  tr.setFilter(l), o = Number(o) || 0;
  const c = new n("Change blur");
  if (o === 0) {
    const p = a.getAttribute("filter");
    if (!p)
      return;
    const d = { filter: p };
    a.removeAttribute("filter"), c.addSubCommand(new r(a, d)), tr.addCommandToHistory(c), tr.setFilter(null), tr.setFilterHidden(!0);
    return;
  }
  if (!l) {
    const p = tr.addSVGElementsFromJson({
      element: "feGaussianBlur",
      attr: {
        in: "SourceGraphic",
        stdDeviation: o
      }
    });
    l = tr.addSVGElementsFromJson({
      element: "filter",
      attr: {
        id: `${s}_blur`
      }
    }), l.append(p);
    const d = tr.findDefs();
    d && d.ownerDocument === l.ownerDocument && d.append(l), tr.setFilter(l), c.addSubCommand(new t(l));
  }
  const u = { filter: a.getAttribute("filter") };
  tr.changeSelectedAttributeNoUndo("filter", `url(#${l.id})`), c.addSubCommand(new r(a, u)), tr.setBlurOffsets(l, o), tr.setCurCommand(c);
  const A = jE(l);
  tr.undoMgr.beginUndoableChange("stdDeviation", [A]), e && (tr.setBlurNoUndo(o), Y0());
}, S3 = G5(), rp = ["font-family", "font-size", "font-stretch", "font-style", "font-weight"], B3 = ["class", "id", "display", "transform", "style"], vh = {
  // SVG Elements
  a: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "href", "mask", "opacity", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "xlink:href", "xlink:title"],
  circle: ["clip-path", "clip-rule", "cx", "cy", "enable-background", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "r", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage"],
  clipPath: ["clipPathUnits"],
  defs: [],
  desc: [],
  ellipse: ["clip-path", "clip-rule", "cx", "cy", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "rx", "ry", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage"],
  feBlend: ["in", "in2"],
  feColorMatrix: ["in", "type", "value", "result", "values"],
  feComposite: ["in", "operator", "result", "in2"],
  feFlood: ["flood-color", "in", "result", "flood-opacity"],
  feGaussianBlur: ["color-interpolation-filters", "in", "requiredFeatures", "stdDeviation", "result"],
  feMerge: [],
  feMergeNode: ["in"],
  feMorphology: ["in", "operator", "radius"],
  feOffset: ["dx", "in", "dy", "result"],
  filter: ["color-interpolation-filters", "filterRes", "filterUnits", "height", "href", "primitiveUnits", "requiredFeatures", "width", "x", "xlink:href", "y"],
  foreignObject: ["font-size", "height", "opacity", "requiredFeatures", "width", "x", "y"],
  g: [...rp, "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor"],
  image: [
    "clip-path",
    "clip-rule",
    "filter",
    "height",
    "mask",
    "opacity",
    "preserveAspectRatio",
    "requiredFeatures",
    "systemLanguage",
    "viewBox",
    "width",
    "x",
    "href",
    "xlink:href",
    "xlink:title",
    "y"
  ],
  line: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "x1", "x2", "y1", "y2"],
  linearGradient: ["gradientTransform", "gradientUnits", "requiredFeatures", "spreadMethod", "systemLanguage", "x1", "x2", "href", "xlink:href", "y1", "y2"],
  marker: ["markerHeight", "markerUnits", "markerWidth", "orient", "preserveAspectRatio", "refX", "refY", "se_type", "systemLanguage", "viewBox"],
  mask: ["height", "maskContentUnits", "maskUnits", "width", "x", "y"],
  metadata: [],
  path: ["clip-path", "clip-rule", "d", "enable-background", "fill", "fill-opacity", "fill-rule", "filter", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage"],
  pattern: ["height", "patternContentUnits", "patternTransform", "patternUnits", "requiredFeatures", "systemLanguage", "viewBox", "width", "x", "href", "xlink:href", "y"],
  polygon: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "points", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "sides", "shape", "edge", "point", "starRadiusMultiplier", "r", "radialshift", "r2", "orient", "cx", "cy"],
  polyline: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "points", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "se:connector"],
  radialGradient: ["cx", "cy", "fx", "fy", "gradientTransform", "gradientUnits", "r", "requiredFeatures", "spreadMethod", "systemLanguage", "href", "xlink:href"],
  rect: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "height", "mask", "opacity", "requiredFeatures", "rx", "ry", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "width", "x", "y"],
  stop: ["offset", "requiredFeatures", "stop-opacity", "systemLanguage", "stop-color", "gradientUnits", "gradientTransform"],
  style: ["type"],
  svg: ["clip-path", "clip-rule", "enable-background", "filter", "height", "mask", "preserveAspectRatio", "requiredFeatures", "systemLanguage", "version", "viewBox", "width", "x", "xmlns", "xmlns:se", "xmlns:xlink", "xmlns:oi", "oi:animations", "y", "stroke-linejoin", "fill-rule", "aria-label", "stroke-width", "fill-rule", "xml:space"],
  switch: ["requiredFeatures", "systemLanguage"],
  symbol: [...rp, "fill", "fill-opacity", "fill-rule", "filter", "opacity", "overflow", "preserveAspectRatio", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "viewBox", "width", "height"],
  text: [...rp, "clip-path", "clip-rule", "dominant-baseline", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor", "letter-spacing", "word-spacing", "text-decoration", "textLength", "lengthAdjust", "x", "xml:space", "y"],
  textPath: ["dominant-baseline", "href", "method", "requiredFeatures", "spacing", "startOffset", "systemLanguage", "xlink:href"],
  title: [],
  tspan: [...rp, "clip-path", "clip-rule", "dx", "dy", "dominant-baseline", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "rotate", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "text-anchor", "textLength", "x", "xml:space", "y"],
  use: ["clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "height", "href", "mask", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "width", "x", "xlink:href", "y", "overflow"],
  // Filter Primitives
  feComponentTransfer: ["in", "result"],
  feFuncR: ["type", "tableValues", "slope", "intercept", "amplitude", "exponent", "offset"],
  feFuncG: ["type", "tableValues", "slope", "intercept", "amplitude", "exponent", "offset"],
  feFuncB: ["type", "tableValues", "slope", "intercept", "amplitude", "exponent", "offset"],
  feFuncA: ["type", "tableValues", "slope", "intercept", "amplitude", "exponent", "offset"],
  feConvolveMatrix: ["in", "order", "kernelMatrix", "divisor", "bias", "targetX", "targetY", "edgeMode", "kernelUnitLength", "preserveAlpha"],
  feDiffuseLighting: ["in", "surfaceScale", "diffuseConstant", "kernelUnitLength", "lighting-color"],
  feSpecularLighting: ["in", "surfaceScale", "specularConstant", "specularExponent", "kernelUnitLength", "lighting-color"],
  feDisplacementMap: ["in", "in2", "scale", "xChannelSelector", "yChannelSelector"],
  feTurbulence: ["baseFrequency", "numOctaves", "result", "seed", "stitchTiles", "type"],
  feTile: ["in"],
  // MathML Elements
  annotation: ["encoding"],
  "annotation-xml": ["encoding"],
  maction: ["actiontype", "other", "selection"],
  math: ["xmlns"],
  menclose: ["notation"],
  merror: [],
  mfrac: ["linethickness"],
  mi: ["mathvariant"],
  mmultiscripts: [],
  mn: [],
  mo: ["fence", "lspace", "maxsize", "minsize", "rspace", "stretchy"],
  mover: [],
  mpadded: ["lspace", "width", "height", "depth", "voffset"],
  mphantom: [],
  mprescripts: [],
  mroot: [],
  mrow: ["href", "xlink:href", "xlink:type", "xmlns:xlink"],
  mspace: ["depth", "height", "width"],
  msqrt: [],
  mstyle: ["displaystyle", "mathbackground", "mathcolor", "mathvariant", "scriptlevel"],
  msub: [],
  msubsup: [],
  msup: [],
  mtable: ["align", "columnalign", "columnlines", "columnspacing", "displaystyle", "equalcolumns", "equalrows", "frame", "rowalign", "rowlines", "rowspacing", "width"],
  mtd: ["columnalign", "columnspan", "rowalign", "rowspan"],
  mtext: [],
  mtr: ["columnalign", "rowalign"],
  munder: [],
  munderover: [],
  none: [],
  semantics: [],
  // HTML Elements for use in a foreignObject
  div: [],
  p: [],
  li: [],
  pre: [],
  ol: [],
  ul: [],
  span: [],
  hr: [],
  br: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: []
};
for (const [o, e] of Object.entries(vh))
  vh[o] = [...e, ...B3];
const LE = {};
for (const [o, e] of Object.entries(vh)) {
  const t = {};
  for (const r of e)
    if (r.includes(":")) {
      const [n, i] = r.split(":");
      t[i] = vt[n.toUpperCase()];
    } else
      t[r] = r === "xmlns" ? vt.XMLNS : null;
  LE[o] = t;
}
const pb = (o) => {
  if (o.nodeType === 3 && (o.nodeValue = o.nodeValue.trim(), o.nodeValue.length || o.remove()), o.nodeType !== 1)
    return;
  const e = o.ownerDocument, t = o.parentNode;
  if (!e || !t)
    return;
  const r = vh[o.nodeName], n = LE[o.nodeName];
  if (typeof r < "u") {
    const i = [];
    let a = o.attributes.length;
    for (; a--; ) {
      const c = o.attributes.item(a), u = c.nodeName, A = c.localName, p = c.namespaceURI;
      if (p !== n[A] && p !== vt.XMLNS && !(p === vt.XMLNS && S3[c.value]) && !(A === "href" && r.includes("href")))
        if (u.startsWith("se:") || u.startsWith("oi:") || u.startsWith("data-")) {
          const d = u.startsWith("se:") ? vt.SE : u.startsWith("oi:") ? vt.OI : null;
          i.push([u, c.value, d]);
        } else
          xn(`attribute ${u} in element ${o.nodeName} not in whitelist is removed: ${o.outerHTML}`, null, "sanitize"), o.removeAttributeNS(p, A);
      if (u === "style") {
        const d = c.value.split(";");
        let g = d.length;
        for (; g--; ) {
          const [_, f] = d[g].split(":"), m = (_ || "").trim(), b = (f || "").trim();
          r.includes(m) && o.setAttribute(m, b);
        }
        o.removeAttribute("style");
      }
    }
    const s = o.getAttributeNS(vt.XLINK, "href");
    s && (o.setAttribute("href", s), o.removeAttributeNS(vt.XLINK, "href")), Object.values(i).forEach(([c, u, A]) => {
      o.setAttributeNS(A, c, u);
    });
    const l = ca(o);
    if (l && [
      "filter",
      "linearGradient",
      "pattern",
      "radialGradient",
      "textPath",
      "use"
    ].includes(o.nodeName) && l[0] !== "#" && (vi(o, ""), xn(`attribute href in element ${o.nodeName} pointing to a non-local reference (${l}) is removed: ${o.outerHTML}`, null, "sanitize"), o.removeAttributeNS(vt.XLINK, "href"), o.removeAttribute("href")), o.nodeName === "use" && !ca(o)) {
      xn(`element ${o.nodeName} without a xlink:href or href is removed: ${o.outerHTML}`, null, "sanitize"), o.remove();
      return;
    }
    if (o.nodeName === "use") {
      const c = Gs(ca(o));
      if (c) {
        const u = c.getAttribute("viewBox"), A = u ? u.split(/[\s,]+/).map(Number) : null, p = Number(c.getAttribute("width")), d = Number(c.getAttribute("height"));
        if (!o.hasAttribute("width")) {
          const g = A?.[2] || p;
          g && o.setAttribute("width", g);
        }
        if (!o.hasAttribute("height")) {
          const g = A?.[3] || d;
          g && o.setAttribute("height", g);
        }
      }
    }
    for (["clip-path", "fill", "filter", "marker-end", "marker-mid", "marker-start", "mask", "stroke"].forEach((c) => {
      let u = o.getAttribute(c);
      u && (u = TA(u), u && u[0] !== "#" && (o.setAttribute(c, ""), xn(`attribute ${c} in element ${o.nodeName} pointing to a non-local reference (${u}) is removed: ${o.outerHTML}`, null, "sanitize"), o.removeAttribute(c)));
    }), a = o.childNodes.length; a--; )
      pb(o.childNodes.item(a));
  } else {
    xn(`element ${o.nodeName} not supported is removed: ${o.outerHTML}`, null, "sanitize");
    const i = [];
    for (; o.hasChildNodes(); )
      i.push(t.insertBefore(o.firstChild, o));
    o.remove();
    let a = i.length;
    for (; a--; )
      pb(i[a]);
  }
};
function yr(o) {
  "@babel/helpers - typeof";
  return yr = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, yr(o);
}
var qi = Uint8Array, _i = Uint16Array, jv = Int32Array, Lv = new qi([
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  1,
  1,
  1,
  1,
  2,
  2,
  2,
  2,
  3,
  3,
  3,
  3,
  4,
  4,
  4,
  4,
  5,
  5,
  5,
  5,
  0,
  /* unused */
  0,
  0,
  /* impossible */
  0
]), Tv = new qi([
  0,
  0,
  0,
  0,
  1,
  1,
  2,
  2,
  3,
  3,
  4,
  4,
  5,
  5,
  6,
  6,
  7,
  7,
  8,
  8,
  9,
  9,
  10,
  10,
  11,
  11,
  12,
  12,
  13,
  13,
  /* unused */
  0,
  0
]), Z0 = new qi([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), TE = function(o, e) {
  for (var t = new _i(31), r = 0; r < 31; ++r)
    t[r] = e += 1 << o[r - 1];
  for (var n = new jv(t[30]), r = 1; r < 30; ++r)
    for (var i = t[r]; i < t[r + 1]; ++i)
      n[i] = i - t[r] << 5 | r;
  return { b: t, r: n };
}, PE = TE(Lv, 2), E3 = PE.b, hb = PE.r;
E3[28] = 258, hb[258] = 28;
var j3 = TE(Tv, 0), J0 = j3.r, FE = new _i(32768);
for (var Yr = 0; Yr < 32768; ++Yr) {
  var bs = (Yr & 43690) >> 1 | (Yr & 21845) << 1;
  bs = (bs & 52428) >> 2 | (bs & 13107) << 2, bs = (bs & 61680) >> 4 | (bs & 3855) << 4, FE[Yr] = ((bs & 65280) >> 8 | (bs & 255) << 8) >> 1;
}
var vA = (function(o, e, t) {
  for (var r = o.length, n = 0, i = new _i(e); n < r; ++n)
    o[n] && ++i[o[n] - 1];
  var a = new _i(e);
  for (n = 1; n < e; ++n)
    a[n] = a[n - 1] + i[n - 1] << 1;
  var s;
  for (s = new _i(r), n = 0; n < r; ++n)
    o[n] && (s[n] = FE[a[o[n] - 1]++] >> 15 - o[n]);
  return s;
}), Ol = new qi(288);
for (var Yr = 0; Yr < 144; ++Yr)
  Ol[Yr] = 8;
for (var Yr = 144; Yr < 256; ++Yr)
  Ol[Yr] = 9;
for (var Yr = 256; Yr < 280; ++Yr)
  Ol[Yr] = 7;
for (var Yr = 280; Yr < 288; ++Yr)
  Ol[Yr] = 8;
var wh = new qi(32);
for (var Yr = 0; Yr < 32; ++Yr)
  wh[Yr] = 5;
var L3 = /* @__PURE__ */ vA(Ol, 9), T3 = /* @__PURE__ */ vA(wh, 5), UE = function(o) {
  return (o + 7) / 8 | 0;
}, P3 = function(o, e, t) {
  return (t == null || t > o.length) && (t = o.length), new qi(o.subarray(e, t));
}, La = function(o, e, t) {
  t <<= e & 7;
  var r = e / 8 | 0;
  o[r] |= t, o[r + 1] |= t >> 8;
}, Uu = function(o, e, t) {
  t <<= e & 7;
  var r = e / 8 | 0;
  o[r] |= t, o[r + 1] |= t >> 8, o[r + 2] |= t >> 16;
}, f_ = function(o, e) {
  for (var t = [], r = 0; r < o.length; ++r)
    o[r] && t.push({ s: r, f: o[r] });
  var n = t.length, i = t.slice();
  if (!n)
    return { t: IE, l: 0 };
  if (n == 1) {
    var a = new qi(t[0].s + 1);
    return a[t[0].s] = 1, { t: a, l: 1 };
  }
  t.sort(function(C, E) {
    return C.f - E.f;
  }), t.push({ s: -1, f: 25001 });
  var s = t[0], l = t[1], c = 0, u = 1, A = 2;
  for (t[0] = { s: -1, f: s.f + l.f, l: s, r: l }; u != n - 1; )
    s = t[t[c].f < t[A].f ? c++ : A++], l = t[c != u && t[c].f < t[A].f ? c++ : A++], t[u++] = { s: -1, f: s.f + l.f, l: s, r: l };
  for (var p = i[0].s, r = 1; r < n; ++r)
    i[r].s > p && (p = i[r].s);
  var d = new _i(p + 1), g = gb(t[u - 1], d, 0);
  if (g > e) {
    var r = 0, _ = 0, f = g - e, m = 1 << f;
    for (i.sort(function(E, T) {
      return d[T.s] - d[E.s] || E.f - T.f;
    }); r < n; ++r) {
      var b = i[r].s;
      if (d[b] > e)
        _ += m - (1 << g - d[b]), d[b] = e;
      else
        break;
    }
    for (_ >>= f; _ > 0; ) {
      var v = i[r].s;
      d[v] < e ? _ -= 1 << e - d[v]++ - 1 : ++r;
    }
    for (; r >= 0 && _; --r) {
      var w = i[r].s;
      d[w] == e && (--d[w], ++_);
    }
    g = e;
  }
  return { t: new qi(d), l: g };
}, gb = function(o, e, t) {
  return o.s == -1 ? Math.max(gb(o.l, e, t + 1), gb(o.r, e, t + 1)) : e[o.s] = t;
}, ex = function(o) {
  for (var e = o.length; e && !o[--e]; )
    ;
  for (var t = new _i(++e), r = 0, n = o[0], i = 1, a = function(l) {
    t[r++] = l;
  }, s = 1; s <= e; ++s)
    if (o[s] == n && s != e)
      ++i;
    else {
      if (!n && i > 2) {
        for (; i > 138; i -= 138)
          a(32754);
        i > 2 && (a(i > 10 ? i - 11 << 5 | 28690 : i - 3 << 5 | 12305), i = 0);
      } else if (i > 3) {
        for (a(n), --i; i > 6; i -= 6)
          a(8304);
        i > 2 && (a(i - 3 << 5 | 8208), i = 0);
      }
      for (; i--; )
        a(n);
      i = 1, n = o[s];
    }
  return { c: t.subarray(0, r), n: e };
}, Nu = function(o, e) {
  for (var t = 0, r = 0; r < e.length; ++r)
    t += o[r] * e[r];
  return t;
}, NE = function(o, e, t) {
  var r = t.length, n = UE(e + 2);
  o[n] = r & 255, o[n + 1] = r >> 8, o[n + 2] = o[n] ^ 255, o[n + 3] = o[n + 1] ^ 255;
  for (var i = 0; i < r; ++i)
    o[n + i + 4] = t[i];
  return (n + 4 + r) * 8;
}, tx = function(o, e, t, r, n, i, a, s, l, c, u) {
  La(e, u++, t), ++n[256];
  for (var A = f_(n, 15), p = A.t, d = A.l, g = f_(i, 15), _ = g.t, f = g.l, m = ex(p), b = m.c, v = m.n, w = ex(_), C = w.c, E = w.n, T = new _i(19), F = 0; F < b.length; ++F)
    ++T[b[F] & 31];
  for (var F = 0; F < C.length; ++F)
    ++T[C[F] & 31];
  for (var B = f_(T, 7), P = B.t, S = B.l, L = 19; L > 4 && !P[Z0[L - 1]]; --L)
    ;
  var U = c + 5 << 3, O = Nu(n, Ol) + Nu(i, wh) + a, K = Nu(n, p) + Nu(i, _) + a + 14 + 3 * L + Nu(T, P) + 2 * T[16] + 3 * T[17] + 7 * T[18];
  if (l >= 0 && U <= O && U <= K)
    return NE(e, u, o.subarray(l, l + c));
  var te, Y, ee, oe;
  if (La(e, u, 1 + (K < O)), u += 2, K < O) {
    te = vA(p, d), Y = p, ee = vA(_, f), oe = _;
    var de = vA(P, S);
    La(e, u, v - 257), La(e, u + 5, E - 1), La(e, u + 10, L - 4), u += 14;
    for (var F = 0; F < L; ++F)
      La(e, u + 3 * F, P[Z0[F]]);
    u += 3 * L;
    for (var ae = [b, C], I = 0; I < 2; ++I)
      for (var G = ae[I], F = 0; F < G.length; ++F) {
        var H = G[F] & 31;
        La(e, u, de[H]), u += P[H], H > 15 && (La(e, u, G[F] >> 5 & 127), u += G[F] >> 12);
      }
  } else
    te = L3, Y = Ol, ee = T3, oe = wh;
  for (var F = 0; F < s; ++F) {
    var Z = r[F];
    if (Z > 255) {
      var H = Z >> 18 & 31;
      Uu(e, u, te[H + 257]), u += Y[H + 257], H > 7 && (La(e, u, Z >> 23 & 31), u += Lv[H]);
      var ne = Z & 31;
      Uu(e, u, ee[ne]), u += oe[ne], ne > 3 && (Uu(e, u, Z >> 5 & 8191), u += Tv[ne]);
    } else
      Uu(e, u, te[Z]), u += Y[Z];
  }
  return Uu(e, u, te[256]), u + Y[256];
}, F3 = /* @__PURE__ */ new jv([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]), IE = /* @__PURE__ */ new qi(0), U3 = function(o, e, t, r, n, i) {
  var a = i.z || o.length, s = new qi(r + a + 5 * (1 + Math.ceil(a / 7e3)) + n), l = s.subarray(r, s.length - n), c = i.l, u = (i.r || 0) & 7;
  if (e) {
    u && (l[0] = i.r >> 3);
    for (var A = F3[e - 1], p = A >> 13, d = A & 8191, g = (1 << t) - 1, _ = i.p || new _i(32768), f = i.h || new _i(g + 1), m = Math.ceil(t / 3), b = 2 * m, v = function(Xe) {
      return (o[Xe] ^ o[Xe + 1] << m ^ o[Xe + 2] << b) & g;
    }, w = new jv(25e3), C = new _i(288), E = new _i(32), T = 0, F = 0, B = i.i || 0, P = 0, S = i.w || 0, L = 0; B + 2 < a; ++B) {
      var U = v(B), O = B & 32767, K = f[U];
      if (_[O] = K, f[U] = O, S <= B) {
        var te = a - B;
        if ((T > 7e3 || P > 24576) && (te > 423 || !c)) {
          u = tx(o, l, 0, w, C, E, F, P, L, B - L, u), P = T = F = 0, L = B;
          for (var Y = 0; Y < 286; ++Y)
            C[Y] = 0;
          for (var Y = 0; Y < 30; ++Y)
            E[Y] = 0;
        }
        var ee = 2, oe = 0, de = d, ae = O - K & 32767;
        if (te > 2 && U == v(B - ae))
          for (var I = Math.min(p, te) - 1, G = Math.min(32767, B), H = Math.min(258, te); ae <= G && --de && O != K; ) {
            if (o[B + ee] == o[B + ee - ae]) {
              for (var Z = 0; Z < H && o[B + Z] == o[B + Z - ae]; ++Z)
                ;
              if (Z > ee) {
                if (ee = Z, oe = ae, Z > I)
                  break;
                for (var ne = Math.min(ae, Z - 2), le = 0, Y = 0; Y < ne; ++Y) {
                  var me = B - ae + Y & 32767, ce = _[me], ye = me - ce & 32767;
                  ye > le && (le = ye, K = me);
                }
              }
            }
            O = K, K = _[O], ae += O - K & 32767;
          }
        if (oe) {
          w[P++] = 268435456 | hb[ee] << 18 | J0[oe];
          var Ce = hb[ee] & 31, Ue = J0[oe] & 31;
          F += Lv[Ce] + Tv[Ue], ++C[257 + Ce], ++E[Ue], S = B + ee, ++T;
        } else
          w[P++] = o[B], ++C[o[B]];
      }
    }
    for (B = Math.max(B, S); B < a; ++B)
      w[P++] = o[B], ++C[o[B]];
    u = tx(o, l, c, w, C, E, F, P, L, B - L, u), c || (i.r = u & 7 | l[u / 8 | 0] << 3, u -= 7, i.h = f, i.p = _, i.i = B, i.w = S);
  } else {
    for (var B = i.w || 0; B < a + c; B += 65535) {
      var Qe = B + 65535;
      Qe >= a && (l[u / 8 | 0] = c, Qe = a), u = NE(l, u + 1, o.subarray(B, Qe));
    }
    i.i = a;
  }
  return P3(s, 0, r + UE(u) + n);
}, ME = function() {
  var o = 1, e = 0;
  return {
    p: function(t) {
      for (var r = o, n = e, i = t.length | 0, a = 0; a != i; ) {
        for (var s = Math.min(a + 2655, i); a < s; ++a)
          n += r += t[a];
        r = (r & 65535) + 15 * (r >> 16), n = (n & 65535) + 15 * (n >> 16);
      }
      o = r, e = n;
    },
    d: function() {
      return o %= 65521, e %= 65521, (o & 255) << 24 | (o & 65280) << 8 | (e & 255) << 8 | e >> 8;
    }
  };
}, N3 = function(o, e, t, r, n) {
  if (!n && (n = { l: 1 }, e.dictionary)) {
    var i = e.dictionary.subarray(-32768), a = new qi(i.length + o.length);
    a.set(i), a.set(o, i.length), o = a, n.w = i.length;
  }
  return U3(o, e.level == null ? 6 : e.level, e.mem == null ? n.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(o.length))) * 1.5) : 20 : 12 + e.mem, t, r, n);
}, RE = function(o, e, t) {
  for (; t; ++e)
    o[e] = t, t >>>= 8;
}, I3 = function(o, e) {
  var t = e.level, r = t == 0 ? 0 : t < 6 ? 1 : t == 9 ? 3 : 2;
  if (o[0] = 120, o[1] = r << 6 | (e.dictionary && 32), o[1] |= 31 - (o[0] << 8 | o[1]) % 31, e.dictionary) {
    var n = ME();
    n.p(e.dictionary), RE(o, 2, n.d());
  }
};
function _b(o, e) {
  e || (e = {});
  var t = ME();
  t.p(o);
  var r = N3(o, e, e.dictionary ? 6 : 2, 4);
  return I3(r, e), RE(r, r.length - 4, t.d()), r;
}
var M3 = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), R3 = 0;
try {
  M3.decode(IE, { stream: !0 }), R3 = 1;
} catch {
}
function O3(o) {
  if (Array.isArray(o)) return o;
}
function Q3(o, e) {
  var t = o == null ? null : typeof Symbol < "u" && o[Symbol.iterator] || o["@@iterator"];
  if (t != null) {
    var r, n, i, a, s = [], l = !0, c = !1;
    try {
      if (i = (t = t.call(o)).next, e !== 0) for (; !(l = (r = i.call(t)).done) && (s.push(r.value), s.length !== e); l = !0) ;
    } catch (u) {
      c = !0, n = u;
    } finally {
      try {
        if (!l && t.return != null && (a = t.return(), Object(a) !== a)) return;
      } finally {
        if (c) throw n;
      }
    }
    return s;
  }
}
function rx(o, e) {
  (e == null || e > o.length) && (e = o.length);
  for (var t = 0, r = Array(e); t < e; t++) r[t] = o[t];
  return r;
}
function q3(o, e) {
  if (o) {
    if (typeof o == "string") return rx(o, e);
    var t = {}.toString.call(o).slice(8, -1);
    return t === "Object" && o.constructor && (t = o.constructor.name), t === "Map" || t === "Set" ? Array.from(o) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? rx(o, e) : void 0;
  }
}
function G3() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function ox(o, e) {
  return O3(o) || Q3(o, e) || q3(o, e) || G3();
}
function nx(o, e = "utf8") {
  return new TextDecoder(e).decode(o);
}
const V3 = new TextEncoder();
function D3(o) {
  return V3.encode(o);
}
const H3 = 1024 * 8, z3 = (() => {
  const o = new Uint8Array(4), e = new Uint32Array(o.buffer);
  return !((e[0] = 1) & o[0]);
})(), m_ = {
  int8: globalThis.Int8Array,
  uint8: globalThis.Uint8Array,
  int16: globalThis.Int16Array,
  uint16: globalThis.Uint16Array,
  int32: globalThis.Int32Array,
  uint32: globalThis.Uint32Array,
  uint64: globalThis.BigUint64Array,
  int64: globalThis.BigInt64Array,
  float32: globalThis.Float32Array,
  float64: globalThis.Float64Array
};
class Pv {
  /**
   * Reference to the internal ArrayBuffer object.
   */
  buffer;
  /**
   * Byte length of the internal ArrayBuffer.
   */
  byteLength;
  /**
   * Byte offset of the internal ArrayBuffer.
   */
  byteOffset;
  /**
   * Byte length of the internal ArrayBuffer.
   */
  length;
  /**
   * The current offset of the buffer's pointer.
   */
  offset;
  lastWrittenByte;
  littleEndian;
  _data;
  _mark;
  _marks;
  /**
   * Create a new IOBuffer.
   * @param data - The data to construct the IOBuffer with.
   * If data is a number, it will be the new buffer's length<br>
   * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
   * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
   * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
   * @param options - An object for the options.
   * @returns A new IOBuffer instance.
   */
  constructor(e = H3, t = {}) {
    let r = !1;
    typeof e == "number" ? e = new ArrayBuffer(e) : (r = !0, this.lastWrittenByte = e.byteLength);
    const n = t.offset ? t.offset >>> 0 : 0, i = e.byteLength - n;
    let a = n;
    (ArrayBuffer.isView(e) || e instanceof Pv) && (e.byteLength !== e.buffer.byteLength && (a = e.byteOffset + n), e = e.buffer), r ? this.lastWrittenByte = i : this.lastWrittenByte = 0, this.buffer = e, this.length = i, this.byteLength = i, this.byteOffset = a, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, a, i), this._mark = 0, this._marks = [];
  }
  /**
   * Checks if the memory allocated to the buffer is sufficient to store more
   * bytes after the offset.
   * @param byteLength - The needed memory in bytes.
   * @returns `true` if there is sufficient space and `false` otherwise.
   */
  available(e = 1) {
    return this.offset + e <= this.length;
  }
  /**
   * Check if little-endian mode is used for reading and writing multi-byte
   * values.
   * @returns `true` if little-endian mode is used, `false` otherwise.
   */
  isLittleEndian() {
    return this.littleEndian;
  }
  /**
   * Set little-endian mode for reading and writing multi-byte values.
   * @returns This.
   */
  setLittleEndian() {
    return this.littleEndian = !0, this;
  }
  /**
   * Check if big-endian mode is used for reading and writing multi-byte values.
   * @returns `true` if big-endian mode is used, `false` otherwise.
   */
  isBigEndian() {
    return !this.littleEndian;
  }
  /**
   * Switches to big-endian mode for reading and writing multi-byte values.
   * @returns This.
   */
  setBigEndian() {
    return this.littleEndian = !1, this;
  }
  /**
   * Move the pointer n bytes forward.
   * @param n - Number of bytes to skip.
   * @returns This.
   */
  skip(e = 1) {
    return this.offset += e, this;
  }
  /**
   * Move the pointer n bytes backward.
   * @param n - Number of bytes to move back.
   * @returns This.
   */
  back(e = 1) {
    return this.offset -= e, this;
  }
  /**
   * Move the pointer to the given offset.
   * @param offset - The offset to move to.
   * @returns This.
   */
  seek(e) {
    return this.offset = e, this;
  }
  /**
   * Store the current pointer offset.
   * @see {@link IOBuffer#reset}
   * @returns This.
   */
  mark() {
    return this._mark = this.offset, this;
  }
  /**
   * Move the pointer back to the last pointer offset set by mark.
   * @see {@link IOBuffer#mark}
   * @returns This.
   */
  reset() {
    return this.offset = this._mark, this;
  }
  /**
   * Push the current pointer offset to the mark stack.
   * @see {@link IOBuffer#popMark}
   * @returns This.
   */
  pushMark() {
    return this._marks.push(this.offset), this;
  }
  /**
   * Pop the last pointer offset from the mark stack, and set the current
   * pointer offset to the popped value.
   * @see {@link IOBuffer#pushMark}
   * @returns This.
   */
  popMark() {
    const e = this._marks.pop();
    if (e === void 0)
      throw new Error("Mark stack empty");
    return this.seek(e), this;
  }
  /**
   * Move the pointer offset back to 0.
   * @returns This.
   */
  rewind() {
    return this.offset = 0, this;
  }
  /**
   * Make sure the buffer has sufficient memory to write a given byteLength at
   * the current pointer offset.
   * If the buffer's memory is insufficient, this method will create a new
   * buffer (a copy) with a length that is twice (byteLength + current offset).
   * @param byteLength - The needed memory in bytes.
   * @returns This.
   */
  ensureAvailable(e = 1) {
    if (!this.available(e)) {
      const t = (this.offset + e) * 2, r = new Uint8Array(t);
      r.set(new Uint8Array(this.buffer)), this.buffer = r.buffer, this.length = t, this.byteLength = t, this._data = new DataView(this.buffer);
    }
    return this;
  }
  /**
   * Read a byte and return false if the byte's value is 0, or true otherwise.
   * Moves pointer forward by one byte.
   * @returns The read boolean.
   */
  readBoolean() {
    return this.readUint8() !== 0;
  }
  /**
   * Read a signed 8-bit integer and move pointer forward by 1 byte.
   * @returns The read byte.
   */
  readInt8() {
    return this._data.getInt8(this.offset++);
  }
  /**
   * Read an unsigned 8-bit integer and move pointer forward by 1 byte.
   * @returns The read byte.
   */
  readUint8() {
    return this._data.getUint8(this.offset++);
  }
  /**
   * Alias for {@link IOBuffer#readUint8}.
   * @returns The read byte.
   */
  readByte() {
    return this.readUint8();
  }
  /**
   * Read `n` bytes and move pointer forward by `n` bytes.
   * @param n - Number of bytes to read.
   * @returns The read bytes.
   */
  readBytes(e = 1) {
    return this.readArray(e, "uint8");
  }
  /**
   * Creates an array of corresponding to the type `type` and size `size`.
   * For example type `uint8` will create a `Uint8Array`.
   * @param size - size of the resulting array
   * @param type - number type of elements to read
   * @returns The read array.
   */
  readArray(e, t) {
    const r = m_[t].BYTES_PER_ELEMENT * e, n = this.byteOffset + this.offset, i = this.buffer.slice(n, n + r);
    if (this.littleEndian === z3 && t !== "uint8" && t !== "int8") {
      const s = new Uint8Array(this.buffer.slice(n, n + r));
      s.reverse();
      const l = new m_[t](s.buffer);
      return this.offset += r, l.reverse(), l;
    }
    const a = new m_[t](i);
    return this.offset += r, a;
  }
  /**
   * Read a 16-bit signed integer and move pointer forward by 2 bytes.
   * @returns The read value.
   */
  readInt16() {
    const e = this._data.getInt16(this.offset, this.littleEndian);
    return this.offset += 2, e;
  }
  /**
   * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
   * @returns The read value.
   */
  readUint16() {
    const e = this._data.getUint16(this.offset, this.littleEndian);
    return this.offset += 2, e;
  }
  /**
   * Read a 32-bit signed integer and move pointer forward by 4 bytes.
   * @returns The read value.
   */
  readInt32() {
    const e = this._data.getInt32(this.offset, this.littleEndian);
    return this.offset += 4, e;
  }
  /**
   * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
   * @returns The read value.
   */
  readUint32() {
    const e = this._data.getUint32(this.offset, this.littleEndian);
    return this.offset += 4, e;
  }
  /**
   * Read a 32-bit floating number and move pointer forward by 4 bytes.
   * @returns The read value.
   */
  readFloat32() {
    const e = this._data.getFloat32(this.offset, this.littleEndian);
    return this.offset += 4, e;
  }
  /**
   * Read a 64-bit floating number and move pointer forward by 8 bytes.
   * @returns The read value.
   */
  readFloat64() {
    const e = this._data.getFloat64(this.offset, this.littleEndian);
    return this.offset += 8, e;
  }
  /**
   * Read a 64-bit signed integer number and move pointer forward by 8 bytes.
   * @returns The read value.
   */
  readBigInt64() {
    const e = this._data.getBigInt64(this.offset, this.littleEndian);
    return this.offset += 8, e;
  }
  /**
   * Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
   * @returns The read value.
   */
  readBigUint64() {
    const e = this._data.getBigUint64(this.offset, this.littleEndian);
    return this.offset += 8, e;
  }
  /**
   * Read a 1-byte ASCII character and move pointer forward by 1 byte.
   * @returns The read character.
   */
  readChar() {
    return String.fromCharCode(this.readInt8());
  }
  /**
   * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
   * @param n - Number of characters to read.
   * @returns The read characters.
   */
  readChars(e = 1) {
    let t = "";
    for (let r = 0; r < e; r++)
      t += this.readChar();
    return t;
  }
  /**
   * Read the next `n` bytes, return a UTF-8 decoded string and move pointer
   * forward by `n` bytes.
   * @param n - Number of bytes to read.
   * @returns The decoded string.
   */
  readUtf8(e = 1) {
    return nx(this.readBytes(e));
  }
  /**
   * Read the next `n` bytes, return a string decoded with `encoding` and move pointer
   * forward by `n` bytes.
   * If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
   * @param n - Number of bytes to read.
   * @param encoding - The encoding to use. Default is 'utf8'.
   * @returns The decoded string.
   */
  decodeText(e = 1, t = "utf8") {
    return nx(this.readBytes(e), t);
  }
  /**
   * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
   * forward by 1 byte.
   * @param value - The value to write.
   * @returns This.
   */
  writeBoolean(e) {
    return this.writeUint8(e ? 255 : 0), this;
  }
  /**
   * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
   * @param value - The value to write.
   * @returns This.
   */
  writeInt8(e) {
    return this.ensureAvailable(1), this._data.setInt8(this.offset++, e), this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as an 8-bit unsigned integer and move pointer forward by 1
   * byte.
   * @param value - The value to write.
   * @returns This.
   */
  writeUint8(e) {
    return this.ensureAvailable(1), this._data.setUint8(this.offset++, e), this._updateLastWrittenByte(), this;
  }
  /**
   * An alias for {@link IOBuffer#writeUint8}.
   * @param value - The value to write.
   * @returns This.
   */
  writeByte(e) {
    return this.writeUint8(e);
  }
  /**
   * Write all elements of `bytes` as uint8 values and move pointer forward by
   * `bytes.length` bytes.
   * @param bytes - The array of bytes to write.
   * @returns This.
   */
  writeBytes(e) {
    this.ensureAvailable(e.length);
    for (let t = 0; t < e.length; t++)
      this._data.setUint8(this.offset++, e[t]);
    return this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 16-bit signed integer and move pointer forward by 2
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeInt16(e) {
    return this.ensureAvailable(2), this._data.setInt16(this.offset, e, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 16-bit unsigned integer and move pointer forward by 2
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeUint16(e) {
    return this.ensureAvailable(2), this._data.setUint16(this.offset, e, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 32-bit signed integer and move pointer forward by 4
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeInt32(e) {
    return this.ensureAvailable(4), this._data.setInt32(this.offset, e, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 32-bit unsigned integer and move pointer forward by 4
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeUint32(e) {
    return this.ensureAvailable(4), this._data.setUint32(this.offset, e, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 32-bit floating number and move pointer forward by 4
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeFloat32(e) {
    return this.ensureAvailable(4), this._data.setFloat32(this.offset, e, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 64-bit floating number and move pointer forward by 8
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeFloat64(e) {
    return this.ensureAvailable(8), this._data.setFloat64(this.offset, e, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 64-bit signed bigint and move pointer forward by 8
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeBigInt64(e) {
    return this.ensureAvailable(8), this._data.setBigInt64(this.offset, e, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
  }
  /**
   * Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
   * bytes.
   * @param value - The value to write.
   * @returns This.
   */
  writeBigUint64(e) {
    return this.ensureAvailable(8), this._data.setBigUint64(this.offset, e, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
  }
  /**
   * Write the charCode of `str`'s first character as an 8-bit unsigned integer
   * and move pointer forward by 1 byte.
   * @param str - The character to write.
   * @returns This.
   */
  writeChar(e) {
    return this.writeUint8(e.charCodeAt(0));
  }
  /**
   * Write the charCodes of all `str`'s characters as 8-bit unsigned integers
   * and move pointer forward by `str.length` bytes.
   * @param str - The characters to write.
   * @returns This.
   */
  writeChars(e) {
    for (let t = 0; t < e.length; t++)
      this.writeUint8(e.charCodeAt(t));
    return this;
  }
  /**
   * UTF-8 encode and write `str` to the current pointer offset and move pointer
   * forward according to the encoded length.
   * @param str - The string to write.
   * @returns This.
   */
  writeUtf8(e) {
    return this.writeBytes(D3(e));
  }
  /**
   * Export a Uint8Array view of the internal buffer.
   * The view starts at the byte offset and its length
   * is calculated to stop at the last written byte or the original length.
   * @returns A new Uint8Array view.
   */
  toArray() {
    return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
  }
  /**
   *  Get the total number of bytes written so far, regardless of the current offset.
   * @returns - Total number of bytes.
   */
  getWrittenByteLength() {
    return this.lastWrittenByte - this.byteOffset;
  }
  /**
   * Update the last written byte offset
   * @private
   */
  _updateLastWrittenByte() {
    this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset);
  }
}
function tu(o) {
  let e = o.length;
  for (; --e >= 0; )
    o[e] = 0;
}
const K3 = 3, $3 = 258, OE = 29, W3 = 256, X3 = W3 + 1 + OE, QE = 30, Y3 = 512, Z3 = new Array((X3 + 2) * 2);
tu(Z3);
const J3 = new Array(QE * 2);
tu(J3);
const eR = new Array(Y3);
tu(eR);
const tR = new Array($3 - K3 + 1);
tu(tR);
const rR = new Array(OE);
tu(rR);
const oR = new Array(QE);
tu(oR);
const nR = (o, e, t, r) => {
  let n = o & 65535 | 0, i = o >>> 16 & 65535 | 0, a = 0;
  for (; t !== 0; ) {
    a = t > 2e3 ? 2e3 : t, t -= a;
    do
      n = n + e[r++] | 0, i = i + n | 0;
    while (--a);
    n %= 65521, i %= 65521;
  }
  return n | i << 16 | 0;
};
var fb = nR;
const iR = () => {
  let o, e = [];
  for (var t = 0; t < 256; t++) {
    o = t;
    for (var r = 0; r < 8; r++)
      o = o & 1 ? 3988292384 ^ o >>> 1 : o >>> 1;
    e[t] = o;
  }
  return e;
}, aR = new Uint32Array(iR()), sR = (o, e, t, r) => {
  const n = aR, i = r + t;
  o ^= -1;
  for (let a = r; a < i; a++)
    o = o >>> 8 ^ n[(o ^ e[a]) & 255];
  return o ^ -1;
};
var ra = sR, mb = {
  2: "need dictionary",
  /* Z_NEED_DICT       2  */
  1: "stream end",
  /* Z_STREAM_END      1  */
  0: "",
  /* Z_OK              0  */
  "-1": "file error",
  /* Z_ERRNO         (-1) */
  "-2": "stream error",
  /* Z_STREAM_ERROR  (-2) */
  "-3": "data error",
  /* Z_DATA_ERROR    (-3) */
  "-4": "insufficient memory",
  /* Z_MEM_ERROR     (-4) */
  "-5": "buffer error",
  /* Z_BUF_ERROR     (-5) */
  "-6": "incompatible version"
  /* Z_VERSION_ERROR (-6) */
}, qE = {
  /* Allowed flush values; see deflate() and inflate() below for details */
  Z_NO_FLUSH: 0,
  Z_FINISH: 4,
  Z_BLOCK: 5,
  Z_TREES: 6,
  /* Return codes for the compression/decompression functions. Negative values
  * are errors, positive values are used for special but normal events.
  */
  Z_OK: 0,
  Z_STREAM_END: 1,
  Z_NEED_DICT: 2,
  Z_STREAM_ERROR: -2,
  Z_DATA_ERROR: -3,
  Z_MEM_ERROR: -4,
  Z_BUF_ERROR: -5,
  /* The deflate compression method */
  Z_DEFLATED: 8
  //Z_NULL:                 null // Use -1 or null inline, depending on var type
};
const lR = (o, e) => Object.prototype.hasOwnProperty.call(o, e);
var cR = function(o) {
  const e = Array.prototype.slice.call(arguments, 1);
  for (; e.length; ) {
    const t = e.shift();
    if (t) {
      if (typeof t != "object")
        throw new TypeError(t + "must be non-object");
      for (const r in t)
        lR(t, r) && (o[r] = t[r]);
    }
  }
  return o;
}, uR = (o) => {
  let e = 0;
  for (let r = 0, n = o.length; r < n; r++)
    e += o[r].length;
  const t = new Uint8Array(e);
  for (let r = 0, n = 0, i = o.length; r < i; r++) {
    let a = o[r];
    t.set(a, n), n += a.length;
  }
  return t;
}, GE = {
  assign: cR,
  flattenChunks: uR
};
let VE = !0;
try {
  String.fromCharCode.apply(null, new Uint8Array(1));
} catch {
  VE = !1;
}
const NA = new Uint8Array(256);
for (let o = 0; o < 256; o++)
  NA[o] = o >= 252 ? 6 : o >= 248 ? 5 : o >= 240 ? 4 : o >= 224 ? 3 : o >= 192 ? 2 : 1;
NA[254] = NA[254] = 1;
var AR = (o) => {
  if (typeof TextEncoder == "function" && TextEncoder.prototype.encode)
    return new TextEncoder().encode(o);
  let e, t, r, n, i, a = o.length, s = 0;
  for (n = 0; n < a; n++)
    t = o.charCodeAt(n), (t & 64512) === 55296 && n + 1 < a && (r = o.charCodeAt(n + 1), (r & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (r - 56320), n++)), s += t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4;
  for (e = new Uint8Array(s), i = 0, n = 0; i < s; n++)
    t = o.charCodeAt(n), (t & 64512) === 55296 && n + 1 < a && (r = o.charCodeAt(n + 1), (r & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (r - 56320), n++)), t < 128 ? e[i++] = t : t < 2048 ? (e[i++] = 192 | t >>> 6, e[i++] = 128 | t & 63) : t < 65536 ? (e[i++] = 224 | t >>> 12, e[i++] = 128 | t >>> 6 & 63, e[i++] = 128 | t & 63) : (e[i++] = 240 | t >>> 18, e[i++] = 128 | t >>> 12 & 63, e[i++] = 128 | t >>> 6 & 63, e[i++] = 128 | t & 63);
  return e;
};
const dR = (o, e) => {
  if (e < 65534 && o.subarray && VE)
    return String.fromCharCode.apply(null, o.length === e ? o : o.subarray(0, e));
  let t = "";
  for (let r = 0; r < e; r++)
    t += String.fromCharCode(o[r]);
  return t;
};
var pR = (o, e) => {
  const t = e || o.length;
  if (typeof TextDecoder == "function" && TextDecoder.prototype.decode)
    return new TextDecoder().decode(o.subarray(0, e));
  let r, n;
  const i = new Array(t * 2);
  for (n = 0, r = 0; r < t; ) {
    let a = o[r++];
    if (a < 128) {
      i[n++] = a;
      continue;
    }
    let s = NA[a];
    if (s > 4) {
      i[n++] = 65533, r += s - 1;
      continue;
    }
    for (a &= s === 2 ? 31 : s === 3 ? 15 : 7; s > 1 && r < t; )
      a = a << 6 | o[r++] & 63, s--;
    if (s > 1) {
      i[n++] = 65533;
      continue;
    }
    a < 65536 ? i[n++] = a : (a -= 65536, i[n++] = 55296 | a >> 10 & 1023, i[n++] = 56320 | a & 1023);
  }
  return dR(i, n);
}, hR = (o, e) => {
  e = e || o.length, e > o.length && (e = o.length);
  let t = e - 1;
  for (; t >= 0 && (o[t] & 192) === 128; )
    t--;
  return t < 0 || t === 0 ? e : t + NA[o[t]] > e ? t : e;
}, yb = {
  string2buf: AR,
  buf2string: pR,
  utf8border: hR
};
function gR() {
  this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
}
var _R = gR;
const op = 16209, fR = 16191;
var mR = function(o, e) {
  let t, r, n, i, a, s, l, c, u, A, p, d, g, _, f, m, b, v, w, C, E, T, F, B;
  const P = o.state;
  t = o.next_in, F = o.input, r = t + (o.avail_in - 5), n = o.next_out, B = o.output, i = n - (e - o.avail_out), a = n + (o.avail_out - 257), s = P.dmax, l = P.wsize, c = P.whave, u = P.wnext, A = P.window, p = P.hold, d = P.bits, g = P.lencode, _ = P.distcode, f = (1 << P.lenbits) - 1, m = (1 << P.distbits) - 1;
  e:
    do {
      d < 15 && (p += F[t++] << d, d += 8, p += F[t++] << d, d += 8), b = g[p & f];
      t:
        for (; ; ) {
          if (v = b >>> 24, p >>>= v, d -= v, v = b >>> 16 & 255, v === 0)
            B[n++] = b & 65535;
          else if (v & 16) {
            w = b & 65535, v &= 15, v && (d < v && (p += F[t++] << d, d += 8), w += p & (1 << v) - 1, p >>>= v, d -= v), d < 15 && (p += F[t++] << d, d += 8, p += F[t++] << d, d += 8), b = _[p & m];
            r:
              for (; ; ) {
                if (v = b >>> 24, p >>>= v, d -= v, v = b >>> 16 & 255, v & 16) {
                  if (C = b & 65535, v &= 15, d < v && (p += F[t++] << d, d += 8, d < v && (p += F[t++] << d, d += 8)), C += p & (1 << v) - 1, C > s) {
                    o.msg = "invalid distance too far back", P.mode = op;
                    break e;
                  }
                  if (p >>>= v, d -= v, v = n - i, C > v) {
                    if (v = C - v, v > c && P.sane) {
                      o.msg = "invalid distance too far back", P.mode = op;
                      break e;
                    }
                    if (E = 0, T = A, u === 0) {
                      if (E += l - v, v < w) {
                        w -= v;
                        do
                          B[n++] = A[E++];
                        while (--v);
                        E = n - C, T = B;
                      }
                    } else if (u < v) {
                      if (E += l + u - v, v -= u, v < w) {
                        w -= v;
                        do
                          B[n++] = A[E++];
                        while (--v);
                        if (E = 0, u < w) {
                          v = u, w -= v;
                          do
                            B[n++] = A[E++];
                          while (--v);
                          E = n - C, T = B;
                        }
                      }
                    } else if (E += u - v, v < w) {
                      w -= v;
                      do
                        B[n++] = A[E++];
                      while (--v);
                      E = n - C, T = B;
                    }
                    for (; w > 2; )
                      B[n++] = T[E++], B[n++] = T[E++], B[n++] = T[E++], w -= 3;
                    w && (B[n++] = T[E++], w > 1 && (B[n++] = T[E++]));
                  } else {
                    E = n - C;
                    do
                      B[n++] = B[E++], B[n++] = B[E++], B[n++] = B[E++], w -= 3;
                    while (w > 2);
                    w && (B[n++] = B[E++], w > 1 && (B[n++] = B[E++]));
                  }
                } else if ((v & 64) === 0) {
                  b = _[(b & 65535) + (p & (1 << v) - 1)];
                  continue r;
                } else {
                  o.msg = "invalid distance code", P.mode = op;
                  break e;
                }
                break;
              }
          } else if ((v & 64) === 0) {
            b = g[(b & 65535) + (p & (1 << v) - 1)];
            continue t;
          } else if (v & 32) {
            P.mode = fR;
            break e;
          } else {
            o.msg = "invalid literal/length code", P.mode = op;
            break e;
          }
          break;
        }
    } while (t < r && n < a);
  w = d >> 3, t -= w, d -= w << 3, p &= (1 << d) - 1, o.next_in = t, o.next_out = n, o.avail_in = t < r ? 5 + (r - t) : 5 - (t - r), o.avail_out = n < a ? 257 + (a - n) : 257 - (n - a), P.hold = p, P.bits = d;
};
const Ac = 15, ix = 852, ax = 592, sx = 0, y_ = 1, lx = 2, yR = new Uint16Array([
  /* Length codes 257..285 base */
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10,
  11,
  13,
  15,
  17,
  19,
  23,
  27,
  31,
  35,
  43,
  51,
  59,
  67,
  83,
  99,
  115,
  131,
  163,
  195,
  227,
  258,
  0,
  0
]), bR = new Uint8Array([
  /* Length codes 257..285 extra */
  16,
  16,
  16,
  16,
  16,
  16,
  16,
  16,
  17,
  17,
  17,
  17,
  18,
  18,
  18,
  18,
  19,
  19,
  19,
  19,
  20,
  20,
  20,
  20,
  21,
  21,
  21,
  21,
  16,
  72,
  78
]), vR = new Uint16Array([
  /* Distance codes 0..29 base */
  1,
  2,
  3,
  4,
  5,
  7,
  9,
  13,
  17,
  25,
  33,
  49,
  65,
  97,
  129,
  193,
  257,
  385,
  513,
  769,
  1025,
  1537,
  2049,
  3073,
  4097,
  6145,
  8193,
  12289,
  16385,
  24577,
  0,
  0
]), wR = new Uint8Array([
  /* Distance codes 0..29 extra */
  16,
  16,
  16,
  16,
  17,
  17,
  18,
  18,
  19,
  19,
  20,
  20,
  21,
  21,
  22,
  22,
  23,
  23,
  24,
  24,
  25,
  25,
  26,
  26,
  27,
  27,
  28,
  28,
  29,
  29,
  64,
  64
]), xR = (o, e, t, r, n, i, a, s) => {
  const l = s.bits;
  let c = 0, u = 0, A = 0, p = 0, d = 0, g = 0, _ = 0, f = 0, m = 0, b = 0, v, w, C, E, T, F = null, B;
  const P = new Uint16Array(Ac + 1), S = new Uint16Array(Ac + 1);
  let L = null, U, O, K;
  for (c = 0; c <= Ac; c++)
    P[c] = 0;
  for (u = 0; u < r; u++)
    P[e[t + u]]++;
  for (d = l, p = Ac; p >= 1 && P[p] === 0; p--)
    ;
  if (d > p && (d = p), p === 0)
    return n[i++] = 1 << 24 | 64 << 16 | 0, n[i++] = 1 << 24 | 64 << 16 | 0, s.bits = 1, 0;
  for (A = 1; A < p && P[A] === 0; A++)
    ;
  for (d < A && (d = A), f = 1, c = 1; c <= Ac; c++)
    if (f <<= 1, f -= P[c], f < 0)
      return -1;
  if (f > 0 && (o === sx || p !== 1))
    return -1;
  for (S[1] = 0, c = 1; c < Ac; c++)
    S[c + 1] = S[c] + P[c];
  for (u = 0; u < r; u++)
    e[t + u] !== 0 && (a[S[e[t + u]]++] = u);
  if (o === sx ? (F = L = a, B = 20) : o === y_ ? (F = yR, L = bR, B = 257) : (F = vR, L = wR, B = 0), b = 0, u = 0, c = A, T = i, g = d, _ = 0, C = -1, m = 1 << d, E = m - 1, o === y_ && m > ix || o === lx && m > ax)
    return 1;
  for (; ; ) {
    U = c - _, a[u] + 1 < B ? (O = 0, K = a[u]) : a[u] >= B ? (O = L[a[u] - B], K = F[a[u] - B]) : (O = 96, K = 0), v = 1 << c - _, w = 1 << g, A = w;
    do
      w -= v, n[T + (b >> _) + w] = U << 24 | O << 16 | K | 0;
    while (w !== 0);
    for (v = 1 << c - 1; b & v; )
      v >>= 1;
    if (v !== 0 ? (b &= v - 1, b += v) : b = 0, u++, --P[c] === 0) {
      if (c === p)
        break;
      c = e[t + a[u]];
    }
    if (c > d && (b & E) !== C) {
      for (_ === 0 && (_ = d), T += A, g = c - _, f = 1 << g; g + _ < p && (f -= P[g + _], !(f <= 0)); )
        g++, f <<= 1;
      if (m += 1 << g, o === y_ && m > ix || o === lx && m > ax)
        return 1;
      C = b & E, n[C] = d << 24 | g << 16 | T - i | 0;
    }
  }
  return b !== 0 && (n[T + b] = c - _ << 24 | 64 << 16 | 0), s.bits = d, 0;
};
var wA = xR;
const kR = 0, DE = 1, HE = 2, {
  Z_FINISH: cx,
  Z_BLOCK: CR,
  Z_TREES: np,
  Z_OK: Ql,
  Z_STREAM_END: SR,
  Z_NEED_DICT: BR,
  Z_STREAM_ERROR: Gi,
  Z_DATA_ERROR: zE,
  Z_MEM_ERROR: KE,
  Z_BUF_ERROR: ER,
  Z_DEFLATED: ux
} = qE, Hh = 16180, Ax = 16181, dx = 16182, px = 16183, hx = 16184, gx = 16185, _x = 16186, fx = 16187, mx = 16188, yx = 16189, xh = 16190, Ta = 16191, b_ = 16192, bx = 16193, v_ = 16194, vx = 16195, wx = 16196, xx = 16197, kx = 16198, ip = 16199, ap = 16200, Cx = 16201, Sx = 16202, Bx = 16203, Ex = 16204, jx = 16205, w_ = 16206, Lx = 16207, Tx = 16208, Jr = 16209, $E = 16210, WE = 16211, jR = 852, LR = 592, TR = 15, PR = TR, Px = (o) => (o >>> 24 & 255) + (o >>> 8 & 65280) + ((o & 65280) << 8) + ((o & 255) << 24);
function FR() {
  this.strm = null, this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
}
const Dl = (o) => {
  if (!o)
    return 1;
  const e = o.state;
  return !e || e.strm !== o || e.mode < Hh || e.mode > WE ? 1 : 0;
}, XE = (o) => {
  if (Dl(o))
    return Gi;
  const e = o.state;
  return o.total_in = o.total_out = e.total = 0, o.msg = "", e.wrap && (o.adler = e.wrap & 1), e.mode = Hh, e.last = 0, e.havedict = 0, e.flags = -1, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(jR), e.distcode = e.distdyn = new Int32Array(LR), e.sane = 1, e.back = -1, Ql;
}, YE = (o) => {
  if (Dl(o))
    return Gi;
  const e = o.state;
  return e.wsize = 0, e.whave = 0, e.wnext = 0, XE(o);
}, ZE = (o, e) => {
  let t;
  if (Dl(o))
    return Gi;
  const r = o.state;
  return e < 0 ? (t = 0, e = -e) : (t = (e >> 4) + 5, e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? Gi : (r.window !== null && r.wbits !== e && (r.window = null), r.wrap = t, r.wbits = e, YE(o));
}, JE = (o, e) => {
  if (!o)
    return Gi;
  const t = new FR();
  o.state = t, t.strm = o, t.window = null, t.mode = Hh;
  const r = ZE(o, e);
  return r !== Ql && (o.state = null), r;
}, UR = (o) => JE(o, PR);
let Fx = !0, x_, k_;
const NR = (o) => {
  if (Fx) {
    x_ = new Int32Array(512), k_ = new Int32Array(32);
    let e = 0;
    for (; e < 144; )
      o.lens[e++] = 8;
    for (; e < 256; )
      o.lens[e++] = 9;
    for (; e < 280; )
      o.lens[e++] = 7;
    for (; e < 288; )
      o.lens[e++] = 8;
    for (wA(DE, o.lens, 0, 288, x_, 0, o.work, { bits: 9 }), e = 0; e < 32; )
      o.lens[e++] = 5;
    wA(HE, o.lens, 0, 32, k_, 0, o.work, { bits: 5 }), Fx = !1;
  }
  o.lencode = x_, o.lenbits = 9, o.distcode = k_, o.distbits = 5;
}, ej = (o, e, t, r) => {
  let n;
  const i = o.state;
  return i.window === null && (i.wsize = 1 << i.wbits, i.wnext = 0, i.whave = 0, i.window = new Uint8Array(i.wsize)), r >= i.wsize ? (i.window.set(e.subarray(t - i.wsize, t), 0), i.wnext = 0, i.whave = i.wsize) : (n = i.wsize - i.wnext, n > r && (n = r), i.window.set(e.subarray(t - r, t - r + n), i.wnext), r -= n, r ? (i.window.set(e.subarray(t - r, t), 0), i.wnext = r, i.whave = i.wsize) : (i.wnext += n, i.wnext === i.wsize && (i.wnext = 0), i.whave < i.wsize && (i.whave += n))), 0;
}, IR = (o, e) => {
  let t, r, n, i, a, s, l, c, u, A, p, d, g, _, f = 0, m, b, v, w, C, E, T, F;
  const B = new Uint8Array(4);
  let P, S;
  const L = (
    /* permutation of code lengths */
    new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
  );
  if (Dl(o) || !o.output || !o.input && o.avail_in !== 0)
    return Gi;
  t = o.state, t.mode === Ta && (t.mode = b_), a = o.next_out, n = o.output, l = o.avail_out, i = o.next_in, r = o.input, s = o.avail_in, c = t.hold, u = t.bits, A = s, p = l, F = Ql;
  e:
    for (; ; )
      switch (t.mode) {
        case Hh:
          if (t.wrap === 0) {
            t.mode = b_;
            break;
          }
          for (; u < 16; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if (t.wrap & 2 && c === 35615) {
            t.wbits === 0 && (t.wbits = 15), t.check = 0, B[0] = c & 255, B[1] = c >>> 8 & 255, t.check = ra(t.check, B, 2, 0), c = 0, u = 0, t.mode = Ax;
            break;
          }
          if (t.head && (t.head.done = !1), !(t.wrap & 1) || /* check if zlib header allowed */
          (((c & 255) << 8) + (c >> 8)) % 31) {
            o.msg = "incorrect header check", t.mode = Jr;
            break;
          }
          if ((c & 15) !== ux) {
            o.msg = "unknown compression method", t.mode = Jr;
            break;
          }
          if (c >>>= 4, u -= 4, T = (c & 15) + 8, t.wbits === 0 && (t.wbits = T), T > 15 || T > t.wbits) {
            o.msg = "invalid window size", t.mode = Jr;
            break;
          }
          t.dmax = 1 << t.wbits, t.flags = 0, o.adler = t.check = 1, t.mode = c & 512 ? yx : Ta, c = 0, u = 0;
          break;
        case Ax:
          for (; u < 16; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if (t.flags = c, (t.flags & 255) !== ux) {
            o.msg = "unknown compression method", t.mode = Jr;
            break;
          }
          if (t.flags & 57344) {
            o.msg = "unknown header flags set", t.mode = Jr;
            break;
          }
          t.head && (t.head.text = c >> 8 & 1), t.flags & 512 && t.wrap & 4 && (B[0] = c & 255, B[1] = c >>> 8 & 255, t.check = ra(t.check, B, 2, 0)), c = 0, u = 0, t.mode = dx;
        /* falls through */
        case dx:
          for (; u < 32; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          t.head && (t.head.time = c), t.flags & 512 && t.wrap & 4 && (B[0] = c & 255, B[1] = c >>> 8 & 255, B[2] = c >>> 16 & 255, B[3] = c >>> 24 & 255, t.check = ra(t.check, B, 4, 0)), c = 0, u = 0, t.mode = px;
        /* falls through */
        case px:
          for (; u < 16; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          t.head && (t.head.xflags = c & 255, t.head.os = c >> 8), t.flags & 512 && t.wrap & 4 && (B[0] = c & 255, B[1] = c >>> 8 & 255, t.check = ra(t.check, B, 2, 0)), c = 0, u = 0, t.mode = hx;
        /* falls through */
        case hx:
          if (t.flags & 1024) {
            for (; u < 16; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            t.length = c, t.head && (t.head.extra_len = c), t.flags & 512 && t.wrap & 4 && (B[0] = c & 255, B[1] = c >>> 8 & 255, t.check = ra(t.check, B, 2, 0)), c = 0, u = 0;
          } else t.head && (t.head.extra = null);
          t.mode = gx;
        /* falls through */
        case gx:
          if (t.flags & 1024 && (d = t.length, d > s && (d = s), d && (t.head && (T = t.head.extra_len - t.length, t.head.extra || (t.head.extra = new Uint8Array(t.head.extra_len)), t.head.extra.set(
            r.subarray(
              i,
              // extra field is limited to 65536 bytes
              // - no need for additional size check
              i + d
            ),
            /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
            T
          )), t.flags & 512 && t.wrap & 4 && (t.check = ra(t.check, r, d, i)), s -= d, i += d, t.length -= d), t.length))
            break e;
          t.length = 0, t.mode = _x;
        /* falls through */
        case _x:
          if (t.flags & 2048) {
            if (s === 0)
              break e;
            d = 0;
            do
              T = r[i + d++], t.head && T && t.length < 65536 && (t.head.name += String.fromCharCode(T));
            while (T && d < s);
            if (t.flags & 512 && t.wrap & 4 && (t.check = ra(t.check, r, d, i)), s -= d, i += d, T)
              break e;
          } else t.head && (t.head.name = null);
          t.length = 0, t.mode = fx;
        /* falls through */
        case fx:
          if (t.flags & 4096) {
            if (s === 0)
              break e;
            d = 0;
            do
              T = r[i + d++], t.head && T && t.length < 65536 && (t.head.comment += String.fromCharCode(T));
            while (T && d < s);
            if (t.flags & 512 && t.wrap & 4 && (t.check = ra(t.check, r, d, i)), s -= d, i += d, T)
              break e;
          } else t.head && (t.head.comment = null);
          t.mode = mx;
        /* falls through */
        case mx:
          if (t.flags & 512) {
            for (; u < 16; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            if (t.wrap & 4 && c !== (t.check & 65535)) {
              o.msg = "header crc mismatch", t.mode = Jr;
              break;
            }
            c = 0, u = 0;
          }
          t.head && (t.head.hcrc = t.flags >> 9 & 1, t.head.done = !0), o.adler = t.check = 0, t.mode = Ta;
          break;
        case yx:
          for (; u < 32; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          o.adler = t.check = Px(c), c = 0, u = 0, t.mode = xh;
        /* falls through */
        case xh:
          if (t.havedict === 0)
            return o.next_out = a, o.avail_out = l, o.next_in = i, o.avail_in = s, t.hold = c, t.bits = u, BR;
          o.adler = t.check = 1, t.mode = Ta;
        /* falls through */
        case Ta:
          if (e === CR || e === np)
            break e;
        /* falls through */
        case b_:
          if (t.last) {
            c >>>= u & 7, u -= u & 7, t.mode = w_;
            break;
          }
          for (; u < 3; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          switch (t.last = c & 1, c >>>= 1, u -= 1, c & 3) {
            case 0:
              t.mode = bx;
              break;
            case 1:
              if (NR(t), t.mode = ip, e === np) {
                c >>>= 2, u -= 2;
                break e;
              }
              break;
            case 2:
              t.mode = wx;
              break;
            case 3:
              o.msg = "invalid block type", t.mode = Jr;
          }
          c >>>= 2, u -= 2;
          break;
        case bx:
          for (c >>>= u & 7, u -= u & 7; u < 32; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if ((c & 65535) !== (c >>> 16 ^ 65535)) {
            o.msg = "invalid stored block lengths", t.mode = Jr;
            break;
          }
          if (t.length = c & 65535, c = 0, u = 0, t.mode = v_, e === np)
            break e;
        /* falls through */
        case v_:
          t.mode = vx;
        /* falls through */
        case vx:
          if (d = t.length, d) {
            if (d > s && (d = s), d > l && (d = l), d === 0)
              break e;
            n.set(r.subarray(i, i + d), a), s -= d, i += d, l -= d, a += d, t.length -= d;
            break;
          }
          t.mode = Ta;
          break;
        case wx:
          for (; u < 14; ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if (t.nlen = (c & 31) + 257, c >>>= 5, u -= 5, t.ndist = (c & 31) + 1, c >>>= 5, u -= 5, t.ncode = (c & 15) + 4, c >>>= 4, u -= 4, t.nlen > 286 || t.ndist > 30) {
            o.msg = "too many length or distance symbols", t.mode = Jr;
            break;
          }
          t.have = 0, t.mode = xx;
        /* falls through */
        case xx:
          for (; t.have < t.ncode; ) {
            for (; u < 3; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            t.lens[L[t.have++]] = c & 7, c >>>= 3, u -= 3;
          }
          for (; t.have < 19; )
            t.lens[L[t.have++]] = 0;
          if (t.lencode = t.lendyn, t.lenbits = 7, P = { bits: t.lenbits }, F = wA(kR, t.lens, 0, 19, t.lencode, 0, t.work, P), t.lenbits = P.bits, F) {
            o.msg = "invalid code lengths set", t.mode = Jr;
            break;
          }
          t.have = 0, t.mode = kx;
        /* falls through */
        case kx:
          for (; t.have < t.nlen + t.ndist; ) {
            for (; f = t.lencode[c & (1 << t.lenbits) - 1], m = f >>> 24, b = f >>> 16 & 255, v = f & 65535, !(m <= u); ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            if (v < 16)
              c >>>= m, u -= m, t.lens[t.have++] = v;
            else {
              if (v === 16) {
                for (S = m + 2; u < S; ) {
                  if (s === 0)
                    break e;
                  s--, c += r[i++] << u, u += 8;
                }
                if (c >>>= m, u -= m, t.have === 0) {
                  o.msg = "invalid bit length repeat", t.mode = Jr;
                  break;
                }
                T = t.lens[t.have - 1], d = 3 + (c & 3), c >>>= 2, u -= 2;
              } else if (v === 17) {
                for (S = m + 3; u < S; ) {
                  if (s === 0)
                    break e;
                  s--, c += r[i++] << u, u += 8;
                }
                c >>>= m, u -= m, T = 0, d = 3 + (c & 7), c >>>= 3, u -= 3;
              } else {
                for (S = m + 7; u < S; ) {
                  if (s === 0)
                    break e;
                  s--, c += r[i++] << u, u += 8;
                }
                c >>>= m, u -= m, T = 0, d = 11 + (c & 127), c >>>= 7, u -= 7;
              }
              if (t.have + d > t.nlen + t.ndist) {
                o.msg = "invalid bit length repeat", t.mode = Jr;
                break;
              }
              for (; d--; )
                t.lens[t.have++] = T;
            }
          }
          if (t.mode === Jr)
            break;
          if (t.lens[256] === 0) {
            o.msg = "invalid code -- missing end-of-block", t.mode = Jr;
            break;
          }
          if (t.lenbits = 9, P = { bits: t.lenbits }, F = wA(DE, t.lens, 0, t.nlen, t.lencode, 0, t.work, P), t.lenbits = P.bits, F) {
            o.msg = "invalid literal/lengths set", t.mode = Jr;
            break;
          }
          if (t.distbits = 6, t.distcode = t.distdyn, P = { bits: t.distbits }, F = wA(HE, t.lens, t.nlen, t.ndist, t.distcode, 0, t.work, P), t.distbits = P.bits, F) {
            o.msg = "invalid distances set", t.mode = Jr;
            break;
          }
          if (t.mode = ip, e === np)
            break e;
        /* falls through */
        case ip:
          t.mode = ap;
        /* falls through */
        case ap:
          if (s >= 6 && l >= 258) {
            o.next_out = a, o.avail_out = l, o.next_in = i, o.avail_in = s, t.hold = c, t.bits = u, mR(o, p), a = o.next_out, n = o.output, l = o.avail_out, i = o.next_in, r = o.input, s = o.avail_in, c = t.hold, u = t.bits, t.mode === Ta && (t.back = -1);
            break;
          }
          for (t.back = 0; f = t.lencode[c & (1 << t.lenbits) - 1], m = f >>> 24, b = f >>> 16 & 255, v = f & 65535, !(m <= u); ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if (b && (b & 240) === 0) {
            for (w = m, C = b, E = v; f = t.lencode[E + ((c & (1 << w + C) - 1) >> w)], m = f >>> 24, b = f >>> 16 & 255, v = f & 65535, !(w + m <= u); ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            c >>>= w, u -= w, t.back += w;
          }
          if (c >>>= m, u -= m, t.back += m, t.length = v, b === 0) {
            t.mode = jx;
            break;
          }
          if (b & 32) {
            t.back = -1, t.mode = Ta;
            break;
          }
          if (b & 64) {
            o.msg = "invalid literal/length code", t.mode = Jr;
            break;
          }
          t.extra = b & 15, t.mode = Cx;
        /* falls through */
        case Cx:
          if (t.extra) {
            for (S = t.extra; u < S; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            t.length += c & (1 << t.extra) - 1, c >>>= t.extra, u -= t.extra, t.back += t.extra;
          }
          t.was = t.length, t.mode = Sx;
        /* falls through */
        case Sx:
          for (; f = t.distcode[c & (1 << t.distbits) - 1], m = f >>> 24, b = f >>> 16 & 255, v = f & 65535, !(m <= u); ) {
            if (s === 0)
              break e;
            s--, c += r[i++] << u, u += 8;
          }
          if ((b & 240) === 0) {
            for (w = m, C = b, E = v; f = t.distcode[E + ((c & (1 << w + C) - 1) >> w)], m = f >>> 24, b = f >>> 16 & 255, v = f & 65535, !(w + m <= u); ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            c >>>= w, u -= w, t.back += w;
          }
          if (c >>>= m, u -= m, t.back += m, b & 64) {
            o.msg = "invalid distance code", t.mode = Jr;
            break;
          }
          t.offset = v, t.extra = b & 15, t.mode = Bx;
        /* falls through */
        case Bx:
          if (t.extra) {
            for (S = t.extra; u < S; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            t.offset += c & (1 << t.extra) - 1, c >>>= t.extra, u -= t.extra, t.back += t.extra;
          }
          if (t.offset > t.dmax) {
            o.msg = "invalid distance too far back", t.mode = Jr;
            break;
          }
          t.mode = Ex;
        /* falls through */
        case Ex:
          if (l === 0)
            break e;
          if (d = p - l, t.offset > d) {
            if (d = t.offset - d, d > t.whave && t.sane) {
              o.msg = "invalid distance too far back", t.mode = Jr;
              break;
            }
            d > t.wnext ? (d -= t.wnext, g = t.wsize - d) : g = t.wnext - d, d > t.length && (d = t.length), _ = t.window;
          } else
            _ = n, g = a - t.offset, d = t.length;
          d > l && (d = l), l -= d, t.length -= d;
          do
            n[a++] = _[g++];
          while (--d);
          t.length === 0 && (t.mode = ap);
          break;
        case jx:
          if (l === 0)
            break e;
          n[a++] = t.length, l--, t.mode = ap;
          break;
        case w_:
          if (t.wrap) {
            for (; u < 32; ) {
              if (s === 0)
                break e;
              s--, c |= r[i++] << u, u += 8;
            }
            if (p -= l, o.total_out += p, t.total += p, t.wrap & 4 && p && (o.adler = t.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/
            t.flags ? ra(t.check, n, p, a - p) : fb(t.check, n, p, a - p)), p = l, t.wrap & 4 && (t.flags ? c : Px(c)) !== t.check) {
              o.msg = "incorrect data check", t.mode = Jr;
              break;
            }
            c = 0, u = 0;
          }
          t.mode = Lx;
        /* falls through */
        case Lx:
          if (t.wrap && t.flags) {
            for (; u < 32; ) {
              if (s === 0)
                break e;
              s--, c += r[i++] << u, u += 8;
            }
            if (t.wrap & 4 && c !== (t.total & 4294967295)) {
              o.msg = "incorrect length check", t.mode = Jr;
              break;
            }
            c = 0, u = 0;
          }
          t.mode = Tx;
        /* falls through */
        case Tx:
          F = SR;
          break e;
        case Jr:
          F = zE;
          break e;
        case $E:
          return KE;
        case WE:
        /* falls through */
        default:
          return Gi;
      }
  return o.next_out = a, o.avail_out = l, o.next_in = i, o.avail_in = s, t.hold = c, t.bits = u, (t.wsize || p !== o.avail_out && t.mode < Jr && (t.mode < w_ || e !== cx)) && ej(o, o.output, o.next_out, p - o.avail_out), A -= o.avail_in, p -= o.avail_out, o.total_in += A, o.total_out += p, t.total += p, t.wrap & 4 && p && (o.adler = t.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
  t.flags ? ra(t.check, n, p, o.next_out - p) : fb(t.check, n, p, o.next_out - p)), o.data_type = t.bits + (t.last ? 64 : 0) + (t.mode === Ta ? 128 : 0) + (t.mode === ip || t.mode === v_ ? 256 : 0), (A === 0 && p === 0 || e === cx) && F === Ql && (F = ER), F;
}, MR = (o) => {
  if (Dl(o))
    return Gi;
  let e = o.state;
  return e.window && (e.window = null), o.state = null, Ql;
}, RR = (o, e) => {
  if (Dl(o))
    return Gi;
  const t = o.state;
  return (t.wrap & 2) === 0 ? Gi : (t.head = e, e.done = !1, Ql);
}, OR = (o, e) => {
  const t = e.length;
  let r, n, i;
  return Dl(o) || (r = o.state, r.wrap !== 0 && r.mode !== xh) ? Gi : r.mode === xh && (n = 1, n = fb(n, e, t, 0), n !== r.check) ? zE : (i = ej(o, e, t, t), i ? (r.mode = $E, KE) : (r.havedict = 1, Ql));
};
var QR = YE, qR = ZE, GR = XE, VR = UR, DR = JE, HR = IR, zR = MR, KR = RR, $R = OR, WR = "pako inflate (from Nodeca project)", Ra = {
  inflateReset: QR,
  inflateReset2: qR,
  inflateResetKeep: GR,
  inflateInit: VR,
  inflateInit2: DR,
  inflate: HR,
  inflateEnd: zR,
  inflateGetHeader: KR,
  inflateSetDictionary: $R,
  inflateInfo: WR
};
function XR() {
  this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1;
}
var YR = XR;
const tj = Object.prototype.toString, {
  Z_NO_FLUSH: ZR,
  Z_FINISH: JR,
  Z_OK: IA,
  Z_STREAM_END: C_,
  Z_NEED_DICT: S_,
  Z_STREAM_ERROR: eO,
  Z_DATA_ERROR: Ux,
  Z_MEM_ERROR: tO
} = qE;
function YA(o) {
  this.options = GE.assign({
    chunkSize: 1024 * 64,
    windowBits: 15,
    to: ""
  }, o || {});
  const e = this.options;
  e.raw && e.windowBits >= 0 && e.windowBits < 16 && (e.windowBits = -e.windowBits, e.windowBits === 0 && (e.windowBits = -15)), e.windowBits >= 0 && e.windowBits < 16 && !(o && o.windowBits) && (e.windowBits += 32), e.windowBits > 15 && e.windowBits < 48 && (e.windowBits & 15) === 0 && (e.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new _R(), this.strm.avail_out = 0;
  let t = Ra.inflateInit2(
    this.strm,
    e.windowBits
  );
  if (t !== IA)
    throw new Error(mb[t]);
  if (this.header = new YR(), Ra.inflateGetHeader(this.strm, this.header), e.dictionary && (typeof e.dictionary == "string" ? e.dictionary = yb.string2buf(e.dictionary) : tj.call(e.dictionary) === "[object ArrayBuffer]" && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (t = Ra.inflateSetDictionary(this.strm, e.dictionary), t !== IA)))
    throw new Error(mb[t]);
}
YA.prototype.push = function(o, e) {
  const t = this.strm, r = this.options.chunkSize, n = this.options.dictionary;
  let i, a, s;
  if (this.ended) return !1;
  for (e === ~~e ? a = e : a = e === !0 ? JR : ZR, tj.call(o) === "[object ArrayBuffer]" ? t.input = new Uint8Array(o) : t.input = o, t.next_in = 0, t.avail_in = t.input.length; ; ) {
    for (t.avail_out === 0 && (t.output = new Uint8Array(r), t.next_out = 0, t.avail_out = r), i = Ra.inflate(t, a), i === S_ && n && (i = Ra.inflateSetDictionary(t, n), i === IA ? i = Ra.inflate(t, a) : i === Ux && (i = S_)); t.avail_in > 0 && i === C_ && t.state.wrap > 0 && o[t.next_in] !== 0; )
      Ra.inflateReset(t), i = Ra.inflate(t, a);
    switch (i) {
      case eO:
      case Ux:
      case S_:
      case tO:
        return this.onEnd(i), this.ended = !0, !1;
    }
    if (s = t.avail_out, t.next_out && (t.avail_out === 0 || i === C_))
      if (this.options.to === "string") {
        let l = yb.utf8border(t.output, t.next_out), c = t.next_out - l, u = yb.buf2string(t.output, l);
        t.next_out = c, t.avail_out = r - c, c && t.output.set(t.output.subarray(l, l + c), 0), this.onData(u);
      } else
        this.onData(t.output.length === t.next_out ? t.output : t.output.subarray(0, t.next_out));
    if (!(i === IA && s === 0)) {
      if (i === C_)
        return i = Ra.inflateEnd(this.strm), this.onEnd(i), this.ended = !0, !0;
      if (t.avail_in === 0) break;
    }
  }
  return !0;
};
YA.prototype.onData = function(o) {
  this.chunks.push(o);
};
YA.prototype.onEnd = function(o) {
  o === IA && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = GE.flattenChunks(this.chunks)), this.chunks = [], this.err = o, this.msg = this.strm.msg;
};
function rO(o, e) {
  const t = new YA(e);
  if (t.push(o), t.err) throw t.msg || mb[t.err];
  return t.result;
}
var oO = YA, nO = rO, iO = {
  Inflate: oO,
  inflate: nO
};
const { Inflate: aO, inflate: sO } = iO;
var Nx = aO, lO = sO;
const rj = [];
for (let o = 0; o < 256; o++) {
  let e = o;
  for (let t = 0; t < 8; t++)
    e & 1 ? e = 3988292384 ^ e >>> 1 : e = e >>> 1;
  rj[o] = e;
}
const Ix = 4294967295;
function cO(o, e, t) {
  let r = o;
  for (let n = 0; n < t; n++)
    r = rj[(r ^ e[n]) & 255] ^ r >>> 8;
  return r;
}
function uO(o, e) {
  return (cO(Ix, o, e) ^ Ix) >>> 0;
}
function Mx(o, e, t) {
  const r = o.readUint32(), n = uO(new Uint8Array(o.buffer, o.byteOffset + o.offset - e - 4, e), e);
  if (n !== r)
    throw new Error(`CRC mismatch for chunk ${t}. Expected ${r}, found ${n}`);
}
function oj(o, e, t) {
  for (let r = 0; r < t; r++)
    e[r] = o[r];
}
function nj(o, e, t, r) {
  let n = 0;
  for (; n < r; n++)
    e[n] = o[n];
  for (; n < t; n++)
    e[n] = o[n] + e[n - r] & 255;
}
function ij(o, e, t, r) {
  let n = 0;
  if (t.length === 0)
    for (; n < r; n++)
      e[n] = o[n];
  else
    for (; n < r; n++)
      e[n] = o[n] + t[n] & 255;
}
function aj(o, e, t, r, n) {
  let i = 0;
  if (t.length === 0) {
    for (; i < n; i++)
      e[i] = o[i];
    for (; i < r; i++)
      e[i] = o[i] + (e[i - n] >> 1) & 255;
  } else {
    for (; i < n; i++)
      e[i] = o[i] + (t[i] >> 1) & 255;
    for (; i < r; i++)
      e[i] = o[i] + (e[i - n] + t[i] >> 1) & 255;
  }
}
function sj(o, e, t, r, n) {
  let i = 0;
  if (t.length === 0) {
    for (; i < n; i++)
      e[i] = o[i];
    for (; i < r; i++)
      e[i] = o[i] + e[i - n] & 255;
  } else {
    for (; i < n; i++)
      e[i] = o[i] + t[i] & 255;
    for (; i < r; i++)
      e[i] = o[i] + AO(e[i - n], t[i], t[i - n]) & 255;
  }
}
function AO(o, e, t) {
  const r = o + e - t, n = Math.abs(r - o), i = Math.abs(r - e), a = Math.abs(r - t);
  return n <= i && n <= a ? o : i <= a ? e : t;
}
function dO(o, e, t, r, n, i) {
  switch (o) {
    case 0:
      oj(e, t, n);
      break;
    case 1:
      nj(e, t, n, i);
      break;
    case 2:
      ij(e, t, r, n);
      break;
    case 3:
      aj(e, t, r, n, i);
      break;
    case 4:
      sj(e, t, r, n, i);
      break;
    default:
      throw new Error(`Unsupported filter: ${o}`);
  }
}
const pO = new Uint16Array([255]), hO = new Uint8Array(pO.buffer), gO = hO[0] === 255;
function _O(o) {
  const { data: e, width: t, height: r, channels: n, depth: i } = o, a = [
    { x: 0, y: 0, xStep: 8, yStep: 8 },
    // Pass 1
    { x: 4, y: 0, xStep: 8, yStep: 8 },
    // Pass 2
    { x: 0, y: 4, xStep: 4, yStep: 8 },
    // Pass 3
    { x: 2, y: 0, xStep: 4, yStep: 4 },
    // Pass 4
    { x: 0, y: 2, xStep: 2, yStep: 4 },
    // Pass 5
    { x: 1, y: 0, xStep: 2, yStep: 2 },
    // Pass 6
    { x: 0, y: 1, xStep: 1, yStep: 2 }
    // Pass 7
  ], s = Math.ceil(i / 8) * n, l = new Uint8Array(r * t * s);
  let c = 0;
  for (let u = 0; u < 7; u++) {
    const A = a[u], p = Math.ceil((t - A.x) / A.xStep), d = Math.ceil((r - A.y) / A.yStep);
    if (p <= 0 || d <= 0)
      continue;
    const g = p * s, _ = new Uint8Array(g);
    for (let f = 0; f < d; f++) {
      const m = e[c++], b = e.subarray(c, c + g);
      c += g;
      const v = new Uint8Array(g);
      dO(m, b, v, _, g, s), _.set(v);
      for (let w = 0; w < p; w++) {
        const C = A.x + w * A.xStep, E = A.y + f * A.yStep;
        if (!(C >= t || E >= r))
          for (let T = 0; T < s; T++)
            l[(E * t + C) * s + T] = v[w * s + T];
      }
    }
  }
  if (i === 16) {
    const u = new Uint16Array(l.buffer);
    if (gO)
      for (let A = 0; A < u.length; A++)
        u[A] = fO(u[A]);
    return u;
  } else
    return l;
}
function fO(o) {
  return (o & 255) << 8 | o >> 8 & 255;
}
const mO = new Uint16Array([255]), yO = new Uint8Array(mO.buffer), bO = yO[0] === 255, vO = new Uint8Array(0);
function Rx(o) {
  const { data: e, width: t, height: r, channels: n, depth: i } = o, a = Math.ceil(i / 8) * n, s = Math.ceil(i / 8 * n * t), l = new Uint8Array(r * s);
  let c = vO, u = 0, A, p;
  for (let d = 0; d < r; d++) {
    switch (A = e.subarray(u + 1, u + 1 + s), p = l.subarray(d * s, (d + 1) * s), e[u]) {
      case 0:
        oj(A, p, s);
        break;
      case 1:
        nj(A, p, s, a);
        break;
      case 2:
        ij(A, p, c, s);
        break;
      case 3:
        aj(A, p, c, s, a);
        break;
      case 4:
        sj(A, p, c, s, a);
        break;
      default:
        throw new Error(`Unsupported filter: ${e[u]}`);
    }
    c = p, u += s + 1;
  }
  if (i === 16) {
    const d = new Uint16Array(l.buffer);
    if (bO)
      for (let g = 0; g < d.length; g++)
        d[g] = wO(d[g]);
    return d;
  } else
    return l;
}
function wO(o) {
  return (o & 255) << 8 | o >> 8 & 255;
}
const Jp = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
function Ox(o) {
  if (!xO(o.readBytes(Jp.length)))
    throw new Error("wrong PNG signature");
}
function xO(o) {
  if (o.length < Jp.length)
    return !1;
  for (let e = 0; e < Jp.length; e++)
    if (o[e] !== Jp[e])
      return !1;
  return !0;
}
const kO = "tEXt", CO = 0, lj = new TextDecoder("latin1");
function SO(o) {
  if (EO(o), o.length === 0 || o.length > 79)
    throw new Error("keyword length must be between 1 and 79");
}
const BO = /^[\u0000-\u00FF]*$/;
function EO(o) {
  if (!BO.test(o))
    throw new Error("invalid latin1 text");
}
function jO(o, e, t) {
  const r = cj(e);
  o[r] = LO(e, t - r.length - 1);
}
function cj(o) {
  for (o.mark(); o.readByte() !== CO; )
    ;
  const e = o.offset;
  o.reset();
  const t = lj.decode(o.readBytes(e - o.offset - 1));
  return o.skip(1), SO(t), t;
}
function LO(o, e) {
  return lj.decode(o.readBytes(e));
}
const ri = {
  UNKNOWN: -1,
  GREYSCALE: 0,
  TRUECOLOUR: 2,
  INDEXED_COLOUR: 3,
  GREYSCALE_ALPHA: 4,
  TRUECOLOUR_ALPHA: 6
}, B_ = {
  UNKNOWN: -1,
  DEFLATE: 0
}, Qx = {
  UNKNOWN: -1,
  ADAPTIVE: 0
}, E_ = {
  UNKNOWN: -1,
  NO_INTERLACE: 0,
  ADAM7: 1
}, sp = {
  NONE: 0,
  BACKGROUND: 1,
  PREVIOUS: 2
}, j_ = {
  SOURCE: 0,
  OVER: 1
};
class TO extends Pv {
  _checkCrc;
  _inflator;
  _png;
  _apng;
  _end;
  _hasPalette;
  _palette;
  _hasTransparency;
  _transparency;
  _compressionMethod;
  _filterMethod;
  _interlaceMethod;
  _colorType;
  _isAnimated;
  _numberOfFrames;
  _numberOfPlays;
  _frames;
  _writingDataChunks;
  constructor(e, t = {}) {
    super(e);
    const { checkCrc: r = !1 } = t;
    this._checkCrc = r, this._inflator = new Nx(), this._png = {
      width: -1,
      height: -1,
      channels: -1,
      data: new Uint8Array(0),
      depth: 1,
      text: {}
    }, this._apng = {
      width: -1,
      height: -1,
      channels: -1,
      depth: 1,
      numberOfFrames: 1,
      numberOfPlays: 0,
      text: {},
      frames: []
    }, this._end = !1, this._hasPalette = !1, this._palette = [], this._hasTransparency = !1, this._transparency = new Uint16Array(0), this._compressionMethod = B_.UNKNOWN, this._filterMethod = Qx.UNKNOWN, this._interlaceMethod = E_.UNKNOWN, this._colorType = ri.UNKNOWN, this._isAnimated = !1, this._numberOfFrames = 1, this._numberOfPlays = 0, this._frames = [], this._writingDataChunks = !1, this.setBigEndian();
  }
  decode() {
    for (Ox(this); !this._end; ) {
      const e = this.readUint32(), t = this.readChars(4);
      this.decodeChunk(e, t);
    }
    return this.decodeImage(), this._png;
  }
  decodeApng() {
    for (Ox(this); !this._end; ) {
      const e = this.readUint32(), t = this.readChars(4);
      this.decodeApngChunk(e, t);
    }
    return this.decodeApngImage(), this._apng;
  }
  // https://www.w3.org/TR/PNG/#5Chunk-layout
  decodeChunk(e, t) {
    const r = this.offset;
    switch (t) {
      // 11.2 Critical chunks
      case "IHDR":
        this.decodeIHDR();
        break;
      case "PLTE":
        this.decodePLTE(e);
        break;
      case "IDAT":
        this.decodeIDAT(e);
        break;
      case "IEND":
        this._end = !0;
        break;
      // 11.3 Ancillary chunks
      case "tRNS":
        this.decodetRNS(e);
        break;
      case "iCCP":
        this.decodeiCCP(e);
        break;
      case kO:
        jO(this._png.text, this, e);
        break;
      case "pHYs":
        this.decodepHYs();
        break;
      default:
        this.skip(e);
        break;
    }
    if (this.offset - r !== e)
      throw new Error(`Length mismatch while decoding chunk ${t}`);
    this._checkCrc ? Mx(this, e + 4, t) : this.skip(4);
  }
  decodeApngChunk(e, t) {
    const r = this.offset;
    switch (t !== "fdAT" && t !== "IDAT" && this._writingDataChunks && this.pushDataToFrame(), t) {
      case "acTL":
        this.decodeACTL();
        break;
      case "fcTL":
        this.decodeFCTL();
        break;
      case "fdAT":
        this.decodeFDAT(e);
        break;
      default:
        this.decodeChunk(e, t), this.offset = r + e;
        break;
    }
    if (this.offset - r !== e)
      throw new Error(`Length mismatch while decoding chunk ${t}`);
    this._checkCrc ? Mx(this, e + 4, t) : this.skip(4);
  }
  // https://www.w3.org/TR/PNG/#11IHDR
  decodeIHDR() {
    const e = this._png;
    e.width = this.readUint32(), e.height = this.readUint32(), e.depth = PO(this.readUint8());
    const t = this.readUint8();
    this._colorType = t;
    let r;
    switch (t) {
      case ri.GREYSCALE:
        r = 1;
        break;
      case ri.TRUECOLOUR:
        r = 3;
        break;
      case ri.INDEXED_COLOUR:
        r = 1;
        break;
      case ri.GREYSCALE_ALPHA:
        r = 2;
        break;
      case ri.TRUECOLOUR_ALPHA:
        r = 4;
        break;
      // Kept for exhaustiveness.
      // eslint-disable-next-line unicorn/no-useless-switch-case
      case ri.UNKNOWN:
      default:
        throw new Error(`Unknown color type: ${t}`);
    }
    if (this._png.channels = r, this._compressionMethod = this.readUint8(), this._compressionMethod !== B_.DEFLATE)
      throw new Error(`Unsupported compression method: ${this._compressionMethod}`);
    this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8();
  }
  decodeACTL() {
    this._numberOfFrames = this.readUint32(), this._numberOfPlays = this.readUint32(), this._isAnimated = !0;
  }
  decodeFCTL() {
    const e = {
      sequenceNumber: this.readUint32(),
      width: this.readUint32(),
      height: this.readUint32(),
      xOffset: this.readUint32(),
      yOffset: this.readUint32(),
      delayNumber: this.readUint16(),
      delayDenominator: this.readUint16(),
      disposeOp: this.readUint8(),
      blendOp: this.readUint8(),
      data: new Uint8Array(0)
    };
    this._frames.push(e);
  }
  // https://www.w3.org/TR/PNG/#11PLTE
  decodePLTE(e) {
    if (e % 3 !== 0)
      throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);
    const t = e / 3;
    this._hasPalette = !0;
    const r = [];
    this._palette = r;
    for (let n = 0; n < t; n++)
      r.push([this.readUint8(), this.readUint8(), this.readUint8()]);
  }
  // https://www.w3.org/TR/PNG/#11IDAT
  decodeIDAT(e) {
    this._writingDataChunks = !0;
    const t = e, r = this.offset + this.byteOffset;
    if (this._inflator.push(new Uint8Array(this.buffer, r, t)), this._inflator.err)
      throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
    this.skip(e);
  }
  decodeFDAT(e) {
    this._writingDataChunks = !0;
    let t = e, r = this.offset + this.byteOffset;
    if (r += 4, t -= 4, this._inflator.push(new Uint8Array(this.buffer, r, t)), this._inflator.err)
      throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
    this.skip(e);
  }
  // https://www.w3.org/TR/PNG/#11tRNS
  decodetRNS(e) {
    switch (this._colorType) {
      case ri.GREYSCALE:
      case ri.TRUECOLOUR: {
        if (e % 2 !== 0)
          throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);
        if (e / 2 > this._png.width * this._png.height)
          throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e / 2} vs ${this._png.width * this._png.height})`);
        this._hasTransparency = !0, this._transparency = new Uint16Array(e / 2);
        for (let t = 0; t < e / 2; t++)
          this._transparency[t] = this.readUint16();
        break;
      }
      case ri.INDEXED_COLOUR: {
        if (e > this._palette.length)
          throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);
        let t = 0;
        for (; t < e; t++) {
          const r = this.readByte();
          this._palette[t].push(r);
        }
        for (; t < this._palette.length; t++)
          this._palette[t].push(255);
        break;
      }
      // Kept for exhaustiveness.
      /* eslint-disable unicorn/no-useless-switch-case */
      case ri.UNKNOWN:
      case ri.GREYSCALE_ALPHA:
      case ri.TRUECOLOUR_ALPHA:
      default:
        throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`);
    }
  }
  // https://www.w3.org/TR/PNG/#11iCCP
  decodeiCCP(e) {
    const t = cj(this), r = this.readUint8();
    if (r !== B_.DEFLATE)
      throw new Error(`Unsupported iCCP compression method: ${r}`);
    const n = this.readBytes(e - t.length - 2);
    this._png.iccEmbeddedProfile = {
      name: t,
      profile: lO(n)
    };
  }
  // https://www.w3.org/TR/PNG/#11pHYs
  decodepHYs() {
    const e = this.readUint32(), t = this.readUint32(), r = this.readByte();
    this._png.resolution = { x: e, y: t, unit: r };
  }
  decodeApngImage() {
    this._apng.width = this._png.width, this._apng.height = this._png.height, this._apng.channels = this._png.channels, this._apng.depth = this._png.depth, this._apng.numberOfFrames = this._numberOfFrames, this._apng.numberOfPlays = this._numberOfPlays, this._apng.text = this._png.text, this._apng.resolution = this._png.resolution;
    for (let e = 0; e < this._numberOfFrames; e++) {
      const t = {
        sequenceNumber: this._frames[e].sequenceNumber,
        delayNumber: this._frames[e].delayNumber,
        delayDenominator: this._frames[e].delayDenominator,
        data: this._apng.depth === 8 ? new Uint8Array(this._apng.width * this._apng.height * this._apng.channels) : new Uint16Array(this._apng.width * this._apng.height * this._apng.channels)
      }, r = this._frames.at(e);
      if (r) {
        if (r.data = Rx({
          data: r.data,
          width: r.width,
          height: r.height,
          channels: this._apng.channels,
          depth: this._apng.depth
        }), this._hasPalette && (this._apng.palette = this._palette), this._hasTransparency && (this._apng.transparency = this._transparency), e === 0 || r.xOffset === 0 && r.yOffset === 0 && r.width === this._png.width && r.height === this._png.height)
          t.data = r.data;
        else {
          const n = this._apng.frames.at(e - 1);
          this.disposeFrame(r, n, t), this.addFrameDataToCanvas(t, r);
        }
        this._apng.frames.push(t);
      }
    }
    return this._apng;
  }
  disposeFrame(e, t, r) {
    switch (e.disposeOp) {
      case sp.NONE:
        break;
      case sp.BACKGROUND:
        for (let n = 0; n < this._png.height; n++)
          for (let i = 0; i < this._png.width; i++) {
            const a = (n * e.width + i) * this._png.channels;
            for (let s = 0; s < this._png.channels; s++)
              r.data[a + s] = 0;
          }
        break;
      case sp.PREVIOUS:
        r.data.set(t.data);
        break;
      default:
        throw new Error("Unknown disposeOp");
    }
  }
  addFrameDataToCanvas(e, t) {
    const r = 1 << this._png.depth, n = (i, a) => {
      const s = ((i + t.yOffset) * this._png.width + t.xOffset + a) * this._png.channels, l = (i * t.width + a) * this._png.channels;
      return { index: s, frameIndex: l };
    };
    switch (t.blendOp) {
      case j_.SOURCE:
        for (let i = 0; i < t.height; i++)
          for (let a = 0; a < t.width; a++) {
            const { index: s, frameIndex: l } = n(i, a);
            for (let c = 0; c < this._png.channels; c++)
              e.data[s + c] = t.data[l + c];
          }
        break;
      // https://www.w3.org/TR/png-3/#13Alpha-channel-processing
      case j_.OVER:
        for (let i = 0; i < t.height; i++)
          for (let a = 0; a < t.width; a++) {
            const { index: s, frameIndex: l } = n(i, a);
            for (let c = 0; c < this._png.channels; c++) {
              const u = t.data[l + this._png.channels - 1] / r, A = c % (this._png.channels - 1) === 0 ? 1 : t.data[l + c], p = Math.floor(u * A + (1 - u) * e.data[s + c]);
              e.data[s + c] += p;
            }
          }
        break;
      default:
        throw new Error("Unknown blendOp");
    }
  }
  decodeImage() {
    if (this._inflator.err)
      throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
    const e = this._isAnimated ? (this._frames?.at(0)).data : this._inflator.result;
    if (this._filterMethod !== Qx.ADAPTIVE)
      throw new Error(`Filter method ${this._filterMethod} not supported`);
    if (this._interlaceMethod === E_.NO_INTERLACE)
      this._png.data = Rx({
        data: e,
        width: this._png.width,
        height: this._png.height,
        channels: this._png.channels,
        depth: this._png.depth
      });
    else if (this._interlaceMethod === E_.ADAM7)
      this._png.data = _O({
        data: e,
        width: this._png.width,
        height: this._png.height,
        channels: this._png.channels,
        depth: this._png.depth
      });
    else
      throw new Error(`Interlace method ${this._interlaceMethod} not supported`);
    this._hasPalette && (this._png.palette = this._palette), this._hasTransparency && (this._png.transparency = this._transparency);
  }
  pushDataToFrame() {
    const e = this._inflator.result, t = this._frames.at(-1);
    t ? t.data = e : this._frames.push({
      sequenceNumber: 0,
      width: this._png.width,
      height: this._png.height,
      xOffset: 0,
      yOffset: 0,
      delayNumber: 0,
      delayDenominator: 0,
      disposeOp: sp.NONE,
      blendOp: j_.SOURCE,
      data: e
    }), this._inflator = new Nx(), this._writingDataChunks = !1;
  }
}
function PO(o) {
  if (o !== 1 && o !== 2 && o !== 4 && o !== 8 && o !== 16)
    throw new Error(`invalid bit depth: ${o}`);
  return o;
}
var qx;
(function(o) {
  o[o.UNKNOWN = 0] = "UNKNOWN", o[o.METRE = 1] = "METRE";
})(qx || (qx = {}));
function FO(o, e) {
  return new TO(o, e).decode();
}
var Gt = /* @__PURE__ */ (function() {
  return typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : this;
})();
function L_() {
  Gt.console && typeof Gt.console.log == "function" && Gt.console.log.apply(Gt.console, arguments);
}
var Or = { log: L_, warn: function(o) {
  Gt.console && (typeof Gt.console.warn == "function" ? Gt.console.warn.apply(Gt.console, arguments) : L_.call(null, arguments));
}, error: function(o) {
  Gt.console && (typeof Gt.console.error == "function" ? Gt.console.error.apply(Gt.console, arguments) : L_(o));
} };
function T_(o, e, t) {
  var r = new XMLHttpRequest();
  r.open("GET", o), r.responseType = "blob", r.onload = function() {
    xl(r.response, e, t);
  }, r.onerror = function() {
    Or.error("could not download file");
  }, r.send();
}
function Gx(o) {
  var e = new XMLHttpRequest();
  e.open("HEAD", o, !1);
  try {
    e.send();
  } catch {
  }
  return e.status >= 200 && e.status <= 299;
}
function lp(o) {
  try {
    o.dispatchEvent(new MouseEvent("click"));
  } catch {
    var e = document.createEvent("MouseEvents");
    e.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), o.dispatchEvent(e);
  }
}
var xl = Gt.saveAs || ((typeof window > "u" ? "undefined" : yr(window)) !== "object" || window !== Gt ? function() {
} : typeof HTMLAnchorElement < "u" && "download" in HTMLAnchorElement.prototype ? function(o, e, t) {
  var r = Gt.URL || Gt.webkitURL, n = document.createElement("a");
  e = e || o.name || "download", n.download = e, n.rel = "noopener", typeof o == "string" ? (n.href = o, n.origin !== location.origin ? Gx(n.href) ? T_(o, e, t) : lp(n, n.target = "_blank") : lp(n)) : (n.href = r.createObjectURL(o), setTimeout(function() {
    r.revokeObjectURL(n.href);
  }, 4e4), setTimeout(function() {
    lp(n);
  }, 0));
} : "msSaveOrOpenBlob" in navigator ? function(o, e, t) {
  if (e = e || o.name || "download", typeof o == "string") if (Gx(o)) T_(o, e, t);
  else {
    var r = document.createElement("a");
    r.href = o, r.target = "_blank", setTimeout(function() {
      lp(r);
    });
  }
  else navigator.msSaveOrOpenBlob((function(n, i) {
    return i === void 0 ? i = { autoBom: !1 } : yr(i) !== "object" && (Or.warn("Deprecated: Expected third argument to be a object"), i = { autoBom: !i }), i.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type) ? new Blob(["\uFEFF", n], { type: n.type }) : n;
  })(o, t), e);
} : function(o, e, t, r) {
  if ((r = r || open("", "_blank")) && (r.document.title = r.document.body.innerText = "downloading..."), typeof o == "string") return T_(o, e, t);
  var n = o.type === "application/octet-stream", i = /constructor/i.test(Gt.HTMLElement) || Gt.safari, a = /CriOS\/[\d]+/.test(navigator.userAgent);
  if ((a || n && i) && (typeof FileReader > "u" ? "undefined" : yr(FileReader)) === "object") {
    var s = new FileReader();
    s.onloadend = function() {
      var u = s.result;
      u = a ? u : u.replace(/^data:[^;]*;/, "data:attachment/file;"), r ? r.location.href = u : location = u, r = null;
    }, s.readAsDataURL(o);
  } else {
    var l = Gt.URL || Gt.webkitURL, c = l.createObjectURL(o);
    r ? r.location = c : location.href = c, r = null, setTimeout(function() {
      l.revokeObjectURL(c);
    }, 4e4);
  }
});
function uj(o) {
  var e;
  o = o || "", this.ok = !1, o.charAt(0) == "#" && (o = o.substr(1, 6)), o = { aliceblue: "f0f8ff", antiquewhite: "faebd7", aqua: "00ffff", aquamarine: "7fffd4", azure: "f0ffff", beige: "f5f5dc", bisque: "ffe4c4", black: "000000", blanchedalmond: "ffebcd", blue: "0000ff", blueviolet: "8a2be2", brown: "a52a2a", burlywood: "deb887", cadetblue: "5f9ea0", chartreuse: "7fff00", chocolate: "d2691e", coral: "ff7f50", cornflowerblue: "6495ed", cornsilk: "fff8dc", crimson: "dc143c", cyan: "00ffff", darkblue: "00008b", darkcyan: "008b8b", darkgoldenrod: "b8860b", darkgray: "a9a9a9", darkgreen: "006400", darkkhaki: "bdb76b", darkmagenta: "8b008b", darkolivegreen: "556b2f", darkorange: "ff8c00", darkorchid: "9932cc", darkred: "8b0000", darksalmon: "e9967a", darkseagreen: "8fbc8f", darkslateblue: "483d8b", darkslategray: "2f4f4f", darkturquoise: "00ced1", darkviolet: "9400d3", deeppink: "ff1493", deepskyblue: "00bfff", dimgray: "696969", dodgerblue: "1e90ff", feldspar: "d19275", firebrick: "b22222", floralwhite: "fffaf0", forestgreen: "228b22", fuchsia: "ff00ff", gainsboro: "dcdcdc", ghostwhite: "f8f8ff", gold: "ffd700", goldenrod: "daa520", gray: "808080", green: "008000", greenyellow: "adff2f", honeydew: "f0fff0", hotpink: "ff69b4", indianred: "cd5c5c", indigo: "4b0082", ivory: "fffff0", khaki: "f0e68c", lavender: "e6e6fa", lavenderblush: "fff0f5", lawngreen: "7cfc00", lemonchiffon: "fffacd", lightblue: "add8e6", lightcoral: "f08080", lightcyan: "e0ffff", lightgoldenrodyellow: "fafad2", lightgrey: "d3d3d3", lightgreen: "90ee90", lightpink: "ffb6c1", lightsalmon: "ffa07a", lightseagreen: "20b2aa", lightskyblue: "87cefa", lightslateblue: "8470ff", lightslategray: "778899", lightsteelblue: "b0c4de", lightyellow: "ffffe0", lime: "00ff00", limegreen: "32cd32", linen: "faf0e6", magenta: "ff00ff", maroon: "800000", mediumaquamarine: "66cdaa", mediumblue: "0000cd", mediumorchid: "ba55d3", mediumpurple: "9370d8", mediumseagreen: "3cb371", mediumslateblue: "7b68ee", mediumspringgreen: "00fa9a", mediumturquoise: "48d1cc", mediumvioletred: "c71585", midnightblue: "191970", mintcream: "f5fffa", mistyrose: "ffe4e1", moccasin: "ffe4b5", navajowhite: "ffdead", navy: "000080", oldlace: "fdf5e6", olive: "808000", olivedrab: "6b8e23", orange: "ffa500", orangered: "ff4500", orchid: "da70d6", palegoldenrod: "eee8aa", palegreen: "98fb98", paleturquoise: "afeeee", palevioletred: "d87093", papayawhip: "ffefd5", peachpuff: "ffdab9", peru: "cd853f", pink: "ffc0cb", plum: "dda0dd", powderblue: "b0e0e6", purple: "800080", red: "ff0000", rosybrown: "bc8f8f", royalblue: "4169e1", saddlebrown: "8b4513", salmon: "fa8072", sandybrown: "f4a460", seagreen: "2e8b57", seashell: "fff5ee", sienna: "a0522d", silver: "c0c0c0", skyblue: "87ceeb", slateblue: "6a5acd", slategray: "708090", snow: "fffafa", springgreen: "00ff7f", steelblue: "4682b4", tan: "d2b48c", teal: "008080", thistle: "d8bfd8", tomato: "ff6347", turquoise: "40e0d0", violet: "ee82ee", violetred: "d02090", wheat: "f5deb3", white: "ffffff", whitesmoke: "f5f5f5", yellow: "ffff00", yellowgreen: "9acd32" }[o = (o = o.replace(/ /g, "")).toLowerCase()] || o;
  for (var t = [{ re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, example: ["rgb(123, 234, 45)", "rgb(255,234,245)"], process: function(s) {
    return [parseInt(s[1]), parseInt(s[2]), parseInt(s[3])];
  } }, { re: /^(\w{2})(\w{2})(\w{2})$/, example: ["#00ff00", "336699"], process: function(s) {
    return [parseInt(s[1], 16), parseInt(s[2], 16), parseInt(s[3], 16)];
  } }, { re: /^(\w{1})(\w{1})(\w{1})$/, example: ["#fb0", "f0f"], process: function(s) {
    return [parseInt(s[1] + s[1], 16), parseInt(s[2] + s[2], 16), parseInt(s[3] + s[3], 16)];
  } }], r = 0; r < t.length; r++) {
    var n = t[r].re, i = t[r].process, a = n.exec(o);
    a && (e = i(a), this.r = e[0], this.g = e[1], this.b = e[2], this.ok = !0);
  }
  this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r, this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g, this.b = this.b < 0 || isNaN(this.b) ? 0 : this.b > 255 ? 255 : this.b, this.toRGB = function() {
    return "rgb(" + this.r + ", " + this.g + ", " + this.b + ")";
  }, this.toHex = function() {
    var s = this.r.toString(16), l = this.g.toString(16), c = this.b.toString(16);
    return s.length == 1 && (s = "0" + s), l.length == 1 && (l = "0" + l), c.length == 1 && (c = "0" + c), "#" + s + l + c;
  };
}
var eh = Gt.atob.bind(Gt), Vx = Gt.btoa.bind(Gt);
function P_(o, e) {
  var t = o[0], r = o[1], n = o[2], i = o[3];
  t = gn(t, r, n, i, e[0], 7, -680876936), i = gn(i, t, r, n, e[1], 12, -389564586), n = gn(n, i, t, r, e[2], 17, 606105819), r = gn(r, n, i, t, e[3], 22, -1044525330), t = gn(t, r, n, i, e[4], 7, -176418897), i = gn(i, t, r, n, e[5], 12, 1200080426), n = gn(n, i, t, r, e[6], 17, -1473231341), r = gn(r, n, i, t, e[7], 22, -45705983), t = gn(t, r, n, i, e[8], 7, 1770035416), i = gn(i, t, r, n, e[9], 12, -1958414417), n = gn(n, i, t, r, e[10], 17, -42063), r = gn(r, n, i, t, e[11], 22, -1990404162), t = gn(t, r, n, i, e[12], 7, 1804603682), i = gn(i, t, r, n, e[13], 12, -40341101), n = gn(n, i, t, r, e[14], 17, -1502002290), t = _n(t, r = gn(r, n, i, t, e[15], 22, 1236535329), n, i, e[1], 5, -165796510), i = _n(i, t, r, n, e[6], 9, -1069501632), n = _n(n, i, t, r, e[11], 14, 643717713), r = _n(r, n, i, t, e[0], 20, -373897302), t = _n(t, r, n, i, e[5], 5, -701558691), i = _n(i, t, r, n, e[10], 9, 38016083), n = _n(n, i, t, r, e[15], 14, -660478335), r = _n(r, n, i, t, e[4], 20, -405537848), t = _n(t, r, n, i, e[9], 5, 568446438), i = _n(i, t, r, n, e[14], 9, -1019803690), n = _n(n, i, t, r, e[3], 14, -187363961), r = _n(r, n, i, t, e[8], 20, 1163531501), t = _n(t, r, n, i, e[13], 5, -1444681467), i = _n(i, t, r, n, e[2], 9, -51403784), n = _n(n, i, t, r, e[7], 14, 1735328473), t = fn(t, r = _n(r, n, i, t, e[12], 20, -1926607734), n, i, e[5], 4, -378558), i = fn(i, t, r, n, e[8], 11, -2022574463), n = fn(n, i, t, r, e[11], 16, 1839030562), r = fn(r, n, i, t, e[14], 23, -35309556), t = fn(t, r, n, i, e[1], 4, -1530992060), i = fn(i, t, r, n, e[4], 11, 1272893353), n = fn(n, i, t, r, e[7], 16, -155497632), r = fn(r, n, i, t, e[10], 23, -1094730640), t = fn(t, r, n, i, e[13], 4, 681279174), i = fn(i, t, r, n, e[0], 11, -358537222), n = fn(n, i, t, r, e[3], 16, -722521979), r = fn(r, n, i, t, e[6], 23, 76029189), t = fn(t, r, n, i, e[9], 4, -640364487), i = fn(i, t, r, n, e[12], 11, -421815835), n = fn(n, i, t, r, e[15], 16, 530742520), t = mn(t, r = fn(r, n, i, t, e[2], 23, -995338651), n, i, e[0], 6, -198630844), i = mn(i, t, r, n, e[7], 10, 1126891415), n = mn(n, i, t, r, e[14], 15, -1416354905), r = mn(r, n, i, t, e[5], 21, -57434055), t = mn(t, r, n, i, e[12], 6, 1700485571), i = mn(i, t, r, n, e[3], 10, -1894986606), n = mn(n, i, t, r, e[10], 15, -1051523), r = mn(r, n, i, t, e[1], 21, -2054922799), t = mn(t, r, n, i, e[8], 6, 1873313359), i = mn(i, t, r, n, e[15], 10, -30611744), n = mn(n, i, t, r, e[6], 15, -1560198380), r = mn(r, n, i, t, e[13], 21, 1309151649), t = mn(t, r, n, i, e[4], 6, -145523070), i = mn(i, t, r, n, e[11], 10, -1120210379), n = mn(n, i, t, r, e[2], 15, 718787259), r = mn(r, n, i, t, e[9], 21, -343485551), o[0] = Fs(t, o[0]), o[1] = Fs(r, o[1]), o[2] = Fs(n, o[2]), o[3] = Fs(i, o[3]);
}
function zh(o, e, t, r, n, i) {
  return e = Fs(Fs(e, o), Fs(r, i)), Fs(e << n | e >>> 32 - n, t);
}
function gn(o, e, t, r, n, i, a) {
  return zh(e & t | ~e & r, o, e, n, i, a);
}
function _n(o, e, t, r, n, i, a) {
  return zh(e & r | t & ~r, o, e, n, i, a);
}
function fn(o, e, t, r, n, i, a) {
  return zh(e ^ t ^ r, o, e, n, i, a);
}
function mn(o, e, t, r, n, i, a) {
  return zh(t ^ (e | ~r), o, e, n, i, a);
}
function Aj(o) {
  var e, t = o.length, r = [1732584193, -271733879, -1732584194, 271733878];
  for (e = 64; e <= o.length; e += 64) P_(r, UO(o.substring(e - 64, e)));
  o = o.substring(e - 64);
  var n = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  for (e = 0; e < o.length; e++) n[e >> 2] |= o.charCodeAt(e) << (e % 4 << 3);
  if (n[e >> 2] |= 128 << (e % 4 << 3), e > 55) for (P_(r, n), e = 0; e < 16; e++) n[e] = 0;
  return n[14] = 8 * t, P_(r, n), r;
}
function UO(o) {
  var e, t = [];
  for (e = 0; e < 64; e += 4) t[e >> 2] = o.charCodeAt(e) + (o.charCodeAt(e + 1) << 8) + (o.charCodeAt(e + 2) << 16) + (o.charCodeAt(e + 3) << 24);
  return t;
}
var Dx = "0123456789abcdef".split("");
function NO(o) {
  for (var e = "", t = 0; t < 4; t++) e += Dx[o >> 8 * t + 4 & 15] + Dx[o >> 8 * t & 15];
  return e;
}
function IO(o) {
  return String.fromCharCode(255 & o, (65280 & o) >> 8, (16711680 & o) >> 16, (4278190080 & o) >> 24);
}
function bb(o) {
  return Aj(o).map(IO).join("");
}
var MO = (function(o) {
  for (var e = 0; e < o.length; e++) o[e] = NO(o[e]);
  return o.join("");
})(Aj("hello")) != "5d41402abc4b2a76b9719d911017c592";
function Fs(o, e) {
  if (MO) {
    var t = (65535 & o) + (65535 & e);
    return (o >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
  }
  return o + e & 4294967295;
}
function vb(o, e) {
  var t, r, n, i;
  if (o !== t) {
    for (var a = (n = o, i = 1 + (256 / o.length | 0), new Array(i + 1).join(n)), s = [], l = 0; l < 256; l++) s[l] = l;
    var c = 0;
    for (l = 0; l < 256; l++) {
      var u = s[l];
      c = (c + u + a.charCodeAt(l)) % 256, s[l] = s[c], s[c] = u;
    }
    t = o, r = s;
  } else s = r;
  var A = e.length, p = 0, d = 0, g = "";
  for (l = 0; l < A; l++) d = (d + (u = s[p = (p + 1) % 256])) % 256, s[p] = s[d], s[d] = u, a = s[(s[p] + s[d]) % 256], g += String.fromCharCode(e.charCodeAt(l) ^ a);
  return g;
}
var Hx = { print: 4, modify: 8, copy: 16, "annot-forms": 32 };
function kc(o, e, t, r) {
  this.v = 1, this.r = 2;
  var n = 192;
  o.forEach(function(s) {
    if (Hx.perm !== void 0) throw new Error("Invalid permission: " + s);
    n += Hx[s];
  }), this.padding = "(¿N^NuŠAd\0NVÿú\b..\0¶Ðh>€/\f©þdSiz";
  var i = (e + this.padding).substr(0, 32), a = (t + this.padding).substr(0, 32);
  this.O = this.processOwnerPassword(i, a), this.P = -(1 + (255 ^ n)), this.encryptionKey = bb(i + this.O + this.lsbFirstWord(this.P) + this.hexToBytes(r)).substr(0, 5), this.U = vb(this.encryptionKey, this.padding);
}
function Cc(o) {
  if (/[^\u0000-\u00ff]/.test(o)) throw new Error("Invalid PDF Name Object: " + o + ", Only accept ASCII characters.");
  for (var e = "", t = o.length, r = 0; r < t; r++) {
    var n = o.charCodeAt(r);
    e += n < 33 || n === 35 || n === 37 || n === 40 || n === 41 || n === 47 || n === 60 || n === 62 || n === 91 || n === 93 || n === 123 || n === 125 || n > 126 ? "#" + ("0" + n.toString(16)).slice(-2) : o[r];
  }
  return e;
}
function zx(o) {
  if (yr(o) !== "object") throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");
  var e = {};
  this.subscribe = function(t, r, n) {
    if (n = n || !1, typeof t != "string" || typeof r != "function" || typeof n != "boolean") throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");
    e.hasOwnProperty(t) || (e[t] = {});
    var i = Math.random().toString(35);
    return e[t][i] = [r, !!n], i;
  }, this.unsubscribe = function(t) {
    for (var r in e) if (e[r][t]) return delete e[r][t], Object.keys(e[r]).length === 0 && delete e[r], !0;
    return !1;
  }, this.publish = function(t) {
    if (e.hasOwnProperty(t)) {
      var r = Array.prototype.slice.call(arguments, 1), n = [];
      for (var i in e[t]) {
        var a = e[t][i];
        try {
          a[0].apply(o, r);
        } catch (s) {
          Gt.console && Or.error("jsPDF PubSub Error", s.message, s);
        }
        a[1] && n.push(i);
      }
      n.length && n.forEach(this.unsubscribe);
    }
  }, this.getTopics = function() {
    return e;
  };
}
function ql(o) {
  if (!(this instanceof ql)) return new ql(o);
  var e = "opacity,stroke-opacity".split(",");
  for (var t in o) o.hasOwnProperty(t) && e.indexOf(t) >= 0 && (this[t] = o[t]);
  this.id = "", this.objectNumber = -1;
}
function dj(o, e) {
  this.gState = o, this.matrix = e, this.id = "", this.objectNumber = -1;
}
function Es(o, e, t, r, n) {
  if (!(this instanceof Es)) return new Es(o, e, t, r, n);
  this.type = o === "axial" ? 2 : 3, this.coords = e, this.colors = t, dj.call(this, r, n);
}
function Bl(o, e, t, r, n) {
  if (!(this instanceof Bl)) return new Bl(o, e, t, r, n);
  this.boundingBox = o, this.xStep = e, this.yStep = t, this.stream = "", this.cloneIndex = 0, dj.call(this, r, n);
}
function Tt(o) {
  var e, t = typeof arguments[0] == "string" ? arguments[0] : "p", r = arguments[1], n = arguments[2], i = arguments[3], a = [], s = 1, l = 16, c = "S", u = null;
  yr(o = o || {}) === "object" && (t = o.orientation, r = o.unit || r, n = o.format || n, i = o.compress || o.compressPdf || i, (u = o.encryption || null) !== null && (u.userPassword = u.userPassword || "", u.ownerPassword = u.ownerPassword || "", u.userPermissions = u.userPermissions || []), s = typeof o.userUnit == "number" ? Math.abs(o.userUnit) : 1, o.precision !== void 0 && (e = o.precision), o.floatPrecision !== void 0 && (l = o.floatPrecision), c = o.defaultPathOperation || "S"), a = o.filters || (i === !0 ? ["FlateEncode"] : a), r = r || "mm", t = ("" + (t || "P")).toLowerCase();
  var A = o.putOnlyUsedFonts || !1, p = {}, d = { internal: {}, __private__: {} };
  d.__private__.PubSub = zx;
  var g = "1.3", _ = d.__private__.getPdfVersion = function() {
    return g;
  };
  d.__private__.setPdfVersion = function(x) {
    g = x;
  };
  var f = { a0: [2383.94, 3370.39], a1: [1683.78, 2383.94], a2: [1190.55, 1683.78], a3: [841.89, 1190.55], a4: [595.28, 841.89], a5: [419.53, 595.28], a6: [297.64, 419.53], a7: [209.76, 297.64], a8: [147.4, 209.76], a9: [104.88, 147.4], a10: [73.7, 104.88], b0: [2834.65, 4008.19], b1: [2004.09, 2834.65], b2: [1417.32, 2004.09], b3: [1000.63, 1417.32], b4: [708.66, 1000.63], b5: [498.9, 708.66], b6: [354.33, 498.9], b7: [249.45, 354.33], b8: [175.75, 249.45], b9: [124.72, 175.75], b10: [87.87, 124.72], c0: [2599.37, 3676.54], c1: [1836.85, 2599.37], c2: [1298.27, 1836.85], c3: [918.43, 1298.27], c4: [649.13, 918.43], c5: [459.21, 649.13], c6: [323.15, 459.21], c7: [229.61, 323.15], c8: [161.57, 229.61], c9: [113.39, 161.57], c10: [79.37, 113.39], dl: [311.81, 623.62], letter: [612, 792], "government-letter": [576, 756], legal: [612, 1008], "junior-legal": [576, 360], ledger: [1224, 792], tabloid: [792, 1224], "credit-card": [153, 243] };
  d.__private__.getPageFormats = function() {
    return f;
  };
  var m = d.__private__.getPageFormat = function(x) {
    return f[x];
  };
  n = n || "a4";
  var b = "compat", v = "advanced", w = b;
  function C() {
    this.saveGraphicsState(), D(new xt(Ct, 0, 0, -Ct, 0, nl() * Ct).toString() + " cm"), this.setFontSize(this.getFontSize() / Ct), c = "n", w = v;
  }
  function E() {
    this.restoreGraphicsState(), c = "S", w = b;
  }
  var T = d.__private__.combineFontStyleAndFontWeight = function(x, M) {
    if (x == "bold" && M == "normal" || x == "bold" && M == 400 || x == "normal" && M == "italic" || x == "bold" && M == "italic") throw new Error("Invalid Combination of fontweight and fontstyle");
    return M && (x = M == 400 || M === "normal" ? x === "italic" ? "italic" : "normal" : M != 700 && M !== "bold" || x !== "normal" ? (M == 700 ? "bold" : M) + "" + x : "bold"), x;
  };
  d.advancedAPI = function(x) {
    var M = w === b;
    return M && C.call(this), typeof x != "function" || (x(this), M && E.call(this)), this;
  }, d.compatAPI = function(x) {
    var M = w === v;
    return M && E.call(this), typeof x != "function" || (x(this), M && C.call(this)), this;
  }, d.isAdvancedAPI = function() {
    return w === v;
  };
  var F, B = function(x) {
    if (w !== v) throw new Error(x + " is only available in 'advanced' API mode. You need to call advancedAPI() first.");
  }, P = d.roundToPrecision = d.__private__.roundToPrecision = function(x, M) {
    var X = e || M;
    if (isNaN(x) || isNaN(X)) throw new Error("Invalid argument passed to jsPDF.roundToPrecision");
    return x.toFixed(X).replace(/0+$/, "");
  };
  F = d.hpf = d.__private__.hpf = typeof l == "number" ? function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.hpf");
    return P(x, l);
  } : l === "smart" ? function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.hpf");
    return P(x, x > -1 && x < 1 ? 16 : 5);
  } : function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.hpf");
    return P(x, 16);
  };
  var S = d.f2 = d.__private__.f2 = function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.f2");
    return P(x, 2);
  }, L = d.__private__.f3 = function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.f3");
    return P(x, 3);
  }, U = d.scale = d.__private__.scale = function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.scale");
    return w === b ? x * Ct : w === v ? x : void 0;
  }, O = function(x) {
    return U((function(M) {
      return w === b ? nl() - M : w === v ? M : void 0;
    })(x));
  };
  d.__private__.setPrecision = d.setPrecision = function(x) {
    typeof parseInt(x, 10) == "number" && (e = parseInt(x, 10));
  };
  var K, te = "00000000000000000000000000000000", Y = d.__private__.getFileId = function() {
    return te;
  }, ee = d.__private__.setFileId = function(x) {
    return te = x !== void 0 && /^[a-fA-F0-9]{32}$/.test(x) ? x.toUpperCase() : te.split("").map(function() {
      return "ABCDEF0123456789".charAt(Math.floor(16 * Math.random()));
    }).join(""), u !== null && (Go = new kc(u.userPermissions, u.userPassword, u.ownerPassword, te)), te;
  };
  d.setFileId = function(x) {
    return ee(x), this;
  }, d.getFileId = function() {
    return Y();
  };
  var oe = d.__private__.convertDateToPDFDate = function(x) {
    var M = x.getTimezoneOffset(), X = M < 0 ? "+" : "-", ie = Math.floor(Math.abs(M / 60)), he = Math.abs(M % 60), Ee = [X, H(ie), "'", H(he), "'"].join("");
    return ["D:", x.getFullYear(), H(x.getMonth() + 1), H(x.getDate()), H(x.getHours()), H(x.getMinutes()), H(x.getSeconds()), Ee].join("");
  }, de = d.__private__.convertPDFDateToDate = function(x) {
    var M = parseInt(x.substr(2, 4), 10), X = parseInt(x.substr(6, 2), 10) - 1, ie = parseInt(x.substr(8, 2), 10), he = parseInt(x.substr(10, 2), 10), Ee = parseInt(x.substr(12, 2), 10), Re = parseInt(x.substr(14, 2), 10);
    return new Date(M, X, ie, he, Ee, Re, 0);
  }, ae = d.__private__.setCreationDate = function(x) {
    var M;
    if (x === void 0 && (x = /* @__PURE__ */ new Date()), x instanceof Date) M = oe(x);
    else {
      if (!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(x)) throw new Error("Invalid argument passed to jsPDF.setCreationDate");
      M = x;
    }
    return K = M;
  }, I = d.__private__.getCreationDate = function(x) {
    var M = K;
    return x === "jsDate" && (M = de(K)), M;
  };
  d.setCreationDate = function(x) {
    return ae(x), this;
  }, d.getCreationDate = function(x) {
    return I(x);
  };
  var G, H = d.__private__.padd2 = function(x) {
    return ("0" + parseInt(x)).slice(-2);
  }, Z = d.__private__.padd2Hex = function(x) {
    return ("00" + (x = x.toString())).substr(x.length);
  }, ne = 0, le = [], me = [], ce = 0, ye = [], Ce = [], Ue = !1, Qe = me;
  d.__private__.setCustomOutputDestination = function(x) {
    Ue = !0, Qe = x;
  };
  var Xe = function(x) {
    Ue || (Qe = x);
  };
  d.__private__.resetCustomOutputDestination = function() {
    Ue = !1, Qe = me;
  };
  var D = d.__private__.out = function(x) {
    return x = x.toString(), ce += x.length + 1, Qe.push(x), Qe;
  }, Ne = d.__private__.write = function(x) {
    return D(arguments.length === 1 ? x.toString() : Array.prototype.join.call(arguments, " "));
  }, ct = d.__private__.getArrayBuffer = function(x) {
    for (var M = x.length, X = new ArrayBuffer(M), ie = new Uint8Array(X); M--; ) ie[M] = x.charCodeAt(M);
    return X;
  }, ot = [["Helvetica", "helvetica", "normal", "WinAnsiEncoding"], ["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"], ["Helvetica-Oblique", "helvetica", "italic", "WinAnsiEncoding"], ["Helvetica-BoldOblique", "helvetica", "bolditalic", "WinAnsiEncoding"], ["Courier", "courier", "normal", "WinAnsiEncoding"], ["Courier-Bold", "courier", "bold", "WinAnsiEncoding"], ["Courier-Oblique", "courier", "italic", "WinAnsiEncoding"], ["Courier-BoldOblique", "courier", "bolditalic", "WinAnsiEncoding"], ["Times-Roman", "times", "normal", "WinAnsiEncoding"], ["Times-Bold", "times", "bold", "WinAnsiEncoding"], ["Times-Italic", "times", "italic", "WinAnsiEncoding"], ["Times-BoldItalic", "times", "bolditalic", "WinAnsiEncoding"], ["ZapfDingbats", "zapfdingbats", "normal", null], ["Symbol", "symbol", "normal", null]];
  d.__private__.getStandardFonts = function() {
    return ot;
  };
  var Be = o.fontSize || 16;
  d.__private__.setFontSize = d.setFontSize = function(x) {
    return Be = w === v ? x / Ct : x, this;
  };
  var et, Le = d.__private__.getFontSize = d.getFontSize = function() {
    return w === b ? Be : Be * Ct;
  }, Fe = o.R2L || !1;
  d.__private__.setR2L = d.setR2L = function(x) {
    return Fe = x, this;
  }, d.__private__.getR2L = d.getR2L = function() {
    return Fe;
  };
  var tt, we = d.__private__.setZoomMode = function(x) {
    if (/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(x)) et = x;
    else if (isNaN(x)) {
      if ([void 0, null, "fullwidth", "fullheight", "fullpage", "original"].indexOf(x) === -1) throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "' + x + '" is not recognized.');
      et = x;
    } else et = parseInt(x, 10);
  };
  d.__private__.getZoomMode = function() {
    return et;
  };
  var Ge, ze = d.__private__.setPageMode = function(x) {
    if ([void 0, null, "UseNone", "UseOutlines", "UseThumbs", "FullScreen"].indexOf(x) == -1) throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "' + x + '" is not recognized.');
    tt = x;
  };
  d.__private__.getPageMode = function() {
    return tt;
  };
  var Ze = d.__private__.setLayoutMode = function(x) {
    if ([void 0, null, "continuous", "single", "twoleft", "tworight", "two"].indexOf(x) == -1) throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "' + x + '" is not recognized.');
    Ge = x;
  };
  d.__private__.getLayoutMode = function() {
    return Ge;
  }, d.__private__.setDisplayMode = d.setDisplayMode = function(x, M, X) {
    return we(x), Ze(M), ze(X), this;
  };
  var ht = { title: "", subject: "", author: "", keywords: "", creator: "" };
  d.__private__.getDocumentProperty = function(x) {
    if (Object.keys(ht).indexOf(x) === -1) throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");
    return ht[x];
  }, d.__private__.getDocumentProperties = function() {
    return ht;
  }, d.__private__.setDocumentProperties = d.setProperties = d.setDocumentProperties = function(x) {
    for (var M in ht) ht.hasOwnProperty(M) && x[M] && (ht[M] = x[M]);
    return this;
  }, d.__private__.setDocumentProperty = function(x, M) {
    if (Object.keys(ht).indexOf(x) === -1) throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");
    return ht[x] = M;
  };
  var rt, Ct, it, Kt, ve, J = {}, ge = {}, We = [], nt = {}, rr = {}, _t = {}, wt = {}, or = null, mt = 0, Nt = [], Bt = new zx(d), ur = o.hotfixes || [], vr = {}, Kr = {}, To = [], xt = function x(M, X, ie, he, Ee, Re) {
    if (!(this instanceof x)) return new x(M, X, ie, he, Ee, Re);
    isNaN(M) && (M = 1), isNaN(X) && (X = 0), isNaN(ie) && (ie = 0), isNaN(he) && (he = 1), isNaN(Ee) && (Ee = 0), isNaN(Re) && (Re = 0), this._matrix = [M, X, ie, he, Ee, Re];
  };
  Object.defineProperty(xt.prototype, "sx", { get: function() {
    return this._matrix[0];
  }, set: function(x) {
    this._matrix[0] = x;
  } }), Object.defineProperty(xt.prototype, "shy", { get: function() {
    return this._matrix[1];
  }, set: function(x) {
    this._matrix[1] = x;
  } }), Object.defineProperty(xt.prototype, "shx", { get: function() {
    return this._matrix[2];
  }, set: function(x) {
    this._matrix[2] = x;
  } }), Object.defineProperty(xt.prototype, "sy", { get: function() {
    return this._matrix[3];
  }, set: function(x) {
    this._matrix[3] = x;
  } }), Object.defineProperty(xt.prototype, "tx", { get: function() {
    return this._matrix[4];
  }, set: function(x) {
    this._matrix[4] = x;
  } }), Object.defineProperty(xt.prototype, "ty", { get: function() {
    return this._matrix[5];
  }, set: function(x) {
    this._matrix[5] = x;
  } }), Object.defineProperty(xt.prototype, "a", { get: function() {
    return this._matrix[0];
  }, set: function(x) {
    this._matrix[0] = x;
  } }), Object.defineProperty(xt.prototype, "b", { get: function() {
    return this._matrix[1];
  }, set: function(x) {
    this._matrix[1] = x;
  } }), Object.defineProperty(xt.prototype, "c", { get: function() {
    return this._matrix[2];
  }, set: function(x) {
    this._matrix[2] = x;
  } }), Object.defineProperty(xt.prototype, "d", { get: function() {
    return this._matrix[3];
  }, set: function(x) {
    this._matrix[3] = x;
  } }), Object.defineProperty(xt.prototype, "e", { get: function() {
    return this._matrix[4];
  }, set: function(x) {
    this._matrix[4] = x;
  } }), Object.defineProperty(xt.prototype, "f", { get: function() {
    return this._matrix[5];
  }, set: function(x) {
    this._matrix[5] = x;
  } }), Object.defineProperty(xt.prototype, "rotation", { get: function() {
    return Math.atan2(this.shx, this.sx);
  } }), Object.defineProperty(xt.prototype, "scaleX", { get: function() {
    return this.decompose().scale.sx;
  } }), Object.defineProperty(xt.prototype, "scaleY", { get: function() {
    return this.decompose().scale.sy;
  } }), Object.defineProperty(xt.prototype, "isIdentity", { get: function() {
    return this.sx === 1 && this.shy === 0 && this.shx === 0 && this.sy === 1 && this.tx === 0 && this.ty === 0;
  } }), xt.prototype.join = function(x) {
    return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty].map(F).join(x);
  }, xt.prototype.multiply = function(x) {
    var M = x.sx * this.sx + x.shy * this.shx, X = x.sx * this.shy + x.shy * this.sy, ie = x.shx * this.sx + x.sy * this.shx, he = x.shx * this.shy + x.sy * this.sy, Ee = x.tx * this.sx + x.ty * this.shx + this.tx, Re = x.tx * this.shy + x.ty * this.sy + this.ty;
    return new xt(M, X, ie, he, Ee, Re);
  }, xt.prototype.decompose = function() {
    var x = this.sx, M = this.shy, X = this.shx, ie = this.sy, he = this.tx, Ee = this.ty, Re = Math.sqrt(x * x + M * M), St = (x /= Re) * X + (M /= Re) * ie;
    X -= x * St, ie -= M * St;
    var Pt = Math.sqrt(X * X + ie * ie);
    return St /= Pt, x * (ie /= Pt) < M * (X /= Pt) && (x = -x, M = -M, St = -St, Re = -Re), { scale: new xt(Re, 0, 0, Pt, 0, 0), translate: new xt(1, 0, 0, 1, he, Ee), rotate: new xt(x, M, -M, x, 0, 0), skew: new xt(1, 0, St, 1, 0, 0) };
  }, xt.prototype.toString = function(x) {
    return this.join(" ");
  }, xt.prototype.inversed = function() {
    var x = this.sx, M = this.shy, X = this.shx, ie = this.sy, he = this.tx, Ee = this.ty, Re = 1 / (x * ie - M * X), St = ie * Re, Pt = -M * Re, Vt = -X * Re, Zt = x * Re;
    return new xt(St, Pt, Vt, Zt, -St * he - Vt * Ee, -Pt * he - Zt * Ee);
  }, xt.prototype.applyToPoint = function(x) {
    var M = x.x * this.sx + x.y * this.shx + this.tx, X = x.x * this.shy + x.y * this.sy + this.ty;
    return new ya(M, X);
  }, xt.prototype.applyToRectangle = function(x) {
    var M = this.applyToPoint(x), X = this.applyToPoint(new ya(x.x + x.w, x.y + x.h));
    return new du(M.x, M.y, X.x - M.x, X.y - M.y);
  }, xt.prototype.clone = function() {
    var x = this.sx, M = this.shy, X = this.shx, ie = this.sy, he = this.tx, Ee = this.ty;
    return new xt(x, M, X, ie, he, Ee);
  }, d.Matrix = xt;
  var Qo = d.matrixMult = function(x, M) {
    return M.multiply(x);
  }, qo = new xt(1, 0, 0, 1, 0, 0);
  d.unitMatrix = d.identityMatrix = qo;
  var Xo = function(x, M) {
    if (!rr[x]) {
      var X = (M instanceof Es ? "Sh" : "P") + (Object.keys(nt).length + 1).toString(10);
      M.id = X, rr[x] = X, nt[X] = M, Bt.publish("addPattern", M);
    }
  };
  d.ShadingPattern = Es, d.TilingPattern = Bl, d.addShadingPattern = function(x, M) {
    return B("addShadingPattern()"), Xo(x, M), this;
  }, d.beginTilingPattern = function(x) {
    B("beginTilingPattern()"), pu(x.boundingBox[0], x.boundingBox[1], x.boundingBox[2] - x.boundingBox[0], x.boundingBox[3] - x.boundingBox[1], x.matrix);
  }, d.endTilingPattern = function(x, M) {
    B("endTilingPattern()"), M.stream = Ce[G].join(`
`), Xo(x, M), Bt.publish("endTilingPattern", M), To.pop().restore();
  };
  var lo, jr = d.__private__.newObject = function() {
    var x = Ir();
    return Ie(x, !0), x;
  }, Ir = d.__private__.newObjectDeferred = function() {
    return ne++, le[ne] = function() {
      return ce;
    }, ne;
  }, Ie = function(x, M) {
    return M = typeof M == "boolean" && M, le[x] = ce, M && D(x + " 0 obj"), x;
  }, gt = d.__private__.newAdditionalObject = function() {
    var x = { objId: Ir(), content: "" };
    return ye.push(x), x;
  }, dt = Ir(), Me = Ir(), Ht = d.__private__.decodeColorString = function(x) {
    var M = x.split(" ");
    if (M.length !== 2 || M[1] !== "g" && M[1] !== "G") M.length !== 5 || M[4] !== "k" && M[4] !== "K" || (M = [(1 - M[0]) * (1 - M[3]), (1 - M[1]) * (1 - M[3]), (1 - M[2]) * (1 - M[3]), "r"]);
    else {
      var X = parseFloat(M[0]);
      M = [X, X, X, "r"];
    }
    for (var ie = "#", he = 0; he < 3; he++) ie += ("0" + Math.floor(255 * parseFloat(M[he])).toString(16)).slice(-2);
    return ie;
  }, Ot = d.__private__.encodeColorString = function(x) {
    var M;
    typeof x == "string" && (x = { ch1: x });
    var X = x.ch1, ie = x.ch2, he = x.ch3, Ee = x.ch4, Re = x.pdfColorType === "draw" ? ["G", "RG", "K"] : ["g", "rg", "k"];
    if (typeof X == "string" && X.charAt(0) !== "#") {
      var St = new uj(X);
      if (St.ok) X = St.toHex();
      else if (!/^\d*\.?\d*$/.test(X)) throw new Error('Invalid color "' + X + '" passed to jsPDF.encodeColorString.');
    }
    if (typeof X == "string" && /^#[0-9A-Fa-f]{3}$/.test(X) && (X = "#" + X[1] + X[1] + X[2] + X[2] + X[3] + X[3]), typeof X == "string" && /^#[0-9A-Fa-f]{6}$/.test(X)) {
      var Pt = parseInt(X.substr(1), 16);
      X = Pt >> 16 & 255, ie = Pt >> 8 & 255, he = 255 & Pt;
    }
    if (ie === void 0 || Ee === void 0 && X === ie && ie === he) M = typeof X == "string" ? X + " " + Re[0] : x.precision === 2 ? S(X / 255) + " " + Re[0] : L(X / 255) + " " + Re[0];
    else if (Ee === void 0 || yr(Ee) === "object") {
      if (Ee && !isNaN(Ee.a) && Ee.a === 0) return ["1.", "1.", "1.", Re[1]].join(" ");
      M = typeof X == "string" ? [X, ie, he, Re[1]].join(" ") : x.precision === 2 ? [S(X / 255), S(ie / 255), S(he / 255), Re[1]].join(" ") : [L(X / 255), L(ie / 255), L(he / 255), Re[1]].join(" ");
    } else M = typeof X == "string" ? [X, ie, he, Ee, Re[2]].join(" ") : x.precision === 2 ? [S(X), S(ie), S(he), S(Ee), Re[2]].join(" ") : [L(X), L(ie), L(he), L(Ee), Re[2]].join(" ");
    return M;
  }, qt = d.__private__.getFilters = function() {
    return a;
  }, Zr = d.__private__.putStream = function(x) {
    var M = (x = x || {}).data || "", X = x.filters || qt(), ie = x.alreadyAppliedFilters || [], he = x.addLength1 || !1, Ee = M.length, Re = x.objectId, St = function(Do) {
      return Do;
    };
    if (u !== null && Re === void 0) throw new Error("ObjectId must be passed to putStream for file encryption");
    u !== null && (St = Go.encryptor(Re, 0));
    var Pt = {};
    X === !0 && (X = ["FlateEncode"]);
    var Vt = x.additionalKeyValues || [], Zt = (Pt = Tt.API.processDataByFilters !== void 0 ? Tt.API.processDataByFilters(M, X) : { data: M, reverseChain: [] }).reverseChain + (Array.isArray(ie) ? ie.join(" ") : ie.toString());
    if (Pt.data.length !== 0 && (Vt.push({ key: "Length", value: Pt.data.length }), he === !0 && Vt.push({ key: "Length1", value: Ee })), Zt.length != 0) if (Zt.split("/").length - 1 == 1) Vt.push({ key: "Filter", value: Zt });
    else {
      Vt.push({ key: "Filter", value: "[" + Zt + "]" });
      for (var gr = 0; gr < Vt.length; gr += 1) if (Vt[gr].key === "DecodeParms") {
        for (var ao = [], Vo = 0; Vo < Pt.reverseChain.split("/").length - 1; Vo += 1) ao.push("null");
        ao.push(Vt[gr].value), Vt[gr].value = "[" + ao.join(" ") + "]";
      }
    }
    D("<<");
    for (var Gr = 0; Gr < Vt.length; Gr++) D("/" + Vt[Gr].key + " " + Vt[Gr].value);
    D(">>"), Pt.data.length !== 0 && (D("stream"), D(St(Pt.data)), D("endstream"));
  }, $r = d.__private__.putPage = function(x) {
    var M = x.number, X = x.data, ie = x.objId, he = x.contentsObjId;
    Ie(ie, !0), D("<</Type /Page"), D("/Parent " + x.rootDictionaryObjId + " 0 R"), D("/Resources " + x.resourceDictionaryObjId + " 0 R"), D("/MediaBox [" + parseFloat(F(x.mediaBox.bottomLeftX)) + " " + parseFloat(F(x.mediaBox.bottomLeftY)) + " " + F(x.mediaBox.topRightX) + " " + F(x.mediaBox.topRightY) + "]"), x.cropBox !== null && D("/CropBox [" + F(x.cropBox.bottomLeftX) + " " + F(x.cropBox.bottomLeftY) + " " + F(x.cropBox.topRightX) + " " + F(x.cropBox.topRightY) + "]"), x.bleedBox !== null && D("/BleedBox [" + F(x.bleedBox.bottomLeftX) + " " + F(x.bleedBox.bottomLeftY) + " " + F(x.bleedBox.topRightX) + " " + F(x.bleedBox.topRightY) + "]"), x.trimBox !== null && D("/TrimBox [" + F(x.trimBox.bottomLeftX) + " " + F(x.trimBox.bottomLeftY) + " " + F(x.trimBox.topRightX) + " " + F(x.trimBox.topRightY) + "]"), x.artBox !== null && D("/ArtBox [" + F(x.artBox.bottomLeftX) + " " + F(x.artBox.bottomLeftY) + " " + F(x.artBox.topRightX) + " " + F(x.artBox.topRightY) + "]"), typeof x.userUnit == "number" && x.userUnit !== 1 && D("/UserUnit " + x.userUnit), Bt.publish("putPage", { objId: ie, pageContext: Nt[M], pageNumber: M, page: X }), D("/Contents " + he + " 0 R"), D(">>"), D("endobj");
    var Ee = X.join(`
`);
    return w === v && (Ee += `
Q`), Ie(he, !0), Zr({ data: Ee, filters: qt(), objectId: he }), D("endobj"), ie;
  }, re = d.__private__.putPages = function() {
    var x, M, X = [];
    for (x = 1; x <= mt; x++) Nt[x].objId = Ir(), Nt[x].contentsObjId = Ir();
    for (x = 1; x <= mt; x++) X.push($r({ number: x, data: Ce[x], objId: Nt[x].objId, contentsObjId: Nt[x].contentsObjId, mediaBox: Nt[x].mediaBox, cropBox: Nt[x].cropBox, bleedBox: Nt[x].bleedBox, trimBox: Nt[x].trimBox, artBox: Nt[x].artBox, userUnit: Nt[x].userUnit, rootDictionaryObjId: dt, resourceDictionaryObjId: Me }));
    Ie(dt, !0), D("<</Type /Pages");
    var ie = "/Kids [";
    for (M = 0; M < mt; M++) ie += X[M] + " 0 R ";
    D(ie + "]"), D("/Count " + mt), D(">>"), D("endobj"), Bt.publish("postPutPages");
  }, Ke = function(x) {
    Bt.publish("putFont", { font: x, out: D, newObject: jr, putStream: Zr }), x.isAlreadyPutted !== !0 && (x.objectNumber = jr(), D("<<"), D("/Type /Font"), D("/BaseFont /" + Cc(x.postScriptName)), D("/Subtype /Type1"), typeof x.encoding == "string" && D("/Encoding /" + x.encoding), D("/FirstChar 32"), D("/LastChar 255"), D(">>"), D("endobj"));
  }, He = function(x) {
    x.objectNumber = jr();
    var M = [];
    M.push({ key: "Type", value: "/XObject" }), M.push({ key: "Subtype", value: "/Form" }), M.push({ key: "BBox", value: "[" + [F(x.x), F(x.y), F(x.x + x.width), F(x.y + x.height)].join(" ") + "]" }), M.push({ key: "Matrix", value: "[" + x.matrix.toString() + "]" });
    var X = x.pages[1].join(`
`);
    Zr({ data: X, additionalKeyValues: M, objectId: x.objectNumber }), D("endobj");
  }, $t = function(x, M) {
    M || (M = 21);
    var X = jr(), ie = (function(Re, St) {
      var Pt, Vt = [], Zt = 1 / (St - 1);
      for (Pt = 0; Pt < 1; Pt += Zt) Vt.push(Pt);
      if (Vt.push(1), Re[0].offset != 0) {
        var gr = { offset: 0, color: Re[0].color };
        Re.unshift(gr);
      }
      if (Re[Re.length - 1].offset != 1) {
        var ao = { offset: 1, color: Re[Re.length - 1].color };
        Re.push(ao);
      }
      for (var Vo = "", Gr = 0, Do = 0; Do < Vt.length; Do++) {
        for (Pt = Vt[Do]; Pt > Re[Gr + 1].offset; ) Gr++;
        var Uo = Re[Gr].offset, on = (Pt - Uo) / (Re[Gr + 1].offset - Uo), wa = Re[Gr].color, Ci = Re[Gr + 1].color;
        Vo += Z(Math.round((1 - on) * wa[0] + on * Ci[0]).toString(16)) + Z(Math.round((1 - on) * wa[1] + on * Ci[1]).toString(16)) + Z(Math.round((1 - on) * wa[2] + on * Ci[2]).toString(16));
      }
      return Vo.trim();
    })(x.colors, M), he = [];
    he.push({ key: "FunctionType", value: "0" }), he.push({ key: "Domain", value: "[0.0 1.0]" }), he.push({ key: "Size", value: "[" + M + "]" }), he.push({ key: "BitsPerSample", value: "8" }), he.push({ key: "Range", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" }), he.push({ key: "Decode", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" }), Zr({ data: ie, additionalKeyValues: he, alreadyAppliedFilters: ["/ASCIIHexDecode"], objectId: X }), D("endobj"), x.objectNumber = jr(), D("<< /ShadingType " + x.type), D("/ColorSpace /DeviceRGB");
    var Ee = "/Coords [" + F(parseFloat(x.coords[0])) + " " + F(parseFloat(x.coords[1])) + " ";
    x.type === 2 ? Ee += F(parseFloat(x.coords[2])) + " " + F(parseFloat(x.coords[3])) : Ee += F(parseFloat(x.coords[2])) + " " + F(parseFloat(x.coords[3])) + " " + F(parseFloat(x.coords[4])) + " " + F(parseFloat(x.coords[5])), D(Ee += "]"), x.matrix && D("/Matrix [" + x.matrix.toString() + "]"), D("/Function " + X + " 0 R"), D("/Extend [true true]"), D(">>"), D("endobj");
  }, dr = function(x, M) {
    var X = Ir(), ie = jr();
    M.push({ resourcesOid: X, objectOid: ie }), x.objectNumber = ie;
    var he = [];
    he.push({ key: "Type", value: "/Pattern" }), he.push({ key: "PatternType", value: "1" }), he.push({ key: "PaintType", value: "1" }), he.push({ key: "TilingType", value: "1" }), he.push({ key: "BBox", value: "[" + x.boundingBox.map(F).join(" ") + "]" }), he.push({ key: "XStep", value: F(x.xStep) }), he.push({ key: "YStep", value: F(x.yStep) }), he.push({ key: "Resources", value: X + " 0 R" }), x.matrix && he.push({ key: "Matrix", value: "[" + x.matrix.toString() + "]" }), Zr({ data: x.stream, additionalKeyValues: he, objectId: x.objectNumber }), D("endobj");
  }, Pr = function(x) {
    for (var M in x.objectNumber = jr(), D("<<"), x) switch (M) {
      case "opacity":
        D("/ca " + S(x[M]));
        break;
      case "stroke-opacity":
        D("/CA " + S(x[M]));
    }
    D(">>"), D("endobj");
  }, Po = function(x) {
    Ie(x.resourcesOid, !0), D("<<"), D("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"), (function() {
      for (var M in D("/Font <<"), J) J.hasOwnProperty(M) && (A === !1 || A === !0 && p.hasOwnProperty(M)) && D("/" + M + " " + J[M].objectNumber + " 0 R");
      D(">>");
    })(), (function() {
      if (Object.keys(nt).length > 0) {
        for (var M in D("/Shading <<"), nt) nt.hasOwnProperty(M) && nt[M] instanceof Es && nt[M].objectNumber >= 0 && D("/" + M + " " + nt[M].objectNumber + " 0 R");
        Bt.publish("putShadingPatternDict"), D(">>");
      }
    })(), (function(M) {
      if (Object.keys(nt).length > 0) {
        for (var X in D("/Pattern <<"), nt) nt.hasOwnProperty(X) && nt[X] instanceof d.TilingPattern && nt[X].objectNumber >= 0 && nt[X].objectNumber < M && D("/" + X + " " + nt[X].objectNumber + " 0 R");
        Bt.publish("putTilingPatternDict"), D(">>");
      }
    })(x.objectOid), (function() {
      if (Object.keys(_t).length > 0) {
        var M;
        for (M in D("/ExtGState <<"), _t) _t.hasOwnProperty(M) && _t[M].objectNumber >= 0 && D("/" + M + " " + _t[M].objectNumber + " 0 R");
        Bt.publish("putGStateDict"), D(">>");
      }
    })(), (function() {
      for (var M in D("/XObject <<"), vr) vr.hasOwnProperty(M) && vr[M].objectNumber >= 0 && D("/" + M + " " + vr[M].objectNumber + " 0 R");
      Bt.publish("putXobjectDict"), D(">>");
    })(), D(">>"), D("endobj");
  }, rn = function(x) {
    ge[x.fontName] = ge[x.fontName] || {}, ge[x.fontName][x.fontStyle] = x.id;
  }, Sn = function(x, M, X, ie, he) {
    var Ee = { id: "F" + (Object.keys(J).length + 1).toString(10), postScriptName: x, fontName: M, fontStyle: X, encoding: ie, isStandardFont: he || !1, metadata: {} };
    return Bt.publish("addFont", { font: Ee, instance: this }), J[Ee.id] = Ee, rn(Ee), Ee.id;
  }, Fr = d.__private__.pdfEscape = d.pdfEscape = function(x, M) {
    return (function(X, ie) {
      var he, Ee, Re, St, Pt, Vt, Zt, gr, ao;
      if (Re = (ie = ie || {}).sourceEncoding || "Unicode", Pt = ie.outputEncoding, (ie.autoencode || Pt) && J[rt].metadata && J[rt].metadata[Re] && J[rt].metadata[Re].encoding && (St = J[rt].metadata[Re].encoding, !Pt && J[rt].encoding && (Pt = J[rt].encoding), !Pt && St.codePages && (Pt = St.codePages[0]), typeof Pt == "string" && (Pt = St[Pt]), Pt)) {
        for (Zt = !1, Vt = [], he = 0, Ee = X.length; he < Ee; he++) (gr = Pt[X.charCodeAt(he)]) ? Vt.push(String.fromCharCode(gr)) : Vt.push(X[he]), Vt[he].charCodeAt(0) >> 8 && (Zt = !0);
        X = Vt.join("");
      }
      for (he = X.length; Zt === void 0 && he !== 0; ) X.charCodeAt(he - 1) >> 8 && (Zt = !0), he--;
      if (!Zt) return X;
      for (Vt = ie.noBOM ? [] : [254, 255], he = 0, Ee = X.length; he < Ee; he++) {
        if ((ao = (gr = X.charCodeAt(he)) >> 8) >> 8) throw new Error("Character at position " + he + " of string '" + X + "' exceeds 16bits. Cannot be encoded into UCS-2 BE");
        Vt.push(ao), Vt.push(gr - (ao << 8));
      }
      return String.fromCharCode.apply(void 0, Vt);
    })(x, M).replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)");
  }, os = d.__private__.beginPage = function(x) {
    Ce[++mt] = [], Nt[mt] = { objId: 0, contentsObjId: 0, userUnit: Number(s), artBox: null, bleedBox: null, cropBox: null, trimBox: null, mediaBox: { bottomLeftX: 0, bottomLeftY: 0, topRightX: Number(x[0]), topRightY: Number(x[1]) } }, fd(mt), Xe(Ce[G]);
  }, Xl = function(x, M) {
    var X, ie, he;
    switch (t = M || t, typeof x == "string" && (X = m(x.toLowerCase()), Array.isArray(X) && (ie = X[0], he = X[1])), Array.isArray(x) && (ie = x[0] * Ct, he = x[1] * Ct), isNaN(ie) && (ie = n[0], he = n[1]), (ie > 14400 || he > 14400) && (Or.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"), ie = Math.min(14400, ie), he = Math.min(14400, he)), n = [ie, he], t.substr(0, 1)) {
      case "l":
        he > ie && (n = [he, ie]);
        break;
      case "p":
        ie > he && (n = [he, ie]);
    }
    os(n), zt(lu), D(ec), uu !== 0 && D(uu + " J"), Au !== 0 && D(Au + " j"), Bt.publish("addPage", { pageNumber: mt });
  }, au = function(x) {
    x > 0 && x <= mt && (Ce.splice(x, 1), Nt.splice(x, 1), mt--, G > mt && (G = mt), this.setPage(G));
  }, fd = function(x) {
    x > 0 && x <= mt && (G = x);
  }, md = d.__private__.getNumberOfPages = d.getNumberOfPages = function() {
    return Ce.length - 1;
  }, yd = function(x, M, X) {
    var ie, he = void 0;
    return X = X || {}, x = x !== void 0 ? x : J[rt].fontName, M = M !== void 0 ? M : J[rt].fontStyle, ie = x.toLowerCase(), ge[ie] !== void 0 && ge[ie][M] !== void 0 ? he = ge[ie][M] : ge[x] !== void 0 && ge[x][M] !== void 0 ? he = ge[x][M] : X.disableWarning === !1 && Or.warn("Unable to look up font label for font '" + x + "', '" + M + "'. Refer to getFontList() for available fonts."), he || X.noFallback || (he = ge.times[M]) == null && (he = ge.times.normal), he;
  }, Wi = d.__private__.putInfo = function() {
    var x = jr(), M = function(ie) {
      return ie;
    };
    for (var X in u !== null && (M = Go.encryptor(x, 0)), D("<<"), D("/Producer (" + Fr(M("jsPDF " + Tt.version)) + ")"), ht) ht.hasOwnProperty(X) && ht[X] && D("/" + X.substr(0, 1).toUpperCase() + X.substr(1) + " (" + Fr(M(ht[X])) + ")");
    D("/CreationDate (" + Fr(M(K)) + ")"), D(">>"), D("endobj");
  }, Yl = d.__private__.putCatalog = function(x) {
    var M = (x = x || {}).rootDictionaryObjId || dt;
    switch (jr(), D("<<"), D("/Type /Catalog"), D("/Pages " + M + " 0 R"), et || (et = "fullwidth"), et) {
      case "fullwidth":
        D("/OpenAction [3 0 R /FitH null]");
        break;
      case "fullheight":
        D("/OpenAction [3 0 R /FitV null]");
        break;
      case "fullpage":
        D("/OpenAction [3 0 R /Fit]");
        break;
      case "original":
        D("/OpenAction [3 0 R /XYZ null null 1]");
        break;
      default:
        var X = "" + et;
        X.substr(X.length - 1) === "%" && (et = parseInt(et) / 100), typeof et == "number" && D("/OpenAction [3 0 R /XYZ null null " + S(et) + "]");
    }
    switch (Ge || (Ge = "continuous"), Ge) {
      case "continuous":
        D("/PageLayout /OneColumn");
        break;
      case "single":
        D("/PageLayout /SinglePage");
        break;
      case "two":
      case "twoleft":
        D("/PageLayout /TwoColumnLeft");
        break;
      case "tworight":
        D("/PageLayout /TwoColumnRight");
    }
    tt && D("/PageMode /" + tt), Bt.publish("putCatalog"), D(">>"), D("endobj");
  }, kg = d.__private__.putTrailer = function() {
    D("trailer"), D("<<"), D("/Size " + (ne + 1)), D("/Root " + ne + " 0 R"), D("/Info " + (ne - 1) + " 0 R"), u !== null && D("/Encrypt " + Go.oid + " 0 R"), D("/ID [ <" + te + "> <" + te + "> ]"), D(">>");
  }, Fo = d.__private__.putHeader = function() {
    D("%PDF-" + g), D("%ºß¬à");
  }, bd = d.__private__.putXRef = function() {
    var x = "0000000000";
    D("xref"), D("0 " + (ne + 1)), D("0000000000 65535 f ");
    for (var M = 1; M <= ne; M++) typeof le[M] == "function" ? D((x + le[M]()).slice(-10) + " 00000 n ") : le[M] !== void 0 ? D((x + le[M]).slice(-10) + " 00000 n ") : D("0000000000 00000 n ");
  }, Xi = d.__private__.buildDocument = function() {
    var x;
    ne = 0, ce = 0, me = [], le = [], ye = [], dt = Ir(), Me = Ir(), Xe(me), Bt.publish("buildDocument"), Fo(), re(), (function() {
      Bt.publish("putAdditionalObjects");
      for (var X = 0; X < ye.length; X++) {
        var ie = ye[X];
        Ie(ie.objId, !0), D(ie.content), D("endobj");
      }
      Bt.publish("postPutAdditionalObjects");
    })(), x = [], (function() {
      for (var X in J) J.hasOwnProperty(X) && (A === !1 || A === !0 && p.hasOwnProperty(X)) && Ke(J[X]);
    })(), (function() {
      var X;
      for (X in _t) _t.hasOwnProperty(X) && Pr(_t[X]);
    })(), (function() {
      for (var X in vr) vr.hasOwnProperty(X) && He(vr[X]);
    })(), (function(X) {
      var ie;
      for (ie in nt) nt.hasOwnProperty(ie) && (nt[ie] instanceof Es ? $t(nt[ie]) : nt[ie] instanceof Bl && dr(nt[ie], X));
    })(x), Bt.publish("putResources"), x.forEach(Po), Po({ resourcesOid: Me, objectOid: Number.MAX_SAFE_INTEGER }), Bt.publish("postPutResources"), u !== null && (Go.oid = jr(), D("<<"), D("/Filter /Standard"), D("/V " + Go.v), D("/R " + Go.r), D("/U <" + Go.toHexString(Go.U) + ">"), D("/O <" + Go.toHexString(Go.O) + ">"), D("/P " + Go.P), D(">>"), D("endobj")), Wi(), Yl();
    var M = ce;
    return bd(), kg(), D("startxref"), D("" + M), D("%%EOF"), Xe(Ce[G]), me.join(`
`);
  }, Zl = d.__private__.getBlob = function(x) {
    return new Blob([ct(x)], { type: "application/pdf" });
  }, vd = d.output = d.__private__.output = (lo = function(x, M) {
    switch (typeof (M = M || {}) == "string" ? M = { filename: M } : M.filename = M.filename || "generated.pdf", x) {
      case void 0:
        return Xi();
      case "save":
        d.save(M.filename);
        break;
      case "arraybuffer":
        return ct(Xi());
      case "blob":
        return Zl(Xi());
      case "bloburi":
      case "bloburl":
        if (Gt.URL !== void 0 && typeof Gt.URL.createObjectURL == "function") return Gt.URL && Gt.URL.createObjectURL(Zl(Xi())) || void 0;
        Or.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.");
        break;
      case "datauristring":
      case "dataurlstring":
        var X = "", ie = Xi();
        try {
          X = Vx(ie);
        } catch {
          X = Vx(unescape(encodeURIComponent(ie)));
        }
        return "data:application/pdf;filename=" + M.filename + ";base64," + X;
      case "pdfobjectnewwindow":
        if (Object.prototype.toString.call(Gt) === "[object Window]") {
          var he = "https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js", Ee = ' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';
          M.pdfObjectUrl && (he = M.pdfObjectUrl, Ee = "");
          var Re = '<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style><body><script src="' + he + '"' + Ee + '><\/script><script >PDFObject.embed("' + this.output("dataurlstring") + '", ' + JSON.stringify(M) + ");<\/script></body></html>", St = Gt.open();
          return St !== null && St.document.write(Re), St;
        }
        throw new Error("The option pdfobjectnewwindow just works in a browser-environment.");
      case "pdfjsnewwindow":
        if (Object.prototype.toString.call(Gt) === "[object Window]") {
          var Pt = '<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style><body><iframe id="pdfViewer" src="' + (M.pdfJsUrl || "examples/PDF.js/web/viewer.html") + "?file=&downloadName=" + M.filename + '" width="500px" height="400px" /></body></html>', Vt = Gt.open();
          if (Vt !== null) {
            Vt.document.write(Pt);
            var Zt = this;
            Vt.document.documentElement.querySelector("#pdfViewer").onload = function() {
              Vt.document.title = M.filename, Vt.document.documentElement.querySelector("#pdfViewer").contentWindow.PDFViewerApplication.open(Zt.output("bloburl"));
            };
          }
          return Vt;
        }
        throw new Error("The option pdfjsnewwindow just works in a browser-environment.");
      case "dataurlnewwindow":
        if (Object.prototype.toString.call(Gt) !== "[object Window]") throw new Error("The option dataurlnewwindow just works in a browser-environment.");
        var gr = '<html><style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style><body><iframe src="' + this.output("datauristring", M) + '"></iframe></body></html>', ao = Gt.open();
        if (ao !== null && (ao.document.write(gr), ao.document.title = M.filename), ao || typeof safari > "u") return ao;
        break;
      case "datauri":
      case "dataurl":
        return Gt.document.location.href = this.output("datauristring", M);
      default:
        return null;
    }
  }, lo.foo = function() {
    try {
      return lo.apply(this, arguments);
    } catch (X) {
      var x = X.stack || "";
      ~x.indexOf(" at ") && (x = x.split(" at ")[1]);
      var M = "Error in function " + x.split(`
`)[0].split("<")[0] + ": " + X.message;
      if (!Gt.console) throw new Error(M);
      Gt.console.error(M, X), Gt.alert && alert(M);
    }
  }, lo.foo.bar = lo, lo.foo), li = function(x) {
    return Array.isArray(ur) === !0 && ur.indexOf(x) > -1;
  };
  switch (r) {
    case "pt":
      Ct = 1;
      break;
    case "mm":
      Ct = 72 / 25.4;
      break;
    case "cm":
      Ct = 72 / 2.54;
      break;
    case "in":
      Ct = 72;
      break;
    case "px":
      Ct = li("px_scaling") == 1 ? 0.75 : 96 / 72;
      break;
    case "pc":
    case "em":
      Ct = 12;
      break;
    case "ex":
      Ct = 6;
      break;
    default:
      if (typeof r != "number") throw new Error("Invalid unit: " + r);
      Ct = r;
  }
  var Go = null;
  ae(), ee();
  var ga = d.__private__.getPageInfo = d.getPageInfo = function(x) {
    if (isNaN(x) || x % 1 != 0) throw new Error("Invalid argument passed to jsPDF.getPageInfo");
    return { objId: Nt[x].objId, pageNumber: x, pageContext: Nt[x] };
  }, wd = d.__private__.getPageInfoByObjId = function(x) {
    if (isNaN(x) || x % 1 != 0) throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");
    for (var M in Nt) if (Nt[M].objId === x) break;
    return ga(M);
  }, Cg = d.__private__.getCurrentPageInfo = d.getCurrentPageInfo = function() {
    return { objId: Nt[G].objId, pageNumber: G, pageContext: Nt[G] };
  };
  d.addPage = function() {
    return Xl.apply(this, arguments), this;
  }, d.setPage = function() {
    return fd.apply(this, arguments), Xe.call(this, Ce[G]), this;
  }, d.insertPage = function(x) {
    return this.addPage(), this.movePage(G, x), this;
  }, d.movePage = function(x, M) {
    var X, ie;
    if (x > M) {
      X = Ce[x], ie = Nt[x];
      for (var he = x; he > M; he--) Ce[he] = Ce[he - 1], Nt[he] = Nt[he - 1];
      Ce[M] = X, Nt[M] = ie, this.setPage(M);
    } else if (x < M) {
      X = Ce[x], ie = Nt[x];
      for (var Ee = x; Ee < M; Ee++) Ce[Ee] = Ce[Ee + 1], Nt[Ee] = Nt[Ee + 1];
      Ce[M] = X, Nt[M] = ie, this.setPage(M);
    }
    return this;
  }, d.deletePage = function() {
    return au.apply(this, arguments), this;
  }, d.__private__.text = d.text = function(x, M, X, ie, he) {
    var Ee, Re, St, Pt, Vt, Zt, gr, ao, Vo, Gr = (ie = ie || {}).scope || this;
    if (typeof x == "number" && typeof M == "number" && (typeof X == "string" || Array.isArray(X))) {
      var Do = X;
      X = M, M = x, x = Do;
    }
    if (arguments[3] instanceof xt == 0 ? (St = arguments[4], Pt = arguments[5], yr(gr = arguments[3]) === "object" && gr !== null || (typeof St == "string" && (Pt = St, St = null), typeof gr == "string" && (Pt = gr, gr = null), typeof gr == "number" && (St = gr, gr = null), ie = { flags: gr, angle: St, align: Pt })) : (B("The transform parameter of text() with a Matrix value"), Vo = he), isNaN(M) || isNaN(X) || x == null) throw new Error("Invalid arguments passed to jsPDF.text");
    if (x.length === 0) return Gr;
    var Uo, on = "", wa = typeof ie.lineHeightFactor == "number" ? ie.lineHeightFactor : tl, Ci = Gr.internal.scaleFactor;
    function xa(Sr) {
      return Sr = Sr.split("	").join(Array(ie.TabLen || 9).join(" ")), Fr(Sr, gr);
    }
    function gu(Sr) {
      for (var Mr, mo = Sr.concat(), Ho = [], Sa = mo.length; Sa--; ) typeof (Mr = mo.shift()) == "string" ? Ho.push(Mr) : Array.isArray(Sr) && (Mr.length === 1 || Mr[1] === void 0 && Mr[2] === void 0) ? Ho.push(Mr[0]) : Ho.push([Mr[0], Mr[1], Mr[2]]);
      return Ho;
    }
    function rc(Sr, Mr) {
      var mo;
      if (typeof Sr == "string") mo = Mr(Sr)[0];
      else if (Array.isArray(Sr)) {
        for (var Ho, Sa, Cu = Sr.concat(), ic = [], Fd = Cu.length; Fd--; ) typeof (Ho = Cu.shift()) == "string" ? ic.push(Mr(Ho)[0]) : Array.isArray(Ho) && typeof Ho[0] == "string" && (Sa = Mr(Ho[0], Ho[1], Ho[2]), ic.push([Sa[0], Sa[1], Sa[2]]));
        mo = ic;
      }
      return mo;
    }
    var ns = !1, il = !0;
    if (typeof x == "string") ns = !0;
    else if (Array.isArray(x)) {
      var al = x.concat();
      Re = [];
      for (var is, nn = al.length; nn--; ) (typeof (is = al.shift()) != "string" || Array.isArray(is) && typeof is[0] != "string") && (il = !1);
      ns = il;
    }
    if (ns === !1) throw new Error('Type of text must be string or Array. "' + x + '" is not recognized.');
    typeof x == "string" && (x = x.match(/[\r?\n]/) ? x.split(/\r\n|\r|\n/g) : [x]);
    var sl = Be / Gr.internal.scaleFactor, ll = sl * (wa - 1);
    switch (ie.baseline) {
      case "bottom":
        X -= ll;
        break;
      case "top":
        X += sl - ll;
        break;
      case "hanging":
        X += sl - 2 * ll;
        break;
      case "middle":
        X += sl / 2 - ll;
    }
    if ((Zt = ie.maxWidth || 0) > 0 && (typeof x == "string" ? x = Gr.splitTextToSize(x, Zt) : Object.prototype.toString.call(x) === "[object Array]" && (x = x.reduce(function(Sr, Mr) {
      return Sr.concat(Gr.splitTextToSize(Mr, Zt));
    }, []))), Ee = { text: x, x: M, y: X, options: ie, mutex: { pdfEscape: Fr, activeFontKey: rt, fonts: J, activeFontSize: Be } }, Bt.publish("preProcessText", Ee), x = Ee.text, St = (ie = Ee.options).angle, Vo instanceof xt == 0 && St && typeof St == "number") {
      St *= Math.PI / 180, ie.rotationDirection === 0 && (St = -St), w === v && (St = -St);
      var _u = Math.cos(St), fu = Math.sin(St);
      Vo = new xt(_u, fu, -fu, _u, 0, 0);
    } else St && St instanceof xt && (Vo = St);
    w !== v || Vo || (Vo = qo), (Vt = ie.charSpace || ma) !== void 0 && (on += F(U(Vt)) + ` Tc
`, this.setCharSpace(this.getCharSpace() || 0)), (ao = ie.horizontalScale) !== void 0 && (on += F(100 * ao) + ` Tz
`), ie.lang;
    var Bn = -1, ka = ie.renderingMode !== void 0 ? ie.renderingMode : ie.stroke, oc = Gr.internal.getCurrentPageInfo().pageContext;
    switch (ka) {
      case 0:
      case !1:
      case "fill":
        Bn = 0;
        break;
      case 1:
      case !0:
      case "stroke":
        Bn = 1;
        break;
      case 2:
      case "fillThenStroke":
        Bn = 2;
        break;
      case 3:
      case "invisible":
        Bn = 3;
        break;
      case 4:
      case "fillAndAddForClipping":
        Bn = 4;
        break;
      case 5:
      case "strokeAndAddPathForClipping":
        Bn = 5;
        break;
      case 6:
      case "fillThenStrokeAndAddToPathForClipping":
        Bn = 6;
        break;
      case 7:
      case "addToPathForClipping":
        Bn = 7;
    }
    var Td = oc.usedRenderingMode !== void 0 ? oc.usedRenderingMode : -1;
    Bn !== -1 ? on += Bn + ` Tr
` : Td !== -1 && (on += `0 Tr
`), Bn !== -1 && (oc.usedRenderingMode = Bn), Pt = ie.align || "left";
    var ci, cl = Be * wa, mu = Gr.internal.pageSize.getWidth(), yu = J[rt];
    Vt = ie.charSpace || ma, Zt = ie.maxWidth || 0, gr = Object.assign({ autoencode: !0, noBOM: !0 }, ie.flags);
    var as = [], ul = function(Sr) {
      return Gr.getStringUnitWidth(Sr, { font: yu, charSpace: Vt, fontSize: Be, doKerning: !1 }) * Be / Ci;
    };
    if (Object.prototype.toString.call(x) === "[object Array]") {
      var $n;
      Re = gu(x), Pt !== "left" && (ci = Re.map(ul));
      var Wn, ss = 0;
      if (Pt === "right") {
        M -= ci[0], x = [], nn = Re.length;
        for (var Ca = 0; Ca < nn; Ca++) Ca === 0 ? (Wn = _a(M), $n = fa(X)) : (Wn = U(ss - ci[Ca]), $n = -cl), x.push([Re[Ca], Wn, $n]), ss = ci[Ca];
      } else if (Pt === "center") {
        M -= ci[0] / 2, x = [], nn = Re.length;
        for (var ls = 0; ls < nn; ls++) ls === 0 ? (Wn = _a(M), $n = fa(X)) : (Wn = U((ss - ci[ls]) / 2), $n = -cl), x.push([Re[ls], Wn, $n]), ss = ci[ls];
      } else if (Pt === "left") {
        x = [], nn = Re.length;
        for (var bu = 0; bu < nn; bu++) x.push(Re[bu]);
      } else if (Pt === "justify" && yu.encoding === "Identity-H") {
        x = [], nn = Re.length, Zt = Zt !== 0 ? Zt : mu;
        for (var nc = 0, fo = 0; fo < nn; fo++) if ($n = fo === 0 ? fa(X) : -cl, Wn = fo === 0 ? _a(M) : nc, fo < nn - 1) {
          var Pd = U((Zt - ci[fo]) / (Re[fo].split(" ").length - 1)), Zi = Re[fo].split(" ");
          x.push([Zi[0] + " ", Wn, $n]), nc = 0;
          for (var Ji = 1; Ji < Zi.length; Ji++) {
            var vu = (ul(Zi[Ji - 1] + " " + Zi[Ji]) - ul(Zi[Ji])) * Ci + Pd;
            Ji == Zi.length - 1 ? x.push([Zi[Ji], vu, 0]) : x.push([Zi[Ji] + " ", vu, 0]), nc -= vu;
          }
        } else x.push([Re[fo], Wn, $n]);
        x.push(["", nc, 0]);
      } else {
        if (Pt !== "justify") throw new Error('Unrecognized alignment option, use "left", "center", "right" or "justify".');
        for (x = [], nn = Re.length, Zt = Zt !== 0 ? Zt : mu, fo = 0; fo < nn; fo++) {
          $n = fo === 0 ? fa(X) : -cl, Wn = fo === 0 ? _a(M) : 0;
          var wu = Re[fo].split(" ").length - 1, xu = wu > 0 ? (Zt - ci[fo]) / wu : 0;
          fo < nn - 1 ? as.push(F(U(xu))) : as.push(0), x.push([Re[fo], Wn, $n]);
        }
      }
    }
    (typeof ie.R2L == "boolean" ? ie.R2L : Fe) === !0 && (x = rc(x, function(Sr, Mr, mo) {
      return [Sr.split("").reverse().join(""), Mr, mo];
    })), Ee = { text: x, x: M, y: X, options: ie, mutex: { pdfEscape: Fr, activeFontKey: rt, fonts: J, activeFontSize: Be } }, Bt.publish("postProcessText", Ee), x = Ee.text, Uo = Ee.mutex.isHex || !1;
    var ku = J[rt].encoding;
    ku !== "WinAnsiEncoding" && ku !== "StandardEncoding" || (x = rc(x, function(Sr, Mr, mo) {
      return [xa(Sr), Mr, mo];
    })), Re = gu(x), x = [];
    for (var cs, us, As, Al = Array.isArray(Re[0]) ? 1 : 0, ds = "", dl = function(Sr, Mr, mo) {
      var Ho = "";
      return mo instanceof xt ? (mo = typeof ie.angle == "number" ? Qo(mo, new xt(1, 0, 0, 1, Sr, Mr)) : Qo(new xt(1, 0, 0, 1, Sr, Mr), mo), w === v && (mo = Qo(new xt(1, 0, 0, -1, 0, 0), mo)), Ho = mo.join(" ") + ` Tm
`) : Ho = F(Sr) + " " + F(Mr) + ` Td
`, Ho;
    }, ui = 0; ui < Re.length; ui++) {
      switch (ds = "", Al) {
        case 1:
          As = (Uo ? "<" : "(") + Re[ui][0] + (Uo ? ">" : ")"), cs = parseFloat(Re[ui][1]), us = parseFloat(Re[ui][2]);
          break;
        case 0:
          As = (Uo ? "<" : "(") + Re[ui] + (Uo ? ">" : ")"), cs = _a(M), us = fa(X);
      }
      as !== void 0 && as[ui] !== void 0 && (ds = as[ui] + ` Tw
`), ui === 0 ? x.push(ds + dl(cs, us, Vo) + As) : Al === 0 ? x.push(ds + As) : Al === 1 && x.push(ds + dl(cs, us, Vo) + As);
    }
    x = Al === 0 ? x.join(` Tj
T* `) : x.join(` Tj
`), x += ` Tj
`;
    var ea = `BT
/`;
    return ea += rt + " " + Be + ` Tf
`, ea += F(Be * wa) + ` TL
`, ea += rl + `
`, ea += on, ea += x, D(ea += "ET"), p[rt] = !0, Gr;
  };
  var Sg = d.__private__.clip = d.clip = function(x) {
    return D(x === "evenodd" ? "W*" : "W"), this;
  };
  d.clipEvenOdd = function() {
    return Sg("evenodd");
  }, d.__private__.discardPath = d.discardPath = function() {
    return D("n"), this;
  };
  var Yi = d.__private__.isValidStyle = function(x) {
    var M = !1;
    return [void 0, null, "S", "D", "F", "DF", "FD", "f", "f*", "B", "B*", "n"].indexOf(x) !== -1 && (M = !0), M;
  };
  d.__private__.setDefaultPathOperation = d.setDefaultPathOperation = function(x) {
    return Yi(x) && (c = x), this;
  };
  var xd = d.__private__.getStyle = d.getStyle = function(x) {
    var M = c;
    switch (x) {
      case "D":
      case "S":
        M = "S";
        break;
      case "F":
        M = "f";
        break;
      case "FD":
      case "DF":
        M = "B";
        break;
      case "f":
      case "f*":
      case "B":
      case "B*":
        M = x;
    }
    return M;
  }, kd = d.close = function() {
    return D("h"), this;
  };
  d.stroke = function() {
    return D("S"), this;
  }, d.fill = function(x) {
    return Jl("f", x), this;
  }, d.fillEvenOdd = function(x) {
    return Jl("f*", x), this;
  }, d.fillStroke = function(x) {
    return Jl("B", x), this;
  }, d.fillStrokeEvenOdd = function(x) {
    return Jl("B*", x), this;
  };
  var Jl = function(x, M) {
    yr(M) === "object" ? Eg(M, x) : D(x);
  }, el = function(x) {
    x === null || w === v && x === void 0 || (x = xd(x), D(x));
  };
  function Bg(x, M, X, ie, he) {
    var Ee = new Bl(M || this.boundingBox, X || this.xStep, ie || this.yStep, this.gState, he || this.matrix);
    Ee.stream = this.stream;
    var Re = x + "$$" + this.cloneIndex++ + "$$";
    return Xo(Re, Ee), Ee;
  }
  var Eg = function(x, M) {
    var X = rr[x.key], ie = nt[X];
    if (ie instanceof Es) D("q"), D(jg(M)), ie.gState && d.setGState(ie.gState), D(x.matrix.toString() + " cm"), D("/" + X + " sh"), D("Q");
    else if (ie instanceof Bl) {
      var he = new xt(1, 0, 0, -1, 0, nl());
      x.matrix && (he = he.multiply(x.matrix || qo), X = Bg.call(ie, x.key, x.boundingBox, x.xStep, x.yStep, he).id), D("q"), D("/Pattern cs"), D("/" + X + " scn"), ie.gState && d.setGState(ie.gState), D(M), D("Q");
    }
  }, jg = function(x) {
    switch (x) {
      case "f":
      case "F":
      case "n":
        return "W n";
      case "f*":
        return "W* n";
      case "B":
      case "S":
        return "W S";
      case "B*":
        return "W* S";
    }
  }, su = d.moveTo = function(x, M) {
    return D(F(U(x)) + " " + F(O(M)) + " m"), this;
  }, Cd = d.lineTo = function(x, M) {
    return D(F(U(x)) + " " + F(O(M)) + " l"), this;
  }, ki = d.curveTo = function(x, M, X, ie, he, Ee) {
    return D([F(U(x)), F(O(M)), F(U(X)), F(O(ie)), F(U(he)), F(O(Ee)), "c"].join(" ")), this;
  };
  d.__private__.line = d.line = function(x, M, X, ie, he) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || isNaN(ie) || !Yi(he)) throw new Error("Invalid arguments passed to jsPDF.line");
    return w === b ? this.lines([[X - x, ie - M]], x, M, [1, 1], he || "S") : this.lines([[X - x, ie - M]], x, M, [1, 1]).stroke();
  }, d.__private__.lines = d.lines = function(x, M, X, ie, he, Ee) {
    var Re, St, Pt, Vt, Zt, gr, ao, Vo, Gr, Do, Uo, on;
    if (typeof x == "number" && (on = X, X = M, M = x, x = on), ie = ie || [1, 1], Ee = Ee || !1, isNaN(M) || isNaN(X) || !Array.isArray(x) || !Array.isArray(ie) || !Yi(he) || typeof Ee != "boolean") throw new Error("Invalid arguments passed to jsPDF.lines");
    for (su(M, X), Re = ie[0], St = ie[1], Vt = x.length, Do = M, Uo = X, Pt = 0; Pt < Vt; Pt++) (Zt = x[Pt]).length === 2 ? (Do = Zt[0] * Re + Do, Uo = Zt[1] * St + Uo, Cd(Do, Uo)) : (gr = Zt[0] * Re + Do, ao = Zt[1] * St + Uo, Vo = Zt[2] * Re + Do, Gr = Zt[3] * St + Uo, Do = Zt[4] * Re + Do, Uo = Zt[5] * St + Uo, ki(gr, ao, Vo, Gr, Do, Uo));
    return Ee && kd(), el(he), this;
  }, d.path = function(x) {
    for (var M = 0; M < x.length; M++) {
      var X = x[M], ie = X.c;
      switch (X.op) {
        case "m":
          su(ie[0], ie[1]);
          break;
        case "l":
          Cd(ie[0], ie[1]);
          break;
        case "c":
          ki.apply(this, ie);
          break;
        case "h":
          kd();
      }
    }
    return this;
  }, d.__private__.rect = d.rect = function(x, M, X, ie, he) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || isNaN(ie) || !Yi(he)) throw new Error("Invalid arguments passed to jsPDF.rect");
    return w === b && (ie = -ie), D([F(U(x)), F(O(M)), F(U(X)), F(U(ie)), "re"].join(" ")), el(he), this;
  }, d.__private__.triangle = d.triangle = function(x, M, X, ie, he, Ee, Re) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || isNaN(ie) || isNaN(he) || isNaN(Ee) || !Yi(Re)) throw new Error("Invalid arguments passed to jsPDF.triangle");
    return this.lines([[X - x, ie - M], [he - X, Ee - ie], [x - he, M - Ee]], x, M, [1, 1], Re, !0), this;
  }, d.__private__.roundedRect = d.roundedRect = function(x, M, X, ie, he, Ee, Re) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || isNaN(ie) || isNaN(he) || isNaN(Ee) || !Yi(Re)) throw new Error("Invalid arguments passed to jsPDF.roundedRect");
    var St = 4 / 3 * (Math.SQRT2 - 1);
    return he = Math.min(he, 0.5 * X), Ee = Math.min(Ee, 0.5 * ie), this.lines([[X - 2 * he, 0], [he * St, 0, he, Ee - Ee * St, he, Ee], [0, ie - 2 * Ee], [0, Ee * St, -he * St, Ee, -he, Ee], [2 * he - X, 0], [-he * St, 0, -he, -Ee * St, -he, -Ee], [0, 2 * Ee - ie], [0, -Ee * St, he * St, -Ee, he, -Ee]], x + he, M, [1, 1], Re, !0), this;
  }, d.__private__.ellipse = d.ellipse = function(x, M, X, ie, he) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || isNaN(ie) || !Yi(he)) throw new Error("Invalid arguments passed to jsPDF.ellipse");
    var Ee = 4 / 3 * (Math.SQRT2 - 1) * X, Re = 4 / 3 * (Math.SQRT2 - 1) * ie;
    return su(x + X, M), ki(x + X, M - Re, x + Ee, M - ie, x, M - ie), ki(x - Ee, M - ie, x - X, M - Re, x - X, M), ki(x - X, M + Re, x - Ee, M + ie, x, M + ie), ki(x + Ee, M + ie, x + X, M + Re, x + X, M), el(he), this;
  }, d.__private__.circle = d.circle = function(x, M, X, ie) {
    if (isNaN(x) || isNaN(M) || isNaN(X) || !Yi(ie)) throw new Error("Invalid arguments passed to jsPDF.circle");
    return this.ellipse(x, M, X, X, ie);
  }, d.setFont = function(x, M, X) {
    return X && (M = T(M, X)), rt = yd(x, M, { disableWarning: !1 }), this;
  };
  var Lg = d.__private__.getFont = d.getFont = function() {
    return J[yd.apply(d, arguments)];
  };
  d.__private__.getFontList = d.getFontList = function() {
    var x, M, X = {};
    for (x in ge) if (ge.hasOwnProperty(x)) for (M in X[x] = [], ge[x]) ge[x].hasOwnProperty(M) && X[x].push(M);
    return X;
  }, d.addFont = function(x, M, X, ie, he) {
    var Ee = ["StandardEncoding", "MacRomanEncoding", "Identity-H", "WinAnsiEncoding"];
    return arguments[3] && Ee.indexOf(arguments[3]) !== -1 ? he = arguments[3] : arguments[3] && Ee.indexOf(arguments[3]) == -1 && (X = T(X, ie)), Sn.call(this, x, M, X, he = he || "Identity-H");
  };
  var tl, lu = o.lineWidth || 0.200025, Tg = d.__private__.getLineWidth = d.getLineWidth = function() {
    return lu;
  }, zt = d.__private__.setLineWidth = d.setLineWidth = function(x) {
    return lu = x, D(F(U(x)) + " w"), this;
  };
  d.__private__.setLineDash = Tt.API.setLineDash = Tt.API.setLineDashPattern = function(x, M) {
    if (x = x || [], M = M || 0, isNaN(M) || !Array.isArray(x)) throw new Error("Invalid arguments passed to jsPDF.setLineDash");
    return x = x.map(function(X) {
      return F(U(X));
    }).join(" "), M = F(U(M)), D("[" + x + "] " + M + " d"), this;
  };
  var Pg = d.__private__.getLineHeight = d.getLineHeight = function() {
    return Be * tl;
  };
  d.__private__.getLineHeight = d.getLineHeight = function() {
    return Be * tl;
  };
  var Fg = d.__private__.setLineHeightFactor = d.setLineHeightFactor = function(x) {
    return typeof (x = x || 1.15) == "number" && (tl = x), this;
  }, Ug = d.__private__.getLineHeightFactor = d.getLineHeightFactor = function() {
    return tl;
  };
  Fg(o.lineHeight);
  var _a = d.__private__.getHorizontalCoordinate = function(x) {
    return U(x);
  }, fa = d.__private__.getVerticalCoordinate = function(x) {
    return w === v ? x : Nt[G].mediaBox.topRightY - Nt[G].mediaBox.bottomLeftY - U(x);
  }, Ng = d.__private__.getHorizontalCoordinateString = d.getHorizontalCoordinateString = function(x) {
    return F(_a(x));
  }, Ig = d.__private__.getVerticalCoordinateString = d.getVerticalCoordinateString = function(x) {
    return F(fa(x));
  }, ec = o.strokeColor || "0 G";
  d.__private__.getStrokeColor = d.getDrawColor = function() {
    return Ht(ec);
  }, d.__private__.setStrokeColor = d.setDrawColor = function(x, M, X, ie) {
    return ec = Ot({ ch1: x, ch2: M, ch3: X, ch4: ie, pdfColorType: "draw", precision: 2 }), D(ec), this;
  };
  var cu = o.fillColor || "0 g";
  d.__private__.getFillColor = d.getFillColor = function() {
    return Ht(cu);
  }, d.__private__.setFillColor = d.setFillColor = function(x, M, X, ie) {
    return cu = Ot({ ch1: x, ch2: M, ch3: X, ch4: ie, pdfColorType: "fill", precision: 2 }), D(cu), this;
  };
  var rl = o.textColor || "0 g", Mg = d.__private__.getTextColor = d.getTextColor = function() {
    return Ht(rl);
  };
  d.__private__.setTextColor = d.setTextColor = function(x, M, X, ie) {
    return rl = Ot({ ch1: x, ch2: M, ch3: X, ch4: ie, pdfColorType: "text", precision: 3 }), this;
  };
  var ma = o.charSpace, Rg = d.__private__.getCharSpace = d.getCharSpace = function() {
    return parseFloat(ma || 0);
  };
  d.__private__.setCharSpace = d.setCharSpace = function(x) {
    if (isNaN(x)) throw new Error("Invalid argument passed to jsPDF.setCharSpace");
    return ma = x, this;
  };
  var uu = 0;
  d.CapJoinStyles = { 0: 0, butt: 0, but: 0, miter: 0, 1: 1, round: 1, rounded: 1, circle: 1, 2: 2, projecting: 2, project: 2, square: 2, bevel: 2 }, d.__private__.setLineCap = d.setLineCap = function(x) {
    var M = d.CapJoinStyles[x];
    if (M === void 0) throw new Error("Line cap style of '" + x + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
    return uu = M, D(M + " J"), this;
  };
  var Au = 0;
  d.__private__.setLineJoin = d.setLineJoin = function(x) {
    var M = d.CapJoinStyles[x];
    if (M === void 0) throw new Error("Line join style of '" + x + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
    return Au = M, D(M + " j"), this;
  }, d.__private__.setLineMiterLimit = d.__private__.setMiterLimit = d.setLineMiterLimit = d.setMiterLimit = function(x) {
    if (x = x || 0, isNaN(x)) throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");
    return D(F(U(x)) + " M"), this;
  }, d.GState = ql, d.setGState = function(x) {
    (x = typeof x == "string" ? _t[wt[x]] : Sd(null, x)).equals(or) || (D("/" + x.id + " gs"), or = x);
  };
  var Sd = function(x, M) {
    if (!x || !wt[x]) {
      var X = !1;
      for (var ie in _t) if (_t.hasOwnProperty(ie) && _t[ie].equals(M)) {
        X = !0;
        break;
      }
      if (X) M = _t[ie];
      else {
        var he = "GS" + (Object.keys(_t).length + 1).toString(10);
        _t[he] = M, M.id = he;
      }
      return x && (wt[x] = M.id), Bt.publish("addGState", M), M;
    }
  };
  d.addGState = function(x, M) {
    return Sd(x, M), this;
  }, d.saveGraphicsState = function() {
    return D("q"), We.push({ key: rt, size: Be, color: rl }), this;
  }, d.restoreGraphicsState = function() {
    D("Q");
    var x = We.pop();
    return rt = x.key, Be = x.size, rl = x.color, or = null, this;
  }, d.setCurrentTransformationMatrix = function(x) {
    return D(x.toString() + " cm"), this;
  }, d.comment = function(x) {
    return D("#" + x), this;
  };
  var ya = function(x, M) {
    var X = x || 0;
    Object.defineProperty(this, "x", { enumerable: !0, get: function() {
      return X;
    }, set: function(Ee) {
      isNaN(Ee) || (X = parseFloat(Ee));
    } });
    var ie = M || 0;
    Object.defineProperty(this, "y", { enumerable: !0, get: function() {
      return ie;
    }, set: function(Ee) {
      isNaN(Ee) || (ie = parseFloat(Ee));
    } });
    var he = "pt";
    return Object.defineProperty(this, "type", { enumerable: !0, get: function() {
      return he;
    }, set: function(Ee) {
      he = Ee.toString();
    } }), this;
  }, du = function(x, M, X, ie) {
    ya.call(this, x, M), this.type = "rect";
    var he = X || 0;
    Object.defineProperty(this, "w", { enumerable: !0, get: function() {
      return he;
    }, set: function(Re) {
      isNaN(Re) || (he = parseFloat(Re));
    } });
    var Ee = ie || 0;
    return Object.defineProperty(this, "h", { enumerable: !0, get: function() {
      return Ee;
    }, set: function(Re) {
      isNaN(Re) || (Ee = parseFloat(Re));
    } }), this;
  }, tc = function() {
    this.page = mt, this.currentPage = G, this.pages = Ce.slice(0), this.pagesContext = Nt.slice(0), this.x = it, this.y = Kt, this.matrix = ve, this.width = hu(G), this.height = Ed(G), this.outputDestination = Qe, this.id = "", this.objectNumber = -1;
  };
  tc.prototype.restore = function() {
    mt = this.page, G = this.currentPage, Nt = this.pagesContext, Ce = this.pages, it = this.x, Kt = this.y, ve = this.matrix, Bd(G, this.width), ba(G, this.height), Qe = this.outputDestination;
  };
  var pu = function(x, M, X, ie, he) {
    To.push(new tc()), mt = G = 0, Ce = [], it = x, Kt = M, ve = he, os([X, ie]);
  };
  for (var ol in d.beginFormObject = function(x, M, X, ie, he) {
    return pu(x, M, X, ie, he), this;
  }, d.endFormObject = function(x) {
    return (function(M) {
      if (Kr[M]) To.pop().restore();
      else {
        var X = new tc(), ie = "Xo" + (Object.keys(vr).length + 1).toString(10);
        X.id = ie, Kr[M] = ie, vr[ie] = X, Bt.publish("addFormObject", X), To.pop().restore();
      }
    })(x), this;
  }, d.doFormObject = function(x, M) {
    var X = vr[Kr[x]];
    return D("q"), D(M.toString() + " cm"), D("/" + X.id + " Do"), D("Q"), this;
  }, d.getFormObject = function(x) {
    var M = vr[Kr[x]];
    return { x: M.x, y: M.y, width: M.width, height: M.height, matrix: M.matrix };
  }, d.save = function(x, M) {
    return x = x || "generated.pdf", (M = M || {}).returnPromise = M.returnPromise || !1, M.returnPromise === !1 ? (xl(Zl(Xi()), x), typeof xl.unload == "function" && Gt.setTimeout && setTimeout(xl.unload, 911), this) : new Promise(function(X, ie) {
      try {
        var he = xl(Zl(Xi()), x);
        typeof xl.unload == "function" && Gt.setTimeout && setTimeout(xl.unload, 911), X(he);
      } catch (Ee) {
        ie(Ee.message);
      }
    });
  }, Tt.API) Tt.API.hasOwnProperty(ol) && (ol === "events" && Tt.API.events.length ? (function(x, M) {
    var X, ie, he;
    for (he = M.length - 1; he !== -1; he--) X = M[he][0], ie = M[he][1], x.subscribe.apply(x, [X].concat(typeof ie == "function" ? [ie] : ie));
  })(Bt, Tt.API.events) : d[ol] = Tt.API[ol]);
  function hu(x) {
    return Nt[x].mediaBox.topRightX - Nt[x].mediaBox.bottomLeftX;
  }
  function Bd(x, M) {
    Nt[x].mediaBox.topRightX = M + Nt[x].mediaBox.bottomLeftX;
  }
  function Ed(x) {
    return Nt[x].mediaBox.topRightY - Nt[x].mediaBox.bottomLeftY;
  }
  function ba(x, M) {
    Nt[x].mediaBox.topRightY = M + Nt[x].mediaBox.bottomLeftY;
  }
  var va = d.getPageWidth = function(x) {
    return hu(x = x || G) / Ct;
  }, jd = d.setPageWidth = function(x, M) {
    Bd(x, M * Ct);
  }, nl = d.getPageHeight = function(x) {
    return Ed(x = x || G) / Ct;
  }, Ld = d.setPageHeight = function(x, M) {
    ba(x, M * Ct);
  };
  return d.internal = { pdfEscape: Fr, getStyle: xd, getFont: Lg, getFontSize: Le, getCharSpace: Rg, getTextColor: Mg, getLineHeight: Pg, getLineHeightFactor: Ug, getLineWidth: Tg, write: Ne, getHorizontalCoordinate: _a, getVerticalCoordinate: fa, getCoordinateString: Ng, getVerticalCoordinateString: Ig, collections: {}, newObject: jr, newAdditionalObject: gt, newObjectDeferred: Ir, newObjectDeferredBegin: Ie, getFilters: qt, putStream: Zr, events: Bt, scaleFactor: Ct, pageSize: { getWidth: function() {
    return va(G);
  }, setWidth: function(x) {
    jd(G, x);
  }, getHeight: function() {
    return nl(G);
  }, setHeight: function(x) {
    Ld(G, x);
  } }, encryptionOptions: u, encryption: Go, getEncryptor: function(x) {
    return u !== null ? Go.encryptor(x, 0) : function(M) {
      return M;
    };
  }, output: vd, getNumberOfPages: md, get pages() {
    return Ce;
  }, out: D, f2: S, f3: L, getPageInfo: ga, getPageInfoByObjId: wd, getCurrentPageInfo: Cg, getPDFVersion: _, Point: ya, Rectangle: du, Matrix: xt, hasHotfix: li }, Object.defineProperty(d.internal.pageSize, "width", { get: function() {
    return va(G);
  }, set: function(x) {
    jd(G, x);
  }, enumerable: !0, configurable: !0 }), Object.defineProperty(d.internal.pageSize, "height", { get: function() {
    return nl(G);
  }, set: function(x) {
    Ld(G, x);
  }, enumerable: !0, configurable: !0 }), (function(x) {
    for (var M = 0, X = ot.length; M < X; M++) {
      var ie = Sn.call(this, x[M][0], x[M][1], x[M][2], ot[M][3], !0);
      A === !1 && (p[ie] = !0);
      var he = x[M][0].split("-");
      rn({ id: ie, fontName: he[0], fontStyle: he[1] || "" });
    }
    Bt.publish("addFonts", { fonts: J, dictionary: ge });
  }).call(d, ot), rt = "F1", Xl(n, t), Bt.publish("initialized"), d;
}
kc.prototype.lsbFirstWord = function(o) {
  return String.fromCharCode(255 & o, o >> 8 & 255, o >> 16 & 255, o >> 24 & 255);
}, kc.prototype.toHexString = function(o) {
  return o.split("").map(function(e) {
    return ("0" + (255 & e.charCodeAt(0)).toString(16)).slice(-2);
  }).join("");
}, kc.prototype.hexToBytes = function(o) {
  for (var e = [], t = 0; t < o.length; t += 2) e.push(String.fromCharCode(parseInt(o.substr(t, 2), 16)));
  return e.join("");
}, kc.prototype.processOwnerPassword = function(o, e) {
  return vb(bb(e).substr(0, 5), o);
}, kc.prototype.encryptor = function(o, e) {
  var t = bb(this.encryptionKey + String.fromCharCode(255 & o, o >> 8 & 255, o >> 16 & 255, 255 & e, e >> 8 & 255)).substr(0, 10);
  return function(r) {
    return vb(t, r);
  };
}, ql.prototype.equals = function(o) {
  var e, t = "id,objectNumber,equals";
  if (!o || yr(o) !== yr(this)) return !1;
  var r = 0;
  for (e in this) if (!(t.indexOf(e) >= 0)) {
    if (this.hasOwnProperty(e) && !o.hasOwnProperty(e) || this[e] !== o[e]) return !1;
    r++;
  }
  for (e in o) o.hasOwnProperty(e) && t.indexOf(e) < 0 && r--;
  return r === 0;
}, Tt.API = { events: [] }, Tt.version = "4.0.0";
var po = Tt.API, Fv = 1, Hl = function(o) {
  return o.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)");
}, dc = function(o) {
  return o.replace(/\\\\/g, "\\").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
}, Wt = function(o) {
  return o.toFixed(2);
}, vs = function(o) {
  return o.toFixed(5);
};
po.__acroform__ = {};
var zn = function(o, e) {
  o.prototype = Object.create(e.prototype), o.prototype.constructor = o;
}, Kx = function(o) {
  return o * Fv;
}, ia = function(o) {
  var e = new hj(), t = kt.internal.getHeight(o) || 0, r = kt.internal.getWidth(o) || 0;
  return e.BBox = [0, 0, Number(Wt(r)), Number(Wt(t))], e;
}, RO = po.__acroform__.setBit = function(o, e) {
  if (o = o || 0, e = e || 0, isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");
  return o | 1 << e;
}, OO = po.__acroform__.clearBit = function(o, e) {
  if (o = o || 0, e = e || 0, isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit");
  return o & ~(1 << e);
}, QO = po.__acroform__.getBit = function(o, e) {
  if (isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit");
  return o & 1 << e ? 1 : 0;
}, So = po.__acroform__.getBitForPdf = function(o, e) {
  if (isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");
  return QO(o, e - 1);
}, Bo = po.__acroform__.setBitForPdf = function(o, e) {
  if (isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf");
  return RO(o, e - 1);
}, Eo = po.__acroform__.clearBitForPdf = function(o, e) {
  if (isNaN(o) || isNaN(e)) throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");
  return OO(o, e - 1);
}, qO = po.__acroform__.calculateCoordinates = function(o, e) {
  var t = e.internal.getHorizontalCoordinate, r = e.internal.getVerticalCoordinate, n = o[0], i = o[1], a = o[2], s = o[3], l = {};
  return l.lowerLeft_X = t(n) || 0, l.lowerLeft_Y = r(i + s) || 0, l.upperRight_X = t(n + a) || 0, l.upperRight_Y = r(i) || 0, [Number(Wt(l.lowerLeft_X)), Number(Wt(l.lowerLeft_Y)), Number(Wt(l.upperRight_X)), Number(Wt(l.upperRight_Y))];
}, GO = function(o) {
  if (o.appearanceStreamContent) return o.appearanceStreamContent;
  if (o.V || o.DV) {
    var e = [], t = o._V || o.DV, r = wb(o, t), n = o.scope.internal.getFont(o.fontName, o.fontStyle).id;
    e.push("/Tx BMC"), e.push("q"), e.push("BT"), e.push(o.scope.__private__.encodeColorString(o.color)), e.push("/" + n + " " + Wt(r.fontSize) + " Tf"), e.push("1 0 0 1 0 0 Tm"), e.push(r.text), e.push("ET"), e.push("Q"), e.push("EMC");
    var i = ia(o);
    return i.scope = o.scope, i.stream = e.join(`
`), i;
  }
}, wb = function(o, e) {
  var t = o.fontSize === 0 ? o.maxFontSize : o.fontSize, r = { text: "", fontSize: "" }, n = (e = (e = e.substr(0, 1) == "(" ? e.substr(1) : e).substr(e.length - 1) == ")" ? e.substr(0, e.length - 1) : e).split(" ");
  n = o.multiline ? n.map(function(S) {
    return S.split(`
`);
  }) : n.map(function(S) {
    return [S];
  });
  var i = t, a = kt.internal.getHeight(o) || 0;
  a = a < 0 ? -a : a;
  var s = kt.internal.getWidth(o) || 0;
  s = s < 0 ? -s : s;
  var l = function(S, L, U) {
    if (S + 1 < n.length) {
      var O = L + " " + n[S + 1][0];
      return cp(O, o, U).width <= s - 4;
    }
    return !1;
  };
  i++;
  e: for (; i > 0; ) {
    e = "", i--;
    var c, u, A = cp("3", o, i).height, p = o.multiline ? a - i : (a - A) / 2, d = p += 2, g = 0, _ = 0, f = 0;
    if (i <= 0) {
      e = `(...) Tj
`, e += "% Width of Text: " + cp(e, o, i = 12).width + ", FieldWidth:" + s + `
`;
      break;
    }
    for (var m = "", b = 0, v = 0; v < n.length; v++) if (n.hasOwnProperty(v)) {
      var w = !1;
      if (n[v].length !== 1 && f !== n[v].length - 1) {
        if ((A + 2) * (b + 2) + 2 > a) continue e;
        m += n[v][f], w = !0, _ = v, v--;
      } else {
        m = (m += n[v][f] + " ").substr(m.length - 1) == " " ? m.substr(0, m.length - 1) : m;
        var C = parseInt(v), E = l(C, m, i), T = v >= n.length - 1;
        if (E && !T) {
          m += " ", f = 0;
          continue;
        }
        if (E || T) {
          if (T) _ = C;
          else if (o.multiline && (A + 2) * (b + 2) + 2 > a) continue e;
        } else {
          if (!o.multiline || (A + 2) * (b + 2) + 2 > a) continue e;
          _ = C;
        }
      }
      for (var F = "", B = g; B <= _; B++) {
        var P = n[B];
        if (o.multiline) {
          if (B === _) {
            F += P[f] + " ", f = (f + 1) % P.length;
            continue;
          }
          if (B === g) {
            F += P[P.length - 1] + " ";
            continue;
          }
        }
        F += P[0] + " ";
      }
      switch (F = F.substr(F.length - 1) == " " ? F.substr(0, F.length - 1) : F, u = cp(F, o, i).width, o.textAlign) {
        case "right":
          c = s - u - 2;
          break;
        case "center":
          c = (s - u) / 2;
          break;
        default:
          c = 2;
      }
      e += Wt(c) + " " + Wt(d) + ` Td
`, e += "(" + Hl(F) + `) Tj
`, e += -Wt(c) + ` 0 Td
`, d = -(i + 2), u = 0, g = w ? _ : _ + 1, b++, m = "";
    }
    break;
  }
  return r.text = e, r.fontSize = i, r;
}, cp = function(o, e, t) {
  var r = e.scope.internal.getFont(e.fontName, e.fontStyle), n = e.scope.getStringUnitWidth(o, { font: r, fontSize: parseFloat(t), charSpace: 0 }) * parseFloat(t);
  return { height: e.scope.getStringUnitWidth("3", { font: r, fontSize: parseFloat(t), charSpace: 0 }) * parseFloat(t) * 1.5, width: n };
}, VO = { fields: [], xForms: [], acroFormDictionaryRoot: null, printedOut: !1, internal: null, isInitialized: !1 }, DO = function(o, e) {
  var t = { type: "reference", object: o };
  e.internal.getPageInfo(o.page).pageContext.annotations.find(function(r) {
    return r.type === t.type && r.object === t.object;
  }) === void 0 && e.internal.getPageInfo(o.page).pageContext.annotations.push(t);
}, HO = function(o, e) {
  if (e.scope = o, o.internal !== void 0 && (o.internal.acroformPlugin === void 0 || o.internal.acroformPlugin.isInitialized === !1)) {
    if (Vi.FieldNum = 0, o.internal.acroformPlugin = JSON.parse(JSON.stringify(VO)), o.internal.acroformPlugin.acroFormDictionaryRoot) throw new Error("Exception while creating AcroformDictionary");
    Fv = o.internal.scaleFactor, o.internal.acroformPlugin.acroFormDictionaryRoot = new gj(), o.internal.acroformPlugin.acroFormDictionaryRoot.scope = o, o.internal.acroformPlugin.acroFormDictionaryRoot._eventID = o.internal.events.subscribe("postPutResources", function() {
      (function(t) {
        t.internal.events.unsubscribe(t.internal.acroformPlugin.acroFormDictionaryRoot._eventID), delete t.internal.acroformPlugin.acroFormDictionaryRoot._eventID, t.internal.acroformPlugin.printedOut = !0;
      })(o);
    }), o.internal.events.subscribe("buildDocument", function() {
      (function(t) {
        t.internal.acroformPlugin.acroFormDictionaryRoot.objId = void 0;
        var r = t.internal.acroformPlugin.acroFormDictionaryRoot.Fields;
        for (var n in r) if (r.hasOwnProperty(n)) {
          var i = r[n];
          i.objId = void 0, i.hasAnnotation && DO(i, t);
        }
      })(o);
    }), o.internal.events.subscribe("putCatalog", function() {
      (function(t) {
        if (t.internal.acroformPlugin.acroFormDictionaryRoot === void 0) throw new Error("putCatalogCallback: Root missing.");
        t.internal.write("/AcroForm " + t.internal.acroformPlugin.acroFormDictionaryRoot.objId + " 0 R");
      })(o);
    }), o.internal.events.subscribe("postPutPages", function(t) {
      (function(r, n) {
        var i = !r;
        for (var a in r || (n.internal.newObjectDeferredBegin(n.internal.acroformPlugin.acroFormDictionaryRoot.objId, !0), n.internal.acroformPlugin.acroFormDictionaryRoot.putStream()), r = r || n.internal.acroformPlugin.acroFormDictionaryRoot.Kids) if (r.hasOwnProperty(a)) {
          var s = r[a], l = [], c = s.Rect;
          if (s.Rect && (s.Rect = qO(s.Rect, n)), n.internal.newObjectDeferredBegin(s.objId, !0), s.DA = kt.createDefaultAppearanceStream(s), yr(s) === "object" && typeof s.getKeyValueListForStream == "function" && (l = s.getKeyValueListForStream()), s.Rect = c, s.hasAppearanceStream && !s.appearanceStreamContent) {
            var u = GO(s);
            l.push({ key: "AP", value: "<</N " + u + ">>" }), n.internal.acroformPlugin.xForms.push(u);
          }
          if (s.appearanceStreamContent) {
            var A = "";
            for (var p in s.appearanceStreamContent) if (s.appearanceStreamContent.hasOwnProperty(p)) {
              var d = s.appearanceStreamContent[p];
              if (A += "/" + p + " ", A += "<<", Object.keys(d).length >= 1 || Array.isArray(d)) {
                for (var a in d) if (d.hasOwnProperty(a)) {
                  var g = d[a];
                  typeof g == "function" && (g = g.call(n, s)), A += "/" + a + " " + g + " ", n.internal.acroformPlugin.xForms.indexOf(g) >= 0 || n.internal.acroformPlugin.xForms.push(g);
                }
              } else typeof (g = d) == "function" && (g = g.call(n, s)), A += "/" + a + " " + g, n.internal.acroformPlugin.xForms.indexOf(g) >= 0 || n.internal.acroformPlugin.xForms.push(g);
              A += ">>";
            }
            l.push({ key: "AP", value: `<<
` + A + ">>" });
          }
          n.internal.putStream({ additionalKeyValues: l, objectId: s.objId }), n.internal.out("endobj");
        }
        i && (function(_, f) {
          for (var m in _) if (_.hasOwnProperty(m)) {
            var b = m, v = _[m];
            f.internal.newObjectDeferredBegin(v.objId, !0), yr(v) === "object" && typeof v.putStream == "function" && v.putStream(), delete _[b];
          }
        })(n.internal.acroformPlugin.xForms, n);
      })(t, o);
    }), o.internal.acroformPlugin.isInitialized = !0;
  }
}, pj = po.__acroform__.arrayToPdfArray = function(o, e, t) {
  var r = function(a) {
    return a;
  };
  if (Array.isArray(o)) {
    for (var n = "[", i = 0; i < o.length; i++) switch (i !== 0 && (n += " "), yr(o[i])) {
      case "boolean":
      case "number":
      case "object":
        n += o[i].toString();
        break;
      case "string":
        o[i].substr(0, 1) !== "/" ? (e !== void 0 && t && (r = t.internal.getEncryptor(e)), n += "(" + Hl(r(o[i].toString())) + ")") : n += o[i].toString();
    }
    return n + "]";
  }
  throw new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray");
}, F_ = function(o, e, t) {
  var r = function(n) {
    return n;
  };
  return e !== void 0 && t && (r = t.internal.getEncryptor(e)), (o = o || "").toString(), "(" + Hl(r(o)) + ")";
}, la = function() {
  this._objId = void 0, this._scope = void 0, Object.defineProperty(this, "objId", { get: function() {
    if (this._objId === void 0) {
      if (this.scope === void 0) return;
      this._objId = this.scope.internal.newObjectDeferred();
    }
    return this._objId;
  }, set: function(o) {
    this._objId = o;
  } }), Object.defineProperty(this, "scope", { value: this._scope, writable: !0 });
};
la.prototype.toString = function() {
  return this.objId + " 0 R";
}, la.prototype.putStream = function() {
  var o = this.getKeyValueListForStream();
  this.scope.internal.putStream({ data: this.stream, additionalKeyValues: o, objectId: this.objId }), this.scope.internal.out("endobj");
}, la.prototype.getKeyValueListForStream = function() {
  var o = [], e = Object.getOwnPropertyNames(this).filter(function(i) {
    return i != "content" && i != "appearanceStreamContent" && i != "scope" && i != "objId" && i.substring(0, 1) != "_";
  });
  for (var t in e) if (Object.getOwnPropertyDescriptor(this, e[t]).configurable === !1) {
    var r = e[t], n = this[r];
    n && (Array.isArray(n) ? o.push({ key: r, value: pj(n, this.objId, this.scope) }) : n instanceof la ? (n.scope = this.scope, o.push({ key: r, value: n.objId + " 0 R" })) : typeof n != "function" && o.push({ key: r, value: n }));
  }
  return o;
};
var hj = function() {
  la.call(this), Object.defineProperty(this, "Type", { value: "/XObject", configurable: !1, writable: !0 }), Object.defineProperty(this, "Subtype", { value: "/Form", configurable: !1, writable: !0 }), Object.defineProperty(this, "FormType", { value: 1, configurable: !1, writable: !0 });
  var o, e = [];
  Object.defineProperty(this, "BBox", { configurable: !1, get: function() {
    return e;
  }, set: function(t) {
    e = t;
  } }), Object.defineProperty(this, "Resources", { value: "2 0 R", configurable: !1, writable: !0 }), Object.defineProperty(this, "stream", { enumerable: !1, configurable: !0, set: function(t) {
    o = t.trim();
  }, get: function() {
    return o || null;
  } });
};
zn(hj, la);
var gj = function() {
  la.call(this);
  var o, e = [];
  Object.defineProperty(this, "Kids", { enumerable: !1, configurable: !0, get: function() {
    return e.length > 0 ? e : void 0;
  } }), Object.defineProperty(this, "Fields", { enumerable: !1, configurable: !1, get: function() {
    return e;
  } }), Object.defineProperty(this, "DA", { enumerable: !1, configurable: !1, get: function() {
    if (o) {
      var t = function(r) {
        return r;
      };
      return this.scope && (t = this.scope.internal.getEncryptor(this.objId)), "(" + Hl(t(o)) + ")";
    }
  }, set: function(t) {
    o = t;
  } });
};
zn(gj, la);
var Vi = function o() {
  la.call(this);
  var e = 4;
  Object.defineProperty(this, "F", { enumerable: !1, configurable: !1, get: function() {
    return e;
  }, set: function(m) {
    if (isNaN(m)) throw new Error('Invalid value "' + m + '" for attribute F supplied.');
    e = m;
  } }), Object.defineProperty(this, "showWhenPrinted", { enumerable: !0, configurable: !0, get: function() {
    return !!So(e, 3);
  }, set: function(m) {
    m ? this.F = Bo(e, 3) : this.F = Eo(e, 3);
  } });
  var t = 0;
  Object.defineProperty(this, "Ff", { enumerable: !1, configurable: !1, get: function() {
    return t;
  }, set: function(m) {
    if (isNaN(m)) throw new Error('Invalid value "' + m + '" for attribute Ff supplied.');
    t = m;
  } });
  var r = [];
  Object.defineProperty(this, "Rect", { enumerable: !1, configurable: !1, get: function() {
    if (r.length !== 0) return r;
  }, set: function(m) {
    r = m !== void 0 ? m : [];
  } }), Object.defineProperty(this, "x", { enumerable: !0, configurable: !0, get: function() {
    return !r || isNaN(r[0]) ? 0 : r[0];
  }, set: function(m) {
    r[0] = m;
  } }), Object.defineProperty(this, "y", { enumerable: !0, configurable: !0, get: function() {
    return !r || isNaN(r[1]) ? 0 : r[1];
  }, set: function(m) {
    r[1] = m;
  } }), Object.defineProperty(this, "width", { enumerable: !0, configurable: !0, get: function() {
    return !r || isNaN(r[2]) ? 0 : r[2];
  }, set: function(m) {
    r[2] = m;
  } }), Object.defineProperty(this, "height", { enumerable: !0, configurable: !0, get: function() {
    return !r || isNaN(r[3]) ? 0 : r[3];
  }, set: function(m) {
    r[3] = m;
  } });
  var n = "";
  Object.defineProperty(this, "FT", { enumerable: !0, configurable: !1, get: function() {
    return n;
  }, set: function(m) {
    switch (m) {
      case "/Btn":
      case "/Tx":
      case "/Ch":
      case "/Sig":
        n = m;
        break;
      default:
        throw new Error('Invalid value "' + m + '" for attribute FT supplied.');
    }
  } });
  var i = null;
  Object.defineProperty(this, "T", { enumerable: !0, configurable: !1, get: function() {
    if (!i || i.length < 1) {
      if (this instanceof kh) return;
      i = "FieldObject" + o.FieldNum++;
    }
    var m = function(b) {
      return b;
    };
    return this.scope && (m = this.scope.internal.getEncryptor(this.objId)), "(" + Hl(m(i)) + ")";
  }, set: function(m) {
    i = m.toString();
  } }), Object.defineProperty(this, "fieldName", { configurable: !0, enumerable: !0, get: function() {
    return i;
  }, set: function(m) {
    i = m;
  } });
  var a = "helvetica";
  Object.defineProperty(this, "fontName", { enumerable: !0, configurable: !0, get: function() {
    return a;
  }, set: function(m) {
    a = m;
  } });
  var s = "normal";
  Object.defineProperty(this, "fontStyle", { enumerable: !0, configurable: !0, get: function() {
    return s;
  }, set: function(m) {
    s = m;
  } });
  var l = 0;
  Object.defineProperty(this, "fontSize", { enumerable: !0, configurable: !0, get: function() {
    return l;
  }, set: function(m) {
    l = m;
  } });
  var c = void 0;
  Object.defineProperty(this, "maxFontSize", { enumerable: !0, configurable: !0, get: function() {
    return c === void 0 ? 50 / Fv : c;
  }, set: function(m) {
    c = m;
  } });
  var u = "black";
  Object.defineProperty(this, "color", { enumerable: !0, configurable: !0, get: function() {
    return u;
  }, set: function(m) {
    u = m;
  } });
  var A = "/F1 0 Tf 0 g";
  Object.defineProperty(this, "DA", { enumerable: !0, configurable: !1, get: function() {
    if (!(!A || this instanceof kh || this instanceof Fl)) return F_(A, this.objId, this.scope);
  }, set: function(m) {
    m = m.toString(), A = m;
  } });
  var p = null;
  Object.defineProperty(this, "DV", { enumerable: !1, configurable: !1, get: function() {
    if (p) return this instanceof Jo == 0 ? F_(p, this.objId, this.scope) : p;
  }, set: function(m) {
    m = m.toString(), p = this instanceof Jo == 0 ? m.substr(0, 1) === "(" ? dc(m.substr(1, m.length - 2)) : dc(m) : m;
  } }), Object.defineProperty(this, "defaultValue", { enumerable: !0, configurable: !0, get: function() {
    return this instanceof Jo == 1 ? dc(p.substr(1, p.length - 1)) : p;
  }, set: function(m) {
    m = m.toString(), p = this instanceof Jo == 1 ? "/" + m : m;
  } });
  var d = null;
  Object.defineProperty(this, "_V", { enumerable: !1, configurable: !1, get: function() {
    if (d) return d;
  }, set: function(m) {
    this.V = m;
  } }), Object.defineProperty(this, "V", { enumerable: !1, configurable: !1, get: function() {
    if (d) return this instanceof Jo == 0 ? F_(d, this.objId, this.scope) : d;
  }, set: function(m) {
    m = m.toString(), d = this instanceof Jo == 0 ? m.substr(0, 1) === "(" ? dc(m.substr(1, m.length - 2)) : dc(m) : m;
  } }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, get: function() {
    return this instanceof Jo == 1 ? dc(d.substr(1, d.length - 1)) : d;
  }, set: function(m) {
    m = m.toString(), d = this instanceof Jo == 1 ? "/" + m : m;
  } }), Object.defineProperty(this, "hasAnnotation", { enumerable: !0, configurable: !0, get: function() {
    return this.Rect;
  } }), Object.defineProperty(this, "Type", { enumerable: !0, configurable: !1, get: function() {
    return this.hasAnnotation ? "/Annot" : null;
  } }), Object.defineProperty(this, "Subtype", { enumerable: !0, configurable: !1, get: function() {
    return this.hasAnnotation ? "/Widget" : null;
  } });
  var g, _ = !1;
  Object.defineProperty(this, "hasAppearanceStream", { enumerable: !0, configurable: !0, get: function() {
    return _;
  }, set: function(m) {
    m = !!m, _ = m;
  } }), Object.defineProperty(this, "page", { enumerable: !0, configurable: !0, get: function() {
    if (g) return g;
  }, set: function(m) {
    g = m;
  } }), Object.defineProperty(this, "readOnly", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 1);
  }, set: function(m) {
    m ? this.Ff = Bo(this.Ff, 1) : this.Ff = Eo(this.Ff, 1);
  } }), Object.defineProperty(this, "required", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 2);
  }, set: function(m) {
    m ? this.Ff = Bo(this.Ff, 2) : this.Ff = Eo(this.Ff, 2);
  } }), Object.defineProperty(this, "noExport", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 3);
  }, set: function(m) {
    m ? this.Ff = Bo(this.Ff, 3) : this.Ff = Eo(this.Ff, 3);
  } });
  var f = null;
  Object.defineProperty(this, "Q", { enumerable: !0, configurable: !1, get: function() {
    if (f !== null) return f;
  }, set: function(m) {
    if ([0, 1, 2].indexOf(m) === -1) throw new Error('Invalid value "' + m + '" for attribute Q supplied.');
    f = m;
  } }), Object.defineProperty(this, "textAlign", { get: function() {
    var m;
    switch (f) {
      case 0:
      default:
        m = "left";
        break;
      case 1:
        m = "center";
        break;
      case 2:
        m = "right";
    }
    return m;
  }, configurable: !0, enumerable: !0, set: function(m) {
    switch (m) {
      case "right":
      case 2:
        f = 2;
        break;
      case "center":
      case 1:
        f = 1;
        break;
      default:
        f = 0;
    }
  } });
};
zn(Vi, la);
var Qc = function() {
  Vi.call(this), this.FT = "/Ch", this.V = "()", this.fontName = "zapfdingbats";
  var o = 0;
  Object.defineProperty(this, "TI", { enumerable: !0, configurable: !1, get: function() {
    return o;
  }, set: function(t) {
    o = t;
  } }), Object.defineProperty(this, "topIndex", { enumerable: !0, configurable: !0, get: function() {
    return o;
  }, set: function(t) {
    o = t;
  } });
  var e = [];
  Object.defineProperty(this, "Opt", { enumerable: !0, configurable: !1, get: function() {
    return pj(e, this.objId, this.scope);
  }, set: function(t) {
    var r, n;
    n = [], typeof (r = t) == "string" && (n = (function(i, a, s) {
      s || (s = 1);
      for (var l, c = []; l = a.exec(i); ) c.push(l[s]);
      return c;
    })(r, /\((.*?)\)/g)), e = n;
  } }), this.getOptions = function() {
    return e;
  }, this.setOptions = function(t) {
    e = t, this.sort && e.sort();
  }, this.addOption = function(t) {
    t = (t = t || "").toString(), e.push(t), this.sort && e.sort();
  }, this.removeOption = function(t, r) {
    for (r = r || !1, t = (t = t || "").toString(); e.indexOf(t) !== -1 && (e.splice(e.indexOf(t), 1), r !== !1); ) ;
  }, Object.defineProperty(this, "combo", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 18);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 18) : this.Ff = Eo(this.Ff, 18);
  } }), Object.defineProperty(this, "edit", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 19);
  }, set: function(t) {
    this.combo === !0 && (t ? this.Ff = Bo(this.Ff, 19) : this.Ff = Eo(this.Ff, 19));
  } }), Object.defineProperty(this, "sort", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 20);
  }, set: function(t) {
    t ? (this.Ff = Bo(this.Ff, 20), e.sort()) : this.Ff = Eo(this.Ff, 20);
  } }), Object.defineProperty(this, "multiSelect", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 22);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 22) : this.Ff = Eo(this.Ff, 22);
  } }), Object.defineProperty(this, "doNotSpellCheck", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 23);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 23) : this.Ff = Eo(this.Ff, 23);
  } }), Object.defineProperty(this, "commitOnSelChange", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 27);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 27) : this.Ff = Eo(this.Ff, 27);
  } }), this.hasAppearanceStream = !1;
};
zn(Qc, Vi);
var qc = function() {
  Qc.call(this), this.fontName = "helvetica", this.combo = !1;
};
zn(qc, Qc);
var Gc = function() {
  qc.call(this), this.combo = !0;
};
zn(Gc, qc);
var th = function() {
  Gc.call(this), this.edit = !0;
};
zn(th, Gc);
var Jo = function() {
  Vi.call(this), this.FT = "/Btn", Object.defineProperty(this, "noToggleToOff", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 15);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 15) : this.Ff = Eo(this.Ff, 15);
  } }), Object.defineProperty(this, "radio", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 16);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 16) : this.Ff = Eo(this.Ff, 16);
  } }), Object.defineProperty(this, "pushButton", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 17);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 17) : this.Ff = Eo(this.Ff, 17);
  } }), Object.defineProperty(this, "radioIsUnison", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 26);
  }, set: function(t) {
    t ? this.Ff = Bo(this.Ff, 26) : this.Ff = Eo(this.Ff, 26);
  } });
  var o, e = {};
  Object.defineProperty(this, "MK", { enumerable: !1, configurable: !1, get: function() {
    var t = function(i) {
      return i;
    };
    if (this.scope && (t = this.scope.internal.getEncryptor(this.objId)), Object.keys(e).length !== 0) {
      var r, n = [];
      for (r in n.push("<<"), e) n.push("/" + r + " (" + Hl(t(e[r])) + ")");
      return n.push(">>"), n.join(`
`);
    }
  }, set: function(t) {
    yr(t) === "object" && (e = t);
  } }), Object.defineProperty(this, "caption", { enumerable: !0, configurable: !0, get: function() {
    return e.CA || "";
  }, set: function(t) {
    typeof t == "string" && (e.CA = t);
  } }), Object.defineProperty(this, "AS", { enumerable: !1, configurable: !1, get: function() {
    return o;
  }, set: function(t) {
    o = t;
  } }), Object.defineProperty(this, "appearanceState", { enumerable: !0, configurable: !0, get: function() {
    return o.substr(1, o.length - 1);
  }, set: function(t) {
    o = "/" + t;
  } });
};
zn(Jo, Vi);
var rh = function() {
  Jo.call(this), this.pushButton = !0;
};
zn(rh, Jo);
var Vc = function() {
  Jo.call(this), this.radio = !0, this.pushButton = !1;
  var o = [];
  Object.defineProperty(this, "Kids", { enumerable: !0, configurable: !1, get: function() {
    return o;
  }, set: function(e) {
    o = e !== void 0 ? e : [];
  } });
};
zn(Vc, Jo);
var kh = function() {
  var o, e;
  Vi.call(this), Object.defineProperty(this, "Parent", { enumerable: !1, configurable: !1, get: function() {
    return o;
  }, set: function(n) {
    o = n;
  } }), Object.defineProperty(this, "optionName", { enumerable: !1, configurable: !0, get: function() {
    return e;
  }, set: function(n) {
    e = n;
  } });
  var t, r = {};
  Object.defineProperty(this, "MK", { enumerable: !1, configurable: !1, get: function() {
    var n = function(s) {
      return s;
    };
    this.scope && (n = this.scope.internal.getEncryptor(this.objId));
    var i, a = [];
    for (i in a.push("<<"), r) a.push("/" + i + " (" + Hl(n(r[i])) + ")");
    return a.push(">>"), a.join(`
`);
  }, set: function(n) {
    yr(n) === "object" && (r = n);
  } }), Object.defineProperty(this, "caption", { enumerable: !0, configurable: !0, get: function() {
    return r.CA || "";
  }, set: function(n) {
    typeof n == "string" && (r.CA = n);
  } }), Object.defineProperty(this, "AS", { enumerable: !1, configurable: !1, get: function() {
    return t;
  }, set: function(n) {
    t = n;
  } }), Object.defineProperty(this, "appearanceState", { enumerable: !0, configurable: !0, get: function() {
    return t.substr(1, t.length - 1);
  }, set: function(n) {
    t = "/" + n;
  } }), this.caption = "l", this.appearanceState = "Off", this._AppearanceType = kt.RadioButton.Circle, this.appearanceStreamContent = this._AppearanceType.createAppearanceStream(this.optionName);
};
zn(kh, Vi), Vc.prototype.setAppearance = function(o) {
  if (!("createAppearanceStream" in o) || !("getCA" in o)) throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");
  for (var e in this.Kids) if (this.Kids.hasOwnProperty(e)) {
    var t = this.Kids[e];
    t.appearanceStreamContent = o.createAppearanceStream(t.optionName), t.caption = o.getCA();
  }
}, Vc.prototype.createOption = function(o) {
  var e = new kh();
  return e.Parent = this, e.optionName = o, this.Kids.push(e), zO.call(this.scope, e), e;
};
var oh = function() {
  Jo.call(this), this.fontName = "zapfdingbats", this.caption = "3", this.appearanceState = "On", this.value = "On", this.textAlign = "center", this.appearanceStreamContent = kt.CheckBox.createAppearanceStream();
};
zn(oh, Jo);
var Fl = function() {
  Vi.call(this), this.FT = "/Tx", Object.defineProperty(this, "multiline", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 13);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 13) : this.Ff = Eo(this.Ff, 13);
  } }), Object.defineProperty(this, "fileSelect", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 21);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 21) : this.Ff = Eo(this.Ff, 21);
  } }), Object.defineProperty(this, "doNotSpellCheck", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 23);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 23) : this.Ff = Eo(this.Ff, 23);
  } }), Object.defineProperty(this, "doNotScroll", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 24);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 24) : this.Ff = Eo(this.Ff, 24);
  } }), Object.defineProperty(this, "comb", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 25);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 25) : this.Ff = Eo(this.Ff, 25);
  } }), Object.defineProperty(this, "richText", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 26);
  }, set: function(e) {
    e ? this.Ff = Bo(this.Ff, 26) : this.Ff = Eo(this.Ff, 26);
  } });
  var o = null;
  Object.defineProperty(this, "MaxLen", { enumerable: !0, configurable: !1, get: function() {
    return o;
  }, set: function(e) {
    o = e;
  } }), Object.defineProperty(this, "maxLength", { enumerable: !0, configurable: !0, get: function() {
    return o;
  }, set: function(e) {
    Number.isInteger(e) && (o = e);
  } }), Object.defineProperty(this, "hasAppearanceStream", { enumerable: !0, configurable: !0, get: function() {
    return this.V || this.DV;
  } });
};
zn(Fl, Vi);
var nh = function() {
  Fl.call(this), Object.defineProperty(this, "password", { enumerable: !0, configurable: !0, get: function() {
    return !!So(this.Ff, 14);
  }, set: function(o) {
    o ? this.Ff = Bo(this.Ff, 14) : this.Ff = Eo(this.Ff, 14);
  } }), this.password = !0;
};
zn(nh, Fl);
var kt = { CheckBox: { createAppearanceStream: function() {
  return { N: { On: kt.CheckBox.YesNormal }, D: { On: kt.CheckBox.YesPushDown, Off: kt.CheckBox.OffPushDown } };
}, YesPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [], r = o.scope.internal.getFont(o.fontName, o.fontStyle).id, n = o.scope.__private__.encodeColorString(o.color), i = wb(o, o.caption);
  return t.push("0.749023 g"), t.push("0 0 " + Wt(kt.internal.getWidth(o)) + " " + Wt(kt.internal.getHeight(o)) + " re"), t.push("f"), t.push("BMC"), t.push("q"), t.push("0 0 1 rg"), t.push("/" + r + " " + Wt(i.fontSize) + " Tf " + n), t.push("BT"), t.push(i.text), t.push("ET"), t.push("Q"), t.push("EMC"), e.stream = t.join(`
`), e;
}, YesNormal: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = o.scope.internal.getFont(o.fontName, o.fontStyle).id, r = o.scope.__private__.encodeColorString(o.color), n = [], i = kt.internal.getHeight(o), a = kt.internal.getWidth(o), s = wb(o, o.caption);
  return n.push("1 g"), n.push("0 0 " + Wt(a) + " " + Wt(i) + " re"), n.push("f"), n.push("q"), n.push("0 0 1 rg"), n.push("0 0 " + Wt(a - 1) + " " + Wt(i - 1) + " re"), n.push("W"), n.push("n"), n.push("0 g"), n.push("BT"), n.push("/" + t + " " + Wt(s.fontSize) + " Tf " + r), n.push(s.text), n.push("ET"), n.push("Q"), e.stream = n.join(`
`), e;
}, OffPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [];
  return t.push("0.749023 g"), t.push("0 0 " + Wt(kt.internal.getWidth(o)) + " " + Wt(kt.internal.getHeight(o)) + " re"), t.push("f"), e.stream = t.join(`
`), e;
} }, RadioButton: { Circle: { createAppearanceStream: function(o) {
  var e = { D: { Off: kt.RadioButton.Circle.OffPushDown }, N: {} };
  return e.N[o] = kt.RadioButton.Circle.YesNormal, e.D[o] = kt.RadioButton.Circle.YesPushDown, e;
}, getCA: function() {
  return "l";
}, YesNormal: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [], r = kt.internal.getWidth(o) <= kt.internal.getHeight(o) ? kt.internal.getWidth(o) / 4 : kt.internal.getHeight(o) / 4;
  r = Number((0.9 * r).toFixed(5));
  var n = kt.internal.Bezier_C, i = Number((r * n).toFixed(5));
  return t.push("q"), t.push("1 0 0 1 " + vs(kt.internal.getWidth(o) / 2) + " " + vs(kt.internal.getHeight(o) / 2) + " cm"), t.push(r + " 0 m"), t.push(r + " " + i + " " + i + " " + r + " 0 " + r + " c"), t.push("-" + i + " " + r + " -" + r + " " + i + " -" + r + " 0 c"), t.push("-" + r + " -" + i + " -" + i + " -" + r + " 0 -" + r + " c"), t.push(i + " -" + r + " " + r + " -" + i + " " + r + " 0 c"), t.push("f"), t.push("Q"), e.stream = t.join(`
`), e;
}, YesPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [], r = kt.internal.getWidth(o) <= kt.internal.getHeight(o) ? kt.internal.getWidth(o) / 4 : kt.internal.getHeight(o) / 4;
  r = Number((0.9 * r).toFixed(5));
  var n = Number((2 * r).toFixed(5)), i = Number((n * kt.internal.Bezier_C).toFixed(5)), a = Number((r * kt.internal.Bezier_C).toFixed(5));
  return t.push("0.749023 g"), t.push("q"), t.push("1 0 0 1 " + vs(kt.internal.getWidth(o) / 2) + " " + vs(kt.internal.getHeight(o) / 2) + " cm"), t.push(n + " 0 m"), t.push(n + " " + i + " " + i + " " + n + " 0 " + n + " c"), t.push("-" + i + " " + n + " -" + n + " " + i + " -" + n + " 0 c"), t.push("-" + n + " -" + i + " -" + i + " -" + n + " 0 -" + n + " c"), t.push(i + " -" + n + " " + n + " -" + i + " " + n + " 0 c"), t.push("f"), t.push("Q"), t.push("0 g"), t.push("q"), t.push("1 0 0 1 " + vs(kt.internal.getWidth(o) / 2) + " " + vs(kt.internal.getHeight(o) / 2) + " cm"), t.push(r + " 0 m"), t.push(r + " " + a + " " + a + " " + r + " 0 " + r + " c"), t.push("-" + a + " " + r + " -" + r + " " + a + " -" + r + " 0 c"), t.push("-" + r + " -" + a + " -" + a + " -" + r + " 0 -" + r + " c"), t.push(a + " -" + r + " " + r + " -" + a + " " + r + " 0 c"), t.push("f"), t.push("Q"), e.stream = t.join(`
`), e;
}, OffPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [], r = kt.internal.getWidth(o) <= kt.internal.getHeight(o) ? kt.internal.getWidth(o) / 4 : kt.internal.getHeight(o) / 4;
  r = Number((0.9 * r).toFixed(5));
  var n = Number((2 * r).toFixed(5)), i = Number((n * kt.internal.Bezier_C).toFixed(5));
  return t.push("0.749023 g"), t.push("q"), t.push("1 0 0 1 " + vs(kt.internal.getWidth(o) / 2) + " " + vs(kt.internal.getHeight(o) / 2) + " cm"), t.push(n + " 0 m"), t.push(n + " " + i + " " + i + " " + n + " 0 " + n + " c"), t.push("-" + i + " " + n + " -" + n + " " + i + " -" + n + " 0 c"), t.push("-" + n + " -" + i + " -" + i + " -" + n + " 0 -" + n + " c"), t.push(i + " -" + n + " " + n + " -" + i + " " + n + " 0 c"), t.push("f"), t.push("Q"), e.stream = t.join(`
`), e;
} }, Cross: { createAppearanceStream: function(o) {
  var e = { D: { Off: kt.RadioButton.Cross.OffPushDown }, N: {} };
  return e.N[o] = kt.RadioButton.Cross.YesNormal, e.D[o] = kt.RadioButton.Cross.YesPushDown, e;
}, getCA: function() {
  return "8";
}, YesNormal: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [], r = kt.internal.calculateCross(o);
  return t.push("q"), t.push("1 1 " + Wt(kt.internal.getWidth(o) - 2) + " " + Wt(kt.internal.getHeight(o) - 2) + " re"), t.push("W"), t.push("n"), t.push(Wt(r.x1.x) + " " + Wt(r.x1.y) + " m"), t.push(Wt(r.x2.x) + " " + Wt(r.x2.y) + " l"), t.push(Wt(r.x4.x) + " " + Wt(r.x4.y) + " m"), t.push(Wt(r.x3.x) + " " + Wt(r.x3.y) + " l"), t.push("s"), t.push("Q"), e.stream = t.join(`
`), e;
}, YesPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = kt.internal.calculateCross(o), r = [];
  return r.push("0.749023 g"), r.push("0 0 " + Wt(kt.internal.getWidth(o)) + " " + Wt(kt.internal.getHeight(o)) + " re"), r.push("f"), r.push("q"), r.push("1 1 " + Wt(kt.internal.getWidth(o) - 2) + " " + Wt(kt.internal.getHeight(o) - 2) + " re"), r.push("W"), r.push("n"), r.push(Wt(t.x1.x) + " " + Wt(t.x1.y) + " m"), r.push(Wt(t.x2.x) + " " + Wt(t.x2.y) + " l"), r.push(Wt(t.x4.x) + " " + Wt(t.x4.y) + " m"), r.push(Wt(t.x3.x) + " " + Wt(t.x3.y) + " l"), r.push("s"), r.push("Q"), e.stream = r.join(`
`), e;
}, OffPushDown: function(o) {
  var e = ia(o);
  e.scope = o.scope;
  var t = [];
  return t.push("0.749023 g"), t.push("0 0 " + Wt(kt.internal.getWidth(o)) + " " + Wt(kt.internal.getHeight(o)) + " re"), t.push("f"), e.stream = t.join(`
`), e;
} } }, createDefaultAppearanceStream: function(o) {
  var e = o.scope.internal.getFont(o.fontName, o.fontStyle).id, t = o.scope.__private__.encodeColorString(o.color);
  return "/" + e + " " + o.fontSize + " Tf " + t;
} };
kt.internal = { Bezier_C: 0.551915024494, calculateCross: function(o) {
  var e = kt.internal.getWidth(o), t = kt.internal.getHeight(o), r = Math.min(e, t);
  return { x1: { x: (e - r) / 2, y: (t - r) / 2 + r }, x2: { x: (e - r) / 2 + r, y: (t - r) / 2 }, x3: { x: (e - r) / 2, y: (t - r) / 2 }, x4: { x: (e - r) / 2 + r, y: (t - r) / 2 + r } };
} }, kt.internal.getWidth = function(o) {
  var e = 0;
  return yr(o) === "object" && (e = Kx(o.Rect[2])), e;
}, kt.internal.getHeight = function(o) {
  var e = 0;
  return yr(o) === "object" && (e = Kx(o.Rect[3])), e;
};
var zO = po.addField = function(o) {
  if (HO(this, o), !(o instanceof Vi)) throw new Error("Invalid argument passed to jsPDF.addField.");
  var e;
  return (e = o).scope.internal.acroformPlugin.printedOut && (e.scope.internal.acroformPlugin.printedOut = !1, e.scope.internal.acroformPlugin.acroFormDictionaryRoot = null), e.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(e), o.page = o.scope.internal.getCurrentPageInfo().pageNumber, this;
};
po.AcroFormChoiceField = Qc, po.AcroFormListBox = qc, po.AcroFormComboBox = Gc, po.AcroFormEditBox = th, po.AcroFormButton = Jo, po.AcroFormPushButton = rh, po.AcroFormRadioButton = Vc, po.AcroFormCheckBox = oh, po.AcroFormTextField = Fl, po.AcroFormPasswordField = nh, po.AcroFormAppearance = kt, po.AcroForm = { ChoiceField: Qc, ListBox: qc, ComboBox: Gc, EditBox: th, Button: Jo, PushButton: rh, RadioButton: Vc, CheckBox: oh, TextField: Fl, PasswordField: nh, Appearance: kt }, Tt.AcroForm = { ChoiceField: Qc, ListBox: qc, ComboBox: Gc, EditBox: th, Button: Jo, PushButton: rh, RadioButton: Vc, CheckBox: oh, TextField: Fl, PasswordField: nh, Appearance: kt };
Tt.AcroForm;
function _j(o) {
  return o.reduce(function(e, t, r) {
    return e[t] = r, e;
  }, {});
}
(function(o) {
  var e = "addImage_";
  o.__addimage__ = {};
  var t = "UNKNOWN", r = { PNG: [[137, 80, 78, 71]], TIFF: [[77, 77, 0, 42], [73, 73, 42, 0]], JPEG: [[255, 216, 255, 224, void 0, void 0, 74, 70, 73, 70, 0], [255, 216, 255, 225, void 0, void 0, 69, 120, 105, 102, 0, 0], [255, 216, 255, 219], [255, 216, 255, 238]], JPEG2000: [[0, 0, 0, 12, 106, 80, 32, 32]], GIF87a: [[71, 73, 70, 56, 55, 97]], GIF89a: [[71, 73, 70, 56, 57, 97]], WEBP: [[82, 73, 70, 70, void 0, void 0, void 0, void 0, 87, 69, 66, 80]], BMP: [[66, 77], [66, 65], [67, 73], [67, 80], [73, 67], [80, 84]] }, n = o.__addimage__.getImageFileTypeByImageData = function(S, L) {
    var U, O, K, te, Y, ee = t;
    if ((L = L || t) === "RGBA" || S.data !== void 0 && S.data instanceof Uint8ClampedArray && "height" in S && "width" in S) return "RGBA";
    if (E(S)) for (Y in r) for (K = r[Y], U = 0; U < K.length; U += 1) {
      for (te = !0, O = 0; O < K[U].length; O += 1) if (K[U][O] !== void 0 && K[U][O] !== S[O]) {
        te = !1;
        break;
      }
      if (te === !0) {
        ee = Y;
        break;
      }
    }
    else for (Y in r) for (K = r[Y], U = 0; U < K.length; U += 1) {
      for (te = !0, O = 0; O < K[U].length; O += 1) if (K[U][O] !== void 0 && K[U][O] !== S.charCodeAt(O)) {
        te = !1;
        break;
      }
      if (te === !0) {
        ee = Y;
        break;
      }
    }
    return ee === t && L !== t && (ee = L), ee;
  }, i = function S(L) {
    for (var U = this.internal.write, O = this.internal.putStream, K = (0, this.internal.getFilters)(); K.indexOf("FlateEncode") !== -1; ) K.splice(K.indexOf("FlateEncode"), 1);
    L.objectId = this.internal.newObject();
    var te = [];
    if (te.push({ key: "Type", value: "/XObject" }), te.push({ key: "Subtype", value: "/Image" }), te.push({ key: "Width", value: L.width }), te.push({ key: "Height", value: L.height }), L.colorSpace === m.INDEXED ? te.push({ key: "ColorSpace", value: "[/Indexed /DeviceRGB " + (L.palette.length / 3 - 1) + " " + ("sMask" in L && L.sMask !== void 0 ? L.objectId + 2 : L.objectId + 1) + " 0 R]" }) : (te.push({ key: "ColorSpace", value: "/" + L.colorSpace }), L.colorSpace === m.DEVICE_CMYK && te.push({ key: "Decode", value: "[1 0 1 0 1 0 1 0]" })), te.push({ key: "BitsPerComponent", value: L.bitsPerComponent }), "decodeParameters" in L && L.decodeParameters !== void 0 && te.push({ key: "DecodeParms", value: "<<" + L.decodeParameters + ">>" }), "transparency" in L && Array.isArray(L.transparency) && L.transparency.length > 0) {
      for (var Y = "", ee = 0, oe = L.transparency.length; ee < oe; ee++) Y += L.transparency[ee] + " " + L.transparency[ee] + " ";
      te.push({ key: "Mask", value: "[" + Y + "]" });
    }
    L.sMask !== void 0 && te.push({ key: "SMask", value: L.objectId + 1 + " 0 R" });
    var de = L.filter !== void 0 ? ["/" + L.filter] : void 0;
    if (O({ data: L.data, additionalKeyValues: te, alreadyAppliedFilters: de, objectId: L.objectId }), U("endobj"), "sMask" in L && L.sMask !== void 0) {
      var ae, I = (ae = L.sMaskBitsPerComponent) !== null && ae !== void 0 ? ae : L.bitsPerComponent, G = { width: L.width, height: L.height, colorSpace: "DeviceGray", bitsPerComponent: I, data: L.sMask };
      "filter" in L && (G.decodeParameters = "/Predictor ".concat(L.predictor, " /Colors 1 /BitsPerComponent ").concat(I, " /Columns ").concat(L.width), G.filter = L.filter), S.call(this, G);
    }
    if (L.colorSpace === m.INDEXED) {
      var H = this.internal.newObject();
      O({ data: F(new Uint8Array(L.palette)), objectId: H }), U("endobj");
    }
  }, a = function() {
    var S = this.internal.collections[e + "images"];
    for (var L in S) i.call(this, S[L]);
  }, s = function() {
    var S, L = this.internal.collections[e + "images"], U = this.internal.write;
    for (var O in L) U("/I" + (S = L[O]).index, S.objectId, "0", "R");
  }, l = function() {
    this.internal.collections[e + "images"] || (this.internal.collections[e + "images"] = {}, this.internal.events.subscribe("putResources", a), this.internal.events.subscribe("putXobjectDict", s));
  }, c = function() {
    var S = this.internal.collections[e + "images"];
    return l.call(this), S;
  }, u = function() {
    return Object.keys(this.internal.collections[e + "images"]).length;
  }, A = function(S) {
    return typeof o["process" + S.toUpperCase()] == "function";
  }, p = function(S) {
    return yr(S) === "object" && S.nodeType === 1;
  }, d = function(S, L) {
    if (S.nodeName === "IMG" && S.hasAttribute("src")) {
      var U = "" + S.getAttribute("src");
      if (U.indexOf("data:image/") === 0) return eh(unescape(U).split("base64,").pop());
      var O = o.loadFile(U, !0);
      if (O !== void 0) return O;
    }
    if (S.nodeName === "CANVAS") {
      if (S.width === 0 || S.height === 0) throw new Error("Given canvas must have data. Canvas width: " + S.width + ", height: " + S.height);
      var K;
      switch (L) {
        case "PNG":
          K = "image/png";
          break;
        case "WEBP":
          K = "image/webp";
          break;
        default:
          K = "image/jpeg";
      }
      return eh(S.toDataURL(K, 1).split("base64,").pop());
    }
  }, g = function(S) {
    var L = this.internal.collections[e + "images"];
    if (L) {
      for (var U in L) if (S === L[U].alias) return L[U];
    }
  }, _ = function(S, L, U) {
    return S || L || (S = -96, L = -96), S < 0 && (S = -1 * U.width * 72 / S / this.internal.scaleFactor), L < 0 && (L = -1 * U.height * 72 / L / this.internal.scaleFactor), S === 0 && (S = L * U.width / U.height), L === 0 && (L = S * U.height / U.width), [S, L];
  }, f = function(S, L, U, O, K, te) {
    var Y = _.call(this, U, O, K), ee = this.internal.getCoordinateString, oe = this.internal.getVerticalCoordinateString, de = c.call(this);
    if (U = Y[0], O = Y[1], de[K.index] = K, te) {
      te *= Math.PI / 180;
      var ae = Math.cos(te), I = Math.sin(te), G = function(Z) {
        return Z.toFixed(4);
      }, H = [G(ae), G(I), G(-1 * I), G(ae), 0, 0, "cm"];
    }
    this.internal.write("q"), te ? (this.internal.write([1, "0", "0", 1, ee(S), oe(L + O), "cm"].join(" ")), this.internal.write(H.join(" ")), this.internal.write([ee(U), "0", "0", ee(O), "0", "0", "cm"].join(" "))) : this.internal.write([ee(U), "0", "0", ee(O), ee(S), oe(L + O), "cm"].join(" ")), this.isAdvancedAPI() && this.internal.write([1, 0, 0, -1, 0, 0, "cm"].join(" ")), this.internal.write("/I" + K.index + " Do"), this.internal.write("Q");
  }, m = o.color_spaces = { DEVICE_RGB: "DeviceRGB", DEVICE_GRAY: "DeviceGray", DEVICE_CMYK: "DeviceCMYK", CAL_GREY: "CalGray", CAL_RGB: "CalRGB", LAB: "Lab", ICC_BASED: "ICCBased", INDEXED: "Indexed", PATTERN: "Pattern", SEPARATION: "Separation", DEVICE_N: "DeviceN" };
  o.decode = { DCT_DECODE: "DCTDecode", FLATE_DECODE: "FlateDecode", LZW_DECODE: "LZWDecode", JPX_DECODE: "JPXDecode", JBIG2_DECODE: "JBIG2Decode", ASCII85_DECODE: "ASCII85Decode", ASCII_HEX_DECODE: "ASCIIHexDecode", RUN_LENGTH_DECODE: "RunLengthDecode", CCITT_FAX_DECODE: "CCITTFaxDecode" };
  var b = o.image_compression = { NONE: "NONE", FAST: "FAST", MEDIUM: "MEDIUM", SLOW: "SLOW" }, v = o.__addimage__.sHashCode = function(S) {
    var L, U, O = 0;
    if (typeof S == "string") for (U = S.length, L = 0; L < U; L++) O = (O << 5) - O + S.charCodeAt(L), O |= 0;
    else if (E(S)) for (U = S.byteLength / 2, L = 0; L < U; L++) O = (O << 5) - O + S[L], O |= 0;
    return O;
  }, w = o.__addimage__.validateStringAsBase64 = function(S) {
    (S = S || "").toString().trim();
    var L = !0;
    return S.length === 0 && (L = !1), S.length % 4 != 0 && (L = !1), /^[A-Za-z0-9+/]+$/.test(S.substr(0, S.length - 2)) === !1 && (L = !1), /^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(S.substr(-2)) === !1 && (L = !1), L;
  }, C = o.__addimage__.extractImageFromDataUrl = function(S) {
    if (S == null || !(S = S.trim()).startsWith("data:")) return null;
    var L = S.indexOf(",");
    return L < 0 ? null : S.substring(0, L).trim().endsWith("base64") ? S.substring(L + 1) : null;
  };
  o.__addimage__.isArrayBuffer = function(S) {
    return S instanceof ArrayBuffer;
  };
  var E = o.__addimage__.isArrayBufferView = function(S) {
    return S instanceof Int8Array || S instanceof Uint8Array || S instanceof Uint8ClampedArray || S instanceof Int16Array || S instanceof Uint16Array || S instanceof Int32Array || S instanceof Uint32Array || S instanceof Float32Array || S instanceof Float64Array;
  }, T = o.__addimage__.binaryStringToUint8Array = function(S) {
    for (var L = S.length, U = new Uint8Array(L), O = 0; O < L; O++) U[O] = S.charCodeAt(O);
    return U;
  }, F = o.__addimage__.arrayBufferToBinaryString = function(S) {
    for (var L = "", U = E(S) ? S : new Uint8Array(S), O = 0; O < U.length; O += 8192) L += String.fromCharCode.apply(null, U.subarray(O, O + 8192));
    return L;
  };
  o.addImage = function() {
    var S, L, U, O, K, te, Y, ee, oe;
    if (typeof arguments[1] == "number" ? (L = t, U = arguments[1], O = arguments[2], K = arguments[3], te = arguments[4], Y = arguments[5], ee = arguments[6], oe = arguments[7]) : (L = arguments[1], U = arguments[2], O = arguments[3], K = arguments[4], te = arguments[5], Y = arguments[6], ee = arguments[7], oe = arguments[8]), yr(S = arguments[0]) === "object" && !p(S) && "imageData" in S) {
      var de = S;
      S = de.imageData, L = de.format || L || t, U = de.x || U || 0, O = de.y || O || 0, K = de.w || de.width || K, te = de.h || de.height || te, Y = de.alias || Y, ee = de.compression || ee, oe = de.rotation || de.angle || oe;
    }
    var ae = this.internal.getFilters();
    if (ee === void 0 && ae.indexOf("FlateEncode") !== -1 && (ee = "SLOW"), isNaN(U) || isNaN(O)) throw new Error("Invalid coordinates passed to jsPDF.addImage");
    l.call(this);
    var I = B.call(this, S, L, Y, ee);
    return f.call(this, U, O, K, te, I, oe), this;
  };
  var B = function(S, L, U, O) {
    var K, te, Y;
    if (typeof S == "string" && n(S) === t) {
      S = unescape(S);
      var ee = P(S, !1);
      (ee !== "" || (ee = o.loadFile(S, !0)) !== void 0) && (S = ee);
    }
    if (p(S) && (S = d(S, L)), L = n(S, L), !A(L)) throw new Error("addImage does not support files of type '" + L + "', please ensure that a plugin for '" + L + "' support is added.");
    if (((Y = U) == null || Y.length === 0) && (U = (function(oe) {
      return typeof oe == "string" || E(oe) ? v(oe) : E(oe.data) ? v(oe.data) : null;
    })(S)), (K = g.call(this, U)) || (S instanceof Uint8Array || L === "RGBA" || (te = S, S = T(S)), K = this["process" + L.toUpperCase()](S, u.call(this), U, (function(oe) {
      return oe && typeof oe == "string" && (oe = oe.toUpperCase()), oe in o.image_compression ? oe : b.NONE;
    })(O), te)), !K) throw new Error("An unknown error occurred whilst processing the image.");
    return K;
  }, P = o.__addimage__.convertBase64ToBinaryString = function(S, L) {
    L = typeof L != "boolean" || L;
    var U, O = "";
    if (typeof S == "string") {
      var K;
      U = (K = C(S)) !== null && K !== void 0 ? K : S;
      try {
        O = eh(U);
      } catch (te) {
        if (L) throw w(U) ? new Error("atob-Error in jsPDF.convertBase64ToBinaryString " + te.message) : new Error("Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString ");
      }
    }
    return O;
  };
  o.getImageProperties = function(S) {
    var L, U, O = "";
    if (p(S) && (S = d(S)), typeof S == "string" && n(S) === t && ((O = P(S, !1)) === "" && (O = o.loadFile(S) || ""), S = O), U = n(S), !A(U)) throw new Error("addImage does not support files of type '" + U + "', please ensure that a plugin for '" + U + "' support is added.");
    if (S instanceof Uint8Array || (S = T(S)), !(L = this["process" + U.toUpperCase()](S))) throw new Error("An unknown error occurred whilst processing the image");
    return L.fileType = U, L;
  };
})(Tt.API), /**
* @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC)  [email protected]
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = function(t) {
    if (t !== void 0 && t != "") return !0;
  };
  Tt.API.events.push(["addPage", function(t) {
    this.internal.getPageInfo(t.pageNumber).pageContext.annotations = [];
  }]), o.events.push(["putPage", function(t) {
    for (var r, n, i, a = this.internal.getCoordinateString, s = this.internal.getVerticalCoordinateString, l = this.internal.getPageInfoByObjId(t.objId), c = t.pageContext.annotations, u = !1, A = 0; A < c.length && !u; A++) switch ((r = c[A]).type) {
      case "link":
        (e(r.options.url) || e(r.options.pageNumber)) && (u = !0);
        break;
      case "reference":
      case "text":
      case "freetext":
        u = !0;
    }
    if (u != 0) {
      this.internal.write("/Annots [");
      for (var p = 0; p < c.length; p++) {
        r = c[p];
        var d = this.internal.pdfEscape, g = this.internal.getEncryptor(t.objId);
        switch (r.type) {
          case "reference":
            this.internal.write(" " + r.object.objId + " 0 R ");
            break;
          case "text":
            var _ = this.internal.newAdditionalObject(), f = this.internal.newAdditionalObject(), m = this.internal.getEncryptor(_.objId), b = r.title || "Note";
            i = "<</Type /Annot /Subtype /Text " + (n = "/Rect [" + a(r.bounds.x) + " " + s(r.bounds.y + r.bounds.h) + " " + a(r.bounds.x + r.bounds.w) + " " + s(r.bounds.y) + "] ") + "/Contents (" + d(m(r.contents)) + ")", i += " /Popup " + f.objId + " 0 R", i += " /P " + l.objId + " 0 R", i += " /T (" + d(m(b)) + ") >>", _.content = i;
            var v = _.objId + " 0 R";
            i = "<</Type /Annot /Subtype /Popup " + (n = "/Rect [" + a(r.bounds.x + 30) + " " + s(r.bounds.y + r.bounds.h) + " " + a(r.bounds.x + r.bounds.w + 30) + " " + s(r.bounds.y) + "] ") + " /Parent " + v, r.open && (i += " /Open true"), i += " >>", f.content = i, this.internal.write(_.objId, "0 R", f.objId, "0 R");
            break;
          case "freetext":
            n = "/Rect [" + a(r.bounds.x) + " " + s(r.bounds.y) + " " + a(r.bounds.x + r.bounds.w) + " " + s(r.bounds.y + r.bounds.h) + "] ";
            var w = r.color || "#000000";
            i = "<</Type /Annot /Subtype /FreeText " + n + "/Contents (" + d(g(r.contents)) + ")", i += " /DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#" + w + ")", i += " /Border [0 0 0]", i += " >>", this.internal.write(i);
            break;
          case "link":
            if (r.options.name) {
              var C = this.annotations._nameMap[r.options.name];
              r.options.pageNumber = C.page, r.options.top = C.y;
            } else r.options.top || (r.options.top = 0);
            if (n = "/Rect [" + r.finalBounds.x + " " + r.finalBounds.y + " " + r.finalBounds.w + " " + r.finalBounds.h + "] ", i = "", r.options.url) i = "<</Type /Annot /Subtype /Link " + n + "/Border [0 0 0] /A <</S /URI /URI (" + d(g(r.options.url)) + ") >>";
            else if (r.options.pageNumber) switch (i = "<</Type /Annot /Subtype /Link " + n + "/Border [0 0 0] /Dest [" + this.internal.getPageInfo(r.options.pageNumber).objId + " 0 R", r.options.magFactor = r.options.magFactor || "XYZ", r.options.magFactor) {
              case "Fit":
                i += " /Fit]";
                break;
              case "FitH":
                i += " /FitH " + r.options.top + "]";
                break;
              case "FitV":
                r.options.left = r.options.left || 0, i += " /FitV " + r.options.left + "]";
                break;
              default:
                var E = s(r.options.top);
                r.options.left = r.options.left || 0, r.options.zoom === void 0 && (r.options.zoom = 0), i += " /XYZ " + r.options.left + " " + E + " " + r.options.zoom + "]";
            }
            i != "" && (i += " >>", this.internal.write(i));
        }
      }
      this.internal.write("]");
    }
  }]), o.createAnnotation = function(t) {
    var r = this.internal.getCurrentPageInfo();
    switch (t.type) {
      case "link":
        this.link(t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h, t);
        break;
      case "text":
      case "freetext":
        r.pageContext.annotations.push(t);
    }
  }, o.link = function(t, r, n, i, a) {
    var s = this.internal.getCurrentPageInfo(), l = this.internal.getCoordinateString, c = this.internal.getVerticalCoordinateString;
    s.pageContext.annotations.push({ finalBounds: { x: l(t), y: c(r), w: l(t + n), h: c(r + i) }, options: a, type: "link" });
  }, o.textWithLink = function(t, r, n, i) {
    var a, s, l = this.getTextWidth(t), c = this.internal.getLineHeight() / this.internal.scaleFactor;
    if (i.maxWidth !== void 0) {
      s = i.maxWidth;
      var u = this.splitTextToSize(t, s).length;
      a = Math.ceil(c * u);
    } else s = l, a = c;
    return this.text(t, r, n, i), n += 0.2 * c, i.align === "center" && (r -= l / 2), i.align === "right" && (r -= l), this.link(r, n - c, s, a, i), l;
  }, o.getTextWidth = function(t) {
    var r = this.internal.getFontSize();
    return this.getStringUnitWidth(t) * r / this.internal.scaleFactor;
  };
})(Tt.API), /**
* @license
* Copyright (c) 2017 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = { 1569: [65152], 1570: [65153, 65154], 1571: [65155, 65156], 1572: [65157, 65158], 1573: [65159, 65160], 1574: [65161, 65162, 65163, 65164], 1575: [65165, 65166], 1576: [65167, 65168, 65169, 65170], 1577: [65171, 65172], 1578: [65173, 65174, 65175, 65176], 1579: [65177, 65178, 65179, 65180], 1580: [65181, 65182, 65183, 65184], 1581: [65185, 65186, 65187, 65188], 1582: [65189, 65190, 65191, 65192], 1583: [65193, 65194], 1584: [65195, 65196], 1585: [65197, 65198], 1586: [65199, 65200], 1587: [65201, 65202, 65203, 65204], 1588: [65205, 65206, 65207, 65208], 1589: [65209, 65210, 65211, 65212], 1590: [65213, 65214, 65215, 65216], 1591: [65217, 65218, 65219, 65220], 1592: [65221, 65222, 65223, 65224], 1593: [65225, 65226, 65227, 65228], 1594: [65229, 65230, 65231, 65232], 1601: [65233, 65234, 65235, 65236], 1602: [65237, 65238, 65239, 65240], 1603: [65241, 65242, 65243, 65244], 1604: [65245, 65246, 65247, 65248], 1605: [65249, 65250, 65251, 65252], 1606: [65253, 65254, 65255, 65256], 1607: [65257, 65258, 65259, 65260], 1608: [65261, 65262], 1609: [65263, 65264, 64488, 64489], 1610: [65265, 65266, 65267, 65268], 1649: [64336, 64337], 1655: [64477], 1657: [64358, 64359, 64360, 64361], 1658: [64350, 64351, 64352, 64353], 1659: [64338, 64339, 64340, 64341], 1662: [64342, 64343, 64344, 64345], 1663: [64354, 64355, 64356, 64357], 1664: [64346, 64347, 64348, 64349], 1667: [64374, 64375, 64376, 64377], 1668: [64370, 64371, 64372, 64373], 1670: [64378, 64379, 64380, 64381], 1671: [64382, 64383, 64384, 64385], 1672: [64392, 64393], 1676: [64388, 64389], 1677: [64386, 64387], 1678: [64390, 64391], 1681: [64396, 64397], 1688: [64394, 64395], 1700: [64362, 64363, 64364, 64365], 1702: [64366, 64367, 64368, 64369], 1705: [64398, 64399, 64400, 64401], 1709: [64467, 64468, 64469, 64470], 1711: [64402, 64403, 64404, 64405], 1713: [64410, 64411, 64412, 64413], 1715: [64406, 64407, 64408, 64409], 1722: [64414, 64415], 1723: [64416, 64417, 64418, 64419], 1726: [64426, 64427, 64428, 64429], 1728: [64420, 64421], 1729: [64422, 64423, 64424, 64425], 1733: [64480, 64481], 1734: [64473, 64474], 1735: [64471, 64472], 1736: [64475, 64476], 1737: [64482, 64483], 1739: [64478, 64479], 1740: [64508, 64509, 64510, 64511], 1744: [64484, 64485, 64486, 64487], 1746: [64430, 64431], 1747: [64432, 64433] }, t = { 65247: { 65154: 65269, 65156: 65271, 65160: 65273, 65166: 65275 }, 65248: { 65154: 65270, 65156: 65272, 65160: 65274, 65166: 65276 }, 65165: { 65247: { 65248: { 65258: 65010 } } }, 1617: { 1612: 64606, 1613: 64607, 1614: 64608, 1615: 64609, 1616: 64610 } }, r = { 1612: 64606, 1613: 64607, 1614: 64608, 1615: 64609, 1616: 64610 }, n = [1570, 1571, 1573, 1575];
  o.__arabicParser__ = {};
  var i = o.__arabicParser__.isInArabicSubstitutionA = function(_) {
    return e[_.charCodeAt(0)] !== void 0;
  }, a = o.__arabicParser__.isArabicLetter = function(_) {
    return typeof _ == "string" && /^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(_);
  }, s = o.__arabicParser__.isArabicEndLetter = function(_) {
    return a(_) && i(_) && e[_.charCodeAt(0)].length <= 2;
  }, l = o.__arabicParser__.isArabicAlfLetter = function(_) {
    return a(_) && n.indexOf(_.charCodeAt(0)) >= 0;
  };
  o.__arabicParser__.arabicLetterHasIsolatedForm = function(_) {
    return a(_) && i(_) && e[_.charCodeAt(0)].length >= 1;
  };
  var c = o.__arabicParser__.arabicLetterHasFinalForm = function(_) {
    return a(_) && i(_) && e[_.charCodeAt(0)].length >= 2;
  };
  o.__arabicParser__.arabicLetterHasInitialForm = function(_) {
    return a(_) && i(_) && e[_.charCodeAt(0)].length >= 3;
  };
  var u = o.__arabicParser__.arabicLetterHasMedialForm = function(_) {
    return a(_) && i(_) && e[_.charCodeAt(0)].length == 4;
  }, A = o.__arabicParser__.resolveLigatures = function(_) {
    var f = 0, m = t, b = "", v = 0;
    for (f = 0; f < _.length; f += 1) m[_.charCodeAt(f)] !== void 0 ? (v++, typeof (m = m[_.charCodeAt(f)]) == "number" && (b += String.fromCharCode(m), m = t, v = 0), f === _.length - 1 && (m = t, b += _.charAt(f - (v - 1)), f -= v - 1, v = 0)) : (m = t, b += _.charAt(f - v), f -= v, v = 0);
    return b;
  };
  o.__arabicParser__.isArabicDiacritic = function(_) {
    return _ !== void 0 && r[_.charCodeAt(0)] !== void 0;
  };
  var p = o.__arabicParser__.getCorrectForm = function(_, f, m) {
    return a(_) ? i(_) === !1 ? -1 : !c(_) || !a(f) && !a(m) || !a(m) && s(f) || s(_) && !a(f) || s(_) && l(f) || s(_) && s(f) ? 0 : u(_) && a(f) && !s(f) && a(m) && c(m) ? 3 : s(_) || !a(m) ? 1 : 2 : -1;
  }, d = function(_) {
    var f = 0, m = 0, b = 0, v = "", w = "", C = "", E = (_ = _ || "").split("\\s+"), T = [];
    for (f = 0; f < E.length; f += 1) {
      for (T.push(""), m = 0; m < E[f].length; m += 1) v = E[f][m], w = E[f][m - 1], C = E[f][m + 1], a(v) ? (b = p(v, w, C), T[f] += b !== -1 ? String.fromCharCode(e[v.charCodeAt(0)][b]) : v) : T[f] += v;
      T[f] = A(T[f]);
    }
    return T.join(" ");
  }, g = o.__arabicParser__.processArabic = o.processArabic = function() {
    var _, f = typeof arguments[0] == "string" ? arguments[0] : arguments[0].text, m = [];
    if (Array.isArray(f)) {
      var b = 0;
      for (m = [], b = 0; b < f.length; b += 1) Array.isArray(f[b]) ? m.push([d(f[b][0]), f[b][1], f[b][2]]) : m.push([d(f[b])]);
      _ = m;
    } else _ = d(f);
    return typeof arguments[0] == "string" ? _ : (arguments[0].text = _, arguments[0]);
  };
  o.events.push(["preProcessText", g]);
})(Tt.API), Tt.API.autoPrint = function(o) {
  var e;
  return (o = o || {}).variant = o.variant || "non-conform", o.variant === "javascript" ? this.addJS("print({});") : (this.internal.events.subscribe("postPutResources", function() {
    e = this.internal.newObject(), this.internal.out("<<"), this.internal.out("/S /Named"), this.internal.out("/Type /Action"), this.internal.out("/N /Print"), this.internal.out(">>"), this.internal.out("endobj");
  }), this.internal.events.subscribe("putCatalog", function() {
    this.internal.out("/OpenAction " + e + " 0 R");
  })), this;
}, /**
* @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC)  [email protected]
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = function() {
    var t = void 0;
    Object.defineProperty(this, "pdf", { get: function() {
      return t;
    }, set: function(s) {
      t = s;
    } });
    var r = 150;
    Object.defineProperty(this, "width", { get: function() {
      return r;
    }, set: function(s) {
      r = isNaN(s) || Number.isInteger(s) === !1 || s < 0 ? 150 : s, this.getContext("2d").pageWrapXEnabled && (this.getContext("2d").pageWrapX = r + 1);
    } });
    var n = 300;
    Object.defineProperty(this, "height", { get: function() {
      return n;
    }, set: function(s) {
      n = isNaN(s) || Number.isInteger(s) === !1 || s < 0 ? 300 : s, this.getContext("2d").pageWrapYEnabled && (this.getContext("2d").pageWrapY = n + 1);
    } });
    var i = [];
    Object.defineProperty(this, "childNodes", { get: function() {
      return i;
    }, set: function(s) {
      i = s;
    } });
    var a = {};
    Object.defineProperty(this, "style", { get: function() {
      return a;
    }, set: function(s) {
      a = s;
    } }), Object.defineProperty(this, "parentNode", {});
  };
  e.prototype.getContext = function(t, r) {
    var n;
    if ((t = t || "2d") !== "2d") return null;
    for (n in r) this.pdf.context2d.hasOwnProperty(n) && (this.pdf.context2d[n] = r[n]);
    return this.pdf.context2d._canvas = this, this.pdf.context2d;
  }, e.prototype.toDataURL = function() {
    throw new Error("toDataURL is not implemented.");
  }, o.events.push(["initialized", function() {
    this.canvas = new e(), this.canvas.pdf = this;
  }]);
})(Tt.API), (function(o) {
  var e = { left: 0, top: 0, bottom: 0, right: 0 }, t = !1, r = function() {
    this.internal.__cell__ === void 0 && (this.internal.__cell__ = {}, this.internal.__cell__.padding = 3, this.internal.__cell__.headerFunction = void 0, this.internal.__cell__.margins = Object.assign({}, e), this.internal.__cell__.margins.width = this.getPageWidth(), n.call(this));
  }, n = function() {
    this.internal.__cell__.lastCell = new i(), this.internal.__cell__.pages = 1;
  }, i = function() {
    var l = arguments[0];
    Object.defineProperty(this, "x", { enumerable: !0, get: function() {
      return l;
    }, set: function(_) {
      l = _;
    } });
    var c = arguments[1];
    Object.defineProperty(this, "y", { enumerable: !0, get: function() {
      return c;
    }, set: function(_) {
      c = _;
    } });
    var u = arguments[2];
    Object.defineProperty(this, "width", { enumerable: !0, get: function() {
      return u;
    }, set: function(_) {
      u = _;
    } });
    var A = arguments[3];
    Object.defineProperty(this, "height", { enumerable: !0, get: function() {
      return A;
    }, set: function(_) {
      A = _;
    } });
    var p = arguments[4];
    Object.defineProperty(this, "text", { enumerable: !0, get: function() {
      return p;
    }, set: function(_) {
      p = _;
    } });
    var d = arguments[5];
    Object.defineProperty(this, "lineNumber", { enumerable: !0, get: function() {
      return d;
    }, set: function(_) {
      d = _;
    } });
    var g = arguments[6];
    return Object.defineProperty(this, "align", { enumerable: !0, get: function() {
      return g;
    }, set: function(_) {
      g = _;
    } }), this;
  };
  i.prototype.clone = function() {
    return new i(this.x, this.y, this.width, this.height, this.text, this.lineNumber, this.align);
  }, i.prototype.toArray = function() {
    return [this.x, this.y, this.width, this.height, this.text, this.lineNumber, this.align];
  }, o.setHeaderFunction = function(l) {
    return r.call(this), this.internal.__cell__.headerFunction = typeof l == "function" ? l : void 0, this;
  }, o.getTextDimensions = function(l, c) {
    r.call(this);
    var u = (c = c || {}).fontSize || this.getFontSize(), A = c.font || this.getFont(), p = c.scaleFactor || this.internal.scaleFactor, d = 0, g = 0, _ = 0, f = this;
    if (!Array.isArray(l) && typeof l != "string") {
      if (typeof l != "number") throw new Error("getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.");
      l = String(l);
    }
    var m = c.maxWidth;
    m > 0 ? typeof l == "string" ? l = this.splitTextToSize(l, m) : Object.prototype.toString.call(l) === "[object Array]" && (l = l.reduce(function(v, w) {
      return v.concat(f.splitTextToSize(w, m));
    }, [])) : l = Array.isArray(l) ? l : [l];
    for (var b = 0; b < l.length; b++) d < (_ = this.getStringUnitWidth(l[b], { font: A }) * u) && (d = _);
    return d !== 0 && (g = l.length), { w: d /= p, h: Math.max((g * u * this.getLineHeightFactor() - u * (this.getLineHeightFactor() - 1)) / p, 0) };
  }, o.cellAddPage = function() {
    r.call(this), this.addPage();
    var l = this.internal.__cell__.margins || e;
    return this.internal.__cell__.lastCell = new i(l.left, l.top, void 0, void 0), this.internal.__cell__.pages += 1, this;
  };
  var a = o.cell = function() {
    var l;
    l = arguments[0] instanceof i ? arguments[0] : new i(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]), r.call(this);
    var c = this.internal.__cell__.lastCell, u = this.internal.__cell__.padding, A = this.internal.__cell__.margins || e, p = this.internal.__cell__.tableHeaderRow, d = this.internal.__cell__.printHeaders;
    return c.lineNumber !== void 0 && (c.lineNumber === l.lineNumber ? (l.x = (c.x || 0) + (c.width || 0), l.y = c.y || 0) : c.y + c.height + l.height + A.bottom > this.getPageHeight() ? (this.cellAddPage(), l.y = A.top, d && p && (this.printHeaderRow(l.lineNumber, !0), l.y += p[0].height)) : l.y = c.y + c.height || l.y), l.text[0] !== void 0 && (this.rect(l.x, l.y, l.width, l.height, t === !0 ? "FD" : void 0), l.align === "right" ? this.text(l.text, l.x + l.width - u, l.y + u, { align: "right", baseline: "top" }) : l.align === "center" ? this.text(l.text, l.x + l.width / 2, l.y + u, { align: "center", baseline: "top", maxWidth: l.width - u - u }) : this.text(l.text, l.x + u, l.y + u, { align: "left", baseline: "top", maxWidth: l.width - u - u })), this.internal.__cell__.lastCell = l, this;
  };
  o.table = function(l, c, u, A, p) {
    if (r.call(this), !u) throw new Error("No data for PDF table.");
    var d, g, _, f, m = [], b = [], v = [], w = {}, C = {}, E = [], T = [], F = (p = p || {}).autoSize || !1, B = p.printHeaders !== !1, P = p.css && p.css["font-size"] !== void 0 ? 16 * p.css["font-size"] : p.fontSize || 12, S = p.margins || Object.assign({ width: this.getPageWidth() }, e), L = typeof p.padding == "number" ? p.padding : 3, U = p.headerBackgroundColor || "#c8c8c8", O = p.headerTextColor || "#000";
    if (n.call(this), this.internal.__cell__.printHeaders = B, this.internal.__cell__.margins = S, this.internal.__cell__.table_font_size = P, this.internal.__cell__.padding = L, this.internal.__cell__.headerBackgroundColor = U, this.internal.__cell__.headerTextColor = O, this.setFontSize(P), A == null) b = m = Object.keys(u[0]), v = m.map(function() {
      return "left";
    });
    else if (Array.isArray(A) && yr(A[0]) === "object") for (m = A.map(function(de) {
      return de.name;
    }), b = A.map(function(de) {
      return de.prompt || de.name || "";
    }), v = A.map(function(de) {
      return de.align || "left";
    }), d = 0; d < A.length; d += 1) C[A[d].name] = 0.7499990551181103 * A[d].width;
    else Array.isArray(A) && typeof A[0] == "string" && (b = m = A, v = m.map(function() {
      return "left";
    }));
    if (F || Array.isArray(A) && typeof A[0] == "string") for (d = 0; d < m.length; d += 1) {
      for (w[f = m[d]] = u.map(function(de) {
        return de[f];
      }), this.setFont(void 0, "bold"), E.push(this.getTextDimensions(b[d], { fontSize: this.internal.__cell__.table_font_size, scaleFactor: this.internal.scaleFactor }).w), g = w[f], this.setFont(void 0, "normal"), _ = 0; _ < g.length; _ += 1) E.push(this.getTextDimensions(g[_], { fontSize: this.internal.__cell__.table_font_size, scaleFactor: this.internal.scaleFactor }).w);
      C[f] = Math.max.apply(null, E) + L + L, E = [];
    }
    if (B) {
      var K = {};
      for (d = 0; d < m.length; d += 1) K[m[d]] = {}, K[m[d]].text = b[d], K[m[d]].align = v[d];
      var te = s.call(this, K, C);
      T = m.map(function(de) {
        return new i(l, c, C[de], te, K[de].text, void 0, K[de].align);
      }), this.setTableHeaderRow(T), this.printHeaderRow(1, !1);
    }
    var Y = A.reduce(function(de, ae) {
      return de[ae.name] = ae.align, de;
    }, {});
    for (d = 0; d < u.length; d += 1) {
      "rowStart" in p && p.rowStart instanceof Function && p.rowStart({ row: d, data: u[d] }, this);
      var ee = s.call(this, u[d], C);
      for (_ = 0; _ < m.length; _ += 1) {
        var oe = u[d][m[_]];
        "cellStart" in p && p.cellStart instanceof Function && p.cellStart({ row: d, col: _, data: oe }, this), a.call(this, new i(l, c, C[m[_]], ee, oe, d + 2, Y[m[_]]));
      }
    }
    return this.internal.__cell__.table_x = l, this.internal.__cell__.table_y = c, this;
  };
  var s = function(l, c) {
    var u = this.internal.__cell__.padding, A = this.internal.__cell__.table_font_size, p = this.internal.scaleFactor;
    return Object.keys(l).map(function(d) {
      var g = l[d];
      return this.splitTextToSize(g.hasOwnProperty("text") ? g.text : g, c[d] - u - u);
    }, this).map(function(d) {
      return this.getLineHeightFactor() * d.length * A / p + u + u;
    }, this).reduce(function(d, g) {
      return Math.max(d, g);
    }, 0);
  };
  o.setTableHeaderRow = function(l) {
    r.call(this), this.internal.__cell__.tableHeaderRow = l;
  }, o.printHeaderRow = function(l, c) {
    if (r.call(this), !this.internal.__cell__.tableHeaderRow) throw new Error("Property tableHeaderRow does not exist.");
    var u;
    if (t = !0, typeof this.internal.__cell__.headerFunction == "function") {
      var A = this.internal.__cell__.headerFunction(this, this.internal.__cell__.pages);
      this.internal.__cell__.lastCell = new i(A[0], A[1], A[2], A[3], void 0, -1);
    }
    this.setFont(void 0, "bold");
    for (var p = [], d = 0; d < this.internal.__cell__.tableHeaderRow.length; d += 1) {
      u = this.internal.__cell__.tableHeaderRow[d].clone(), c && (u.y = this.internal.__cell__.margins.top || 0, p.push(u)), u.lineNumber = l;
      var g = this.getTextColor();
      this.setTextColor(this.internal.__cell__.headerTextColor), this.setFillColor(this.internal.__cell__.headerBackgroundColor), a.call(this, u), this.setTextColor(g);
    }
    p.length > 0 && this.setTableHeaderRow(p), this.setFont(void 0, "normal"), t = !1;
  };
})(Tt.API);
var fj = { italic: ["italic", "oblique", "normal"], oblique: ["oblique", "italic", "normal"], normal: ["normal", "oblique", "italic"] }, mj = ["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"], xb = _j(mj), yj = [100, 200, 300, 400, 500, 600, 700, 800, 900], KO = _j(yj);
function U_(o) {
  var e = o.family.replace(/"|'/g, "").toLowerCase(), t = (function(i) {
    return fj[i = i || "normal"] ? i : "normal";
  })(o.style), r = (function(i) {
    return i ? typeof i == "number" ? i >= 100 && i <= 900 && i % 100 == 0 ? i : 400 : /^\d00$/.test(i) ? parseInt(i) : i === "bold" ? 700 : 400 : 400;
  })(o.weight), n = (function(i) {
    return typeof xb[i = i || "normal"] == "number" ? i : "normal";
  })(o.stretch);
  return { family: e, style: t, weight: r, stretch: n, src: o.src || [], ref: o.ref || { name: e, style: [n, t, r].join(" ") } };
}
function $x(o, e, t, r) {
  var n;
  for (n = t; n >= 0 && n < e.length; n += r) if (o[e[n]]) return o[e[n]];
  for (n = t; n >= 0 && n < e.length; n -= r) if (o[e[n]]) return o[e[n]];
}
var $O = { "sans-serif": "helvetica", fixed: "courier", monospace: "courier", terminal: "courier", cursive: "times", fantasy: "times", serif: "times" }, Wx = { caption: "times", icon: "times", menu: "times", "message-box": "times", "small-caption": "times", "status-bar": "times" };
function Xx(o) {
  return [o.stretch, o.style, o.weight, o.family].join(" ");
}
function Yx(o) {
  return o.trimLeft();
}
function WO(o, e) {
  for (var t = 0; t < o.length; ) {
    if (o.charAt(t) === e) return [o.substring(0, t), o.substring(t + 1)];
    t += 1;
  }
  return null;
}
function XO(o) {
  var e = o.match(/^(-[a-z_]|[a-z_])[a-z0-9_-]*/i);
  return e === null ? null : [e[0], o.substring(e[0].length)];
}
var up, Zx, Jx, pc, Ap, e1, t1, r1, o1 = ["times"];
function n1(o, e, t, r, n) {
  var i = 4, a = a1;
  switch (n) {
    case Tt.API.image_compression.FAST:
      i = 1, a = i1;
      break;
    case Tt.API.image_compression.MEDIUM:
      i = 6, a = s1;
      break;
    case Tt.API.image_compression.SLOW:
      i = 9, a = l1;
  }
  o = (function(l, c, u, A) {
    for (var p, d = l.length / c, g = new Uint8Array(l.length + d), _ = [YO, i1, a1, s1, l1], f = 0; f < d; f += 1) {
      var m = f * c, b = l.subarray(m, m + c);
      if (A) g.set(A(b, u, p), m + f);
      else {
        for (var v = _.length, w = [], C = 0; C < v; C += 1) w[C] = _[C](b, u, p);
        var E = JO(w.concat());
        g.set(w[E], m + f);
      }
      p = b;
    }
    return g;
  })(o, e, Math.ceil(t * r / 8), a);
  var s = _b(o, { level: i });
  return Tt.API.__addimage__.arrayBufferToBinaryString(s);
}
function YO(o) {
  var e = Array.apply([], o);
  return e.unshift(0), e;
}
function i1(o, e) {
  var t = o.length, r = [];
  r[0] = 1;
  for (var n = 0; n < t; n += 1) {
    var i = o[n - e] || 0;
    r[n + 1] = o[n] - i + 256 & 255;
  }
  return r;
}
function a1(o, e, t) {
  var r = o.length, n = [];
  n[0] = 2;
  for (var i = 0; i < r; i += 1) {
    var a = t && t[i] || 0;
    n[i + 1] = o[i] - a + 256 & 255;
  }
  return n;
}
function s1(o, e, t) {
  var r = o.length, n = [];
  n[0] = 3;
  for (var i = 0; i < r; i += 1) {
    var a = o[i - e] || 0, s = t && t[i] || 0;
    n[i + 1] = o[i] + 256 - (a + s >>> 1) & 255;
  }
  return n;
}
function l1(o, e, t) {
  var r = o.length, n = [];
  n[0] = 4;
  for (var i = 0; i < r; i += 1) {
    var a = ZO(o[i - e] || 0, t && t[i] || 0, t && t[i - e] || 0);
    n[i + 1] = o[i] - a + 256 & 255;
  }
  return n;
}
function ZO(o, e, t) {
  if (o === e && e === t) return o;
  var r = Math.abs(e - t), n = Math.abs(o - t), i = Math.abs(o + e - t - t);
  return r <= n && r <= i ? o : n <= i ? e : t;
}
function JO(o) {
  var e = o.map(function(t) {
    return t.reduce(function(r, n) {
      return r + Math.abs(n);
    }, 0);
  });
  return e.indexOf(Math.min.apply(null, e));
}
function N_(o, e, t) {
  var r = e * t, n = Math.floor(r / 8), i = 16 - (r - 8 * n + t), a = (1 << t) - 1;
  return bj(o, n) >> i & a;
}
function c1(o, e, t, r) {
  var n = t * r, i = Math.floor(n / 8), a = 16 - (n - 8 * i + r), s = (1 << r) - 1, l = (e & s) << a;
  (function(c, u, A) {
    if (u + 1 < c.byteLength) c.setUint16(u, A, !1);
    else {
      var p = A >> 8 & 255;
      c.setUint8(u, p);
    }
  })(o, i, bj(o, i) & ~(s << a) & 65535 | l);
}
function bj(o, e) {
  return e + 1 < o.byteLength ? o.getUint16(e, !1) : o.getUint8(e) << 8;
}
function eQ(o) {
  var e = 0;
  if (o[e++] !== 71 || o[e++] !== 73 || o[e++] !== 70 || o[e++] !== 56 || (o[e++] + 1 & 253) != 56 || o[e++] !== 97) throw new Error("Invalid GIF 87a/89a header.");
  var t = o[e++] | o[e++] << 8, r = o[e++] | o[e++] << 8, n = o[e++], i = n >> 7, a = 1 << 1 + (7 & n);
  o[e++], o[e++];
  var s = null, l = null;
  i && (s = e, l = a, e += 3 * a);
  var c = !0, u = [], A = 0, p = null, d = 0, g = null;
  for (this.width = t, this.height = r; c && e < o.length; ) switch (o[e++]) {
    case 33:
      switch (o[e++]) {
        case 255:
          if (o[e] !== 11 || o[e + 1] == 78 && o[e + 2] == 69 && o[e + 3] == 84 && o[e + 4] == 83 && o[e + 5] == 67 && o[e + 6] == 65 && o[e + 7] == 80 && o[e + 8] == 69 && o[e + 9] == 50 && o[e + 10] == 46 && o[e + 11] == 48 && o[e + 12] == 3 && o[e + 13] == 1 && o[e + 16] == 0) e += 14, g = o[e++] | o[e++] << 8, e++;
          else for (e += 12; ; ) {
            if (!((S = o[e++]) >= 0)) throw Error("Invalid block size");
            if (S === 0) break;
            e += S;
          }
          break;
        case 249:
          if (o[e++] !== 4 || o[e + 4] !== 0) throw new Error("Invalid graphics extension block.");
          var _ = o[e++];
          A = o[e++] | o[e++] << 8, p = o[e++], 1 & _ || (p = null), d = _ >> 2 & 7, e++;
          break;
        case 254:
          for (; ; ) {
            if (!((S = o[e++]) >= 0)) throw Error("Invalid block size");
            if (S === 0) break;
            e += S;
          }
          break;
        default:
          throw new Error("Unknown graphic control label: 0x" + o[e - 1].toString(16));
      }
      break;
    case 44:
      var f = o[e++] | o[e++] << 8, m = o[e++] | o[e++] << 8, b = o[e++] | o[e++] << 8, v = o[e++] | o[e++] << 8, w = o[e++], C = w >> 6 & 1, E = 1 << 1 + (7 & w), T = s, F = l, B = !1;
      w >> 7 && (B = !0, T = e, F = E, e += 3 * E);
      var P = e;
      for (e++; ; ) {
        var S;
        if (!((S = o[e++]) >= 0)) throw Error("Invalid block size");
        if (S === 0) break;
        e += S;
      }
      u.push({ x: f, y: m, width: b, height: v, has_local_palette: B, palette_offset: T, palette_size: F, data_offset: P, data_length: e - P, transparent_index: p, interlaced: !!C, delay: A, disposal: d });
      break;
    case 59:
      c = !1;
      break;
    default:
      throw new Error("Unknown gif block: 0x" + o[e - 1].toString(16));
  }
  this.numFrames = function() {
    return u.length;
  }, this.loopCount = function() {
    return g;
  }, this.frameInfo = function(L) {
    if (L < 0 || L >= u.length) throw new Error("Frame index out of range.");
    return u[L];
  }, this.decodeAndBlitFrameBGRA = function(L, U) {
    var O = this.frameInfo(L), K = O.width * O.height, te = new Uint8Array(K);
    u1(o, O.data_offset, te, K);
    var Y = O.palette_offset, ee = O.transparent_index;
    ee === null && (ee = 256);
    var oe = O.width, de = t - oe, ae = oe, I = 4 * (O.y * t + O.x), G = 4 * ((O.y + O.height) * t + O.x), H = I, Z = 4 * de;
    O.interlaced === !0 && (Z += 4 * t * 7);
    for (var ne = 8, le = 0, me = te.length; le < me; ++le) {
      var ce = te[le];
      if (ae === 0 && (ae = oe, (H += Z) >= G && (Z = 4 * de + 4 * t * (ne - 1), H = I + (oe + de) * (ne << 1), ne >>= 1)), ce === ee) H += 4;
      else {
        var ye = o[Y + 3 * ce], Ce = o[Y + 3 * ce + 1], Ue = o[Y + 3 * ce + 2];
        U[H++] = Ue, U[H++] = Ce, U[H++] = ye, U[H++] = 255;
      }
      --ae;
    }
  }, this.decodeAndBlitFrameRGBA = function(L, U) {
    var O = this.frameInfo(L), K = O.width * O.height, te = new Uint8Array(K);
    u1(o, O.data_offset, te, K);
    var Y = O.palette_offset, ee = O.transparent_index;
    ee === null && (ee = 256);
    var oe = O.width, de = t - oe, ae = oe, I = 4 * (O.y * t + O.x), G = 4 * ((O.y + O.height) * t + O.x), H = I, Z = 4 * de;
    O.interlaced === !0 && (Z += 4 * t * 7);
    for (var ne = 8, le = 0, me = te.length; le < me; ++le) {
      var ce = te[le];
      if (ae === 0 && (ae = oe, (H += Z) >= G && (Z = 4 * de + 4 * t * (ne - 1), H = I + (oe + de) * (ne << 1), ne >>= 1)), ce === ee) H += 4;
      else {
        var ye = o[Y + 3 * ce], Ce = o[Y + 3 * ce + 1], Ue = o[Y + 3 * ce + 2];
        U[H++] = ye, U[H++] = Ce, U[H++] = Ue, U[H++] = 255;
      }
      --ae;
    }
  };
}
function u1(o, e, t, r) {
  for (var n = o[e++], i = 1 << n, a = i + 1, s = a + 1, l = n + 1, c = (1 << l) - 1, u = 0, A = 0, p = 0, d = o[e++], g = new Int32Array(4096), _ = null; ; ) {
    for (; u < 16 && d !== 0; ) A |= o[e++] << u, u += 8, d === 1 ? d = o[e++] : --d;
    if (u < l) break;
    var f = A & c;
    if (A >>= l, u -= l, f !== i) {
      if (f === a) break;
      for (var m = f < s ? f : _, b = 0, v = m; v > i; ) v = g[v] >> 8, ++b;
      var w = v;
      if (p + b + (m !== f ? 1 : 0) > r) return void Or.log("Warning, gif stream longer than expected.");
      t[p++] = w;
      var C = p += b;
      for (m !== f && (t[p++] = w), v = m; b--; ) v = g[v], t[--C] = 255 & v, v >>= 8;
      _ !== null && s < 4096 && (g[s++] = _ << 8 | w, s >= c + 1 && l < 12 && (++l, c = c << 1 | 1)), _ = f;
    } else s = a + 1, c = (1 << (l = n + 1)) - 1, _ = null;
  }
  return p !== r && Or.log("Warning, gif stream shorter than expected."), t;
}
function I_(o) {
  var e, t, r, n, i, a = Math.floor, s = new Array(64), l = new Array(64), c = new Array(64), u = new Array(64), A = new Array(65535), p = new Array(65535), d = new Array(64), g = new Array(64), _ = [], f = 0, m = 7, b = new Array(64), v = new Array(64), w = new Array(64), C = new Array(256), E = new Array(2048), T = [0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63], F = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], B = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], P = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125], S = [1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250], L = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], U = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], O = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119], K = [0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250];
  function te(I, G) {
    for (var H = 0, Z = 0, ne = new Array(), le = 1; le <= 16; le++) {
      for (var me = 1; me <= I[le]; me++) ne[G[Z]] = [], ne[G[Z]][0] = H, ne[G[Z]][1] = le, Z++, H++;
      H *= 2;
    }
    return ne;
  }
  function Y(I) {
    for (var G = I[0], H = I[1] - 1; H >= 0; ) G & 1 << H && (f |= 1 << m), H--, --m < 0 && (f == 255 ? (ee(255), ee(0)) : ee(f), m = 7, f = 0);
  }
  function ee(I) {
    _.push(I);
  }
  function oe(I) {
    ee(I >> 8 & 255), ee(255 & I);
  }
  function de(I, G, H, Z, ne) {
    for (var le, me = ne[0], ce = ne[240], ye = (function(Be, et) {
      var Le, Fe, tt, we, Ge, ze, Ze, ht, rt, Ct, it = 0;
      for (rt = 0; rt < 8; ++rt) {
        Le = Be[it], Fe = Be[it + 1], tt = Be[it + 2], we = Be[it + 3], Ge = Be[it + 4], ze = Be[it + 5], Ze = Be[it + 6];
        var Kt = Le + (ht = Be[it + 7]), ve = Le - ht, J = Fe + Ze, ge = Fe - Ze, We = tt + ze, nt = tt - ze, rr = we + Ge, _t = we - Ge, wt = Kt + rr, or = Kt - rr, mt = J + We, Nt = J - We;
        Be[it] = wt + mt, Be[it + 4] = wt - mt;
        var Bt = 0.707106781 * (Nt + or);
        Be[it + 2] = or + Bt, Be[it + 6] = or - Bt;
        var ur = 0.382683433 * ((wt = _t + nt) - (Nt = ge + ve)), vr = 0.5411961 * wt + ur, Kr = 1.306562965 * Nt + ur, To = 0.707106781 * (mt = nt + ge), xt = ve + To, Qo = ve - To;
        Be[it + 5] = Qo + vr, Be[it + 3] = Qo - vr, Be[it + 1] = xt + Kr, Be[it + 7] = xt - Kr, it += 8;
      }
      for (it = 0, rt = 0; rt < 8; ++rt) {
        Le = Be[it], Fe = Be[it + 8], tt = Be[it + 16], we = Be[it + 24], Ge = Be[it + 32], ze = Be[it + 40], Ze = Be[it + 48];
        var qo = Le + (ht = Be[it + 56]), Xo = Le - ht, lo = Fe + Ze, jr = Fe - Ze, Ir = tt + ze, Ie = tt - ze, gt = we + Ge, dt = we - Ge, Me = qo + gt, Ht = qo - gt, Ot = lo + Ir, qt = lo - Ir;
        Be[it] = Me + Ot, Be[it + 32] = Me - Ot;
        var Zr = 0.707106781 * (qt + Ht);
        Be[it + 16] = Ht + Zr, Be[it + 48] = Ht - Zr;
        var $r = 0.382683433 * ((Me = dt + Ie) - (qt = jr + Xo)), re = 0.5411961 * Me + $r, Ke = 1.306562965 * qt + $r, He = 0.707106781 * (Ot = Ie + jr), $t = Xo + He, dr = Xo - He;
        Be[it + 40] = dr + re, Be[it + 24] = dr - re, Be[it + 8] = $t + Ke, Be[it + 56] = $t - Ke, it++;
      }
      for (rt = 0; rt < 64; ++rt) Ct = Be[rt] * et[rt], d[rt] = Ct > 0 ? Ct + 0.5 | 0 : Ct - 0.5 | 0;
      return d;
    })(I, G), Ce = 0; Ce < 64; ++Ce) g[T[Ce]] = ye[Ce];
    var Ue = g[0] - H;
    H = g[0], Ue == 0 ? Y(Z[0]) : (Y(Z[p[le = 32767 + Ue]]), Y(A[le]));
    for (var Qe = 63; Qe > 0 && g[Qe] == 0; ) Qe--;
    if (Qe == 0) return Y(me), H;
    for (var Xe, D = 1; D <= Qe; ) {
      for (var Ne = D; g[D] == 0 && D <= Qe; ) ++D;
      var ct = D - Ne;
      if (ct >= 16) {
        Xe = ct >> 4;
        for (var ot = 1; ot <= Xe; ++ot) Y(ce);
        ct &= 15;
      }
      le = 32767 + g[D], Y(ne[(ct << 4) + p[le]]), Y(A[le]), D++;
    }
    return Qe != 63 && Y(me), H;
  }
  function ae(I) {
    I = Math.min(Math.max(I, 1), 100), i != I && ((function(G) {
      for (var H = [16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99], Z = 0; Z < 64; Z++) {
        var ne = a((H[Z] * G + 50) / 100);
        ne = Math.min(Math.max(ne, 1), 255), s[T[Z]] = ne;
      }
      for (var le = [17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99], me = 0; me < 64; me++) {
        var ce = a((le[me] * G + 50) / 100);
        ce = Math.min(Math.max(ce, 1), 255), l[T[me]] = ce;
      }
      for (var ye = [1, 1.387039845, 1.306562965, 1.175875602, 1, 0.785694958, 0.5411961, 0.275899379], Ce = 0, Ue = 0; Ue < 8; Ue++) for (var Qe = 0; Qe < 8; Qe++) c[Ce] = 1 / (s[T[Ce]] * ye[Ue] * ye[Qe] * 8), u[Ce] = 1 / (l[T[Ce]] * ye[Ue] * ye[Qe] * 8), Ce++;
    })(I < 50 ? Math.floor(5e3 / I) : Math.floor(200 - 2 * I)), i = I);
  }
  this.encode = function(I, G) {
    G && ae(G), _ = new Array(), f = 0, m = 7, oe(65496), oe(65504), oe(16), ee(74), ee(70), ee(73), ee(70), ee(0), ee(1), ee(1), ee(0), oe(1), oe(1), ee(0), ee(0), (function() {
      oe(65499), oe(132), ee(0);
      for (var Fe = 0; Fe < 64; Fe++) ee(s[Fe]);
      ee(1);
      for (var tt = 0; tt < 64; tt++) ee(l[tt]);
    })(), (function(Fe, tt) {
      oe(65472), oe(17), ee(8), oe(tt), oe(Fe), ee(3), ee(1), ee(17), ee(0), ee(2), ee(17), ee(1), ee(3), ee(17), ee(1);
    })(I.width, I.height), (function() {
      oe(65476), oe(418), ee(0);
      for (var Fe = 0; Fe < 16; Fe++) ee(F[Fe + 1]);
      for (var tt = 0; tt <= 11; tt++) ee(B[tt]);
      ee(16);
      for (var we = 0; we < 16; we++) ee(P[we + 1]);
      for (var Ge = 0; Ge <= 161; Ge++) ee(S[Ge]);
      ee(1);
      for (var ze = 0; ze < 16; ze++) ee(L[ze + 1]);
      for (var Ze = 0; Ze <= 11; Ze++) ee(U[Ze]);
      ee(17);
      for (var ht = 0; ht < 16; ht++) ee(O[ht + 1]);
      for (var rt = 0; rt <= 161; rt++) ee(K[rt]);
    })(), oe(65498), oe(12), ee(3), ee(1), ee(0), ee(2), ee(17), ee(3), ee(17), ee(0), ee(63), ee(0);
    var H = 0, Z = 0, ne = 0;
    f = 0, m = 7, this.encode.displayName = "_encode_";
    for (var le, me, ce, ye, Ce, Ue, Qe, Xe, D, Ne = I.data, ct = I.width, ot = I.height, Be = 4 * ct, et = 0; et < ot; ) {
      for (le = 0; le < Be; ) {
        for (Ce = Be * et + le, Qe = -1, Xe = 0, D = 0; D < 64; D++) Ue = Ce + (Xe = D >> 3) * Be + (Qe = 4 * (7 & D)), et + Xe >= ot && (Ue -= Be * (et + 1 + Xe - ot)), le + Qe >= Be && (Ue -= le + Qe - Be + 4), me = Ne[Ue++], ce = Ne[Ue++], ye = Ne[Ue++], b[D] = (E[me] + E[ce + 256 | 0] + E[ye + 512 | 0] >> 16) - 128, v[D] = (E[me + 768 | 0] + E[ce + 1024 | 0] + E[ye + 1280 | 0] >> 16) - 128, w[D] = (E[me + 1280 | 0] + E[ce + 1536 | 0] + E[ye + 1792 | 0] >> 16) - 128;
        H = de(b, c, H, e, r), Z = de(v, u, Z, t, n), ne = de(w, u, ne, t, n), le += 32;
      }
      et += 8;
    }
    if (m >= 0) {
      var Le = [];
      Le[1] = m + 1, Le[0] = (1 << m + 1) - 1, Y(Le);
    }
    return oe(65497), new Uint8Array(_);
  }, o = o || 50, (function() {
    for (var I = String.fromCharCode, G = 0; G < 256; G++) C[G] = I(G);
  })(), e = te(F, B), t = te(L, U), r = te(P, S), n = te(O, K), (function() {
    for (var I = 1, G = 2, H = 1; H <= 15; H++) {
      for (var Z = I; Z < G; Z++) p[32767 + Z] = H, A[32767 + Z] = [], A[32767 + Z][1] = H, A[32767 + Z][0] = Z;
      for (var ne = -(G - 1); ne <= -I; ne++) p[32767 + ne] = H, A[32767 + ne] = [], A[32767 + ne][1] = H, A[32767 + ne][0] = G - 1 + ne;
      I <<= 1, G <<= 1;
    }
  })(), (function() {
    for (var I = 0; I < 256; I++) E[I] = 19595 * I, E[I + 256 | 0] = 38470 * I, E[I + 512 | 0] = 7471 * I + 32768, E[I + 768 | 0] = -11059 * I, E[I + 1024 | 0] = -21709 * I, E[I + 1280 | 0] = 32768 * I + 8421375, E[I + 1536 | 0] = -27439 * I, E[I + 1792 | 0] = -5329 * I;
  })(), ae(o);
}
function ji(o, e) {
  if (this.pos = 0, this.buffer = o, this.datav = new DataView(o.buffer), this.is_with_alpha = !!e, this.bottom_up = !0, this.flag = String.fromCharCode(this.buffer[0]) + String.fromCharCode(this.buffer[1]), this.pos += 2, ["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag) === -1) throw new Error("Invalid BMP File");
  this.parseHeader(), this.parseBGR();
}
function A1(o) {
  function e(B) {
    if (!B) throw Error("assert :P");
  }
  function t(B, P, S) {
    for (var L = 0; 4 > L; L++) if (B[P + L] != S.charCodeAt(L)) return !0;
    return !1;
  }
  function r(B, P, S, L, U) {
    for (var O = 0; O < U; O++) B[P + O] = S[L + O];
  }
  function n(B, P, S, L) {
    for (var U = 0; U < L; U++) B[P + U] = S;
  }
  function i(B) {
    return new Int32Array(B);
  }
  function a(B, P) {
    for (var S = [], L = 0; L < B; L++) S.push(new P());
    return S;
  }
  function s(B, P) {
    var S = [];
    return (function L(U, O, K) {
      for (var te = K[O], Y = 0; Y < te && (U.push(K.length > O + 1 ? [] : new P()), !(K.length < O + 1)); Y++) L(U[Y], O + 1, K);
    })(S, 0, B), S;
  }
  var l = function() {
    var B = this;
    function P(h, y) {
      for (var k = 1 << y - 1 >>> 0; h & k; ) k >>>= 1;
      return k ? (h & k - 1) + k : h;
    }
    function S(h, y, k, j, R) {
      e(!(j % k));
      do
        h[y + (j -= k)] = R;
      while (0 < j);
    }
    function L(h, y, k, j, R) {
      if (e(2328 >= R), 512 >= R) var Q = i(512);
      else if ((Q = i(R)) == null) return 0;
      return (function(q, V, z, $, se, be) {
        var W, ue, _e = V, xe = 1 << z, fe = i(16), Se = i(16);
        for (e(se != 0), e($ != null), e(q != null), e(0 < z), ue = 0; ue < se; ++ue) {
          if (15 < $[ue]) return 0;
          ++fe[$[ue]];
        }
        if (fe[0] == se) return 0;
        for (Se[1] = 0, W = 1; 15 > W; ++W) {
          if (fe[W] > 1 << W) return 0;
          Se[W + 1] = Se[W] + fe[W];
        }
        for (ue = 0; ue < se; ++ue) W = $[ue], 0 < $[ue] && (be[Se[W]++] = ue);
        if (Se[15] == 1) return ($ = new U()).g = 0, $.value = be[0], S(q, _e, 1, xe, $), xe;
        var je, Ve = -1, Oe = xe - 1, Ft = 0, yt = 1, Jt = 1, jt = 1 << z;
        for (ue = 0, W = 1, se = 2; W <= z; ++W, se <<= 1) {
          if (yt += Jt <<= 1, 0 > (Jt -= fe[W])) return 0;
          for (; 0 < fe[W]; --fe[W]) ($ = new U()).g = W, $.value = be[ue++], S(q, _e + Ft, se, jt, $), Ft = P(Ft, W);
        }
        for (W = z + 1, se = 2; 15 >= W; ++W, se <<= 1) {
          if (yt += Jt <<= 1, 0 > (Jt -= fe[W])) return 0;
          for (; 0 < fe[W]; --fe[W]) {
            if ($ = new U(), (Ft & Oe) != Ve) {
              for (_e += jt, je = 1 << (Ve = W) - z; 15 > Ve && !(0 >= (je -= fe[Ve])); ) ++Ve, je <<= 1;
              xe += jt = 1 << (je = Ve - z), q[V + (Ve = Ft & Oe)].g = je + z, q[V + Ve].value = _e - V - Ve;
            }
            $.g = W - z, $.value = be[ue++], S(q, _e + (Ft >> z), se, jt, $), Ft = P(Ft, W);
          }
        }
        return yt != 2 * Se[15] - 1 ? 0 : xe;
      })(h, y, k, j, R, Q);
    }
    function U() {
      this.value = this.g = 0;
    }
    function O() {
      this.value = this.g = 0;
    }
    function K() {
      this.G = a(5, U), this.H = i(5), this.jc = this.Qb = this.qb = this.nd = 0, this.pd = a(ul, O);
    }
    function te(h, y, k, j) {
      e(h != null), e(y != null), e(2147483648 > j), h.Ca = 254, h.I = 0, h.b = -8, h.Ka = 0, h.oa = y, h.pa = k, h.Jd = y, h.Yc = k + j, h.Zc = 4 <= j ? k + j - 4 + 1 : k, me(h);
    }
    function Y(h, y) {
      for (var k = 0; 0 < y--; ) k |= ye(h, 128) << y;
      return k;
    }
    function ee(h, y) {
      var k = Y(h, y);
      return ce(h) ? -k : k;
    }
    function oe(h, y, k, j) {
      var R, Q = 0;
      for (e(h != null), e(y != null), e(4294967288 > j), h.Sb = j, h.Ra = 0, h.u = 0, h.h = 0, 4 < j && (j = 4), R = 0; R < j; ++R) Q += y[k + R] << 8 * R;
      h.Ra = Q, h.bb = j, h.oa = y, h.pa = k;
    }
    function de(h) {
      for (; 8 <= h.u && h.bb < h.Sb; ) h.Ra >>>= 8, h.Ra += h.oa[h.pa + h.bb] << ss - 8 >>> 0, ++h.bb, h.u -= 8;
      Z(h) && (h.h = 1, h.u = 0);
    }
    function ae(h, y) {
      if (e(0 <= y), !h.h && y <= Wn) {
        var k = H(h) & $n[y];
        return h.u += y, de(h), k;
      }
      return h.h = 1, h.u = 0;
    }
    function I() {
      this.b = this.Ca = this.I = 0, this.oa = [], this.pa = 0, this.Jd = [], this.Yc = 0, this.Zc = [], this.Ka = 0;
    }
    function G() {
      this.Ra = 0, this.oa = [], this.h = this.u = this.bb = this.Sb = this.pa = 0;
    }
    function H(h) {
      return h.Ra >>> (h.u & ss - 1) >>> 0;
    }
    function Z(h) {
      return e(h.bb <= h.Sb), h.h || h.bb == h.Sb && h.u > ss;
    }
    function ne(h, y) {
      h.u = y, h.h = Z(h);
    }
    function le(h) {
      h.u >= Ca && (e(h.u >= Ca), de(h));
    }
    function me(h) {
      e(h != null && h.oa != null), h.pa < h.Zc ? (h.I = (h.oa[h.pa++] | h.I << 8) >>> 0, h.b += 8) : (e(h != null && h.oa != null), h.pa < h.Yc ? (h.b += 8, h.I = h.oa[h.pa++] | h.I << 8) : h.Ka ? h.b = 0 : (h.I <<= 8, h.b += 8, h.Ka = 1));
    }
    function ce(h) {
      return Y(h, 1);
    }
    function ye(h, y) {
      var k = h.Ca;
      0 > h.b && me(h);
      var j = h.b, R = k * y >>> 8, Q = (h.I >>> j > R) + 0;
      for (Q ? (k -= R, h.I -= R + 1 << j >>> 0) : k = R + 1, j = k, R = 0; 256 <= j; ) R += 8, j >>= 8;
      return j = 7 ^ R + ls[j], h.b -= j, h.Ca = (k << j) - 1, Q;
    }
    function Ce(h, y, k) {
      h[y + 0] = k >> 24 & 255, h[y + 1] = k >> 16 & 255, h[y + 2] = k >> 8 & 255, h[y + 3] = 255 & k;
    }
    function Ue(h, y) {
      return h[y + 0] | h[y + 1] << 8;
    }
    function Qe(h, y) {
      return Ue(h, y) | h[y + 2] << 16;
    }
    function Xe(h, y) {
      return Ue(h, y) | Ue(h, y + 2) << 16;
    }
    function D(h, y) {
      var k = 1 << y;
      return e(h != null), e(0 < y), h.X = i(k), h.X == null ? 0 : (h.Mb = 32 - y, h.Xa = y, 1);
    }
    function Ne(h, y) {
      e(h != null), e(y != null), e(h.Xa == y.Xa), r(y.X, 0, h.X, 0, 1 << y.Xa);
    }
    function ct() {
      this.X = [], this.Xa = this.Mb = 0;
    }
    function ot(h, y, k, j) {
      e(k != null), e(j != null);
      var R = k[0], Q = j[0];
      return R == 0 && (R = (h * Q + y / 2) / y), Q == 0 && (Q = (y * R + h / 2) / h), 0 >= R || 0 >= Q ? 0 : (k[0] = R, j[0] = Q, 1);
    }
    function Be(h, y) {
      return h + (1 << y) - 1 >>> y;
    }
    function et(h, y) {
      return ((4278255360 & h) + (4278255360 & y) >>> 0 & 4278255360) + ((16711935 & h) + (16711935 & y) >>> 0 & 16711935) >>> 0;
    }
    function Le(h, y) {
      B[y] = function(k, j, R, Q, q, V, z) {
        var $;
        for ($ = 0; $ < q; ++$) {
          var se = B[h](V[z + $ - 1], R, Q + $);
          V[z + $] = et(k[j + $], se);
        }
      };
    }
    function Fe() {
      this.ud = this.hd = this.jd = 0;
    }
    function tt(h, y) {
      return ((4278124286 & (h ^ y)) >>> 1) + (h & y) >>> 0;
    }
    function we(h) {
      return 0 <= h && 256 > h ? h : 0 > h ? 0 : 255 < h ? 255 : void 0;
    }
    function Ge(h, y) {
      return we(h + (h - y + 0.5 >> 1));
    }
    function ze(h, y, k) {
      return Math.abs(y - k) - Math.abs(h - k);
    }
    function Ze(h, y, k, j, R, Q, q) {
      for (j = Q[q - 1], k = 0; k < R; ++k) Q[q + k] = j = et(h[y + k], j);
    }
    function ht(h, y, k, j, R) {
      var Q;
      for (Q = 0; Q < k; ++Q) {
        var q = h[y + Q], V = q >> 8 & 255, z = 16711935 & (z = (z = 16711935 & q) + ((V << 16) + V));
        j[R + Q] = (4278255360 & q) + z >>> 0;
      }
    }
    function rt(h, y) {
      y.jd = 255 & h, y.hd = h >> 8 & 255, y.ud = h >> 16 & 255;
    }
    function Ct(h, y, k, j, R, Q) {
      var q;
      for (q = 0; q < j; ++q) {
        var V = y[k + q], z = V >>> 8, $ = V, se = 255 & (se = (se = V >>> 16) + ((h.jd << 24 >> 24) * (z << 24 >> 24) >>> 5));
        $ = 255 & ($ = ($ += (h.hd << 24 >> 24) * (z << 24 >> 24) >>> 5) + ((h.ud << 24 >> 24) * (se << 24 >> 24) >>> 5)), R[Q + q] = (4278255360 & V) + (se << 16) + $;
      }
    }
    function it(h, y, k, j, R) {
      B[y] = function(Q, q, V, z, $, se, be, W, ue) {
        for (z = be; z < W; ++z) for (be = 0; be < ue; ++be) $[se++] = R(V[j(Q[q++])]);
      }, B[h] = function(Q, q, V, z, $, se, be) {
        var W = 8 >> Q.b, ue = Q.Ea, _e = Q.K[0], xe = Q.w;
        if (8 > W) for (Q = (1 << Q.b) - 1, xe = (1 << W) - 1; q < V; ++q) {
          var fe, Se = 0;
          for (fe = 0; fe < ue; ++fe) fe & Q || (Se = j(z[$++])), se[be++] = R(_e[Se & xe]), Se >>= W;
        }
        else B["VP8LMapColor" + k](z, $, _e, xe, se, be, q, V, ue);
      };
    }
    function Kt(h, y, k, j, R) {
      for (k = y + k; y < k; ) {
        var Q = h[y++];
        j[R++] = Q >> 16 & 255, j[R++] = Q >> 8 & 255, j[R++] = 255 & Q;
      }
    }
    function ve(h, y, k, j, R) {
      for (k = y + k; y < k; ) {
        var Q = h[y++];
        j[R++] = Q >> 16 & 255, j[R++] = Q >> 8 & 255, j[R++] = 255 & Q, j[R++] = Q >> 24 & 255;
      }
    }
    function J(h, y, k, j, R) {
      for (k = y + k; y < k; ) {
        var Q = (q = h[y++]) >> 16 & 240 | q >> 12 & 15, q = 240 & q | q >> 28 & 15;
        j[R++] = Q, j[R++] = q;
      }
    }
    function ge(h, y, k, j, R) {
      for (k = y + k; y < k; ) {
        var Q = (q = h[y++]) >> 16 & 248 | q >> 13 & 7, q = q >> 5 & 224 | q >> 3 & 31;
        j[R++] = Q, j[R++] = q;
      }
    }
    function We(h, y, k, j, R) {
      for (k = y + k; y < k; ) {
        var Q = h[y++];
        j[R++] = 255 & Q, j[R++] = Q >> 8 & 255, j[R++] = Q >> 16 & 255;
      }
    }
    function nt(h, y, k, j, R, Q) {
      if (Q == 0) for (k = y + k; y < k; ) Ce(j, ((Q = h[y++])[0] >> 24 | Q[1] >> 8 & 65280 | Q[2] << 8 & 16711680 | Q[3] << 24) >>> 0), R += 32;
      else r(j, R, h, y, k);
    }
    function rr(h, y) {
      B[y][0] = B[h + "0"], B[y][1] = B[h + "1"], B[y][2] = B[h + "2"], B[y][3] = B[h + "3"], B[y][4] = B[h + "4"], B[y][5] = B[h + "5"], B[y][6] = B[h + "6"], B[y][7] = B[h + "7"], B[y][8] = B[h + "8"], B[y][9] = B[h + "9"], B[y][10] = B[h + "10"], B[y][11] = B[h + "11"], B[y][12] = B[h + "12"], B[y][13] = B[h + "13"], B[y][14] = B[h + "0"], B[y][15] = B[h + "0"];
    }
    function _t(h) {
      return h == qg || h == Gg || h == Od || h == Vg;
    }
    function wt() {
      this.eb = [], this.size = this.A = this.fb = 0;
    }
    function or() {
      this.y = [], this.f = [], this.ea = [], this.F = [], this.Tc = this.Ed = this.Cd = this.Fd = this.lb = this.Db = this.Ab = this.fa = this.J = this.W = this.N = this.O = 0;
    }
    function mt() {
      this.Rd = this.height = this.width = this.S = 0, this.f = {}, this.f.RGBA = new wt(), this.f.kb = new or(), this.sd = null;
    }
    function Nt() {
      this.width = [0], this.height = [0], this.Pd = [0], this.Qd = [0], this.format = [0];
    }
    function Bt() {
      this.Id = this.fd = this.Md = this.hb = this.ib = this.da = this.bd = this.cd = this.j = this.v = this.Da = this.Sd = this.ob = 0;
    }
    function ur(h) {
      return alert("todo:WebPSamplerProcessPlane"), h.T;
    }
    function vr(h, y) {
      var k = h.T, j = y.ba.f.RGBA, R = j.eb, Q = j.fb + h.ka * j.A, q = di[y.ba.S], V = h.y, z = h.O, $ = h.f, se = h.N, be = h.ea, W = h.W, ue = y.cc, _e = y.dc, xe = y.Mc, fe = y.Nc, Se = h.ka, je = h.ka + h.T, Ve = h.U, Oe = Ve + 1 >> 1;
      for (Se == 0 ? q(V, z, null, null, $, se, be, W, $, se, be, W, R, Q, null, null, Ve) : (q(y.ec, y.fc, V, z, ue, _e, xe, fe, $, se, be, W, R, Q - j.A, R, Q, Ve), ++k); Se + 2 < je; Se += 2) ue = $, _e = se, xe = be, fe = W, se += h.Rc, W += h.Rc, Q += 2 * j.A, q(V, (z += 2 * h.fa) - h.fa, V, z, ue, _e, xe, fe, $, se, be, W, R, Q - j.A, R, Q, Ve);
      return z += h.fa, h.j + je < h.o ? (r(y.ec, y.fc, V, z, Ve), r(y.cc, y.dc, $, se, Oe), r(y.Mc, y.Nc, be, W, Oe), k--) : 1 & je || q(V, z, null, null, $, se, be, W, $, se, be, W, R, Q + j.A, null, null, Ve), k;
    }
    function Kr(h, y, k) {
      var j = h.F, R = [h.J];
      if (j != null) {
        var Q = h.U, q = y.ba.S, V = q == Rd || q == Od;
        y = y.ba.f.RGBA;
        var z = [0], $ = h.ka;
        z[0] = h.T, h.Kb && ($ == 0 ? --z[0] : (--$, R[0] -= h.width), h.j + h.ka + h.T == h.o && (z[0] = h.o - h.j - $));
        var se = y.eb;
        $ = y.fb + $ * y.A, h = Tw(j, R[0], h.width, Q, z, se, $ + (V ? 0 : 3), y.A), e(k == z), h && _t(q) && Su(se, $, V, Q, z, y.A);
      }
      return 0;
    }
    function To(h) {
      var y = h.ma, k = y.ba.S, j = 11 > k, R = k == Id || k == Md || k == Rd || k == Qg || k == 12 || _t(k);
      if (y.memory = null, y.Ib = null, y.Jb = null, y.Nd = null, !mu(y.Oa, h, R ? 11 : 12)) return 0;
      if (R && _t(k) && gu(), h.da) alert("todo:use_scaling");
      else {
        if (j) {
          if (y.Ib = ur, h.Kb) {
            if (k = h.U + 1 >> 1, y.memory = i(h.U + 2 * k), y.memory == null) return 0;
            y.ec = y.memory, y.fc = 0, y.cc = y.ec, y.dc = y.fc + h.U, y.Mc = y.cc, y.Nc = y.dc + k, y.Ib = vr, gu();
          }
        } else alert("todo:EmitYUV");
        R && (y.Jb = Kr, j && Ci());
      }
      if (j && !Kw) {
        for (h = 0; 256 > h; ++h) eF[h] = 89858 * (h - 128) + qd >> Qd, oF[h] = -22014 * (h - 128) + qd, rF[h] = -45773 * (h - 128), tF[h] = 113618 * (h - 128) + qd >> Qd;
        for (h = Eu; h < zg; ++h) y = 76283 * (h - 16) + qd >> Qd, nF[h - Eu] = Wi(y, 255), iF[h - Eu] = Wi(y + 8 >> 4, 15);
        Kw = 1;
      }
      return 1;
    }
    function xt(h) {
      var y = h.ma, k = h.U, j = h.T;
      return e(!(1 & h.ka)), 0 >= k || 0 >= j ? 0 : (k = y.Ib(h, y), y.Jb != null && y.Jb(h, y, k), y.Dc += k, 1);
    }
    function Qo(h) {
      h.ma.memory = null;
    }
    function qo(h, y, k, j) {
      return ae(h, 8) != 47 ? 0 : (y[0] = ae(h, 14) + 1, k[0] = ae(h, 14) + 1, j[0] = ae(h, 1), ae(h, 3) != 0 ? 0 : !h.h);
    }
    function Xo(h, y) {
      if (4 > h) return h + 1;
      var k = h - 2 >> 1;
      return (2 + (1 & h) << k) + ae(y, k) + 1;
    }
    function lo(h, y) {
      return 120 < y ? y - 120 : 1 <= (k = ((k = QP[y - 1]) >> 4) * h + (8 - (15 & k))) ? k : 1;
      var k;
    }
    function jr(h, y, k) {
      var j = H(k), R = h[y += 255 & j].g - 8;
      return 0 < R && (ne(k, k.u + 8), j = H(k), y += h[y].value, y += j & (1 << R) - 1), ne(k, k.u + h[y].g), h[y].value;
    }
    function Ir(h, y, k) {
      return k.g += h.g, k.value += h.value << y >>> 0, e(8 >= k.g), h.g;
    }
    function Ie(h, y, k) {
      var j = h.xc;
      return e((y = j == 0 ? 0 : h.vc[h.md * (k >> j) + (y >> j)]) < h.Wb), h.Ya[y];
    }
    function gt(h, y, k, j) {
      var R = h.ab, Q = h.c * y, q = h.C;
      y = q + y;
      var V = k, z = j;
      for (j = h.Ta, k = h.Ua; 0 < R--; ) {
        var $ = h.gc[R], se = q, be = y, W = V, ue = z, _e = (z = j, V = k, $.Ea);
        switch (e(se < be), e(be <= $.nc), $.hc) {
          case 2:
            fo(W, ue, (be - se) * _e, z, V);
            break;
          case 0:
            var xe = se, fe = be, Se = z, je = V, Ve = (jt = $).Ea;
            xe == 0 && (bu(W, ue, null, null, 1, Se, je), Ze(W, ue + 1, 0, 0, Ve - 1, Se, je + 1), ue += Ve, je += Ve, ++xe);
            for (var Oe = 1 << jt.b, Ft = Oe - 1, yt = Be(Ve, jt.b), Jt = jt.K, jt = jt.w + (xe >> jt.b) * yt; xe < fe; ) {
              var Ar = Jt, zo = jt, er = 1;
              for (nc(W, ue, Se, je - Ve, 1, Se, je); er < Ve; ) {
                var Lt = (er & ~Ft) + Oe;
                Lt > Ve && (Lt = Ve), (0, wu[Ar[zo++] >> 8 & 15])(W, ue + +er, Se, je + er - Ve, Lt - er, Se, je + er), er = Lt;
              }
              ue += Ve, je += Ve, ++xe & Ft || (jt += yt);
            }
            be != $.nc && r(z, V - _e, z, V + (be - se - 1) * _e, _e);
            break;
          case 1:
            for (_e = W, fe = ue, Ve = (W = $.Ea) - (je = W & ~(Se = (ue = 1 << $.b) - 1)), xe = Be(W, $.b), Oe = $.K, $ = $.w + (se >> $.b) * xe; se < be; ) {
              for (Ft = Oe, yt = $, Jt = new Fe(), jt = fe + je, Ar = fe + W; fe < jt; ) rt(Ft[yt++], Jt), xu(Jt, _e, fe, ue, z, V), fe += ue, V += ue;
              fe < Ar && (rt(Ft[yt++], Jt), xu(Jt, _e, fe, Ve, z, V), fe += Ve, V += Ve), ++se & Se || ($ += xe);
            }
            break;
          case 3:
            if (W == z && ue == V && 0 < $.b) {
              for (fe = z, W = _e = V + (be - se) * _e - (je = (be - se) * Be($.Ea, $.b)), ue = z, Se = V, xe = [], je = (Ve = je) - 1; 0 <= je; --je) xe[je] = ue[Se + je];
              for (je = Ve - 1; 0 <= je; --je) fe[W + je] = xe[je];
              Pd($, se, be, z, _e, z, V);
            } else Pd($, se, be, W, ue, z, V);
        }
        V = j, z = k;
      }
      z != k && r(j, k, V, z, Q);
    }
    function dt(h, y) {
      var k = h.V, j = h.Ba + h.c * h.C, R = y - h.C;
      if (e(y <= h.l.o), e(16 >= R), 0 < R) {
        var Q = h.l, q = h.Ta, V = h.Ua, z = Q.width;
        if (gt(h, R, k, j), R = V = [V], e((k = h.C) < (j = y)), e(Q.v < Q.va), j > Q.o && (j = Q.o), k < Q.j) {
          var $ = Q.j - k;
          k = Q.j, R[0] += $ * z;
        }
        if (k >= j ? k = 0 : (R[0] += 4 * Q.v, Q.ka = k - Q.j, Q.U = Q.va - Q.v, Q.T = j - k, k = 1), k) {
          if (V = V[0], 11 > (k = h.ca).S) {
            var se = k.f.RGBA, be = (j = k.S, R = Q.U, Q = Q.T, $ = se.eb, se.A), W = Q;
            for (se = se.fb + h.Ma * se.A; 0 < W--; ) {
              var ue = q, _e = V, xe = R, fe = $, Se = se;
              switch (j) {
                case Nd:
                  ku(ue, _e, xe, fe, Se);
                  break;
                case Id:
                  cs(ue, _e, xe, fe, Se);
                  break;
                case qg:
                  cs(ue, _e, xe, fe, Se), Su(fe, Se, 0, xe, 1, 0);
                  break;
                case Rw:
                  Al(ue, _e, xe, fe, Se);
                  break;
                case Md:
                  nt(ue, _e, xe, fe, Se, 1);
                  break;
                case Gg:
                  nt(ue, _e, xe, fe, Se, 1), Su(fe, Se, 0, xe, 1, 0);
                  break;
                case Rd:
                  nt(ue, _e, xe, fe, Se, 0);
                  break;
                case Od:
                  nt(ue, _e, xe, fe, Se, 0), Su(fe, Se, 1, xe, 1, 0);
                  break;
                case Qg:
                  us(ue, _e, xe, fe, Se);
                  break;
                case Vg:
                  us(ue, _e, xe, fe, Se), Lw(fe, Se, xe, 1, 0);
                  break;
                case Ow:
                  As(ue, _e, xe, fe, Se);
                  break;
                default:
                  e(0);
              }
              V += z, se += be;
            }
            h.Ma += Q;
          } else alert("todo:EmitRescaledRowsYUVA");
          e(h.Ma <= k.height);
        }
      }
      h.C = y, e(h.C <= h.i);
    }
    function Me(h) {
      var y;
      if (0 < h.ua) return 0;
      for (y = 0; y < h.Wb; ++y) {
        var k = h.Ya[y].G, j = h.Ya[y].H;
        if (0 < k[1][j[1] + 0].g || 0 < k[2][j[2] + 0].g || 0 < k[3][j[3] + 0].g) return 0;
      }
      return 1;
    }
    function Ht(h, y, k, j, R, Q) {
      if (h.Z != 0) {
        var q = h.qd, V = h.rd;
        for (e(hs[h.Z] != null); y < k; ++y) hs[h.Z](q, V, j, R, j, R, Q), q = j, V = R, R += Q;
        h.qd = q, h.rd = V;
      }
    }
    function Ot(h, y) {
      var k = h.l.ma, j = k.Z == 0 || k.Z == 1 ? h.l.j : h.C;
      if (j = h.C < j ? j : h.C, e(y <= h.l.o), y > j) {
        var R = h.l.width, Q = k.ca, q = k.tb + R * j, V = h.V, z = h.Ba + h.c * j, $ = h.gc;
        e(h.ab == 1), e($[0].hc == 3), Ji($[0], j, y, V, z, Q, q), Ht(k, j, y, Q, q, R);
      }
      h.C = h.Ma = y;
    }
    function qt(h, y, k, j, R, Q, q) {
      var V = h.$ / j, z = h.$ % j, $ = h.m, se = h.s, be = k + h.$, W = be;
      R = k + j * R;
      var ue = k + j * Q, _e = 280 + se.ua, xe = h.Pb ? V : 16777216, fe = 0 < se.ua ? se.Wa : null, Se = se.wc, je = be < ue ? Ie(se, z, V) : null;
      e(h.C < Q), e(ue <= R);
      var Ve = !1;
      e: for (; ; ) {
        for (; Ve || be < ue; ) {
          var Oe = 0;
          if (V >= xe) {
            var Ft = be - k;
            e((xe = h).Pb), xe.wd = xe.m, xe.xd = Ft, 0 < xe.s.ua && Ne(xe.s.Wa, xe.s.vb), xe = V + GP;
          }
          if (z & Se || (je = Ie(se, z, V)), e(je != null), je.Qb && (y[be] = je.qb, Ve = !0), !Ve) if (le($), je.jc) {
            Oe = $, Ft = y;
            var yt = be, Jt = je.pd[H(Oe) & ul - 1];
            e(je.jc), 256 > Jt.g ? (ne(Oe, Oe.u + Jt.g), Ft[yt] = Jt.value, Oe = 0) : (ne(Oe, Oe.u + Jt.g - 256), e(256 <= Jt.value), Oe = Jt.value), Oe == 0 && (Ve = !0);
          } else Oe = jr(je.G[0], je.H[0], $);
          if ($.h) break;
          if (Ve || 256 > Oe) {
            if (!Ve) if (je.nd) y[be] = (je.qb | Oe << 8) >>> 0;
            else {
              if (le($), Ve = jr(je.G[1], je.H[1], $), le($), Ft = jr(je.G[2], je.H[2], $), yt = jr(je.G[3], je.H[3], $), $.h) break;
              y[be] = (yt << 24 | Ve << 16 | Oe << 8 | Ft) >>> 0;
            }
            if (Ve = !1, ++be, ++z >= j && (z = 0, ++V, q != null && V <= Q && !(V % 16) && q(h, V), fe != null)) for (; W < be; ) Oe = y[W++], fe.X[(506832829 * Oe & 4294967295) >>> fe.Mb] = Oe;
          } else if (280 > Oe) {
            if (Oe = Xo(Oe - 256, $), Ft = jr(je.G[4], je.H[4], $), le($), Ft = lo(j, Ft = Xo(Ft, $)), $.h) break;
            if (be - k < Ft || R - be < Oe) break e;
            for (yt = 0; yt < Oe; ++yt) y[be + yt] = y[be + yt - Ft];
            for (be += Oe, z += Oe; z >= j; ) z -= j, ++V, q != null && V <= Q && !(V % 16) && q(h, V);
            if (e(be <= R), z & Se && (je = Ie(se, z, V)), fe != null) for (; W < be; ) Oe = y[W++], fe.X[(506832829 * Oe & 4294967295) >>> fe.Mb] = Oe;
          } else {
            if (!(Oe < _e)) break e;
            for (Ve = Oe - 280, e(fe != null); W < be; ) Oe = y[W++], fe.X[(506832829 * Oe & 4294967295) >>> fe.Mb] = Oe;
            Oe = be, e(!(Ve >>> (Ft = fe).Xa)), y[Oe] = Ft.X[Ve], Ve = !0;
          }
          Ve || e($.h == Z($));
        }
        if (h.Pb && $.h && be < R) e(h.m.h), h.a = 5, h.m = h.wd, h.$ = h.xd, 0 < h.s.ua && Ne(h.s.vb, h.s.Wa);
        else {
          if ($.h) break e;
          q?.(h, V > Q ? Q : V), h.a = 0, h.$ = be - k;
        }
        return 1;
      }
      return h.a = 3, 0;
    }
    function Zr(h) {
      e(h != null), h.vc = null, h.yc = null, h.Ya = null;
      var y = h.Wa;
      y != null && (y.X = null), h.vb = null, e(h != null);
    }
    function $r() {
      var h = new Vt();
      return h == null ? null : (h.a = 0, h.xb = Gw, rr("Predictor", "VP8LPredictors"), rr("Predictor", "VP8LPredictors_C"), rr("PredictorAdd", "VP8LPredictorsAdd"), rr("PredictorAdd", "VP8LPredictorsAdd_C"), fo = ht, xu = Ct, ku = Kt, cs = ve, us = J, As = ge, Al = We, B.VP8LMapColor32b = Zi, B.VP8LMapColor8b = vu, h);
    }
    function re(h, y, k, j, R) {
      var Q = 1, q = [h], V = [y], z = j.m, $ = j.s, se = null, be = 0;
      e: for (; ; ) {
        if (k) for (; Q && ae(z, 1); ) {
          var W = q, ue = V, _e = j, xe = 1, fe = _e.m, Se = _e.gc[_e.ab], je = ae(fe, 2);
          if (_e.Oc & 1 << je) Q = 0;
          else {
            switch (_e.Oc |= 1 << je, Se.hc = je, Se.Ea = W[0], Se.nc = ue[0], Se.K = [null], ++_e.ab, e(4 >= _e.ab), je) {
              case 0:
              case 1:
                Se.b = ae(fe, 3) + 2, xe = re(Be(Se.Ea, Se.b), Be(Se.nc, Se.b), 0, _e, Se.K), Se.K = Se.K[0];
                break;
              case 3:
                var Ve, Oe = ae(fe, 8) + 1, Ft = 16 < Oe ? 0 : 4 < Oe ? 1 : 2 < Oe ? 2 : 3;
                if (W[0] = Be(Se.Ea, Ft), Se.b = Ft, Ve = xe = re(Oe, 1, 0, _e, Se.K)) {
                  var yt, Jt = Oe, jt = Se, Ar = 1 << (8 >> jt.b), zo = i(Ar);
                  if (zo == null) Ve = 0;
                  else {
                    var er = jt.K[0], Lt = jt.w;
                    for (zo[0] = jt.K[0][0], yt = 1; yt < 1 * Jt; ++yt) zo[yt] = et(er[Lt + yt], zo[yt - 1]);
                    for (; yt < 4 * Ar; ++yt) zo[yt] = 0;
                    jt.K[0] = null, jt.K[0] = zo, Ve = 1;
                  }
                }
                xe = Ve;
                break;
              case 2:
                break;
              default:
                e(0);
            }
            Q = xe;
          }
        }
        if (q = q[0], V = V[0], Q && ae(z, 1) && !(Q = 1 <= (be = ae(z, 4)) && 11 >= be)) {
          j.a = 3;
          break e;
        }
        var at;
        if (at = Q) t: {
          var yo, Xt, pr, Wr = j, an = q, En = V, co = be, hn = k, jn = Wr.m, Ko = Wr.s, _r = [null], Lr = 1, uo = 0, Tr = qP[co];
          r: for (; ; ) {
            if (hn && ae(jn, 1)) {
              var sn = ae(jn, 3) + 2, Bi = Be(an, sn), bo = Be(En, sn), On = Bi * bo;
              if (!re(Bi, bo, 0, Wr, _r)) break r;
              for (_r = _r[0], Ko.xc = sn, yo = 0; yo < On; ++yo) {
                var Rr = _r[yo] >> 8 & 65535;
                _r[yo] = Rr, Rr >= Lr && (Lr = Rr + 1);
              }
            }
            if (jn.h) break r;
            for (Xt = 0; 5 > Xt; ++Xt) {
              var $o = Qw[Xt];
              !Xt && 0 < co && ($o += 1 << co), uo < $o && (uo = $o);
            }
            var Yn = a(Lr * Tr, U), Ln = Lr, Zn = a(Ln, K);
            if (Zn == null) var Jn = null;
            else e(65536 >= Ln), Jn = Zn;
            var Qn = i(uo);
            if (Jn == null || Qn == null || Yn == null) {
              Wr.a = 1;
              break r;
            }
            var ei = Yn;
            for (yo = pr = 0; yo < Lr; ++yo) {
              var Vr = Jn[yo], ti = Vr.G, Ei = Vr.H, pl = 0, Ea = 1, ln = 0;
              for (Xt = 0; 5 > Xt; ++Xt) {
                $o = Qw[Xt], ti[Xt] = ei, Ei[Xt] = pr, !Xt && 0 < co && ($o += 1 << co);
                n: {
                  var Vd, Kg = $o, Dd = Wr, ju = Qn, lF = ei, cF = pr, $g = 0, gs = Dd.m, uF = ae(gs, 1);
                  if (n(ju, 0, 0, Kg), uF) {
                    var AF = ae(gs, 1) + 1, dF = ae(gs, 1), Xw = ae(gs, dF == 0 ? 1 : 8);
                    ju[Xw] = 1, AF == 2 && (ju[Xw = ae(gs, 8)] = 1);
                    var Hd = 1;
                  } else {
                    var Yw = i(19), Zw = ae(gs, 4) + 4;
                    if (19 < Zw) {
                      Dd.a = 3;
                      var zd = 0;
                      break n;
                    }
                    for (Vd = 0; Vd < Zw; ++Vd) Yw[OP[Vd]] = ae(gs, 3);
                    var Wg = void 0, Lu = void 0, Jw = Dd, pF = Yw, Kd = Kg, e0 = ju, Xg = 0, _s = Jw.m, t0 = 8, r0 = a(128, U);
                    o: for (; L(r0, 0, 7, pF, 19); ) {
                      if (ae(_s, 1)) {
                        var hF = 2 + 2 * ae(_s, 3);
                        if ((Wg = 2 + ae(_s, hF)) > Kd) break o;
                      } else Wg = Kd;
                      for (Lu = 0; Lu < Kd && Wg--; ) {
                        le(_s);
                        var o0 = r0[0 + (127 & H(_s))];
                        ne(_s, _s.u + o0.g);
                        var ac = o0.value;
                        if (16 > ac) e0[Lu++] = ac, ac != 0 && (t0 = ac);
                        else {
                          var gF = ac == 16, n0 = ac - 16, _F = MP[n0], i0 = ae(_s, IP[n0]) + _F;
                          if (Lu + i0 > Kd) break o;
                          for (var fF = gF ? t0 : 0; 0 < i0--; ) e0[Lu++] = fF;
                        }
                      }
                      Xg = 1;
                      break o;
                    }
                    Xg || (Jw.a = 3), Hd = Xg;
                  }
                  (Hd = Hd && !gs.h) && ($g = L(lF, cF, 8, ju, Kg)), Hd && $g != 0 ? zd = $g : (Dd.a = 3, zd = 0);
                }
                if (zd == 0) break r;
                if (Ea && RP[Xt] == 1 && (Ea = ei[pr].g == 0), pl += ei[pr].g, pr += zd, 3 >= Xt) {
                  var Tu, Yg = Qn[0];
                  for (Tu = 1; Tu < $o; ++Tu) Qn[Tu] > Yg && (Yg = Qn[Tu]);
                  ln += Yg;
                }
              }
              if (Vr.nd = Ea, Vr.Qb = 0, Ea && (Vr.qb = (ti[3][Ei[3] + 0].value << 24 | ti[1][Ei[1] + 0].value << 16 | ti[2][Ei[2] + 0].value) >>> 0, pl == 0 && 256 > ti[0][Ei[0] + 0].value && (Vr.Qb = 1, Vr.qb += ti[0][Ei[0] + 0].value << 8)), Vr.jc = !Vr.Qb && 6 > ln, Vr.jc) {
                var $d, ja = Vr;
                for ($d = 0; $d < ul; ++$d) {
                  var fs = $d, ms = ja.pd[fs], Wd = ja.G[0][ja.H[0] + fs];
                  256 <= Wd.value ? (ms.g = Wd.g + 256, ms.value = Wd.value) : (ms.g = 0, ms.value = 0, fs >>= Ir(Wd, 8, ms), fs >>= Ir(ja.G[1][ja.H[1] + fs], 16, ms), fs >>= Ir(ja.G[2][ja.H[2] + fs], 0, ms), Ir(ja.G[3][ja.H[3] + fs], 24, ms));
                }
              }
            }
            Ko.vc = _r, Ko.Wb = Lr, Ko.Ya = Jn, Ko.yc = Yn, at = 1;
            break t;
          }
          at = 0;
        }
        if (!(Q = at)) {
          j.a = 3;
          break e;
        }
        if (0 < be) {
          if ($.ua = 1 << be, !D($.Wa, be)) {
            j.a = 1, Q = 0;
            break e;
          }
        } else $.ua = 0;
        var Zg = j, a0 = q, mF = V, Jg = Zg.s, e_ = Jg.xc;
        if (Zg.c = a0, Zg.i = mF, Jg.md = Be(a0, e_), Jg.wc = e_ == 0 ? -1 : (1 << e_) - 1, k) {
          j.xb = WP;
          break e;
        }
        if ((se = i(q * V)) == null) {
          j.a = 1, Q = 0;
          break e;
        }
        Q = (Q = qt(j, se, 0, q, V, V, null)) && !z.h;
        break e;
      }
      return Q ? (R != null ? R[0] = se : (e(se == null), e(k)), j.$ = 0, k || Zr($)) : Zr($), Q;
    }
    function Ke(h, y) {
      var k = h.c * h.i, j = k + y + 16 * y;
      return e(h.c <= y), h.V = i(j), h.V == null ? (h.Ta = null, h.Ua = 0, h.a = 1, 0) : (h.Ta = h.V, h.Ua = h.Ba + k + y, 1);
    }
    function He(h, y) {
      var k = h.C, j = y - k, R = h.V, Q = h.Ba + h.c * k;
      for (e(y <= h.l.o); 0 < j; ) {
        var q = 16 < j ? 16 : j, V = h.l.ma, z = h.l.width, $ = z * q, se = V.ca, be = V.tb + z * k, W = h.Ta, ue = h.Ua;
        gt(h, q, R, Q), Pw(W, ue, se, be, $), Ht(V, k, k + q, se, be, z), j -= q, R += q * h.c, k += q;
      }
      e(k == y), h.C = h.Ma = y;
    }
    function $t() {
      this.ub = this.yd = this.td = this.Rb = 0;
    }
    function dr() {
      this.Kd = this.Ld = this.Ud = this.Td = this.i = this.c = 0;
    }
    function Pr() {
      this.Fb = this.Bb = this.Cb = 0, this.Zb = i(4), this.Lb = i(4);
    }
    function Po() {
      this.Yb = (function() {
        var h = [];
        return (function y(k, j, R) {
          for (var Q = R[j], q = 0; q < Q && (k.push(R.length > j + 1 ? [] : 0), !(R.length < j + 1)); q++) y(k[q], j + 1, R);
        })(h, 0, [3, 11]), h;
      })();
    }
    function rn() {
      this.jb = i(3), this.Wc = s([4, 8], Po), this.Xc = s([4, 17], Po);
    }
    function Sn() {
      this.Pc = this.wb = this.Tb = this.zd = 0, this.vd = new i(4), this.od = new i(4);
    }
    function Fr() {
      this.ld = this.La = this.dd = this.tc = 0;
    }
    function os() {
      this.Na = this.la = 0;
    }
    function Xl() {
      this.Sc = [0, 0], this.Eb = [0, 0], this.Qc = [0, 0], this.ia = this.lc = 0;
    }
    function au() {
      this.ad = i(384), this.Za = 0, this.Ob = i(16), this.$b = this.Ad = this.ia = this.Gc = this.Hc = this.Dd = 0;
    }
    function fd() {
      this.uc = this.M = this.Nb = 0, this.wa = Array(new Fr()), this.Y = 0, this.ya = Array(new au()), this.aa = 0, this.l = new Yl();
    }
    function md() {
      this.y = i(16), this.f = i(8), this.ea = i(8);
    }
    function yd() {
      this.cb = this.a = 0, this.sc = "", this.m = new I(), this.Od = new $t(), this.Kc = new dr(), this.ed = new Sn(), this.Qa = new Pr(), this.Ic = this.$c = this.Aa = 0, this.D = new fd(), this.Xb = this.Va = this.Hb = this.zb = this.yb = this.Ub = this.za = 0, this.Jc = a(8, I), this.ia = 0, this.pb = a(4, Xl), this.Pa = new rn(), this.Bd = this.kc = 0, this.Ac = [], this.Bc = 0, this.zc = [0, 0, 0, 0], this.Gd = Array(new md()), this.Hd = 0, this.rb = Array(new os()), this.sb = 0, this.wa = Array(new Fr()), this.Y = 0, this.oc = [], this.pc = 0, this.sa = [], this.ta = 0, this.qa = [], this.ra = 0, this.Ha = [], this.B = this.R = this.Ia = 0, this.Ec = [], this.M = this.ja = this.Vb = this.Fc = 0, this.ya = Array(new au()), this.L = this.aa = 0, this.gd = s([4, 2], Fr), this.ga = null, this.Fa = [], this.Cc = this.qc = this.P = 0, this.Gb = [], this.Uc = 0, this.mb = [], this.nb = 0, this.rc = [], this.Ga = this.Vc = 0;
    }
    function Wi(h, y) {
      return 0 > h ? 0 : h > y ? y : h;
    }
    function Yl() {
      this.T = this.U = this.ka = this.height = this.width = 0, this.y = [], this.f = [], this.ea = [], this.Rc = this.fa = this.W = this.N = this.O = 0, this.ma = "void", this.put = "VP8IoPutHook", this.ac = "VP8IoSetupHook", this.bc = "VP8IoTeardownHook", this.ha = this.Kb = 0, this.data = [], this.hb = this.ib = this.da = this.o = this.j = this.va = this.v = this.Da = this.ob = this.w = 0, this.F = [], this.J = 0;
    }
    function kg() {
      var h = new yd();
      return h != null && (h.a = 0, h.sc = "OK", h.cb = 0, h.Xb = 0, Bu || (Bu = Zl)), h;
    }
    function Fo(h, y, k) {
      return h.a == 0 && (h.a = y, h.sc = k, h.cb = 0), 0;
    }
    function bd(h, y, k) {
      return 3 <= k && h[y + 0] == 157 && h[y + 1] == 1 && h[y + 2] == 42;
    }
    function Xi(h, y) {
      if (h == null) return 0;
      if (h.a = 0, h.sc = "OK", y == null) return Fo(h, 2, "null VP8Io passed to VP8GetHeaders()");
      var k = y.data, j = y.w, R = y.ha;
      if (4 > R) return Fo(h, 7, "Truncated header.");
      var Q = k[j + 0] | k[j + 1] << 8 | k[j + 2] << 16, q = h.Od;
      if (q.Rb = !(1 & Q), q.td = Q >> 1 & 7, q.yd = Q >> 4 & 1, q.ub = Q >> 5, 3 < q.td) return Fo(h, 3, "Incorrect keyframe parameters.");
      if (!q.yd) return Fo(h, 4, "Frame not displayable.");
      j += 3, R -= 3;
      var V = h.Kc;
      if (q.Rb) {
        if (7 > R) return Fo(h, 7, "cannot parse picture header");
        if (!bd(k, j, R)) return Fo(h, 3, "Bad code word");
        V.c = 16383 & (k[j + 4] << 8 | k[j + 3]), V.Td = k[j + 4] >> 6, V.i = 16383 & (k[j + 6] << 8 | k[j + 5]), V.Ud = k[j + 6] >> 6, j += 7, R -= 7, h.za = V.c + 15 >> 4, h.Ub = V.i + 15 >> 4, y.width = V.c, y.height = V.i, y.Da = 0, y.j = 0, y.v = 0, y.va = y.width, y.o = y.height, y.da = 0, y.ib = y.width, y.hb = y.height, y.U = y.width, y.T = y.height, n((Q = h.Pa).jb, 0, 255, Q.jb.length), e((Q = h.Qa) != null), Q.Cb = 0, Q.Bb = 0, Q.Fb = 1, n(Q.Zb, 0, 0, Q.Zb.length), n(Q.Lb, 0, 0, Q.Lb);
      }
      if (q.ub > R) return Fo(h, 7, "bad partition length");
      te(Q = h.m, k, j, q.ub), j += q.ub, R -= q.ub, q.Rb && (V.Ld = ce(Q), V.Kd = ce(Q)), V = h.Qa;
      var z, $ = h.Pa;
      if (e(Q != null), e(V != null), V.Cb = ce(Q), V.Cb) {
        if (V.Bb = ce(Q), ce(Q)) {
          for (V.Fb = ce(Q), z = 0; 4 > z; ++z) V.Zb[z] = ce(Q) ? ee(Q, 7) : 0;
          for (z = 0; 4 > z; ++z) V.Lb[z] = ce(Q) ? ee(Q, 6) : 0;
        }
        if (V.Bb) for (z = 0; 3 > z; ++z) $.jb[z] = ce(Q) ? Y(Q, 8) : 255;
      } else V.Bb = 0;
      if (Q.Ka) return Fo(h, 3, "cannot parse segment header");
      if ((V = h.ed).zd = ce(Q), V.Tb = Y(Q, 6), V.wb = Y(Q, 3), V.Pc = ce(Q), V.Pc && ce(Q)) {
        for ($ = 0; 4 > $; ++$) ce(Q) && (V.vd[$] = ee(Q, 6));
        for ($ = 0; 4 > $; ++$) ce(Q) && (V.od[$] = ee(Q, 6));
      }
      if (h.L = V.Tb == 0 ? 0 : V.zd ? 1 : 2, Q.Ka) return Fo(h, 3, "cannot parse filter header");
      var se = R;
      if (R = z = j, j = z + se, V = se, h.Xb = (1 << Y(h.m, 2)) - 1, se < 3 * ($ = h.Xb)) k = 7;
      else {
        for (z += 3 * $, V -= 3 * $, se = 0; se < $; ++se) {
          var be = k[R + 0] | k[R + 1] << 8 | k[R + 2] << 16;
          be > V && (be = V), te(h.Jc[+se], k, z, be), z += be, V -= be, R += 3;
        }
        te(h.Jc[+$], k, z, V), k = z < j ? 0 : 5;
      }
      if (k != 0) return Fo(h, k, "cannot parse partitions");
      for (k = Y(z = h.m, 7), R = ce(z) ? ee(z, 4) : 0, j = ce(z) ? ee(z, 4) : 0, V = ce(z) ? ee(z, 4) : 0, $ = ce(z) ? ee(z, 4) : 0, z = ce(z) ? ee(z, 4) : 0, se = h.Qa, be = 0; 4 > be; ++be) {
        if (se.Cb) {
          var W = se.Zb[be];
          se.Fb || (W += k);
        } else {
          if (0 < be) {
            h.pb[be] = h.pb[0];
            continue;
          }
          W = k;
        }
        var ue = h.pb[be];
        ue.Sc[0] = Dg[Wi(W + R, 127)], ue.Sc[1] = Hg[Wi(W + 0, 127)], ue.Eb[0] = 2 * Dg[Wi(W + j, 127)], ue.Eb[1] = 101581 * Hg[Wi(W + V, 127)] >> 16, 8 > ue.Eb[1] && (ue.Eb[1] = 8), ue.Qc[0] = Dg[Wi(W + $, 117)], ue.Qc[1] = Hg[Wi(W + z, 127)], ue.lc = W + z;
      }
      if (!q.Rb) return Fo(h, 4, "Not a key frame.");
      for (ce(Q), q = h.Pa, k = 0; 4 > k; ++k) {
        for (R = 0; 8 > R; ++R) for (j = 0; 3 > j; ++j) for (V = 0; 11 > V; ++V) $ = ye(Q, KP[k][R][j][V]) ? Y(Q, 8) : HP[k][R][j][V], q.Wc[k][R].Yb[j][V] = $;
        for (R = 0; 17 > R; ++R) q.Xc[k][R] = q.Wc[k][$P[R]];
      }
      return h.kc = ce(Q), h.kc && (h.Bd = Y(Q, 8)), h.cb = 1;
    }
    function Zl(h, y, k, j, R, Q, q) {
      var V = y[R].Yb[k];
      for (k = 0; 16 > R; ++R) {
        if (!ye(h, V[k + 0])) return R;
        for (; !ye(h, V[k + 1]); ) if (V = y[++R].Yb[0], k = 0, R == 16) return 16;
        var z = y[R + 1].Yb;
        if (ye(h, V[k + 2])) {
          var $ = h, se = 0;
          if (ye($, (W = V)[(be = k) + 3])) if (ye($, W[be + 6])) {
            for (V = 0, be = 2 * (se = ye($, W[be + 8])) + (W = ye($, W[be + 9 + se])), se = 0, W = VP[be]; W[V]; ++V) se += se + ye($, W[V]);
            se += 3 + (8 << be);
          } else ye($, W[be + 7]) ? (se = 7 + 2 * ye($, 165), se += ye($, 145)) : se = 5 + ye($, 159);
          else se = ye($, W[be + 4]) ? 3 + ye($, W[be + 5]) : 2;
          V = z[2];
        } else se = 1, V = z[1];
        z = q + DP[R], 0 > ($ = h).b && me($);
        var be, W = $.b, ue = (be = $.Ca >> 1) - ($.I >> W) >> 31;
        --$.b, $.Ca += ue, $.Ca |= 1, $.I -= (be + 1 & ue) << W, Q[z] = ((se ^ ue) - ue) * j[(0 < R) + 0];
      }
      return 16;
    }
    function vd(h) {
      var y = h.rb[h.sb - 1];
      y.la = 0, y.Na = 0, n(h.zc, 0, 0, h.zc.length), h.ja = 0;
    }
    function li(h, y, k, j, R) {
      R = h[y + k + 32 * j] + (R >> 3), h[y + k + 32 * j] = -256 & R ? 0 > R ? 0 : 255 : R;
    }
    function Go(h, y, k, j, R, Q) {
      li(h, y, 0, k, j + R), li(h, y, 1, k, j + Q), li(h, y, 2, k, j - Q), li(h, y, 3, k, j - R);
    }
    function ga(h) {
      return (20091 * h >> 16) + h;
    }
    function wd(h, y, k, j) {
      var R, Q = 0, q = i(16);
      for (R = 0; 4 > R; ++R) {
        var V = h[y + 0] + h[y + 8], z = h[y + 0] - h[y + 8], $ = (35468 * h[y + 4] >> 16) - ga(h[y + 12]), se = ga(h[y + 4]) + (35468 * h[y + 12] >> 16);
        q[Q + 0] = V + se, q[Q + 1] = z + $, q[Q + 2] = z - $, q[Q + 3] = V - se, Q += 4, y++;
      }
      for (R = Q = 0; 4 > R; ++R) V = (h = q[Q + 0] + 4) + q[Q + 8], z = h - q[Q + 8], $ = (35468 * q[Q + 4] >> 16) - ga(q[Q + 12]), li(k, j, 0, 0, V + (se = ga(q[Q + 4]) + (35468 * q[Q + 12] >> 16))), li(k, j, 1, 0, z + $), li(k, j, 2, 0, z - $), li(k, j, 3, 0, V - se), Q++, j += 32;
    }
    function Cg(h, y, k, j) {
      var R = h[y + 0] + 4, Q = 35468 * h[y + 4] >> 16, q = ga(h[y + 4]), V = 35468 * h[y + 1] >> 16;
      Go(k, j, 0, R + q, h = ga(h[y + 1]), V), Go(k, j, 1, R + Q, h, V), Go(k, j, 2, R - Q, h, V), Go(k, j, 3, R - q, h, V);
    }
    function Sg(h, y, k, j, R) {
      wd(h, y, k, j), R && wd(h, y + 16, k, j + 4);
    }
    function Yi(h, y, k, j) {
      dl(h, y + 0, k, j, 1), dl(h, y + 32, k, j + 128, 1);
    }
    function xd(h, y, k, j) {
      var R;
      for (h = h[y + 0] + 4, R = 0; 4 > R; ++R) for (y = 0; 4 > y; ++y) li(k, j, y, R, h);
    }
    function kd(h, y, k, j) {
      h[y + 0] && Sr(h, y + 0, k, j), h[y + 16] && Sr(h, y + 16, k, j + 4), h[y + 32] && Sr(h, y + 32, k, j + 128), h[y + 48] && Sr(h, y + 48, k, j + 128 + 4);
    }
    function Jl(h, y, k, j) {
      var R, Q = i(16);
      for (R = 0; 4 > R; ++R) {
        var q = h[y + 0 + R] + h[y + 12 + R], V = h[y + 4 + R] + h[y + 8 + R], z = h[y + 4 + R] - h[y + 8 + R], $ = h[y + 0 + R] - h[y + 12 + R];
        Q[0 + R] = q + V, Q[8 + R] = q - V, Q[4 + R] = $ + z, Q[12 + R] = $ - z;
      }
      for (R = 0; 4 > R; ++R) q = (h = Q[0 + 4 * R] + 3) + Q[3 + 4 * R], V = Q[1 + 4 * R] + Q[2 + 4 * R], z = Q[1 + 4 * R] - Q[2 + 4 * R], $ = h - Q[3 + 4 * R], k[j + 0] = q + V >> 3, k[j + 16] = $ + z >> 3, k[j + 32] = q - V >> 3, k[j + 48] = $ - z >> 3, j += 64;
    }
    function el(h, y, k) {
      var j, R = y - 32, Q = Xn, q = 255 - h[R - 1];
      for (j = 0; j < k; ++j) {
        var V, z = Q, $ = q + h[y - 1];
        for (V = 0; V < k; ++V) h[y + V] = z[$ + h[R + V]];
        y += 32;
      }
    }
    function Bg(h, y) {
      el(h, y, 4);
    }
    function Eg(h, y) {
      el(h, y, 8);
    }
    function jg(h, y) {
      el(h, y, 16);
    }
    function su(h, y) {
      var k;
      for (k = 0; 16 > k; ++k) r(h, y + 32 * k, h, y - 32, 16);
    }
    function Cd(h, y) {
      var k;
      for (k = 16; 0 < k; --k) n(h, y, h[y - 1], 16), y += 32;
    }
    function ki(h, y, k) {
      var j;
      for (j = 0; 16 > j; ++j) n(y, k + 32 * j, h, 16);
    }
    function Lg(h, y) {
      var k, j = 16;
      for (k = 0; 16 > k; ++k) j += h[y - 1 + 32 * k] + h[y + k - 32];
      ki(j >> 5, h, y);
    }
    function tl(h, y) {
      var k, j = 8;
      for (k = 0; 16 > k; ++k) j += h[y - 1 + 32 * k];
      ki(j >> 4, h, y);
    }
    function lu(h, y) {
      var k, j = 8;
      for (k = 0; 16 > k; ++k) j += h[y + k - 32];
      ki(j >> 4, h, y);
    }
    function Tg(h, y) {
      ki(128, h, y);
    }
    function zt(h, y, k) {
      return h + 2 * y + k + 2 >> 2;
    }
    function Pg(h, y) {
      var k, j = y - 32;
      for (j = new Uint8Array([zt(h[j - 1], h[j + 0], h[j + 1]), zt(h[j + 0], h[j + 1], h[j + 2]), zt(h[j + 1], h[j + 2], h[j + 3]), zt(h[j + 2], h[j + 3], h[j + 4])]), k = 0; 4 > k; ++k) r(h, y + 32 * k, j, 0, j.length);
    }
    function Fg(h, y) {
      var k = h[y - 1], j = h[y - 1 + 32], R = h[y - 1 + 64], Q = h[y - 1 + 96];
      Ce(h, y + 0, 16843009 * zt(h[y - 1 - 32], k, j)), Ce(h, y + 32, 16843009 * zt(k, j, R)), Ce(h, y + 64, 16843009 * zt(j, R, Q)), Ce(h, y + 96, 16843009 * zt(R, Q, Q));
    }
    function Ug(h, y) {
      var k, j = 4;
      for (k = 0; 4 > k; ++k) j += h[y + k - 32] + h[y - 1 + 32 * k];
      for (j >>= 3, k = 0; 4 > k; ++k) n(h, y + 32 * k, j, 4);
    }
    function _a(h, y) {
      var k = h[y - 1 + 0], j = h[y - 1 + 32], R = h[y - 1 + 64], Q = h[y - 1 - 32], q = h[y + 0 - 32], V = h[y + 1 - 32], z = h[y + 2 - 32], $ = h[y + 3 - 32];
      h[y + 0 + 96] = zt(j, R, h[y - 1 + 96]), h[y + 1 + 96] = h[y + 0 + 64] = zt(k, j, R), h[y + 2 + 96] = h[y + 1 + 64] = h[y + 0 + 32] = zt(Q, k, j), h[y + 3 + 96] = h[y + 2 + 64] = h[y + 1 + 32] = h[y + 0 + 0] = zt(q, Q, k), h[y + 3 + 64] = h[y + 2 + 32] = h[y + 1 + 0] = zt(V, q, Q), h[y + 3 + 32] = h[y + 2 + 0] = zt(z, V, q), h[y + 3 + 0] = zt($, z, V);
    }
    function fa(h, y) {
      var k = h[y + 1 - 32], j = h[y + 2 - 32], R = h[y + 3 - 32], Q = h[y + 4 - 32], q = h[y + 5 - 32], V = h[y + 6 - 32], z = h[y + 7 - 32];
      h[y + 0 + 0] = zt(h[y + 0 - 32], k, j), h[y + 1 + 0] = h[y + 0 + 32] = zt(k, j, R), h[y + 2 + 0] = h[y + 1 + 32] = h[y + 0 + 64] = zt(j, R, Q), h[y + 3 + 0] = h[y + 2 + 32] = h[y + 1 + 64] = h[y + 0 + 96] = zt(R, Q, q), h[y + 3 + 32] = h[y + 2 + 64] = h[y + 1 + 96] = zt(Q, q, V), h[y + 3 + 64] = h[y + 2 + 96] = zt(q, V, z), h[y + 3 + 96] = zt(V, z, z);
    }
    function Ng(h, y) {
      var k = h[y - 1 + 0], j = h[y - 1 + 32], R = h[y - 1 + 64], Q = h[y - 1 - 32], q = h[y + 0 - 32], V = h[y + 1 - 32], z = h[y + 2 - 32], $ = h[y + 3 - 32];
      h[y + 0 + 0] = h[y + 1 + 64] = Q + q + 1 >> 1, h[y + 1 + 0] = h[y + 2 + 64] = q + V + 1 >> 1, h[y + 2 + 0] = h[y + 3 + 64] = V + z + 1 >> 1, h[y + 3 + 0] = z + $ + 1 >> 1, h[y + 0 + 96] = zt(R, j, k), h[y + 0 + 64] = zt(j, k, Q), h[y + 0 + 32] = h[y + 1 + 96] = zt(k, Q, q), h[y + 1 + 32] = h[y + 2 + 96] = zt(Q, q, V), h[y + 2 + 32] = h[y + 3 + 96] = zt(q, V, z), h[y + 3 + 32] = zt(V, z, $);
    }
    function Ig(h, y) {
      var k = h[y + 0 - 32], j = h[y + 1 - 32], R = h[y + 2 - 32], Q = h[y + 3 - 32], q = h[y + 4 - 32], V = h[y + 5 - 32], z = h[y + 6 - 32], $ = h[y + 7 - 32];
      h[y + 0 + 0] = k + j + 1 >> 1, h[y + 1 + 0] = h[y + 0 + 64] = j + R + 1 >> 1, h[y + 2 + 0] = h[y + 1 + 64] = R + Q + 1 >> 1, h[y + 3 + 0] = h[y + 2 + 64] = Q + q + 1 >> 1, h[y + 0 + 32] = zt(k, j, R), h[y + 1 + 32] = h[y + 0 + 96] = zt(j, R, Q), h[y + 2 + 32] = h[y + 1 + 96] = zt(R, Q, q), h[y + 3 + 32] = h[y + 2 + 96] = zt(Q, q, V), h[y + 3 + 64] = zt(q, V, z), h[y + 3 + 96] = zt(V, z, $);
    }
    function ec(h, y) {
      var k = h[y - 1 + 0], j = h[y - 1 + 32], R = h[y - 1 + 64], Q = h[y - 1 + 96];
      h[y + 0 + 0] = k + j + 1 >> 1, h[y + 2 + 0] = h[y + 0 + 32] = j + R + 1 >> 1, h[y + 2 + 32] = h[y + 0 + 64] = R + Q + 1 >> 1, h[y + 1 + 0] = zt(k, j, R), h[y + 3 + 0] = h[y + 1 + 32] = zt(j, R, Q), h[y + 3 + 32] = h[y + 1 + 64] = zt(R, Q, Q), h[y + 3 + 64] = h[y + 2 + 64] = h[y + 0 + 96] = h[y + 1 + 96] = h[y + 2 + 96] = h[y + 3 + 96] = Q;
    }
    function cu(h, y) {
      var k = h[y - 1 + 0], j = h[y - 1 + 32], R = h[y - 1 + 64], Q = h[y - 1 + 96], q = h[y - 1 - 32], V = h[y + 0 - 32], z = h[y + 1 - 32], $ = h[y + 2 - 32];
      h[y + 0 + 0] = h[y + 2 + 32] = k + q + 1 >> 1, h[y + 0 + 32] = h[y + 2 + 64] = j + k + 1 >> 1, h[y + 0 + 64] = h[y + 2 + 96] = R + j + 1 >> 1, h[y + 0 + 96] = Q + R + 1 >> 1, h[y + 3 + 0] = zt(V, z, $), h[y + 2 + 0] = zt(q, V, z), h[y + 1 + 0] = h[y + 3 + 32] = zt(k, q, V), h[y + 1 + 32] = h[y + 3 + 64] = zt(j, k, q), h[y + 1 + 64] = h[y + 3 + 96] = zt(R, j, k), h[y + 1 + 96] = zt(Q, R, j);
    }
    function rl(h, y) {
      var k;
      for (k = 0; 8 > k; ++k) r(h, y + 32 * k, h, y - 32, 8);
    }
    function Mg(h, y) {
      var k;
      for (k = 0; 8 > k; ++k) n(h, y, h[y - 1], 8), y += 32;
    }
    function ma(h, y, k) {
      var j;
      for (j = 0; 8 > j; ++j) n(y, k + 32 * j, h, 8);
    }
    function Rg(h, y) {
      var k, j = 8;
      for (k = 0; 8 > k; ++k) j += h[y + k - 32] + h[y - 1 + 32 * k];
      ma(j >> 4, h, y);
    }
    function uu(h, y) {
      var k, j = 4;
      for (k = 0; 8 > k; ++k) j += h[y + k - 32];
      ma(j >> 3, h, y);
    }
    function Au(h, y) {
      var k, j = 4;
      for (k = 0; 8 > k; ++k) j += h[y - 1 + 32 * k];
      ma(j >> 3, h, y);
    }
    function Sd(h, y) {
      ma(128, h, y);
    }
    function ya(h, y, k) {
      var j = h[y - k], R = h[y + 0], Q = 3 * (R - j) + Og[1020 + h[y - 2 * k] - h[y + k]], q = Ud[112 + (Q + 4 >> 3)];
      h[y - k] = Xn[255 + j + Ud[112 + (Q + 3 >> 3)]], h[y + 0] = Xn[255 + R - q];
    }
    function du(h, y, k, j) {
      var R = h[y + 0], Q = h[y + k];
      return Ai[255 + h[y - 2 * k] - h[y - k]] > j || Ai[255 + Q - R] > j;
    }
    function tc(h, y, k, j) {
      return 4 * Ai[255 + h[y - k] - h[y + 0]] + Ai[255 + h[y - 2 * k] - h[y + k]] <= j;
    }
    function pu(h, y, k, j, R) {
      var Q = h[y - 3 * k], q = h[y - 2 * k], V = h[y - k], z = h[y + 0], $ = h[y + k], se = h[y + 2 * k], be = h[y + 3 * k];
      return 4 * Ai[255 + V - z] + Ai[255 + q - $] > j ? 0 : Ai[255 + h[y - 4 * k] - Q] <= R && Ai[255 + Q - q] <= R && Ai[255 + q - V] <= R && Ai[255 + be - se] <= R && Ai[255 + se - $] <= R && Ai[255 + $ - z] <= R;
    }
    function ol(h, y, k, j) {
      var R = 2 * j + 1;
      for (j = 0; 16 > j; ++j) tc(h, y + j, k, R) && ya(h, y + j, k);
    }
    function hu(h, y, k, j) {
      var R = 2 * j + 1;
      for (j = 0; 16 > j; ++j) tc(h, y + j * k, 1, R) && ya(h, y + j * k, 1);
    }
    function Bd(h, y, k, j) {
      var R;
      for (R = 3; 0 < R; --R) ol(h, y += 4 * k, k, j);
    }
    function Ed(h, y, k, j) {
      var R;
      for (R = 3; 0 < R; --R) hu(h, y += 4, k, j);
    }
    function ba(h, y, k, j, R, Q, q, V) {
      for (Q = 2 * Q + 1; 0 < R--; ) {
        if (pu(h, y, k, Q, q)) if (du(h, y, k, V)) ya(h, y, k);
        else {
          var z = h, $ = y, se = k, be = z[$ - 2 * se], W = z[$ - se], ue = z[$ + 0], _e = z[$ + se], xe = z[$ + 2 * se], fe = 27 * (je = Og[1020 + 3 * (ue - W) + Og[1020 + be - _e]]) + 63 >> 7, Se = 18 * je + 63 >> 7, je = 9 * je + 63 >> 7;
          z[$ - 3 * se] = Xn[255 + z[$ - 3 * se] + je], z[$ - 2 * se] = Xn[255 + be + Se], z[$ - se] = Xn[255 + W + fe], z[$ + 0] = Xn[255 + ue - fe], z[$ + se] = Xn[255 + _e - Se], z[$ + 2 * se] = Xn[255 + xe - je];
        }
        y += j;
      }
    }
    function va(h, y, k, j, R, Q, q, V) {
      for (Q = 2 * Q + 1; 0 < R--; ) {
        if (pu(h, y, k, Q, q)) if (du(h, y, k, V)) ya(h, y, k);
        else {
          var z = h, $ = y, se = k, be = z[$ - se], W = z[$ + 0], ue = z[$ + se], _e = Ud[112 + (4 + (xe = 3 * (W - be)) >> 3)], xe = Ud[112 + (xe + 3 >> 3)], fe = _e + 1 >> 1;
          z[$ - 2 * se] = Xn[255 + z[$ - 2 * se] + fe], z[$ - se] = Xn[255 + be + xe], z[$ + 0] = Xn[255 + W - _e], z[$ + se] = Xn[255 + ue - fe];
        }
        y += j;
      }
    }
    function jd(h, y, k, j, R, Q) {
      ba(h, y, k, 1, 16, j, R, Q);
    }
    function nl(h, y, k, j, R, Q) {
      ba(h, y, 1, k, 16, j, R, Q);
    }
    function Ld(h, y, k, j, R, Q) {
      var q;
      for (q = 3; 0 < q; --q) va(h, y += 4 * k, k, 1, 16, j, R, Q);
    }
    function x(h, y, k, j, R, Q) {
      var q;
      for (q = 3; 0 < q; --q) va(h, y += 4, 1, k, 16, j, R, Q);
    }
    function M(h, y, k, j, R, Q, q, V) {
      ba(h, y, R, 1, 8, Q, q, V), ba(k, j, R, 1, 8, Q, q, V);
    }
    function X(h, y, k, j, R, Q, q, V) {
      ba(h, y, 1, R, 8, Q, q, V), ba(k, j, 1, R, 8, Q, q, V);
    }
    function ie(h, y, k, j, R, Q, q, V) {
      va(h, y + 4 * R, R, 1, 8, Q, q, V), va(k, j + 4 * R, R, 1, 8, Q, q, V);
    }
    function he(h, y, k, j, R, Q, q, V) {
      va(h, y + 4, 1, R, 8, Q, q, V), va(k, j + 4, 1, R, 8, Q, q, V);
    }
    function Ee() {
      this.ba = new mt(), this.ec = [], this.cc = [], this.Mc = [], this.Dc = this.Nc = this.dc = this.fc = 0, this.Oa = new Bt(), this.memory = 0, this.Ib = "OutputFunc", this.Jb = "OutputAlphaFunc", this.Nd = "OutputRowFunc";
    }
    function Re() {
      this.data = [], this.offset = this.kd = this.ha = this.w = 0, this.na = [], this.xa = this.gb = this.Ja = this.Sa = this.P = 0;
    }
    function St() {
      this.nc = this.Ea = this.b = this.hc = 0, this.K = [], this.w = 0;
    }
    function Pt() {
      this.ua = 0, this.Wa = new ct(), this.vb = new ct(), this.md = this.xc = this.wc = 0, this.vc = [], this.Wb = 0, this.Ya = new K(), this.yc = new U();
    }
    function Vt() {
      this.xb = this.a = 0, this.l = new Yl(), this.ca = new mt(), this.V = [], this.Ba = 0, this.Ta = [], this.Ua = 0, this.m = new G(), this.Pb = 0, this.wd = new G(), this.Ma = this.$ = this.C = this.i = this.c = this.xd = 0, this.s = new Pt(), this.ab = 0, this.gc = a(4, St), this.Oc = 0;
    }
    function Zt() {
      this.Lc = this.Z = this.$a = this.i = this.c = 0, this.l = new Yl(), this.ic = 0, this.ca = [], this.tb = 0, this.qd = null, this.rd = 0;
    }
    function gr(h, y, k, j, R, Q, q) {
      for (h = h == null ? 0 : h[y + 0], y = 0; y < q; ++y) R[Q + y] = h + k[j + y] & 255, h = R[Q + y];
    }
    function ao(h, y, k, j, R, Q, q) {
      var V;
      if (h == null) gr(null, null, k, j, R, Q, q);
      else for (V = 0; V < q; ++V) R[Q + V] = h[y + V] + k[j + V] & 255;
    }
    function Vo(h, y, k, j, R, Q, q) {
      if (h == null) gr(null, null, k, j, R, Q, q);
      else {
        var V, z = h[y + 0], $ = z, se = z;
        for (V = 0; V < q; ++V) $ = se + (z = h[y + V]) - $, se = k[j + V] + (-256 & $ ? 0 > $ ? 0 : 255 : $) & 255, $ = z, R[Q + V] = se;
      }
    }
    function Gr(h, y, k, j) {
      var R = y.width, Q = y.o;
      if (e(h != null && y != null), 0 > k || 0 >= j || k + j > Q) return null;
      if (!h.Cc) {
        if (h.ga == null) {
          var q;
          if (h.ga = new Zt(), (q = h.ga == null) || (q = y.width * y.o, e(h.Gb.length == 0), h.Gb = i(q), h.Uc = 0, h.Gb == null ? q = 0 : (h.mb = h.Gb, h.nb = h.Uc, h.rc = null, q = 1), q = !q), !q) {
            q = h.ga;
            var V = h.Fa, z = h.P, $ = h.qc, se = h.mb, be = h.nb, W = z + 1, ue = $ - 1, _e = q.l;
            if (e(V != null && se != null && y != null), hs[0] = null, hs[1] = gr, hs[2] = ao, hs[3] = Vo, q.ca = se, q.tb = be, q.c = y.width, q.i = y.height, e(0 < q.c && 0 < q.i), 1 >= $) y = 0;
            else if (q.$a = 3 & V[z + 0], q.Z = V[z + 0] >> 2 & 3, q.Lc = V[z + 0] >> 4 & 3, z = V[z + 0] >> 6 & 3, 0 > q.$a || 1 < q.$a || 4 <= q.Z || 1 < q.Lc || z) y = 0;
            else if (_e.put = xt, _e.ac = To, _e.bc = Qo, _e.ma = q, _e.width = y.width, _e.height = y.height, _e.Da = y.Da, _e.v = y.v, _e.va = y.va, _e.j = y.j, _e.o = y.o, q.$a) e: {
              e(q.$a == 1), y = $r();
              t: for (; ; ) {
                if (y == null) {
                  y = 0;
                  break e;
                }
                if (e(q != null), q.mc = y, y.c = q.c, y.i = q.i, y.l = q.l, y.l.ma = q, y.l.width = q.c, y.l.height = q.i, y.a = 0, oe(y.m, V, W, ue), !re(q.c, q.i, 1, y, null) || (y.ab == 1 && y.gc[0].hc == 3 && Me(y.s) ? (q.ic = 1, V = y.c * y.i, y.Ta = null, y.Ua = 0, y.V = i(V), y.Ba = 0, y.V == null ? (y.a = 1, y = 0) : y = 1) : (q.ic = 0, y = Ke(y, q.c)), !y)) break t;
                y = 1;
                break e;
              }
              q.mc = null, y = 0;
            }
            else y = ue >= q.c * q.i;
            q = !y;
          }
          if (q) return null;
          h.ga.Lc != 1 ? h.Ga = 0 : j = Q - k;
        }
        e(h.ga != null), e(k + j <= Q);
        e: {
          if (y = (V = h.ga).c, Q = V.l.o, V.$a == 0) {
            if (W = h.rc, ue = h.Vc, _e = h.Fa, z = h.P + 1 + k * y, $ = h.mb, se = h.nb + k * y, e(z <= h.P + h.qc), V.Z != 0) for (e(hs[V.Z] != null), q = 0; q < j; ++q) hs[V.Z](W, ue, _e, z, $, se, y), W = $, ue = se, se += y, z += y;
            else for (q = 0; q < j; ++q) r($, se, _e, z, y), W = $, ue = se, se += y, z += y;
            h.rc = W, h.Vc = ue;
          } else {
            if (e(V.mc != null), y = k + j, e((q = V.mc) != null), e(y <= q.i), q.C >= y) y = 1;
            else if (V.ic || Ci(), V.ic) {
              V = q.V, W = q.Ba, ue = q.c;
              var xe = q.i, fe = (_e = 1, z = q.$ / ue, $ = q.$ % ue, se = q.m, be = q.s, q.$), Se = ue * xe, je = ue * y, Ve = be.wc, Oe = fe < je ? Ie(be, $, z) : null;
              e(fe <= Se), e(y <= xe), e(Me(be));
              t: for (; ; ) {
                for (; !se.h && fe < je; ) {
                  if ($ & Ve || (Oe = Ie(be, $, z)), e(Oe != null), le(se), 256 > (xe = jr(Oe.G[0], Oe.H[0], se))) V[W + fe] = xe, ++fe, ++$ >= ue && ($ = 0, ++z <= y && !(z % 16) && Ot(q, z));
                  else {
                    if (!(280 > xe)) {
                      _e = 0;
                      break t;
                    }
                    xe = Xo(xe - 256, se);
                    var Ft, yt = jr(Oe.G[4], Oe.H[4], se);
                    if (le(se), !(fe >= (yt = lo(ue, yt = Xo(yt, se))) && Se - fe >= xe)) {
                      _e = 0;
                      break t;
                    }
                    for (Ft = 0; Ft < xe; ++Ft) V[W + fe + Ft] = V[W + fe + Ft - yt];
                    for (fe += xe, $ += xe; $ >= ue; ) $ -= ue, ++z <= y && !(z % 16) && Ot(q, z);
                    fe < je && $ & Ve && (Oe = Ie(be, $, z));
                  }
                  e(se.h == Z(se));
                }
                Ot(q, z > y ? y : z);
                break t;
              }
              !_e || se.h && fe < Se ? (_e = 0, q.a = se.h ? 5 : 3) : q.$ = fe, y = _e;
            } else y = qt(q, q.V, q.Ba, q.c, q.i, y, He);
            if (!y) {
              j = 0;
              break e;
            }
          }
          k + j >= Q && (h.Cc = 1), j = 1;
        }
        if (!j) return null;
        if (h.Cc && ((j = h.ga) != null && (j.mc = null), h.ga = null, 0 < h.Ga)) return alert("todo:WebPDequantizeLevels"), null;
      }
      return h.nb + k * R;
    }
    function Do(h, y, k, j, R, Q) {
      for (; 0 < R--; ) {
        var q, V = h, z = y + (k ? 1 : 0), $ = h, se = y + (k ? 0 : 3);
        for (q = 0; q < j; ++q) {
          var be = $[se + 4 * q];
          be != 255 && (be *= 32897, V[z + 4 * q + 0] = V[z + 4 * q + 0] * be >> 23, V[z + 4 * q + 1] = V[z + 4 * q + 1] * be >> 23, V[z + 4 * q + 2] = V[z + 4 * q + 2] * be >> 23);
        }
        y += Q;
      }
    }
    function Uo(h, y, k, j, R) {
      for (; 0 < j--; ) {
        var Q;
        for (Q = 0; Q < k; ++Q) {
          var q = h[y + 2 * Q + 0], V = 15 & ($ = h[y + 2 * Q + 1]), z = 4369 * V, $ = (240 & $ | $ >> 4) * z >> 16;
          h[y + 2 * Q + 0] = (240 & q | q >> 4) * z >> 16 & 240 | (15 & q | q << 4) * z >> 16 >> 4 & 15, h[y + 2 * Q + 1] = 240 & $ | V;
        }
        y += R;
      }
    }
    function on(h, y, k, j, R, Q, q, V) {
      var z, $, se = 255;
      for ($ = 0; $ < R; ++$) {
        for (z = 0; z < j; ++z) {
          var be = h[y + z];
          Q[q + 4 * z] = be, se &= be;
        }
        y += k, q += V;
      }
      return se != 255;
    }
    function wa(h, y, k, j, R) {
      var Q;
      for (Q = 0; Q < R; ++Q) k[j + Q] = h[y + Q] >> 8;
    }
    function Ci() {
      Su = Do, Lw = Uo, Tw = on, Pw = wa;
    }
    function xa(h, y, k) {
      B[h] = function(j, R, Q, q, V, z, $, se, be, W, ue, _e, xe, fe, Se, je, Ve) {
        var Oe, Ft = Ve - 1 >> 1, yt = V[z + 0] | $[se + 0] << 16, Jt = be[W + 0] | ue[_e + 0] << 16;
        e(j != null);
        var jt = 3 * yt + Jt + 131074 >> 2;
        for (y(j[R + 0], 255 & jt, jt >> 16, xe, fe), Q != null && (jt = 3 * Jt + yt + 131074 >> 2, y(Q[q + 0], 255 & jt, jt >> 16, Se, je)), Oe = 1; Oe <= Ft; ++Oe) {
          var Ar = V[z + Oe] | $[se + Oe] << 16, zo = be[W + Oe] | ue[_e + Oe] << 16, er = yt + Ar + Jt + zo + 524296, Lt = er + 2 * (Ar + Jt) >> 3;
          jt = Lt + yt >> 1, yt = (er = er + 2 * (yt + zo) >> 3) + Ar >> 1, y(j[R + 2 * Oe - 1], 255 & jt, jt >> 16, xe, fe + (2 * Oe - 1) * k), y(j[R + 2 * Oe - 0], 255 & yt, yt >> 16, xe, fe + (2 * Oe - 0) * k), Q != null && (jt = er + Jt >> 1, yt = Lt + zo >> 1, y(Q[q + 2 * Oe - 1], 255 & jt, jt >> 16, Se, je + (2 * Oe - 1) * k), y(Q[q + 2 * Oe + 0], 255 & yt, yt >> 16, Se, je + (2 * Oe + 0) * k)), yt = Ar, Jt = zo;
        }
        1 & Ve || (jt = 3 * yt + Jt + 131074 >> 2, y(j[R + Ve - 1], 255 & jt, jt >> 16, xe, fe + (Ve - 1) * k), Q != null && (jt = 3 * Jt + yt + 131074 >> 2, y(Q[q + Ve - 1], 255 & jt, jt >> 16, Se, je + (Ve - 1) * k)));
      };
    }
    function gu() {
      di[Nd] = XP, di[Id] = Vw, di[Rw] = YP, di[Md] = Dw, di[Rd] = Hw, di[Qg] = zw, di[Ow] = ZP, di[qg] = Vw, di[Gg] = Dw, di[Od] = Hw, di[Vg] = zw;
    }
    function rc(h) {
      return h & -16384 ? 0 > h ? 0 : 255 : h >> JP;
    }
    function ns(h, y) {
      return rc((19077 * h >> 8) + (26149 * y >> 8) - 14234);
    }
    function il(h, y, k) {
      return rc((19077 * h >> 8) - (6419 * y >> 8) - (13320 * k >> 8) + 8708);
    }
    function al(h, y) {
      return rc((19077 * h >> 8) + (33050 * y >> 8) - 17685);
    }
    function is(h, y, k, j, R) {
      j[R + 0] = ns(h, k), j[R + 1] = il(h, y, k), j[R + 2] = al(h, y);
    }
    function nn(h, y, k, j, R) {
      j[R + 0] = al(h, y), j[R + 1] = il(h, y, k), j[R + 2] = ns(h, k);
    }
    function sl(h, y, k, j, R) {
      var Q = il(h, y, k);
      y = Q << 3 & 224 | al(h, y) >> 3, j[R + 0] = 248 & ns(h, k) | Q >> 5, j[R + 1] = y;
    }
    function ll(h, y, k, j, R) {
      var Q = 240 & al(h, y) | 15;
      j[R + 0] = 240 & ns(h, k) | il(h, y, k) >> 4, j[R + 1] = Q;
    }
    function _u(h, y, k, j, R) {
      j[R + 0] = 255, is(h, y, k, j, R + 1);
    }
    function fu(h, y, k, j, R) {
      nn(h, y, k, j, R), j[R + 3] = 255;
    }
    function Bn(h, y, k, j, R) {
      is(h, y, k, j, R), j[R + 3] = 255;
    }
    function ka(h, y, k) {
      B[h] = function(j, R, Q, q, V, z, $, se, be) {
        for (var W = se + (-2 & be) * k; se != W; ) y(j[R + 0], Q[q + 0], V[z + 0], $, se), y(j[R + 1], Q[q + 0], V[z + 0], $, se + k), R += 2, ++q, ++z, se += 2 * k;
        1 & be && y(j[R + 0], Q[q + 0], V[z + 0], $, se);
      };
    }
    function oc(h, y, k) {
      return k == 0 ? h == 0 ? y == 0 ? 6 : 5 : y == 0 ? 4 : 0 : k;
    }
    function Td(h, y, k, j, R) {
      switch (h >>> 30) {
        case 3:
          dl(y, k, j, R, 0);
          break;
        case 2:
          ui(y, k, j, R);
          break;
        case 1:
          Sr(y, k, j, R);
      }
    }
    function ci(h, y) {
      var k, j, R = y.M, Q = y.Nb, q = h.oc, V = h.pc + 40, z = h.oc, $ = h.pc + 584, se = h.oc, be = h.pc + 600;
      for (k = 0; 16 > k; ++k) q[V + 32 * k - 1] = 129;
      for (k = 0; 8 > k; ++k) z[$ + 32 * k - 1] = 129, se[be + 32 * k - 1] = 129;
      for (0 < R ? q[V - 1 - 32] = z[$ - 1 - 32] = se[be - 1 - 32] = 129 : (n(q, V - 32 - 1, 127, 21), n(z, $ - 32 - 1, 127, 9), n(se, be - 32 - 1, 127, 9)), j = 0; j < h.za; ++j) {
        var W = y.ya[y.aa + j];
        if (0 < j) {
          for (k = -1; 16 > k; ++k) r(q, V + 32 * k - 4, q, V + 32 * k + 12, 4);
          for (k = -1; 8 > k; ++k) r(z, $ + 32 * k - 4, z, $ + 32 * k + 4, 4), r(se, be + 32 * k - 4, se, be + 32 * k + 4, 4);
        }
        var ue = h.Gd, _e = h.Hd + j, xe = W.ad, fe = W.Hc;
        if (0 < R && (r(q, V - 32, ue[_e].y, 0, 16), r(z, $ - 32, ue[_e].f, 0, 8), r(se, be - 32, ue[_e].ea, 0, 8)), W.Za) {
          var Se = q, je = V - 32 + 16;
          for (0 < R && (j >= h.za - 1 ? n(Se, je, ue[_e].y[15], 4) : r(Se, je, ue[_e + 1].y, 0, 4)), k = 0; 4 > k; k++) Se[je + 128 + k] = Se[je + 256 + k] = Se[je + 384 + k] = Se[je + 0 + k];
          for (k = 0; 16 > k; ++k, fe <<= 2) Se = q, je = V + $w[k], Si[W.Ob[k]](Se, je), Td(fe, xe, 16 * +k, Se, je);
        } else if (Se = oc(j, R, W.Ob[0]), ps[Se](q, V), fe != 0) for (k = 0; 16 > k; ++k, fe <<= 2) Td(fe, xe, 16 * +k, q, V + $w[k]);
        for (k = W.Gc, Se = oc(j, R, W.Dd), Ba[Se](z, $), Ba[Se](se, be), fe = xe, Se = z, je = $, 255 & (W = 0 | k) && (170 & W ? ea(fe, 256, Se, je) : Mr(fe, 256, Se, je)), W = se, fe = be, 255 & (k >>= 8) && (170 & k ? ea(xe, 320, W, fe) : Mr(xe, 320, W, fe)), R < h.Ub - 1 && (r(ue[_e].y, 0, q, V + 480, 16), r(ue[_e].f, 0, z, $ + 224, 8), r(ue[_e].ea, 0, se, be + 224, 8)), k = 8 * Q * h.B, ue = h.sa, _e = h.ta + 16 * j + 16 * Q * h.R, xe = h.qa, W = h.ra + 8 * j + k, fe = h.Ha, Se = h.Ia + 8 * j + k, k = 0; 16 > k; ++k) r(ue, _e + k * h.R, q, V + 32 * k, 16);
        for (k = 0; 8 > k; ++k) r(xe, W + k * h.B, z, $ + 32 * k, 8), r(fe, Se + k * h.B, se, be + 32 * k, 8);
      }
    }
    function cl(h, y, k, j, R, Q, q, V, z) {
      var $ = [0], se = [0], be = 0, W = z != null ? z.kd : 0, ue = z ?? new Re();
      if (h == null || 12 > k) return 7;
      ue.data = h, ue.w = y, ue.ha = k, y = [y], k = [k], ue.gb = [ue.gb];
      e: {
        var _e = y, xe = k, fe = ue.gb;
        if (e(h != null), e(xe != null), e(fe != null), fe[0] = 0, 12 <= xe[0] && !t(h, _e[0], "RIFF")) {
          if (t(h, _e[0] + 8, "WEBP")) {
            fe = 3;
            break e;
          }
          var Se = Xe(h, _e[0] + 4);
          if (12 > Se || 4294967286 < Se) {
            fe = 3;
            break e;
          }
          if (W && Se > xe[0] - 8) {
            fe = 7;
            break e;
          }
          fe[0] = Se, _e[0] += 12, xe[0] -= 12;
        }
        fe = 0;
      }
      if (fe != 0) return fe;
      for (Se = 0 < ue.gb[0], k = k[0]; ; ) {
        e: {
          var je = h;
          xe = y, fe = k;
          var Ve = $, Oe = se, Ft = _e = [0];
          if ((jt = be = [be])[0] = 0, 8 > fe[0]) fe = 7;
          else {
            if (!t(je, xe[0], "VP8X")) {
              if (Xe(je, xe[0] + 4) != 10) {
                fe = 3;
                break e;
              }
              if (18 > fe[0]) {
                fe = 7;
                break e;
              }
              var yt = Xe(je, xe[0] + 8), Jt = 1 + Qe(je, xe[0] + 12);
              if (2147483648 <= Jt * (je = 1 + Qe(je, xe[0] + 15))) {
                fe = 3;
                break e;
              }
              Ft != null && (Ft[0] = yt), Ve != null && (Ve[0] = Jt), Oe != null && (Oe[0] = je), xe[0] += 18, fe[0] -= 18, jt[0] = 1;
            }
            fe = 0;
          }
        }
        if (be = be[0], _e = _e[0], fe != 0) return fe;
        if (xe = !!(2 & _e), !Se && be) return 3;
        if (Q != null && (Q[0] = !!(16 & _e)), q != null && (q[0] = xe), V != null && (V[0] = 0), q = $[0], _e = se[0], be && xe && z == null) {
          fe = 0;
          break;
        }
        if (4 > k) {
          fe = 7;
          break;
        }
        if (Se && be || !Se && !be && !t(h, y[0], "ALPH")) {
          k = [k], ue.na = [ue.na], ue.P = [ue.P], ue.Sa = [ue.Sa];
          e: {
            yt = h, fe = y, Se = k;
            var jt = ue.gb;
            Ve = ue.na, Oe = ue.P, Ft = ue.Sa, Jt = 22, e(yt != null), e(Se != null), je = fe[0];
            var Ar = Se[0];
            for (e(Ve != null), e(Ft != null), Ve[0] = null, Oe[0] = null, Ft[0] = 0; ; ) {
              if (fe[0] = je, Se[0] = Ar, 8 > Ar) {
                fe = 7;
                break e;
              }
              var zo = Xe(yt, je + 4);
              if (4294967286 < zo) {
                fe = 3;
                break e;
              }
              var er = 8 + zo + 1 & -2;
              if (Jt += er, 0 < jt && Jt > jt) {
                fe = 3;
                break e;
              }
              if (!t(yt, je, "VP8 ") || !t(yt, je, "VP8L")) {
                fe = 0;
                break e;
              }
              if (Ar[0] < er) {
                fe = 7;
                break e;
              }
              t(yt, je, "ALPH") || (Ve[0] = yt, Oe[0] = je + 8, Ft[0] = zo), je += er, Ar -= er;
            }
          }
          if (k = k[0], ue.na = ue.na[0], ue.P = ue.P[0], ue.Sa = ue.Sa[0], fe != 0) break;
        }
        k = [k], ue.Ja = [ue.Ja], ue.xa = [ue.xa];
        e: if (jt = h, fe = y, Se = k, Ve = ue.gb[0], Oe = ue.Ja, Ft = ue.xa, yt = fe[0], je = !t(jt, yt, "VP8 "), Jt = !t(jt, yt, "VP8L"), e(jt != null), e(Se != null), e(Oe != null), e(Ft != null), 8 > Se[0]) fe = 7;
        else {
          if (je || Jt) {
            if (jt = Xe(jt, yt + 4), 12 <= Ve && jt > Ve - 12) {
              fe = 3;
              break e;
            }
            if (W && jt > Se[0] - 8) {
              fe = 7;
              break e;
            }
            Oe[0] = jt, fe[0] += 8, Se[0] -= 8, Ft[0] = Jt;
          } else Ft[0] = 5 <= Se[0] && jt[yt + 0] == 47 && !(jt[yt + 4] >> 5), Oe[0] = Se[0];
          fe = 0;
        }
        if (k = k[0], ue.Ja = ue.Ja[0], ue.xa = ue.xa[0], y = y[0], fe != 0) break;
        if (4294967286 < ue.Ja) return 3;
        if (V == null || xe || (V[0] = ue.xa ? 2 : 1), q = [q], _e = [_e], ue.xa) {
          if (5 > k) {
            fe = 7;
            break;
          }
          V = q, W = _e, xe = Q, h == null || 5 > k ? h = 0 : 5 <= k && h[y + 0] == 47 && !(h[y + 4] >> 5) ? (Se = [0], jt = [0], Ve = [0], oe(Oe = new G(), h, y, k), qo(Oe, Se, jt, Ve) ? (V != null && (V[0] = Se[0]), W != null && (W[0] = jt[0]), xe != null && (xe[0] = Ve[0]), h = 1) : h = 0) : h = 0;
        } else {
          if (10 > k) {
            fe = 7;
            break;
          }
          V = _e, h == null || 10 > k || !bd(h, y + 3, k - 3) ? h = 0 : (W = h[y + 0] | h[y + 1] << 8 | h[y + 2] << 16, xe = 16383 & (h[y + 7] << 8 | h[y + 6]), h = 16383 & (h[y + 9] << 8 | h[y + 8]), 1 & W || 3 < (W >> 1 & 7) || !(W >> 4 & 1) || W >> 5 >= ue.Ja || !xe || !h ? h = 0 : (q && (q[0] = xe), V && (V[0] = h), h = 1));
        }
        if (!h || (q = q[0], _e = _e[0], be && ($[0] != q || se[0] != _e))) return 3;
        z != null && (z[0] = ue, z.offset = y - z.w, e(4294967286 > y - z.w), e(z.offset == z.ha - k));
        break;
      }
      return fe == 0 || fe == 7 && be && z == null ? (Q != null && (Q[0] |= ue.na != null && 0 < ue.na.length), j != null && (j[0] = q), R != null && (R[0] = _e), 0) : fe;
    }
    function mu(h, y, k) {
      var j = y.width, R = y.height, Q = 0, q = 0, V = j, z = R;
      if (y.Da = h != null && 0 < h.Da, y.Da && (V = h.cd, z = h.bd, Q = h.v, q = h.j, 11 > k || (Q &= -2, q &= -2), 0 > Q || 0 > q || 0 >= V || 0 >= z || Q + V > j || q + z > R)) return 0;
      if (y.v = Q, y.j = q, y.va = Q + V, y.o = q + z, y.U = V, y.T = z, y.da = h != null && 0 < h.da, y.da) {
        if (!ot(V, z, k = [h.ib], Q = [h.hb])) return 0;
        y.ib = k[0], y.hb = Q[0];
      }
      return y.ob = h != null && h.ob, y.Kb = h == null || !h.Sd, y.da && (y.ob = y.ib < 3 * j / 4 && y.hb < 3 * R / 4, y.Kb = 0), 1;
    }
    function yu(h) {
      if (h == null) return 2;
      if (11 > h.S) {
        var y = h.f.RGBA;
        y.fb += (h.height - 1) * y.A, y.A = -y.A;
      } else y = h.f.kb, h = h.height, y.O += (h - 1) * y.fa, y.fa = -y.fa, y.N += (h - 1 >> 1) * y.Ab, y.Ab = -y.Ab, y.W += (h - 1 >> 1) * y.Db, y.Db = -y.Db, y.F != null && (y.J += (h - 1) * y.lb, y.lb = -y.lb);
      return 0;
    }
    function as(h, y, k, j) {
      if (j == null || 0 >= h || 0 >= y) return 2;
      if (k != null) {
        if (k.Da) {
          var R = k.cd, Q = k.bd, q = -2 & k.v, V = -2 & k.j;
          if (0 > q || 0 > V || 0 >= R || 0 >= Q || q + R > h || V + Q > y) return 2;
          h = R, y = Q;
        }
        if (k.da) {
          if (!ot(h, y, R = [k.ib], Q = [k.hb])) return 2;
          h = R[0], y = Q[0];
        }
      }
      j.width = h, j.height = y;
      e: {
        var z = j.width, $ = j.height;
        if (h = j.S, 0 >= z || 0 >= $ || !(h >= Nd && 13 > h)) h = 2;
        else {
          if (0 >= j.Rd && j.sd == null) {
            q = Q = R = y = 0;
            var se = (V = z * Ww[h]) * $;
            if (11 > h || (Q = ($ + 1) / 2 * (y = (z + 1) / 2), h == 12 && (q = (R = z) * $)), ($ = i(se + 2 * Q + q)) == null) {
              h = 1;
              break e;
            }
            j.sd = $, 11 > h ? ((z = j.f.RGBA).eb = $, z.fb = 0, z.A = V, z.size = se) : ((z = j.f.kb).y = $, z.O = 0, z.fa = V, z.Fd = se, z.f = $, z.N = 0 + se, z.Ab = y, z.Cd = Q, z.ea = $, z.W = 0 + se + Q, z.Db = y, z.Ed = Q, h == 12 && (z.F = $, z.J = 0 + se + 2 * Q), z.Tc = q, z.lb = R);
          }
          if (y = 1, R = j.S, Q = j.width, q = j.height, R >= Nd && 13 > R) if (11 > R) h = j.f.RGBA, y &= (V = Math.abs(h.A)) * (q - 1) + Q <= h.size, y &= V >= Q * Ww[R], y &= h.eb != null;
          else {
            h = j.f.kb, V = (Q + 1) / 2, se = (q + 1) / 2, z = Math.abs(h.fa), $ = Math.abs(h.Ab);
            var be = Math.abs(h.Db), W = Math.abs(h.lb), ue = W * (q - 1) + Q;
            y &= z * (q - 1) + Q <= h.Fd, y &= $ * (se - 1) + V <= h.Cd, y = (y &= be * (se - 1) + V <= h.Ed) & z >= Q & $ >= V & be >= V, y &= h.y != null, y &= h.f != null, y &= h.ea != null, R == 12 && (y &= W >= Q, y &= ue <= h.Tc, y &= h.F != null);
          }
          else y = 0;
          h = y ? 0 : 2;
        }
      }
      return h != 0 || k != null && k.fd && (h = yu(j)), h;
    }
    var ul = 64, $n = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215], Wn = 24, ss = 32, Ca = 8, ls = [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7];
    Le("Predictor0", "PredictorAdd0"), B.Predictor0 = function() {
      return 4278190080;
    }, B.Predictor1 = function(h) {
      return h;
    }, B.Predictor2 = function(h, y, k) {
      return y[k + 0];
    }, B.Predictor3 = function(h, y, k) {
      return y[k + 1];
    }, B.Predictor4 = function(h, y, k) {
      return y[k - 1];
    }, B.Predictor5 = function(h, y, k) {
      return tt(tt(h, y[k + 1]), y[k + 0]);
    }, B.Predictor6 = function(h, y, k) {
      return tt(h, y[k - 1]);
    }, B.Predictor7 = function(h, y, k) {
      return tt(h, y[k + 0]);
    }, B.Predictor8 = function(h, y, k) {
      return tt(y[k - 1], y[k + 0]);
    }, B.Predictor9 = function(h, y, k) {
      return tt(y[k + 0], y[k + 1]);
    }, B.Predictor10 = function(h, y, k) {
      return tt(tt(h, y[k - 1]), tt(y[k + 0], y[k + 1]));
    }, B.Predictor11 = function(h, y, k) {
      var j = y[k + 0];
      return 0 >= ze(j >> 24 & 255, h >> 24 & 255, (y = y[k - 1]) >> 24 & 255) + ze(j >> 16 & 255, h >> 16 & 255, y >> 16 & 255) + ze(j >> 8 & 255, h >> 8 & 255, y >> 8 & 255) + ze(255 & j, 255 & h, 255 & y) ? j : h;
    }, B.Predictor12 = function(h, y, k) {
      var j = y[k + 0];
      return (we((h >> 24 & 255) + (j >> 24 & 255) - ((y = y[k - 1]) >> 24 & 255)) << 24 | we((h >> 16 & 255) + (j >> 16 & 255) - (y >> 16 & 255)) << 16 | we((h >> 8 & 255) + (j >> 8 & 255) - (y >> 8 & 255)) << 8 | we((255 & h) + (255 & j) - (255 & y))) >>> 0;
    }, B.Predictor13 = function(h, y, k) {
      var j = y[k - 1];
      return (Ge((h = tt(h, y[k + 0])) >> 24 & 255, j >> 24 & 255) << 24 | Ge(h >> 16 & 255, j >> 16 & 255) << 16 | Ge(h >> 8 & 255, j >> 8 & 255) << 8 | Ge(255 & h, 255 & j)) >>> 0;
    };
    var bu = B.PredictorAdd0;
    B.PredictorAdd1 = Ze, Le("Predictor2", "PredictorAdd2"), Le("Predictor3", "PredictorAdd3"), Le("Predictor4", "PredictorAdd4"), Le("Predictor5", "PredictorAdd5"), Le("Predictor6", "PredictorAdd6"), Le("Predictor7", "PredictorAdd7"), Le("Predictor8", "PredictorAdd8"), Le("Predictor9", "PredictorAdd9"), Le("Predictor10", "PredictorAdd10"), Le("Predictor11", "PredictorAdd11"), Le("Predictor12", "PredictorAdd12"), Le("Predictor13", "PredictorAdd13");
    var nc = B.PredictorAdd2;
    it("ColorIndexInverseTransform", "MapARGB", "32b", function(h) {
      return h >> 8 & 255;
    }, function(h) {
      return h;
    }), it("VP8LColorIndexInverseTransformAlpha", "MapAlpha", "8b", function(h) {
      return h;
    }, function(h) {
      return h >> 8 & 255;
    });
    var fo, Pd = B.ColorIndexInverseTransform, Zi = B.MapARGB, Ji = B.VP8LColorIndexInverseTransformAlpha, vu = B.MapAlpha, wu = B.VP8LPredictorsAdd = [];
    wu.length = 16, (B.VP8LPredictors = []).length = 16, (B.VP8LPredictorsAdd_C = []).length = 16, (B.VP8LPredictors_C = []).length = 16;
    var xu, ku, cs, us, As, Al, ds, dl, ui, ea, Sr, Mr, mo, Ho, Sa, Cu, ic, Fd, kw, Cw, Sw, Bw, Ew, jw, Su, Lw, Tw, Pw, Fw = i(511), Uw = i(2041), Nw = i(225), Iw = i(767), Mw = 0, Og = Uw, Ud = Nw, Xn = Iw, Ai = Fw, Nd = 0, Id = 1, Rw = 2, Md = 3, Rd = 4, Qg = 5, Ow = 6, qg = 7, Gg = 8, Od = 9, Vg = 10, IP = [2, 3, 7], MP = [3, 3, 11], Qw = [280, 256, 256, 256, 40], RP = [0, 1, 1, 1, 0], OP = [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], QP = [24, 7, 23, 25, 40, 6, 39, 41, 22, 26, 38, 42, 56, 5, 55, 57, 21, 27, 54, 58, 37, 43, 72, 4, 71, 73, 20, 28, 53, 59, 70, 74, 36, 44, 88, 69, 75, 52, 60, 3, 87, 89, 19, 29, 86, 90, 35, 45, 68, 76, 85, 91, 51, 61, 104, 2, 103, 105, 18, 30, 102, 106, 34, 46, 84, 92, 67, 77, 101, 107, 50, 62, 120, 1, 119, 121, 83, 93, 17, 31, 100, 108, 66, 78, 118, 122, 33, 47, 117, 123, 49, 63, 99, 109, 82, 94, 0, 116, 124, 65, 79, 16, 32, 98, 110, 48, 115, 125, 81, 95, 64, 114, 126, 97, 111, 80, 113, 127, 96, 112], qP = [2954, 2956, 2958, 2962, 2970, 2986, 3018, 3082, 3212, 3468, 3980, 5004], GP = 8, Dg = [4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157], Hg = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284], Bu = null, VP = [[173, 148, 140, 0], [176, 155, 140, 135, 0], [180, 157, 141, 134, 130, 0], [254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0]], DP = [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15], qw = [-0, 1, -1, 2, -2, 3, 4, 6, -3, 5, -4, -5, -6, 7, -7, 8, -8, -9], HP = [[[[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]], [[253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128], [189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128], [106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128]], [[1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128], [181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128], [78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128]], [[1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128], [184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128], [77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128]], [[1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128], [170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128], [37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128]], [[1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128], [207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128], [102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128]], [[1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128], [177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128], [80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128]], [[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]]], [[[198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62], [131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1], [68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128]], [[1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128], [184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128], [81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128]], [[1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128], [99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128], [23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128]], [[1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128], [109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128], [44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128]], [[1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128], [94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128], [22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128]], [[1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128], [124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128], [35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128]], [[1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128], [121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128], [45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128]], [[1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128], [203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128], [137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128]]], [[[253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128], [175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128], [73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128]], [[1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128], [239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128], [155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128]], [[1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128], [201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128], [69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128]], [[1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128], [223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128], [141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128]], [[1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128], [190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128], [149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128], [247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128], [240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128], [213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128], [55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128]], [[128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128], [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]]], [[[202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255], [126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128], [61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128]], [[1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128], [166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128], [39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128]], [[1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128], [124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128], [24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128]], [[1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128], [149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128], [28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128]], [[1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128], [123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128], [20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128]], [[1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128], [168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128], [47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128]], [[1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128], [141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128], [42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128]], [[1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128], [238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128]]]], zP = [[[231, 120, 48, 89, 115, 113, 120, 152, 112], [152, 179, 64, 126, 170, 118, 46, 70, 95], [175, 69, 143, 80, 85, 82, 72, 155, 103], [56, 58, 10, 171, 218, 189, 17, 13, 152], [114, 26, 17, 163, 44, 195, 21, 10, 173], [121, 24, 80, 195, 26, 62, 44, 64, 85], [144, 71, 10, 38, 171, 213, 144, 34, 26], [170, 46, 55, 19, 136, 160, 33, 206, 71], [63, 20, 8, 114, 114, 208, 12, 9, 226], [81, 40, 11, 96, 182, 84, 29, 16, 36]], [[134, 183, 89, 137, 98, 101, 106, 165, 148], [72, 187, 100, 130, 157, 111, 32, 75, 80], [66, 102, 167, 99, 74, 62, 40, 234, 128], [41, 53, 9, 178, 241, 141, 26, 8, 107], [74, 43, 26, 146, 73, 166, 49, 23, 157], [65, 38, 105, 160, 51, 52, 31, 115, 128], [104, 79, 12, 27, 217, 255, 87, 17, 7], [87, 68, 71, 44, 114, 51, 15, 186, 23], [47, 41, 14, 110, 182, 183, 21, 17, 194], [66, 45, 25, 102, 197, 189, 23, 18, 22]], [[88, 88, 147, 150, 42, 46, 45, 196, 205], [43, 97, 183, 117, 85, 38, 35, 179, 61], [39, 53, 200, 87, 26, 21, 43, 232, 171], [56, 34, 51, 104, 114, 102, 29, 93, 77], [39, 28, 85, 171, 58, 165, 90, 98, 64], [34, 22, 116, 206, 23, 34, 43, 166, 73], [107, 54, 32, 26, 51, 1, 81, 43, 31], [68, 25, 106, 22, 64, 171, 36, 225, 114], [34, 19, 21, 102, 132, 188, 16, 76, 124], [62, 18, 78, 95, 85, 57, 50, 48, 51]], [[193, 101, 35, 159, 215, 111, 89, 46, 111], [60, 148, 31, 172, 219, 228, 21, 18, 111], [112, 113, 77, 85, 179, 255, 38, 120, 114], [40, 42, 1, 196, 245, 209, 10, 25, 109], [88, 43, 29, 140, 166, 213, 37, 43, 154], [61, 63, 30, 155, 67, 45, 68, 1, 209], [100, 80, 8, 43, 154, 1, 51, 26, 71], [142, 78, 78, 16, 255, 128, 34, 197, 171], [41, 40, 5, 102, 211, 183, 4, 1, 221], [51, 50, 17, 168, 209, 192, 23, 25, 82]], [[138, 31, 36, 171, 27, 166, 38, 44, 229], [67, 87, 58, 169, 82, 115, 26, 59, 179], [63, 59, 90, 180, 59, 166, 93, 73, 154], [40, 40, 21, 116, 143, 209, 34, 39, 175], [47, 15, 16, 183, 34, 223, 49, 45, 183], [46, 17, 33, 183, 6, 98, 15, 32, 183], [57, 46, 22, 24, 128, 1, 54, 17, 37], [65, 32, 73, 115, 28, 128, 23, 128, 205], [40, 3, 9, 115, 51, 192, 18, 6, 223], [87, 37, 9, 115, 59, 77, 64, 21, 47]], [[104, 55, 44, 218, 9, 54, 53, 130, 226], [64, 90, 70, 205, 40, 41, 23, 26, 57], [54, 57, 112, 184, 5, 41, 38, 166, 213], [30, 34, 26, 133, 152, 116, 10, 32, 134], [39, 19, 53, 221, 26, 114, 32, 73, 255], [31, 9, 65, 234, 2, 15, 1, 118, 73], [75, 32, 12, 51, 192, 255, 160, 43, 51], [88, 31, 35, 67, 102, 85, 55, 186, 85], [56, 21, 23, 111, 59, 205, 45, 37, 192], [55, 38, 70, 124, 73, 102, 1, 34, 98]], [[125, 98, 42, 88, 104, 85, 117, 175, 82], [95, 84, 53, 89, 128, 100, 113, 101, 45], [75, 79, 123, 47, 51, 128, 81, 171, 1], [57, 17, 5, 71, 102, 57, 53, 41, 49], [38, 33, 13, 121, 57, 73, 26, 1, 85], [41, 10, 67, 138, 77, 110, 90, 47, 114], [115, 21, 2, 10, 102, 255, 166, 23, 6], [101, 29, 16, 10, 85, 128, 101, 196, 26], [57, 18, 10, 102, 102, 213, 34, 20, 43], [117, 20, 15, 36, 163, 128, 68, 1, 26]], [[102, 61, 71, 37, 34, 53, 31, 243, 192], [69, 60, 71, 38, 73, 119, 28, 222, 37], [68, 45, 128, 34, 1, 47, 11, 245, 171], [62, 17, 19, 70, 146, 85, 55, 62, 70], [37, 43, 37, 154, 100, 163, 85, 160, 1], [63, 9, 92, 136, 28, 64, 32, 201, 85], [75, 15, 9, 9, 64, 255, 184, 119, 16], [86, 6, 28, 5, 64, 255, 25, 248, 1], [56, 8, 17, 132, 137, 255, 55, 116, 128], [58, 15, 20, 82, 135, 57, 26, 121, 40]], [[164, 50, 31, 137, 154, 133, 25, 35, 218], [51, 103, 44, 131, 131, 123, 31, 6, 158], [86, 40, 64, 135, 148, 224, 45, 183, 128], [22, 26, 17, 131, 240, 154, 14, 1, 209], [45, 16, 21, 91, 64, 222, 7, 1, 197], [56, 21, 39, 155, 60, 138, 23, 102, 213], [83, 12, 13, 54, 192, 255, 68, 47, 28], [85, 26, 85, 85, 128, 128, 32, 146, 171], [18, 11, 7, 63, 144, 171, 4, 4, 246], [35, 27, 10, 146, 174, 171, 12, 26, 128]], [[190, 80, 35, 99, 180, 80, 126, 54, 45], [85, 126, 47, 87, 176, 51, 41, 20, 32], [101, 75, 128, 139, 118, 146, 116, 128, 85], [56, 41, 15, 176, 236, 85, 37, 9, 62], [71, 30, 17, 119, 118, 255, 17, 18, 138], [101, 38, 60, 138, 55, 70, 43, 26, 142], [146, 36, 19, 30, 171, 255, 97, 27, 20], [138, 45, 61, 62, 219, 1, 81, 188, 64], [32, 41, 20, 117, 151, 142, 20, 21, 163], [112, 19, 12, 61, 195, 128, 48, 4, 24]]], KP = [[[[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255], [223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255], [249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255], [234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255], [239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255], [250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255], [234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255]], [[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255]], [[255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255], [249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255], [247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255], [250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255], [234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255], [251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255]], [[255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255]], [[255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]], [[[248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255], [248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255]], [[255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255], [246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255], [252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255]], [[255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255], [248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255], [253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255]], [[255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255], [245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255], [253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255], [252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255], [249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255], [250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], [[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]]], $P = [0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0], ps = [], Si = [], Ba = [], WP = 1, Gw = 2, hs = [], di = [];
    xa("UpsampleRgbLinePair", is, 3), xa("UpsampleBgrLinePair", nn, 3), xa("UpsampleRgbaLinePair", Bn, 4), xa("UpsampleBgraLinePair", fu, 4), xa("UpsampleArgbLinePair", _u, 4), xa("UpsampleRgba4444LinePair", ll, 2), xa("UpsampleRgb565LinePair", sl, 2);
    var XP = B.UpsampleRgbLinePair, YP = B.UpsampleBgrLinePair, Vw = B.UpsampleRgbaLinePair, Dw = B.UpsampleBgraLinePair, Hw = B.UpsampleArgbLinePair, zw = B.UpsampleRgba4444LinePair, ZP = B.UpsampleRgb565LinePair, Qd = 16, qd = 1 << Qd - 1, Eu = -227, zg = 482, JP = 6, Kw = 0, eF = i(256), tF = i(256), rF = i(256), oF = i(256), nF = i(zg - Eu), iF = i(zg - Eu);
    ka("YuvToRgbRow", is, 3), ka("YuvToBgrRow", nn, 3), ka("YuvToRgbaRow", Bn, 4), ka("YuvToBgraRow", fu, 4), ka("YuvToArgbRow", _u, 4), ka("YuvToRgba4444Row", ll, 2), ka("YuvToRgb565Row", sl, 2);
    var $w = [0, 4, 8, 12, 128, 132, 136, 140, 256, 260, 264, 268, 384, 388, 392, 396], Gd = [0, 2, 8], aF = [8, 7, 6, 4, 4, 2, 2, 2, 1, 1, 1, 1], sF = 1;
    this.WebPDecodeRGBA = function(h, y, k, j, R) {
      var Q = Id, q = new Ee(), V = new mt();
      q.ba = V, V.S = Q, V.width = [V.width], V.height = [V.height];
      var z = V.width, $ = V.height, se = new Nt();
      if (se == null || h == null) var be = 2;
      else e(se != null), be = cl(h, y, k, se.width, se.height, se.Pd, se.Qd, se.format, null);
      if (be != 0 ? z = 0 : (z != null && (z[0] = se.width[0]), $ != null && ($[0] = se.height[0]), z = 1), z) {
        V.width = V.width[0], V.height = V.height[0], j != null && (j[0] = V.width), R != null && (R[0] = V.height);
        e: {
          if (j = new Yl(), (R = new Re()).data = h, R.w = y, R.ha = k, R.kd = 1, y = [0], e(R != null), ((h = cl(R.data, R.w, R.ha, null, null, null, y, null, R)) == 0 || h == 7) && y[0] && (h = 4), (y = h) == 0) {
            if (e(q != null), j.data = R.data, j.w = R.w + R.offset, j.ha = R.ha - R.offset, j.put = xt, j.ac = To, j.bc = Qo, j.ma = q, R.xa) {
              if ((h = $r()) == null) {
                q = 1;
                break e;
              }
              if ((function(W, ue) {
                var _e = [0], xe = [0], fe = [0];
                t: for (; ; ) {
                  if (W == null) return 0;
                  if (ue == null) return W.a = 2, 0;
                  if (W.l = ue, W.a = 0, oe(W.m, ue.data, ue.w, ue.ha), !qo(W.m, _e, xe, fe)) {
                    W.a = 3;
                    break t;
                  }
                  if (W.xb = Gw, ue.width = _e[0], ue.height = xe[0], !re(_e[0], xe[0], 1, W, null)) break t;
                  return 1;
                }
                return e(W.a != 0), 0;
              })(h, j)) {
                if (j = (y = as(j.width, j.height, q.Oa, q.ba)) == 0) {
                  t: {
                    j = h;
                    r: for (; ; ) {
                      if (j == null) {
                        j = 0;
                        break t;
                      }
                      if (e(j.s.yc != null), e(j.s.Ya != null), e(0 < j.s.Wb), e((k = j.l) != null), e((R = k.ma) != null), j.xb != 0) {
                        if (j.ca = R.ba, j.tb = R.tb, e(j.ca != null), !mu(R.Oa, k, Md)) {
                          j.a = 2;
                          break r;
                        }
                        if (!Ke(j, k.width) || k.da) break r;
                        if ((k.da || _t(j.ca.S)) && Ci(), 11 > j.ca.S || (alert("todo:WebPInitConvertARGBToYUV"), j.ca.f.kb.F != null && Ci()), j.Pb && 0 < j.s.ua && j.s.vb.X == null && !D(j.s.vb, j.s.Wa.Xa)) {
                          j.a = 1;
                          break r;
                        }
                        j.xb = 0;
                      }
                      if (!qt(j, j.V, j.Ba, j.c, j.i, k.o, dt)) break r;
                      R.Dc = j.Ma, j = 1;
                      break t;
                    }
                    e(j.a != 0), j = 0;
                  }
                  j = !j;
                }
                j && (y = h.a);
              } else y = h.a;
            } else {
              if ((h = new kg()) == null) {
                q = 1;
                break e;
              }
              if (h.Fa = R.na, h.P = R.P, h.qc = R.Sa, Xi(h, j)) {
                if ((y = as(j.width, j.height, q.Oa, q.ba)) == 0) {
                  if (h.Aa = 0, k = q.Oa, e((R = h) != null), k != null) {
                    if (0 < (z = 0 > (z = k.Md) ? 0 : 100 < z ? 255 : 255 * z / 100)) {
                      for ($ = se = 0; 4 > $; ++$) 12 > (be = R.pb[$]).lc && (be.ia = z * aF[0 > be.lc ? 0 : be.lc] >> 3), se |= be.ia;
                      se && (alert("todo:VP8InitRandom"), R.ia = 1);
                    }
                    R.Ga = k.Id, 100 < R.Ga ? R.Ga = 100 : 0 > R.Ga && (R.Ga = 0);
                  }
                  (function(W, ue) {
                    if (W == null) return 0;
                    if (ue == null) return Fo(W, 2, "NULL VP8Io parameter in VP8Decode().");
                    if (!W.cb && !Xi(W, ue)) return 0;
                    if (e(W.cb), ue.ac == null || ue.ac(ue)) {
                      ue.ob && (W.L = 0);
                      var _e = Gd[W.L];
                      if (W.L == 2 ? (W.yb = 0, W.zb = 0) : (W.yb = ue.v - _e >> 4, W.zb = ue.j - _e >> 4, 0 > W.yb && (W.yb = 0), 0 > W.zb && (W.zb = 0)), W.Va = ue.o + 15 + _e >> 4, W.Hb = ue.va + 15 + _e >> 4, W.Hb > W.za && (W.Hb = W.za), W.Va > W.Ub && (W.Va = W.Ub), 0 < W.L) {
                        var xe = W.ed;
                        for (_e = 0; 4 > _e; ++_e) {
                          var fe;
                          if (W.Qa.Cb) {
                            var Se = W.Qa.Lb[_e];
                            W.Qa.Fb || (Se += xe.Tb);
                          } else Se = xe.Tb;
                          for (fe = 0; 1 >= fe; ++fe) {
                            var je = W.gd[_e][fe], Ve = Se;
                            if (xe.Pc && (Ve += xe.vd[0], fe && (Ve += xe.od[0])), 0 < (Ve = 0 > Ve ? 0 : 63 < Ve ? 63 : Ve)) {
                              var Oe = Ve;
                              0 < xe.wb && (Oe = 4 < xe.wb ? Oe >> 2 : Oe >> 1) > 9 - xe.wb && (Oe = 9 - xe.wb), 1 > Oe && (Oe = 1), je.dd = Oe, je.tc = 2 * Ve + Oe, je.ld = 40 <= Ve ? 2 : 15 <= Ve ? 1 : 0;
                            } else je.tc = 0;
                            je.La = fe;
                          }
                        }
                      }
                      _e = 0;
                    } else Fo(W, 6, "Frame setup failed"), _e = W.a;
                    if (_e = _e == 0) {
                      if (_e) {
                        W.$c = 0, 0 < W.Aa || (W.Ic = sF);
                        t: {
                          _e = W.Ic, xe = 4 * (Oe = W.za);
                          var Ft = 32 * Oe, yt = Oe + 1, Jt = 0 < W.L ? Oe * (0 < W.Aa ? 2 : 1) : 0, jt = (W.Aa == 2 ? 2 : 1) * Oe;
                          if ((je = xe + 832 + (fe = 3 * (16 * _e + Gd[W.L]) / 2 * Ft) + (Se = W.Fa != null && 0 < W.Fa.length ? W.Kc.c * W.Kc.i : 0)) != je) _e = 0;
                          else {
                            if (je > W.Vb) {
                              if (W.Vb = 0, W.Ec = i(je), W.Fc = 0, W.Ec == null) {
                                _e = Fo(W, 1, "no memory during frame initialization.");
                                break t;
                              }
                              W.Vb = je;
                            }
                            je = W.Ec, Ve = W.Fc, W.Ac = je, W.Bc = Ve, Ve += xe, W.Gd = a(Ft, md), W.Hd = 0, W.rb = a(yt + 1, os), W.sb = 1, W.wa = Jt ? a(Jt, Fr) : null, W.Y = 0, W.D.Nb = 0, W.D.wa = W.wa, W.D.Y = W.Y, 0 < W.Aa && (W.D.Y += Oe), e(!0), W.oc = je, W.pc = Ve, Ve += 832, W.ya = a(jt, au), W.aa = 0, W.D.ya = W.ya, W.D.aa = W.aa, W.Aa == 2 && (W.D.aa += Oe), W.R = 16 * Oe, W.B = 8 * Oe, Oe = (Ft = Gd[W.L]) * W.R, Ft = Ft / 2 * W.B, W.sa = je, W.ta = Ve + Oe, W.qa = W.sa, W.ra = W.ta + 16 * _e * W.R + Ft, W.Ha = W.qa, W.Ia = W.ra + 8 * _e * W.B + Ft, W.$c = 0, Ve += fe, W.mb = Se ? je : null, W.nb = Se ? Ve : null, e(Ve + Se <= W.Fc + W.Vb), vd(W), n(W.Ac, W.Bc, 0, xe), _e = 1;
                          }
                        }
                        if (_e) {
                          if (ue.ka = 0, ue.y = W.sa, ue.O = W.ta, ue.f = W.qa, ue.N = W.ra, ue.ea = W.Ha, ue.Vd = W.Ia, ue.fa = W.R, ue.Rc = W.B, ue.F = null, ue.J = 0, !Mw) {
                            for (_e = -255; 255 >= _e; ++_e) Fw[255 + _e] = 0 > _e ? -_e : _e;
                            for (_e = -1020; 1020 >= _e; ++_e) Uw[1020 + _e] = -128 > _e ? -128 : 127 < _e ? 127 : _e;
                            for (_e = -112; 112 >= _e; ++_e) Nw[112 + _e] = -16 > _e ? -16 : 15 < _e ? 15 : _e;
                            for (_e = -255; 510 >= _e; ++_e) Iw[255 + _e] = 0 > _e ? 0 : 255 < _e ? 255 : _e;
                            Mw = 1;
                          }
                          ds = Jl, dl = Sg, ea = Yi, Sr = xd, Mr = kd, ui = Cg, mo = jd, Ho = nl, Sa = M, Cu = X, ic = Ld, Fd = x, kw = ie, Cw = he, Sw = ol, Bw = hu, Ew = Bd, jw = Ed, Si[0] = Ug, Si[1] = Bg, Si[2] = Pg, Si[3] = Fg, Si[4] = _a, Si[5] = Ng, Si[6] = fa, Si[7] = Ig, Si[8] = cu, Si[9] = ec, ps[0] = Lg, ps[1] = jg, ps[2] = su, ps[3] = Cd, ps[4] = tl, ps[5] = lu, ps[6] = Tg, Ba[0] = Rg, Ba[1] = Eg, Ba[2] = rl, Ba[3] = Mg, Ba[4] = Au, Ba[5] = uu, Ba[6] = Sd, _e = 1;
                        } else _e = 0;
                      }
                      _e && (_e = (function(Ar, zo) {
                        for (Ar.M = 0; Ar.M < Ar.Va; ++Ar.M) {
                          var er, Lt = Ar.Jc[Ar.M & Ar.Xb], at = Ar.m, yo = Ar;
                          for (er = 0; er < yo.za; ++er) {
                            var Xt = at, pr = yo, Wr = pr.Ac, an = pr.Bc + 4 * er, En = pr.zc, co = pr.ya[pr.aa + er];
                            if (pr.Qa.Bb ? co.$b = ye(Xt, pr.Pa.jb[0]) ? 2 + ye(Xt, pr.Pa.jb[2]) : ye(Xt, pr.Pa.jb[1]) : co.$b = 0, pr.kc && (co.Ad = ye(Xt, pr.Bd)), co.Za = !ye(Xt, 145) + 0, co.Za) {
                              var hn = co.Ob, jn = 0;
                              for (pr = 0; 4 > pr; ++pr) {
                                var Ko, _r = En[0 + pr];
                                for (Ko = 0; 4 > Ko; ++Ko) {
                                  _r = zP[Wr[an + Ko]][_r];
                                  for (var Lr = qw[ye(Xt, _r[0])]; 0 < Lr; ) Lr = qw[2 * Lr + ye(Xt, _r[Lr])];
                                  _r = -Lr, Wr[an + Ko] = _r;
                                }
                                r(hn, jn, Wr, an, 4), jn += 4, En[0 + pr] = _r;
                              }
                            } else _r = ye(Xt, 156) ? ye(Xt, 128) ? 1 : 3 : ye(Xt, 163) ? 2 : 0, co.Ob[0] = _r, n(Wr, an, _r, 4), n(En, 0, _r, 4);
                            co.Dd = ye(Xt, 142) ? ye(Xt, 114) ? ye(Xt, 183) ? 1 : 3 : 2 : 0;
                          }
                          if (yo.m.Ka) return Fo(Ar, 7, "Premature end-of-partition0 encountered.");
                          for (; Ar.ja < Ar.za; ++Ar.ja) {
                            if (yo = Lt, Xt = (at = Ar).rb[at.sb - 1], Wr = at.rb[at.sb + at.ja], er = at.ya[at.aa + at.ja], an = at.kc ? er.Ad : 0) Xt.la = Wr.la = 0, er.Za || (Xt.Na = Wr.Na = 0), er.Hc = 0, er.Gc = 0, er.ia = 0;
                            else {
                              var uo, Tr;
                              if (Xt = Wr, Wr = yo, an = at.Pa.Xc, En = at.ya[at.aa + at.ja], co = at.pb[En.$b], pr = En.ad, hn = 0, jn = at.rb[at.sb - 1], _r = Ko = 0, n(pr, hn, 0, 384), En.Za) var sn = 0, Bi = an[3];
                              else {
                                Lr = i(16);
                                var bo = Xt.Na + jn.Na;
                                if (bo = Bu(Wr, an[1], bo, co.Eb, 0, Lr, 0), Xt.Na = jn.Na = (0 < bo) + 0, 1 < bo) ds(Lr, 0, pr, hn);
                                else {
                                  var On = Lr[0] + 3 >> 3;
                                  for (Lr = 0; 256 > Lr; Lr += 16) pr[hn + Lr] = On;
                                }
                                sn = 1, Bi = an[0];
                              }
                              var Rr = 15 & Xt.la, $o = 15 & jn.la;
                              for (Lr = 0; 4 > Lr; ++Lr) {
                                var Yn = 1 & $o;
                                for (On = Tr = 0; 4 > On; ++On) Rr = Rr >> 1 | (Yn = (bo = Bu(Wr, Bi, bo = Yn + (1 & Rr), co.Sc, sn, pr, hn)) > sn) << 7, Tr = Tr << 2 | (3 < bo ? 3 : 1 < bo ? 2 : pr[hn + 0] != 0), hn += 16;
                                Rr >>= 4, $o = $o >> 1 | Yn << 7, Ko = (Ko << 8 | Tr) >>> 0;
                              }
                              for (Bi = Rr, sn = $o >> 4, uo = 0; 4 > uo; uo += 2) {
                                for (Tr = 0, Rr = Xt.la >> 4 + uo, $o = jn.la >> 4 + uo, Lr = 0; 2 > Lr; ++Lr) {
                                  for (Yn = 1 & $o, On = 0; 2 > On; ++On) bo = Yn + (1 & Rr), Rr = Rr >> 1 | (Yn = 0 < (bo = Bu(Wr, an[2], bo, co.Qc, 0, pr, hn))) << 3, Tr = Tr << 2 | (3 < bo ? 3 : 1 < bo ? 2 : pr[hn + 0] != 0), hn += 16;
                                  Rr >>= 2, $o = $o >> 1 | Yn << 5;
                                }
                                _r |= Tr << 4 * uo, Bi |= Rr << 4 << uo, sn |= (240 & $o) << uo;
                              }
                              Xt.la = Bi, jn.la = sn, En.Hc = Ko, En.Gc = _r, En.ia = 43690 & _r ? 0 : co.ia, an = !(Ko | _r);
                            }
                            if (0 < at.L && (at.wa[at.Y + at.ja] = at.gd[er.$b][er.Za], at.wa[at.Y + at.ja].La |= !an), yo.Ka) return Fo(Ar, 7, "Premature end-of-file encountered.");
                          }
                          if (vd(Ar), at = zo, yo = 1, er = (Lt = Ar).D, Xt = 0 < Lt.L && Lt.M >= Lt.zb && Lt.M <= Lt.Va, Lt.Aa == 0) t: {
                            if (er.M = Lt.M, er.uc = Xt, ci(Lt, er), yo = 1, er = (Tr = Lt.D).Nb, Xt = (_r = Gd[Lt.L]) * Lt.R, Wr = _r / 2 * Lt.B, Lr = 16 * er * Lt.R, On = 8 * er * Lt.B, an = Lt.sa, En = Lt.ta - Xt + Lr, co = Lt.qa, pr = Lt.ra - Wr + On, hn = Lt.Ha, jn = Lt.Ia - Wr + On, $o = (Rr = Tr.M) == 0, Ko = Rr >= Lt.Va - 1, Lt.Aa == 2 && ci(Lt, Tr), Tr.uc) for (Yn = (bo = Lt).D.M, e(bo.D.uc), Tr = bo.yb; Tr < bo.Hb; ++Tr) {
                              sn = Tr, Bi = Yn;
                              var Ln = (Zn = (ln = bo).D).Nb;
                              uo = ln.R;
                              var Zn = Zn.wa[Zn.Y + sn], Jn = ln.sa, Qn = ln.ta + 16 * Ln * uo + 16 * sn, ei = Zn.dd, Vr = Zn.tc;
                              if (Vr != 0) if (e(3 <= Vr), ln.L == 1) 0 < sn && Bw(Jn, Qn, uo, Vr + 4), Zn.La && jw(Jn, Qn, uo, Vr), 0 < Bi && Sw(Jn, Qn, uo, Vr + 4), Zn.La && Ew(Jn, Qn, uo, Vr);
                              else {
                                var ti = ln.B, Ei = ln.qa, pl = ln.ra + 8 * Ln * ti + 8 * sn, Ea = ln.Ha, ln = ln.Ia + 8 * Ln * ti + 8 * sn;
                                Ln = Zn.ld, 0 < sn && (Ho(Jn, Qn, uo, Vr + 4, ei, Ln), Cu(Ei, pl, Ea, ln, ti, Vr + 4, ei, Ln)), Zn.La && (Fd(Jn, Qn, uo, Vr, ei, Ln), Cw(Ei, pl, Ea, ln, ti, Vr, ei, Ln)), 0 < Bi && (mo(Jn, Qn, uo, Vr + 4, ei, Ln), Sa(Ei, pl, Ea, ln, ti, Vr + 4, ei, Ln)), Zn.La && (ic(Jn, Qn, uo, Vr, ei, Ln), kw(Ei, pl, Ea, ln, ti, Vr, ei, Ln));
                              }
                            }
                            if (Lt.ia && alert("todo:DitherRow"), at.put != null) {
                              if (Tr = 16 * Rr, Rr = 16 * (Rr + 1), $o ? (at.y = Lt.sa, at.O = Lt.ta + Lr, at.f = Lt.qa, at.N = Lt.ra + On, at.ea = Lt.Ha, at.W = Lt.Ia + On) : (Tr -= _r, at.y = an, at.O = En, at.f = co, at.N = pr, at.ea = hn, at.W = jn), Ko || (Rr -= _r), Rr > at.o && (Rr = at.o), at.F = null, at.J = null, Lt.Fa != null && 0 < Lt.Fa.length && Tr < Rr && (at.J = Gr(Lt, at, Tr, Rr - Tr), at.F = Lt.mb, at.F == null && at.F.length == 0)) {
                                yo = Fo(Lt, 3, "Could not decode alpha data.");
                                break t;
                              }
                              Tr < at.j && (_r = at.j - Tr, Tr = at.j, e(!(1 & _r)), at.O += Lt.R * _r, at.N += Lt.B * (_r >> 1), at.W += Lt.B * (_r >> 1), at.F != null && (at.J += at.width * _r)), Tr < Rr && (at.O += at.v, at.N += at.v >> 1, at.W += at.v >> 1, at.F != null && (at.J += at.v), at.ka = Tr - at.j, at.U = at.va - at.v, at.T = Rr - Tr, yo = at.put(at));
                            }
                            er + 1 != Lt.Ic || Ko || (r(Lt.sa, Lt.ta - Xt, an, En + 16 * Lt.R, Xt), r(Lt.qa, Lt.ra - Wr, co, pr + 8 * Lt.B, Wr), r(Lt.Ha, Lt.Ia - Wr, hn, jn + 8 * Lt.B, Wr));
                          }
                          if (!yo) return Fo(Ar, 6, "Output aborted.");
                        }
                        return 1;
                      })(W, ue)), ue.bc != null && ue.bc(ue), _e &= 1;
                    }
                    return _e ? (W.cb = 0, _e) : 0;
                  })(h, j) || (y = h.a);
                }
              } else y = h.a;
            }
            y == 0 && q.Oa != null && q.Oa.fd && (y = yu(q.ba));
          }
          q = y;
        }
        Q = q != 0 ? null : 11 > Q ? V.f.RGBA.eb : V.f.kb.y;
      } else Q = null;
      return Q;
    };
    var Ww = [3, 4, 3, 4, 4, 2, 2, 4, 4, 4, 2, 1, 1];
  };
  function c(B, P) {
    for (var S = "", L = 0; L < 4; L++) S += String.fromCharCode(B[P++]);
    return S;
  }
  function u(B, P) {
    return B[P + 0] | B[P + 1] << 8;
  }
  function A(B, P) {
    return (B[P + 0] | B[P + 1] << 8 | B[P + 2] << 16) >>> 0;
  }
  function p(B, P) {
    return (B[P + 0] | B[P + 1] << 8 | B[P + 2] << 16 | B[P + 3] << 24) >>> 0;
  }
  new l();
  var d = [0], g = [0], _ = [], f = new l(), m = o, b = (function(B, P) {
    var S = {}, L = 0, U = !1, O = 0, K = 0;
    if (S.frames = [], !/** @license
     * Copyright (c) 2017 Dominik Homberger
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    https://webpjs.appspot.com
    WebPRiffParser [email protected]
    */
    (function(I, G) {
      for (var H = 0; H < 4; H++) if (I[G + H] != "RIFF".charCodeAt(H)) return !0;
      return !1;
    })(B, P)) {
      for (p(B, P += 4), P += 8; P < B.length; ) {
        var te = c(B, P), Y = p(B, P += 4);
        P += 4;
        var ee = Y + (1 & Y);
        switch (te) {
          case "VP8 ":
          case "VP8L":
            S.frames[L] === void 0 && (S.frames[L] = {}), (ae = S.frames[L]).src_off = U ? K : P - 8, ae.src_size = O + Y + 8, L++, U && (U = !1, O = 0, K = 0);
            break;
          case "VP8X":
            (ae = S.header = {}).feature_flags = B[P];
            var oe = P + 4;
            ae.canvas_width = 1 + A(B, oe), oe += 3, ae.canvas_height = 1 + A(B, oe), oe += 3;
            break;
          case "ALPH":
            U = !0, O = ee + 8, K = P - 8;
            break;
          case "ANIM":
            (ae = S.header).bgcolor = p(B, P), oe = P + 4, ae.loop_count = u(B, oe), oe += 2;
            break;
          case "ANMF":
            var de, ae;
            (ae = S.frames[L] = {}).offset_x = 2 * A(B, P), P += 3, ae.offset_y = 2 * A(B, P), P += 3, ae.width = 1 + A(B, P), P += 3, ae.height = 1 + A(B, P), P += 3, ae.duration = A(B, P), P += 3, de = B[P++], ae.dispose = 1 & de, ae.blend = de >> 1 & 1;
        }
        te != "ANMF" && (P += ee);
      }
      return S;
    }
  })(m, 0);
  b.response = m, b.rgbaoutput = !0, b.dataurl = !1;
  var v = b.header ? b.header : null, w = b.frames ? b.frames : null;
  if (v) {
    v.loop_counter = v.loop_count, d = [v.canvas_height], g = [v.canvas_width];
    for (var C = 0; C < w.length && w[C].blend != 0; C++) ;
  }
  var E = w[0], T = f.WebPDecodeRGBA(m, E.src_off, E.src_size, g, d);
  E.rgba = T, E.imgwidth = g[0], E.imgheight = d[0];
  for (var F = 0; F < g[0] * d[0] * 4; F++) _[F] = T[F];
  return this.width = g, this.height = d, this.data = _, this;
}
(function(o) {
  var e, t, r, n, i, a, s, l, c, u = function(I) {
    return I = I || {}, this.isStrokeTransparent = I.isStrokeTransparent || !1, this.strokeOpacity = I.strokeOpacity || 1, this.strokeStyle = I.strokeStyle || "#000000", this.fillStyle = I.fillStyle || "#000000", this.isFillTransparent = I.isFillTransparent || !1, this.fillOpacity = I.fillOpacity || 1, this.font = I.font || "10px sans-serif", this.textBaseline = I.textBaseline || "alphabetic", this.textAlign = I.textAlign || "left", this.lineWidth = I.lineWidth || 1, this.lineJoin = I.lineJoin || "miter", this.lineCap = I.lineCap || "butt", this.path = I.path || [], this.transform = I.transform !== void 0 ? I.transform.clone() : new l(), this.globalCompositeOperation = I.globalCompositeOperation || "normal", this.globalAlpha = I.globalAlpha || 1, this.clip_path = I.clip_path || [], this.currentPoint = I.currentPoint || new a(), this.miterLimit = I.miterLimit || 10, this.lastPoint = I.lastPoint || new a(), this.lineDashOffset = I.lineDashOffset || 0, this.lineDash = I.lineDash || [], this.margin = I.margin || [0, 0, 0, 0], this.prevPageLastElemOffset = I.prevPageLastElemOffset || 0, this.ignoreClearRect = typeof I.ignoreClearRect != "boolean" || I.ignoreClearRect, this;
  };
  o.events.push(["initialized", function() {
    this.context2d = new A(this), e = this.internal.f2, t = this.internal.getCoordinateString, r = this.internal.getVerticalCoordinateString, n = this.internal.getHorizontalCoordinate, i = this.internal.getVerticalCoordinate, a = this.internal.Point, s = this.internal.Rectangle, l = this.internal.Matrix, c = new u();
  }]);
  var A = function(I) {
    Object.defineProperty(this, "canvas", { get: function() {
      return { parentNode: !1, style: !1 };
    } });
    var G = I;
    Object.defineProperty(this, "pdf", { get: function() {
      return G;
    } });
    var H = !1;
    Object.defineProperty(this, "pageWrapXEnabled", { get: function() {
      return H;
    }, set: function(D) {
      H = !!D;
    } });
    var Z = !1;
    Object.defineProperty(this, "pageWrapYEnabled", { get: function() {
      return Z;
    }, set: function(D) {
      Z = !!D;
    } });
    var ne = 0;
    Object.defineProperty(this, "posX", { get: function() {
      return ne;
    }, set: function(D) {
      isNaN(D) || (ne = D);
    } });
    var le = 0;
    Object.defineProperty(this, "posY", { get: function() {
      return le;
    }, set: function(D) {
      isNaN(D) || (le = D);
    } }), Object.defineProperty(this, "margin", { get: function() {
      return c.margin;
    }, set: function(D) {
      var Ne;
      typeof D == "number" ? Ne = [D, D, D, D] : ((Ne = new Array(4))[0] = D[0], Ne[1] = D.length >= 2 ? D[1] : Ne[0], Ne[2] = D.length >= 3 ? D[2] : Ne[0], Ne[3] = D.length >= 4 ? D[3] : Ne[1]), c.margin = Ne;
    } });
    var me = !1;
    Object.defineProperty(this, "autoPaging", { get: function() {
      return me;
    }, set: function(D) {
      me = D;
    } });
    var ce = 0;
    Object.defineProperty(this, "lastBreak", { get: function() {
      return ce;
    }, set: function(D) {
      ce = D;
    } });
    var ye = [];
    Object.defineProperty(this, "pageBreaks", { get: function() {
      return ye;
    }, set: function(D) {
      ye = D;
    } }), Object.defineProperty(this, "ctx", { get: function() {
      return c;
    }, set: function(D) {
      D instanceof u && (c = D);
    } }), Object.defineProperty(this, "path", { get: function() {
      return c.path;
    }, set: function(D) {
      c.path = D;
    } });
    var Ce = [];
    Object.defineProperty(this, "ctxStack", { get: function() {
      return Ce;
    }, set: function(D) {
      Ce = D;
    } }), Object.defineProperty(this, "fillStyle", { get: function() {
      return this.ctx.fillStyle;
    }, set: function(D) {
      var Ne;
      Ne = p(D), this.ctx.fillStyle = Ne.style, this.ctx.isFillTransparent = Ne.a === 0, this.ctx.fillOpacity = Ne.a, this.pdf.setFillColor(Ne.r, Ne.g, Ne.b, { a: Ne.a }), this.pdf.setTextColor(Ne.r, Ne.g, Ne.b, { a: Ne.a });
    } }), Object.defineProperty(this, "strokeStyle", { get: function() {
      return this.ctx.strokeStyle;
    }, set: function(D) {
      var Ne = p(D);
      this.ctx.strokeStyle = Ne.style, this.ctx.isStrokeTransparent = Ne.a === 0, this.ctx.strokeOpacity = Ne.a, Ne.a === 0 ? this.pdf.setDrawColor(255, 255, 255) : (Ne.a, this.pdf.setDrawColor(Ne.r, Ne.g, Ne.b));
    } }), Object.defineProperty(this, "lineCap", { get: function() {
      return this.ctx.lineCap;
    }, set: function(D) {
      ["butt", "round", "square"].indexOf(D) !== -1 && (this.ctx.lineCap = D, this.pdf.setLineCap(D));
    } }), Object.defineProperty(this, "lineWidth", { get: function() {
      return this.ctx.lineWidth;
    }, set: function(D) {
      isNaN(D) || (this.ctx.lineWidth = D, this.pdf.setLineWidth(D));
    } }), Object.defineProperty(this, "lineJoin", { get: function() {
      return this.ctx.lineJoin;
    }, set: function(D) {
      ["bevel", "round", "miter"].indexOf(D) !== -1 && (this.ctx.lineJoin = D, this.pdf.setLineJoin(D));
    } }), Object.defineProperty(this, "miterLimit", { get: function() {
      return this.ctx.miterLimit;
    }, set: function(D) {
      isNaN(D) || (this.ctx.miterLimit = D, this.pdf.setMiterLimit(D));
    } }), Object.defineProperty(this, "textBaseline", { get: function() {
      return this.ctx.textBaseline;
    }, set: function(D) {
      this.ctx.textBaseline = D;
    } }), Object.defineProperty(this, "textAlign", { get: function() {
      return this.ctx.textAlign;
    }, set: function(D) {
      ["right", "end", "center", "left", "start"].indexOf(D) !== -1 && (this.ctx.textAlign = D);
    } });
    var Ue = null, Qe = null, Xe = null;
    Object.defineProperty(this, "fontFaces", { get: function() {
      return Xe;
    }, set: function(D) {
      Ue = null, Qe = null, Xe = D;
    } }), Object.defineProperty(this, "font", { get: function() {
      return this.ctx.font;
    }, set: function(D) {
      var Ne;
      if (this.ctx.font = D, (Ne = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(D)) !== null) {
        var ct = Ne[1];
        Ne[2];
        var ot = Ne[3], Be = Ne[4];
        Ne[5];
        var et = Ne[6], Le = /^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(Be)[2];
        Be = Math.floor(Le === "px" ? parseFloat(Be) * this.pdf.internal.scaleFactor : Le === "em" ? parseFloat(Be) * this.pdf.getFontSize() : parseFloat(Be) * this.pdf.internal.scaleFactor), this.pdf.setFontSize(Be);
        var Fe = (function(it) {
          var Kt, ve, J = [], ge = it.trim();
          if (ge === "") return o1;
          if (ge in Wx) return [Wx[ge]];
          for (; ge !== ""; ) {
            switch (ve = null, Kt = (ge = Yx(ge)).charAt(0)) {
              case '"':
              case "'":
                ve = WO(ge.substring(1), Kt);
                break;
              default:
                ve = XO(ge);
            }
            if (ve === null || (J.push(ve[0]), (ge = Yx(ve[1])) !== "" && ge.charAt(0) !== ",")) return o1;
            ge = ge.replace(/^,/, "");
          }
          return J;
        })(et);
        if (this.fontFaces) {
          var tt = (function(it, Kt) {
            var ve = it.getFontList(), J = JSON.stringify(ve);
            if (Ue === null || Qe !== J) {
              var ge = (function(We) {
                var nt = [];
                return Object.keys(We).forEach(function(rr) {
                  We[rr].forEach(function(_t) {
                    var wt = null;
                    switch (_t) {
                      case "bold":
                        wt = { family: rr, weight: "bold" };
                        break;
                      case "italic":
                        wt = { family: rr, style: "italic" };
                        break;
                      case "bolditalic":
                        wt = { family: rr, weight: "bold", style: "italic" };
                        break;
                      case "":
                      case "normal":
                        wt = { family: rr };
                    }
                    wt !== null && (wt.ref = { name: rr, style: _t }, nt.push(wt));
                  });
                }), nt;
              })(ve);
              Ue = (function(We) {
                for (var nt = {}, rr = 0; rr < We.length; ++rr) {
                  var _t = U_(We[rr]), wt = _t.family, or = _t.stretch, mt = _t.style, Nt = _t.weight;
                  nt[wt] = nt[wt] || {}, nt[wt][or] = nt[wt][or] || {}, nt[wt][or][mt] = nt[wt][or][mt] || {}, nt[wt][or][mt][Nt] = _t;
                }
                return nt;
              })(ge.concat(Kt)), Qe = J;
            }
            return Ue;
          })(this.pdf, this.fontFaces), we = Fe.map(function(it) {
            return { family: it, stretch: "normal", weight: ot, style: ct };
          }), Ge = (function(it, Kt, ve) {
            for (var J = (ve = ve || {}).defaultFontFamily || "times", ge = Object.assign({}, $O, ve.genericFontFamilies || {}), We = null, nt = null, rr = 0; rr < Kt.length; ++rr) if (ge[(We = U_(Kt[rr])).family] && (We.family = ge[We.family]), it.hasOwnProperty(We.family)) {
              nt = it[We.family];
              break;
            }
            if (!(nt = nt || it[J])) throw new Error("Could not find a font-family for the rule '" + Xx(We) + "' and default family '" + J + "'.");
            if (nt = (function(_t, wt) {
              if (wt[_t]) return wt[_t];
              var or = xb[_t], mt = or <= xb.normal ? -1 : 1, Nt = $x(wt, mj, or, mt);
              if (!Nt) throw new Error("Could not find a matching font-stretch value for " + _t);
              return Nt;
            })(We.stretch, nt), nt = (function(_t, wt) {
              if (wt[_t]) return wt[_t];
              for (var or = fj[_t], mt = 0; mt < or.length; ++mt) if (wt[or[mt]]) return wt[or[mt]];
              throw new Error("Could not find a matching font-style for " + _t);
            })(We.style, nt), !(nt = (function(_t, wt) {
              if (wt[_t]) return wt[_t];
              if (_t === 400 && wt[500]) return wt[500];
              if (_t === 500 && wt[400]) return wt[400];
              var or = KO[_t], mt = $x(wt, yj, or, _t < 400 ? -1 : 1);
              if (!mt) throw new Error("Could not find a matching font-weight for value " + _t);
              return mt;
            })(We.weight, nt))) throw new Error("Failed to resolve a font for the rule '" + Xx(We) + "'.");
            return nt;
          })(tt, we);
          this.pdf.setFont(Ge.ref.name, Ge.ref.style);
        } else {
          var ze = "";
          (ot === "bold" || parseInt(ot, 10) >= 700 || ct === "bold") && (ze = "bold"), ct === "italic" && (ze += "italic"), ze.length === 0 && (ze = "normal");
          for (var Ze = "", ht = { arial: "Helvetica", Arial: "Helvetica", verdana: "Helvetica", Verdana: "Helvetica", helvetica: "Helvetica", Helvetica: "Helvetica", "sans-serif": "Helvetica", fixed: "Courier", monospace: "Courier", terminal: "Courier", cursive: "Times", fantasy: "Times", serif: "Times" }, rt = 0; rt < Fe.length; rt++) {
            if (this.pdf.internal.getFont(Fe[rt], ze, { noFallback: !0, disableWarning: !0 }) !== void 0) {
              Ze = Fe[rt];
              break;
            }
            if (ze === "bolditalic" && this.pdf.internal.getFont(Fe[rt], "bold", { noFallback: !0, disableWarning: !0 }) !== void 0) Ze = Fe[rt], ze = "bold";
            else if (this.pdf.internal.getFont(Fe[rt], "normal", { noFallback: !0, disableWarning: !0 }) !== void 0) {
              Ze = Fe[rt], ze = "normal";
              break;
            }
          }
          if (Ze === "") {
            for (var Ct = 0; Ct < Fe.length; Ct++) if (ht[Fe[Ct]]) {
              Ze = ht[Fe[Ct]];
              break;
            }
          }
          Ze = Ze === "" ? "Times" : Ze, this.pdf.setFont(Ze, ze);
        }
      }
    } }), Object.defineProperty(this, "globalCompositeOperation", { get: function() {
      return this.ctx.globalCompositeOperation;
    }, set: function(D) {
      this.ctx.globalCompositeOperation = D;
    } }), Object.defineProperty(this, "globalAlpha", { get: function() {
      return this.ctx.globalAlpha;
    }, set: function(D) {
      this.ctx.globalAlpha = D;
    } }), Object.defineProperty(this, "lineDashOffset", { get: function() {
      return this.ctx.lineDashOffset;
    }, set: function(D) {
      this.ctx.lineDashOffset = D, ae.call(this);
    } }), Object.defineProperty(this, "lineDash", { get: function() {
      return this.ctx.lineDash;
    }, set: function(D) {
      this.ctx.lineDash = D, ae.call(this);
    } }), Object.defineProperty(this, "ignoreClearRect", { get: function() {
      return this.ctx.ignoreClearRect;
    }, set: function(D) {
      this.ctx.ignoreClearRect = !!D;
    } });
  };
  A.prototype.setLineDash = function(I) {
    this.lineDash = I;
  }, A.prototype.getLineDash = function() {
    return this.lineDash.length % 2 ? this.lineDash.concat(this.lineDash) : this.lineDash.slice();
  }, A.prototype.fill = function() {
    w.call(this, "fill", !1);
  }, A.prototype.stroke = function() {
    w.call(this, "stroke", !1);
  }, A.prototype.beginPath = function() {
    this.path = [{ type: "begin" }];
  }, A.prototype.moveTo = function(I, G) {
    if (isNaN(I) || isNaN(G)) throw Or.error("jsPDF.context2d.moveTo: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.moveTo");
    var H = this.ctx.transform.applyToPoint(new a(I, G));
    this.path.push({ type: "mt", x: H.x, y: H.y }), this.ctx.lastPoint = new a(I, G);
  }, A.prototype.closePath = function() {
    var I = new a(0, 0), G = 0;
    for (G = this.path.length - 1; G !== -1; G--) if (this.path[G].type === "begin" && yr(this.path[G + 1]) === "object" && typeof this.path[G + 1].x == "number") {
      I = new a(this.path[G + 1].x, this.path[G + 1].y);
      break;
    }
    this.path.push({ type: "close" }), this.ctx.lastPoint = new a(I.x, I.y);
  }, A.prototype.lineTo = function(I, G) {
    if (isNaN(I) || isNaN(G)) throw Or.error("jsPDF.context2d.lineTo: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.lineTo");
    var H = this.ctx.transform.applyToPoint(new a(I, G));
    this.path.push({ type: "lt", x: H.x, y: H.y }), this.ctx.lastPoint = new a(H.x, H.y);
  }, A.prototype.clip = function() {
    this.ctx.clip_path = JSON.parse(JSON.stringify(this.path)), w.call(this, null, !0);
  }, A.prototype.quadraticCurveTo = function(I, G, H, Z) {
    if (isNaN(H) || isNaN(Z) || isNaN(I) || isNaN(G)) throw Or.error("jsPDF.context2d.quadraticCurveTo: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo");
    var ne = this.ctx.transform.applyToPoint(new a(H, Z)), le = this.ctx.transform.applyToPoint(new a(I, G));
    this.path.push({ type: "qct", x1: le.x, y1: le.y, x: ne.x, y: ne.y }), this.ctx.lastPoint = new a(ne.x, ne.y);
  }, A.prototype.bezierCurveTo = function(I, G, H, Z, ne, le) {
    if (isNaN(ne) || isNaN(le) || isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z)) throw Or.error("jsPDF.context2d.bezierCurveTo: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo");
    var me = this.ctx.transform.applyToPoint(new a(ne, le)), ce = this.ctx.transform.applyToPoint(new a(I, G)), ye = this.ctx.transform.applyToPoint(new a(H, Z));
    this.path.push({ type: "bct", x1: ce.x, y1: ce.y, x2: ye.x, y2: ye.y, x: me.x, y: me.y }), this.ctx.lastPoint = new a(me.x, me.y);
  }, A.prototype.arc = function(I, G, H, Z, ne, le) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z) || isNaN(ne)) throw Or.error("jsPDF.context2d.arc: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.arc");
    if (le = !!le, !this.ctx.transform.isIdentity) {
      var me = this.ctx.transform.applyToPoint(new a(I, G));
      I = me.x, G = me.y;
      var ce = this.ctx.transform.applyToPoint(new a(0, H)), ye = this.ctx.transform.applyToPoint(new a(0, 0));
      H = Math.sqrt(Math.pow(ce.x - ye.x, 2) + Math.pow(ce.y - ye.y, 2));
    }
    Math.abs(ne - Z) >= 2 * Math.PI && (Z = 0, ne = 2 * Math.PI), this.path.push({ type: "arc", x: I, y: G, radius: H, startAngle: Z, endAngle: ne, counterclockwise: le });
  }, A.prototype.arcTo = function(I, G, H, Z, ne) {
    throw new Error("arcTo not implemented.");
  }, A.prototype.rect = function(I, G, H, Z) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z)) throw Or.error("jsPDF.context2d.rect: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.rect");
    this.moveTo(I, G), this.lineTo(I + H, G), this.lineTo(I + H, G + Z), this.lineTo(I, G + Z), this.lineTo(I, G), this.lineTo(I + H, G), this.lineTo(I, G);
  }, A.prototype.fillRect = function(I, G, H, Z) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z)) throw Or.error("jsPDF.context2d.fillRect: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.fillRect");
    if (!d.call(this)) {
      var ne = {};
      this.lineCap !== "butt" && (ne.lineCap = this.lineCap, this.lineCap = "butt"), this.lineJoin !== "miter" && (ne.lineJoin = this.lineJoin, this.lineJoin = "miter"), this.beginPath(), this.rect(I, G, H, Z), this.fill(), ne.hasOwnProperty("lineCap") && (this.lineCap = ne.lineCap), ne.hasOwnProperty("lineJoin") && (this.lineJoin = ne.lineJoin);
    }
  }, A.prototype.strokeRect = function(I, G, H, Z) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z)) throw Or.error("jsPDF.context2d.strokeRect: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");
    g.call(this) || (this.beginPath(), this.rect(I, G, H, Z), this.stroke());
  }, A.prototype.clearRect = function(I, G, H, Z) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z)) throw Or.error("jsPDF.context2d.clearRect: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.clearRect");
    this.ignoreClearRect || (this.fillStyle = "#ffffff", this.fillRect(I, G, H, Z));
  }, A.prototype.save = function(I) {
    I = typeof I != "boolean" || I;
    for (var G = this.pdf.internal.getCurrentPageInfo().pageNumber, H = 0; H < this.pdf.internal.getNumberOfPages(); H++) this.pdf.setPage(H + 1), this.pdf.internal.out("q");
    if (this.pdf.setPage(G), I) {
      this.ctx.fontSize = this.pdf.internal.getFontSize();
      var Z = new u(this.ctx);
      this.ctxStack.push(this.ctx), this.ctx = Z;
    }
  }, A.prototype.restore = function(I) {
    I = typeof I != "boolean" || I;
    for (var G = this.pdf.internal.getCurrentPageInfo().pageNumber, H = 0; H < this.pdf.internal.getNumberOfPages(); H++) this.pdf.setPage(H + 1), this.pdf.internal.out("Q");
    this.pdf.setPage(G), I && this.ctxStack.length !== 0 && (this.ctx = this.ctxStack.pop(), this.fillStyle = this.ctx.fillStyle, this.strokeStyle = this.ctx.strokeStyle, this.font = this.ctx.font, this.lineCap = this.ctx.lineCap, this.lineWidth = this.ctx.lineWidth, this.lineJoin = this.ctx.lineJoin, this.lineDash = this.ctx.lineDash, this.lineDashOffset = this.ctx.lineDashOffset);
  }, A.prototype.toDataURL = function() {
    throw new Error("toDataUrl not implemented.");
  };
  var p = function(I) {
    var G, H, Z, ne;
    if (I.isCanvasGradient === !0 && (I = I.getColor()), !I) return { r: 0, g: 0, b: 0, a: 0, style: I };
    if (/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/.test(I)) G = 0, H = 0, Z = 0, ne = 0;
    else {
      var le = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(I);
      if (le !== null) G = parseInt(le[1]), H = parseInt(le[2]), Z = parseInt(le[3]), ne = 1;
      else if ((le = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/.exec(I)) !== null) G = parseInt(le[1]), H = parseInt(le[2]), Z = parseInt(le[3]), ne = parseFloat(le[4]);
      else {
        if (ne = 1, typeof I == "string" && I.charAt(0) !== "#") {
          var me = new uj(I);
          I = me.ok ? me.toHex() : "#000000";
        }
        I.length === 4 ? (G = I.substring(1, 2), G += G, H = I.substring(2, 3), H += H, Z = I.substring(3, 4), Z += Z) : (G = I.substring(1, 3), H = I.substring(3, 5), Z = I.substring(5, 7)), G = parseInt(G, 16), H = parseInt(H, 16), Z = parseInt(Z, 16);
      }
    }
    return { r: G, g: H, b: Z, a: ne, style: I };
  }, d = function() {
    return this.ctx.isFillTransparent || this.globalAlpha == 0;
  }, g = function() {
    return !!(this.ctx.isStrokeTransparent || this.globalAlpha == 0);
  };
  A.prototype.fillText = function(I, G, H, Z) {
    if (isNaN(G) || isNaN(H) || typeof I != "string") throw Or.error("jsPDF.context2d.fillText: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.fillText");
    if (Z = isNaN(Z) ? void 0 : Z, !d.call(this)) {
      var ne = ee(this.ctx.transform.rotation), le = this.ctx.transform.scaleX;
      L.call(this, { text: I, x: G, y: H, scale: le, angle: ne, align: this.textAlign, maxWidth: Z });
    }
  }, A.prototype.strokeText = function(I, G, H, Z) {
    if (isNaN(G) || isNaN(H) || typeof I != "string") throw Or.error("jsPDF.context2d.strokeText: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.strokeText");
    if (!g.call(this)) {
      Z = isNaN(Z) ? void 0 : Z;
      var ne = ee(this.ctx.transform.rotation), le = this.ctx.transform.scaleX;
      L.call(this, { text: I, x: G, y: H, scale: le, renderingMode: "stroke", angle: ne, align: this.textAlign, maxWidth: Z });
    }
  }, A.prototype.measureText = function(I) {
    if (typeof I != "string") throw Or.error("jsPDF.context2d.measureText: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.measureText");
    var G = this.pdf, H = this.pdf.internal.scaleFactor, Z = G.internal.getFontSize(), ne = G.getStringUnitWidth(I) * Z / G.internal.scaleFactor;
    return new function(le) {
      var me = (le = le || {}).width || 0;
      return Object.defineProperty(this, "width", { get: function() {
        return me;
      } }), this;
    }({ width: ne *= Math.round(96 * H / 72 * 1e4) / 1e4 });
  }, A.prototype.scale = function(I, G) {
    if (isNaN(I) || isNaN(G)) throw Or.error("jsPDF.context2d.scale: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.scale");
    var H = new l(I, 0, 0, G, 0, 0);
    this.ctx.transform = this.ctx.transform.multiply(H);
  }, A.prototype.rotate = function(I) {
    if (isNaN(I)) throw Or.error("jsPDF.context2d.rotate: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.rotate");
    var G = new l(Math.cos(I), Math.sin(I), -Math.sin(I), Math.cos(I), 0, 0);
    this.ctx.transform = this.ctx.transform.multiply(G);
  }, A.prototype.translate = function(I, G) {
    if (isNaN(I) || isNaN(G)) throw Or.error("jsPDF.context2d.translate: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.translate");
    var H = new l(1, 0, 0, 1, I, G);
    this.ctx.transform = this.ctx.transform.multiply(H);
  }, A.prototype.transform = function(I, G, H, Z, ne, le) {
    if (isNaN(I) || isNaN(G) || isNaN(H) || isNaN(Z) || isNaN(ne) || isNaN(le)) throw Or.error("jsPDF.context2d.transform: Invalid arguments", arguments), new Error("Invalid arguments passed to jsPDF.context2d.transform");
    var me = new l(I, G, H, Z, ne, le);
    this.ctx.transform = this.ctx.transform.multiply(me);
  }, A.prototype.setTransform = function(I, G, H, Z, ne, le) {
    I = isNaN(I) ? 1 : I, G = isNaN(G) ? 0 : G, H = isNaN(H) ? 0 : H, Z = isNaN(Z) ? 1 : Z, ne = isNaN(ne) ? 0 : ne, le = isNaN(le) ? 0 : le, this.ctx.transform = new l(I, G, H, Z, ne, le);
  };
  var _ = function() {
    return this.margin[0] > 0 || this.margin[1] > 0 || this.margin[2] > 0 || this.margin[3] > 0;
  };
  A.prototype.drawImage = function(I, G, H, Z, ne, le, me, ce, ye) {
    var Ce = this.pdf.getImageProperties(I), Ue = 1, Qe = 1, Xe = 1, D = 1;
    Z !== void 0 && ce !== void 0 && (Xe = ce / Z, D = ye / ne, Ue = Ce.width / Z * ce / Z, Qe = Ce.height / ne * ye / ne), le === void 0 && (le = G, me = H, G = 0, H = 0), Z !== void 0 && ce === void 0 && (ce = Z, ye = ne), Z === void 0 && ce === void 0 && (ce = Ce.width, ye = Ce.height);
    var Ne = this.ctx.transform.decompose(), ct = ee(Ne.rotate.shx), ot = new l(), Be = (ot = (ot = (ot = ot.multiply(Ne.translate)).multiply(Ne.skew)).multiply(Ne.scale)).applyToRectangle(new s(le - G * Xe, me - H * D, Z * Ue, ne * Qe));
    if (this.autoPaging) {
      for (var et, Le = f.call(this, Be), Fe = [], tt = 0; tt < Le.length; tt += 1) Fe.indexOf(Le[tt]) === -1 && Fe.push(Le[tt]);
      v(Fe);
      for (var we = Fe[0], Ge = Fe[Fe.length - 1], ze = we; ze < Ge + 1; ze++) {
        this.pdf.setPage(ze);
        var Ze = this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1], ht = ze === 1 ? this.posY + this.margin[0] : this.margin[0], rt = this.pdf.internal.pageSize.height - this.posY - this.margin[0] - this.margin[2], Ct = this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2], it = ze === 1 ? 0 : rt + (ze - 2) * Ct;
        if (this.ctx.clip_path.length !== 0) {
          var Kt = this.path;
          et = JSON.parse(JSON.stringify(this.ctx.clip_path)), this.path = b(et, this.posX + this.margin[3], -it + ht + this.ctx.prevPageLastElemOffset), C.call(this, "fill", !0), this.path = Kt;
        }
        var ve = JSON.parse(JSON.stringify(Be));
        ve = b([ve], this.posX + this.margin[3], -it + ht + this.ctx.prevPageLastElemOffset)[0];
        var J = (ze > we || ze < Ge) && _.call(this);
        J && (this.pdf.saveGraphicsState(), this.pdf.rect(this.margin[3], this.margin[0], Ze, Ct, null).clip().discardPath()), this.pdf.addImage(I, "JPEG", ve.x, ve.y, ve.w, ve.h, null, null, ct), J && this.pdf.restoreGraphicsState();
      }
    } else this.pdf.addImage(I, "JPEG", Be.x, Be.y, Be.w, Be.h, null, null, ct);
  };
  var f = function(I, G, H) {
    var Z = [];
    G = G || this.pdf.internal.pageSize.width, H = H || this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2];
    var ne = this.posY + this.ctx.prevPageLastElemOffset;
    switch (I.type) {
      default:
      case "mt":
      case "lt":
        Z.push(Math.floor((I.y + ne) / H) + 1);
        break;
      case "arc":
        Z.push(Math.floor((I.y + ne - I.radius) / H) + 1), Z.push(Math.floor((I.y + ne + I.radius) / H) + 1);
        break;
      case "qct":
        var le = oe(this.ctx.lastPoint.x, this.ctx.lastPoint.y, I.x1, I.y1, I.x, I.y);
        Z.push(Math.floor((le.y + ne) / H) + 1), Z.push(Math.floor((le.y + le.h + ne) / H) + 1);
        break;
      case "bct":
        var me = de(this.ctx.lastPoint.x, this.ctx.lastPoint.y, I.x1, I.y1, I.x2, I.y2, I.x, I.y);
        Z.push(Math.floor((me.y + ne) / H) + 1), Z.push(Math.floor((me.y + me.h + ne) / H) + 1);
        break;
      case "rect":
        Z.push(Math.floor((I.y + ne) / H) + 1), Z.push(Math.floor((I.y + I.h + ne) / H) + 1);
    }
    for (var ce = 0; ce < Z.length; ce += 1) for (; this.pdf.internal.getNumberOfPages() < Z[ce]; ) m.call(this);
    return Z;
  }, m = function() {
    var I = this.fillStyle, G = this.strokeStyle, H = this.font, Z = this.lineCap, ne = this.lineWidth, le = this.lineJoin;
    this.pdf.addPage(), this.fillStyle = I, this.strokeStyle = G, this.font = H, this.lineCap = Z, this.lineWidth = ne, this.lineJoin = le;
  }, b = function(I, G, H) {
    for (var Z = 0; Z < I.length; Z++) switch (I[Z].type) {
      case "bct":
        I[Z].x2 += G, I[Z].y2 += H;
      case "qct":
        I[Z].x1 += G, I[Z].y1 += H;
      default:
        I[Z].x += G, I[Z].y += H;
    }
    return I;
  }, v = function(I) {
    return I.sort(function(G, H) {
      return G - H;
    });
  }, w = function(I, G) {
    var H = this.fillStyle, Z = this.strokeStyle, ne = this.lineCap, le = this.lineWidth, me = Math.abs(le * this.ctx.transform.scaleX), ce = this.lineJoin;
    if (this.autoPaging) {
      for (var ye, Ce, Ue = JSON.parse(JSON.stringify(this.path)), Qe = JSON.parse(JSON.stringify(this.path)), Xe = [], D = 0; D < Qe.length; D++) if (Qe[D].x !== void 0) for (var Ne = f.call(this, Qe[D]), ct = 0; ct < Ne.length; ct += 1) Xe.indexOf(Ne[ct]) === -1 && Xe.push(Ne[ct]);
      for (var ot = 0; ot < Xe.length; ot++) for (; this.pdf.internal.getNumberOfPages() < Xe[ot]; ) m.call(this);
      v(Xe);
      for (var Be = Xe[0], et = Xe[Xe.length - 1], Le = Be; Le < et + 1; Le++) {
        this.pdf.setPage(Le), this.fillStyle = H, this.strokeStyle = Z, this.lineCap = ne, this.lineWidth = me, this.lineJoin = ce;
        var Fe = this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1], tt = Le === 1 ? this.posY + this.margin[0] : this.margin[0], we = this.pdf.internal.pageSize.height - this.posY - this.margin[0] - this.margin[2], Ge = this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2], ze = Le === 1 ? 0 : we + (Le - 2) * Ge;
        if (this.ctx.clip_path.length !== 0) {
          var Ze = this.path;
          ye = JSON.parse(JSON.stringify(this.ctx.clip_path)), this.path = b(ye, this.posX + this.margin[3], -ze + tt + this.ctx.prevPageLastElemOffset), C.call(this, I, !0), this.path = Ze;
        }
        if (Ce = JSON.parse(JSON.stringify(Ue)), this.path = b(Ce, this.posX + this.margin[3], -ze + tt + this.ctx.prevPageLastElemOffset), G === !1 || Le === 0) {
          var ht = (Le > Be || Le < et) && _.call(this);
          ht && (this.pdf.saveGraphicsState(), this.pdf.rect(this.margin[3], this.margin[0], Fe, Ge, null).clip().discardPath()), C.call(this, I, G), ht && this.pdf.restoreGraphicsState();
        }
        this.lineWidth = le;
      }
      this.path = Ue;
    } else this.lineWidth = me, C.call(this, I, G), this.lineWidth = le;
  }, C = function(I, G) {
    if ((I !== "stroke" || G || !g.call(this)) && (I === "stroke" || G || !d.call(this))) {
      for (var H, Z, ne = [], le = this.path, me = 0; me < le.length; me++) {
        var ce = le[me];
        switch (ce.type) {
          case "begin":
            ne.push({ begin: !0 });
            break;
          case "close":
            ne.push({ close: !0 });
            break;
          case "mt":
            ne.push({ start: ce, deltas: [], abs: [] });
            break;
          case "lt":
            var ye = ne.length;
            if (le[me - 1] && !isNaN(le[me - 1].x) && (H = [ce.x - le[me - 1].x, ce.y - le[me - 1].y], ye > 0)) {
              for (; ye >= 0; ye--) if (ne[ye - 1].close !== !0 && ne[ye - 1].begin !== !0) {
                ne[ye - 1].deltas.push(H), ne[ye - 1].abs.push(ce);
                break;
              }
            }
            break;
          case "bct":
            H = [ce.x1 - le[me - 1].x, ce.y1 - le[me - 1].y, ce.x2 - le[me - 1].x, ce.y2 - le[me - 1].y, ce.x - le[me - 1].x, ce.y - le[me - 1].y], ne[ne.length - 1].deltas.push(H);
            break;
          case "qct":
            var Ce = le[me - 1].x + 2 / 3 * (ce.x1 - le[me - 1].x), Ue = le[me - 1].y + 2 / 3 * (ce.y1 - le[me - 1].y), Qe = ce.x + 2 / 3 * (ce.x1 - ce.x), Xe = ce.y + 2 / 3 * (ce.y1 - ce.y), D = ce.x, Ne = ce.y;
            H = [Ce - le[me - 1].x, Ue - le[me - 1].y, Qe - le[me - 1].x, Xe - le[me - 1].y, D - le[me - 1].x, Ne - le[me - 1].y], ne[ne.length - 1].deltas.push(H);
            break;
          case "arc":
            ne.push({ deltas: [], abs: [], arc: !0 }), Array.isArray(ne[ne.length - 1].abs) && ne[ne.length - 1].abs.push(ce);
        }
      }
      Z = G ? null : I === "stroke" ? "stroke" : "fill";
      for (var ct = !1, ot = 0; ot < ne.length; ot++) if (ne[ot].arc) for (var Be = ne[ot].abs, et = 0; et < Be.length; et++) {
        var Le = Be[et];
        Le.type === "arc" ? F.call(this, Le.x, Le.y, Le.radius, Le.startAngle, Le.endAngle, Le.counterclockwise, void 0, G, !ct) : U.call(this, Le.x, Le.y), ct = !0;
      }
      else if (ne[ot].close === !0) this.pdf.internal.out("h"), ct = !1;
      else if (ne[ot].begin !== !0) {
        var Fe = ne[ot].start.x, tt = ne[ot].start.y;
        O.call(this, ne[ot].deltas, Fe, tt), ct = !0;
      }
      Z && B.call(this, Z), G && P.call(this);
    }
  }, E = function(I) {
    var G = this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor, H = G * (this.pdf.internal.getLineHeightFactor() - 1);
    switch (this.ctx.textBaseline) {
      case "bottom":
        return I - H;
      case "top":
        return I + G - H;
      case "hanging":
        return I + G - 2 * H;
      case "middle":
        return I + G / 2 - H;
      default:
        return I;
    }
  }, T = function(I) {
    return I + this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor * (this.pdf.internal.getLineHeightFactor() - 1);
  };
  A.prototype.createLinearGradient = function() {
    var I = function() {
    };
    return I.colorStops = [], I.addColorStop = function(G, H) {
      this.colorStops.push([G, H]);
    }, I.getColor = function() {
      return this.colorStops.length === 0 ? "#000000" : this.colorStops[0][1];
    }, I.isCanvasGradient = !0, I;
  }, A.prototype.createPattern = function() {
    return this.createLinearGradient();
  }, A.prototype.createRadialGradient = function() {
    return this.createLinearGradient();
  };
  var F = function(I, G, H, Z, ne, le, me, ce, ye) {
    for (var Ce = te.call(this, H, Z, ne, le), Ue = 0; Ue < Ce.length; Ue++) {
      var Qe = Ce[Ue];
      Ue === 0 && (ye ? S.call(this, Qe.x1 + I, Qe.y1 + G) : U.call(this, Qe.x1 + I, Qe.y1 + G)), K.call(this, I, G, Qe.x2, Qe.y2, Qe.x3, Qe.y3, Qe.x4, Qe.y4);
    }
    ce ? P.call(this) : B.call(this, me);
  }, B = function(I) {
    switch (I) {
      case "stroke":
        this.pdf.internal.out("S");
        break;
      case "fill":
        this.pdf.internal.out("f");
    }
  }, P = function() {
    this.pdf.clip(), this.pdf.discardPath();
  }, S = function(I, G) {
    this.pdf.internal.out(t(I) + " " + r(G) + " m");
  }, L = function(I) {
    var G;
    switch (I.align) {
      case "right":
      case "end":
        G = "right";
        break;
      case "center":
        G = "center";
        break;
      default:
        G = "left";
    }
    var H, Z, ne, le = this.pdf.getTextDimensions(I.text), me = E.call(this, I.y), ce = T.call(this, me) - le.h, ye = this.ctx.transform.applyToPoint(new a(I.x, me));
    if (this.autoPaging) {
      var Ce = this.ctx.transform.decompose(), Ue = new l();
      Ue = (Ue = (Ue = Ue.multiply(Ce.translate)).multiply(Ce.skew)).multiply(Ce.scale);
      for (var Qe = this.ctx.transform.applyToRectangle(new s(I.x, me, le.w, le.h)), Xe = Ue.applyToRectangle(new s(I.x, ce, le.w, le.h)), D = f.call(this, Xe), Ne = [], ct = 0; ct < D.length; ct += 1) Ne.indexOf(D[ct]) === -1 && Ne.push(D[ct]);
      v(Ne);
      for (var ot = Ne[0], Be = Ne[Ne.length - 1], et = ot; et < Be + 1; et++) {
        this.pdf.setPage(et);
        var Le = et === 1 ? this.posY + this.margin[0] : this.margin[0], Fe = this.pdf.internal.pageSize.height - this.posY - this.margin[0] - this.margin[2], tt = this.pdf.internal.pageSize.height - this.margin[2], we = tt - this.margin[0], Ge = this.pdf.internal.pageSize.width - this.margin[1], ze = Ge - this.margin[3], Ze = et === 1 ? 0 : Fe + (et - 2) * we;
        if (this.ctx.clip_path.length !== 0) {
          var ht = this.path;
          H = JSON.parse(JSON.stringify(this.ctx.clip_path)), this.path = b(H, this.posX + this.margin[3], -1 * Ze + Le), C.call(this, "fill", !0), this.path = ht;
        }
        var rt = b([JSON.parse(JSON.stringify(Xe))], this.posX + this.margin[3], -Ze + Le + this.ctx.prevPageLastElemOffset)[0];
        I.scale >= 0.01 && (Z = this.pdf.internal.getFontSize(), this.pdf.setFontSize(Z * I.scale), ne = this.lineWidth, this.lineWidth = ne * I.scale);
        var Ct = this.autoPaging !== "text";
        if (Ct || rt.y + rt.h <= tt) {
          if (Ct || rt.y >= Le && rt.x <= Ge) {
            var it = Ct ? I.text : this.pdf.splitTextToSize(I.text, I.maxWidth || Ge - rt.x)[0], Kt = b([JSON.parse(JSON.stringify(Qe))], this.posX + this.margin[3], -Ze + Le + this.ctx.prevPageLastElemOffset)[0], ve = Ct && (et > ot || et < Be) && _.call(this);
            ve && (this.pdf.saveGraphicsState(), this.pdf.rect(this.margin[3], this.margin[0], ze, we, null).clip().discardPath()), this.pdf.text(it, Kt.x, Kt.y, { angle: I.angle, align: G, renderingMode: I.renderingMode }), ve && this.pdf.restoreGraphicsState();
          }
        } else rt.y < tt && (this.ctx.prevPageLastElemOffset += tt - rt.y);
        I.scale >= 0.01 && (this.pdf.setFontSize(Z), this.lineWidth = ne);
      }
    } else I.scale >= 0.01 && (Z = this.pdf.internal.getFontSize(), this.pdf.setFontSize(Z * I.scale), ne = this.lineWidth, this.lineWidth = ne * I.scale), this.pdf.text(I.text, ye.x + this.posX, ye.y + this.posY, { angle: I.angle, align: G, renderingMode: I.renderingMode, maxWidth: I.maxWidth }), I.scale >= 0.01 && (this.pdf.setFontSize(Z), this.lineWidth = ne);
  }, U = function(I, G, H, Z) {
    H = H || 0, Z = Z || 0, this.pdf.internal.out(t(I + H) + " " + r(G + Z) + " l");
  }, O = function(I, G, H) {
    return this.pdf.lines(I, G, H, null, null);
  }, K = function(I, G, H, Z, ne, le, me, ce) {
    this.pdf.internal.out([e(n(H + I)), e(i(Z + G)), e(n(ne + I)), e(i(le + G)), e(n(me + I)), e(i(ce + G)), "c"].join(" "));
  }, te = function(I, G, H, Z) {
    for (var ne = 2 * Math.PI, le = Math.PI / 2; G > H; ) G -= ne;
    var me = Math.abs(H - G);
    me < ne && Z && (me = ne - me);
    for (var ce = [], ye = Z ? -1 : 1, Ce = G; me > 1e-5; ) {
      var Ue = Ce + ye * Math.min(me, le);
      ce.push(Y.call(this, I, Ce, Ue)), me -= Math.abs(Ue - Ce), Ce = Ue;
    }
    return ce;
  }, Y = function(I, G, H) {
    var Z = (H - G) / 2, ne = I * Math.cos(Z), le = I * Math.sin(Z), me = ne, ce = -le, ye = me * me + ce * ce, Ce = ye + me * ne + ce * le, Ue = 4 / 3 * (Math.sqrt(2 * ye * Ce) - Ce) / (me * le - ce * ne), Qe = me - Ue * ce, Xe = ce + Ue * me, D = Qe, Ne = -Xe, ct = Z + G, ot = Math.cos(ct), Be = Math.sin(ct);
    return { x1: I * Math.cos(G), y1: I * Math.sin(G), x2: Qe * ot - Xe * Be, y2: Qe * Be + Xe * ot, x3: D * ot - Ne * Be, y3: D * Be + Ne * ot, x4: I * Math.cos(H), y4: I * Math.sin(H) };
  }, ee = function(I) {
    return 180 * I / Math.PI;
  }, oe = function(I, G, H, Z, ne, le) {
    var me = I + 0.5 * (H - I), ce = G + 0.5 * (Z - G), ye = ne + 0.5 * (H - ne), Ce = le + 0.5 * (Z - le), Ue = Math.min(I, ne, me, ye), Qe = Math.max(I, ne, me, ye), Xe = Math.min(G, le, ce, Ce), D = Math.max(G, le, ce, Ce);
    return new s(Ue, Xe, Qe - Ue, D - Xe);
  }, de = function(I, G, H, Z, ne, le, me, ce) {
    var ye, Ce, Ue, Qe, Xe, D, Ne, ct, ot, Be, et, Le, Fe, tt, we = H - I, Ge = Z - G, ze = ne - H, Ze = le - Z, ht = me - ne, rt = ce - le;
    for (Ce = 0; Ce < 41; Ce++) ot = (Ne = (Ue = I + (ye = Ce / 40) * we) + ye * ((Xe = H + ye * ze) - Ue)) + ye * (Xe + ye * (ne + ye * ht - Xe) - Ne), Be = (ct = (Qe = G + ye * Ge) + ye * ((D = Z + ye * Ze) - Qe)) + ye * (D + ye * (le + ye * rt - D) - ct), Ce == 0 ? (et = ot, Le = Be, Fe = ot, tt = Be) : (et = Math.min(et, ot), Le = Math.min(Le, Be), Fe = Math.max(Fe, ot), tt = Math.max(tt, Be));
    return new s(Math.round(et), Math.round(Le), Math.round(Fe - et), Math.round(tt - Le));
  }, ae = function() {
    if (this.prevLineDash || this.ctx.lineDash.length || this.ctx.lineDashOffset) {
      var I, G, H = (I = this.ctx.lineDash, G = this.ctx.lineDashOffset, JSON.stringify({ lineDash: I, lineDashOffset: G }));
      this.prevLineDash !== H && (this.pdf.setLineDash(this.ctx.lineDash, this.ctx.lineDashOffset), this.prevLineDash = H);
    }
  };
})(Tt.API), /**
* @license
* jsPDF filters PlugIn
* Copyright (c) 2014 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = function(a) {
    var s, l, c, u, A, p, d, g, _, f;
    for (l = [], c = 0, u = (a += s = "\0\0\0\0".slice(a.length % 4 || 4)).length; u > c; c += 4) (A = (a.charCodeAt(c) << 24) + (a.charCodeAt(c + 1) << 16) + (a.charCodeAt(c + 2) << 8) + a.charCodeAt(c + 3)) !== 0 ? (p = (A = ((A = ((A = ((A = (A - (f = A % 85)) / 85) - (_ = A % 85)) / 85) - (g = A % 85)) / 85) - (d = A % 85)) / 85) % 85, l.push(p + 33, d + 33, g + 33, _ + 33, f + 33)) : l.push(122);
    return (function(m, b) {
      for (var v = b; v > 0; v--) m.pop();
    })(l, s.length), String.fromCharCode.apply(String, l) + "~>";
  }, t = function(a) {
    var s, l, c, u, A, p = String, d = "length", g = 255, _ = "charCodeAt", f = "slice", m = "replace";
    for (a[f](-2), a = a[f](0, -2)[m](/\s/g, "")[m]("z", "!!!!!"), c = [], u = 0, A = (a += s = "uuuuu"[f](a[d] % 5 || 5))[d]; A > u; u += 5) l = 52200625 * (a[_](u) - 33) + 614125 * (a[_](u + 1) - 33) + 7225 * (a[_](u + 2) - 33) + 85 * (a[_](u + 3) - 33) + (a[_](u + 4) - 33), c.push(g & l >> 24, g & l >> 16, g & l >> 8, g & l);
    return (function(b, v) {
      for (var w = v; w > 0; w--) b.pop();
    })(c, s[d]), p.fromCharCode.apply(p, c);
  }, r = function(a) {
    return a.split("").map(function(s) {
      return ("0" + s.charCodeAt().toString(16)).slice(-2);
    }).join("") + ">";
  }, n = function(a) {
    var s = new RegExp(/^([0-9A-Fa-f]{2})+$/);
    if ((a = a.replace(/\s/g, "")).indexOf(">") !== -1 && (a = a.substr(0, a.indexOf(">"))), a.length % 2 && (a += "0"), s.test(a) === !1) return "";
    for (var l = "", c = 0; c < a.length; c += 2) l += String.fromCharCode("0x" + (a[c] + a[c + 1]));
    return l;
  }, i = function(a) {
    for (var s = new Uint8Array(a.length), l = a.length; l--; ) s[l] = a.charCodeAt(l);
    return (s = _b(s)).reduce(function(c, u) {
      return c + String.fromCharCode(u);
    }, "");
  };
  o.processDataByFilters = function(a, s) {
    var l = 0, c = a || "", u = [];
    for (typeof (s = s || []) == "string" && (s = [s]), l = 0; l < s.length; l += 1) switch (s[l]) {
      case "ASCII85Decode":
      case "/ASCII85Decode":
        c = t(c), u.push("/ASCII85Encode");
        break;
      case "ASCII85Encode":
      case "/ASCII85Encode":
        c = e(c), u.push("/ASCII85Decode");
        break;
      case "ASCIIHexDecode":
      case "/ASCIIHexDecode":
        c = n(c), u.push("/ASCIIHexEncode");
        break;
      case "ASCIIHexEncode":
      case "/ASCIIHexEncode":
        c = r(c), u.push("/ASCIIHexDecode");
        break;
      case "FlateEncode":
      case "/FlateEncode":
        c = i(c), u.push("/FlateDecode");
        break;
      default:
        throw new Error('The filter: "' + s[l] + '" is not implemented');
    }
    return { data: c, reverseChain: u.reverse().join(" ") };
  };
})(Tt.API), /**
* @license
* jsPDF fileloading PlugIn
* Copyright (c) 2018 Aras Abbasi ([email protected])
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  o.loadFile = function(e, t, r) {
    return (function(n, i, a) {
      i = i !== !1, a = typeof a == "function" ? a : function() {
      };
      var s = void 0;
      try {
        s = (function(l, c, u) {
          var A = new XMLHttpRequest(), p = 0, d = function(g) {
            var _ = g.length, f = [], m = String.fromCharCode;
            for (p = 0; p < _; p += 1) f.push(m(255 & g.charCodeAt(p)));
            return f.join("");
          };
          if (A.open("GET", l, !c), A.overrideMimeType("text/plain; charset=x-user-defined"), c === !1 && (A.onload = function() {
            A.status === 200 ? u(d(this.responseText)) : u(void 0);
          }), A.send(null), c && A.status === 200) return d(A.responseText);
        })(n, i, a);
      } catch {
      }
      return s;
    })(e, t, r);
  }, o.allowFsRead = void 0, o.loadImageFile = o.loadFile;
})(Tt.API), (function(o) {
  function e() {
    return (Gt.html2canvas ? Promise.resolve(Gt.html2canvas) : Promise.resolve().then(() => WH)).catch(function(s) {
      return Promise.reject(new Error("Could not load html2canvas: " + s));
    }).then(function(s) {
      return s.default ? s.default : s;
    });
  }
  function t() {
    return (Gt.DOMPurify ? Promise.resolve(Gt.DOMPurify) : Promise.resolve().then(() => m8)).catch(function(s) {
      return Promise.reject(new Error("Could not load dompurify: " + s));
    }).then(function(s) {
      return s.default ? s.default : s;
    });
  }
  var r = function(s) {
    var l = yr(s);
    return l === "undefined" ? "undefined" : l === "string" || s instanceof String ? "string" : l === "number" || s instanceof Number ? "number" : l === "function" || s instanceof Function ? "function" : s && s.constructor === Array ? "array" : s && s.nodeType === 1 ? "element" : l === "object" ? "object" : "unknown";
  }, n = function(s, l) {
    var c = document.createElement(s);
    for (var u in l.className && (c.className = l.className), l.innerHTML && l.dompurify && (c.innerHTML = l.dompurify.sanitize(l.innerHTML)), l.style) c.style[u] = l.style[u];
    return c;
  }, i = function s(l, c) {
    for (var u = l.nodeType === 3 ? document.createTextNode(l.nodeValue) : l.cloneNode(!1), A = l.firstChild; A; A = A.nextSibling) c !== !0 && A.nodeType === 1 && A.nodeName === "SCRIPT" || u.appendChild(s(A, c));
    return l.nodeType === 1 && (l.nodeName === "CANVAS" ? (u.width = l.width, u.height = l.height, u.getContext("2d").drawImage(l, 0, 0)) : l.nodeName !== "TEXTAREA" && l.nodeName !== "SELECT" || (u.value = l.value), u.addEventListener("load", function() {
      u.scrollTop = l.scrollTop, u.scrollLeft = l.scrollLeft;
    }, !0)), u;
  }, a = function s(l) {
    var c = Object.assign(s.convert(Promise.resolve()), JSON.parse(JSON.stringify(s.template))), u = s.convert(Promise.resolve(), c);
    return (u = u.setProgress(1, s, 1, [s])).set(l);
  };
  (a.prototype = Object.create(Promise.prototype)).constructor = a, a.convert = function(s, l) {
    return s.__proto__ = l || a.prototype, s;
  }, a.template = { prop: { src: null, container: null, overlay: null, canvas: null, img: null, pdf: null, pageSize: null, callback: function() {
  } }, progress: { val: 0, state: null, n: 0, stack: [] }, opt: { filename: "file.pdf", margin: [0, 0, 0, 0], enableLinks: !0, x: 0, y: 0, html2canvas: {}, jsPDF: {}, backgroundColor: "transparent" } }, a.prototype.from = function(s, l) {
    return this.then(function() {
      switch (l = l || (function(c) {
        switch (r(c)) {
          case "string":
            return "string";
          case "element":
            return c.nodeName.toLowerCase() === "canvas" ? "canvas" : "element";
          default:
            return "unknown";
        }
      })(s), l) {
        case "string":
          return this.then(t).then(function(c) {
            return this.set({ src: n("div", { innerHTML: s, dompurify: c }) });
          });
        case "element":
          return this.set({ src: s });
        case "canvas":
          return this.set({ canvas: s });
        case "img":
          return this.set({ img: s });
        default:
          return this.error("Unknown source type.");
      }
    });
  }, a.prototype.to = function(s) {
    switch (s) {
      case "container":
        return this.toContainer();
      case "canvas":
        return this.toCanvas();
      case "img":
        return this.toImg();
      case "pdf":
        return this.toPdf();
      default:
        return this.error("Invalid target.");
    }
  }, a.prototype.toContainer = function() {
    return this.thenList([function() {
      return this.prop.src || this.error("Cannot duplicate - no source HTML.");
    }, function() {
      return this.prop.pageSize || this.setPageSize();
    }]).then(function() {
      var s = { position: "relative", display: "inline-block", width: (typeof this.opt.width != "number" || isNaN(this.opt.width) || typeof this.opt.windowWidth != "number" || isNaN(this.opt.windowWidth) ? Math.max(this.prop.src.clientWidth, this.prop.src.scrollWidth, this.prop.src.offsetWidth) : this.opt.windowWidth) + "px", left: 0, right: 0, top: 0, margin: "auto", backgroundColor: this.opt.backgroundColor }, l = i(this.prop.src, this.opt.html2canvas.javascriptEnabled);
      l.tagName === "BODY" && (s.height = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight) + "px"), this.prop.overlay = n("div", { className: "html2pdf__overlay", style: { position: "fixed", overflow: "hidden", zIndex: 1e3, left: "-100000px", right: 0, bottom: 0, top: 0 } }), this.prop.container = n("div", { className: "html2pdf__container", style: s }), this.prop.container.appendChild(l), this.prop.container.firstChild.appendChild(n("div", { style: { clear: "both", border: "0 none transparent", margin: 0, padding: 0, height: 0 } })), this.prop.container.style.float = "none", this.prop.overlay.appendChild(this.prop.container), document.body.appendChild(this.prop.overlay), this.prop.container.firstChild.style.position = "relative", this.prop.container.height = Math.max(this.prop.container.firstChild.clientHeight, this.prop.container.firstChild.scrollHeight, this.prop.container.firstChild.offsetHeight) + "px";
    });
  }, a.prototype.toCanvas = function() {
    var s = [function() {
      return document.body.contains(this.prop.container) || this.toContainer();
    }];
    return this.thenList(s).then(e).then(function(l) {
      var c = Object.assign({}, this.opt.html2canvas);
      return delete c.onrendered, l(this.prop.container, c);
    }).then(function(l) {
      (this.opt.html2canvas.onrendered || function() {
      })(l), this.prop.canvas = l, document.body.removeChild(this.prop.overlay);
    });
  }, a.prototype.toContext2d = function() {
    var s = [function() {
      return document.body.contains(this.prop.container) || this.toContainer();
    }];
    return this.thenList(s).then(e).then(function(l) {
      var c = this.opt.jsPDF, u = this.opt.fontFaces, A = typeof this.opt.width != "number" || isNaN(this.opt.width) || typeof this.opt.windowWidth != "number" || isNaN(this.opt.windowWidth) ? 1 : this.opt.width / this.opt.windowWidth, p = Object.assign({ async: !0, allowTaint: !0, scale: A, scrollX: this.opt.scrollX || 0, scrollY: this.opt.scrollY || 0, backgroundColor: "#ffffff", imageTimeout: 15e3, logging: !0, proxy: null, removeContainer: !0, foreignObjectRendering: !1, useCORS: !1 }, this.opt.html2canvas);
      if (delete p.onrendered, c.context2d.autoPaging = this.opt.autoPaging === void 0 || this.opt.autoPaging, c.context2d.posX = this.opt.x, c.context2d.posY = this.opt.y, c.context2d.margin = this.opt.margin, c.context2d.fontFaces = u, u) for (var d = 0; d < u.length; ++d) {
        var g = u[d], _ = g.src.find(function(f) {
          return f.format === "truetype";
        });
        _ && c.addFont(_.url, g.ref.name, g.ref.style);
      }
      return p.windowHeight = p.windowHeight || 0, p.windowHeight = p.windowHeight == 0 ? Math.max(this.prop.container.clientHeight, this.prop.container.scrollHeight, this.prop.container.offsetHeight) : p.windowHeight, c.context2d.save(!0), l(this.prop.container, p);
    }).then(function(l) {
      this.opt.jsPDF.context2d.restore(!0), (this.opt.html2canvas.onrendered || function() {
      })(l), this.prop.canvas = l, document.body.removeChild(this.prop.overlay);
    });
  }, a.prototype.toImg = function() {
    return this.thenList([function() {
      return this.prop.canvas || this.toCanvas();
    }]).then(function() {
      var s = this.prop.canvas.toDataURL("image/" + this.opt.image.type, this.opt.image.quality);
      this.prop.img = document.createElement("img"), this.prop.img.src = s;
    });
  }, a.prototype.toPdf = function() {
    return this.thenList([function() {
      return this.toContext2d();
    }]).then(function() {
      this.prop.pdf = this.prop.pdf || this.opt.jsPDF;
    });
  }, a.prototype.output = function(s, l, c) {
    return (c = c || "pdf").toLowerCase() === "img" || c.toLowerCase() === "image" ? this.outputImg(s, l) : this.outputPdf(s, l);
  }, a.prototype.outputPdf = function(s, l) {
    return this.thenList([function() {
      return this.prop.pdf || this.toPdf();
    }]).then(function() {
      return this.prop.pdf.output(s, l);
    });
  }, a.prototype.outputImg = function(s) {
    return this.thenList([function() {
      return this.prop.img || this.toImg();
    }]).then(function() {
      switch (s) {
        case void 0:
        case "img":
          return this.prop.img;
        case "datauristring":
        case "dataurlstring":
          return this.prop.img.src;
        case "datauri":
        case "dataurl":
          return document.location.href = this.prop.img.src;
        default:
          throw 'Image output type "' + s + '" is not supported.';
      }
    });
  }, a.prototype.save = function(s) {
    return this.thenList([function() {
      return this.prop.pdf || this.toPdf();
    }]).set(s ? { filename: s } : null).then(function() {
      this.prop.pdf.save(this.opt.filename);
    });
  }, a.prototype.doCallback = function() {
    return this.thenList([function() {
      return this.prop.pdf || this.toPdf();
    }]).then(function() {
      this.prop.callback(this.prop.pdf);
    });
  }, a.prototype.set = function(s) {
    if (r(s) !== "object") return this;
    var l = Object.keys(s || {}).map(function(c) {
      if (c in a.template.prop) return function() {
        this.prop[c] = s[c];
      };
      switch (c) {
        case "margin":
          return this.setMargin.bind(this, s.margin);
        case "jsPDF":
          return function() {
            return this.opt.jsPDF = s.jsPDF, this.setPageSize();
          };
        case "pageSize":
          return this.setPageSize.bind(this, s.pageSize);
        default:
          return function() {
            this.opt[c] = s[c];
          };
      }
    }, this);
    return this.then(function() {
      return this.thenList(l);
    });
  }, a.prototype.get = function(s, l) {
    return this.then(function() {
      var c = s in a.template.prop ? this.prop[s] : this.opt[s];
      return l ? l(c) : c;
    });
  }, a.prototype.setMargin = function(s) {
    return this.then(function() {
      switch (r(s)) {
        case "number":
          s = [s, s, s, s];
        case "array":
          if (s.length === 2 && (s = [s[0], s[1], s[0], s[1]]), s.length === 4) break;
        default:
          return this.error("Invalid margin array.");
      }
      this.opt.margin = s;
    }).then(this.setPageSize);
  }, a.prototype.setPageSize = function(s) {
    function l(c, u) {
      return Math.floor(c * u / 72 * 96);
    }
    return this.then(function() {
      (s = s || Tt.getPageSize(this.opt.jsPDF)).hasOwnProperty("inner") || (s.inner = { width: s.width - this.opt.margin[1] - this.opt.margin[3], height: s.height - this.opt.margin[0] - this.opt.margin[2] }, s.inner.px = { width: l(s.inner.width, s.k), height: l(s.inner.height, s.k) }, s.inner.ratio = s.inner.height / s.inner.width), this.prop.pageSize = s;
    });
  }, a.prototype.setProgress = function(s, l, c, u) {
    return s != null && (this.progress.val = s), l != null && (this.progress.state = l), c != null && (this.progress.n = c), u != null && (this.progress.stack = u), this.progress.ratio = this.progress.val / this.progress.state, this;
  }, a.prototype.updateProgress = function(s, l, c, u) {
    return this.setProgress(s ? this.progress.val + s : null, l || null, c ? this.progress.n + c : null, u ? this.progress.stack.concat(u) : null);
  }, a.prototype.then = function(s, l) {
    var c = this;
    return this.thenCore(s, l, function(u, A) {
      return c.updateProgress(null, null, 1, [u]), Promise.prototype.then.call(this, function(p) {
        return c.updateProgress(null, u), p;
      }).then(u, A).then(function(p) {
        return c.updateProgress(1), p;
      });
    });
  }, a.prototype.thenCore = function(s, l, c) {
    c = c || Promise.prototype.then;
    var u = this;
    s && (s = s.bind(u)), l && (l = l.bind(u));
    var A = Promise.toString().indexOf("[native code]") !== -1 && Promise.name === "Promise" ? u : a.convert(Object.assign({}, u), Promise.prototype), p = c.call(A, s, l);
    return a.convert(p, u.__proto__);
  }, a.prototype.thenExternal = function(s, l) {
    return Promise.prototype.then.call(this, s, l);
  }, a.prototype.thenList = function(s) {
    var l = this;
    return s.forEach(function(c) {
      l = l.thenCore(c);
    }), l;
  }, a.prototype.catch = function(s) {
    s && (s = s.bind(this));
    var l = Promise.prototype.catch.call(this, s);
    return a.convert(l, this);
  }, a.prototype.catchExternal = function(s) {
    return Promise.prototype.catch.call(this, s);
  }, a.prototype.error = function(s) {
    return this.then(function() {
      throw new Error(s);
    });
  }, a.prototype.using = a.prototype.set, a.prototype.saveAs = a.prototype.save, a.prototype.export = a.prototype.output, a.prototype.run = a.prototype.then, Tt.getPageSize = function(s, l, c) {
    if (yr(s) === "object") {
      var u = s;
      s = u.orientation, l = u.unit || l, c = u.format || c;
    }
    l = l || "mm", c = c || "a4", s = ("" + (s || "P")).toLowerCase();
    var A, p = ("" + c).toLowerCase(), d = { a0: [2383.94, 3370.39], a1: [1683.78, 2383.94], a2: [1190.55, 1683.78], a3: [841.89, 1190.55], a4: [595.28, 841.89], a5: [419.53, 595.28], a6: [297.64, 419.53], a7: [209.76, 297.64], a8: [147.4, 209.76], a9: [104.88, 147.4], a10: [73.7, 104.88], b0: [2834.65, 4008.19], b1: [2004.09, 2834.65], b2: [1417.32, 2004.09], b3: [1000.63, 1417.32], b4: [708.66, 1000.63], b5: [498.9, 708.66], b6: [354.33, 498.9], b7: [249.45, 354.33], b8: [175.75, 249.45], b9: [124.72, 175.75], b10: [87.87, 124.72], c0: [2599.37, 3676.54], c1: [1836.85, 2599.37], c2: [1298.27, 1836.85], c3: [918.43, 1298.27], c4: [649.13, 918.43], c5: [459.21, 649.13], c6: [323.15, 459.21], c7: [229.61, 323.15], c8: [161.57, 229.61], c9: [113.39, 161.57], c10: [79.37, 113.39], dl: [311.81, 623.62], letter: [612, 792], "government-letter": [576, 756], legal: [612, 1008], "junior-legal": [576, 360], ledger: [1224, 792], tabloid: [792, 1224], "credit-card": [153, 243] };
    switch (l) {
      case "pt":
        A = 1;
        break;
      case "mm":
        A = 72 / 25.4;
        break;
      case "cm":
        A = 72 / 2.54;
        break;
      case "in":
        A = 72;
        break;
      case "px":
        A = 0.75;
        break;
      case "pc":
      case "em":
        A = 12;
        break;
      case "ex":
        A = 6;
        break;
      default:
        throw "Invalid unit: " + l;
    }
    var g, _ = 0, f = 0;
    if (d.hasOwnProperty(p)) _ = d[p][1] / A, f = d[p][0] / A;
    else try {
      _ = c[1], f = c[0];
    } catch {
      throw new Error("Invalid format: " + c);
    }
    if (s === "p" || s === "portrait") s = "p", f > _ && (g = f, f = _, _ = g);
    else {
      if (s !== "l" && s !== "landscape") throw "Invalid orientation: " + s;
      s = "l", _ > f && (g = f, f = _, _ = g);
    }
    return { width: f, height: _, unit: l, k: A, orientation: s };
  }, o.html = function(s, l) {
    (l = l || {}).callback = l.callback || function() {
    }, l.html2canvas = l.html2canvas || {}, l.html2canvas.canvas = l.html2canvas.canvas || this.canvas, l.jsPDF = l.jsPDF || this, l.fontFaces = l.fontFaces ? l.fontFaces.map(U_) : null;
    var c = new a(l);
    return l.worker ? c : c.from(s).doCallback();
  };
})(Tt.API), Tt.API.addJS = function(o) {
  return Jx = o, this.internal.events.subscribe("postPutResources", function() {
    up = this.internal.newObject(), this.internal.out("<<"), this.internal.out("/Names [(EmbeddedJS) " + (up + 1) + " 0 R]"), this.internal.out(">>"), this.internal.out("endobj"), Zx = this.internal.newObject(), this.internal.out("<<"), this.internal.out("/S /JavaScript"), this.internal.out("/JS (" + Jx + ")"), this.internal.out(">>"), this.internal.out("endobj");
  }), this.internal.events.subscribe("putCatalog", function() {
    up !== void 0 && Zx !== void 0 && this.internal.out("/Names <</JavaScript " + up + " 0 R>>");
  }), this;
}, /**
* @license
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC)  [email protected]
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e;
  o.events.push(["postPutResources", function() {
    var t = this, r = /^(\d+) 0 obj$/;
    if (this.outline.root.children.length > 0) for (var n = t.outline.render().split(/\r\n/), i = 0; i < n.length; i++) {
      var a = n[i], s = r.exec(a);
      if (s != null) {
        var l = s[1];
        t.internal.newObjectDeferredBegin(l, !1);
      }
      t.internal.write(a);
    }
    if (this.outline.createNamedDestinations) {
      var c = this.internal.pages.length, u = [];
      for (i = 0; i < c; i++) {
        var A = t.internal.newObject();
        u.push(A);
        var p = t.internal.getPageInfo(i + 1);
        t.internal.write("<< /D[" + p.objId + " 0 R /XYZ null null null]>> endobj");
      }
      var d = t.internal.newObject();
      for (t.internal.write("<< /Names [ "), i = 0; i < u.length; i++) t.internal.write("(page_" + (i + 1) + ")" + u[i] + " 0 R");
      t.internal.write(" ] >>", "endobj"), e = t.internal.newObject(), t.internal.write("<< /Dests " + d + " 0 R"), t.internal.write(">>", "endobj");
    }
  }]), o.events.push(["putCatalog", function() {
    var t = this;
    t.outline.root.children.length > 0 && (t.internal.write("/Outlines", this.outline.makeRef(this.outline.root)), this.outline.createNamedDestinations && t.internal.write("/Names " + e + " 0 R"));
  }]), o.events.push(["initialized", function() {
    var t = this;
    t.outline = { createNamedDestinations: !1, root: { children: [] } }, t.outline.add = function(r, n, i) {
      var a = { title: n, options: i, children: [] };
      return r == null && (r = this.root), r.children.push(a), a;
    }, t.outline.render = function() {
      return this.ctx = {}, this.ctx.val = "", this.ctx.pdf = t, this.genIds_r(this.root), this.renderRoot(this.root), this.renderItems(this.root), this.ctx.val;
    }, t.outline.genIds_r = function(r) {
      r.id = t.internal.newObjectDeferred();
      for (var n = 0; n < r.children.length; n++) this.genIds_r(r.children[n]);
    }, t.outline.renderRoot = function(r) {
      this.objStart(r), this.line("/Type /Outlines"), r.children.length > 0 && (this.line("/First " + this.makeRef(r.children[0])), this.line("/Last " + this.makeRef(r.children[r.children.length - 1]))), this.line("/Count " + this.count_r({ count: 0 }, r)), this.objEnd();
    }, t.outline.renderItems = function(r) {
      for (var n = this.ctx.pdf.internal.getVerticalCoordinateString, i = 0; i < r.children.length; i++) {
        var a = r.children[i];
        this.objStart(a), this.line("/Title " + this.makeString(a.title)), this.line("/Parent " + this.makeRef(r)), i > 0 && this.line("/Prev " + this.makeRef(r.children[i - 1])), i < r.children.length - 1 && this.line("/Next " + this.makeRef(r.children[i + 1])), a.children.length > 0 && (this.line("/First " + this.makeRef(a.children[0])), this.line("/Last " + this.makeRef(a.children[a.children.length - 1])));
        var s = this.count = this.count_r({ count: 0 }, a);
        if (s > 0 && this.line("/Count " + s), a.options && a.options.pageNumber) {
          var l = t.internal.getPageInfo(a.options.pageNumber);
          this.line("/Dest [" + l.objId + " 0 R /XYZ 0 " + n(0) + " 0]");
        }
        this.objEnd();
      }
      for (var c = 0; c < r.children.length; c++) this.renderItems(r.children[c]);
    }, t.outline.line = function(r) {
      this.ctx.val += r + `\r
`;
    }, t.outline.makeRef = function(r) {
      return r.id + " 0 R";
    }, t.outline.makeString = function(r) {
      return "(" + t.internal.pdfEscape(r) + ")";
    }, t.outline.objStart = function(r) {
      this.ctx.val += `\r
` + r.id + ` 0 obj\r
<<\r
`;
    }, t.outline.objEnd = function() {
      this.ctx.val += `>> \r
endobj\r
`;
    }, t.outline.count_r = function(r, n) {
      for (var i = 0; i < n.children.length; i++) r.count++, this.count_r(r, n.children[i]);
      return r.count;
    };
  }]);
})(Tt.API), /**
* @license
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = [192, 193, 194, 195, 196, 197, 198, 199];
  o.processJPEG = function(t, r, n, i, a, s) {
    var l, c = this.decode.DCT_DECODE, u = null;
    if (typeof t == "string" || this.__addimage__.isArrayBuffer(t) || this.__addimage__.isArrayBufferView(t)) {
      switch (t = a || t, t = this.__addimage__.isArrayBuffer(t) ? new Uint8Array(t) : t, l = (function(A) {
        for (var p, d = 256 * A.charCodeAt(4) + A.charCodeAt(5), g = A.length, _ = { width: 0, height: 0, numcomponents: 1 }, f = 4; f < g; f += 2) {
          if (f += d, e.indexOf(A.charCodeAt(f + 1)) !== -1) {
            p = 256 * A.charCodeAt(f + 5) + A.charCodeAt(f + 6), _ = { width: 256 * A.charCodeAt(f + 7) + A.charCodeAt(f + 8), height: p, numcomponents: A.charCodeAt(f + 9) };
            break;
          }
          d = 256 * A.charCodeAt(f + 2) + A.charCodeAt(f + 3);
        }
        return _;
      })(t = this.__addimage__.isArrayBufferView(t) ? this.__addimage__.arrayBufferToBinaryString(t) : t), l.numcomponents) {
        case 1:
          s = this.color_spaces.DEVICE_GRAY;
          break;
        case 4:
          s = this.color_spaces.DEVICE_CMYK;
          break;
        case 3:
          s = this.color_spaces.DEVICE_RGB;
      }
      u = { data: t, width: l.width, height: l.height, colorSpace: s, bitsPerComponent: 8, filter: c, index: r, alias: n };
    }
    return u;
  };
})(Tt.API), Tt.API.processPNG = function(o, e, t, r) {
  if (this.__addimage__.isArrayBuffer(o) && (o = new Uint8Array(o)), this.__addimage__.isArrayBufferView(o)) {
    var n, i = FO(o, { checkCrc: !0 }), a = i.width, s = i.height, l = i.channels, c = i.palette, u = i.depth;
    n = c && l === 1 ? (function(F) {
      for (var B = F.width, P = F.height, S = F.data, L = F.palette, U = F.depth, O = !1, K = [], te = [], Y = void 0, ee = !1, oe = 0, de = 0; de < L.length; de++) {
        var ae = ox(L[de], 4), I = ae[0], G = ae[1], H = ae[2], Z = ae[3];
        K.push(I, G, H), Z != null && (Z === 0 ? (oe++, te.length < 1 && te.push(de)) : Z < 255 && (ee = !0));
      }
      if (ee || oe > 1) {
        O = !0, te = void 0;
        var ne = B * P;
        Y = new Uint8Array(ne);
        for (var le = new DataView(S.buffer), me = 0; me < ne; me++) {
          var ce = N_(le, me, U), ye = ox(L[ce], 4)[3];
          Y[me] = ye;
        }
      } else oe === 0 && (te = void 0);
      return { colorSpace: "Indexed", colorsPerPixel: 1, sMaskBitsPerComponent: O ? 8 : void 0, colorBytes: S, alphaBytes: Y, needSMask: O, palette: K, mask: te };
    })(i) : l === 2 || l === 4 ? (function(F) {
      for (var B = F.data, P = F.width, S = F.height, L = F.channels, U = F.depth, O = L === 2 ? "DeviceGray" : "DeviceRGB", K = L - 1, te = P * S, Y = K, ee = te * Y, oe = 1 * te, de = Math.ceil(ee * U / 8), ae = Math.ceil(oe * U / 8), I = new Uint8Array(de), G = new Uint8Array(ae), H = new DataView(B.buffer), Z = new DataView(I.buffer), ne = new DataView(G.buffer), le = !1, me = 0; me < te; me++) {
        for (var ce = me * L, ye = 0; ye < Y; ye++) c1(Z, N_(H, ce + ye, U), me * Y + ye, U);
        var Ce = N_(H, ce + Y, U);
        Ce < (1 << U) - 1 && (le = !0), c1(ne, Ce, 1 * me, U);
      }
      return { colorSpace: O, colorsPerPixel: K, sMaskBitsPerComponent: le ? U : void 0, colorBytes: I, alphaBytes: G, needSMask: le };
    })(i) : (function(F) {
      var B = F.data, P = F.channels === 1 ? "DeviceGray" : "DeviceRGB";
      return { colorSpace: P, colorsPerPixel: P === "DeviceGray" ? 1 : 3, colorBytes: B instanceof Uint16Array ? (function(S) {
        for (var L = S.length, U = new Uint8Array(2 * L), O = new DataView(U.buffer, U.byteOffset, U.byteLength), K = 0; K < L; K++) O.setUint16(2 * K, S[K], !1);
        return U;
      })(B) : B, needSMask: !1 };
    })(i);
    var A, p, d, g = n, _ = g.colorSpace, f = g.colorsPerPixel, m = g.sMaskBitsPerComponent, b = g.colorBytes, v = g.alphaBytes, w = g.needSMask, C = g.palette, E = g.mask, T = null;
    return r !== Tt.API.image_compression.NONE && typeof _b == "function" ? (T = (function(F) {
      var B;
      switch (F) {
        case Tt.API.image_compression.FAST:
          B = 11;
          break;
        case Tt.API.image_compression.MEDIUM:
          B = 13;
          break;
        case Tt.API.image_compression.SLOW:
          B = 14;
          break;
        default:
          B = 12;
      }
      return B;
    })(r), A = this.decode.FLATE_DECODE, p = "/Predictor ".concat(T, " /Colors ").concat(f, " /BitsPerComponent ").concat(u, " /Columns ").concat(a), o = n1(b, Math.ceil(a * f * u / 8), f, u, r), w && (d = n1(v, Math.ceil(a * m / 8), 1, m, r))) : (A = void 0, p = void 0, o = b, w && (d = v)), (this.__addimage__.isArrayBuffer(o) || this.__addimage__.isArrayBufferView(o)) && (o = this.__addimage__.arrayBufferToBinaryString(o)), (d && this.__addimage__.isArrayBuffer(d) || this.__addimage__.isArrayBufferView(d)) && (d = this.__addimage__.arrayBufferToBinaryString(d)), { alias: t, data: o, index: e, filter: A, decodeParameters: p, transparency: E, palette: C, sMask: d, predictor: T, width: a, height: s, bitsPerComponent: u, sMaskBitsPerComponent: m, colorSpace: _ };
  }
}, (function(o) {
  o.processGIF89A = function(e, t, r, n) {
    var i = new eQ(e), a = i.width, s = i.height, l = [];
    i.decodeAndBlitFrameRGBA(0, l);
    var c = { data: l, width: a, height: s }, u = new I_(100).encode(c, 100);
    return o.processJPEG.call(this, u, t, r, n);
  }, o.processGIF87A = o.processGIF89A;
})(Tt.API), ji.prototype.parseHeader = function() {
  if (this.fileSize = this.datav.getUint32(this.pos, !0), this.pos += 4, this.reserved = this.datav.getUint32(this.pos, !0), this.pos += 4, this.offset = this.datav.getUint32(this.pos, !0), this.pos += 4, this.headerSize = this.datav.getUint32(this.pos, !0), this.pos += 4, this.width = this.datav.getUint32(this.pos, !0), this.pos += 4, this.height = this.datav.getInt32(this.pos, !0), this.pos += 4, this.planes = this.datav.getUint16(this.pos, !0), this.pos += 2, this.bitPP = this.datav.getUint16(this.pos, !0), this.pos += 2, this.compress = this.datav.getUint32(this.pos, !0), this.pos += 4, this.rawSize = this.datav.getUint32(this.pos, !0), this.pos += 4, this.hr = this.datav.getUint32(this.pos, !0), this.pos += 4, this.vr = this.datav.getUint32(this.pos, !0), this.pos += 4, this.colors = this.datav.getUint32(this.pos, !0), this.pos += 4, this.importantColors = this.datav.getUint32(this.pos, !0), this.pos += 4, this.bitPP === 16 && this.is_with_alpha && (this.bitPP = 15), this.bitPP < 15) {
    var o = this.colors === 0 ? 1 << this.bitPP : this.colors;
    this.palette = new Array(o);
    for (var e = 0; e < o; e++) {
      var t = this.datav.getUint8(this.pos++, !0), r = this.datav.getUint8(this.pos++, !0), n = this.datav.getUint8(this.pos++, !0), i = this.datav.getUint8(this.pos++, !0);
      this.palette[e] = { red: n, green: r, blue: t, quad: i };
    }
  }
  this.height < 0 && (this.height *= -1, this.bottom_up = !1);
}, ji.prototype.parseBGR = function() {
  this.pos = this.offset;
  try {
    var o = "bit" + this.bitPP, e = this.width * this.height * 4;
    this.data = new Uint8Array(e), this[o]();
  } catch (t) {
    Or.log("bit decode error:" + t);
  }
}, ji.prototype.bit1 = function() {
  var o, e = Math.ceil(this.width / 8), t = e % 4;
  for (o = this.height - 1; o >= 0; o--) {
    for (var r = this.bottom_up ? o : this.height - 1 - o, n = 0; n < e; n++) for (var i = this.datav.getUint8(this.pos++, !0), a = r * this.width * 4 + 8 * n * 4, s = 0; s < 8 && 8 * n + s < this.width; s++) {
      var l = this.palette[i >> 7 - s & 1];
      this.data[a + 4 * s] = l.blue, this.data[a + 4 * s + 1] = l.green, this.data[a + 4 * s + 2] = l.red, this.data[a + 4 * s + 3] = 255;
    }
    t !== 0 && (this.pos += 4 - t);
  }
}, ji.prototype.bit4 = function() {
  for (var o = Math.ceil(this.width / 2), e = o % 4, t = this.height - 1; t >= 0; t--) {
    for (var r = this.bottom_up ? t : this.height - 1 - t, n = 0; n < o; n++) {
      var i = this.datav.getUint8(this.pos++, !0), a = r * this.width * 4 + 2 * n * 4, s = i >> 4, l = 15 & i, c = this.palette[s];
      if (this.data[a] = c.blue, this.data[a + 1] = c.green, this.data[a + 2] = c.red, this.data[a + 3] = 255, 2 * n + 1 >= this.width) break;
      c = this.palette[l], this.data[a + 4] = c.blue, this.data[a + 4 + 1] = c.green, this.data[a + 4 + 2] = c.red, this.data[a + 4 + 3] = 255;
    }
    e !== 0 && (this.pos += 4 - e);
  }
}, ji.prototype.bit8 = function() {
  for (var o = this.width % 4, e = this.height - 1; e >= 0; e--) {
    for (var t = this.bottom_up ? e : this.height - 1 - e, r = 0; r < this.width; r++) {
      var n = this.datav.getUint8(this.pos++, !0), i = t * this.width * 4 + 4 * r;
      if (n < this.palette.length) {
        var a = this.palette[n];
        this.data[i] = a.red, this.data[i + 1] = a.green, this.data[i + 2] = a.blue, this.data[i + 3] = 255;
      } else this.data[i] = 255, this.data[i + 1] = 255, this.data[i + 2] = 255, this.data[i + 3] = 255;
    }
    o !== 0 && (this.pos += 4 - o);
  }
}, ji.prototype.bit15 = function() {
  for (var o = this.width % 3, e = parseInt("11111", 2), t = this.height - 1; t >= 0; t--) {
    for (var r = this.bottom_up ? t : this.height - 1 - t, n = 0; n < this.width; n++) {
      var i = this.datav.getUint16(this.pos, !0);
      this.pos += 2;
      var a = (i & e) / e * 255 | 0, s = (i >> 5 & e) / e * 255 | 0, l = (i >> 10 & e) / e * 255 | 0, c = i >> 15 ? 255 : 0, u = r * this.width * 4 + 4 * n;
      this.data[u] = l, this.data[u + 1] = s, this.data[u + 2] = a, this.data[u + 3] = c;
    }
    this.pos += o;
  }
}, ji.prototype.bit16 = function() {
  for (var o = this.width % 3, e = parseInt("11111", 2), t = parseInt("111111", 2), r = this.height - 1; r >= 0; r--) {
    for (var n = this.bottom_up ? r : this.height - 1 - r, i = 0; i < this.width; i++) {
      var a = this.datav.getUint16(this.pos, !0);
      this.pos += 2;
      var s = (a & e) / e * 255 | 0, l = (a >> 5 & t) / t * 255 | 0, c = (a >> 11) / e * 255 | 0, u = n * this.width * 4 + 4 * i;
      this.data[u] = c, this.data[u + 1] = l, this.data[u + 2] = s, this.data[u + 3] = 255;
    }
    this.pos += o;
  }
}, ji.prototype.bit24 = function() {
  for (var o = this.height - 1; o >= 0; o--) {
    for (var e = this.bottom_up ? o : this.height - 1 - o, t = 0; t < this.width; t++) {
      var r = this.datav.getUint8(this.pos++, !0), n = this.datav.getUint8(this.pos++, !0), i = this.datav.getUint8(this.pos++, !0), a = e * this.width * 4 + 4 * t;
      this.data[a] = i, this.data[a + 1] = n, this.data[a + 2] = r, this.data[a + 3] = 255;
    }
    this.pos += this.width % 4;
  }
}, ji.prototype.bit32 = function() {
  for (var o = this.height - 1; o >= 0; o--) for (var e = this.bottom_up ? o : this.height - 1 - o, t = 0; t < this.width; t++) {
    var r = this.datav.getUint8(this.pos++, !0), n = this.datav.getUint8(this.pos++, !0), i = this.datav.getUint8(this.pos++, !0), a = this.datav.getUint8(this.pos++, !0), s = e * this.width * 4 + 4 * t;
    this.data[s] = i, this.data[s + 1] = n, this.data[s + 2] = r, this.data[s + 3] = a;
  }
}, ji.prototype.getData = function() {
  return this.data;
}, /**
* @license
* Copyright (c) 2018 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  o.processBMP = function(e, t, r, n) {
    var i = new ji(e, !1), a = i.width, s = i.height, l = { data: i.getData(), width: a, height: s }, c = new I_(100).encode(l, 100);
    return o.processJPEG.call(this, c, t, r, n);
  };
})(Tt.API), A1.prototype.getData = function() {
  return this.data;
}, /**
* @license
* Copyright (c) 2019 Aras Abbasi
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  o.processWEBP = function(e, t, r, n) {
    var i = new A1(e), a = i.width, s = i.height, l = { data: i.getData(), width: a, height: s }, c = new I_(100).encode(l, 100);
    return o.processJPEG.call(this, c, t, r, n);
  };
})(Tt.API), Tt.API.processRGBA = function(o, e, t) {
  for (var r = o.data, n = r.length, i = new Uint8Array(n / 4 * 3), a = new Uint8Array(n / 4), s = 0, l = 0, c = 0; c < n; c += 4) {
    var u = r[c], A = r[c + 1], p = r[c + 2], d = r[c + 3];
    i[s++] = u, i[s++] = A, i[s++] = p, a[l++] = d;
  }
  var g = this.__addimage__.arrayBufferToBinaryString(i);
  return { alpha: this.__addimage__.arrayBufferToBinaryString(a), data: g, index: e, alias: t, colorSpace: "DeviceRGB", bitsPerComponent: 8, width: o.width, height: o.height };
}, Tt.API.setLanguage = function(o) {
  return this.internal.languageSettings === void 0 && (this.internal.languageSettings = {}, this.internal.languageSettings.isSubscribed = !1), { af: "Afrikaans", sq: "Albanian", ar: "Arabic (Standard)", "ar-DZ": "Arabic (Algeria)", "ar-BH": "Arabic (Bahrain)", "ar-EG": "Arabic (Egypt)", "ar-IQ": "Arabic (Iraq)", "ar-JO": "Arabic (Jordan)", "ar-KW": "Arabic (Kuwait)", "ar-LB": "Arabic (Lebanon)", "ar-LY": "Arabic (Libya)", "ar-MA": "Arabic (Morocco)", "ar-OM": "Arabic (Oman)", "ar-QA": "Arabic (Qatar)", "ar-SA": "Arabic (Saudi Arabia)", "ar-SY": "Arabic (Syria)", "ar-TN": "Arabic (Tunisia)", "ar-AE": "Arabic (U.A.E.)", "ar-YE": "Arabic (Yemen)", an: "Aragonese", hy: "Armenian", as: "Assamese", ast: "Asturian", az: "Azerbaijani", eu: "Basque", be: "Belarusian", bn: "Bengali", bs: "Bosnian", br: "Breton", bg: "Bulgarian", my: "Burmese", ca: "Catalan", ch: "Chamorro", ce: "Chechen", zh: "Chinese", "zh-HK": "Chinese (Hong Kong)", "zh-CN": "Chinese (PRC)", "zh-SG": "Chinese (Singapore)", "zh-TW": "Chinese (Taiwan)", cv: "Chuvash", co: "Corsican", cr: "Cree", hr: "Croatian", cs: "Czech", da: "Danish", nl: "Dutch (Standard)", "nl-BE": "Dutch (Belgian)", en: "English", "en-AU": "English (Australia)", "en-BZ": "English (Belize)", "en-CA": "English (Canada)", "en-IE": "English (Ireland)", "en-JM": "English (Jamaica)", "en-NZ": "English (New Zealand)", "en-PH": "English (Philippines)", "en-ZA": "English (South Africa)", "en-TT": "English (Trinidad & Tobago)", "en-GB": "English (United Kingdom)", "en-US": "English (United States)", "en-ZW": "English (Zimbabwe)", eo: "Esperanto", et: "Estonian", fo: "Faeroese", fj: "Fijian", fi: "Finnish", fr: "French (Standard)", "fr-BE": "French (Belgium)", "fr-CA": "French (Canada)", "fr-FR": "French (France)", "fr-LU": "French (Luxembourg)", "fr-MC": "French (Monaco)", "fr-CH": "French (Switzerland)", fy: "Frisian", fur: "Friulian", gd: "Gaelic (Scots)", "gd-IE": "Gaelic (Irish)", gl: "Galacian", ka: "Georgian", de: "German (Standard)", "de-AT": "German (Austria)", "de-DE": "German (Germany)", "de-LI": "German (Liechtenstein)", "de-LU": "German (Luxembourg)", "de-CH": "German (Switzerland)", el: "Greek", gu: "Gujurati", ht: "Haitian", he: "Hebrew", hi: "Hindi", hu: "Hungarian", is: "Icelandic", id: "Indonesian", iu: "Inuktitut", ga: "Irish", it: "Italian (Standard)", "it-CH": "Italian (Switzerland)", ja: "Japanese", kn: "Kannada", ks: "Kashmiri", kk: "Kazakh", km: "Khmer", ky: "Kirghiz", tlh: "Klingon", ko: "Korean", "ko-KP": "Korean (North Korea)", "ko-KR": "Korean (South Korea)", la: "Latin", lv: "Latvian", lt: "Lithuanian", lb: "Luxembourgish", mk: "North Macedonia", ms: "Malay", ml: "Malayalam", mt: "Maltese", mi: "Maori", mr: "Marathi", mo: "Moldavian", nv: "Navajo", ng: "Ndonga", ne: "Nepali", no: "Norwegian", nb: "Norwegian (Bokmal)", nn: "Norwegian (Nynorsk)", oc: "Occitan", or: "Oriya", om: "Oromo", fa: "Persian", "fa-IR": "Persian/Iran", pl: "Polish", pt: "Portuguese", "pt-BR": "Portuguese (Brazil)", pa: "Punjabi", "pa-IN": "Punjabi (India)", "pa-PK": "Punjabi (Pakistan)", qu: "Quechua", rm: "Rhaeto-Romanic", ro: "Romanian", "ro-MO": "Romanian (Moldavia)", ru: "Russian", "ru-MO": "Russian (Moldavia)", sz: "Sami (Lappish)", sg: "Sango", sa: "Sanskrit", sc: "Sardinian", sd: "Sindhi", si: "Singhalese", sr: "Serbian", sk: "Slovak", sl: "Slovenian", so: "Somani", sb: "Sorbian", es: "Spanish", "es-AR": "Spanish (Argentina)", "es-BO": "Spanish (Bolivia)", "es-CL": "Spanish (Chile)", "es-CO": "Spanish (Colombia)", "es-CR": "Spanish (Costa Rica)", "es-DO": "Spanish (Dominican Republic)", "es-EC": "Spanish (Ecuador)", "es-SV": "Spanish (El Salvador)", "es-GT": "Spanish (Guatemala)", "es-HN": "Spanish (Honduras)", "es-MX": "Spanish (Mexico)", "es-NI": "Spanish (Nicaragua)", "es-PA": "Spanish (Panama)", "es-PY": "Spanish (Paraguay)", "es-PE": "Spanish (Peru)", "es-PR": "Spanish (Puerto Rico)", "es-ES": "Spanish (Spain)", "es-UY": "Spanish (Uruguay)", "es-VE": "Spanish (Venezuela)", sx: "Sutu", sw: "Swahili", sv: "Swedish", "sv-FI": "Swedish (Finland)", "sv-SV": "Swedish (Sweden)", ta: "Tamil", tt: "Tatar", te: "Teluga", th: "Thai", tig: "Tigre", ts: "Tsonga", tn: "Tswana", tr: "Turkish", tk: "Turkmen", uk: "Ukrainian", hsb: "Upper Sorbian", ur: "Urdu", ve: "Venda", vi: "Vietnamese", vo: "Volapuk", wa: "Walloon", cy: "Welsh", xh: "Xhosa", ji: "Yiddish", zu: "Zulu" }[o] !== void 0 && (this.internal.languageSettings.languageCode = o, this.internal.languageSettings.isSubscribed === !1 && (this.internal.events.subscribe("putCatalog", function() {
    this.internal.write("/Lang (" + this.internal.languageSettings.languageCode + ")");
  }), this.internal.languageSettings.isSubscribed = !0)), this;
}, pc = Tt.API, Ap = pc.getCharWidthsArray = function(o, e) {
  var t, r, n = (e = e || {}).font || this.internal.getFont(), i = e.fontSize || this.internal.getFontSize(), a = e.charSpace || this.internal.getCharSpace(), s = e.widths ? e.widths : n.metadata.Unicode.widths, l = s.fof ? s.fof : 1, c = e.kerning ? e.kerning : n.metadata.Unicode.kerning, u = c.fof ? c.fof : 1, A = e.doKerning !== !1, p = 0, d = o.length, g = 0, _ = s[0] || l, f = [];
  for (t = 0; t < d; t++) r = o.charCodeAt(t), typeof n.metadata.widthOfString == "function" ? f.push((n.metadata.widthOfGlyph(n.metadata.characterToGlyph(r)) + a * (1e3 / i) || 0) / 1e3) : (p = A && yr(c[r]) === "object" && !isNaN(parseInt(c[r][g], 10)) ? c[r][g] / u : 0, f.push((s[r] || _) / l + p)), g = r;
  return f;
}, e1 = pc.getStringUnitWidth = function(o, e) {
  var t = (e = e || {}).fontSize || this.internal.getFontSize(), r = e.font || this.internal.getFont(), n = e.charSpace || this.internal.getCharSpace();
  return pc.processArabic && (o = pc.processArabic(o)), typeof r.metadata.widthOfString == "function" ? r.metadata.widthOfString(o, t, n) / t : Ap.apply(this, arguments).reduce(function(i, a) {
    return i + a;
  }, 0);
}, t1 = function(o, e, t, r) {
  for (var n = [], i = 0, a = o.length, s = 0; i !== a && s + e[i] < t; ) s += e[i], i++;
  n.push(o.slice(0, i));
  var l = i;
  for (s = 0; i !== a; ) s + e[i] > r && (n.push(o.slice(l, i)), s = 0, l = i), s += e[i], i++;
  return l !== i && n.push(o.slice(l, i)), n;
}, r1 = function(o, e, t) {
  t || (t = {});
  var r, n, i, a, s, l, c, u = [], A = [u], p = t.textIndent || 0, d = 0, g = 0, _ = o.split(" "), f = Ap.apply(this, [" ", t])[0];
  if (l = t.lineIndent === -1 ? _[0].length + 2 : t.lineIndent || 0) {
    var m = Array(l).join(" "), b = [];
    _.map(function(w) {
      (w = w.split(/\s*\n/)).length > 1 ? b = b.concat(w.map(function(C, E) {
        return (E && C.length ? `
` : "") + C;
      })) : b.push(w[0]);
    }), _ = b, l = e1.apply(this, [m, t]);
  }
  for (i = 0, a = _.length; i < a; i++) {
    var v = 0;
    if (r = _[i], l && r[0] == `
` && (r = r.substr(1), v = 1), p + d + (g = (n = Ap.apply(this, [r, t])).reduce(function(w, C) {
      return w + C;
    }, 0)) > e || v) {
      if (g > e) {
        for (s = t1.apply(this, [r, n, e - (p + d), e]), u.push(s.shift()), u = [s.pop()]; s.length; ) A.push([s.shift()]);
        g = n.slice(r.length - (u[0] ? u[0].length : 0)).reduce(function(w, C) {
          return w + C;
        }, 0);
      } else u = [r];
      A.push(u), p = g + l, d = f;
    } else u.push(r), p += d + g, d = f;
  }
  return c = l ? function(w, C) {
    return (C ? m : "") + w.join(" ");
  } : function(w) {
    return w.join(" ");
  }, A.map(c);
}, pc.splitTextToSize = function(o, e, t) {
  var r, n = (t = t || {}).fontSize || this.internal.getFontSize(), i = (function(u) {
    if (u.widths && u.kerning) return { widths: u.widths, kerning: u.kerning };
    var A = this.internal.getFont(u.fontName, u.fontStyle), p = "Unicode";
    return A.metadata[p] ? { widths: A.metadata[p].widths || { 0: 1 }, kerning: A.metadata[p].kerning || {} } : { font: A.metadata, fontSize: this.internal.getFontSize(), charSpace: this.internal.getCharSpace() };
  }).call(this, t);
  r = Array.isArray(o) ? o : String(o).split(/\r?\n/);
  var a = 1 * this.internal.scaleFactor * e / n;
  i.textIndent = t.textIndent ? 1 * t.textIndent * this.internal.scaleFactor / n : 0, i.lineIndent = t.lineIndent;
  var s, l, c = [];
  for (s = 0, l = r.length; s < l; s++) c = c.concat(r1.apply(this, [r[s], a, i]));
  return c;
}, (function(o) {
  o.__fontmetrics__ = o.__fontmetrics__ || {};
  for (var e = "0123456789abcdef", t = "klmnopqrstuvwxyz", r = {}, n = {}, i = 0; i < 16; i++) r[t[i]] = e[i], n[e[i]] = t[i];
  var a = function(p) {
    return "0x" + parseInt(p, 10).toString(16);
  }, s = o.__fontmetrics__.compress = function(p) {
    var d, g, _, f, m = ["{"];
    for (var b in p) {
      if (d = p[b], isNaN(parseInt(b, 10)) ? g = "'" + b + "'" : (b = parseInt(b, 10), g = (g = a(b).slice(2)).slice(0, -1) + n[g.slice(-1)]), typeof d == "number") d < 0 ? (_ = a(d).slice(3), f = "-") : (_ = a(d).slice(2), f = ""), _ = f + _.slice(0, -1) + n[_.slice(-1)];
      else {
        if (yr(d) !== "object") throw new Error("Don't know what to do with value type " + yr(d) + ".");
        _ = s(d);
      }
      m.push(g + _);
    }
    return m.push("}"), m.join("");
  }, l = o.__fontmetrics__.uncompress = function(p) {
    if (typeof p != "string") throw new Error("Invalid argument passed to uncompress.");
    for (var d, g, _, f, m = {}, b = 1, v = m, w = [], C = "", E = "", T = p.length - 1, F = 1; F < T; F += 1) (f = p[F]) == "'" ? d ? (_ = d.join(""), d = void 0) : d = [] : d ? d.push(f) : f == "{" ? (w.push([v, _]), v = {}, _ = void 0) : f == "}" ? ((g = w.pop())[0][g[1]] = v, _ = void 0, v = g[0]) : f == "-" ? b = -1 : _ === void 0 ? r.hasOwnProperty(f) ? (C += r[f], _ = parseInt(C, 16) * b, b = 1, C = "") : C += f : r.hasOwnProperty(f) ? (E += r[f], v[_] = parseInt(E, 16) * b, b = 1, _ = void 0, E = "") : E += f;
    return m;
  }, c = { codePages: ["WinAnsiEncoding"], WinAnsiEncoding: l("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}") }, u = { Unicode: { Courier: c, "Courier-Bold": c, "Courier-BoldOblique": c, "Courier-Oblique": c, Helvetica: c, "Helvetica-Bold": c, "Helvetica-BoldOblique": c, "Helvetica-Oblique": c, "Times-Roman": c, "Times-Bold": c, "Times-BoldItalic": c, "Times-Italic": c } }, A = { Unicode: { "Courier-Oblique": l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-BoldItalic": l("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"), "Helvetica-Bold": l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"), Courier: l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Courier-BoldOblique": l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-Bold": l("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"), Symbol: l("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"), Helvetica: l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"), "Helvetica-BoldOblique": l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"), ZapfDingbats: l("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"), "Courier-Bold": l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"), "Times-Italic": l("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"), "Times-Roman": l("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"), "Helvetica-Oblique": l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}") } };
  o.events.push(["addFont", function(p) {
    var d = p.font, g = A.Unicode[d.postScriptName];
    g && (d.metadata.Unicode = {}, d.metadata.Unicode.widths = g.widths, d.metadata.Unicode.kerning = g.kerning);
    var _ = u.Unicode[d.postScriptName];
    _ && (d.metadata.Unicode.encoding = _, d.encoding = _.codePages[0]);
  }]);
})(Tt.API), /**
* @license
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = function(t) {
    for (var r = t.length, n = new Uint8Array(r), i = 0; i < r; i++) n[i] = t.charCodeAt(i);
    return n;
  };
  o.API.events.push(["addFont", function(t) {
    var r = void 0, n = t.font, i = t.instance;
    if (!n.isStandardFont) {
      if (i === void 0) throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('" + n.postScriptName + "').");
      if (typeof (r = i.existsFileInVFS(n.postScriptName) === !1 ? i.loadFile(n.postScriptName) : i.getFileFromVFS(n.postScriptName)) != "string") throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('" + n.postScriptName + "').");
      (function(a, s) {
        s = /^\x00\x01\x00\x00/.test(s) ? e(s) : e(eh(s)), a.metadata = o.API.TTFFont.open(s), a.metadata.Unicode = a.metadata.Unicode || { encoding: {}, kerning: {}, widths: [] }, a.metadata.glyIdsUsed = [0];
      })(n, r);
    }
  }]);
})(Tt), Tt.API.addSvgAsImage = function(o, e, t, r, n, i, a, s) {
  if (isNaN(e) || isNaN(t)) throw Or.error("jsPDF.addSvgAsImage: Invalid coordinates", arguments), new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");
  if (isNaN(r) || isNaN(n)) throw Or.error("jsPDF.addSvgAsImage: Invalid measurements", arguments), new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");
  var l = document.createElement("canvas");
  l.width = r, l.height = n;
  var c = l.getContext("2d");
  c.fillStyle = "#fff", c.fillRect(0, 0, l.width, l.height);
  var u = { ignoreMouse: !0, ignoreAnimation: !0, ignoreDimensions: !0 }, A = this;
  return (Gt.canvg ? Promise.resolve(Gt.canvg) : Promise.resolve().then(() => Sz)).catch(function(p) {
    return Promise.reject(new Error("Could not load canvg: " + p));
  }).then(function(p) {
    return p.default ? p.default : p;
  }).then(function(p) {
    return p.fromString(c, o, u);
  }, function() {
    return Promise.reject(new Error("Could not load canvg."));
  }).then(function(p) {
    return p.render(u);
  }).then(function() {
    A.addImage(l.toDataURL("image/jpeg", 1), e, t, r, n, a, s);
  });
}, Tt.API.putTotalPages = function(o) {
  var e, t = 0;
  parseInt(this.internal.getFont().id.substr(1), 10) < 15 ? (e = new RegExp(o, "g"), t = this.internal.getNumberOfPages()) : (e = new RegExp(this.pdfEscape16(o, this.internal.getFont()), "g"), t = this.pdfEscape16(this.internal.getNumberOfPages() + "", this.internal.getFont()));
  for (var r = 1; r <= this.internal.getNumberOfPages(); r++) for (var n = 0; n < this.internal.pages[r].length; n++) this.internal.pages[r][n] = this.internal.pages[r][n].replace(e, t);
  return this;
}, Tt.API.viewerPreferences = function(o, e) {
  var t;
  o = o || {}, e = e || !1;
  var r, n, i, a = { HideToolbar: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.3 }, HideMenubar: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.3 }, HideWindowUI: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.3 }, FitWindow: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.3 }, CenterWindow: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.3 }, DisplayDocTitle: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.4 }, NonFullScreenPageMode: { defaultValue: "UseNone", value: "UseNone", type: "name", explicitSet: !1, valueSet: ["UseNone", "UseOutlines", "UseThumbs", "UseOC"], pdfVersion: 1.3 }, Direction: { defaultValue: "L2R", value: "L2R", type: "name", explicitSet: !1, valueSet: ["L2R", "R2L"], pdfVersion: 1.3 }, ViewArea: { defaultValue: "CropBox", value: "CropBox", type: "name", explicitSet: !1, valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"], pdfVersion: 1.4 }, ViewClip: { defaultValue: "CropBox", value: "CropBox", type: "name", explicitSet: !1, valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"], pdfVersion: 1.4 }, PrintArea: { defaultValue: "CropBox", value: "CropBox", type: "name", explicitSet: !1, valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"], pdfVersion: 1.4 }, PrintClip: { defaultValue: "CropBox", value: "CropBox", type: "name", explicitSet: !1, valueSet: ["MediaBox", "CropBox", "TrimBox", "BleedBox", "ArtBox"], pdfVersion: 1.4 }, PrintScaling: { defaultValue: "AppDefault", value: "AppDefault", type: "name", explicitSet: !1, valueSet: ["AppDefault", "None"], pdfVersion: 1.6 }, Duplex: { defaultValue: "", value: "none", type: "name", explicitSet: !1, valueSet: ["Simplex", "DuplexFlipShortEdge", "DuplexFlipLongEdge", "none"], pdfVersion: 1.7 }, PickTrayByPDFSize: { defaultValue: !1, value: !1, type: "boolean", explicitSet: !1, valueSet: [!0, !1], pdfVersion: 1.7 }, PrintPageRange: { defaultValue: "", value: "", type: "array", explicitSet: !1, valueSet: null, pdfVersion: 1.7 }, NumCopies: { defaultValue: 1, value: 1, type: "integer", explicitSet: !1, valueSet: null, pdfVersion: 1.7 } }, s = Object.keys(a), l = [], c = 0, u = 0, A = 0;
  function p(g, _) {
    var f, m = !1;
    for (f = 0; f < g.length; f += 1) g[f] === _ && (m = !0);
    return m;
  }
  if (this.internal.viewerpreferences === void 0 && (this.internal.viewerpreferences = {}, this.internal.viewerpreferences.configuration = JSON.parse(JSON.stringify(a)), this.internal.viewerpreferences.isSubscribed = !1), t = this.internal.viewerpreferences.configuration, o === "reset" || e === !0) {
    var d = s.length;
    for (A = 0; A < d; A += 1) t[s[A]].value = t[s[A]].defaultValue, t[s[A]].explicitSet = !1;
  }
  if (yr(o) === "object") {
    for (n in o) if (i = o[n], p(s, n) && i !== void 0) {
      if (t[n].type === "boolean" && typeof i == "boolean") t[n].value = i;
      else if (t[n].type === "name" && p(t[n].valueSet, i)) t[n].value = i;
      else if (t[n].type === "integer" && Number.isInteger(i)) t[n].value = i;
      else if (t[n].type === "array") {
        for (c = 0; c < i.length; c += 1) if (r = !0, i[c].length === 1 && typeof i[c][0] == "number") l.push(String(i[c] - 1));
        else if (i[c].length > 1) {
          for (u = 0; u < i[c].length; u += 1) typeof i[c][u] != "number" && (r = !1);
          r === !0 && l.push([i[c][0] - 1, i[c][1] - 1].join(" "));
        }
        t[n].value = "[" + l.join(" ") + "]";
      } else t[n].value = t[n].defaultValue;
      t[n].explicitSet = !0;
    }
  }
  return this.internal.viewerpreferences.isSubscribed === !1 && (this.internal.events.subscribe("putCatalog", function() {
    var g, _ = [];
    for (g in t) t[g].explicitSet === !0 && (t[g].type === "name" ? _.push("/" + g + " /" + t[g].value) : _.push("/" + g + " " + t[g].value));
    _.length !== 0 && this.internal.write(`/ViewerPreferences
<<
` + _.join(`
`) + `
>>`);
  }), this.internal.viewerpreferences.isSubscribed = !0), this.internal.viewerpreferences.configuration = t, this;
}, /** ====================================================================
* @license
* jsPDF XMP metadata plugin
* Copyright (c) 2016 Jussi Utunen, [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
(function(o) {
  var e = function() {
    var r = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="' + this.internal.__metadata__.namespaceuri + '"><jspdf:metadata>', n = unescape(encodeURIComponent('<x:xmpmeta xmlns:x="adobe:ns:meta/">')), i = unescape(encodeURIComponent(r)), a = unescape(encodeURIComponent(this.internal.__metadata__.metadata)), s = unescape(encodeURIComponent("</jspdf:metadata></rdf:Description></rdf:RDF>")), l = unescape(encodeURIComponent("</x:xmpmeta>")), c = i.length + a.length + s.length + n.length + l.length;
    this.internal.__metadata__.metadata_object_number = this.internal.newObject(), this.internal.write("<< /Type /Metadata /Subtype /XML /Length " + c + " >>"), this.internal.write("stream"), this.internal.write(n + i + a + s + l), this.internal.write("endstream"), this.internal.write("endobj");
  }, t = function() {
    this.internal.__metadata__.metadata_object_number && this.internal.write("/Metadata " + this.internal.__metadata__.metadata_object_number + " 0 R");
  };
  o.addMetadata = function(r, n) {
    return this.internal.__metadata__ === void 0 && (this.internal.__metadata__ = { metadata: r, namespaceuri: n || "http://jspdf.default.namespaceuri/" }, this.internal.events.subscribe("putCatalog", t), this.internal.events.subscribe("postPutResources", e)), this;
  };
})(Tt.API), (function(o) {
  var e = o.API, t = e.pdfEscape16 = function(i, a) {
    for (var s, l = a.metadata.Unicode.widths, c = ["", "0", "00", "000", "0000"], u = [""], A = 0, p = i.length; A < p; ++A) {
      if (s = a.metadata.characterToGlyph(i.charCodeAt(A)), a.metadata.glyIdsUsed.push(s), a.metadata.toUnicode[s] = i.charCodeAt(A), l.indexOf(s) == -1 && (l.push(s), l.push([parseInt(a.metadata.widthOfGlyph(s), 10)])), s == "0") return u.join("");
      s = s.toString(16), u.push(c[4 - s.length], s);
    }
    return u.join("");
  }, r = function(i) {
    var a, s, l, c, u, A, p;
    for (u = `/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo <<
  /Registry (Adobe)
  /Ordering (UCS)
  /Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000><ffff>
endcodespacerange`, l = [], A = 0, p = (s = Object.keys(i).sort(function(d, g) {
      return d - g;
    })).length; A < p; A++) a = s[A], l.length >= 100 && (u += `
` + l.length + ` beginbfchar
` + l.join(`
`) + `
endbfchar`, l = []), i[a] !== void 0 && i[a] !== null && typeof i[a].toString == "function" && (c = ("0000" + i[a].toString(16)).slice(-4), a = ("0000" + (+a).toString(16)).slice(-4), l.push("<" + a + "><" + c + ">"));
    return l.length && (u += `
` + l.length + ` beginbfchar
` + l.join(`
`) + `
endbfchar
`), u + `endcmap
CMapName currentdict /CMap defineresource pop
end
end`;
  };
  e.events.push(["putFont", function(i) {
    (function(a) {
      var s = a.font, l = a.out, c = a.newObject, u = a.putStream;
      if (s.metadata instanceof o.API.TTFFont && s.encoding === "Identity-H") {
        for (var A = s.metadata.Unicode.widths, p = s.metadata.subset.encode(s.metadata.glyIdsUsed, 1), d = "", g = 0; g < p.length; g++) d += String.fromCharCode(p[g]);
        var _ = c();
        u({ data: d, addLength1: !0, objectId: _ }), l("endobj");
        var f = c();
        u({ data: r(s.metadata.toUnicode), addLength1: !0, objectId: f }), l("endobj");
        var m = c();
        l("<<"), l("/Type /FontDescriptor"), l("/FontName /" + Cc(s.fontName)), l("/FontFile2 " + _ + " 0 R"), l("/FontBBox " + o.API.PDFObject.convert(s.metadata.bbox)), l("/Flags " + s.metadata.flags), l("/StemV " + s.metadata.stemV), l("/ItalicAngle " + s.metadata.italicAngle), l("/Ascent " + s.metadata.ascender), l("/Descent " + s.metadata.decender), l("/CapHeight " + s.metadata.capHeight), l(">>"), l("endobj");
        var b = c();
        l("<<"), l("/Type /Font"), l("/BaseFont /" + Cc(s.fontName)), l("/FontDescriptor " + m + " 0 R"), l("/W " + o.API.PDFObject.convert(A)), l("/CIDToGIDMap /Identity"), l("/DW 1000"), l("/Subtype /CIDFontType2"), l("/CIDSystemInfo"), l("<<"), l("/Supplement 0"), l("/Registry (Adobe)"), l("/Ordering (" + s.encoding + ")"), l(">>"), l(">>"), l("endobj"), s.objectNumber = c(), l("<<"), l("/Type /Font"), l("/Subtype /Type0"), l("/ToUnicode " + f + " 0 R"), l("/BaseFont /" + Cc(s.fontName)), l("/Encoding /" + s.encoding), l("/DescendantFonts [" + b + " 0 R]"), l(">>"), l("endobj"), s.isAlreadyPutted = !0;
      }
    })(i);
  }]), e.events.push(["putFont", function(i) {
    (function(a) {
      var s = a.font, l = a.out, c = a.newObject, u = a.putStream;
      if (s.metadata instanceof o.API.TTFFont && s.encoding === "WinAnsiEncoding") {
        for (var A = s.metadata.rawData, p = "", d = 0; d < A.length; d++) p += String.fromCharCode(A[d]);
        var g = c();
        u({ data: p, addLength1: !0, objectId: g }), l("endobj");
        var _ = c();
        u({ data: r(s.metadata.toUnicode), addLength1: !0, objectId: _ }), l("endobj");
        var f = c();
        l("<<"), l("/Descent " + s.metadata.decender), l("/CapHeight " + s.metadata.capHeight), l("/StemV " + s.metadata.stemV), l("/Type /FontDescriptor"), l("/FontFile2 " + g + " 0 R"), l("/Flags 96"), l("/FontBBox " + o.API.PDFObject.convert(s.metadata.bbox)), l("/FontName /" + Cc(s.fontName)), l("/ItalicAngle " + s.metadata.italicAngle), l("/Ascent " + s.metadata.ascender), l(">>"), l("endobj"), s.objectNumber = c();
        for (var m = 0; m < s.metadata.hmtx.widths.length; m++) s.metadata.hmtx.widths[m] = parseInt(s.metadata.hmtx.widths[m] * (1e3 / s.metadata.head.unitsPerEm));
        l("<</Subtype/TrueType/Type/Font/ToUnicode " + _ + " 0 R/BaseFont/" + Cc(s.fontName) + "/FontDescriptor " + f + " 0 R/Encoding/" + s.encoding + " /FirstChar 29 /LastChar 255 /Widths " + o.API.PDFObject.convert(s.metadata.hmtx.widths) + ">>"), l("endobj"), s.isAlreadyPutted = !0;
      }
    })(i);
  }]);
  var n = function(i) {
    var a, s = i.text || "", l = i.x, c = i.y, u = i.options || {}, A = i.mutex || {}, p = A.pdfEscape, d = A.activeFontKey, g = A.fonts, _ = d, f = "", m = 0, b = "", v = g[_].encoding;
    if (g[_].encoding !== "Identity-H") return { text: s, x: l, y: c, options: u, mutex: A };
    for (b = s, _ = d, Array.isArray(s) && (b = s[0]), m = 0; m < b.length; m += 1) g[_].metadata.hasOwnProperty("cmap") && (a = g[_].metadata.cmap.unicode.codeMap[b[m].charCodeAt(0)]), a || b[m].charCodeAt(0) < 256 && g[_].metadata.hasOwnProperty("Unicode") ? f += b[m] : f += "";
    var w = "";
    return parseInt(_.slice(1)) < 14 || v === "WinAnsiEncoding" ? w = p(f, _).split("").map(function(C) {
      return C.charCodeAt(0).toString(16);
    }).join("") : v === "Identity-H" && (w = t(f, g[_])), A.isHex = !0, { text: w, x: l, y: c, options: u, mutex: A };
  };
  e.events.push(["postProcessText", function(i) {
    var a = i.text || "", s = [], l = { text: a, x: i.x, y: i.y, options: i.options, mutex: i.mutex };
    if (Array.isArray(a)) {
      var c = 0;
      for (c = 0; c < a.length; c += 1) Array.isArray(a[c]) && a[c].length === 3 ? s.push([n(Object.assign({}, l, { text: a[c][0] })).text, a[c][1], a[c][2]]) : s.push(n(Object.assign({}, l, { text: a[c] })).text);
      i.text = s;
    } else i.text = n(Object.assign({}, l, { text: a })).text;
  }]);
})(Tt), /**
* @license
* jsPDF virtual FileSystem functionality
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function(o) {
  var e = function() {
    return this.internal.vFS === void 0 && (this.internal.vFS = {}), !0;
  };
  o.existsFileInVFS = function(t) {
    return e.call(this), this.internal.vFS[t] !== void 0;
  }, o.addFileToVFS = function(t, r) {
    return e.call(this), this.internal.vFS[t] = r, this;
  }, o.getFileFromVFS = function(t) {
    return e.call(this), this.internal.vFS[t] !== void 0 ? this.internal.vFS[t] : null;
  };
})(Tt.API), /**
* @license
* Unicode Bidi Engine based on the work of Alex Shensis (@asthensis)
* MIT License
*/
(function(o) {
  o.__bidiEngine__ = o.prototype.__bidiEngine__ = function(r) {
    var n, i, a, s, l, c, u, A = e, p = [[0, 3, 0, 1, 0, 0, 0], [0, 3, 0, 1, 2, 2, 0], [0, 3, 0, 17, 2, 0, 1], [0, 3, 5, 5, 4, 1, 0], [0, 3, 21, 21, 4, 0, 1], [0, 3, 5, 5, 4, 2, 0]], d = [[2, 0, 1, 1, 0, 1, 0], [2, 0, 1, 1, 0, 2, 0], [2, 0, 2, 1, 3, 2, 0], [2, 0, 2, 33, 3, 1, 1]], g = { L: 0, R: 1, EN: 2, AN: 3, N: 4, B: 5, S: 6 }, _ = { 0: 0, 5: 1, 6: 2, 7: 3, 32: 4, 251: 5, 254: 6, 255: 7 }, f = ["(", ")", "(", "<", ">", "<", "[", "]", "[", "{", "}", "{", "«", "»", "«", "‹", "›", "‹", "⁅", "⁆", "⁅", "⁽", "⁾", "⁽", "₍", "₎", "₍", "≤", "≥", "≤", "〈", "〉", "〈", "﹙", "﹚", "﹙", "﹛", "﹜", "﹛", "﹝", "﹞", "﹝", "﹤", "﹥", "﹤"], m = new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/), b = !1, v = 0;
    this.__bidiEngine__ = {};
    var w = function(S) {
      var L = S.charCodeAt(), U = L >> 8, O = _[U];
      return O !== void 0 ? A[256 * O + (255 & L)] : U === 252 || U === 253 ? "AL" : m.test(U) ? "L" : U === 8 ? "R" : "N";
    }, C = function(S) {
      for (var L, U = 0; U < S.length; U++) {
        if ((L = w(S.charAt(U))) === "L") return !1;
        if (L === "R") return !0;
      }
      return !1;
    }, E = function(S, L, U, O) {
      var K, te, Y, ee, oe = L[O];
      switch (oe) {
        case "L":
        case "R":
        case "LRE":
        case "RLE":
        case "LRO":
        case "RLO":
        case "PDF":
          b = !1;
          break;
        case "N":
        case "AN":
          break;
        case "EN":
          b && (oe = "AN");
          break;
        case "AL":
          b = !0, oe = "R";
          break;
        case "WS":
        case "BN":
          oe = "N";
          break;
        case "CS":
          O < 1 || O + 1 >= L.length || (K = U[O - 1]) !== "EN" && K !== "AN" || (te = L[O + 1]) !== "EN" && te !== "AN" ? oe = "N" : b && (te = "AN"), oe = te === K ? te : "N";
          break;
        case "ES":
          oe = (K = O > 0 ? U[O - 1] : "B") === "EN" && O + 1 < L.length && L[O + 1] === "EN" ? "EN" : "N";
          break;
        case "ET":
          if (O > 0 && U[O - 1] === "EN") {
            oe = "EN";
            break;
          }
          if (b) {
            oe = "N";
            break;
          }
          for (Y = O + 1, ee = L.length; Y < ee && L[Y] === "ET"; ) Y++;
          oe = Y < ee && L[Y] === "EN" ? "EN" : "N";
          break;
        case "NSM":
          if (a && !s) {
            for (ee = L.length, Y = O + 1; Y < ee && L[Y] === "NSM"; ) Y++;
            if (Y < ee) {
              var de = S[O], ae = de >= 1425 && de <= 2303 || de === 64286;
              if (K = L[Y], ae && (K === "R" || K === "AL")) {
                oe = "R";
                break;
              }
            }
          }
          oe = O < 1 || (K = L[O - 1]) === "B" ? "N" : U[O - 1];
          break;
        case "B":
          b = !1, n = !0, oe = v;
          break;
        case "S":
          i = !0, oe = "N";
      }
      return oe;
    }, T = function(S, L, U) {
      var O = S.split("");
      return U && F(O, U, { hiLevel: v }), O.reverse(), L && L.reverse(), O.join("");
    }, F = function(S, L, U) {
      var O, K, te, Y, ee, oe = -1, de = S.length, ae = 0, I = [], G = v ? d : p, H = [];
      for (b = !1, n = !1, i = !1, K = 0; K < de; K++) H[K] = w(S[K]);
      for (te = 0; te < de; te++) {
        if (ee = ae, I[te] = E(S, H, I, te), O = 240 & (ae = G[ee][g[I[te]]]), ae &= 15, L[te] = Y = G[ae][5], O > 0) if (O === 16) {
          for (K = oe; K < te; K++) L[K] = 1;
          oe = -1;
        } else oe = -1;
        if (G[ae][6]) oe === -1 && (oe = te);
        else if (oe > -1) {
          for (K = oe; K < te; K++) L[K] = Y;
          oe = -1;
        }
        H[te] === "B" && (L[te] = 0), U.hiLevel |= Y;
      }
      i && (function(Z, ne, le) {
        for (var me = 0; me < le; me++) if (Z[me] === "S") {
          ne[me] = v;
          for (var ce = me - 1; ce >= 0 && Z[ce] === "WS"; ce--) ne[ce] = v;
        }
      })(H, L, de);
    }, B = function(S, L, U, O, K) {
      if (!(K.hiLevel < S)) {
        if (S === 1 && v === 1 && !n) return L.reverse(), void (U && U.reverse());
        for (var te, Y, ee, oe, de = L.length, ae = 0; ae < de; ) {
          if (O[ae] >= S) {
            for (ee = ae + 1; ee < de && O[ee] >= S; ) ee++;
            for (oe = ae, Y = ee - 1; oe < Y; oe++, Y--) te = L[oe], L[oe] = L[Y], L[Y] = te, U && (te = U[oe], U[oe] = U[Y], U[Y] = te);
            ae = ee;
          }
          ae++;
        }
      }
    }, P = function(S, L, U) {
      var O = S.split(""), K = { hiLevel: v };
      return U || (U = []), F(O, U, K), (function(te, Y, ee) {
        if (ee.hiLevel !== 0 && u) for (var oe, de = 0; de < te.length; de++) Y[de] === 1 && (oe = f.indexOf(te[de])) >= 0 && (te[de] = f[oe + 1]);
      })(O, U, K), B(2, O, L, U, K), B(1, O, L, U, K), O.join("");
    };
    return this.__bidiEngine__.doBidiReorder = function(S, L, U) {
      if ((function(K, te) {
        if (te) for (var Y = 0; Y < K.length; Y++) te[Y] = Y;
        s === void 0 && (s = C(K)), c === void 0 && (c = C(K));
      })(S, L), a || !l || c) if (a && l && s ^ c) v = s ? 1 : 0, S = T(S, L, U);
      else if (!a && l && c) v = s ? 1 : 0, S = P(S, L, U), S = T(S, L);
      else if (!a || s || l || c) {
        if (a && !l && s ^ c) S = T(S, L), s ? (v = 0, S = P(S, L, U)) : (v = 1, S = P(S, L, U), S = T(S, L));
        else if (a && s && !l && c) v = 1, S = P(S, L, U), S = T(S, L);
        else if (!a && !l && s ^ c) {
          var O = u;
          s ? (v = 1, S = P(S, L, U), v = 0, u = !1, S = P(S, L, U), u = O) : (v = 0, S = P(S, L, U), S = T(S, L), v = 1, u = !1, S = P(S, L, U), u = O, S = T(S, L));
        }
      } else v = 0, S = P(S, L, U);
      else v = s ? 1 : 0, S = P(S, L, U);
      return S;
    }, this.__bidiEngine__.setOptions = function(S) {
      S && (a = S.isInputVisual, l = S.isOutputVisual, s = S.isInputRtl, c = S.isOutputRtl, u = S.isSymmetricSwapping);
    }, this.__bidiEngine__.setOptions(r), this.__bidiEngine__;
  };
  var e = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "N", "N", "ET", "ET", "ET", "N", "N", "N", "N", "N", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "N", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "L", "N", "N", "BN", "N", "N", "ET", "ET", "EN", "EN", "N", "L", "N", "N", "N", "EN", "L", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "L", "L", "L", "L", "L", "L", "L", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "L", "N", "N", "N", "N", "N", "ET", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "R", "NSM", "R", "NSM", "NSM", "R", "NSM", "NSM", "R", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "AN", "AN", "AN", "AN", "AN", "AN", "N", "N", "AL", "ET", "ET", "AL", "CS", "AL", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "N", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "N", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "R", "R", "N", "N", "N", "N", "R", "N", "N", "N", "N", "N", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "WS", "BN", "BN", "BN", "L", "R", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "WS", "B", "LRE", "RLE", "PDF", "LRO", "RLO", "CS", "ET", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "CS", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "WS", "BN", "BN", "BN", "BN", "BN", "N", "LRI", "RLI", "FSI", "PDI", "BN", "BN", "BN", "BN", "BN", "BN", "EN", "L", "N", "N", "EN", "EN", "EN", "EN", "EN", "EN", "ES", "ES", "N", "N", "N", "L", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "ES", "ES", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "ET", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "L", "L", "L", "L", "L", "N", "N", "N", "N", "N", "R", "NSM", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "ES", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "N", "R", "R", "R", "R", "R", "N", "R", "N", "R", "R", "N", "R", "R", "N", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "CS", "N", "CS", "N", "N", "CS", "N", "N", "N", "N", "N", "N", "N", "N", "N", "ET", "N", "N", "ES", "ES", "N", "N", "N", "N", "N", "ET", "ET", "N", "N", "N", "N", "N", "AL", "AL", "AL", "AL", "AL", "N", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "A

File truncated at 1 MB.