var ei = Object.defineProperty;
var ti = (t, A, e) => A in t ? ei(t, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[A] = e;
var oA = (t, A, e) => (ti(t, typeof A != "symbol" ? A + "" : A, e), e);
import { ViewMode as Gs, UIActionHandler as ri, PluginStaticResource as si } from "@ibiz-template/runtime";
import { useWFStepTraceViewController as ni, usePropsWatch as Rs, useNamespace as RA, useViewController as Ns, useEditView3Controller as ii, getUploadProps as ai, getEditorEmits as Bi, getGridUploadProps as pr, getGridEditorEmits as Vs, useClickOutside as oi, useEventListener as ci } from "@ibiz-template/vue-util";
import { defineComponent as mA, getCurrentInstance as Ft, ref as G, onMounted as li, h as x, watch as EA, toRefs as Er } from "vue";
import { EditFormModel as gi, ViewType as rA, AppEntityModel as Hr, UnsupportedModelError as Ps, DefectModelError as Sr, getModelService as ui } from "@ibiz-template/model";
import { createUUID as it, getCookie as wi, isNilOrEmpty as Qi, ascSort as Tr, notNilEmpty as xr, descSort as fi } from "qx-util";
import { WFDynaEditView3Controller as Ci, WFStepTraceViewController as hi, UploadEditorController as ks } from "@ibiz-template/controller";
import { HttpError as _s, isImage as Ui, uploadFile as Fi, RuntimeError as ZA, HttpResponse as X } from "@ibiz-template/core";
import { isNil as lA, isEmpty as tA, clone as pA, equals as bA, where as we } from "ramda";
import { WorkFlowService as di, EntityService as pi } from "@ibiz-template/service";
const Xs = mA({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    },
    modelData: {
      type: gi,
      required: !0
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ft(), e = ni(A, t.modelPath);
    Rs(A, "deName", e.setDeName.bind(e));
    const r = RA("wf-step-trace-grid"), s = G([]), n = G([]), i = G([{
      title: "处理环节",
      key: "nodeName",
      width: 250,
      resizable: !0,
      tree: !0,
      className: "clhj"
    }, {
      title: "处理人",
      key: "personName",
      width: 200,
      resizable: !0
    }, {
      title: "处理时间",
      key: "time",
      width: 180,
      resizable: !0
    }, {
      title: "处理内容",
      key: "content",
      width: 150,
      resizable: !0
    }, {
      title: "处理意见",
      key: "comment"
    }]);
    li(() => {
      var o, c;
      const B = (c = (o = t.modelData) == null ? void 0 : o.source.getPSControlParam()) == null ? void 0 : c.ctrlParams;
      if (B && B.SHOWCOLUMNS)
        try {
          n.value = JSON.parse(B.SHOWCOLUMNS);
        } catch (l) {
          console.log("WFStepTraceGrid部件参数配置错误", l);
        }
      if (n.value.length > 0) {
        const l = i.value.filter((g) => n.value.includes(g.title));
        i.value = l;
      }
    });
    const a = (B, o, c = !1) => {
      B.comments.length > 0 && B.comments.forEach((l) => {
        c && l.type === "启动流程" || o.push({
          id: it(),
          nodeName: B.userTaskName,
          personName: l.authorName,
          time: l.time,
          content: l.type,
          comment: l.fullMessage && l.fullMessage !== "null" ? l.fullMessage : ""
        });
      });
    };
    return e.nerve.self.evt.on("mounted", () => {
      var B;
      e.data && ((B = e.data.usertasks) == null || B.forEach((o) => {
        if (o.usertasks && o.usertasks.length > 0) {
          if (o.usertasks.length === 1)
            return;
          const c = [];
          o.usertasks.forEach((l) => {
            a(l, c, !0);
          }), s.value.push({
            id: it(),
            nodeName: `${o.userTaskName}`,
            personName: "",
            time: "",
            content: "",
            comment: "",
            children: c,
            _showChildren: !0
          });
        } else
          a(o, s.value);
      }), s.value.sort((o, c) => Date.parse(o.time) - Date.parse(c.time)));
    }), {
      c: e,
      ns: r,
      gridData: s,
      columns: i
    };
  },
  render() {
    return x("div", {
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.e("title")
    }, [x("span", {
      class: this.ns.e("caption")
    }, ["审批信息"])]), x("i-table", {
      attrs: {
        "disabled-hover": !0,
        columns: this.columns,
        data: this.gridData,
        "row-key": "id"
      },
      class: this.ns.e("grid")
    })]);
  }
});
class Ei extends Ci {
  async calcWfToolbar() {
    await super.calcWfToolbar(), this.isEditable && this.wfLinks.unshift({
      sequenceFlowName: "保存",
      type: "FORM_SAVE"
    });
  }
  async onLinkClick(A) {
    A.type === "FORM_SAVE" ? await this.save() : super.onLinkClick(A);
  }
}
const Hi = mA({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ft(), e = Ns(A, (i, a) => new Ei(t.modelPath, i, a)), r = RA(`view-${rA.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), s = G(["mainForm"]);
    return {
      c: e,
      ns: r,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(t) {
    const A = [];
    if (this.c.complete) {
      const {
        activeForm: e
      } = this.c;
      e && this.c.providers[e.name] && A.push(t(this.c.providers[e.name].component, {
        props: {
          modelData: e,
          context: this.c.context,
          params: this.c.params
        },
        style: {
          height: "auto"
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit("form")
        }
      }));
    }
    if (this.c.complete && this.c.model.drTab.pages[0]) {
      const e = this.c.model.drTab.pages[0], r = this.c.drPages[e.source.name];
      A.push(t(Xs, {
        attrs: {
          context: r.context,
          params: r.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: e.embedView.source.modelPath,
          modelData: this.c.model.form
        }
      }));
    }
    return t("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && t("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (e) => {
              this.c.onLinkClick(e);
            }
          }
        })] : null
      }
    }, [this.c.complete && t("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [t("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [A]), this.c.model.drTab.pages.map((e) => {
      const r = this.c.drPages[e.source.name];
      return t("i-tab-pane", {
        class: this.ns.be("", "tab-item"),
        attrs: {
          tab: this.c.model.drTab.source.name,
          disabled: this.c.isNewData,
          label: e.source.caption,
          name: e.source.name
        }
      }, [!this.c.isNewData && this.lazyList.includes(e.source.name) && t("ViewShell", {
        attrs: {
          context: r.context,
          params: r.params,
          modal: {
            mode: Gs.EMBED
          },
          modelPath: e.embedView.source.modelPath,
          // 流程跟踪视图用
          deName: this.c.model.appEntity.source.codeName
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(e.source.name)
        },
        key: r.key
      })]);
    })])]);
  }
});
class vi {
  constructor() {
    oA(this, "component", Hi);
  }
}
const mi = mA({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ft(), e = ii(A, t.modelPath), r = RA("view-deeditview3"), s = G(["mainForm"]);
    return {
      c: e,
      ns: r,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(t) {
    return t("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && t("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [t("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [t("edit-form-control", {
      attrs: {
        modelData: this.c.model.form,
        context: this.c.context,
        params: this.c.params
      },
      style: {
        height: "auto"
      },
      on: {
        neuronInit: this.c.nerve.onNeuronInit(this.c.model.form.source.name)
      }
    }), t(Xs, {
      attrs: {
        modelData: this.c.model.form,
        context: this.c.drPages[this.c.model.drTab.pages[0].source.name].context,
        params: this.c.drPages[this.c.model.drTab.pages[0].source.name].params,
        deName: this.c.model.appEntity.source.codeName,
        modal: this.modal,
        modelPath: this.c.model.drTab.pages[0].embedView.source.modelPath
      }
    })]), this.c.model.drTab.pages.map((A) => {
      const e = this.c.drPages[A.source.name];
      if (e)
        return t("i-tab-pane", {
          class: this.ns.be("", "tab-item"),
          attrs: {
            tab: this.c.model.drTab.source.name,
            disabled: this.c.isNewData,
            label: A.source.caption,
            name: A.source.name
          }
        }, [!this.c.isNewData && this.lazyList.includes(A.source.name) && t("ViewShell", {
          attrs: {
            context: e.context,
            params: e.params,
            modal: {
              mode: Gs.EMBED
            },
            modelPath: A.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(A.source.name)
          },
          key: e.key
        })]);
    })])]);
  }
});
class Ii {
  constructor() {
    oA(this, "component", mi);
  }
}
/*!
 * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
 * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
 * Released under MIT License
 */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var $t = function(t, A) {
  return $t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
    e.__proto__ = r;
  } || function(e, r) {
    for (var s in r)
      Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
  }, $t(t, A);
};
function gA(t, A) {
  if (typeof A != "function" && A !== null)
    throw new TypeError("Class extends value " + String(A) + " is not a constructor or null");
  $t(t, A);
  function e() {
    this.constructor = t;
  }
  t.prototype = A === null ? Object.create(A) : (e.prototype = A.prototype, new e());
}
var Ar = function() {
  return Ar = Object.assign || function(A) {
    for (var e, r = 1, s = arguments.length; r < s; r++) {
      e = arguments[r];
      for (var n in e)
        Object.prototype.hasOwnProperty.call(e, n) && (A[n] = e[n]);
    }
    return A;
  }, Ar.apply(this, arguments);
};
function q(t, A, e, r) {
  function s(n) {
    return n instanceof e ? n : new e(function(i) {
      i(n);
    });
  }
  return new (e || (e = Promise))(function(n, i) {
    function a(c) {
      try {
        o(r.next(c));
      } catch (l) {
        i(l);
      }
    }
    function B(c) {
      try {
        o(r.throw(c));
      } catch (l) {
        i(l);
      }
    }
    function o(c) {
      c.done ? n(c.value) : s(c.value).then(a, B);
    }
    o((r = r.apply(t, A || [])).next());
  });
}
function Z(t, A) {
  var e = { label: 0, sent: function() {
    if (n[0] & 1)
      throw n[1];
    return n[1];
  }, trys: [], ops: [] }, r, s, n, i;
  return i = { next: a(0), throw: a(1), return: a(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
    return this;
  }), i;
  function a(o) {
    return function(c) {
      return B([o, c]);
    };
  }
  function B(o) {
    if (r)
      throw new TypeError("Generator is already executing.");
    for (; e; )
      try {
        if (r = 1, s && (n = o[0] & 2 ? s.return : o[0] ? s.throw || ((n = s.return) && n.call(s), 0) : s.next) && !(n = n.call(s, o[1])).done)
          return n;
        switch (s = 0, n && (o = [o[0] & 2, n.value]), o[0]) {
          case 0:
          case 1:
            n = o;
            break;
          case 4:
            return e.label++, { value: o[1], done: !1 };
          case 5:
            e.label++, s = o[1], o = [0];
            continue;
          case 7:
            o = e.ops.pop(), e.trys.pop();
            continue;
          default:
            if (n = e.trys, !(n = n.length > 0 && n[n.length - 1]) && (o[0] === 6 || o[0] === 2)) {
              e = 0;
              continue;
            }
            if (o[0] === 3 && (!n || o[1] > n[0] && o[1] < n[3])) {
              e.label = o[1];
              break;
            }
            if (o[0] === 6 && e.label < n[1]) {
              e.label = n[1], n = o;
              break;
            }
            if (n && e.label < n[2]) {
              e.label = n[2], e.ops.push(o);
              break;
            }
            n[2] && e.ops.pop(), e.trys.pop();
            continue;
        }
        o = A.call(t, e);
      } catch (c) {
        o = [6, c], s = 0;
      } finally {
        r = n = 0;
      }
    if (o[0] & 5)
      throw o[1];
    return { value: o[0] ? o[1] : void 0, done: !0 };
  }
}
function Se(t, A, e) {
  if (e || arguments.length === 2)
    for (var r = 0, s = A.length, n; r < s; r++)
      (n || !(r in A)) && (n || (n = Array.prototype.slice.call(A, 0, r)), n[r] = A[r]);
  return t.concat(n || A);
}
var vA = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.left = A, this.top = e, this.width = r, this.height = s;
    }
    return t.prototype.add = function(A, e, r, s) {
      return new t(this.left + A, this.top + e, this.width + r, this.height + s);
    }, t.fromClientRect = function(A, e) {
      return new t(e.left + A.windowBounds.left, e.top + A.windowBounds.top, e.width, e.height);
    }, t.fromDOMRectList = function(A, e) {
      var r = Array.from(e).find(function(s) {
        return s.width !== 0;
      });
      return r ? new t(r.left + A.windowBounds.left, r.top + A.windowBounds.top, r.width, r.height) : t.EMPTY;
    }, t.EMPTY = new t(0, 0, 0, 0), t;
  }()
), dt = function(t, A) {
  return vA.fromClientRect(t, A.getBoundingClientRect());
}, yi = function(t) {
  var A = t.body, e = t.documentElement;
  if (!A || !e)
    throw new Error("Unable to get document size");
  var r = Math.max(Math.max(A.scrollWidth, e.scrollWidth), Math.max(A.offsetWidth, e.offsetWidth), Math.max(A.clientWidth, e.clientWidth)), s = Math.max(Math.max(A.scrollHeight, e.scrollHeight), Math.max(A.offsetHeight, e.offsetHeight), Math.max(A.clientHeight, e.clientHeight));
  return new vA(0, 0, r, s);
}, pt = function(t) {
  for (var A = [], e = 0, r = t.length; e < r; ) {
    var s = t.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < r) {
      var n = t.charCodeAt(e++);
      (n & 64512) === 56320 ? A.push(((s & 1023) << 10) + (n & 1023) + 65536) : (A.push(s), e--);
    } else
      A.push(s);
  }
  return A;
}, V = function() {
  for (var t = [], A = 0; A < arguments.length; A++)
    t[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, t);
  var e = t.length;
  if (!e)
    return "";
  for (var r = [], s = -1, n = ""; ++s < e; ) {
    var i = t[s];
    i <= 65535 ? r.push(i) : (i -= 65536, r.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || r.length > 16384) && (n += String.fromCharCode.apply(String, r), r.length = 0);
  }
  return n;
}, Mr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ki = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Te = 0; Te < Mr.length; Te++)
  Ki[Mr.charCodeAt(Te)] = Te;
var Or = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Qe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var xe = 0; xe < Or.length; xe++)
  Qe[Or.charCodeAt(xe)] = xe;
var Li = function(t) {
  var A = t.length * 0.75, e = t.length, r, s = 0, n, i, a, B;
  t[t.length - 1] === "=" && (A--, t[t.length - 2] === "=" && A--);
  var o = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(o) ? o : new Uint8Array(o);
  for (r = 0; r < e; r += 4)
    n = Qe[t.charCodeAt(r)], i = Qe[t.charCodeAt(r + 1)], a = Qe[t.charCodeAt(r + 2)], B = Qe[t.charCodeAt(r + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | B & 63;
  return o;
}, bi = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 2)
    e.push(t[r + 1] << 8 | t[r]);
  return e;
}, Di = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 4)
    e.push(t[r + 3] << 24 | t[r + 2] << 16 | t[r + 1] << 8 | t[r]);
  return e;
}, JA = 5, vr = 6 + 5, Dt = 2, Si = vr - JA, Js = 65536 >> JA, Ti = 1 << JA, St = Ti - 1, xi = 1024 >> JA, Mi = Js + xi, Oi = Mi, Gi = 32, Ri = Oi + Gi, Ni = 65536 >> vr, Vi = 1 << Si, Pi = Vi - 1, Gr = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint16Array(Array.prototype.slice.call(t, A, e));
}, ki = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint32Array(Array.prototype.slice.call(t, A, e));
}, _i = function(t, A) {
  var e = Li(t), r = Array.isArray(e) ? Di(e) : new Uint32Array(e), s = Array.isArray(e) ? bi(e) : new Uint16Array(e), n = 24, i = Gr(s, n / 2, r[4] / 2), a = r[5] === 2 ? Gr(s, (n + r[4]) / 2) : ki(r, Math.ceil((n + r[4]) / 4));
  return new Xi(r[0], r[1], r[2], r[3], i, a);
}, Xi = (
  /** @class */
  function() {
    function t(A, e, r, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = r, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return t.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> JA], e = (e << Dt) + (A & St), this.data[e];
        if (A <= 65535)
          return e = this.index[Js + (A - 55296 >> JA)], e = (e << Dt) + (A & St), this.data[e];
        if (A < this.highStart)
          return e = Ri - Ni + (A >> vr), e = this.index[e], e += A >> JA & Pi, e = this.index[e], e = (e << Dt) + (A & St), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, t;
  }()
), Rr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ji = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Me = 0; Me < Rr.length; Me++)
  Ji[Rr.charCodeAt(Me)] = Me;
var Wi = " ", Nr = 50, Yi = 1, Ws = 2, Ys = 3, Zi = 4, zi = 5, Vr = 7, Zs = 8, Pr = 9, SA = 10, er = 11, kr = 12, tr = 13, ji = 14, fe = 15, rr = 16, Oe = 17, ce = 18, qi = 19, _r = 20, sr = 21, le = 22, Tt = 23, jA = 24, eA = 25, Ce = 26, he = 27, qA = 28, $i = 29, _A = 30, Aa = 31, Ge = 32, Re = 33, nr = 34, ir = 35, ar = 36, ye = 37, Br = 38, tt = 39, rt = 40, xt = 41, zs = 42, ea = 43, ta = [9001, 65288], js = "!", b = "×", Ne = "÷", or = _i(Wi), FA = [_A, ar], cr = [Yi, Ws, Ys, zi], qs = [SA, Zs], Xr = [he, Ce], ra = cr.concat(qs), Jr = [Br, tt, rt, nr, ir], sa = [fe, tr], na = function(t, A) {
  A === void 0 && (A = "strict");
  var e = [], r = [], s = [];
  return t.forEach(function(n, i) {
    var a = or.get(n);
    if (a > Nr ? (s.push(!0), a -= Nr) : s.push(!1), ["normal", "auto", "loose"].indexOf(A) !== -1 && [8208, 8211, 12316, 12448].indexOf(n) !== -1)
      return r.push(i), e.push(rr);
    if (a === Zi || a === er) {
      if (i === 0)
        return r.push(i), e.push(_A);
      var B = e[i - 1];
      return ra.indexOf(B) === -1 ? (r.push(r[i - 1]), e.push(B)) : (r.push(i), e.push(_A));
    }
    if (r.push(i), a === Aa)
      return e.push(A === "strict" ? sr : ye);
    if (a === zs || a === $i)
      return e.push(_A);
    if (a === ea)
      return n >= 131072 && n <= 196605 || n >= 196608 && n <= 262141 ? e.push(ye) : e.push(_A);
    e.push(a);
  }), [r, e, s];
}, Mt = function(t, A, e, r) {
  var s = r[e];
  if (Array.isArray(t) ? t.indexOf(s) !== -1 : t === s)
    for (var n = e; n <= r.length; ) {
      n++;
      var i = r[n];
      if (i === A)
        return !0;
      if (i !== SA)
        break;
    }
  if (s === SA)
    for (var n = e; n > 0; ) {
      n--;
      var a = r[n];
      if (Array.isArray(t) ? t.indexOf(a) !== -1 : t === a)
        for (var B = e; B <= r.length; ) {
          B++;
          var i = r[B];
          if (i === A)
            return !0;
          if (i !== SA)
            break;
        }
      if (a !== SA)
        break;
    }
  return !1;
}, Wr = function(t, A) {
  for (var e = t; e >= 0; ) {
    var r = A[e];
    if (r === SA)
      e--;
    else
      return r;
  }
  return 0;
}, ia = function(t, A, e, r, s) {
  if (e[r] === 0)
    return b;
  var n = r - 1;
  if (Array.isArray(s) && s[n] === !0)
    return b;
  var i = n - 1, a = n + 1, B = A[n], o = i >= 0 ? A[i] : 0, c = A[a];
  if (B === Ws && c === Ys)
    return b;
  if (cr.indexOf(B) !== -1)
    return js;
  if (cr.indexOf(c) !== -1 || qs.indexOf(c) !== -1)
    return b;
  if (Wr(n, A) === Zs)
    return Ne;
  if (or.get(t[n]) === er || (B === Ge || B === Re) && or.get(t[a]) === er || B === Vr || c === Vr || B === Pr || [SA, tr, fe].indexOf(B) === -1 && c === Pr || [Oe, ce, qi, jA, qA].indexOf(c) !== -1 || Wr(n, A) === le || Mt(Tt, le, n, A) || Mt([Oe, ce], sr, n, A) || Mt(kr, kr, n, A))
    return b;
  if (B === SA)
    return Ne;
  if (B === Tt || c === Tt)
    return b;
  if (c === rr || B === rr)
    return Ne;
  if ([tr, fe, sr].indexOf(c) !== -1 || B === ji || o === ar && sa.indexOf(B) !== -1 || B === qA && c === ar || c === _r || FA.indexOf(c) !== -1 && B === eA || FA.indexOf(B) !== -1 && c === eA || B === he && [ye, Ge, Re].indexOf(c) !== -1 || [ye, Ge, Re].indexOf(B) !== -1 && c === Ce || FA.indexOf(B) !== -1 && Xr.indexOf(c) !== -1 || Xr.indexOf(B) !== -1 && FA.indexOf(c) !== -1 || // (PR | PO) × ( OP | HY )? NU
  [he, Ce].indexOf(B) !== -1 && (c === eA || [le, fe].indexOf(c) !== -1 && A[a + 1] === eA) || // ( OP | HY ) × NU
  [le, fe].indexOf(B) !== -1 && c === eA || // NU ×	(NU | SY | IS)
  B === eA && [eA, qA, jA].indexOf(c) !== -1)
    return b;
  if ([eA, qA, jA, Oe, ce].indexOf(c) !== -1)
    for (var l = n; l >= 0; ) {
      var g = A[l];
      if (g === eA)
        return b;
      if ([qA, jA].indexOf(g) !== -1)
        l--;
      else
        break;
    }
  if ([he, Ce].indexOf(c) !== -1)
    for (var l = [Oe, ce].indexOf(B) !== -1 ? i : n; l >= 0; ) {
      var g = A[l];
      if (g === eA)
        return b;
      if ([qA, jA].indexOf(g) !== -1)
        l--;
      else
        break;
    }
  if (Br === B && [Br, tt, nr, ir].indexOf(c) !== -1 || [tt, nr].indexOf(B) !== -1 && [tt, rt].indexOf(c) !== -1 || [rt, ir].indexOf(B) !== -1 && c === rt || Jr.indexOf(B) !== -1 && [_r, Ce].indexOf(c) !== -1 || Jr.indexOf(c) !== -1 && B === he || FA.indexOf(B) !== -1 && FA.indexOf(c) !== -1 || B === jA && FA.indexOf(c) !== -1 || FA.concat(eA).indexOf(B) !== -1 && c === le && ta.indexOf(t[a]) === -1 || FA.concat(eA).indexOf(c) !== -1 && B === ce)
    return b;
  if (B === xt && c === xt) {
    for (var Q = e[n], u = 1; Q > 0 && (Q--, A[Q] === xt); )
      u++;
    if (u % 2 !== 0)
      return b;
  }
  return B === Ge && c === Re ? b : Ne;
}, aa = function(t, A) {
  A || (A = { lineBreak: "normal", wordBreak: "normal" });
  var e = na(t, A.lineBreak), r = e[0], s = e[1], n = e[2];
  (A.wordBreak === "break-all" || A.wordBreak === "break-word") && (s = s.map(function(a) {
    return [eA, _A, zs].indexOf(a) !== -1 ? ye : a;
  }));
  var i = A.wordBreak === "keep-all" ? n.map(function(a, B) {
    return a && t[B] >= 19968 && t[B] <= 40959;
  }) : void 0;
  return [r, s, i];
}, Ba = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.codePoints = A, this.required = e === js, this.start = r, this.end = s;
    }
    return t.prototype.slice = function() {
      return V.apply(void 0, this.codePoints.slice(this.start, this.end));
    }, t;
  }()
), oa = function(t, A) {
  var e = pt(t), r = aa(e, A), s = r[0], n = r[1], i = r[2], a = e.length, B = 0, o = 0;
  return {
    next: function() {
      if (o >= a)
        return { done: !0, value: null };
      for (var c = b; o < a && (c = ia(e, n, s, ++o, i)) === b; )
        ;
      if (c !== b || o === a) {
        var l = new Ba(e, c, B, o);
        return B = o, { value: l, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, ca = 1 << 0, la = 1 << 1, be = 1 << 2, Yr = 1 << 3, at = 10, Zr = 47, Ee = 92, ga = 9, ua = 32, Ve = 34, ge = 61, wa = 35, Qa = 36, fa = 37, Pe = 39, ke = 40, ue = 41, Ca = 95, AA = 45, ha = 33, Ua = 60, Fa = 62, da = 64, pa = 91, Ea = 93, Ha = 61, va = 123, _e = 63, ma = 125, zr = 124, Ia = 126, ya = 128, jr = 65533, Ot = 42, XA = 43, Ka = 44, La = 58, ba = 59, Ke = 46, Da = 0, Sa = 8, Ta = 11, xa = 14, Ma = 31, Oa = 127, wA = -1, $s = 48, An = 97, en = 101, Ga = 102, Ra = 117, Na = 122, tn = 65, rn = 69, sn = 70, Va = 85, Pa = 90, z = function(t) {
  return t >= $s && t <= 57;
}, ka = function(t) {
  return t >= 55296 && t <= 57343;
}, $A = function(t) {
  return z(t) || t >= tn && t <= sn || t >= An && t <= Ga;
}, _a = function(t) {
  return t >= An && t <= Na;
}, Xa = function(t) {
  return t >= tn && t <= Pa;
}, Ja = function(t) {
  return _a(t) || Xa(t);
}, Wa = function(t) {
  return t >= ya;
}, Xe = function(t) {
  return t === at || t === ga || t === ua;
}, Bt = function(t) {
  return Ja(t) || Wa(t) || t === Ca;
}, qr = function(t) {
  return Bt(t) || z(t) || t === AA;
}, Ya = function(t) {
  return t >= Da && t <= Sa || t === Ta || t >= xa && t <= Ma || t === Oa;
}, DA = function(t, A) {
  return t !== Ee ? !1 : A !== at;
}, Je = function(t, A, e) {
  return t === AA ? Bt(A) || DA(A, e) : Bt(t) ? !0 : !!(t === Ee && DA(t, A));
}, Gt = function(t, A, e) {
  return t === XA || t === AA ? z(A) ? !0 : A === Ke && z(e) : z(t === Ke ? A : t);
}, Za = function(t) {
  var A = 0, e = 1;
  (t[A] === XA || t[A] === AA) && (t[A] === AA && (e = -1), A++);
  for (var r = []; z(t[A]); )
    r.push(t[A++]);
  var s = r.length ? parseInt(V.apply(void 0, r), 10) : 0;
  t[A] === Ke && A++;
  for (var n = []; z(t[A]); )
    n.push(t[A++]);
  var i = n.length, a = i ? parseInt(V.apply(void 0, n), 10) : 0;
  (t[A] === rn || t[A] === en) && A++;
  var B = 1;
  (t[A] === XA || t[A] === AA) && (t[A] === AA && (B = -1), A++);
  for (var o = []; z(t[A]); )
    o.push(t[A++]);
  var c = o.length ? parseInt(V.apply(void 0, o), 10) : 0;
  return e * (s + a * Math.pow(10, -i)) * Math.pow(10, B * c);
}, za = {
  type: 2
  /* LEFT_PARENTHESIS_TOKEN */
}, ja = {
  type: 3
  /* RIGHT_PARENTHESIS_TOKEN */
}, qa = {
  type: 4
  /* COMMA_TOKEN */
}, $a = {
  type: 13
  /* SUFFIX_MATCH_TOKEN */
}, AB = {
  type: 8
  /* PREFIX_MATCH_TOKEN */
}, eB = {
  type: 21
  /* COLUMN_TOKEN */
}, tB = {
  type: 9
  /* DASH_MATCH_TOKEN */
}, rB = {
  type: 10
  /* INCLUDE_MATCH_TOKEN */
}, sB = {
  type: 11
  /* LEFT_CURLY_BRACKET_TOKEN */
}, nB = {
  type: 12
  /* RIGHT_CURLY_BRACKET_TOKEN */
}, iB = {
  type: 14
  /* SUBSTRING_MATCH_TOKEN */
}, We = {
  type: 23
  /* BAD_URL_TOKEN */
}, aB = {
  type: 1
  /* BAD_STRING_TOKEN */
}, BB = {
  type: 25
  /* CDO_TOKEN */
}, oB = {
  type: 24
  /* CDC_TOKEN */
}, cB = {
  type: 26
  /* COLON_TOKEN */
}, lB = {
  type: 27
  /* SEMICOLON_TOKEN */
}, gB = {
  type: 28
  /* LEFT_SQUARE_BRACKET_TOKEN */
}, uB = {
  type: 29
  /* RIGHT_SQUARE_BRACKET_TOKEN */
}, wB = {
  type: 31
  /* WHITESPACE_TOKEN */
}, lr = {
  type: 32
  /* EOF_TOKEN */
}, nn = (
  /** @class */
  function() {
    function t() {
      this._value = [];
    }
    return t.prototype.write = function(A) {
      this._value = this._value.concat(pt(A));
    }, t.prototype.read = function() {
      for (var A = [], e = this.consumeToken(); e !== lr; )
        A.push(e), e = this.consumeToken();
      return A;
    }, t.prototype.consumeToken = function() {
      var A = this.consumeCodePoint();
      switch (A) {
        case Ve:
          return this.consumeStringToken(Ve);
        case wa:
          var e = this.peekCodePoint(0), r = this.peekCodePoint(1), s = this.peekCodePoint(2);
          if (qr(e) || DA(r, s)) {
            var n = Je(e, r, s) ? la : ca, i = this.consumeName();
            return { type: 5, value: i, flags: n };
          }
          break;
        case Qa:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), $a;
          break;
        case Pe:
          return this.consumeStringToken(Pe);
        case ke:
          return za;
        case ue:
          return ja;
        case Ot:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), iB;
          break;
        case XA:
          if (Gt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case Ka:
          return qa;
        case AA:
          var a = A, B = this.peekCodePoint(0), o = this.peekCodePoint(1);
          if (Gt(a, B, o))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          if (Je(a, B, o))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          if (B === AA && o === Fa)
            return this.consumeCodePoint(), this.consumeCodePoint(), oB;
          break;
        case Ke:
          if (Gt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case Zr:
          if (this.peekCodePoint(0) === Ot)
            for (this.consumeCodePoint(); ; ) {
              var c = this.consumeCodePoint();
              if (c === Ot && (c = this.consumeCodePoint(), c === Zr))
                return this.consumeToken();
              if (c === wA)
                return this.consumeToken();
            }
          break;
        case La:
          return cB;
        case ba:
          return lB;
        case Ua:
          if (this.peekCodePoint(0) === ha && this.peekCodePoint(1) === AA && this.peekCodePoint(2) === AA)
            return this.consumeCodePoint(), this.consumeCodePoint(), BB;
          break;
        case da:
          var l = this.peekCodePoint(0), g = this.peekCodePoint(1), Q = this.peekCodePoint(2);
          if (Je(l, g, Q)) {
            var i = this.consumeName();
            return { type: 7, value: i };
          }
          break;
        case pa:
          return gB;
        case Ee:
          if (DA(A, this.peekCodePoint(0)))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          break;
        case Ea:
          return uB;
        case Ha:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), AB;
          break;
        case va:
          return sB;
        case ma:
          return nB;
        case Ra:
        case Va:
          var u = this.peekCodePoint(0), w = this.peekCodePoint(1);
          return u === XA && ($A(w) || w === _e) && (this.consumeCodePoint(), this.consumeUnicodeRangeToken()), this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
        case zr:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), tB;
          if (this.peekCodePoint(0) === zr)
            return this.consumeCodePoint(), eB;
          break;
        case Ia:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), rB;
          break;
        case wA:
          return lr;
      }
      return Xe(A) ? (this.consumeWhiteSpace(), wB) : z(A) ? (this.reconsumeCodePoint(A), this.consumeNumericToken()) : Bt(A) ? (this.reconsumeCodePoint(A), this.consumeIdentLikeToken()) : { type: 6, value: V(A) };
    }, t.prototype.consumeCodePoint = function() {
      var A = this._value.shift();
      return typeof A > "u" ? -1 : A;
    }, t.prototype.reconsumeCodePoint = function(A) {
      this._value.unshift(A);
    }, t.prototype.peekCodePoint = function(A) {
      return A >= this._value.length ? -1 : this._value[A];
    }, t.prototype.consumeUnicodeRangeToken = function() {
      for (var A = [], e = this.consumeCodePoint(); $A(e) && A.length < 6; )
        A.push(e), e = this.consumeCodePoint();
      for (var r = !1; e === _e && A.length < 6; )
        A.push(e), e = this.consumeCodePoint(), r = !0;
      if (r) {
        var s = parseInt(V.apply(void 0, A.map(function(B) {
          return B === _e ? $s : B;
        })), 16), n = parseInt(V.apply(void 0, A.map(function(B) {
          return B === _e ? sn : B;
        })), 16);
        return { type: 30, start: s, end: n };
      }
      var i = parseInt(V.apply(void 0, A), 16);
      if (this.peekCodePoint(0) === AA && $A(this.peekCodePoint(1))) {
        this.consumeCodePoint(), e = this.consumeCodePoint();
        for (var a = []; $A(e) && a.length < 6; )
          a.push(e), e = this.consumeCodePoint();
        var n = parseInt(V.apply(void 0, a), 16);
        return { type: 30, start: i, end: n };
      } else
        return { type: 30, start: i, end: i };
    }, t.prototype.consumeIdentLikeToken = function() {
      var A = this.consumeName();
      return A.toLowerCase() === "url" && this.peekCodePoint(0) === ke ? (this.consumeCodePoint(), this.consumeUrlToken()) : this.peekCodePoint(0) === ke ? (this.consumeCodePoint(), { type: 19, value: A }) : { type: 20, value: A };
    }, t.prototype.consumeUrlToken = function() {
      var A = [];
      if (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA)
        return { type: 22, value: "" };
      var e = this.peekCodePoint(0);
      if (e === Pe || e === Ve) {
        var r = this.consumeStringToken(this.consumeCodePoint());
        return r.type === 0 && (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === ue) ? (this.consumeCodePoint(), { type: 22, value: r.value }) : (this.consumeBadUrlRemnants(), We);
      }
      for (; ; ) {
        var s = this.consumeCodePoint();
        if (s === wA || s === ue)
          return { type: 22, value: V.apply(void 0, A) };
        if (Xe(s))
          return this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === ue ? (this.consumeCodePoint(), { type: 22, value: V.apply(void 0, A) }) : (this.consumeBadUrlRemnants(), We);
        if (s === Ve || s === Pe || s === ke || Ya(s))
          return this.consumeBadUrlRemnants(), We;
        if (s === Ee)
          if (DA(s, this.peekCodePoint(0)))
            A.push(this.consumeEscapedCodePoint());
          else
            return this.consumeBadUrlRemnants(), We;
        else
          A.push(s);
      }
    }, t.prototype.consumeWhiteSpace = function() {
      for (; Xe(this.peekCodePoint(0)); )
        this.consumeCodePoint();
    }, t.prototype.consumeBadUrlRemnants = function() {
      for (; ; ) {
        var A = this.consumeCodePoint();
        if (A === ue || A === wA)
          return;
        DA(A, this.peekCodePoint(0)) && this.consumeEscapedCodePoint();
      }
    }, t.prototype.consumeStringSlice = function(A) {
      for (var e = 5e4, r = ""; A > 0; ) {
        var s = Math.min(e, A);
        r += V.apply(void 0, this._value.splice(0, s)), A -= s;
      }
      return this._value.shift(), r;
    }, t.prototype.consumeStringToken = function(A) {
      var e = "", r = 0;
      do {
        var s = this._value[r];
        if (s === wA || s === void 0 || s === A)
          return e += this.consumeStringSlice(r), { type: 0, value: e };
        if (s === at)
          return this._value.splice(0, r), aB;
        if (s === Ee) {
          var n = this._value[r + 1];
          n !== wA && n !== void 0 && (n === at ? (e += this.consumeStringSlice(r), r = -1, this._value.shift()) : DA(s, n) && (e += this.consumeStringSlice(r), e += V(this.consumeEscapedCodePoint()), r = -1));
        }
        r++;
      } while (!0);
    }, t.prototype.consumeNumber = function() {
      var A = [], e = be, r = this.peekCodePoint(0);
      for ((r === XA || r === AA) && A.push(this.consumeCodePoint()); z(this.peekCodePoint(0)); )
        A.push(this.consumeCodePoint());
      r = this.peekCodePoint(0);
      var s = this.peekCodePoint(1);
      if (r === Ke && z(s))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = Yr; z(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      r = this.peekCodePoint(0), s = this.peekCodePoint(1);
      var n = this.peekCodePoint(2);
      if ((r === rn || r === en) && ((s === XA || s === AA) && z(n) || z(s)))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = Yr; z(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      return [Za(A), e];
    }, t.prototype.consumeNumericToken = function() {
      var A = this.consumeNumber(), e = A[0], r = A[1], s = this.peekCodePoint(0), n = this.peekCodePoint(1), i = this.peekCodePoint(2);
      if (Je(s, n, i)) {
        var a = this.consumeName();
        return { type: 15, number: e, flags: r, unit: a };
      }
      return s === fa ? (this.consumeCodePoint(), { type: 16, number: e, flags: r }) : { type: 17, number: e, flags: r };
    }, t.prototype.consumeEscapedCodePoint = function() {
      var A = this.consumeCodePoint();
      if ($A(A)) {
        for (var e = V(A); $A(this.peekCodePoint(0)) && e.length < 6; )
          e += V(this.consumeCodePoint());
        Xe(this.peekCodePoint(0)) && this.consumeCodePoint();
        var r = parseInt(e, 16);
        return r === 0 || ka(r) || r > 1114111 ? jr : r;
      }
      return A === wA ? jr : A;
    }, t.prototype.consumeName = function() {
      for (var A = ""; ; ) {
        var e = this.consumeCodePoint();
        if (qr(e))
          A += V(e);
        else if (DA(e, this.peekCodePoint(0)))
          A += V(this.consumeEscapedCodePoint());
        else
          return this.reconsumeCodePoint(e), A;
      }
    }, t;
  }()
), an = (
  /** @class */
  function() {
    function t(A) {
      this._tokens = A;
    }
    return t.create = function(A) {
      var e = new nn();
      return e.write(A), new t(e.read());
    }, t.parseValue = function(A) {
      return t.create(A).parseComponentValue();
    }, t.parseValues = function(A) {
      return t.create(A).parseComponentValues();
    }, t.prototype.parseComponentValue = function() {
      for (var A = this.consumeToken(); A.type === 31; )
        A = this.consumeToken();
      if (A.type === 32)
        throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
      this.reconsumeToken(A);
      var e = this.consumeComponentValue();
      do
        A = this.consumeToken();
      while (A.type === 31);
      if (A.type === 32)
        return e;
      throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
    }, t.prototype.parseComponentValues = function() {
      for (var A = []; ; ) {
        var e = this.consumeComponentValue();
        if (e.type === 32)
          return A;
        A.push(e), A.push();
      }
    }, t.prototype.consumeComponentValue = function() {
      var A = this.consumeToken();
      switch (A.type) {
        case 11:
        case 28:
        case 2:
          return this.consumeSimpleBlock(A.type);
        case 19:
          return this.consumeFunction(A);
      }
      return A;
    }, t.prototype.consumeSimpleBlock = function(A) {
      for (var e = { type: A, values: [] }, r = this.consumeToken(); ; ) {
        if (r.type === 32 || fB(r, A))
          return e;
        this.reconsumeToken(r), e.values.push(this.consumeComponentValue()), r = this.consumeToken();
      }
    }, t.prototype.consumeFunction = function(A) {
      for (var e = {
        name: A.value,
        values: [],
        type: 18
        /* FUNCTION */
      }; ; ) {
        var r = this.consumeToken();
        if (r.type === 32 || r.type === 3)
          return e;
        this.reconsumeToken(r), e.values.push(this.consumeComponentValue());
      }
    }, t.prototype.consumeToken = function() {
      var A = this._tokens.shift();
      return typeof A > "u" ? lr : A;
    }, t.prototype.reconsumeToken = function(A) {
      this._tokens.unshift(A);
    }, t;
  }()
), De = function(t) {
  return t.type === 15;
}, Be = function(t) {
  return t.type === 17;
}, T = function(t) {
  return t.type === 20;
}, QB = function(t) {
  return t.type === 0;
}, gr = function(t, A) {
  return T(t) && t.value === A;
}, Bn = function(t) {
  return t.type !== 31;
}, ae = function(t) {
  return t.type !== 31 && t.type !== 4;
}, fA = function(t) {
  var A = [], e = [];
  return t.forEach(function(r) {
    if (r.type === 4) {
      if (e.length === 0)
        throw new Error("Error parsing function args, zero tokens for arg");
      A.push(e), e = [];
      return;
    }
    r.type !== 31 && e.push(r);
  }), e.length && A.push(e), A;
}, fB = function(t, A) {
  return A === 11 && t.type === 12 || A === 28 && t.type === 29 ? !0 : A === 2 && t.type === 3;
}, GA = function(t) {
  return t.type === 17 || t.type === 15;
}, P = function(t) {
  return t.type === 16 || GA(t);
}, on = function(t) {
  return t.length > 1 ? [t[0], t[1]] : [t[0]];
}, W = {
  type: 17,
  number: 0,
  flags: be
}, mr = {
  type: 16,
  number: 50,
  flags: be
}, TA = {
  type: 16,
  number: 100,
  flags: be
}, Ue = function(t, A, e) {
  var r = t[0], s = t[1];
  return [M(r, A), M(typeof s < "u" ? s : r, e)];
}, M = function(t, A) {
  if (t.type === 16)
    return t.number / 100 * A;
  if (De(t))
    switch (t.unit) {
      case "rem":
      case "em":
        return 16 * t.number;
      case "px":
      default:
        return t.number;
    }
  return t.number;
}, cn = "deg", ln = "grad", gn = "rad", un = "turn", Et = {
  name: "angle",
  parse: function(t, A) {
    if (A.type === 15)
      switch (A.unit) {
        case cn:
          return Math.PI * A.number / 180;
        case ln:
          return Math.PI / 200 * A.number;
        case gn:
          return A.number;
        case un:
          return Math.PI * 2 * A.number;
      }
    throw new Error("Unsupported angle type");
  }
}, wn = function(t) {
  return t.type === 15 && (t.unit === cn || t.unit === ln || t.unit === gn || t.unit === un);
}, Qn = function(t) {
  var A = t.filter(T).map(function(e) {
    return e.value;
  }).join(" ");
  switch (A) {
    case "to bottom right":
    case "to right bottom":
    case "left top":
    case "top left":
      return [W, W];
    case "to top":
    case "bottom":
      return iA(0);
    case "to bottom left":
    case "to left bottom":
    case "right top":
    case "top right":
      return [W, TA];
    case "to right":
    case "left":
      return iA(90);
    case "to top left":
    case "to left top":
    case "right bottom":
    case "bottom right":
      return [TA, TA];
    case "to bottom":
    case "top":
      return iA(180);
    case "to top right":
    case "to right top":
    case "left bottom":
    case "bottom left":
      return [TA, W];
    case "to left":
    case "right":
      return iA(270);
  }
  return 0;
}, iA = function(t) {
  return Math.PI * t / 180;
}, MA = {
  name: "color",
  parse: function(t, A) {
    if (A.type === 18) {
      var e = CB[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported color function "' + A.name + '"');
      return e(t, A.values);
    }
    if (A.type === 5) {
      if (A.value.length === 3) {
        var r = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3);
        return xA(parseInt(r + r, 16), parseInt(s + s, 16), parseInt(n + n, 16), 1);
      }
      if (A.value.length === 4) {
        var r = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3), i = A.value.substring(3, 4);
        return xA(parseInt(r + r, 16), parseInt(s + s, 16), parseInt(n + n, 16), parseInt(i + i, 16) / 255);
      }
      if (A.value.length === 6) {
        var r = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6);
        return xA(parseInt(r, 16), parseInt(s, 16), parseInt(n, 16), 1);
      }
      if (A.value.length === 8) {
        var r = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6), i = A.value.substring(6, 8);
        return xA(parseInt(r, 16), parseInt(s, 16), parseInt(n, 16), parseInt(i, 16) / 255);
      }
    }
    if (A.type === 20) {
      var a = HA[A.value.toUpperCase()];
      if (typeof a < "u")
        return a;
    }
    return HA.TRANSPARENT;
  }
}, OA = function(t) {
  return (255 & t) === 0;
}, _ = function(t) {
  var A = 255 & t, e = 255 & t >> 8, r = 255 & t >> 16, s = 255 & t >> 24;
  return A < 255 ? "rgba(" + s + "," + r + "," + e + "," + A / 255 + ")" : "rgb(" + s + "," + r + "," + e + ")";
}, xA = function(t, A, e, r) {
  return (t << 24 | A << 16 | e << 8 | Math.round(r * 255) << 0) >>> 0;
}, $r = function(t, A) {
  if (t.type === 17)
    return t.number;
  if (t.type === 16) {
    var e = A === 3 ? 1 : 255;
    return A === 3 ? t.number / 100 * e : Math.round(t.number / 100 * e);
  }
  return 0;
}, As = function(t, A) {
  var e = A.filter(ae);
  if (e.length === 3) {
    var r = e.map($r), s = r[0], n = r[1], i = r[2];
    return xA(s, n, i, 1);
  }
  if (e.length === 4) {
    var a = e.map($r), s = a[0], n = a[1], i = a[2], B = a[3];
    return xA(s, n, i, B);
  }
  return 0;
};
function Rt(t, A, e) {
  return e < 0 && (e += 1), e >= 1 && (e -= 1), e < 1 / 6 ? (A - t) * e * 6 + t : e < 1 / 2 ? A : e < 2 / 3 ? (A - t) * 6 * (2 / 3 - e) + t : t;
}
var es = function(t, A) {
  var e = A.filter(ae), r = e[0], s = e[1], n = e[2], i = e[3], a = (r.type === 17 ? iA(r.number) : Et.parse(t, r)) / (Math.PI * 2), B = P(s) ? s.number / 100 : 0, o = P(n) ? n.number / 100 : 0, c = typeof i < "u" && P(i) ? M(i, 1) : 1;
  if (B === 0)
    return xA(o * 255, o * 255, o * 255, 1);
  var l = o <= 0.5 ? o * (B + 1) : o + B - o * B, g = o * 2 - l, Q = Rt(g, l, a + 1 / 3), u = Rt(g, l, a), w = Rt(g, l, a - 1 / 3);
  return xA(Q * 255, u * 255, w * 255, c);
}, CB = {
  hsl: es,
  hsla: es,
  rgb: As,
  rgba: As
}, He = function(t, A) {
  return MA.parse(t, an.create(A).parseComponentValue());
}, HA = {
  ALICEBLUE: 4042850303,
  ANTIQUEWHITE: 4209760255,
  AQUA: 16777215,
  AQUAMARINE: 2147472639,
  AZURE: 4043309055,
  BEIGE: 4126530815,
  BISQUE: 4293182719,
  BLACK: 255,
  BLANCHEDALMOND: 4293643775,
  BLUE: 65535,
  BLUEVIOLET: 2318131967,
  BROWN: 2771004159,
  BURLYWOOD: 3736635391,
  CADETBLUE: 1604231423,
  CHARTREUSE: 2147418367,
  CHOCOLATE: 3530104575,
  CORAL: 4286533887,
  CORNFLOWERBLUE: 1687547391,
  CORNSILK: 4294499583,
  CRIMSON: 3692313855,
  CYAN: 16777215,
  DARKBLUE: 35839,
  DARKCYAN: 9145343,
  DARKGOLDENROD: 3095837695,
  DARKGRAY: 2846468607,
  DARKGREEN: 6553855,
  DARKGREY: 2846468607,
  DARKKHAKI: 3182914559,
  DARKMAGENTA: 2332068863,
  DARKOLIVEGREEN: 1433087999,
  DARKORANGE: 4287365375,
  DARKORCHID: 2570243327,
  DARKRED: 2332033279,
  DARKSALMON: 3918953215,
  DARKSEAGREEN: 2411499519,
  DARKSLATEBLUE: 1211993087,
  DARKSLATEGRAY: 793726975,
  DARKSLATEGREY: 793726975,
  DARKTURQUOISE: 13554175,
  DARKVIOLET: 2483082239,
  DEEPPINK: 4279538687,
  DEEPSKYBLUE: 12582911,
  DIMGRAY: 1768516095,
  DIMGREY: 1768516095,
  DODGERBLUE: 512819199,
  FIREBRICK: 2988581631,
  FLORALWHITE: 4294635775,
  FORESTGREEN: 579543807,
  FUCHSIA: 4278255615,
  GAINSBORO: 3705462015,
  GHOSTWHITE: 4177068031,
  GOLD: 4292280575,
  GOLDENROD: 3668254975,
  GRAY: 2155905279,
  GREEN: 8388863,
  GREENYELLOW: 2919182335,
  GREY: 2155905279,
  HONEYDEW: 4043305215,
  HOTPINK: 4285117695,
  INDIANRED: 3445382399,
  INDIGO: 1258324735,
  IVORY: 4294963455,
  KHAKI: 4041641215,
  LAVENDER: 3873897215,
  LAVENDERBLUSH: 4293981695,
  LAWNGREEN: 2096890111,
  LEMONCHIFFON: 4294626815,
  LIGHTBLUE: 2916673279,
  LIGHTCORAL: 4034953471,
  LIGHTCYAN: 3774873599,
  LIGHTGOLDENRODYELLOW: 4210742015,
  LIGHTGRAY: 3553874943,
  LIGHTGREEN: 2431553791,
  LIGHTGREY: 3553874943,
  LIGHTPINK: 4290167295,
  LIGHTSALMON: 4288707327,
  LIGHTSEAGREEN: 548580095,
  LIGHTSKYBLUE: 2278488831,
  LIGHTSLATEGRAY: 2005441023,
  LIGHTSLATEGREY: 2005441023,
  LIGHTSTEELBLUE: 2965692159,
  LIGHTYELLOW: 4294959359,
  LIME: 16711935,
  LIMEGREEN: 852308735,
  LINEN: 4210091775,
  MAGENTA: 4278255615,
  MAROON: 2147483903,
  MEDIUMAQUAMARINE: 1724754687,
  MEDIUMBLUE: 52735,
  MEDIUMORCHID: 3126187007,
  MEDIUMPURPLE: 2473647103,
  MEDIUMSEAGREEN: 1018393087,
  MEDIUMSLATEBLUE: 2070474495,
  MEDIUMSPRINGGREEN: 16423679,
  MEDIUMTURQUOISE: 1221709055,
  MEDIUMVIOLETRED: 3340076543,
  MIDNIGHTBLUE: 421097727,
  MINTCREAM: 4127193855,
  MISTYROSE: 4293190143,
  MOCCASIN: 4293178879,
  NAVAJOWHITE: 4292783615,
  NAVY: 33023,
  OLDLACE: 4260751103,
  OLIVE: 2155872511,
  OLIVEDRAB: 1804477439,
  ORANGE: 4289003775,
  ORANGERED: 4282712319,
  ORCHID: 3664828159,
  PALEGOLDENROD: 4008225535,
  PALEGREEN: 2566625535,
  PALETURQUOISE: 2951671551,
  PALEVIOLETRED: 3681588223,
  PAPAYAWHIP: 4293907967,
  PEACHPUFF: 4292524543,
  PERU: 3448061951,
  PINK: 4290825215,
  PLUM: 3718307327,
  POWDERBLUE: 2967529215,
  PURPLE: 2147516671,
  REBECCAPURPLE: 1714657791,
  RED: 4278190335,
  ROSYBROWN: 3163525119,
  ROYALBLUE: 1097458175,
  SADDLEBROWN: 2336560127,
  SALMON: 4202722047,
  SANDYBROWN: 4104413439,
  SEAGREEN: 780883967,
  SEASHELL: 4294307583,
  SIENNA: 2689740287,
  SILVER: 3233857791,
  SKYBLUE: 2278484991,
  SLATEBLUE: 1784335871,
  SLATEGRAY: 1887473919,
  SLATEGREY: 1887473919,
  SNOW: 4294638335,
  SPRINGGREEN: 16744447,
  STEELBLUE: 1182971135,
  TAN: 3535047935,
  TEAL: 8421631,
  THISTLE: 3636451583,
  TOMATO: 4284696575,
  TRANSPARENT: 0,
  TURQUOISE: 1088475391,
  VIOLET: 4001558271,
  WHEAT: 4125012991,
  WHITE: 4294967295,
  WHITESMOKE: 4126537215,
  YELLOW: 4294902015,
  YELLOWGREEN: 2597139199
}, hB = {
  name: "background-clip",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.map(function(e) {
      if (T(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, UB = {
  name: "background-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, Ht = function(t, A) {
  var e = MA.parse(t, A[0]), r = A[1];
  return r && P(r) ? { color: e, stop: r } : { color: e, stop: null };
}, ts = function(t, A) {
  var e = t[0], r = t[t.length - 1];
  e.stop === null && (e.stop = W), r.stop === null && (r.stop = TA);
  for (var s = [], n = 0, i = 0; i < t.length; i++) {
    var a = t[i].stop;
    if (a !== null) {
      var B = M(a, A);
      B > n ? s.push(B) : s.push(n), n = B;
    } else
      s.push(null);
  }
  for (var o = null, i = 0; i < s.length; i++) {
    var c = s[i];
    if (c === null)
      o === null && (o = i);
    else if (o !== null) {
      for (var l = i - o, g = s[o - 1], Q = (c - g) / (l + 1), u = 1; u <= l; u++)
        s[o + u - 1] = Q * u;
      o = null;
    }
  }
  return t.map(function(w, E) {
    var C = w.color;
    return { color: C, stop: Math.max(Math.min(1, s[E] / A), 0) };
  });
}, FB = function(t, A, e) {
  var r = A / 2, s = e / 2, n = M(t[0], A) - r, i = s - M(t[1], e);
  return (Math.atan2(i, n) + Math.PI * 2) % (Math.PI * 2);
}, dB = function(t, A, e) {
  var r = typeof t == "number" ? t : FB(t, A, e), s = Math.abs(A * Math.sin(r)) + Math.abs(e * Math.cos(r)), n = A / 2, i = e / 2, a = s / 2, B = Math.sin(r - Math.PI / 2) * a, o = Math.cos(r - Math.PI / 2) * a;
  return [s, n - o, n + o, i - B, i + B];
}, cA = function(t, A) {
  return Math.sqrt(t * t + A * A);
}, rs = function(t, A, e, r, s) {
  var n = [
    [0, 0],
    [0, A],
    [t, 0],
    [t, A]
  ];
  return n.reduce(function(i, a) {
    var B = a[0], o = a[1], c = cA(e - B, r - o);
    return (s ? c < i.optimumDistance : c > i.optimumDistance) ? {
      optimumCorner: a,
      optimumDistance: c
    } : i;
  }, {
    optimumDistance: s ? 1 / 0 : -1 / 0,
    optimumCorner: null
  }).optimumCorner;
}, pB = function(t, A, e, r, s) {
  var n = 0, i = 0;
  switch (t.size) {
    case 0:
      t.shape === 0 ? n = i = Math.min(Math.abs(A), Math.abs(A - r), Math.abs(e), Math.abs(e - s)) : t.shape === 1 && (n = Math.min(Math.abs(A), Math.abs(A - r)), i = Math.min(Math.abs(e), Math.abs(e - s)));
      break;
    case 2:
      if (t.shape === 0)
        n = i = Math.min(cA(A, e), cA(A, e - s), cA(A - r, e), cA(A - r, e - s));
      else if (t.shape === 1) {
        var a = Math.min(Math.abs(e), Math.abs(e - s)) / Math.min(Math.abs(A), Math.abs(A - r)), B = rs(r, s, A, e, !0), o = B[0], c = B[1];
        n = cA(o - A, (c - e) / a), i = a * n;
      }
      break;
    case 1:
      t.shape === 0 ? n = i = Math.max(Math.abs(A), Math.abs(A - r), Math.abs(e), Math.abs(e - s)) : t.shape === 1 && (n = Math.max(Math.abs(A), Math.abs(A - r)), i = Math.max(Math.abs(e), Math.abs(e - s)));
      break;
    case 3:
      if (t.shape === 0)
        n = i = Math.max(cA(A, e), cA(A, e - s), cA(A - r, e), cA(A - r, e - s));
      else if (t.shape === 1) {
        var a = Math.max(Math.abs(e), Math.abs(e - s)) / Math.max(Math.abs(A), Math.abs(A - r)), l = rs(r, s, A, e, !1), o = l[0], c = l[1];
        n = cA(o - A, (c - e) / a), i = a * n;
      }
      break;
  }
  return Array.isArray(t.size) && (n = M(t.size[0], r), i = t.size.length === 2 ? M(t.size[1], s) : n), [n, i];
}, EB = function(t, A) {
  var e = iA(180), r = [];
  return fA(A).forEach(function(s, n) {
    if (n === 0) {
      var i = s[0];
      if (i.type === 20 && i.value === "to") {
        e = Qn(s);
        return;
      } else if (wn(i)) {
        e = Et.parse(t, i);
        return;
      }
    }
    var a = Ht(t, s);
    r.push(a);
  }), {
    angle: e,
    stops: r,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, Ye = function(t, A) {
  var e = iA(180), r = [];
  return fA(A).forEach(function(s, n) {
    if (n === 0) {
      var i = s[0];
      if (i.type === 20 && ["top", "left", "right", "bottom"].indexOf(i.value) !== -1) {
        e = Qn(s);
        return;
      } else if (wn(i)) {
        e = (Et.parse(t, i) + iA(270)) % iA(360);
        return;
      }
    }
    var a = Ht(t, s);
    r.push(a);
  }), {
    angle: e,
    stops: r,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, HB = function(t, A) {
  var e = iA(180), r = [], s = 1, n = 0, i = 3, a = [];
  return fA(A).forEach(function(B, o) {
    var c = B[0];
    if (o === 0) {
      if (T(c) && c.value === "linear") {
        s = 1;
        return;
      } else if (T(c) && c.value === "radial") {
        s = 2;
        return;
      }
    }
    if (c.type === 18) {
      if (c.name === "from") {
        var l = MA.parse(t, c.values[0]);
        r.push({ stop: W, color: l });
      } else if (c.name === "to") {
        var l = MA.parse(t, c.values[0]);
        r.push({ stop: TA, color: l });
      } else if (c.name === "color-stop") {
        var g = c.values.filter(ae);
        if (g.length === 2) {
          var l = MA.parse(t, g[1]), Q = g[0];
          Be(Q) && r.push({
            stop: { type: 16, number: Q.number * 100, flags: Q.flags },
            color: l
          });
        }
      }
    }
  }), s === 1 ? {
    angle: (e + iA(180)) % iA(360),
    stops: r,
    type: s
  } : { size: i, shape: n, stops: r, position: a, type: s };
}, fn = "closest-side", Cn = "farthest-side", hn = "closest-corner", Un = "farthest-corner", Fn = "circle", dn = "ellipse", pn = "cover", En = "contain", vB = function(t, A) {
  var e = 0, r = 3, s = [], n = [];
  return fA(A).forEach(function(i, a) {
    var B = !0;
    if (a === 0) {
      var o = !1;
      B = i.reduce(function(l, g) {
        if (o)
          if (T(g))
            switch (g.value) {
              case "center":
                return n.push(mr), l;
              case "top":
              case "left":
                return n.push(W), l;
              case "right":
              case "bottom":
                return n.push(TA), l;
            }
          else
            (P(g) || GA(g)) && n.push(g);
        else if (T(g))
          switch (g.value) {
            case Fn:
              return e = 0, !1;
            case dn:
              return e = 1, !1;
            case "at":
              return o = !0, !1;
            case fn:
              return r = 0, !1;
            case pn:
            case Cn:
              return r = 1, !1;
            case En:
            case hn:
              return r = 2, !1;
            case Un:
              return r = 3, !1;
          }
        else if (GA(g) || P(g))
          return Array.isArray(r) || (r = []), r.push(g), !1;
        return l;
      }, B);
    }
    if (B) {
      var c = Ht(t, i);
      s.push(c);
    }
  }), {
    size: r,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, Ze = function(t, A) {
  var e = 0, r = 3, s = [], n = [];
  return fA(A).forEach(function(i, a) {
    var B = !0;
    if (a === 0 ? B = i.reduce(function(c, l) {
      if (T(l))
        switch (l.value) {
          case "center":
            return n.push(mr), !1;
          case "top":
          case "left":
            return n.push(W), !1;
          case "right":
          case "bottom":
            return n.push(TA), !1;
        }
      else if (P(l) || GA(l))
        return n.push(l), !1;
      return c;
    }, B) : a === 1 && (B = i.reduce(function(c, l) {
      if (T(l))
        switch (l.value) {
          case Fn:
            return e = 0, !1;
          case dn:
            return e = 1, !1;
          case En:
          case fn:
            return r = 0, !1;
          case Cn:
            return r = 1, !1;
          case hn:
            return r = 2, !1;
          case pn:
          case Un:
            return r = 3, !1;
        }
      else if (GA(l) || P(l))
        return Array.isArray(r) || (r = []), r.push(l), !1;
      return c;
    }, B)), B) {
      var o = Ht(t, i);
      s.push(o);
    }
  }), {
    size: r,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, mB = function(t) {
  return t.type === 1;
}, IB = function(t) {
  return t.type === 2;
}, Ir = {
  name: "image",
  parse: function(t, A) {
    if (A.type === 22) {
      var e = {
        url: A.value,
        type: 0
        /* URL */
      };
      return t.cache.addImage(A.value), e;
    }
    if (A.type === 18) {
      var r = Hn[A.name];
      if (typeof r > "u")
        throw new Error('Attempting to parse an unsupported image function "' + A.name + '"');
      return r(t, A.values);
    }
    throw new Error("Unsupported image type " + A.type);
  }
};
function yB(t) {
  return !(t.type === 20 && t.value === "none") && (t.type !== 18 || !!Hn[t.name]);
}
var Hn = {
  "linear-gradient": EB,
  "-moz-linear-gradient": Ye,
  "-ms-linear-gradient": Ye,
  "-o-linear-gradient": Ye,
  "-webkit-linear-gradient": Ye,
  "radial-gradient": vB,
  "-moz-radial-gradient": Ze,
  "-ms-radial-gradient": Ze,
  "-o-radial-gradient": Ze,
  "-webkit-radial-gradient": Ze,
  "-webkit-gradient": HB
}, KB = {
  name: "background-image",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A.filter(function(r) {
      return ae(r) && yB(r);
    }).map(function(r) {
      return Ir.parse(t, r);
    });
  }
}, LB = {
  name: "background-origin",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.map(function(e) {
      if (T(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, bB = {
  name: "background-position",
  initialValue: "0% 0%",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return fA(A).map(function(e) {
      return e.filter(P);
    }).map(on);
  }
}, DB = {
  name: "background-repeat",
  initialValue: "repeat",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return fA(A).map(function(e) {
      return e.filter(T).map(function(r) {
        return r.value;
      }).join(" ");
    }).map(SB);
  }
}, SB = function(t) {
  switch (t) {
    case "no-repeat":
      return 1;
    case "repeat-x":
    case "repeat no-repeat":
      return 2;
    case "repeat-y":
    case "no-repeat repeat":
      return 3;
    case "repeat":
    default:
      return 0;
  }
}, ie;
(function(t) {
  t.AUTO = "auto", t.CONTAIN = "contain", t.COVER = "cover";
})(ie || (ie = {}));
var TB = {
  name: "background-size",
  initialValue: "0",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return fA(A).map(function(e) {
      return e.filter(xB);
    });
  }
}, xB = function(t) {
  return T(t) || P(t);
}, vt = function(t) {
  return {
    name: "border-" + t + "-color",
    initialValue: "transparent",
    prefix: !1,
    type: 3,
    format: "color"
  };
}, MB = vt("top"), OB = vt("right"), GB = vt("bottom"), RB = vt("left"), mt = function(t) {
  return {
    name: "border-radius-" + t,
    initialValue: "0 0",
    prefix: !1,
    type: 1,
    parse: function(A, e) {
      return on(e.filter(P));
    }
  };
}, NB = mt("top-left"), VB = mt("top-right"), PB = mt("bottom-right"), kB = mt("bottom-left"), It = function(t) {
  return {
    name: "border-" + t + "-style",
    initialValue: "solid",
    prefix: !1,
    type: 2,
    parse: function(A, e) {
      switch (e) {
        case "none":
          return 0;
        case "dashed":
          return 2;
        case "dotted":
          return 3;
        case "double":
          return 4;
      }
      return 1;
    }
  };
}, _B = It("top"), XB = It("right"), JB = It("bottom"), WB = It("left"), yt = function(t) {
  return {
    name: "border-" + t + "-width",
    initialValue: "0",
    type: 0,
    prefix: !1,
    parse: function(A, e) {
      return De(e) ? e.number : 0;
    }
  };
}, YB = yt("top"), ZB = yt("right"), zB = yt("bottom"), jB = yt("left"), qB = {
  name: "color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, $B = {
  name: "direction",
  initialValue: "ltr",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "rtl":
        return 1;
      case "ltr":
      default:
        return 0;
    }
  }
}, Ao = {
  name: "display",
  initialValue: "inline-block",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(T).reduce(
      function(e, r) {
        return e | eo(r.value);
      },
      0
      /* NONE */
    );
  }
}, eo = function(t) {
  switch (t) {
    case "block":
    case "-webkit-box":
      return 2;
    case "inline":
      return 4;
    case "run-in":
      return 8;
    case "flow":
      return 16;
    case "flow-root":
      return 32;
    case "table":
      return 64;
    case "flex":
    case "-webkit-flex":
      return 128;
    case "grid":
    case "-ms-grid":
      return 256;
    case "ruby":
      return 512;
    case "subgrid":
      return 1024;
    case "list-item":
      return 2048;
    case "table-row-group":
      return 4096;
    case "table-header-group":
      return 8192;
    case "table-footer-group":
      return 16384;
    case "table-row":
      return 32768;
    case "table-cell":
      return 65536;
    case "table-column-group":
      return 131072;
    case "table-column":
      return 262144;
    case "table-caption":
      return 524288;
    case "ruby-base":
      return 1048576;
    case "ruby-text":
      return 2097152;
    case "ruby-base-container":
      return 4194304;
    case "ruby-text-container":
      return 8388608;
    case "contents":
      return 16777216;
    case "inline-block":
      return 33554432;
    case "inline-list-item":
      return 67108864;
    case "inline-table":
      return 134217728;
    case "inline-flex":
      return 268435456;
    case "inline-grid":
      return 536870912;
  }
  return 0;
}, to = {
  name: "float",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "left":
        return 1;
      case "right":
        return 2;
      case "inline-start":
        return 3;
      case "inline-end":
        return 4;
    }
    return 0;
  }
}, ro = {
  name: "letter-spacing",
  initialValue: "0",
  prefix: !1,
  type: 0,
  parse: function(t, A) {
    return A.type === 20 && A.value === "normal" ? 0 : A.type === 17 || A.type === 15 ? A.number : 0;
  }
}, ot;
(function(t) {
  t.NORMAL = "normal", t.STRICT = "strict";
})(ot || (ot = {}));
var so = {
  name: "line-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "strict":
        return ot.STRICT;
      case "normal":
      default:
        return ot.NORMAL;
    }
  }
}, no = {
  name: "line-height",
  initialValue: "normal",
  prefix: !1,
  type: 4
  /* TOKEN_VALUE */
}, ss = function(t, A) {
  return T(t) && t.value === "normal" ? 1.2 * A : t.type === 17 ? A * t.number : P(t) ? M(t, A) : A;
}, io = {
  name: "list-style-image",
  initialValue: "none",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return A.type === 20 && A.value === "none" ? null : Ir.parse(t, A);
  }
}, ao = {
  name: "list-style-position",
  initialValue: "outside",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "inside":
        return 0;
      case "outside":
      default:
        return 1;
    }
  }
}, ur = {
  name: "list-style-type",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "disc":
        return 0;
      case "circle":
        return 1;
      case "square":
        return 2;
      case "decimal":
        return 3;
      case "cjk-decimal":
        return 4;
      case "decimal-leading-zero":
        return 5;
      case "lower-roman":
        return 6;
      case "upper-roman":
        return 7;
      case "lower-greek":
        return 8;
      case "lower-alpha":
        return 9;
      case "upper-alpha":
        return 10;
      case "arabic-indic":
        return 11;
      case "armenian":
        return 12;
      case "bengali":
        return 13;
      case "cambodian":
        return 14;
      case "cjk-earthly-branch":
        return 15;
      case "cjk-heavenly-stem":
        return 16;
      case "cjk-ideographic":
        return 17;
      case "devanagari":
        return 18;
      case "ethiopic-numeric":
        return 19;
      case "georgian":
        return 20;
      case "gujarati":
        return 21;
      case "gurmukhi":
        return 22;
      case "hebrew":
        return 22;
      case "hiragana":
        return 23;
      case "hiragana-iroha":
        return 24;
      case "japanese-formal":
        return 25;
      case "japanese-informal":
        return 26;
      case "kannada":
        return 27;
      case "katakana":
        return 28;
      case "katakana-iroha":
        return 29;
      case "khmer":
        return 30;
      case "korean-hangul-formal":
        return 31;
      case "korean-hanja-formal":
        return 32;
      case "korean-hanja-informal":
        return 33;
      case "lao":
        return 34;
      case "lower-armenian":
        return 35;
      case "malayalam":
        return 36;
      case "mongolian":
        return 37;
      case "myanmar":
        return 38;
      case "oriya":
        return 39;
      case "persian":
        return 40;
      case "simp-chinese-formal":
        return 41;
      case "simp-chinese-informal":
        return 42;
      case "tamil":
        return 43;
      case "telugu":
        return 44;
      case "thai":
        return 45;
      case "tibetan":
        return 46;
      case "trad-chinese-formal":
        return 47;
      case "trad-chinese-informal":
        return 48;
      case "upper-armenian":
        return 49;
      case "disclosure-open":
        return 50;
      case "disclosure-closed":
        return 51;
      case "none":
      default:
        return -1;
    }
  }
}, Kt = function(t) {
  return {
    name: "margin-" + t,
    initialValue: "0",
    prefix: !1,
    type: 4
    /* TOKEN_VALUE */
  };
}, Bo = Kt("top"), oo = Kt("right"), co = Kt("bottom"), lo = Kt("left"), go = {
  name: "overflow",
  initialValue: "visible",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(T).map(function(e) {
      switch (e.value) {
        case "hidden":
          return 1;
        case "scroll":
          return 2;
        case "clip":
          return 3;
        case "auto":
          return 4;
        case "visible":
        default:
          return 0;
      }
    });
  }
}, uo = {
  name: "overflow-wrap",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "break-word":
        return "break-word";
      case "normal":
      default:
        return "normal";
    }
  }
}, Lt = function(t) {
  return {
    name: "padding-" + t,
    initialValue: "0",
    prefix: !1,
    type: 3,
    format: "length-percentage"
  };
}, wo = Lt("top"), Qo = Lt("right"), fo = Lt("bottom"), Co = Lt("left"), ho = {
  name: "text-align",
  initialValue: "left",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "right":
        return 2;
      case "center":
      case "justify":
        return 1;
      case "left":
      default:
        return 0;
    }
  }
}, Uo = {
  name: "position",
  initialValue: "static",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "relative":
        return 1;
      case "absolute":
        return 2;
      case "fixed":
        return 3;
      case "sticky":
        return 4;
    }
    return 0;
  }
}, Fo = {
  name: "text-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.length === 1 && gr(A[0], "none") ? [] : fA(A).map(function(e) {
      for (var r = {
        color: HA.TRANSPARENT,
        offsetX: W,
        offsetY: W,
        blur: W
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        GA(i) ? (s === 0 ? r.offsetX = i : s === 1 ? r.offsetY = i : r.blur = i, s++) : r.color = MA.parse(t, i);
      }
      return r;
    });
  }
}, po = {
  name: "text-transform",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "uppercase":
        return 2;
      case "lowercase":
        return 1;
      case "capitalize":
        return 3;
    }
    return 0;
  }
}, Eo = {
  name: "transform",
  initialValue: "none",
  prefix: !0,
  type: 0,
  parse: function(t, A) {
    if (A.type === 20 && A.value === "none")
      return null;
    if (A.type === 18) {
      var e = mo[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported transform function "' + A.name + '"');
      return e(A.values);
    }
    return null;
  }
}, Ho = function(t) {
  var A = t.filter(function(e) {
    return e.type === 17;
  }).map(function(e) {
    return e.number;
  });
  return A.length === 6 ? A : null;
}, vo = function(t) {
  var A = t.filter(function(B) {
    return B.type === 17;
  }).map(function(B) {
    return B.number;
  }), e = A[0], r = A[1];
  A[2], A[3];
  var s = A[4], n = A[5];
  A[6], A[7], A[8], A[9], A[10], A[11];
  var i = A[12], a = A[13];
  return A[14], A[15], A.length === 16 ? [e, r, s, n, i, a] : null;
}, mo = {
  matrix: Ho,
  matrix3d: vo
}, ns = {
  type: 16,
  number: 50,
  flags: be
}, Io = [ns, ns], yo = {
  name: "transform-origin",
  initialValue: "50% 50%",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    var e = A.filter(P);
    return e.length !== 2 ? Io : [e[0], e[1]];
  }
}, Ko = {
  name: "visible",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "hidden":
        return 1;
      case "collapse":
        return 2;
      case "visible":
      default:
        return 0;
    }
  }
}, ve;
(function(t) {
  t.NORMAL = "normal", t.BREAK_ALL = "break-all", t.KEEP_ALL = "keep-all";
})(ve || (ve = {}));
var Lo = {
  name: "word-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "break-all":
        return ve.BREAK_ALL;
      case "keep-all":
        return ve.KEEP_ALL;
      case "normal":
      default:
        return ve.NORMAL;
    }
  }
}, bo = {
  name: "z-index",
  initialValue: "auto",
  prefix: !1,
  type: 0,
  parse: function(t, A) {
    if (A.type === 20)
      return { auto: !0, order: 0 };
    if (Be(A))
      return { auto: !1, order: A.number };
    throw new Error("Invalid z-index number parsed");
  }
}, vn = {
  name: "time",
  parse: function(t, A) {
    if (A.type === 15)
      switch (A.unit.toLowerCase()) {
        case "s":
          return 1e3 * A.number;
        case "ms":
          return A.number;
      }
    throw new Error("Unsupported time type");
  }
}, Do = {
  name: "opacity",
  initialValue: "1",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return Be(A) ? A.number : 1;
  }
}, So = {
  name: "text-decoration-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, To = {
  name: "text-decoration-line",
  initialValue: "none",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(T).map(function(e) {
      switch (e.value) {
        case "underline":
          return 1;
        case "overline":
          return 2;
        case "line-through":
          return 3;
        case "none":
          return 4;
      }
      return 0;
    }).filter(function(e) {
      return e !== 0;
    });
  }
}, xo = {
  name: "font-family",
  initialValue: "",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    var e = [], r = [];
    return A.forEach(function(s) {
      switch (s.type) {
        case 20:
        case 0:
          e.push(s.value);
          break;
        case 17:
          e.push(s.number.toString());
          break;
        case 4:
          r.push(e.join(" ")), e.length = 0;
          break;
      }
    }), e.length && r.push(e.join(" ")), r.map(function(s) {
      return s.indexOf(" ") === -1 ? s : "'" + s + "'";
    });
  }
}, Mo = {
  name: "font-size",
  initialValue: "0",
  prefix: !1,
  type: 3,
  format: "length"
}, Oo = {
  name: "font-weight",
  initialValue: "normal",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    if (Be(A))
      return A.number;
    if (T(A))
      switch (A.value) {
        case "bold":
          return 700;
        case "normal":
        default:
          return 400;
      }
    return 400;
  }
}, Go = {
  name: "font-variant",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.filter(T).map(function(e) {
      return e.value;
    });
  }
}, Ro = {
  name: "font-style",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "oblique":
        return "oblique";
      case "italic":
        return "italic";
      case "normal":
      default:
        return "normal";
    }
  }
}, k = function(t, A) {
  return (t & A) !== 0;
}, No = {
  name: "content",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A;
  }
}, Vo = {
  name: "counter-increment",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    for (var r = [], s = A.filter(Bn), n = 0; n < s.length; n++) {
      var i = s[n], a = s[n + 1];
      if (i.type === 20) {
        var B = a && Be(a) ? a.number : 1;
        r.push({ counter: i.value, increment: B });
      }
    }
    return r;
  }
}, Po = {
  name: "counter-reset",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    for (var e = [], r = A.filter(Bn), s = 0; s < r.length; s++) {
      var n = r[s], i = r[s + 1];
      if (T(n) && n.value !== "none") {
        var a = i && Be(i) ? i.number : 0;
        e.push({ counter: n.value, reset: a });
      }
    }
    return e;
  }
}, ko = {
  name: "duration",
  initialValue: "0s",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(De).map(function(e) {
      return vn.parse(t, e);
    });
  }
}, _o = {
  name: "quotes",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    var r = [], s = A.filter(QB);
    if (s.length % 2 !== 0)
      return null;
    for (var n = 0; n < s.length; n += 2) {
      var i = s[n].value, a = s[n + 1].value;
      r.push({ open: i, close: a });
    }
    return r;
  }
}, is = function(t, A, e) {
  if (!t)
    return "";
  var r = t[Math.min(A, t.length - 1)];
  return r ? e ? r.open : r.close : "";
}, Xo = {
  name: "box-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.length === 1 && gr(A[0], "none") ? [] : fA(A).map(function(e) {
      for (var r = {
        color: 255,
        offsetX: W,
        offsetY: W,
        blur: W,
        spread: W,
        inset: !1
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        gr(i, "inset") ? r.inset = !0 : GA(i) ? (s === 0 ? r.offsetX = i : s === 1 ? r.offsetY = i : s === 2 ? r.blur = i : r.spread = i, s++) : r.color = MA.parse(t, i);
      }
      return r;
    });
  }
}, Jo = {
  name: "paint-order",
  initialValue: "normal",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    var e = [
      0,
      1,
      2
      /* MARKERS */
    ], r = [];
    return A.filter(T).forEach(function(s) {
      switch (s.value) {
        case "stroke":
          r.push(
            1
            /* STROKE */
          );
          break;
        case "fill":
          r.push(
            0
            /* FILL */
          );
          break;
        case "markers":
          r.push(
            2
            /* MARKERS */
          );
          break;
      }
    }), e.forEach(function(s) {
      r.indexOf(s) === -1 && r.push(s);
    }), r;
  }
}, Wo = {
  name: "-webkit-text-stroke-color",
  initialValue: "currentcolor",
  prefix: !1,
  type: 3,
  format: "color"
}, Yo = {
  name: "-webkit-text-stroke-width",
  initialValue: "0",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return De(A) ? A.number : 0;
  }
}, Zo = (
  /** @class */
  function() {
    function t(A, e) {
      var r, s;
      this.animationDuration = d(A, ko, e.animationDuration), this.backgroundClip = d(A, hB, e.backgroundClip), this.backgroundColor = d(A, UB, e.backgroundColor), this.backgroundImage = d(A, KB, e.backgroundImage), this.backgroundOrigin = d(A, LB, e.backgroundOrigin), this.backgroundPosition = d(A, bB, e.backgroundPosition), this.backgroundRepeat = d(A, DB, e.backgroundRepeat), this.backgroundSize = d(A, TB, e.backgroundSize), this.borderTopColor = d(A, MB, e.borderTopColor), this.borderRightColor = d(A, OB, e.borderRightColor), this.borderBottomColor = d(A, GB, e.borderBottomColor), this.borderLeftColor = d(A, RB, e.borderLeftColor), this.borderTopLeftRadius = d(A, NB, e.borderTopLeftRadius), this.borderTopRightRadius = d(A, VB, e.borderTopRightRadius), this.borderBottomRightRadius = d(A, PB, e.borderBottomRightRadius), this.borderBottomLeftRadius = d(A, kB, e.borderBottomLeftRadius), this.borderTopStyle = d(A, _B, e.borderTopStyle), this.borderRightStyle = d(A, XB, e.borderRightStyle), this.borderBottomStyle = d(A, JB, e.borderBottomStyle), this.borderLeftStyle = d(A, WB, e.borderLeftStyle), this.borderTopWidth = d(A, YB, e.borderTopWidth), this.borderRightWidth = d(A, ZB, e.borderRightWidth), this.borderBottomWidth = d(A, zB, e.borderBottomWidth), this.borderLeftWidth = d(A, jB, e.borderLeftWidth), this.boxShadow = d(A, Xo, e.boxShadow), this.color = d(A, qB, e.color), this.direction = d(A, $B, e.direction), this.display = d(A, Ao, e.display), this.float = d(A, to, e.cssFloat), this.fontFamily = d(A, xo, e.fontFamily), this.fontSize = d(A, Mo, e.fontSize), this.fontStyle = d(A, Ro, e.fontStyle), this.fontVariant = d(A, Go, e.fontVariant), this.fontWeight = d(A, Oo, e.fontWeight), this.letterSpacing = d(A, ro, e.letterSpacing), this.lineBreak = d(A, so, e.lineBreak), this.lineHeight = d(A, no, e.lineHeight), this.listStyleImage = d(A, io, e.listStyleImage), this.listStylePosition = d(A, ao, e.listStylePosition), this.listStyleType = d(A, ur, e.listStyleType), this.marginTop = d(A, Bo, e.marginTop), this.marginRight = d(A, oo, e.marginRight), this.marginBottom = d(A, co, e.marginBottom), this.marginLeft = d(A, lo, e.marginLeft), this.opacity = d(A, Do, e.opacity);
      var n = d(A, go, e.overflow);
      this.overflowX = n[0], this.overflowY = n[n.length > 1 ? 1 : 0], this.overflowWrap = d(A, uo, e.overflowWrap), this.paddingTop = d(A, wo, e.paddingTop), this.paddingRight = d(A, Qo, e.paddingRight), this.paddingBottom = d(A, fo, e.paddingBottom), this.paddingLeft = d(A, Co, e.paddingLeft), this.paintOrder = d(A, Jo, e.paintOrder), this.position = d(A, Uo, e.position), this.textAlign = d(A, ho, e.textAlign), this.textDecorationColor = d(A, So, (r = e.textDecorationColor) !== null && r !== void 0 ? r : e.color), this.textDecorationLine = d(A, To, (s = e.textDecorationLine) !== null && s !== void 0 ? s : e.textDecoration), this.textShadow = d(A, Fo, e.textShadow), this.textTransform = d(A, po, e.textTransform), this.transform = d(A, Eo, e.transform), this.transformOrigin = d(A, yo, e.transformOrigin), this.visibility = d(A, Ko, e.visibility), this.webkitTextStrokeColor = d(A, Wo, e.webkitTextStrokeColor), this.webkitTextStrokeWidth = d(A, Yo, e.webkitTextStrokeWidth), this.wordBreak = d(A, Lo, e.wordBreak), this.zIndex = d(A, bo, e.zIndex);
    }
    return t.prototype.isVisible = function() {
      return this.display > 0 && this.opacity > 0 && this.visibility === 0;
    }, t.prototype.isTransparent = function() {
      return OA(this.backgroundColor);
    }, t.prototype.isTransformed = function() {
      return this.transform !== null;
    }, t.prototype.isPositioned = function() {
      return this.position !== 0;
    }, t.prototype.isPositionedWithZIndex = function() {
      return this.isPositioned() && !this.zIndex.auto;
    }, t.prototype.isFloating = function() {
      return this.float !== 0;
    }, t.prototype.isInlineLevel = function() {
      return k(
        this.display,
        4
        /* INLINE */
      ) || k(
        this.display,
        33554432
        /* INLINE_BLOCK */
      ) || k(
        this.display,
        268435456
        /* INLINE_FLEX */
      ) || k(
        this.display,
        536870912
        /* INLINE_GRID */
      ) || k(
        this.display,
        67108864
        /* INLINE_LIST_ITEM */
      ) || k(
        this.display,
        134217728
        /* INLINE_TABLE */
      );
    }, t;
  }()
), zo = (
  /** @class */
  function() {
    function t(A, e) {
      this.content = d(A, No, e.content), this.quotes = d(A, _o, e.quotes);
    }
    return t;
  }()
), as = (
  /** @class */
  function() {
    function t(A, e) {
      this.counterIncrement = d(A, Vo, e.counterIncrement), this.counterReset = d(A, Po, e.counterReset);
    }
    return t;
  }()
), d = function(t, A, e) {
  var r = new nn(), s = e !== null && typeof e < "u" ? e.toString() : A.initialValue;
  r.write(s);
  var n = new an(r.read());
  switch (A.type) {
    case 2:
      var i = n.parseComponentValue();
      return A.parse(t, T(i) ? i.value : A.initialValue);
    case 0:
      return A.parse(t, n.parseComponentValue());
    case 1:
      return A.parse(t, n.parseComponentValues());
    case 4:
      return n.parseComponentValue();
    case 3:
      switch (A.format) {
        case "angle":
          return Et.parse(t, n.parseComponentValue());
        case "color":
          return MA.parse(t, n.parseComponentValue());
        case "image":
          return Ir.parse(t, n.parseComponentValue());
        case "length":
          var a = n.parseComponentValue();
          return GA(a) ? a : W;
        case "length-percentage":
          var B = n.parseComponentValue();
          return P(B) ? B : W;
        case "time":
          return vn.parse(t, n.parseComponentValue());
      }
      break;
  }
}, jo = "data-html2canvas-debug", qo = function(t) {
  var A = t.getAttribute(jo);
  switch (A) {
    case "all":
      return 1;
    case "clone":
      return 2;
    case "parse":
      return 3;
    case "render":
      return 4;
    default:
      return 0;
  }
}, wr = function(t, A) {
  var e = qo(t);
  return e === 1 || A === e;
}, CA = (
  /** @class */
  function() {
    function t(A, e) {
      if (this.context = A, this.textNodes = [], this.elements = [], this.flags = 0, wr(
        e,
        3
        /* PARSE */
      ))
        debugger;
      this.styles = new Zo(A, window.getComputedStyle(e, null)), Cr(e) && (this.styles.animationDuration.some(function(r) {
        return r > 0;
      }) && (e.style.animationDuration = "0s"), this.styles.transform !== null && (e.style.transform = "none")), this.bounds = dt(this.context, e), wr(
        e,
        4
        /* RENDER */
      ) && (this.flags |= 16);
    }
    return t;
  }()
), $o = " ", Bs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Fe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var ze = 0; ze < Bs.length; ze++)
  Fe[Bs.charCodeAt(ze)] = ze;
var Ac = function(t) {
  var A = t.length * 0.75, e = t.length, r, s = 0, n, i, a, B;
  t[t.length - 1] === "=" && (A--, t[t.length - 2] === "=" && A--);
  var o = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(o) ? o : new Uint8Array(o);
  for (r = 0; r < e; r += 4)
    n = Fe[t.charCodeAt(r)], i = Fe[t.charCodeAt(r + 1)], a = Fe[t.charCodeAt(r + 2)], B = Fe[t.charCodeAt(r + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | B & 63;
  return o;
}, ec = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 2)
    e.push(t[r + 1] << 8 | t[r]);
  return e;
}, tc = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 4)
    e.push(t[r + 3] << 24 | t[r + 2] << 16 | t[r + 1] << 8 | t[r]);
  return e;
}, WA = 5, yr = 6 + 5, Nt = 2, rc = yr - WA, mn = 65536 >> WA, sc = 1 << WA, Vt = sc - 1, nc = 1024 >> WA, ic = mn + nc, ac = ic, Bc = 32, oc = ac + Bc, cc = 65536 >> yr, lc = 1 << rc, gc = lc - 1, os = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint16Array(Array.prototype.slice.call(t, A, e));
}, uc = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint32Array(Array.prototype.slice.call(t, A, e));
}, wc = function(t, A) {
  var e = Ac(t), r = Array.isArray(e) ? tc(e) : new Uint32Array(e), s = Array.isArray(e) ? ec(e) : new Uint16Array(e), n = 24, i = os(s, n / 2, r[4] / 2), a = r[5] === 2 ? os(s, (n + r[4]) / 2) : uc(r, Math.ceil((n + r[4]) / 4));
  return new Qc(r[0], r[1], r[2], r[3], i, a);
}, Qc = (
  /** @class */
  function() {
    function t(A, e, r, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = r, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return t.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> WA], e = (e << Nt) + (A & Vt), this.data[e];
        if (A <= 65535)
          return e = this.index[mn + (A - 55296 >> WA)], e = (e << Nt) + (A & Vt), this.data[e];
        if (A < this.highStart)
          return e = oc - cc + (A >> yr), e = this.index[e], e += A >> WA & gc, e = this.index[e], e = (e << Nt) + (A & Vt), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, t;
  }()
), cs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", fc = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var je = 0; je < cs.length; je++)
  fc[cs.charCodeAt(je)] = je;
var Cc = 1, Pt = 2, kt = 3, ls = 4, gs = 5, hc = 7, us = 8, _t = 9, Xt = 10, ws = 11, Qs = 12, fs = 13, Cs = 14, Jt = 15, Uc = function(t) {
  for (var A = [], e = 0, r = t.length; e < r; ) {
    var s = t.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < r) {
      var n = t.charCodeAt(e++);
      (n & 64512) === 56320 ? A.push(((s & 1023) << 10) + (n & 1023) + 65536) : (A.push(s), e--);
    } else
      A.push(s);
  }
  return A;
}, Fc = function() {
  for (var t = [], A = 0; A < arguments.length; A++)
    t[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, t);
  var e = t.length;
  if (!e)
    return "";
  for (var r = [], s = -1, n = ""; ++s < e; ) {
    var i = t[s];
    i <= 65535 ? r.push(i) : (i -= 65536, r.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || r.length > 16384) && (n += String.fromCharCode.apply(String, r), r.length = 0);
  }
  return n;
}, dc = wc($o), sA = "×", Wt = "÷", pc = function(t) {
  return dc.get(t);
}, Ec = function(t, A, e) {
  var r = e - 2, s = A[r], n = A[e - 1], i = A[e];
  if (n === Pt && i === kt)
    return sA;
  if (n === Pt || n === kt || n === ls || i === Pt || i === kt || i === ls)
    return Wt;
  if (n === us && [us, _t, ws, Qs].indexOf(i) !== -1 || (n === ws || n === _t) && (i === _t || i === Xt) || (n === Qs || n === Xt) && i === Xt || i === fs || i === gs || i === hc || n === Cc)
    return sA;
  if (n === fs && i === Cs) {
    for (; s === gs; )
      s = A[--r];
    if (s === Cs)
      return sA;
  }
  if (n === Jt && i === Jt) {
    for (var a = 0; s === Jt; )
      a++, s = A[--r];
    if (a % 2 === 0)
      return sA;
  }
  return Wt;
}, Hc = function(t) {
  var A = Uc(t), e = A.length, r = 0, s = 0, n = A.map(pc);
  return {
    next: function() {
      if (r >= e)
        return { done: !0, value: null };
      for (var i = sA; r < e && (i = Ec(A, n, ++r)) === sA; )
        ;
      if (i !== sA || r === e) {
        var a = Fc.apply(null, A.slice(s, r));
        return s = r, { value: a, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, vc = function(t) {
  for (var A = Hc(t), e = [], r; !(r = A.next()).done; )
    r.value && e.push(r.value.slice());
  return e;
}, mc = function(t) {
  var A = 123;
  if (t.createRange) {
    var e = t.createRange();
    if (e.getBoundingClientRect) {
      var r = t.createElement("boundtest");
      r.style.height = A + "px", r.style.display = "block", t.body.appendChild(r), e.selectNode(r);
      var s = e.getBoundingClientRect(), n = Math.round(s.height);
      if (t.body.removeChild(r), n === A)
        return !0;
    }
  }
  return !1;
}, Ic = function(t) {
  var A = t.createElement("boundtest");
  A.style.width = "50px", A.style.display = "block", A.style.fontSize = "12px", A.style.letterSpacing = "0px", A.style.wordSpacing = "0px", t.body.appendChild(A);
  var e = t.createRange();
  A.innerHTML = typeof "".repeat == "function" ? "&#128104;".repeat(10) : "";
  var r = A.firstChild, s = pt(r.data).map(function(B) {
    return V(B);
  }), n = 0, i = {}, a = s.every(function(B, o) {
    e.setStart(r, n), e.setEnd(r, n + B.length);
    var c = e.getBoundingClientRect();
    n += B.length;
    var l = c.x > i.x || c.y > i.y;
    return i = c, o === 0 ? !0 : l;
  });
  return t.body.removeChild(A), a;
}, yc = function() {
  return typeof new Image().crossOrigin < "u";
}, Kc = function() {
  return typeof new XMLHttpRequest().responseType == "string";
}, Lc = function(t) {
  var A = new Image(), e = t.createElement("canvas"), r = e.getContext("2d");
  if (!r)
    return !1;
  A.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  try {
    r.drawImage(A, 0, 0), e.toDataURL();
  } catch (s) {
    return !1;
  }
  return !0;
}, hs = function(t) {
  return t[0] === 0 && t[1] === 255 && t[2] === 0 && t[3] === 255;
}, bc = function(t) {
  var A = t.createElement("canvas"), e = 100;
  A.width = e, A.height = e;
  var r = A.getContext("2d");
  if (!r)
    return Promise.reject(!1);
  r.fillStyle = "rgb(0, 255, 0)", r.fillRect(0, 0, e, e);
  var s = new Image(), n = A.toDataURL();
  s.src = n;
  var i = Qr(e, e, 0, 0, s);
  return r.fillStyle = "red", r.fillRect(0, 0, e, e), Us(i).then(function(a) {
    r.drawImage(a, 0, 0);
    var B = r.getImageData(0, 0, e, e).data;
    r.fillStyle = "red", r.fillRect(0, 0, e, e);
    var o = t.createElement("div");
    return o.style.backgroundImage = "url(" + n + ")", o.style.height = e + "px", hs(B) ? Us(Qr(e, e, 0, 0, o)) : Promise.reject(!1);
  }).then(function(a) {
    return r.drawImage(a, 0, 0), hs(r.getImageData(0, 0, e, e).data);
  }).catch(function() {
    return !1;
  });
}, Qr = function(t, A, e, r, s) {
  var n = "http://www.w3.org/2000/svg", i = document.createElementNS(n, "svg"), a = document.createElementNS(n, "foreignObject");
  return i.setAttributeNS(null, "width", t.toString()), i.setAttributeNS(null, "height", A.toString()), a.setAttributeNS(null, "width", "100%"), a.setAttributeNS(null, "height", "100%"), a.setAttributeNS(null, "x", e.toString()), a.setAttributeNS(null, "y", r.toString()), a.setAttributeNS(null, "externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(s), i;
}, Us = function(t) {
  return new Promise(function(A, e) {
    var r = new Image();
    r.onload = function() {
      return A(r);
    }, r.onerror = e, r.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(t));
  });
}, J = {
  get SUPPORT_RANGE_BOUNDS() {
    var t = mc(document);
    return Object.defineProperty(J, "SUPPORT_RANGE_BOUNDS", { value: t }), t;
  },
  get SUPPORT_WORD_BREAKING() {
    var t = J.SUPPORT_RANGE_BOUNDS && Ic(document);
    return Object.defineProperty(J, "SUPPORT_WORD_BREAKING", { value: t }), t;
  },
  get SUPPORT_SVG_DRAWING() {
    var t = Lc(document);
    return Object.defineProperty(J, "SUPPORT_SVG_DRAWING", { value: t }), t;
  },
  get SUPPORT_FOREIGNOBJECT_DRAWING() {
    var t = typeof Array.from == "function" && typeof window.fetch == "function" ? bc(document) : Promise.resolve(!1);
    return Object.defineProperty(J, "SUPPORT_FOREIGNOBJECT_DRAWING", { value: t }), t;
  },
  get SUPPORT_CORS_IMAGES() {
    var t = yc();
    return Object.defineProperty(J, "SUPPORT_CORS_IMAGES", { value: t }), t;
  },
  get SUPPORT_RESPONSE_TYPE() {
    var t = Kc();
    return Object.defineProperty(J, "SUPPORT_RESPONSE_TYPE", { value: t }), t;
  },
  get SUPPORT_CORS_XHR() {
    var t = "withCredentials" in new XMLHttpRequest();
    return Object.defineProperty(J, "SUPPORT_CORS_XHR", { value: t }), t;
  },
  get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
    var t = !!(typeof Intl < "u" && Intl.Segmenter);
    return Object.defineProperty(J, "SUPPORT_NATIVE_TEXT_SEGMENTATION", { value: t }), t;
  }
}, me = (
  /** @class */
  function() {
    function t(A, e) {
      this.text = A, this.bounds = e;
    }
    return t;
  }()
), Dc = function(t, A, e, r) {
  var s = xc(A, e), n = [], i = 0;
  return s.forEach(function(a) {
    if (e.textDecorationLine.length || a.trim().length > 0)
      if (J.SUPPORT_RANGE_BOUNDS) {
        var B = Fs(r, i, a.length).getClientRects();
        if (B.length > 1) {
          var o = Kr(a), c = 0;
          o.forEach(function(g) {
            n.push(new me(g, vA.fromDOMRectList(t, Fs(r, c + i, g.length).getClientRects()))), c += g.length;
          });
        } else
          n.push(new me(a, vA.fromDOMRectList(t, B)));
      } else {
        var l = r.splitText(a.length);
        n.push(new me(a, Sc(t, r))), r = l;
      }
    else
      J.SUPPORT_RANGE_BOUNDS || (r = r.splitText(a.length));
    i += a.length;
  }), n;
}, Sc = function(t, A) {
  var e = A.ownerDocument;
  if (e) {
    var r = e.createElement("html2canvaswrapper");
    r.appendChild(A.cloneNode(!0));
    var s = A.parentNode;
    if (s) {
      s.replaceChild(r, A);
      var n = dt(t, r);
      return r.firstChild && s.replaceChild(r.firstChild, r), n;
    }
  }
  return vA.EMPTY;
}, Fs = function(t, A, e) {
  var r = t.ownerDocument;
  if (!r)
    throw new Error("Node has no owner document");
  var s = r.createRange();
  return s.setStart(t, A), s.setEnd(t, A + e), s;
}, Kr = function(t) {
  if (J.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var A = new Intl.Segmenter(void 0, { granularity: "grapheme" });
    return Array.from(A.segment(t)).map(function(e) {
      return e.segment;
    });
  }
  return vc(t);
}, Tc = function(t, A) {
  if (J.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var e = new Intl.Segmenter(void 0, {
      granularity: "word"
    });
    return Array.from(e.segment(t)).map(function(r) {
      return r.segment;
    });
  }
  return Oc(t, A);
}, xc = function(t, A) {
  return A.letterSpacing !== 0 ? Kr(t) : Tc(t, A);
}, Mc = [32, 160, 4961, 65792, 65793, 4153, 4241], Oc = function(t, A) {
  for (var e = oa(t, {
    lineBreak: A.lineBreak,
    wordBreak: A.overflowWrap === "break-word" ? "break-word" : A.wordBreak
  }), r = [], s, n = function() {
    if (s.value) {
      var i = s.value.slice(), a = pt(i), B = "";
      a.forEach(function(o) {
        Mc.indexOf(o) === -1 ? B += V(o) : (B.length && r.push(B), r.push(V(o)), B = "");
      }), B.length && r.push(B);
    }
  }; !(s = e.next()).done; )
    n();
  return r;
}, Gc = (
  /** @class */
  function() {
    function t(A, e, r) {
      this.text = Rc(e.data, r.textTransform), this.textBounds = Dc(A, this.text, r, e);
    }
    return t;
  }()
), Rc = function(t, A) {
  switch (A) {
    case 1:
      return t.toLowerCase();
    case 3:
      return t.replace(Nc, Vc);
    case 2:
      return t.toUpperCase();
    default:
      return t;
  }
}, Nc = /(^|\s|:|-|\(|\))([a-z])/g, Vc = function(t, A, e) {
  return t.length > 0 ? A + e.toUpperCase() : t;
}, In = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.src = r.currentSrc || r.src, s.intrinsicWidth = r.naturalWidth, s.intrinsicHeight = r.naturalHeight, s.context.cache.addImage(s.src), s;
    }
    return A;
  }(CA)
), yn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.canvas = r, s.intrinsicWidth = r.width, s.intrinsicHeight = r.height, s;
    }
    return A;
  }(CA)
), Kn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this, n = new XMLSerializer(), i = dt(e, r);
      return r.setAttribute("width", i.width + "px"), r.setAttribute("height", i.height + "px"), s.svg = "data:image/svg+xml," + encodeURIComponent(n.serializeToString(r)), s.intrinsicWidth = r.width.baseVal.value, s.intrinsicHeight = r.height.baseVal.value, s.context.cache.addImage(s.svg), s;
    }
    return A;
  }(CA)
), Ln = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.value = r.value, s;
    }
    return A;
  }(CA)
), fr = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.start = r.start, s.reversed = typeof r.reversed == "boolean" && r.reversed === !0, s;
    }
    return A;
  }(CA)
), Pc = [
  {
    type: 15,
    flags: 0,
    unit: "px",
    number: 3
  }
], kc = [
  {
    type: 16,
    flags: 0,
    number: 50
  }
], _c = function(t) {
  return t.width > t.height ? new vA(t.left + (t.width - t.height) / 2, t.top, t.height, t.height) : t.width < t.height ? new vA(t.left, t.top + (t.height - t.width) / 2, t.width, t.width) : t;
}, Xc = function(t) {
  var A = t.type === Jc ? new Array(t.value.length + 1).join("•") : t.value;
  return A.length === 0 ? t.placeholder || "" : A;
}, ct = "checkbox", lt = "radio", Jc = "password", ds = 707406591, Lr = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      switch (s.type = r.type.toLowerCase(), s.checked = r.checked, s.value = Xc(r), (s.type === ct || s.type === lt) && (s.styles.backgroundColor = 3739148031, s.styles.borderTopColor = s.styles.borderRightColor = s.styles.borderBottomColor = s.styles.borderLeftColor = 2779096575, s.styles.borderTopWidth = s.styles.borderRightWidth = s.styles.borderBottomWidth = s.styles.borderLeftWidth = 1, s.styles.borderTopStyle = s.styles.borderRightStyle = s.styles.borderBottomStyle = s.styles.borderLeftStyle = 1, s.styles.backgroundClip = [
        0
        /* BORDER_BOX */
      ], s.styles.backgroundOrigin = [
        0
        /* BORDER_BOX */
      ], s.bounds = _c(s.bounds)), s.type) {
        case ct:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = Pc;
          break;
        case lt:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = kc;
          break;
      }
      return s;
    }
    return A;
  }(CA)
), bn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this, n = r.options[r.selectedIndex || 0];
      return s.value = n && n.text || "", s;
    }
    return A;
  }(CA)
), Dn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.value = r.value, s;
    }
    return A;
  }(CA)
), Sn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      s.src = r.src, s.width = parseInt(r.width, 10) || 0, s.height = parseInt(r.height, 10) || 0, s.backgroundColor = s.styles.backgroundColor;
      try {
        if (r.contentWindow && r.contentWindow.document && r.contentWindow.document.documentElement) {
          s.tree = xn(e, r.contentWindow.document.documentElement);
          var n = r.contentWindow.document.documentElement ? He(e, getComputedStyle(r.contentWindow.document.documentElement).backgroundColor) : HA.TRANSPARENT, i = r.contentWindow.document.body ? He(e, getComputedStyle(r.contentWindow.document.body).backgroundColor) : HA.TRANSPARENT;
          s.backgroundColor = OA(n) ? OA(i) ? s.styles.backgroundColor : i : n;
        }
      } catch (a) {
      }
      return s;
    }
    return A;
  }(CA)
), Wc = ["OL", "UL", "MENU"], st = function(t, A, e, r) {
  for (var s = A.firstChild, n = void 0; s; s = n)
    if (n = s.nextSibling, Mn(s) && s.data.trim().length > 0)
      e.textNodes.push(new Gc(t, s, e.styles));
    else if (ne(s))
      if (Nn(s) && s.assignedNodes)
        s.assignedNodes().forEach(function(a) {
          return st(t, a, e, r);
        });
      else {
        var i = Tn(t, s);
        i.styles.isVisible() && (Yc(s, i, r) ? i.flags |= 4 : Zc(i.styles) && (i.flags |= 2), Wc.indexOf(s.tagName) !== -1 && (i.flags |= 8), e.elements.push(i), s.slot, s.shadowRoot ? st(t, s.shadowRoot, i, r) : !gt(s) && !On(s) && !ut(s) && st(t, s, i, r));
      }
}, Tn = function(t, A) {
  return hr(A) ? new In(t, A) : Gn(A) ? new yn(t, A) : On(A) ? new Kn(t, A) : zc(A) ? new Ln(t, A) : jc(A) ? new fr(t, A) : qc(A) ? new Lr(t, A) : ut(A) ? new bn(t, A) : gt(A) ? new Dn(t, A) : Rn(A) ? new Sn(t, A) : new CA(t, A);
}, xn = function(t, A) {
  var e = Tn(t, A);
  return e.flags |= 4, st(t, A, e, e), e;
}, Yc = function(t, A, e) {
  return A.styles.isPositionedWithZIndex() || A.styles.opacity < 1 || A.styles.isTransformed() || br(t) && e.styles.isTransparent();
}, Zc = function(t) {
  return t.isPositioned() || t.isFloating();
}, Mn = function(t) {
  return t.nodeType === Node.TEXT_NODE;
}, ne = function(t) {
  return t.nodeType === Node.ELEMENT_NODE;
}, Cr = function(t) {
  return ne(t) && typeof t.style < "u" && !nt(t);
}, nt = function(t) {
  return typeof t.className == "object";
}, zc = function(t) {
  return t.tagName === "LI";
}, jc = function(t) {
  return t.tagName === "OL";
}, qc = function(t) {
  return t.tagName === "INPUT";
}, $c = function(t) {
  return t.tagName === "HTML";
}, On = function(t) {
  return t.tagName === "svg";
}, br = function(t) {
  return t.tagName === "BODY";
}, Gn = function(t) {
  return t.tagName === "CANVAS";
}, ps = function(t) {
  return t.tagName === "VIDEO";
}, hr = function(t) {
  return t.tagName === "IMG";
}, Rn = function(t) {
  return t.tagName === "IFRAME";
}, Es = function(t) {
  return t.tagName === "STYLE";
}, Al = function(t) {
  return t.tagName === "SCRIPT";
}, gt = function(t) {
  return t.tagName === "TEXTAREA";
}, ut = function(t) {
  return t.tagName === "SELECT";
}, Nn = function(t) {
  return t.tagName === "SLOT";
}, Hs = function(t) {
  return t.tagName.indexOf("-") > 0;
}, el = (
  /** @class */
  function() {
    function t() {
      this.counters = {};
    }
    return t.prototype.getCounterValue = function(A) {
      var e = this.counters[A];
      return e && e.length ? e[e.length - 1] : 1;
    }, t.prototype.getCounterValues = function(A) {
      var e = this.counters[A];
      return e || [];
    }, t.prototype.pop = function(A) {
      var e = this;
      A.forEach(function(r) {
        return e.counters[r].pop();
      });
    }, t.prototype.parse = function(A) {
      var e = this, r = A.counterIncrement, s = A.counterReset, n = !0;
      r !== null && r.forEach(function(a) {
        var B = e.counters[a.counter];
        B && a.increment !== 0 && (n = !1, B.length || B.push(1), B[Math.max(0, B.length - 1)] += a.increment);
      });
      var i = [];
      return n && s.forEach(function(a) {
        var B = e.counters[a.counter];
        i.push(a.counter), B || (B = e.counters[a.counter] = []), B.push(a.reset);
      }), i;
    }, t;
  }()
), vs = {
  integers: [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
  values: ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
}, ms = {
  integers: [
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    900,
    800,
    700,
    600,
    500,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "Ք",
    "Փ",
    "Ւ",
    "Ց",
    "Ր",
    "Տ",
    "Վ",
    "Ս",
    "Ռ",
    "Ջ",
    "Պ",
    "Չ",
    "Ո",
    "Շ",
    "Ն",
    "Յ",
    "Մ",
    "Ճ",
    "Ղ",
    "Ձ",
    "Հ",
    "Կ",
    "Ծ",
    "Խ",
    "Լ",
    "Ի",
    "Ժ",
    "Թ",
    "Ը",
    "Է",
    "Զ",
    "Ե",
    "Դ",
    "Գ",
    "Բ",
    "Ա"
  ]
}, tl = {
  integers: [
    1e4,
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    19,
    18,
    17,
    16,
    15,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "י׳",
    "ט׳",
    "ח׳",
    "ז׳",
    "ו׳",
    "ה׳",
    "ד׳",
    "ג׳",
    "ב׳",
    "א׳",
    "ת",
    "ש",
    "ר",
    "ק",
    "צ",
    "פ",
    "ע",
    "ס",
    "נ",
    "מ",
    "ל",
    "כ",
    "יט",
    "יח",
    "יז",
    "טז",
    "טו",
    "י",
    "ט",
    "ח",
    "ז",
    "ו",
    "ה",
    "ד",
    "ג",
    "ב",
    "א"
  ]
}, rl = {
  integers: [
    1e4,
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    900,
    800,
    700,
    600,
    500,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "ჵ",
    "ჰ",
    "ჯ",
    "ჴ",
    "ხ",
    "ჭ",
    "წ",
    "ძ",
    "ც",
    "ჩ",
    "შ",
    "ყ",
    "ღ",
    "ქ",
    "ფ",
    "ჳ",
    "ტ",
    "ს",
    "რ",
    "ჟ",
    "პ",
    "ო",
    "ჲ",
    "ნ",
    "მ",
    "ლ",
    "კ",
    "ი",
    "თ",
    "ჱ",
    "ზ",
    "ვ",
    "ე",
    "დ",
    "გ",
    "ბ",
    "ა"
  ]
}, Ae = function(t, A, e, r, s, n) {
  return t < A || t > e ? Le(t, s, n.length > 0) : r.integers.reduce(function(i, a, B) {
    for (; t >= a; )
      t -= a, i += r.values[B];
    return i;
  }, "") + n;
}, Vn = function(t, A, e, r) {
  var s = "";
  do
    e || t--, s = r(t) + s, t /= A;
  while (t * A >= A);
  return s;
}, N = function(t, A, e, r, s) {
  var n = e - A + 1;
  return (t < 0 ? "-" : "") + (Vn(Math.abs(t), n, r, function(i) {
    return V(Math.floor(i % n) + A);
  }) + s);
}, kA = function(t, A, e) {
  e === void 0 && (e = ". ");
  var r = A.length;
  return Vn(Math.abs(t), r, !1, function(s) {
    return A[Math.floor(s % r)];
  }) + e;
}, re = 1 << 0, KA = 1 << 1, LA = 1 << 2, de = 1 << 3, dA = function(t, A, e, r, s, n) {
  if (t < -9999 || t > 9999)
    return Le(t, 4, s.length > 0);
  var i = Math.abs(t), a = s;
  if (i === 0)
    return A[0] + a;
  for (var B = 0; i > 0 && B <= 4; B++) {
    var o = i % 10;
    o === 0 && k(n, re) && a !== "" ? a = A[o] + a : o > 1 || o === 1 && B === 0 || o === 1 && B === 1 && k(n, KA) || o === 1 && B === 1 && k(n, LA) && t > 100 || o === 1 && B > 1 && k(n, de) ? a = A[o] + (B > 0 ? e[B - 1] : "") + a : o === 1 && B > 0 && (a = e[B - 1] + a), i = Math.floor(i / 10);
  }
  return (t < 0 ? r : "") + a;
}, Is = "十百千萬", ys = "拾佰仟萬", Ks = "マイナス", Yt = "마이너스", Le = function(t, A, e) {
  var r = e ? ". " : "", s = e ? "、" : "", n = e ? ", " : "", i = e ? " " : "";
  switch (A) {
    case 0:
      return "•" + i;
    case 1:
      return "◦" + i;
    case 2:
      return "◾" + i;
    case 5:
      var a = N(t, 48, 57, !0, r);
      return a.length < 4 ? "0" + a : a;
    case 4:
      return kA(t, "〇一二三四五六七八九", s);
    case 6:
      return Ae(t, 1, 3999, vs, 3, r).toLowerCase();
    case 7:
      return Ae(t, 1, 3999, vs, 3, r);
    case 8:
      return N(t, 945, 969, !1, r);
    case 9:
      return N(t, 97, 122, !1, r);
    case 10:
      return N(t, 65, 90, !1, r);
    case 11:
      return N(t, 1632, 1641, !0, r);
    case 12:
    case 49:
      return Ae(t, 1, 9999, ms, 3, r);
    case 35:
      return Ae(t, 1, 9999, ms, 3, r).toLowerCase();
    case 13:
      return N(t, 2534, 2543, !0, r);
    case 14:
    case 30:
      return N(t, 6112, 6121, !0, r);
    case 15:
      return kA(t, "子丑寅卯辰巳午未申酉戌亥", s);
    case 16:
      return kA(t, "甲乙丙丁戊己庚辛壬癸", s);
    case 17:
    case 48:
      return dA(t, "零一二三四五六七八九", Is, "負", s, KA | LA | de);
    case 47:
      return dA(t, "零壹貳參肆伍陸柒捌玖", ys, "負", s, re | KA | LA | de);
    case 42:
      return dA(t, "零一二三四五六七八九", Is, "负", s, KA | LA | de);
    case 41:
      return dA(t, "零壹贰叁肆伍陆柒捌玖", ys, "负", s, re | KA | LA | de);
    case 26:
      return dA(t, "〇一二三四五六七八九", "十百千万", Ks, s, 0);
    case 25:
      return dA(t, "零壱弐参四伍六七八九", "拾百千万", Ks, s, re | KA | LA);
    case 31:
      return dA(t, "영일이삼사오육칠팔구", "십백천만", Yt, n, re | KA | LA);
    case 33:
      return dA(t, "零一二三四五六七八九", "十百千萬", Yt, n, 0);
    case 32:
      return dA(t, "零壹貳參四五六七八九", "拾百千", Yt, n, re | KA | LA);
    case 18:
      return N(t, 2406, 2415, !0, r);
    case 20:
      return Ae(t, 1, 19999, rl, 3, r);
    case 21:
      return N(t, 2790, 2799, !0, r);
    case 22:
      return N(t, 2662, 2671, !0, r);
    case 22:
      return Ae(t, 1, 10999, tl, 3, r);
    case 23:
      return kA(t, "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");
    case 24:
      return kA(t, "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");
    case 27:
      return N(t, 3302, 3311, !0, r);
    case 28:
      return kA(t, "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン", s);
    case 29:
      return kA(t, "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス", s);
    case 34:
      return N(t, 3792, 3801, !0, r);
    case 37:
      return N(t, 6160, 6169, !0, r);
    case 38:
      return N(t, 4160, 4169, !0, r);
    case 39:
      return N(t, 2918, 2927, !0, r);
    case 40:
      return N(t, 1776, 1785, !0, r);
    case 43:
      return N(t, 3046, 3055, !0, r);
    case 44:
      return N(t, 3174, 3183, !0, r);
    case 45:
      return N(t, 3664, 3673, !0, r);
    case 46:
      return N(t, 3872, 3881, !0, r);
    case 3:
    default:
      return N(t, 48, 57, !0, r);
  }
}, Pn = "data-html2canvas-ignore", Ls = (
  /** @class */
  function() {
    function t(A, e, r) {
      if (this.context = A, this.options = r, this.scrolledElements = [], this.referenceElement = e, this.counters = new el(), this.quoteDepth = 0, !e.ownerDocument)
        throw new Error("Cloned element does not have an owner document");
      this.documentElement = this.cloneNode(e.ownerDocument.documentElement, !1);
    }
    return t.prototype.toIFrame = function(A, e) {
      var r = this, s = sl(A, e);
      if (!s.contentWindow)
        return Promise.reject("Unable to find iframe window");
      var n = A.defaultView.pageXOffset, i = A.defaultView.pageYOffset, a = s.contentWindow, B = a.document, o = al(s).then(function() {
        return q(r, void 0, void 0, function() {
          var c, l;
          return Z(this, function(g) {
            switch (g.label) {
              case 0:
                return this.scrolledElements.forEach(ll), a && (a.scrollTo(e.left, e.top), /(iPad|iPhone|iPod)/g.test(navigator.userAgent) && (a.scrollY !== e.top || a.scrollX !== e.left) && (this.context.logger.warn("Unable to restore scroll position for cloned document"), this.context.windowBounds = this.context.windowBounds.add(a.scrollX - e.left, a.scrollY - e.top, 0, 0))), c = this.options.onclone, l = this.clonedReferenceElement, typeof l > "u" ? [2, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")] : B.fonts && B.fonts.ready ? [4, B.fonts.ready] : [3, 2];
              case 1:
                g.sent(), g.label = 2;
              case 2:
                return /(AppleWebKit)/g.test(navigator.userAgent) ? [4, il(B)] : [3, 4];
              case 3:
                g.sent(), g.label = 4;
              case 4:
                return typeof c == "function" ? [2, Promise.resolve().then(function() {
                  return c(B, l);
                }).then(function() {
                  return s;
                })] : [2, s];
            }
          });
        });
      });
      return B.open(), B.write(ol(document.doctype) + "<html></html>"), cl(this.referenceElement.ownerDocument, n, i), B.replaceChild(B.adoptNode(this.documentElement), B.documentElement), B.close(), o;
    }, t.prototype.createElementClone = function(A) {
      if (wr(
        A,
        2
        /* CLONE */
      ))
        debugger;
      if (Gn(A))
        return this.createCanvasClone(A);
      if (ps(A))
        return this.createVideoClone(A);
      if (Es(A))
        return this.createStyleClone(A);
      var e = A.cloneNode(!1);
      return hr(e) && (hr(A) && A.currentSrc && A.currentSrc !== A.src && (e.src = A.currentSrc, e.srcset = ""), e.loading === "lazy" && (e.loading = "eager")), Hs(e) ? this.createCustomElementClone(e) : e;
    }, t.prototype.createCustomElementClone = function(A) {
      var e = document.createElement("html2canvascustomelement");
      return Zt(A.style, e), e;
    }, t.prototype.createStyleClone = function(A) {
      try {
        var e = A.sheet;
        if (e && e.cssRules) {
          var r = [].slice.call(e.cssRules, 0).reduce(function(n, i) {
            return i && typeof i.cssText == "string" ? n + i.cssText : n;
          }, ""), s = A.cloneNode(!1);
          return s.textContent = r, s;
        }
      } catch (n) {
        if (this.context.logger.error("Unable to access cssRules property", n), n.name !== "SecurityError")
          throw n;
      }
      return A.cloneNode(!1);
    }, t.prototype.createCanvasClone = function(A) {
      var e;
      if (this.options.inlineImages && A.ownerDocument) {
        var r = A.ownerDocument.createElement("img");
        try {
          return r.src = A.toDataURL(), r;
        } catch (o) {
          this.context.logger.info("Unable to inline canvas contents, canvas is tainted", A);
        }
      }
      var s = A.cloneNode(!1);
      try {
        s.width = A.width, s.height = A.height;
        var n = A.getContext("2d"), i = s.getContext("2d");
        if (i)
          if (!this.options.allowTaint && n)
            i.putImageData(n.getImageData(0, 0, A.width, A.height), 0, 0);
          else {
            var a = (e = A.getContext("webgl2")) !== null && e !== void 0 ? e : A.getContext("webgl");
            if (a) {
              var B = a.getContextAttributes();
              (B == null ? void 0 : B.preserveDrawingBuffer) === !1 && this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false", A);
            }
            i.drawImage(A, 0, 0);
          }
        return s;
      } catch (o) {
        this.context.logger.info("Unable to clone canvas as it is tainted", A);
      }
      return s;
    }, t.prototype.createVideoClone = function(A) {
      var e = A.ownerDocument.createElement("canvas");
      e.width = A.offsetWidth, e.height = A.offsetHeight;
      var r = e.getContext("2d");
      try {
        return r && (r.drawImage(A, 0, 0, e.width, e.height), this.options.allowTaint || r.getImageData(0, 0, e.width, e.height)), e;
      } catch (n) {
        this.context.logger.info("Unable to clone video as it is tainted", A);
      }
      var s = A.ownerDocument.createElement("canvas");
      return s.width = A.offsetWidth, s.height = A.offsetHeight, s;
    }, t.prototype.appendChildNode = function(A, e, r) {
      (!ne(e) || !Al(e) && !e.hasAttribute(Pn) && (typeof this.options.ignoreElements != "function" || !this.options.ignoreElements(e))) && (!this.options.copyStyles || !ne(e) || !Es(e)) && A.appendChild(this.cloneNode(e, r));
    }, t.prototype.cloneChildNodes = function(A, e, r) {
      for (var s = this, n = A.shadowRoot ? A.shadowRoot.firstChild : A.firstChild; n; n = n.nextSibling)
        if (ne(n) && Nn(n) && typeof n.assignedNodes == "function") {
          var i = n.assignedNodes();
          i.length && i.forEach(function(a) {
            return s.appendChildNode(e, a, r);
          });
        } else
          this.appendChildNode(e, n, r);
    }, t.prototype.cloneNode = function(A, e) {
      if (Mn(A))
        return document.createTextNode(A.data);
      if (!A.ownerDocument)
        return A.cloneNode(!1);
      var r = A.ownerDocument.defaultView;
      if (r && ne(A) && (Cr(A) || nt(A))) {
        var s = this.createElementClone(A);
        s.style.transitionProperty = "none";
        var n = r.getComputedStyle(A), i = r.getComputedStyle(A, ":before"), a = r.getComputedStyle(A, ":after");
        this.referenceElement === A && Cr(s) && (this.clonedReferenceElement = s), br(s) && wl(s);
        var B = this.counters.parse(new as(this.context, n)), o = this.resolvePseudoContent(A, s, i, Ie.BEFORE);
        Hs(A) && (e = !0), ps(A) || this.cloneChildNodes(A, s, e), o && s.insertBefore(o, s.firstChild);
        var c = this.resolvePseudoContent(A, s, a, Ie.AFTER);
        return c && s.appendChild(c), this.counters.pop(B), (n && (this.options.copyStyles || nt(A)) && !Rn(A) || e) && Zt(n, s), (A.scrollTop !== 0 || A.scrollLeft !== 0) && this.scrolledElements.push([s, A.scrollLeft, A.scrollTop]), (gt(A) || ut(A)) && (gt(s) || ut(s)) && (s.value = A.value), s;
      }
      return A.cloneNode(!1);
    }, t.prototype.resolvePseudoContent = function(A, e, r, s) {
      var n = this;
      if (r) {
        var i = r.content, a = e.ownerDocument;
        if (!(!a || !i || i === "none" || i === "-moz-alt-content" || r.display === "none")) {
          this.counters.parse(new as(this.context, r));
          var B = new zo(this.context, r), o = a.createElement("html2canvaspseudoelement");
          Zt(r, o), B.content.forEach(function(l) {
            if (l.type === 0)
              o.appendChild(a.createTextNode(l.value));
            else if (l.type === 22) {
              var g = a.createElement("img");
              g.src = l.value, g.style.opacity = "1", o.appendChild(g);
            } else if (l.type === 18) {
              if (l.name === "attr") {
                var Q = l.values.filter(T);
                Q.length && o.appendChild(a.createTextNode(A.getAttribute(Q[0].value) || ""));
              } else if (l.name === "counter") {
                var u = l.values.filter(ae), w = u[0], E = u[1];
                if (w && T(w)) {
                  var C = n.counters.getCounterValue(w.value), F = E && T(E) ? ur.parse(n.context, E.value) : 3;
                  o.appendChild(a.createTextNode(Le(C, F, !1)));
                }
              } else if (l.name === "counters") {
                var y = l.values.filter(ae), w = y[0], v = y[1], E = y[2];
                if (w && T(w)) {
                  var H = n.counters.getCounterValues(w.value), h = E && T(E) ? ur.parse(n.context, E.value) : 3, K = v && v.type === 0 ? v.value : "", L = H.map(function(I) {
                    return Le(I, h, !1);
                  }).join(K);
                  o.appendChild(a.createTextNode(L));
                }
              }
            } else if (l.type === 20)
              switch (l.value) {
                case "open-quote":
                  o.appendChild(a.createTextNode(is(B.quotes, n.quoteDepth++, !0)));
                  break;
                case "close-quote":
                  o.appendChild(a.createTextNode(is(B.quotes, --n.quoteDepth, !1)));
                  break;
                default:
                  o.appendChild(a.createTextNode(l.value));
              }
          }), o.className = Ur + " " + Fr;
          var c = s === Ie.BEFORE ? " " + Ur : " " + Fr;
          return nt(e) ? e.className.baseValue += c : e.className += c, o;
        }
      }
    }, t.destroy = function(A) {
      return A.parentNode ? (A.parentNode.removeChild(A), !0) : !1;
    }, t;
  }()
), Ie;
(function(t) {
  t[t.BEFORE = 0] = "BEFORE", t[t.AFTER = 1] = "AFTER";
})(Ie || (Ie = {}));
var sl = function(t, A) {
  var e = t.createElement("iframe");
  return e.className = "html2canvas-container", e.style.visibility = "hidden", e.style.position = "fixed", e.style.left = "-10000px", e.style.top = "0px", e.style.border = "0", e.width = A.width.toString(), e.height = A.height.toString(), e.scrolling = "no", e.setAttribute(Pn, "true"), t.body.appendChild(e), e;
}, nl = function(t) {
  return new Promise(function(A) {
    if (t.complete) {
      A();
      return;
    }
    if (!t.src) {
      A();
      return;
    }
    t.onload = A, t.onerror = A;
  });
}, il = function(t) {
  return Promise.all([].slice.call(t.images, 0).map(nl));
}, al = function(t) {
  return new Promise(function(A, e) {
    var r = t.contentWindow;
    if (!r)
      return e("No window assigned for iframe");
    var s = r.document;
    r.onload = t.onload = function() {
      r.onload = t.onload = null;
      var n = setInterval(function() {
        s.body.childNodes.length > 0 && s.readyState === "complete" && (clearInterval(n), A(t));
      }, 50);
    };
  });
}, Bl = [
  "all",
  "d",
  "content"
  // Safari shows pseudoelements if content is set
], Zt = function(t, A) {
  for (var e = t.length - 1; e >= 0; e--) {
    var r = t.item(e);
    Bl.indexOf(r) === -1 && A.style.setProperty(r, t.getPropertyValue(r));
  }
  return A;
}, ol = function(t) {
  var A = "";
  return t && (A += "<!DOCTYPE ", t.name && (A += t.name), t.internalSubset && (A += t.internalSubset), t.publicId && (A += '"' + t.publicId + '"'), t.systemId && (A += '"' + t.systemId + '"'), A += ">"), A;
}, cl = function(t, A, e) {
  t && t.defaultView && (A !== t.defaultView.pageXOffset || e !== t.defaultView.pageYOffset) && t.defaultView.scrollTo(A, e);
}, ll = function(t) {
  var A = t[0], e = t[1], r = t[2];
  A.scrollLeft = e, A.scrollTop = r;
}, gl = ":before", ul = ":after", Ur = "___html2canvas___pseudoelement_before", Fr = "___html2canvas___pseudoelement_after", bs = `{
    content: "" !important;
    display: none !important;
}`, wl = function(t) {
  Ql(t, "." + Ur + gl + bs + `
         .` + Fr + ul + bs);
}, Ql = function(t, A) {
  var e = t.ownerDocument;
  if (e) {
    var r = e.createElement("style");
    r.textContent = A, t.appendChild(r);
  }
}, kn = (
  /** @class */
  function() {
    function t() {
    }
    return t.getOrigin = function(A) {
      var e = t._link;
      return e ? (e.href = A, e.href = e.href, e.protocol + e.hostname + e.port) : "about:blank";
    }, t.isSameOrigin = function(A) {
      return t.getOrigin(A) === t._origin;
    }, t.setContext = function(A) {
      t._link = A.document.createElement("a"), t._origin = t.getOrigin(A.location.href);
    }, t._origin = "about:blank", t;
  }()
), fl = (
  /** @class */
  function() {
    function t(A, e) {
      this.context = A, this._options = e, this._cache = {};
    }
    return t.prototype.addImage = function(A) {
      var e = Promise.resolve();
      return this.has(A) || (jt(A) || Fl(A)) && (this._cache[A] = this.loadImage(A)).catch(function() {
      }), e;
    }, t.prototype.match = function(A) {
      return this._cache[A];
    }, t.prototype.loadImage = function(A) {
      return q(this, void 0, void 0, function() {
        var e, r, s, n, i = this;
        return Z(this, function(a) {
          switch (a.label) {
            case 0:
              return e = kn.isSameOrigin(A), r = !zt(A) && this._options.useCORS === !0 && J.SUPPORT_CORS_IMAGES && !e, s = !zt(A) && !e && !jt(A) && typeof this._options.proxy == "string" && J.SUPPORT_CORS_XHR && !r, !e && this._options.allowTaint === !1 && !zt(A) && !jt(A) && !s && !r ? [
                2
                /*return*/
              ] : (n = A, s ? [4, this.proxy(n)] : [3, 2]);
            case 1:
              n = a.sent(), a.label = 2;
            case 2:
              return this.context.logger.debug("Added image " + A.substring(0, 256)), [4, new Promise(function(B, o) {
                var c = new Image();
                c.onload = function() {
                  return B(c);
                }, c.onerror = o, (dl(n) || r) && (c.crossOrigin = "anonymous"), c.src = n, c.complete === !0 && setTimeout(function() {
                  return B(c);
                }, 500), i._options.imageTimeout > 0 && setTimeout(function() {
                  return o("Timed out (" + i._options.imageTimeout + "ms) loading image");
                }, i._options.imageTimeout);
              })];
            case 3:
              return [2, a.sent()];
          }
        });
      });
    }, t.prototype.has = function(A) {
      return typeof this._cache[A] < "u";
    }, t.prototype.keys = function() {
      return Promise.resolve(Object.keys(this._cache));
    }, t.prototype.proxy = function(A) {
      var e = this, r = this._options.proxy;
      if (!r)
        throw new Error("No proxy defined");
      var s = A.substring(0, 256);
      return new Promise(function(n, i) {
        var a = J.SUPPORT_RESPONSE_TYPE ? "blob" : "text", B = new XMLHttpRequest();
        B.onload = function() {
          if (B.status === 200)
            if (a === "text")
              n(B.response);
            else {
              var l = new FileReader();
              l.addEventListener("load", function() {
                return n(l.result);
              }, !1), l.addEventListener("error", function(g) {
                return i(g);
              }, !1), l.readAsDataURL(B.response);
            }
          else
            i("Failed to proxy resource " + s + " with status code " + B.status);
        }, B.onerror = i;
        var o = r.indexOf("?") > -1 ? "&" : "?";
        if (B.open("GET", "" + r + o + "url=" + encodeURIComponent(A) + "&responseType=" + a), a !== "text" && B instanceof XMLHttpRequest && (B.responseType = a), e._options.imageTimeout) {
          var c = e._options.imageTimeout;
          B.timeout = c, B.ontimeout = function() {
            return i("Timed out (" + c + "ms) proxying " + s);
          };
        }
        B.send();
      });
    }, t;
  }()
), Cl = /^data:image\/svg\+xml/i, hl = /^data:image\/.*;base64,/i, Ul = /^data:image\/.*/i, Fl = function(t) {
  return J.SUPPORT_SVG_DRAWING || !pl(t);
}, zt = function(t) {
  return Ul.test(t);
}, dl = function(t) {
  return hl.test(t);
}, jt = function(t) {
  return t.substr(0, 4) === "blob";
}, pl = function(t) {
  return t.substr(-3).toLowerCase() === "svg" || Cl.test(t);
}, U = (
  /** @class */
  function() {
    function t(A, e) {
      this.type = 0, this.x = A, this.y = e;
    }
    return t.prototype.add = function(A, e) {
      return new t(this.x + A, this.y + e);
    }, t;
  }()
), ee = function(t, A, e) {
  return new U(t.x + (A.x - t.x) * e, t.y + (A.y - t.y) * e);
}, qe = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.type = 1, this.start = A, this.startControl = e, this.endControl = r, this.end = s;
    }
    return t.prototype.subdivide = function(A, e) {
      var r = ee(this.start, this.startControl, A), s = ee(this.startControl, this.endControl, A), n = ee(this.endControl, this.end, A), i = ee(r, s, A), a = ee(s, n, A), B = ee(i, a, A);
      return e ? new t(this.start, r, i, B) : new t(B, a, n, this.end);
    }, t.prototype.add = function(A, e) {
      return new t(this.start.add(A, e), this.startControl.add(A, e), this.endControl.add(A, e), this.end.add(A, e));
    }, t.prototype.reverse = function() {
      return new t(this.end, this.endControl, this.startControl, this.start);
    }, t;
  }()
), nA = function(t) {
  return t.type === 1;
}, El = (
  /** @class */
  function() {
    function t(A) {
      var e = A.styles, r = A.bounds, s = Ue(e.borderTopLeftRadius, r.width, r.height), n = s[0], i = s[1], a = Ue(e.borderTopRightRadius, r.width, r.height), B = a[0], o = a[1], c = Ue(e.borderBottomRightRadius, r.width, r.height), l = c[0], g = c[1], Q = Ue(e.borderBottomLeftRadius, r.width, r.height), u = Q[0], w = Q[1], E = [];
      E.push((n + B) / r.width), E.push((u + l) / r.width), E.push((i + w) / r.height), E.push((o + g) / r.height);
      var C = Math.max.apply(Math, E);
      C > 1 && (n /= C, i /= C, B /= C, o /= C, l /= C, g /= C, u /= C, w /= C);
      var F = r.width - B, y = r.height - g, v = r.width - l, H = r.height - w, h = e.borderTopWidth, K = e.borderRightWidth, L = e.borderBottomWidth, f = e.borderLeftWidth, p = M(e.paddingTop, A.bounds.width), I = M(e.paddingRight, A.bounds.width), D = M(e.paddingBottom, A.bounds.width), m = M(e.paddingLeft, A.bounds.width);
      this.topLeftBorderDoubleOuterBox = n > 0 || i > 0 ? O(r.left + f / 3, r.top + h / 3, n - f / 3, i - h / 3, S.TOP_LEFT) : new U(r.left + f / 3, r.top + h / 3), this.topRightBorderDoubleOuterBox = n > 0 || i > 0 ? O(r.left + F, r.top + h / 3, B - K / 3, o - h / 3, S.TOP_RIGHT) : new U(r.left + r.width - K / 3, r.top + h / 3), this.bottomRightBorderDoubleOuterBox = l > 0 || g > 0 ? O(r.left + v, r.top + y, l - K / 3, g - L / 3, S.BOTTOM_RIGHT) : new U(r.left + r.width - K / 3, r.top + r.height - L / 3), this.bottomLeftBorderDoubleOuterBox = u > 0 || w > 0 ? O(r.left + f / 3, r.top + H, u - f / 3, w - L / 3, S.BOTTOM_LEFT) : new U(r.left + f / 3, r.top + r.height - L / 3), this.topLeftBorderDoubleInnerBox = n > 0 || i > 0 ? O(r.left + f * 2 / 3, r.top + h * 2 / 3, n - f * 2 / 3, i - h * 2 / 3, S.TOP_LEFT) : new U(r.left + f * 2 / 3, r.top + h * 2 / 3), this.topRightBorderDoubleInnerBox = n > 0 || i > 0 ? O(r.left + F, r.top + h * 2 / 3, B - K * 2 / 3, o - h * 2 / 3, S.TOP_RIGHT) : new U(r.left + r.width - K * 2 / 3, r.top + h * 2 / 3), this.bottomRightBorderDoubleInnerBox = l > 0 || g > 0 ? O(r.left + v, r.top + y, l - K * 2 / 3, g - L * 2 / 3, S.BOTTOM_RIGHT) : new U(r.left + r.width - K * 2 / 3, r.top + r.height - L * 2 / 3), this.bottomLeftBorderDoubleInnerBox = u > 0 || w > 0 ? O(r.left + f * 2 / 3, r.top + H, u - f * 2 / 3, w - L * 2 / 3, S.BOTTOM_LEFT) : new U(r.left + f * 2 / 3, r.top + r.height - L * 2 / 3), this.topLeftBorderStroke = n > 0 || i > 0 ? O(r.left + f / 2, r.top + h / 2, n - f / 2, i - h / 2, S.TOP_LEFT) : new U(r.left + f / 2, r.top + h / 2), this.topRightBorderStroke = n > 0 || i > 0 ? O(r.left + F, r.top + h / 2, B - K / 2, o - h / 2, S.TOP_RIGHT) : new U(r.left + r.width - K / 2, r.top + h / 2), this.bottomRightBorderStroke = l > 0 || g > 0 ? O(r.left + v, r.top + y, l - K / 2, g - L / 2, S.BOTTOM_RIGHT) : new U(r.left + r.width - K / 2, r.top + r.height - L / 2), this.bottomLeftBorderStroke = u > 0 || w > 0 ? O(r.left + f / 2, r.top + H, u - f / 2, w - L / 2, S.BOTTOM_LEFT) : new U(r.left + f / 2, r.top + r.height - L / 2), this.topLeftBorderBox = n > 0 || i > 0 ? O(r.left, r.top, n, i, S.TOP_LEFT) : new U(r.left, r.top), this.topRightBorderBox = B > 0 || o > 0 ? O(r.left + F, r.top, B, o, S.TOP_RIGHT) : new U(r.left + r.width, r.top), this.bottomRightBorderBox = l > 0 || g > 0 ? O(r.left + v, r.top + y, l, g, S.BOTTOM_RIGHT) : new U(r.left + r.width, r.top + r.height), this.bottomLeftBorderBox = u > 0 || w > 0 ? O(r.left, r.top + H, u, w, S.BOTTOM_LEFT) : new U(r.left, r.top + r.height), this.topLeftPaddingBox = n > 0 || i > 0 ? O(r.left + f, r.top + h, Math.max(0, n - f), Math.max(0, i - h), S.TOP_LEFT) : new U(r.left + f, r.top + h), this.topRightPaddingBox = B > 0 || o > 0 ? O(r.left + Math.min(F, r.width - K), r.top + h, F > r.width + K ? 0 : Math.max(0, B - K), Math.max(0, o - h), S.TOP_RIGHT) : new U(r.left + r.width - K, r.top + h), this.bottomRightPaddingBox = l > 0 || g > 0 ? O(r.left + Math.min(v, r.width - f), r.top + Math.min(y, r.height - L), Math.max(0, l - K), Math.max(0, g - L), S.BOTTOM_RIGHT) : new U(r.left + r.width - K, r.top + r.height - L), this.bottomLeftPaddingBox = u > 0 || w > 0 ? O(r.left + f, r.top + Math.min(H, r.height - L), Math.max(0, u - f), Math.max(0, w - L), S.BOTTOM_LEFT) : new U(r.left + f, r.top + r.height - L), this.topLeftContentBox = n > 0 || i > 0 ? O(r.left + f + m, r.top + h + p, Math.max(0, n - (f + m)), Math.max(0, i - (h + p)), S.TOP_LEFT) : new U(r.left + f + m, r.top + h + p), this.topRightContentBox = B > 0 || o > 0 ? O(r.left + Math.min(F, r.width + f + m), r.top + h + p, F > r.width + f + m ? 0 : B - f + m, o - (h + p), S.TOP_RIGHT) : new U(r.left + r.width - (K + I), r.top + h + p), this.bottomRightContentBox = l > 0 || g > 0 ? O(r.left + Math.min(v, r.width - (f + m)), r.top + Math.min(y, r.height + h + p), Math.max(0, l - (K + I)), g - (L + D), S.BOTTOM_RIGHT) : new U(r.left + r.width - (K + I), r.top + r.height - (L + D)), this.bottomLeftContentBox = u > 0 || w > 0 ? O(r.left + f + m, r.top + H, Math.max(0, u - (f + m)), w - (L + D), S.BOTTOM_LEFT) : new U(r.left + f + m, r.top + r.height - (L + D));
    }
    return t;
  }()
), S;
(function(t) {
  t[t.TOP_LEFT = 0] = "TOP_LEFT", t[t.TOP_RIGHT = 1] = "TOP_RIGHT", t[t.BOTTOM_RIGHT = 2] = "BOTTOM_RIGHT", t[t.BOTTOM_LEFT = 3] = "BOTTOM_LEFT";
})(S || (S = {}));
var O = function(t, A, e, r, s) {
  var n = 4 * ((Math.sqrt(2) - 1) / 3), i = e * n, a = r * n, B = t + e, o = A + r;
  switch (s) {
    case S.TOP_LEFT:
      return new qe(new U(t, o), new U(t, o - a), new U(B - i, A), new U(B, A));
    case S.TOP_RIGHT:
      return new qe(new U(t, A), new U(t + i, A), new U(B, o - a), new U(B, o));
    case S.BOTTOM_RIGHT:
      return new qe(new U(B, A), new U(B, A + a), new U(t + i, o), new U(t, o));
    case S.BOTTOM_LEFT:
    default:
      return new qe(new U(B, o), new U(B - i, o), new U(t, A + a), new U(t, A));
  }
}, wt = function(t) {
  return [t.topLeftBorderBox, t.topRightBorderBox, t.bottomRightBorderBox, t.bottomLeftBorderBox];
}, Hl = function(t) {
  return [
    t.topLeftContentBox,
    t.topRightContentBox,
    t.bottomRightContentBox,
    t.bottomLeftContentBox
  ];
}, Qt = function(t) {
  return [
    t.topLeftPaddingBox,
    t.topRightPaddingBox,
    t.bottomRightPaddingBox,
    t.bottomLeftPaddingBox
  ];
}, vl = (
  /** @class */
  function() {
    function t(A, e, r) {
      this.offsetX = A, this.offsetY = e, this.matrix = r, this.type = 0, this.target = 6;
    }
    return t;
  }()
), $e = (
  /** @class */
  function() {
    function t(A, e) {
      this.path = A, this.target = e, this.type = 1;
    }
    return t;
  }()
), ml = (
  /** @class */
  function() {
    function t(A) {
      this.opacity = A, this.type = 2, this.target = 6;
    }
    return t;
  }()
), Il = function(t) {
  return t.type === 0;
}, _n = function(t) {
  return t.type === 1;
}, yl = function(t) {
  return t.type === 2;
}, Ds = function(t, A) {
  return t.length === A.length ? t.some(function(e, r) {
    return e === A[r];
  }) : !1;
}, Kl = function(t, A, e, r, s) {
  return t.map(function(n, i) {
    switch (i) {
      case 0:
        return n.add(A, e);
      case 1:
        return n.add(A + r, e);
      case 2:
        return n.add(A + r, e + s);
      case 3:
        return n.add(A, e + s);
    }
    return n;
  });
}, Xn = (
  /** @class */
  function() {
    function t(A) {
      this.element = A, this.inlineLevel = [], this.nonInlineLevel = [], this.negativeZIndex = [], this.zeroOrAutoZIndexOrTransformedOrOpacity = [], this.positiveZIndex = [], this.nonPositionedFloats = [], this.nonPositionedInlineLevel = [];
    }
    return t;
  }()
), Jn = (
  /** @class */
  function() {
    function t(A, e) {
      if (this.container = A, this.parent = e, this.effects = [], this.curves = new El(this.container), this.container.styles.opacity < 1 && this.effects.push(new ml(this.container.styles.opacity)), this.container.styles.transform !== null) {
        var r = this.container.bounds.left + this.container.styles.transformOrigin[0].number, s = this.container.bounds.top + this.container.styles.transformOrigin[1].number, n = this.container.styles.transform;
        this.effects.push(new vl(r, s, n));
      }
      if (this.container.styles.overflowX !== 0) {
        var i = wt(this.curves), a = Qt(this.curves);
        Ds(i, a) ? this.effects.push(new $e(
          i,
          6
          /* CONTENT */
        )) : (this.effects.push(new $e(
          i,
          2
          /* BACKGROUND_BORDERS */
        )), this.effects.push(new $e(
          a,
          4
          /* CONTENT */
        )));
      }
    }
    return t.prototype.getEffects = function(A) {
      for (var e = [
        2,
        3
        /* FIXED */
      ].indexOf(this.container.styles.position) === -1, r = this.parent, s = this.effects.slice(0); r; ) {
        var n = r.effects.filter(function(B) {
          return !_n(B);
        });
        if (e || r.container.styles.position !== 0 || !r.parent) {
          if (s.unshift.apply(s, n), e = [
            2,
            3
            /* FIXED */
          ].indexOf(r.container.styles.position) === -1, r.container.styles.overflowX !== 0) {
            var i = wt(r.curves), a = Qt(r.curves);
            Ds(i, a) || s.unshift(new $e(
              a,
              6
              /* CONTENT */
            ));
          }
        } else
          s.unshift.apply(s, n);
        r = r.parent;
      }
      return s.filter(function(B) {
        return k(B.target, A);
      });
    }, t;
  }()
), dr = function(t, A, e, r) {
  t.container.elements.forEach(function(s) {
    var n = k(
      s.flags,
      4
      /* CREATES_REAL_STACKING_CONTEXT */
    ), i = k(
      s.flags,
      2
      /* CREATES_STACKING_CONTEXT */
    ), a = new Jn(s, t);
    k(
      s.styles.display,
      2048
      /* LIST_ITEM */
    ) && r.push(a);
    var B = k(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) ? [] : r;
    if (n || i) {
      var o = n || s.styles.isPositioned() ? e : A, c = new Xn(a);
      if (s.styles.isPositioned() || s.styles.opacity < 1 || s.styles.isTransformed()) {
        var l = s.styles.zIndex.order;
        if (l < 0) {
          var g = 0;
          o.negativeZIndex.some(function(u, w) {
            return l > u.element.container.styles.zIndex.order ? (g = w, !1) : g > 0;
          }), o.negativeZIndex.splice(g, 0, c);
        } else if (l > 0) {
          var Q = 0;
          o.positiveZIndex.some(function(u, w) {
            return l >= u.element.container.styles.zIndex.order ? (Q = w + 1, !1) : Q > 0;
          }), o.positiveZIndex.splice(Q, 0, c);
        } else
          o.zeroOrAutoZIndexOrTransformedOrOpacity.push(c);
      } else
        s.styles.isFloating() ? o.nonPositionedFloats.push(c) : o.nonPositionedInlineLevel.push(c);
      dr(a, c, n ? c : e, B);
    } else
      s.styles.isInlineLevel() ? A.inlineLevel.push(a) : A.nonInlineLevel.push(a), dr(a, A, e, B);
    k(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) && Wn(s, B);
  });
}, Wn = function(t, A) {
  for (var e = t instanceof fr ? t.start : 1, r = t instanceof fr ? t.reversed : !1, s = 0; s < A.length; s++) {
    var n = A[s];
    n.container instanceof Ln && typeof n.container.value == "number" && n.container.value !== 0 && (e = n.container.value), n.listValue = Le(e, n.container.styles.listStyleType, !0), e += r ? -1 : 1;
  }
}, Ll = function(t) {
  var A = new Jn(t, null), e = new Xn(A), r = [];
  return dr(A, e, e, r), Wn(A.container, r), e;
}, Ss = function(t, A) {
  switch (A) {
    case 0:
      return aA(t.topLeftBorderBox, t.topLeftPaddingBox, t.topRightBorderBox, t.topRightPaddingBox);
    case 1:
      return aA(t.topRightBorderBox, t.topRightPaddingBox, t.bottomRightBorderBox, t.bottomRightPaddingBox);
    case 2:
      return aA(t.bottomRightBorderBox, t.bottomRightPaddingBox, t.bottomLeftBorderBox, t.bottomLeftPaddingBox);
    case 3:
    default:
      return aA(t.bottomLeftBorderBox, t.bottomLeftPaddingBox, t.topLeftBorderBox, t.topLeftPaddingBox);
  }
}, bl = function(t, A) {
  switch (A) {
    case 0:
      return aA(t.topLeftBorderBox, t.topLeftBorderDoubleOuterBox, t.topRightBorderBox, t.topRightBorderDoubleOuterBox);
    case 1:
      return aA(t.topRightBorderBox, t.topRightBorderDoubleOuterBox, t.bottomRightBorderBox, t.bottomRightBorderDoubleOuterBox);
    case 2:
      return aA(t.bottomRightBorderBox, t.bottomRightBorderDoubleOuterBox, t.bottomLeftBorderBox, t.bottomLeftBorderDoubleOuterBox);
    case 3:
    default:
      return aA(t.bottomLeftBorderBox, t.bottomLeftBorderDoubleOuterBox, t.topLeftBorderBox, t.topLeftBorderDoubleOuterBox);
  }
}, Dl = function(t, A) {
  switch (A) {
    case 0:
      return aA(t.topLeftBorderDoubleInnerBox, t.topLeftPaddingBox, t.topRightBorderDoubleInnerBox, t.topRightPaddingBox);
    case 1:
      return aA(t.topRightBorderDoubleInnerBox, t.topRightPaddingBox, t.bottomRightBorderDoubleInnerBox, t.bottomRightPaddingBox);
    case 2:
      return aA(t.bottomRightBorderDoubleInnerBox, t.bottomRightPaddingBox, t.bottomLeftBorderDoubleInnerBox, t.bottomLeftPaddingBox);
    case 3:
    default:
      return aA(t.bottomLeftBorderDoubleInnerBox, t.bottomLeftPaddingBox, t.topLeftBorderDoubleInnerBox, t.topLeftPaddingBox);
  }
}, Sl = function(t, A) {
  switch (A) {
    case 0:
      return At(t.topLeftBorderStroke, t.topRightBorderStroke);
    case 1:
      return At(t.topRightBorderStroke, t.bottomRightBorderStroke);
    case 2:
      return At(t.bottomRightBorderStroke, t.bottomLeftBorderStroke);
    case 3:
    default:
      return At(t.bottomLeftBorderStroke, t.topLeftBorderStroke);
  }
}, At = function(t, A) {
  var e = [];
  return nA(t) ? e.push(t.subdivide(0.5, !1)) : e.push(t), nA(A) ? e.push(A.subdivide(0.5, !0)) : e.push(A), e;
}, aA = function(t, A, e, r) {
  var s = [];
  return nA(t) ? s.push(t.subdivide(0.5, !1)) : s.push(t), nA(e) ? s.push(e.subdivide(0.5, !0)) : s.push(e), nA(r) ? s.push(r.subdivide(0.5, !0).reverse()) : s.push(r), nA(A) ? s.push(A.subdivide(0.5, !1).reverse()) : s.push(A), s;
}, Yn = function(t) {
  var A = t.bounds, e = t.styles;
  return A.add(e.borderLeftWidth, e.borderTopWidth, -(e.borderRightWidth + e.borderLeftWidth), -(e.borderTopWidth + e.borderBottomWidth));
}, ft = function(t) {
  var A = t.styles, e = t.bounds, r = M(A.paddingLeft, e.width), s = M(A.paddingRight, e.width), n = M(A.paddingTop, e.width), i = M(A.paddingBottom, e.width);
  return e.add(r + A.borderLeftWidth, n + A.borderTopWidth, -(A.borderRightWidth + A.borderLeftWidth + r + s), -(A.borderTopWidth + A.borderBottomWidth + n + i));
}, Tl = function(t, A) {
  return t === 0 ? A.bounds : t === 2 ? ft(A) : Yn(A);
}, xl = function(t, A) {
  return t === 0 ? A.bounds : t === 2 ? ft(A) : Yn(A);
}, qt = function(t, A, e) {
  var r = Tl(se(t.styles.backgroundOrigin, A), t), s = xl(se(t.styles.backgroundClip, A), t), n = Ml(se(t.styles.backgroundSize, A), e, r), i = n[0], a = n[1], B = Ue(se(t.styles.backgroundPosition, A), r.width - i, r.height - a), o = Ol(se(t.styles.backgroundRepeat, A), B, n, r, s), c = Math.round(r.left + B[0]), l = Math.round(r.top + B[1]);
  return [o, c, l, i, a];
}, te = function(t) {
  return T(t) && t.value === ie.AUTO;
}, et = function(t) {
  return typeof t == "number";
}, Ml = function(t, A, e) {
  var r = A[0], s = A[1], n = A[2], i = t[0], a = t[1];
  if (!i)
    return [0, 0];
  if (P(i) && a && P(a))
    return [M(i, e.width), M(a, e.height)];
  var B = et(n);
  if (T(i) && (i.value === ie.CONTAIN || i.value === ie.COVER)) {
    if (et(n)) {
      var o = e.width / e.height;
      return o < n != (i.value === ie.COVER) ? [e.width, e.width / n] : [e.height * n, e.height];
    }
    return [e.width, e.height];
  }
  var c = et(r), l = et(s), g = c || l;
  if (te(i) && (!a || te(a))) {
    if (c && l)
      return [r, s];
    if (!B && !g)
      return [e.width, e.height];
    if (g && B) {
      var Q = c ? r : s * n, u = l ? s : r / n;
      return [Q, u];
    }
    var w = c ? r : e.width, E = l ? s : e.height;
    return [w, E];
  }
  if (B) {
    var C = 0, F = 0;
    return P(i) ? C = M(i, e.width) : P(a) && (F = M(a, e.height)), te(i) ? C = F * n : (!a || te(a)) && (F = C / n), [C, F];
  }
  var y = null, v = null;
  if (P(i) ? y = M(i, e.width) : a && P(a) && (v = M(a, e.height)), y !== null && (!a || te(a)) && (v = c && l ? y / r * s : e.height), v !== null && te(i) && (y = c && l ? v / s * r : e.width), y !== null && v !== null)
    return [y, v];
  throw new Error("Unable to calculate background-size for element");
}, se = function(t, A) {
  var e = t[A];
  return typeof e > "u" ? t[0] : e;
}, Ol = function(t, A, e, r, s) {
  var n = A[0], i = A[1], a = e[0], B = e[1];
  switch (t) {
    case 2:
      return [
        new U(Math.round(r.left), Math.round(r.top + i)),
        new U(Math.round(r.left + r.width), Math.round(r.top + i)),
        new U(Math.round(r.left + r.width), Math.round(B + r.top + i)),
        new U(Math.round(r.left), Math.round(B + r.top + i))
      ];
    case 3:
      return [
        new U(Math.round(r.left + n), Math.round(r.top)),
        new U(Math.round(r.left + n + a), Math.round(r.top)),
        new U(Math.round(r.left + n + a), Math.round(r.height + r.top)),
        new U(Math.round(r.left + n), Math.round(r.height + r.top))
      ];
    case 1:
      return [
        new U(Math.round(r.left + n), Math.round(r.top + i)),
        new U(Math.round(r.left + n + a), Math.round(r.top + i)),
        new U(Math.round(r.left + n + a), Math.round(r.top + i + B)),
        new U(Math.round(r.left + n), Math.round(r.top + i + B))
      ];
    default:
      return [
        new U(Math.round(s.left), Math.round(s.top)),
        new U(Math.round(s.left + s.width), Math.round(s.top)),
        new U(Math.round(s.left + s.width), Math.round(s.height + s.top)),
        new U(Math.round(s.left), Math.round(s.height + s.top))
      ];
  }
}, Gl = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", Ts = "Hidden Text", Rl = (
  /** @class */
  function() {
    function t(A) {
      this._data = {}, this._document = A;
    }
    return t.prototype.parseMetrics = function(A, e) {
      var r = this._document.createElement("div"), s = this._document.createElement("img"), n = this._document.createElement("span"), i = this._document.body;
      r.style.visibility = "hidden", r.style.fontFamily = A, r.style.fontSize = e, r.style.margin = "0", r.style.padding = "0", r.style.whiteSpace = "nowrap", i.appendChild(r), s.src = Gl, s.width = 1, s.height = 1, s.style.margin = "0", s.style.padding = "0", s.style.verticalAlign = "baseline", n.style.fontFamily = A, n.style.fontSize = e, n.style.margin = "0", n.style.padding = "0", n.appendChild(this._document.createTextNode(Ts)), r.appendChild(n), r.appendChild(s);
      var a = s.offsetTop - n.offsetTop + 2;
      r.removeChild(n), r.appendChild(this._document.createTextNode(Ts)), r.style.lineHeight = "normal", s.style.verticalAlign = "super";
      var B = s.offsetTop - r.offsetTop + 2;
      return i.removeChild(r), { baseline: a, middle: B };
    }, t.prototype.getMetrics = function(A, e) {
      var r = A + " " + e;
      return typeof this._data[r] > "u" && (this._data[r] = this.parseMetrics(A, e)), this._data[r];
    }, t;
  }()
), Zn = (
  /** @class */
  function() {
    function t(A, e) {
      this.context = A, this.options = e;
    }
    return t;
  }()
), Nl = 1e4, Vl = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s._activeEffects = [], s.canvas = r.canvas ? r.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), r.canvas || (s.canvas.width = Math.floor(r.width * r.scale), s.canvas.height = Math.floor(r.height * r.scale), s.canvas.style.width = r.width + "px", s.canvas.style.height = r.height + "px"), s.fontMetrics = new Rl(document), s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-r.x, -r.y), s.ctx.textBaseline = "bottom", s._activeEffects = [], s.context.logger.debug("Canvas renderer initialized (" + r.width + "x" + r.height + ") with scale " + r.scale), s;
    }
    return A.prototype.applyEffects = function(e) {
      for (var r = this; this._activeEffects.length; )
        this.popEffect();
      e.forEach(function(s) {
        return r.applyEffect(s);
      });
    }, A.prototype.applyEffect = function(e) {
      this.ctx.save(), yl(e) && (this.ctx.globalAlpha = e.opacity), Il(e) && (this.ctx.translate(e.offsetX, e.offsetY), this.ctx.transform(e.matrix[0], e.matrix[1], e.matrix[2], e.matrix[3], e.matrix[4], e.matrix[5]), this.ctx.translate(-e.offsetX, -e.offsetY)), _n(e) && (this.path(e.path), this.ctx.clip()), this._activeEffects.push(e);
    }, A.prototype.popEffect = function() {
      this._activeEffects.pop(), this.ctx.restore();
    }, A.prototype.renderStack = function(e) {
      return q(this, void 0, void 0, function() {
        var r;
        return Z(this, function(s) {
          switch (s.label) {
            case 0:
              return r = e.element.container.styles, r.isVisible() ? [4, this.renderStackContent(e)] : [3, 2];
            case 1:
              s.sent(), s.label = 2;
            case 2:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNode = function(e) {
      return q(this, void 0, void 0, function() {
        return Z(this, function(r) {
          switch (r.label) {
            case 0:
              if (k(
                e.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return e.container.styles.isVisible() ? [4, this.renderNodeBackgroundAndBorders(e)] : [3, 3];
            case 1:
              return r.sent(), [4, this.renderNodeContent(e)];
            case 2:
              r.sent(), r.label = 3;
            case 3:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderTextWithLetterSpacing = function(e, r, s) {
      var n = this;
      if (r === 0)
        this.ctx.fillText(e.text, e.bounds.left, e.bounds.top + s);
      else {
        var i = Kr(e.text);
        i.reduce(function(a, B) {
          return n.ctx.fillText(B, a, e.bounds.top + s), a + n.ctx.measureText(B).width;
        }, e.bounds.left);
      }
    }, A.prototype.createFontStyle = function(e) {
      var r = e.fontVariant.filter(function(i) {
        return i === "normal" || i === "small-caps";
      }).join(""), s = Jl(e.fontFamily).join(", "), n = De(e.fontSize) ? "" + e.fontSize.number + e.fontSize.unit : e.fontSize.number + "px";
      return [
        [e.fontStyle, r, e.fontWeight, n, s].join(" "),
        s,
        n
      ];
    }, A.prototype.renderTextNode = function(e, r) {
      return q(this, void 0, void 0, function() {
        var s, n, i, a, B, o, c, l, g = this;
        return Z(this, function(Q) {
          return s = this.createFontStyle(r), n = s[0], i = s[1], a = s[2], this.ctx.font = n, this.ctx.direction = r.direction === 1 ? "rtl" : "ltr", this.ctx.textAlign = "left", this.ctx.textBaseline = "alphabetic", B = this.fontMetrics.getMetrics(i, a), o = B.baseline, c = B.middle, l = r.paintOrder, e.textBounds.forEach(function(u) {
            l.forEach(function(w) {
              switch (w) {
                case 0:
                  g.ctx.fillStyle = _(r.color), g.renderTextWithLetterSpacing(u, r.letterSpacing, o);
                  var E = r.textShadow;
                  E.length && u.text.trim().length && (E.slice(0).reverse().forEach(function(C) {
                    g.ctx.shadowColor = _(C.color), g.ctx.shadowOffsetX = C.offsetX.number * g.options.scale, g.ctx.shadowOffsetY = C.offsetY.number * g.options.scale, g.ctx.shadowBlur = C.blur.number, g.renderTextWithLetterSpacing(u, r.letterSpacing, o);
                  }), g.ctx.shadowColor = "", g.ctx.shadowOffsetX = 0, g.ctx.shadowOffsetY = 0, g.ctx.shadowBlur = 0), r.textDecorationLine.length && (g.ctx.fillStyle = _(r.textDecorationColor || r.color), r.textDecorationLine.forEach(function(C) {
                    switch (C) {
                      case 1:
                        g.ctx.fillRect(u.bounds.left, Math.round(u.bounds.top + o), u.bounds.width, 1);
                        break;
                      case 2:
                        g.ctx.fillRect(u.bounds.left, Math.round(u.bounds.top), u.bounds.width, 1);
                        break;
                      case 3:
                        g.ctx.fillRect(u.bounds.left, Math.ceil(u.bounds.top + c), u.bounds.width, 1);
                        break;
                    }
                  }));
                  break;
                case 1:
                  r.webkitTextStrokeWidth && u.text.trim().length && (g.ctx.strokeStyle = _(r.webkitTextStrokeColor), g.ctx.lineWidth = r.webkitTextStrokeWidth, g.ctx.lineJoin = window.chrome ? "miter" : "round", g.ctx.strokeText(u.text, u.bounds.left, u.bounds.top + o)), g.ctx.strokeStyle = "", g.ctx.lineWidth = 0, g.ctx.lineJoin = "miter";
                  break;
              }
            });
          }), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderReplacedElement = function(e, r, s) {
      if (s && e.intrinsicWidth > 0 && e.intrinsicHeight > 0) {
        var n = ft(e), i = Qt(r);
        this.path(i), this.ctx.save(), this.ctx.clip(), this.ctx.drawImage(s, 0, 0, e.intrinsicWidth, e.intrinsicHeight, n.left, n.top, n.width, n.height), this.ctx.restore();
      }
    }, A.prototype.renderNodeContent = function(e) {
      return q(this, void 0, void 0, function() {
        var r, s, n, i, a, B, F, F, o, c, l, g, v, Q, u, H, w, E, C, F, y, v, H;
        return Z(this, function(h) {
          switch (h.label) {
            case 0:
              this.applyEffects(e.getEffects(
                4
                /* CONTENT */
              )), r = e.container, s = e.curves, n = r.styles, i = 0, a = r.textNodes, h.label = 1;
            case 1:
              return i < a.length ? (B = a[i], [4, this.renderTextNode(B, n)]) : [3, 4];
            case 2:
              h.sent(), h.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              if (!(r instanceof In))
                return [3, 8];
              h.label = 5;
            case 5:
              return h.trys.push([5, 7, , 8]), [4, this.context.cache.match(r.src)];
            case 6:
              return F = h.sent(), this.renderReplacedElement(r, s, F), [3, 8];
            case 7:
              return h.sent(), this.context.logger.error("Error loading image " + r.src), [3, 8];
            case 8:
              if (r instanceof yn && this.renderReplacedElement(r, s, r.canvas), !(r instanceof Kn))
                return [3, 12];
              h.label = 9;
            case 9:
              return h.trys.push([9, 11, , 12]), [4, this.context.cache.match(r.svg)];
            case 10:
              return F = h.sent(), this.renderReplacedElement(r, s, F), [3, 12];
            case 11:
              return h.sent(), this.context.logger.error("Error loading svg " + r.svg.substring(0, 255)), [3, 12];
            case 12:
              return r instanceof Sn && r.tree ? (o = new A(this.context, {
                scale: this.options.scale,
                backgroundColor: r.backgroundColor,
                x: 0,
                y: 0,
                width: r.width,
                height: r.height
              }), [4, o.render(r.tree)]) : [3, 14];
            case 13:
              c = h.sent(), r.width && r.height && this.ctx.drawImage(c, 0, 0, r.width, r.height, r.bounds.left, r.bounds.top, r.bounds.width, r.bounds.height), h.label = 14;
            case 14:
              if (r instanceof Lr && (l = Math.min(r.bounds.width, r.bounds.height), r.type === ct ? r.checked && (this.ctx.save(), this.path([
                new U(r.bounds.left + l * 0.39363, r.bounds.top + l * 0.79),
                new U(r.bounds.left + l * 0.16, r.bounds.top + l * 0.5549),
                new U(r.bounds.left + l * 0.27347, r.bounds.top + l * 0.44071),
                new U(r.bounds.left + l * 0.39694, r.bounds.top + l * 0.5649),
                new U(r.bounds.left + l * 0.72983, r.bounds.top + l * 0.23),
                new U(r.bounds.left + l * 0.84, r.bounds.top + l * 0.34085),
                new U(r.bounds.left + l * 0.39363, r.bounds.top + l * 0.79)
              ]), this.ctx.fillStyle = _(ds), this.ctx.fill(), this.ctx.restore()) : r.type === lt && r.checked && (this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(r.bounds.left + l / 2, r.bounds.top + l / 2, l / 4, 0, Math.PI * 2, !0), this.ctx.fillStyle = _(ds), this.ctx.fill(), this.ctx.restore())), Pl(r) && r.value.length) {
                switch (g = this.createFontStyle(n), v = g[0], Q = g[1], u = this.fontMetrics.getMetrics(v, Q).baseline, this.ctx.font = v, this.ctx.fillStyle = _(n.color), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = _l(r.styles.textAlign), H = ft(r), w = 0, r.styles.textAlign) {
                  case 1:
                    w += H.width / 2;
                    break;
                  case 2:
                    w += H.width;
                    break;
                }
                E = H.add(w, 0, 0, -H.height / 2 + 1), this.ctx.save(), this.path([
                  new U(H.left, H.top),
                  new U(H.left + H.width, H.top),
                  new U(H.left + H.width, H.top + H.height),
                  new U(H.left, H.top + H.height)
                ]), this.ctx.clip(), this.renderTextWithLetterSpacing(new me(r.value, E), n.letterSpacing, u), this.ctx.restore(), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = "left";
              }
              if (!k(
                r.styles.display,
                2048
                /* LIST_ITEM */
              ))
                return [3, 20];
              if (r.styles.listStyleImage === null)
                return [3, 19];
              if (C = r.styles.listStyleImage, C.type !== 0)
                return [3, 18];
              F = void 0, y = C.url, h.label = 15;
            case 15:
              return h.trys.push([15, 17, , 18]), [4, this.context.cache.match(y)];
            case 16:
              return F = h.sent(), this.ctx.drawImage(F, r.bounds.left - (F.width + 10), r.bounds.top), [3, 18];
            case 17:
              return h.sent(), this.context.logger.error("Error loading list-style-image " + y), [3, 18];
            case 18:
              return [3, 20];
            case 19:
              e.listValue && r.styles.listStyleType !== -1 && (v = this.createFontStyle(n)[0], this.ctx.font = v, this.ctx.fillStyle = _(n.color), this.ctx.textBaseline = "middle", this.ctx.textAlign = "right", H = new vA(r.bounds.left, r.bounds.top + M(r.styles.paddingTop, r.bounds.width), r.bounds.width, ss(n.lineHeight, n.fontSize.number) / 2 + 1), this.renderTextWithLetterSpacing(new me(e.listValue, H), n.letterSpacing, ss(n.lineHeight, n.fontSize.number) / 2 + 2), this.ctx.textBaseline = "bottom", this.ctx.textAlign = "left"), h.label = 20;
            case 20:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderStackContent = function(e) {
      return q(this, void 0, void 0, function() {
        var r, s, C, n, i, C, a, B, C, o, c, C, l, g, C, Q, u, C, w, E, C;
        return Z(this, function(F) {
          switch (F.label) {
            case 0:
              if (k(
                e.element.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return [4, this.renderNodeBackgroundAndBorders(e.element)];
            case 1:
              F.sent(), r = 0, s = e.negativeZIndex, F.label = 2;
            case 2:
              return r < s.length ? (C = s[r], [4, this.renderStack(C)]) : [3, 5];
            case 3:
              F.sent(), F.label = 4;
            case 4:
              return r++, [3, 2];
            case 5:
              return [4, this.renderNodeContent(e.element)];
            case 6:
              F.sent(), n = 0, i = e.nonInlineLevel, F.label = 7;
            case 7:
              return n < i.length ? (C = i[n], [4, this.renderNode(C)]) : [3, 10];
            case 8:
              F.sent(), F.label = 9;
            case 9:
              return n++, [3, 7];
            case 10:
              a = 0, B = e.nonPositionedFloats, F.label = 11;
            case 11:
              return a < B.length ? (C = B[a], [4, this.renderStack(C)]) : [3, 14];
            case 12:
              F.sent(), F.label = 13;
            case 13:
              return a++, [3, 11];
            case 14:
              o = 0, c = e.nonPositionedInlineLevel, F.label = 15;
            case 15:
              return o < c.length ? (C = c[o], [4, this.renderStack(C)]) : [3, 18];
            case 16:
              F.sent(), F.label = 17;
            case 17:
              return o++, [3, 15];
            case 18:
              l = 0, g = e.inlineLevel, F.label = 19;
            case 19:
              return l < g.length ? (C = g[l], [4, this.renderNode(C)]) : [3, 22];
            case 20:
              F.sent(), F.label = 21;
            case 21:
              return l++, [3, 19];
            case 22:
              Q = 0, u = e.zeroOrAutoZIndexOrTransformedOrOpacity, F.label = 23;
            case 23:
              return Q < u.length ? (C = u[Q], [4, this.renderStack(C)]) : [3, 26];
            case 24:
              F.sent(), F.label = 25;
            case 25:
              return Q++, [3, 23];
            case 26:
              w = 0, E = e.positiveZIndex, F.label = 27;
            case 27:
              return w < E.length ? (C = E[w], [4, this.renderStack(C)]) : [3, 30];
            case 28:
              F.sent(), F.label = 29;
            case 29:
              return w++, [3, 27];
            case 30:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.mask = function(e) {
      this.ctx.beginPath(), this.ctx.moveTo(0, 0), this.ctx.lineTo(this.canvas.width, 0), this.ctx.lineTo(this.canvas.width, this.canvas.height), this.ctx.lineTo(0, this.canvas.height), this.ctx.lineTo(0, 0), this.formatPath(e.slice(0).reverse()), this.ctx.closePath();
    }, A.prototype.path = function(e) {
      this.ctx.beginPath(), this.formatPath(e), this.ctx.closePath();
    }, A.prototype.formatPath = function(e) {
      var r = this;
      e.forEach(function(s, n) {
        var i = nA(s) ? s.start : s;
        n === 0 ? r.ctx.moveTo(i.x, i.y) : r.ctx.lineTo(i.x, i.y), nA(s) && r.ctx.bezierCurveTo(s.startControl.x, s.startControl.y, s.endControl.x, s.endControl.y, s.end.x, s.end.y);
      });
    }, A.prototype.renderRepeat = function(e, r, s, n) {
      this.path(e), this.ctx.fillStyle = r, this.ctx.translate(s, n), this.ctx.fill(), this.ctx.translate(-s, -n);
    }, A.prototype.resizeImage = function(e, r, s) {
      var n;
      if (e.width === r && e.height === s)
        return e;
      var i = (n = this.canvas.ownerDocument) !== null && n !== void 0 ? n : document, a = i.createElement("canvas");
      a.width = Math.max(1, r), a.height = Math.max(1, s);
      var B = a.getContext("2d");
      return B.drawImage(e, 0, 0, e.width, e.height, 0, 0, r, s), a;
    }, A.prototype.renderBackgroundImage = function(e) {
      return q(this, void 0, void 0, function() {
        var r, s, n, i, a, B;
        return Z(this, function(o) {
          switch (o.label) {
            case 0:
              r = e.styles.backgroundImage.length - 1, s = function(c) {
                var l, g, Q, p, j, Y, m, R, L, u, p, j, Y, m, R, w, E, C, F, y, v, H, h, K, L, f, p, I, D, m, R, $, j, Y, BA, uA, IA, NA, VA, hA, PA, UA;
                return Z(this, function(zA) {
                  switch (zA.label) {
                    case 0:
                      if (c.type !== 0)
                        return [3, 5];
                      l = void 0, g = c.url, zA.label = 1;
                    case 1:
                      return zA.trys.push([1, 3, , 4]), [4, n.context.cache.match(g)];
                    case 2:
                      return l = zA.sent(), [3, 4];
                    case 3:
                      return zA.sent(), n.context.logger.error("Error loading background-image " + g), [3, 4];
                    case 4:
                      return l && (Q = qt(e, r, [
                        l.width,
                        l.height,
                        l.width / l.height
                      ]), p = Q[0], j = Q[1], Y = Q[2], m = Q[3], R = Q[4], L = n.ctx.createPattern(n.resizeImage(l, m, R), "repeat"), n.renderRepeat(p, L, j, Y)), [3, 6];
                    case 5:
                      mB(c) ? (u = qt(e, r, [null, null, null]), p = u[0], j = u[1], Y = u[2], m = u[3], R = u[4], w = dB(c.angle, m, R), E = w[0], C = w[1], F = w[2], y = w[3], v = w[4], H = document.createElement("canvas"), H.width = m, H.height = R, h = H.getContext("2d"), K = h.createLinearGradient(C, y, F, v), ts(c.stops, E).forEach(function(oe) {
                        return K.addColorStop(oe.stop, _(oe.color));
                      }), h.fillStyle = K, h.fillRect(0, 0, m, R), m > 0 && R > 0 && (L = n.ctx.createPattern(H, "repeat"), n.renderRepeat(p, L, j, Y))) : IB(c) && (f = qt(e, r, [
                        null,
                        null,
                        null
                      ]), p = f[0], I = f[1], D = f[2], m = f[3], R = f[4], $ = c.position.length === 0 ? [mr] : c.position, j = M($[0], m), Y = M($[$.length - 1], R), BA = pB(c, j, Y, m, R), uA = BA[0], IA = BA[1], uA > 0 && IA > 0 && (NA = n.ctx.createRadialGradient(I + j, D + Y, 0, I + j, D + Y, uA), ts(c.stops, uA * 2).forEach(function(oe) {
                        return NA.addColorStop(oe.stop, _(oe.color));
                      }), n.path(p), n.ctx.fillStyle = NA, uA !== IA ? (VA = e.bounds.left + 0.5 * e.bounds.width, hA = e.bounds.top + 0.5 * e.bounds.height, PA = IA / uA, UA = 1 / PA, n.ctx.save(), n.ctx.translate(VA, hA), n.ctx.transform(1, 0, 0, PA, 0, 0), n.ctx.translate(-VA, -hA), n.ctx.fillRect(I, UA * (D - hA) + hA, m, R * UA), n.ctx.restore()) : n.ctx.fill())), zA.label = 6;
                    case 6:
                      return r--, [
                        2
                        /*return*/
                      ];
                  }
                });
              }, n = this, i = 0, a = e.styles.backgroundImage.slice(0).reverse(), o.label = 1;
            case 1:
              return i < a.length ? (B = a[i], [5, s(B)]) : [3, 4];
            case 2:
              o.sent(), o.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderSolidBorder = function(e, r, s) {
      return q(this, void 0, void 0, function() {
        return Z(this, function(n) {
          return this.path(Ss(s, r)), this.ctx.fillStyle = _(e), this.ctx.fill(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderDoubleBorder = function(e, r, s, n) {
      return q(this, void 0, void 0, function() {
        var i, a;
        return Z(this, function(B) {
          switch (B.label) {
            case 0:
              return r < 3 ? [4, this.renderSolidBorder(e, s, n)] : [3, 2];
            case 1:
              return B.sent(), [
                2
                /*return*/
              ];
            case 2:
              return i = bl(n, s), this.path(i), this.ctx.fillStyle = _(e), this.ctx.fill(), a = Dl(n, s), this.path(a), this.ctx.fill(), [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNodeBackgroundAndBorders = function(e) {
      return q(this, void 0, void 0, function() {
        var r, s, n, i, a, B, o, c, l = this;
        return Z(this, function(g) {
          switch (g.label) {
            case 0:
              return this.applyEffects(e.getEffects(
                2
                /* BACKGROUND_BORDERS */
              )), r = e.container.styles, s = !OA(r.backgroundColor) || r.backgroundImage.length, n = [
                { style: r.borderTopStyle, color: r.borderTopColor, width: r.borderTopWidth },
                { style: r.borderRightStyle, color: r.borderRightColor, width: r.borderRightWidth },
                { style: r.borderBottomStyle, color: r.borderBottomColor, width: r.borderBottomWidth },
                { style: r.borderLeftStyle, color: r.borderLeftColor, width: r.borderLeftWidth }
              ], i = kl(se(r.backgroundClip, 0), e.curves), s || r.boxShadow.length ? (this.ctx.save(), this.path(i), this.ctx.clip(), OA(r.backgroundColor) || (this.ctx.fillStyle = _(r.backgroundColor), this.ctx.fill()), [4, this.renderBackgroundImage(e.container)]) : [3, 2];
            case 1:
              g.sent(), this.ctx.restore(), r.boxShadow.slice(0).reverse().forEach(function(Q) {
                l.ctx.save();
                var u = wt(e.curves), w = Q.inset ? 0 : Nl, E = Kl(u, -w + (Q.inset ? 1 : -1) * Q.spread.number, (Q.inset ? 1 : -1) * Q.spread.number, Q.spread.number * (Q.inset ? -2 : 2), Q.spread.number * (Q.inset ? -2 : 2));
                Q.inset ? (l.path(u), l.ctx.clip(), l.mask(E)) : (l.mask(u), l.ctx.clip(), l.path(E)), l.ctx.shadowOffsetX = Q.offsetX.number + w, l.ctx.shadowOffsetY = Q.offsetY.number, l.ctx.shadowColor = _(Q.color), l.ctx.shadowBlur = Q.blur.number, l.ctx.fillStyle = Q.inset ? _(Q.color) : "rgba(0,0,0,1)", l.ctx.fill(), l.ctx.restore();
              }), g.label = 2;
            case 2:
              a = 0, B = 0, o = n, g.label = 3;
            case 3:
              return B < o.length ? (c = o[B], c.style !== 0 && !OA(c.color) && c.width > 0 ? c.style !== 2 ? [3, 5] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                a,
                e.curves,
                2
                /* DASHED */
              )] : [3, 11]) : [3, 13];
            case 4:
              return g.sent(), [3, 11];
            case 5:
              return c.style !== 3 ? [3, 7] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                a,
                e.curves,
                3
                /* DOTTED */
              )];
            case 6:
              return g.sent(), [3, 11];
            case 7:
              return c.style !== 4 ? [3, 9] : [4, this.renderDoubleBorder(c.color, c.width, a, e.curves)];
            case 8:
              return g.sent(), [3, 11];
            case 9:
              return [4, this.renderSolidBorder(c.color, a, e.curves)];
            case 10:
              g.sent(), g.label = 11;
            case 11:
              a++, g.label = 12;
            case 12:
              return B++, [3, 3];
            case 13:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderDashedDottedBorder = function(e, r, s, n, i) {
      return q(this, void 0, void 0, function() {
        var a, B, o, c, l, g, Q, u, w, E, C, F, y, v, H, h, H, h;
        return Z(this, function(K) {
          return this.ctx.save(), a = Sl(n, s), B = Ss(n, s), i === 2 && (this.path(B), this.ctx.clip()), nA(B[0]) ? (o = B[0].start.x, c = B[0].start.y) : (o = B[0].x, c = B[0].y), nA(B[1]) ? (l = B[1].end.x, g = B[1].end.y) : (l = B[1].x, g = B[1].y), s === 0 || s === 2 ? Q = Math.abs(o - l) : Q = Math.abs(c - g), this.ctx.beginPath(), i === 3 ? this.formatPath(a) : this.formatPath(B.slice(0, 2)), u = r < 3 ? r * 3 : r * 2, w = r < 3 ? r * 2 : r, i === 3 && (u = r, w = r), E = !0, Q <= u * 2 ? E = !1 : Q <= u * 2 + w ? (C = Q / (2 * u + w), u *= C, w *= C) : (F = Math.floor((Q + w) / (u + w)), y = (Q - F * u) / (F - 1), v = (Q - (F + 1) * u) / F, w = v <= 0 || Math.abs(w - y) < Math.abs(w - v) ? y : v), E && (i === 3 ? this.ctx.setLineDash([0, u + w]) : this.ctx.setLineDash([u, w])), i === 3 ? (this.ctx.lineCap = "round", this.ctx.lineWidth = r) : this.ctx.lineWidth = r * 2 + 1.1, this.ctx.strokeStyle = _(e), this.ctx.stroke(), this.ctx.setLineDash([]), i === 2 && (nA(B[0]) && (H = B[3], h = B[0], this.ctx.beginPath(), this.formatPath([new U(H.end.x, H.end.y), new U(h.start.x, h.start.y)]), this.ctx.stroke()), nA(B[1]) && (H = B[1], h = B[2], this.ctx.beginPath(), this.formatPath([new U(H.end.x, H.end.y), new U(h.start.x, h.start.y)]), this.ctx.stroke())), this.ctx.restore(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.render = function(e) {
      return q(this, void 0, void 0, function() {
        var r;
        return Z(this, function(s) {
          switch (s.label) {
            case 0:
              return this.options.backgroundColor && (this.ctx.fillStyle = _(this.options.backgroundColor), this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height)), r = Ll(e), [4, this.renderStack(r)];
            case 1:
              return s.sent(), this.applyEffects([]), [2, this.canvas];
          }
        });
      });
    }, A;
  }(Zn)
), Pl = function(t) {
  return t instanceof Dn || t instanceof bn ? !0 : t instanceof Lr && t.type !== lt && t.type !== ct;
}, kl = function(t, A) {
  switch (t) {
    case 0:
      return wt(A);
    case 2:
      return Hl(A);
    case 1:
    default:
      return Qt(A);
  }
}, _l = function(t) {
  switch (t) {
    case 1:
      return "center";
    case 2:
      return "right";
    case 0:
    default:
      return "left";
  }
}, Xl = ["-apple-system", "system-ui"], Jl = function(t) {
  return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) ? t.filter(function(A) {
    return Xl.indexOf(A) === -1;
  }) : t;
}, Wl = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.canvas = r.canvas ? r.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), s.options = r, s.canvas.width = Math.floor(r.width * r.scale), s.canvas.height = Math.floor(r.height * r.scale), s.canvas.style.width = r.width + "px", s.canvas.style.height = r.height + "px", s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-r.x, -r.y), s.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + r.width + "x" + r.height + " at " + r.x + "," + r.y + ") with scale " + r.scale), s;
    }
    return A.prototype.render = function(e) {
      return q(this, void 0, void 0, function() {
        var r, s;
        return Z(this, function(n) {
          switch (n.label) {
            case 0:
              return r = Qr(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, e), [4, Yl(r)];
            case 1:
              return s = n.sent(), this.options.backgroundColor && (this.ctx.fillStyle = _(this.options.backgroundColor), this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale)), this.ctx.drawImage(s, -this.options.x * this.options.scale, -this.options.y * this.options.scale), [2, this.canvas];
          }
        });
      });
    }, A;
  }(Zn)
), Yl = function(t) {
  return new Promise(function(A, e) {
    var r = new Image();
    r.onload = function() {
      A(r);
    }, r.onerror = e, r.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(t));
  });
}, Zl = (
  /** @class */
  function() {
    function t(A) {
      var e = A.id, r = A.enabled;
      this.id = e, this.enabled = r, this.start = Date.now();
    }
    return t.prototype.debug = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.debug == "function" ? console.debug.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.prototype.getTime = function() {
      return Date.now() - this.start;
    }, t.prototype.info = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && typeof window < "u" && window.console && typeof console.info == "function" && console.info.apply(console, Se([this.id, this.getTime() + "ms"], A));
    }, t.prototype.warn = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.warn == "function" ? console.warn.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.prototype.error = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.error == "function" ? console.error.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.instances = {}, t;
  }()
), zl = (
  /** @class */
  function() {
    function t(A, e) {
      var r;
      this.windowBounds = e, this.instanceName = "#" + t.instanceCount++, this.logger = new Zl({ id: this.instanceName, enabled: A.logging }), this.cache = (r = A.cache) !== null && r !== void 0 ? r : new fl(this, A);
    }
    return t.instanceCount = 1, t;
  }()
), jl = function(t, A) {
  return A === void 0 && (A = {}), ql(t, A);
};
typeof window < "u" && kn.setContext(window);
var ql = function(t, A) {
  return q(void 0, void 0, void 0, function() {
    var e, r, s, n, i, a, B, o, c, l, g, Q, u, w, E, C, F, y, v, H, K, h, K, L, f, p, I, D, m, R, $, j, Y, BA, uA, IA, NA, VA, hA, PA;
    return Z(this, function(UA) {
      switch (UA.label) {
        case 0:
          if (!t || typeof t != "object")
            return [2, Promise.reject("Invalid element provided as first argument")];
          if (e = t.ownerDocument, !e)
            throw new Error("Element is not attached to a Document");
          if (r = e.defaultView, !r)
            throw new Error("Document is not attached to a Window");
          return s = {
            allowTaint: (L = A.allowTaint) !== null && L !== void 0 ? L : !1,
            imageTimeout: (f = A.imageTimeout) !== null && f !== void 0 ? f : 15e3,
            proxy: A.proxy,
            useCORS: (p = A.useCORS) !== null && p !== void 0 ? p : !1
          }, n = Ar({ logging: (I = A.logging) !== null && I !== void 0 ? I : !0, cache: A.cache }, s), i = {
            windowWidth: (D = A.windowWidth) !== null && D !== void 0 ? D : r.innerWidth,
            windowHeight: (m = A.windowHeight) !== null && m !== void 0 ? m : r.innerHeight,
            scrollX: (R = A.scrollX) !== null && R !== void 0 ? R : r.pageXOffset,
            scrollY: ($ = A.scrollY) !== null && $ !== void 0 ? $ : r.pageYOffset
          }, a = new vA(i.scrollX, i.scrollY, i.windowWidth, i.windowHeight), B = new zl(n, a), o = (j = A.foreignObjectRendering) !== null && j !== void 0 ? j : !1, c = {
            allowTaint: (Y = A.allowTaint) !== null && Y !== void 0 ? Y : !1,
            onclone: A.onclone,
            ignoreElements: A.ignoreElements,
            inlineImages: o,
            copyStyles: o
          }, B.logger.debug("Starting document clone with size " + a.width + "x" + a.height + " scrolled to " + -a.left + "," + -a.top), l = new Ls(B, t, c), g = l.clonedReferenceElement, g ? [4, l.toIFrame(e, a)] : [2, Promise.reject("Unable to find element in cloned iframe")];
        case 1:
          return Q = UA.sent(), u = br(g) || $c(g) ? yi(g.ownerDocument) : dt(B, g), w = u.width, E = u.height, C = u.left, F = u.top, y = $l(B, g, A.backgroundColor), v = {
            canvas: A.canvas,
            backgroundColor: y,
            scale: (uA = (BA = A.scale) !== null && BA !== void 0 ? BA : r.devicePixelRatio) !== null && uA !== void 0 ? uA : 1,
            x: ((IA = A.x) !== null && IA !== void 0 ? IA : 0) + C,
            y: ((NA = A.y) !== null && NA !== void 0 ? NA : 0) + F,
            width: (VA = A.width) !== null && VA !== void 0 ? VA : Math.ceil(w),
            height: (hA = A.height) !== null && hA !== void 0 ? hA : Math.ceil(E)
          }, o ? (B.logger.debug("Document cloned, using foreign object rendering"), K = new Wl(B, v), [4, K.render(g)]) : [3, 3];
        case 2:
          return H = UA.sent(), [3, 5];
        case 3:
          return B.logger.debug("Document cloned, element located at " + C + "," + F + " with size " + w + "x" + E + " using computed rendering"), B.logger.debug("Starting DOM parsing"), h = xn(B, g), y === h.styles.backgroundColor && (h.styles.backgroundColor = HA.TRANSPARENT), B.logger.debug("Starting renderer for element at " + v.x + "," + v.y + " with size " + v.width + "x" + v.height), K = new Vl(B, v), [4, K.render(h)];
        case 4:
          H = UA.sent(), UA.label = 5;
        case 5:
          return (!((PA = A.removeContainer) !== null && PA !== void 0) || PA) && (Ls.destroy(Q) || B.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")), B.logger.debug("Finished rendering"), [2, H];
      }
    });
  });
}, $l = function(t, A, e) {
  var r = A.ownerDocument, s = r.documentElement ? He(t, getComputedStyle(r.documentElement).backgroundColor) : HA.TRANSPARENT, n = r.body ? He(t, getComputedStyle(r.body).backgroundColor) : HA.TRANSPARENT, i = typeof e == "string" ? He(t, e) : e === null ? HA.TRANSPARENT : 4294967295;
  return A === r.documentElement ? OA(s) ? OA(n) ? i : n : s : i;
};
class Ag extends ri {
  async execAction(A, e, r, s, n) {
    try {
      this.exportImg(r);
    } catch (i) {
      ibiz.log.error(i);
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
  exportImg(A) {
    const e = document.querySelector(
      ".ibiz-view.ibiz-view-deeditview3"
    ), r = document.querySelector(".ivu-tabs-tabpane");
    if (e && r) {
      const s = e.scrollHeight + r.scrollHeight - r.offsetHeight;
      jl(e, {
        useCORS: !0,
        allowTaint: !0,
        // 这两个属性都是图片跨域相关属性
        height: s,
        windowHeight: s * 2,
        scale: window.devicePixelRatio
      }).then(function(n) {
        const i = n.toDataURL("image/png").replace("image/png", "image/octet-stream"), a = document.createElement("a");
        a.href = i;
        let B = "downLoad.png";
        A && A[0] && (B = `${A[0].srfmajortext}.png`), a.download = B, a.click();
      });
    }
  }
}
class eg {
  constructor() {
    oA(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new Ag()), this.handler;
  }
}
class tg extends hi {
  constructor() {
    super(...arguments);
    /**
     * 流程图url
     *
     * @type {string}
     * @memberof PresetWFChartViewController
     */
    oA(this, "imgSrc");
  }
  async getUIData() {
    const e = Object.assign(this.context.clone(), this.params), r = await this.entityService.wf.getWFProcessDiagram(e), s = new Blob([r.data], {
      type: "image/svg+xml"
    });
    this.imgSrc = URL.createObjectURL(s);
  }
}
const rg = mA({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(t) {
    const A = RA("preset-wf-chart-view"), {
      proxy: e
    } = Ft(), r = Ns(e, (s, n) => new tg(t.modelPath, s, n));
    return Rs(e, "deName", r.setDeName.bind(r)), {
      c: r,
      ns: A
    };
  },
  render() {
    return x("div", {
      class: this.ns.b()
    }, [x("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
}), sg = typeof btoa == "function", Dr = typeof Buffer == "function";
typeof TextDecoder == "function" && new TextDecoder();
const xs = typeof TextEncoder == "function" ? new TextEncoder() : void 0, ng = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", pe = Array.prototype.slice.call(ng);
((t) => {
  let A = {};
  return t.forEach((e, r) => A[e] = r), A;
})(pe);
const QA = String.fromCharCode.bind(String);
typeof Uint8Array.from == "function" && Uint8Array.from.bind(Uint8Array);
const ig = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (A) => A == "+" ? "-" : "_"), ag = (t) => {
  let A, e, r, s, n = "";
  const i = t.length % 3;
  for (let a = 0; a < t.length; ) {
    if ((e = t.charCodeAt(a++)) > 255 || (r = t.charCodeAt(a++)) > 255 || (s = t.charCodeAt(a++)) > 255)
      throw new TypeError("invalid character found");
    A = e << 16 | r << 8 | s, n += pe[A >> 18 & 63] + pe[A >> 12 & 63] + pe[A >> 6 & 63] + pe[A & 63];
  }
  return i ? n.slice(0, i - 3) + "===".substring(i) : n;
}, zn = sg ? (t) => btoa(t) : Dr ? (t) => Buffer.from(t, "binary").toString("base64") : ag, Bg = Dr ? (t) => Buffer.from(t).toString("base64") : (t) => {
  let e = [];
  for (let r = 0, s = t.length; r < s; r += 4096)
    e.push(QA.apply(null, t.subarray(r, r + 4096)));
  return zn(e.join(""));
}, og = (t) => {
  if (t.length < 2) {
    var A = t.charCodeAt(0);
    return A < 128 ? t : A < 2048 ? QA(192 | A >>> 6) + QA(128 | A & 63) : QA(224 | A >>> 12 & 15) + QA(128 | A >>> 6 & 63) + QA(128 | A & 63);
  } else {
    var A = 65536 + (t.charCodeAt(0) - 55296) * 1024 + (t.charCodeAt(1) - 56320);
    return QA(240 | A >>> 18 & 7) + QA(128 | A >>> 12 & 63) + QA(128 | A >>> 6 & 63) + QA(128 | A & 63);
  }
}, cg = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, lg = (t) => t.replace(cg, og), Ms = Dr ? (t) => Buffer.from(t, "utf8").toString("base64") : xs ? (t) => Bg(xs.encode(t)) : (t) => zn(lg(t)), Ct = (t, A = !1) => A ? ig(Ms(t)) : Ms(t);
function gg(t, A, e) {
  var K, L;
  const r = G([]), s = G({
    Authorization: `Bearer ${wi("access_token")}`
  }), n = G(""), i = G(""), a = {
    count: 0,
    cacheFiles: []
    // iview上传过程中不能改default-file-list,所以需要缓存
  }, B = (K = e.editorParams) == null ? void 0 : K.blackList;
  let o = [];
  B && typeof B == "string" && (o = B.split(","));
  const c = (L = e.editorParams) == null ? void 0 : L.previewList;
  let l = [];
  c && typeof c == "string" && (l = c.split(",")), EA(
    () => t.value,
    (f) => {
      r.value = f ? JSON.parse(f) : [];
    },
    { immediate: !0 }
  ), EA(
    () => t.data,
    (f) => {
      if (f) {
        const p = e.calcBaseUrl(f);
        n.value = p.uploadUrl, i.value = p.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), EA(
    r,
    (f) => {
      f != null && f.length && i.value && f.forEach((p) => {
        p.url = p.url || i.value.replace("%fileId%", p.id);
      }), Array.isArray(f) && f.forEach((p) => {
        p.name || (p.isPreview = !1);
        const I = p.name.trim().toLowerCase();
        p.isPreview = l.some(
          (D) => I.endsWith(`.${D}`)
        );
      });
    },
    { immediate: !0 }
  ), EA(
    i,
    (f) => {
      f && r.value.length && r.value.forEach((p) => {
        p.url = i.value.replace("%fileId%", p.id);
      });
    },
    { immediate: !0 }
  );
  const g = () => {
    const f = [...r.value, ...a.cacheFiles], p = f.length > 0 ? JSON.stringify(f.map((I) => ({ name: I.name, id: I.id }))) : null;
    a.cacheFiles = [], A(p);
  }, Q = (f) => {
    const p = f.name.trim().toLowerCase();
    if (o.some((D) => p.endsWith(`.${D}`)))
      return ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`), !1;
    a.count += 1;
  }, u = (f) => {
    f && (a.cacheFiles.push({
      name: f.filename,
      id: f.fileid
    }), a.count -= 1, a.count === 0 && g());
  }, w = (f, p) => {
    throw a.count -= 1, new _s({
      response: { data: p, status: f.status }
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    });
  }, E = (f) => {
    if (t.disabled)
      return;
    const p = r.value.findIndex((I) => I.id === f.id);
    p !== -1 && r.value.splice(p, 1), g();
  }, C = (f) => {
    const p = f.url || i.value.replace("%fileId%", f.id);
    e.fileDownload({ url: p, name: f.name });
  }, F = G(!1), y = G(""), v = G("");
  return {
    uploadUrl: n,
    downloadUrl: i,
    headers: s,
    files: r,
    onDownload: C,
    onError: w,
    onRemove: E,
    onSuccess: u,
    beforeUpload: Q,
    showModal: F,
    modalTitle: y,
    iframeUrl: v,
    onModalCancel: () => {
      F.value = !1, y.value = "", v.value = "";
    },
    previewFile: (f) => {
      if (!f.isPreview)
        return;
      y.value = f.name;
      const p = window.Environment.previewFileUrl;
      if (p) {
        const I = encodeURIComponent(
          Ct(
            `${window.location.origin}${f.url}?fullfilename=${Ct(
              f.name
            )}`
          )
        );
        v.value = `${p}/onlinePreview?url=${I}`, window.open(v.value, "_blank");
      }
    }
  };
}
const ug = mA({
  name: "SyFileUpload",
  props: ai(),
  emits: Bi(),
  setup(t, {
    emit: A
  }) {
    const e = RA("sy-file-upload"), r = t.controller, {
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: B,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: g,
      modalTitle: Q,
      iframeUrl: u,
      onModalCancel: w,
      previewFile: E
    } = gg(t, (C) => {
      A("change", C);
    }, r);
    return {
      ns: e,
      c: r,
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: B,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: g,
      modalTitle: Q,
      iframeUrl: u,
      onModalCancel: w,
      previewFile: E
    };
  },
  render(t) {
    return t("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [t("IUpload", {
      ref: "fileUpload",
      props: {
        action: this.uploadUrl,
        headers: this.headers,
        disabled: this.disabled,
        "default-file-list": this.files,
        multiple: this.c.model.multiple,
        type: this.c.model.isDrag ? "drag" : "select",
        accept: this.c.model.accept,
        "before-upload": this.beforeUpload,
        "on-success": this.onSuccess,
        "on-error": this.onError,
        "on-remove": this.onRemove,
        "on-preview": this.onDownload,
        "show-upload-list": !1
      }
    }, [this.c.model.isDrag ? t("div", {
      class: this.ns.bm("box", "drag")
    }, [t("i-icon", {
      attrs: {
        type: "md-cloud-upload"
      }
    }), t("div", {
      class: this.ns.be("box", "title")
    }, [t("span", ["将文件拖到此处，或"]), t("span", ["点击上传"])])]) : t("i-button", {
      attrs: {
        icon: "ios-cloud-upload-outline"
      },
      class: this.ns.bm("box", "select")
    }, ["上传文件"])]), t("div", {
      class: this.ns.b("file-list")
    }, [this.files.map((A) => t("div", {
      class: this.ns.b("file-item"),
      key: A.id
    }, [t("div", {
      class: this.ns.b("file-item-right")
    }, [t("div", {
      class: this.ns.b("file-item-right-title"),
      on: {
        click: () => this.previewFile(A)
      }
    }, [A.name]), t("div", {
      class: this.ns.b("file-item-right-action")
    }, [t("i-icon", {
      attrs: {
        type: "md-download"
      },
      on: {
        click: () => this.onDownload(A)
      }
    }), A.isPreview ? t("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(A)
      }
    }) : null, this.disabled || this.readonly ? null : t("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.onRemove(A)
      }
    })])])]))]), t("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [t("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
});
function ht(t, A, e) {
  if (t.url = A.replace("%fileId%", t.id), t.status || (t.status = "finished"), !t.fileName) {
    const r = t.name.lastIndexOf(".");
    t.fileName = t.name.substring(0, r), t.fileExt = t.name.substring(r), t.isImage = Ui(t.name);
  }
  if (!e)
    t.isPreview = !1;
  else {
    t.name || (t.isPreview = !1);
    const r = t.name.trim().toLowerCase();
    t.isPreview = e.some((s) => r.endsWith(`.${s}`));
  }
  return t;
}
function jn(t) {
  const A = G(""), e = G(""), r = G([]);
  return EA(
    t.data,
    (s) => {
      if (s) {
        const n = t.controller.value.calcBaseUrl(s);
        A.value = n.uploadUrl, e.value = n.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), EA(
    t.value,
    (s) => {
      r.value = s ? JSON.parse(s) : [], r.value.length && e.value && r.value.forEach((n) => {
        ht(n, e.value);
      });
    },
    { immediate: !0 }
  ), EA(
    e,
    (s) => {
      s && r.value.length && r.value.forEach((n) => {
        ht(n, s);
      });
    },
    { immediate: !0 }
  ), {
    downloadUrl: e,
    uploadUrl: A,
    valueList: r
  };
}
function qn(t) {
  var h, K, L, f;
  const A = G("undo"), e = G([]), { downloadUrl: r, value: s, uploadUrl: n, controller: i } = t, a = (K = (h = i == null ? void 0 : i.value) == null ? void 0 : h.editorParams) == null ? void 0 : K.blackList;
  let B = [];
  a && typeof a == "string" && (B = a.split(","));
  const o = (f = (L = i == null ? void 0 : i.value) == null ? void 0 : L.editorParams) == null ? void 0 : f.previewList;
  let c = [];
  o && typeof o == "string" && (c = o.split(",")), EA(
    s,
    (p) => {
      p.length > 0 && (e.value = [], p.forEach((I) => {
        e.value.push(
          ht(I, r.value, c)
        );
      }));
    },
    {
      immediate: !0,
      deep: !0
    }
  );
  const l = (p, I) => {
    const D = [];
    return I.forEach((m, R) => {
      const $ = m.name.trim().toLowerCase();
      if (B.some((BA) => $.endsWith(`.${BA}`))) {
        D.push(R);
        return;
      }
      const Y = c.some((BA) => $.endsWith(`.${BA}`));
      e.value.push({
        name: m.name,
        status: m.status,
        percentage: m.percentage,
        id: m.uid,
        url: "",
        isPreview: Y
      });
    }), D.length === I.length ? (ibiz.message.error(`不可上传 ${B.join("、")}类型的文件！`), !1) : (D.length && (D.forEach((m) => {
      p.splice(m, 1), I.splice(m, 1);
    }), ibiz.message.error(`不可上传 ${B.join("、")}类型的文件！`)), !0);
  }, g = (p) => {
    p.forEach((I) => {
      e.value.find((D) => D.id === I.uid ? (D.percentage = I.percentage, !0) : !1);
    });
  }, Q = (p, I) => {
    p.forEach((D) => {
      e.value.find((m) => m.id === D.uid ? (m.status = D.status, m.id = I.data.fileid, m.name = I.data.filename, ht(m, r.value, c), !0) : !1);
    });
  }, u = (p, I) => {
    var m;
    p.forEach((R) => {
      e.value.find(($) => $.id === R.uid ? ($.status = R.status, !0) : !1);
    });
    const D = new _s(I);
    ibiz.notification.error({
      title: (m = D.status) == null ? void 0 : m.toString(),
      desc: D.message,
      duration: 10
    });
  }, w = (p) => {
    e.value = e.value.filter((I) => I.status === "finished"), A.value = "done";
  }, E = () => {
    Fi({
      multiple: t.multiple,
      accept: t.accept,
      uploadUrl: n.value,
      beforeUpload: l,
      progress: g,
      success: Q,
      error: u,
      finish: w
    });
  }, C = G(!1), F = G(""), y = G("");
  return {
    selectFile: E,
    fileList: e,
    uploadState: A,
    showModal: C,
    modalTitle: F,
    iframeUrl: y,
    onModalCancel: () => {
      C.value = !1, F.value = "", y.value = "";
    },
    previewFile: (p) => {
      if (!p.isPreview)
        return;
      F.value = p.name;
      const I = window.Environment.previewFileUrl;
      if (I) {
        const D = encodeURIComponent(
          Ct(
            `${window.location.origin}${p.url}?fullfilename=${Ct(
              p.name
            )}`
          )
        );
        y.value = `${I}/onlinePreview?url=${D}`, window.open(y.value, "_blank");
      }
    }
  };
}
const wg = mA({
  name: "SyGridFileUpload",
  props: pr(),
  setup(t) {
    const A = RA("sy-grid-file-upload"), {
      value: e,
      data: r,
      controller: s
    } = Er(t), {
      downloadUrl: n,
      uploadUrl: i,
      valueList: a
    } = jn({
      value: e,
      data: r,
      controller: s
    }), {
      fileList: B,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      previewFile: g,
      onModalCancel: Q
    } = qn({
      downloadUrl: n,
      uploadUrl: i,
      value: a,
      controller: s
    });
    return {
      ns: A,
      fileList: B,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      downloadFile: (w) => {
        t.controller.fileDownload(w);
      },
      previewFile: g,
      onModalCancel: Q
    };
  },
  render() {
    return x("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.previewFile(t)
      }
    }, [t.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [x("i-icon", {
      attrs: {
        type: "md-download"
      },
      on: {
        click: () => this.downloadFile(t)
      }
    }), t.isPreview ? x("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(t)
      }
    }) : null])]))]), x("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [x("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
}), Qg = mA({
  name: "SyGridFileUploadContainer",
  props: pr(),
  emits: Vs(),
  render(t) {
    return this.disabled || this.readonly ? t("SyGridFileUpload", {
      props: {
        ...this.$props
      }
    }) : t("SyEditGridFileUpload", {
      props: {
        ...this.$props
      },
      on: {
        change: (A, e) => {
          this.$emit("change", A, e);
        },
        rowSave: () => {
          this.$emit("rowSave");
        }
      }
    });
  }
});
const fg = mA({
  name: "SyEditGridFileUploadPopover",
  props: {
    uploadUrl: {
      type: String,
      required: !0
    },
    downloadUrl: {
      type: String,
      required: !0
    },
    value: {
      type: Array,
      required: !0
    },
    controller: {
      type: ks,
      required: !0
    }
  },
  emits: {
    close: (t) => !0
  },
  setup(t, {
    emit: A
  }) {
    const e = RA("sy-edit-grid-file-upload-popover"), {
      downloadUrl: r,
      value: s,
      uploadUrl: n,
      controller: i
    } = Er(t), {
      fileList: a,
      uploadState: B,
      selectFile: o
    } = qn({
      downloadUrl: r,
      value: s,
      uploadUrl: n,
      controller: i
    }), c = G(), l = G(!1), g = oi(c, async (w) => {
      A("close", {
        isModified: l.value,
        resultFiles: a.value
      });
    });
    return EA(B, (w) => {
      w === "done" ? (l.value = !0, g.proceed()) : w === "loading" && g.pause();
    }), {
      ns: e,
      componentRef: c,
      fileList: a,
      deleteFile: (w) => {
        const E = a.value.findIndex((C) => C.id === w.id);
        a.value.splice(E, 1), l.value = !0;
      },
      selectFile: o,
      downloadFile: (w) => {
        t.controller.fileDownload(w);
      }
    };
  },
  render() {
    return x("div", {
      ref: "componentRef",
      style: "width:300px",
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(t)
      }
    }, [t.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [x("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.deleteFile(t)
      }
    })])]))]), x("div", {
      on: {
        click: () => this.selectFile()
      },
      class: this.ns.e("button")
    }, [x("i-icon", {
      attrs: {
        type: "md-add"
      }
    }), "添加文件"])]);
  }
});
const Cg = mA({
  name: "SyEditGridFileUpload",
  props: pr(),
  emits: Vs(),
  setup(t, {
    emit: A
  }) {
    const e = RA("sy-edit-grid-file-upload"), {
      value: r,
      data: s,
      controller: n
    } = Er(t), {
      downloadUrl: i,
      uploadUrl: a,
      valueList: B
    } = jn({
      value: r,
      data: s,
      controller: n
    }), o = G(), c = async () => {
      if (!o.value)
        throw new ZA("容器元素不存在");
      const l = o.value.$el, g = l.offsetHeight, Q = ibiz.overlay.createPopover((E) => E(fg, {
        props: {
          value: B.value,
          uploadUrl: a.value,
          downloadUrl: i.value,
          controller: n.value
        },
        on: {
          close: (C) => {
            Q.dismiss(C);
          }
        }
      }), void 0, {
        noArrow: !0,
        placement: "bottom-start",
        offsetOpts: {
          mainAxis: -g,
          crossAxis: 0
        }
      });
      await Q.present(l);
      const {
        isModified: u,
        resultFiles: w
      } = await Q.onWillDismiss();
      if (u) {
        const E = w.length > 0 ? JSON.stringify(w.map((C) => ({
          name: C.name,
          id: C.id
        }))) : null;
        A("change", E), A("rowSave");
      }
    };
    return ci(o, "click", (l) => {
      t.disabled || c();
    }), {
      ns: e,
      valueList: B,
      componentRef: o
    };
  },
  render() {
    return x("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      ref: "componentRef",
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.valueList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title")
    }, [t.name])]))])]);
  }
});
class hg {
  constructor() {
    oA(this, "component", rg);
  }
}
class Ug {
  constructor() {
    oA(this, "formEditor", "SyFileUpload");
    oA(this, "gridEditor", "SyGridFileUploadContainer");
  }
  async createController(A, e) {
    const r = new ks(A, e);
    return await r.init(), r;
  }
}
const Fg = new si(import.meta.url);
function Os(t, A) {
  if (A != null) {
    const { srfkey: e } = A;
    if (!lA(e) && !tA(e))
      return !0;
  }
  throw new ZA(`执行「${t}」不存在「srfkey」无法处理`);
}
function yA(t, A) {
  const { srfsessionid: e } = A;
  if (!lA(e) && !tA(e))
    return !0;
  throw new ZA(`执行「${t}」不存在「srfsessionid」无法处理`);
}
class dg {
  constructor() {
    this.cacheMap = /* @__PURE__ */ new Map();
  }
  /**
   * 强制设置数据，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:45
   * @param {IContext} context
   * @param {Entity} entity
   */
  forceAdd(A, e) {
    const s = this.getCacheByTag(A).get(e.srfkey);
    s && (s.assign(e), ibiz.log.warn("forceAdd", e.srfkey, e));
  }
  /**
   * 强制更新数据，非合并，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:27
   * @param {IContext} context
   * @param {Entity} entity
   */
  forceUpdate(A, e) {
    this.getCacheByTag(A).set(e.srfkey, pA(e)), ibiz.log.warn("forceUpdate", e.srfkey, e);
  }
  /**
   * 强制删除数据，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:08
   * @param {IContext} context
   * @param {string} srfKey
   */
  forceDelete(A, e) {
    this.getCacheByTag(A).delete(e), ibiz.log.warn("forceDelete", e);
  }
  /**
   * 新增数据
   *
   * @param {*} context
   * @param {Entity} entity
   * @return {*}  {boolean}
   * @memberof EntityCache
   */
  add(A, e) {
    try {
      return yA("add", A), (lA(e.srfkey) || tA(e.srfkey)) && (e.srfkey = it()), e.srftempdate = (/* @__PURE__ */ new Date()).getTime(), this.getCacheByTag(A).set(e.srfkey, pA(e)), ibiz.log.warn("add", e.srfkey, e), e;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 查找数据
   *
   * @param {*} context
   * @param {string} srfKey
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  get(A, e) {
    try {
      yA("get", A);
      const s = this.getCacheByTag(A).get(e);
      return ibiz.log.warn("get", e, s), pA(s);
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 更新数据
   *
   * @param {IContext} context
   * @param {Entity} entity
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  update(A, e) {
    try {
      yA("update", A), Os("update", e), e.srftempdate = (/* @__PURE__ */ new Date()).getTime();
      const r = this.getCacheByTag(A), s = r.get(e.srfkey);
      if (s)
        return s.assign(e), r.set(e.srfkey, s), ibiz.log.warn("update", e.srfkey, e), pA(s);
      throw new Error("数据不存在，无法更新!");
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 删除数据
   *
   * @param {IContext} context
   * @param {string} srfKey
   * @return {*}  {(Entity | null)}
   * @memberof EntityCache
   */
  delete(A, e) {
    try {
      yA("delete", A);
      const r = this.getCacheByTag(A), s = e;
      if (r.has(s)) {
        const n = r.get(s);
        return n.srftempdate = (/* @__PURE__ */ new Date()).getTime(), r.delete(s), ibiz.log.warn("delete", s), n;
      }
      return null;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 批量创建临时数据
   *
   * @author chitanda
   * @date 2022-03-23 11:03:52
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  createBatch(A, e) {
    try {
      yA("add", A);
      const r = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        (lA(n.srfkey) || tA(n.srfkey)) && (n.srfkey = it()), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = pA(n);
        r.set(n.srfkey, i), e[s] = i, ibiz.log.warn("add", n.srfkey, n);
      }
      return e;
    } catch (r) {
      ibiz.log.error(r);
    }
    return [];
  }
  /**
   * 批量更新数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:17
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  updateBatch(A, e) {
    try {
      yA("update", A);
      const r = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        Os("update", n), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = r.get(n.srfkey);
        if (i)
          i.assign(n), r.set(n.srfkey, i), ibiz.log.warn("update", n.srfkey, n), e[s] = pA(i);
        else
          throw new Error(`数据[${n.srfdename}-${n.srfmajortext}(${n.srfkey})]不存在，无法更新!`);
      }
      return e;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 批量删除数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:40
   * @param {IContext} context 上下文
   * @param {string[]} srfKeys 需要删除的数据主键
   * @return {*}  {string[]} 未能删除的数据主键
   */
  deleteBatch(A, e) {
    try {
      yA("delete", A);
    } catch (n) {
      return ibiz.log.error(n), e;
    }
    const r = this.getCacheByTag(A), s = [];
    for (let n = 0; n < e.length; n++) {
      const i = e[n];
      r.has(i) || s.push(i);
    }
    if (s.length > 0)
      throw new Error(`未找到以下数据「${s.join("、")}」，无法删除!`);
    for (let n = 0; n < e.length; n++) {
      const i = e[n];
      r.delete(i), ibiz.log.warn("delete", i);
    }
    return [];
  }
  /**
   * 检查数据是否已经存在
   *
   * @author chitanda
   * @date 2022-08-17 23:08:06
   * @param {IContext} context
   * @param {string} srfkey
   * @return {*}  {boolean}
   */
  checkData(A, e) {
    return this.getList(A).findIndex((n) => n.srfkey === e) !== -1;
  }
  /**
   * 根据条件查找数据，未设置条件默认返回全部
   *
   * @author chitanda
   * @date 2022-08-17 23:08:56
   * @param {IContext} context
   * @return {*}  {Entity[]}
   */
  getList(A) {
    try {
      yA("getList", A);
      const e = this.getCacheByTag(A);
      if (!e)
        return [];
      const r = e.values();
      return Array.from(r);
    } catch (e) {
      return ibiz.log.error(e), [];
    }
  }
  /**
   * 根据条件生成查询
   *
   * @author chitanda
   * @date 2022-08-17 23:08:33
   * @param {IParams} [params={}]
   * @return {*}  {<U>(testObj: U) => boolean}
   */
  generatePred(A = {}) {
    const e = {};
    A.srfkey && (e.srfkey = bA(A.srfkey)), delete A.srfkey;
    for (const r in A)
      if (Object.prototype.hasOwnProperty.call(A, r)) {
        const s = A[r];
        e[r] = bA(s);
      }
    return we(e);
  }
  /**
   * 清除缓存
   *
   * @author chitanda
   * @date 2022-08-17 23:08:54
   * @param {IContext} context
   */
  clear(A) {
    const e = A.srfsessionid;
    this.cacheMap.size > 0 && this.cacheMap.delete(e);
  }
  /**
   * 根据标识获取map组
   *
   * @author chitanda
   * @date 2022-08-17 23:08:47
   * @private
   * @param {IContext} context
   * @return {*}  {Map<string, Entity>}
   */
  getCacheByTag(A) {
    const e = A.srfsessionid;
    return this.cacheMap.has(e) || this.cacheMap.set(e, /* @__PURE__ */ new Map()), this.cacheMap.get(e);
  }
}
class pg {
  /**
   * Creates an instance of SearchFilter.
   *
   * @param {*} context
   * @param {*} [data]
   * @memberof SearchFilter
   */
  constructor(A, e) {
    if (this.page = 0, this.size = 1e3, this.data = {}, this.sortField = "srfordervalue", this.sortMode = "ASC", this.context = A, e) {
      if (!lA(e.page) && !tA(e.page) && (this.page = e.page), !lA(e.size) && !tA(e.size) && (this.size = e.size), !lA(e.query) && !tA(e.query) && (this.query = e.query), !lA(e.sort) && !tA(e.sort)) {
        const r = e.sort.split(",");
        r.length >= 1 && ([this.sortField] = r), r.length >= 2 && (this.sortMode = r[1].toUpperCase());
      }
      !lA(e.srfparentkey) && !tA(e.srfparentkey) && (this.srfparentkey = e.srfparentkey), !lA(e.srfparentdename) && !tA(e.srfparentdename) && (this.srfparentdename = e.srfparentdename), this.data = Object.assign({}, e), delete this.data.page, delete this.data.size, delete this.data.query, delete this.data.sort, delete this.data.srfparentkey, delete this.data.srfparentdename;
    }
  }
  /**
   * 获取条件值
   *
   * @author chitanda
   * @date 2022-08-17 22:08:11
   * @param {string} key
   * @return {*}  {unknown}
   */
  getValue(A) {
    return this.data[A] ? this.data[A] : this.context[A];
  }
}
function $n(t, A) {
  let e = [];
  A.forEach((s) => {
    let n = [];
    for (let i = 0; i < s.length - 1; i++) {
      const a = s[i], B = t[a.name];
      B ? (n.push(a.plural), n.push(B)) : n = [];
    }
    e.push(n);
  }), e = e.sort((s, n) => n.length - s.length);
  const [r] = e;
  return r ? `${r.length > 1 ? "/" : ""}${r.join("/")}` : "";
}
rA.DE_GRID_VIEW, rA.DE_GRID_EXP_VIEW, rA.DE_LIST_VIEW, rA.DE_LIST_EXP_VIEW, rA.DE_DATA_VIEW, rA.DE_DATAVIEW_EXP_VIEW, rA.DE_CALENDAR_VIEW, rA.DE_CALENDAR_EXP_VIEW, rA.DE_CHART_VIEW, rA.DE_CHART_EXP_VIEW, rA.DE_KANBAN_VIEW;
class Eg {
  /**
   * Creates an instance of WorkFlowService.
   * @author lxm
   * @date 2022-09-29 11:09:54
   * @param {AppEntityModel} model 应用实体
   */
  constructor(A) {
    this.model = A, this.app = A.source.getPSModelService().app;
    const e = ibiz.appData.context;
    this.commonBaseUrl = `/wfcore/${e.srfsystemid}-app-${this.app.codeName.toLowerCase()}/${this.model.source.name.toLowerCase()}`;
  }
  /**
   * 获取基础路径
   *
   * @author lxm
   * @date 2022-09-29 14:09:40
   * @private
   * @returns {*}
   */
  getBaseUrl() {
    return this.commonBaseUrl;
  }
  /**
   * 获取activeData
   *
   * @private
   * @param {IData} data
   * @param {IParams} context
   * @returns {*}
   * @memberof WorkFlowService
   */
  getActiveData(A, e) {
    return e.srfprocessinstanceid && (A.srfprocessinstanceid = e.srfprocessinstanceid), A;
  }
  /**
   * 根据当前步骤和任务获取工作流步骤数据（如：流程表单等）
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IParams} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFStep(A) {
    const { processDefinitionKey: e, taskDefinitionKey: r } = A;
    return ibiz.net.get(`${this.getBaseUrl()}/process-definitions/${e}/usertasks/${r}`);
  }
  /**
   * 根据业务主键和当前步骤获取操作路径
   *
   * @author lxm
   * @date 2022-09-29 14:09:52
   * @param {IParams} context 路径参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFLink(A, e) {
    const r = A[this.model.deName], { taskDefinitionKey: s } = A;
    return ibiz.net.post(`${this.getBaseUrl()}/${r}/usertasks/${s}/ways`, { activedata: this.getActiveData(e, A) });
  }
  /**
   * 根据业务主键获取工作流程进度
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFHistory(A) {
    const e = A[this.model.deName];
    let r = "alls";
    return !ibiz.env.enableWfAllHistory && A.srfprocessinstanceid && (r = A.srfprocessinstanceid), ibiz.net.get(`${this.getBaseUrl()}/${e}/process-instances/${r}/history`);
  }
  /**
   * 根据业务主键获取工作流流程图片
   *
   * @author lxm
   * @date 2022-10-27 16:10:13
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFProcessDiagram(A) {
    const e = A[this.model.deName];
    return ibiz.net.request(`${this.getBaseUrl()}/${e}/process-instances/alls/processdiagram`, {
      method: "post",
      data: {},
      responseType: "blob"
    });
  }
  /**
   * 获取标准工作流版本信息
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFVersion() {
    return ibiz.net.get(`${this.getBaseUrl()}/process-definitions2`);
  }
  /**
   * 启动工作流
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfStart(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/process-instances`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 提交工作流
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfSubmit(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 提交工作流
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfWithdraw(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/withdraw`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 调用工作流接口
   *
   * @author lxm
   * @date 2022-09-30 17:09:38
   * @param {string} methodName 接口名称
   * @param {IContext} context 路径参数
   * @param {IParams} [params={}] 查询参数
   * @param {IData} [data={}] 主数据数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async exec(A, e, r = {}, s = {}) {
    switch (A) {
      case "WFSTART":
        return this.wfStart(e, r, s);
      case "WFSUBMIT":
        return this.wfSubmit(e, r, s);
      default:
        throw new ZA(`「${A}」未实现`);
    }
  }
}
var Ut;
(function(t) {
  t[t.CREATE = 0] = "CREATE", t[t.UPDATE = 1] = "UPDATE";
})(Ut || (Ut = {}));
class YA {
  get srfuf() {
    return this.srfkey ? Ut.UPDATE : Ut.CREATE;
  }
  /**
   * Creates an instance of Entity.
   *
   * @author chitanda
   * @date 2022-10-11 21:10:21
   * @param {IPSAppDataEntity} entity
   * @param {(IData | Entity)} data
   */
  constructor(A, e) {
    Object.defineProperty(this, "entity", {
      enumerable: !1,
      value: A
    }), Object.defineProperty(this, "data", {
      enumerable: !1,
      value: e instanceof YA ? pA(e.data) : pA(e)
    });
    const r = A.getKeyPSAppDEField().codeName.toLowerCase();
    if (!A.getMajorPSAppDEField())
      throw new ZA(`${A.codeName}缺少主信息属性`);
    const s = A.getMajorPSAppDEField().codeName.toLowerCase();
    Object.defineProperty(this, "srfdename", {
      get() {
        return A.codeName;
      }
    }), Object.defineProperty(this, "srfkey", {
      set(n) {
        this.data[r] = n;
      },
      get() {
        return this.data[r];
      }
    }), Object.defineProperty(this, "srfmajortext", {
      set(n) {
        this.data[s] = n;
      },
      get() {
        return this.data[s];
      }
    }), this.defineProperties();
  }
  /**
   * 代理实际数据
   *
   * @author chitanda
   * @date 2022-10-11 22:10:55
   * @protected
   */
  defineProperties() {
    const { data: A } = this, e = {};
    (this.entity.getAllPSAppDEFields() || []).forEach((s) => {
      const n = s.codeName.toLowerCase();
      e[n] = {
        enumerable: !0,
        set(i) {
          A[n] = i;
        },
        get() {
          return A[n];
        }
      };
    }), Object.defineProperties(this, e);
  }
  /**
   * 克隆数据
   *
   * @author chitanda
   * @date 2022-10-11 00:10:15
   * @return {*}  {Entity}
   */
  clone() {
    return new YA(this.entity, this.data);
  }
  /**
   * 合并参数
   *
   * @author chitanda
   * @date 2022-10-19 11:10:25
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   */
  assign(A) {
    return A instanceof YA ? Object.assign(this.data, A.data) : Object.assign(this.data, A), this;
  }
}
class bt {
  get entity() {
    var A;
    return this._entity || (this._entity = new Hr((A = this.dto) === null || A === void 0 ? void 0 : A.getParentPSModelObject("app.dataentity.IPSAppDataEntity"))), this._entity;
  }
  /**
   * Creates an instance of MethodDto.
   *
   * @author chitanda
   * @date 2022-10-10 23:10:06
   * @param {IPSAppDEMethodDTO} dto
   */
  constructor(A) {
    this.dto = A, this.dtoMap = /* @__PURE__ */ new Map(), this.fields = (A == null ? void 0 : A.getPSAppDEMethodDTOFields()) || [];
  }
  /**
   * 请求参数组合 DTO
   *
   * @author chitanda
   * @date 2022-10-10 23:10:33
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<IData>}
   */
  async get(A, e) {
    const r = {};
    for (let s = 0; s < this.fields.length; s++) {
      const n = this.fields[s], i = n.codeName.toLowerCase();
      switch (n.type) {
        case "SIMPLE": {
          const a = e[i];
          Qi(a) ? r[i] = null : r[i] = a;
          break;
        }
        case "DTOS": {
          const a = await this.getFieldDto(n), B = n.getRefPSAppDataEntity(), c = (await ibiz.entityService.getService(B.codeName, A)).local.getList(A);
          if (c) {
            const l = [];
            for (let g = 0; g < c.length; g++)
              l.push(await a.get(A, c[g]));
            r[i] = l;
          }
          break;
        }
        default:
          throw new Ps(n, `未支持的应用实体方法输入属性类型: ${n.type}`);
      }
    }
    return r;
  }
  /**
   * 设置本地 DTO 存储
   *
   * @author chitanda
   * @date 2022-10-10 23:10:50
   * @param {IContext} context
   * @param {IData[]} data
   * @return {*}  {Promise<Entity[]>}
   */
  async sets(A, e) {
    const r = await ibiz.entityService.getService(this.entity.codeName);
    return r.local.clear(A), Promise.all(e.map(async (s) => {
      const n = this.fields.filter((a) => a.type === "DTOS").map(async (a) => {
        const B = a.codeName.toLowerCase(), o = await this.getFieldDto(a), c = s[B];
        c && await o.sets(A, c);
      });
      for (let a = 0; a < n.length; a++)
        await n[a];
      const i = new YA(this.entity.source, s);
      return this.entity.isLocalMode && await r.local.add(A, i), i;
    }));
  }
  /**
   * 获取子属性 DTO
   *
   * @author chitanda
   * @date 2022-10-17 16:10:47
   * @protected
   * @param {IPSAppDEMethodDTOField} field
   * @return {*}  {Promise<MethodDto>}
   */
  async getFieldDto(A) {
    var e;
    if (this.dtoMap.has(A.codeName))
      return this.dtoMap.get(A.codeName);
    await ((e = A.getRefPSAppDataEntity()) === null || e === void 0 ? void 0 : e.fill(!0));
    const r = new bt(A.getRefPSAppDEMethodDTO());
    return this.dtoMap.set(A.codeName, r), r;
  }
}
class Hg {
  /**
   * Creates an instance of MethodInput.
   *
   * @author chitanda
   * @date 2022-10-11 17:10:59
   * @param {AppEntityModel} entity
   * @param {IPSAppDEMethodInput} [input]
   */
  constructor(A, e) {
    this.entity = A, this.input = e;
    const r = e == null ? void 0 : e.getPSAppDEMethodDTO();
    r && (this.dto = new bt(r));
  }
  /**
   * 处理请求发送参数
   *
   * @author chitanda
   * @date 2022-10-11 14:10:22
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<IData>}
   */
  async handle(A, e) {
    return this.dto ? e instanceof Array ? await Promise.all(e.map((s) => this.dto.get(A, s))) : this.dto.get(A, e) : e;
  }
}
class vg {
  /**
   * Creates an instance of MethodReturn.
   *
   * @author chitanda
   * @date 2022-10-11 17:10:47
   * @param {AppEntityModel} entity
   * @param {IPSAppDEMethodReturn} [output]
   */
  constructor(A, e) {
    this.entity = A, this.output = e;
    const r = e == null ? void 0 : e.getPSAppDEMethodDTO();
    r && (this.dto = new bt(r));
  }
  /**
   * 处理请求返回参数
   *
   * @author chitanda
   * @date 2022-10-19 21:10:06
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<Entity>}
   */
  async handle(A, e) {
    return this.dto ? (await this.dto.sets(A, [e]))[0] : new YA(this.entity.source, e);
  }
}
class Ai {
  /**
   * Creates an instance of Method.
   *
   * @author chitanda
   * @date 2022-10-10 14:10:19
   * @param {AppEntityModel} entity
   * @param {IAppDEMethod} method
   * @param {ServicePathItem[][]} paths
   */
  constructor(A, e, r) {
    this.entity = A, this.method = e, this.paths = r, this.input = new Hg(A, e.getPSAppDEMethodInput()), this.result = new vg(A, e.getPSAppDEMethodReturn());
  }
  /**
   * 发送请求
   *
   * @author chitanda
   * @date 2022-10-10 17:10:44
   * @protected
   * @param {string} path
   * @param {IParams} context
   * @param {IData} data
   * @param {IParams} params
   * @return {*}  {Promise<HttpResponse<any>>}
   */
  async request(A, e, r, s) {
    const n = this.method.requestMethod, i = this.method.codeName.toLowerCase();
    let a = null;
    switch (n) {
      case "POST":
        a = await ibiz.net.post(`${A}/${i}`, r, s);
        break;
      case "GET":
        a = await ibiz.net.get(`${A}/${i}`, r, s);
        break;
      case "PUT":
        a = await ibiz.net.put(`${A}/${i}`, r, s);
        break;
      case "DELETE":
        a = await ibiz.net.delete(`${A}/${i}`, r, s);
        break;
      default:
        throw n ? new Sr(this.method, `未支持的请求方式: ${n}`) : new Sr(this.method, "未配置请求方式");
    }
    return a;
  }
  /**
   * 根据上下文计算当前请求路径
   *
   * @author chitanda
   * @date 2022-08-24 18:08:46
   * @protected
   * @param {IParams} context
   * @return {*}  {string} 拼接结果说明: /祖父实体/祖父实体主键/爷爷实体/爷爷实体主键/父实体/父实体主键/当前实体
   */
  calcPath(A) {
    const e = `/${this.entity.deNamePlural}`;
    return $n(A, this.paths) + e;
  }
  /**
   * 获取当前实体服务
   *
   * @author chitanda
   * @date 2022-10-11 21:10:12
   * @protected
   * @return {*}  {Promise<EntityService>}
   */
  async getService() {
    return this.service || (this.service = await ibiz.entityService.getService(this.entity.codeName)), this.service;
  }
  /**
   * 创建实体
   *
   * @author chitanda
   * @date 2022-10-11 22:10:05
   * @protected
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   */
  createEntity(A) {
    return new YA(this.entity.source, A);
  }
}
class mg extends Ai {
  async exec(A, e, r) {
    this.entity.isLocalMode || (e = await this.input.handle(A, e));
    let s = this.calcPath(A);
    switch (this.method.needResourceKey && (s = `${s}/${A[this.entity.deName]}`), this.method.codeName) {
      case "Create":
        return this.create(A, e, r);
      case "Get":
        return this.get(A, e);
      case "GetDraft":
        return this.getDraft(A, e);
      case "Remove":
        return this.remove(A, e);
      case "Update":
        return this.update(A, e, r);
      case "CreateTemp":
        return this.createTemp(A, e);
      case "GetTemp":
        return this.getTemp(A, e);
      case "GetDraftTemp":
        return this.getDraftTemp(A, e);
      case "RemoveTemp":
        return this.removeTemp(A, e);
      case "UpdateTemp":
        return this.updateTemp(A, e);
      default: {
        const n = await this.request(s, A, e, r);
        return n.data = await this.result.handle(A, n.data), n;
      }
    }
  }
  /**
   * 创建数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:01
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<IHttpResponse<IData>>}
   */
  async create(A, e, r) {
    if (this.entity.isLocalMode)
      return this.createTemp(A, this.createEntity(e));
    const s = this.calcPath(A), n = await ibiz.net.post(s, e, r);
    return n.data = await this.result.handle(A, n.data), n;
  }
  /**
   * 删除数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:56
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async remove(A, e) {
    if (this.entity.isLocalMode)
      return this.removeTemp(A, e);
    const r = this.calcPath(A);
    return await ibiz.net.delete(`${r}/${A[this.entity.deName]}`, e);
  }
  /**
   * 更新数据
   *
   * @author chitanda
   * @date 2022-09-13 19:09:39
   * @param {IContext} context
   * @param {(IData | Entity)} data
   * @param {IParams} [params={}]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async update(A, e, r = {}) {
    if (this.entity.isLocalMode)
      return this.updateTemp(A, this.createEntity(e));
    const s = this.calcPath(A), n = await ibiz.net.put(`${s}/${A[this.entity.deName]}`, e, r);
    return n.data = await this.result.handle(A, n.data), n;
  }
  /**
   * 获取数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:07
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async get(A, e = {}) {
    if (this.entity.isLocalMode)
      return this.getTemp(A, e);
    const r = this.calcPath(A), s = await ibiz.net.get(`${r}/${A[this.entity.deName]}`, e);
    return s.data = await this.result.handle(A, s.data), s;
  }
  /**
   * 获取默认数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:26
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<IData>>}
   */
  async getDraft(A, e) {
    if (this.entity.isLocalMode)
      return this.getDraftTemp(A, e);
    const r = this.calcPath(A), s = await ibiz.net.get(`${r}/getdraft`, e);
    return s.data = await this.result.handle(A, s.data), s;
  }
  /**
   * 新建临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:45
   * @param {IContext} context
   * @param {IData} entity
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async createTemp(A, e) {
    try {
      const s = await (await this.getService()).local.add(A, this.createEntity(e));
      return new X(s);
    } catch (r) {
      return new X(r, 500);
    }
  }
  /**
   * 获取临时数据默认值
   *
   * @author chitanda
   * @date 2022-08-21 17:08:56
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async getDraftTemp(A, e) {
    try {
      const r = this.createEntity({});
      return r ? new X(r) : new X(r, 500);
    } catch (r) {
      return new X(r, 500);
    }
  }
  /**
   * 删除临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:11
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async removeTemp(A, e) {
    try {
      let r = null;
      e && (r = e[this.entity.keyName]), !r && A && (r = A[this.entity.deName]);
      const n = (await this.getService()).local.delete(A, r);
      return n ? new X(n) : new X(n, 500);
    } catch (r) {
      return new X(r, 500);
    }
  }
  /**
   * 更新临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:17
   * @param {IContext} context
   * @param {IData} entity
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async updateTemp(A, e) {
    try {
      const s = (await this.getService()).local.update(A, this.createEntity(e));
      return s ? new X(s) : new X(s, 500);
    } catch (r) {
      return new X(r, 500);
    }
  }
  /**
   * 获取临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:23
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async getTemp(A, e) {
    try {
      let r = null;
      e && (r = e[this.entity.keyName]), !r && A && (r = A[this.entity.deName]);
      const n = (await this.getService()).local.get(A, r);
      return n ? new X(n) : new X(n, 500);
    } catch (r) {
      return new X(r, 500);
    }
  }
  /**
   * 批量删除本地数据
   *
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse>}
   */
  async removeBatchTemp(A, e) {
    if (e) {
      const r = e[this.entity.keyName];
      if (r)
        try {
          await (await this.getService()).local.deleteBatch(A, r);
        } catch (s) {
          return new X(s, 500);
        }
    }
    return new X(!0);
  }
}
class Ig extends Ai {
  async exec(A, e, r) {
    if (this.entity.isLocalMode) {
      const a = await this.searchLocal(null, new pg(A, e));
      return new X(a, 200);
    }
    const s = this.calcPath(A), n = await this.request(s, A, e, r), i = n.data || [];
    return n.data = i.map((a) => this.createEntity(a)), n;
  }
  /**
   * 查询本地数据，根据属性
   *
   * @param {IContext} context
   * @param {IParams} params 根据多实体属性查找，例：{ name: '张三', age: 18, parent: null }
   * @return {*}  {Promise<Entity[]>}
   */
  async selectLocal(A, e = {}) {
    let s = (await this.getService()).local.getList(A);
    s = Tr(s, "srfordervalue");
    const n = {};
    if (xr(A)) {
      const c = this.entity.majorKeyMap;
      if (c) {
        for (const l in c)
          if (Object.prototype.hasOwnProperty.call(c, l)) {
            const g = c[l];
            xr(A[l]) && (n[g] = bA(A[l]));
          }
      }
    }
    const i = {}, a = {}, B = {};
    e.srfkey && (n.srfkey = bA(e.srfkey), delete e.srfkey);
    for (const c in e)
      if (Object.prototype.hasOwnProperty.call(e, c)) {
        const l = e[c];
        l == null ? (i[c] = bA(null), a[c] = bA(void 0), B[c] = bA("")) : n[c] = bA(l);
      }
    if (!tA(n)) {
      const c = we(n), l = we(i), g = we(a), Q = we(B);
      s = s.filter((u) => {
        if (tA(i)) {
          if (c(u))
            return !0;
        } else if (c(u) && (l(u) || g(u) || Q(u)))
          return !0;
        return !1;
      });
    }
    return s.map((c) => c.clone());
  }
  /**
   * 搜索本地数据
   *
   * @protected
   * @param {PSDEDQCondEngine | null} cond 查询实例
   * @param {SearchFilter} filter 过滤对象
   * @param {string[]} [queryParamKeys=this.entity.quickSearchKeys] 当前实体支持快速搜索的属性
   * @return {*}  {Promise<Entity[]>}
   */
  async searchLocal(A, e, r = this.entity.quickSearchKeys) {
    const s = await this.getService();
    let n = [];
    A ? (n = s.local.getList(e.context), n.length > 0 && (n = n.filter((l) => A.test(l, e)))) : (n = await this.selectLocal(e.context), n.length > 0 && e.query && e.query !== "" && r && (n = n.filter((l) => {
      const g = new RegExp(e.query);
      for (let Q = 0; Q < r.length; Q += 1) {
        const u = r[Q], w = l[u];
        if (g.test(w))
          return !0;
      }
      return !1;
    }))), !lA(e.sortField) && !tA(e.sortField) && (e.sortMode === "DESC" ? n = fi(n, e.sortField) : n = Tr(n, e.sortField));
    const { page: i, size: a } = e, B = i * a, o = (i + 1) * a - 1;
    return n.slice(B, o).map((l) => pA(l));
  }
}
class yg {
  /**
   * Creates an instance of FileService.
   * @author lxm
   * @date 2022-11-25 13:11:49
   * @param {AppEntityModel} model 应用实体
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(A, e) {
    this.model = A, this.paths = e;
  }
  /**
   * 后台导出数据，返回文件流
   *
   * @author lxm
   * @date 2022-11-25 14:11:53
   * @param {IPSDEDataExport} dataExport 导出模型
   * @param {string} fetchAction 查询方法
   * @param {IParams} context 上下文
   * @param {IParams} params 请求参数
   * @returns {*}  {Promise<IHttpResponse<Blob>>}
   */
  exportData(A, e, r, s) {
    const i = `${$n(r, this.paths)}/${this.model.deNamePlural}/exportdata/${e.toLowerCase()}/?srfexporttag=${A.codeName}`;
    return ibiz.net.request(i, {
      method: "post",
      data: s,
      responseType: "blob"
    });
  }
}
class Kg {
  /**
   * Creates an instance of EntityService.
   *
   * @author chitanda
   * @date 2022-08-24 18:08:44
   * @param {AppEntityModel} model 应用实体模型
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(A, e) {
    this.model = A, this.paths = e, this.methodMap = /* @__PURE__ */ new Map(), this.local = new dg(), this.wf = new Eg(A), this.file = new yg(A, e);
  }
  /**
   * 获取实体服务方法实例
   *
   * @author chitanda
   * @date 2022-10-10 14:10:53
   * @protected
   * @param {string} methodName
   * @return {*}  {Method}
   */
  getMethod(A) {
    if (this.methodMap.has(A))
      return this.methodMap.get(A);
    const e = this.model.findPSAppDeMethod(A);
    let r = null;
    switch (e.methodType) {
      case "DEACTION":
        r = new mg(this.model, e, this.paths);
        break;
      case "FETCH":
      case "FETCHTEMP":
        r = new Ig(this.model, e, this.paths);
        break;
      default:
        throw new Ps(e, `未支持的服务方法类型: ${e.methodType}`);
    }
    return this.methodMap.set(A, r), r;
  }
  /**
   * 执行服务方法
   *
   * @author chitanda
   * @date 2022-09-13 19:09:55
   * @param {string} methodName
   * @param {IParams} context
   * @param {IData} [params={}] 请求参数
   * @param {IParams} [params2={}] 查询参数
   * @return {*}  {Promise<IHttpResponse>}
   */
  exec(A, e, r = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, r, s);
    throw new ZA(`${this.model.deName}未支持「${A}」方法`);
  }
  getPath(A, e, r = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, r, s);
    throw new ZA(`${this.model.deName}未支持「${A}」方法`);
  }
}
class Lg {
  constructor() {
    this.cache = /* @__PURE__ */ new Map(), this.allEntities = /* @__PURE__ */ new Map();
  }
  /**
   * 初始化实体缓存
   *
   * @author chitanda
   * @date 2022-08-18 22:08:56
   * @protected
   * @param {IParams} [context]
   * @return {*}  {Promise<void>}
   */
  async initAllEntities(A) {
    if (this.allEntities.size !== 0)
      return;
    ((await ui(A)).app.getAllPSAppDataEntities() || []).forEach((s) => {
      const n = s.isFill ? s.codeName : s.refM.codeName;
      this.allEntities.set(n, s);
    });
  }
  /**
   * 根据实体标识获取实体服务
   *
   * @author chitanda
   * @date 2022-08-17 23:08:20
   * @param {string} entityCodeName 实体标识
   * @param {IParams} [context] 上下文,用于计算模型所属沙箱环境
   * @return {*}  {Promise<EntityService>}
   */
  async getService(A, e) {
    if (!this.cache.has(A)) {
      await this.initAllEntities(e);
      const r = this.allEntities.get(A);
      if (!r)
        throw new Error(`找不到实体[${A}]模型`);
      await r.fill(!0);
      const s = new Hr(r);
      await s.init();
      const n = ibiz.resourcePathUtil.calcPaths(e || {}, A), i = await new Kg(s, n);
      this.cache.set(A, i);
    }
    return this.cache.get(A);
  }
  /**
   * 清理所有服务, 当前临时域下的所有临时数据缓存
   *
   * @description 根据 srfsessionid 作为临时数据域
   * @author chitanda
   * @date 2022-08-18 14:08:48
   * @param {IContext} context
   */
  clearTempCache(A) {
    this.cache.forEach((e) => {
      e.local.clear(A);
    });
  }
}
class bg extends di {
  constructor(e) {
    super(e);
    oA(this, "SyWFHistoryBase");
    /**
     * 应用的模型
     *
     * @author lxm
     * @date 2022-09-29 14:09:39
     * @private
     * @type {IPSApplication}
     */
    oA(this, "appSy");
    this.model = e, this.appSy = e.source.getPSModelService().app;
    const r = ibiz.appData.context;
    this.SyWFHistoryBase = `/wfcoreex/${r.srfsystemid}-app-${this.appSy.codeName.toLowerCase()}/${this.model.source.name.toLowerCase()}`;
  }
  /**
   * 根据业务主键获取工作流程进度
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFHistory(e) {
    const r = e[this.model.deName];
    let s = "alls";
    return !ibiz.env.enableWfAllHistory && e.srfprocessinstanceid && (s = e.srfprocessinstanceid), ibiz.net.get(
      `${this.SyWFHistoryBase}/${r}/process-instances/${s}/history`
    );
  }
}
class Dg extends pi {
  /**
   * Creates an instance of EntityService.
   *
   * @author chitanda
   * @date 2022-08-24 18:08:44
   * @param {AppEntityModel} model 应用实体模型
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(e, r) {
    super(e, r);
    /**
     * 工作流相关服务
     *
     * @author lxm
     * @date 2022-09-29 11:09:28
     * @type {WorkFlowService}
     */
    oA(this, "wf");
    this.model = e, this.paths = r, this.wf = new bg(e);
  }
}
class Sg extends Lg {
  /**
   * 根据实体标识获取实体服务
   *
   * @author chitanda
   * @date 2022-08-17 23:08:20
   * @param {string} entityCodeName 实体标识
   * @param {IParams} [context] 上下文,用于计算模型所属沙箱环境
   * @return {*}  {Promise<EntityService>}
   */
  async getService(A, e) {
    if (!this.cache.has(A)) {
      await this.initAllEntities(e);
      const r = this.allEntities.get(A);
      if (!r)
        throw new Error(`找不到实体[${A}]模型`);
      await r.fill(!0);
      const s = new Hr(r);
      await s.init();
      const n = ibiz.resourcePathUtil.calcPaths(
        e || {},
        A
      ), i = await new Dg(s, n);
      this.cache.set(A, i);
    }
    return this.cache.get(A);
  }
}
function Tg() {
  ibiz.entityService = new Sg();
}
const Xg = {
  mateUrl: import.meta.url,
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
  install(t) {
    Fg.loadStyle(["/style.css"]), Tg(), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new vi()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new Ii()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_ExportAsImagePlugin",
      new eg()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new hg()
    ), t.component("SyFileUpload", ug), t.component("SyGridFileUpload", wg), t.component("SyEditGridFileUpload", Cg), t.component("SyGridFileUploadContainer", Qg), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_SyFileUpload",
      new Ug()
    );
  }
};
export {
  Xg as default
};
