csres.com

check update

Versione datata 11/01/2023. Vedi la nuova versione l'ultima versione.

// ==UserScript==
// @name         csres.com
// @version      0.1.20230111.7
// @author       tcatche
// @description  check update
// @match			   *://www.csres.com/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.min.js
// @namespace https://greasyfork.org/users/290273
// ==/UserScript==

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __vite_style__ = document.createElement("style");
__vite_style__.innerHTML = "\n.actions[data-v-15629706] {\r\n  float: right;\r\n  margin-bottom: 4px;\r\n  position: relative;\r\n  padding-bottom: 16px;\n}\n.page[data-v-15629706] {\r\n  font-size: 14px;\n}\n[data-v-15629706] .el-input-number {\r\n  margin: 0 5px;\r\n  width: 120px;\n}\n[data-v-15629706] .el-progress__text {\r\n  display: none;\n}\n.el-progress[data-v-15629706] {\r\n  width: 100%;\r\n  display: inline-block;\r\n  position: absolute;\r\n  bottom: 8px;\n}\r\n\n.uploader-wrapper[data-v-44fc689e] {\r\n  display: flex;\r\n  align-items: center;\r\n  justify-content: flex-end;\r\n  margin-top: 20px;\n}\n[data-v-44fc689e] .el-upload {\r\n  width: 600px;\r\n  margin-top: 30px;\n}\r\n\n.table-wrapper {\r\n  margin-bottom: 30px;\n}\ntable {\r\n  font-size: 12px;\n}\n.warning-row {\r\n  background-color: var(--el-color-warning-light-7) !important;\n}\r\n\n.wrapper[data-v-7ba5bd90] {\n  position: fixed;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background: #fff;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  display: none;\n  z-index: 10000;\n}\n.wrapper-inner[data-v-7ba5bd90] {\n  height: 100%;\n  overflow-y: auto;\n  padding: 30px;\n  width: 100%;\n}\n.wrapper-inner > div[data-v-7ba5bd90] {\n  /* padding: 0 30px; */\n}\n.show[data-v-7ba5bd90] {\n  display: flex;\n}\n.open-button[data-v-7ba5bd90] {\n  position: fixed;\n  top: 0;\n  left: 0;\n  background: red;\n  color: #fff;\n  width: 40px;\n  /* height: 30px; */\n  padding: 10px;\n  z-index: 9999;\n}\n.close-button[data-v-7ba5bd90] {\n  position: fixed;\n  top: 0;\n  right: 0;\n  width: 40px;\n  color: var(--el-color-primary);\n  /* height: 30px; */\n  padding: 10px;\n}\n";
document.head.appendChild(__vite_style__);
(function() {
  "use strict";
  /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
  var XLSX = {};
  XLSX.version = "0.18.5";
  var current_ansi = 1252;
  var VALID_ANSI = [874, 932, 936, 949, 950, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1e4];
  var CS2CP = {
    0: 1252,
    1: 65001,
    2: 65001,
    77: 1e4,
    128: 932,
    129: 949,
    130: 1361,
    134: 936,
    136: 950,
    161: 1253,
    162: 1254,
    163: 1258,
    177: 1255,
    178: 1256,
    186: 1257,
    204: 1251,
    222: 874,
    238: 1250,
    255: 1252,
    69: 6969
  };
  var set_ansi = function(cp) {
    if (VALID_ANSI.indexOf(cp) == -1)
      return;
    current_ansi = CS2CP[0] = cp;
  };
  function reset_ansi() {
    set_ansi(1252);
  }
  var set_cp = function(cp) {
    set_ansi(cp);
  };
  function reset_cp() {
    set_cp(1200);
    reset_ansi();
  }
  function char_codes(data) {
    var o2 = [];
    for (var i = 0, len = data.length; i < len; ++i)
      o2[i] = data.charCodeAt(i);
    return o2;
  }
  function utf16leread(data) {
    var o2 = [];
    for (var i = 0; i < data.length >> 1; ++i)
      o2[i] = String.fromCharCode(data.charCodeAt(2 * i) + (data.charCodeAt(2 * i + 1) << 8));
    return o2.join("");
  }
  function utf16beread(data) {
    var o2 = [];
    for (var i = 0; i < data.length >> 1; ++i)
      o2[i] = String.fromCharCode(data.charCodeAt(2 * i + 1) + (data.charCodeAt(2 * i) << 8));
    return o2.join("");
  }
  var debom = function(data) {
    var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1);
    if (c1 == 255 && c2 == 254)
      return utf16leread(data.slice(2));
    if (c1 == 254 && c2 == 255)
      return utf16beread(data.slice(2));
    if (c1 == 65279)
      return data.slice(1);
    return data;
  };
  var _getchar = function _gc1(x2) {
    return String.fromCharCode(x2);
  };
  var _getansi = function _ga1(x2) {
    return String.fromCharCode(x2);
  };
  var $cptable;
  var Base64_map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  function Base64_encode(input) {
    var o2 = "";
    var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0;
    for (var i = 0; i < input.length; ) {
      c1 = input.charCodeAt(i++);
      e1 = c1 >> 2;
      c2 = input.charCodeAt(i++);
      e2 = (c1 & 3) << 4 | c2 >> 4;
      c3 = input.charCodeAt(i++);
      e3 = (c2 & 15) << 2 | c3 >> 6;
      e4 = c3 & 63;
      if (isNaN(c2)) {
        e3 = e4 = 64;
      } else if (isNaN(c3)) {
        e4 = 64;
      }
      o2 += Base64_map.charAt(e1) + Base64_map.charAt(e2) + Base64_map.charAt(e3) + Base64_map.charAt(e4);
    }
    return o2;
  }
  function Base64_decode(input) {
    var o2 = "";
    var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0;
    input = input.replace(/[^\w\+\/\=]/g, "");
    for (var i = 0; i < input.length; ) {
      e1 = Base64_map.indexOf(input.charAt(i++));
      e2 = Base64_map.indexOf(input.charAt(i++));
      c1 = e1 << 2 | e2 >> 4;
      o2 += String.fromCharCode(c1);
      e3 = Base64_map.indexOf(input.charAt(i++));
      c2 = (e2 & 15) << 4 | e3 >> 2;
      if (e3 !== 64) {
        o2 += String.fromCharCode(c2);
      }
      e4 = Base64_map.indexOf(input.charAt(i++));
      c3 = (e3 & 3) << 6 | e4;
      if (e4 !== 64) {
        o2 += String.fromCharCode(c3);
      }
    }
    return o2;
  }
  var has_buf = /* @__PURE__ */ function() {
    return typeof Buffer !== "undefined" && typeof process !== "undefined" && typeof process.versions !== "undefined" && !!process.versions.node;
  }();
  var Buffer_from = /* @__PURE__ */ function() {
    if (typeof Buffer !== "undefined") {
      var nbfs = !Buffer.from;
      if (!nbfs)
        try {
          Buffer.from("foo", "utf8");
        } catch (e) {
          nbfs = true;
        }
      return nbfs ? function(buf, enc) {
        return enc ? new Buffer(buf, enc) : new Buffer(buf);
      } : Buffer.from.bind(Buffer);
    }
    return function() {
    };
  }();
  function new_raw_buf(len) {
    if (has_buf)
      return Buffer.alloc ? Buffer.alloc(len) : new Buffer(len);
    return typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
  }
  function new_unsafe_buf(len) {
    if (has_buf)
      return Buffer.allocUnsafe ? Buffer.allocUnsafe(len) : new Buffer(len);
    return typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
  }
  var s2a = function s2a2(s2) {
    if (has_buf)
      return Buffer_from(s2, "binary");
    return s2.split("").map(function(x2) {
      return x2.charCodeAt(0) & 255;
    });
  };
  function s2ab(s2) {
    if (typeof ArrayBuffer === "undefined")
      return s2a(s2);
    var buf = new ArrayBuffer(s2.length), view = new Uint8Array(buf);
    for (var i = 0; i != s2.length; ++i)
      view[i] = s2.charCodeAt(i) & 255;
    return buf;
  }
  function a2s(data) {
    if (Array.isArray(data))
      return data.map(function(c2) {
        return String.fromCharCode(c2);
      }).join("");
    var o2 = [];
    for (var i = 0; i < data.length; ++i)
      o2[i] = String.fromCharCode(data[i]);
    return o2.join("");
  }
  function a2u(data) {
    if (typeof Uint8Array === "undefined")
      throw new Error("Unsupported");
    return new Uint8Array(data);
  }
  function ab2a(data) {
    if (typeof ArrayBuffer == "undefined")
      throw new Error("Unsupported");
    if (data instanceof ArrayBuffer)
      return ab2a(new Uint8Array(data));
    var o2 = new Array(data.length);
    for (var i = 0; i < data.length; ++i)
      o2[i] = data[i];
    return o2;
  }
  var bconcat = has_buf ? function(bufs) {
    return Buffer.concat(bufs.map(function(buf) {
      return Buffer.isBuffer(buf) ? buf : Buffer_from(buf);
    }));
  } : function(bufs) {
    if (typeof Uint8Array !== "undefined") {
      var i = 0, maxlen = 0;
      for (i = 0; i < bufs.length; ++i)
        maxlen += bufs[i].length;
      var o2 = new Uint8Array(maxlen);
      var len = 0;
      for (i = 0, maxlen = 0; i < bufs.length; maxlen += len, ++i) {
        len = bufs[i].length;
        if (bufs[i] instanceof Uint8Array)
          o2.set(bufs[i], maxlen);
        else if (typeof bufs[i] == "string") {
          throw "wtf";
        } else
          o2.set(new Uint8Array(bufs[i]), maxlen);
      }
      return o2;
    }
    return [].concat.apply([], bufs.map(function(buf) {
      return Array.isArray(buf) ? buf : [].slice.call(buf);
    }));
  };
  function utf8decode(content) {
    var out = [], widx = 0, L = content.length + 250;
    var o2 = new_raw_buf(content.length + 255);
    for (var ridx = 0; ridx < content.length; ++ridx) {
      var c2 = content.charCodeAt(ridx);
      if (c2 < 128)
        o2[widx++] = c2;
      else if (c2 < 2048) {
        o2[widx++] = 192 | c2 >> 6 & 31;
        o2[widx++] = 128 | c2 & 63;
      } else if (c2 >= 55296 && c2 < 57344) {
        c2 = (c2 & 1023) + 64;
        var d2 = content.charCodeAt(++ridx) & 1023;
        o2[widx++] = 240 | c2 >> 8 & 7;
        o2[widx++] = 128 | c2 >> 2 & 63;
        o2[widx++] = 128 | d2 >> 6 & 15 | (c2 & 3) << 4;
        o2[widx++] = 128 | d2 & 63;
      } else {
        o2[widx++] = 224 | c2 >> 12 & 15;
        o2[widx++] = 128 | c2 >> 6 & 63;
        o2[widx++] = 128 | c2 & 63;
      }
      if (widx > L) {
        out.push(o2.slice(0, widx));
        widx = 0;
        o2 = new_raw_buf(65535);
        L = 65530;
      }
    }
    out.push(o2.slice(0, widx));
    return bconcat(out);
  }
  var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
  function _strrev(x2) {
    var o2 = "", i = x2.length - 1;
    while (i >= 0)
      o2 += x2.charAt(i--);
    return o2;
  }
  function pad0(v2, d2) {
    var t = "" + v2;
    return t.length >= d2 ? t : fill("0", d2 - t.length) + t;
  }
  function pad_(v2, d2) {
    var t = "" + v2;
    return t.length >= d2 ? t : fill(" ", d2 - t.length) + t;
  }
  function rpad_(v2, d2) {
    var t = "" + v2;
    return t.length >= d2 ? t : t + fill(" ", d2 - t.length);
  }
  function pad0r1(v2, d2) {
    var t = "" + Math.round(v2);
    return t.length >= d2 ? t : fill("0", d2 - t.length) + t;
  }
  function pad0r2(v2, d2) {
    var t = "" + v2;
    return t.length >= d2 ? t : fill("0", d2 - t.length) + t;
  }
  var p2_32 = /* @__PURE__ */ Math.pow(2, 32);
  function pad0r(v2, d2) {
    if (v2 > p2_32 || v2 < -p2_32)
      return pad0r1(v2, d2);
    var i = Math.round(v2);
    return pad0r2(i, d2);
  }
  function SSF_isgeneral(s2, i) {
    i = i || 0;
    return s2.length >= 7 + i && (s2.charCodeAt(i) | 32) === 103 && (s2.charCodeAt(i + 1) | 32) === 101 && (s2.charCodeAt(i + 2) | 32) === 110 && (s2.charCodeAt(i + 3) | 32) === 101 && (s2.charCodeAt(i + 4) | 32) === 114 && (s2.charCodeAt(i + 5) | 32) === 97 && (s2.charCodeAt(i + 6) | 32) === 108;
  }
  var days = [
    ["Sun", "Sunday"],
    ["Mon", "Monday"],
    ["Tue", "Tuesday"],
    ["Wed", "Wednesday"],
    ["Thu", "Thursday"],
    ["Fri", "Friday"],
    ["Sat", "Saturday"]
  ];
  var months = [
    ["J", "Jan", "January"],
    ["F", "Feb", "February"],
    ["M", "Mar", "March"],
    ["A", "Apr", "April"],
    ["M", "May", "May"],
    ["J", "Jun", "June"],
    ["J", "Jul", "July"],
    ["A", "Aug", "August"],
    ["S", "Sep", "September"],
    ["O", "Oct", "October"],
    ["N", "Nov", "November"],
    ["D", "Dec", "December"]
  ];
  function SSF_init_table(t) {
    if (!t)
      t = {};
    t[0] = "General";
    t[1] = "0";
    t[2] = "0.00";
    t[3] = "#,##0";
    t[4] = "#,##0.00";
    t[9] = "0%";
    t[10] = "0.00%";
    t[11] = "0.00E+00";
    t[12] = "# ?/?";
    t[13] = "# ??/??";
    t[14] = "m/d/yy";
    t[15] = "d-mmm-yy";
    t[16] = "d-mmm";
    t[17] = "mmm-yy";
    t[18] = "h:mm AM/PM";
    t[19] = "h:mm:ss AM/PM";
    t[20] = "h:mm";
    t[21] = "h:mm:ss";
    t[22] = "m/d/yy h:mm";
    t[37] = "#,##0 ;(#,##0)";
    t[38] = "#,##0 ;[Red](#,##0)";
    t[39] = "#,##0.00;(#,##0.00)";
    t[40] = "#,##0.00;[Red](#,##0.00)";
    t[45] = "mm:ss";
    t[46] = "[h]:mm:ss";
    t[47] = "mmss.0";
    t[48] = "##0.0E+0";
    t[49] = "@";
    t[56] = '"\u4E0A\u5348/\u4E0B\u5348 "hh"\u6642"mm"\u5206"ss"\u79D2 "';
    return t;
  }
  var table_fmt = {
    0: "General",
    1: "0",
    2: "0.00",
    3: "#,##0",
    4: "#,##0.00",
    9: "0%",
    10: "0.00%",
    11: "0.00E+00",
    12: "# ?/?",
    13: "# ??/??",
    14: "m/d/yy",
    15: "d-mmm-yy",
    16: "d-mmm",
    17: "mmm-yy",
    18: "h:mm AM/PM",
    19: "h:mm:ss AM/PM",
    20: "h:mm",
    21: "h:mm:ss",
    22: "m/d/yy h:mm",
    37: "#,##0 ;(#,##0)",
    38: "#,##0 ;[Red](#,##0)",
    39: "#,##0.00;(#,##0.00)",
    40: "#,##0.00;[Red](#,##0.00)",
    45: "mm:ss",
    46: "[h]:mm:ss",
    47: "mmss.0",
    48: "##0.0E+0",
    49: "@",
    56: '"\u4E0A\u5348/\u4E0B\u5348 "hh"\u6642"mm"\u5206"ss"\u79D2 "'
  };
  var SSF_default_map = {
    5: 37,
    6: 38,
    7: 39,
    8: 40,
    23: 0,
    24: 0,
    25: 0,
    26: 0,
    27: 14,
    28: 14,
    29: 14,
    30: 14,
    31: 14,
    50: 14,
    51: 14,
    52: 14,
    53: 14,
    54: 14,
    55: 14,
    56: 14,
    57: 14,
    58: 14,
    59: 1,
    60: 2,
    61: 3,
    62: 4,
    67: 9,
    68: 10,
    69: 12,
    70: 13,
    71: 14,
    72: 14,
    73: 15,
    74: 16,
    75: 17,
    76: 20,
    77: 21,
    78: 22,
    79: 45,
    80: 46,
    81: 47,
    82: 0
  };
  var SSF_default_str = {
    5: '"$"#,##0_);\\("$"#,##0\\)',
    63: '"$"#,##0_);\\("$"#,##0\\)',
    6: '"$"#,##0_);[Red]\\("$"#,##0\\)',
    64: '"$"#,##0_);[Red]\\("$"#,##0\\)',
    7: '"$"#,##0.00_);\\("$"#,##0.00\\)',
    65: '"$"#,##0.00_);\\("$"#,##0.00\\)',
    8: '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
    66: '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
    41: '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',
    42: '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',
    43: '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',
    44: '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'
  };
  function SSF_frac(x2, D2, mixed) {
    var sgn = x2 < 0 ? -1 : 1;
    var B2 = x2 * sgn;
    var P_2 = 0, P_1 = 1, P2 = 0;
    var Q_2 = 1, Q_1 = 0, Q2 = 0;
    var A2 = Math.floor(B2);
    while (Q_1 < D2) {
      A2 = Math.floor(B2);
      P2 = A2 * P_1 + P_2;
      Q2 = A2 * Q_1 + Q_2;
      if (B2 - A2 < 5e-8)
        break;
      B2 = 1 / (B2 - A2);
      P_2 = P_1;
      P_1 = P2;
      Q_2 = Q_1;
      Q_1 = Q2;
    }
    if (Q2 > D2) {
      if (Q_1 > D2) {
        Q2 = Q_2;
        P2 = P_2;
      } else {
        Q2 = Q_1;
        P2 = P_1;
      }
    }
    if (!mixed)
      return [0, sgn * P2, Q2];
    var q2 = Math.floor(sgn * P2 / Q2);
    return [q2, sgn * P2 - q2 * Q2, Q2];
  }
  function SSF_parse_date_code(v2, opts, b2) {
    if (v2 > 2958465 || v2 < 0)
      return null;
    var date = v2 | 0, time = Math.floor(86400 * (v2 - date)), dow = 0;
    var dout = [];
    var out = { D: date, T: time, u: 86400 * (v2 - date) - time, y: 0, m: 0, d: 0, H: 0, M: 0, S: 0, q: 0 };
    if (Math.abs(out.u) < 1e-6)
      out.u = 0;
    if (opts && opts.date1904)
      date += 1462;
    if (out.u > 0.9999) {
      out.u = 0;
      if (++time == 86400) {
        out.T = time = 0;
        ++date;
        ++out.D;
      }
    }
    if (date === 60) {
      dout = b2 ? [1317, 10, 29] : [1900, 2, 29];
      dow = 3;
    } else if (date === 0) {
      dout = b2 ? [1317, 8, 29] : [1900, 1, 0];
      dow = 6;
    } else {
      if (date > 60)
        --date;
      var d2 = new Date(1900, 0, 1);
      d2.setDate(d2.getDate() + date - 1);
      dout = [d2.getFullYear(), d2.getMonth() + 1, d2.getDate()];
      dow = d2.getDay();
      if (date < 60)
        dow = (dow + 6) % 7;
      if (b2)
        dow = SSF_fix_hijri(d2, dout);
    }
    out.y = dout[0];
    out.m = dout[1];
    out.d = dout[2];
    out.S = time % 60;
    time = Math.floor(time / 60);
    out.M = time % 60;
    time = Math.floor(time / 60);
    out.H = time;
    out.q = dow;
    return out;
  }
  var SSFbasedate = /* @__PURE__ */ new Date(1899, 11, 31, 0, 0, 0);
  var SSFdnthresh = /* @__PURE__ */ SSFbasedate.getTime();
  var SSFbase1904 = /* @__PURE__ */ new Date(1900, 2, 1, 0, 0, 0);
  function datenum_local(v2, date1904) {
    var epoch = /* @__PURE__ */ v2.getTime();
    if (date1904)
      epoch -= 1461 * 24 * 60 * 60 * 1e3;
    else if (v2 >= SSFbase1904)
      epoch += 24 * 60 * 60 * 1e3;
    return (epoch - (SSFdnthresh + (/* @__PURE__ */ v2.getTimezoneOffset() - /* @__PURE__ */ SSFbasedate.getTimezoneOffset()) * 6e4)) / (24 * 60 * 60 * 1e3);
  }
  function SSF_strip_decimal(o2) {
    return o2.indexOf(".") == -1 ? o2 : o2.replace(/(?:\.0*|(\.\d*[1-9])0+)$/, "$1");
  }
  function SSF_normalize_exp(o2) {
    if (o2.indexOf("E") == -1)
      return o2;
    return o2.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/, "$1E").replace(/(E[+-])(\d)$/, "$10$2");
  }
  function SSF_small_exp(v2) {
    var w2 = v2 < 0 ? 12 : 11;
    var o2 = SSF_strip_decimal(v2.toFixed(12));
    if (o2.length <= w2)
      return o2;
    o2 = v2.toPrecision(10);
    if (o2.length <= w2)
      return o2;
    return v2.toExponential(5);
  }
  function SSF_large_exp(v2) {
    var o2 = SSF_strip_decimal(v2.toFixed(11));
    return o2.length > (v2 < 0 ? 12 : 11) || o2 === "0" || o2 === "-0" ? v2.toPrecision(6) : o2;
  }
  function SSF_general_num(v2) {
    var V = Math.floor(Math.log(Math.abs(v2)) * Math.LOG10E), o2;
    if (V >= -4 && V <= -1)
      o2 = v2.toPrecision(10 + V);
    else if (Math.abs(V) <= 9)
      o2 = SSF_small_exp(v2);
    else if (V === 10)
      o2 = v2.toFixed(10).substr(0, 12);
    else
      o2 = SSF_large_exp(v2);
    return SSF_strip_decimal(SSF_normalize_exp(o2.toUpperCase()));
  }
  function SSF_general(v2, opts) {
    switch (typeof v2) {
      case "string":
        return v2;
      case "boolean":
        return v2 ? "TRUE" : "FALSE";
      case "number":
        return (v2 | 0) === v2 ? v2.toString(10) : SSF_general_num(v2);
      case "undefined":
        return "";
      case "object":
        if (v2 == null)
          return "";
        if (v2 instanceof Date)
          return SSF_format(14, datenum_local(v2, opts && opts.date1904), opts);
    }
    throw new Error("unsupported value in General format: " + v2);
  }
  function SSF_fix_hijri(date, o2) {
    o2[0] -= 581;
    var dow = date.getDay();
    if (date < 60)
      dow = (dow + 6) % 7;
    return dow;
  }
  function SSF_write_date(type, fmt, val, ss0) {
    var o2 = "", ss = 0, tt2 = 0, y = val.y, out, outl = 0;
    switch (type) {
      case 98:
        y = val.y + 543;
      case 121:
        switch (fmt.length) {
          case 1:
          case 2:
            out = y % 100;
            outl = 2;
            break;
          default:
            out = y % 1e4;
            outl = 4;
            break;
        }
        break;
      case 109:
        switch (fmt.length) {
          case 1:
          case 2:
            out = val.m;
            outl = fmt.length;
            break;
          case 3:
            return months[val.m - 1][1];
          case 5:
            return months[val.m - 1][0];
          default:
            return months[val.m - 1][2];
        }
        break;
      case 100:
        switch (fmt.length) {
          case 1:
          case 2:
            out = val.d;
            outl = fmt.length;
            break;
          case 3:
            return days[val.q][0];
          default:
            return days[val.q][1];
        }
        break;
      case 104:
        switch (fmt.length) {
          case 1:
          case 2:
            out = 1 + (val.H + 11) % 12;
            outl = fmt.length;
            break;
          default:
            throw "bad hour format: " + fmt;
        }
        break;
      case 72:
        switch (fmt.length) {
          case 1:
          case 2:
            out = val.H;
            outl = fmt.length;
            break;
          default:
            throw "bad hour format: " + fmt;
        }
        break;
      case 77:
        switch (fmt.length) {
          case 1:
          case 2:
            out = val.M;
            outl = fmt.length;
            break;
          default:
            throw "bad minute format: " + fmt;
        }
        break;
      case 115:
        if (fmt != "s" && fmt != "ss" && fmt != ".0" && fmt != ".00" && fmt != ".000")
          throw "bad second format: " + fmt;
        if (val.u === 0 && (fmt == "s" || fmt == "ss"))
          return pad0(val.S, fmt.length);
        if (ss0 >= 2)
          tt2 = ss0 === 3 ? 1e3 : 100;
        else
          tt2 = ss0 === 1 ? 10 : 1;
        ss = Math.round(tt2 * (val.S + val.u));
        if (ss >= 60 * tt2)
          ss = 0;
        if (fmt === "s")
          return ss === 0 ? "0" : "" + ss / tt2;
        o2 = pad0(ss, 2 + ss0);
        if (fmt === "ss")
          return o2.substr(0, 2);
        return "." + o2.substr(2, fmt.length - 1);
      case 90:
        switch (fmt) {
          case "[h]":
          case "[hh]":
            out = val.D * 24 + val.H;
            break;
          case "[m]":
          case "[mm]":
            out = (val.D * 24 + val.H) * 60 + val.M;
            break;
          case "[s]":
          case "[ss]":
            out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);
            break;
          default:
            throw "bad abstime format: " + fmt;
        }
        outl = fmt.length === 3 ? 1 : 2;
        break;
      case 101:
        out = y;
        outl = 1;
        break;
    }
    var outstr = outl > 0 ? pad0(out, outl) : "";
    return outstr;
  }
  function commaify(s2) {
    var w2 = 3;
    if (s2.length <= w2)
      return s2;
    var j = s2.length % w2, o2 = s2.substr(0, j);
    for (; j != s2.length; j += w2)
      o2 += (o2.length > 0 ? "," : "") + s2.substr(j, w2);
    return o2;
  }
  var pct1 = /%/g;
  function write_num_pct(type, fmt, val) {
    var sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
    return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
  }
  function write_num_cm(type, fmt, val) {
    var idx = fmt.length - 1;
    while (fmt.charCodeAt(idx - 1) === 44)
      --idx;
    return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
  }
  function write_num_exp(fmt, val) {
    var o2;
    var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
    if (fmt.match(/^#+0.0E\+0$/)) {
      if (val == 0)
        return "0.0E+0";
      else if (val < 0)
        return "-" + write_num_exp(fmt, -val);
      var period = fmt.indexOf(".");
      if (period === -1)
        period = fmt.indexOf("E");
      var ee2 = Math.floor(Math.log(val) * Math.LOG10E) % period;
      if (ee2 < 0)
        ee2 += period;
      o2 = (val / Math.pow(10, ee2)).toPrecision(idx + 1 + (period + ee2) % period);
      if (o2.indexOf("e") === -1) {
        var fakee = Math.floor(Math.log(val) * Math.LOG10E);
        if (o2.indexOf(".") === -1)
          o2 = o2.charAt(0) + "." + o2.substr(1) + "E+" + (fakee - o2.length + ee2);
        else
          o2 += "E+" + (fakee - ee2);
        while (o2.substr(0, 2) === "0.") {
          o2 = o2.charAt(0) + o2.substr(2, period) + "." + o2.substr(2 + period);
          o2 = o2.replace(/^0+([1-9])/, "$1").replace(/^0+\./, "0.");
        }
        o2 = o2.replace(/\+-/, "-");
      }
      o2 = o2.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
        return $1 + $2 + $3.substr(0, (period + ee2) % period) + "." + $3.substr(ee2) + "E";
      });
    } else
      o2 = val.toExponential(idx);
    if (fmt.match(/E\+00$/) && o2.match(/e[+-]\d$/))
      o2 = o2.substr(0, o2.length - 1) + "0" + o2.charAt(o2.length - 1);
    if (fmt.match(/E\-/) && o2.match(/e\+/))
      o2 = o2.replace(/e\+/, "e");
    return o2.replace("e", "E");
  }
  var frac1 = /# (\?+)( ?)\/( ?)(\d+)/;
  function write_num_f1(r, aval, sign) {
    var den = parseInt(r[4], 10), rr = Math.round(aval * den), base = Math.floor(rr / den);
    var myn = rr - base * den, myd = den;
    return sign + (base === 0 ? "" : "" + base) + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[4].length) : pad_(myn, r[1].length) + r[2] + "/" + r[3] + pad0(myd, r[4].length));
  }
  function write_num_f2(r, aval, sign) {
    return sign + (aval === 0 ? "" : "" + aval) + fill(" ", r[1].length + 2 + r[4].length);
  }
  var dec1 = /^#*0*\.([0#]+)/;
  var closeparen = /\).*[0#]/;
  var phone = /\(###\) ###\\?-####/;
  function hashq(str) {
    var o2 = "", cc;
    for (var i = 0; i != str.length; ++i)
      switch (cc = str.charCodeAt(i)) {
        case 35:
          break;
        case 63:
          o2 += " ";
          break;
        case 48:
          o2 += "0";
          break;
        default:
          o2 += String.fromCharCode(cc);
      }
    return o2;
  }
  function rnd(val, d2) {
    var dd = Math.pow(10, d2);
    return "" + Math.round(val * dd) / dd;
  }
  function dec(val, d2) {
    var _frac = val - Math.floor(val), dd = Math.pow(10, d2);
    if (d2 < ("" + Math.round(_frac * dd)).length)
      return 0;
    return Math.round(_frac * dd);
  }
  function carry(val, d2) {
    if (d2 < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d2))).length) {
      return 1;
    }
    return 0;
  }
  function flr(val) {
    if (val < 2147483647 && val > -2147483648)
      return "" + (val >= 0 ? val | 0 : val - 1 | 0);
    return "" + Math.floor(val);
  }
  function write_num_flt(type, fmt, val) {
    if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
      var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
      if (val >= 0)
        return write_num_flt("n", ffmt, val);
      return "(" + write_num_flt("n", ffmt, -val) + ")";
    }
    if (fmt.charCodeAt(fmt.length - 1) === 44)
      return write_num_cm(type, fmt, val);
    if (fmt.indexOf("%") !== -1)
      return write_num_pct(type, fmt, val);
    if (fmt.indexOf("E") !== -1)
      return write_num_exp(fmt, val);
    if (fmt.charCodeAt(0) === 36)
      return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
    var o2;
    var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
    if (fmt.match(/^00+$/))
      return sign + pad0r(aval, fmt.length);
    if (fmt.match(/^[#?]+$/)) {
      o2 = pad0r(val, 0);
      if (o2 === "0")
        o2 = "";
      return o2.length > fmt.length ? o2 : hashq(fmt.substr(0, fmt.length - o2.length)) + o2;
    }
    if (r = fmt.match(frac1))
      return write_num_f1(r, aval, sign);
    if (fmt.match(/^#+0+$/))
      return sign + pad0r(aval, fmt.length - fmt.indexOf("0"));
    if (r = fmt.match(dec1)) {
      o2 = rnd(val, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function($$, $1) {
        return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
      });
      return fmt.indexOf("0.") !== -1 ? o2 : o2.replace(/^0\./, ".");
    }
    fmt = fmt.replace(/^#+([0.])/, "$1");
    if (r = fmt.match(/^(0*)\.(#*)$/)) {
      return sign + rnd(aval, r[2].length).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
    }
    if (r = fmt.match(/^#{1,3},##0(\.?)$/))
      return sign + commaify(pad0r(aval, 0));
    if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
      return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify("" + (Math.floor(val) + carry(val, r[1].length))) + "." + pad0(dec(val, r[1].length), r[1].length);
    }
    if (r = fmt.match(/^#,#*,#0/))
      return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val);
    if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
      o2 = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val));
      ri = 0;
      return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x3) {
        return ri < o2.length ? o2.charAt(ri++) : x3 === "0" ? "0" : "";
      }));
    }
    if (fmt.match(phone)) {
      o2 = write_num_flt(type, "##########", val);
      return "(" + o2.substr(0, 3) + ") " + o2.substr(3, 3) + "-" + o2.substr(6);
    }
    var oa = "";
    if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
      ri = Math.min(r[4].length, 7);
      ff = SSF_frac(aval, Math.pow(10, ri) - 1, false);
      o2 = "" + sign;
      oa = write_num("n", r[1], ff[1]);
      if (oa.charAt(oa.length - 1) == " ")
        oa = oa.substr(0, oa.length - 1) + "0";
      o2 += oa + r[2] + "/" + r[3];
      oa = rpad_(ff[2], ri);
      if (oa.length < r[4].length)
        oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
      o2 += oa;
      return o2;
    }
    if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
      ri = Math.min(Math.max(r[1].length, r[4].length), 7);
      ff = SSF_frac(aval, Math.pow(10, ri) - 1, true);
      return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
    }
    if (r = fmt.match(/^[#0?]+$/)) {
      o2 = pad0r(val, 0);
      if (fmt.length <= o2.length)
        return o2;
      return hashq(fmt.substr(0, fmt.length - o2.length)) + o2;
    }
    if (r = fmt.match(/^([#0?]+)\.([#0]+)$/)) {
      o2 = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
      ri = o2.indexOf(".");
      var lres = fmt.indexOf(".") - ri, rres = fmt.length - o2.length - lres;
      return hashq(fmt.substr(0, lres) + o2 + fmt.substr(fmt.length - rres));
    }
    if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
      ri = dec(val, r[1].length);
      return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
        return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
      }) + "." + pad0(ri, r[1].length);
    }
    switch (fmt) {
      case "###,##0.00":
        return write_num_flt(type, "#,##0.00", val);
      case "###,###":
      case "##,###":
      case "#,###":
        var x2 = commaify(pad0r(aval, 0));
        return x2 !== "0" ? sign + x2 : "";
      case "###,###.00":
        return write_num_flt(type, "###,##0.00", val).replace(/^0\./, ".");
      case "#,###.00":
        return write_num_flt(type, "#,##0.00", val).replace(/^0\./, ".");
    }
    throw new Error("unsupported format |" + fmt + "|");
  }
  function write_num_cm2(type, fmt, val) {
    var idx = fmt.length - 1;
    while (fmt.charCodeAt(idx - 1) === 44)
      --idx;
    return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
  }
  function write_num_pct2(type, fmt, val) {
    var sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
    return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
  }
  function write_num_exp2(fmt, val) {
    var o2;
    var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
    if (fmt.match(/^#+0.0E\+0$/)) {
      if (val == 0)
        return "0.0E+0";
      else if (val < 0)
        return "-" + write_num_exp2(fmt, -val);
      var period = fmt.indexOf(".");
      if (period === -1)
        period = fmt.indexOf("E");
      var ee2 = Math.floor(Math.log(val) * Math.LOG10E) % period;
      if (ee2 < 0)
        ee2 += period;
      o2 = (val / Math.pow(10, ee2)).toPrecision(idx + 1 + (period + ee2) % period);
      if (!o2.match(/[Ee]/)) {
        var fakee = Math.floor(Math.log(val) * Math.LOG10E);
        if (o2.indexOf(".") === -1)
          o2 = o2.charAt(0) + "." + o2.substr(1) + "E+" + (fakee - o2.length + ee2);
        else
          o2 += "E+" + (fakee - ee2);
        o2 = o2.replace(/\+-/, "-");
      }
      o2 = o2.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
        return $1 + $2 + $3.substr(0, (period + ee2) % period) + "." + $3.substr(ee2) + "E";
      });
    } else
      o2 = val.toExponential(idx);
    if (fmt.match(/E\+00$/) && o2.match(/e[+-]\d$/))
      o2 = o2.substr(0, o2.length - 1) + "0" + o2.charAt(o2.length - 1);
    if (fmt.match(/E\-/) && o2.match(/e\+/))
      o2 = o2.replace(/e\+/, "e");
    return o2.replace("e", "E");
  }
  function write_num_int(type, fmt, val) {
    if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
      var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
      if (val >= 0)
        return write_num_int("n", ffmt, val);
      return "(" + write_num_int("n", ffmt, -val) + ")";
    }
    if (fmt.charCodeAt(fmt.length - 1) === 44)
      return write_num_cm2(type, fmt, val);
    if (fmt.indexOf("%") !== -1)
      return write_num_pct2(type, fmt, val);
    if (fmt.indexOf("E") !== -1)
      return write_num_exp2(fmt, val);
    if (fmt.charCodeAt(0) === 36)
      return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
    var o2;
    var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
    if (fmt.match(/^00+$/))
      return sign + pad0(aval, fmt.length);
    if (fmt.match(/^[#?]+$/)) {
      o2 = "" + val;
      if (val === 0)
        o2 = "";
      return o2.length > fmt.length ? o2 : hashq(fmt.substr(0, fmt.length - o2.length)) + o2;
    }
    if (r = fmt.match(frac1))
      return write_num_f2(r, aval, sign);
    if (fmt.match(/^#+0+$/))
      return sign + pad0(aval, fmt.length - fmt.indexOf("0"));
    if (r = fmt.match(dec1)) {
      o2 = ("" + val).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
      o2 = o2.replace(/\.(\d*)$/, function($$, $1) {
        return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
      });
      return fmt.indexOf("0.") !== -1 ? o2 : o2.replace(/^0\./, ".");
    }
    fmt = fmt.replace(/^#+([0.])/, "$1");
    if (r = fmt.match(/^(0*)\.(#*)$/)) {
      return sign + ("" + aval).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
    }
    if (r = fmt.match(/^#{1,3},##0(\.?)$/))
      return sign + commaify("" + aval);
    if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
      return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val) + "." + fill("0", r[1].length);
    }
    if (r = fmt.match(/^#,#*,#0/))
      return write_num_int(type, fmt.replace(/^#,#*,/, ""), val);
    if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
      o2 = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val));
      ri = 0;
      return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x3) {
        return ri < o2.length ? o2.charAt(ri++) : x3 === "0" ? "0" : "";
      }));
    }
    if (fmt.match(phone)) {
      o2 = write_num_int(type, "##########", val);
      return "(" + o2.substr(0, 3) + ") " + o2.substr(3, 3) + "-" + o2.substr(6);
    }
    var oa = "";
    if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
      ri = Math.min(r[4].length, 7);
      ff = SSF_frac(aval, Math.pow(10, ri) - 1, false);
      o2 = "" + sign;
      oa = write_num("n", r[1], ff[1]);
      if (oa.charAt(oa.length - 1) == " ")
        oa = oa.substr(0, oa.length - 1) + "0";
      o2 += oa + r[2] + "/" + r[3];
      oa = rpad_(ff[2], ri);
      if (oa.length < r[4].length)
        oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
      o2 += oa;
      return o2;
    }
    if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
      ri = Math.min(Math.max(r[1].length, r[4].length), 7);
      ff = SSF_frac(aval, Math.pow(10, ri) - 1, true);
      return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
    }
    if (r = fmt.match(/^[#0?]+$/)) {
      o2 = "" + val;
      if (fmt.length <= o2.length)
        return o2;
      return hashq(fmt.substr(0, fmt.length - o2.length)) + o2;
    }
    if (r = fmt.match(/^([#0]+)\.([#0]+)$/)) {
      o2 = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
      ri = o2.indexOf(".");
      var lres = fmt.indexOf(".") - ri, rres = fmt.length - o2.length - lres;
      return hashq(fmt.substr(0, lres) + o2 + fmt.substr(fmt.length - rres));
    }
    if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
      return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
        return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
      }) + "." + pad0(0, r[1].length);
    }
    switch (fmt) {
      case "###,###":
      case "##,###":
      case "#,###":
        var x2 = commaify("" + aval);
        return x2 !== "0" ? sign + x2 : "";
      default:
        if (fmt.match(/\.[0#?]*$/))
          return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val) + hashq(fmt.slice(fmt.lastIndexOf(".")));
    }
    throw new Error("unsupported format |" + fmt + "|");
  }
  function write_num(type, fmt, val) {
    return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
  }
  function SSF_split_fmt(fmt) {
    var out = [];
    var in_str = false;
    for (var i = 0, j = 0; i < fmt.length; ++i)
      switch (fmt.charCodeAt(i)) {
        case 34:
          in_str = !in_str;
          break;
        case 95:
        case 42:
        case 92:
          ++i;
          break;
        case 59:
          out[out.length] = fmt.substr(j, i - j);
          j = i + 1;
      }
    out[out.length] = fmt.substr(j);
    if (in_str === true)
      throw new Error("Format |" + fmt + "| unterminated string ");
    return out;
  }
  var SSF_abstime = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;
  function fmt_is_date(fmt) {
    var i = 0, c2 = "", o2 = "";
    while (i < fmt.length) {
      switch (c2 = fmt.charAt(i)) {
        case "G":
          if (SSF_isgeneral(fmt, i))
            i += 6;
          i++;
          break;
        case '"':
          for (; fmt.charCodeAt(++i) !== 34 && i < fmt.length; ) {
          }
          ++i;
          break;
        case "\\":
          i += 2;
          break;
        case "_":
          i += 2;
          break;
        case "@":
          ++i;
          break;
        case "B":
        case "b":
          if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2")
            return true;
        case "M":
        case "D":
        case "Y":
        case "H":
        case "S":
        case "E":
        case "m":
        case "d":
        case "y":
        case "h":
        case "s":
        case "e":
        case "g":
          return true;
        case "A":
        case "a":
        case "\u4E0A":
          if (fmt.substr(i, 3).toUpperCase() === "A/P")
            return true;
          if (fmt.substr(i, 5).toUpperCase() === "AM/PM")
            return true;
          if (fmt.substr(i, 5).toUpperCase() === "\u4E0A\u5348/\u4E0B\u5348")
            return true;
          ++i;
          break;
        case "[":
          o2 = c2;
          while (fmt.charAt(i++) !== "]" && i < fmt.length)
            o2 += fmt.charAt(i);
          if (o2.match(SSF_abstime))
            return true;
          break;
        case ".":
        case "0":
        case "#":
          while (i < fmt.length && ("0#?.,E+-%".indexOf(c2 = fmt.charAt(++i)) > -1 || c2 == "\\" && fmt.charAt(i + 1) == "-" && "0#".indexOf(fmt.charAt(i + 2)) > -1)) {
          }
          break;
        case "?":
          while (fmt.charAt(++i) === c2) {
          }
          break;
        case "*":
          ++i;
          if (fmt.charAt(i) == " " || fmt.charAt(i) == "*")
            ++i;
          break;
        case "(":
        case ")":
          ++i;
          break;
        case "1":
        case "2":
        case "3":
        case "4":
        case "5":
        case "6":
        case "7":
        case "8":
        case "9":
          while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) {
          }
          break;
        case " ":
          ++i;
          break;
        default:
          ++i;
          break;
      }
    }
    return false;
  }
  function eval_fmt(fmt, v2, opts, flen) {
    var out = [], o2 = "", i = 0, c2 = "", lst = "t", dt2, j, cc;
    var hr = "H";
    while (i < fmt.length) {
      switch (c2 = fmt.charAt(i)) {
        case "G":
          if (!SSF_isgeneral(fmt, i))
            throw new Error("unrecognized character " + c2 + " in " + fmt);
          out[out.length] = { t: "G", v: "General" };
          i += 7;
          break;
        case '"':
          for (o2 = ""; (cc = fmt.charCodeAt(++i)) !== 34 && i < fmt.length; )
            o2 += String.fromCharCode(cc);
          out[out.length] = { t: "t", v: o2 };
          ++i;
          break;
        case "\\":
          var w2 = fmt.charAt(++i), t = w2 === "(" || w2 === ")" ? w2 : "t";
          out[out.length] = { t, v: w2 };
          ++i;
          break;
        case "_":
          out[out.length] = { t: "t", v: " " };
          i += 2;
          break;
        case "@":
          out[out.length] = { t: "T", v: v2 };
          ++i;
          break;
        case "B":
        case "b":
          if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2") {
            if (dt2 == null) {
              dt2 = SSF_parse_date_code(v2, opts, fmt.charAt(i + 1) === "2");
              if (dt2 == null)
                return "";
            }
            out[out.length] = { t: "X", v: fmt.substr(i, 2) };
            lst = c2;
            i += 2;
            break;
          }
        case "M":
        case "D":
        case "Y":
        case "H":
        case "S":
        case "E":
          c2 = c2.toLowerCase();
        case "m":
        case "d":
        case "y":
        case "h":
        case "s":
        case "e":
        case "g":
          if (v2 < 0)
            return "";
          if (dt2 == null) {
            dt2 = SSF_parse_date_code(v2, opts);
            if (dt2 == null)
              return "";
          }
          o2 = c2;
          while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c2)
            o2 += c2;
          if (c2 === "m" && lst.toLowerCase() === "h")
            c2 = "M";
          if (c2 === "h")
            c2 = hr;
          out[out.length] = { t: c2, v: o2 };
          lst = c2;
          break;
        case "A":
        case "a":
        case "\u4E0A":
          var q2 = { t: c2, v: c2 };
          if (dt2 == null)
            dt2 = SSF_parse_date_code(v2, opts);
          if (fmt.substr(i, 3).toUpperCase() === "A/P") {
            if (dt2 != null)
              q2.v = dt2.H >= 12 ? "P" : "A";
            q2.t = "T";
            hr = "h";
            i += 3;
          } else if (fmt.substr(i, 5).toUpperCase() === "AM/PM") {
            if (dt2 != null)
              q2.v = dt2.H >= 12 ? "PM" : "AM";
            q2.t = "T";
            i += 5;
            hr = "h";
          } else if (fmt.substr(i, 5).toUpperCase() === "\u4E0A\u5348/\u4E0B\u5348") {
            if (dt2 != null)
              q2.v = dt2.H >= 12 ? "\u4E0B\u5348" : "\u4E0A\u5348";
            q2.t = "T";
            i += 5;
            hr = "h";
          } else {
            q2.t = "t";
            ++i;
          }
          if (dt2 == null && q2.t === "T")
            return "";
          out[out.length] = q2;
          lst = c2;
          break;
        case "[":
          o2 = c2;
          while (fmt.charAt(i++) !== "]" && i < fmt.length)
            o2 += fmt.charAt(i);
          if (o2.slice(-1) !== "]")
            throw 'unterminated "[" block: |' + o2 + "|";
          if (o2.match(SSF_abstime)) {
            if (dt2 == null) {
              dt2 = SSF_parse_date_code(v2, opts);
              if (dt2 == null)
                return "";
            }
            out[out.length] = { t: "Z", v: o2.toLowerCase() };
            lst = o2.charAt(1);
          } else if (o2.indexOf("$") > -1) {
            o2 = (o2.match(/\$([^-\[\]]*)/) || [])[1] || "$";
            if (!fmt_is_date(fmt))
              out[out.length] = { t: "t", v: o2 };
          }
          break;
        case ".":
          if (dt2 != null) {
            o2 = c2;
            while (++i < fmt.length && (c2 = fmt.charAt(i)) === "0")
              o2 += c2;
            out[out.length] = { t: "s", v: o2 };
            break;
          }
        case "0":
        case "#":
          o2 = c2;
          while (++i < fmt.length && "0#?.,E+-%".indexOf(c2 = fmt.charAt(i)) > -1)
            o2 += c2;
          out[out.length] = { t: "n", v: o2 };
          break;
        case "?":
          o2 = c2;
          while (fmt.charAt(++i) === c2)
            o2 += c2;
          out[out.length] = { t: c2, v: o2 };
          lst = c2;
          break;
        case "*":
          ++i;
          if (fmt.charAt(i) == " " || fmt.charAt(i) == "*")
            ++i;
          break;
        case "(":
        case ")":
          out[out.length] = { t: flen === 1 ? "t" : c2, v: c2 };
          ++i;
          break;
        case "1":
        case "2":
        case "3":
        case "4":
        case "5":
        case "6":
        case "7":
        case "8":
        case "9":
          o2 = c2;
          while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1)
            o2 += fmt.charAt(i);
          out[out.length] = { t: "D", v: o2 };
          break;
        case " ":
          out[out.length] = { t: c2, v: c2 };
          ++i;
          break;
        case "$":
          out[out.length] = { t: "t", v: "$" };
          ++i;
          break;
        default:
          if (",$-+/():!^&'~{}<>=\u20ACacfijklopqrtuvwxzP".indexOf(c2) === -1)
            throw new Error("unrecognized character " + c2 + " in " + fmt);
          out[out.length] = { t: "t", v: c2 };
          ++i;
          break;
      }
    }
    var bt2 = 0, ss0 = 0, ssm;
    for (i = out.length - 1, lst = "t"; i >= 0; --i) {
      switch (out[i].t) {
        case "h":
        case "H":
          out[i].t = hr;
          lst = "h";
          if (bt2 < 1)
            bt2 = 1;
          break;
        case "s":
          if (ssm = out[i].v.match(/\.0+$/))
            ss0 = Math.max(ss0, ssm[0].length - 1);
          if (bt2 < 3)
            bt2 = 3;
        case "d":
        case "y":
        case "M":
        case "e":
          lst = out[i].t;
          break;
        case "m":
          if (lst === "s") {
            out[i].t = "M";
            if (bt2 < 2)
              bt2 = 2;
          }
          break;
        case "X":
          break;
        case "Z":
          if (bt2 < 1 && out[i].v.match(/[Hh]/))
            bt2 = 1;
          if (bt2 < 2 && out[i].v.match(/[Mm]/))
            bt2 = 2;
          if (bt2 < 3 && out[i].v.match(/[Ss]/))
            bt2 = 3;
      }
    }
    switch (bt2) {
      case 0:
        break;
      case 1:
        if (dt2.u >= 0.5) {
          dt2.u = 0;
          ++dt2.S;
        }
        if (dt2.S >= 60) {
          dt2.S = 0;
          ++dt2.M;
        }
        if (dt2.M >= 60) {
          dt2.M = 0;
          ++dt2.H;
        }
        break;
      case 2:
        if (dt2.u >= 0.5) {
          dt2.u = 0;
          ++dt2.S;
        }
        if (dt2.S >= 60) {
          dt2.S = 0;
          ++dt2.M;
        }
        break;
    }
    var nstr = "", jj;
    for (i = 0; i < out.length; ++i) {
      switch (out[i].t) {
        case "t":
        case "T":
        case " ":
        case "D":
          break;
        case "X":
          out[i].v = "";
          out[i].t = ";";
          break;
        case "d":
        case "m":
        case "y":
        case "h":
        case "H":
        case "M":
        case "s":
        case "e":
        case "b":
        case "Z":
          out[i].v = SSF_write_date(out[i].t.charCodeAt(0), out[i].v, dt2, ss0);
          out[i].t = "t";
          break;
        case "n":
        case "?":
          jj = i + 1;
          while (out[jj] != null && ((c2 = out[jj].t) === "?" || c2 === "D" || (c2 === " " || c2 === "t") && out[jj + 1] != null && (out[jj + 1].t === "?" || out[jj + 1].t === "t" && out[jj + 1].v === "/") || out[i].t === "(" && (c2 === " " || c2 === "n" || c2 === ")") || c2 === "t" && (out[jj].v === "/" || out[jj].v === " " && out[jj + 1] != null && out[jj + 1].t == "?"))) {
            out[i].v += out[jj].v;
            out[jj] = { v: "", t: ";" };
            ++jj;
          }
          nstr += out[i].v;
          i = jj - 1;
          break;
        case "G":
          out[i].t = "t";
          out[i].v = SSF_general(v2, opts);
          break;
      }
    }
    var vv = "", myv, ostr;
    if (nstr.length > 0) {
      if (nstr.charCodeAt(0) == 40) {
        myv = v2 < 0 && nstr.charCodeAt(0) === 45 ? -v2 : v2;
        ostr = write_num("n", nstr, myv);
      } else {
        myv = v2 < 0 && flen > 1 ? -v2 : v2;
        ostr = write_num("n", nstr, myv);
        if (myv < 0 && out[0] && out[0].t == "t") {
          ostr = ostr.substr(1);
          out[0].v = "-" + out[0].v;
        }
      }
      jj = ostr.length - 1;
      var decpt = out.length;
      for (i = 0; i < out.length; ++i)
        if (out[i] != null && out[i].t != "t" && out[i].v.indexOf(".") > -1) {
          decpt = i;
          break;
        }
      var lasti = out.length;
      if (decpt === out.length && ostr.indexOf("E") === -1) {
        for (i = out.length - 1; i >= 0; --i) {
          if (out[i] == null || "n?".indexOf(out[i].t) === -1)
            continue;
          if (jj >= out[i].v.length - 1) {
            jj -= out[i].v.length;
            out[i].v = ostr.substr(jj + 1, out[i].v.length);
          } else if (jj < 0)
            out[i].v = "";
          else {
            out[i].v = ostr.substr(0, jj + 1);
            jj = -1;
          }
          out[i].t = "t";
          lasti = i;
        }
        if (jj >= 0 && lasti < out.length)
          out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
      } else if (decpt !== out.length && ostr.indexOf("E") === -1) {
        jj = ostr.indexOf(".") - 1;
        for (i = decpt; i >= 0; --i) {
          if (out[i] == null || "n?".indexOf(out[i].t) === -1)
            continue;
          j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") - 1 : out[i].v.length - 1;
          vv = out[i].v.substr(j + 1);
          for (; j >= 0; --j) {
            if (jj >= 0 && (out[i].v.charAt(j) === "0" || out[i].v.charAt(j) === "#"))
              vv = ostr.charAt(jj--) + vv;
          }
          out[i].v = vv;
          out[i].t = "t";
          lasti = i;
        }
        if (jj >= 0 && lasti < out.length)
          out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
        jj = ostr.indexOf(".") + 1;
        for (i = decpt; i < out.length; ++i) {
          if (out[i] == null || "n?(".indexOf(out[i].t) === -1 && i !== decpt)
            continue;
          j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") + 1 : 0;
          vv = out[i].v.substr(0, j);
          for (; j < out[i].v.length; ++j) {
            if (jj < ostr.length)
              vv += ostr.charAt(jj++);
          }
          out[i].v = vv;
          out[i].t = "t";
          lasti = i;
        }
      }
    }
    for (i = 0; i < out.length; ++i)
      if (out[i] != null && "n?".indexOf(out[i].t) > -1) {
        myv = flen > 1 && v2 < 0 && i > 0 && out[i - 1].v === "-" ? -v2 : v2;
        out[i].v = write_num(out[i].t, out[i].v, myv);
        out[i].t = "t";
      }
    var retval = "";
    for (i = 0; i !== out.length; ++i)
      if (out[i] != null)
        retval += out[i].v;
    return retval;
  }
  var cfregex2 = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
  function chkcond(v2, rr) {
    if (rr == null)
      return false;
    var thresh = parseFloat(rr[2]);
    switch (rr[1]) {
      case "=":
        if (v2 == thresh)
          return true;
        break;
      case ">":
        if (v2 > thresh)
          return true;
        break;
      case "<":
        if (v2 < thresh)
          return true;
        break;
      case "<>":
        if (v2 != thresh)
          return true;
        break;
      case ">=":
        if (v2 >= thresh)
          return true;
        break;
      case "<=":
        if (v2 <= thresh)
          return true;
        break;
    }
    return false;
  }
  function choose_fmt(f2, v2) {
    var fmt = SSF_split_fmt(f2);
    var l2 = fmt.length, lat = fmt[l2 - 1].indexOf("@");
    if (l2 < 4 && lat > -1)
      --l2;
    if (fmt.length > 4)
      throw new Error("cannot find right format for |" + fmt.join("|") + "|");
    if (typeof v2 !== "number")
      return [4, fmt.length === 4 || lat > -1 ? fmt[fmt.length - 1] : "@"];
    switch (fmt.length) {
      case 1:
        fmt = lat > -1 ? ["General", "General", "General", fmt[0]] : [fmt[0], fmt[0], fmt[0], "@"];
        break;
      case 2:
        fmt = lat > -1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], "@"];
        break;
      case 3:
        fmt = lat > -1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], "@"];
        break;
    }
    var ff = v2 > 0 ? fmt[0] : v2 < 0 ? fmt[1] : fmt[2];
    if (fmt[0].indexOf("[") === -1 && fmt[1].indexOf("[") === -1)
      return [l2, ff];
    if (fmt[0].match(/\[[=<>]/) != null || fmt[1].match(/\[[=<>]/) != null) {
      var m1 = fmt[0].match(cfregex2);
      var m2 = fmt[1].match(cfregex2);
      return chkcond(v2, m1) ? [l2, fmt[0]] : chkcond(v2, m2) ? [l2, fmt[1]] : [l2, fmt[m1 != null && m2 != null ? 2 : 1]];
    }
    return [l2, ff];
  }
  function SSF_format(fmt, v2, o2) {
    if (o2 == null)
      o2 = {};
    var sfmt = "";
    switch (typeof fmt) {
      case "string":
        if (fmt == "m/d/yy" && o2.dateNF)
          sfmt = o2.dateNF;
        else
          sfmt = fmt;
        break;
      case "number":
        if (fmt == 14 && o2.dateNF)
          sfmt = o2.dateNF;
        else
          sfmt = (o2.table != null ? o2.table : table_fmt)[fmt];
        if (sfmt == null)
          sfmt = o2.table && o2.table[SSF_default_map[fmt]] || table_fmt[SSF_default_map[fmt]];
        if (sfmt == null)
          sfmt = SSF_default_str[fmt] || "General";
        break;
    }
    if (SSF_isgeneral(sfmt, 0))
      return SSF_general(v2, o2);
    if (v2 instanceof Date)
      v2 = datenum_local(v2, o2.date1904);
    var f2 = choose_fmt(sfmt, v2);
    if (SSF_isgeneral(f2[1]))
      return SSF_general(v2, o2);
    if (v2 === true)
      v2 = "TRUE";
    else if (v2 === false)
      v2 = "FALSE";
    else if (v2 === "" || v2 == null)
      return "";
    return eval_fmt(f2[1], v2, o2, f2[0]);
  }
  function SSF_load(fmt, idx) {
    if (typeof idx != "number") {
      idx = +idx || -1;
      for (var i = 0; i < 392; ++i) {
        if (table_fmt[i] == void 0) {
          if (idx < 0)
            idx = i;
          continue;
        }
        if (table_fmt[i] == fmt) {
          idx = i;
          break;
        }
      }
      if (idx < 0)
        idx = 391;
    }
    table_fmt[idx] = fmt;
    return idx;
  }
  function SSF_load_table(tbl) {
    for (var i = 0; i != 392; ++i)
      if (tbl[i] !== void 0)
        SSF_load(tbl[i], i);
  }
  function make_ssf() {
    table_fmt = SSF_init_table();
  }
  var SSFImplicit = {
    "5": '"$"#,##0_);\\("$"#,##0\\)',
    "6": '"$"#,##0_);[Red]\\("$"#,##0\\)',
    "7": '"$"#,##0.00_);\\("$"#,##0.00\\)',
    "8": '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
    "23": "General",
    "24": "General",
    "25": "General",
    "26": "General",
    "27": "m/d/yy",
    "28": "m/d/yy",
    "29": "m/d/yy",
    "30": "m/d/yy",
    "31": "m/d/yy",
    "32": "h:mm:ss",
    "33": "h:mm:ss",
    "34": "h:mm:ss",
    "35": "h:mm:ss",
    "36": "m/d/yy",
    "41": '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',
    "42": '_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)',
    "43": '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',
    "44": '_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',
    "50": "m/d/yy",
    "51": "m/d/yy",
    "52": "m/d/yy",
    "53": "m/d/yy",
    "54": "m/d/yy",
    "55": "m/d/yy",
    "56": "m/d/yy",
    "57": "m/d/yy",
    "58": "m/d/yy",
    "59": "0",
    "60": "0.00",
    "61": "#,##0",
    "62": "#,##0.00",
    "63": '"$"#,##0_);\\("$"#,##0\\)',
    "64": '"$"#,##0_);[Red]\\("$"#,##0\\)',
    "65": '"$"#,##0.00_);\\("$"#,##0.00\\)',
    "66": '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
    "67": "0%",
    "68": "0.00%",
    "69": "# ?/?",
    "70": "# ??/??",
    "71": "m/d/yy",
    "72": "m/d/yy",
    "73": "d-mmm-yy",
    "74": "d-mmm",
    "75": "mmm-yy",
    "76": "h:mm",
    "77": "h:mm:ss",
    "78": "m/d/yy h:mm",
    "79": "mm:ss",
    "80": "[h]:mm:ss",
    "81": "mmss.0"
  };
  var dateNFregex = /[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;
  function dateNF_regex(dateNF) {
    var fmt = typeof dateNF == "number" ? table_fmt[dateNF] : dateNF;
    fmt = fmt.replace(dateNFregex, "(\\d+)");
    return new RegExp("^" + fmt + "$");
  }
  function dateNF_fix(str, dateNF, match) {
    var Y2 = -1, m2 = -1, d2 = -1, H2 = -1, M2 = -1, S2 = -1;
    (dateNF.match(dateNFregex) || []).forEach(function(n, i) {
      var v2 = parseInt(match[i + 1], 10);
      switch (n.toLowerCase().charAt(0)) {
        case "y":
          Y2 = v2;
          break;
        case "d":
          d2 = v2;
          break;
        case "h":
          H2 = v2;
          break;
        case "s":
          S2 = v2;
          break;
        case "m":
          if (H2 >= 0)
            M2 = v2;
          else
            m2 = v2;
          break;
      }
    });
    if (S2 >= 0 && M2 == -1 && m2 >= 0) {
      M2 = m2;
      m2 = -1;
    }
    var datestr = ("" + (Y2 >= 0 ? Y2 : new Date().getFullYear())).slice(-4) + "-" + ("00" + (m2 >= 1 ? m2 : 1)).slice(-2) + "-" + ("00" + (d2 >= 1 ? d2 : 1)).slice(-2);
    if (datestr.length == 7)
      datestr = "0" + datestr;
    if (datestr.length == 8)
      datestr = "20" + datestr;
    var timestr = ("00" + (H2 >= 0 ? H2 : 0)).slice(-2) + ":" + ("00" + (M2 >= 0 ? M2 : 0)).slice(-2) + ":" + ("00" + (S2 >= 0 ? S2 : 0)).slice(-2);
    if (H2 == -1 && M2 == -1 && S2 == -1)
      return datestr;
    if (Y2 == -1 && m2 == -1 && d2 == -1)
      return timestr;
    return datestr + "T" + timestr;
  }
  var CRC32 = /* @__PURE__ */ function() {
    var CRC322 = {};
    CRC322.version = "1.2.0";
    function signed_crc_table() {
      var c2 = 0, table = new Array(256);
      for (var n = 0; n != 256; ++n) {
        c2 = n;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        c2 = c2 & 1 ? -306674912 ^ c2 >>> 1 : c2 >>> 1;
        table[n] = c2;
      }
      return typeof Int32Array !== "undefined" ? new Int32Array(table) : table;
    }
    var T0 = signed_crc_table();
    function slice_by_16_tables(T10) {
      var c2 = 0, v2 = 0, n = 0, table = typeof Int32Array !== "undefined" ? new Int32Array(4096) : new Array(4096);
      for (n = 0; n != 256; ++n)
        table[n] = T10[n];
      for (n = 0; n != 256; ++n) {
        v2 = T10[n];
        for (c2 = 256 + n; c2 < 4096; c2 += 256)
          v2 = table[c2] = v2 >>> 8 ^ T10[v2 & 255];
      }
      var out = [];
      for (n = 1; n != 16; ++n)
        out[n - 1] = typeof Int32Array !== "undefined" ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
      return out;
    }
    var TT = slice_by_16_tables(T0);
    var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
    var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
    var Tb = TT[10], Tc = TT[11], Td = TT[12], Te2 = TT[13], Tf = TT[14];
    function crc32_bstr(bstr, seed) {
      var C2 = seed ^ -1;
      for (var i = 0, L = bstr.length; i < L; )
        C2 = C2 >>> 8 ^ T0[(C2 ^ bstr.charCodeAt(i++)) & 255];
      return ~C2;
    }
    function crc32_buf(B2, seed) {
      var C2 = seed ^ -1, L = B2.length - 15, i = 0;
      for (; i < L; )
        C2 = Tf[B2[i++] ^ C2 & 255] ^ Te2[B2[i++] ^ C2 >> 8 & 255] ^ Td[B2[i++] ^ C2 >> 16 & 255] ^ Tc[B2[i++] ^ C2 >>> 24] ^ Tb[B2[i++]] ^ Ta[B2[i++]] ^ T9[B2[i++]] ^ T8[B2[i++]] ^ T7[B2[i++]] ^ T6[B2[i++]] ^ T5[B2[i++]] ^ T4[B2[i++]] ^ T3[B2[i++]] ^ T2[B2[i++]] ^ T1[B2[i++]] ^ T0[B2[i++]];
      L += 15;
      while (i < L)
        C2 = C2 >>> 8 ^ T0[(C2 ^ B2[i++]) & 255];
      return ~C2;
    }
    function crc32_str(str, seed) {
      var C2 = seed ^ -1;
      for (var i = 0, L = str.length, c2 = 0, d2 = 0; i < L; ) {
        c2 = str.charCodeAt(i++);
        if (c2 < 128) {
          C2 = C2 >>> 8 ^ T0[(C2 ^ c2) & 255];
        } else if (c2 < 2048) {
          C2 = C2 >>> 8 ^ T0[(C2 ^ (192 | c2 >> 6 & 31)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | c2 & 63)) & 255];
        } else if (c2 >= 55296 && c2 < 57344) {
          c2 = (c2 & 1023) + 64;
          d2 = str.charCodeAt(i++) & 1023;
          C2 = C2 >>> 8 ^ T0[(C2 ^ (240 | c2 >> 8 & 7)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | c2 >> 2 & 63)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | d2 >> 6 & 15 | (c2 & 3) << 4)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | d2 & 63)) & 255];
        } else {
          C2 = C2 >>> 8 ^ T0[(C2 ^ (224 | c2 >> 12 & 15)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | c2 >> 6 & 63)) & 255];
          C2 = C2 >>> 8 ^ T0[(C2 ^ (128 | c2 & 63)) & 255];
        }
      }
      return ~C2;
    }
    CRC322.table = T0;
    CRC322.bstr = crc32_bstr;
    CRC322.buf = crc32_buf;
    CRC322.str = crc32_str;
    return CRC322;
  }();
  var CFB = /* @__PURE__ */ function _CFB() {
    var exports2 = {};
    exports2.version = "1.2.1";
    function namecmp(l2, r) {
      var L = l2.split("/"), R2 = r.split("/");
      for (var i2 = 0, c2 = 0, Z2 = Math.min(L.length, R2.length); i2 < Z2; ++i2) {
        if (c2 = L[i2].length - R2[i2].length)
          return c2;
        if (L[i2] != R2[i2])
          return L[i2] < R2[i2] ? -1 : 1;
      }
      return L.length - R2.length;
    }
    function dirname(p2) {
      if (p2.charAt(p2.length - 1) == "/")
        return p2.slice(0, -1).indexOf("/") === -1 ? p2 : dirname(p2.slice(0, -1));
      var c2 = p2.lastIndexOf("/");
      return c2 === -1 ? p2 : p2.slice(0, c2 + 1);
    }
    function filename(p2) {
      if (p2.charAt(p2.length - 1) == "/")
        return filename(p2.slice(0, -1));
      var c2 = p2.lastIndexOf("/");
      return c2 === -1 ? p2 : p2.slice(c2 + 1);
    }
    function write_dos_date(buf, date) {
      if (typeof date === "string")
        date = new Date(date);
      var hms = date.getHours();
      hms = hms << 6 | date.getMinutes();
      hms = hms << 5 | date.getSeconds() >>> 1;
      buf.write_shift(2, hms);
      var ymd = date.getFullYear() - 1980;
      ymd = ymd << 4 | date.getMonth() + 1;
      ymd = ymd << 5 | date.getDate();
      buf.write_shift(2, ymd);
    }
    function parse_dos_date(buf) {
      var hms = buf.read_shift(2) & 65535;
      var ymd = buf.read_shift(2) & 65535;
      var val = new Date();
      var d2 = ymd & 31;
      ymd >>>= 5;
      var m2 = ymd & 15;
      ymd >>>= 4;
      val.setMilliseconds(0);
      val.setFullYear(ymd + 1980);
      val.setMonth(m2 - 1);
      val.setDate(d2);
      var S2 = hms & 31;
      hms >>>= 5;
      var M2 = hms & 63;
      hms >>>= 6;
      val.setHours(hms);
      val.setMinutes(M2);
      val.setSeconds(S2 << 1);
      return val;
    }
    function parse_extra_field(blob) {
      prep_blob(blob, 0);
      var o2 = {};
      var flags = 0;
      while (blob.l <= blob.length - 4) {
        var type = blob.read_shift(2);
        var sz = blob.read_shift(2), tgt = blob.l + sz;
        var p2 = {};
        switch (type) {
          case 21589:
            {
              flags = blob.read_shift(1);
              if (flags & 1)
                p2.mtime = blob.read_shift(4);
              if (sz > 5) {
                if (flags & 2)
                  p2.atime = blob.read_shift(4);
                if (flags & 4)
                  p2.ctime = blob.read_shift(4);
              }
              if (p2.mtime)
                p2.mt = new Date(p2.mtime * 1e3);
            }
            break;
        }
        blob.l = tgt;
        o2[type] = p2;
      }
      return o2;
    }
    var fs;
    function get_fs() {
      return fs || (fs = {});
    }
    function parse(file, options) {
      if (file[0] == 80 && file[1] == 75)
        return parse_zip2(file, options);
      if ((file[0] | 32) == 109 && (file[1] | 32) == 105)
        return parse_mad(file, options);
      if (file.length < 512)
        throw new Error("CFB file size " + file.length + " < 512");
      var mver = 3;
      var ssz = 512;
      var nmfs = 0;
      var difat_sec_cnt = 0;
      var dir_start = 0;
      var minifat_start = 0;
      var difat_start = 0;
      var fat_addrs = [];
      var blob = file.slice(0, 512);
      prep_blob(blob, 0);
      var mv = check_get_mver(blob);
      mver = mv[0];
      switch (mver) {
        case 3:
          ssz = 512;
          break;
        case 4:
          ssz = 4096;
          break;
        case 0:
          if (mv[1] == 0)
            return parse_zip2(file, options);
        default:
          throw new Error("Major Version: Expected 3 or 4 saw " + mver);
      }
      if (ssz !== 512) {
        blob = file.slice(0, ssz);
        prep_blob(blob, 28);
      }
      var header = file.slice(0, ssz);
      check_shifts(blob, mver);
      var dir_cnt = blob.read_shift(4, "i");
      if (mver === 3 && dir_cnt !== 0)
        throw new Error("# Directory Sectors: Expected 0 saw " + dir_cnt);
      blob.l += 4;
      dir_start = blob.read_shift(4, "i");
      blob.l += 4;
      blob.chk("00100000", "Mini Stream Cutoff Size: ");
      minifat_start = blob.read_shift(4, "i");
      nmfs = blob.read_shift(4, "i");
      difat_start = blob.read_shift(4, "i");
      difat_sec_cnt = blob.read_shift(4, "i");
      for (var q3 = -1, j = 0; j < 109; ++j) {
        q3 = blob.read_shift(4, "i");
        if (q3 < 0)
          break;
        fat_addrs[j] = q3;
      }
      var sectors = sectorify(file, ssz);
      sleuth_fat(difat_start, difat_sec_cnt, sectors, ssz, fat_addrs);
      var sector_list = make_sector_list(sectors, dir_start, fat_addrs, ssz);
      sector_list[dir_start].name = "!Directory";
      if (nmfs > 0 && minifat_start !== ENDOFCHAIN)
        sector_list[minifat_start].name = "!MiniFAT";
      sector_list[fat_addrs[0]].name = "!FAT";
      sector_list.fat_addrs = fat_addrs;
      sector_list.ssz = ssz;
      var files = {}, Paths = [], FileIndex = [], FullPaths = [];
      read_directory(dir_start, sector_list, sectors, Paths, nmfs, files, FileIndex, minifat_start);
      build_full_paths(FileIndex, FullPaths, Paths);
      Paths.shift();
      var o2 = {
        FileIndex,
        FullPaths
      };
      if (options && options.raw)
        o2.raw = { header, sectors };
      return o2;
    }
    function check_get_mver(blob) {
      if (blob[blob.l] == 80 && blob[blob.l + 1] == 75)
        return [0, 0];
      blob.chk(HEADER_SIGNATURE, "Header Signature: ");
      blob.l += 16;
      var mver = blob.read_shift(2, "u");
      return [blob.read_shift(2, "u"), mver];
    }
    function check_shifts(blob, mver) {
      var shift = 9;
      blob.l += 2;
      switch (shift = blob.read_shift(2)) {
        case 9:
          if (mver != 3)
            throw new Error("Sector Shift: Expected 9 saw " + shift);
          break;
        case 12:
          if (mver != 4)
            throw new Error("Sector Shift: Expected 12 saw " + shift);
          break;
        default:
          throw new Error("Sector Shift: Expected 9 or 12 saw " + shift);
      }
      blob.chk("0600", "Mini Sector Shift: ");
      blob.chk("000000000000", "Reserved: ");
    }
    function sectorify(file, ssz) {
      var nsectors = Math.ceil(file.length / ssz) - 1;
      var sectors = [];
      for (var i2 = 1; i2 < nsectors; ++i2)
        sectors[i2 - 1] = file.slice(i2 * ssz, (i2 + 1) * ssz);
      sectors[nsectors - 1] = file.slice(nsectors * ssz);
      return sectors;
    }
    function build_full_paths(FI, FP, Paths) {
      var i2 = 0, L = 0, R2 = 0, C2 = 0, j = 0, pl = Paths.length;
      var dad = [], q3 = [];
      for (; i2 < pl; ++i2) {
        dad[i2] = q3[i2] = i2;
        FP[i2] = Paths[i2];
      }
      for (; j < q3.length; ++j) {
        i2 = q3[j];
        L = FI[i2].L;
        R2 = FI[i2].R;
        C2 = FI[i2].C;
        if (dad[i2] === i2) {
          if (L !== -1 && dad[L] !== L)
            dad[i2] = dad[L];
          if (R2 !== -1 && dad[R2] !== R2)
            dad[i2] = dad[R2];
        }
        if (C2 !== -1)
          dad[C2] = i2;
        if (L !== -1 && i2 != dad[i2]) {
          dad[L] = dad[i2];
          if (q3.lastIndexOf(L) < j)
            q3.push(L);
        }
        if (R2 !== -1 && i2 != dad[i2]) {
          dad[R2] = dad[i2];
          if (q3.lastIndexOf(R2) < j)
            q3.push(R2);
        }
      }
      for (i2 = 1; i2 < pl; ++i2)
        if (dad[i2] === i2) {
          if (R2 !== -1 && dad[R2] !== R2)
            dad[i2] = dad[R2];
          else if (L !== -1 && dad[L] !== L)
            dad[i2] = dad[L];
        }
      for (i2 = 1; i2 < pl; ++i2) {
        if (FI[i2].type === 0)
          continue;
        j = i2;
        if (j != dad[j])
          do {
            j = dad[j];
            FP[i2] = FP[j] + "/" + FP[i2];
          } while (j !== 0 && dad[j] !== -1 && j != dad[j]);
        dad[i2] = -1;
      }
      FP[0] += "/";
      for (i2 = 1; i2 < pl; ++i2) {
        if (FI[i2].type !== 2)
          FP[i2] += "/";
      }
    }
    function get_mfat_entry(entry, payload, mini) {
      var start = entry.start, size2 = entry.size;
      var o2 = [];
      var idx = start;
      while (mini && size2 > 0 && idx >= 0) {
        o2.push(payload.slice(idx * MSSZ, idx * MSSZ + MSSZ));
        size2 -= MSSZ;
        idx = __readInt32LE(mini, idx * 4);
      }
      if (o2.length === 0)
        return new_buf(0);
      return bconcat(o2).slice(0, entry.size);
    }
    function sleuth_fat(idx, cnt, sectors, ssz, fat_addrs) {
      var q3 = ENDOFCHAIN;
      if (idx === ENDOFCHAIN) {
        if (cnt !== 0)
          throw new Error("DIFAT chain shorter than expected");
      } else if (idx !== -1) {
        var sector = sectors[idx], m2 = (ssz >>> 2) - 1;
        if (!sector)
          return;
        for (var i2 = 0; i2 < m2; ++i2) {
          if ((q3 = __readInt32LE(sector, i2 * 4)) === ENDOFCHAIN)
            break;
          fat_addrs.push(q3);
        }
        sleuth_fat(__readInt32LE(sector, ssz - 4), cnt - 1, sectors, ssz, fat_addrs);
      }
    }
    function get_sector_list(sectors, start, fat_addrs, ssz, chkd) {
      var buf = [], buf_chain = [];
      if (!chkd)
        chkd = [];
      var modulus = ssz - 1, j = 0, jj = 0;
      for (j = start; j >= 0; ) {
        chkd[j] = true;
        buf[buf.length] = j;
        buf_chain.push(sectors[j]);
        var addr = fat_addrs[Math.floor(j * 4 / ssz)];
        jj = j * 4 & modulus;
        if (ssz < 4 + jj)
          throw new Error("FAT boundary crossed: " + j + " 4 " + ssz);
        if (!sectors[addr])
          break;
        j = __readInt32LE(sectors[addr], jj);
      }
      return { nodes: buf, data: __toBuffer([buf_chain]) };
    }
    function make_sector_list(sectors, dir_start, fat_addrs, ssz) {
      var sl = sectors.length, sector_list = [];
      var chkd = [], buf = [], buf_chain = [];
      var modulus = ssz - 1, i2 = 0, j = 0, k = 0, jj = 0;
      for (i2 = 0; i2 < sl; ++i2) {
        buf = [];
        k = i2 + dir_start;
        if (k >= sl)
          k -= sl;
        if (chkd[k])
          continue;
        buf_chain = [];
        var seen = [];
        for (j = k; j >= 0; ) {
          seen[j] = true;
          chkd[j] = true;
          buf[buf.length] = j;
          buf_chain.push(sectors[j]);
          var addr = fat_addrs[Math.floor(j * 4 / ssz)];
          jj = j * 4 & modulus;
          if (ssz < 4 + jj)
            throw new Error("FAT boundary crossed: " + j + " 4 " + ssz);
          if (!sectors[addr])
            break;
          j = __readInt32LE(sectors[addr], jj);
          if (seen[j])
            break;
        }
        sector_list[k] = { nodes: buf, data: __toBuffer([buf_chain]) };
      }
      return sector_list;
    }
    function read_directory(dir_start, sector_list, sectors, Paths, nmfs, files, FileIndex, mini) {
      var minifat_store = 0, pl = Paths.length ? 2 : 0;
      var sector = sector_list[dir_start].data;
      var i2 = 0, namelen = 0, name;
      for (; i2 < sector.length; i2 += 128) {
        var blob = sector.slice(i2, i2 + 128);
        prep_blob(blob, 64);
        namelen = blob.read_shift(2);
        name = __utf16le(blob, 0, namelen - pl);
        Paths.push(name);
        var o2 = {
          name,
          type: blob.read_shift(1),
          color: blob.read_shift(1),
          L: blob.read_shift(4, "i"),
          R: blob.read_shift(4, "i"),
          C: blob.read_shift(4, "i"),
          clsid: blob.read_shift(16),
          state: blob.read_shift(4, "i"),
          start: 0,
          size: 0
        };
        var ctime = blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2);
        if (ctime !== 0)
          o2.ct = read_date(blob, blob.l - 8);
        var mtime = blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2) + blob.read_shift(2);
        if (mtime !== 0)
          o2.mt = read_date(blob, blob.l - 8);
        o2.start = blob.read_shift(4, "i");
        o2.size = blob.read_shift(4, "i");
        if (o2.size < 0 && o2.start < 0) {
          o2.size = o2.type = 0;
          o2.start = ENDOFCHAIN;
          o2.name = "";
        }
        if (o2.type === 5) {
          minifat_store = o2.start;
          if (nmfs > 0 && minifat_store !== ENDOFCHAIN)
            sector_list[minifat_store].name = "!StreamData";
        } else if (o2.size >= 4096) {
          o2.storage = "fat";
          if (sector_list[o2.start] === void 0)
            sector_list[o2.start] = get_sector_list(sectors, o2.start, sector_list.fat_addrs, sector_list.ssz);
          sector_list[o2.start].name = o2.name;
          o2.content = sector_list[o2.start].data.slice(0, o2.size);
        } else {
          o2.storage = "minifat";
          if (o2.size < 0)
            o2.size = 0;
          else if (minifat_store !== ENDOFCHAIN && o2.start !== ENDOFCHAIN && sector_list[minifat_store]) {
            o2.content = get_mfat_entry(o2, sector_list[minifat_store].data, (sector_list[mini] || {}).data);
          }
        }
        if (o2.content)
          prep_blob(o2.content, 0);
        files[name] = o2;
        FileIndex.push(o2);
      }
    }
    function read_date(blob, offset) {
      return new Date((__readUInt32LE(blob, offset + 4) / 1e7 * Math.pow(2, 32) + __readUInt32LE(blob, offset) / 1e7 - 11644473600) * 1e3);
    }
    function read_file(filename2, options) {
      get_fs();
      return parse(fs.readFileSync(filename2), options);
    }
    function read(blob, options) {
      var type = options && options.type;
      if (!type) {
        if (has_buf && Buffer.isBuffer(blob))
          type = "buffer";
      }
      switch (type || "base64") {
        case "file":
          return read_file(blob, options);
        case "base64":
          return parse(s2a(Base64_decode(blob)), options);
        case "binary":
          return parse(s2a(blob), options);
      }
      return parse(blob, options);
    }
    function init_cfb(cfb, opts) {
      var o2 = opts || {}, root2 = o2.root || "Root Entry";
      if (!cfb.FullPaths)
        cfb.FullPaths = [];
      if (!cfb.FileIndex)
        cfb.FileIndex = [];
      if (cfb.FullPaths.length !== cfb.FileIndex.length)
        throw new Error("inconsistent CFB structure");
      if (cfb.FullPaths.length === 0) {
        cfb.FullPaths[0] = root2 + "/";
        cfb.FileIndex[0] = { name: root2, type: 5 };
      }
      if (o2.CLSID)
        cfb.FileIndex[0].clsid = o2.CLSID;
      seed_cfb(cfb);
    }
    function seed_cfb(cfb) {
      var nm = "Sh33tJ5";
      if (CFB.find(cfb, "/" + nm))
        return;
      var p2 = new_buf(4);
      p2[0] = 55;
      p2[1] = p2[3] = 50;
      p2[2] = 54;
      cfb.FileIndex.push({ name: nm, type: 2, content: p2, size: 4, L: 69, R: 69, C: 69 });
      cfb.FullPaths.push(cfb.FullPaths[0] + nm);
      rebuild_cfb(cfb);
    }
    function rebuild_cfb(cfb, f2) {
      init_cfb(cfb);
      var gc = false, s2 = false;
      for (var i2 = cfb.FullPaths.length - 1; i2 >= 0; --i2) {
        var _file = cfb.FileIndex[i2];
        switch (_file.type) {
          case 0:
            if (s2)
              gc = true;
            else {
              cfb.FileIndex.pop();
              cfb.FullPaths.pop();
            }
            break;
          case 1:
          case 2:
          case 5:
            s2 = true;
            if (isNaN(_file.R * _file.L * _file.C))
              gc = true;
            if (_file.R > -1 && _file.L > -1 && _file.R == _file.L)
              gc = true;
            break;
          default:
            gc = true;
            break;
        }
      }
      if (!gc && !f2)
        return;
      var now2 = new Date(1987, 1, 19), j = 0;
      var fullPaths = Object.create ? /* @__PURE__ */ Object.create(null) : {};
      var data = [];
      for (i2 = 0; i2 < cfb.FullPaths.length; ++i2) {
        fullPaths[cfb.FullPaths[i2]] = true;
        if (cfb.FileIndex[i2].type === 0)
          continue;
        data.push([cfb.FullPaths[i2], cfb.FileIndex[i2]]);
      }
      for (i2 = 0; i2 < data.length; ++i2) {
        var dad = dirname(data[i2][0]);
        s2 = fullPaths[dad];
        if (!s2) {
          data.push([dad, {
            name: filename(dad).replace("/", ""),
            type: 1,
            clsid: HEADER_CLSID,
            ct: now2,
            mt: now2,
            content: null
          }]);
          fullPaths[dad] = true;
        }
      }
      data.sort(function(x2, y) {
        return namecmp(x2[0], y[0]);
      });
      cfb.FullPaths = [];
      cfb.FileIndex = [];
      for (i2 = 0; i2 < data.length; ++i2) {
        cfb.FullPaths[i2] = data[i2][0];
        cfb.FileIndex[i2] = data[i2][1];
      }
      for (i2 = 0; i2 < data.length; ++i2) {
        var elt = cfb.FileIndex[i2];
        var nm = cfb.FullPaths[i2];
        elt.name = filename(nm).replace("/", "");
        elt.L = elt.R = elt.C = -(elt.color = 1);
        elt.size = elt.content ? elt.content.length : 0;
        elt.start = 0;
        elt.clsid = elt.clsid || HEADER_CLSID;
        if (i2 === 0) {
          elt.C = data.length > 1 ? 1 : -1;
          elt.size = 0;
          elt.type = 5;
        } else if (nm.slice(-1) == "/") {
          for (j = i2 + 1; j < data.length; ++j)
            if (dirname(cfb.FullPaths[j]) == nm)
              break;
          elt.C = j >= data.length ? -1 : j;
          for (j = i2 + 1; j < data.length; ++j)
            if (dirname(cfb.FullPaths[j]) == dirname(nm))
              break;
          elt.R = j >= data.length ? -1 : j;
          elt.type = 1;
        } else {
          if (dirname(cfb.FullPaths[i2 + 1] || "") == dirname(nm))
            elt.R = i2 + 1;
          elt.type = 2;
        }
      }
    }
    function _write(cfb, options) {
      var _opts = options || {};
      if (_opts.fileType == "mad")
        return write_mad(cfb, _opts);
      rebuild_cfb(cfb);
      switch (_opts.fileType) {
        case "zip":
          return write_zip2(cfb, _opts);
      }
      var L = function(cfb2) {
        var mini_size = 0, fat_size = 0;
        for (var i3 = 0; i3 < cfb2.FileIndex.length; ++i3) {
          var file2 = cfb2.FileIndex[i3];
          if (!file2.content)
            continue;
          var flen2 = file2.content.length;
          if (flen2 > 0) {
            if (flen2 < 4096)
              mini_size += flen2 + 63 >> 6;
            else
              fat_size += flen2 + 511 >> 9;
          }
        }
        var dir_cnt = cfb2.FullPaths.length + 3 >> 2;
        var mini_cnt = mini_size + 7 >> 3;
        var mfat_cnt = mini_size + 127 >> 7;
        var fat_base = mini_cnt + fat_size + dir_cnt + mfat_cnt;
        var fat_cnt = fat_base + 127 >> 7;
        var difat_cnt = fat_cnt <= 109 ? 0 : Math.ceil((fat_cnt - 109) / 127);
        while (fat_base + fat_cnt + difat_cnt + 127 >> 7 > fat_cnt)
          difat_cnt = ++fat_cnt <= 109 ? 0 : Math.ceil((fat_cnt - 109) / 127);
        var L2 = [1, difat_cnt, fat_cnt, mfat_cnt, dir_cnt, fat_size, mini_size, 0];
        cfb2.FileIndex[0].size = mini_size << 6;
        L2[7] = (cfb2.FileIndex[0].start = L2[0] + L2[1] + L2[2] + L2[3] + L2[4] + L2[5]) + (L2[6] + 7 >> 3);
        return L2;
      }(cfb);
      var o2 = new_buf(L[7] << 9);
      var i2 = 0, T2 = 0;
      {
        for (i2 = 0; i2 < 8; ++i2)
          o2.write_shift(1, HEADER_SIG[i2]);
        for (i2 = 0; i2 < 8; ++i2)
          o2.write_shift(2, 0);
        o2.write_shift(2, 62);
        o2.write_shift(2, 3);
        o2.write_shift(2, 65534);
        o2.write_shift(2, 9);
        o2.write_shift(2, 6);
        for (i2 = 0; i2 < 3; ++i2)
          o2.write_shift(2, 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, L[2]);
        o2.write_shift(4, L[0] + L[1] + L[2] + L[3] - 1);
        o2.write_shift(4, 0);
        o2.write_shift(4, 1 << 12);
        o2.write_shift(4, L[3] ? L[0] + L[1] + L[2] - 1 : ENDOFCHAIN);
        o2.write_shift(4, L[3]);
        o2.write_shift(-4, L[1] ? L[0] - 1 : ENDOFCHAIN);
        o2.write_shift(4, L[1]);
        for (i2 = 0; i2 < 109; ++i2)
          o2.write_shift(-4, i2 < L[2] ? L[1] + i2 : -1);
      }
      if (L[1]) {
        for (T2 = 0; T2 < L[1]; ++T2) {
          for (; i2 < 236 + T2 * 127; ++i2)
            o2.write_shift(-4, i2 < L[2] ? L[1] + i2 : -1);
          o2.write_shift(-4, T2 === L[1] - 1 ? ENDOFCHAIN : T2 + 1);
        }
      }
      var chainit = function(w2) {
        for (T2 += w2; i2 < T2 - 1; ++i2)
          o2.write_shift(-4, i2 + 1);
        if (w2) {
          ++i2;
          o2.write_shift(-4, ENDOFCHAIN);
        }
      };
      T2 = i2 = 0;
      for (T2 += L[1]; i2 < T2; ++i2)
        o2.write_shift(-4, consts.DIFSECT);
      for (T2 += L[2]; i2 < T2; ++i2)
        o2.write_shift(-4, consts.FATSECT);
      chainit(L[3]);
      chainit(L[4]);
      var j = 0, flen = 0;
      var file = cfb.FileIndex[0];
      for (; j < cfb.FileIndex.length; ++j) {
        file = cfb.FileIndex[j];
        if (!file.content)
          continue;
        flen = file.content.length;
        if (flen < 4096)
          continue;
        file.start = T2;
        chainit(flen + 511 >> 9);
      }
      chainit(L[6] + 7 >> 3);
      while (o2.l & 511)
        o2.write_shift(-4, consts.ENDOFCHAIN);
      T2 = i2 = 0;
      for (j = 0; j < cfb.FileIndex.length; ++j) {
        file = cfb.FileIndex[j];
        if (!file.content)
          continue;
        flen = file.content.length;
        if (!flen || flen >= 4096)
          continue;
        file.start = T2;
        chainit(flen + 63 >> 6);
      }
      while (o2.l & 511)
        o2.write_shift(-4, consts.ENDOFCHAIN);
      for (i2 = 0; i2 < L[4] << 2; ++i2) {
        var nm = cfb.FullPaths[i2];
        if (!nm || nm.length === 0) {
          for (j = 0; j < 17; ++j)
            o2.write_shift(4, 0);
          for (j = 0; j < 3; ++j)
            o2.write_shift(4, -1);
          for (j = 0; j < 12; ++j)
            o2.write_shift(4, 0);
          continue;
        }
        file = cfb.FileIndex[i2];
        if (i2 === 0)
          file.start = file.size ? file.start - 1 : ENDOFCHAIN;
        var _nm = i2 === 0 && _opts.root || file.name;
        flen = 2 * (_nm.length + 1);
        o2.write_shift(64, _nm, "utf16le");
        o2.write_shift(2, flen);
        o2.write_shift(1, file.type);
        o2.write_shift(1, file.color);
        o2.write_shift(-4, file.L);
        o2.write_shift(-4, file.R);
        o2.write_shift(-4, file.C);
        if (!file.clsid)
          for (j = 0; j < 4; ++j)
            o2.write_shift(4, 0);
        else
          o2.write_shift(16, file.clsid, "hex");
        o2.write_shift(4, file.state || 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, file.start);
        o2.write_shift(4, file.size);
        o2.write_shift(4, 0);
      }
      for (i2 = 1; i2 < cfb.FileIndex.length; ++i2) {
        file = cfb.FileIndex[i2];
        if (file.size >= 4096) {
          o2.l = file.start + 1 << 9;
          if (has_buf && Buffer.isBuffer(file.content)) {
            file.content.copy(o2, o2.l, 0, file.size);
            o2.l += file.size + 511 & -512;
          } else {
            for (j = 0; j < file.size; ++j)
              o2.write_shift(1, file.content[j]);
            for (; j & 511; ++j)
              o2.write_shift(1, 0);
          }
        }
      }
      for (i2 = 1; i2 < cfb.FileIndex.length; ++i2) {
        file = cfb.FileIndex[i2];
        if (file.size > 0 && file.size < 4096) {
          if (has_buf && Buffer.isBuffer(file.content)) {
            file.content.copy(o2, o2.l, 0, file.size);
            o2.l += file.size + 63 & -64;
          } else {
            for (j = 0; j < file.size; ++j)
              o2.write_shift(1, file.content[j]);
            for (; j & 63; ++j)
              o2.write_shift(1, 0);
          }
        }
      }
      if (has_buf) {
        o2.l = o2.length;
      } else {
        while (o2.l < o2.length)
          o2.write_shift(1, 0);
      }
      return o2;
    }
    function find(cfb, path) {
      var UCFullPaths = cfb.FullPaths.map(function(x2) {
        return x2.toUpperCase();
      });
      var UCPaths = UCFullPaths.map(function(x2) {
        var y = x2.split("/");
        return y[y.length - (x2.slice(-1) == "/" ? 2 : 1)];
      });
      var k = false;
      if (path.charCodeAt(0) === 47) {
        k = true;
        path = UCFullPaths[0].slice(0, -1) + path;
      } else
        k = path.indexOf("/") !== -1;
      var UCPath = path.toUpperCase();
      var w2 = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
      if (w2 !== -1)
        return cfb.FileIndex[w2];
      var m2 = !UCPath.match(chr1);
      UCPath = UCPath.replace(chr0, "");
      if (m2)
        UCPath = UCPath.replace(chr1, "!");
      for (w2 = 0; w2 < UCFullPaths.length; ++w2) {
        if ((m2 ? UCFullPaths[w2].replace(chr1, "!") : UCFullPaths[w2]).replace(chr0, "") == UCPath)
          return cfb.FileIndex[w2];
        if ((m2 ? UCPaths[w2].replace(chr1, "!") : UCPaths[w2]).replace(chr0, "") == UCPath)
          return cfb.FileIndex[w2];
      }
      return null;
    }
    var MSSZ = 64;
    var ENDOFCHAIN = -2;
    var HEADER_SIGNATURE = "d0cf11e0a1b11ae1";
    var HEADER_SIG = [208, 207, 17, 224, 161, 177, 26, 225];
    var HEADER_CLSID = "00000000000000000000000000000000";
    var consts = {
      MAXREGSECT: -6,
      DIFSECT: -4,
      FATSECT: -3,
      ENDOFCHAIN,
      FREESECT: -1,
      HEADER_SIGNATURE,
      HEADER_MINOR_VERSION: "3e00",
      MAXREGSID: -6,
      NOSTREAM: -1,
      HEADER_CLSID,
      EntryTypes: ["unknown", "storage", "stream", "lockbytes", "property", "root"]
    };
    function write_file(cfb, filename2, options) {
      get_fs();
      var o2 = _write(cfb, options);
      fs.writeFileSync(filename2, o2);
    }
    function a2s2(o2) {
      var out = new Array(o2.length);
      for (var i2 = 0; i2 < o2.length; ++i2)
        out[i2] = String.fromCharCode(o2[i2]);
      return out.join("");
    }
    function write(cfb, options) {
      var o2 = _write(cfb, options);
      switch (options && options.type || "buffer") {
        case "file":
          get_fs();
          fs.writeFileSync(options.filename, o2);
          return o2;
        case "binary":
          return typeof o2 == "string" ? o2 : a2s2(o2);
        case "base64":
          return Base64_encode(typeof o2 == "string" ? o2 : a2s2(o2));
        case "buffer":
          if (has_buf)
            return Buffer.isBuffer(o2) ? o2 : Buffer_from(o2);
        case "array":
          return typeof o2 == "string" ? s2a(o2) : o2;
      }
      return o2;
    }
    var _zlib;
    function use_zlib(zlib) {
      try {
        var InflateRaw = zlib.InflateRaw;
        var InflRaw = new InflateRaw();
        InflRaw._processChunk(new Uint8Array([3, 0]), InflRaw._finishFlushFlag);
        if (InflRaw.bytesRead)
          _zlib = zlib;
        else
          throw new Error("zlib does not expose bytesRead");
      } catch (e) {
        console.error("cannot use native zlib: " + (e.message || e));
      }
    }
    function _inflateRawSync(payload, usz) {
      if (!_zlib)
        return _inflate(payload, usz);
      var InflateRaw = _zlib.InflateRaw;
      var InflRaw = new InflateRaw();
      var out = InflRaw._processChunk(payload.slice(payload.l), InflRaw._finishFlushFlag);
      payload.l += InflRaw.bytesRead;
      return out;
    }
    function _deflateRawSync(payload) {
      return _zlib ? _zlib.deflateRawSync(payload) : _deflate(payload);
    }
    var CLEN_ORDER = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
    var LEN_LN = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258];
    var DST_LN = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];
    function bit_swap_8(n) {
      var t = (n << 1 | n << 11) & 139536 | (n << 5 | n << 15) & 558144;
      return (t >> 16 | t >> 8 | t) & 255;
    }
    var use_typed_arrays = typeof Uint8Array !== "undefined";
    var bitswap8 = use_typed_arrays ? new Uint8Array(1 << 8) : [];
    for (var q2 = 0; q2 < 1 << 8; ++q2)
      bitswap8[q2] = bit_swap_8(q2);
    function bit_swap_n(n, b2) {
      var rev = bitswap8[n & 255];
      if (b2 <= 8)
        return rev >>> 8 - b2;
      rev = rev << 8 | bitswap8[n >> 8 & 255];
      if (b2 <= 16)
        return rev >>> 16 - b2;
      rev = rev << 8 | bitswap8[n >> 16 & 255];
      return rev >>> 24 - b2;
    }
    function read_bits_2(buf, bl) {
      var w2 = bl & 7, h2 = bl >>> 3;
      return (buf[h2] | (w2 <= 6 ? 0 : buf[h2 + 1] << 8)) >>> w2 & 3;
    }
    function read_bits_3(buf, bl) {
      var w2 = bl & 7, h2 = bl >>> 3;
      return (buf[h2] | (w2 <= 5 ? 0 : buf[h2 + 1] << 8)) >>> w2 & 7;
    }
    function read_bits_4(buf, bl) {
      var w2 = bl & 7, h2 = bl >>> 3;
      return (buf[h2] | (w2 <= 4 ? 0 : buf[h2 + 1] << 8)) >>> w2 & 15;
    }
    function read_bits_5(buf, bl) {
      var w2 = bl & 7, h2 = bl >>> 3;
      return (buf[h2] | (w2 <= 3 ? 0 : buf[h2 + 1] << 8)) >>> w2 & 31;
    }
    function read_bits_7(buf, bl) {
      var w2 = bl & 7, h2 = bl >>> 3;
      return (buf[h2] | (w2 <= 1 ? 0 : buf[h2 + 1] << 8)) >>> w2 & 127;
    }
    function read_bits_n(buf, bl, n) {
      var w2 = bl & 7, h2 = bl >>> 3, f2 = (1 << n) - 1;
      var v2 = buf[h2] >>> w2;
      if (n < 8 - w2)
        return v2 & f2;
      v2 |= buf[h2 + 1] << 8 - w2;
      if (n < 16 - w2)
        return v2 & f2;
      v2 |= buf[h2 + 2] << 16 - w2;
      if (n < 24 - w2)
        return v2 & f2;
      v2 |= buf[h2 + 3] << 24 - w2;
      return v2 & f2;
    }
    function write_bits_3(buf, bl, v2) {
      var w2 = bl & 7, h2 = bl >>> 3;
      if (w2 <= 5)
        buf[h2] |= (v2 & 7) << w2;
      else {
        buf[h2] |= v2 << w2 & 255;
        buf[h2 + 1] = (v2 & 7) >> 8 - w2;
      }
      return bl + 3;
    }
    function write_bits_1(buf, bl, v2) {
      var w2 = bl & 7, h2 = bl >>> 3;
      v2 = (v2 & 1) << w2;
      buf[h2] |= v2;
      return bl + 1;
    }
    function write_bits_8(buf, bl, v2) {
      var w2 = bl & 7, h2 = bl >>> 3;
      v2 <<= w2;
      buf[h2] |= v2 & 255;
      v2 >>>= 8;
      buf[h2 + 1] = v2;
      return bl + 8;
    }
    function write_bits_16(buf, bl, v2) {
      var w2 = bl & 7, h2 = bl >>> 3;
      v2 <<= w2;
      buf[h2] |= v2 & 255;
      v2 >>>= 8;
      buf[h2 + 1] = v2 & 255;
      buf[h2 + 2] = v2 >>> 8;
      return bl + 16;
    }
    function realloc(b2, sz) {
      var L = b2.length, M2 = 2 * L > sz ? 2 * L : sz + 5, i2 = 0;
      if (L >= sz)
        return b2;
      if (has_buf) {
        var o2 = new_unsafe_buf(M2);
        if (b2.copy)
          b2.copy(o2);
        else
          for (; i2 < b2.length; ++i2)
            o2[i2] = b2[i2];
        return o2;
      } else if (use_typed_arrays) {
        var a2 = new Uint8Array(M2);
        if (a2.set)
          a2.set(b2);
        else
          for (; i2 < L; ++i2)
            a2[i2] = b2[i2];
        return a2;
      }
      b2.length = M2;
      return b2;
    }
    function zero_fill_array(n) {
      var o2 = new Array(n);
      for (var i2 = 0; i2 < n; ++i2)
        o2[i2] = 0;
      return o2;
    }
    function build_tree(clens, cmap, MAX) {
      var maxlen = 1, w2 = 0, i2 = 0, j = 0, ccode = 0, L = clens.length;
      var bl_count = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);
      for (i2 = 0; i2 < 32; ++i2)
        bl_count[i2] = 0;
      for (i2 = L; i2 < MAX; ++i2)
        clens[i2] = 0;
      L = clens.length;
      var ctree = use_typed_arrays ? new Uint16Array(L) : zero_fill_array(L);
      for (i2 = 0; i2 < L; ++i2) {
        bl_count[w2 = clens[i2]]++;
        if (maxlen < w2)
          maxlen = w2;
        ctree[i2] = 0;
      }
      bl_count[0] = 0;
      for (i2 = 1; i2 <= maxlen; ++i2)
        bl_count[i2 + 16] = ccode = ccode + bl_count[i2 - 1] << 1;
      for (i2 = 0; i2 < L; ++i2) {
        ccode = clens[i2];
        if (ccode != 0)
          ctree[i2] = bl_count[ccode + 16]++;
      }
      var cleni = 0;
      for (i2 = 0; i2 < L; ++i2) {
        cleni = clens[i2];
        if (cleni != 0) {
          ccode = bit_swap_n(ctree[i2], maxlen) >> maxlen - cleni;
          for (j = (1 << maxlen + 4 - cleni) - 1; j >= 0; --j)
            cmap[ccode | j << cleni] = cleni & 15 | i2 << 4;
        }
      }
      return maxlen;
    }
    var fix_lmap = use_typed_arrays ? new Uint16Array(512) : zero_fill_array(512);
    var fix_dmap = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);
    if (!use_typed_arrays) {
      for (var i = 0; i < 512; ++i)
        fix_lmap[i] = 0;
      for (i = 0; i < 32; ++i)
        fix_dmap[i] = 0;
    }
    (function() {
      var dlens = [];
      var i2 = 0;
      for (; i2 < 32; i2++)
        dlens.push(5);
      build_tree(dlens, fix_dmap, 32);
      var clens = [];
      i2 = 0;
      for (; i2 <= 143; i2++)
        clens.push(8);
      for (; i2 <= 255; i2++)
        clens.push(9);
      for (; i2 <= 279; i2++)
        clens.push(7);
      for (; i2 <= 287; i2++)
        clens.push(8);
      build_tree(clens, fix_lmap, 288);
    })();
    var _deflateRaw = /* @__PURE__ */ function _deflateRawIIFE() {
      var DST_LN_RE = use_typed_arrays ? new Uint8Array(32768) : [];
      var j = 0, k = 0;
      for (; j < DST_LN.length - 1; ++j) {
        for (; k < DST_LN[j + 1]; ++k)
          DST_LN_RE[k] = j;
      }
      for (; k < 32768; ++k)
        DST_LN_RE[k] = 29;
      var LEN_LN_RE = use_typed_arrays ? new Uint8Array(259) : [];
      for (j = 0, k = 0; j < LEN_LN.length - 1; ++j) {
        for (; k < LEN_LN[j + 1]; ++k)
          LEN_LN_RE[k] = j;
      }
      function write_stored(data, out) {
        var boff = 0;
        while (boff < data.length) {
          var L = Math.min(65535, data.length - boff);
          var h2 = boff + L == data.length;
          out.write_shift(1, +h2);
          out.write_shift(2, L);
          out.write_shift(2, ~L & 65535);
          while (L-- > 0)
            out[out.l++] = data[boff++];
        }
        return out.l;
      }
      function write_huff_fixed(data, out) {
        var bl = 0;
        var boff = 0;
        var addrs = use_typed_arrays ? new Uint16Array(32768) : [];
        while (boff < data.length) {
          var L = Math.min(65535, data.length - boff);
          if (L < 10) {
            bl = write_bits_3(out, bl, +!!(boff + L == data.length));
            if (bl & 7)
              bl += 8 - (bl & 7);
            out.l = bl / 8 | 0;
            out.write_shift(2, L);
            out.write_shift(2, ~L & 65535);
            while (L-- > 0)
              out[out.l++] = data[boff++];
            bl = out.l * 8;
            continue;
          }
          bl = write_bits_3(out, bl, +!!(boff + L == data.length) + 2);
          var hash = 0;
          while (L-- > 0) {
            var d2 = data[boff];
            hash = (hash << 5 ^ d2) & 32767;
            var match = -1, mlen = 0;
            if (match = addrs[hash]) {
              match |= boff & ~32767;
              if (match > boff)
                match -= 32768;
              if (match < boff)
                while (data[match + mlen] == data[boff + mlen] && mlen < 250)
                  ++mlen;
            }
            if (mlen > 2) {
              d2 = LEN_LN_RE[mlen];
              if (d2 <= 22)
                bl = write_bits_8(out, bl, bitswap8[d2 + 1] >> 1) - 1;
              else {
                write_bits_8(out, bl, 3);
                bl += 5;
                write_bits_8(out, bl, bitswap8[d2 - 23] >> 5);
                bl += 3;
              }
              var len_eb = d2 < 8 ? 0 : d2 - 4 >> 2;
              if (len_eb > 0) {
                write_bits_16(out, bl, mlen - LEN_LN[d2]);
                bl += len_eb;
              }
              d2 = DST_LN_RE[boff - match];
              bl = write_bits_8(out, bl, bitswap8[d2] >> 3);
              bl -= 3;
              var dst_eb = d2 < 4 ? 0 : d2 - 2 >> 1;
              if (dst_eb > 0) {
                write_bits_16(out, bl, boff - match - DST_LN[d2]);
                bl += dst_eb;
              }
              for (var q3 = 0; q3 < mlen; ++q3) {
                addrs[hash] = boff & 32767;
                hash = (hash << 5 ^ data[boff]) & 32767;
                ++boff;
              }
              L -= mlen - 1;
            } else {
              if (d2 <= 143)
                d2 = d2 + 48;
              else
                bl = write_bits_1(out, bl, 1);
              bl = write_bits_8(out, bl, bitswap8[d2]);
              addrs[hash] = boff & 32767;
              ++boff;
            }
          }
          bl = write_bits_8(out, bl, 0) - 1;
        }
        out.l = (bl + 7) / 8 | 0;
        return out.l;
      }
      return function _deflateRaw2(data, out) {
        if (data.length < 8)
          return write_stored(data, out);
        return write_huff_fixed(data, out);
      };
    }();
    function _deflate(data) {
      var buf = new_buf(50 + Math.floor(data.length * 1.1));
      var off = _deflateRaw(data, buf);
      return buf.slice(0, off);
    }
    var dyn_lmap = use_typed_arrays ? new Uint16Array(32768) : zero_fill_array(32768);
    var dyn_dmap = use_typed_arrays ? new Uint16Array(32768) : zero_fill_array(32768);
    var dyn_cmap = use_typed_arrays ? new Uint16Array(128) : zero_fill_array(128);
    var dyn_len_1 = 1, dyn_len_2 = 1;
    function dyn(data, boff) {
      var _HLIT = read_bits_5(data, boff) + 257;
      boff += 5;
      var _HDIST = read_bits_5(data, boff) + 1;
      boff += 5;
      var _HCLEN = read_bits_4(data, boff) + 4;
      boff += 4;
      var w2 = 0;
      var clens = use_typed_arrays ? new Uint8Array(19) : zero_fill_array(19);
      var ctree = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      var maxlen = 1;
      var bl_count = use_typed_arrays ? new Uint8Array(8) : zero_fill_array(8);
      var next_code = use_typed_arrays ? new Uint8Array(8) : zero_fill_array(8);
      var L = clens.length;
      for (var i2 = 0; i2 < _HCLEN; ++i2) {
        clens[CLEN_ORDER[i2]] = w2 = read_bits_3(data, boff);
        if (maxlen < w2)
          maxlen = w2;
        bl_count[w2]++;
        boff += 3;
      }
      var ccode = 0;
      bl_count[0] = 0;
      for (i2 = 1; i2 <= maxlen; ++i2)
        next_code[i2] = ccode = ccode + bl_count[i2 - 1] << 1;
      for (i2 = 0; i2 < L; ++i2)
        if ((ccode = clens[i2]) != 0)
          ctree[i2] = next_code[ccode]++;
      var cleni = 0;
      for (i2 = 0; i2 < L; ++i2) {
        cleni = clens[i2];
        if (cleni != 0) {
          ccode = bitswap8[ctree[i2]] >> 8 - cleni;
          for (var j = (1 << 7 - cleni) - 1; j >= 0; --j)
            dyn_cmap[ccode | j << cleni] = cleni & 7 | i2 << 3;
        }
      }
      var hcodes = [];
      maxlen = 1;
      for (; hcodes.length < _HLIT + _HDIST; ) {
        ccode = dyn_cmap[read_bits_7(data, boff)];
        boff += ccode & 7;
        switch (ccode >>>= 3) {
          case 16:
            w2 = 3 + read_bits_2(data, boff);
            boff += 2;
            ccode = hcodes[hcodes.length - 1];
            while (w2-- > 0)
              hcodes.push(ccode);
            break;
          case 17:
            w2 = 3 + read_bits_3(data, boff);
            boff += 3;
            while (w2-- > 0)
              hcodes.push(0);
            break;
          case 18:
            w2 = 11 + read_bits_7(data, boff);
            boff += 7;
            while (w2-- > 0)
              hcodes.push(0);
            break;
          default:
            hcodes.push(ccode);
            if (maxlen < ccode)
              maxlen = ccode;
            break;
        }
      }
      var h1 = hcodes.slice(0, _HLIT), h2 = hcodes.slice(_HLIT);
      for (i2 = _HLIT; i2 < 286; ++i2)
        h1[i2] = 0;
      for (i2 = _HDIST; i2 < 30; ++i2)
        h2[i2] = 0;
      dyn_len_1 = build_tree(h1, dyn_lmap, 286);
      dyn_len_2 = build_tree(h2, dyn_dmap, 30);
      return boff;
    }
    function inflate(data, usz) {
      if (data[0] == 3 && !(data[1] & 3)) {
        return [new_raw_buf(usz), 2];
      }
      var boff = 0;
      var header = 0;
      var outbuf = new_unsafe_buf(usz ? usz : 1 << 18);
      var woff = 0;
      var OL = outbuf.length >>> 0;
      var max_len_1 = 0, max_len_2 = 0;
      while ((header & 1) == 0) {
        header = read_bits_3(data, boff);
        boff += 3;
        if (header >>> 1 == 0) {
          if (boff & 7)
            boff += 8 - (boff & 7);
          var sz = data[boff >>> 3] | data[(boff >>> 3) + 1] << 8;
          boff += 32;
          if (sz > 0) {
            if (!usz && OL < woff + sz) {
              outbuf = realloc(outbuf, woff + sz);
              OL = outbuf.length;
            }
            while (sz-- > 0) {
              outbuf[woff++] = data[boff >>> 3];
              boff += 8;
            }
          }
          continue;
        } else if (header >> 1 == 1) {
          max_len_1 = 9;
          max_len_2 = 5;
        } else {
          boff = dyn(data, boff);
          max_len_1 = dyn_len_1;
          max_len_2 = dyn_len_2;
        }
        for (; ; ) {
          if (!usz && OL < woff + 32767) {
            outbuf = realloc(outbuf, woff + 32767);
            OL = outbuf.length;
          }
          var bits = read_bits_n(data, boff, max_len_1);
          var code = header >>> 1 == 1 ? fix_lmap[bits] : dyn_lmap[bits];
          boff += code & 15;
          code >>>= 4;
          if ((code >>> 8 & 255) === 0)
            outbuf[woff++] = code;
          else if (code == 256)
            break;
          else {
            code -= 257;
            var len_eb = code < 8 ? 0 : code - 4 >> 2;
            if (len_eb > 5)
              len_eb = 0;
            var tgt = woff + LEN_LN[code];
            if (len_eb > 0) {
              tgt += read_bits_n(data, boff, len_eb);
              boff += len_eb;
            }
            bits = read_bits_n(data, boff, max_len_2);
            code = header >>> 1 == 1 ? fix_dmap[bits] : dyn_dmap[bits];
            boff += code & 15;
            code >>>= 4;
            var dst_eb = code < 4 ? 0 : code - 2 >> 1;
            var dst = DST_LN[code];
            if (dst_eb > 0) {
              dst += read_bits_n(data, boff, dst_eb);
              boff += dst_eb;
            }
            if (!usz && OL < tgt) {
              outbuf = realloc(outbuf, tgt + 100);
              OL = outbuf.length;
            }
            while (woff < tgt) {
              outbuf[woff] = outbuf[woff - dst];
              ++woff;
            }
          }
        }
      }
      if (usz)
        return [outbuf, boff + 7 >>> 3];
      return [outbuf.slice(0, woff), boff + 7 >>> 3];
    }
    function _inflate(payload, usz) {
      var data = payload.slice(payload.l || 0);
      var out = inflate(data, usz);
      payload.l += out[1];
      return out[0];
    }
    function warn_or_throw(wrn, msg) {
      if (wrn) {
        if (typeof console !== "undefined")
          console.error(msg);
      } else
        throw new Error(msg);
    }
    function parse_zip2(file, options) {
      var blob = file;
      prep_blob(blob, 0);
      var FileIndex = [], FullPaths = [];
      var o2 = {
        FileIndex,
        FullPaths
      };
      init_cfb(o2, { root: options.root });
      var i2 = blob.length - 4;
      while ((blob[i2] != 80 || blob[i2 + 1] != 75 || blob[i2 + 2] != 5 || blob[i2 + 3] != 6) && i2 >= 0)
        --i2;
      blob.l = i2 + 4;
      blob.l += 4;
      var fcnt = blob.read_shift(2);
      blob.l += 6;
      var start_cd = blob.read_shift(4);
      blob.l = start_cd;
      for (i2 = 0; i2 < fcnt; ++i2) {
        blob.l += 20;
        var csz = blob.read_shift(4);
        var usz = blob.read_shift(4);
        var namelen = blob.read_shift(2);
        var efsz = blob.read_shift(2);
        var fcsz = blob.read_shift(2);
        blob.l += 8;
        var offset = blob.read_shift(4);
        var EF = parse_extra_field(blob.slice(blob.l + namelen, blob.l + namelen + efsz));
        blob.l += namelen + efsz + fcsz;
        var L = blob.l;
        blob.l = offset + 4;
        parse_local_file(blob, csz, usz, o2, EF);
        blob.l = L;
      }
      return o2;
    }
    function parse_local_file(blob, csz, usz, o2, EF) {
      blob.l += 2;
      var flags = blob.read_shift(2);
      var meth = blob.read_shift(2);
      var date = parse_dos_date(blob);
      if (flags & 8257)
        throw new Error("Unsupported ZIP encryption");
      var crc32 = blob.read_shift(4);
      var _csz = blob.read_shift(4);
      var _usz = blob.read_shift(4);
      var namelen = blob.read_shift(2);
      var efsz = blob.read_shift(2);
      var name = "";
      for (var i2 = 0; i2 < namelen; ++i2)
        name += String.fromCharCode(blob[blob.l++]);
      if (efsz) {
        var ef = parse_extra_field(blob.slice(blob.l, blob.l + efsz));
        if ((ef[21589] || {}).mt)
          date = ef[21589].mt;
        if (((EF || {})[21589] || {}).mt)
          date = EF[21589].mt;
      }
      blob.l += efsz;
      var data = blob.slice(blob.l, blob.l + _csz);
      switch (meth) {
        case 8:
          data = _inflateRawSync(blob, _usz);
          break;
        case 0:
          break;
        default:
          throw new Error("Unsupported ZIP Compression method " + meth);
      }
      var wrn = false;
      if (flags & 8) {
        crc32 = blob.read_shift(4);
        if (crc32 == 134695760) {
          crc32 = blob.read_shift(4);
          wrn = true;
        }
        _csz = blob.read_shift(4);
        _usz = blob.read_shift(4);
      }
      if (_csz != csz)
        warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
      if (_usz != usz)
        warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
      cfb_add(o2, name, data, { unsafe: true, mt: date });
    }
    function write_zip2(cfb, options) {
      var _opts = options || {};
      var out = [], cdirs = [];
      var o2 = new_buf(1);
      var method = _opts.compression ? 8 : 0, flags = 0;
      var i2 = 0, j = 0;
      var start_cd = 0, fcnt = 0;
      var root2 = cfb.FullPaths[0], fp = root2, fi = cfb.FileIndex[0];
      var crcs = [];
      var sz_cd = 0;
      for (i2 = 1; i2 < cfb.FullPaths.length; ++i2) {
        fp = cfb.FullPaths[i2].slice(root2.length);
        fi = cfb.FileIndex[i2];
        if (!fi.size || !fi.content || fp == "Sh33tJ5")
          continue;
        var start = start_cd;
        var namebuf = new_buf(fp.length);
        for (j = 0; j < fp.length; ++j)
          namebuf.write_shift(1, fp.charCodeAt(j) & 127);
        namebuf = namebuf.slice(0, namebuf.l);
        crcs[fcnt] = CRC32.buf(fi.content, 0);
        var outbuf = fi.content;
        if (method == 8)
          outbuf = _deflateRawSync(outbuf);
        o2 = new_buf(30);
        o2.write_shift(4, 67324752);
        o2.write_shift(2, 20);
        o2.write_shift(2, flags);
        o2.write_shift(2, method);
        if (fi.mt)
          write_dos_date(o2, fi.mt);
        else
          o2.write_shift(4, 0);
        o2.write_shift(-4, crcs[fcnt]);
        o2.write_shift(4, outbuf.length);
        o2.write_shift(4, fi.content.length);
        o2.write_shift(2, namebuf.length);
        o2.write_shift(2, 0);
        start_cd += o2.length;
        out.push(o2);
        start_cd += namebuf.length;
        out.push(namebuf);
        start_cd += outbuf.length;
        out.push(outbuf);
        o2 = new_buf(46);
        o2.write_shift(4, 33639248);
        o2.write_shift(2, 0);
        o2.write_shift(2, 20);
        o2.write_shift(2, flags);
        o2.write_shift(2, method);
        o2.write_shift(4, 0);
        o2.write_shift(-4, crcs[fcnt]);
        o2.write_shift(4, outbuf.length);
        o2.write_shift(4, fi.content.length);
        o2.write_shift(2, namebuf.length);
        o2.write_shift(2, 0);
        o2.write_shift(2, 0);
        o2.write_shift(2, 0);
        o2.write_shift(2, 0);
        o2.write_shift(4, 0);
        o2.write_shift(4, start);
        sz_cd += o2.l;
        cdirs.push(o2);
        sz_cd += namebuf.length;
        cdirs.push(namebuf);
        ++fcnt;
      }
      o2 = new_buf(22);
      o2.write_shift(4, 101010256);
      o2.write_shift(2, 0);
      o2.write_shift(2, 0);
      o2.write_shift(2, fcnt);
      o2.write_shift(2, fcnt);
      o2.write_shift(4, sz_cd);
      o2.write_shift(4, start_cd);
      o2.write_shift(2, 0);
      return bconcat([bconcat(out), bconcat(cdirs), o2]);
    }
    var ContentTypeMap = {
      "htm": "text/html",
      "xml": "text/xml",
      "gif": "image/gif",
      "jpg": "image/jpeg",
      "png": "image/png",
      "mso": "application/x-mso",
      "thmx": "application/vnd.ms-officetheme",
      "sh33tj5": "application/octet-stream"
    };
    function get_content_type(fi, fp) {
      if (fi.ctype)
        return fi.ctype;
      var ext = fi.name || "", m2 = ext.match(/\.([^\.]+)$/);
      if (m2 && ContentTypeMap[m2[1]])
        return ContentTypeMap[m2[1]];
      if (fp) {
        m2 = (ext = fp).match(/[\.\\]([^\.\\])+$/);
        if (m2 && ContentTypeMap[m2[1]])
          return ContentTypeMap[m2[1]];
      }
      return "application/octet-stream";
    }
    function write_base64_76(bstr) {
      var data = Base64_encode(bstr);
      var o2 = [];
      for (var i2 = 0; i2 < data.length; i2 += 76)
        o2.push(data.slice(i2, i2 + 76));
      return o2.join("\r\n") + "\r\n";
    }
    function write_quoted_printable(text) {
      var encoded = text.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g, function(c2) {
        var w2 = c2.charCodeAt(0).toString(16).toUpperCase();
        return "=" + (w2.length == 1 ? "0" + w2 : w2);
      });
      encoded = encoded.replace(/ $/mg, "=20").replace(/\t$/mg, "=09");
      if (encoded.charAt(0) == "\n")
        encoded = "=0D" + encoded.slice(1);
      encoded = encoded.replace(/\r(?!\n)/mg, "=0D").replace(/\n\n/mg, "\n=0A").replace(/([^\r\n])\n/mg, "$1=0A");
      var o2 = [], split = encoded.split("\r\n");
      for (var si = 0; si < split.length; ++si) {
        var str = split[si];
        if (str.length == 0) {
          o2.push("");
          continue;
        }
        for (var i2 = 0; i2 < str.length; ) {
          var end = 76;
          var tmp = str.slice(i2, i2 + end);
          if (tmp.charAt(end - 1) == "=")
            end--;
          else if (tmp.charAt(end - 2) == "=")
            end -= 2;
          else if (tmp.charAt(end - 3) == "=")
            end -= 3;
          tmp = str.slice(i2, i2 + end);
          i2 += end;
          if (i2 < str.length)
            tmp += "=";
          o2.push(tmp);
        }
      }
      return o2.join("\r\n");
    }
    function parse_quoted_printable(data) {
      var o2 = [];
      for (var di = 0; di < data.length; ++di) {
        var line = data[di];
        while (di <= data.length && line.charAt(line.length - 1) == "=")
          line = line.slice(0, line.length - 1) + data[++di];
        o2.push(line);
      }
      for (var oi = 0; oi < o2.length; ++oi)
        o2[oi] = o2[oi].replace(/[=][0-9A-Fa-f]{2}/g, function($$) {
          return String.fromCharCode(parseInt($$.slice(1), 16));
        });
      return s2a(o2.join("\r\n"));
    }
    function parse_mime(cfb, data, root2) {
      var fname = "", cte = "", ctype = "", fdata;
      var di = 0;
      for (; di < 10; ++di) {
        var line = data[di];
        if (!line || line.match(/^\s*$/))
          break;
        var m2 = line.match(/^(.*?):\s*([^\s].*)$/);
        if (m2)
          switch (m2[1].toLowerCase()) {
            case "content-location":
              fname = m2[2].trim();
              break;
            case "content-type":
              ctype = m2[2].trim();
              break;
            case "content-transfer-encoding":
              cte = m2[2].trim();
              break;
          }
      }
      ++di;
      switch (cte.toLowerCase()) {
        case "base64":
          fdata = s2a(Base64_decode(data.slice(di).join("")));
          break;
        case "quoted-printable":
          fdata = parse_quoted_printable(data.slice(di));
          break;
        default:
          throw new Error("Unsupported Content-Transfer-Encoding " + cte);
      }
      var file = cfb_add(cfb, fname.slice(root2.length), fdata, { unsafe: true });
      if (ctype)
        file.ctype = ctype;
    }
    function parse_mad(file, options) {
      if (a2s2(file.slice(0, 13)).toLowerCase() != "mime-version:")
        throw new Error("Unsupported MAD header");
      var root2 = options && options.root || "";
      var data = (has_buf && Buffer.isBuffer(file) ? file.toString("binary") : a2s2(file)).split("\r\n");
      var di = 0, row = "";
      for (di = 0; di < data.length; ++di) {
        row = data[di];
        if (!/^Content-Location:/i.test(row))
          continue;
        row = row.slice(row.indexOf("file"));
        if (!root2)
          root2 = row.slice(0, row.lastIndexOf("/") + 1);
        if (row.slice(0, root2.length) == root2)
          continue;
        while (root2.length > 0) {
          root2 = root2.slice(0, root2.length - 1);
          root2 = root2.slice(0, root2.lastIndexOf("/") + 1);
          if (row.slice(0, root2.length) == root2)
            break;
        }
      }
      var mboundary = (data[1] || "").match(/boundary="(.*?)"/);
      if (!mboundary)
        throw new Error("MAD cannot find boundary");
      var boundary = "--" + (mboundary[1] || "");
      var FileIndex = [], FullPaths = [];
      var o2 = {
        FileIndex,
        FullPaths
      };
      init_cfb(o2);
      var start_di, fcnt = 0;
      for (di = 0; di < data.length; ++di) {
        var line = data[di];
        if (line !== boundary && line !== boundary + "--")
          continue;
        if (fcnt++)
          parse_mime(o2, data.slice(start_di, di), root2);
        start_di = di;
      }
      return o2;
    }
    function write_mad(cfb, options) {
      var opts = options || {};
      var boundary = opts.boundary || "SheetJS";
      boundary = "------=" + boundary;
      var out = [
        "MIME-Version: 1.0",
        'Content-Type: multipart/related; boundary="' + boundary.slice(2) + '"',
        "",
        "",
        ""
      ];
      var root2 = cfb.FullPaths[0], fp = root2, fi = cfb.FileIndex[0];
      for (var i2 = 1; i2 < cfb.FullPaths.length; ++i2) {
        fp = cfb.FullPaths[i2].slice(root2.length);
        fi = cfb.FileIndex[i2];
        if (!fi.size || !fi.content || fp == "Sh33tJ5")
          continue;
        fp = fp.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g, function(c2) {
          return "_x" + c2.charCodeAt(0).toString(16) + "_";
        }).replace(/[\u0080-\uFFFF]/g, function(u2) {
          return "_u" + u2.charCodeAt(0).toString(16) + "_";
        });
        var ca = fi.content;
        var cstr = has_buf && Buffer.isBuffer(ca) ? ca.toString("binary") : a2s2(ca);
        var dispcnt = 0, L = Math.min(1024, cstr.length), cc = 0;
        for (var csl = 0; csl <= L; ++csl)
          if ((cc = cstr.charCodeAt(csl)) >= 32 && cc < 128)
            ++dispcnt;
        var qp = dispcnt >= L * 4 / 5;
        out.push(boundary);
        out.push("Content-Location: " + (opts.root || "file:///C:/SheetJS/") + fp);
        out.push("Content-Transfer-Encoding: " + (qp ? "quoted-printable" : "base64"));
        out.push("Content-Type: " + get_content_type(fi, fp));
        out.push("");
        out.push(qp ? write_quoted_printable(cstr) : write_base64_76(cstr));
      }
      out.push(boundary + "--\r\n");
      return out.join("\r\n");
    }
    function cfb_new(opts) {
      var o2 = {};
      init_cfb(o2, opts);
      return o2;
    }
    function cfb_add(cfb, name, content, opts) {
      var unsafe = opts && opts.unsafe;
      if (!unsafe)
        init_cfb(cfb);
      var file = !unsafe && CFB.find(cfb, name);
      if (!file) {
        var fpath = cfb.FullPaths[0];
        if (name.slice(0, fpath.length) == fpath)
          fpath = name;
        else {
          if (fpath.slice(-1) != "/")
            fpath += "/";
          fpath = (fpath + name).replace("//", "/");
        }
        file = { name: filename(name), type: 2 };
        cfb.FileIndex.push(file);
        cfb.FullPaths.push(fpath);
        if (!unsafe)
          CFB.utils.cfb_gc(cfb);
      }
      file.content = content;
      file.size = content ? content.length : 0;
      if (opts) {
        if (opts.CLSID)
          file.clsid = opts.CLSID;
        if (opts.mt)
          file.mt = opts.mt;
        if (opts.ct)
          file.ct = opts.ct;
      }
      return file;
    }
    function cfb_del(cfb, name) {
      init_cfb(cfb);
      var file = CFB.find(cfb, name);
      if (file) {
        for (var j = 0; j < cfb.FileIndex.length; ++j)
          if (cfb.FileIndex[j] == file) {
            cfb.FileIndex.splice(j, 1);
            cfb.FullPaths.splice(j, 1);
            return true;
          }
      }
      return false;
    }
    function cfb_mov(cfb, old_name, new_name) {
      init_cfb(cfb);
      var file = CFB.find(cfb, old_name);
      if (file) {
        for (var j = 0; j < cfb.FileIndex.length; ++j)
          if (cfb.FileIndex[j] == file) {
            cfb.FileIndex[j].name = filename(new_name);
            cfb.FullPaths[j] = new_name;
            return true;
          }
      }
      return false;
    }
    function cfb_gc(cfb) {
      rebuild_cfb(cfb, true);
    }
    exports2.find = find;
    exports2.read = read;
    exports2.parse = parse;
    exports2.write = write;
    exports2.writeFile = write_file;
    exports2.utils = {
      cfb_new,
      cfb_add,
      cfb_del,
      cfb_mov,
      cfb_gc,
      ReadShift,
      CheckField,
      prep_blob,
      bconcat,
      use_zlib,
      _deflateRaw: _deflate,
      _inflateRaw: _inflate,
      consts
    };
    return exports2;
  }();
  function blobify(data) {
    if (typeof data === "string")
      return s2ab(data);
    if (Array.isArray(data))
      return a2u(data);
    return data;
  }
  function write_dl(fname, payload, enc) {
    if (typeof Deno !== "undefined") {
      if (enc && typeof payload == "string")
        switch (enc) {
          case "utf8":
            payload = new TextEncoder(enc).encode(payload);
            break;
          case "binary":
            payload = s2ab(payload);
            break;
          default:
            throw new Error("Unsupported encoding " + enc);
        }
      return Deno.writeFileSync(fname, payload);
    }
    var data = enc == "utf8" ? utf8write(payload) : payload;
    if (typeof IE_SaveFile !== "undefined")
      return IE_SaveFile(data, fname);
    if (typeof Blob !== "undefined") {
      var blob = new Blob([blobify(data)], { type: "application/octet-stream" });
      if (typeof navigator !== "undefined" && navigator.msSaveBlob)
        return navigator.msSaveBlob(blob, fname);
      if (typeof saveAs !== "undefined")
        return saveAs(blob, fname);
      if (typeof URL !== "undefined" && typeof document !== "undefined" && document.createElement && URL.createObjectURL) {
        var url = URL.createObjectURL(blob);
        if (typeof chrome === "object" && typeof (chrome.downloads || {}).download == "function") {
          if (URL.revokeObjectURL && typeof setTimeout !== "undefined")
            setTimeout(function() {
              URL.revokeObjectURL(url);
            }, 6e4);
          return chrome.downloads.download({ url, filename: fname, saveAs: true });
        }
        var a2 = document.createElement("a");
        if (a2.download != null) {
          a2.download = fname;
          a2.href = url;
          document.body.appendChild(a2);
          a2.click();
          document.body.removeChild(a2);
          if (URL.revokeObjectURL && typeof setTimeout !== "undefined")
            setTimeout(function() {
              URL.revokeObjectURL(url);
            }, 6e4);
          return url;
        }
      }
    }
    if (typeof $ !== "undefined" && typeof File !== "undefined" && typeof Folder !== "undefined")
      try {
        var out = File(fname);
        out.open("w");
        out.encoding = "binary";
        if (Array.isArray(payload))
          payload = a2s(payload);
        out.write(payload);
        out.close();
        return payload;
      } catch (e) {
        if (!e.message || !e.message.match(/onstruct/))
          throw e;
      }
    throw new Error("cannot save file " + fname);
  }
  function read_binary(path) {
    if (typeof Deno !== "undefined")
      return Deno.readFileSync(path);
    if (typeof $ !== "undefined" && typeof File !== "undefined" && typeof Folder !== "undefined")
      try {
        var infile = File(path);
        infile.open("r");
        infile.encoding = "binary";
        var data = infile.read();
        infile.close();
        return data;
      } catch (e) {
        if (!e.message || !e.message.match(/onstruct/))
          throw e;
      }
    throw new Error("Cannot access file " + path);
  }
  function keys$1(o2) {
    var ks = Object.keys(o2), o22 = [];
    for (var i = 0; i < ks.length; ++i)
      if (Object.prototype.hasOwnProperty.call(o2, ks[i]))
        o22.push(ks[i]);
    return o22;
  }
  function evert_key(obj, key) {
    var o2 = [], K2 = keys$1(obj);
    for (var i = 0; i !== K2.length; ++i)
      if (o2[obj[K2[i]][key]] == null)
        o2[obj[K2[i]][key]] = K2[i];
    return o2;
  }
  function evert(obj) {
    var o2 = [], K2 = keys$1(obj);
    for (var i = 0; i !== K2.length; ++i)
      o2[obj[K2[i]]] = K2[i];
    return o2;
  }
  function evert_num(obj) {
    var o2 = [], K2 = keys$1(obj);
    for (var i = 0; i !== K2.length; ++i)
      o2[obj[K2[i]]] = parseInt(K2[i], 10);
    return o2;
  }
  function evert_arr(obj) {
    var o2 = [], K2 = keys$1(obj);
    for (var i = 0; i !== K2.length; ++i) {
      if (o2[obj[K2[i]]] == null)
        o2[obj[K2[i]]] = [];
      o2[obj[K2[i]]].push(K2[i]);
    }
    return o2;
  }
  var basedate = /* @__PURE__ */ new Date(1899, 11, 30, 0, 0, 0);
  function datenum(v2, date1904) {
    var epoch = /* @__PURE__ */ v2.getTime();
    if (date1904)
      epoch -= 1462 * 24 * 60 * 60 * 1e3;
    var dnthresh2 = /* @__PURE__ */ basedate.getTime() + (/* @__PURE__ */ v2.getTimezoneOffset() - /* @__PURE__ */ basedate.getTimezoneOffset()) * 6e4;
    return (epoch - dnthresh2) / (24 * 60 * 60 * 1e3);
  }
  var refdate = /* @__PURE__ */ new Date();
  var dnthresh = /* @__PURE__ */ basedate.getTime() + (/* @__PURE__ */ refdate.getTimezoneOffset() - /* @__PURE__ */ basedate.getTimezoneOffset()) * 6e4;
  var refoffset = /* @__PURE__ */ refdate.getTimezoneOffset();
  function numdate(v2) {
    var out = new Date();
    out.setTime(v2 * 24 * 60 * 60 * 1e3 + dnthresh);
    if (out.getTimezoneOffset() !== refoffset) {
      out.setTime(out.getTime() + (out.getTimezoneOffset() - refoffset) * 6e4);
    }
    return out;
  }
  function parse_isodur(s2) {
    var sec = 0, mt2 = 0, time = false;
    var m2 = s2.match(/P([0-9\.]+Y)?([0-9\.]+M)?([0-9\.]+D)?T([0-9\.]+H)?([0-9\.]+M)?([0-9\.]+S)?/);
    if (!m2)
      throw new Error("|" + s2 + "| is not an ISO8601 Duration");
    for (var i = 1; i != m2.length; ++i) {
      if (!m2[i])
        continue;
      mt2 = 1;
      if (i > 3)
        time = true;
      switch (m2[i].slice(m2[i].length - 1)) {
        case "Y":
          throw new Error("Unsupported ISO Duration Field: " + m2[i].slice(m2[i].length - 1));
        case "D":
          mt2 *= 24;
        case "H":
          mt2 *= 60;
        case "M":
          if (!time)
            throw new Error("Unsupported ISO Duration Field: M");
          else
            mt2 *= 60;
      }
      sec += mt2 * parseInt(m2[i], 10);
    }
    return sec;
  }
  var good_pd_date_1 = /* @__PURE__ */ new Date("2017-02-19T19:06:09.000Z");
  var good_pd_date = /* @__PURE__ */ isNaN(/* @__PURE__ */ good_pd_date_1.getFullYear()) ? /* @__PURE__ */ new Date("2/19/17") : good_pd_date_1;
  var good_pd = /* @__PURE__ */ good_pd_date.getFullYear() == 2017;
  function parseDate(str, fixdate) {
    var d2 = new Date(str);
    if (good_pd) {
      if (fixdate > 0)
        d2.setTime(d2.getTime() + d2.getTimezoneOffset() * 60 * 1e3);
      else if (fixdate < 0)
        d2.setTime(d2.getTime() - d2.getTimezoneOffset() * 60 * 1e3);
      return d2;
    }
    if (str instanceof Date)
      return str;
    if (good_pd_date.getFullYear() == 1917 && !isNaN(d2.getFullYear())) {
      var s2 = d2.getFullYear();
      if (str.indexOf("" + s2) > -1)
        return d2;
      d2.setFullYear(d2.getFullYear() + 100);
      return d2;
    }
    var n = str.match(/\d+/g) || ["2017", "2", "19", "0", "0", "0"];
    var out = new Date(+n[0], +n[1] - 1, +n[2], +n[3] || 0, +n[4] || 0, +n[5] || 0);
    if (str.indexOf("Z") > -1)
      out = new Date(out.getTime() - out.getTimezoneOffset() * 60 * 1e3);
    return out;
  }
  function cc2str(arr, debomit) {
    if (has_buf && Buffer.isBuffer(arr)) {
      if (debomit) {
        if (arr[0] == 255 && arr[1] == 254)
          return utf8write(arr.slice(2).toString("utf16le"));
        if (arr[1] == 254 && arr[2] == 255)
          return utf8write(utf16beread(arr.slice(2).toString("binary")));
      }
      return arr.toString("binary");
    }
    if (typeof TextDecoder !== "undefined")
      try {
        if (debomit) {
          if (arr[0] == 255 && arr[1] == 254)
            return utf8write(new TextDecoder("utf-16le").decode(arr.slice(2)));
          if (arr[0] == 254 && arr[1] == 255)
            return utf8write(new TextDecoder("utf-16be").decode(arr.slice(2)));
        }
        var rev = {
          "\u20AC": "\x80",
          "\u201A": "\x82",
          "\u0192": "\x83",
          "\u201E": "\x84",
          "\u2026": "\x85",
          "\u2020": "\x86",
          "\u2021": "\x87",
          "\u02C6": "\x88",
          "\u2030": "\x89",
          "\u0160": "\x8A",
          "\u2039": "\x8B",
          "\u0152": "\x8C",
          "\u017D": "\x8E",
          "\u2018": "\x91",
          "\u2019": "\x92",
          "\u201C": "\x93",
          "\u201D": "\x94",
          "\u2022": "\x95",
          "\u2013": "\x96",
          "\u2014": "\x97",
          "\u02DC": "\x98",
          "\u2122": "\x99",
          "\u0161": "\x9A",
          "\u203A": "\x9B",
          "\u0153": "\x9C",
          "\u017E": "\x9E",
          "\u0178": "\x9F"
        };
        if (Array.isArray(arr))
          arr = new Uint8Array(arr);
        return new TextDecoder("latin1").decode(arr).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g, function(c2) {
          return rev[c2] || c2;
        });
      } catch (e) {
      }
    var o2 = [];
    for (var i = 0; i != arr.length; ++i)
      o2.push(String.fromCharCode(arr[i]));
    return o2.join("");
  }
  function dup(o2) {
    if (typeof JSON != "undefined" && !Array.isArray(o2))
      return JSON.parse(JSON.stringify(o2));
    if (typeof o2 != "object" || o2 == null)
      return o2;
    if (o2 instanceof Date)
      return new Date(o2.getTime());
    var out = {};
    for (var k in o2)
      if (Object.prototype.hasOwnProperty.call(o2, k))
        out[k] = dup(o2[k]);
    return out;
  }
  function fill(c2, l2) {
    var o2 = "";
    while (o2.length < l2)
      o2 += c2;
    return o2;
  }
  function fuzzynum(s2) {
    var v2 = Number(s2);
    if (!isNaN(v2))
      return isFinite(v2) ? v2 : NaN;
    if (!/\d/.test(s2))
      return v2;
    var wt2 = 1;
    var ss = s2.replace(/([\d]),([\d])/g, "$1$2").replace(/[$]/g, "").replace(/[%]/g, function() {
      wt2 *= 100;
      return "";
    });
    if (!isNaN(v2 = Number(ss)))
      return v2 / wt2;
    ss = ss.replace(/[(](.*)[)]/, function($$, $1) {
      wt2 = -wt2;
      return $1;
    });
    if (!isNaN(v2 = Number(ss)))
      return v2 / wt2;
    return v2;
  }
  var lower_months = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
  function fuzzydate(s2) {
    var o2 = new Date(s2), n = new Date(NaN);
    var y = o2.getYear(), m2 = o2.getMonth(), d2 = o2.getDate();
    if (isNaN(d2))
      return n;
    var lower = s2.toLowerCase();
    if (lower.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)) {
      lower = lower.replace(/[^a-z]/g, "").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/, "");
      if (lower.length > 3 && lower_months.indexOf(lower) == -1)
        return n;
    } else if (lower.match(/[a-z]/))
      return n;
    if (y < 0 || y > 8099)
      return n;
    if ((m2 > 0 || d2 > 1) && y != 101)
      return o2;
    if (s2.match(/[^-0-9:,\/\\]/))
      return n;
    return o2;
  }
  var split_regex = /* @__PURE__ */ function() {
    var safe_split_regex = "abacaba".split(/(:?b)/i).length == 5;
    return function split_regex2(str, re, def2) {
      if (safe_split_regex || typeof re == "string")
        return str.split(re);
      var p2 = str.split(re), o2 = [p2[0]];
      for (var i = 1; i < p2.length; ++i) {
        o2.push(def2);
        o2.push(p2[i]);
      }
      return o2;
    };
  }();
  function getdatastr(data) {
    if (!data)
      return null;
    if (data.content && data.type)
      return cc2str(data.content, true);
    if (data.data)
      return debom(data.data);
    if (data.asNodeBuffer && has_buf)
      return debom(data.asNodeBuffer().toString("binary"));
    if (data.asBinary)
      return debom(data.asBinary());
    if (data._data && data._data.getContent)
      return debom(cc2str(Array.prototype.slice.call(data._data.getContent(), 0)));
    return null;
  }
  function getdatabin(data) {
    if (!data)
      return null;
    if (data.data)
      return char_codes(data.data);
    if (data.asNodeBuffer && has_buf)
      return data.asNodeBuffer();
    if (data._data && data._data.getContent) {
      var o2 = data._data.getContent();
      if (typeof o2 == "string")
        return char_codes(o2);
      return Array.prototype.slice.call(o2);
    }
    if (data.content && data.type)
      return data.content;
    return null;
  }
  function getdata(data) {
    return data && data.name.slice(-4) === ".bin" ? getdatabin(data) : getdatastr(data);
  }
  function safegetzipfile(zip, file) {
    var k = zip.FullPaths || keys$1(zip.files);
    var f2 = file.toLowerCase().replace(/[\/]/g, "\\"), g = f2.replace(/\\/g, "/");
    for (var i = 0; i < k.length; ++i) {
      var n = k[i].replace(/^Root Entry[\/]/, "").toLowerCase();
      if (f2 == n || g == n)
        return zip.files ? zip.files[k[i]] : zip.FileIndex[i];
    }
    return null;
  }
  function getzipfile(zip, file) {
    var o2 = safegetzipfile(zip, file);
    if (o2 == null)
      throw new Error("Cannot find file " + file + " in zip");
    return o2;
  }
  function getzipdata(zip, file, safe) {
    if (!safe)
      return getdata(getzipfile(zip, file));
    if (!file)
      return null;
    try {
      return getzipdata(zip, file);
    } catch (e) {
      return null;
    }
  }
  function getzipstr(zip, file, safe) {
    if (!safe)
      return getdatastr(getzipfile(zip, file));
    if (!file)
      return null;
    try {
      return getzipstr(zip, file);
    } catch (e) {
      return null;
    }
  }
  function getzipbin(zip, file, safe) {
    if (!safe)
      return getdatabin(getzipfile(zip, file));
    if (!file)
      return null;
    try {
      return getzipbin(zip, file);
    } catch (e) {
      return null;
    }
  }
  function zipentries(zip) {
    var k = zip.FullPaths || keys$1(zip.files), o2 = [];
    for (var i = 0; i < k.length; ++i)
      if (k[i].slice(-1) != "/")
        o2.push(k[i].replace(/^Root Entry[\/]/, ""));
    return o2.sort();
  }
  function zip_add_file(zip, path, content) {
    if (zip.FullPaths) {
      if (typeof content == "string") {
        var res;
        if (has_buf)
          res = Buffer_from(content);
        else
          res = utf8decode(content);
        return CFB.utils.cfb_add(zip, path, res);
      }
      CFB.utils.cfb_add(zip, path, content);
    } else
      zip.file(path, content);
  }
  function zip_new() {
    return CFB.utils.cfb_new();
  }
  function zip_read(d2, o2) {
    switch (o2.type) {
      case "base64":
        return CFB.read(d2, { type: "base64" });
      case "binary":
        return CFB.read(d2, { type: "binary" });
      case "buffer":
      case "array":
        return CFB.read(d2, { type: "buffer" });
    }
    throw new Error("Unrecognized type " + o2.type);
  }
  function resolve_path(path, base) {
    if (path.charAt(0) == "/")
      return path.slice(1);
    var result = base.split("/");
    if (base.slice(-1) != "/")
      result.pop();
    var target = path.split("/");
    while (target.length !== 0) {
      var step = target.shift();
      if (step === "..")
        result.pop();
      else if (step !== ".")
        result.push(step);
    }
    return result.join("/");
  }
  var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
  var attregexg = /([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
  var tagregex1 = /<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg, tagregex2 = /<[^>]*>/g;
  var tagregex = /* @__PURE__ */ XML_HEADER.match(tagregex1) ? tagregex1 : tagregex2;
  var nsregex = /<\w*:/, nsregex2 = /<(\/?)\w+:/;
  function parsexmltag(tag, skip_root, skip_LC) {
    var z = {};
    var eq2 = 0, c2 = 0;
    for (; eq2 !== tag.length; ++eq2)
      if ((c2 = tag.charCodeAt(eq2)) === 32 || c2 === 10 || c2 === 13)
        break;
    if (!skip_root)
      z[0] = tag.slice(0, eq2);
    if (eq2 === tag.length)
      return z;
    var m2 = tag.match(attregexg), j = 0, v2 = "", i = 0, q2 = "", cc = "", quot = 1;
    if (m2)
      for (i = 0; i != m2.length; ++i) {
        cc = m2[i];
        for (c2 = 0; c2 != cc.length; ++c2)
          if (cc.charCodeAt(c2) === 61)
            break;
        q2 = cc.slice(0, c2).trim();
        while (cc.charCodeAt(c2 + 1) == 32)
          ++c2;
        quot = (eq2 = cc.charCodeAt(c2 + 1)) == 34 || eq2 == 39 ? 1 : 0;
        v2 = cc.slice(c2 + 1 + quot, cc.length - quot);
        for (j = 0; j != q2.length; ++j)
          if (q2.charCodeAt(j) === 58)
            break;
        if (j === q2.length) {
          if (q2.indexOf("_") > 0)
            q2 = q2.slice(0, q2.indexOf("_"));
          z[q2] = v2;
          if (!skip_LC)
            z[q2.toLowerCase()] = v2;
        } else {
          var k = (j === 5 && q2.slice(0, 5) === "xmlns" ? "xmlns" : "") + q2.slice(j + 1);
          if (z[k] && q2.slice(j - 3, j) == "ext")
            continue;
          z[k] = v2;
          if (!skip_LC)
            z[k.toLowerCase()] = v2;
        }
      }
    return z;
  }
  function strip_ns(x2) {
    return x2.replace(nsregex2, "<$1");
  }
  var encodings = {
    "&quot;": '"',
    "&apos;": "'",
    "&gt;": ">",
    "&lt;": "<",
    "&amp;": "&"
  };
  var rencoding = /* @__PURE__ */ evert(encodings);
  var unescapexml = /* @__PURE__ */ function() {
    var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/ig, coderegex = /_x([\da-fA-F]{4})_/ig;
    return function unescapexml2(text) {
      var s2 = text + "", i = s2.indexOf("<![CDATA[");
      if (i == -1)
        return s2.replace(encregex, function($$, $1) {
          return encodings[$$] || String.fromCharCode(parseInt($1, $$.indexOf("x") > -1 ? 16 : 10)) || $$;
        }).replace(coderegex, function(m2, c2) {
          return String.fromCharCode(parseInt(c2, 16));
        });
      var j = s2.indexOf("]]>");
      return unescapexml2(s2.slice(0, i)) + s2.slice(i + 9, j) + unescapexml2(s2.slice(j + 3));
    };
  }();
  var decregex = /[&<>'"]/g, charegex = /[\u0000-\u0008\u000b-\u001f]/g;
  function escapexml(text) {
    var s2 = text + "";
    return s2.replace(decregex, function(y) {
      return rencoding[y];
    }).replace(charegex, function(s3) {
      return "_x" + ("000" + s3.charCodeAt(0).toString(16)).slice(-4) + "_";
    });
  }
  function escapexmltag(text) {
    return escapexml(text).replace(/ /g, "_x0020_");
  }
  var htmlcharegex = /[\u0000-\u001f]/g;
  function escapehtml(text) {
    var s2 = text + "";
    return s2.replace(decregex, function(y) {
      return rencoding[y];
    }).replace(/\n/g, "<br/>").replace(htmlcharegex, function(s3) {
      return "&#x" + ("000" + s3.charCodeAt(0).toString(16)).slice(-4) + ";";
    });
  }
  function escapexlml(text) {
    var s2 = text + "";
    return s2.replace(decregex, function(y) {
      return rencoding[y];
    }).replace(htmlcharegex, function(s3) {
      return "&#x" + s3.charCodeAt(0).toString(16).toUpperCase() + ";";
    });
  }
  var xlml_fixstr = /* @__PURE__ */ function() {
    var entregex = /&#(\d+);/g;
    function entrepl($$, $1) {
      return String.fromCharCode(parseInt($1, 10));
    }
    return function xlml_fixstr2(str) {
      return str.replace(entregex, entrepl);
    };
  }();
  function xlml_unfixstr(str) {
    return str.replace(/(\r\n|[\r\n])/g, "&#10;");
  }
  function parsexmlbool(value) {
    switch (value) {
      case 1:
      case true:
      case "1":
      case "true":
      case "TRUE":
        return true;
      default:
        return false;
    }
  }
  function utf8reada(orig) {
    var out = "", i = 0, c2 = 0, d2 = 0, e = 0, f2 = 0, w2 = 0;
    while (i < orig.length) {
      c2 = orig.charCodeAt(i++);
      if (c2 < 128) {
        out += String.fromCharCode(c2);
        continue;
      }
      d2 = orig.charCodeAt(i++);
      if (c2 > 191 && c2 < 224) {
        f2 = (c2 & 31) << 6;
        f2 |= d2 & 63;
        out += String.fromCharCode(f2);
        continue;
      }
      e = orig.charCodeAt(i++);
      if (c2 < 240) {
        out += String.fromCharCode((c2 & 15) << 12 | (d2 & 63) << 6 | e & 63);
        continue;
      }
      f2 = orig.charCodeAt(i++);
      w2 = ((c2 & 7) << 18 | (d2 & 63) << 12 | (e & 63) << 6 | f2 & 63) - 65536;
      out += String.fromCharCode(55296 + (w2 >>> 10 & 1023));
      out += String.fromCharCode(56320 + (w2 & 1023));
    }
    return out;
  }
  function utf8readb(data) {
    var out = new_raw_buf(2 * data.length), w2, i, j = 1, k = 0, ww = 0, c2;
    for (i = 0; i < data.length; i += j) {
      j = 1;
      if ((c2 = data.charCodeAt(i)) < 128)
        w2 = c2;
      else if (c2 < 224) {
        w2 = (c2 & 31) * 64 + (data.charCodeAt(i + 1) & 63);
        j = 2;
      } else if (c2 < 240) {
        w2 = (c2 & 15) * 4096 + (data.charCodeAt(i + 1) & 63) * 64 + (data.charCodeAt(i + 2) & 63);
        j = 3;
      } else {
        j = 4;
        w2 = (c2 & 7) * 262144 + (data.charCodeAt(i + 1) & 63) * 4096 + (data.charCodeAt(i + 2) & 63) * 64 + (data.charCodeAt(i + 3) & 63);
        w2 -= 65536;
        ww = 55296 + (w2 >>> 10 & 1023);
        w2 = 56320 + (w2 & 1023);
      }
      if (ww !== 0) {
        out[k++] = ww & 255;
        out[k++] = ww >>> 8;
        ww = 0;
      }
      out[k++] = w2 % 256;
      out[k++] = w2 >>> 8;
    }
    return out.slice(0, k).toString("ucs2");
  }
  function utf8readc(data) {
    return Buffer_from(data, "binary").toString("utf8");
  }
  var utf8corpus = "foo bar baz\xE2\x98\x83\xF0\x9F\x8D\xA3";
  var utf8read = has_buf && (/* @__PURE__ */ utf8readc(utf8corpus) == /* @__PURE__ */ utf8reada(utf8corpus) && utf8readc || /* @__PURE__ */ utf8readb(utf8corpus) == /* @__PURE__ */ utf8reada(utf8corpus) && utf8readb) || utf8reada;
  var utf8write = has_buf ? function(data) {
    return Buffer_from(data, "utf8").toString("binary");
  } : function(orig) {
    var out = [], i = 0, c2 = 0, d2 = 0;
    while (i < orig.length) {
      c2 = orig.charCodeAt(i++);
      switch (true) {
        case c2 < 128:
          out.push(String.fromCharCode(c2));
          break;
        case c2 < 2048:
          out.push(String.fromCharCode(192 + (c2 >> 6)));
          out.push(String.fromCharCode(128 + (c2 & 63)));
          break;
        case (c2 >= 55296 && c2 < 57344):
          c2 -= 55296;
          d2 = orig.charCodeAt(i++) - 56320 + (c2 << 10);
          out.push(String.fromCharCode(240 + (d2 >> 18 & 7)));
          out.push(String.fromCharCode(144 + (d2 >> 12 & 63)));
          out.push(String.fromCharCode(128 + (d2 >> 6 & 63)));
          out.push(String.fromCharCode(128 + (d2 & 63)));
          break;
        default:
          out.push(String.fromCharCode(224 + (c2 >> 12)));
          out.push(String.fromCharCode(128 + (c2 >> 6 & 63)));
          out.push(String.fromCharCode(128 + (c2 & 63)));
      }
    }
    return out.join("");
  };
  var matchtag = /* @__PURE__ */ function() {
    var mtcache = {};
    return function matchtag2(f2, g) {
      var t = f2 + "|" + (g || "");
      if (mtcache[t])
        return mtcache[t];
      return mtcache[t] = new RegExp("<(?:\\w+:)?" + f2 + '(?: xml:space="preserve")?(?:[^>]*)>([\\s\\S]*?)</(?:\\w+:)?' + f2 + ">", g || "");
    };
  }();
  var htmldecode = /* @__PURE__ */ function() {
    var entities = [
      ["nbsp", " "],
      ["middot", "\xB7"],
      ["quot", '"'],
      ["apos", "'"],
      ["gt", ">"],
      ["lt", "<"],
      ["amp", "&"]
    ].map(function(x2) {
      return [new RegExp("&" + x2[0] + ";", "ig"), x2[1]];
    });
    return function htmldecode2(str) {
      var o2 = str.replace(/^[\t\n\r ]+/, "").replace(/[\t\n\r ]+$/, "").replace(/>\s+/g, ">").replace(/\s+</g, "<").replace(/[\t\n\r ]+/g, " ").replace(/<\s*[bB][rR]\s*\/?>/g, "\n").replace(/<[^>]*>/g, "");
      for (var i = 0; i < entities.length; ++i)
        o2 = o2.replace(entities[i][0], entities[i][1]);
      return o2;
    };
  }();
  var vtregex = /* @__PURE__ */ function() {
    var vt_cache = {};
    return function vt_regex(bt2) {
      if (vt_cache[bt2] !== void 0)
        return vt_cache[bt2];
      return vt_cache[bt2] = new RegExp("<(?:vt:)?" + bt2 + ">([\\s\\S]*?)</(?:vt:)?" + bt2 + ">", "g");
    };
  }();
  var vtvregex = /<\/?(?:vt:)?variant>/g, vtmregex = /<(?:vt:)([^>]*)>([\s\S]*)</;
  function parseVector(data, opts) {
    var h2 = parsexmltag(data);
    var matches = data.match(vtregex(h2.baseType)) || [];
    var res = [];
    if (matches.length != h2.size) {
      if (opts.WTF)
        throw new Error("unexpected vector length " + matches.length + " != " + h2.size);
      return res;
    }
    matches.forEach(function(x2) {
      var v2 = x2.replace(vtvregex, "").match(vtmregex);
      if (v2)
        res.push({ v: utf8read(v2[2]), t: v2[1] });
    });
    return res;
  }
  var wtregex = /(^\s|\s$|\n)/;
  function writetag(f2, g) {
    return "<" + f2 + (g.match(wtregex) ? ' xml:space="preserve"' : "") + ">" + g + "</" + f2 + ">";
  }
  function wxt_helper(h2) {
    return keys$1(h2).map(function(k) {
      return " " + k + '="' + h2[k] + '"';
    }).join("");
  }
  function writextag(f2, g, h2) {
    return "<" + f2 + (h2 != null ? wxt_helper(h2) : "") + (g != null ? (g.match(wtregex) ? ' xml:space="preserve"' : "") + ">" + g + "</" + f2 : "/") + ">";
  }
  function write_w3cdtf(d2, t) {
    try {
      return d2.toISOString().replace(/\.\d*/, "");
    } catch (e) {
      if (t)
        throw e;
    }
    return "";
  }
  function write_vt(s2, xlsx) {
    switch (typeof s2) {
      case "string":
        var o2 = writextag("vt:lpwstr", escapexml(s2));
        if (xlsx)
          o2 = o2.replace(/&quot;/g, "_x0022_");
        return o2;
      case "number":
        return writextag((s2 | 0) == s2 ? "vt:i4" : "vt:r8", escapexml(String(s2)));
      case "boolean":
        return writextag("vt:bool", s2 ? "true" : "false");
    }
    if (s2 instanceof Date)
      return writextag("vt:filetime", write_w3cdtf(s2));
    throw new Error("Unable to serialize " + s2);
  }
  function xlml_normalize(d2) {
    if (has_buf && Buffer.isBuffer(d2))
      return d2.toString("utf8");
    if (typeof d2 === "string")
      return d2;
    if (typeof Uint8Array !== "undefined" && d2 instanceof Uint8Array)
      return utf8read(a2s(ab2a(d2)));
    throw new Error("Bad input format: expected Buffer or string");
  }
  var xlmlregex = /<(\/?)([^\s?><!\/:]*:|)([^\s?<>:\/]+)(?:[\s?:\/][^>]*)?>/mg;
  var XMLNS = {
    CORE_PROPS: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
    CUST_PROPS: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
    EXT_PROPS: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
    CT: "http://schemas.openxmlformats.org/package/2006/content-types",
    RELS: "http://schemas.openxmlformats.org/package/2006/relationships",
    TCMNT: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
    "dc": "http://purl.org/dc/elements/1.1/",
    "dcterms": "http://purl.org/dc/terms/",
    "dcmitype": "http://purl.org/dc/dcmitype/",
    "mx": "http://schemas.microsoft.com/office/mac/excel/2008/main",
    "r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
    "sjs": "http://schemas.openxmlformats.org/package/2006/sheetjs/core-properties",
    "vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
    "xsi": "http://www.w3.org/2001/XMLSchema-instance",
    "xsd": "http://www.w3.org/2001/XMLSchema"
  };
  var XMLNS_main = [
    "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
    "http://purl.oclc.org/ooxml/spreadsheetml/main",
    "http://schemas.microsoft.com/office/excel/2006/main",
    "http://schemas.microsoft.com/office/excel/2006/2"
  ];
  var XLMLNS = {
    "o": "urn:schemas-microsoft-com:office:office",
    "x": "urn:schemas-microsoft-com:office:excel",
    "ss": "urn:schemas-microsoft-com:office:spreadsheet",
    "dt": "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",
    "mv": "http://macVmlSchemaUri",
    "v": "urn:schemas-microsoft-com:vml",
    "html": "http://www.w3.org/TR/REC-html40"
  };
  function read_double_le(b2, idx) {
    var s2 = 1 - 2 * (b2[idx + 7] >>> 7);
    var e = ((b2[idx + 7] & 127) << 4) + (b2[idx + 6] >>> 4 & 15);
    var m2 = b2[idx + 6] & 15;
    for (var i = 5; i >= 0; --i)
      m2 = m2 * 256 + b2[idx + i];
    if (e == 2047)
      return m2 == 0 ? s2 * Infinity : NaN;
    if (e == 0)
      e = -1022;
    else {
      e -= 1023;
      m2 += Math.pow(2, 52);
    }
    return s2 * Math.pow(2, e - 52) * m2;
  }
  function write_double_le(b2, v2, idx) {
    var bs = (v2 < 0 || 1 / v2 == -Infinity ? 1 : 0) << 7, e = 0, m2 = 0;
    var av = bs ? -v2 : v2;
    if (!isFinite(av)) {
      e = 2047;
      m2 = isNaN(v2) ? 26985 : 0;
    } else if (av == 0)
      e = m2 = 0;
    else {
      e = Math.floor(Math.log(av) / Math.LN2);
      m2 = av * Math.pow(2, 52 - e);
      if (e <= -1023 && (!isFinite(m2) || m2 < Math.pow(2, 52))) {
        e = -1022;
      } else {
        m2 -= Math.pow(2, 52);
        e += 1023;
      }
    }
    for (var i = 0; i <= 5; ++i, m2 /= 256)
      b2[idx + i] = m2 & 255;
    b2[idx + 6] = (e & 15) << 4 | m2 & 15;
    b2[idx + 7] = e >> 4 | bs;
  }
  var ___toBuffer = function(bufs) {
    var x2 = [], w2 = 10240;
    for (var i = 0; i < bufs[0].length; ++i)
      if (bufs[0][i])
        for (var j = 0, L = bufs[0][i].length; j < L; j += w2)
          x2.push.apply(x2, bufs[0][i].slice(j, j + w2));
    return x2;
  };
  var __toBuffer = has_buf ? function(bufs) {
    return bufs[0].length > 0 && Buffer.isBuffer(bufs[0][0]) ? Buffer.concat(bufs[0].map(function(x2) {
      return Buffer.isBuffer(x2) ? x2 : Buffer_from(x2);
    })) : ___toBuffer(bufs);
  } : ___toBuffer;
  var ___utf16le = function(b2, s2, e) {
    var ss = [];
    for (var i = s2; i < e; i += 2)
      ss.push(String.fromCharCode(__readUInt16LE(b2, i)));
    return ss.join("").replace(chr0, "");
  };
  var __utf16le = has_buf ? function(b2, s2, e) {
    if (!Buffer.isBuffer(b2))
      return ___utf16le(b2, s2, e);
    return b2.toString("utf16le", s2, e).replace(chr0, "");
  } : ___utf16le;
  var ___hexlify = function(b2, s2, l2) {
    var ss = [];
    for (var i = s2; i < s2 + l2; ++i)
      ss.push(("0" + b2[i].toString(16)).slice(-2));
    return ss.join("");
  };
  var __hexlify = has_buf ? function(b2, s2, l2) {
    return Buffer.isBuffer(b2) ? b2.toString("hex", s2, s2 + l2) : ___hexlify(b2, s2, l2);
  } : ___hexlify;
  var ___utf8 = function(b2, s2, e) {
    var ss = [];
    for (var i = s2; i < e; i++)
      ss.push(String.fromCharCode(__readUInt8(b2, i)));
    return ss.join("");
  };
  var __utf8 = has_buf ? function utf8_b(b2, s2, e) {
    return Buffer.isBuffer(b2) ? b2.toString("utf8", s2, e) : ___utf8(b2, s2, e);
  } : ___utf8;
  var ___lpstr = function(b2, i) {
    var len = __readUInt32LE(b2, i);
    return len > 0 ? __utf8(b2, i + 4, i + 4 + len - 1) : "";
  };
  var __lpstr = ___lpstr;
  var ___cpstr = function(b2, i) {
    var len = __readUInt32LE(b2, i);
    return len > 0 ? __utf8(b2, i + 4, i + 4 + len - 1) : "";
  };
  var __cpstr = ___cpstr;
  var ___lpwstr = function(b2, i) {
    var len = 2 * __readUInt32LE(b2, i);
    return len > 0 ? __utf8(b2, i + 4, i + 4 + len - 1) : "";
  };
  var __lpwstr = ___lpwstr;
  var ___lpp4 = function lpp4_(b2, i) {
    var len = __readUInt32LE(b2, i);
    return len > 0 ? __utf16le(b2, i + 4, i + 4 + len) : "";
  };
  var __lpp4 = ___lpp4;
  var ___8lpp4 = function(b2, i) {
    var len = __readUInt32LE(b2, i);
    return len > 0 ? __utf8(b2, i + 4, i + 4 + len) : "";
  };
  var __8lpp4 = ___8lpp4;
  var ___double = function(b2, idx) {
    return read_double_le(b2, idx);
  };
  var __double = ___double;
  var is_buf = function is_buf_a(a2) {
    return Array.isArray(a2) || typeof Uint8Array !== "undefined" && a2 instanceof Uint8Array;
  };
  if (has_buf) {
    __lpstr = function lpstr_b(b2, i) {
      if (!Buffer.isBuffer(b2))
        return ___lpstr(b2, i);
      var len = b2.readUInt32LE(i);
      return len > 0 ? b2.toString("utf8", i + 4, i + 4 + len - 1) : "";
    };
    __cpstr = function cpstr_b(b2, i) {
      if (!Buffer.isBuffer(b2))
        return ___cpstr(b2, i);
      var len = b2.readUInt32LE(i);
      return len > 0 ? b2.toString("utf8", i + 4, i + 4 + len - 1) : "";
    };
    __lpwstr = function lpwstr_b(b2, i) {
      if (!Buffer.isBuffer(b2))
        return ___lpwstr(b2, i);
      var len = 2 * b2.readUInt32LE(i);
      return b2.toString("utf16le", i + 4, i + 4 + len - 1);
    };
    __lpp4 = function lpp4_b(b2, i) {
      if (!Buffer.isBuffer(b2))
        return ___lpp4(b2, i);
      var len = b2.readUInt32LE(i);
      return b2.toString("utf16le", i + 4, i + 4 + len);
    };
    __8lpp4 = function lpp4_8b(b2, i) {
      if (!Buffer.isBuffer(b2))
        return ___8lpp4(b2, i);
      var len = b2.readUInt32LE(i);
      return b2.toString("utf8", i + 4, i + 4 + len);
    };
    __double = function double_(b2, i) {
      if (Buffer.isBuffer(b2))
        return b2.readDoubleLE(i);
      return ___double(b2, i);
    };
    is_buf = function is_buf_b(a2) {
      return Buffer.isBuffer(a2) || Array.isArray(a2) || typeof Uint8Array !== "undefined" && a2 instanceof Uint8Array;
    };
  }
  var __readUInt8 = function(b2, idx) {
    return b2[idx];
  };
  var __readUInt16LE = function(b2, idx) {
    return b2[idx + 1] * (1 << 8) + b2[idx];
  };
  var __readInt16LE = function(b2, idx) {
    var u2 = b2[idx + 1] * (1 << 8) + b2[idx];
    return u2 < 32768 ? u2 : (65535 - u2 + 1) * -1;
  };
  var __readUInt32LE = function(b2, idx) {
    return b2[idx + 3] * (1 << 24) + (b2[idx + 2] << 16) + (b2[idx + 1] << 8) + b2[idx];
  };
  var __readInt32LE = function(b2, idx) {
    return b2[idx + 3] << 24 | b2[idx + 2] << 16 | b2[idx + 1] << 8 | b2[idx];
  };
  var __readInt32BE = function(b2, idx) {
    return b2[idx] << 24 | b2[idx + 1] << 16 | b2[idx + 2] << 8 | b2[idx + 3];
  };
  function ReadShift(size2, t) {
    var o2 = "", oI, oR, oo = [], w2, vv, i, loc;
    switch (t) {
      case "dbcs":
        loc = this.l;
        if (has_buf && Buffer.isBuffer(this))
          o2 = this.slice(this.l, this.l + 2 * size2).toString("utf16le");
        else
          for (i = 0; i < size2; ++i) {
            o2 += String.fromCharCode(__readUInt16LE(this, loc));
            loc += 2;
          }
        size2 *= 2;
        break;
      case "utf8":
        o2 = __utf8(this, this.l, this.l + size2);
        break;
      case "utf16le":
        size2 *= 2;
        o2 = __utf16le(this, this.l, this.l + size2);
        break;
      case "wstr":
        return ReadShift.call(this, size2, "dbcs");
      case "lpstr-ansi":
        o2 = __lpstr(this, this.l);
        size2 = 4 + __readUInt32LE(this, this.l);
        break;
      case "lpstr-cp":
        o2 = __cpstr(this, this.l);
        size2 = 4 + __readUInt32LE(this, this.l);
        break;
      case "lpwstr":
        o2 = __lpwstr(this, this.l);
        size2 = 4 + 2 * __readUInt32LE(this, this.l);
        break;
      case "lpp4":
        size2 = 4 + __readUInt32LE(this, this.l);
        o2 = __lpp4(this, this.l);
        if (size2 & 2)
          size2 += 2;
        break;
      case "8lpp4":
        size2 = 4 + __readUInt32LE(this, this.l);
        o2 = __8lpp4(this, this.l);
        if (size2 & 3)
          size2 += 4 - (size2 & 3);
        break;
      case "cstr":
        size2 = 0;
        o2 = "";
        while ((w2 = __readUInt8(this, this.l + size2++)) !== 0)
          oo.push(_getchar(w2));
        o2 = oo.join("");
        break;
      case "_wstr":
        size2 = 0;
        o2 = "";
        while ((w2 = __readUInt16LE(this, this.l + size2)) !== 0) {
          oo.push(_getchar(w2));
          size2 += 2;
        }
        size2 += 2;
        o2 = oo.join("");
        break;
      case "dbcs-cont":
        o2 = "";
        loc = this.l;
        for (i = 0; i < size2; ++i) {
          if (this.lens && this.lens.indexOf(loc) !== -1) {
            w2 = __readUInt8(this, loc);
            this.l = loc + 1;
            vv = ReadShift.call(this, size2 - i, w2 ? "dbcs-cont" : "sbcs-cont");
            return oo.join("") + vv;
          }
          oo.push(_getchar(__readUInt16LE(this, loc)));
          loc += 2;
        }
        o2 = oo.join("");
        size2 *= 2;
        break;
      case "cpstr":
      case "sbcs-cont":
        o2 = "";
        loc = this.l;
        for (i = 0; i != size2; ++i) {
          if (this.lens && this.lens.indexOf(loc) !== -1) {
            w2 = __readUInt8(this, loc);
            this.l = loc + 1;
            vv = ReadShift.call(this, size2 - i, w2 ? "dbcs-cont" : "sbcs-cont");
            return oo.join("") + vv;
          }
          oo.push(_getchar(__readUInt8(this, loc)));
          loc += 1;
        }
        o2 = oo.join("");
        break;
      default:
        switch (size2) {
          case 1:
            oI = __readUInt8(this, this.l);
            this.l++;
            return oI;
          case 2:
            oI = (t === "i" ? __readInt16LE : __readUInt16LE)(this, this.l);
            this.l += 2;
            return oI;
          case 4:
          case -4:
            if (t === "i" || (this[this.l + 3] & 128) === 0) {
              oI = (size2 > 0 ? __readInt32LE : __readInt32BE)(this, this.l);
              this.l += 4;
              return oI;
            } else {
              oR = __readUInt32LE(this, this.l);
              this.l += 4;
            }
            return oR;
          case 8:
          case -8:
            if (t === "f") {
              if (size2 == 8)
                oR = __double(this, this.l);
              else
                oR = __double([this[this.l + 7], this[this.l + 6], this[this.l + 5], this[this.l + 4], this[this.l + 3], this[this.l + 2], this[this.l + 1], this[this.l + 0]], 0);
              this.l += 8;
              return oR;
            } else
              size2 = 8;
          case 16:
            o2 = __hexlify(this, this.l, size2);
            break;
        }
    }
    this.l += size2;
    return o2;
  }
  var __writeUInt32LE = function(b2, val, idx) {
    b2[idx] = val & 255;
    b2[idx + 1] = val >>> 8 & 255;
    b2[idx + 2] = val >>> 16 & 255;
    b2[idx + 3] = val >>> 24 & 255;
  };
  var __writeInt32LE = function(b2, val, idx) {
    b2[idx] = val & 255;
    b2[idx + 1] = val >> 8 & 255;
    b2[idx + 2] = val >> 16 & 255;
    b2[idx + 3] = val >> 24 & 255;
  };
  var __writeUInt16LE = function(b2, val, idx) {
    b2[idx] = val & 255;
    b2[idx + 1] = val >>> 8 & 255;
  };
  function WriteShift(t, val, f2) {
    var size2 = 0, i = 0;
    if (f2 === "dbcs") {
      for (i = 0; i != val.length; ++i)
        __writeUInt16LE(this, val.charCodeAt(i), this.l + 2 * i);
      size2 = 2 * val.length;
    } else if (f2 === "sbcs") {
      {
        val = val.replace(/[^\x00-\x7F]/g, "_");
        for (i = 0; i != val.length; ++i)
          this[this.l + i] = val.charCodeAt(i) & 255;
      }
      size2 = val.length;
    } else if (f2 === "hex") {
      for (; i < t; ++i) {
        this[this.l++] = parseInt(val.slice(2 * i, 2 * i + 2), 16) || 0;
      }
      return this;
    } else if (f2 === "utf16le") {
      var end = Math.min(this.l + t, this.length);
      for (i = 0; i < Math.min(val.length, t); ++i) {
        var cc = val.charCodeAt(i);
        this[this.l++] = cc & 255;
        this[this.l++] = cc >> 8;
      }
      while (this.l < end)
        this[this.l++] = 0;
      return this;
    } else
      switch (t) {
        case 1:
          size2 = 1;
          this[this.l] = val & 255;
          break;
        case 2:
          size2 = 2;
          this[this.l] = val & 255;
          val >>>= 8;
          this[this.l + 1] = val & 255;
          break;
        case 3:
          size2 = 3;
          this[this.l] = val & 255;
          val >>>= 8;
          this[this.l + 1] = val & 255;
          val >>>= 8;
          this[this.l + 2] = val & 255;
          break;
        case 4:
          size2 = 4;
          __writeUInt32LE(this, val, this.l);
          break;
        case 8:
          size2 = 8;
          if (f2 === "f") {
            write_double_le(this, val, this.l);
            break;
          }
        case 16:
          break;
        case -4:
          size2 = 4;
          __writeInt32LE(this, val, this.l);
          break;
      }
    this.l += size2;
    return this;
  }
  function CheckField(hexstr, fld) {
    var m2 = __hexlify(this, this.l, hexstr.length >> 1);
    if (m2 !== hexstr)
      throw new Error(fld + "Expected " + hexstr + " saw " + m2);
    this.l += hexstr.length >> 1;
  }
  function prep_blob(blob, pos) {
    blob.l = pos;
    blob.read_shift = ReadShift;
    blob.chk = CheckField;
    blob.write_shift = WriteShift;
  }
  function parsenoop(blob, length) {
    blob.l += length;
  }
  function new_buf(sz) {
    var o2 = new_raw_buf(sz);
    prep_blob(o2, 0);
    return o2;
  }
  function recordhopper(data, cb, opts) {
    if (!data)
      return;
    var tmpbyte, cntbyte, length;
    prep_blob(data, data.l || 0);
    var L = data.length, RT = 0, tgt = 0;
    while (data.l < L) {
      RT = data.read_shift(1);
      if (RT & 128)
        RT = (RT & 127) + ((data.read_shift(1) & 127) << 7);
      var R2 = XLSBRecordEnum[RT] || XLSBRecordEnum[65535];
      tmpbyte = data.read_shift(1);
      length = tmpbyte & 127;
      for (cntbyte = 1; cntbyte < 4 && tmpbyte & 128; ++cntbyte)
        length += ((tmpbyte = data.read_shift(1)) & 127) << 7 * cntbyte;
      tgt = data.l + length;
      var d2 = R2.f && R2.f(data, length, opts);
      data.l = tgt;
      if (cb(d2, R2, RT))
        return;
    }
  }
  function buf_array() {
    var bufs = [], blksz = has_buf ? 256 : 2048;
    var newblk = function ba_newblk(sz) {
      var o2 = new_buf(sz);
      prep_blob(o2, 0);
      return o2;
    };
    var curbuf = newblk(blksz);
    var endbuf = function ba_endbuf() {
      if (!curbuf)
        return;
      if (curbuf.length > curbuf.l) {
        curbuf = curbuf.slice(0, curbuf.l);
        curbuf.l = curbuf.length;
      }
      if (curbuf.length > 0)
        bufs.push(curbuf);
      curbuf = null;
    };
    var next = function ba_next(sz) {
      if (curbuf && sz < curbuf.length - curbuf.l)
        return curbuf;
      endbuf();
      return curbuf = newblk(Math.max(sz + 1, blksz));
    };
    var end = function ba_end() {
      endbuf();
      return bconcat(bufs);
    };
    var push = function ba_push(buf) {
      endbuf();
      curbuf = buf;
      if (curbuf.l == null)
        curbuf.l = curbuf.length;
      next(blksz);
    };
    return { next, push, end, _bufs: bufs };
  }
  function write_record(ba, type, payload, length) {
    var t = +type, l2;
    if (isNaN(t))
      return;
    if (!length)
      length = XLSBRecordEnum[t].p || (payload || []).length || 0;
    l2 = 1 + (t >= 128 ? 1 : 0) + 1;
    if (length >= 128)
      ++l2;
    if (length >= 16384)
      ++l2;
    if (length >= 2097152)
      ++l2;
    var o2 = ba.next(l2);
    if (t <= 127)
      o2.write_shift(1, t);
    else {
      o2.write_shift(1, (t & 127) + 128);
      o2.write_shift(1, t >> 7);
    }
    for (var i = 0; i != 4; ++i) {
      if (length >= 128) {
        o2.write_shift(1, (length & 127) + 128);
        length >>= 7;
      } else {
        o2.write_shift(1, length);
        break;
      }
    }
    if (length > 0 && is_buf(payload))
      ba.push(payload);
  }
  function shift_cell_xls(cell, tgt, opts) {
    var out = dup(cell);
    if (tgt.s) {
      if (out.cRel)
        out.c += tgt.s.c;
      if (out.rRel)
        out.r += tgt.s.r;
    } else {
      if (out.cRel)
        out.c += tgt.c;
      if (out.rRel)
        out.r += tgt.r;
    }
    if (!opts || opts.biff < 12) {
      while (out.c >= 256)
        out.c -= 256;
      while (out.r >= 65536)
        out.r -= 65536;
    }
    return out;
  }
  function shift_range_xls(cell, range, opts) {
    var out = dup(cell);
    out.s = shift_cell_xls(out.s, range.s, opts);
    out.e = shift_cell_xls(out.e, range.s, opts);
    return out;
  }
  function encode_cell_xls(c2, biff) {
    if (c2.cRel && c2.c < 0) {
      c2 = dup(c2);
      while (c2.c < 0)
        c2.c += biff > 8 ? 16384 : 256;
    }
    if (c2.rRel && c2.r < 0) {
      c2 = dup(c2);
      while (c2.r < 0)
        c2.r += biff > 8 ? 1048576 : biff > 5 ? 65536 : 16384;
    }
    var s2 = encode_cell(c2);
    if (!c2.cRel && c2.cRel != null)
      s2 = fix_col(s2);
    if (!c2.rRel && c2.rRel != null)
      s2 = fix_row(s2);
    return s2;
  }
  function encode_range_xls(r, opts) {
    if (r.s.r == 0 && !r.s.rRel) {
      if (r.e.r == (opts.biff >= 12 ? 1048575 : opts.biff >= 8 ? 65536 : 16384) && !r.e.rRel) {
        return (r.s.cRel ? "" : "$") + encode_col(r.s.c) + ":" + (r.e.cRel ? "" : "$") + encode_col(r.e.c);
      }
    }
    if (r.s.c == 0 && !r.s.cRel) {
      if (r.e.c == (opts.biff >= 12 ? 16383 : 255) && !r.e.cRel) {
        return (r.s.rRel ? "" : "$") + encode_row(r.s.r) + ":" + (r.e.rRel ? "" : "$") + encode_row(r.e.r);
      }
    }
    return encode_cell_xls(r.s, opts.biff) + ":" + encode_cell_xls(r.e, opts.biff);
  }
  function decode_row(rowstr) {
    return parseInt(unfix_row(rowstr), 10) - 1;
  }
  function encode_row(row) {
    return "" + (row + 1);
  }
  function fix_row(cstr) {
    return cstr.replace(/([A-Z]|^)(\d+)$/, "$1$$$2");
  }
  function unfix_row(cstr) {
    return cstr.replace(/\$(\d+)$/, "$1");
  }
  function decode_col(colstr) {
    var c2 = unfix_col(colstr), d2 = 0, i = 0;
    for (; i !== c2.length; ++i)
      d2 = 26 * d2 + c2.charCodeAt(i) - 64;
    return d2 - 1;
  }
  function encode_col(col) {
    if (col < 0)
      throw new Error("invalid column " + col);
    var s2 = "";
    for (++col; col; col = Math.floor((col - 1) / 26))
      s2 = String.fromCharCode((col - 1) % 26 + 65) + s2;
    return s2;
  }
  function fix_col(cstr) {
    return cstr.replace(/^([A-Z])/, "$$$1");
  }
  function unfix_col(cstr) {
    return cstr.replace(/^\$([A-Z])/, "$1");
  }
  function split_cell(cstr) {
    return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/, "$1,$2").split(",");
  }
  function decode_cell(cstr) {
    var R2 = 0, C2 = 0;
    for (var i = 0; i < cstr.length; ++i) {
      var cc = cstr.charCodeAt(i);
      if (cc >= 48 && cc <= 57)
        R2 = 10 * R2 + (cc - 48);
      else if (cc >= 65 && cc <= 90)
        C2 = 26 * C2 + (cc - 64);
    }
    return { c: C2 - 1, r: R2 - 1 };
  }
  function encode_cell(cell) {
    var col = cell.c + 1;
    var s2 = "";
    for (; col; col = (col - 1) / 26 | 0)
      s2 = String.fromCharCode((col - 1) % 26 + 65) + s2;
    return s2 + (cell.r + 1);
  }
  function decode_range(range) {
    var idx = range.indexOf(":");
    if (idx == -1)
      return { s: decode_cell(range), e: decode_cell(range) };
    return { s: decode_cell(range.slice(0, idx)), e: decode_cell(range.slice(idx + 1)) };
  }
  function encode_range(cs, ce2) {
    if (typeof ce2 === "undefined" || typeof ce2 === "number") {
      return encode_range(cs.s, cs.e);
    }
    if (typeof cs !== "string")
      cs = encode_cell(cs);
    if (typeof ce2 !== "string")
      ce2 = encode_cell(ce2);
    return cs == ce2 ? cs : cs + ":" + ce2;
  }
  function safe_decode_range(range) {
    var o2 = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
    var idx = 0, i = 0, cc = 0;
    var len = range.length;
    for (idx = 0; i < len; ++i) {
      if ((cc = range.charCodeAt(i) - 64) < 1 || cc > 26)
        break;
      idx = 26 * idx + cc;
    }
    o2.s.c = --idx;
    for (idx = 0; i < len; ++i) {
      if ((cc = range.charCodeAt(i) - 48) < 0 || cc > 9)
        break;
      idx = 10 * idx + cc;
    }
    o2.s.r = --idx;
    if (i === len || cc != 10) {
      o2.e.c = o2.s.c;
      o2.e.r = o2.s.r;
      return o2;
    }
    ++i;
    for (idx = 0; i != len; ++i) {
      if ((cc = range.charCodeAt(i) - 64) < 1 || cc > 26)
        break;
      idx = 26 * idx + cc;
    }
    o2.e.c = --idx;
    for (idx = 0; i != len; ++i) {
      if ((cc = range.charCodeAt(i) - 48) < 0 || cc > 9)
        break;
      idx = 10 * idx + cc;
    }
    o2.e.r = --idx;
    return o2;
  }
  function safe_format_cell(cell, v2) {
    var q2 = cell.t == "d" && v2 instanceof Date;
    if (cell.z != null)
      try {
        return cell.w = SSF_format(cell.z, q2 ? datenum(v2) : v2);
      } catch (e) {
      }
    try {
      return cell.w = SSF_format((cell.XF || {}).numFmtId || (q2 ? 14 : 0), q2 ? datenum(v2) : v2);
    } catch (e) {
      return "" + v2;
    }
  }
  function format_cell(cell, v2, o2) {
    if (cell == null || cell.t == null || cell.t == "z")
      return "";
    if (cell.w !== void 0)
      return cell.w;
    if (cell.t == "d" && !cell.z && o2 && o2.dateNF)
      cell.z = o2.dateNF;
    if (cell.t == "e")
      return BErr[cell.v] || cell.v;
    if (v2 == void 0)
      return safe_format_cell(cell, cell.v);
    return safe_format_cell(cell, v2);
  }
  function sheet_to_workbook(sheet, opts) {
    var n = opts && opts.sheet ? opts.sheet : "Sheet1";
    var sheets = {};
    sheets[n] = sheet;
    return { SheetNames: [n], Sheets: sheets };
  }
  function sheet_add_aoa(_ws, data, opts) {
    var o2 = opts || {};
    var dense = _ws ? Array.isArray(_ws) : o2.dense;
    var ws = _ws || (dense ? [] : {});
    var _R = 0, _C = 0;
    if (ws && o2.origin != null) {
      if (typeof o2.origin == "number")
        _R = o2.origin;
      else {
        var _origin = typeof o2.origin == "string" ? decode_cell(o2.origin) : o2.origin;
        _R = _origin.r;
        _C = _origin.c;
      }
      if (!ws["!ref"])
        ws["!ref"] = "A1:A1";
    }
    var range = { s: { c: 1e7, r: 1e7 }, e: { c: 0, r: 0 } };
    if (ws["!ref"]) {
      var _range = safe_decode_range(ws["!ref"]);
      range.s.c = _range.s.c;
      range.s.r = _range.s.r;
      range.e.c = Math.max(range.e.c, _range.e.c);
      range.e.r = Math.max(range.e.r, _range.e.r);
      if (_R == -1)
        range.e.r = _R = _range.e.r + 1;
    }
    for (var R2 = 0; R2 != data.length; ++R2) {
      if (!data[R2])
        continue;
      if (!Array.isArray(data[R2]))
        throw new Error("aoa_to_sheet expects an array of arrays");
      for (var C2 = 0; C2 != data[R2].length; ++C2) {
        if (typeof data[R2][C2] === "undefined")
          continue;
        var cell = { v: data[R2][C2] };
        var __R = _R + R2, __C = _C + C2;
        if (range.s.r > __R)
          range.s.r = __R;
        if (range.s.c > __C)
          range.s.c = __C;
        if (range.e.r < __R)
          range.e.r = __R;
        if (range.e.c < __C)
          range.e.c = __C;
        if (data[R2][C2] && typeof data[R2][C2] === "object" && !Array.isArray(data[R2][C2]) && !(data[R2][C2] instanceof Date))
          cell = data[R2][C2];
        else {
          if (Array.isArray(cell.v)) {
            cell.f = data[R2][C2][1];
            cell.v = cell.v[0];
          }
          if (cell.v === null) {
            if (cell.f)
              cell.t = "n";
            else if (o2.nullError) {
              cell.t = "e";
              cell.v = 0;
            } else if (!o2.sheetStubs)
              continue;
            else
              cell.t = "z";
          } else if (typeof cell.v === "number")
            cell.t = "n";
          else if (typeof cell.v === "boolean")
            cell.t = "b";
          else if (cell.v instanceof Date) {
            cell.z = o2.dateNF || table_fmt[14];
            if (o2.cellDates) {
              cell.t = "d";
              cell.w = SSF_format(cell.z, datenum(cell.v));
            } else {
              cell.t = "n";
              cell.v = datenum(cell.v);
              cell.w = SSF_format(cell.z, cell.v);
            }
          } else
            cell.t = "s";
        }
        if (dense) {
          if (!ws[__R])
            ws[__R] = [];
          if (ws[__R][__C] && ws[__R][__C].z)
            cell.z = ws[__R][__C].z;
          ws[__R][__C] = cell;
        } else {
          var cell_ref = encode_cell({ c: __C, r: __R });
          if (ws[cell_ref] && ws[cell_ref].z)
            cell.z = ws[cell_ref].z;
          ws[cell_ref] = cell;
        }
      }
    }
    if (range.s.c < 1e7)
      ws["!ref"] = encode_range(range);
    return ws;
  }
  function aoa_to_sheet(data, opts) {
    return sheet_add_aoa(null, data, opts);
  }
  function parse_Int32LE(data) {
    return data.read_shift(4, "i");
  }
  function write_UInt32LE(x2, o2) {
    if (!o2)
      o2 = new_buf(4);
    o2.write_shift(4, x2);
    return o2;
  }
  function parse_XLWideString(data) {
    var cchCharacters = data.read_shift(4);
    return cchCharacters === 0 ? "" : data.read_shift(cchCharacters, "dbcs");
  }
  function write_XLWideString(data, o2) {
    var _null = false;
    if (o2 == null) {
      _null = true;
      o2 = new_buf(4 + 2 * data.length);
    }
    o2.write_shift(4, data.length);
    if (data.length > 0)
      o2.write_shift(0, data, "dbcs");
    return _null ? o2.slice(0, o2.l) : o2;
  }
  function parse_StrRun(data) {
    return { ich: data.read_shift(2), ifnt: data.read_shift(2) };
  }
  function write_StrRun(run, o2) {
    if (!o2)
      o2 = new_buf(4);
    o2.write_shift(2, run.ich || 0);
    o2.write_shift(2, run.ifnt || 0);
    return o2;
  }
  function parse_RichStr(data, length) {
    var start = data.l;
    var flags = data.read_shift(1);
    var str = parse_XLWideString(data);
    var rgsStrRun = [];
    var z = { t: str, h: str };
    if ((flags & 1) !== 0) {
      var dwSizeStrRun = data.read_shift(4);
      for (var i = 0; i != dwSizeStrRun; ++i)
        rgsStrRun.push(parse_StrRun(data));
      z.r = rgsStrRun;
    } else
      z.r = [{ ich: 0, ifnt: 0 }];
    data.l = start + length;
    return z;
  }
  function write_RichStr(str, o2) {
    var _null = false;
    if (o2 == null) {
      _null = true;
      o2 = new_buf(15 + 4 * str.t.length);
    }
    o2.write_shift(1, 0);
    write_XLWideString(str.t, o2);
    return _null ? o2.slice(0, o2.l) : o2;
  }
  var parse_BrtCommentText = parse_RichStr;
  function write_BrtCommentText(str, o2) {
    var _null = false;
    if (o2 == null) {
      _null = true;
      o2 = new_buf(23 + 4 * str.t.length);
    }
    o2.write_shift(1, 1);
    write_XLWideString(str.t, o2);
    o2.write_shift(4, 1);
    write_StrRun({ ich: 0, ifnt: 0 }, o2);
    return _null ? o2.slice(0, o2.l) : o2;
  }
  function parse_XLSBCell(data) {
    var col = data.read_shift(4);
    var iStyleRef = data.read_shift(2);
    iStyleRef += data.read_shift(1) << 16;
    data.l++;
    return { c: col, iStyleRef };
  }
  function write_XLSBCell(cell, o2) {
    if (o2 == null)
      o2 = new_buf(8);
    o2.write_shift(-4, cell.c);
    o2.write_shift(3, cell.iStyleRef || cell.s);
    o2.write_shift(1, 0);
    return o2;
  }
  function parse_XLSBShortCell(data) {
    var iStyleRef = data.read_shift(2);
    iStyleRef += data.read_shift(1) << 16;
    data.l++;
    return { c: -1, iStyleRef };
  }
  function write_XLSBShortCell(cell, o2) {
    if (o2 == null)
      o2 = new_buf(4);
    o2.write_shift(3, cell.iStyleRef || cell.s);
    o2.write_shift(1, 0);
    return o2;
  }
  var parse_XLSBCodeName = parse_XLWideString;
  var write_XLSBCodeName = write_XLWideString;
  function parse_XLNullableWideString(data) {
    var cchCharacters = data.read_shift(4);
    return cchCharacters === 0 || cchCharacters === 4294967295 ? "" : data.read_shift(cchCharacters, "dbcs");
  }
  function write_XLNullableWideString(data, o2) {
    var _null = false;
    if (o2 == null) {
      _null = true;
      o2 = new_buf(127);
    }
    o2.write_shift(4, data.length > 0 ? data.length : 4294967295);
    if (data.length > 0)
      o2.write_shift(0, data, "dbcs");
    return _null ? o2.slice(0, o2.l) : o2;
  }
  var parse_XLNameWideString = parse_XLWideString;
  var parse_RelID = parse_XLNullableWideString;
  var write_RelID = write_XLNullableWideString;
  function parse_RkNumber(data) {
    var b2 = data.slice(data.l, data.l + 4);
    var fX100 = b2[0] & 1, fInt = b2[0] & 2;
    data.l += 4;
    var RK = fInt === 0 ? __double([0, 0, 0, 0, b2[0] & 252, b2[1], b2[2], b2[3]], 0) : __readInt32LE(b2, 0) >> 2;
    return fX100 ? RK / 100 : RK;
  }
  function write_RkNumber(data, o2) {
    if (o2 == null)
      o2 = new_buf(4);
    var fX100 = 0, fInt = 0, d100 = data * 100;
    if (data == (data | 0) && data >= -(1 << 29) && data < 1 << 29) {
      fInt = 1;
    } else if (d100 == (d100 | 0) && d100 >= -(1 << 29) && d100 < 1 << 29) {
      fInt = 1;
      fX100 = 1;
    }
    if (fInt)
      o2.write_shift(-4, ((fX100 ? d100 : data) << 2) + (fX100 + 2));
    else
      throw new Error("unsupported RkNumber " + data);
  }
  function parse_RfX(data) {
    var cell = { s: {}, e: {} };
    cell.s.r = data.read_shift(4);
    cell.e.r = data.read_shift(4);
    cell.s.c = data.read_shift(4);
    cell.e.c = data.read_shift(4);
    return cell;
  }
  function write_RfX(r, o2) {
    if (!o2)
      o2 = new_buf(16);
    o2.write_shift(4, r.s.r);
    o2.write_shift(4, r.e.r);
    o2.write_shift(4, r.s.c);
    o2.write_shift(4, r.e.c);
    return o2;
  }
  var parse_UncheckedRfX = parse_RfX;
  var write_UncheckedRfX = write_RfX;
  function parse_Xnum(data) {
    if (data.length - data.l < 8)
      throw "XLS Xnum Buffer underflow";
    return data.read_shift(8, "f");
  }
  function write_Xnum(data, o2) {
    return (o2 || new_buf(8)).write_shift(8, data, "f");
  }
  function parse_BrtColor(data) {
    var out = {};
    var d2 = data.read_shift(1);
    var xColorType = d2 >>> 1;
    var index = data.read_shift(1);
    var nTS = data.read_shift(2, "i");
    var bR = data.read_shift(1);
    var bG = data.read_shift(1);
    var bB = data.read_shift(1);
    data.l++;
    switch (xColorType) {
      case 0:
        out.auto = 1;
        break;
      case 1:
        out.index = index;
        var icv = XLSIcv[index];
        if (icv)
          out.rgb = rgb2Hex(icv);
        break;
      case 2:
        out.rgb = rgb2Hex([bR, bG, bB]);
        break;
      case 3:
        out.theme = index;
        break;
    }
    if (nTS != 0)
      out.tint = nTS > 0 ? nTS / 32767 : nTS / 32768;
    return out;
  }
  function write_BrtColor(color, o2) {
    if (!o2)
      o2 = new_buf(8);
    if (!color || color.auto) {
      o2.write_shift(4, 0);
      o2.write_shift(4, 0);
      return o2;
    }
    if (color.index != null) {
      o2.write_shift(1, 2);
      o2.write_shift(1, color.index);
    } else if (color.theme != null) {
      o2.write_shift(1, 6);
      o2.write_shift(1, color.theme);
    } else {
      o2.write_shift(1, 5);
      o2.write_shift(1, 0);
    }
    var nTS = color.tint || 0;
    if (nTS > 0)
      nTS *= 32767;
    else if (nTS < 0)
      nTS *= 32768;
    o2.write_shift(2, nTS);
    if (!color.rgb || color.theme != null) {
      o2.write_shift(2, 0);
      o2.write_shift(1, 0);
      o2.write_shift(1, 0);
    } else {
      var rgb = color.rgb || "FFFFFF";
      if (typeof rgb == "number")
        rgb = ("000000" + rgb.toString(16)).slice(-6);
      o2.write_shift(1, parseInt(rgb.slice(0, 2), 16));
      o2.write_shift(1, parseInt(rgb.slice(2, 4), 16));
      o2.write_shift(1, parseInt(rgb.slice(4, 6), 16));
      o2.write_shift(1, 255);
    }
    return o2;
  }
  function parse_FontFlags(data) {
    var d2 = data.read_shift(1);
    data.l++;
    var out = {
      fBold: d2 & 1,
      fItalic: d2 & 2,
      fUnderline: d2 & 4,
      fStrikeout: d2 & 8,
      fOutline: d2 & 16,
      fShadow: d2 & 32,
      fCondense: d2 & 64,
      fExtend: d2 & 128
    };
    return out;
  }
  function write_FontFlags(font, o2) {
    if (!o2)
      o2 = new_buf(2);
    var grbit = (font.italic ? 2 : 0) | (font.strike ? 8 : 0) | (font.outline ? 16 : 0) | (font.shadow ? 32 : 0) | (font.condense ? 64 : 0) | (font.extend ? 128 : 0);
    o2.write_shift(1, grbit);
    o2.write_shift(1, 0);
    return o2;
  }
  function parse_ClipboardFormatOrString(o2, w2) {
    var ClipFmt = { 2: "BITMAP", 3: "METAFILEPICT", 8: "DIB", 14: "ENHMETAFILE" };
    var m2 = o2.read_shift(4);
    switch (m2) {
      case 0:
        return "";
      case 4294967295:
      case 4294967294:
        return ClipFmt[o2.read_shift(4)] || "";
    }
    if (m2 > 400)
      throw new Error("Unsupported Clipboard: " + m2.toString(16));
    o2.l -= 4;
    return o2.read_shift(0, w2 == 1 ? "lpstr" : "lpwstr");
  }
  function parse_ClipboardFormatOrAnsiString(o2) {
    return parse_ClipboardFormatOrString(o2, 1);
  }
  function parse_ClipboardFormatOrUnicodeString(o2) {
    return parse_ClipboardFormatOrString(o2, 2);
  }
  var VT_I2 = 2;
  var VT_I4 = 3;
  var VT_BOOL = 11;
  var VT_VARIANT = 12;
  var VT_UI4 = 19;
  var VT_FILETIME = 64;
  var VT_BLOB = 65;
  var VT_CF = 71;
  var VT_VECTOR_VARIANT = 4108;
  var VT_VECTOR_LPSTR = 4126;
  var VT_STRING = 80;
  var VT_USTR = 81;
  var VT_CUSTOM = [VT_STRING, VT_USTR];
  var DocSummaryPIDDSI = {
    1: { n: "CodePage", t: VT_I2 },
    2: { n: "Category", t: VT_STRING },
    3: { n: "PresentationFormat", t: VT_STRING },
    4: { n: "ByteCount", t: VT_I4 },
    5: { n: "LineCount", t: VT_I4 },
    6: { n: "ParagraphCount", t: VT_I4 },
    7: { n: "SlideCount", t: VT_I4 },
    8: { n: "NoteCount", t: VT_I4 },
    9: { n: "HiddenCount", t: VT_I4 },
    10: { n: "MultimediaClipCount", t: VT_I4 },
    11: { n: "ScaleCrop", t: VT_BOOL },
    12: { n: "HeadingPairs", t: VT_VECTOR_VARIANT },
    13: { n: "TitlesOfParts", t: VT_VECTOR_LPSTR },
    14: { n: "Manager", t: VT_STRING },
    15: { n: "Company", t: VT_STRING },
    16: { n: "LinksUpToDate", t: VT_BOOL },
    17: { n: "CharacterCount", t: VT_I4 },
    19: { n: "SharedDoc", t: VT_BOOL },
    22: { n: "HyperlinksChanged", t: VT_BOOL },
    23: { n: "AppVersion", t: VT_I4, p: "version" },
    24: { n: "DigSig", t: VT_BLOB },
    26: { n: "ContentType", t: VT_STRING },
    27: { n: "ContentStatus", t: VT_STRING },
    28: { n: "Language", t: VT_STRING },
    29: { n: "Version", t: VT_STRING },
    255: {},
    2147483648: { n: "Locale", t: VT_UI4 },
    2147483651: { n: "Behavior", t: VT_UI4 },
    1919054434: {}
  };
  var SummaryPIDSI = {
    1: { n: "CodePage", t: VT_I2 },
    2: { n: "Title", t: VT_STRING },
    3: { n: "Subject", t: VT_STRING },
    4: { n: "Author", t: VT_STRING },
    5: { n: "Keywords", t: VT_STRING },
    6: { n: "Comments", t: VT_STRING },
    7: { n: "Template", t: VT_STRING },
    8: { n: "LastAuthor", t: VT_STRING },
    9: { n: "RevNumber", t: VT_STRING },
    10: { n: "EditTime", t: VT_FILETIME },
    11: { n: "LastPrinted", t: VT_FILETIME },
    12: { n: "CreatedDate", t: VT_FILETIME },
    13: { n: "ModifiedDate", t: VT_FILETIME },
    14: { n: "PageCount", t: VT_I4 },
    15: { n: "WordCount", t: VT_I4 },
    16: { n: "CharCount", t: VT_I4 },
    17: { n: "Thumbnail", t: VT_CF },
    18: { n: "Application", t: VT_STRING },
    19: { n: "DocSecurity", t: VT_I4 },
    255: {},
    2147483648: { n: "Locale", t: VT_UI4 },
    2147483651: { n: "Behavior", t: VT_UI4 },
    1919054434: {}
  };
  var CountryEnum = {
    1: "US",
    2: "CA",
    3: "",
    7: "RU",
    20: "EG",
    30: "GR",
    31: "NL",
    32: "BE",
    33: "FR",
    34: "ES",
    36: "HU",
    39: "IT",
    41: "CH",
    43: "AT",
    44: "GB",
    45: "DK",
    46: "SE",
    47: "NO",
    48: "PL",
    49: "DE",
    52: "MX",
    55: "BR",
    61: "AU",
    64: "NZ",
    66: "TH",
    81: "JP",
    82: "KR",
    84: "VN",
    86: "CN",
    90: "TR",
    105: "JS",
    213: "DZ",
    216: "MA",
    218: "LY",
    351: "PT",
    354: "IS",
    358: "FI",
    420: "CZ",
    886: "TW",
    961: "LB",
    962: "JO",
    963: "SY",
    964: "IQ",
    965: "KW",
    966: "SA",
    971: "AE",
    972: "IL",
    974: "QA",
    981: "IR",
    65535: "US"
  };
  var XLSFillPattern = [
    null,
    "solid",
    "mediumGray",
    "darkGray",
    "lightGray",
    "darkHorizontal",
    "darkVertical",
    "darkDown",
    "darkUp",
    "darkGrid",
    "darkTrellis",
    "lightHorizontal",
    "lightVertical",
    "lightDown",
    "lightUp",
    "lightGrid",
    "lightTrellis",
    "gray125",
    "gray0625"
  ];
  function rgbify(arr) {
    return arr.map(function(x2) {
      return [x2 >> 16 & 255, x2 >> 8 & 255, x2 & 255];
    });
  }
  var _XLSIcv = /* @__PURE__ */ rgbify([
    0,
    16777215,
    16711680,
    65280,
    255,
    16776960,
    16711935,
    65535,
    0,
    16777215,
    16711680,
    65280,
    255,
    16776960,
    16711935,
    65535,
    8388608,
    32768,
    128,
    8421376,
    8388736,
    32896,
    12632256,
    8421504,
    10066431,
    10040166,
    16777164,
    13434879,
    6684774,
    16744576,
    26316,
    13421823,
    128,
    16711935,
    16776960,
    65535,
    8388736,
    8388608,
    32896,
    255,
    52479,
    13434879,
    13434828,
    16777113,
    10079487,
    16751052,
    13408767,
    16764057,
    3368703,
    3394764,
    10079232,
    16763904,
    16750848,
    16737792,
    6710937,
    9868950,
    13158,
    3381606,
    13056,
    3355392,
    10040064,
    10040166,
    3355545,
    3355443,
    16777215,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]);
  var XLSIcv = /* @__PURE__ */ dup(_XLSIcv);
  var BErr = {
    0: "#NULL!",
    7: "#DIV/0!",
    15: "#VALUE!",
    23: "#REF!",
    29: "#NAME?",
    36: "#NUM!",
    42: "#N/A",
    43: "#GETTING_DATA",
    255: "#WTF?"
  };
  var RBErr = {
    "#NULL!": 0,
    "#DIV/0!": 7,
    "#VALUE!": 15,
    "#REF!": 23,
    "#NAME?": 29,
    "#NUM!": 36,
    "#N/A": 42,
    "#GETTING_DATA": 43,
    "#WTF?": 255
  };
  var ct2type = {
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
    "application/vnd.ms-excel.sheet.macroEnabled.main+xml": "workbooks",
    "application/vnd.ms-excel.sheet.binary.macroEnabled.main": "workbooks",
    "application/vnd.ms-excel.addin.macroEnabled.main+xml": "workbooks",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": "workbooks",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": "sheets",
    "application/vnd.ms-excel.worksheet": "sheets",
    "application/vnd.ms-excel.binIndexWs": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "charts",
    "application/vnd.ms-excel.chartsheet": "charts",
    "application/vnd.ms-excel.macrosheet+xml": "macros",
    "application/vnd.ms-excel.macrosheet": "macros",
    "application/vnd.ms-excel.intlmacrosheet": "TODO",
    "application/vnd.ms-excel.binIndexMs": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "dialogs",
    "application/vnd.ms-excel.dialogsheet": "dialogs",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml": "strs",
    "application/vnd.ms-excel.sharedStrings": "strs",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": "styles",
    "application/vnd.ms-excel.styles": "styles",
    "application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
    "application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
    "application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
    "application/vnd.openxmlformats-officedocument.customXmlProperties+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
    "application/vnd.ms-excel.comments": "comments",
    "application/vnd.ms-excel.threadedcomments+xml": "threadedcomments",
    "application/vnd.ms-excel.person+xml": "people",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "metadata",
    "application/vnd.ms-excel.sheetMetadata": "metadata",
    "application/vnd.ms-excel.pivotTable": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": "TODO",
    "application/vnd.ms-office.chartcolorstyle+xml": "TODO",
    "application/vnd.ms-office.chartstyle+xml": "TODO",
    "application/vnd.ms-office.chartex+xml": "TODO",
    "application/vnd.ms-excel.calcChain": "calcchains",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml": "calcchains",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings": "TODO",
    "application/vnd.ms-office.activeX": "TODO",
    "application/vnd.ms-office.activeX+xml": "TODO",
    "application/vnd.ms-excel.attachedToolbars": "TODO",
    "application/vnd.ms-excel.connections": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": "TODO",
    "application/vnd.ms-excel.externalLink": "links",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "links",
    "application/vnd.ms-excel.pivotCacheDefinition": "TODO",
    "application/vnd.ms-excel.pivotCacheRecords": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml": "TODO",
    "application/vnd.ms-excel.queryTable": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml": "TODO",
    "application/vnd.ms-excel.userNames": "TODO",
    "application/vnd.ms-excel.revisionHeaders": "TODO",
    "application/vnd.ms-excel.revisionLog": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml": "TODO",
    "application/vnd.ms-excel.tableSingleCells": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml": "TODO",
    "application/vnd.ms-excel.slicer": "TODO",
    "application/vnd.ms-excel.slicerCache": "TODO",
    "application/vnd.ms-excel.slicer+xml": "TODO",
    "application/vnd.ms-excel.slicerCache+xml": "TODO",
    "application/vnd.ms-excel.wsSortMap": "TODO",
    "application/vnd.ms-excel.table": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.theme+xml": "themes",
    "application/vnd.openxmlformats-officedocument.themeOverride+xml": "TODO",
    "application/vnd.ms-excel.Timeline+xml": "TODO",
    "application/vnd.ms-excel.TimelineCache+xml": "TODO",
    "application/vnd.ms-office.vbaProject": "vba",
    "application/vnd.ms-office.vbaProjectSignature": "TODO",
    "application/vnd.ms-office.volatileDependencies": "TODO",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml": "TODO",
    "application/vnd.ms-excel.controlproperties+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.model+data": "TODO",
    "application/vnd.ms-excel.Survey+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawing+xml": "drawings",
    "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml": "TODO",
    "application/vnd.openxmlformats-officedocument.vmlDrawing": "TODO",
    "application/vnd.openxmlformats-package.relationships+xml": "rels",
    "application/vnd.openxmlformats-officedocument.oleObject": "TODO",
    "image/png": "TODO",
    "sheet": "js"
  };
  var CT_LIST = {
    workbooks: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
      xlsm: "application/vnd.ms-excel.sheet.macroEnabled.main+xml",
      xlsb: "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
      xlam: "application/vnd.ms-excel.addin.macroEnabled.main+xml",
      xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
    },
    strs: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
      xlsb: "application/vnd.ms-excel.sharedStrings"
    },
    comments: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
      xlsb: "application/vnd.ms-excel.comments"
    },
    sheets: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
      xlsb: "application/vnd.ms-excel.worksheet"
    },
    charts: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",
      xlsb: "application/vnd.ms-excel.chartsheet"
    },
    dialogs: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml",
      xlsb: "application/vnd.ms-excel.dialogsheet"
    },
    macros: {
      xlsx: "application/vnd.ms-excel.macrosheet+xml",
      xlsb: "application/vnd.ms-excel.macrosheet"
    },
    metadata: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",
      xlsb: "application/vnd.ms-excel.sheetMetadata"
    },
    styles: {
      xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
      xlsb: "application/vnd.ms-excel.styles"
    }
  };
  function new_ct() {
    return {
      workbooks: [],
      sheets: [],
      charts: [],
      dialogs: [],
      macros: [],
      rels: [],
      strs: [],
      comments: [],
      threadedcomments: [],
      links: [],
      coreprops: [],
      extprops: [],
      custprops: [],
      themes: [],
      styles: [],
      calcchains: [],
      vba: [],
      drawings: [],
      metadata: [],
      people: [],
      TODO: [],
      xmlns: ""
    };
  }
  function parse_ct(data) {
    var ct2 = new_ct();
    if (!data || !data.match)
      return ct2;
    var ctext = {};
    (data.match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (y[0].replace(nsregex, "<")) {
        case "<?xml":
          break;
        case "<Types":
          ct2.xmlns = y["xmlns" + (y[0].match(/<(\w+):/) || ["", ""])[1]];
          break;
        case "<Default":
          ctext[y.Extension] = y.ContentType;
          break;
        case "<Override":
          if (ct2[ct2type[y.ContentType]] !== void 0)
            ct2[ct2type[y.ContentType]].push(y.PartName);
          break;
      }
    });
    if (ct2.xmlns !== XMLNS.CT)
      throw new Error("Unknown Namespace: " + ct2.xmlns);
    ct2.calcchain = ct2.calcchains.length > 0 ? ct2.calcchains[0] : "";
    ct2.sst = ct2.strs.length > 0 ? ct2.strs[0] : "";
    ct2.style = ct2.styles.length > 0 ? ct2.styles[0] : "";
    ct2.defaults = ctext;
    delete ct2.calcchains;
    return ct2;
  }
  function write_ct(ct2, opts) {
    var type2ct = evert_arr(ct2type);
    var o2 = [], v2;
    o2[o2.length] = XML_HEADER;
    o2[o2.length] = writextag("Types", null, {
      "xmlns": XMLNS.CT,
      "xmlns:xsd": XMLNS.xsd,
      "xmlns:xsi": XMLNS.xsi
    });
    o2 = o2.concat([
      ["xml", "application/xml"],
      ["bin", "application/vnd.ms-excel.sheet.binary.macroEnabled.main"],
      ["vml", "application/vnd.openxmlformats-officedocument.vmlDrawing"],
      ["data", "application/vnd.openxmlformats-officedocument.model+data"],
      ["bmp", "image/bmp"],
      ["png", "image/png"],
      ["gif", "image/gif"],
      ["emf", "image/x-emf"],
      ["wmf", "image/x-wmf"],
      ["jpg", "image/jpeg"],
      ["jpeg", "image/jpeg"],
      ["tif", "image/tiff"],
      ["tiff", "image/tiff"],
      ["pdf", "application/pdf"],
      ["rels", "application/vnd.openxmlformats-package.relationships+xml"]
    ].map(function(x2) {
      return writextag("Default", null, { "Extension": x2[0], "ContentType": x2[1] });
    }));
    var f1 = function(w2) {
      if (ct2[w2] && ct2[w2].length > 0) {
        v2 = ct2[w2][0];
        o2[o2.length] = writextag("Override", null, {
          "PartName": (v2[0] == "/" ? "" : "/") + v2,
          "ContentType": CT_LIST[w2][opts.bookType] || CT_LIST[w2]["xlsx"]
        });
      }
    };
    var f2 = function(w2) {
      (ct2[w2] || []).forEach(function(v3) {
        o2[o2.length] = writextag("Override", null, {
          "PartName": (v3[0] == "/" ? "" : "/") + v3,
          "ContentType": CT_LIST[w2][opts.bookType] || CT_LIST[w2]["xlsx"]
        });
      });
    };
    var f3 = function(t) {
      (ct2[t] || []).forEach(function(v3) {
        o2[o2.length] = writextag("Override", null, {
          "PartName": (v3[0] == "/" ? "" : "/") + v3,
          "ContentType": type2ct[t][0]
        });
      });
    };
    f1("workbooks");
    f2("sheets");
    f2("charts");
    f3("themes");
    ["strs", "styles"].forEach(f1);
    ["coreprops", "extprops", "custprops"].forEach(f3);
    f3("vba");
    f3("comments");
    f3("threadedcomments");
    f3("drawings");
    f2("metadata");
    f3("people");
    if (o2.length > 2) {
      o2[o2.length] = "</Types>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  var RELS = {
    WB: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
    SHEET: "http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
    HLINK: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
    VML: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
    XPATH: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath",
    XMISS: "http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing",
    XLINK: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",
    CXML: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
    CXMLP: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps",
    CMNT: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
    CORE_PROPS: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
    EXT_PROPS: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
    CUST_PROPS: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",
    SST: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
    STY: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
    THEME: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
    CHART: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
    CHARTEX: "http://schemas.microsoft.com/office/2014/relationships/chartEx",
    CS: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
    WS: [
      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
      "http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
    ],
    DS: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",
    MS: "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet",
    IMG: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
    DRAW: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
    XLMETA: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata",
    TCMNT: "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",
    PEOPLE: "http://schemas.microsoft.com/office/2017/10/relationships/person",
    VBA: "http://schemas.microsoft.com/office/2006/relationships/vbaProject"
  };
  function get_rels_path(file) {
    var n = file.lastIndexOf("/");
    return file.slice(0, n + 1) + "_rels/" + file.slice(n + 1) + ".rels";
  }
  function parse_rels(data, currentFilePath) {
    var rels = { "!id": {} };
    if (!data)
      return rels;
    if (currentFilePath.charAt(0) !== "/") {
      currentFilePath = "/" + currentFilePath;
    }
    var hash = {};
    (data.match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      if (y[0] === "<Relationship") {
        var rel = {};
        rel.Type = y.Type;
        rel.Target = y.Target;
        rel.Id = y.Id;
        if (y.TargetMode)
          rel.TargetMode = y.TargetMode;
        var canonictarget = y.TargetMode === "External" ? y.Target : resolve_path(y.Target, currentFilePath);
        rels[canonictarget] = rel;
        hash[y.Id] = rel;
      }
    });
    rels["!id"] = hash;
    return rels;
  }
  function write_rels(rels) {
    var o2 = [XML_HEADER, writextag("Relationships", null, {
      "xmlns": XMLNS.RELS
    })];
    keys$1(rels["!id"]).forEach(function(rid) {
      o2[o2.length] = writextag("Relationship", null, rels["!id"][rid]);
    });
    if (o2.length > 2) {
      o2[o2.length] = "</Relationships>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function add_rels(rels, rId, f2, type, relobj, targetmode) {
    if (!relobj)
      relobj = {};
    if (!rels["!id"])
      rels["!id"] = {};
    if (!rels["!idx"])
      rels["!idx"] = 1;
    if (rId < 0)
      for (rId = rels["!idx"]; rels["!id"]["rId" + rId]; ++rId) {
      }
    rels["!idx"] = rId + 1;
    relobj.Id = "rId" + rId;
    relobj.Type = type;
    relobj.Target = f2;
    if (targetmode)
      relobj.TargetMode = targetmode;
    else if ([RELS.HLINK, RELS.XPATH, RELS.XMISS].indexOf(relobj.Type) > -1)
      relobj.TargetMode = "External";
    if (rels["!id"][relobj.Id])
      throw new Error("Cannot rewrite rId " + rId);
    rels["!id"][relobj.Id] = relobj;
    rels[("/" + relobj.Target).replace("//", "/")] = relobj;
    return rId;
  }
  var CT_ODS = "application/vnd.oasis.opendocument.spreadsheet";
  function parse_manifest(d2, opts) {
    var str = xlml_normalize(d2);
    var Rn;
    var FEtag;
    while (Rn = xlmlregex.exec(str))
      switch (Rn[3]) {
        case "manifest":
          break;
        case "file-entry":
          FEtag = parsexmltag(Rn[0], false);
          if (FEtag.path == "/" && FEtag.type !== CT_ODS)
            throw new Error("This OpenDocument is not a spreadsheet");
          break;
        case "encryption-data":
        case "algorithm":
        case "start-key-generation":
        case "key-derivation":
          throw new Error("Unsupported ODS Encryption");
        default:
          if (opts && opts.WTF)
            throw Rn;
      }
  }
  function write_manifest(manifest) {
    var o2 = [XML_HEADER];
    o2.push('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">\n');
    o2.push('  <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>\n');
    for (var i = 0; i < manifest.length; ++i)
      o2.push('  <manifest:file-entry manifest:full-path="' + manifest[i][0] + '" manifest:media-type="' + manifest[i][1] + '"/>\n');
    o2.push("</manifest:manifest>");
    return o2.join("");
  }
  function write_rdf_type(file, res, tag) {
    return [
      '  <rdf:Description rdf:about="' + file + '">\n',
      '    <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/' + (tag || "odf") + "#" + res + '"/>\n',
      "  </rdf:Description>\n"
    ].join("");
  }
  function write_rdf_has(base, file) {
    return [
      '  <rdf:Description rdf:about="' + base + '">\n',
      '    <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="' + file + '"/>\n',
      "  </rdf:Description>\n"
    ].join("");
  }
  function write_rdf(rdf) {
    var o2 = [XML_HEADER];
    o2.push('<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n');
    for (var i = 0; i != rdf.length; ++i) {
      o2.push(write_rdf_type(rdf[i][0], rdf[i][1]));
      o2.push(write_rdf_has("", rdf[i][0]));
    }
    o2.push(write_rdf_type("", "Document", "pkg"));
    o2.push("</rdf:RDF>");
    return o2.join("");
  }
  function write_meta_ods() {
    return '<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" office:version="1.2"><office:meta><meta:generator>SheetJS ' + XLSX.version + "</meta:generator></office:meta></office:document-meta>";
  }
  var CORE_PROPS = [
    ["cp:category", "Category"],
    ["cp:contentStatus", "ContentStatus"],
    ["cp:keywords", "Keywords"],
    ["cp:lastModifiedBy", "LastAuthor"],
    ["cp:lastPrinted", "LastPrinted"],
    ["cp:revision", "RevNumber"],
    ["cp:version", "Version"],
    ["dc:creator", "Author"],
    ["dc:description", "Comments"],
    ["dc:identifier", "Identifier"],
    ["dc:language", "Language"],
    ["dc:subject", "Subject"],
    ["dc:title", "Title"],
    ["dcterms:created", "CreatedDate", "date"],
    ["dcterms:modified", "ModifiedDate", "date"]
  ];
  var CORE_PROPS_REGEX = /* @__PURE__ */ function() {
    var r = new Array(CORE_PROPS.length);
    for (var i = 0; i < CORE_PROPS.length; ++i) {
      var f2 = CORE_PROPS[i];
      var g = "(?:" + f2[0].slice(0, f2[0].indexOf(":")) + ":)" + f2[0].slice(f2[0].indexOf(":") + 1);
      r[i] = new RegExp("<" + g + "[^>]*>([\\s\\S]*?)</" + g + ">");
    }
    return r;
  }();
  function parse_core_props(data) {
    var p2 = {};
    data = utf8read(data);
    for (var i = 0; i < CORE_PROPS.length; ++i) {
      var f2 = CORE_PROPS[i], cur = data.match(CORE_PROPS_REGEX[i]);
      if (cur != null && cur.length > 0)
        p2[f2[1]] = unescapexml(cur[1]);
      if (f2[2] === "date" && p2[f2[1]])
        p2[f2[1]] = parseDate(p2[f2[1]]);
    }
    return p2;
  }
  function cp_doit(f2, g, h2, o2, p2) {
    if (p2[f2] != null || g == null || g === "")
      return;
    p2[f2] = g;
    g = escapexml(g);
    o2[o2.length] = h2 ? writextag(f2, g, h2) : writetag(f2, g);
  }
  function write_core_props(cp, _opts) {
    var opts = _opts || {};
    var o2 = [XML_HEADER, writextag("cp:coreProperties", null, {
      "xmlns:cp": XMLNS.CORE_PROPS,
      "xmlns:dc": XMLNS.dc,
      "xmlns:dcterms": XMLNS.dcterms,
      "xmlns:dcmitype": XMLNS.dcmitype,
      "xmlns:xsi": XMLNS.xsi
    })], p2 = {};
    if (!cp && !opts.Props)
      return o2.join("");
    if (cp) {
      if (cp.CreatedDate != null)
        cp_doit("dcterms:created", typeof cp.CreatedDate === "string" ? cp.CreatedDate : write_w3cdtf(cp.CreatedDate, opts.WTF), { "xsi:type": "dcterms:W3CDTF" }, o2, p2);
      if (cp.ModifiedDate != null)
        cp_doit("dcterms:modified", typeof cp.ModifiedDate === "string" ? cp.ModifiedDate : write_w3cdtf(cp.ModifiedDate, opts.WTF), { "xsi:type": "dcterms:W3CDTF" }, o2, p2);
    }
    for (var i = 0; i != CORE_PROPS.length; ++i) {
      var f2 = CORE_PROPS[i];
      var v2 = opts.Props && opts.Props[f2[1]] != null ? opts.Props[f2[1]] : cp ? cp[f2[1]] : null;
      if (v2 === true)
        v2 = "1";
      else if (v2 === false)
        v2 = "0";
      else if (typeof v2 == "number")
        v2 = String(v2);
      if (v2 != null)
        cp_doit(f2[0], v2, null, o2, p2);
    }
    if (o2.length > 2) {
      o2[o2.length] = "</cp:coreProperties>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  var EXT_PROPS = [
    ["Application", "Application", "string"],
    ["AppVersion", "AppVersion", "string"],
    ["Company", "Company", "string"],
    ["DocSecurity", "DocSecurity", "string"],
    ["Manager", "Manager", "string"],
    ["HyperlinksChanged", "HyperlinksChanged", "bool"],
    ["SharedDoc", "SharedDoc", "bool"],
    ["LinksUpToDate", "LinksUpToDate", "bool"],
    ["ScaleCrop", "ScaleCrop", "bool"],
    ["HeadingPairs", "HeadingPairs", "raw"],
    ["TitlesOfParts", "TitlesOfParts", "raw"]
  ];
  var PseudoPropsPairs = [
    "Worksheets",
    "SheetNames",
    "NamedRanges",
    "DefinedNames",
    "Chartsheets",
    "ChartNames"
  ];
  function load_props_pairs(HP, TOP, props, opts) {
    var v2 = [];
    if (typeof HP == "string")
      v2 = parseVector(HP, opts);
    else
      for (var j = 0; j < HP.length; ++j)
        v2 = v2.concat(HP[j].map(function(hp) {
          return { v: hp };
        }));
    var parts = typeof TOP == "string" ? parseVector(TOP, opts).map(function(x2) {
      return x2.v;
    }) : TOP;
    var idx = 0, len = 0;
    if (parts.length > 0)
      for (var i = 0; i !== v2.length; i += 2) {
        len = +v2[i + 1].v;
        switch (v2[i].v) {
          case "Worksheets":
          case "\u5DE5\u4F5C\u8868":
          case "\u041B\u0438\u0441\u0442\u044B":
          case "\u0623\u0648\u0631\u0627\u0642 \u0627\u0644\u0639\u0645\u0644":
          case "\u30EF\u30FC\u30AF\u30B7\u30FC\u30C8":
          case "\u05D2\u05DC\u05D9\u05D5\u05E0\u05D5\u05EA \u05E2\u05D1\u05D5\u05D3\u05D4":
          case "Arbeitsbl\xE4tter":
          case "\xC7al\u0131\u015Fma Sayfalar\u0131":
          case "Feuilles de calcul":
          case "Fogli di lavoro":
          case "Folhas de c\xE1lculo":
          case "Planilhas":
          case "Regneark":
          case "Hojas de c\xE1lculo":
          case "Werkbladen":
            props.Worksheets = len;
            props.SheetNames = parts.slice(idx, idx + len);
            break;
          case "Named Ranges":
          case "Rangos con nombre":
          case "\u540D\u524D\u4ED8\u304D\u4E00\u89A7":
          case "Benannte Bereiche":
          case "Navngivne omr\xE5der":
            props.NamedRanges = len;
            props.DefinedNames = parts.slice(idx, idx + len);
            break;
          case "Charts":
          case "Diagramme":
            props.Chartsheets = len;
            props.ChartNames = parts.slice(idx, idx + len);
            break;
        }
        idx += len;
      }
  }
  function parse_ext_props(data, p2, opts) {
    var q2 = {};
    if (!p2)
      p2 = {};
    data = utf8read(data);
    EXT_PROPS.forEach(function(f2) {
      var xml = (data.match(matchtag(f2[0])) || [])[1];
      switch (f2[2]) {
        case "string":
          if (xml)
            p2[f2[1]] = unescapexml(xml);
          break;
        case "bool":
          p2[f2[1]] = xml === "true";
          break;
        case "raw":
          var cur = data.match(new RegExp("<" + f2[0] + "[^>]*>([\\s\\S]*?)</" + f2[0] + ">"));
          if (cur && cur.length > 0)
            q2[f2[1]] = cur[1];
          break;
      }
    });
    if (q2.HeadingPairs && q2.TitlesOfParts)
      load_props_pairs(q2.HeadingPairs, q2.TitlesOfParts, p2, opts);
    return p2;
  }
  function write_ext_props(cp) {
    var o2 = [], W2 = writextag;
    if (!cp)
      cp = {};
    cp.Application = "SheetJS";
    o2[o2.length] = XML_HEADER;
    o2[o2.length] = writextag("Properties", null, {
      "xmlns": XMLNS.EXT_PROPS,
      "xmlns:vt": XMLNS.vt
    });
    EXT_PROPS.forEach(function(f2) {
      if (cp[f2[1]] === void 0)
        return;
      var v2;
      switch (f2[2]) {
        case "string":
          v2 = escapexml(String(cp[f2[1]]));
          break;
        case "bool":
          v2 = cp[f2[1]] ? "true" : "false";
          break;
      }
      if (v2 !== void 0)
        o2[o2.length] = W2(f2[0], v2);
    });
    o2[o2.length] = W2("HeadingPairs", W2("vt:vector", W2("vt:variant", "<vt:lpstr>Worksheets</vt:lpstr>") + W2("vt:variant", W2("vt:i4", String(cp.Worksheets))), { size: 2, baseType: "variant" }));
    o2[o2.length] = W2("TitlesOfParts", W2("vt:vector", cp.SheetNames.map(function(s2) {
      return "<vt:lpstr>" + escapexml(s2) + "</vt:lpstr>";
    }).join(""), { size: cp.Worksheets, baseType: "lpstr" }));
    if (o2.length > 2) {
      o2[o2.length] = "</Properties>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  var custregex = /<[^>]+>[^<]*/g;
  function parse_cust_props(data, opts) {
    var p2 = {}, name = "";
    var m2 = data.match(custregex);
    if (m2)
      for (var i = 0; i != m2.length; ++i) {
        var x2 = m2[i], y = parsexmltag(x2);
        switch (y[0]) {
          case "<?xml":
            break;
          case "<Properties":
            break;
          case "<property":
            name = unescapexml(y.name);
            break;
          case "</property>":
            name = null;
            break;
          default:
            if (x2.indexOf("<vt:") === 0) {
              var toks = x2.split(">");
              var type = toks[0].slice(4), text = toks[1];
              switch (type) {
                case "lpstr":
                case "bstr":
                case "lpwstr":
                  p2[name] = unescapexml(text);
                  break;
                case "bool":
                  p2[name] = parsexmlbool(text);
                  break;
                case "i1":
                case "i2":
                case "i4":
                case "i8":
                case "int":
                case "uint":
                  p2[name] = parseInt(text, 10);
                  break;
                case "r4":
                case "r8":
                case "decimal":
                  p2[name] = parseFloat(text);
                  break;
                case "filetime":
                case "date":
                  p2[name] = parseDate(text);
                  break;
                case "cy":
                case "error":
                  p2[name] = unescapexml(text);
                  break;
                default:
                  if (type.slice(-1) == "/")
                    break;
                  if (opts.WTF && typeof console !== "undefined")
                    console.warn("Unexpected", x2, type, toks);
              }
            } else if (x2.slice(0, 2) === "</")
              ;
            else if (opts.WTF)
              throw new Error(x2);
        }
      }
    return p2;
  }
  function write_cust_props(cp) {
    var o2 = [XML_HEADER, writextag("Properties", null, {
      "xmlns": XMLNS.CUST_PROPS,
      "xmlns:vt": XMLNS.vt
    })];
    if (!cp)
      return o2.join("");
    var pid = 1;
    keys$1(cp).forEach(function custprop(k) {
      ++pid;
      o2[o2.length] = writextag("property", write_vt(cp[k], true), {
        "fmtid": "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
        "pid": pid,
        "name": escapexml(k)
      });
    });
    if (o2.length > 2) {
      o2[o2.length] = "</Properties>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  var XLMLDocPropsMap = {
    Title: "Title",
    Subject: "Subject",
    Author: "Author",
    Keywords: "Keywords",
    Comments: "Description",
    LastAuthor: "LastAuthor",
    RevNumber: "Revision",
    Application: "AppName",
    LastPrinted: "LastPrinted",
    CreatedDate: "Created",
    ModifiedDate: "LastSaved",
    Category: "Category",
    Manager: "Manager",
    Company: "Company",
    AppVersion: "Version",
    ContentStatus: "ContentStatus",
    Identifier: "Identifier",
    Language: "Language"
  };
  var evert_XLMLDPM;
  function xlml_set_prop(Props, tag, val) {
    if (!evert_XLMLDPM)
      evert_XLMLDPM = evert(XLMLDocPropsMap);
    tag = evert_XLMLDPM[tag] || tag;
    Props[tag] = val;
  }
  function xlml_write_docprops(Props, opts) {
    var o2 = [];
    keys$1(XLMLDocPropsMap).map(function(m2) {
      for (var i = 0; i < CORE_PROPS.length; ++i)
        if (CORE_PROPS[i][1] == m2)
          return CORE_PROPS[i];
      for (i = 0; i < EXT_PROPS.length; ++i)
        if (EXT_PROPS[i][1] == m2)
          return EXT_PROPS[i];
      throw m2;
    }).forEach(function(p2) {
      if (Props[p2[1]] == null)
        return;
      var m2 = opts && opts.Props && opts.Props[p2[1]] != null ? opts.Props[p2[1]] : Props[p2[1]];
      switch (p2[2]) {
        case "date":
          m2 = new Date(m2).toISOString().replace(/\.\d*Z/, "Z");
          break;
      }
      if (typeof m2 == "number")
        m2 = String(m2);
      else if (m2 === true || m2 === false) {
        m2 = m2 ? "1" : "0";
      } else if (m2 instanceof Date)
        m2 = new Date(m2).toISOString().replace(/\.\d*Z/, "");
      o2.push(writetag(XLMLDocPropsMap[p2[1]] || p2[1], m2));
    });
    return writextag("DocumentProperties", o2.join(""), { xmlns: XLMLNS.o });
  }
  function xlml_write_custprops(Props, Custprops) {
    var BLACKLIST = ["Worksheets", "SheetNames"];
    var T2 = "CustomDocumentProperties";
    var o2 = [];
    if (Props)
      keys$1(Props).forEach(function(k) {
        if (!Object.prototype.hasOwnProperty.call(Props, k))
          return;
        for (var i = 0; i < CORE_PROPS.length; ++i)
          if (k == CORE_PROPS[i][1])
            return;
        for (i = 0; i < EXT_PROPS.length; ++i)
          if (k == EXT_PROPS[i][1])
            return;
        for (i = 0; i < BLACKLIST.length; ++i)
          if (k == BLACKLIST[i])
            return;
        var m2 = Props[k];
        var t = "string";
        if (typeof m2 == "number") {
          t = "float";
          m2 = String(m2);
        } else if (m2 === true || m2 === false) {
          t = "boolean";
          m2 = m2 ? "1" : "0";
        } else
          m2 = String(m2);
        o2.push(writextag(escapexmltag(k), m2, { "dt:dt": t }));
      });
    if (Custprops)
      keys$1(Custprops).forEach(function(k) {
        if (!Object.prototype.hasOwnProperty.call(Custprops, k))
          return;
        if (Props && Object.prototype.hasOwnProperty.call(Props, k))
          return;
        var m2 = Custprops[k];
        var t = "string";
        if (typeof m2 == "number") {
          t = "float";
          m2 = String(m2);
        } else if (m2 === true || m2 === false) {
          t = "boolean";
          m2 = m2 ? "1" : "0";
        } else if (m2 instanceof Date) {
          t = "dateTime.tz";
          m2 = m2.toISOString();
        } else
          m2 = String(m2);
        o2.push(writextag(escapexmltag(k), m2, { "dt:dt": t }));
      });
    return "<" + T2 + ' xmlns="' + XLMLNS.o + '">' + o2.join("") + "</" + T2 + ">";
  }
  function parse_FILETIME(blob) {
    var dwLowDateTime = blob.read_shift(4), dwHighDateTime = blob.read_shift(4);
    return new Date((dwHighDateTime / 1e7 * Math.pow(2, 32) + dwLowDateTime / 1e7 - 11644473600) * 1e3).toISOString().replace(/\.000/, "");
  }
  function write_FILETIME(time) {
    var date = typeof time == "string" ? new Date(Date.parse(time)) : time;
    var t = date.getTime() / 1e3 + 11644473600;
    var l2 = t % Math.pow(2, 32), h2 = (t - l2) / Math.pow(2, 32);
    l2 *= 1e7;
    h2 *= 1e7;
    var w2 = l2 / Math.pow(2, 32) | 0;
    if (w2 > 0) {
      l2 = l2 % Math.pow(2, 32);
      h2 += w2;
    }
    var o2 = new_buf(8);
    o2.write_shift(4, l2);
    o2.write_shift(4, h2);
    return o2;
  }
  function parse_lpstr(blob, type, pad) {
    var start = blob.l;
    var str = blob.read_shift(0, "lpstr-cp");
    if (pad)
      while (blob.l - start & 3)
        ++blob.l;
    return str;
  }
  function parse_lpwstr(blob, type, pad) {
    var str = blob.read_shift(0, "lpwstr");
    if (pad)
      blob.l += 4 - (str.length + 1 & 3) & 3;
    return str;
  }
  function parse_VtStringBase(blob, stringType, pad) {
    if (stringType === 31)
      return parse_lpwstr(blob);
    return parse_lpstr(blob, stringType, pad);
  }
  function parse_VtString(blob, t, pad) {
    return parse_VtStringBase(blob, t, pad === false ? 0 : 4);
  }
  function parse_VtUnalignedString(blob, t) {
    if (!t)
      throw new Error("VtUnalignedString must have positive length");
    return parse_VtStringBase(blob, t, 0);
  }
  function parse_VtVecLpwstrValue(blob) {
    var length = blob.read_shift(4);
    var ret = [];
    for (var i = 0; i != length; ++i) {
      var start = blob.l;
      ret[i] = blob.read_shift(0, "lpwstr").replace(chr0, "");
      if (blob.l - start & 2)
        blob.l += 2;
    }
    return ret;
  }
  function parse_VtVecUnalignedLpstrValue(blob) {
    var length = blob.read_shift(4);
    var ret = [];
    for (var i = 0; i != length; ++i)
      ret[i] = blob.read_shift(0, "lpstr-cp").replace(chr0, "");
    return ret;
  }
  function parse_VtHeadingPair(blob) {
    var start = blob.l;
    var headingString = parse_TypedPropertyValue(blob, VT_USTR);
    if (blob[blob.l] == 0 && blob[blob.l + 1] == 0 && blob.l - start & 2)
      blob.l += 2;
    var headerParts = parse_TypedPropertyValue(blob, VT_I4);
    return [headingString, headerParts];
  }
  function parse_VtVecHeadingPairValue(blob) {
    var cElements = blob.read_shift(4);
    var out = [];
    for (var i = 0; i < cElements / 2; ++i)
      out.push(parse_VtHeadingPair(blob));
    return out;
  }
  function parse_dictionary(blob, CodePage) {
    var cnt = blob.read_shift(4);
    var dict = {};
    for (var j = 0; j != cnt; ++j) {
      var pid = blob.read_shift(4);
      var len = blob.read_shift(4);
      dict[pid] = blob.read_shift(len, CodePage === 1200 ? "utf16le" : "utf8").replace(chr0, "").replace(chr1, "!");
      if (CodePage === 1200 && len % 2)
        blob.l += 2;
    }
    if (blob.l & 3)
      blob.l = blob.l >> 2 + 1 << 2;
    return dict;
  }
  function parse_BLOB(blob) {
    var size2 = blob.read_shift(4);
    var bytes = blob.slice(blob.l, blob.l + size2);
    blob.l += size2;
    if ((size2 & 3) > 0)
      blob.l += 4 - (size2 & 3) & 3;
    return bytes;
  }
  function parse_ClipboardData(blob) {
    var o2 = {};
    o2.Size = blob.read_shift(4);
    blob.l += o2.Size + 3 - (o2.Size - 1) % 4;
    return o2;
  }
  function parse_TypedPropertyValue(blob, type, _opts) {
    var t = blob.read_shift(2), ret, opts = _opts || {};
    blob.l += 2;
    if (type !== VT_VARIANT) {
      if (t !== type && VT_CUSTOM.indexOf(type) === -1 && !((type & 65534) == 4126 && (t & 65534) == 4126))
        throw new Error("Expected type " + type + " saw " + t);
    }
    switch (type === VT_VARIANT ? t : type) {
      case 2:
        ret = blob.read_shift(2, "i");
        if (!opts.raw)
          blob.l += 2;
        return ret;
      case 3:
        ret = blob.read_shift(4, "i");
        return ret;
      case 11:
        return blob.read_shift(4) !== 0;
      case 19:
        ret = blob.read_shift(4);
        return ret;
      case 30:
        return parse_lpstr(blob, t, 4).replace(chr0, "");
      case 31:
        return parse_lpwstr(blob);
      case 64:
        return parse_FILETIME(blob);
      case 65:
        return parse_BLOB(blob);
      case 71:
        return parse_ClipboardData(blob);
      case 80:
        return parse_VtString(blob, t, !opts.raw).replace(chr0, "");
      case 81:
        return parse_VtUnalignedString(blob, t).replace(chr0, "");
      case 4108:
        return parse_VtVecHeadingPairValue(blob);
      case 4126:
      case 4127:
        return t == 4127 ? parse_VtVecLpwstrValue(blob) : parse_VtVecUnalignedLpstrValue(blob);
      default:
        throw new Error("TypedPropertyValue unrecognized type " + type + " " + t);
    }
  }
  function write_TypedPropertyValue(type, value) {
    var o2 = new_buf(4), p2 = new_buf(4);
    o2.write_shift(4, type == 80 ? 31 : type);
    switch (type) {
      case 3:
        p2.write_shift(-4, value);
        break;
      case 5:
        p2 = new_buf(8);
        p2.write_shift(8, value, "f");
        break;
      case 11:
        p2.write_shift(4, value ? 1 : 0);
        break;
      case 64:
        p2 = write_FILETIME(value);
        break;
      case 31:
      case 80:
        p2 = new_buf(4 + 2 * (value.length + 1) + (value.length % 2 ? 0 : 2));
        p2.write_shift(4, value.length + 1);
        p2.write_shift(0, value, "dbcs");
        while (p2.l != p2.length)
          p2.write_shift(1, 0);
        break;
      default:
        throw new Error("TypedPropertyValue unrecognized type " + type + " " + value);
    }
    return bconcat([o2, p2]);
  }
  function parse_PropertySet(blob, PIDSI) {
    var start_addr = blob.l;
    var size2 = blob.read_shift(4);
    var NumProps = blob.read_shift(4);
    var Props = [], i = 0;
    var CodePage = 0;
    var Dictionary = -1, DictObj = {};
    for (i = 0; i != NumProps; ++i) {
      var PropID = blob.read_shift(4);
      var Offset = blob.read_shift(4);
      Props[i] = [PropID, Offset + start_addr];
    }
    Props.sort(function(x2, y) {
      return x2[1] - y[1];
    });
    var PropH = {};
    for (i = 0; i != NumProps; ++i) {
      if (blob.l !== Props[i][1]) {
        var fail = true;
        if (i > 0 && PIDSI)
          switch (PIDSI[Props[i - 1][0]].t) {
            case 2:
              if (blob.l + 2 === Props[i][1]) {
                blob.l += 2;
                fail = false;
              }
              break;
            case 80:
              if (blob.l <= Props[i][1]) {
                blob.l = Props[i][1];
                fail = false;
              }
              break;
            case 4108:
              if (blob.l <= Props[i][1]) {
                blob.l = Props[i][1];
                fail = false;
              }
              break;
          }
        if ((!PIDSI || i == 0) && blob.l <= Props[i][1]) {
          fail = false;
          blob.l = Props[i][1];
        }
        if (fail)
          throw new Error("Read Error: Expected address " + Props[i][1] + " at " + blob.l + " :" + i);
      }
      if (PIDSI) {
        var piddsi = PIDSI[Props[i][0]];
        PropH[piddsi.n] = parse_TypedPropertyValue(blob, piddsi.t, { raw: true });
        if (piddsi.p === "version")
          PropH[piddsi.n] = String(PropH[piddsi.n] >> 16) + "." + ("0000" + String(PropH[piddsi.n] & 65535)).slice(-4);
        if (piddsi.n == "CodePage")
          switch (PropH[piddsi.n]) {
            case 0:
              PropH[piddsi.n] = 1252;
            case 874:
            case 932:
            case 936:
            case 949:
            case 950:
            case 1250:
            case 1251:
            case 1253:
            case 1254:
            case 1255:
            case 1256:
            case 1257:
            case 1258:
            case 1e4:
            case 1200:
            case 1201:
            case 1252:
            case 65e3:
            case -536:
            case 65001:
            case -535:
              set_cp(CodePage = PropH[piddsi.n] >>> 0 & 65535);
              break;
            default:
              throw new Error("Unsupported CodePage: " + PropH[piddsi.n]);
          }
      } else {
        if (Props[i][0] === 1) {
          CodePage = PropH.CodePage = parse_TypedPropertyValue(blob, VT_I2);
          set_cp(CodePage);
          if (Dictionary !== -1) {
            var oldpos = blob.l;
            blob.l = Props[Dictionary][1];
            DictObj = parse_dictionary(blob, CodePage);
            blob.l = oldpos;
          }
        } else if (Props[i][0] === 0) {
          if (CodePage === 0) {
            Dictionary = i;
            blob.l = Props[i + 1][1];
            continue;
          }
          DictObj = parse_dictionary(blob, CodePage);
        } else {
          var name = DictObj[Props[i][0]];
          var val;
          switch (blob[blob.l]) {
            case 65:
              blob.l += 4;
              val = parse_BLOB(blob);
              break;
            case 30:
              blob.l += 4;
              val = parse_VtString(blob, blob[blob.l - 4]).replace(/\u0000+$/, "");
              break;
            case 31:
              blob.l += 4;
              val = parse_VtString(blob, blob[blob.l - 4]).replace(/\u0000+$/, "");
              break;
            case 3:
              blob.l += 4;
              val = blob.read_shift(4, "i");
              break;
            case 19:
              blob.l += 4;
              val = blob.read_shift(4);
              break;
            case 5:
              blob.l += 4;
              val = blob.read_shift(8, "f");
              break;
            case 11:
              blob.l += 4;
              val = parsebool(blob, 4);
              break;
            case 64:
              blob.l += 4;
              val = parseDate(parse_FILETIME(blob));
              break;
            default:
              throw new Error("unparsed value: " + blob[blob.l]);
          }
          PropH[name] = val;
        }
      }
    }
    blob.l = start_addr + size2;
    return PropH;
  }
  var XLSPSSkip = ["CodePage", "Thumbnail", "_PID_LINKBASE", "_PID_HLINKS", "SystemIdentifier", "FMTID"];
  function guess_property_type(val) {
    switch (typeof val) {
      case "boolean":
        return 11;
      case "number":
        return (val | 0) == val ? 3 : 5;
      case "string":
        return 31;
      case "object":
        if (val instanceof Date)
          return 64;
        break;
    }
    return -1;
  }
  function write_PropertySet(entries, RE, PIDSI) {
    var hdr = new_buf(8), piao = [], prop = [];
    var sz = 8, i = 0;
    var pr = new_buf(8), pio = new_buf(8);
    pr.write_shift(4, 2);
    pr.write_shift(4, 1200);
    pio.write_shift(4, 1);
    prop.push(pr);
    piao.push(pio);
    sz += 8 + pr.length;
    if (!RE) {
      pio = new_buf(8);
      pio.write_shift(4, 0);
      piao.unshift(pio);
      var bufs = [new_buf(4)];
      bufs[0].write_shift(4, entries.length);
      for (i = 0; i < entries.length; ++i) {
        var value = entries[i][0];
        pr = new_buf(4 + 4 + 2 * (value.length + 1) + (value.length % 2 ? 0 : 2));
        pr.write_shift(4, i + 2);
        pr.write_shift(4, value.length + 1);
        pr.write_shift(0, value, "dbcs");
        while (pr.l != pr.length)
          pr.write_shift(1, 0);
        bufs.push(pr);
      }
      pr = bconcat(bufs);
      prop.unshift(pr);
      sz += 8 + pr.length;
    }
    for (i = 0; i < entries.length; ++i) {
      if (RE && !RE[entries[i][0]])
        continue;
      if (XLSPSSkip.indexOf(entries[i][0]) > -1 || PseudoPropsPairs.indexOf(entries[i][0]) > -1)
        continue;
      if (entries[i][1] == null)
        continue;
      var val = entries[i][1], idx = 0;
      if (RE) {
        idx = +RE[entries[i][0]];
        var pinfo = PIDSI[idx];
        if (pinfo.p == "version" && typeof val == "string") {
          var arr = val.split(".");
          val = (+arr[0] << 16) + (+arr[1] || 0);
        }
        pr = write_TypedPropertyValue(pinfo.t, val);
      } else {
        var T2 = guess_property_type(val);
        if (T2 == -1) {
          T2 = 31;
          val = String(val);
        }
        pr = write_TypedPropertyValue(T2, val);
      }
      prop.push(pr);
      pio = new_buf(8);
      pio.write_shift(4, !RE ? 2 + i : idx);
      piao.push(pio);
      sz += 8 + pr.length;
    }
    var w2 = 8 * (prop.length + 1);
    for (i = 0; i < prop.length; ++i) {
      piao[i].write_shift(4, w2);
      w2 += prop[i].length;
    }
    hdr.write_shift(4, sz);
    hdr.write_shift(4, prop.length);
    return bconcat([hdr].concat(piao).concat(prop));
  }
  function parse_PropertySetStream(file, PIDSI, clsid) {
    var blob = file.content;
    if (!blob)
      return {};
    prep_blob(blob, 0);
    var NumSets, FMTID0, FMTID1, Offset0, Offset1 = 0;
    blob.chk("feff", "Byte Order: ");
    blob.read_shift(2);
    var SystemIdentifier = blob.read_shift(4);
    var CLSID = blob.read_shift(16);
    if (CLSID !== CFB.utils.consts.HEADER_CLSID && CLSID !== clsid)
      throw new Error("Bad PropertySet CLSID " + CLSID);
    NumSets = blob.read_shift(4);
    if (NumSets !== 1 && NumSets !== 2)
      throw new Error("Unrecognized #Sets: " + NumSets);
    FMTID0 = blob.read_shift(16);
    Offset0 = blob.read_shift(4);
    if (NumSets === 1 && Offset0 !== blob.l)
      throw new Error("Length mismatch: " + Offset0 + " !== " + blob.l);
    else if (NumSets === 2) {
      FMTID1 = blob.read_shift(16);
      Offset1 = blob.read_shift(4);
    }
    var PSet0 = parse_PropertySet(blob, PIDSI);
    var rval = { SystemIdentifier };
    for (var y in PSet0)
      rval[y] = PSet0[y];
    rval.FMTID = FMTID0;
    if (NumSets === 1)
      return rval;
    if (Offset1 - blob.l == 2)
      blob.l += 2;
    if (blob.l !== Offset1)
      throw new Error("Length mismatch 2: " + blob.l + " !== " + Offset1);
    var PSet1;
    try {
      PSet1 = parse_PropertySet(blob, null);
    } catch (e) {
    }
    for (y in PSet1)
      rval[y] = PSet1[y];
    rval.FMTID = [FMTID0, FMTID1];
    return rval;
  }
  function write_PropertySetStream(entries, clsid, RE, PIDSI, entries2, clsid2) {
    var hdr = new_buf(entries2 ? 68 : 48);
    var bufs = [hdr];
    hdr.write_shift(2, 65534);
    hdr.write_shift(2, 0);
    hdr.write_shift(4, 842412599);
    hdr.write_shift(16, CFB.utils.consts.HEADER_CLSID, "hex");
    hdr.write_shift(4, entries2 ? 2 : 1);
    hdr.write_shift(16, clsid, "hex");
    hdr.write_shift(4, entries2 ? 68 : 48);
    var ps0 = write_PropertySet(entries, RE, PIDSI);
    bufs.push(ps0);
    if (entries2) {
      var ps1 = write_PropertySet(entries2, null, null);
      hdr.write_shift(16, clsid2, "hex");
      hdr.write_shift(4, 68 + ps0.length);
      bufs.push(ps1);
    }
    return bconcat(bufs);
  }
  function parsenoop2(blob, length) {
    blob.read_shift(length);
    return null;
  }
  function writezeroes(n, o2) {
    if (!o2)
      o2 = new_buf(n);
    for (var j = 0; j < n; ++j)
      o2.write_shift(1, 0);
    return o2;
  }
  function parslurp(blob, length, cb) {
    var arr = [], target = blob.l + length;
    while (blob.l < target)
      arr.push(cb(blob, target - blob.l));
    if (target !== blob.l)
      throw new Error("Slurp error");
    return arr;
  }
  function parsebool(blob, length) {
    return blob.read_shift(length) === 1;
  }
  function writebool(v2, o2) {
    if (!o2)
      o2 = new_buf(2);
    o2.write_shift(2, +!!v2);
    return o2;
  }
  function parseuint16(blob) {
    return blob.read_shift(2, "u");
  }
  function writeuint16(v2, o2) {
    if (!o2)
      o2 = new_buf(2);
    o2.write_shift(2, v2);
    return o2;
  }
  function parseuint16a(blob, length) {
    return parslurp(blob, length, parseuint16);
  }
  function parse_Bes(blob) {
    var v2 = blob.read_shift(1), t = blob.read_shift(1);
    return t === 1 ? v2 : v2 === 1;
  }
  function write_Bes(v2, t, o2) {
    if (!o2)
      o2 = new_buf(2);
    o2.write_shift(1, t == "e" ? +v2 : +!!v2);
    o2.write_shift(1, t == "e" ? 1 : 0);
    return o2;
  }
  function parse_ShortXLUnicodeString(blob, length, opts) {
    var cch = blob.read_shift(opts && opts.biff >= 12 ? 2 : 1);
    var encoding = "sbcs-cont";
    if (opts && opts.biff >= 8)
      ;
    if (!opts || opts.biff == 8) {
      var fHighByte = blob.read_shift(1);
      if (fHighByte) {
        encoding = "dbcs-cont";
      }
    } else if (opts.biff == 12) {
      encoding = "wstr";
    }
    if (opts.biff >= 2 && opts.biff <= 5)
      encoding = "cpstr";
    var o2 = cch ? blob.read_shift(cch, encoding) : "";
    return o2;
  }
  function parse_XLUnicodeRichExtendedString(blob) {
    var cch = blob.read_shift(2), flags = blob.read_shift(1);
    var fExtSt = flags & 4, fRichSt = flags & 8;
    var width = 1 + (flags & 1);
    var cRun = 0, cbExtRst;
    var z = {};
    if (fRichSt)
      cRun = blob.read_shift(2);
    if (fExtSt)
      cbExtRst = blob.read_shift(4);
    var encoding = width == 2 ? "dbcs-cont" : "sbcs-cont";
    var msg = cch === 0 ? "" : blob.read_shift(cch, encoding);
    if (fRichSt)
      blob.l += 4 * cRun;
    if (fExtSt)
      blob.l += cbExtRst;
    z.t = msg;
    if (!fRichSt) {
      z.raw = "<t>" + z.t + "</t>";
      z.r = z.t;
    }
    return z;
  }
  function write_XLUnicodeRichExtendedString(xlstr) {
    var str = xlstr.t || "";
    var hdr = new_buf(3 + 0);
    hdr.write_shift(2, str.length);
    hdr.write_shift(1, 0 | 1);
    var otext = new_buf(2 * str.length);
    otext.write_shift(2 * str.length, str, "utf16le");
    var out = [hdr, otext];
    return bconcat(out);
  }
  function parse_XLUnicodeStringNoCch(blob, cch, opts) {
    var retval;
    if (opts) {
      if (opts.biff >= 2 && opts.biff <= 5)
        return blob.read_shift(cch, "cpstr");
      if (opts.biff >= 12)
        return blob.read_shift(cch, "dbcs-cont");
    }
    var fHighByte = blob.read_shift(1);
    if (fHighByte === 0) {
      retval = blob.read_shift(cch, "sbcs-cont");
    } else {
      retval = blob.read_shift(cch, "dbcs-cont");
    }
    return retval;
  }
  function parse_XLUnicodeString(blob, length, opts) {
    var cch = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    if (cch === 0) {
      blob.l++;
      return "";
    }
    return parse_XLUnicodeStringNoCch(blob, cch, opts);
  }
  function parse_XLUnicodeString2(blob, length, opts) {
    if (opts.biff > 5)
      return parse_XLUnicodeString(blob, length, opts);
    var cch = blob.read_shift(1);
    if (cch === 0) {
      blob.l++;
      return "";
    }
    return blob.read_shift(cch, opts.biff <= 4 || !blob.lens ? "cpstr" : "sbcs-cont");
  }
  function write_XLUnicodeString(str, opts, o2) {
    if (!o2)
      o2 = new_buf(3 + 2 * str.length);
    o2.write_shift(2, str.length);
    o2.write_shift(1, 1);
    o2.write_shift(31, str, "utf16le");
    return o2;
  }
  function parse_ControlInfo(blob) {
    var flags = blob.read_shift(1);
    blob.l++;
    var accel = blob.read_shift(2);
    blob.l += 2;
    return [flags, accel];
  }
  function parse_URLMoniker(blob) {
    var len = blob.read_shift(4), start = blob.l;
    var extra = false;
    if (len > 24) {
      blob.l += len - 24;
      if (blob.read_shift(16) === "795881f43b1d7f48af2c825dc4852763")
        extra = true;
      blob.l = start;
    }
    var url = blob.read_shift((extra ? len - 24 : len) >> 1, "utf16le").replace(chr0, "");
    if (extra)
      blob.l += 24;
    return url;
  }
  function parse_FileMoniker(blob) {
    var cAnti = blob.read_shift(2);
    var preamble = "";
    while (cAnti-- > 0)
      preamble += "../";
    var ansiPath = blob.read_shift(0, "lpstr-ansi");
    blob.l += 2;
    if (blob.read_shift(2) != 57005)
      throw new Error("Bad FileMoniker");
    var sz = blob.read_shift(4);
    if (sz === 0)
      return preamble + ansiPath.replace(/\\/g, "/");
    var bytes = blob.read_shift(4);
    if (blob.read_shift(2) != 3)
      throw new Error("Bad FileMoniker");
    var unicodePath = blob.read_shift(bytes >> 1, "utf16le").replace(chr0, "");
    return preamble + unicodePath;
  }
  function parse_HyperlinkMoniker(blob, length) {
    var clsid = blob.read_shift(16);
    switch (clsid) {
      case "e0c9ea79f9bace118c8200aa004ba90b":
        return parse_URLMoniker(blob);
      case "0303000000000000c000000000000046":
        return parse_FileMoniker(blob);
      default:
        throw new Error("Unsupported Moniker " + clsid);
    }
  }
  function parse_HyperlinkString(blob) {
    var len = blob.read_shift(4);
    var o2 = len > 0 ? blob.read_shift(len, "utf16le").replace(chr0, "") : "";
    return o2;
  }
  function write_HyperlinkString(str, o2) {
    if (!o2)
      o2 = new_buf(6 + str.length * 2);
    o2.write_shift(4, 1 + str.length);
    for (var i = 0; i < str.length; ++i)
      o2.write_shift(2, str.charCodeAt(i));
    o2.write_shift(2, 0);
    return o2;
  }
  function parse_Hyperlink(blob, length) {
    var end = blob.l + length;
    var sVer = blob.read_shift(4);
    if (sVer !== 2)
      throw new Error("Unrecognized streamVersion: " + sVer);
    var flags = blob.read_shift(2);
    blob.l += 2;
    var displayName, targetFrameName, moniker, oleMoniker, Loc = "", guid, fileTime;
    if (flags & 16)
      displayName = parse_HyperlinkString(blob, end - blob.l);
    if (flags & 128)
      targetFrameName = parse_HyperlinkString(blob, end - blob.l);
    if ((flags & 257) === 257)
      moniker = parse_HyperlinkString(blob, end - blob.l);
    if ((flags & 257) === 1)
      oleMoniker = parse_HyperlinkMoniker(blob, end - blob.l);
    if (flags & 8)
      Loc = parse_HyperlinkString(blob, end - blob.l);
    if (flags & 32)
      guid = blob.read_shift(16);
    if (flags & 64)
      fileTime = parse_FILETIME(blob);
    blob.l = end;
    var target = targetFrameName || moniker || oleMoniker || "";
    if (target && Loc)
      target += "#" + Loc;
    if (!target)
      target = "#" + Loc;
    if (flags & 2 && target.charAt(0) == "/" && target.charAt(1) != "/")
      target = "file://" + target;
    var out = { Target: target };
    if (guid)
      out.guid = guid;
    if (fileTime)
      out.time = fileTime;
    if (displayName)
      out.Tooltip = displayName;
    return out;
  }
  function write_Hyperlink(hl) {
    var out = new_buf(512), i = 0;
    var Target = hl.Target;
    if (Target.slice(0, 7) == "file://")
      Target = Target.slice(7);
    var hashidx = Target.indexOf("#");
    var F2 = hashidx > -1 ? 31 : 23;
    switch (Target.charAt(0)) {
      case "#":
        F2 = 28;
        break;
      case ".":
        F2 &= ~2;
        break;
    }
    out.write_shift(4, 2);
    out.write_shift(4, F2);
    var data = [8, 6815827, 6619237, 4849780, 83];
    for (i = 0; i < data.length; ++i)
      out.write_shift(4, data[i]);
    if (F2 == 28) {
      Target = Target.slice(1);
      write_HyperlinkString(Target, out);
    } else if (F2 & 2) {
      data = "e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" ");
      for (i = 0; i < data.length; ++i)
        out.write_shift(1, parseInt(data[i], 16));
      var Pretarget = hashidx > -1 ? Target.slice(0, hashidx) : Target;
      out.write_shift(4, 2 * (Pretarget.length + 1));
      for (i = 0; i < Pretarget.length; ++i)
        out.write_shift(2, Pretarget.charCodeAt(i));
      out.write_shift(2, 0);
      if (F2 & 8)
        write_HyperlinkString(hashidx > -1 ? Target.slice(hashidx + 1) : "", out);
    } else {
      data = "03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46".split(" ");
      for (i = 0; i < data.length; ++i)
        out.write_shift(1, parseInt(data[i], 16));
      var P2 = 0;
      while (Target.slice(P2 * 3, P2 * 3 + 3) == "../" || Target.slice(P2 * 3, P2 * 3 + 3) == "..\\")
        ++P2;
      out.write_shift(2, P2);
      out.write_shift(4, Target.length - 3 * P2 + 1);
      for (i = 0; i < Target.length - 3 * P2; ++i)
        out.write_shift(1, Target.charCodeAt(i + 3 * P2) & 255);
      out.write_shift(1, 0);
      out.write_shift(2, 65535);
      out.write_shift(2, 57005);
      for (i = 0; i < 6; ++i)
        out.write_shift(4, 0);
    }
    return out.slice(0, out.l);
  }
  function parse_LongRGBA(blob) {
    var r = blob.read_shift(1), g = blob.read_shift(1), b2 = blob.read_shift(1), a2 = blob.read_shift(1);
    return [r, g, b2, a2];
  }
  function parse_LongRGB(blob, length) {
    var x2 = parse_LongRGBA(blob);
    x2[3] = 0;
    return x2;
  }
  function parse_XLSCell(blob) {
    var rw = blob.read_shift(2);
    var col = blob.read_shift(2);
    var ixfe = blob.read_shift(2);
    return { r: rw, c: col, ixfe };
  }
  function write_XLSCell(R2, C2, ixfe, o2) {
    if (!o2)
      o2 = new_buf(6);
    o2.write_shift(2, R2);
    o2.write_shift(2, C2);
    o2.write_shift(2, ixfe || 0);
    return o2;
  }
  function parse_frtHeader(blob) {
    var rt2 = blob.read_shift(2);
    var flags = blob.read_shift(2);
    blob.l += 8;
    return { type: rt2, flags };
  }
  function parse_OptXLUnicodeString(blob, length, opts) {
    return length === 0 ? "" : parse_XLUnicodeString2(blob, length, opts);
  }
  function parse_XTI(blob, length, opts) {
    var w2 = opts.biff > 8 ? 4 : 2;
    var iSupBook = blob.read_shift(w2), itabFirst = blob.read_shift(w2, "i"), itabLast = blob.read_shift(w2, "i");
    return [iSupBook, itabFirst, itabLast];
  }
  function parse_RkRec(blob) {
    var ixfe = blob.read_shift(2);
    var RK = parse_RkNumber(blob);
    return [ixfe, RK];
  }
  function parse_AddinUdf(blob, length, opts) {
    blob.l += 4;
    length -= 4;
    var l2 = blob.l + length;
    var udfName = parse_ShortXLUnicodeString(blob, length, opts);
    var cb = blob.read_shift(2);
    l2 -= blob.l;
    if (cb !== l2)
      throw new Error("Malformed AddinUdf: padding = " + l2 + " != " + cb);
    blob.l += cb;
    return udfName;
  }
  function parse_Ref8U(blob) {
    var rwFirst = blob.read_shift(2);
    var rwLast = blob.read_shift(2);
    var colFirst = blob.read_shift(2);
    var colLast = blob.read_shift(2);
    return { s: { c: colFirst, r: rwFirst }, e: { c: colLast, r: rwLast } };
  }
  function write_Ref8U(r, o2) {
    if (!o2)
      o2 = new_buf(8);
    o2.write_shift(2, r.s.r);
    o2.write_shift(2, r.e.r);
    o2.write_shift(2, r.s.c);
    o2.write_shift(2, r.e.c);
    return o2;
  }
  function parse_RefU(blob) {
    var rwFirst = blob.read_shift(2);
    var rwLast = blob.read_shift(2);
    var colFirst = blob.read_shift(1);
    var colLast = blob.read_shift(1);
    return { s: { c: colFirst, r: rwFirst }, e: { c: colLast, r: rwLast } };
  }
  var parse_Ref = parse_RefU;
  function parse_FtCmo(blob) {
    blob.l += 4;
    var ot2 = blob.read_shift(2);
    var id = blob.read_shift(2);
    var flags = blob.read_shift(2);
    blob.l += 12;
    return [id, ot2, flags];
  }
  function parse_FtNts(blob) {
    var out = {};
    blob.l += 4;
    blob.l += 16;
    out.fSharedNote = blob.read_shift(2);
    blob.l += 4;
    return out;
  }
  function parse_FtCf(blob) {
    var out = {};
    blob.l += 4;
    blob.cf = blob.read_shift(2);
    return out;
  }
  function parse_FtSkip(blob) {
    blob.l += 2;
    blob.l += blob.read_shift(2);
  }
  var FtTab = {
    0: parse_FtSkip,
    4: parse_FtSkip,
    5: parse_FtSkip,
    6: parse_FtSkip,
    7: parse_FtCf,
    8: parse_FtSkip,
    9: parse_FtSkip,
    10: parse_FtSkip,
    11: parse_FtSkip,
    12: parse_FtSkip,
    13: parse_FtNts,
    14: parse_FtSkip,
    15: parse_FtSkip,
    16: parse_FtSkip,
    17: parse_FtSkip,
    18: parse_FtSkip,
    19: parse_FtSkip,
    20: parse_FtSkip,
    21: parse_FtCmo
  };
  function parse_FtArray(blob, length) {
    var tgt = blob.l + length;
    var fts = [];
    while (blob.l < tgt) {
      var ft2 = blob.read_shift(2);
      blob.l -= 2;
      try {
        fts.push(FtTab[ft2](blob, tgt - blob.l));
      } catch (e) {
        blob.l = tgt;
        return fts;
      }
    }
    if (blob.l != tgt)
      blob.l = tgt;
    return fts;
  }
  function parse_BOF(blob, length) {
    var o2 = { BIFFVer: 0, dt: 0 };
    o2.BIFFVer = blob.read_shift(2);
    length -= 2;
    if (length >= 2) {
      o2.dt = blob.read_shift(2);
      blob.l -= 2;
    }
    switch (o2.BIFFVer) {
      case 1536:
      case 1280:
      case 1024:
      case 768:
      case 512:
      case 2:
      case 7:
        break;
      default:
        if (length > 6)
          throw new Error("Unexpected BIFF Ver " + o2.BIFFVer);
    }
    blob.read_shift(length);
    return o2;
  }
  function write_BOF(wb, t, o2) {
    var h2 = 1536, w2 = 16;
    switch (o2.bookType) {
      case "biff8":
        break;
      case "biff5":
        h2 = 1280;
        w2 = 8;
        break;
      case "biff4":
        h2 = 4;
        w2 = 6;
        break;
      case "biff3":
        h2 = 3;
        w2 = 6;
        break;
      case "biff2":
        h2 = 2;
        w2 = 4;
        break;
      case "xla":
        break;
      default:
        throw new Error("unsupported BIFF version");
    }
    var out = new_buf(w2);
    out.write_shift(2, h2);
    out.write_shift(2, t);
    if (w2 > 4)
      out.write_shift(2, 29282);
    if (w2 > 6)
      out.write_shift(2, 1997);
    if (w2 > 8) {
      out.write_shift(2, 49161);
      out.write_shift(2, 1);
      out.write_shift(2, 1798);
      out.write_shift(2, 0);
    }
    return out;
  }
  function parse_InterfaceHdr(blob, length) {
    if (length === 0)
      return 1200;
    if (blob.read_shift(2) !== 1200)
      ;
    return 1200;
  }
  function parse_WriteAccess(blob, length, opts) {
    if (opts.enc) {
      blob.l += length;
      return "";
    }
    var l2 = blob.l;
    var UserName = parse_XLUnicodeString2(blob, 0, opts);
    blob.read_shift(length + l2 - blob.l);
    return UserName;
  }
  function write_WriteAccess(s2, opts) {
    var b8 = !opts || opts.biff == 8;
    var o2 = new_buf(b8 ? 112 : 54);
    o2.write_shift(opts.biff == 8 ? 2 : 1, 7);
    if (b8)
      o2.write_shift(1, 0);
    o2.write_shift(4, 859007059);
    o2.write_shift(4, 5458548 | (b8 ? 0 : 536870912));
    while (o2.l < o2.length)
      o2.write_shift(1, b8 ? 0 : 32);
    return o2;
  }
  function parse_WsBool(blob, length, opts) {
    var flags = opts && opts.biff == 8 || length == 2 ? blob.read_shift(2) : (blob.l += length, 0);
    return { fDialog: flags & 16, fBelow: flags & 64, fRight: flags & 128 };
  }
  function parse_BoundSheet8(blob, length, opts) {
    var pos = blob.read_shift(4);
    var hidden = blob.read_shift(1) & 3;
    var dt2 = blob.read_shift(1);
    switch (dt2) {
      case 0:
        dt2 = "Worksheet";
        break;
      case 1:
        dt2 = "Macrosheet";
        break;
      case 2:
        dt2 = "Chartsheet";
        break;
      case 6:
        dt2 = "VBAModule";
        break;
    }
    var name = parse_ShortXLUnicodeString(blob, 0, opts);
    if (name.length === 0)
      name = "Sheet1";
    return { pos, hs: hidden, dt: dt2, name };
  }
  function write_BoundSheet8(data, opts) {
    var w2 = !opts || opts.biff >= 8 ? 2 : 1;
    var o2 = new_buf(8 + w2 * data.name.length);
    o2.write_shift(4, data.pos);
    o2.write_shift(1, data.hs || 0);
    o2.write_shift(1, data.dt);
    o2.write_shift(1, data.name.length);
    if (opts.biff >= 8)
      o2.write_shift(1, 1);
    o2.write_shift(w2 * data.name.length, data.name, opts.biff < 8 ? "sbcs" : "utf16le");
    var out = o2.slice(0, o2.l);
    out.l = o2.l;
    return out;
  }
  function parse_SST(blob, length) {
    var end = blob.l + length;
    var cnt = blob.read_shift(4);
    var ucnt = blob.read_shift(4);
    var strs2 = [];
    for (var i = 0; i != ucnt && blob.l < end; ++i) {
      strs2.push(parse_XLUnicodeRichExtendedString(blob));
    }
    strs2.Count = cnt;
    strs2.Unique = ucnt;
    return strs2;
  }
  function write_SST(sst, opts) {
    var header = new_buf(8);
    header.write_shift(4, sst.Count);
    header.write_shift(4, sst.Unique);
    var strs2 = [];
    for (var j = 0; j < sst.length; ++j)
      strs2[j] = write_XLUnicodeRichExtendedString(sst[j]);
    var o2 = bconcat([header].concat(strs2));
    o2.parts = [header.length].concat(strs2.map(function(str) {
      return str.length;
    }));
    return o2;
  }
  function parse_ExtSST(blob, length) {
    var extsst = {};
    extsst.dsst = blob.read_shift(2);
    blob.l += length - 2;
    return extsst;
  }
  function parse_Row(blob) {
    var z = {};
    z.r = blob.read_shift(2);
    z.c = blob.read_shift(2);
    z.cnt = blob.read_shift(2) - z.c;
    var miyRw = blob.read_shift(2);
    blob.l += 4;
    var flags = blob.read_shift(1);
    blob.l += 3;
    if (flags & 7)
      z.level = flags & 7;
    if (flags & 32)
      z.hidden = true;
    if (flags & 64)
      z.hpt = miyRw / 20;
    return z;
  }
  function parse_ForceFullCalculation(blob) {
    var header = parse_frtHeader(blob);
    if (header.type != 2211)
      throw new Error("Invalid Future Record " + header.type);
    var fullcalc = blob.read_shift(4);
    return fullcalc !== 0;
  }
  function parse_RecalcId(blob) {
    blob.read_shift(2);
    return blob.read_shift(4);
  }
  function parse_DefaultRowHeight(blob, length, opts) {
    var f2 = 0;
    if (!(opts && opts.biff == 2)) {
      f2 = blob.read_shift(2);
    }
    var miyRw = blob.read_shift(2);
    if (opts && opts.biff == 2) {
      f2 = 1 - (miyRw >> 15);
      miyRw &= 32767;
    }
    var fl = { Unsynced: f2 & 1, DyZero: (f2 & 2) >> 1, ExAsc: (f2 & 4) >> 2, ExDsc: (f2 & 8) >> 3 };
    return [fl, miyRw];
  }
  function parse_Window1(blob) {
    var xWn = blob.read_shift(2), yWn = blob.read_shift(2), dxWn = blob.read_shift(2), dyWn = blob.read_shift(2);
    var flags = blob.read_shift(2), iTabCur = blob.read_shift(2), iTabFirst = blob.read_shift(2);
    var ctabSel = blob.read_shift(2), wTabRatio = blob.read_shift(2);
    return {
      Pos: [xWn, yWn],
      Dim: [dxWn, dyWn],
      Flags: flags,
      CurTab: iTabCur,
      FirstTab: iTabFirst,
      Selected: ctabSel,
      TabRatio: wTabRatio
    };
  }
  function write_Window1() {
    var o2 = new_buf(18);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 29280);
    o2.write_shift(2, 17600);
    o2.write_shift(2, 56);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 1);
    o2.write_shift(2, 500);
    return o2;
  }
  function parse_Window2(blob, length, opts) {
    if (opts && opts.biff >= 2 && opts.biff < 5)
      return {};
    var f2 = blob.read_shift(2);
    return { RTL: f2 & 64 };
  }
  function write_Window2(view) {
    var o2 = new_buf(18), f2 = 1718;
    if (view && view.RTL)
      f2 |= 64;
    o2.write_shift(2, f2);
    o2.write_shift(4, 0);
    o2.write_shift(4, 64);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    return o2;
  }
  function parse_Pane() {
  }
  function parse_Font(blob, length, opts) {
    var o2 = {
      dyHeight: blob.read_shift(2),
      fl: blob.read_shift(2)
    };
    switch (opts && opts.biff || 8) {
      case 2:
        break;
      case 3:
      case 4:
        blob.l += 2;
        break;
      default:
        blob.l += 10;
        break;
    }
    o2.name = parse_ShortXLUnicodeString(blob, 0, opts);
    return o2;
  }
  function write_Font(data, opts) {
    var name = data.name || "Arial";
    var b5 = opts && opts.biff == 5, w2 = b5 ? 15 + name.length : 16 + 2 * name.length;
    var o2 = new_buf(w2);
    o2.write_shift(2, (data.sz || 12) * 20);
    o2.write_shift(4, 0);
    o2.write_shift(2, 400);
    o2.write_shift(4, 0);
    o2.write_shift(2, 0);
    o2.write_shift(1, name.length);
    if (!b5)
      o2.write_shift(1, 1);
    o2.write_shift((b5 ? 1 : 2) * name.length, name, b5 ? "sbcs" : "utf16le");
    return o2;
  }
  function parse_LabelSst(blob) {
    var cell = parse_XLSCell(blob);
    cell.isst = blob.read_shift(4);
    return cell;
  }
  function write_LabelSst(R2, C2, v2, os) {
    var o2 = new_buf(10);
    write_XLSCell(R2, C2, os, o2);
    o2.write_shift(4, v2);
    return o2;
  }
  function parse_Label(blob, length, opts) {
    if (opts.biffguess && opts.biff == 2)
      opts.biff = 5;
    var target = blob.l + length;
    var cell = parse_XLSCell(blob);
    if (opts.biff == 2)
      blob.l++;
    var str = parse_XLUnicodeString(blob, target - blob.l, opts);
    cell.val = str;
    return cell;
  }
  function write_Label(R2, C2, v2, os, opts) {
    var b8 = !opts || opts.biff == 8;
    var o2 = new_buf(6 + 2 + +b8 + (1 + b8) * v2.length);
    write_XLSCell(R2, C2, os, o2);
    o2.write_shift(2, v2.length);
    if (b8)
      o2.write_shift(1, 1);
    o2.write_shift((1 + b8) * v2.length, v2, b8 ? "utf16le" : "sbcs");
    return o2;
  }
  function parse_Format(blob, length, opts) {
    var numFmtId = blob.read_shift(2);
    var fmtstr = parse_XLUnicodeString2(blob, 0, opts);
    return [numFmtId, fmtstr];
  }
  function write_Format(i, f2, opts, o2) {
    var b5 = opts && opts.biff == 5;
    if (!o2)
      o2 = new_buf(b5 ? 3 + f2.length : 5 + 2 * f2.length);
    o2.write_shift(2, i);
    o2.write_shift(b5 ? 1 : 2, f2.length);
    if (!b5)
      o2.write_shift(1, 1);
    o2.write_shift((b5 ? 1 : 2) * f2.length, f2, b5 ? "sbcs" : "utf16le");
    var out = o2.length > o2.l ? o2.slice(0, o2.l) : o2;
    if (out.l == null)
      out.l = out.length;
    return out;
  }
  var parse_BIFF2Format = parse_XLUnicodeString2;
  function parse_Dimensions(blob, length, opts) {
    var end = blob.l + length;
    var w2 = opts.biff == 8 || !opts.biff ? 4 : 2;
    var r = blob.read_shift(w2), R2 = blob.read_shift(w2);
    var c2 = blob.read_shift(2), C2 = blob.read_shift(2);
    blob.l = end;
    return { s: { r, c: c2 }, e: { r: R2, c: C2 } };
  }
  function write_Dimensions(range, opts) {
    var w2 = opts.biff == 8 || !opts.biff ? 4 : 2;
    var o2 = new_buf(2 * w2 + 6);
    o2.write_shift(w2, range.s.r);
    o2.write_shift(w2, range.e.r + 1);
    o2.write_shift(2, range.s.c);
    o2.write_shift(2, range.e.c + 1);
    o2.write_shift(2, 0);
    return o2;
  }
  function parse_RK(blob) {
    var rw = blob.read_shift(2), col = blob.read_shift(2);
    var rkrec = parse_RkRec(blob);
    return { r: rw, c: col, ixfe: rkrec[0], rknum: rkrec[1] };
  }
  function parse_MulRk(blob, length) {
    var target = blob.l + length - 2;
    var rw = blob.read_shift(2), col = blob.read_shift(2);
    var rkrecs = [];
    while (blob.l < target)
      rkrecs.push(parse_RkRec(blob));
    if (blob.l !== target)
      throw new Error("MulRK read error");
    var lastcol = blob.read_shift(2);
    if (rkrecs.length != lastcol - col + 1)
      throw new Error("MulRK length mismatch");
    return { r: rw, c: col, C: lastcol, rkrec: rkrecs };
  }
  function parse_MulBlank(blob, length) {
    var target = blob.l + length - 2;
    var rw = blob.read_shift(2), col = blob.read_shift(2);
    var ixfes = [];
    while (blob.l < target)
      ixfes.push(blob.read_shift(2));
    if (blob.l !== target)
      throw new Error("MulBlank read error");
    var lastcol = blob.read_shift(2);
    if (ixfes.length != lastcol - col + 1)
      throw new Error("MulBlank length mismatch");
    return { r: rw, c: col, C: lastcol, ixfe: ixfes };
  }
  function parse_CellStyleXF(blob, length, style2, opts) {
    var o2 = {};
    var a2 = blob.read_shift(4), b2 = blob.read_shift(4);
    var c2 = blob.read_shift(4), d2 = blob.read_shift(2);
    o2.patternType = XLSFillPattern[c2 >> 26];
    if (!opts.cellStyles)
      return o2;
    o2.alc = a2 & 7;
    o2.fWrap = a2 >> 3 & 1;
    o2.alcV = a2 >> 4 & 7;
    o2.fJustLast = a2 >> 7 & 1;
    o2.trot = a2 >> 8 & 255;
    o2.cIndent = a2 >> 16 & 15;
    o2.fShrinkToFit = a2 >> 20 & 1;
    o2.iReadOrder = a2 >> 22 & 2;
    o2.fAtrNum = a2 >> 26 & 1;
    o2.fAtrFnt = a2 >> 27 & 1;
    o2.fAtrAlc = a2 >> 28 & 1;
    o2.fAtrBdr = a2 >> 29 & 1;
    o2.fAtrPat = a2 >> 30 & 1;
    o2.fAtrProt = a2 >> 31 & 1;
    o2.dgLeft = b2 & 15;
    o2.dgRight = b2 >> 4 & 15;
    o2.dgTop = b2 >> 8 & 15;
    o2.dgBottom = b2 >> 12 & 15;
    o2.icvLeft = b2 >> 16 & 127;
    o2.icvRight = b2 >> 23 & 127;
    o2.grbitDiag = b2 >> 30 & 3;
    o2.icvTop = c2 & 127;
    o2.icvBottom = c2 >> 7 & 127;
    o2.icvDiag = c2 >> 14 & 127;
    o2.dgDiag = c2 >> 21 & 15;
    o2.icvFore = d2 & 127;
    o2.icvBack = d2 >> 7 & 127;
    o2.fsxButton = d2 >> 14 & 1;
    return o2;
  }
  function parse_XF(blob, length, opts) {
    var o2 = {};
    o2.ifnt = blob.read_shift(2);
    o2.numFmtId = blob.read_shift(2);
    o2.flags = blob.read_shift(2);
    o2.fStyle = o2.flags >> 2 & 1;
    length -= 6;
    o2.data = parse_CellStyleXF(blob, length, o2.fStyle, opts);
    return o2;
  }
  function write_XF(data, ixfeP, opts, o2) {
    var b5 = opts && opts.biff == 5;
    if (!o2)
      o2 = new_buf(b5 ? 16 : 20);
    o2.write_shift(2, 0);
    if (data.style) {
      o2.write_shift(2, data.numFmtId || 0);
      o2.write_shift(2, 65524);
    } else {
      o2.write_shift(2, data.numFmtId || 0);
      o2.write_shift(2, ixfeP << 4);
    }
    var f2 = 0;
    if (data.numFmtId > 0 && b5)
      f2 |= 1024;
    o2.write_shift(4, f2);
    o2.write_shift(4, 0);
    if (!b5)
      o2.write_shift(4, 0);
    o2.write_shift(2, 0);
    return o2;
  }
  function parse_Guts(blob) {
    blob.l += 4;
    var out = [blob.read_shift(2), blob.read_shift(2)];
    if (out[0] !== 0)
      out[0]--;
    if (out[1] !== 0)
      out[1]--;
    if (out[0] > 7 || out[1] > 7)
      throw new Error("Bad Gutters: " + out.join("|"));
    return out;
  }
  function write_Guts(guts) {
    var o2 = new_buf(8);
    o2.write_shift(4, 0);
    o2.write_shift(2, guts[0] ? guts[0] + 1 : 0);
    o2.write_shift(2, guts[1] ? guts[1] + 1 : 0);
    return o2;
  }
  function parse_BoolErr(blob, length, opts) {
    var cell = parse_XLSCell(blob);
    if (opts.biff == 2 || length == 9)
      ++blob.l;
    var val = parse_Bes(blob);
    cell.val = val;
    cell.t = val === true || val === false ? "b" : "e";
    return cell;
  }
  function write_BoolErr(R2, C2, v2, os, opts, t) {
    var o2 = new_buf(8);
    write_XLSCell(R2, C2, os, o2);
    write_Bes(v2, t, o2);
    return o2;
  }
  function parse_Number(blob, length, opts) {
    if (opts.biffguess && opts.biff == 2)
      opts.biff = 5;
    var cell = parse_XLSCell(blob);
    var xnum = parse_Xnum(blob);
    cell.val = xnum;
    return cell;
  }
  function write_Number(R2, C2, v2, os) {
    var o2 = new_buf(14);
    write_XLSCell(R2, C2, os, o2);
    write_Xnum(v2, o2);
    return o2;
  }
  var parse_XLHeaderFooter = parse_OptXLUnicodeString;
  function parse_SupBook(blob, length, opts) {
    var end = blob.l + length;
    var ctab = blob.read_shift(2);
    var cch = blob.read_shift(2);
    opts.sbcch = cch;
    if (cch == 1025 || cch == 14849)
      return [cch, ctab];
    if (cch < 1 || cch > 255)
      throw new Error("Unexpected SupBook type: " + cch);
    var virtPath = parse_XLUnicodeStringNoCch(blob, cch);
    var rgst = [];
    while (end > blob.l)
      rgst.push(parse_XLUnicodeString(blob));
    return [cch, ctab, virtPath, rgst];
  }
  function parse_ExternName(blob, length, opts) {
    var flags = blob.read_shift(2);
    var body;
    var o2 = {
      fBuiltIn: flags & 1,
      fWantAdvise: flags >>> 1 & 1,
      fWantPict: flags >>> 2 & 1,
      fOle: flags >>> 3 & 1,
      fOleLink: flags >>> 4 & 1,
      cf: flags >>> 5 & 1023,
      fIcon: flags >>> 15 & 1
    };
    if (opts.sbcch === 14849)
      body = parse_AddinUdf(blob, length - 2, opts);
    o2.body = body || blob.read_shift(length - 2);
    if (typeof body === "string")
      o2.Name = body;
    return o2;
  }
  var XLSLblBuiltIn = [
    "_xlnm.Consolidate_Area",
    "_xlnm.Auto_Open",
    "_xlnm.Auto_Close",
    "_xlnm.Extract",
    "_xlnm.Database",
    "_xlnm.Criteria",
    "_xlnm.Print_Area",
    "_xlnm.Print_Titles",
    "_xlnm.Recorder",
    "_xlnm.Data_Form",
    "_xlnm.Auto_Activate",
    "_xlnm.Auto_Deactivate",
    "_xlnm.Sheet_Title",
    "_xlnm._FilterDatabase"
  ];
  function parse_Lbl(blob, length, opts) {
    var target = blob.l + length;
    var flags = blob.read_shift(2);
    var chKey = blob.read_shift(1);
    var cch = blob.read_shift(1);
    var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    var itab = 0;
    if (!opts || opts.biff >= 5) {
      if (opts.biff != 5)
        blob.l += 2;
      itab = blob.read_shift(2);
      if (opts.biff == 5)
        blob.l += 2;
      blob.l += 4;
    }
    var name = parse_XLUnicodeStringNoCch(blob, cch, opts);
    if (flags & 32)
      name = XLSLblBuiltIn[name.charCodeAt(0)];
    var npflen = target - blob.l;
    if (opts && opts.biff == 2)
      --npflen;
    var rgce = target == blob.l || cce === 0 || !(npflen > 0) ? [] : parse_NameParsedFormula(blob, npflen, opts, cce);
    return {
      chKey,
      Name: name,
      itab,
      rgce
    };
  }
  function parse_ExternSheet(blob, length, opts) {
    if (opts.biff < 8)
      return parse_BIFF5ExternSheet(blob, length, opts);
    var o2 = [], target = blob.l + length, len = blob.read_shift(opts.biff > 8 ? 4 : 2);
    while (len-- !== 0)
      o2.push(parse_XTI(blob, opts.biff > 8 ? 12 : 6, opts));
    if (blob.l != target)
      throw new Error("Bad ExternSheet: " + blob.l + " != " + target);
    return o2;
  }
  function parse_BIFF5ExternSheet(blob, length, opts) {
    if (blob[blob.l + 1] == 3)
      blob[blob.l]++;
    var o2 = parse_ShortXLUnicodeString(blob, length, opts);
    return o2.charCodeAt(0) == 3 ? o2.slice(1) : o2;
  }
  function parse_NameCmt(blob, length, opts) {
    if (opts.biff < 8) {
      blob.l += length;
      return;
    }
    var cchName = blob.read_shift(2);
    var cchComment = blob.read_shift(2);
    var name = parse_XLUnicodeStringNoCch(blob, cchName, opts);
    var comment = parse_XLUnicodeStringNoCch(blob, cchComment, opts);
    return [name, comment];
  }
  function parse_ShrFmla(blob, length, opts) {
    var ref2 = parse_RefU(blob);
    blob.l++;
    var cUse = blob.read_shift(1);
    length -= 8;
    return [parse_SharedParsedFormula(blob, length, opts), cUse, ref2];
  }
  function parse_Array(blob, length, opts) {
    var ref2 = parse_Ref(blob);
    switch (opts.biff) {
      case 2:
        blob.l++;
        length -= 7;
        break;
      case 3:
      case 4:
        blob.l += 2;
        length -= 8;
        break;
      default:
        blob.l += 6;
        length -= 12;
    }
    return [ref2, parse_ArrayParsedFormula(blob, length, opts)];
  }
  function parse_MTRSettings(blob) {
    var fMTREnabled = blob.read_shift(4) !== 0;
    var fUserSetThreadCount = blob.read_shift(4) !== 0;
    var cUserThreadCount = blob.read_shift(4);
    return [fMTREnabled, fUserSetThreadCount, cUserThreadCount];
  }
  function parse_NoteSh(blob, length, opts) {
    if (opts.biff < 8)
      return;
    var row = blob.read_shift(2), col = blob.read_shift(2);
    var flags = blob.read_shift(2), idObj = blob.read_shift(2);
    var stAuthor = parse_XLUnicodeString2(blob, 0, opts);
    if (opts.biff < 8)
      blob.read_shift(1);
    return [{ r: row, c: col }, stAuthor, idObj, flags];
  }
  function parse_Note(blob, length, opts) {
    return parse_NoteSh(blob, length, opts);
  }
  function parse_MergeCells(blob, length) {
    var merges = [];
    var cmcs = blob.read_shift(2);
    while (cmcs--)
      merges.push(parse_Ref8U(blob));
    return merges;
  }
  function write_MergeCells(merges) {
    var o2 = new_buf(2 + merges.length * 8);
    o2.write_shift(2, merges.length);
    for (var i = 0; i < merges.length; ++i)
      write_Ref8U(merges[i], o2);
    return o2;
  }
  function parse_Obj(blob, length, opts) {
    if (opts && opts.biff < 8)
      return parse_BIFF5Obj(blob, length, opts);
    var cmo = parse_FtCmo(blob);
    var fts = parse_FtArray(blob, length - 22, cmo[1]);
    return { cmo, ft: fts };
  }
  var parse_BIFF5OT = {
    8: function(blob, length) {
      var tgt = blob.l + length;
      blob.l += 10;
      var cf = blob.read_shift(2);
      blob.l += 4;
      blob.l += 2;
      blob.l += 2;
      blob.l += 2;
      blob.l += 4;
      var cchName = blob.read_shift(1);
      blob.l += cchName;
      blob.l = tgt;
      return { fmt: cf };
    }
  };
  function parse_BIFF5Obj(blob, length, opts) {
    blob.l += 4;
    var ot2 = blob.read_shift(2);
    var id = blob.read_shift(2);
    var grbit = blob.read_shift(2);
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 2;
    blob.l += 6;
    length -= 36;
    var fts = [];
    fts.push((parse_BIFF5OT[ot2] || parsenoop)(blob, length, opts));
    return { cmo: [id, ot2, grbit], ft: fts };
  }
  function parse_TxO(blob, length, opts) {
    var s2 = blob.l;
    var texts = "";
    try {
      blob.l += 4;
      var ot2 = (opts.lastobj || { cmo: [0, 0] }).cmo[1];
      var controlInfo;
      if ([0, 5, 7, 11, 12, 14].indexOf(ot2) == -1)
        blob.l += 6;
      else
        controlInfo = parse_ControlInfo(blob, 6, opts);
      var cchText = blob.read_shift(2);
      blob.read_shift(2);
      parseuint16(blob, 2);
      var len = blob.read_shift(2);
      blob.l += len;
      for (var i = 1; i < blob.lens.length - 1; ++i) {
        if (blob.l - s2 != blob.lens[i])
          throw new Error("TxO: bad continue record");
        var hdr = blob[blob.l];
        var t = parse_XLUnicodeStringNoCch(blob, blob.lens[i + 1] - blob.lens[i] - 1);
        texts += t;
        if (texts.length >= (hdr ? cchText : 2 * cchText))
          break;
      }
      if (texts.length !== cchText && texts.length !== cchText * 2) {
        throw new Error("cchText: " + cchText + " != " + texts.length);
      }
      blob.l = s2 + length;
      return { t: texts };
    } catch (e) {
      blob.l = s2 + length;
      return { t: texts };
    }
  }
  function parse_HLink(blob, length) {
    var ref2 = parse_Ref8U(blob);
    blob.l += 16;
    var hlink = parse_Hyperlink(blob, length - 24);
    return [ref2, hlink];
  }
  function write_HLink(hl) {
    var O2 = new_buf(24);
    var ref2 = decode_cell(hl[0]);
    O2.write_shift(2, ref2.r);
    O2.write_shift(2, ref2.r);
    O2.write_shift(2, ref2.c);
    O2.write_shift(2, ref2.c);
    var clsid = "d0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" ");
    for (var i = 0; i < 16; ++i)
      O2.write_shift(1, parseInt(clsid[i], 16));
    return bconcat([O2, write_Hyperlink(hl[1])]);
  }
  function parse_HLinkTooltip(blob, length) {
    blob.read_shift(2);
    var ref2 = parse_Ref8U(blob);
    var wzTooltip = blob.read_shift((length - 10) / 2, "dbcs-cont");
    wzTooltip = wzTooltip.replace(chr0, "");
    return [ref2, wzTooltip];
  }
  function write_HLinkTooltip(hl) {
    var TT = hl[1].Tooltip;
    var O2 = new_buf(10 + 2 * (TT.length + 1));
    O2.write_shift(2, 2048);
    var ref2 = decode_cell(hl[0]);
    O2.write_shift(2, ref2.r);
    O2.write_shift(2, ref2.r);
    O2.write_shift(2, ref2.c);
    O2.write_shift(2, ref2.c);
    for (var i = 0; i < TT.length; ++i)
      O2.write_shift(2, TT.charCodeAt(i));
    O2.write_shift(2, 0);
    return O2;
  }
  function parse_Country(blob) {
    var o2 = [0, 0], d2;
    d2 = blob.read_shift(2);
    o2[0] = CountryEnum[d2] || d2;
    d2 = blob.read_shift(2);
    o2[1] = CountryEnum[d2] || d2;
    return o2;
  }
  function write_Country(o2) {
    if (!o2)
      o2 = new_buf(4);
    o2.write_shift(2, 1);
    o2.write_shift(2, 1);
    return o2;
  }
  function parse_ClrtClient(blob) {
    var ccv = blob.read_shift(2);
    var o2 = [];
    while (ccv-- > 0)
      o2.push(parse_LongRGB(blob));
    return o2;
  }
  function parse_Palette(blob) {
    var ccv = blob.read_shift(2);
    var o2 = [];
    while (ccv-- > 0)
      o2.push(parse_LongRGB(blob));
    return o2;
  }
  function parse_XFCRC(blob) {
    blob.l += 2;
    var o2 = { cxfs: 0, crc: 0 };
    o2.cxfs = blob.read_shift(2);
    o2.crc = blob.read_shift(4);
    return o2;
  }
  function parse_ColInfo(blob, length, opts) {
    if (!opts.cellStyles)
      return parsenoop(blob, length);
    var w2 = opts && opts.biff >= 12 ? 4 : 2;
    var colFirst = blob.read_shift(w2);
    var colLast = blob.read_shift(w2);
    var coldx = blob.read_shift(w2);
    var ixfe = blob.read_shift(w2);
    var flags = blob.read_shift(2);
    if (w2 == 2)
      blob.l += 2;
    var o2 = { s: colFirst, e: colLast, w: coldx, ixfe, flags };
    if (opts.biff >= 5 || !opts.biff)
      o2.level = flags >> 8 & 7;
    return o2;
  }
  function write_ColInfo(col, idx) {
    var o2 = new_buf(12);
    o2.write_shift(2, idx);
    o2.write_shift(2, idx);
    o2.write_shift(2, col.width * 256);
    o2.write_shift(2, 0);
    var f2 = 0;
    if (col.hidden)
      f2 |= 1;
    o2.write_shift(1, f2);
    f2 = col.level || 0;
    o2.write_shift(1, f2);
    o2.write_shift(2, 0);
    return o2;
  }
  function parse_Setup(blob, length) {
    var o2 = {};
    if (length < 32)
      return o2;
    blob.l += 16;
    o2.header = parse_Xnum(blob);
    o2.footer = parse_Xnum(blob);
    blob.l += 2;
    return o2;
  }
  function parse_ShtProps(blob, length, opts) {
    var def2 = { area: false };
    if (opts.biff != 5) {
      blob.l += length;
      return def2;
    }
    var d2 = blob.read_shift(1);
    blob.l += 3;
    if (d2 & 16)
      def2.area = true;
    return def2;
  }
  function write_RRTabId(n) {
    var out = new_buf(2 * n);
    for (var i = 0; i < n; ++i)
      out.write_shift(2, i + 1);
    return out;
  }
  var parse_Blank = parse_XLSCell;
  var parse_Scl = parseuint16a;
  var parse_String = parse_XLUnicodeString;
  function parse_ImData(blob) {
    var cf = blob.read_shift(2);
    var env = blob.read_shift(2);
    var lcb = blob.read_shift(4);
    var o2 = { fmt: cf, env, len: lcb, data: blob.slice(blob.l, blob.l + lcb) };
    blob.l += lcb;
    return o2;
  }
  function parse_BIFF2STR(blob, length, opts) {
    if (opts.biffguess && opts.biff == 5)
      opts.biff = 2;
    var cell = parse_XLSCell(blob);
    ++blob.l;
    var str = parse_XLUnicodeString2(blob, length - 7, opts);
    cell.t = "str";
    cell.val = str;
    return cell;
  }
  function parse_BIFF2NUM(blob) {
    var cell = parse_XLSCell(blob);
    ++blob.l;
    var num = parse_Xnum(blob);
    cell.t = "n";
    cell.val = num;
    return cell;
  }
  function write_BIFF2NUM(r, c2, val) {
    var out = new_buf(15);
    write_BIFF2Cell(out, r, c2);
    out.write_shift(8, val, "f");
    return out;
  }
  function parse_BIFF2INT(blob) {
    var cell = parse_XLSCell(blob);
    ++blob.l;
    var num = blob.read_shift(2);
    cell.t = "n";
    cell.val = num;
    return cell;
  }
  function write_BIFF2INT(r, c2, val) {
    var out = new_buf(9);
    write_BIFF2Cell(out, r, c2);
    out.write_shift(2, val);
    return out;
  }
  function parse_BIFF2STRING(blob) {
    var cch = blob.read_shift(1);
    if (cch === 0) {
      blob.l++;
      return "";
    }
    return blob.read_shift(cch, "sbcs-cont");
  }
  function parse_BIFF2FONTXTRA(blob, length) {
    blob.l += 6;
    blob.l += 2;
    blob.l += 1;
    blob.l += 3;
    blob.l += 1;
    blob.l += length - 13;
  }
  function parse_RString(blob, length, opts) {
    var end = blob.l + length;
    var cell = parse_XLSCell(blob);
    var cch = blob.read_shift(2);
    var str = parse_XLUnicodeStringNoCch(blob, cch, opts);
    blob.l = end;
    cell.t = "str";
    cell.val = str;
    return cell;
  }
  var DBF_SUPPORTED_VERSIONS = [2, 3, 48, 49, 131, 139, 140, 245];
  var DBF = /* @__PURE__ */ function() {
    var dbf_codepage_map = {
      1: 437,
      2: 850,
      3: 1252,
      4: 1e4,
      100: 852,
      101: 866,
      102: 865,
      103: 861,
      104: 895,
      105: 620,
      106: 737,
      107: 857,
      120: 950,
      121: 949,
      122: 936,
      123: 932,
      124: 874,
      125: 1255,
      126: 1256,
      150: 10007,
      151: 10029,
      152: 10006,
      200: 1250,
      201: 1251,
      202: 1254,
      203: 1253,
      0: 20127,
      8: 865,
      9: 437,
      10: 850,
      11: 437,
      13: 437,
      14: 850,
      15: 437,
      16: 850,
      17: 437,
      18: 850,
      19: 932,
      20: 850,
      21: 437,
      22: 850,
      23: 865,
      24: 437,
      25: 437,
      26: 850,
      27: 437,
      28: 863,
      29: 850,
      31: 852,
      34: 852,
      35: 852,
      36: 860,
      37: 850,
      38: 866,
      55: 850,
      64: 852,
      77: 936,
      78: 949,
      79: 950,
      80: 874,
      87: 1252,
      88: 1252,
      89: 1252,
      108: 863,
      134: 737,
      135: 852,
      136: 857,
      204: 1257,
      255: 16969
    };
    var dbf_reverse_map = evert({
      1: 437,
      2: 850,
      3: 1252,
      4: 1e4,
      100: 852,
      101: 866,
      102: 865,
      103: 861,
      104: 895,
      105: 620,
      106: 737,
      107: 857,
      120: 950,
      121: 949,
      122: 936,
      123: 932,
      124: 874,
      125: 1255,
      126: 1256,
      150: 10007,
      151: 10029,
      152: 10006,
      200: 1250,
      201: 1251,
      202: 1254,
      203: 1253,
      0: 20127
    });
    function dbf_to_aoa(buf, opts) {
      var out = [];
      var d2 = new_raw_buf(1);
      switch (opts.type) {
        case "base64":
          d2 = s2a(Base64_decode(buf));
          break;
        case "binary":
          d2 = s2a(buf);
          break;
        case "buffer":
        case "array":
          d2 = buf;
          break;
      }
      prep_blob(d2, 0);
      var ft2 = d2.read_shift(1);
      var memo = !!(ft2 & 136);
      var vfp = false, l7 = false;
      switch (ft2) {
        case 2:
          break;
        case 3:
          break;
        case 48:
          vfp = true;
          memo = true;
          break;
        case 49:
          vfp = true;
          memo = true;
          break;
        case 131:
          break;
        case 139:
          break;
        case 140:
          l7 = true;
          break;
        case 245:
          break;
        default:
          throw new Error("DBF Unsupported Version: " + ft2.toString(16));
      }
      var nrow = 0, fpos = 521;
      if (ft2 == 2)
        nrow = d2.read_shift(2);
      d2.l += 3;
      if (ft2 != 2)
        nrow = d2.read_shift(4);
      if (nrow > 1048576)
        nrow = 1e6;
      if (ft2 != 2)
        fpos = d2.read_shift(2);
      var rlen = d2.read_shift(2);
      var current_cp = opts.codepage || 1252;
      if (ft2 != 2) {
        d2.l += 16;
        d2.read_shift(1);
        if (d2[d2.l] !== 0)
          current_cp = dbf_codepage_map[d2[d2.l]];
        d2.l += 1;
        d2.l += 2;
      }
      if (l7)
        d2.l += 36;
      var fields = [], field = {};
      var hend = Math.min(d2.length, ft2 == 2 ? 521 : fpos - 10 - (vfp ? 264 : 0));
      var ww = l7 ? 32 : 11;
      while (d2.l < hend && d2[d2.l] != 13) {
        field = {};
        field.name = $cptable.utils.decode(current_cp, d2.slice(d2.l, d2.l + ww)).replace(/[\u0000\r\n].*$/g, "");
        d2.l += ww;
        field.type = String.fromCharCode(d2.read_shift(1));
        if (ft2 != 2 && !l7)
          field.offset = d2.read_shift(4);
        field.len = d2.read_shift(1);
        if (ft2 == 2)
          field.offset = d2.read_shift(2);
        field.dec = d2.read_shift(1);
        if (field.name.length)
          fields.push(field);
        if (ft2 != 2)
          d2.l += l7 ? 13 : 14;
        switch (field.type) {
          case "B":
            if ((!vfp || field.len != 8) && opts.WTF)
              console.log("Skipping " + field.name + ":" + field.type);
            break;
          case "G":
          case "P":
            if (opts.WTF)
              console.log("Skipping " + field.name + ":" + field.type);
            break;
          case "+":
          case "0":
          case "@":
          case "C":
          case "D":
          case "F":
          case "I":
          case "L":
          case "M":
          case "N":
          case "O":
          case "T":
          case "Y":
            break;
          default:
            throw new Error("Unknown Field Type: " + field.type);
        }
      }
      if (d2[d2.l] !== 13)
        d2.l = fpos - 1;
      if (d2.read_shift(1) !== 13)
        throw new Error("DBF Terminator not found " + d2.l + " " + d2[d2.l]);
      d2.l = fpos;
      var R2 = 0, C2 = 0;
      out[0] = [];
      for (C2 = 0; C2 != fields.length; ++C2)
        out[0][C2] = fields[C2].name;
      while (nrow-- > 0) {
        if (d2[d2.l] === 42) {
          d2.l += rlen;
          continue;
        }
        ++d2.l;
        out[++R2] = [];
        C2 = 0;
        for (C2 = 0; C2 != fields.length; ++C2) {
          var dd = d2.slice(d2.l, d2.l + fields[C2].len);
          d2.l += fields[C2].len;
          prep_blob(dd, 0);
          var s2 = $cptable.utils.decode(current_cp, dd);
          switch (fields[C2].type) {
            case "C":
              if (s2.trim().length)
                out[R2][C2] = s2.replace(/\s+$/, "");
              break;
            case "D":
              if (s2.length === 8)
                out[R2][C2] = new Date(+s2.slice(0, 4), +s2.slice(4, 6) - 1, +s2.slice(6, 8));
              else
                out[R2][C2] = s2;
              break;
            case "F":
              out[R2][C2] = parseFloat(s2.trim());
              break;
            case "+":
            case "I":
              out[R2][C2] = l7 ? dd.read_shift(-4, "i") ^ 2147483648 : dd.read_shift(4, "i");
              break;
            case "L":
              switch (s2.trim().toUpperCase()) {
                case "Y":
                case "T":
                  out[R2][C2] = true;
                  break;
                case "N":
                case "F":
                  out[R2][C2] = false;
                  break;
                case "":
                case "?":
                  break;
                default:
                  throw new Error("DBF Unrecognized L:|" + s2 + "|");
              }
              break;
            case "M":
              if (!memo)
                throw new Error("DBF Unexpected MEMO for type " + ft2.toString(16));
              out[R2][C2] = "##MEMO##" + (l7 ? parseInt(s2.trim(), 10) : dd.read_shift(4));
              break;
            case "N":
              s2 = s2.replace(/\u0000/g, "").trim();
              if (s2 && s2 != ".")
                out[R2][C2] = +s2 || 0;
              break;
            case "@":
              out[R2][C2] = new Date(dd.read_shift(-8, "f") - 621356832e5);
              break;
            case "T":
              out[R2][C2] = new Date((dd.read_shift(4) - 2440588) * 864e5 + dd.read_shift(4));
              break;
            case "Y":
              out[R2][C2] = dd.read_shift(4, "i") / 1e4 + dd.read_shift(4, "i") / 1e4 * Math.pow(2, 32);
              break;
            case "O":
              out[R2][C2] = -dd.read_shift(-8, "f");
              break;
            case "B":
              if (vfp && fields[C2].len == 8) {
                out[R2][C2] = dd.read_shift(8, "f");
                break;
              }
            case "G":
            case "P":
              dd.l += fields[C2].len;
              break;
            case "0":
              if (fields[C2].name === "_NullFlags")
                break;
            default:
              throw new Error("DBF Unsupported data type " + fields[C2].type);
          }
        }
      }
      if (ft2 != 2) {
        if (d2.l < d2.length && d2[d2.l++] != 26)
          throw new Error("DBF EOF Marker missing " + (d2.l - 1) + " of " + d2.length + " " + d2[d2.l - 1].toString(16));
      }
      if (opts && opts.sheetRows)
        out = out.slice(0, opts.sheetRows);
      opts.DBF = fields;
      return out;
    }
    function dbf_to_sheet(buf, opts) {
      var o2 = opts || {};
      if (!o2.dateNF)
        o2.dateNF = "yyyymmdd";
      var ws = aoa_to_sheet(dbf_to_aoa(buf, o2), o2);
      ws["!cols"] = o2.DBF.map(function(field) {
        return {
          wch: field.len,
          DBF: field
        };
      });
      delete o2.DBF;
      return ws;
    }
    function dbf_to_workbook(buf, opts) {
      try {
        return sheet_to_workbook(dbf_to_sheet(buf, opts), opts);
      } catch (e) {
        if (opts && opts.WTF)
          throw e;
      }
      return { SheetNames: [], Sheets: {} };
    }
    var _RLEN = { "B": 8, "C": 250, "L": 1, "D": 8, "?": 0, "": 0 };
    function sheet_to_dbf(ws, opts) {
      var o2 = opts || {};
      if (+o2.codepage >= 0)
        set_cp(+o2.codepage);
      if (o2.type == "string")
        throw new Error("Cannot write DBF to JS string");
      var ba = buf_array();
      var aoa = sheet_to_json(ws, { header: 1, raw: true, cellDates: true });
      var headers = aoa[0], data = aoa.slice(1), cols = ws["!cols"] || [];
      var i = 0, j = 0, hcnt = 0, rlen = 1;
      for (i = 0; i < headers.length; ++i) {
        if (((cols[i] || {}).DBF || {}).name) {
          headers[i] = cols[i].DBF.name;
          ++hcnt;
          continue;
        }
        if (headers[i] == null)
          continue;
        ++hcnt;
        if (typeof headers[i] === "number")
          headers[i] = headers[i].toString(10);
        if (typeof headers[i] !== "string")
          throw new Error("DBF Invalid column name " + headers[i] + " |" + typeof headers[i] + "|");
        if (headers.indexOf(headers[i]) !== i) {
          for (j = 0; j < 1024; ++j)
            if (headers.indexOf(headers[i] + "_" + j) == -1) {
              headers[i] += "_" + j;
              break;
            }
        }
      }
      var range = safe_decode_range(ws["!ref"]);
      var coltypes = [];
      var colwidths = [];
      var coldecimals = [];
      for (i = 0; i <= range.e.c - range.s.c; ++i) {
        var guess = "", _guess = "", maxlen = 0;
        var col = [];
        for (j = 0; j < data.length; ++j) {
          if (data[j][i] != null)
            col.push(data[j][i]);
        }
        if (col.length == 0 || headers[i] == null) {
          coltypes[i] = "?";
          continue;
        }
        for (j = 0; j < col.length; ++j) {
          switch (typeof col[j]) {
            case "number":
              _guess = "B";
              break;
            case "string":
              _guess = "C";
              break;
            case "boolean":
              _guess = "L";
              break;
            case "object":
              _guess = col[j] instanceof Date ? "D" : "C";
              break;
            default:
              _guess = "C";
          }
          maxlen = Math.max(maxlen, String(col[j]).length);
          guess = guess && guess != _guess ? "C" : _guess;
        }
        if (maxlen > 250)
          maxlen = 250;
        _guess = ((cols[i] || {}).DBF || {}).type;
        if (_guess == "C") {
          if (cols[i].DBF.len > maxlen)
            maxlen = cols[i].DBF.len;
        }
        if (guess == "B" && _guess == "N") {
          guess = "N";
          coldecimals[i] = cols[i].DBF.dec;
          maxlen = cols[i].DBF.len;
        }
        colwidths[i] = guess == "C" || _guess == "N" ? maxlen : _RLEN[guess] || 0;
        rlen += colwidths[i];
        coltypes[i] = guess;
      }
      var h2 = ba.next(32);
      h2.write_shift(4, 318902576);
      h2.write_shift(4, data.length);
      h2.write_shift(2, 296 + 32 * hcnt);
      h2.write_shift(2, rlen);
      for (i = 0; i < 4; ++i)
        h2.write_shift(4, 0);
      h2.write_shift(4, 0 | (+dbf_reverse_map[current_ansi] || 3) << 8);
      for (i = 0, j = 0; i < headers.length; ++i) {
        if (headers[i] == null)
          continue;
        var hf = ba.next(32);
        var _f = (headers[i].slice(-10) + "\0\0\0\0\0\0\0\0\0\0\0").slice(0, 11);
        hf.write_shift(1, _f, "sbcs");
        hf.write_shift(1, coltypes[i] == "?" ? "C" : coltypes[i], "sbcs");
        hf.write_shift(4, j);
        hf.write_shift(1, colwidths[i] || _RLEN[coltypes[i]] || 0);
        hf.write_shift(1, coldecimals[i] || 0);
        hf.write_shift(1, 2);
        hf.write_shift(4, 0);
        hf.write_shift(1, 0);
        hf.write_shift(4, 0);
        hf.write_shift(4, 0);
        j += colwidths[i] || _RLEN[coltypes[i]] || 0;
      }
      var hb = ba.next(264);
      hb.write_shift(4, 13);
      for (i = 0; i < 65; ++i)
        hb.write_shift(4, 0);
      for (i = 0; i < data.length; ++i) {
        var rout = ba.next(rlen);
        rout.write_shift(1, 0);
        for (j = 0; j < headers.length; ++j) {
          if (headers[j] == null)
            continue;
          switch (coltypes[j]) {
            case "L":
              rout.write_shift(1, data[i][j] == null ? 63 : data[i][j] ? 84 : 70);
              break;
            case "B":
              rout.write_shift(8, data[i][j] || 0, "f");
              break;
            case "N":
              var _n = "0";
              if (typeof data[i][j] == "number")
                _n = data[i][j].toFixed(coldecimals[j] || 0);
              for (hcnt = 0; hcnt < colwidths[j] - _n.length; ++hcnt)
                rout.write_shift(1, 32);
              rout.write_shift(1, _n, "sbcs");
              break;
            case "D":
              if (!data[i][j])
                rout.write_shift(8, "00000000", "sbcs");
              else {
                rout.write_shift(4, ("0000" + data[i][j].getFullYear()).slice(-4), "sbcs");
                rout.write_shift(2, ("00" + (data[i][j].getMonth() + 1)).slice(-2), "sbcs");
                rout.write_shift(2, ("00" + data[i][j].getDate()).slice(-2), "sbcs");
              }
              break;
            case "C":
              var _s = String(data[i][j] != null ? data[i][j] : "").slice(0, colwidths[j]);
              rout.write_shift(1, _s, "sbcs");
              for (hcnt = 0; hcnt < colwidths[j] - _s.length; ++hcnt)
                rout.write_shift(1, 32);
              break;
          }
        }
      }
      ba.next(1).write_shift(1, 26);
      return ba.end();
    }
    return {
      to_workbook: dbf_to_workbook,
      to_sheet: dbf_to_sheet,
      from_sheet: sheet_to_dbf
    };
  }();
  var SYLK = /* @__PURE__ */ function() {
    var sylk_escapes = {
      AA: "\xC0",
      BA: "\xC1",
      CA: "\xC2",
      DA: 195,
      HA: "\xC4",
      JA: 197,
      AE: "\xC8",
      BE: "\xC9",
      CE: "\xCA",
      HE: "\xCB",
      AI: "\xCC",
      BI: "\xCD",
      CI: "\xCE",
      HI: "\xCF",
      AO: "\xD2",
      BO: "\xD3",
      CO: "\xD4",
      DO: 213,
      HO: "\xD6",
      AU: "\xD9",
      BU: "\xDA",
      CU: "\xDB",
      HU: "\xDC",
      Aa: "\xE0",
      Ba: "\xE1",
      Ca: "\xE2",
      Da: 227,
      Ha: "\xE4",
      Ja: 229,
      Ae: "\xE8",
      Be: "\xE9",
      Ce: "\xEA",
      He: "\xEB",
      Ai: "\xEC",
      Bi: "\xED",
      Ci: "\xEE",
      Hi: "\xEF",
      Ao: "\xF2",
      Bo: "\xF3",
      Co: "\xF4",
      Do: 245,
      Ho: "\xF6",
      Au: "\xF9",
      Bu: "\xFA",
      Cu: "\xFB",
      Hu: "\xFC",
      KC: "\xC7",
      Kc: "\xE7",
      q: "\xE6",
      z: "\u0153",
      a: "\xC6",
      j: "\u0152",
      DN: 209,
      Dn: 241,
      Hy: 255,
      S: 169,
      c: 170,
      R: 174,
      "B ": 180,
      0: 176,
      1: 177,
      2: 178,
      3: 179,
      5: 181,
      6: 182,
      7: 183,
      Q: 185,
      k: 186,
      b: 208,
      i: 216,
      l: 222,
      s: 240,
      y: 248,
      "!": 161,
      '"': 162,
      "#": 163,
      "(": 164,
      "%": 165,
      "'": 167,
      "H ": 168,
      "+": 171,
      ";": 187,
      "<": 188,
      "=": 189,
      ">": 190,
      "?": 191,
      "{": 223
    };
    var sylk_char_regex = new RegExp("\x1BN(" + keys$1(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g, "\\$1") + "|\\|)", "gm");
    var sylk_char_fn = function(_2, $1) {
      var o2 = sylk_escapes[$1];
      return typeof o2 == "number" ? _getansi(o2) : o2;
    };
    var decode_sylk_char = function($$, $1, $2) {
      var newcc = $1.charCodeAt(0) - 32 << 4 | $2.charCodeAt(0) - 48;
      return newcc == 59 ? $$ : _getansi(newcc);
    };
    sylk_escapes["|"] = 254;
    function sylk_to_aoa(d2, opts) {
      switch (opts.type) {
        case "base64":
          return sylk_to_aoa_str(Base64_decode(d2), opts);
        case "binary":
          return sylk_to_aoa_str(d2, opts);
        case "buffer":
          return sylk_to_aoa_str(has_buf && Buffer.isBuffer(d2) ? d2.toString("binary") : a2s(d2), opts);
        case "array":
          return sylk_to_aoa_str(cc2str(d2), opts);
      }
      throw new Error("Unrecognized type " + opts.type);
    }
    function sylk_to_aoa_str(str, opts) {
      var records = str.split(/[\n\r]+/), R2 = -1, C2 = -1, ri = 0, rj = 0, arr = [];
      var formats = [];
      var next_cell_format = null;
      var sht = {}, rowinfo = [], colinfo = [], cw = [];
      var Mval = 0, j;
      if (+opts.codepage >= 0)
        set_cp(+opts.codepage);
      for (; ri !== records.length; ++ri) {
        Mval = 0;
        var rstr = records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, decode_sylk_char).replace(sylk_char_regex, sylk_char_fn);
        var record = rstr.replace(/;;/g, "\0").split(";").map(function(x2) {
          return x2.replace(/\u0000/g, ";");
        });
        var RT = record[0], val;
        if (rstr.length > 0)
          switch (RT) {
            case "ID":
              break;
            case "E":
              break;
            case "B":
              break;
            case "O":
              break;
            case "W":
              break;
            case "P":
              if (record[1].charAt(0) == "P")
                formats.push(rstr.slice(3).replace(/;;/g, ";"));
              break;
            case "C":
              var C_seen_K = false, C_seen_X = false, C_seen_S = false, C_seen_E = false, _R = -1, _C = -1;
              for (rj = 1; rj < record.length; ++rj)
                switch (record[rj].charAt(0)) {
                  case "A":
                    break;
                  case "X":
                    C2 = parseInt(record[rj].slice(1)) - 1;
                    C_seen_X = true;
                    break;
                  case "Y":
                    R2 = parseInt(record[rj].slice(1)) - 1;
                    if (!C_seen_X)
                      C2 = 0;
                    for (j = arr.length; j <= R2; ++j)
                      arr[j] = [];
                    break;
                  case "K":
                    val = record[rj].slice(1);
                    if (val.charAt(0) === '"')
                      val = val.slice(1, val.length - 1);
                    else if (val === "TRUE")
                      val = true;
                    else if (val === "FALSE")
                      val = false;
                    else if (!isNaN(fuzzynum(val))) {
                      val = fuzzynum(val);
                      if (next_cell_format !== null && fmt_is_date(next_cell_format))
                        val = numdate(val);
                    } else if (!isNaN(fuzzydate(val).getDate())) {
                      val = parseDate(val);
                    }
                    C_seen_K = true;
                    break;
                  case "E":
                    C_seen_E = true;
                    var formula = rc_to_a1(record[rj].slice(1), { r: R2, c: C2 });
                    arr[R2][C2] = [arr[R2][C2], formula];
                    break;
                  case "S":
                    C_seen_S = true;
                    arr[R2][C2] = [arr[R2][C2], "S5S"];
                    break;
                  case "G":
                    break;
                  case "R":
                    _R = parseInt(record[rj].slice(1)) - 1;
                    break;
                  case "C":
                    _C = parseInt(record[rj].slice(1)) - 1;
                    break;
                  default:
                    if (opts && opts.WTF)
                      throw new Error("SYLK bad record " + rstr);
                }
              if (C_seen_K) {
                if (arr[R2][C2] && arr[R2][C2].length == 2)
                  arr[R2][C2][0] = val;
                else
                  arr[R2][C2] = val;
                next_cell_format = null;
              }
              if (C_seen_S) {
                if (C_seen_E)
                  throw new Error("SYLK shared formula cannot have own formula");
                var shrbase = _R > -1 && arr[_R][_C];
                if (!shrbase || !shrbase[1])
                  throw new Error("SYLK shared formula cannot find base");
                arr[R2][C2][1] = shift_formula_str(shrbase[1], { r: R2 - _R, c: C2 - _C });
              }
              break;
            case "F":
              var F_seen = 0;
              for (rj = 1; rj < record.length; ++rj)
                switch (record[rj].charAt(0)) {
                  case "X":
                    C2 = parseInt(record[rj].slice(1)) - 1;
                    ++F_seen;
                    break;
                  case "Y":
                    R2 = parseInt(record[rj].slice(1)) - 1;
                    for (j = arr.length; j <= R2; ++j)
                      arr[j] = [];
                    break;
                  case "M":
                    Mval = parseInt(record[rj].slice(1)) / 20;
                    break;
                  case "F":
                    break;
                  case "G":
                    break;
                  case "P":
                    next_cell_format = formats[parseInt(record[rj].slice(1))];
                    break;
                  case "S":
                    break;
                  case "D":
                    break;
                  case "N":
                    break;
                  case "W":
                    cw = record[rj].slice(1).split(" ");
                    for (j = parseInt(cw[0], 10); j <= parseInt(cw[1], 10); ++j) {
                      Mval = parseInt(cw[2], 10);
                      colinfo[j - 1] = Mval === 0 ? { hidden: true } : { wch: Mval };
                      process_col(colinfo[j - 1]);
                    }
                    break;
                  case "C":
                    C2 = parseInt(record[rj].slice(1)) - 1;
                    if (!colinfo[C2])
                      colinfo[C2] = {};
                    break;
                  case "R":
                    R2 = parseInt(record[rj].slice(1)) - 1;
                    if (!rowinfo[R2])
                      rowinfo[R2] = {};
                    if (Mval > 0) {
                      rowinfo[R2].hpt = Mval;
                      rowinfo[R2].hpx = pt2px(Mval);
                    } else if (Mval === 0)
                      rowinfo[R2].hidden = true;
                    break;
                  default:
                    if (opts && opts.WTF)
                      throw new Error("SYLK bad record " + rstr);
                }
              if (F_seen < 1)
                next_cell_format = null;
              break;
            default:
              if (opts && opts.WTF)
                throw new Error("SYLK bad record " + rstr);
          }
      }
      if (rowinfo.length > 0)
        sht["!rows"] = rowinfo;
      if (colinfo.length > 0)
        sht["!cols"] = colinfo;
      if (opts && opts.sheetRows)
        arr = arr.slice(0, opts.sheetRows);
      return [arr, sht];
    }
    function sylk_to_sheet(d2, opts) {
      var aoasht = sylk_to_aoa(d2, opts);
      var aoa = aoasht[0], ws = aoasht[1];
      var o2 = aoa_to_sheet(aoa, opts);
      keys$1(ws).forEach(function(k) {
        o2[k] = ws[k];
      });
      return o2;
    }
    function sylk_to_workbook(d2, opts) {
      return sheet_to_workbook(sylk_to_sheet(d2, opts), opts);
    }
    function write_ws_cell_sylk(cell, ws, R2, C2) {
      var o2 = "C;Y" + (R2 + 1) + ";X" + (C2 + 1) + ";K";
      switch (cell.t) {
        case "n":
          o2 += cell.v || 0;
          if (cell.f && !cell.F)
            o2 += ";E" + a1_to_rc(cell.f, { r: R2, c: C2 });
          break;
        case "b":
          o2 += cell.v ? "TRUE" : "FALSE";
          break;
        case "e":
          o2 += cell.w || cell.v;
          break;
        case "d":
          o2 += '"' + (cell.w || cell.v) + '"';
          break;
        case "s":
          o2 += '"' + cell.v.replace(/"/g, "").replace(/;/g, ";;") + '"';
          break;
      }
      return o2;
    }
    function write_ws_cols_sylk(out, cols) {
      cols.forEach(function(col, i) {
        var rec = "F;W" + (i + 1) + " " + (i + 1) + " ";
        if (col.hidden)
          rec += "0";
        else {
          if (typeof col.width == "number" && !col.wpx)
            col.wpx = width2px(col.width);
          if (typeof col.wpx == "number" && !col.wch)
            col.wch = px2char(col.wpx);
          if (typeof col.wch == "number")
            rec += Math.round(col.wch);
        }
        if (rec.charAt(rec.length - 1) != " ")
          out.push(rec);
      });
    }
    function write_ws_rows_sylk(out, rows) {
      rows.forEach(function(row, i) {
        var rec = "F;";
        if (row.hidden)
          rec += "M0;";
        else if (row.hpt)
          rec += "M" + 20 * row.hpt + ";";
        else if (row.hpx)
          rec += "M" + 20 * px2pt(row.hpx) + ";";
        if (rec.length > 2)
          out.push(rec + "R" + (i + 1));
      });
    }
    function sheet_to_sylk(ws, opts) {
      var preamble = ["ID;PWXL;N;E"], o2 = [];
      var r = safe_decode_range(ws["!ref"]), cell;
      var dense = Array.isArray(ws);
      var RS = "\r\n";
      preamble.push("P;PGeneral");
      preamble.push("F;P0;DG0G8;M255");
      if (ws["!cols"])
        write_ws_cols_sylk(preamble, ws["!cols"]);
      if (ws["!rows"])
        write_ws_rows_sylk(preamble, ws["!rows"]);
      preamble.push("B;Y" + (r.e.r - r.s.r + 1) + ";X" + (r.e.c - r.s.c + 1) + ";D" + [r.s.c, r.s.r, r.e.c, r.e.r].join(" "));
      for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
        for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
          var coord = encode_cell({ r: R2, c: C2 });
          cell = dense ? (ws[R2] || [])[C2] : ws[coord];
          if (!cell || cell.v == null && (!cell.f || cell.F))
            continue;
          o2.push(write_ws_cell_sylk(cell, ws, R2, C2));
        }
      }
      return preamble.join(RS) + RS + o2.join(RS) + RS + "E" + RS;
    }
    return {
      to_workbook: sylk_to_workbook,
      to_sheet: sylk_to_sheet,
      from_sheet: sheet_to_sylk
    };
  }();
  var DIF = /* @__PURE__ */ function() {
    function dif_to_aoa(d2, opts) {
      switch (opts.type) {
        case "base64":
          return dif_to_aoa_str(Base64_decode(d2), opts);
        case "binary":
          return dif_to_aoa_str(d2, opts);
        case "buffer":
          return dif_to_aoa_str(has_buf && Buffer.isBuffer(d2) ? d2.toString("binary") : a2s(d2), opts);
        case "array":
          return dif_to_aoa_str(cc2str(d2), opts);
      }
      throw new Error("Unrecognized type " + opts.type);
    }
    function dif_to_aoa_str(str, opts) {
      var records = str.split("\n"), R2 = -1, C2 = -1, ri = 0, arr = [];
      for (; ri !== records.length; ++ri) {
        if (records[ri].trim() === "BOT") {
          arr[++R2] = [];
          C2 = 0;
          continue;
        }
        if (R2 < 0)
          continue;
        var metadata = records[ri].trim().split(",");
        var type = metadata[0], value = metadata[1];
        ++ri;
        var data = records[ri] || "";
        while ((data.match(/["]/g) || []).length & 1 && ri < records.length - 1)
          data += "\n" + records[++ri];
        data = data.trim();
        switch (+type) {
          case -1:
            if (data === "BOT") {
              arr[++R2] = [];
              C2 = 0;
              continue;
            } else if (data !== "EOD")
              throw new Error("Unrecognized DIF special command " + data);
            break;
          case 0:
            if (data === "TRUE")
              arr[R2][C2] = true;
            else if (data === "FALSE")
              arr[R2][C2] = false;
            else if (!isNaN(fuzzynum(value)))
              arr[R2][C2] = fuzzynum(value);
            else if (!isNaN(fuzzydate(value).getDate()))
              arr[R2][C2] = parseDate(value);
            else
              arr[R2][C2] = value;
            ++C2;
            break;
          case 1:
            data = data.slice(1, data.length - 1);
            data = data.replace(/""/g, '"');
            if (data && data.match(/^=".*"$/))
              data = data.slice(2, -1);
            arr[R2][C2++] = data !== "" ? data : null;
            break;
        }
        if (data === "EOD")
          break;
      }
      if (opts && opts.sheetRows)
        arr = arr.slice(0, opts.sheetRows);
      return arr;
    }
    function dif_to_sheet(str, opts) {
      return aoa_to_sheet(dif_to_aoa(str, opts), opts);
    }
    function dif_to_workbook(str, opts) {
      return sheet_to_workbook(dif_to_sheet(str, opts), opts);
    }
    var sheet_to_dif = /* @__PURE__ */ function() {
      var push_field = function pf(o2, topic, v2, n, s2) {
        o2.push(topic);
        o2.push(v2 + "," + n);
        o2.push('"' + s2.replace(/"/g, '""') + '"');
      };
      var push_value = function po(o2, type, v2, s2) {
        o2.push(type + "," + v2);
        o2.push(type == 1 ? '"' + s2.replace(/"/g, '""') + '"' : s2);
      };
      return function sheet_to_dif2(ws) {
        var o2 = [];
        var r = safe_decode_range(ws["!ref"]), cell;
        var dense = Array.isArray(ws);
        push_field(o2, "TABLE", 0, 1, "sheetjs");
        push_field(o2, "VECTORS", 0, r.e.r - r.s.r + 1, "");
        push_field(o2, "TUPLES", 0, r.e.c - r.s.c + 1, "");
        push_field(o2, "DATA", 0, 0, "");
        for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
          push_value(o2, -1, 0, "BOT");
          for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
            var coord = encode_cell({ r: R2, c: C2 });
            cell = dense ? (ws[R2] || [])[C2] : ws[coord];
            if (!cell) {
              push_value(o2, 1, 0, "");
              continue;
            }
            switch (cell.t) {
              case "n":
                var val = cell.w;
                if (!val && cell.v != null)
                  val = cell.v;
                if (val == null) {
                  if (cell.f && !cell.F)
                    push_value(o2, 1, 0, "=" + cell.f);
                  else
                    push_value(o2, 1, 0, "");
                } else
                  push_value(o2, 0, val, "V");
                break;
              case "b":
                push_value(o2, 0, cell.v ? 1 : 0, cell.v ? "TRUE" : "FALSE");
                break;
              case "s":
                push_value(o2, 1, 0, isNaN(cell.v) ? cell.v : '="' + cell.v + '"');
                break;
              case "d":
                if (!cell.w)
                  cell.w = SSF_format(cell.z || table_fmt[14], datenum(parseDate(cell.v)));
                push_value(o2, 0, cell.w, "V");
                break;
              default:
                push_value(o2, 1, 0, "");
            }
          }
        }
        push_value(o2, -1, 0, "EOD");
        var RS = "\r\n";
        var oo = o2.join(RS);
        return oo;
      };
    }();
    return {
      to_workbook: dif_to_workbook,
      to_sheet: dif_to_sheet,
      from_sheet: sheet_to_dif
    };
  }();
  var ETH = /* @__PURE__ */ function() {
    function decode(s2) {
      return s2.replace(/\\b/g, "\\").replace(/\\c/g, ":").replace(/\\n/g, "\n");
    }
    function encode(s2) {
      return s2.replace(/\\/g, "\\b").replace(/:/g, "\\c").replace(/\n/g, "\\n");
    }
    function eth_to_aoa(str, opts) {
      var records = str.split("\n"), R2 = -1, C2 = -1, ri = 0, arr = [];
      for (; ri !== records.length; ++ri) {
        var record = records[ri].trim().split(":");
        if (record[0] !== "cell")
          continue;
        var addr = decode_cell(record[1]);
        if (arr.length <= addr.r) {
          for (R2 = arr.length; R2 <= addr.r; ++R2)
            if (!arr[R2])
              arr[R2] = [];
        }
        R2 = addr.r;
        C2 = addr.c;
        switch (record[2]) {
          case "t":
            arr[R2][C2] = decode(record[3]);
            break;
          case "v":
            arr[R2][C2] = +record[3];
            break;
          case "vtf":
            var _f = record[record.length - 1];
          case "vtc":
            switch (record[3]) {
              case "nl":
                arr[R2][C2] = +record[4] ? true : false;
                break;
              default:
                arr[R2][C2] = +record[4];
                break;
            }
            if (record[2] == "vtf")
              arr[R2][C2] = [arr[R2][C2], _f];
        }
      }
      if (opts && opts.sheetRows)
        arr = arr.slice(0, opts.sheetRows);
      return arr;
    }
    function eth_to_sheet(d2, opts) {
      return aoa_to_sheet(eth_to_aoa(d2, opts), opts);
    }
    function eth_to_workbook(d2, opts) {
      return sheet_to_workbook(eth_to_sheet(d2, opts), opts);
    }
    var header = [
      "socialcalc:version:1.5",
      "MIME-Version: 1.0",
      "Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"
    ].join("\n");
    var sep = [
      "--SocialCalcSpreadsheetControlSave",
      "Content-type: text/plain; charset=UTF-8"
    ].join("\n") + "\n";
    var meta = [
      "# SocialCalc Spreadsheet Control Save",
      "part:sheet"
    ].join("\n");
    var end = "--SocialCalcSpreadsheetControlSave--";
    function sheet_to_eth_data(ws) {
      if (!ws || !ws["!ref"])
        return "";
      var o2 = [], oo = [], cell, coord = "";
      var r = decode_range(ws["!ref"]);
      var dense = Array.isArray(ws);
      for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
        for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
          coord = encode_cell({ r: R2, c: C2 });
          cell = dense ? (ws[R2] || [])[C2] : ws[coord];
          if (!cell || cell.v == null || cell.t === "z")
            continue;
          oo = ["cell", coord, "t"];
          switch (cell.t) {
            case "s":
            case "str":
              oo.push(encode(cell.v));
              break;
            case "n":
              if (!cell.f) {
                oo[2] = "v";
                oo[3] = cell.v;
              } else {
                oo[2] = "vtf";
                oo[3] = "n";
                oo[4] = cell.v;
                oo[5] = encode(cell.f);
              }
              break;
            case "b":
              oo[2] = "vt" + (cell.f ? "f" : "c");
              oo[3] = "nl";
              oo[4] = cell.v ? "1" : "0";
              oo[5] = encode(cell.f || (cell.v ? "TRUE" : "FALSE"));
              break;
            case "d":
              var t = datenum(parseDate(cell.v));
              oo[2] = "vtc";
              oo[3] = "nd";
              oo[4] = "" + t;
              oo[5] = cell.w || SSF_format(cell.z || table_fmt[14], t);
              break;
            case "e":
              continue;
          }
          o2.push(oo.join(":"));
        }
      }
      o2.push("sheet:c:" + (r.e.c - r.s.c + 1) + ":r:" + (r.e.r - r.s.r + 1) + ":tvf:1");
      o2.push("valueformat:1:text-wiki");
      return o2.join("\n");
    }
    function sheet_to_eth(ws) {
      return [header, sep, meta, sep, sheet_to_eth_data(ws), end].join("\n");
    }
    return {
      to_workbook: eth_to_workbook,
      to_sheet: eth_to_sheet,
      from_sheet: sheet_to_eth
    };
  }();
  var PRN = /* @__PURE__ */ function() {
    function set_text_arr(data, arr, R2, C2, o2) {
      if (o2.raw)
        arr[R2][C2] = data;
      else if (data === "")
        ;
      else if (data === "TRUE")
        arr[R2][C2] = true;
      else if (data === "FALSE")
        arr[R2][C2] = false;
      else if (!isNaN(fuzzynum(data)))
        arr[R2][C2] = fuzzynum(data);
      else if (!isNaN(fuzzydate(data).getDate()))
        arr[R2][C2] = parseDate(data);
      else
        arr[R2][C2] = data;
    }
    function prn_to_aoa_str(f2, opts) {
      var o2 = opts || {};
      var arr = [];
      if (!f2 || f2.length === 0)
        return arr;
      var lines = f2.split(/[\r\n]/);
      var L = lines.length - 1;
      while (L >= 0 && lines[L].length === 0)
        --L;
      var start = 10, idx = 0;
      var R2 = 0;
      for (; R2 <= L; ++R2) {
        idx = lines[R2].indexOf(" ");
        if (idx == -1)
          idx = lines[R2].length;
        else
          idx++;
        start = Math.max(start, idx);
      }
      for (R2 = 0; R2 <= L; ++R2) {
        arr[R2] = [];
        var C2 = 0;
        set_text_arr(lines[R2].slice(0, start).trim(), arr, R2, C2, o2);
        for (C2 = 1; C2 <= (lines[R2].length - start) / 10 + 1; ++C2)
          set_text_arr(lines[R2].slice(start + (C2 - 1) * 10, start + C2 * 10).trim(), arr, R2, C2, o2);
      }
      if (o2.sheetRows)
        arr = arr.slice(0, o2.sheetRows);
      return arr;
    }
    var guess_seps = {
      44: ",",
      9: "	",
      59: ";",
      124: "|"
    };
    var guess_sep_weights = {
      44: 3,
      9: 2,
      59: 1,
      124: 0
    };
    function guess_sep(str) {
      var cnt = {}, instr = false, end = 0, cc = 0;
      for (; end < str.length; ++end) {
        if ((cc = str.charCodeAt(end)) == 34)
          instr = !instr;
        else if (!instr && cc in guess_seps)
          cnt[cc] = (cnt[cc] || 0) + 1;
      }
      cc = [];
      for (end in cnt)
        if (Object.prototype.hasOwnProperty.call(cnt, end)) {
          cc.push([cnt[end], end]);
        }
      if (!cc.length) {
        cnt = guess_sep_weights;
        for (end in cnt)
          if (Object.prototype.hasOwnProperty.call(cnt, end)) {
            cc.push([cnt[end], end]);
          }
      }
      cc.sort(function(a2, b2) {
        return a2[0] - b2[0] || guess_sep_weights[a2[1]] - guess_sep_weights[b2[1]];
      });
      return guess_seps[cc.pop()[1]] || 44;
    }
    function dsv_to_sheet_str(str, opts) {
      var o2 = opts || {};
      var sep = "";
      var ws = o2.dense ? [] : {};
      var range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
      if (str.slice(0, 4) == "sep=") {
        if (str.charCodeAt(5) == 13 && str.charCodeAt(6) == 10) {
          sep = str.charAt(4);
          str = str.slice(7);
        } else if (str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10) {
          sep = str.charAt(4);
          str = str.slice(6);
        } else
          sep = guess_sep(str.slice(0, 1024));
      } else if (o2 && o2.FS)
        sep = o2.FS;
      else
        sep = guess_sep(str.slice(0, 1024));
      var R2 = 0, C2 = 0, v2 = 0;
      var start = 0, end = 0, sepcc = sep.charCodeAt(0), instr = false, cc = 0, startcc = str.charCodeAt(0);
      str = str.replace(/\r\n/mg, "\n");
      var _re = o2.dateNF != null ? dateNF_regex(o2.dateNF) : null;
      function finish_cell() {
        var s2 = str.slice(start, end);
        var cell = {};
        if (s2.charAt(0) == '"' && s2.charAt(s2.length - 1) == '"')
          s2 = s2.slice(1, -1).replace(/""/g, '"');
        if (s2.length === 0)
          cell.t = "z";
        else if (o2.raw) {
          cell.t = "s";
          cell.v = s2;
        } else if (s2.trim().length === 0) {
          cell.t = "s";
          cell.v = s2;
        } else if (s2.charCodeAt(0) == 61) {
          if (s2.charCodeAt(1) == 34 && s2.charCodeAt(s2.length - 1) == 34) {
            cell.t = "s";
            cell.v = s2.slice(2, -1).replace(/""/g, '"');
          } else if (fuzzyfmla(s2)) {
            cell.t = "n";
            cell.f = s2.slice(1);
          } else {
            cell.t = "s";
            cell.v = s2;
          }
        } else if (s2 == "TRUE") {
          cell.t = "b";
          cell.v = true;
        } else if (s2 == "FALSE") {
          cell.t = "b";
          cell.v = false;
        } else if (!isNaN(v2 = fuzzynum(s2))) {
          cell.t = "n";
          if (o2.cellText !== false)
            cell.w = s2;
          cell.v = v2;
        } else if (!isNaN(fuzzydate(s2).getDate()) || _re && s2.match(_re)) {
          cell.z = o2.dateNF || table_fmt[14];
          var k = 0;
          if (_re && s2.match(_re)) {
            s2 = dateNF_fix(s2, o2.dateNF, s2.match(_re) || []);
            k = 1;
          }
          if (o2.cellDates) {
            cell.t = "d";
            cell.v = parseDate(s2, k);
          } else {
            cell.t = "n";
            cell.v = datenum(parseDate(s2, k));
          }
          if (o2.cellText !== false)
            cell.w = SSF_format(cell.z, cell.v instanceof Date ? datenum(cell.v) : cell.v);
          if (!o2.cellNF)
            delete cell.z;
        } else {
          cell.t = "s";
          cell.v = s2;
        }
        if (cell.t == "z")
          ;
        else if (o2.dense) {
          if (!ws[R2])
            ws[R2] = [];
          ws[R2][C2] = cell;
        } else
          ws[encode_cell({ c: C2, r: R2 })] = cell;
        start = end + 1;
        startcc = str.charCodeAt(start);
        if (range.e.c < C2)
          range.e.c = C2;
        if (range.e.r < R2)
          range.e.r = R2;
        if (cc == sepcc)
          ++C2;
        else {
          C2 = 0;
          ++R2;
          if (o2.sheetRows && o2.sheetRows <= R2)
            return true;
        }
      }
      outer:
        for (; end < str.length; ++end)
          switch (cc = str.charCodeAt(end)) {
            case 34:
              if (startcc === 34)
                instr = !instr;
              break;
            case sepcc:
            case 10:
            case 13:
              if (!instr && finish_cell())
                break outer;
              break;
          }
      if (end - start > 0)
        finish_cell();
      ws["!ref"] = encode_range(range);
      return ws;
    }
    function prn_to_sheet_str(str, opts) {
      if (!(opts && opts.PRN))
        return dsv_to_sheet_str(str, opts);
      if (opts.FS)
        return dsv_to_sheet_str(str, opts);
      if (str.slice(0, 4) == "sep=")
        return dsv_to_sheet_str(str, opts);
      if (str.indexOf("	") >= 0 || str.indexOf(",") >= 0 || str.indexOf(";") >= 0)
        return dsv_to_sheet_str(str, opts);
      return aoa_to_sheet(prn_to_aoa_str(str, opts), opts);
    }
    function prn_to_sheet(d2, opts) {
      var str = "", bytes = opts.type == "string" ? [0, 0, 0, 0] : firstbyte(d2, opts);
      switch (opts.type) {
        case "base64":
          str = Base64_decode(d2);
          break;
        case "binary":
          str = d2;
          break;
        case "buffer":
          if (opts.codepage == 65001)
            str = d2.toString("utf8");
          else if (opts.codepage && typeof $cptable !== "undefined")
            str = $cptable.utils.decode(opts.codepage, d2);
          else
            str = has_buf && Buffer.isBuffer(d2) ? d2.toString("binary") : a2s(d2);
          break;
        case "array":
          str = cc2str(d2);
          break;
        case "string":
          str = d2;
          break;
        default:
          throw new Error("Unrecognized type " + opts.type);
      }
      if (bytes[0] == 239 && bytes[1] == 187 && bytes[2] == 191)
        str = utf8read(str.slice(3));
      else if (opts.type != "string" && opts.type != "buffer" && opts.codepage == 65001)
        str = utf8read(str);
      else if (opts.type == "binary" && typeof $cptable !== "undefined" && opts.codepage)
        str = $cptable.utils.decode(opts.codepage, $cptable.utils.encode(28591, str));
      if (str.slice(0, 19) == "socialcalc:version:")
        return ETH.to_sheet(opts.type == "string" ? str : utf8read(str), opts);
      return prn_to_sheet_str(str, opts);
    }
    function prn_to_workbook(d2, opts) {
      return sheet_to_workbook(prn_to_sheet(d2, opts), opts);
    }
    function sheet_to_prn(ws) {
      var o2 = [];
      var r = safe_decode_range(ws["!ref"]), cell;
      var dense = Array.isArray(ws);
      for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
        var oo = [];
        for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
          var coord = encode_cell({ r: R2, c: C2 });
          cell = dense ? (ws[R2] || [])[C2] : ws[coord];
          if (!cell || cell.v == null) {
            oo.push("          ");
            continue;
          }
          var w2 = (cell.w || (format_cell(cell), cell.w) || "").slice(0, 10);
          while (w2.length < 10)
            w2 += " ";
          oo.push(w2 + (C2 === 0 ? " " : ""));
        }
        o2.push(oo.join(""));
      }
      return o2.join("\n");
    }
    return {
      to_workbook: prn_to_workbook,
      to_sheet: prn_to_sheet,
      from_sheet: sheet_to_prn
    };
  }();
  function read_wb_ID(d2, opts) {
    var o2 = opts || {}, OLD_WTF = !!o2.WTF;
    o2.WTF = true;
    try {
      var out = SYLK.to_workbook(d2, o2);
      o2.WTF = OLD_WTF;
      return out;
    } catch (e) {
      o2.WTF = OLD_WTF;
      if (!e.message.match(/SYLK bad record ID/) && OLD_WTF)
        throw e;
      return PRN.to_workbook(d2, opts);
    }
  }
  var WK_ = /* @__PURE__ */ function() {
    function lotushopper(data, cb, opts) {
      if (!data)
        return;
      prep_blob(data, data.l || 0);
      var Enum = opts.Enum || WK1Enum;
      while (data.l < data.length) {
        var RT = data.read_shift(2);
        var R2 = Enum[RT] || Enum[65535];
        var length = data.read_shift(2);
        var tgt = data.l + length;
        var d2 = R2.f && R2.f(data, length, opts);
        data.l = tgt;
        if (cb(d2, R2, RT))
          return;
      }
    }
    function lotus_to_workbook(d2, opts) {
      switch (opts.type) {
        case "base64":
          return lotus_to_workbook_buf(s2a(Base64_decode(d2)), opts);
        case "binary":
          return lotus_to_workbook_buf(s2a(d2), opts);
        case "buffer":
        case "array":
          return lotus_to_workbook_buf(d2, opts);
      }
      throw "Unsupported type " + opts.type;
    }
    function lotus_to_workbook_buf(d2, opts) {
      if (!d2)
        return d2;
      var o2 = opts || {};
      var s2 = o2.dense ? [] : {}, n = "Sheet1", next_n = "", sidx = 0;
      var sheets = {}, snames = [], realnames = [];
      var refguess = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
      var sheetRows = o2.sheetRows || 0;
      if (d2[2] == 0) {
        if (d2[3] == 8 || d2[3] == 9) {
          if (d2.length >= 16 && d2[14] == 5 && d2[15] === 108)
            throw new Error("Unsupported Works 3 for Mac file");
        }
      }
      if (d2[2] == 2) {
        o2.Enum = WK1Enum;
        lotushopper(d2, function(val, R2, RT) {
          switch (RT) {
            case 0:
              o2.vers = val;
              if (val >= 4096)
                o2.qpro = true;
              break;
            case 6:
              refguess = val;
              break;
            case 204:
              if (val)
                next_n = val;
              break;
            case 222:
              next_n = val;
              break;
            case 15:
            case 51:
              if (!o2.qpro)
                val[1].v = val[1].v.slice(1);
            case 13:
            case 14:
            case 16:
              if (RT == 14 && (val[2] & 112) == 112 && (val[2] & 15) > 1 && (val[2] & 15) < 15) {
                val[1].z = o2.dateNF || table_fmt[14];
                if (o2.cellDates) {
                  val[1].t = "d";
                  val[1].v = numdate(val[1].v);
                }
              }
              if (o2.qpro) {
                if (val[3] > sidx) {
                  s2["!ref"] = encode_range(refguess);
                  sheets[n] = s2;
                  snames.push(n);
                  s2 = o2.dense ? [] : {};
                  refguess = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
                  sidx = val[3];
                  n = next_n || "Sheet" + (sidx + 1);
                  next_n = "";
                }
              }
              var tmpcell = o2.dense ? (s2[val[0].r] || [])[val[0].c] : s2[encode_cell(val[0])];
              if (tmpcell) {
                tmpcell.t = val[1].t;
                tmpcell.v = val[1].v;
                if (val[1].z != null)
                  tmpcell.z = val[1].z;
                if (val[1].f != null)
                  tmpcell.f = val[1].f;
                break;
              }
              if (o2.dense) {
                if (!s2[val[0].r])
                  s2[val[0].r] = [];
                s2[val[0].r][val[0].c] = val[1];
              } else
                s2[encode_cell(val[0])] = val[1];
              break;
          }
        }, o2);
      } else if (d2[2] == 26 || d2[2] == 14) {
        o2.Enum = WK3Enum;
        if (d2[2] == 14) {
          o2.qpro = true;
          d2.l = 0;
        }
        lotushopper(d2, function(val, R2, RT) {
          switch (RT) {
            case 204:
              n = val;
              break;
            case 22:
              val[1].v = val[1].v.slice(1);
            case 23:
            case 24:
            case 25:
            case 37:
            case 39:
            case 40:
              if (val[3] > sidx) {
                s2["!ref"] = encode_range(refguess);
                sheets[n] = s2;
                snames.push(n);
                s2 = o2.dense ? [] : {};
                refguess = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
                sidx = val[3];
                n = "Sheet" + (sidx + 1);
              }
              if (sheetRows > 0 && val[0].r >= sheetRows)
                break;
              if (o2.dense) {
                if (!s2[val[0].r])
                  s2[val[0].r] = [];
                s2[val[0].r][val[0].c] = val[1];
              } else
                s2[encode_cell(val[0])] = val[1];
              if (refguess.e.c < val[0].c)
                refguess.e.c = val[0].c;
              if (refguess.e.r < val[0].r)
                refguess.e.r = val[0].r;
              break;
            case 27:
              if (val[14e3])
                realnames[val[14e3][0]] = val[14e3][1];
              break;
            case 1537:
              realnames[val[0]] = val[1];
              if (val[0] == sidx)
                n = val[1];
              break;
          }
        }, o2);
      } else
        throw new Error("Unrecognized LOTUS BOF " + d2[2]);
      s2["!ref"] = encode_range(refguess);
      sheets[next_n || n] = s2;
      snames.push(next_n || n);
      if (!realnames.length)
        return { SheetNames: snames, Sheets: sheets };
      var osheets = {}, rnames = [];
      for (var i = 0; i < realnames.length; ++i)
        if (sheets[snames[i]]) {
          rnames.push(realnames[i] || snames[i]);
          osheets[realnames[i]] = sheets[realnames[i]] || sheets[snames[i]];
        } else {
          rnames.push(realnames[i]);
          osheets[realnames[i]] = { "!ref": "A1" };
        }
      return { SheetNames: rnames, Sheets: osheets };
    }
    function sheet_to_wk1(ws, opts) {
      var o2 = opts || {};
      if (+o2.codepage >= 0)
        set_cp(+o2.codepage);
      if (o2.type == "string")
        throw new Error("Cannot write WK1 to JS string");
      var ba = buf_array();
      var range = safe_decode_range(ws["!ref"]);
      var dense = Array.isArray(ws);
      var cols = [];
      write_biff_rec(ba, 0, write_BOF_WK1(1030));
      write_biff_rec(ba, 6, write_RANGE(range));
      var max_R = Math.min(range.e.r, 8191);
      for (var R2 = range.s.r; R2 <= max_R; ++R2) {
        var rr = encode_row(R2);
        for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
          if (R2 === range.s.r)
            cols[C2] = encode_col(C2);
          var ref2 = cols[C2] + rr;
          var cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
          if (!cell || cell.t == "z")
            continue;
          if (cell.t == "n") {
            if ((cell.v | 0) == cell.v && cell.v >= -32768 && cell.v <= 32767)
              write_biff_rec(ba, 13, write_INTEGER(R2, C2, cell.v));
            else
              write_biff_rec(ba, 14, write_NUMBER(R2, C2, cell.v));
          } else {
            var str = format_cell(cell);
            write_biff_rec(ba, 15, write_LABEL(R2, C2, str.slice(0, 239)));
          }
        }
      }
      write_biff_rec(ba, 1);
      return ba.end();
    }
    function book_to_wk3(wb, opts) {
      var o2 = opts || {};
      if (+o2.codepage >= 0)
        set_cp(+o2.codepage);
      if (o2.type == "string")
        throw new Error("Cannot write WK3 to JS string");
      var ba = buf_array();
      write_biff_rec(ba, 0, write_BOF_WK3(wb));
      for (var i = 0, cnt = 0; i < wb.SheetNames.length; ++i)
        if ((wb.Sheets[wb.SheetNames[i]] || {})["!ref"])
          write_biff_rec(ba, 27, write_XFORMAT_SHEETNAME(wb.SheetNames[i], cnt++));
      var wsidx = 0;
      for (i = 0; i < wb.SheetNames.length; ++i) {
        var ws = wb.Sheets[wb.SheetNames[i]];
        if (!ws || !ws["!ref"])
          continue;
        var range = safe_decode_range(ws["!ref"]);
        var dense = Array.isArray(ws);
        var cols = [];
        var max_R = Math.min(range.e.r, 8191);
        for (var R2 = range.s.r; R2 <= max_R; ++R2) {
          var rr = encode_row(R2);
          for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
            if (R2 === range.s.r)
              cols[C2] = encode_col(C2);
            var ref2 = cols[C2] + rr;
            var cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
            if (!cell || cell.t == "z")
              continue;
            if (cell.t == "n") {
              write_biff_rec(ba, 23, write_NUMBER_17(R2, C2, wsidx, cell.v));
            } else {
              var str = format_cell(cell);
              write_biff_rec(ba, 22, write_LABEL_16(R2, C2, wsidx, str.slice(0, 239)));
            }
          }
        }
        ++wsidx;
      }
      write_biff_rec(ba, 1);
      return ba.end();
    }
    function write_BOF_WK1(v2) {
      var out = new_buf(2);
      out.write_shift(2, v2);
      return out;
    }
    function write_BOF_WK3(wb) {
      var out = new_buf(26);
      out.write_shift(2, 4096);
      out.write_shift(2, 4);
      out.write_shift(4, 0);
      var rows = 0, cols = 0, wscnt = 0;
      for (var i = 0; i < wb.SheetNames.length; ++i) {
        var name = wb.SheetNames[i];
        var ws = wb.Sheets[name];
        if (!ws || !ws["!ref"])
          continue;
        ++wscnt;
        var range = decode_range(ws["!ref"]);
        if (rows < range.e.r)
          rows = range.e.r;
        if (cols < range.e.c)
          cols = range.e.c;
      }
      if (rows > 8191)
        rows = 8191;
      out.write_shift(2, rows);
      out.write_shift(1, wscnt);
      out.write_shift(1, cols);
      out.write_shift(2, 0);
      out.write_shift(2, 0);
      out.write_shift(1, 1);
      out.write_shift(1, 2);
      out.write_shift(4, 0);
      out.write_shift(4, 0);
      return out;
    }
    function parse_RANGE(blob, length, opts) {
      var o2 = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
      if (length == 8 && opts.qpro) {
        o2.s.c = blob.read_shift(1);
        blob.l++;
        o2.s.r = blob.read_shift(2);
        o2.e.c = blob.read_shift(1);
        blob.l++;
        o2.e.r = blob.read_shift(2);
        return o2;
      }
      o2.s.c = blob.read_shift(2);
      o2.s.r = blob.read_shift(2);
      if (length == 12 && opts.qpro)
        blob.l += 2;
      o2.e.c = blob.read_shift(2);
      o2.e.r = blob.read_shift(2);
      if (length == 12 && opts.qpro)
        blob.l += 2;
      if (o2.s.c == 65535)
        o2.s.c = o2.e.c = o2.s.r = o2.e.r = 0;
      return o2;
    }
    function write_RANGE(range) {
      var out = new_buf(8);
      out.write_shift(2, range.s.c);
      out.write_shift(2, range.s.r);
      out.write_shift(2, range.e.c);
      out.write_shift(2, range.e.r);
      return out;
    }
    function parse_cell(blob, length, opts) {
      var o2 = [{ c: 0, r: 0 }, { t: "n", v: 0 }, 0, 0];
      if (opts.qpro && opts.vers != 20768) {
        o2[0].c = blob.read_shift(1);
        o2[3] = blob.read_shift(1);
        o2[0].r = blob.read_shift(2);
        blob.l += 2;
      } else {
        o2[2] = blob.read_shift(1);
        o2[0].c = blob.read_shift(2);
        o2[0].r = blob.read_shift(2);
      }
      return o2;
    }
    function parse_LABEL(blob, length, opts) {
      var tgt = blob.l + length;
      var o2 = parse_cell(blob, length, opts);
      o2[1].t = "s";
      if (opts.vers == 20768) {
        blob.l++;
        var len = blob.read_shift(1);
        o2[1].v = blob.read_shift(len, "utf8");
        return o2;
      }
      if (opts.qpro)
        blob.l++;
      o2[1].v = blob.read_shift(tgt - blob.l, "cstr");
      return o2;
    }
    function write_LABEL(R2, C2, s2) {
      var o2 = new_buf(7 + s2.length);
      o2.write_shift(1, 255);
      o2.write_shift(2, C2);
      o2.write_shift(2, R2);
      o2.write_shift(1, 39);
      for (var i = 0; i < o2.length; ++i) {
        var cc = s2.charCodeAt(i);
        o2.write_shift(1, cc >= 128 ? 95 : cc);
      }
      o2.write_shift(1, 0);
      return o2;
    }
    function parse_INTEGER(blob, length, opts) {
      var o2 = parse_cell(blob, length, opts);
      o2[1].v = blob.read_shift(2, "i");
      return o2;
    }
    function write_INTEGER(R2, C2, v2) {
      var o2 = new_buf(7);
      o2.write_shift(1, 255);
      o2.write_shift(2, C2);
      o2.write_shift(2, R2);
      o2.write_shift(2, v2, "i");
      return o2;
    }
    function parse_NUMBER(blob, length, opts) {
      var o2 = parse_cell(blob, length, opts);
      o2[1].v = blob.read_shift(8, "f");
      return o2;
    }
    function write_NUMBER(R2, C2, v2) {
      var o2 = new_buf(13);
      o2.write_shift(1, 255);
      o2.write_shift(2, C2);
      o2.write_shift(2, R2);
      o2.write_shift(8, v2, "f");
      return o2;
    }
    function parse_FORMULA(blob, length, opts) {
      var tgt = blob.l + length;
      var o2 = parse_cell(blob, length, opts);
      o2[1].v = blob.read_shift(8, "f");
      if (opts.qpro)
        blob.l = tgt;
      else {
        var flen = blob.read_shift(2);
        wk1_fmla_to_csf(blob.slice(blob.l, blob.l + flen), o2);
        blob.l += flen;
      }
      return o2;
    }
    function wk1_parse_rc(B2, V, col) {
      var rel = V & 32768;
      V &= ~32768;
      V = (rel ? B2 : 0) + (V >= 8192 ? V - 16384 : V);
      return (rel ? "" : "$") + (col ? encode_col(V) : encode_row(V));
    }
    var FuncTab = {
      51: ["FALSE", 0],
      52: ["TRUE", 0],
      70: ["LEN", 1],
      80: ["SUM", 69],
      81: ["AVERAGEA", 69],
      82: ["COUNTA", 69],
      83: ["MINA", 69],
      84: ["MAXA", 69],
      111: ["T", 1]
    };
    var BinOpTab = [
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "+",
      "-",
      "*",
      "/",
      "^",
      "=",
      "<>",
      "<=",
      ">=",
      "<",
      ">",
      "",
      "",
      "",
      "",
      "&",
      "",
      "",
      "",
      "",
      "",
      "",
      ""
    ];
    function wk1_fmla_to_csf(blob, o2) {
      prep_blob(blob, 0);
      var out = [], argc = 0, R2 = "", C2 = "", argL = "", argR = "";
      while (blob.l < blob.length) {
        var cc = blob[blob.l++];
        switch (cc) {
          case 0:
            out.push(blob.read_shift(8, "f"));
            break;
          case 1:
            {
              C2 = wk1_parse_rc(o2[0].c, blob.read_shift(2), true);
              R2 = wk1_parse_rc(o2[0].r, blob.read_shift(2), false);
              out.push(C2 + R2);
            }
            break;
          case 2:
            {
              var c2 = wk1_parse_rc(o2[0].c, blob.read_shift(2), true);
              var r = wk1_parse_rc(o2[0].r, blob.read_shift(2), false);
              C2 = wk1_parse_rc(o2[0].c, blob.read_shift(2), true);
              R2 = wk1_parse_rc(o2[0].r, blob.read_shift(2), false);
              out.push(c2 + r + ":" + C2 + R2);
            }
            break;
          case 3:
            if (blob.l < blob.length) {
              console.error("WK1 premature formula end");
              return;
            }
            break;
          case 4:
            out.push("(" + out.pop() + ")");
            break;
          case 5:
            out.push(blob.read_shift(2));
            break;
          case 6:
            {
              var Z2 = "";
              while (cc = blob[blob.l++])
                Z2 += String.fromCharCode(cc);
              out.push('"' + Z2.replace(/"/g, '""') + '"');
            }
            break;
          case 8:
            out.push("-" + out.pop());
            break;
          case 23:
            out.push("+" + out.pop());
            break;
          case 22:
            out.push("NOT(" + out.pop() + ")");
            break;
          case 20:
          case 21:
            {
              argR = out.pop();
              argL = out.pop();
              out.push(["AND", "OR"][cc - 20] + "(" + argL + "," + argR + ")");
            }
            break;
          default:
            if (cc < 32 && BinOpTab[cc]) {
              argR = out.pop();
              argL = out.pop();
              out.push(argL + BinOpTab[cc] + argR);
            } else if (FuncTab[cc]) {
              argc = FuncTab[cc][1];
              if (argc == 69)
                argc = blob[blob.l++];
              if (argc > out.length) {
                console.error("WK1 bad formula parse 0x" + cc.toString(16) + ":|" + out.join("|") + "|");
                return;
              }
              var args = out.slice(-argc);
              out.length -= argc;
              out.push(FuncTab[cc][0] + "(" + args.join(",") + ")");
            } else if (cc <= 7)
              return console.error("WK1 invalid opcode " + cc.toString(16));
            else if (cc <= 24)
              return console.error("WK1 unsupported op " + cc.toString(16));
            else if (cc <= 30)
              return console.error("WK1 invalid opcode " + cc.toString(16));
            else if (cc <= 115)
              return console.error("WK1 unsupported function opcode " + cc.toString(16));
            else
              return console.error("WK1 unrecognized opcode " + cc.toString(16));
        }
      }
      if (out.length == 1)
        o2[1].f = "" + out[0];
      else
        console.error("WK1 bad formula parse |" + out.join("|") + "|");
    }
    function parse_cell_3(blob) {
      var o2 = [{ c: 0, r: 0 }, { t: "n", v: 0 }, 0];
      o2[0].r = blob.read_shift(2);
      o2[3] = blob[blob.l++];
      o2[0].c = blob[blob.l++];
      return o2;
    }
    function parse_LABEL_16(blob, length) {
      var o2 = parse_cell_3(blob);
      o2[1].t = "s";
      o2[1].v = blob.read_shift(length - 4, "cstr");
      return o2;
    }
    function write_LABEL_16(R2, C2, wsidx, s2) {
      var o2 = new_buf(6 + s2.length);
      o2.write_shift(2, R2);
      o2.write_shift(1, wsidx);
      o2.write_shift(1, C2);
      o2.write_shift(1, 39);
      for (var i = 0; i < s2.length; ++i) {
        var cc = s2.charCodeAt(i);
        o2.write_shift(1, cc >= 128 ? 95 : cc);
      }
      o2.write_shift(1, 0);
      return o2;
    }
    function parse_NUMBER_18(blob, length) {
      var o2 = parse_cell_3(blob);
      o2[1].v = blob.read_shift(2);
      var v2 = o2[1].v >> 1;
      if (o2[1].v & 1) {
        switch (v2 & 7) {
          case 0:
            v2 = (v2 >> 3) * 5e3;
            break;
          case 1:
            v2 = (v2 >> 3) * 500;
            break;
          case 2:
            v2 = (v2 >> 3) / 20;
            break;
          case 3:
            v2 = (v2 >> 3) / 200;
            break;
          case 4:
            v2 = (v2 >> 3) / 2e3;
            break;
          case 5:
            v2 = (v2 >> 3) / 2e4;
            break;
          case 6:
            v2 = (v2 >> 3) / 16;
            break;
          case 7:
            v2 = (v2 >> 3) / 64;
            break;
        }
      }
      o2[1].v = v2;
      return o2;
    }
    function parse_NUMBER_17(blob, length) {
      var o2 = parse_cell_3(blob);
      var v1 = blob.read_shift(4);
      var v2 = blob.read_shift(4);
      var e = blob.read_shift(2);
      if (e == 65535) {
        if (v1 === 0 && v2 === 3221225472) {
          o2[1].t = "e";
          o2[1].v = 15;
        } else if (v1 === 0 && v2 === 3489660928) {
          o2[1].t = "e";
          o2[1].v = 42;
        } else
          o2[1].v = 0;
        return o2;
      }
      var s2 = e & 32768;
      e = (e & 32767) - 16446;
      o2[1].v = (1 - s2 * 2) * (v2 * Math.pow(2, e + 32) + v1 * Math.pow(2, e));
      return o2;
    }
    function write_NUMBER_17(R2, C2, wsidx, v2) {
      var o2 = new_buf(14);
      o2.write_shift(2, R2);
      o2.write_shift(1, wsidx);
      o2.write_shift(1, C2);
      if (v2 == 0) {
        o2.write_shift(4, 0);
        o2.write_shift(4, 0);
        o2.write_shift(2, 65535);
        return o2;
      }
      var s2 = 0, e = 0, v1 = 0, v22 = 0;
      if (v2 < 0) {
        s2 = 1;
        v2 = -v2;
      }
      e = Math.log2(v2) | 0;
      v2 /= Math.pow(2, e - 31);
      v22 = v2 >>> 0;
      if ((v22 & 2147483648) == 0) {
        v2 /= 2;
        ++e;
        v22 = v2 >>> 0;
      }
      v2 -= v22;
      v22 |= 2147483648;
      v22 >>>= 0;
      v2 *= Math.pow(2, 32);
      v1 = v2 >>> 0;
      o2.write_shift(4, v1);
      o2.write_shift(4, v22);
      e += 16383 + (s2 ? 32768 : 0);
      o2.write_shift(2, e);
      return o2;
    }
    function parse_FORMULA_19(blob, length) {
      var o2 = parse_NUMBER_17(blob);
      blob.l += length - 14;
      return o2;
    }
    function parse_NUMBER_25(blob, length) {
      var o2 = parse_cell_3(blob);
      var v1 = blob.read_shift(4);
      o2[1].v = v1 >> 6;
      return o2;
    }
    function parse_NUMBER_27(blob, length) {
      var o2 = parse_cell_3(blob);
      var v1 = blob.read_shift(8, "f");
      o2[1].v = v1;
      return o2;
    }
    function parse_FORMULA_28(blob, length) {
      var o2 = parse_NUMBER_27(blob);
      blob.l += length - 10;
      return o2;
    }
    function parse_SHEETNAMECS(blob, length) {
      return blob[blob.l + length - 1] == 0 ? blob.read_shift(length, "cstr") : "";
    }
    function parse_SHEETNAMELP(blob, length) {
      var len = blob[blob.l++];
      if (len > length - 1)
        len = length - 1;
      var o2 = "";
      while (o2.length < len)
        o2 += String.fromCharCode(blob[blob.l++]);
      return o2;
    }
    function parse_SHEETINFOQP(blob, length, opts) {
      if (!opts.qpro || length < 21)
        return;
      var id = blob.read_shift(1);
      blob.l += 17;
      blob.l += 1;
      blob.l += 2;
      var nm = blob.read_shift(length - 21, "cstr");
      return [id, nm];
    }
    function parse_XFORMAT(blob, length) {
      var o2 = {}, tgt = blob.l + length;
      while (blob.l < tgt) {
        var dt2 = blob.read_shift(2);
        if (dt2 == 14e3) {
          o2[dt2] = [0, ""];
          o2[dt2][0] = blob.read_shift(2);
          while (blob[blob.l]) {
            o2[dt2][1] += String.fromCharCode(blob[blob.l]);
            blob.l++;
          }
          blob.l++;
        }
      }
      return o2;
    }
    function write_XFORMAT_SHEETNAME(name, wsidx) {
      var out = new_buf(5 + name.length);
      out.write_shift(2, 14e3);
      out.write_shift(2, wsidx);
      for (var i = 0; i < name.length; ++i) {
        var cc = name.charCodeAt(i);
        out[out.l++] = cc > 127 ? 95 : cc;
      }
      out[out.l++] = 0;
      return out;
    }
    var WK1Enum = {
      0: { n: "BOF", f: parseuint16 },
      1: { n: "EOF" },
      2: { n: "CALCMODE" },
      3: { n: "CALCORDER" },
      4: { n: "SPLIT" },
      5: { n: "SYNC" },
      6: { n: "RANGE", f: parse_RANGE },
      7: { n: "WINDOW1" },
      8: { n: "COLW1" },
      9: { n: "WINTWO" },
      10: { n: "COLW2" },
      11: { n: "NAME" },
      12: { n: "BLANK" },
      13: { n: "INTEGER", f: parse_INTEGER },
      14: { n: "NUMBER", f: parse_NUMBER },
      15: { n: "LABEL", f: parse_LABEL },
      16: { n: "FORMULA", f: parse_FORMULA },
      24: { n: "TABLE" },
      25: { n: "ORANGE" },
      26: { n: "PRANGE" },
      27: { n: "SRANGE" },
      28: { n: "FRANGE" },
      29: { n: "KRANGE1" },
      32: { n: "HRANGE" },
      35: { n: "KRANGE2" },
      36: { n: "PROTEC" },
      37: { n: "FOOTER" },
      38: { n: "HEADER" },
      39: { n: "SETUP" },
      40: { n: "MARGINS" },
      41: { n: "LABELFMT" },
      42: { n: "TITLES" },
      43: { n: "SHEETJS" },
      45: { n: "GRAPH" },
      46: { n: "NGRAPH" },
      47: { n: "CALCCOUNT" },
      48: { n: "UNFORMATTED" },
      49: { n: "CURSORW12" },
      50: { n: "WINDOW" },
      51: { n: "STRING", f: parse_LABEL },
      55: { n: "PASSWORD" },
      56: { n: "LOCKED" },
      60: { n: "QUERY" },
      61: { n: "QUERYNAME" },
      62: { n: "PRINT" },
      63: { n: "PRINTNAME" },
      64: { n: "GRAPH2" },
      65: { n: "GRAPHNAME" },
      66: { n: "ZOOM" },
      67: { n: "SYMSPLIT" },
      68: { n: "NSROWS" },
      69: { n: "NSCOLS" },
      70: { n: "RULER" },
      71: { n: "NNAME" },
      72: { n: "ACOMM" },
      73: { n: "AMACRO" },
      74: { n: "PARSE" },
      102: { n: "PRANGES??" },
      103: { n: "RRANGES??" },
      104: { n: "FNAME??" },
      105: { n: "MRANGES??" },
      204: { n: "SHEETNAMECS", f: parse_SHEETNAMECS },
      222: { n: "SHEETNAMELP", f: parse_SHEETNAMELP },
      65535: { n: "" }
    };
    var WK3Enum = {
      0: { n: "BOF" },
      1: { n: "EOF" },
      2: { n: "PASSWORD" },
      3: { n: "CALCSET" },
      4: { n: "WINDOWSET" },
      5: { n: "SHEETCELLPTR" },
      6: { n: "SHEETLAYOUT" },
      7: { n: "COLUMNWIDTH" },
      8: { n: "HIDDENCOLUMN" },
      9: { n: "USERRANGE" },
      10: { n: "SYSTEMRANGE" },
      11: { n: "ZEROFORCE" },
      12: { n: "SORTKEYDIR" },
      13: { n: "FILESEAL" },
      14: { n: "DATAFILLNUMS" },
      15: { n: "PRINTMAIN" },
      16: { n: "PRINTSTRING" },
      17: { n: "GRAPHMAIN" },
      18: { n: "GRAPHSTRING" },
      19: { n: "??" },
      20: { n: "ERRCELL" },
      21: { n: "NACELL" },
      22: { n: "LABEL16", f: parse_LABEL_16 },
      23: { n: "NUMBER17", f: parse_NUMBER_17 },
      24: { n: "NUMBER18", f: parse_NUMBER_18 },
      25: { n: "FORMULA19", f: parse_FORMULA_19 },
      26: { n: "FORMULA1A" },
      27: { n: "XFORMAT", f: parse_XFORMAT },
      28: { n: "DTLABELMISC" },
      29: { n: "DTLABELCELL" },
      30: { n: "GRAPHWINDOW" },
      31: { n: "CPA" },
      32: { n: "LPLAUTO" },
      33: { n: "QUERY" },
      34: { n: "HIDDENSHEET" },
      35: { n: "??" },
      37: { n: "NUMBER25", f: parse_NUMBER_25 },
      38: { n: "??" },
      39: { n: "NUMBER27", f: parse_NUMBER_27 },
      40: { n: "FORMULA28", f: parse_FORMULA_28 },
      142: { n: "??" },
      147: { n: "??" },
      150: { n: "??" },
      151: { n: "??" },
      152: { n: "??" },
      153: { n: "??" },
      154: { n: "??" },
      155: { n: "??" },
      156: { n: "??" },
      163: { n: "??" },
      174: { n: "??" },
      175: { n: "??" },
      176: { n: "??" },
      177: { n: "??" },
      184: { n: "??" },
      185: { n: "??" },
      186: { n: "??" },
      187: { n: "??" },
      188: { n: "??" },
      195: { n: "??" },
      201: { n: "??" },
      204: { n: "SHEETNAMECS", f: parse_SHEETNAMECS },
      205: { n: "??" },
      206: { n: "??" },
      207: { n: "??" },
      208: { n: "??" },
      256: { n: "??" },
      259: { n: "??" },
      260: { n: "??" },
      261: { n: "??" },
      262: { n: "??" },
      263: { n: "??" },
      265: { n: "??" },
      266: { n: "??" },
      267: { n: "??" },
      268: { n: "??" },
      270: { n: "??" },
      271: { n: "??" },
      384: { n: "??" },
      389: { n: "??" },
      390: { n: "??" },
      393: { n: "??" },
      396: { n: "??" },
      512: { n: "??" },
      514: { n: "??" },
      513: { n: "??" },
      516: { n: "??" },
      517: { n: "??" },
      640: { n: "??" },
      641: { n: "??" },
      642: { n: "??" },
      643: { n: "??" },
      644: { n: "??" },
      645: { n: "??" },
      646: { n: "??" },
      647: { n: "??" },
      648: { n: "??" },
      658: { n: "??" },
      659: { n: "??" },
      660: { n: "??" },
      661: { n: "??" },
      662: { n: "??" },
      665: { n: "??" },
      666: { n: "??" },
      768: { n: "??" },
      772: { n: "??" },
      1537: { n: "SHEETINFOQP", f: parse_SHEETINFOQP },
      1600: { n: "??" },
      1602: { n: "??" },
      1793: { n: "??" },
      1794: { n: "??" },
      1795: { n: "??" },
      1796: { n: "??" },
      1920: { n: "??" },
      2048: { n: "??" },
      2049: { n: "??" },
      2052: { n: "??" },
      2688: { n: "??" },
      10998: { n: "??" },
      12849: { n: "??" },
      28233: { n: "??" },
      28484: { n: "??" },
      65535: { n: "" }
    };
    return {
      sheet_to_wk1,
      book_to_wk3,
      to_workbook: lotus_to_workbook
    };
  }();
  function parse_rpr(rpr) {
    var font = {}, m2 = rpr.match(tagregex), i = 0;
    var pass = false;
    if (m2)
      for (; i != m2.length; ++i) {
        var y = parsexmltag(m2[i]);
        switch (y[0].replace(/\w*:/g, "")) {
          case "<condense":
            break;
          case "<extend":
            break;
          case "<shadow":
            if (!y.val)
              break;
          case "<shadow>":
          case "<shadow/>":
            font.shadow = 1;
            break;
          case "</shadow>":
            break;
          case "<charset":
            if (y.val == "1")
              break;
            font.cp = CS2CP[parseInt(y.val, 10)];
            break;
          case "<outline":
            if (!y.val)
              break;
          case "<outline>":
          case "<outline/>":
            font.outline = 1;
            break;
          case "</outline>":
            break;
          case "<rFont":
            font.name = y.val;
            break;
          case "<sz":
            font.sz = y.val;
            break;
          case "<strike":
            if (!y.val)
              break;
          case "<strike>":
          case "<strike/>":
            font.strike = 1;
            break;
          case "</strike>":
            break;
          case "<u":
            if (!y.val)
              break;
            switch (y.val) {
              case "double":
                font.uval = "double";
                break;
              case "singleAccounting":
                font.uval = "single-accounting";
                break;
              case "doubleAccounting":
                font.uval = "double-accounting";
                break;
            }
          case "<u>":
          case "<u/>":
            font.u = 1;
            break;
          case "</u>":
            break;
          case "<b":
            if (y.val == "0")
              break;
          case "<b>":
          case "<b/>":
            font.b = 1;
            break;
          case "</b>":
            break;
          case "<i":
            if (y.val == "0")
              break;
          case "<i>":
          case "<i/>":
            font.i = 1;
            break;
          case "</i>":
            break;
          case "<color":
            if (y.rgb)
              font.color = y.rgb.slice(2, 8);
            break;
          case "<color>":
          case "<color/>":
          case "</color>":
            break;
          case "<family":
            font.family = y.val;
            break;
          case "<family>":
          case "<family/>":
          case "</family>":
            break;
          case "<vertAlign":
            font.valign = y.val;
            break;
          case "<vertAlign>":
          case "<vertAlign/>":
          case "</vertAlign>":
            break;
          case "<scheme":
            break;
          case "<scheme>":
          case "<scheme/>":
          case "</scheme>":
            break;
          case "<extLst":
          case "<extLst>":
          case "</extLst>":
            break;
          case "<ext":
            pass = true;
            break;
          case "</ext>":
            pass = false;
            break;
          default:
            if (y[0].charCodeAt(1) !== 47 && !pass)
              throw new Error("Unrecognized rich format " + y[0]);
        }
      }
    return font;
  }
  var parse_rs = /* @__PURE__ */ function() {
    var tregex = matchtag("t"), rpregex = matchtag("rPr");
    function parse_r(r) {
      var t = r.match(tregex);
      if (!t)
        return { t: "s", v: "" };
      var o2 = { t: "s", v: unescapexml(t[1]) };
      var rpr = r.match(rpregex);
      if (rpr)
        o2.s = parse_rpr(rpr[1]);
      return o2;
    }
    var rregex = /<(?:\w+:)?r>/g, rend = /<\/(?:\w+:)?r>/;
    return function parse_rs2(rs) {
      return rs.replace(rregex, "").split(rend).map(parse_r).filter(function(r) {
        return r.v;
      });
    };
  }();
  var rs_to_html = /* @__PURE__ */ function parse_rs_factory() {
    var nlregex = /(\r\n|\n)/g;
    function parse_rpr2(font, intro, outro) {
      var style2 = [];
      if (font.u)
        style2.push("text-decoration: underline;");
      if (font.uval)
        style2.push("text-underline-style:" + font.uval + ";");
      if (font.sz)
        style2.push("font-size:" + font.sz + "pt;");
      if (font.outline)
        style2.push("text-effect: outline;");
      if (font.shadow)
        style2.push("text-shadow: auto;");
      intro.push('<span style="' + style2.join("") + '">');
      if (font.b) {
        intro.push("<b>");
        outro.push("</b>");
      }
      if (font.i) {
        intro.push("<i>");
        outro.push("</i>");
      }
      if (font.strike) {
        intro.push("<s>");
        outro.push("</s>");
      }
      var align = font.valign || "";
      if (align == "superscript" || align == "super")
        align = "sup";
      else if (align == "subscript")
        align = "sub";
      if (align != "") {
        intro.push("<" + align + ">");
        outro.push("</" + align + ">");
      }
      outro.push("</span>");
      return font;
    }
    function r_to_html(r) {
      var terms = [[], r.v, []];
      if (!r.v)
        return "";
      if (r.s)
        parse_rpr2(r.s, terms[0], terms[2]);
      return terms[0].join("") + terms[1].replace(nlregex, "<br/>") + terms[2].join("");
    }
    return function parse_rs2(rs) {
      return rs.map(r_to_html).join("");
    };
  }();
  var sitregex = /<(?:\w+:)?t[^>]*>([^<]*)<\/(?:\w+:)?t>/g, sirregex = /<(?:\w+:)?r>/;
  var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
  function parse_si(x2, opts) {
    var html = opts ? opts.cellHTML : true;
    var z = {};
    if (!x2)
      return { t: "" };
    if (x2.match(/^\s*<(?:\w+:)?t[^>]*>/)) {
      z.t = unescapexml(utf8read(x2.slice(x2.indexOf(">") + 1).split(/<\/(?:\w+:)?t>/)[0] || ""));
      z.r = utf8read(x2);
      if (html)
        z.h = escapehtml(z.t);
    } else if (x2.match(sirregex)) {
      z.r = utf8read(x2);
      z.t = unescapexml(utf8read((x2.replace(sirphregex, "").match(sitregex) || []).join("").replace(tagregex, "")));
      if (html)
        z.h = rs_to_html(parse_rs(z.r));
    }
    return z;
  }
  var sstr0 = /<(?:\w+:)?sst([^>]*)>([\s\S]*)<\/(?:\w+:)?sst>/;
  var sstr1 = /<(?:\w+:)?(?:si|sstItem)>/g;
  var sstr2 = /<\/(?:\w+:)?(?:si|sstItem)>/;
  function parse_sst_xml(data, opts) {
    var s2 = [], ss = "";
    if (!data)
      return s2;
    var sst = data.match(sstr0);
    if (sst) {
      ss = sst[2].replace(sstr1, "").split(sstr2);
      for (var i = 0; i != ss.length; ++i) {
        var o2 = parse_si(ss[i].trim(), opts);
        if (o2 != null)
          s2[s2.length] = o2;
      }
      sst = parsexmltag(sst[1]);
      s2.Count = sst.count;
      s2.Unique = sst.uniqueCount;
    }
    return s2;
  }
  var straywsregex = /^\s|\s$|[\t\n\r]/;
  function write_sst_xml(sst, opts) {
    if (!opts.bookSST)
      return "";
    var o2 = [XML_HEADER];
    o2[o2.length] = writextag("sst", null, {
      xmlns: XMLNS_main[0],
      count: sst.Count,
      uniqueCount: sst.Unique
    });
    for (var i = 0; i != sst.length; ++i) {
      if (sst[i] == null)
        continue;
      var s2 = sst[i];
      var sitag = "<si>";
      if (s2.r)
        sitag += s2.r;
      else {
        sitag += "<t";
        if (!s2.t)
          s2.t = "";
        if (s2.t.match(straywsregex))
          sitag += ' xml:space="preserve"';
        sitag += ">" + escapexml(s2.t) + "</t>";
      }
      sitag += "</si>";
      o2[o2.length] = sitag;
    }
    if (o2.length > 2) {
      o2[o2.length] = "</sst>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function parse_BrtBeginSst(data) {
    return [data.read_shift(4), data.read_shift(4)];
  }
  function parse_sst_bin(data, opts) {
    var s2 = [];
    var pass = false;
    recordhopper(data, function hopper_sst(val, R2, RT) {
      switch (RT) {
        case 159:
          s2.Count = val[0];
          s2.Unique = val[1];
          break;
        case 19:
          s2.push(val);
          break;
        case 160:
          return true;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        default:
          if (R2.T)
            ;
          if (!pass || opts.WTF)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    });
    return s2;
  }
  function write_BrtBeginSst(sst, o2) {
    if (!o2)
      o2 = new_buf(8);
    o2.write_shift(4, sst.Count);
    o2.write_shift(4, sst.Unique);
    return o2;
  }
  var write_BrtSSTItem = write_RichStr;
  function write_sst_bin(sst) {
    var ba = buf_array();
    write_record(ba, 159, write_BrtBeginSst(sst));
    for (var i = 0; i < sst.length; ++i)
      write_record(ba, 19, write_BrtSSTItem(sst[i]));
    write_record(ba, 160);
    return ba.end();
  }
  function _JS2ANSI(str) {
    var o2 = [], oo = str.split("");
    for (var i = 0; i < oo.length; ++i)
      o2[i] = oo[i].charCodeAt(0);
    return o2;
  }
  function parse_CRYPTOVersion(blob, length) {
    var o2 = {};
    o2.Major = blob.read_shift(2);
    o2.Minor = blob.read_shift(2);
    if (length >= 4)
      blob.l += length - 4;
    return o2;
  }
  function parse_DataSpaceVersionInfo(blob) {
    var o2 = {};
    o2.id = blob.read_shift(0, "lpp4");
    o2.R = parse_CRYPTOVersion(blob, 4);
    o2.U = parse_CRYPTOVersion(blob, 4);
    o2.W = parse_CRYPTOVersion(blob, 4);
    return o2;
  }
  function parse_DataSpaceMapEntry(blob) {
    var len = blob.read_shift(4);
    var end = blob.l + len - 4;
    var o2 = {};
    var cnt = blob.read_shift(4);
    var comps = [];
    while (cnt-- > 0)
      comps.push({ t: blob.read_shift(4), v: blob.read_shift(0, "lpp4") });
    o2.name = blob.read_shift(0, "lpp4");
    o2.comps = comps;
    if (blob.l != end)
      throw new Error("Bad DataSpaceMapEntry: " + blob.l + " != " + end);
    return o2;
  }
  function parse_DataSpaceMap(blob) {
    var o2 = [];
    blob.l += 4;
    var cnt = blob.read_shift(4);
    while (cnt-- > 0)
      o2.push(parse_DataSpaceMapEntry(blob));
    return o2;
  }
  function parse_DataSpaceDefinition(blob) {
    var o2 = [];
    blob.l += 4;
    var cnt = blob.read_shift(4);
    while (cnt-- > 0)
      o2.push(blob.read_shift(0, "lpp4"));
    return o2;
  }
  function parse_TransformInfoHeader(blob) {
    var o2 = {};
    blob.read_shift(4);
    blob.l += 4;
    o2.id = blob.read_shift(0, "lpp4");
    o2.name = blob.read_shift(0, "lpp4");
    o2.R = parse_CRYPTOVersion(blob, 4);
    o2.U = parse_CRYPTOVersion(blob, 4);
    o2.W = parse_CRYPTOVersion(blob, 4);
    return o2;
  }
  function parse_Primary(blob) {
    var hdr = parse_TransformInfoHeader(blob);
    hdr.ename = blob.read_shift(0, "8lpp4");
    hdr.blksz = blob.read_shift(4);
    hdr.cmode = blob.read_shift(4);
    if (blob.read_shift(4) != 4)
      throw new Error("Bad !Primary record");
    return hdr;
  }
  function parse_EncryptionHeader(blob, length) {
    var tgt = blob.l + length;
    var o2 = {};
    o2.Flags = blob.read_shift(4) & 63;
    blob.l += 4;
    o2.AlgID = blob.read_shift(4);
    var valid = false;
    switch (o2.AlgID) {
      case 26126:
      case 26127:
      case 26128:
        valid = o2.Flags == 36;
        break;
      case 26625:
        valid = o2.Flags == 4;
        break;
      case 0:
        valid = o2.Flags == 16 || o2.Flags == 4 || o2.Flags == 36;
        break;
      default:
        throw "Unrecognized encryption algorithm: " + o2.AlgID;
    }
    if (!valid)
      throw new Error("Encryption Flags/AlgID mismatch");
    o2.AlgIDHash = blob.read_shift(4);
    o2.KeySize = blob.read_shift(4);
    o2.ProviderType = blob.read_shift(4);
    blob.l += 8;
    o2.CSPName = blob.read_shift(tgt - blob.l >> 1, "utf16le");
    blob.l = tgt;
    return o2;
  }
  function parse_EncryptionVerifier(blob, length) {
    var o2 = {}, tgt = blob.l + length;
    blob.l += 4;
    o2.Salt = blob.slice(blob.l, blob.l + 16);
    blob.l += 16;
    o2.Verifier = blob.slice(blob.l, blob.l + 16);
    blob.l += 16;
    blob.read_shift(4);
    o2.VerifierHash = blob.slice(blob.l, tgt);
    blob.l = tgt;
    return o2;
  }
  function parse_EncryptionInfo(blob) {
    var vers = parse_CRYPTOVersion(blob);
    switch (vers.Minor) {
      case 2:
        return [vers.Minor, parse_EncInfoStd(blob)];
      case 3:
        return [vers.Minor, parse_EncInfoExt()];
      case 4:
        return [vers.Minor, parse_EncInfoAgl(blob)];
    }
    throw new Error("ECMA-376 Encrypted file unrecognized Version: " + vers.Minor);
  }
  function parse_EncInfoStd(blob) {
    var flags = blob.read_shift(4);
    if ((flags & 63) != 36)
      throw new Error("EncryptionInfo mismatch");
    var sz = blob.read_shift(4);
    var hdr = parse_EncryptionHeader(blob, sz);
    var verifier = parse_EncryptionVerifier(blob, blob.length - blob.l);
    return { t: "Std", h: hdr, v: verifier };
  }
  function parse_EncInfoExt() {
    throw new Error("File is password-protected: ECMA-376 Extensible");
  }
  function parse_EncInfoAgl(blob) {
    var KeyData = ["saltSize", "blockSize", "keyBits", "hashSize", "cipherAlgorithm", "cipherChaining", "hashAlgorithm", "saltValue"];
    blob.l += 4;
    var xml = blob.read_shift(blob.length - blob.l, "utf8");
    var o2 = {};
    xml.replace(tagregex, function xml_agile(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<?xml":
          break;
        case "<encryption":
        case "</encryption>":
          break;
        case "<keyData":
          KeyData.forEach(function(k) {
            o2[k] = y[k];
          });
          break;
        case "<dataIntegrity":
          o2.encryptedHmacKey = y.encryptedHmacKey;
          o2.encryptedHmacValue = y.encryptedHmacValue;
          break;
        case "<keyEncryptors>":
        case "<keyEncryptors":
          o2.encs = [];
          break;
        case "</keyEncryptors>":
          break;
        case "<keyEncryptor":
          o2.uri = y.uri;
          break;
        case "</keyEncryptor>":
          break;
        case "<encryptedKey":
          o2.encs.push(y);
          break;
        default:
          throw y[0];
      }
    });
    return o2;
  }
  function parse_RC4CryptoHeader(blob, length) {
    var o2 = {};
    var vers = o2.EncryptionVersionInfo = parse_CRYPTOVersion(blob, 4);
    length -= 4;
    if (vers.Minor != 2)
      throw new Error("unrecognized minor version code: " + vers.Minor);
    if (vers.Major > 4 || vers.Major < 2)
      throw new Error("unrecognized major version code: " + vers.Major);
    o2.Flags = blob.read_shift(4);
    length -= 4;
    var sz = blob.read_shift(4);
    length -= 4;
    o2.EncryptionHeader = parse_EncryptionHeader(blob, sz);
    length -= sz;
    o2.EncryptionVerifier = parse_EncryptionVerifier(blob, length);
    return o2;
  }
  function parse_RC4Header(blob) {
    var o2 = {};
    var vers = o2.EncryptionVersionInfo = parse_CRYPTOVersion(blob, 4);
    if (vers.Major != 1 || vers.Minor != 1)
      throw "unrecognized version code " + vers.Major + " : " + vers.Minor;
    o2.Salt = blob.read_shift(16);
    o2.EncryptedVerifier = blob.read_shift(16);
    o2.EncryptedVerifierHash = blob.read_shift(16);
    return o2;
  }
  function crypto_CreatePasswordVerifier_Method1(Password) {
    var Verifier = 0, PasswordArray;
    var PasswordDecoded = _JS2ANSI(Password);
    var len = PasswordDecoded.length + 1, i, PasswordByte;
    var Intermediate1, Intermediate2, Intermediate3;
    PasswordArray = new_raw_buf(len);
    PasswordArray[0] = PasswordDecoded.length;
    for (i = 1; i != len; ++i)
      PasswordArray[i] = PasswordDecoded[i - 1];
    for (i = len - 1; i >= 0; --i) {
      PasswordByte = PasswordArray[i];
      Intermediate1 = (Verifier & 16384) === 0 ? 0 : 1;
      Intermediate2 = Verifier << 1 & 32767;
      Intermediate3 = Intermediate1 | Intermediate2;
      Verifier = Intermediate3 ^ PasswordByte;
    }
    return Verifier ^ 52811;
  }
  var crypto_CreateXorArray_Method1 = /* @__PURE__ */ function() {
    var PadArray = [187, 255, 255, 186, 255, 255, 185, 128, 0, 190, 15, 0, 191, 15, 0];
    var InitialCode = [57840, 7439, 52380, 33984, 4364, 3600, 61902, 12606, 6258, 57657, 54287, 34041, 10252, 43370, 20163];
    var XorMatrix = [44796, 19929, 39858, 10053, 20106, 40212, 10761, 31585, 63170, 64933, 60267, 50935, 40399, 11199, 17763, 35526, 1453, 2906, 5812, 11624, 23248, 885, 1770, 3540, 7080, 14160, 28320, 56640, 55369, 41139, 20807, 41614, 21821, 43642, 17621, 28485, 56970, 44341, 19019, 38038, 14605, 29210, 60195, 50791, 40175, 10751, 21502, 43004, 24537, 18387, 36774, 3949, 7898, 15796, 31592, 63184, 47201, 24803, 49606, 37805, 14203, 28406, 56812, 17824, 35648, 1697, 3394, 6788, 13576, 27152, 43601, 17539, 35078, 557, 1114, 2228, 4456, 30388, 60776, 51953, 34243, 7079, 14158, 28316, 14128, 28256, 56512, 43425, 17251, 34502, 7597, 13105, 26210, 52420, 35241, 883, 1766, 3532, 4129, 8258, 16516, 33032, 4657, 9314, 18628];
    var Ror = function(Byte) {
      return (Byte / 2 | Byte * 128) & 255;
    };
    var XorRor = function(byte1, byte2) {
      return Ror(byte1 ^ byte2);
    };
    var CreateXorKey_Method1 = function(Password) {
      var XorKey = InitialCode[Password.length - 1];
      var CurrentElement = 104;
      for (var i = Password.length - 1; i >= 0; --i) {
        var Char = Password[i];
        for (var j = 0; j != 7; ++j) {
          if (Char & 64)
            XorKey ^= XorMatrix[CurrentElement];
          Char *= 2;
          --CurrentElement;
        }
      }
      return XorKey;
    };
    return function(password) {
      var Password = _JS2ANSI(password);
      var XorKey = CreateXorKey_Method1(Password);
      var Index = Password.length;
      var ObfuscationArray = new_raw_buf(16);
      for (var i = 0; i != 16; ++i)
        ObfuscationArray[i] = 0;
      var Temp, PasswordLastChar, PadIndex;
      if ((Index & 1) === 1) {
        Temp = XorKey >> 8;
        ObfuscationArray[Index] = XorRor(PadArray[0], Temp);
        --Index;
        Temp = XorKey & 255;
        PasswordLastChar = Password[Password.length - 1];
        ObfuscationArray[Index] = XorRor(PasswordLastChar, Temp);
      }
      while (Index > 0) {
        --Index;
        Temp = XorKey >> 8;
        ObfuscationArray[Index] = XorRor(Password[Index], Temp);
        --Index;
        Temp = XorKey & 255;
        ObfuscationArray[Index] = XorRor(Password[Index], Temp);
      }
      Index = 15;
      PadIndex = 15 - Password.length;
      while (PadIndex > 0) {
        Temp = XorKey >> 8;
        ObfuscationArray[Index] = XorRor(PadArray[PadIndex], Temp);
        --Index;
        --PadIndex;
        Temp = XorKey & 255;
        ObfuscationArray[Index] = XorRor(Password[Index], Temp);
        --Index;
        --PadIndex;
      }
      return ObfuscationArray;
    };
  }();
  var crypto_DecryptData_Method1 = function(password, Data, XorArrayIndex, XorArray, O2) {
    if (!O2)
      O2 = Data;
    if (!XorArray)
      XorArray = crypto_CreateXorArray_Method1(password);
    var Index, Value;
    for (Index = 0; Index != Data.length; ++Index) {
      Value = Data[Index];
      Value ^= XorArray[XorArrayIndex];
      Value = (Value >> 5 | Value << 3) & 255;
      O2[Index] = Value;
      ++XorArrayIndex;
    }
    return [O2, XorArrayIndex, XorArray];
  };
  var crypto_MakeXorDecryptor = function(password) {
    var XorArrayIndex = 0, XorArray = crypto_CreateXorArray_Method1(password);
    return function(Data) {
      var O2 = crypto_DecryptData_Method1("", Data, XorArrayIndex, XorArray);
      XorArrayIndex = O2[1];
      return O2[0];
    };
  };
  function parse_XORObfuscation(blob, length, opts, out) {
    var o2 = { key: parseuint16(blob), verificationBytes: parseuint16(blob) };
    if (opts.password)
      o2.verifier = crypto_CreatePasswordVerifier_Method1(opts.password);
    out.valid = o2.verificationBytes === o2.verifier;
    if (out.valid)
      out.insitu = crypto_MakeXorDecryptor(opts.password);
    return o2;
  }
  function parse_FilePassHeader(blob, length, oo) {
    var o2 = oo || {};
    o2.Info = blob.read_shift(2);
    blob.l -= 2;
    if (o2.Info === 1)
      o2.Data = parse_RC4Header(blob);
    else
      o2.Data = parse_RC4CryptoHeader(blob, length);
    return o2;
  }
  function parse_FilePass(blob, length, opts) {
    var o2 = { Type: opts.biff >= 8 ? blob.read_shift(2) : 0 };
    if (o2.Type)
      parse_FilePassHeader(blob, length - 2, o2);
    else
      parse_XORObfuscation(blob, opts.biff >= 8 ? length : length - 2, opts, o2);
    return o2;
  }
  var RTF = /* @__PURE__ */ function() {
    function rtf_to_sheet(d2, opts) {
      switch (opts.type) {
        case "base64":
          return rtf_to_sheet_str(Base64_decode(d2), opts);
        case "binary":
          return rtf_to_sheet_str(d2, opts);
        case "buffer":
          return rtf_to_sheet_str(has_buf && Buffer.isBuffer(d2) ? d2.toString("binary") : a2s(d2), opts);
        case "array":
          return rtf_to_sheet_str(cc2str(d2), opts);
      }
      throw new Error("Unrecognized type " + opts.type);
    }
    function rtf_to_sheet_str(str, opts) {
      var o2 = opts || {};
      var ws = o2.dense ? [] : {};
      var rows = str.match(/\\trowd.*?\\row\b/g);
      if (!rows.length)
        throw new Error("RTF missing table");
      var range = { s: { c: 0, r: 0 }, e: { c: 0, r: rows.length - 1 } };
      rows.forEach(function(rowtf, R2) {
        if (Array.isArray(ws))
          ws[R2] = [];
        var rtfre = /\\\w+\b/g;
        var last_index = 0;
        var res;
        var C2 = -1;
        while (res = rtfre.exec(rowtf)) {
          switch (res[0]) {
            case "\\cell":
              var data = rowtf.slice(last_index, rtfre.lastIndex - res[0].length);
              if (data[0] == " ")
                data = data.slice(1);
              ++C2;
              if (data.length) {
                var cell = { v: data, t: "s" };
                if (Array.isArray(ws))
                  ws[R2][C2] = cell;
                else
                  ws[encode_cell({ r: R2, c: C2 })] = cell;
              }
              break;
          }
          last_index = rtfre.lastIndex;
        }
        if (C2 > range.e.c)
          range.e.c = C2;
      });
      ws["!ref"] = encode_range(range);
      return ws;
    }
    function rtf_to_workbook(d2, opts) {
      return sheet_to_workbook(rtf_to_sheet(d2, opts), opts);
    }
    function sheet_to_rtf(ws) {
      var o2 = ["{\\rtf1\\ansi"];
      var r = safe_decode_range(ws["!ref"]), cell;
      var dense = Array.isArray(ws);
      for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
        o2.push("\\trowd\\trautofit1");
        for (var C2 = r.s.c; C2 <= r.e.c; ++C2)
          o2.push("\\cellx" + (C2 + 1));
        o2.push("\\pard\\intbl");
        for (C2 = r.s.c; C2 <= r.e.c; ++C2) {
          var coord = encode_cell({ r: R2, c: C2 });
          cell = dense ? (ws[R2] || [])[C2] : ws[coord];
          if (!cell || cell.v == null && (!cell.f || cell.F))
            continue;
          o2.push(" " + (cell.w || (format_cell(cell), cell.w)));
          o2.push("\\cell");
        }
        o2.push("\\pard\\intbl\\row");
      }
      return o2.join("") + "}";
    }
    return {
      to_workbook: rtf_to_workbook,
      to_sheet: rtf_to_sheet,
      from_sheet: sheet_to_rtf
    };
  }();
  function hex2RGB(h2) {
    var o2 = h2.slice(h2[0] === "#" ? 1 : 0).slice(0, 6);
    return [parseInt(o2.slice(0, 2), 16), parseInt(o2.slice(2, 4), 16), parseInt(o2.slice(4, 6), 16)];
  }
  function rgb2Hex(rgb) {
    for (var i = 0, o2 = 1; i != 3; ++i)
      o2 = o2 * 256 + (rgb[i] > 255 ? 255 : rgb[i] < 0 ? 0 : rgb[i]);
    return o2.toString(16).toUpperCase().slice(1);
  }
  function rgb2HSL(rgb) {
    var R2 = rgb[0] / 255, G2 = rgb[1] / 255, B2 = rgb[2] / 255;
    var M2 = Math.max(R2, G2, B2), m2 = Math.min(R2, G2, B2), C2 = M2 - m2;
    if (C2 === 0)
      return [0, 0, R2];
    var H6 = 0, S2 = 0, L2 = M2 + m2;
    S2 = C2 / (L2 > 1 ? 2 - L2 : L2);
    switch (M2) {
      case R2:
        H6 = ((G2 - B2) / C2 + 6) % 6;
        break;
      case G2:
        H6 = (B2 - R2) / C2 + 2;
        break;
      case B2:
        H6 = (R2 - G2) / C2 + 4;
        break;
    }
    return [H6 / 6, S2, L2 / 2];
  }
  function hsl2RGB(hsl) {
    var H2 = hsl[0], S2 = hsl[1], L = hsl[2];
    var C2 = S2 * 2 * (L < 0.5 ? L : 1 - L), m2 = L - C2 / 2;
    var rgb = [m2, m2, m2], h6 = 6 * H2;
    var X2;
    if (S2 !== 0)
      switch (h6 | 0) {
        case 0:
        case 6:
          X2 = C2 * h6;
          rgb[0] += C2;
          rgb[1] += X2;
          break;
        case 1:
          X2 = C2 * (2 - h6);
          rgb[0] += X2;
          rgb[1] += C2;
          break;
        case 2:
          X2 = C2 * (h6 - 2);
          rgb[1] += C2;
          rgb[2] += X2;
          break;
        case 3:
          X2 = C2 * (4 - h6);
          rgb[1] += X2;
          rgb[2] += C2;
          break;
        case 4:
          X2 = C2 * (h6 - 4);
          rgb[2] += C2;
          rgb[0] += X2;
          break;
        case 5:
          X2 = C2 * (6 - h6);
          rgb[2] += X2;
          rgb[0] += C2;
          break;
      }
    for (var i = 0; i != 3; ++i)
      rgb[i] = Math.round(rgb[i] * 255);
    return rgb;
  }
  function rgb_tint(hex, tint) {
    if (tint === 0)
      return hex;
    var hsl = rgb2HSL(hex2RGB(hex));
    if (tint < 0)
      hsl[2] = hsl[2] * (1 + tint);
    else
      hsl[2] = 1 - (1 - hsl[2]) * (1 - tint);
    return rgb2Hex(hsl2RGB(hsl));
  }
  var DEF_MDW = 6, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
  function width2px(width) {
    return Math.floor((width + Math.round(128 / MDW) / 256) * MDW);
  }
  function px2char(px) {
    return Math.floor((px - 5) / MDW * 100 + 0.5) / 100;
  }
  function char2width(chr) {
    return Math.round((chr * MDW + 5) / MDW * 256) / 256;
  }
  function cycle_width(collw) {
    return char2width(px2char(width2px(collw)));
  }
  function find_mdw_colw(collw) {
    var delta = Math.abs(collw - cycle_width(collw)), _MDW = MDW;
    if (delta > 5e-3) {
      for (MDW = MIN_MDW; MDW < MAX_MDW; ++MDW)
        if (Math.abs(collw - cycle_width(collw)) <= delta) {
          delta = Math.abs(collw - cycle_width(collw));
          _MDW = MDW;
        }
    }
    MDW = _MDW;
  }
  function process_col(coll) {
    if (coll.width) {
      coll.wpx = width2px(coll.width);
      coll.wch = px2char(coll.wpx);
      coll.MDW = MDW;
    } else if (coll.wpx) {
      coll.wch = px2char(coll.wpx);
      coll.width = char2width(coll.wch);
      coll.MDW = MDW;
    } else if (typeof coll.wch == "number") {
      coll.width = char2width(coll.wch);
      coll.wpx = width2px(coll.width);
      coll.MDW = MDW;
    }
    if (coll.customWidth)
      delete coll.customWidth;
  }
  var DEF_PPI = 96, PPI = DEF_PPI;
  function px2pt(px) {
    return px * 96 / PPI;
  }
  function pt2px(pt2) {
    return pt2 * PPI / 96;
  }
  var XLMLPatternTypeMap = {
    "None": "none",
    "Solid": "solid",
    "Gray50": "mediumGray",
    "Gray75": "darkGray",
    "Gray25": "lightGray",
    "HorzStripe": "darkHorizontal",
    "VertStripe": "darkVertical",
    "ReverseDiagStripe": "darkDown",
    "DiagStripe": "darkUp",
    "DiagCross": "darkGrid",
    "ThickDiagCross": "darkTrellis",
    "ThinHorzStripe": "lightHorizontal",
    "ThinVertStripe": "lightVertical",
    "ThinReverseDiagStripe": "lightDown",
    "ThinHorzCross": "lightGrid"
  };
  function parse_borders(t, styles, themes, opts) {
    styles.Borders = [];
    var border = {};
    var pass = false;
    (t[0].match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<borders":
        case "<borders>":
        case "</borders>":
          break;
        case "<border":
        case "<border>":
        case "<border/>":
          border = {};
          if (y.diagonalUp)
            border.diagonalUp = parsexmlbool(y.diagonalUp);
          if (y.diagonalDown)
            border.diagonalDown = parsexmlbool(y.diagonalDown);
          styles.Borders.push(border);
          break;
        case "</border>":
          break;
        case "<left/>":
          break;
        case "<left":
        case "<left>":
          break;
        case "</left>":
          break;
        case "<right/>":
          break;
        case "<right":
        case "<right>":
          break;
        case "</right>":
          break;
        case "<top/>":
          break;
        case "<top":
        case "<top>":
          break;
        case "</top>":
          break;
        case "<bottom/>":
          break;
        case "<bottom":
        case "<bottom>":
          break;
        case "</bottom>":
          break;
        case "<diagonal":
        case "<diagonal>":
        case "<diagonal/>":
          break;
        case "</diagonal>":
          break;
        case "<horizontal":
        case "<horizontal>":
        case "<horizontal/>":
          break;
        case "</horizontal>":
          break;
        case "<vertical":
        case "<vertical>":
        case "<vertical/>":
          break;
        case "</vertical>":
          break;
        case "<start":
        case "<start>":
        case "<start/>":
          break;
        case "</start>":
          break;
        case "<end":
        case "<end>":
        case "<end/>":
          break;
        case "</end>":
          break;
        case "<color":
        case "<color>":
          break;
        case "<color/>":
        case "</color>":
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (opts && opts.WTF) {
            if (!pass)
              throw new Error("unrecognized " + y[0] + " in borders");
          }
      }
    });
  }
  function parse_fills(t, styles, themes, opts) {
    styles.Fills = [];
    var fill2 = {};
    var pass = false;
    (t[0].match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<fills":
        case "<fills>":
        case "</fills>":
          break;
        case "<fill>":
        case "<fill":
        case "<fill/>":
          fill2 = {};
          styles.Fills.push(fill2);
          break;
        case "</fill>":
          break;
        case "<gradientFill>":
          break;
        case "<gradientFill":
        case "</gradientFill>":
          styles.Fills.push(fill2);
          fill2 = {};
          break;
        case "<patternFill":
        case "<patternFill>":
          if (y.patternType)
            fill2.patternType = y.patternType;
          break;
        case "<patternFill/>":
        case "</patternFill>":
          break;
        case "<bgColor":
          if (!fill2.bgColor)
            fill2.bgColor = {};
          if (y.indexed)
            fill2.bgColor.indexed = parseInt(y.indexed, 10);
          if (y.theme)
            fill2.bgColor.theme = parseInt(y.theme, 10);
          if (y.tint)
            fill2.bgColor.tint = parseFloat(y.tint);
          if (y.rgb)
            fill2.bgColor.rgb = y.rgb.slice(-6);
          break;
        case "<bgColor/>":
        case "</bgColor>":
          break;
        case "<fgColor":
          if (!fill2.fgColor)
            fill2.fgColor = {};
          if (y.theme)
            fill2.fgColor.theme = parseInt(y.theme, 10);
          if (y.tint)
            fill2.fgColor.tint = parseFloat(y.tint);
          if (y.rgb != null)
            fill2.fgColor.rgb = y.rgb.slice(-6);
          break;
        case "<fgColor/>":
        case "</fgColor>":
          break;
        case "<stop":
        case "<stop/>":
          break;
        case "</stop>":
          break;
        case "<color":
        case "<color/>":
          break;
        case "</color>":
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (opts && opts.WTF) {
            if (!pass)
              throw new Error("unrecognized " + y[0] + " in fills");
          }
      }
    });
  }
  function parse_fonts(t, styles, themes, opts) {
    styles.Fonts = [];
    var font = {};
    var pass = false;
    (t[0].match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<fonts":
        case "<fonts>":
        case "</fonts>":
          break;
        case "<font":
        case "<font>":
          break;
        case "</font>":
        case "<font/>":
          styles.Fonts.push(font);
          font = {};
          break;
        case "<name":
          if (y.val)
            font.name = utf8read(y.val);
          break;
        case "<name/>":
        case "</name>":
          break;
        case "<b":
          font.bold = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<b/>":
          font.bold = 1;
          break;
        case "<i":
          font.italic = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<i/>":
          font.italic = 1;
          break;
        case "<u":
          switch (y.val) {
            case "none":
              font.underline = 0;
              break;
            case "single":
              font.underline = 1;
              break;
            case "double":
              font.underline = 2;
              break;
            case "singleAccounting":
              font.underline = 33;
              break;
            case "doubleAccounting":
              font.underline = 34;
              break;
          }
          break;
        case "<u/>":
          font.underline = 1;
          break;
        case "<strike":
          font.strike = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<strike/>":
          font.strike = 1;
          break;
        case "<outline":
          font.outline = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<outline/>":
          font.outline = 1;
          break;
        case "<shadow":
          font.shadow = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<shadow/>":
          font.shadow = 1;
          break;
        case "<condense":
          font.condense = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<condense/>":
          font.condense = 1;
          break;
        case "<extend":
          font.extend = y.val ? parsexmlbool(y.val) : 1;
          break;
        case "<extend/>":
          font.extend = 1;
          break;
        case "<sz":
          if (y.val)
            font.sz = +y.val;
          break;
        case "<sz/>":
        case "</sz>":
          break;
        case "<vertAlign":
          if (y.val)
            font.vertAlign = y.val;
          break;
        case "<vertAlign/>":
        case "</vertAlign>":
          break;
        case "<family":
          if (y.val)
            font.family = parseInt(y.val, 10);
          break;
        case "<family/>":
        case "</family>":
          break;
        case "<scheme":
          if (y.val)
            font.scheme = y.val;
          break;
        case "<scheme/>":
        case "</scheme>":
          break;
        case "<charset":
          if (y.val == "1")
            break;
          y.codepage = CS2CP[parseInt(y.val, 10)];
          break;
        case "<color":
          if (!font.color)
            font.color = {};
          if (y.auto)
            font.color.auto = parsexmlbool(y.auto);
          if (y.rgb)
            font.color.rgb = y.rgb.slice(-6);
          else if (y.indexed) {
            font.color.index = parseInt(y.indexed, 10);
            var icv = XLSIcv[font.color.index];
            if (font.color.index == 81)
              icv = XLSIcv[1];
            if (!icv)
              icv = XLSIcv[1];
            font.color.rgb = icv[0].toString(16) + icv[1].toString(16) + icv[2].toString(16);
          } else if (y.theme) {
            font.color.theme = parseInt(y.theme, 10);
            if (y.tint)
              font.color.tint = parseFloat(y.tint);
            if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
              font.color.rgb = rgb_tint(themes.themeElements.clrScheme[font.color.theme].rgb, font.color.tint || 0);
            }
          }
          break;
        case "<color/>":
        case "</color>":
          break;
        case "<AlternateContent":
          pass = true;
          break;
        case "</AlternateContent>":
          pass = false;
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (opts && opts.WTF) {
            if (!pass)
              throw new Error("unrecognized " + y[0] + " in fonts");
          }
      }
    });
  }
  function parse_numFmts(t, styles, opts) {
    styles.NumberFmt = [];
    var k = keys$1(table_fmt);
    for (var i = 0; i < k.length; ++i)
      styles.NumberFmt[k[i]] = table_fmt[k[i]];
    var m2 = t[0].match(tagregex);
    if (!m2)
      return;
    for (i = 0; i < m2.length; ++i) {
      var y = parsexmltag(m2[i]);
      switch (strip_ns(y[0])) {
        case "<numFmts":
        case "</numFmts>":
        case "<numFmts/>":
        case "<numFmts>":
          break;
        case "<numFmt":
          {
            var f2 = unescapexml(utf8read(y.formatCode)), j = parseInt(y.numFmtId, 10);
            styles.NumberFmt[j] = f2;
            if (j > 0) {
              if (j > 392) {
                for (j = 392; j > 60; --j)
                  if (styles.NumberFmt[j] == null)
                    break;
                styles.NumberFmt[j] = f2;
              }
              SSF_load(f2, j);
            }
          }
          break;
        case "</numFmt>":
          break;
        default:
          if (opts.WTF)
            throw new Error("unrecognized " + y[0] + " in numFmts");
      }
    }
  }
  function write_numFmts(NF) {
    var o2 = ["<numFmts>"];
    [[5, 8], [23, 26], [41, 44], [50, 392]].forEach(function(r) {
      for (var i = r[0]; i <= r[1]; ++i)
        if (NF[i] != null)
          o2[o2.length] = writextag("numFmt", null, { numFmtId: i, formatCode: escapexml(NF[i]) });
    });
    if (o2.length === 1)
      return "";
    o2[o2.length] = "</numFmts>";
    o2[0] = writextag("numFmts", null, { count: o2.length - 2 }).replace("/>", ">");
    return o2.join("");
  }
  var cellXF_uint = ["numFmtId", "fillId", "fontId", "borderId", "xfId"];
  var cellXF_bool = ["applyAlignment", "applyBorder", "applyFill", "applyFont", "applyNumberFormat", "applyProtection", "pivotButton", "quotePrefix"];
  function parse_cellXfs(t, styles, opts) {
    styles.CellXf = [];
    var xf;
    var pass = false;
    (t[0].match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2), i = 0;
      switch (strip_ns(y[0])) {
        case "<cellXfs":
        case "<cellXfs>":
        case "<cellXfs/>":
        case "</cellXfs>":
          break;
        case "<xf":
        case "<xf/>":
          xf = y;
          delete xf[0];
          for (i = 0; i < cellXF_uint.length; ++i)
            if (xf[cellXF_uint[i]])
              xf[cellXF_uint[i]] = parseInt(xf[cellXF_uint[i]], 10);
          for (i = 0; i < cellXF_bool.length; ++i)
            if (xf[cellXF_bool[i]])
              xf[cellXF_bool[i]] = parsexmlbool(xf[cellXF_bool[i]]);
          if (styles.NumberFmt && xf.numFmtId > 392) {
            for (i = 392; i > 60; --i)
              if (styles.NumberFmt[xf.numFmtId] == styles.NumberFmt[i]) {
                xf.numFmtId = i;
                break;
              }
          }
          styles.CellXf.push(xf);
          break;
        case "</xf>":
          break;
        case "<alignment":
        case "<alignment/>":
          var alignment = {};
          if (y.vertical)
            alignment.vertical = y.vertical;
          if (y.horizontal)
            alignment.horizontal = y.horizontal;
          if (y.textRotation != null)
            alignment.textRotation = y.textRotation;
          if (y.indent)
            alignment.indent = y.indent;
          if (y.wrapText)
            alignment.wrapText = parsexmlbool(y.wrapText);
          xf.alignment = alignment;
          break;
        case "</alignment>":
          break;
        case "<protection":
          break;
        case "</protection>":
        case "<protection/>":
          break;
        case "<AlternateContent":
          pass = true;
          break;
        case "</AlternateContent>":
          pass = false;
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (opts && opts.WTF) {
            if (!pass)
              throw new Error("unrecognized " + y[0] + " in cellXfs");
          }
      }
    });
  }
  function write_cellXfs(cellXfs) {
    var o2 = [];
    o2[o2.length] = writextag("cellXfs", null);
    cellXfs.forEach(function(c2) {
      o2[o2.length] = writextag("xf", null, c2);
    });
    o2[o2.length] = "</cellXfs>";
    if (o2.length === 2)
      return "";
    o2[0] = writextag("cellXfs", null, { count: o2.length - 2 }).replace("/>", ">");
    return o2.join("");
  }
  var parse_sty_xml = /* @__PURE__ */ function make_pstyx() {
    var numFmtRegex = /<(?:\w+:)?numFmts([^>]*)>[\S\s]*?<\/(?:\w+:)?numFmts>/;
    var cellXfRegex = /<(?:\w+:)?cellXfs([^>]*)>[\S\s]*?<\/(?:\w+:)?cellXfs>/;
    var fillsRegex = /<(?:\w+:)?fills([^>]*)>[\S\s]*?<\/(?:\w+:)?fills>/;
    var fontsRegex = /<(?:\w+:)?fonts([^>]*)>[\S\s]*?<\/(?:\w+:)?fonts>/;
    var bordersRegex = /<(?:\w+:)?borders([^>]*)>[\S\s]*?<\/(?:\w+:)?borders>/;
    return function parse_sty_xml2(data, themes, opts) {
      var styles = {};
      if (!data)
        return styles;
      data = data.replace(/<!--([\s\S]*?)-->/mg, "").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm, "");
      var t;
      if (t = data.match(numFmtRegex))
        parse_numFmts(t, styles, opts);
      if (t = data.match(fontsRegex))
        parse_fonts(t, styles, themes, opts);
      if (t = data.match(fillsRegex))
        parse_fills(t, styles, themes, opts);
      if (t = data.match(bordersRegex))
        parse_borders(t, styles, themes, opts);
      if (t = data.match(cellXfRegex))
        parse_cellXfs(t, styles, opts);
      return styles;
    };
  }();
  function write_sty_xml(wb, opts) {
    var o2 = [XML_HEADER, writextag("styleSheet", null, {
      "xmlns": XMLNS_main[0],
      "xmlns:vt": XMLNS.vt
    })], w2;
    if (wb.SSF && (w2 = write_numFmts(wb.SSF)) != null)
      o2[o2.length] = w2;
    o2[o2.length] = '<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>';
    o2[o2.length] = '<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>';
    o2[o2.length] = '<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>';
    o2[o2.length] = '<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>';
    if (w2 = write_cellXfs(opts.cellXfs))
      o2[o2.length] = w2;
    o2[o2.length] = '<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>';
    o2[o2.length] = '<dxfs count="0"/>';
    o2[o2.length] = '<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>';
    if (o2.length > 2) {
      o2[o2.length] = "</styleSheet>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function parse_BrtFmt(data, length) {
    var numFmtId = data.read_shift(2);
    var stFmtCode = parse_XLWideString(data);
    return [numFmtId, stFmtCode];
  }
  function write_BrtFmt(i, f2, o2) {
    if (!o2)
      o2 = new_buf(6 + 4 * f2.length);
    o2.write_shift(2, i);
    write_XLWideString(f2, o2);
    var out = o2.length > o2.l ? o2.slice(0, o2.l) : o2;
    if (o2.l == null)
      o2.l = o2.length;
    return out;
  }
  function parse_BrtFont(data, length, opts) {
    var out = {};
    out.sz = data.read_shift(2) / 20;
    var grbit = parse_FontFlags(data);
    if (grbit.fItalic)
      out.italic = 1;
    if (grbit.fCondense)
      out.condense = 1;
    if (grbit.fExtend)
      out.extend = 1;
    if (grbit.fShadow)
      out.shadow = 1;
    if (grbit.fOutline)
      out.outline = 1;
    if (grbit.fStrikeout)
      out.strike = 1;
    var bls = data.read_shift(2);
    if (bls === 700)
      out.bold = 1;
    switch (data.read_shift(2)) {
      case 1:
        out.vertAlign = "superscript";
        break;
      case 2:
        out.vertAlign = "subscript";
        break;
    }
    var underline = data.read_shift(1);
    if (underline != 0)
      out.underline = underline;
    var family = data.read_shift(1);
    if (family > 0)
      out.family = family;
    var bCharSet = data.read_shift(1);
    if (bCharSet > 0)
      out.charset = bCharSet;
    data.l++;
    out.color = parse_BrtColor(data);
    switch (data.read_shift(1)) {
      case 1:
        out.scheme = "major";
        break;
      case 2:
        out.scheme = "minor";
        break;
    }
    out.name = parse_XLWideString(data);
    return out;
  }
  function write_BrtFont(font, o2) {
    if (!o2)
      o2 = new_buf(25 + 4 * 32);
    o2.write_shift(2, font.sz * 20);
    write_FontFlags(font, o2);
    o2.write_shift(2, font.bold ? 700 : 400);
    var sss = 0;
    if (font.vertAlign == "superscript")
      sss = 1;
    else if (font.vertAlign == "subscript")
      sss = 2;
    o2.write_shift(2, sss);
    o2.write_shift(1, font.underline || 0);
    o2.write_shift(1, font.family || 0);
    o2.write_shift(1, font.charset || 0);
    o2.write_shift(1, 0);
    write_BrtColor(font.color, o2);
    var scheme = 0;
    if (font.scheme == "major")
      scheme = 1;
    if (font.scheme == "minor")
      scheme = 2;
    o2.write_shift(1, scheme);
    write_XLWideString(font.name, o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  var XLSBFillPTNames = [
    "none",
    "solid",
    "mediumGray",
    "darkGray",
    "lightGray",
    "darkHorizontal",
    "darkVertical",
    "darkDown",
    "darkUp",
    "darkGrid",
    "darkTrellis",
    "lightHorizontal",
    "lightVertical",
    "lightDown",
    "lightUp",
    "lightGrid",
    "lightTrellis",
    "gray125",
    "gray0625"
  ];
  var rev_XLSBFillPTNames;
  var parse_BrtFill = parsenoop;
  function write_BrtFill(fill2, o2) {
    if (!o2)
      o2 = new_buf(4 * 3 + 8 * 7 + 16 * 1);
    if (!rev_XLSBFillPTNames)
      rev_XLSBFillPTNames = evert(XLSBFillPTNames);
    var fls = rev_XLSBFillPTNames[fill2.patternType];
    if (fls == null)
      fls = 40;
    o2.write_shift(4, fls);
    var j = 0;
    if (fls != 40) {
      write_BrtColor({ auto: 1 }, o2);
      write_BrtColor({ auto: 1 }, o2);
      for (; j < 12; ++j)
        o2.write_shift(4, 0);
    } else {
      for (; j < 4; ++j)
        o2.write_shift(4, 0);
      for (; j < 12; ++j)
        o2.write_shift(4, 0);
    }
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function parse_BrtXF(data, length) {
    var tgt = data.l + length;
    var ixfeParent = data.read_shift(2);
    var ifmt = data.read_shift(2);
    data.l = tgt;
    return { ixfe: ixfeParent, numFmtId: ifmt };
  }
  function write_BrtXF(data, ixfeP, o2) {
    if (!o2)
      o2 = new_buf(16);
    o2.write_shift(2, ixfeP || 0);
    o2.write_shift(2, data.numFmtId || 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(1, 0);
    o2.write_shift(1, 0);
    var flow = 0;
    o2.write_shift(1, flow);
    o2.write_shift(1, 0);
    o2.write_shift(1, 0);
    o2.write_shift(1, 0);
    return o2;
  }
  function write_Blxf(data, o2) {
    if (!o2)
      o2 = new_buf(10);
    o2.write_shift(1, 0);
    o2.write_shift(1, 0);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    return o2;
  }
  var parse_BrtBorder = parsenoop;
  function write_BrtBorder(border, o2) {
    if (!o2)
      o2 = new_buf(51);
    o2.write_shift(1, 0);
    write_Blxf(null, o2);
    write_Blxf(null, o2);
    write_Blxf(null, o2);
    write_Blxf(null, o2);
    write_Blxf(null, o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function write_BrtStyle(style2, o2) {
    if (!o2)
      o2 = new_buf(12 + 4 * 10);
    o2.write_shift(4, style2.xfId);
    o2.write_shift(2, 1);
    o2.write_shift(1, +style2.builtinId);
    o2.write_shift(1, 0);
    write_XLNullableWideString(style2.name || "", o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function write_BrtBeginTableStyles(cnt, defTableStyle, defPivotStyle) {
    var o2 = new_buf(4 + 256 * 2 * 4);
    o2.write_shift(4, cnt);
    write_XLNullableWideString(defTableStyle, o2);
    write_XLNullableWideString(defPivotStyle, o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function parse_sty_bin(data, themes, opts) {
    var styles = {};
    styles.NumberFmt = [];
    for (var y in table_fmt)
      styles.NumberFmt[y] = table_fmt[y];
    styles.CellXf = [];
    styles.Fonts = [];
    var state = [];
    var pass = false;
    recordhopper(data, function hopper_sty(val, R2, RT) {
      switch (RT) {
        case 44:
          styles.NumberFmt[val[0]] = val[1];
          SSF_load(val[1], val[0]);
          break;
        case 43:
          styles.Fonts.push(val);
          if (val.color.theme != null && themes && themes.themeElements && themes.themeElements.clrScheme) {
            val.color.rgb = rgb_tint(themes.themeElements.clrScheme[val.color.theme].rgb, val.color.tint || 0);
          }
          break;
        case 1025:
          break;
        case 45:
          break;
        case 46:
          break;
        case 47:
          if (state[state.length - 1] == 617) {
            styles.CellXf.push(val);
          }
          break;
        case 48:
        case 507:
        case 572:
        case 475:
          break;
        case 1171:
        case 2102:
        case 1130:
        case 512:
        case 2095:
        case 3072:
          break;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        case 37:
          state.push(RT);
          pass = true;
          break;
        case 38:
          state.pop();
          pass = false;
          break;
        default:
          if (R2.T > 0)
            state.push(RT);
          else if (R2.T < 0)
            state.pop();
          else if (!pass || opts.WTF && state[state.length - 1] != 37)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    });
    return styles;
  }
  function write_FMTS_bin(ba, NF) {
    if (!NF)
      return;
    var cnt = 0;
    [[5, 8], [23, 26], [41, 44], [50, 392]].forEach(function(r) {
      for (var i = r[0]; i <= r[1]; ++i)
        if (NF[i] != null)
          ++cnt;
    });
    if (cnt == 0)
      return;
    write_record(ba, 615, write_UInt32LE(cnt));
    [[5, 8], [23, 26], [41, 44], [50, 392]].forEach(function(r) {
      for (var i = r[0]; i <= r[1]; ++i)
        if (NF[i] != null)
          write_record(ba, 44, write_BrtFmt(i, NF[i]));
    });
    write_record(ba, 616);
  }
  function write_FONTS_bin(ba) {
    var cnt = 1;
    write_record(ba, 611, write_UInt32LE(cnt));
    write_record(ba, 43, write_BrtFont({
      sz: 12,
      color: { theme: 1 },
      name: "Calibri",
      family: 2,
      scheme: "minor"
    }));
    write_record(ba, 612);
  }
  function write_FILLS_bin(ba) {
    var cnt = 2;
    write_record(ba, 603, write_UInt32LE(cnt));
    write_record(ba, 45, write_BrtFill({ patternType: "none" }));
    write_record(ba, 45, write_BrtFill({ patternType: "gray125" }));
    write_record(ba, 604);
  }
  function write_BORDERS_bin(ba) {
    var cnt = 1;
    write_record(ba, 613, write_UInt32LE(cnt));
    write_record(ba, 46, write_BrtBorder());
    write_record(ba, 614);
  }
  function write_CELLSTYLEXFS_bin(ba) {
    var cnt = 1;
    write_record(ba, 626, write_UInt32LE(cnt));
    write_record(ba, 47, write_BrtXF({
      numFmtId: 0,
      fontId: 0,
      fillId: 0,
      borderId: 0
    }, 65535));
    write_record(ba, 627);
  }
  function write_CELLXFS_bin(ba, data) {
    write_record(ba, 617, write_UInt32LE(data.length));
    data.forEach(function(c2) {
      write_record(ba, 47, write_BrtXF(c2, 0));
    });
    write_record(ba, 618);
  }
  function write_STYLES_bin(ba) {
    var cnt = 1;
    write_record(ba, 619, write_UInt32LE(cnt));
    write_record(ba, 48, write_BrtStyle({
      xfId: 0,
      builtinId: 0,
      name: "Normal"
    }));
    write_record(ba, 620);
  }
  function write_DXFS_bin(ba) {
    var cnt = 0;
    write_record(ba, 505, write_UInt32LE(cnt));
    write_record(ba, 506);
  }
  function write_TABLESTYLES_bin(ba) {
    var cnt = 0;
    write_record(ba, 508, write_BrtBeginTableStyles(cnt, "TableStyleMedium9", "PivotStyleMedium4"));
    write_record(ba, 509);
  }
  function write_sty_bin(wb, opts) {
    var ba = buf_array();
    write_record(ba, 278);
    write_FMTS_bin(ba, wb.SSF);
    write_FONTS_bin(ba);
    write_FILLS_bin(ba);
    write_BORDERS_bin(ba);
    write_CELLSTYLEXFS_bin(ba);
    write_CELLXFS_bin(ba, opts.cellXfs);
    write_STYLES_bin(ba);
    write_DXFS_bin(ba);
    write_TABLESTYLES_bin(ba);
    write_record(ba, 279);
    return ba.end();
  }
  var XLSXThemeClrScheme = [
    "</a:lt1>",
    "</a:dk1>",
    "</a:lt2>",
    "</a:dk2>",
    "</a:accent1>",
    "</a:accent2>",
    "</a:accent3>",
    "</a:accent4>",
    "</a:accent5>",
    "</a:accent6>",
    "</a:hlink>",
    "</a:folHlink>"
  ];
  function parse_clrScheme(t, themes, opts) {
    themes.themeElements.clrScheme = [];
    var color = {};
    (t[0].match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (y[0]) {
        case "<a:clrScheme":
        case "</a:clrScheme>":
          break;
        case "<a:srgbClr":
          color.rgb = y.val;
          break;
        case "<a:sysClr":
          color.rgb = y.lastClr;
          break;
        case "<a:dk1>":
        case "</a:dk1>":
        case "<a:lt1>":
        case "</a:lt1>":
        case "<a:dk2>":
        case "</a:dk2>":
        case "<a:lt2>":
        case "</a:lt2>":
        case "<a:accent1>":
        case "</a:accent1>":
        case "<a:accent2>":
        case "</a:accent2>":
        case "<a:accent3>":
        case "</a:accent3>":
        case "<a:accent4>":
        case "</a:accent4>":
        case "<a:accent5>":
        case "</a:accent5>":
        case "<a:accent6>":
        case "</a:accent6>":
        case "<a:hlink>":
        case "</a:hlink>":
        case "<a:folHlink>":
        case "</a:folHlink>":
          if (y[0].charAt(1) === "/") {
            themes.themeElements.clrScheme[XLSXThemeClrScheme.indexOf(y[0])] = color;
            color = {};
          } else {
            color.name = y[0].slice(3, y[0].length - 1);
          }
          break;
        default:
          if (opts && opts.WTF)
            throw new Error("Unrecognized " + y[0] + " in clrScheme");
      }
    });
  }
  function parse_fontScheme() {
  }
  function parse_fmtScheme() {
  }
  var clrsregex = /<a:clrScheme([^>]*)>[\s\S]*<\/a:clrScheme>/;
  var fntsregex = /<a:fontScheme([^>]*)>[\s\S]*<\/a:fontScheme>/;
  var fmtsregex = /<a:fmtScheme([^>]*)>[\s\S]*<\/a:fmtScheme>/;
  function parse_themeElements(data, themes, opts) {
    themes.themeElements = {};
    var t;
    [
      ["clrScheme", clrsregex, parse_clrScheme],
      ["fontScheme", fntsregex, parse_fontScheme],
      ["fmtScheme", fmtsregex, parse_fmtScheme]
    ].forEach(function(m2) {
      if (!(t = data.match(m2[1])))
        throw new Error(m2[0] + " not found in themeElements");
      m2[2](t, themes, opts);
    });
  }
  var themeltregex = /<a:themeElements([^>]*)>[\s\S]*<\/a:themeElements>/;
  function parse_theme_xml(data, opts) {
    if (!data || data.length === 0)
      data = write_theme();
    var t;
    var themes = {};
    if (!(t = data.match(themeltregex)))
      throw new Error("themeElements not found in theme");
    parse_themeElements(t[0], themes, opts);
    themes.raw = data;
    return themes;
  }
  function write_theme(Themes, opts) {
    if (opts && opts.themeXLSX)
      return opts.themeXLSX;
    if (Themes && typeof Themes.raw == "string")
      return Themes.raw;
    var o2 = [XML_HEADER];
    o2[o2.length] = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">';
    o2[o2.length] = "<a:themeElements>";
    o2[o2.length] = '<a:clrScheme name="Office">';
    o2[o2.length] = '<a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1>';
    o2[o2.length] = '<a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>';
    o2[o2.length] = '<a:dk2><a:srgbClr val="1F497D"/></a:dk2>';
    o2[o2.length] = '<a:lt2><a:srgbClr val="EEECE1"/></a:lt2>';
    o2[o2.length] = '<a:accent1><a:srgbClr val="4F81BD"/></a:accent1>';
    o2[o2.length] = '<a:accent2><a:srgbClr val="C0504D"/></a:accent2>';
    o2[o2.length] = '<a:accent3><a:srgbClr val="9BBB59"/></a:accent3>';
    o2[o2.length] = '<a:accent4><a:srgbClr val="8064A2"/></a:accent4>';
    o2[o2.length] = '<a:accent5><a:srgbClr val="4BACC6"/></a:accent5>';
    o2[o2.length] = '<a:accent6><a:srgbClr val="F79646"/></a:accent6>';
    o2[o2.length] = '<a:hlink><a:srgbClr val="0000FF"/></a:hlink>';
    o2[o2.length] = '<a:folHlink><a:srgbClr val="800080"/></a:folHlink>';
    o2[o2.length] = "</a:clrScheme>";
    o2[o2.length] = '<a:fontScheme name="Office">';
    o2[o2.length] = "<a:majorFont>";
    o2[o2.length] = '<a:latin typeface="Cambria"/>';
    o2[o2.length] = '<a:ea typeface=""/>';
    o2[o2.length] = '<a:cs typeface=""/>';
    o2[o2.length] = '<a:font script="Jpan" typeface="\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF"/>';
    o2[o2.length] = '<a:font script="Hang" typeface="\uB9D1\uC740 \uACE0\uB515"/>';
    o2[o2.length] = '<a:font script="Hans" typeface="\u5B8B\u4F53"/>';
    o2[o2.length] = '<a:font script="Hant" typeface="\u65B0\u7D30\u660E\u9AD4"/>';
    o2[o2.length] = '<a:font script="Arab" typeface="Times New Roman"/>';
    o2[o2.length] = '<a:font script="Hebr" typeface="Times New Roman"/>';
    o2[o2.length] = '<a:font script="Thai" typeface="Tahoma"/>';
    o2[o2.length] = '<a:font script="Ethi" typeface="Nyala"/>';
    o2[o2.length] = '<a:font script="Beng" typeface="Vrinda"/>';
    o2[o2.length] = '<a:font script="Gujr" typeface="Shruti"/>';
    o2[o2.length] = '<a:font script="Khmr" typeface="MoolBoran"/>';
    o2[o2.length] = '<a:font script="Knda" typeface="Tunga"/>';
    o2[o2.length] = '<a:font script="Guru" typeface="Raavi"/>';
    o2[o2.length] = '<a:font script="Cans" typeface="Euphemia"/>';
    o2[o2.length] = '<a:font script="Cher" typeface="Plantagenet Cherokee"/>';
    o2[o2.length] = '<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>';
    o2[o2.length] = '<a:font script="Tibt" typeface="Microsoft Himalaya"/>';
    o2[o2.length] = '<a:font script="Thaa" typeface="MV Boli"/>';
    o2[o2.length] = '<a:font script="Deva" typeface="Mangal"/>';
    o2[o2.length] = '<a:font script="Telu" typeface="Gautami"/>';
    o2[o2.length] = '<a:font script="Taml" typeface="Latha"/>';
    o2[o2.length] = '<a:font script="Syrc" typeface="Estrangelo Edessa"/>';
    o2[o2.length] = '<a:font script="Orya" typeface="Kalinga"/>';
    o2[o2.length] = '<a:font script="Mlym" typeface="Kartika"/>';
    o2[o2.length] = '<a:font script="Laoo" typeface="DokChampa"/>';
    o2[o2.length] = '<a:font script="Sinh" typeface="Iskoola Pota"/>';
    o2[o2.length] = '<a:font script="Mong" typeface="Mongolian Baiti"/>';
    o2[o2.length] = '<a:font script="Viet" typeface="Times New Roman"/>';
    o2[o2.length] = '<a:font script="Uigh" typeface="Microsoft Uighur"/>';
    o2[o2.length] = '<a:font script="Geor" typeface="Sylfaen"/>';
    o2[o2.length] = "</a:majorFont>";
    o2[o2.length] = "<a:minorFont>";
    o2[o2.length] = '<a:latin typeface="Calibri"/>';
    o2[o2.length] = '<a:ea typeface=""/>';
    o2[o2.length] = '<a:cs typeface=""/>';
    o2[o2.length] = '<a:font script="Jpan" typeface="\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF"/>';
    o2[o2.length] = '<a:font script="Hang" typeface="\uB9D1\uC740 \uACE0\uB515"/>';
    o2[o2.length] = '<a:font script="Hans" typeface="\u5B8B\u4F53"/>';
    o2[o2.length] = '<a:font script="Hant" typeface="\u65B0\u7D30\u660E\u9AD4"/>';
    o2[o2.length] = '<a:font script="Arab" typeface="Arial"/>';
    o2[o2.length] = '<a:font script="Hebr" typeface="Arial"/>';
    o2[o2.length] = '<a:font script="Thai" typeface="Tahoma"/>';
    o2[o2.length] = '<a:font script="Ethi" typeface="Nyala"/>';
    o2[o2.length] = '<a:font script="Beng" typeface="Vrinda"/>';
    o2[o2.length] = '<a:font script="Gujr" typeface="Shruti"/>';
    o2[o2.length] = '<a:font script="Khmr" typeface="DaunPenh"/>';
    o2[o2.length] = '<a:font script="Knda" typeface="Tunga"/>';
    o2[o2.length] = '<a:font script="Guru" typeface="Raavi"/>';
    o2[o2.length] = '<a:font script="Cans" typeface="Euphemia"/>';
    o2[o2.length] = '<a:font script="Cher" typeface="Plantagenet Cherokee"/>';
    o2[o2.length] = '<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>';
    o2[o2.length] = '<a:font script="Tibt" typeface="Microsoft Himalaya"/>';
    o2[o2.length] = '<a:font script="Thaa" typeface="MV Boli"/>';
    o2[o2.length] = '<a:font script="Deva" typeface="Mangal"/>';
    o2[o2.length] = '<a:font script="Telu" typeface="Gautami"/>';
    o2[o2.length] = '<a:font script="Taml" typeface="Latha"/>';
    o2[o2.length] = '<a:font script="Syrc" typeface="Estrangelo Edessa"/>';
    o2[o2.length] = '<a:font script="Orya" typeface="Kalinga"/>';
    o2[o2.length] = '<a:font script="Mlym" typeface="Kartika"/>';
    o2[o2.length] = '<a:font script="Laoo" typeface="DokChampa"/>';
    o2[o2.length] = '<a:font script="Sinh" typeface="Iskoola Pota"/>';
    o2[o2.length] = '<a:font script="Mong" typeface="Mongolian Baiti"/>';
    o2[o2.length] = '<a:font script="Viet" typeface="Arial"/>';
    o2[o2.length] = '<a:font script="Uigh" typeface="Microsoft Uighur"/>';
    o2[o2.length] = '<a:font script="Geor" typeface="Sylfaen"/>';
    o2[o2.length] = "</a:minorFont>";
    o2[o2.length] = "</a:fontScheme>";
    o2[o2.length] = '<a:fmtScheme name="Office">';
    o2[o2.length] = "<a:fillStyleLst>";
    o2[o2.length] = '<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>';
    o2[o2.length] = '<a:gradFill rotWithShape="1">';
    o2[o2.length] = "<a:gsLst>";
    o2[o2.length] = '<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>';
    o2[o2.length] = "</a:gsLst>";
    o2[o2.length] = '<a:lin ang="16200000" scaled="1"/>';
    o2[o2.length] = "</a:gradFill>";
    o2[o2.length] = '<a:gradFill rotWithShape="1">';
    o2[o2.length] = "<a:gsLst>";
    o2[o2.length] = '<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs>';
    o2[o2.length] = "</a:gsLst>";
    o2[o2.length] = '<a:lin ang="16200000" scaled="0"/>';
    o2[o2.length] = "</a:gradFill>";
    o2[o2.length] = "</a:fillStyleLst>";
    o2[o2.length] = "<a:lnStyleLst>";
    o2[o2.length] = '<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln>';
    o2[o2.length] = '<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>';
    o2[o2.length] = '<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>';
    o2[o2.length] = "</a:lnStyleLst>";
    o2[o2.length] = "<a:effectStyleLst>";
    o2[o2.length] = "<a:effectStyle>";
    o2[o2.length] = "<a:effectLst>";
    o2[o2.length] = '<a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw>';
    o2[o2.length] = "</a:effectLst>";
    o2[o2.length] = "</a:effectStyle>";
    o2[o2.length] = "<a:effectStyle>";
    o2[o2.length] = "<a:effectLst>";
    o2[o2.length] = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>';
    o2[o2.length] = "</a:effectLst>";
    o2[o2.length] = "</a:effectStyle>";
    o2[o2.length] = "<a:effectStyle>";
    o2[o2.length] = "<a:effectLst>";
    o2[o2.length] = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>';
    o2[o2.length] = "</a:effectLst>";
    o2[o2.length] = '<a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d>';
    o2[o2.length] = '<a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d>';
    o2[o2.length] = "</a:effectStyle>";
    o2[o2.length] = "</a:effectStyleLst>";
    o2[o2.length] = "<a:bgFillStyleLst>";
    o2[o2.length] = '<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>';
    o2[o2.length] = '<a:gradFill rotWithShape="1">';
    o2[o2.length] = "<a:gsLst>";
    o2[o2.length] = '<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>';
    o2[o2.length] = "</a:gsLst>";
    o2[o2.length] = '<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>';
    o2[o2.length] = "</a:gradFill>";
    o2[o2.length] = '<a:gradFill rotWithShape="1">';
    o2[o2.length] = "<a:gsLst>";
    o2[o2.length] = '<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>';
    o2[o2.length] = '<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>';
    o2[o2.length] = "</a:gsLst>";
    o2[o2.length] = '<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>';
    o2[o2.length] = "</a:gradFill>";
    o2[o2.length] = "</a:bgFillStyleLst>";
    o2[o2.length] = "</a:fmtScheme>";
    o2[o2.length] = "</a:themeElements>";
    o2[o2.length] = "<a:objectDefaults>";
    o2[o2.length] = "<a:spDef>";
    o2[o2.length] = '<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="1"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></a:style>';
    o2[o2.length] = "</a:spDef>";
    o2[o2.length] = "<a:lnDef>";
    o2[o2.length] = '<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="2"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1"/></a:fontRef></a:style>';
    o2[o2.length] = "</a:lnDef>";
    o2[o2.length] = "</a:objectDefaults>";
    o2[o2.length] = "<a:extraClrSchemeLst/>";
    o2[o2.length] = "</a:theme>";
    return o2.join("");
  }
  function parse_Theme(blob, length, opts) {
    var end = blob.l + length;
    var dwThemeVersion = blob.read_shift(4);
    if (dwThemeVersion === 124226)
      return;
    if (!opts.cellStyles) {
      blob.l = end;
      return;
    }
    var data = blob.slice(blob.l);
    blob.l = end;
    var zip;
    try {
      zip = zip_read(data, { type: "array" });
    } catch (e) {
      return;
    }
    var themeXML = getzipstr(zip, "theme/theme/theme1.xml", true);
    if (!themeXML)
      return;
    return parse_theme_xml(themeXML, opts);
  }
  function parse_ColorTheme(blob) {
    return blob.read_shift(4);
  }
  function parse_FullColorExt(blob) {
    var o2 = {};
    o2.xclrType = blob.read_shift(2);
    o2.nTintShade = blob.read_shift(2);
    switch (o2.xclrType) {
      case 0:
        blob.l += 4;
        break;
      case 1:
        o2.xclrValue = parse_IcvXF(blob, 4);
        break;
      case 2:
        o2.xclrValue = parse_LongRGBA(blob);
        break;
      case 3:
        o2.xclrValue = parse_ColorTheme(blob);
        break;
      case 4:
        blob.l += 4;
        break;
    }
    blob.l += 8;
    return o2;
  }
  function parse_IcvXF(blob, length) {
    return parsenoop(blob, length);
  }
  function parse_XFExtGradient(blob, length) {
    return parsenoop(blob, length);
  }
  function parse_ExtProp(blob) {
    var extType = blob.read_shift(2);
    var cb = blob.read_shift(2) - 4;
    var o2 = [extType];
    switch (extType) {
      case 4:
      case 5:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
      case 13:
        o2[1] = parse_FullColorExt(blob);
        break;
      case 6:
        o2[1] = parse_XFExtGradient(blob, cb);
        break;
      case 14:
      case 15:
        o2[1] = blob.read_shift(cb === 1 ? 1 : 2);
        break;
      default:
        throw new Error("Unrecognized ExtProp type: " + extType + " " + cb);
    }
    return o2;
  }
  function parse_XFExt(blob, length) {
    var end = blob.l + length;
    blob.l += 2;
    var ixfe = blob.read_shift(2);
    blob.l += 2;
    var cexts = blob.read_shift(2);
    var ext = [];
    while (cexts-- > 0)
      ext.push(parse_ExtProp(blob, end - blob.l));
    return { ixfe, ext };
  }
  function update_xfext(xf, xfext) {
    xfext.forEach(function(xfe) {
      switch (xfe[0]) {
      }
    });
  }
  function parse_BrtMdtinfo(data, length) {
    return {
      flags: data.read_shift(4),
      version: data.read_shift(4),
      name: parse_XLWideString(data)
    };
  }
  function write_BrtMdtinfo(data) {
    var o2 = new_buf(12 + 2 * data.name.length);
    o2.write_shift(4, data.flags);
    o2.write_shift(4, data.version);
    write_XLWideString(data.name, o2);
    return o2.slice(0, o2.l);
  }
  function parse_BrtMdb(data) {
    var out = [];
    var cnt = data.read_shift(4);
    while (cnt-- > 0)
      out.push([data.read_shift(4), data.read_shift(4)]);
    return out;
  }
  function write_BrtMdb(mdb) {
    var o2 = new_buf(4 + 8 * mdb.length);
    o2.write_shift(4, mdb.length);
    for (var i = 0; i < mdb.length; ++i) {
      o2.write_shift(4, mdb[i][0]);
      o2.write_shift(4, mdb[i][1]);
    }
    return o2;
  }
  function write_BrtBeginEsfmd(cnt, name) {
    var o2 = new_buf(8 + 2 * name.length);
    o2.write_shift(4, cnt);
    write_XLWideString(name, o2);
    return o2.slice(0, o2.l);
  }
  function parse_BrtBeginEsmdb(data) {
    data.l += 4;
    return data.read_shift(4) != 0;
  }
  function write_BrtBeginEsmdb(cnt, cm) {
    var o2 = new_buf(8);
    o2.write_shift(4, cnt);
    o2.write_shift(4, cm ? 1 : 0);
    return o2;
  }
  function parse_xlmeta_bin(data, name, _opts) {
    var out = { Types: [], Cell: [], Value: [] };
    var opts = _opts || {};
    var state = [];
    var pass = false;
    var metatype = 2;
    recordhopper(data, function(val, R2, RT) {
      switch (RT) {
        case 335:
          out.Types.push({ name: val.name });
          break;
        case 51:
          val.forEach(function(r) {
            if (metatype == 1)
              out.Cell.push({ type: out.Types[r[0] - 1].name, index: r[1] });
            else if (metatype == 0)
              out.Value.push({ type: out.Types[r[0] - 1].name, index: r[1] });
          });
          break;
        case 337:
          metatype = val ? 1 : 0;
          break;
        case 338:
          metatype = 2;
          break;
        case 35:
          state.push(RT);
          pass = true;
          break;
        case 36:
          state.pop();
          pass = false;
          break;
        default:
          if (R2.T)
            ;
          else if (!pass || opts.WTF && state[state.length - 1] != 35)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    });
    return out;
  }
  function write_xlmeta_bin() {
    var ba = buf_array();
    write_record(ba, 332);
    write_record(ba, 334, write_UInt32LE(1));
    write_record(ba, 335, write_BrtMdtinfo({
      name: "XLDAPR",
      version: 12e4,
      flags: 3496657072
    }));
    write_record(ba, 336);
    write_record(ba, 339, write_BrtBeginEsfmd(1, "XLDAPR"));
    write_record(ba, 52);
    write_record(ba, 35, write_UInt32LE(514));
    write_record(ba, 4096, write_UInt32LE(0));
    write_record(ba, 4097, writeuint16(1));
    write_record(ba, 36);
    write_record(ba, 53);
    write_record(ba, 340);
    write_record(ba, 337, write_BrtBeginEsmdb(1, true));
    write_record(ba, 51, write_BrtMdb([[1, 0]]));
    write_record(ba, 338);
    write_record(ba, 333);
    return ba.end();
  }
  function parse_xlmeta_xml(data, name, opts) {
    var out = { Types: [], Cell: [], Value: [] };
    if (!data)
      return out;
    var pass = false;
    var metatype = 2;
    var lastmeta;
    data.replace(tagregex, function(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<?xml":
          break;
        case "<metadata":
        case "</metadata>":
          break;
        case "<metadataTypes":
        case "</metadataTypes>":
          break;
        case "<metadataType":
          out.Types.push({ name: y.name });
          break;
        case "</metadataType>":
          break;
        case "<futureMetadata":
          for (var j = 0; j < out.Types.length; ++j)
            if (out.Types[j].name == y.name)
              lastmeta = out.Types[j];
          break;
        case "</futureMetadata>":
          break;
        case "<bk>":
          break;
        case "</bk>":
          break;
        case "<rc":
          if (metatype == 1)
            out.Cell.push({ type: out.Types[y.t - 1].name, index: +y.v });
          else if (metatype == 0)
            out.Value.push({ type: out.Types[y.t - 1].name, index: +y.v });
          break;
        case "</rc>":
          break;
        case "<cellMetadata":
          metatype = 1;
          break;
        case "</cellMetadata>":
          metatype = 2;
          break;
        case "<valueMetadata":
          metatype = 0;
          break;
        case "</valueMetadata>":
          metatype = 2;
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
        case "<extLst/>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        case "<rvb":
          if (!lastmeta)
            break;
          if (!lastmeta.offsets)
            lastmeta.offsets = [];
          lastmeta.offsets.push(+y.i);
          break;
        default:
          if (!pass && opts.WTF)
            throw new Error("unrecognized " + y[0] + " in metadata");
      }
      return x2;
    });
    return out;
  }
  function write_xlmeta_xml() {
    var o2 = [XML_HEADER];
    o2.push('<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray">\n  <metadataTypes count="1">\n    <metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>\n  </metadataTypes>\n  <futureMetadata name="XLDAPR" count="1">\n    <bk>\n      <extLst>\n        <ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}">\n          <xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/>\n        </ext>\n      </extLst>\n    </bk>\n  </futureMetadata>\n  <cellMetadata count="1">\n    <bk>\n      <rc t="1" v="0"/>\n    </bk>\n  </cellMetadata>\n</metadata>');
    return o2.join("");
  }
  function parse_cc_xml(data) {
    var d2 = [];
    if (!data)
      return d2;
    var i = 1;
    (data.match(tagregex) || []).forEach(function(x2) {
      var y = parsexmltag(x2);
      switch (y[0]) {
        case "<?xml":
          break;
        case "<calcChain":
        case "<calcChain>":
        case "</calcChain>":
          break;
        case "<c":
          delete y[0];
          if (y.i)
            i = y.i;
          else
            y.i = i;
          d2.push(y);
          break;
      }
    });
    return d2;
  }
  function parse_BrtCalcChainItem$(data) {
    var out = {};
    out.i = data.read_shift(4);
    var cell = {};
    cell.r = data.read_shift(4);
    cell.c = data.read_shift(4);
    out.r = encode_cell(cell);
    var flags = data.read_shift(1);
    if (flags & 2)
      out.l = "1";
    if (flags & 8)
      out.a = "1";
    return out;
  }
  function parse_cc_bin(data, name, opts) {
    var out = [];
    recordhopper(data, function hopper_cc(val, R2, RT) {
      switch (RT) {
        case 63:
          out.push(val);
          break;
        default:
          if (R2.T)
            ;
          else
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    });
    return out;
  }
  function parse_xlink_xml() {
  }
  function parse_xlink_bin(data, rel, name, _opts) {
    if (!data)
      return data;
    var opts = _opts || {};
    var pass = false;
    recordhopper(data, function xlink_parse(val, R2, RT) {
      switch (RT) {
        case 359:
        case 363:
        case 364:
        case 366:
        case 367:
        case 368:
        case 369:
        case 370:
        case 371:
        case 472:
        case 577:
        case 578:
        case 579:
        case 580:
        case 581:
        case 582:
        case 583:
        case 584:
        case 585:
        case 586:
        case 587:
          break;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        default:
          if (R2.T)
            ;
          else if (!pass || opts.WTF)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    }, opts);
  }
  function parse_drawing(data, rels) {
    if (!data)
      return "??";
    var id = (data.match(/<c:chart [^>]*r:id="([^"]*)"/) || ["", ""])[1];
    return rels["!id"][id].Target;
  }
  var _shapeid = 1024;
  function write_comments_vml(rId, comments) {
    var csize = [21600, 21600];
    var bbox = ["m0,0l0", csize[1], csize[0], csize[1], csize[0], "0xe"].join(",");
    var o2 = [
      writextag("xml", null, { "xmlns:v": XLMLNS.v, "xmlns:o": XLMLNS.o, "xmlns:x": XLMLNS.x, "xmlns:mv": XLMLNS.mv }).replace(/\/>/, ">"),
      writextag("o:shapelayout", writextag("o:idmap", null, { "v:ext": "edit", "data": rId }), { "v:ext": "edit" }),
      writextag("v:shapetype", [
        writextag("v:stroke", null, { joinstyle: "miter" }),
        writextag("v:path", null, { gradientshapeok: "t", "o:connecttype": "rect" })
      ].join(""), { id: "_x0000_t202", "o:spt": 202, coordsize: csize.join(","), path: bbox })
    ];
    while (_shapeid < rId * 1e3)
      _shapeid += 1e3;
    comments.forEach(function(x2) {
      var c2 = decode_cell(x2[0]);
      var fillopts = { "color2": "#BEFF82", "type": "gradient" };
      if (fillopts.type == "gradient")
        fillopts.angle = "-180";
      var fillparm = fillopts.type == "gradient" ? writextag("o:fill", null, { type: "gradientUnscaled", "v:ext": "view" }) : null;
      var fillxml = writextag("v:fill", fillparm, fillopts);
      var shadata = { on: "t", "obscured": "t" };
      ++_shapeid;
      o2 = o2.concat([
        "<v:shape" + wxt_helper({
          id: "_x0000_s" + _shapeid,
          type: "#_x0000_t202",
          style: "position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x2[1].hidden ? ";visibility:hidden" : ""),
          fillcolor: "#ECFAD4",
          strokecolor: "#edeaa1"
        }) + ">",
        fillxml,
        writextag("v:shadow", null, shadata),
        writextag("v:path", null, { "o:connecttype": "none" }),
        '<v:textbox><div style="text-align:left"></div></v:textbox>',
        '<x:ClientData ObjectType="Note">',
        "<x:MoveWithCells/>",
        "<x:SizeWithCells/>",
        writetag("x:Anchor", [c2.c + 1, 0, c2.r + 1, 0, c2.c + 3, 20, c2.r + 5, 20].join(",")),
        writetag("x:AutoFill", "False"),
        writetag("x:Row", String(c2.r)),
        writetag("x:Column", String(c2.c)),
        x2[1].hidden ? "" : "<x:Visible/>",
        "</x:ClientData>",
        "</v:shape>"
      ]);
    });
    o2.push("</xml>");
    return o2.join("");
  }
  function sheet_insert_comments(sheet, comments, threaded, people) {
    var dense = Array.isArray(sheet);
    var cell;
    comments.forEach(function(comment) {
      var r = decode_cell(comment.ref);
      if (dense) {
        if (!sheet[r.r])
          sheet[r.r] = [];
        cell = sheet[r.r][r.c];
      } else
        cell = sheet[comment.ref];
      if (!cell) {
        cell = { t: "z" };
        if (dense)
          sheet[r.r][r.c] = cell;
        else
          sheet[comment.ref] = cell;
        var range = safe_decode_range(sheet["!ref"] || "BDWGO1000001:A1");
        if (range.s.r > r.r)
          range.s.r = r.r;
        if (range.e.r < r.r)
          range.e.r = r.r;
        if (range.s.c > r.c)
          range.s.c = r.c;
        if (range.e.c < r.c)
          range.e.c = r.c;
        var encoded = encode_range(range);
        if (encoded !== sheet["!ref"])
          sheet["!ref"] = encoded;
      }
      if (!cell.c)
        cell.c = [];
      var o2 = { a: comment.author, t: comment.t, r: comment.r, T: threaded };
      if (comment.h)
        o2.h = comment.h;
      for (var i = cell.c.length - 1; i >= 0; --i) {
        if (!threaded && cell.c[i].T)
          return;
        if (threaded && !cell.c[i].T)
          cell.c.splice(i, 1);
      }
      if (threaded && people)
        for (i = 0; i < people.length; ++i) {
          if (o2.a == people[i].id) {
            o2.a = people[i].name || o2.a;
            break;
          }
        }
      cell.c.push(o2);
    });
  }
  function parse_comments_xml(data, opts) {
    if (data.match(/<(?:\w+:)?comments *\/>/))
      return [];
    var authors = [];
    var commentList = [];
    var authtag = data.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);
    if (authtag && authtag[1])
      authtag[1].split(/<\/\w*:?author>/).forEach(function(x2) {
        if (x2 === "" || x2.trim() === "")
          return;
        var a2 = x2.match(/<(?:\w+:)?author[^>]*>(.*)/);
        if (a2)
          authors.push(a2[1]);
      });
    var cmnttag = data.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);
    if (cmnttag && cmnttag[1])
      cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x2) {
        if (x2 === "" || x2.trim() === "")
          return;
        var cm = x2.match(/<(?:\w+:)?comment[^>]*>/);
        if (!cm)
          return;
        var y = parsexmltag(cm[0]);
        var comment = { author: y.authorId && authors[y.authorId] || "sheetjsghost", ref: y.ref, guid: y.guid };
        var cell = decode_cell(y.ref);
        if (opts.sheetRows && opts.sheetRows <= cell.r)
          return;
        var textMatch = x2.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/);
        var rt2 = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || { r: "", t: "", h: "" };
        comment.r = rt2.r;
        if (rt2.r == "<t></t>")
          rt2.t = rt2.h = "";
        comment.t = (rt2.t || "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
        if (opts.cellHTML)
          comment.h = rt2.h;
        commentList.push(comment);
      });
    return commentList;
  }
  function write_comments_xml(data) {
    var o2 = [XML_HEADER, writextag("comments", null, { "xmlns": XMLNS_main[0] })];
    var iauthor = [];
    o2.push("<authors>");
    data.forEach(function(x2) {
      x2[1].forEach(function(w2) {
        var a2 = escapexml(w2.a);
        if (iauthor.indexOf(a2) == -1) {
          iauthor.push(a2);
          o2.push("<author>" + a2 + "</author>");
        }
        if (w2.T && w2.ID && iauthor.indexOf("tc=" + w2.ID) == -1) {
          iauthor.push("tc=" + w2.ID);
          o2.push("<author>tc=" + w2.ID + "</author>");
        }
      });
    });
    if (iauthor.length == 0) {
      iauthor.push("SheetJ5");
      o2.push("<author>SheetJ5</author>");
    }
    o2.push("</authors>");
    o2.push("<commentList>");
    data.forEach(function(d2) {
      var lastauthor = 0, ts = [];
      if (d2[1][0] && d2[1][0].T && d2[1][0].ID)
        lastauthor = iauthor.indexOf("tc=" + d2[1][0].ID);
      else
        d2[1].forEach(function(c2) {
          if (c2.a)
            lastauthor = iauthor.indexOf(escapexml(c2.a));
          ts.push(c2.t || "");
        });
      o2.push('<comment ref="' + d2[0] + '" authorId="' + lastauthor + '"><text>');
      if (ts.length <= 1)
        o2.push(writetag("t", escapexml(ts[0] || "")));
      else {
        var t = "Comment:\n    " + ts[0] + "\n";
        for (var i = 1; i < ts.length; ++i)
          t += "Reply:\n    " + ts[i] + "\n";
        o2.push(writetag("t", escapexml(t)));
      }
      o2.push("</text></comment>");
    });
    o2.push("</commentList>");
    if (o2.length > 2) {
      o2[o2.length] = "</comments>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function parse_tcmnt_xml(data, opts) {
    var out = [];
    var pass = false, comment = {}, tidx = 0;
    data.replace(tagregex, function xml_tcmnt(x2, idx) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<?xml":
          break;
        case "<ThreadedComments":
          break;
        case "</ThreadedComments>":
          break;
        case "<threadedComment":
          comment = { author: y.personId, guid: y.id, ref: y.ref, T: 1 };
          break;
        case "</threadedComment>":
          if (comment.t != null)
            out.push(comment);
          break;
        case "<text>":
        case "<text":
          tidx = idx + x2.length;
          break;
        case "</text>":
          comment.t = data.slice(tidx, idx).replace(/\r\n/g, "\n").replace(/\r/g, "\n");
          break;
        case "<mentions":
        case "<mentions>":
          pass = true;
          break;
        case "</mentions>":
          pass = false;
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
        case "<extLst/>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (!pass && opts.WTF)
            throw new Error("unrecognized " + y[0] + " in threaded comments");
      }
      return x2;
    });
    return out;
  }
  function write_tcmnt_xml(comments, people, opts) {
    var o2 = [XML_HEADER, writextag("ThreadedComments", null, { "xmlns": XMLNS.TCMNT }).replace(/[\/]>/, ">")];
    comments.forEach(function(carr) {
      var rootid = "";
      (carr[1] || []).forEach(function(c2, idx) {
        if (!c2.T) {
          delete c2.ID;
          return;
        }
        if (c2.a && people.indexOf(c2.a) == -1)
          people.push(c2.a);
        var tcopts = {
          ref: carr[0],
          id: "{54EE7951-7262-4200-6969-" + ("000000000000" + opts.tcid++).slice(-12) + "}"
        };
        if (idx == 0)
          rootid = tcopts.id;
        else
          tcopts.parentId = rootid;
        c2.ID = tcopts.id;
        if (c2.a)
          tcopts.personId = "{54EE7950-7262-4200-6969-" + ("000000000000" + people.indexOf(c2.a)).slice(-12) + "}";
        o2.push(writextag("threadedComment", writetag("text", c2.t || ""), tcopts));
      });
    });
    o2.push("</ThreadedComments>");
    return o2.join("");
  }
  function parse_people_xml(data, opts) {
    var out = [];
    var pass = false;
    data.replace(tagregex, function xml_tcmnt(x2) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<?xml":
          break;
        case "<personList":
          break;
        case "</personList>":
          break;
        case "<person":
          out.push({ name: y.displayname, id: y.id });
          break;
        case "</person>":
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
        case "<extLst/>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        default:
          if (!pass && opts.WTF)
            throw new Error("unrecognized " + y[0] + " in threaded comments");
      }
      return x2;
    });
    return out;
  }
  function write_people_xml(people) {
    var o2 = [XML_HEADER, writextag("personList", null, {
      "xmlns": XMLNS.TCMNT,
      "xmlns:x": XMLNS_main[0]
    }).replace(/[\/]>/, ">")];
    people.forEach(function(person, idx) {
      o2.push(writextag("person", null, {
        displayName: person,
        id: "{54EE7950-7262-4200-6969-" + ("000000000000" + idx).slice(-12) + "}",
        userId: person,
        providerId: "None"
      }));
    });
    o2.push("</personList>");
    return o2.join("");
  }
  function parse_BrtBeginComment(data) {
    var out = {};
    out.iauthor = data.read_shift(4);
    var rfx = parse_UncheckedRfX(data);
    out.rfx = rfx.s;
    out.ref = encode_cell(rfx.s);
    data.l += 16;
    return out;
  }
  function write_BrtBeginComment(data, o2) {
    if (o2 == null)
      o2 = new_buf(36);
    o2.write_shift(4, data[1].iauthor);
    write_UncheckedRfX(data[0], o2);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    return o2;
  }
  var parse_BrtCommentAuthor = parse_XLWideString;
  function write_BrtCommentAuthor(data) {
    return write_XLWideString(data.slice(0, 54));
  }
  function parse_comments_bin(data, opts) {
    var out = [];
    var authors = [];
    var c2 = {};
    var pass = false;
    recordhopper(data, function hopper_cmnt(val, R2, RT) {
      switch (RT) {
        case 632:
          authors.push(val);
          break;
        case 635:
          c2 = val;
          break;
        case 637:
          c2.t = val.t;
          c2.h = val.h;
          c2.r = val.r;
          break;
        case 636:
          c2.author = authors[c2.iauthor];
          delete c2.iauthor;
          if (opts.sheetRows && c2.rfx && opts.sheetRows <= c2.rfx.r)
            break;
          if (!c2.t)
            c2.t = "";
          delete c2.rfx;
          out.push(c2);
          break;
        case 3072:
          break;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        case 37:
          break;
        case 38:
          break;
        default:
          if (R2.T)
            ;
          else if (!pass || opts.WTF)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    });
    return out;
  }
  function write_comments_bin(data) {
    var ba = buf_array();
    var iauthor = [];
    write_record(ba, 628);
    write_record(ba, 630);
    data.forEach(function(comment) {
      comment[1].forEach(function(c2) {
        if (iauthor.indexOf(c2.a) > -1)
          return;
        iauthor.push(c2.a.slice(0, 54));
        write_record(ba, 632, write_BrtCommentAuthor(c2.a));
      });
    });
    write_record(ba, 631);
    write_record(ba, 633);
    data.forEach(function(comment) {
      comment[1].forEach(function(c2) {
        c2.iauthor = iauthor.indexOf(c2.a);
        var range = { s: decode_cell(comment[0]), e: decode_cell(comment[0]) };
        write_record(ba, 635, write_BrtBeginComment([range, c2]));
        if (c2.t && c2.t.length > 0)
          write_record(ba, 637, write_BrtCommentText(c2));
        write_record(ba, 636);
        delete c2.iauthor;
      });
    });
    write_record(ba, 634);
    write_record(ba, 629);
    return ba.end();
  }
  var CT_VBA = "application/vnd.ms-office.vbaProject";
  function make_vba_xls(cfb) {
    var newcfb = CFB.utils.cfb_new({ root: "R" });
    cfb.FullPaths.forEach(function(p2, i) {
      if (p2.slice(-1) === "/" || !p2.match(/_VBA_PROJECT_CUR/))
        return;
      var newpath = p2.replace(/^[^\/]*/, "R").replace(/\/_VBA_PROJECT_CUR\u0000*/, "");
      CFB.utils.cfb_add(newcfb, newpath, cfb.FileIndex[i].content);
    });
    return CFB.write(newcfb);
  }
  function fill_vba_xls(cfb, vba) {
    vba.FullPaths.forEach(function(p2, i) {
      if (i == 0)
        return;
      var newpath = p2.replace(/[^\/]*[\/]/, "/_VBA_PROJECT_CUR/");
      if (newpath.slice(-1) !== "/")
        CFB.utils.cfb_add(cfb, newpath, vba.FileIndex[i].content);
    });
  }
  var VBAFMTS = ["xlsb", "xlsm", "xlam", "biff8", "xla"];
  function parse_ds_bin() {
    return { "!type": "dialog" };
  }
  function parse_ds_xml() {
    return { "!type": "dialog" };
  }
  function parse_ms_bin() {
    return { "!type": "macro" };
  }
  function parse_ms_xml() {
    return { "!type": "macro" };
  }
  var rc_to_a1 = /* @__PURE__ */ function() {
    var rcregex = /(^|[^A-Za-z_])R(\[?-?\d+\]|[1-9]\d*|)C(\[?-?\d+\]|[1-9]\d*|)(?![A-Za-z0-9_])/g;
    var rcbase = { r: 0, c: 0 };
    function rcfunc($$, $1, $2, $3) {
      var cRel = false, rRel = false;
      if ($2.length == 0)
        rRel = true;
      else if ($2.charAt(0) == "[") {
        rRel = true;
        $2 = $2.slice(1, -1);
      }
      if ($3.length == 0)
        cRel = true;
      else if ($3.charAt(0) == "[") {
        cRel = true;
        $3 = $3.slice(1, -1);
      }
      var R2 = $2.length > 0 ? parseInt($2, 10) | 0 : 0, C2 = $3.length > 0 ? parseInt($3, 10) | 0 : 0;
      if (cRel)
        C2 += rcbase.c;
      else
        --C2;
      if (rRel)
        R2 += rcbase.r;
      else
        --R2;
      return $1 + (cRel ? "" : "$") + encode_col(C2) + (rRel ? "" : "$") + encode_row(R2);
    }
    return function rc_to_a12(fstr, base) {
      rcbase = base;
      return fstr.replace(rcregex, rcfunc);
    };
  }();
  var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})(?![_.\(A-Za-z0-9])/g;
  var a1_to_rc = /* @__PURE__ */ function() {
    return function a1_to_rc2(fstr, base) {
      return fstr.replace(crefregex, function($0, $1, $2, $3, $4, $5) {
        var c2 = decode_col($3) - ($2 ? 0 : base.c);
        var r = decode_row($5) - ($4 ? 0 : base.r);
        var R2 = r == 0 ? "" : !$4 ? "[" + r + "]" : r + 1;
        var C2 = c2 == 0 ? "" : !$2 ? "[" + c2 + "]" : c2 + 1;
        return $1 + "R" + R2 + "C" + C2;
      });
    };
  }();
  function shift_formula_str(f2, delta) {
    return f2.replace(crefregex, function($0, $1, $2, $3, $4, $5) {
      return $1 + ($2 == "$" ? $2 + $3 : encode_col(decode_col($3) + delta.c)) + ($4 == "$" ? $4 + $5 : encode_row(decode_row($5) + delta.r));
    });
  }
  function shift_formula_xlsx(f2, range, cell) {
    var r = decode_range(range), s2 = r.s, c2 = decode_cell(cell);
    var delta = { r: c2.r - s2.r, c: c2.c - s2.c };
    return shift_formula_str(f2, delta);
  }
  function fuzzyfmla(f2) {
    if (f2.length == 1)
      return false;
    return true;
  }
  function _xlfn(f2) {
    return f2.replace(/_xlfn\./g, "");
  }
  function parseread1(blob) {
    blob.l += 1;
    return;
  }
  function parse_ColRelU(blob, length) {
    var c2 = blob.read_shift(length == 1 ? 1 : 2);
    return [c2 & 16383, c2 >> 14 & 1, c2 >> 15 & 1];
  }
  function parse_RgceArea(blob, length, opts) {
    var w2 = 2;
    if (opts) {
      if (opts.biff >= 2 && opts.biff <= 5)
        return parse_RgceArea_BIFF2(blob);
      else if (opts.biff == 12)
        w2 = 4;
    }
    var r = blob.read_shift(w2), R2 = blob.read_shift(w2);
    var c2 = parse_ColRelU(blob, 2);
    var C2 = parse_ColRelU(blob, 2);
    return { s: { r, c: c2[0], cRel: c2[1], rRel: c2[2] }, e: { r: R2, c: C2[0], cRel: C2[1], rRel: C2[2] } };
  }
  function parse_RgceArea_BIFF2(blob) {
    var r = parse_ColRelU(blob, 2), R2 = parse_ColRelU(blob, 2);
    var c2 = blob.read_shift(1);
    var C2 = blob.read_shift(1);
    return { s: { r: r[0], c: c2, cRel: r[1], rRel: r[2] }, e: { r: R2[0], c: C2, cRel: R2[1], rRel: R2[2] } };
  }
  function parse_RgceAreaRel(blob, length, opts) {
    if (opts.biff < 8)
      return parse_RgceArea_BIFF2(blob);
    var r = blob.read_shift(opts.biff == 12 ? 4 : 2), R2 = blob.read_shift(opts.biff == 12 ? 4 : 2);
    var c2 = parse_ColRelU(blob, 2);
    var C2 = parse_ColRelU(blob, 2);
    return { s: { r, c: c2[0], cRel: c2[1], rRel: c2[2] }, e: { r: R2, c: C2[0], cRel: C2[1], rRel: C2[2] } };
  }
  function parse_RgceLoc(blob, length, opts) {
    if (opts && opts.biff >= 2 && opts.biff <= 5)
      return parse_RgceLoc_BIFF2(blob);
    var r = blob.read_shift(opts && opts.biff == 12 ? 4 : 2);
    var c2 = parse_ColRelU(blob, 2);
    return { r, c: c2[0], cRel: c2[1], rRel: c2[2] };
  }
  function parse_RgceLoc_BIFF2(blob) {
    var r = parse_ColRelU(blob, 2);
    var c2 = blob.read_shift(1);
    return { r: r[0], c: c2, cRel: r[1], rRel: r[2] };
  }
  function parse_RgceElfLoc(blob) {
    var r = blob.read_shift(2);
    var c2 = blob.read_shift(2);
    return { r, c: c2 & 255, fQuoted: !!(c2 & 16384), cRel: c2 >> 15, rRel: c2 >> 15 };
  }
  function parse_RgceLocRel(blob, length, opts) {
    var biff = opts && opts.biff ? opts.biff : 8;
    if (biff >= 2 && biff <= 5)
      return parse_RgceLocRel_BIFF2(blob);
    var r = blob.read_shift(biff >= 12 ? 4 : 2);
    var cl = blob.read_shift(2);
    var cRel = (cl & 16384) >> 14, rRel = (cl & 32768) >> 15;
    cl &= 16383;
    if (rRel == 1)
      while (r > 524287)
        r -= 1048576;
    if (cRel == 1)
      while (cl > 8191)
        cl = cl - 16384;
    return { r, c: cl, cRel, rRel };
  }
  function parse_RgceLocRel_BIFF2(blob) {
    var rl = blob.read_shift(2);
    var c2 = blob.read_shift(1);
    var rRel = (rl & 32768) >> 15, cRel = (rl & 16384) >> 14;
    rl &= 16383;
    if (rRel == 1 && rl >= 8192)
      rl = rl - 16384;
    if (cRel == 1 && c2 >= 128)
      c2 = c2 - 256;
    return { r: rl, c: c2, cRel, rRel };
  }
  function parse_PtgArea(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    var area = parse_RgceArea(blob, opts.biff >= 2 && opts.biff <= 5 ? 6 : 8, opts);
    return [type, area];
  }
  function parse_PtgArea3d(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    var ixti = blob.read_shift(2, "i");
    var w2 = 8;
    if (opts)
      switch (opts.biff) {
        case 5:
          blob.l += 12;
          w2 = 6;
          break;
        case 12:
          w2 = 12;
          break;
      }
    var area = parse_RgceArea(blob, w2, opts);
    return [type, ixti, area];
  }
  function parse_PtgAreaErr(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    blob.l += opts && opts.biff > 8 ? 12 : opts.biff < 8 ? 6 : 8;
    return [type];
  }
  function parse_PtgAreaErr3d(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    var ixti = blob.read_shift(2);
    var w2 = 8;
    if (opts)
      switch (opts.biff) {
        case 5:
          blob.l += 12;
          w2 = 6;
          break;
        case 12:
          w2 = 12;
          break;
      }
    blob.l += w2;
    return [type, ixti];
  }
  function parse_PtgAreaN(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    var area = parse_RgceAreaRel(blob, length - 1, opts);
    return [type, area];
  }
  function parse_PtgArray(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    blob.l += opts.biff == 2 ? 6 : opts.biff == 12 ? 14 : 7;
    return [type];
  }
  function parse_PtgAttrBaxcel(blob) {
    var bitSemi = blob[blob.l + 1] & 1;
    var bitBaxcel = 1;
    blob.l += 4;
    return [bitSemi, bitBaxcel];
  }
  function parse_PtgAttrChoose(blob, length, opts) {
    blob.l += 2;
    var offset = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    var o2 = [];
    for (var i = 0; i <= offset; ++i)
      o2.push(blob.read_shift(opts && opts.biff == 2 ? 1 : 2));
    return o2;
  }
  function parse_PtgAttrGoto(blob, length, opts) {
    var bitGoto = blob[blob.l + 1] & 255 ? 1 : 0;
    blob.l += 2;
    return [bitGoto, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];
  }
  function parse_PtgAttrIf(blob, length, opts) {
    var bitIf = blob[blob.l + 1] & 255 ? 1 : 0;
    blob.l += 2;
    return [bitIf, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];
  }
  function parse_PtgAttrIfError(blob) {
    var bitIf = blob[blob.l + 1] & 255 ? 1 : 0;
    blob.l += 2;
    return [bitIf, blob.read_shift(2)];
  }
  function parse_PtgAttrSemi(blob, length, opts) {
    var bitSemi = blob[blob.l + 1] & 255 ? 1 : 0;
    blob.l += opts && opts.biff == 2 ? 3 : 4;
    return [bitSemi];
  }
  function parse_PtgAttrSpaceType(blob) {
    var type = blob.read_shift(1), cch = blob.read_shift(1);
    return [type, cch];
  }
  function parse_PtgAttrSpace(blob) {
    blob.read_shift(2);
    return parse_PtgAttrSpaceType(blob);
  }
  function parse_PtgAttrSpaceSemi(blob) {
    blob.read_shift(2);
    return parse_PtgAttrSpaceType(blob);
  }
  function parse_PtgRef(blob, length, opts) {
    var type = (blob[blob.l] & 96) >> 5;
    blob.l += 1;
    var loc = parse_RgceLoc(blob, 0, opts);
    return [type, loc];
  }
  function parse_PtgRefN(blob, length, opts) {
    var type = (blob[blob.l] & 96) >> 5;
    blob.l += 1;
    var loc = parse_RgceLocRel(blob, 0, opts);
    return [type, loc];
  }
  function parse_PtgRef3d(blob, length, opts) {
    var type = (blob[blob.l] & 96) >> 5;
    blob.l += 1;
    var ixti = blob.read_shift(2);
    if (opts && opts.biff == 5)
      blob.l += 12;
    var loc = parse_RgceLoc(blob, 0, opts);
    return [type, ixti, loc];
  }
  function parse_PtgFunc(blob, length, opts) {
    var type = (blob[blob.l] & 96) >> 5;
    blob.l += 1;
    var iftab = blob.read_shift(opts && opts.biff <= 3 ? 1 : 2);
    return [FtabArgc[iftab], Ftab[iftab], type];
  }
  function parse_PtgFuncVar(blob, length, opts) {
    var type = blob[blob.l++];
    var cparams = blob.read_shift(1), tab = opts && opts.biff <= 3 ? [type == 88 ? -1 : 0, blob.read_shift(1)] : parsetab(blob);
    return [cparams, (tab[0] === 0 ? Ftab : Cetab)[tab[1]]];
  }
  function parsetab(blob) {
    return [blob[blob.l + 1] >> 7, blob.read_shift(2) & 32767];
  }
  function parse_PtgAttrSum(blob, length, opts) {
    blob.l += opts && opts.biff == 2 ? 3 : 4;
    return;
  }
  function parse_PtgExp(blob, length, opts) {
    blob.l++;
    if (opts && opts.biff == 12)
      return [blob.read_shift(4, "i"), 0];
    var row = blob.read_shift(2);
    var col = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    return [row, col];
  }
  function parse_PtgErr(blob) {
    blob.l++;
    return BErr[blob.read_shift(1)];
  }
  function parse_PtgInt(blob) {
    blob.l++;
    return blob.read_shift(2);
  }
  function parse_PtgBool(blob) {
    blob.l++;
    return blob.read_shift(1) !== 0;
  }
  function parse_PtgNum(blob) {
    blob.l++;
    return parse_Xnum(blob);
  }
  function parse_PtgStr(blob, length, opts) {
    blob.l++;
    return parse_ShortXLUnicodeString(blob, length - 1, opts);
  }
  function parse_SerAr(blob, biff) {
    var val = [blob.read_shift(1)];
    if (biff == 12)
      switch (val[0]) {
        case 2:
          val[0] = 4;
          break;
        case 4:
          val[0] = 16;
          break;
        case 0:
          val[0] = 1;
          break;
        case 1:
          val[0] = 2;
          break;
      }
    switch (val[0]) {
      case 4:
        val[1] = parsebool(blob, 1) ? "TRUE" : "FALSE";
        if (biff != 12)
          blob.l += 7;
        break;
      case 37:
      case 16:
        val[1] = BErr[blob[blob.l]];
        blob.l += biff == 12 ? 4 : 8;
        break;
      case 0:
        blob.l += 8;
        break;
      case 1:
        val[1] = parse_Xnum(blob);
        break;
      case 2:
        val[1] = parse_XLUnicodeString2(blob, 0, { biff: biff > 0 && biff < 8 ? 2 : biff });
        break;
      default:
        throw new Error("Bad SerAr: " + val[0]);
    }
    return val;
  }
  function parse_PtgExtraMem(blob, cce, opts) {
    var count = blob.read_shift(opts.biff == 12 ? 4 : 2);
    var out = [];
    for (var i = 0; i != count; ++i)
      out.push((opts.biff == 12 ? parse_UncheckedRfX : parse_Ref8U)(blob));
    return out;
  }
  function parse_PtgExtraArray(blob, length, opts) {
    var rows = 0, cols = 0;
    if (opts.biff == 12) {
      rows = blob.read_shift(4);
      cols = blob.read_shift(4);
    } else {
      cols = 1 + blob.read_shift(1);
      rows = 1 + blob.read_shift(2);
    }
    if (opts.biff >= 2 && opts.biff < 8) {
      --rows;
      if (--cols == 0)
        cols = 256;
    }
    for (var i = 0, o2 = []; i != rows && (o2[i] = []); ++i)
      for (var j = 0; j != cols; ++j)
        o2[i][j] = parse_SerAr(blob, opts.biff);
    return o2;
  }
  function parse_PtgName(blob, length, opts) {
    var type = blob.read_shift(1) >>> 5 & 3;
    var w2 = !opts || opts.biff >= 8 ? 4 : 2;
    var nameindex = blob.read_shift(w2);
    switch (opts.biff) {
      case 2:
        blob.l += 5;
        break;
      case 3:
      case 4:
        blob.l += 8;
        break;
      case 5:
        blob.l += 12;
        break;
    }
    return [type, 0, nameindex];
  }
  function parse_PtgNameX(blob, length, opts) {
    if (opts.biff == 5)
      return parse_PtgNameX_BIFF5(blob);
    var type = blob.read_shift(1) >>> 5 & 3;
    var ixti = blob.read_shift(2);
    var nameindex = blob.read_shift(4);
    return [type, ixti, nameindex];
  }
  function parse_PtgNameX_BIFF5(blob) {
    var type = blob.read_shift(1) >>> 5 & 3;
    var ixti = blob.read_shift(2, "i");
    blob.l += 8;
    var nameindex = blob.read_shift(2);
    blob.l += 12;
    return [type, ixti, nameindex];
  }
  function parse_PtgMemArea(blob, length, opts) {
    var type = blob.read_shift(1) >>> 5 & 3;
    blob.l += opts && opts.biff == 2 ? 3 : 4;
    var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    return [type, cce];
  }
  function parse_PtgMemFunc(blob, length, opts) {
    var type = blob.read_shift(1) >>> 5 & 3;
    var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
    return [type, cce];
  }
  function parse_PtgRefErr(blob, length, opts) {
    var type = blob.read_shift(1) >>> 5 & 3;
    blob.l += 4;
    if (opts.biff < 8)
      blob.l--;
    if (opts.biff == 12)
      blob.l += 2;
    return [type];
  }
  function parse_PtgRefErr3d(blob, length, opts) {
    var type = (blob[blob.l++] & 96) >> 5;
    var ixti = blob.read_shift(2);
    var w2 = 4;
    if (opts)
      switch (opts.biff) {
        case 5:
          w2 = 15;
          break;
        case 12:
          w2 = 6;
          break;
      }
    blob.l += w2;
    return [type, ixti];
  }
  var parse_PtgMemErr = parsenoop;
  var parse_PtgMemNoMem = parsenoop;
  var parse_PtgTbl = parsenoop;
  function parse_PtgElfLoc(blob, length, opts) {
    blob.l += 2;
    return [parse_RgceElfLoc(blob)];
  }
  function parse_PtgElfNoop(blob) {
    blob.l += 6;
    return [];
  }
  var parse_PtgElfCol = parse_PtgElfLoc;
  var parse_PtgElfColS = parse_PtgElfNoop;
  var parse_PtgElfColSV = parse_PtgElfNoop;
  var parse_PtgElfColV = parse_PtgElfLoc;
  function parse_PtgElfLel(blob) {
    blob.l += 2;
    return [parseuint16(blob), blob.read_shift(2) & 1];
  }
  var parse_PtgElfRadical = parse_PtgElfLoc;
  var parse_PtgElfRadicalLel = parse_PtgElfLel;
  var parse_PtgElfRadicalS = parse_PtgElfNoop;
  var parse_PtgElfRw = parse_PtgElfLoc;
  var parse_PtgElfRwV = parse_PtgElfLoc;
  var PtgListRT = [
    "Data",
    "All",
    "Headers",
    "??",
    "?Data2",
    "??",
    "?DataHeaders",
    "??",
    "Totals",
    "??",
    "??",
    "??",
    "?DataTotals",
    "??",
    "??",
    "??",
    "?Current"
  ];
  function parse_PtgList(blob) {
    blob.l += 2;
    var ixti = blob.read_shift(2);
    var flags = blob.read_shift(2);
    var idx = blob.read_shift(4);
    var c2 = blob.read_shift(2);
    var C2 = blob.read_shift(2);
    var rt2 = PtgListRT[flags >> 2 & 31];
    return { ixti, coltype: flags & 3, rt: rt2, idx, c: c2, C: C2 };
  }
  function parse_PtgSxName(blob) {
    blob.l += 2;
    return [blob.read_shift(4)];
  }
  function parse_PtgSheet(blob, length, opts) {
    blob.l += 5;
    blob.l += 2;
    blob.l += opts.biff == 2 ? 1 : 4;
    return ["PTGSHEET"];
  }
  function parse_PtgEndSheet(blob, length, opts) {
    blob.l += opts.biff == 2 ? 4 : 5;
    return ["PTGENDSHEET"];
  }
  function parse_PtgMemAreaN(blob) {
    var type = blob.read_shift(1) >>> 5 & 3;
    var cce = blob.read_shift(2);
    return [type, cce];
  }
  function parse_PtgMemNoMemN(blob) {
    var type = blob.read_shift(1) >>> 5 & 3;
    var cce = blob.read_shift(2);
    return [type, cce];
  }
  function parse_PtgAttrNoop(blob) {
    blob.l += 4;
    return [0, 0];
  }
  var PtgTypes = {
    1: { n: "PtgExp", f: parse_PtgExp },
    2: { n: "PtgTbl", f: parse_PtgTbl },
    3: { n: "PtgAdd", f: parseread1 },
    4: { n: "PtgSub", f: parseread1 },
    5: { n: "PtgMul", f: parseread1 },
    6: { n: "PtgDiv", f: parseread1 },
    7: { n: "PtgPower", f: parseread1 },
    8: { n: "PtgConcat", f: parseread1 },
    9: { n: "PtgLt", f: parseread1 },
    10: { n: "PtgLe", f: parseread1 },
    11: { n: "PtgEq", f: parseread1 },
    12: { n: "PtgGe", f: parseread1 },
    13: { n: "PtgGt", f: parseread1 },
    14: { n: "PtgNe", f: parseread1 },
    15: { n: "PtgIsect", f: parseread1 },
    16: { n: "PtgUnion", f: parseread1 },
    17: { n: "PtgRange", f: parseread1 },
    18: { n: "PtgUplus", f: parseread1 },
    19: { n: "PtgUminus", f: parseread1 },
    20: { n: "PtgPercent", f: parseread1 },
    21: { n: "PtgParen", f: parseread1 },
    22: { n: "PtgMissArg", f: parseread1 },
    23: { n: "PtgStr", f: parse_PtgStr },
    26: { n: "PtgSheet", f: parse_PtgSheet },
    27: { n: "PtgEndSheet", f: parse_PtgEndSheet },
    28: { n: "PtgErr", f: parse_PtgErr },
    29: { n: "PtgBool", f: parse_PtgBool },
    30: { n: "PtgInt", f: parse_PtgInt },
    31: { n: "PtgNum", f: parse_PtgNum },
    32: { n: "PtgArray", f: parse_PtgArray },
    33: { n: "PtgFunc", f: parse_PtgFunc },
    34: { n: "PtgFuncVar", f: parse_PtgFuncVar },
    35: { n: "PtgName", f: parse_PtgName },
    36: { n: "PtgRef", f: parse_PtgRef },
    37: { n: "PtgArea", f: parse_PtgArea },
    38: { n: "PtgMemArea", f: parse_PtgMemArea },
    39: { n: "PtgMemErr", f: parse_PtgMemErr },
    40: { n: "PtgMemNoMem", f: parse_PtgMemNoMem },
    41: { n: "PtgMemFunc", f: parse_PtgMemFunc },
    42: { n: "PtgRefErr", f: parse_PtgRefErr },
    43: { n: "PtgAreaErr", f: parse_PtgAreaErr },
    44: { n: "PtgRefN", f: parse_PtgRefN },
    45: { n: "PtgAreaN", f: parse_PtgAreaN },
    46: { n: "PtgMemAreaN", f: parse_PtgMemAreaN },
    47: { n: "PtgMemNoMemN", f: parse_PtgMemNoMemN },
    57: { n: "PtgNameX", f: parse_PtgNameX },
    58: { n: "PtgRef3d", f: parse_PtgRef3d },
    59: { n: "PtgArea3d", f: parse_PtgArea3d },
    60: { n: "PtgRefErr3d", f: parse_PtgRefErr3d },
    61: { n: "PtgAreaErr3d", f: parse_PtgAreaErr3d },
    255: {}
  };
  var PtgDupes = {
    64: 32,
    96: 32,
    65: 33,
    97: 33,
    66: 34,
    98: 34,
    67: 35,
    99: 35,
    68: 36,
    100: 36,
    69: 37,
    101: 37,
    70: 38,
    102: 38,
    71: 39,
    103: 39,
    72: 40,
    104: 40,
    73: 41,
    105: 41,
    74: 42,
    106: 42,
    75: 43,
    107: 43,
    76: 44,
    108: 44,
    77: 45,
    109: 45,
    78: 46,
    110: 46,
    79: 47,
    111: 47,
    88: 34,
    120: 34,
    89: 57,
    121: 57,
    90: 58,
    122: 58,
    91: 59,
    123: 59,
    92: 60,
    124: 60,
    93: 61,
    125: 61
  };
  var Ptg18 = {
    1: { n: "PtgElfLel", f: parse_PtgElfLel },
    2: { n: "PtgElfRw", f: parse_PtgElfRw },
    3: { n: "PtgElfCol", f: parse_PtgElfCol },
    6: { n: "PtgElfRwV", f: parse_PtgElfRwV },
    7: { n: "PtgElfColV", f: parse_PtgElfColV },
    10: { n: "PtgElfRadical", f: parse_PtgElfRadical },
    11: { n: "PtgElfRadicalS", f: parse_PtgElfRadicalS },
    13: { n: "PtgElfColS", f: parse_PtgElfColS },
    15: { n: "PtgElfColSV", f: parse_PtgElfColSV },
    16: { n: "PtgElfRadicalLel", f: parse_PtgElfRadicalLel },
    25: { n: "PtgList", f: parse_PtgList },
    29: { n: "PtgSxName", f: parse_PtgSxName },
    255: {}
  };
  var Ptg19 = {
    0: { n: "PtgAttrNoop", f: parse_PtgAttrNoop },
    1: { n: "PtgAttrSemi", f: parse_PtgAttrSemi },
    2: { n: "PtgAttrIf", f: parse_PtgAttrIf },
    4: { n: "PtgAttrChoose", f: parse_PtgAttrChoose },
    8: { n: "PtgAttrGoto", f: parse_PtgAttrGoto },
    16: { n: "PtgAttrSum", f: parse_PtgAttrSum },
    32: { n: "PtgAttrBaxcel", f: parse_PtgAttrBaxcel },
    33: { n: "PtgAttrBaxcel", f: parse_PtgAttrBaxcel },
    64: { n: "PtgAttrSpace", f: parse_PtgAttrSpace },
    65: { n: "PtgAttrSpaceSemi", f: parse_PtgAttrSpaceSemi },
    128: { n: "PtgAttrIfError", f: parse_PtgAttrIfError },
    255: {}
  };
  function parse_RgbExtra(blob, length, rgce, opts) {
    if (opts.biff < 8)
      return parsenoop(blob, length);
    var target = blob.l + length;
    var o2 = [];
    for (var i = 0; i !== rgce.length; ++i) {
      switch (rgce[i][0]) {
        case "PtgArray":
          rgce[i][1] = parse_PtgExtraArray(blob, 0, opts);
          o2.push(rgce[i][1]);
          break;
        case "PtgMemArea":
          rgce[i][2] = parse_PtgExtraMem(blob, rgce[i][1], opts);
          o2.push(rgce[i][2]);
          break;
        case "PtgExp":
          if (opts && opts.biff == 12) {
            rgce[i][1][1] = blob.read_shift(4);
            o2.push(rgce[i][1]);
          }
          break;
        case "PtgList":
        case "PtgElfRadicalS":
        case "PtgElfColS":
        case "PtgElfColSV":
          throw "Unsupported " + rgce[i][0];
      }
    }
    length = target - blob.l;
    if (length !== 0)
      o2.push(parsenoop(blob, length));
    return o2;
  }
  function parse_Rgce(blob, length, opts) {
    var target = blob.l + length;
    var R2, id, ptgs = [];
    while (target != blob.l) {
      length = target - blob.l;
      id = blob[blob.l];
      R2 = PtgTypes[id] || PtgTypes[PtgDupes[id]];
      if (id === 24 || id === 25)
        R2 = (id === 24 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
      if (!R2 || !R2.f) {
        parsenoop(blob, length);
      } else {
        ptgs.push([R2.n, R2.f(blob, length, opts)]);
      }
    }
    return ptgs;
  }
  function stringify_array(f2) {
    var o2 = [];
    for (var i = 0; i < f2.length; ++i) {
      var x2 = f2[i], r = [];
      for (var j = 0; j < x2.length; ++j) {
        var y = x2[j];
        if (y)
          switch (y[0]) {
            case 2:
              r.push('"' + y[1].replace(/"/g, '""') + '"');
              break;
            default:
              r.push(y[1]);
          }
        else
          r.push("");
      }
      o2.push(r.join(","));
    }
    return o2.join(";");
  }
  var PtgBinOp = {
    PtgAdd: "+",
    PtgConcat: "&",
    PtgDiv: "/",
    PtgEq: "=",
    PtgGe: ">=",
    PtgGt: ">",
    PtgLe: "<=",
    PtgLt: "<",
    PtgMul: "*",
    PtgNe: "<>",
    PtgPower: "^",
    PtgSub: "-"
  };
  function formula_quote_sheet_name(sname, opts) {
    if (!sname && !(opts && opts.biff <= 5 && opts.biff >= 2))
      throw new Error("empty sheet name");
    if (/[^\w\u4E00-\u9FFF\u3040-\u30FF]/.test(sname))
      return "'" + sname + "'";
    return sname;
  }
  function get_ixti_raw(supbooks, ixti, opts) {
    if (!supbooks)
      return "SH33TJSERR0";
    if (opts.biff > 8 && (!supbooks.XTI || !supbooks.XTI[ixti]))
      return supbooks.SheetNames[ixti];
    if (!supbooks.XTI)
      return "SH33TJSERR6";
    var XTI = supbooks.XTI[ixti];
    if (opts.biff < 8) {
      if (ixti > 1e4)
        ixti -= 65536;
      if (ixti < 0)
        ixti = -ixti;
      return ixti == 0 ? "" : supbooks.XTI[ixti - 1];
    }
    if (!XTI)
      return "SH33TJSERR1";
    var o2 = "";
    if (opts.biff > 8)
      switch (supbooks[XTI[0]][0]) {
        case 357:
          o2 = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]];
          return XTI[1] == XTI[2] ? o2 : o2 + ":" + supbooks.SheetNames[XTI[2]];
        case 358:
          if (opts.SID != null)
            return supbooks.SheetNames[opts.SID];
          return "SH33TJSSAME" + supbooks[XTI[0]][0];
        case 355:
        default:
          return "SH33TJSSRC" + supbooks[XTI[0]][0];
      }
    switch (supbooks[XTI[0]][0][0]) {
      case 1025:
        o2 = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]] || "SH33TJSERR3";
        return XTI[1] == XTI[2] ? o2 : o2 + ":" + supbooks.SheetNames[XTI[2]];
      case 14849:
        return supbooks[XTI[0]].slice(1).map(function(name) {
          return name.Name;
        }).join(";;");
      default:
        if (!supbooks[XTI[0]][0][3])
          return "SH33TJSERR2";
        o2 = XTI[1] == -1 ? "#REF" : supbooks[XTI[0]][0][3][XTI[1]] || "SH33TJSERR4";
        return XTI[1] == XTI[2] ? o2 : o2 + ":" + supbooks[XTI[0]][0][3][XTI[2]];
    }
  }
  function get_ixti(supbooks, ixti, opts) {
    var ixtiraw = get_ixti_raw(supbooks, ixti, opts);
    return ixtiraw == "#REF" ? ixtiraw : formula_quote_sheet_name(ixtiraw, opts);
  }
  function stringify_formula(formula, range, cell, supbooks, opts) {
    var biff = opts && opts.biff || 8;
    var _range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } };
    var stack2 = [], e1, e2, c2, ixti = 0, nameidx = 0, r, sname = "";
    if (!formula[0] || !formula[0][0])
      return "";
    var last_sp = -1, sp = "";
    for (var ff = 0, fflen = formula[0].length; ff < fflen; ++ff) {
      var f2 = formula[0][ff];
      switch (f2[0]) {
        case "PtgUminus":
          stack2.push("-" + stack2.pop());
          break;
        case "PtgUplus":
          stack2.push("+" + stack2.pop());
          break;
        case "PtgPercent":
          stack2.push(stack2.pop() + "%");
          break;
        case "PtgAdd":
        case "PtgConcat":
        case "PtgDiv":
        case "PtgEq":
        case "PtgGe":
        case "PtgGt":
        case "PtgLe":
        case "PtgLt":
        case "PtgMul":
        case "PtgNe":
        case "PtgPower":
        case "PtgSub":
          e1 = stack2.pop();
          e2 = stack2.pop();
          if (last_sp >= 0) {
            switch (formula[0][last_sp][1][0]) {
              case 0:
                sp = fill(" ", formula[0][last_sp][1][1]);
                break;
              case 1:
                sp = fill("\r", formula[0][last_sp][1][1]);
                break;
              default:
                sp = "";
                if (opts.WTF)
                  throw new Error("Unexpected PtgAttrSpaceType " + formula[0][last_sp][1][0]);
            }
            e2 = e2 + sp;
            last_sp = -1;
          }
          stack2.push(e2 + PtgBinOp[f2[0]] + e1);
          break;
        case "PtgIsect":
          e1 = stack2.pop();
          e2 = stack2.pop();
          stack2.push(e2 + " " + e1);
          break;
        case "PtgUnion":
          e1 = stack2.pop();
          e2 = stack2.pop();
          stack2.push(e2 + "," + e1);
          break;
        case "PtgRange":
          e1 = stack2.pop();
          e2 = stack2.pop();
          stack2.push(e2 + ":" + e1);
          break;
        case "PtgAttrChoose":
          break;
        case "PtgAttrGoto":
          break;
        case "PtgAttrIf":
          break;
        case "PtgAttrIfError":
          break;
        case "PtgRef":
          c2 = shift_cell_xls(f2[1][1], _range, opts);
          stack2.push(encode_cell_xls(c2, biff));
          break;
        case "PtgRefN":
          c2 = cell ? shift_cell_xls(f2[1][1], cell, opts) : f2[1][1];
          stack2.push(encode_cell_xls(c2, biff));
          break;
        case "PtgRef3d":
          ixti = f2[1][1];
          c2 = shift_cell_xls(f2[1][2], _range, opts);
          sname = get_ixti(supbooks, ixti, opts);
          stack2.push(sname + "!" + encode_cell_xls(c2, biff));
          break;
        case "PtgFunc":
        case "PtgFuncVar":
          var argc = f2[1][0], func = f2[1][1];
          if (!argc)
            argc = 0;
          argc &= 127;
          var args = argc == 0 ? [] : stack2.slice(-argc);
          stack2.length -= argc;
          if (func === "User")
            func = args.shift();
          stack2.push(func + "(" + args.join(",") + ")");
          break;
        case "PtgBool":
          stack2.push(f2[1] ? "TRUE" : "FALSE");
          break;
        case "PtgInt":
          stack2.push(f2[1]);
          break;
        case "PtgNum":
          stack2.push(String(f2[1]));
          break;
        case "PtgStr":
          stack2.push('"' + f2[1].replace(/"/g, '""') + '"');
          break;
        case "PtgErr":
          stack2.push(f2[1]);
          break;
        case "PtgAreaN":
          r = shift_range_xls(f2[1][1], cell ? { s: cell } : _range, opts);
          stack2.push(encode_range_xls(r, opts));
          break;
        case "PtgArea":
          r = shift_range_xls(f2[1][1], _range, opts);
          stack2.push(encode_range_xls(r, opts));
          break;
        case "PtgArea3d":
          ixti = f2[1][1];
          r = f2[1][2];
          sname = get_ixti(supbooks, ixti, opts);
          stack2.push(sname + "!" + encode_range_xls(r, opts));
          break;
        case "PtgAttrSum":
          stack2.push("SUM(" + stack2.pop() + ")");
          break;
        case "PtgAttrBaxcel":
        case "PtgAttrSemi":
          break;
        case "PtgName":
          nameidx = f2[1][2];
          var lbl = (supbooks.names || [])[nameidx - 1] || (supbooks[0] || [])[nameidx];
          var name = lbl ? lbl.Name : "SH33TJSNAME" + String(nameidx);
          if (name && name.slice(0, 6) == "_xlfn." && !opts.xlfn)
            name = name.slice(6);
          stack2.push(name);
          break;
        case "PtgNameX":
          var bookidx = f2[1][1];
          nameidx = f2[1][2];
          var externbook;
          if (opts.biff <= 5) {
            if (bookidx < 0)
              bookidx = -bookidx;
            if (supbooks[bookidx])
              externbook = supbooks[bookidx][nameidx];
          } else {
            var o2 = "";
            if (((supbooks[bookidx] || [])[0] || [])[0] == 14849)
              ;
            else if (((supbooks[bookidx] || [])[0] || [])[0] == 1025) {
              if (supbooks[bookidx][nameidx] && supbooks[bookidx][nameidx].itab > 0) {
                o2 = supbooks.SheetNames[supbooks[bookidx][nameidx].itab - 1] + "!";
              }
            } else
              o2 = supbooks.SheetNames[nameidx - 1] + "!";
            if (supbooks[bookidx] && supbooks[bookidx][nameidx])
              o2 += supbooks[bookidx][nameidx].Name;
            else if (supbooks[0] && supbooks[0][nameidx])
              o2 += supbooks[0][nameidx].Name;
            else {
              var ixtidata = (get_ixti_raw(supbooks, bookidx, opts) || "").split(";;");
              if (ixtidata[nameidx - 1])
                o2 = ixtidata[nameidx - 1];
              else
                o2 += "SH33TJSERRX";
            }
            stack2.push(o2);
            break;
          }
          if (!externbook)
            externbook = { Name: "SH33TJSERRY" };
          stack2.push(externbook.Name);
          break;
        case "PtgParen":
          var lp = "(", rp = ")";
          if (last_sp >= 0) {
            sp = "";
            switch (formula[0][last_sp][1][0]) {
              case 2:
                lp = fill(" ", formula[0][last_sp][1][1]) + lp;
                break;
              case 3:
                lp = fill("\r", formula[0][last_sp][1][1]) + lp;
                break;
              case 4:
                rp = fill(" ", formula[0][last_sp][1][1]) + rp;
                break;
              case 5:
                rp = fill("\r", formula[0][last_sp][1][1]) + rp;
                break;
              default:
                if (opts.WTF)
                  throw new Error("Unexpected PtgAttrSpaceType " + formula[0][last_sp][1][0]);
            }
            last_sp = -1;
          }
          stack2.push(lp + stack2.pop() + rp);
          break;
        case "PtgRefErr":
          stack2.push("#REF!");
          break;
        case "PtgRefErr3d":
          stack2.push("#REF!");
          break;
        case "PtgExp":
          c2 = { c: f2[1][1], r: f2[1][0] };
          var q2 = { c: cell.c, r: cell.r };
          if (supbooks.sharedf[encode_cell(c2)]) {
            var parsedf = supbooks.sharedf[encode_cell(c2)];
            stack2.push(stringify_formula(parsedf, _range, q2, supbooks, opts));
          } else {
            var fnd = false;
            for (e1 = 0; e1 != supbooks.arrayf.length; ++e1) {
              e2 = supbooks.arrayf[e1];
              if (c2.c < e2[0].s.c || c2.c > e2[0].e.c)
                continue;
              if (c2.r < e2[0].s.r || c2.r > e2[0].e.r)
                continue;
              stack2.push(stringify_formula(e2[1], _range, q2, supbooks, opts));
              fnd = true;
              break;
            }
            if (!fnd)
              stack2.push(f2[1]);
          }
          break;
        case "PtgArray":
          stack2.push("{" + stringify_array(f2[1]) + "}");
          break;
        case "PtgMemArea":
          break;
        case "PtgAttrSpace":
        case "PtgAttrSpaceSemi":
          last_sp = ff;
          break;
        case "PtgTbl":
          break;
        case "PtgMemErr":
          break;
        case "PtgMissArg":
          stack2.push("");
          break;
        case "PtgAreaErr":
          stack2.push("#REF!");
          break;
        case "PtgAreaErr3d":
          stack2.push("#REF!");
          break;
        case "PtgList":
          stack2.push("Table" + f2[1].idx + "[#" + f2[1].rt + "]");
          break;
        case "PtgMemAreaN":
        case "PtgMemNoMemN":
        case "PtgAttrNoop":
        case "PtgSheet":
        case "PtgEndSheet":
          break;
        case "PtgMemFunc":
          break;
        case "PtgMemNoMem":
          break;
        case "PtgElfCol":
        case "PtgElfColS":
        case "PtgElfColSV":
        case "PtgElfColV":
        case "PtgElfLel":
        case "PtgElfRadical":
        case "PtgElfRadicalLel":
        case "PtgElfRadicalS":
        case "PtgElfRw":
        case "PtgElfRwV":
          throw new Error("Unsupported ELFs");
        case "PtgSxName":
          throw new Error("Unrecognized Formula Token: " + String(f2));
        default:
          throw new Error("Unrecognized Formula Token: " + String(f2));
      }
      var PtgNonDisp = ["PtgAttrSpace", "PtgAttrSpaceSemi", "PtgAttrGoto"];
      if (opts.biff != 3) {
        if (last_sp >= 0 && PtgNonDisp.indexOf(formula[0][ff][0]) == -1) {
          f2 = formula[0][last_sp];
          var _left = true;
          switch (f2[1][0]) {
            case 4:
              _left = false;
            case 0:
              sp = fill(" ", f2[1][1]);
              break;
            case 5:
              _left = false;
            case 1:
              sp = fill("\r", f2[1][1]);
              break;
            default:
              sp = "";
              if (opts.WTF)
                throw new Error("Unexpected PtgAttrSpaceType " + f2[1][0]);
          }
          stack2.push((_left ? sp : "") + stack2.pop() + (_left ? "" : sp));
          last_sp = -1;
        }
      }
    }
    if (stack2.length > 1 && opts.WTF)
      throw new Error("bad formula stack");
    return stack2[0];
  }
  function parse_ArrayParsedFormula(blob, length, opts) {
    var target = blob.l + length, len = opts.biff == 2 ? 1 : 2;
    var rgcb, cce = blob.read_shift(len);
    if (cce == 65535)
      return [[], parsenoop(blob, length - 2)];
    var rgce = parse_Rgce(blob, cce, opts);
    if (length !== cce + len)
      rgcb = parse_RgbExtra(blob, length - cce - len, rgce, opts);
    blob.l = target;
    return [rgce, rgcb];
  }
  function parse_XLSCellParsedFormula(blob, length, opts) {
    var target = blob.l + length, len = opts.biff == 2 ? 1 : 2;
    var rgcb, cce = blob.read_shift(len);
    if (cce == 65535)
      return [[], parsenoop(blob, length - 2)];
    var rgce = parse_Rgce(blob, cce, opts);
    if (length !== cce + len)
      rgcb = parse_RgbExtra(blob, length - cce - len, rgce, opts);
    blob.l = target;
    return [rgce, rgcb];
  }
  function parse_NameParsedFormula(blob, length, opts, cce) {
    var target = blob.l + length;
    var rgce = parse_Rgce(blob, cce, opts);
    var rgcb;
    if (target !== blob.l)
      rgcb = parse_RgbExtra(blob, target - blob.l, rgce, opts);
    return [rgce, rgcb];
  }
  function parse_SharedParsedFormula(blob, length, opts) {
    var target = blob.l + length;
    var rgcb, cce = blob.read_shift(2);
    var rgce = parse_Rgce(blob, cce, opts);
    if (cce == 65535)
      return [[], parsenoop(blob, length - 2)];
    if (length !== cce + 2)
      rgcb = parse_RgbExtra(blob, target - cce - 2, rgce, opts);
    return [rgce, rgcb];
  }
  function parse_FormulaValue(blob) {
    var b2;
    if (__readUInt16LE(blob, blob.l + 6) !== 65535)
      return [parse_Xnum(blob), "n"];
    switch (blob[blob.l]) {
      case 0:
        blob.l += 8;
        return ["String", "s"];
      case 1:
        b2 = blob[blob.l + 2] === 1;
        blob.l += 8;
        return [b2, "b"];
      case 2:
        b2 = blob[blob.l + 2];
        blob.l += 8;
        return [b2, "e"];
      case 3:
        blob.l += 8;
        return ["", "s"];
    }
    return [];
  }
  function write_FormulaValue(value) {
    if (value == null) {
      var o2 = new_buf(8);
      o2.write_shift(1, 3);
      o2.write_shift(1, 0);
      o2.write_shift(2, 0);
      o2.write_shift(2, 0);
      o2.write_shift(2, 65535);
      return o2;
    } else if (typeof value == "number")
      return write_Xnum(value);
    return write_Xnum(0);
  }
  function parse_Formula(blob, length, opts) {
    var end = blob.l + length;
    var cell = parse_XLSCell(blob);
    if (opts.biff == 2)
      ++blob.l;
    var val = parse_FormulaValue(blob);
    var flags = blob.read_shift(1);
    if (opts.biff != 2) {
      blob.read_shift(1);
      if (opts.biff >= 5) {
        blob.read_shift(4);
      }
    }
    var cbf = parse_XLSCellParsedFormula(blob, end - blob.l, opts);
    return { cell, val: val[0], formula: cbf, shared: flags >> 3 & 1, tt: val[1] };
  }
  function write_Formula(cell, R2, C2, opts, os) {
    var o1 = write_XLSCell(R2, C2, os);
    var o2 = write_FormulaValue(cell.v);
    var o3 = new_buf(6);
    var flags = 1 | 32;
    o3.write_shift(2, flags);
    o3.write_shift(4, 0);
    var bf = new_buf(cell.bf.length);
    for (var i = 0; i < cell.bf.length; ++i)
      bf[i] = cell.bf[i];
    var out = bconcat([o1, o2, o3, bf]);
    return out;
  }
  function parse_XLSBParsedFormula(data, length, opts) {
    var cce = data.read_shift(4);
    var rgce = parse_Rgce(data, cce, opts);
    var cb = data.read_shift(4);
    var rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;
    return [rgce, rgcb];
  }
  var parse_XLSBArrayParsedFormula = parse_XLSBParsedFormula;
  var parse_XLSBCellParsedFormula = parse_XLSBParsedFormula;
  var parse_XLSBNameParsedFormula = parse_XLSBParsedFormula;
  var parse_XLSBSharedParsedFormula = parse_XLSBParsedFormula;
  var Cetab = {
    0: "BEEP",
    1: "OPEN",
    2: "OPEN.LINKS",
    3: "CLOSE.ALL",
    4: "SAVE",
    5: "SAVE.AS",
    6: "FILE.DELETE",
    7: "PAGE.SETUP",
    8: "PRINT",
    9: "PRINTER.SETUP",
    10: "QUIT",
    11: "NEW.WINDOW",
    12: "ARRANGE.ALL",
    13: "WINDOW.SIZE",
    14: "WINDOW.MOVE",
    15: "FULL",
    16: "CLOSE",
    17: "RUN",
    22: "SET.PRINT.AREA",
    23: "SET.PRINT.TITLES",
    24: "SET.PAGE.BREAK",
    25: "REMOVE.PAGE.BREAK",
    26: "FONT",
    27: "DISPLAY",
    28: "PROTECT.DOCUMENT",
    29: "PRECISION",
    30: "A1.R1C1",
    31: "CALCULATE.NOW",
    32: "CALCULATION",
    34: "DATA.FIND",
    35: "EXTRACT",
    36: "DATA.DELETE",
    37: "SET.DATABASE",
    38: "SET.CRITERIA",
    39: "SORT",
    40: "DATA.SERIES",
    41: "TABLE",
    42: "FORMAT.NUMBER",
    43: "ALIGNMENT",
    44: "STYLE",
    45: "BORDER",
    46: "CELL.PROTECTION",
    47: "COLUMN.WIDTH",
    48: "UNDO",
    49: "CUT",
    50: "COPY",
    51: "PASTE",
    52: "CLEAR",
    53: "PASTE.SPECIAL",
    54: "EDIT.DELETE",
    55: "INSERT",
    56: "FILL.RIGHT",
    57: "FILL.DOWN",
    61: "DEFINE.NAME",
    62: "CREATE.NAMES",
    63: "FORMULA.GOTO",
    64: "FORMULA.FIND",
    65: "SELECT.LAST.CELL",
    66: "SHOW.ACTIVE.CELL",
    67: "GALLERY.AREA",
    68: "GALLERY.BAR",
    69: "GALLERY.COLUMN",
    70: "GALLERY.LINE",
    71: "GALLERY.PIE",
    72: "GALLERY.SCATTER",
    73: "COMBINATION",
    74: "PREFERRED",
    75: "ADD.OVERLAY",
    76: "GRIDLINES",
    77: "SET.PREFERRED",
    78: "AXES",
    79: "LEGEND",
    80: "ATTACH.TEXT",
    81: "ADD.ARROW",
    82: "SELECT.CHART",
    83: "SELECT.PLOT.AREA",
    84: "PATTERNS",
    85: "MAIN.CHART",
    86: "OVERLAY",
    87: "SCALE",
    88: "FORMAT.LEGEND",
    89: "FORMAT.TEXT",
    90: "EDIT.REPEAT",
    91: "PARSE",
    92: "JUSTIFY",
    93: "HIDE",
    94: "UNHIDE",
    95: "WORKSPACE",
    96: "FORMULA",
    97: "FORMULA.FILL",
    98: "FORMULA.ARRAY",
    99: "DATA.FIND.NEXT",
    100: "DATA.FIND.PREV",
    101: "FORMULA.FIND.NEXT",
    102: "FORMULA.FIND.PREV",
    103: "ACTIVATE",
    104: "ACTIVATE.NEXT",
    105: "ACTIVATE.PREV",
    106: "UNLOCKED.NEXT",
    107: "UNLOCKED.PREV",
    108: "COPY.PICTURE",
    109: "SELECT",
    110: "DELETE.NAME",
    111: "DELETE.FORMAT",
    112: "VLINE",
    113: "HLINE",
    114: "VPAGE",
    115: "HPAGE",
    116: "VSCROLL",
    117: "HSCROLL",
    118: "ALERT",
    119: "NEW",
    120: "CANCEL.COPY",
    121: "SHOW.CLIPBOARD",
    122: "MESSAGE",
    124: "PASTE.LINK",
    125: "APP.ACTIVATE",
    126: "DELETE.ARROW",
    127: "ROW.HEIGHT",
    128: "FORMAT.MOVE",
    129: "FORMAT.SIZE",
    130: "FORMULA.REPLACE",
    131: "SEND.KEYS",
    132: "SELECT.SPECIAL",
    133: "APPLY.NAMES",
    134: "REPLACE.FONT",
    135: "FREEZE.PANES",
    136: "SHOW.INFO",
    137: "SPLIT",
    138: "ON.WINDOW",
    139: "ON.DATA",
    140: "DISABLE.INPUT",
    142: "OUTLINE",
    143: "LIST.NAMES",
    144: "FILE.CLOSE",
    145: "SAVE.WORKBOOK",
    146: "DATA.FORM",
    147: "COPY.CHART",
    148: "ON.TIME",
    149: "WAIT",
    150: "FORMAT.FONT",
    151: "FILL.UP",
    152: "FILL.LEFT",
    153: "DELETE.OVERLAY",
    155: "SHORT.MENUS",
    159: "SET.UPDATE.STATUS",
    161: "COLOR.PALETTE",
    162: "DELETE.STYLE",
    163: "WINDOW.RESTORE",
    164: "WINDOW.MAXIMIZE",
    166: "CHANGE.LINK",
    167: "CALCULATE.DOCUMENT",
    168: "ON.KEY",
    169: "APP.RESTORE",
    170: "APP.MOVE",
    171: "APP.SIZE",
    172: "APP.MINIMIZE",
    173: "APP.MAXIMIZE",
    174: "BRING.TO.FRONT",
    175: "SEND.TO.BACK",
    185: "MAIN.CHART.TYPE",
    186: "OVERLAY.CHART.TYPE",
    187: "SELECT.END",
    188: "OPEN.MAIL",
    189: "SEND.MAIL",
    190: "STANDARD.FONT",
    191: "CONSOLIDATE",
    192: "SORT.SPECIAL",
    193: "GALLERY.3D.AREA",
    194: "GALLERY.3D.COLUMN",
    195: "GALLERY.3D.LINE",
    196: "GALLERY.3D.PIE",
    197: "VIEW.3D",
    198: "GOAL.SEEK",
    199: "WORKGROUP",
    200: "FILL.GROUP",
    201: "UPDATE.LINK",
    202: "PROMOTE",
    203: "DEMOTE",
    204: "SHOW.DETAIL",
    206: "UNGROUP",
    207: "OBJECT.PROPERTIES",
    208: "SAVE.NEW.OBJECT",
    209: "SHARE",
    210: "SHARE.NAME",
    211: "DUPLICATE",
    212: "APPLY.STYLE",
    213: "ASSIGN.TO.OBJECT",
    214: "OBJECT.PROTECTION",
    215: "HIDE.OBJECT",
    216: "SET.EXTRACT",
    217: "CREATE.PUBLISHER",
    218: "SUBSCRIBE.TO",
    219: "ATTRIBUTES",
    220: "SHOW.TOOLBAR",
    222: "PRINT.PREVIEW",
    223: "EDIT.COLOR",
    224: "SHOW.LEVELS",
    225: "FORMAT.MAIN",
    226: "FORMAT.OVERLAY",
    227: "ON.RECALC",
    228: "EDIT.SERIES",
    229: "DEFINE.STYLE",
    240: "LINE.PRINT",
    243: "ENTER.DATA",
    249: "GALLERY.RADAR",
    250: "MERGE.STYLES",
    251: "EDITION.OPTIONS",
    252: "PASTE.PICTURE",
    253: "PASTE.PICTURE.LINK",
    254: "SPELLING",
    256: "ZOOM",
    259: "INSERT.OBJECT",
    260: "WINDOW.MINIMIZE",
    265: "SOUND.NOTE",
    266: "SOUND.PLAY",
    267: "FORMAT.SHAPE",
    268: "EXTEND.POLYGON",
    269: "FORMAT.AUTO",
    272: "GALLERY.3D.BAR",
    273: "GALLERY.3D.SURFACE",
    274: "FILL.AUTO",
    276: "CUSTOMIZE.TOOLBAR",
    277: "ADD.TOOL",
    278: "EDIT.OBJECT",
    279: "ON.DOUBLECLICK",
    280: "ON.ENTRY",
    281: "WORKBOOK.ADD",
    282: "WORKBOOK.MOVE",
    283: "WORKBOOK.COPY",
    284: "WORKBOOK.OPTIONS",
    285: "SAVE.WORKSPACE",
    288: "CHART.WIZARD",
    289: "DELETE.TOOL",
    290: "MOVE.TOOL",
    291: "WORKBOOK.SELECT",
    292: "WORKBOOK.ACTIVATE",
    293: "ASSIGN.TO.TOOL",
    295: "COPY.TOOL",
    296: "RESET.TOOL",
    297: "CONSTRAIN.NUMERIC",
    298: "PASTE.TOOL",
    302: "WORKBOOK.NEW",
    305: "SCENARIO.CELLS",
    306: "SCENARIO.DELETE",
    307: "SCENARIO.ADD",
    308: "SCENARIO.EDIT",
    309: "SCENARIO.SHOW",
    310: "SCENARIO.SHOW.NEXT",
    311: "SCENARIO.SUMMARY",
    312: "PIVOT.TABLE.WIZARD",
    313: "PIVOT.FIELD.PROPERTIES",
    314: "PIVOT.FIELD",
    315: "PIVOT.ITEM",
    316: "PIVOT.ADD.FIELDS",
    318: "OPTIONS.CALCULATION",
    319: "OPTIONS.EDIT",
    320: "OPTIONS.VIEW",
    321: "ADDIN.MANAGER",
    322: "MENU.EDITOR",
    323: "ATTACH.TOOLBARS",
    324: "VBAActivate",
    325: "OPTIONS.CHART",
    328: "VBA.INSERT.FILE",
    330: "VBA.PROCEDURE.DEFINITION",
    336: "ROUTING.SLIP",
    338: "ROUTE.DOCUMENT",
    339: "MAIL.LOGON",
    342: "INSERT.PICTURE",
    343: "EDIT.TOOL",
    344: "GALLERY.DOUGHNUT",
    350: "CHART.TREND",
    352: "PIVOT.ITEM.PROPERTIES",
    354: "WORKBOOK.INSERT",
    355: "OPTIONS.TRANSITION",
    356: "OPTIONS.GENERAL",
    370: "FILTER.ADVANCED",
    373: "MAIL.ADD.MAILER",
    374: "MAIL.DELETE.MAILER",
    375: "MAIL.REPLY",
    376: "MAIL.REPLY.ALL",
    377: "MAIL.FORWARD",
    378: "MAIL.NEXT.LETTER",
    379: "DATA.LABEL",
    380: "INSERT.TITLE",
    381: "FONT.PROPERTIES",
    382: "MACRO.OPTIONS",
    383: "WORKBOOK.HIDE",
    384: "WORKBOOK.UNHIDE",
    385: "WORKBOOK.DELETE",
    386: "WORKBOOK.NAME",
    388: "GALLERY.CUSTOM",
    390: "ADD.CHART.AUTOFORMAT",
    391: "DELETE.CHART.AUTOFORMAT",
    392: "CHART.ADD.DATA",
    393: "AUTO.OUTLINE",
    394: "TAB.ORDER",
    395: "SHOW.DIALOG",
    396: "SELECT.ALL",
    397: "UNGROUP.SHEETS",
    398: "SUBTOTAL.CREATE",
    399: "SUBTOTAL.REMOVE",
    400: "RENAME.OBJECT",
    412: "WORKBOOK.SCROLL",
    413: "WORKBOOK.NEXT",
    414: "WORKBOOK.PREV",
    415: "WORKBOOK.TAB.SPLIT",
    416: "FULL.SCREEN",
    417: "WORKBOOK.PROTECT",
    420: "SCROLLBAR.PROPERTIES",
    421: "PIVOT.SHOW.PAGES",
    422: "TEXT.TO.COLUMNS",
    423: "FORMAT.CHARTTYPE",
    424: "LINK.FORMAT",
    425: "TRACER.DISPLAY",
    430: "TRACER.NAVIGATE",
    431: "TRACER.CLEAR",
    432: "TRACER.ERROR",
    433: "PIVOT.FIELD.GROUP",
    434: "PIVOT.FIELD.UNGROUP",
    435: "CHECKBOX.PROPERTIES",
    436: "LABEL.PROPERTIES",
    437: "LISTBOX.PROPERTIES",
    438: "EDITBOX.PROPERTIES",
    439: "PIVOT.REFRESH",
    440: "LINK.COMBO",
    441: "OPEN.TEXT",
    442: "HIDE.DIALOG",
    443: "SET.DIALOG.FOCUS",
    444: "ENABLE.OBJECT",
    445: "PUSHBUTTON.PROPERTIES",
    446: "SET.DIALOG.DEFAULT",
    447: "FILTER",
    448: "FILTER.SHOW.ALL",
    449: "CLEAR.OUTLINE",
    450: "FUNCTION.WIZARD",
    451: "ADD.LIST.ITEM",
    452: "SET.LIST.ITEM",
    453: "REMOVE.LIST.ITEM",
    454: "SELECT.LIST.ITEM",
    455: "SET.CONTROL.VALUE",
    456: "SAVE.COPY.AS",
    458: "OPTIONS.LISTS.ADD",
    459: "OPTIONS.LISTS.DELETE",
    460: "SERIES.AXES",
    461: "SERIES.X",
    462: "SERIES.Y",
    463: "ERRORBAR.X",
    464: "ERRORBAR.Y",
    465: "FORMAT.CHART",
    466: "SERIES.ORDER",
    467: "MAIL.LOGOFF",
    468: "CLEAR.ROUTING.SLIP",
    469: "APP.ACTIVATE.MICROSOFT",
    470: "MAIL.EDIT.MAILER",
    471: "ON.SHEET",
    472: "STANDARD.WIDTH",
    473: "SCENARIO.MERGE",
    474: "SUMMARY.INFO",
    475: "FIND.FILE",
    476: "ACTIVE.CELL.FONT",
    477: "ENABLE.TIPWIZARD",
    478: "VBA.MAKE.ADDIN",
    480: "INSERTDATATABLE",
    481: "WORKGROUP.OPTIONS",
    482: "MAIL.SEND.MAILER",
    485: "AUTOCORRECT",
    489: "POST.DOCUMENT",
    491: "PICKLIST",
    493: "VIEW.SHOW",
    494: "VIEW.DEFINE",
    495: "VIEW.DELETE",
    509: "SHEET.BACKGROUND",
    510: "INSERT.MAP.OBJECT",
    511: "OPTIONS.MENONO",
    517: "MSOCHECKS",
    518: "NORMAL",
    519: "LAYOUT",
    520: "RM.PRINT.AREA",
    521: "CLEAR.PRINT.AREA",
    522: "ADD.PRINT.AREA",
    523: "MOVE.BRK",
    545: "HIDECURR.NOTE",
    546: "HIDEALL.NOTES",
    547: "DELETE.NOTE",
    548: "TRAVERSE.NOTES",
    549: "ACTIVATE.NOTES",
    620: "PROTECT.REVISIONS",
    621: "UNPROTECT.REVISIONS",
    647: "OPTIONS.ME",
    653: "WEB.PUBLISH",
    667: "NEWWEBQUERY",
    673: "PIVOT.TABLE.CHART",
    753: "OPTIONS.SAVE",
    755: "OPTIONS.SPELL",
    808: "HIDEALL.INKANNOTS"
  };
  var Ftab = {
    0: "COUNT",
    1: "IF",
    2: "ISNA",
    3: "ISERROR",
    4: "SUM",
    5: "AVERAGE",
    6: "MIN",
    7: "MAX",
    8: "ROW",
    9: "COLUMN",
    10: "NA",
    11: "NPV",
    12: "STDEV",
    13: "DOLLAR",
    14: "FIXED",
    15: "SIN",
    16: "COS",
    17: "TAN",
    18: "ATAN",
    19: "PI",
    20: "SQRT",
    21: "EXP",
    22: "LN",
    23: "LOG10",
    24: "ABS",
    25: "INT",
    26: "SIGN",
    27: "ROUND",
    28: "LOOKUP",
    29: "INDEX",
    30: "REPT",
    31: "MID",
    32: "LEN",
    33: "VALUE",
    34: "TRUE",
    35: "FALSE",
    36: "AND",
    37: "OR",
    38: "NOT",
    39: "MOD",
    40: "DCOUNT",
    41: "DSUM",
    42: "DAVERAGE",
    43: "DMIN",
    44: "DMAX",
    45: "DSTDEV",
    46: "VAR",
    47: "DVAR",
    48: "TEXT",
    49: "LINEST",
    50: "TREND",
    51: "LOGEST",
    52: "GROWTH",
    53: "GOTO",
    54: "HALT",
    55: "RETURN",
    56: "PV",
    57: "FV",
    58: "NPER",
    59: "PMT",
    60: "RATE",
    61: "MIRR",
    62: "IRR",
    63: "RAND",
    64: "MATCH",
    65: "DATE",
    66: "TIME",
    67: "DAY",
    68: "MONTH",
    69: "YEAR",
    70: "WEEKDAY",
    71: "HOUR",
    72: "MINUTE",
    73: "SECOND",
    74: "NOW",
    75: "AREAS",
    76: "ROWS",
    77: "COLUMNS",
    78: "OFFSET",
    79: "ABSREF",
    80: "RELREF",
    81: "ARGUMENT",
    82: "SEARCH",
    83: "TRANSPOSE",
    84: "ERROR",
    85: "STEP",
    86: "TYPE",
    87: "ECHO",
    88: "SET.NAME",
    89: "CALLER",
    90: "DEREF",
    91: "WINDOWS",
    92: "SERIES",
    93: "DOCUMENTS",
    94: "ACTIVE.CELL",
    95: "SELECTION",
    96: "RESULT",
    97: "ATAN2",
    98: "ASIN",
    99: "ACOS",
    100: "CHOOSE",
    101: "HLOOKUP",
    102: "VLOOKUP",
    103: "LINKS",
    104: "INPUT",
    105: "ISREF",
    106: "GET.FORMULA",
    107: "GET.NAME",
    108: "SET.VALUE",
    109: "LOG",
    110: "EXEC",
    111: "CHAR",
    112: "LOWER",
    113: "UPPER",
    114: "PROPER",
    115: "LEFT",
    116: "RIGHT",
    117: "EXACT",
    118: "TRIM",
    119: "REPLACE",
    120: "SUBSTITUTE",
    121: "CODE",
    122: "NAMES",
    123: "DIRECTORY",
    124: "FIND",
    125: "CELL",
    126: "ISERR",
    127: "ISTEXT",
    128: "ISNUMBER",
    129: "ISBLANK",
    130: "T",
    131: "N",
    132: "FOPEN",
    133: "FCLOSE",
    134: "FSIZE",
    135: "FREADLN",
    136: "FREAD",
    137: "FWRITELN",
    138: "FWRITE",
    139: "FPOS",
    140: "DATEVALUE",
    141: "TIMEVALUE",
    142: "SLN",
    143: "SYD",
    144: "DDB",
    145: "GET.DEF",
    146: "REFTEXT",
    147: "TEXTREF",
    148: "INDIRECT",
    149: "REGISTER",
    150: "CALL",
    151: "ADD.BAR",
    152: "ADD.MENU",
    153: "ADD.COMMAND",
    154: "ENABLE.COMMAND",
    155: "CHECK.COMMAND",
    156: "RENAME.COMMAND",
    157: "SHOW.BAR",
    158: "DELETE.MENU",
    159: "DELETE.COMMAND",
    160: "GET.CHART.ITEM",
    161: "DIALOG.BOX",
    162: "CLEAN",
    163: "MDETERM",
    164: "MINVERSE",
    165: "MMULT",
    166: "FILES",
    167: "IPMT",
    168: "PPMT",
    169: "COUNTA",
    170: "CANCEL.KEY",
    171: "FOR",
    172: "WHILE",
    173: "BREAK",
    174: "NEXT",
    175: "INITIATE",
    176: "REQUEST",
    177: "POKE",
    178: "EXECUTE",
    179: "TERMINATE",
    180: "RESTART",
    181: "HELP",
    182: "GET.BAR",
    183: "PRODUCT",
    184: "FACT",
    185: "GET.CELL",
    186: "GET.WORKSPACE",
    187: "GET.WINDOW",
    188: "GET.DOCUMENT",
    189: "DPRODUCT",
    190: "ISNONTEXT",
    191: "GET.NOTE",
    192: "NOTE",
    193: "STDEVP",
    194: "VARP",
    195: "DSTDEVP",
    196: "DVARP",
    197: "TRUNC",
    198: "ISLOGICAL",
    199: "DCOUNTA",
    200: "DELETE.BAR",
    201: "UNREGISTER",
    204: "USDOLLAR",
    205: "FINDB",
    206: "SEARCHB",
    207: "REPLACEB",
    208: "LEFTB",
    209: "RIGHTB",
    210: "MIDB",
    211: "LENB",
    212: "ROUNDUP",
    213: "ROUNDDOWN",
    214: "ASC",
    215: "DBCS",
    216: "RANK",
    219: "ADDRESS",
    220: "DAYS360",
    221: "TODAY",
    222: "VDB",
    223: "ELSE",
    224: "ELSE.IF",
    225: "END.IF",
    226: "FOR.CELL",
    227: "MEDIAN",
    228: "SUMPRODUCT",
    229: "SINH",
    230: "COSH",
    231: "TANH",
    232: "ASINH",
    233: "ACOSH",
    234: "ATANH",
    235: "DGET",
    236: "CREATE.OBJECT",
    237: "VOLATILE",
    238: "LAST.ERROR",
    239: "CUSTOM.UNDO",
    240: "CUSTOM.REPEAT",
    241: "FORMULA.CONVERT",
    242: "GET.LINK.INFO",
    243: "TEXT.BOX",
    244: "INFO",
    245: "GROUP",
    246: "GET.OBJECT",
    247: "DB",
    248: "PAUSE",
    251: "RESUME",
    252: "FREQUENCY",
    253: "ADD.TOOLBAR",
    254: "DELETE.TOOLBAR",
    255: "User",
    256: "RESET.TOOLBAR",
    257: "EVALUATE",
    258: "GET.TOOLBAR",
    259: "GET.TOOL",
    260: "SPELLING.CHECK",
    261: "ERROR.TYPE",
    262: "APP.TITLE",
    263: "WINDOW.TITLE",
    264: "SAVE.TOOLBAR",
    265: "ENABLE.TOOL",
    266: "PRESS.TOOL",
    267: "REGISTER.ID",
    268: "GET.WORKBOOK",
    269: "AVEDEV",
    270: "BETADIST",
    271: "GAMMALN",
    272: "BETAINV",
    273: "BINOMDIST",
    274: "CHIDIST",
    275: "CHIINV",
    276: "COMBIN",
    277: "CONFIDENCE",
    278: "CRITBINOM",
    279: "EVEN",
    280: "EXPONDIST",
    281: "FDIST",
    282: "FINV",
    283: "FISHER",
    284: "FISHERINV",
    285: "FLOOR",
    286: "GAMMADIST",
    287: "GAMMAINV",
    288: "CEILING",
    289: "HYPGEOMDIST",
    290: "LOGNORMDIST",
    291: "LOGINV",
    292: "NEGBINOMDIST",
    293: "NORMDIST",
    294: "NORMSDIST",
    295: "NORMINV",
    296: "NORMSINV",
    297: "STANDARDIZE",
    298: "ODD",
    299: "PERMUT",
    300: "POISSON",
    301: "TDIST",
    302: "WEIBULL",
    303: "SUMXMY2",
    304: "SUMX2MY2",
    305: "SUMX2PY2",
    306: "CHITEST",
    307: "CORREL",
    308: "COVAR",
    309: "FORECAST",
    310: "FTEST",
    311: "INTERCEPT",
    312: "PEARSON",
    313: "RSQ",
    314: "STEYX",
    315: "SLOPE",
    316: "TTEST",
    317: "PROB",
    318: "DEVSQ",
    319: "GEOMEAN",
    320: "HARMEAN",
    321: "SUMSQ",
    322: "KURT",
    323: "SKEW",
    324: "ZTEST",
    325: "LARGE",
    326: "SMALL",
    327: "QUARTILE",
    328: "PERCENTILE",
    329: "PERCENTRANK",
    330: "MODE",
    331: "TRIMMEAN",
    332: "TINV",
    334: "MOVIE.COMMAND",
    335: "GET.MOVIE",
    336: "CONCATENATE",
    337: "POWER",
    338: "PIVOT.ADD.DATA",
    339: "GET.PIVOT.TABLE",
    340: "GET.PIVOT.FIELD",
    341: "GET.PIVOT.ITEM",
    342: "RADIANS",
    343: "DEGREES",
    344: "SUBTOTAL",
    345: "SUMIF",
    346: "COUNTIF",
    347: "COUNTBLANK",
    348: "SCENARIO.GET",
    349: "OPTIONS.LISTS.GET",
    350: "ISPMT",
    351: "DATEDIF",
    352: "DATESTRING",
    353: "NUMBERSTRING",
    354: "ROMAN",
    355: "OPEN.DIALOG",
    356: "SAVE.DIALOG",
    357: "VIEW.GET",
    358: "GETPIVOTDATA",
    359: "HYPERLINK",
    360: "PHONETIC",
    361: "AVERAGEA",
    362: "MAXA",
    363: "MINA",
    364: "STDEVPA",
    365: "VARPA",
    366: "STDEVA",
    367: "VARA",
    368: "BAHTTEXT",
    369: "THAIDAYOFWEEK",
    370: "THAIDIGIT",
    371: "THAIMONTHOFYEAR",
    372: "THAINUMSOUND",
    373: "THAINUMSTRING",
    374: "THAISTRINGLENGTH",
    375: "ISTHAIDIGIT",
    376: "ROUNDBAHTDOWN",
    377: "ROUNDBAHTUP",
    378: "THAIYEAR",
    379: "RTD",
    380: "CUBEVALUE",
    381: "CUBEMEMBER",
    382: "CUBEMEMBERPROPERTY",
    383: "CUBERANKEDMEMBER",
    384: "HEX2BIN",
    385: "HEX2DEC",
    386: "HEX2OCT",
    387: "DEC2BIN",
    388: "DEC2HEX",
    389: "DEC2OCT",
    390: "OCT2BIN",
    391: "OCT2HEX",
    392: "OCT2DEC",
    393: "BIN2DEC",
    394: "BIN2OCT",
    395: "BIN2HEX",
    396: "IMSUB",
    397: "IMDIV",
    398: "IMPOWER",
    399: "IMABS",
    400: "IMSQRT",
    401: "IMLN",
    402: "IMLOG2",
    403: "IMLOG10",
    404: "IMSIN",
    405: "IMCOS",
    406: "IMEXP",
    407: "IMARGUMENT",
    408: "IMCONJUGATE",
    409: "IMAGINARY",
    410: "IMREAL",
    411: "COMPLEX",
    412: "IMSUM",
    413: "IMPRODUCT",
    414: "SERIESSUM",
    415: "FACTDOUBLE",
    416: "SQRTPI",
    417: "QUOTIENT",
    418: "DELTA",
    419: "GESTEP",
    420: "ISEVEN",
    421: "ISODD",
    422: "MROUND",
    423: "ERF",
    424: "ERFC",
    425: "BESSELJ",
    426: "BESSELK",
    427: "BESSELY",
    428: "BESSELI",
    429: "XIRR",
    430: "XNPV",
    431: "PRICEMAT",
    432: "YIELDMAT",
    433: "INTRATE",
    434: "RECEIVED",
    435: "DISC",
    436: "PRICEDISC",
    437: "YIELDDISC",
    438: "TBILLEQ",
    439: "TBILLPRICE",
    440: "TBILLYIELD",
    441: "PRICE",
    442: "YIELD",
    443: "DOLLARDE",
    444: "DOLLARFR",
    445: "NOMINAL",
    446: "EFFECT",
    447: "CUMPRINC",
    448: "CUMIPMT",
    449: "EDATE",
    450: "EOMONTH",
    451: "YEARFRAC",
    452: "COUPDAYBS",
    453: "COUPDAYS",
    454: "COUPDAYSNC",
    455: "COUPNCD",
    456: "COUPNUM",
    457: "COUPPCD",
    458: "DURATION",
    459: "MDURATION",
    460: "ODDLPRICE",
    461: "ODDLYIELD",
    462: "ODDFPRICE",
    463: "ODDFYIELD",
    464: "RANDBETWEEN",
    465: "WEEKNUM",
    466: "AMORDEGRC",
    467: "AMORLINC",
    468: "CONVERT",
    724: "SHEETJS",
    469: "ACCRINT",
    470: "ACCRINTM",
    471: "WORKDAY",
    472: "NETWORKDAYS",
    473: "GCD",
    474: "MULTINOMIAL",
    475: "LCM",
    476: "FVSCHEDULE",
    477: "CUBEKPIMEMBER",
    478: "CUBESET",
    479: "CUBESETCOUNT",
    480: "IFERROR",
    481: "COUNTIFS",
    482: "SUMIFS",
    483: "AVERAGEIF",
    484: "AVERAGEIFS"
  };
  var FtabArgc = {
    2: 1,
    3: 1,
    10: 0,
    15: 1,
    16: 1,
    17: 1,
    18: 1,
    19: 0,
    20: 1,
    21: 1,
    22: 1,
    23: 1,
    24: 1,
    25: 1,
    26: 1,
    27: 2,
    30: 2,
    31: 3,
    32: 1,
    33: 1,
    34: 0,
    35: 0,
    38: 1,
    39: 2,
    40: 3,
    41: 3,
    42: 3,
    43: 3,
    44: 3,
    45: 3,
    47: 3,
    48: 2,
    53: 1,
    61: 3,
    63: 0,
    65: 3,
    66: 3,
    67: 1,
    68: 1,
    69: 1,
    70: 1,
    71: 1,
    72: 1,
    73: 1,
    74: 0,
    75: 1,
    76: 1,
    77: 1,
    79: 2,
    80: 2,
    83: 1,
    85: 0,
    86: 1,
    89: 0,
    90: 1,
    94: 0,
    95: 0,
    97: 2,
    98: 1,
    99: 1,
    101: 3,
    102: 3,
    105: 1,
    106: 1,
    108: 2,
    111: 1,
    112: 1,
    113: 1,
    114: 1,
    117: 2,
    118: 1,
    119: 4,
    121: 1,
    126: 1,
    127: 1,
    128: 1,
    129: 1,
    130: 1,
    131: 1,
    133: 1,
    134: 1,
    135: 1,
    136: 2,
    137: 2,
    138: 2,
    140: 1,
    141: 1,
    142: 3,
    143: 4,
    144: 4,
    161: 1,
    162: 1,
    163: 1,
    164: 1,
    165: 2,
    172: 1,
    175: 2,
    176: 2,
    177: 3,
    178: 2,
    179: 1,
    184: 1,
    186: 1,
    189: 3,
    190: 1,
    195: 3,
    196: 3,
    197: 1,
    198: 1,
    199: 3,
    201: 1,
    207: 4,
    210: 3,
    211: 1,
    212: 2,
    213: 2,
    214: 1,
    215: 1,
    225: 0,
    229: 1,
    230: 1,
    231: 1,
    232: 1,
    233: 1,
    234: 1,
    235: 3,
    244: 1,
    247: 4,
    252: 2,
    257: 1,
    261: 1,
    271: 1,
    273: 4,
    274: 2,
    275: 2,
    276: 2,
    277: 3,
    278: 3,
    279: 1,
    280: 3,
    281: 3,
    282: 3,
    283: 1,
    284: 1,
    285: 2,
    286: 4,
    287: 3,
    288: 2,
    289: 4,
    290: 3,
    291: 3,
    292: 3,
    293: 4,
    294: 1,
    295: 3,
    296: 1,
    297: 3,
    298: 1,
    299: 2,
    300: 3,
    301: 3,
    302: 4,
    303: 2,
    304: 2,
    305: 2,
    306: 2,
    307: 2,
    308: 2,
    309: 3,
    310: 2,
    311: 2,
    312: 2,
    313: 2,
    314: 2,
    315: 2,
    316: 4,
    325: 2,
    326: 2,
    327: 2,
    328: 2,
    331: 2,
    332: 2,
    337: 2,
    342: 1,
    343: 1,
    346: 2,
    347: 1,
    350: 4,
    351: 3,
    352: 1,
    353: 2,
    360: 1,
    368: 1,
    369: 1,
    370: 1,
    371: 1,
    372: 1,
    373: 1,
    374: 1,
    375: 1,
    376: 1,
    377: 1,
    378: 1,
    382: 3,
    385: 1,
    392: 1,
    393: 1,
    396: 2,
    397: 2,
    398: 2,
    399: 1,
    400: 1,
    401: 1,
    402: 1,
    403: 1,
    404: 1,
    405: 1,
    406: 1,
    407: 1,
    408: 1,
    409: 1,
    410: 1,
    414: 4,
    415: 1,
    416: 1,
    417: 2,
    420: 1,
    421: 1,
    422: 2,
    424: 1,
    425: 2,
    426: 2,
    427: 2,
    428: 2,
    430: 3,
    438: 3,
    439: 3,
    440: 3,
    443: 2,
    444: 2,
    445: 2,
    446: 2,
    447: 6,
    448: 6,
    449: 2,
    450: 2,
    464: 2,
    468: 3,
    476: 2,
    479: 1,
    480: 2,
    65535: 0
  };
  function ods_to_csf_formula(f2) {
    if (f2.slice(0, 3) == "of:")
      f2 = f2.slice(3);
    if (f2.charCodeAt(0) == 61) {
      f2 = f2.slice(1);
      if (f2.charCodeAt(0) == 61)
        f2 = f2.slice(1);
    }
    f2 = f2.replace(/COM\.MICROSOFT\./g, "");
    f2 = f2.replace(/\[((?:\.[A-Z]+[0-9]+)(?::\.[A-Z]+[0-9]+)?)\]/g, function($$, $1) {
      return $1.replace(/\./g, "");
    });
    f2 = f2.replace(/\[.(#[A-Z]*[?!])\]/g, "$1");
    return f2.replace(/[;~]/g, ",").replace(/\|/g, ";");
  }
  function csf_to_ods_formula(f2) {
    var o2 = "of:=" + f2.replace(crefregex, "$1[.$2$3$4$5]").replace(/\]:\[/g, ":");
    return o2.replace(/;/g, "|").replace(/,/g, ";");
  }
  function ods_to_csf_3D(r) {
    var a2 = r.split(":");
    var s2 = a2[0].split(".")[0];
    return [s2, a2[0].split(".")[1] + (a2.length > 1 ? ":" + (a2[1].split(".")[1] || a2[1].split(".")[0]) : "")];
  }
  function csf_to_ods_3D(r) {
    return r.replace(/\./, "!");
  }
  var strs = {};
  var _ssfopts = {};
  var browser_has_Map = typeof Map !== "undefined";
  function get_sst_id(sst, str, rev) {
    var i = 0, len = sst.length;
    if (rev) {
      if (browser_has_Map ? rev.has(str) : Object.prototype.hasOwnProperty.call(rev, str)) {
        var revarr = browser_has_Map ? rev.get(str) : rev[str];
        for (; i < revarr.length; ++i) {
          if (sst[revarr[i]].t === str) {
            sst.Count++;
            return revarr[i];
          }
        }
      }
    } else
      for (; i < len; ++i) {
        if (sst[i].t === str) {
          sst.Count++;
          return i;
        }
      }
    sst[len] = { t: str };
    sst.Count++;
    sst.Unique++;
    if (rev) {
      if (browser_has_Map) {
        if (!rev.has(str))
          rev.set(str, []);
        rev.get(str).push(len);
      } else {
        if (!Object.prototype.hasOwnProperty.call(rev, str))
          rev[str] = [];
        rev[str].push(len);
      }
    }
    return len;
  }
  function col_obj_w(C2, col) {
    var p2 = { min: C2 + 1, max: C2 + 1 };
    var wch = -1;
    if (col.MDW)
      MDW = col.MDW;
    if (col.width != null)
      p2.customWidth = 1;
    else if (col.wpx != null)
      wch = px2char(col.wpx);
    else if (col.wch != null)
      wch = col.wch;
    if (wch > -1) {
      p2.width = char2width(wch);
      p2.customWidth = 1;
    } else if (col.width != null)
      p2.width = col.width;
    if (col.hidden)
      p2.hidden = true;
    if (col.level != null) {
      p2.outlineLevel = p2.level = col.level;
    }
    return p2;
  }
  function default_margins(margins, mode) {
    if (!margins)
      return;
    var defs = [0.7, 0.7, 0.75, 0.75, 0.3, 0.3];
    if (mode == "xlml")
      defs = [1, 1, 1, 1, 0.5, 0.5];
    if (margins.left == null)
      margins.left = defs[0];
    if (margins.right == null)
      margins.right = defs[1];
    if (margins.top == null)
      margins.top = defs[2];
    if (margins.bottom == null)
      margins.bottom = defs[3];
    if (margins.header == null)
      margins.header = defs[4];
    if (margins.footer == null)
      margins.footer = defs[5];
  }
  function get_cell_style(styles, cell, opts) {
    var z = opts.revssf[cell.z != null ? cell.z : "General"];
    var i = 60, len = styles.length;
    if (z == null && opts.ssf) {
      for (; i < 392; ++i)
        if (opts.ssf[i] == null) {
          SSF_load(cell.z, i);
          opts.ssf[i] = cell.z;
          opts.revssf[cell.z] = z = i;
          break;
        }
    }
    for (i = 0; i != len; ++i)
      if (styles[i].numFmtId === z)
        return i;
    styles[len] = {
      numFmtId: z,
      fontId: 0,
      fillId: 0,
      borderId: 0,
      xfId: 0,
      applyNumberFormat: 1
    };
    return len;
  }
  function safe_format(p2, fmtid, fillid, opts, themes, styles) {
    try {
      if (opts.cellNF)
        p2.z = table_fmt[fmtid];
    } catch (e) {
      if (opts.WTF)
        throw e;
    }
    if (p2.t === "z" && !opts.cellStyles)
      return;
    if (p2.t === "d" && typeof p2.v === "string")
      p2.v = parseDate(p2.v);
    if ((!opts || opts.cellText !== false) && p2.t !== "z")
      try {
        if (table_fmt[fmtid] == null)
          SSF_load(SSFImplicit[fmtid] || "General", fmtid);
        if (p2.t === "e")
          p2.w = p2.w || BErr[p2.v];
        else if (fmtid === 0) {
          if (p2.t === "n") {
            if ((p2.v | 0) === p2.v)
              p2.w = p2.v.toString(10);
            else
              p2.w = SSF_general_num(p2.v);
          } else if (p2.t === "d") {
            var dd = datenum(p2.v);
            if ((dd | 0) === dd)
              p2.w = dd.toString(10);
            else
              p2.w = SSF_general_num(dd);
          } else if (p2.v === void 0)
            return "";
          else
            p2.w = SSF_general(p2.v, _ssfopts);
        } else if (p2.t === "d")
          p2.w = SSF_format(fmtid, datenum(p2.v), _ssfopts);
        else
          p2.w = SSF_format(fmtid, p2.v, _ssfopts);
      } catch (e) {
        if (opts.WTF)
          throw e;
      }
    if (!opts.cellStyles)
      return;
    if (fillid != null)
      try {
        p2.s = styles.Fills[fillid];
        if (p2.s.fgColor && p2.s.fgColor.theme && !p2.s.fgColor.rgb) {
          p2.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p2.s.fgColor.theme].rgb, p2.s.fgColor.tint || 0);
          if (opts.WTF)
            p2.s.fgColor.raw_rgb = themes.themeElements.clrScheme[p2.s.fgColor.theme].rgb;
        }
        if (p2.s.bgColor && p2.s.bgColor.theme) {
          p2.s.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p2.s.bgColor.theme].rgb, p2.s.bgColor.tint || 0);
          if (opts.WTF)
            p2.s.bgColor.raw_rgb = themes.themeElements.clrScheme[p2.s.bgColor.theme].rgb;
        }
      } catch (e) {
        if (opts.WTF && styles.Fills)
          throw e;
      }
  }
  function check_ws(ws, sname, i) {
    if (ws && ws["!ref"]) {
      var range = safe_decode_range(ws["!ref"]);
      if (range.e.c < range.s.c || range.e.r < range.s.r)
        throw new Error("Bad range (" + i + "): " + ws["!ref"]);
    }
  }
  function parse_ws_xml_dim(ws, s2) {
    var d2 = safe_decode_range(s2);
    if (d2.s.r <= d2.e.r && d2.s.c <= d2.e.c && d2.s.r >= 0 && d2.s.c >= 0)
      ws["!ref"] = encode_range(d2);
  }
  var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
  var sheetdataregex = /<(?:\w+:)?sheetData[^>]*>([\s\S]*)<\/(?:\w+:)?sheetData>/;
  var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
  var dimregex = /"(\w*:\w*)"/;
  var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
  var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
  var marginregex = /<(?:\w:)?pageMargins[^>]*\/>/g;
  var sheetprregex = /<(?:\w:)?sheetPr\b(?:[^>a-z][^>]*)?\/>/;
  var sheetprregex2 = /<(?:\w:)?sheetPr[^>]*(?:[\/]|>([\s\S]*)<\/(?:\w:)?sheetPr)>/;
  var svsregex = /<(?:\w:)?sheetViews[^>]*(?:[\/]|>([\s\S]*)<\/(?:\w:)?sheetViews)>/;
  function parse_ws_xml(data, opts, idx, rels, wb, themes, styles) {
    if (!data)
      return data;
    if (!rels)
      rels = { "!id": {} };
    var s2 = opts.dense ? [] : {};
    var refguess = { s: { r: 2e6, c: 2e6 }, e: { r: 0, c: 0 } };
    var data1 = "", data2 = "";
    var mtch = data.match(sheetdataregex);
    if (mtch) {
      data1 = data.slice(0, mtch.index);
      data2 = data.slice(mtch.index + mtch[0].length);
    } else
      data1 = data2 = data;
    var sheetPr = data1.match(sheetprregex);
    if (sheetPr)
      parse_ws_xml_sheetpr(sheetPr[0], s2, wb, idx);
    else if (sheetPr = data1.match(sheetprregex2))
      parse_ws_xml_sheetpr2(sheetPr[0], sheetPr[1] || "", s2, wb, idx);
    var ridx = (data1.match(/<(?:\w*:)?dimension/) || { index: -1 }).index;
    if (ridx > 0) {
      var ref2 = data1.slice(ridx, ridx + 50).match(dimregex);
      if (ref2)
        parse_ws_xml_dim(s2, ref2[1]);
    }
    var svs = data1.match(svsregex);
    if (svs && svs[1])
      parse_ws_xml_sheetviews(svs[1], wb);
    var columns = [];
    if (opts.cellStyles) {
      var cols = data1.match(colregex);
      if (cols)
        parse_ws_xml_cols(columns, cols);
    }
    if (mtch)
      parse_ws_xml_data(mtch[1], s2, opts, refguess, themes, styles);
    var afilter = data2.match(afregex);
    if (afilter)
      s2["!autofilter"] = parse_ws_xml_autofilter(afilter[0]);
    var merges = [];
    var _merge = data2.match(mergecregex);
    if (_merge)
      for (ridx = 0; ridx != _merge.length; ++ridx)
        merges[ridx] = safe_decode_range(_merge[ridx].slice(_merge[ridx].indexOf('"') + 1));
    var hlink = data2.match(hlinkregex);
    if (hlink)
      parse_ws_xml_hlinks(s2, hlink, rels);
    var margins = data2.match(marginregex);
    if (margins)
      s2["!margins"] = parse_ws_xml_margins(parsexmltag(margins[0]));
    if (!s2["!ref"] && refguess.e.c >= refguess.s.c && refguess.e.r >= refguess.s.r)
      s2["!ref"] = encode_range(refguess);
    if (opts.sheetRows > 0 && s2["!ref"]) {
      var tmpref = safe_decode_range(s2["!ref"]);
      if (opts.sheetRows <= +tmpref.e.r) {
        tmpref.e.r = opts.sheetRows - 1;
        if (tmpref.e.r > refguess.e.r)
          tmpref.e.r = refguess.e.r;
        if (tmpref.e.r < tmpref.s.r)
          tmpref.s.r = tmpref.e.r;
        if (tmpref.e.c > refguess.e.c)
          tmpref.e.c = refguess.e.c;
        if (tmpref.e.c < tmpref.s.c)
          tmpref.s.c = tmpref.e.c;
        s2["!fullref"] = s2["!ref"];
        s2["!ref"] = encode_range(tmpref);
      }
    }
    if (columns.length > 0)
      s2["!cols"] = columns;
    if (merges.length > 0)
      s2["!merges"] = merges;
    return s2;
  }
  function write_ws_xml_merges(merges) {
    if (merges.length === 0)
      return "";
    var o2 = '<mergeCells count="' + merges.length + '">';
    for (var i = 0; i != merges.length; ++i)
      o2 += '<mergeCell ref="' + encode_range(merges[i]) + '"/>';
    return o2 + "</mergeCells>";
  }
  function parse_ws_xml_sheetpr(sheetPr, s2, wb, idx) {
    var data = parsexmltag(sheetPr);
    if (!wb.Sheets[idx])
      wb.Sheets[idx] = {};
    if (data.codeName)
      wb.Sheets[idx].CodeName = unescapexml(utf8read(data.codeName));
  }
  function parse_ws_xml_sheetpr2(sheetPr, body, s2, wb, idx) {
    parse_ws_xml_sheetpr(sheetPr.slice(0, sheetPr.indexOf(">")), s2, wb, idx);
  }
  function write_ws_xml_sheetpr(ws, wb, idx, opts, o2) {
    var needed = false;
    var props = {}, payload = null;
    if (opts.bookType !== "xlsx" && wb.vbaraw) {
      var cname = wb.SheetNames[idx];
      try {
        if (wb.Workbook)
          cname = wb.Workbook.Sheets[idx].CodeName || cname;
      } catch (e) {
      }
      needed = true;
      props.codeName = utf8write(escapexml(cname));
    }
    if (ws && ws["!outline"]) {
      var outlineprops = { summaryBelow: 1, summaryRight: 1 };
      if (ws["!outline"].above)
        outlineprops.summaryBelow = 0;
      if (ws["!outline"].left)
        outlineprops.summaryRight = 0;
      payload = (payload || "") + writextag("outlinePr", null, outlineprops);
    }
    if (!needed && !payload)
      return;
    o2[o2.length] = writextag("sheetPr", payload, props);
  }
  var sheetprot_deffalse = ["objects", "scenarios", "selectLockedCells", "selectUnlockedCells"];
  var sheetprot_deftrue = [
    "formatColumns",
    "formatRows",
    "formatCells",
    "insertColumns",
    "insertRows",
    "insertHyperlinks",
    "deleteColumns",
    "deleteRows",
    "sort",
    "autoFilter",
    "pivotTables"
  ];
  function write_ws_xml_protection(sp) {
    var o2 = { sheet: 1 };
    sheetprot_deffalse.forEach(function(n) {
      if (sp[n] != null && sp[n])
        o2[n] = "1";
    });
    sheetprot_deftrue.forEach(function(n) {
      if (sp[n] != null && !sp[n])
        o2[n] = "0";
    });
    if (sp.password)
      o2.password = crypto_CreatePasswordVerifier_Method1(sp.password).toString(16).toUpperCase();
    return writextag("sheetProtection", null, o2);
  }
  function parse_ws_xml_hlinks(s2, data, rels) {
    var dense = Array.isArray(s2);
    for (var i = 0; i != data.length; ++i) {
      var val = parsexmltag(utf8read(data[i]), true);
      if (!val.ref)
        return;
      var rel = ((rels || {})["!id"] || [])[val.id];
      if (rel) {
        val.Target = rel.Target;
        if (val.location)
          val.Target += "#" + unescapexml(val.location);
      } else {
        val.Target = "#" + unescapexml(val.location);
        rel = { Target: val.Target, TargetMode: "Internal" };
      }
      val.Rel = rel;
      if (val.tooltip) {
        val.Tooltip = val.tooltip;
        delete val.tooltip;
      }
      var rng = safe_decode_range(val.ref);
      for (var R2 = rng.s.r; R2 <= rng.e.r; ++R2)
        for (var C2 = rng.s.c; C2 <= rng.e.c; ++C2) {
          var addr = encode_cell({ c: C2, r: R2 });
          if (dense) {
            if (!s2[R2])
              s2[R2] = [];
            if (!s2[R2][C2])
              s2[R2][C2] = { t: "z", v: void 0 };
            s2[R2][C2].l = val;
          } else {
            if (!s2[addr])
              s2[addr] = { t: "z", v: void 0 };
            s2[addr].l = val;
          }
        }
    }
  }
  function parse_ws_xml_margins(margin) {
    var o2 = {};
    ["left", "right", "top", "bottom", "header", "footer"].forEach(function(k) {
      if (margin[k])
        o2[k] = parseFloat(margin[k]);
    });
    return o2;
  }
  function write_ws_xml_margins(margin) {
    default_margins(margin);
    return writextag("pageMargins", null, margin);
  }
  function parse_ws_xml_cols(columns, cols) {
    var seencol = false;
    for (var coli = 0; coli != cols.length; ++coli) {
      var coll = parsexmltag(cols[coli], true);
      if (coll.hidden)
        coll.hidden = parsexmlbool(coll.hidden);
      var colm = parseInt(coll.min, 10) - 1, colM = parseInt(coll.max, 10) - 1;
      if (coll.outlineLevel)
        coll.level = +coll.outlineLevel || 0;
      delete coll.min;
      delete coll.max;
      coll.width = +coll.width;
      if (!seencol && coll.width) {
        seencol = true;
        find_mdw_colw(coll.width);
      }
      process_col(coll);
      while (colm <= colM)
        columns[colm++] = dup(coll);
    }
  }
  function write_ws_xml_cols(ws, cols) {
    var o2 = ["<cols>"], col;
    for (var i = 0; i != cols.length; ++i) {
      if (!(col = cols[i]))
        continue;
      o2[o2.length] = writextag("col", null, col_obj_w(i, col));
    }
    o2[o2.length] = "</cols>";
    return o2.join("");
  }
  function parse_ws_xml_autofilter(data) {
    var o2 = { ref: (data.match(/ref="([^"]*)"/) || [])[1] };
    return o2;
  }
  function write_ws_xml_autofilter(data, ws, wb, idx) {
    var ref2 = typeof data.ref == "string" ? data.ref : encode_range(data.ref);
    if (!wb.Workbook)
      wb.Workbook = { Sheets: [] };
    if (!wb.Workbook.Names)
      wb.Workbook.Names = [];
    var names2 = wb.Workbook.Names;
    var range = decode_range(ref2);
    if (range.s.r == range.e.r) {
      range.e.r = decode_range(ws["!ref"]).e.r;
      ref2 = encode_range(range);
    }
    for (var i = 0; i < names2.length; ++i) {
      var name = names2[i];
      if (name.Name != "_xlnm._FilterDatabase")
        continue;
      if (name.Sheet != idx)
        continue;
      name.Ref = "'" + wb.SheetNames[idx] + "'!" + ref2;
      break;
    }
    if (i == names2.length)
      names2.push({ Name: "_xlnm._FilterDatabase", Sheet: idx, Ref: "'" + wb.SheetNames[idx] + "'!" + ref2 });
    return writextag("autoFilter", null, { ref: ref2 });
  }
  var sviewregex = /<(?:\w:)?sheetView(?:[^>a-z][^>]*)?\/?>/;
  function parse_ws_xml_sheetviews(data, wb) {
    if (!wb.Views)
      wb.Views = [{}];
    (data.match(sviewregex) || []).forEach(function(r, i) {
      var tag = parsexmltag(r);
      if (!wb.Views[i])
        wb.Views[i] = {};
      if (+tag.zoomScale)
        wb.Views[i].zoom = +tag.zoomScale;
      if (parsexmlbool(tag.rightToLeft))
        wb.Views[i].RTL = true;
    });
  }
  function write_ws_xml_sheetviews(ws, opts, idx, wb) {
    var sview = { workbookViewId: "0" };
    if ((((wb || {}).Workbook || {}).Views || [])[0])
      sview.rightToLeft = wb.Workbook.Views[0].RTL ? "1" : "0";
    return writextag("sheetViews", writextag("sheetView", null, sview), {});
  }
  function write_ws_xml_cell(cell, ref2, ws, opts) {
    if (cell.c)
      ws["!comments"].push([ref2, cell.c]);
    if (cell.v === void 0 && typeof cell.f !== "string" || cell.t === "z" && !cell.f)
      return "";
    var vv = "";
    var oldt = cell.t, oldv = cell.v;
    if (cell.t !== "z")
      switch (cell.t) {
        case "b":
          vv = cell.v ? "1" : "0";
          break;
        case "n":
          vv = "" + cell.v;
          break;
        case "e":
          vv = BErr[cell.v];
          break;
        case "d":
          if (opts && opts.cellDates)
            vv = parseDate(cell.v, -1).toISOString();
          else {
            cell = dup(cell);
            cell.t = "n";
            vv = "" + (cell.v = datenum(parseDate(cell.v)));
          }
          if (typeof cell.z === "undefined")
            cell.z = table_fmt[14];
          break;
        default:
          vv = cell.v;
          break;
      }
    var v2 = writetag("v", escapexml(vv)), o2 = { r: ref2 };
    var os = get_cell_style(opts.cellXfs, cell, opts);
    if (os !== 0)
      o2.s = os;
    switch (cell.t) {
      case "n":
        break;
      case "d":
        o2.t = "d";
        break;
      case "b":
        o2.t = "b";
        break;
      case "e":
        o2.t = "e";
        break;
      case "z":
        break;
      default:
        if (cell.v == null) {
          delete cell.t;
          break;
        }
        if (cell.v.length > 32767)
          throw new Error("Text length must not exceed 32767 characters");
        if (opts && opts.bookSST) {
          v2 = writetag("v", "" + get_sst_id(opts.Strings, cell.v, opts.revStrings));
          o2.t = "s";
          break;
        }
        o2.t = "str";
        break;
    }
    if (cell.t != oldt) {
      cell.t = oldt;
      cell.v = oldv;
    }
    if (typeof cell.f == "string" && cell.f) {
      var ff = cell.F && cell.F.slice(0, ref2.length) == ref2 ? { t: "array", ref: cell.F } : null;
      v2 = writextag("f", escapexml(cell.f), ff) + (cell.v != null ? v2 : "");
    }
    if (cell.l)
      ws["!links"].push([ref2, cell.l]);
    if (cell.D)
      o2.cm = 1;
    return writextag("c", v2, o2);
  }
  var parse_ws_xml_data = /* @__PURE__ */ function() {
    var cellregex = /<(?:\w+:)?c[ \/>]/, rowregex = /<\/(?:\w+:)?row>/;
    var rregex = /r=["']([^"']*)["']/, isregex = /<(?:\w+:)?is>([\S\s]*?)<\/(?:\w+:)?is>/;
    var refregex = /ref=["']([^"']*)["']/;
    var match_v = matchtag("v"), match_f = matchtag("f");
    return function parse_ws_xml_data2(sdata, s2, opts, guess, themes, styles) {
      var ri = 0, x2 = "", cells = [], cref = [], idx = 0, i = 0, cc = 0, d2 = "", p2;
      var tag, tagr = 0, tagc = 0;
      var sstr, ftag;
      var fmtid = 0, fillid = 0;
      var do_format = Array.isArray(styles.CellXf), cf;
      var arrayf = [];
      var sharedf = [];
      var dense = Array.isArray(s2);
      var rows = [], rowobj = {}, rowrite = false;
      var sheetStubs = !!opts.sheetStubs;
      for (var marr = sdata.split(rowregex), mt2 = 0, marrlen = marr.length; mt2 != marrlen; ++mt2) {
        x2 = marr[mt2].trim();
        var xlen = x2.length;
        if (xlen === 0)
          continue;
        var rstarti = 0;
        outa:
          for (ri = 0; ri < xlen; ++ri)
            switch (x2[ri]) {
              case ">":
                if (x2[ri - 1] != "/") {
                  ++ri;
                  break outa;
                }
                if (opts && opts.cellStyles) {
                  tag = parsexmltag(x2.slice(rstarti, ri), true);
                  tagr = tag.r != null ? parseInt(tag.r, 10) : tagr + 1;
                  tagc = -1;
                  if (opts.sheetRows && opts.sheetRows < tagr)
                    continue;
                  rowobj = {};
                  rowrite = false;
                  if (tag.ht) {
                    rowrite = true;
                    rowobj.hpt = parseFloat(tag.ht);
                    rowobj.hpx = pt2px(rowobj.hpt);
                  }
                  if (tag.hidden == "1") {
                    rowrite = true;
                    rowobj.hidden = true;
                  }
                  if (tag.outlineLevel != null) {
                    rowrite = true;
                    rowobj.level = +tag.outlineLevel;
                  }
                  if (rowrite)
                    rows[tagr - 1] = rowobj;
                }
                break;
              case "<":
                rstarti = ri;
                break;
            }
        if (rstarti >= ri)
          break;
        tag = parsexmltag(x2.slice(rstarti, ri), true);
        tagr = tag.r != null ? parseInt(tag.r, 10) : tagr + 1;
        tagc = -1;
        if (opts.sheetRows && opts.sheetRows < tagr)
          continue;
        if (guess.s.r > tagr - 1)
          guess.s.r = tagr - 1;
        if (guess.e.r < tagr - 1)
          guess.e.r = tagr - 1;
        if (opts && opts.cellStyles) {
          rowobj = {};
          rowrite = false;
          if (tag.ht) {
            rowrite = true;
            rowobj.hpt = parseFloat(tag.ht);
            rowobj.hpx = pt2px(rowobj.hpt);
          }
          if (tag.hidden == "1") {
            rowrite = true;
            rowobj.hidden = true;
          }
          if (tag.outlineLevel != null) {
            rowrite = true;
            rowobj.level = +tag.outlineLevel;
          }
          if (rowrite)
            rows[tagr - 1] = rowobj;
        }
        cells = x2.slice(ri).split(cellregex);
        for (var rslice = 0; rslice != cells.length; ++rslice)
          if (cells[rslice].trim().charAt(0) != "<")
            break;
        cells = cells.slice(rslice);
        for (ri = 0; ri != cells.length; ++ri) {
          x2 = cells[ri].trim();
          if (x2.length === 0)
            continue;
          cref = x2.match(rregex);
          idx = ri;
          i = 0;
          cc = 0;
          x2 = "<c " + (x2.slice(0, 1) == "<" ? ">" : "") + x2;
          if (cref != null && cref.length === 2) {
            idx = 0;
            d2 = cref[1];
            for (i = 0; i != d2.length; ++i) {
              if ((cc = d2.charCodeAt(i) - 64) < 1 || cc > 26)
                break;
              idx = 26 * idx + cc;
            }
            --idx;
            tagc = idx;
          } else
            ++tagc;
          for (i = 0; i != x2.length; ++i)
            if (x2.charCodeAt(i) === 62)
              break;
          ++i;
          tag = parsexmltag(x2.slice(0, i), true);
          if (!tag.r)
            tag.r = encode_cell({ r: tagr - 1, c: tagc });
          d2 = x2.slice(i);
          p2 = { t: "" };
          if ((cref = d2.match(match_v)) != null && cref[1] !== "")
            p2.v = unescapexml(cref[1]);
          if (opts.cellFormula) {
            if ((cref = d2.match(match_f)) != null && cref[1] !== "") {
              p2.f = unescapexml(utf8read(cref[1])).replace(/\r\n/g, "\n");
              if (!opts.xlfn)
                p2.f = _xlfn(p2.f);
              if (cref[0].indexOf('t="array"') > -1) {
                p2.F = (d2.match(refregex) || [])[1];
                if (p2.F.indexOf(":") > -1)
                  arrayf.push([safe_decode_range(p2.F), p2.F]);
              } else if (cref[0].indexOf('t="shared"') > -1) {
                ftag = parsexmltag(cref[0]);
                var ___f = unescapexml(utf8read(cref[1]));
                if (!opts.xlfn)
                  ___f = _xlfn(___f);
                sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
              }
            } else if (cref = d2.match(/<f[^>]*\/>/)) {
              ftag = parsexmltag(cref[0]);
              if (sharedf[ftag.si])
                p2.f = shift_formula_xlsx(sharedf[ftag.si][1], sharedf[ftag.si][2], tag.r);
            }
            var _tag = decode_cell(tag.r);
            for (i = 0; i < arrayf.length; ++i)
              if (_tag.r >= arrayf[i][0].s.r && _tag.r <= arrayf[i][0].e.r) {
                if (_tag.c >= arrayf[i][0].s.c && _tag.c <= arrayf[i][0].e.c)
                  p2.F = arrayf[i][1];
              }
          }
          if (tag.t == null && p2.v === void 0) {
            if (p2.f || p2.F) {
              p2.v = 0;
              p2.t = "n";
            } else if (!sheetStubs)
              continue;
            else
              p2.t = "z";
          } else
            p2.t = tag.t || "n";
          if (guess.s.c > tagc)
            guess.s.c = tagc;
          if (guess.e.c < tagc)
            guess.e.c = tagc;
          switch (p2.t) {
            case "n":
              if (p2.v == "" || p2.v == null) {
                if (!sheetStubs)
                  continue;
                p2.t = "z";
              } else
                p2.v = parseFloat(p2.v);
              break;
            case "s":
              if (typeof p2.v == "undefined") {
                if (!sheetStubs)
                  continue;
                p2.t = "z";
              } else {
                sstr = strs[parseInt(p2.v, 10)];
                p2.v = sstr.t;
                p2.r = sstr.r;
                if (opts.cellHTML)
                  p2.h = sstr.h;
              }
              break;
            case "str":
              p2.t = "s";
              p2.v = p2.v != null ? utf8read(p2.v) : "";
              if (opts.cellHTML)
                p2.h = escapehtml(p2.v);
              break;
            case "inlineStr":
              cref = d2.match(isregex);
              p2.t = "s";
              if (cref != null && (sstr = parse_si(cref[1]))) {
                p2.v = sstr.t;
                if (opts.cellHTML)
                  p2.h = sstr.h;
              } else
                p2.v = "";
              break;
            case "b":
              p2.v = parsexmlbool(p2.v);
              break;
            case "d":
              if (opts.cellDates)
                p2.v = parseDate(p2.v, 1);
              else {
                p2.v = datenum(parseDate(p2.v, 1));
                p2.t = "n";
              }
              break;
            case "e":
              if (!opts || opts.cellText !== false)
                p2.w = p2.v;
              p2.v = RBErr[p2.v];
              break;
          }
          fmtid = fillid = 0;
          cf = null;
          if (do_format && tag.s !== void 0) {
            cf = styles.CellXf[tag.s];
            if (cf != null) {
              if (cf.numFmtId != null)
                fmtid = cf.numFmtId;
              if (opts.cellStyles) {
                if (cf.fillId != null)
                  fillid = cf.fillId;
              }
            }
          }
          safe_format(p2, fmtid, fillid, opts, themes, styles);
          if (opts.cellDates && do_format && p2.t == "n" && fmt_is_date(table_fmt[fmtid])) {
            p2.t = "d";
            p2.v = numdate(p2.v);
          }
          if (tag.cm && opts.xlmeta) {
            var cm = (opts.xlmeta.Cell || [])[+tag.cm - 1];
            if (cm && cm.type == "XLDAPR")
              p2.D = true;
          }
          if (dense) {
            var _r = decode_cell(tag.r);
            if (!s2[_r.r])
              s2[_r.r] = [];
            s2[_r.r][_r.c] = p2;
          } else
            s2[tag.r] = p2;
        }
      }
      if (rows.length > 0)
        s2["!rows"] = rows;
    };
  }();
  function write_ws_xml_data(ws, opts, idx, wb) {
    var o2 = [], r = [], range = safe_decode_range(ws["!ref"]), cell = "", ref2, rr = "", cols = [], R2 = 0, C2 = 0, rows = ws["!rows"];
    var dense = Array.isArray(ws);
    var params = { r: rr }, row, height = -1;
    for (C2 = range.s.c; C2 <= range.e.c; ++C2)
      cols[C2] = encode_col(C2);
    for (R2 = range.s.r; R2 <= range.e.r; ++R2) {
      r = [];
      rr = encode_row(R2);
      for (C2 = range.s.c; C2 <= range.e.c; ++C2) {
        ref2 = cols[C2] + rr;
        var _cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
        if (_cell === void 0)
          continue;
        if ((cell = write_ws_xml_cell(_cell, ref2, ws, opts)) != null)
          r.push(cell);
      }
      if (r.length > 0 || rows && rows[R2]) {
        params = { r: rr };
        if (rows && rows[R2]) {
          row = rows[R2];
          if (row.hidden)
            params.hidden = 1;
          height = -1;
          if (row.hpx)
            height = px2pt(row.hpx);
          else if (row.hpt)
            height = row.hpt;
          if (height > -1) {
            params.ht = height;
            params.customHeight = 1;
          }
          if (row.level) {
            params.outlineLevel = row.level;
          }
        }
        o2[o2.length] = writextag("row", r.join(""), params);
      }
    }
    if (rows)
      for (; R2 < rows.length; ++R2) {
        if (rows && rows[R2]) {
          params = { r: R2 + 1 };
          row = rows[R2];
          if (row.hidden)
            params.hidden = 1;
          height = -1;
          if (row.hpx)
            height = px2pt(row.hpx);
          else if (row.hpt)
            height = row.hpt;
          if (height > -1) {
            params.ht = height;
            params.customHeight = 1;
          }
          if (row.level) {
            params.outlineLevel = row.level;
          }
          o2[o2.length] = writextag("row", "", params);
        }
      }
    return o2.join("");
  }
  function write_ws_xml(idx, opts, wb, rels) {
    var o2 = [XML_HEADER, writextag("worksheet", null, {
      "xmlns": XMLNS_main[0],
      "xmlns:r": XMLNS.r
    })];
    var s2 = wb.SheetNames[idx], sidx = 0, rdata = "";
    var ws = wb.Sheets[s2];
    if (ws == null)
      ws = {};
    var ref2 = ws["!ref"] || "A1";
    var range = safe_decode_range(ref2);
    if (range.e.c > 16383 || range.e.r > 1048575) {
      if (opts.WTF)
        throw new Error("Range " + ref2 + " exceeds format limit A1:XFD1048576");
      range.e.c = Math.min(range.e.c, 16383);
      range.e.r = Math.min(range.e.c, 1048575);
      ref2 = encode_range(range);
    }
    if (!rels)
      rels = {};
    ws["!comments"] = [];
    var _drawing = [];
    write_ws_xml_sheetpr(ws, wb, idx, opts, o2);
    o2[o2.length] = writextag("dimension", null, { "ref": ref2 });
    o2[o2.length] = write_ws_xml_sheetviews(ws, opts, idx, wb);
    if (opts.sheetFormat)
      o2[o2.length] = writextag("sheetFormatPr", null, {
        defaultRowHeight: opts.sheetFormat.defaultRowHeight || "16",
        baseColWidth: opts.sheetFormat.baseColWidth || "10",
        outlineLevelRow: opts.sheetFormat.outlineLevelRow || "7"
      });
    if (ws["!cols"] != null && ws["!cols"].length > 0)
      o2[o2.length] = write_ws_xml_cols(ws, ws["!cols"]);
    o2[sidx = o2.length] = "<sheetData/>";
    ws["!links"] = [];
    if (ws["!ref"] != null) {
      rdata = write_ws_xml_data(ws, opts);
      if (rdata.length > 0)
        o2[o2.length] = rdata;
    }
    if (o2.length > sidx + 1) {
      o2[o2.length] = "</sheetData>";
      o2[sidx] = o2[sidx].replace("/>", ">");
    }
    if (ws["!protect"])
      o2[o2.length] = write_ws_xml_protection(ws["!protect"]);
    if (ws["!autofilter"] != null)
      o2[o2.length] = write_ws_xml_autofilter(ws["!autofilter"], ws, wb, idx);
    if (ws["!merges"] != null && ws["!merges"].length > 0)
      o2[o2.length] = write_ws_xml_merges(ws["!merges"]);
    var relc = -1, rel, rId = -1;
    if (ws["!links"].length > 0) {
      o2[o2.length] = "<hyperlinks>";
      ws["!links"].forEach(function(l2) {
        if (!l2[1].Target)
          return;
        rel = { "ref": l2[0] };
        if (l2[1].Target.charAt(0) != "#") {
          rId = add_rels(rels, -1, escapexml(l2[1].Target).replace(/#.*$/, ""), RELS.HLINK);
          rel["r:id"] = "rId" + rId;
        }
        if ((relc = l2[1].Target.indexOf("#")) > -1)
          rel.location = escapexml(l2[1].Target.slice(relc + 1));
        if (l2[1].Tooltip)
          rel.tooltip = escapexml(l2[1].Tooltip);
        o2[o2.length] = writextag("hyperlink", null, rel);
      });
      o2[o2.length] = "</hyperlinks>";
    }
    delete ws["!links"];
    if (ws["!margins"] != null)
      o2[o2.length] = write_ws_xml_margins(ws["!margins"]);
    if (!opts || opts.ignoreEC || opts.ignoreEC == void 0)
      o2[o2.length] = writetag("ignoredErrors", writextag("ignoredError", null, { numberStoredAsText: 1, sqref: ref2 }));
    if (_drawing.length > 0) {
      rId = add_rels(rels, -1, "../drawings/drawing" + (idx + 1) + ".xml", RELS.DRAW);
      o2[o2.length] = writextag("drawing", null, { "r:id": "rId" + rId });
      ws["!drawing"] = _drawing;
    }
    if (ws["!comments"].length > 0) {
      rId = add_rels(rels, -1, "../drawings/vmlDrawing" + (idx + 1) + ".vml", RELS.VML);
      o2[o2.length] = writextag("legacyDrawing", null, { "r:id": "rId" + rId });
      ws["!legacy"] = rId;
    }
    if (o2.length > 1) {
      o2[o2.length] = "</worksheet>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function parse_BrtRowHdr(data, length) {
    var z = {};
    var tgt = data.l + length;
    z.r = data.read_shift(4);
    data.l += 4;
    var miyRw = data.read_shift(2);
    data.l += 1;
    var flags = data.read_shift(1);
    data.l = tgt;
    if (flags & 7)
      z.level = flags & 7;
    if (flags & 16)
      z.hidden = true;
    if (flags & 32)
      z.hpt = miyRw / 20;
    return z;
  }
  function write_BrtRowHdr(R2, range, ws) {
    var o2 = new_buf(17 + 8 * 16);
    var row = (ws["!rows"] || [])[R2] || {};
    o2.write_shift(4, R2);
    o2.write_shift(4, 0);
    var miyRw = 320;
    if (row.hpx)
      miyRw = px2pt(row.hpx) * 20;
    else if (row.hpt)
      miyRw = row.hpt * 20;
    o2.write_shift(2, miyRw);
    o2.write_shift(1, 0);
    var flags = 0;
    if (row.level)
      flags |= row.level;
    if (row.hidden)
      flags |= 16;
    if (row.hpx || row.hpt)
      flags |= 32;
    o2.write_shift(1, flags);
    o2.write_shift(1, 0);
    var ncolspan = 0, lcs = o2.l;
    o2.l += 4;
    var caddr = { r: R2, c: 0 };
    for (var i = 0; i < 16; ++i) {
      if (range.s.c > i + 1 << 10 || range.e.c < i << 10)
        continue;
      var first = -1, last = -1;
      for (var j = i << 10; j < i + 1 << 10; ++j) {
        caddr.c = j;
        var cell = Array.isArray(ws) ? (ws[caddr.r] || [])[caddr.c] : ws[encode_cell(caddr)];
        if (cell) {
          if (first < 0)
            first = j;
          last = j;
        }
      }
      if (first < 0)
        continue;
      ++ncolspan;
      o2.write_shift(4, first);
      o2.write_shift(4, last);
    }
    var l2 = o2.l;
    o2.l = lcs;
    o2.write_shift(4, ncolspan);
    o2.l = l2;
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function write_row_header(ba, ws, range, R2) {
    var o2 = write_BrtRowHdr(R2, range, ws);
    if (o2.length > 17 || (ws["!rows"] || [])[R2])
      write_record(ba, 0, o2);
  }
  var parse_BrtWsDim = parse_UncheckedRfX;
  var write_BrtWsDim = write_UncheckedRfX;
  function parse_BrtWsFmtInfo() {
  }
  function parse_BrtWsProp(data, length) {
    var z = {};
    var f2 = data[data.l];
    ++data.l;
    z.above = !(f2 & 64);
    z.left = !(f2 & 128);
    data.l += 18;
    z.name = parse_XLSBCodeName(data);
    return z;
  }
  function write_BrtWsProp(str, outl, o2) {
    if (o2 == null)
      o2 = new_buf(84 + 4 * str.length);
    var f2 = 192;
    if (outl) {
      if (outl.above)
        f2 &= ~64;
      if (outl.left)
        f2 &= ~128;
    }
    o2.write_shift(1, f2);
    for (var i = 1; i < 3; ++i)
      o2.write_shift(1, 0);
    write_BrtColor({ auto: 1 }, o2);
    o2.write_shift(-4, -1);
    o2.write_shift(-4, -1);
    write_XLSBCodeName(str, o2);
    return o2.slice(0, o2.l);
  }
  function parse_BrtCellBlank(data) {
    var cell = parse_XLSBCell(data);
    return [cell];
  }
  function write_BrtCellBlank(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(8);
    return write_XLSBCell(ncell, o2);
  }
  function parse_BrtShortBlank(data) {
    var cell = parse_XLSBShortCell(data);
    return [cell];
  }
  function write_BrtShortBlank(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(4);
    return write_XLSBShortCell(ncell, o2);
  }
  function parse_BrtCellBool(data) {
    var cell = parse_XLSBCell(data);
    var fBool = data.read_shift(1);
    return [cell, fBool, "b"];
  }
  function write_BrtCellBool(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(9);
    write_XLSBCell(ncell, o2);
    o2.write_shift(1, cell.v ? 1 : 0);
    return o2;
  }
  function parse_BrtShortBool(data) {
    var cell = parse_XLSBShortCell(data);
    var fBool = data.read_shift(1);
    return [cell, fBool, "b"];
  }
  function write_BrtShortBool(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(5);
    write_XLSBShortCell(ncell, o2);
    o2.write_shift(1, cell.v ? 1 : 0);
    return o2;
  }
  function parse_BrtCellError(data) {
    var cell = parse_XLSBCell(data);
    var bError = data.read_shift(1);
    return [cell, bError, "e"];
  }
  function write_BrtCellError(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(9);
    write_XLSBCell(ncell, o2);
    o2.write_shift(1, cell.v);
    return o2;
  }
  function parse_BrtShortError(data) {
    var cell = parse_XLSBShortCell(data);
    var bError = data.read_shift(1);
    return [cell, bError, "e"];
  }
  function write_BrtShortError(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(8);
    write_XLSBShortCell(ncell, o2);
    o2.write_shift(1, cell.v);
    o2.write_shift(2, 0);
    o2.write_shift(1, 0);
    return o2;
  }
  function parse_BrtCellIsst(data) {
    var cell = parse_XLSBCell(data);
    var isst = data.read_shift(4);
    return [cell, isst, "s"];
  }
  function write_BrtCellIsst(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(12);
    write_XLSBCell(ncell, o2);
    o2.write_shift(4, ncell.v);
    return o2;
  }
  function parse_BrtShortIsst(data) {
    var cell = parse_XLSBShortCell(data);
    var isst = data.read_shift(4);
    return [cell, isst, "s"];
  }
  function write_BrtShortIsst(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(8);
    write_XLSBShortCell(ncell, o2);
    o2.write_shift(4, ncell.v);
    return o2;
  }
  function parse_BrtCellReal(data) {
    var cell = parse_XLSBCell(data);
    var value = parse_Xnum(data);
    return [cell, value, "n"];
  }
  function write_BrtCellReal(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(16);
    write_XLSBCell(ncell, o2);
    write_Xnum(cell.v, o2);
    return o2;
  }
  function parse_BrtShortReal(data) {
    var cell = parse_XLSBShortCell(data);
    var value = parse_Xnum(data);
    return [cell, value, "n"];
  }
  function write_BrtShortReal(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(12);
    write_XLSBShortCell(ncell, o2);
    write_Xnum(cell.v, o2);
    return o2;
  }
  function parse_BrtCellRk(data) {
    var cell = parse_XLSBCell(data);
    var value = parse_RkNumber(data);
    return [cell, value, "n"];
  }
  function write_BrtCellRk(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(12);
    write_XLSBCell(ncell, o2);
    write_RkNumber(cell.v, o2);
    return o2;
  }
  function parse_BrtShortRk(data) {
    var cell = parse_XLSBShortCell(data);
    var value = parse_RkNumber(data);
    return [cell, value, "n"];
  }
  function write_BrtShortRk(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(8);
    write_XLSBShortCell(ncell, o2);
    write_RkNumber(cell.v, o2);
    return o2;
  }
  function parse_BrtCellRString(data) {
    var cell = parse_XLSBCell(data);
    var value = parse_RichStr(data);
    return [cell, value, "is"];
  }
  function parse_BrtCellSt(data) {
    var cell = parse_XLSBCell(data);
    var value = parse_XLWideString(data);
    return [cell, value, "str"];
  }
  function write_BrtCellSt(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(12 + 4 * cell.v.length);
    write_XLSBCell(ncell, o2);
    write_XLWideString(cell.v, o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function parse_BrtShortSt(data) {
    var cell = parse_XLSBShortCell(data);
    var value = parse_XLWideString(data);
    return [cell, value, "str"];
  }
  function write_BrtShortSt(cell, ncell, o2) {
    if (o2 == null)
      o2 = new_buf(8 + 4 * cell.v.length);
    write_XLSBShortCell(ncell, o2);
    write_XLWideString(cell.v, o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function parse_BrtFmlaBool(data, length, opts) {
    var end = data.l + length;
    var cell = parse_XLSBCell(data);
    cell.r = opts["!row"];
    var value = data.read_shift(1);
    var o2 = [cell, value, "b"];
    if (opts.cellFormula) {
      data.l += 2;
      var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
      o2[3] = stringify_formula(formula, null, cell, opts.supbooks, opts);
    } else
      data.l = end;
    return o2;
  }
  function parse_BrtFmlaError(data, length, opts) {
    var end = data.l + length;
    var cell = parse_XLSBCell(data);
    cell.r = opts["!row"];
    var value = data.read_shift(1);
    var o2 = [cell, value, "e"];
    if (opts.cellFormula) {
      data.l += 2;
      var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
      o2[3] = stringify_formula(formula, null, cell, opts.supbooks, opts);
    } else
      data.l = end;
    return o2;
  }
  function parse_BrtFmlaNum(data, length, opts) {
    var end = data.l + length;
    var cell = parse_XLSBCell(data);
    cell.r = opts["!row"];
    var value = parse_Xnum(data);
    var o2 = [cell, value, "n"];
    if (opts.cellFormula) {
      data.l += 2;
      var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
      o2[3] = stringify_formula(formula, null, cell, opts.supbooks, opts);
    } else
      data.l = end;
    return o2;
  }
  function parse_BrtFmlaString(data, length, opts) {
    var end = data.l + length;
    var cell = parse_XLSBCell(data);
    cell.r = opts["!row"];
    var value = parse_XLWideString(data);
    var o2 = [cell, value, "str"];
    if (opts.cellFormula) {
      data.l += 2;
      var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
      o2[3] = stringify_formula(formula, null, cell, opts.supbooks, opts);
    } else
      data.l = end;
    return o2;
  }
  var parse_BrtMergeCell = parse_UncheckedRfX;
  var write_BrtMergeCell = write_UncheckedRfX;
  function write_BrtBeginMergeCells(cnt, o2) {
    if (o2 == null)
      o2 = new_buf(4);
    o2.write_shift(4, cnt);
    return o2;
  }
  function parse_BrtHLink(data, length) {
    var end = data.l + length;
    var rfx = parse_UncheckedRfX(data);
    var relId = parse_XLNullableWideString(data);
    var loc = parse_XLWideString(data);
    var tooltip = parse_XLWideString(data);
    var display = parse_XLWideString(data);
    data.l = end;
    var o2 = { rfx, relId, loc, display };
    if (tooltip)
      o2.Tooltip = tooltip;
    return o2;
  }
  function write_BrtHLink(l2, rId) {
    var o2 = new_buf(50 + 4 * (l2[1].Target.length + (l2[1].Tooltip || "").length));
    write_UncheckedRfX({ s: decode_cell(l2[0]), e: decode_cell(l2[0]) }, o2);
    write_RelID("rId" + rId, o2);
    var locidx = l2[1].Target.indexOf("#");
    var loc = locidx == -1 ? "" : l2[1].Target.slice(locidx + 1);
    write_XLWideString(loc || "", o2);
    write_XLWideString(l2[1].Tooltip || "", o2);
    write_XLWideString("", o2);
    return o2.slice(0, o2.l);
  }
  function parse_BrtPane() {
  }
  function parse_BrtArrFmla(data, length, opts) {
    var end = data.l + length;
    var rfx = parse_RfX(data);
    var fAlwaysCalc = data.read_shift(1);
    var o2 = [rfx];
    o2[2] = fAlwaysCalc;
    if (opts.cellFormula) {
      var formula = parse_XLSBArrayParsedFormula(data, end - data.l, opts);
      o2[1] = formula;
    } else
      data.l = end;
    return o2;
  }
  function parse_BrtShrFmla(data, length, opts) {
    var end = data.l + length;
    var rfx = parse_UncheckedRfX(data);
    var o2 = [rfx];
    if (opts.cellFormula) {
      var formula = parse_XLSBSharedParsedFormula(data, end - data.l, opts);
      o2[1] = formula;
      data.l = end;
    } else
      data.l = end;
    return o2;
  }
  function write_BrtColInfo(C2, col, o2) {
    if (o2 == null)
      o2 = new_buf(18);
    var p2 = col_obj_w(C2, col);
    o2.write_shift(-4, C2);
    o2.write_shift(-4, C2);
    o2.write_shift(4, (p2.width || 10) * 256);
    o2.write_shift(4, 0);
    var flags = 0;
    if (col.hidden)
      flags |= 1;
    if (typeof p2.width == "number")
      flags |= 2;
    if (col.level)
      flags |= col.level << 8;
    o2.write_shift(2, flags);
    return o2;
  }
  var BrtMarginKeys = ["left", "right", "top", "bottom", "header", "footer"];
  function parse_BrtMargins(data) {
    var margins = {};
    BrtMarginKeys.forEach(function(k) {
      margins[k] = parse_Xnum(data);
    });
    return margins;
  }
  function write_BrtMargins(margins, o2) {
    if (o2 == null)
      o2 = new_buf(6 * 8);
    default_margins(margins);
    BrtMarginKeys.forEach(function(k) {
      write_Xnum(margins[k], o2);
    });
    return o2;
  }
  function parse_BrtBeginWsView(data) {
    var f2 = data.read_shift(2);
    data.l += 28;
    return { RTL: f2 & 32 };
  }
  function write_BrtBeginWsView(ws, Workbook, o2) {
    if (o2 == null)
      o2 = new_buf(30);
    var f2 = 924;
    if ((((Workbook || {}).Views || [])[0] || {}).RTL)
      f2 |= 32;
    o2.write_shift(2, f2);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(1, 0);
    o2.write_shift(1, 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 100);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(2, 0);
    o2.write_shift(4, 0);
    return o2;
  }
  function write_BrtCellIgnoreEC(ref2) {
    var o2 = new_buf(24);
    o2.write_shift(4, 4);
    o2.write_shift(4, 1);
    write_UncheckedRfX(ref2, o2);
    return o2;
  }
  function write_BrtSheetProtection(sp, o2) {
    if (o2 == null)
      o2 = new_buf(16 * 4 + 2);
    o2.write_shift(2, sp.password ? crypto_CreatePasswordVerifier_Method1(sp.password) : 0);
    o2.write_shift(4, 1);
    [
      ["objects", false],
      ["scenarios", false],
      ["formatCells", true],
      ["formatColumns", true],
      ["formatRows", true],
      ["insertColumns", true],
      ["insertRows", true],
      ["insertHyperlinks", true],
      ["deleteColumns", true],
      ["deleteRows", true],
      ["selectLockedCells", false],
      ["sort", true],
      ["autoFilter", true],
      ["pivotTables", true],
      ["selectUnlockedCells", false]
    ].forEach(function(n) {
      if (n[1])
        o2.write_shift(4, sp[n[0]] != null && !sp[n[0]] ? 1 : 0);
      else
        o2.write_shift(4, sp[n[0]] != null && sp[n[0]] ? 0 : 1);
    });
    return o2;
  }
  function parse_BrtDVal() {
  }
  function parse_BrtDVal14() {
  }
  function parse_ws_bin(data, _opts, idx, rels, wb, themes, styles) {
    if (!data)
      return data;
    var opts = _opts || {};
    if (!rels)
      rels = { "!id": {} };
    var s2 = opts.dense ? [] : {};
    var ref2;
    var refguess = { s: { r: 2e6, c: 2e6 }, e: { r: 0, c: 0 } };
    var pass = false, end = false;
    var row, p2, cf, R2, C2, addr, sstr, rr, cell;
    var merges = [];
    opts.biff = 12;
    opts["!row"] = 0;
    var ai = 0, af = false;
    var arrayf = [];
    var sharedf = {};
    var supbooks = opts.supbooks || wb.supbooks || [[]];
    supbooks.sharedf = sharedf;
    supbooks.arrayf = arrayf;
    supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x2) {
      return x2.name;
    });
    if (!opts.supbooks) {
      opts.supbooks = supbooks;
      if (wb.Names)
        for (var i = 0; i < wb.Names.length; ++i)
          supbooks[0][i + 1] = wb.Names[i];
    }
    var colinfo = [], rowinfo = [];
    var seencol = false;
    XLSBRecordEnum[16] = { n: "BrtShortReal", f: parse_BrtShortReal };
    var cm;
    recordhopper(data, function ws_parse(val, RR, RT) {
      if (end)
        return;
      switch (RT) {
        case 148:
          ref2 = val;
          break;
        case 0:
          row = val;
          if (opts.sheetRows && opts.sheetRows <= row.r)
            end = true;
          rr = encode_row(R2 = row.r);
          opts["!row"] = row.r;
          if (val.hidden || val.hpt || val.level != null) {
            if (val.hpt)
              val.hpx = pt2px(val.hpt);
            rowinfo[val.r] = val;
          }
          break;
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 13:
        case 14:
        case 15:
        case 16:
        case 17:
        case 18:
        case 62:
          p2 = { t: val[2] };
          switch (val[2]) {
            case "n":
              p2.v = val[1];
              break;
            case "s":
              sstr = strs[val[1]];
              p2.v = sstr.t;
              p2.r = sstr.r;
              break;
            case "b":
              p2.v = val[1] ? true : false;
              break;
            case "e":
              p2.v = val[1];
              if (opts.cellText !== false)
                p2.w = BErr[p2.v];
              break;
            case "str":
              p2.t = "s";
              p2.v = val[1];
              break;
            case "is":
              p2.t = "s";
              p2.v = val[1].t;
              break;
          }
          if (cf = styles.CellXf[val[0].iStyleRef])
            safe_format(p2, cf.numFmtId, null, opts, themes, styles);
          C2 = val[0].c == -1 ? C2 + 1 : val[0].c;
          if (opts.dense) {
            if (!s2[R2])
              s2[R2] = [];
            s2[R2][C2] = p2;
          } else
            s2[encode_col(C2) + rr] = p2;
          if (opts.cellFormula) {
            af = false;
            for (ai = 0; ai < arrayf.length; ++ai) {
              var aii = arrayf[ai];
              if (row.r >= aii[0].s.r && row.r <= aii[0].e.r) {
                if (C2 >= aii[0].s.c && C2 <= aii[0].e.c) {
                  p2.F = encode_range(aii[0]);
                  af = true;
                }
              }
            }
            if (!af && val.length > 3)
              p2.f = val[3];
          }
          if (refguess.s.r > row.r)
            refguess.s.r = row.r;
          if (refguess.s.c > C2)
            refguess.s.c = C2;
          if (refguess.e.r < row.r)
            refguess.e.r = row.r;
          if (refguess.e.c < C2)
            refguess.e.c = C2;
          if (opts.cellDates && cf && p2.t == "n" && fmt_is_date(table_fmt[cf.numFmtId])) {
            var _d = SSF_parse_date_code(p2.v);
            if (_d) {
              p2.t = "d";
              p2.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);
            }
          }
          if (cm) {
            if (cm.type == "XLDAPR")
              p2.D = true;
            cm = void 0;
          }
          break;
        case 1:
        case 12:
          if (!opts.sheetStubs || pass)
            break;
          p2 = { t: "z", v: void 0 };
          C2 = val[0].c == -1 ? C2 + 1 : val[0].c;
          if (opts.dense) {
            if (!s2[R2])
              s2[R2] = [];
            s2[R2][C2] = p2;
          } else
            s2[encode_col(C2) + rr] = p2;
          if (refguess.s.r > row.r)
            refguess.s.r = row.r;
          if (refguess.s.c > C2)
            refguess.s.c = C2;
          if (refguess.e.r < row.r)
            refguess.e.r = row.r;
          if (refguess.e.c < C2)
            refguess.e.c = C2;
          if (cm) {
            if (cm.type == "XLDAPR")
              p2.D = true;
            cm = void 0;
          }
          break;
        case 176:
          merges.push(val);
          break;
        case 49:
          {
            cm = ((opts.xlmeta || {}).Cell || [])[val - 1];
          }
          break;
        case 494:
          var rel = rels["!id"][val.relId];
          if (rel) {
            val.Target = rel.Target;
            if (val.loc)
              val.Target += "#" + val.loc;
            val.Rel = rel;
          } else if (val.relId == "") {
            val.Target = "#" + val.loc;
          }
          for (R2 = val.rfx.s.r; R2 <= val.rfx.e.r; ++R2)
            for (C2 = val.rfx.s.c; C2 <= val.rfx.e.c; ++C2) {
              if (opts.dense) {
                if (!s2[R2])
                  s2[R2] = [];
                if (!s2[R2][C2])
                  s2[R2][C2] = { t: "z", v: void 0 };
                s2[R2][C2].l = val;
              } else {
                addr = encode_cell({ c: C2, r: R2 });
                if (!s2[addr])
                  s2[addr] = { t: "z", v: void 0 };
                s2[addr].l = val;
              }
            }
          break;
        case 426:
          if (!opts.cellFormula)
            break;
          arrayf.push(val);
          cell = opts.dense ? s2[R2][C2] : s2[encode_col(C2) + rr];
          cell.f = stringify_formula(val[1], refguess, { r: row.r, c: C2 }, supbooks, opts);
          cell.F = encode_range(val[0]);
          break;
        case 427:
          if (!opts.cellFormula)
            break;
          sharedf[encode_cell(val[0].s)] = val[1];
          cell = opts.dense ? s2[R2][C2] : s2[encode_col(C2) + rr];
          cell.f = stringify_formula(val[1], refguess, { r: row.r, c: C2 }, supbooks, opts);
          break;
        case 60:
          if (!opts.cellStyles)
            break;
          while (val.e >= val.s) {
            colinfo[val.e--] = { width: val.w / 256, hidden: !!(val.flags & 1), level: val.level };
            if (!seencol) {
              seencol = true;
              find_mdw_colw(val.w / 256);
            }
            process_col(colinfo[val.e + 1]);
          }
          break;
        case 161:
          s2["!autofilter"] = { ref: encode_range(val) };
          break;
        case 476:
          s2["!margins"] = val;
          break;
        case 147:
          if (!wb.Sheets[idx])
            wb.Sheets[idx] = {};
          if (val.name)
            wb.Sheets[idx].CodeName = val.name;
          if (val.above || val.left)
            s2["!outline"] = { above: val.above, left: val.left };
          break;
        case 137:
          if (!wb.Views)
            wb.Views = [{}];
          if (!wb.Views[0])
            wb.Views[0] = {};
          if (val.RTL)
            wb.Views[0].RTL = true;
          break;
        case 485:
          break;
        case 64:
        case 1053:
          break;
        case 151:
          break;
        case 152:
        case 175:
        case 644:
        case 625:
        case 562:
        case 396:
        case 1112:
        case 1146:
        case 471:
        case 1050:
        case 649:
        case 1105:
        case 589:
        case 607:
        case 564:
        case 1055:
        case 168:
        case 174:
        case 1180:
        case 499:
        case 507:
        case 550:
        case 171:
        case 167:
        case 1177:
        case 169:
        case 1181:
        case 551:
        case 552:
        case 661:
        case 639:
        case 478:
        case 537:
        case 477:
        case 536:
        case 1103:
        case 680:
        case 1104:
        case 1024:
        case 663:
        case 535:
        case 678:
        case 504:
        case 1043:
        case 428:
        case 170:
        case 3072:
        case 50:
        case 2070:
        case 1045:
          break;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        case 37:
          pass = true;
          break;
        case 38:
          pass = false;
          break;
        default:
          if (RR.T)
            ;
          else if (!pass || opts.WTF)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    }, opts);
    delete opts.supbooks;
    delete opts["!row"];
    if (!s2["!ref"] && (refguess.s.r < 2e6 || ref2 && (ref2.e.r > 0 || ref2.e.c > 0 || ref2.s.r > 0 || ref2.s.c > 0)))
      s2["!ref"] = encode_range(ref2 || refguess);
    if (opts.sheetRows && s2["!ref"]) {
      var tmpref = safe_decode_range(s2["!ref"]);
      if (opts.sheetRows <= +tmpref.e.r) {
        tmpref.e.r = opts.sheetRows - 1;
        if (tmpref.e.r > refguess.e.r)
          tmpref.e.r = refguess.e.r;
        if (tmpref.e.r < tmpref.s.r)
          tmpref.s.r = tmpref.e.r;
        if (tmpref.e.c > refguess.e.c)
          tmpref.e.c = refguess.e.c;
        if (tmpref.e.c < tmpref.s.c)
          tmpref.s.c = tmpref.e.c;
        s2["!fullref"] = s2["!ref"];
        s2["!ref"] = encode_range(tmpref);
      }
    }
    if (merges.length > 0)
      s2["!merges"] = merges;
    if (colinfo.length > 0)
      s2["!cols"] = colinfo;
    if (rowinfo.length > 0)
      s2["!rows"] = rowinfo;
    return s2;
  }
  function write_ws_bin_cell(ba, cell, R2, C2, opts, ws, last_seen) {
    if (cell.v === void 0)
      return false;
    var vv = "";
    switch (cell.t) {
      case "b":
        vv = cell.v ? "1" : "0";
        break;
      case "d":
        cell = dup(cell);
        cell.z = cell.z || table_fmt[14];
        cell.v = datenum(parseDate(cell.v));
        cell.t = "n";
        break;
      case "n":
      case "e":
        vv = "" + cell.v;
        break;
      default:
        vv = cell.v;
        break;
    }
    var o2 = { r: R2, c: C2 };
    o2.s = get_cell_style(opts.cellXfs, cell, opts);
    if (cell.l)
      ws["!links"].push([encode_cell(o2), cell.l]);
    if (cell.c)
      ws["!comments"].push([encode_cell(o2), cell.c]);
    switch (cell.t) {
      case "s":
      case "str":
        if (opts.bookSST) {
          vv = get_sst_id(opts.Strings, cell.v, opts.revStrings);
          o2.t = "s";
          o2.v = vv;
          if (last_seen)
            write_record(ba, 18, write_BrtShortIsst(cell, o2));
          else
            write_record(ba, 7, write_BrtCellIsst(cell, o2));
        } else {
          o2.t = "str";
          if (last_seen)
            write_record(ba, 17, write_BrtShortSt(cell, o2));
          else
            write_record(ba, 6, write_BrtCellSt(cell, o2));
        }
        return true;
      case "n":
        if (cell.v == (cell.v | 0) && cell.v > -1e3 && cell.v < 1e3) {
          if (last_seen)
            write_record(ba, 13, write_BrtShortRk(cell, o2));
          else
            write_record(ba, 2, write_BrtCellRk(cell, o2));
        } else {
          if (last_seen)
            write_record(ba, 16, write_BrtShortReal(cell, o2));
          else
            write_record(ba, 5, write_BrtCellReal(cell, o2));
        }
        return true;
      case "b":
        o2.t = "b";
        if (last_seen)
          write_record(ba, 15, write_BrtShortBool(cell, o2));
        else
          write_record(ba, 4, write_BrtCellBool(cell, o2));
        return true;
      case "e":
        o2.t = "e";
        if (last_seen)
          write_record(ba, 14, write_BrtShortError(cell, o2));
        else
          write_record(ba, 3, write_BrtCellError(cell, o2));
        return true;
    }
    if (last_seen)
      write_record(ba, 12, write_BrtShortBlank(cell, o2));
    else
      write_record(ba, 1, write_BrtCellBlank(cell, o2));
    return true;
  }
  function write_CELLTABLE(ba, ws, idx, opts) {
    var range = safe_decode_range(ws["!ref"] || "A1"), ref2, rr = "", cols = [];
    write_record(ba, 145);
    var dense = Array.isArray(ws);
    var cap = range.e.r;
    if (ws["!rows"])
      cap = Math.max(range.e.r, ws["!rows"].length - 1);
    for (var R2 = range.s.r; R2 <= cap; ++R2) {
      rr = encode_row(R2);
      write_row_header(ba, ws, range, R2);
      var last_seen = false;
      if (R2 <= range.e.r)
        for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
          if (R2 === range.s.r)
            cols[C2] = encode_col(C2);
          ref2 = cols[C2] + rr;
          var cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
          if (!cell) {
            last_seen = false;
            continue;
          }
          last_seen = write_ws_bin_cell(ba, cell, R2, C2, opts, ws, last_seen);
        }
    }
    write_record(ba, 146);
  }
  function write_MERGECELLS(ba, ws) {
    if (!ws || !ws["!merges"])
      return;
    write_record(ba, 177, write_BrtBeginMergeCells(ws["!merges"].length));
    ws["!merges"].forEach(function(m2) {
      write_record(ba, 176, write_BrtMergeCell(m2));
    });
    write_record(ba, 178);
  }
  function write_COLINFOS(ba, ws) {
    if (!ws || !ws["!cols"])
      return;
    write_record(ba, 390);
    ws["!cols"].forEach(function(m2, i) {
      if (m2)
        write_record(ba, 60, write_BrtColInfo(i, m2));
    });
    write_record(ba, 391);
  }
  function write_IGNOREECS(ba, ws) {
    if (!ws || !ws["!ref"])
      return;
    write_record(ba, 648);
    write_record(ba, 649, write_BrtCellIgnoreEC(safe_decode_range(ws["!ref"])));
    write_record(ba, 650);
  }
  function write_HLINKS(ba, ws, rels) {
    ws["!links"].forEach(function(l2) {
      if (!l2[1].Target)
        return;
      var rId = add_rels(rels, -1, l2[1].Target.replace(/#.*$/, ""), RELS.HLINK);
      write_record(ba, 494, write_BrtHLink(l2, rId));
    });
    delete ws["!links"];
  }
  function write_LEGACYDRAWING(ba, ws, idx, rels) {
    if (ws["!comments"].length > 0) {
      var rId = add_rels(rels, -1, "../drawings/vmlDrawing" + (idx + 1) + ".vml", RELS.VML);
      write_record(ba, 551, write_RelID("rId" + rId));
      ws["!legacy"] = rId;
    }
  }
  function write_AUTOFILTER(ba, ws, wb, idx) {
    if (!ws["!autofilter"])
      return;
    var data = ws["!autofilter"];
    var ref2 = typeof data.ref === "string" ? data.ref : encode_range(data.ref);
    if (!wb.Workbook)
      wb.Workbook = { Sheets: [] };
    if (!wb.Workbook.Names)
      wb.Workbook.Names = [];
    var names2 = wb.Workbook.Names;
    var range = decode_range(ref2);
    if (range.s.r == range.e.r) {
      range.e.r = decode_range(ws["!ref"]).e.r;
      ref2 = encode_range(range);
    }
    for (var i = 0; i < names2.length; ++i) {
      var name = names2[i];
      if (name.Name != "_xlnm._FilterDatabase")
        continue;
      if (name.Sheet != idx)
        continue;
      name.Ref = "'" + wb.SheetNames[idx] + "'!" + ref2;
      break;
    }
    if (i == names2.length)
      names2.push({ Name: "_xlnm._FilterDatabase", Sheet: idx, Ref: "'" + wb.SheetNames[idx] + "'!" + ref2 });
    write_record(ba, 161, write_UncheckedRfX(safe_decode_range(ref2)));
    write_record(ba, 162);
  }
  function write_WSVIEWS2(ba, ws, Workbook) {
    write_record(ba, 133);
    {
      write_record(ba, 137, write_BrtBeginWsView(ws, Workbook));
      write_record(ba, 138);
    }
    write_record(ba, 134);
  }
  function write_SHEETPROTECT(ba, ws) {
    if (!ws["!protect"])
      return;
    write_record(ba, 535, write_BrtSheetProtection(ws["!protect"]));
  }
  function write_ws_bin(idx, opts, wb, rels) {
    var ba = buf_array();
    var s2 = wb.SheetNames[idx], ws = wb.Sheets[s2] || {};
    var c2 = s2;
    try {
      if (wb && wb.Workbook)
        c2 = wb.Workbook.Sheets[idx].CodeName || c2;
    } catch (e) {
    }
    var r = safe_decode_range(ws["!ref"] || "A1");
    if (r.e.c > 16383 || r.e.r > 1048575) {
      if (opts.WTF)
        throw new Error("Range " + (ws["!ref"] || "A1") + " exceeds format limit A1:XFD1048576");
      r.e.c = Math.min(r.e.c, 16383);
      r.e.r = Math.min(r.e.c, 1048575);
    }
    ws["!links"] = [];
    ws["!comments"] = [];
    write_record(ba, 129);
    if (wb.vbaraw || ws["!outline"])
      write_record(ba, 147, write_BrtWsProp(c2, ws["!outline"]));
    write_record(ba, 148, write_BrtWsDim(r));
    write_WSVIEWS2(ba, ws, wb.Workbook);
    write_COLINFOS(ba, ws);
    write_CELLTABLE(ba, ws, idx, opts);
    write_SHEETPROTECT(ba, ws);
    write_AUTOFILTER(ba, ws, wb, idx);
    write_MERGECELLS(ba, ws);
    write_HLINKS(ba, ws, rels);
    if (ws["!margins"])
      write_record(ba, 476, write_BrtMargins(ws["!margins"]));
    if (!opts || opts.ignoreEC || opts.ignoreEC == void 0)
      write_IGNOREECS(ba, ws);
    write_LEGACYDRAWING(ba, ws, idx, rels);
    write_record(ba, 130);
    return ba.end();
  }
  function parse_Cache(data) {
    var col = [];
    var num = data.match(/^<c:numCache>/);
    var f2;
    (data.match(/<c:pt idx="(\d*)">(.*?)<\/c:pt>/mg) || []).forEach(function(pt2) {
      var q2 = pt2.match(/<c:pt idx="(\d*?)"><c:v>(.*)<\/c:v><\/c:pt>/);
      if (!q2)
        return;
      col[+q2[1]] = num ? +q2[2] : q2[2];
    });
    var nf = unescapexml((data.match(/<c:formatCode>([\s\S]*?)<\/c:formatCode>/) || ["", "General"])[1]);
    (data.match(/<c:f>(.*?)<\/c:f>/mg) || []).forEach(function(F2) {
      f2 = F2.replace(/<.*?>/g, "");
    });
    return [col, nf, f2];
  }
  function parse_chart(data, name, opts, rels, wb, csheet) {
    var cs = csheet || { "!type": "chart" };
    if (!data)
      return csheet;
    var C2 = 0, R2 = 0, col = "A";
    var refguess = { s: { r: 2e6, c: 2e6 }, e: { r: 0, c: 0 } };
    (data.match(/<c:numCache>[\s\S]*?<\/c:numCache>/gm) || []).forEach(function(nc) {
      var cache = parse_Cache(nc);
      refguess.s.r = refguess.s.c = 0;
      refguess.e.c = C2;
      col = encode_col(C2);
      cache[0].forEach(function(n, i) {
        cs[col + encode_row(i)] = { t: "n", v: n, z: cache[1] };
        R2 = i;
      });
      if (refguess.e.r < R2)
        refguess.e.r = R2;
      ++C2;
    });
    if (C2 > 0)
      cs["!ref"] = encode_range(refguess);
    return cs;
  }
  function parse_cs_xml(data, opts, idx, rels, wb) {
    if (!data)
      return data;
    if (!rels)
      rels = { "!id": {} };
    var s2 = { "!type": "chart", "!drawel": null, "!rel": "" };
    var m2;
    var sheetPr = data.match(sheetprregex);
    if (sheetPr)
      parse_ws_xml_sheetpr(sheetPr[0], s2, wb, idx);
    if (m2 = data.match(/drawing r:id="(.*?)"/))
      s2["!rel"] = m2[1];
    if (rels["!id"][s2["!rel"]])
      s2["!drawel"] = rels["!id"][s2["!rel"]];
    return s2;
  }
  function parse_BrtCsProp(data, length) {
    data.l += 10;
    var name = parse_XLWideString(data);
    return { name };
  }
  function parse_cs_bin(data, opts, idx, rels, wb) {
    if (!data)
      return data;
    if (!rels)
      rels = { "!id": {} };
    var s2 = { "!type": "chart", "!drawel": null, "!rel": "" };
    var pass = false;
    recordhopper(data, function cs_parse(val, R2, RT) {
      switch (RT) {
        case 550:
          s2["!rel"] = val;
          break;
        case 651:
          if (!wb.Sheets[idx])
            wb.Sheets[idx] = {};
          if (val.name)
            wb.Sheets[idx].CodeName = val.name;
          break;
        case 562:
        case 652:
        case 669:
        case 679:
        case 551:
        case 552:
        case 476:
        case 3072:
          break;
        case 35:
          pass = true;
          break;
        case 36:
          pass = false;
          break;
        case 37:
          break;
        case 38:
          break;
        default:
          if (R2.T > 0)
            ;
          else if (R2.T < 0)
            ;
          else if (!pass || opts.WTF)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    }, opts);
    if (rels["!id"][s2["!rel"]])
      s2["!drawel"] = rels["!id"][s2["!rel"]];
    return s2;
  }
  var WBPropsDef = [
    ["allowRefreshQuery", false, "bool"],
    ["autoCompressPictures", true, "bool"],
    ["backupFile", false, "bool"],
    ["checkCompatibility", false, "bool"],
    ["CodeName", ""],
    ["date1904", false, "bool"],
    ["defaultThemeVersion", 0, "int"],
    ["filterPrivacy", false, "bool"],
    ["hidePivotFieldList", false, "bool"],
    ["promptedSolutions", false, "bool"],
    ["publishItems", false, "bool"],
    ["refreshAllConnections", false, "bool"],
    ["saveExternalLinkValues", true, "bool"],
    ["showBorderUnselectedTables", true, "bool"],
    ["showInkAnnotation", true, "bool"],
    ["showObjects", "all"],
    ["showPivotChartFilter", false, "bool"],
    ["updateLinks", "userSet"]
  ];
  var WBViewDef = [
    ["activeTab", 0, "int"],
    ["autoFilterDateGrouping", true, "bool"],
    ["firstSheet", 0, "int"],
    ["minimized", false, "bool"],
    ["showHorizontalScroll", true, "bool"],
    ["showSheetTabs", true, "bool"],
    ["showVerticalScroll", true, "bool"],
    ["tabRatio", 600, "int"],
    ["visibility", "visible"]
  ];
  var SheetDef = [];
  var CalcPrDef = [
    ["calcCompleted", "true"],
    ["calcMode", "auto"],
    ["calcOnSave", "true"],
    ["concurrentCalc", "true"],
    ["fullCalcOnLoad", "false"],
    ["fullPrecision", "true"],
    ["iterate", "false"],
    ["iterateCount", "100"],
    ["iterateDelta", "0.001"],
    ["refMode", "A1"]
  ];
  function push_defaults_array(target, defaults) {
    for (var j = 0; j != target.length; ++j) {
      var w2 = target[j];
      for (var i = 0; i != defaults.length; ++i) {
        var z = defaults[i];
        if (w2[z[0]] == null)
          w2[z[0]] = z[1];
        else
          switch (z[2]) {
            case "bool":
              if (typeof w2[z[0]] == "string")
                w2[z[0]] = parsexmlbool(w2[z[0]]);
              break;
            case "int":
              if (typeof w2[z[0]] == "string")
                w2[z[0]] = parseInt(w2[z[0]], 10);
              break;
          }
      }
    }
  }
  function push_defaults(target, defaults) {
    for (var i = 0; i != defaults.length; ++i) {
      var z = defaults[i];
      if (target[z[0]] == null)
        target[z[0]] = z[1];
      else
        switch (z[2]) {
          case "bool":
            if (typeof target[z[0]] == "string")
              target[z[0]] = parsexmlbool(target[z[0]]);
            break;
          case "int":
            if (typeof target[z[0]] == "string")
              target[z[0]] = parseInt(target[z[0]], 10);
            break;
        }
    }
  }
  function parse_wb_defaults(wb) {
    push_defaults(wb.WBProps, WBPropsDef);
    push_defaults(wb.CalcPr, CalcPrDef);
    push_defaults_array(wb.WBView, WBViewDef);
    push_defaults_array(wb.Sheets, SheetDef);
    _ssfopts.date1904 = parsexmlbool(wb.WBProps.date1904);
  }
  function safe1904(wb) {
    if (!wb.Workbook)
      return "false";
    if (!wb.Workbook.WBProps)
      return "false";
    return parsexmlbool(wb.Workbook.WBProps.date1904) ? "true" : "false";
  }
  var badchars = /* @__PURE__ */ "][*?/\\".split("");
  function check_ws_name(n, safe) {
    if (n.length > 31) {
      if (safe)
        return false;
      throw new Error("Sheet names cannot exceed 31 chars");
    }
    var _good = true;
    badchars.forEach(function(c2) {
      if (n.indexOf(c2) == -1)
        return;
      if (!safe)
        throw new Error("Sheet name cannot contain : \\ / ? * [ ]");
      _good = false;
    });
    return _good;
  }
  function check_wb_names(N2, S2, codes) {
    N2.forEach(function(n, i) {
      check_ws_name(n);
      for (var j = 0; j < i; ++j)
        if (n == N2[j])
          throw new Error("Duplicate Sheet Name: " + n);
      if (codes) {
        var cn2 = S2 && S2[i] && S2[i].CodeName || n;
        if (cn2.charCodeAt(0) == 95 && cn2.length > 22)
          throw new Error("Bad Code Name: Worksheet" + cn2);
      }
    });
  }
  function check_wb(wb) {
    if (!wb || !wb.SheetNames || !wb.Sheets)
      throw new Error("Invalid Workbook");
    if (!wb.SheetNames.length)
      throw new Error("Workbook is empty");
    var Sheets = wb.Workbook && wb.Workbook.Sheets || [];
    check_wb_names(wb.SheetNames, Sheets, !!wb.vbaraw);
    for (var i = 0; i < wb.SheetNames.length; ++i)
      check_ws(wb.Sheets[wb.SheetNames[i]], wb.SheetNames[i], i);
  }
  var wbnsregex = /<\w+:workbook/;
  function parse_wb_xml(data, opts) {
    if (!data)
      throw new Error("Could not find file");
    var wb = { AppVersion: {}, WBProps: {}, WBView: [], Sheets: [], CalcPr: {}, Names: [], xmlns: "" };
    var pass = false, xmlns = "xmlns";
    var dname = {}, dnstart = 0;
    data.replace(tagregex, function xml_wb(x2, idx) {
      var y = parsexmltag(x2);
      switch (strip_ns(y[0])) {
        case "<?xml":
          break;
        case "<workbook":
          if (x2.match(wbnsregex))
            xmlns = "xmlns" + x2.match(/<(\w+):/)[1];
          wb.xmlns = y[xmlns];
          break;
        case "</workbook>":
          break;
        case "<fileVersion":
          delete y[0];
          wb.AppVersion = y;
          break;
        case "<fileVersion/>":
        case "</fileVersion>":
          break;
        case "<fileSharing":
          break;
        case "<fileSharing/>":
          break;
        case "<workbookPr":
        case "<workbookPr/>":
          WBPropsDef.forEach(function(w2) {
            if (y[w2[0]] == null)
              return;
            switch (w2[2]) {
              case "bool":
                wb.WBProps[w2[0]] = parsexmlbool(y[w2[0]]);
                break;
              case "int":
                wb.WBProps[w2[0]] = parseInt(y[w2[0]], 10);
                break;
              default:
                wb.WBProps[w2[0]] = y[w2[0]];
            }
          });
          if (y.codeName)
            wb.WBProps.CodeName = utf8read(y.codeName);
          break;
        case "</workbookPr>":
          break;
        case "<workbookProtection":
          break;
        case "<workbookProtection/>":
          break;
        case "<bookViews":
        case "<bookViews>":
        case "</bookViews>":
          break;
        case "<workbookView":
        case "<workbookView/>":
          delete y[0];
          wb.WBView.push(y);
          break;
        case "</workbookView>":
          break;
        case "<sheets":
        case "<sheets>":
        case "</sheets>":
          break;
        case "<sheet":
          switch (y.state) {
            case "hidden":
              y.Hidden = 1;
              break;
            case "veryHidden":
              y.Hidden = 2;
              break;
            default:
              y.Hidden = 0;
          }
          delete y.state;
          y.name = unescapexml(utf8read(y.name));
          delete y[0];
          wb.Sheets.push(y);
          break;
        case "</sheet>":
          break;
        case "<functionGroups":
        case "<functionGroups/>":
          break;
        case "<functionGroup":
          break;
        case "<externalReferences":
        case "</externalReferences>":
        case "<externalReferences>":
          break;
        case "<externalReference":
          break;
        case "<definedNames/>":
          break;
        case "<definedNames>":
        case "<definedNames":
          pass = true;
          break;
        case "</definedNames>":
          pass = false;
          break;
        case "<definedName":
          {
            dname = {};
            dname.Name = utf8read(y.name);
            if (y.comment)
              dname.Comment = y.comment;
            if (y.localSheetId)
              dname.Sheet = +y.localSheetId;
            if (parsexmlbool(y.hidden || "0"))
              dname.Hidden = true;
            dnstart = idx + x2.length;
          }
          break;
        case "</definedName>":
          {
            dname.Ref = unescapexml(utf8read(data.slice(dnstart, idx)));
            wb.Names.push(dname);
          }
          break;
        case "<definedName/>":
          break;
        case "<calcPr":
          delete y[0];
          wb.CalcPr = y;
          break;
        case "<calcPr/>":
          delete y[0];
          wb.CalcPr = y;
          break;
        case "</calcPr>":
          break;
        case "<oleSize":
          break;
        case "<customWorkbookViews>":
        case "</customWorkbookViews>":
        case "<customWorkbookViews":
          break;
        case "<customWorkbookView":
        case "</customWorkbookView>":
          break;
        case "<pivotCaches>":
        case "</pivotCaches>":
        case "<pivotCaches":
          break;
        case "<pivotCache":
          break;
        case "<smartTagPr":
        case "<smartTagPr/>":
          break;
        case "<smartTagTypes":
        case "<smartTagTypes>":
        case "</smartTagTypes>":
          break;
        case "<smartTagType":
          break;
        case "<webPublishing":
        case "<webPublishing/>":
          break;
        case "<fileRecoveryPr":
        case "<fileRecoveryPr/>":
          break;
        case "<webPublishObjects>":
        case "<webPublishObjects":
        case "</webPublishObjects>":
          break;
        case "<webPublishObject":
          break;
        case "<extLst":
        case "<extLst>":
        case "</extLst>":
        case "<extLst/>":
          break;
        case "<ext":
          pass = true;
          break;
        case "</ext>":
          pass = false;
          break;
        case "<ArchID":
          break;
        case "<AlternateContent":
        case "<AlternateContent>":
          pass = true;
          break;
        case "</AlternateContent>":
          pass = false;
          break;
        case "<revisionPtr":
          break;
        default:
          if (!pass && opts.WTF)
            throw new Error("unrecognized " + y[0] + " in workbook");
      }
      return x2;
    });
    if (XMLNS_main.indexOf(wb.xmlns) === -1)
      throw new Error("Unknown Namespace: " + wb.xmlns);
    parse_wb_defaults(wb);
    return wb;
  }
  function write_wb_xml(wb) {
    var o2 = [XML_HEADER];
    o2[o2.length] = writextag("workbook", null, {
      "xmlns": XMLNS_main[0],
      "xmlns:r": XMLNS.r
    });
    var write_names = wb.Workbook && (wb.Workbook.Names || []).length > 0;
    var workbookPr = { codeName: "ThisWorkbook" };
    if (wb.Workbook && wb.Workbook.WBProps) {
      WBPropsDef.forEach(function(x2) {
        if (wb.Workbook.WBProps[x2[0]] == null)
          return;
        if (wb.Workbook.WBProps[x2[0]] == x2[1])
          return;
        workbookPr[x2[0]] = wb.Workbook.WBProps[x2[0]];
      });
      if (wb.Workbook.WBProps.CodeName) {
        workbookPr.codeName = wb.Workbook.WBProps.CodeName;
        delete workbookPr.CodeName;
      }
    }
    o2[o2.length] = writextag("workbookPr", null, workbookPr);
    var sheets = wb.Workbook && wb.Workbook.Sheets || [];
    var i = 0;
    if (sheets && sheets[0] && !!sheets[0].Hidden) {
      o2[o2.length] = "<bookViews>";
      for (i = 0; i != wb.SheetNames.length; ++i) {
        if (!sheets[i])
          break;
        if (!sheets[i].Hidden)
          break;
      }
      if (i == wb.SheetNames.length)
        i = 0;
      o2[o2.length] = '<workbookView firstSheet="' + i + '" activeTab="' + i + '"/>';
      o2[o2.length] = "</bookViews>";
    }
    o2[o2.length] = "<sheets>";
    for (i = 0; i != wb.SheetNames.length; ++i) {
      var sht = { name: escapexml(wb.SheetNames[i].slice(0, 31)) };
      sht.sheetId = "" + (i + 1);
      sht["r:id"] = "rId" + (i + 1);
      if (sheets[i])
        switch (sheets[i].Hidden) {
          case 1:
            sht.state = "hidden";
            break;
          case 2:
            sht.state = "veryHidden";
            break;
        }
      o2[o2.length] = writextag("sheet", null, sht);
    }
    o2[o2.length] = "</sheets>";
    if (write_names) {
      o2[o2.length] = "<definedNames>";
      if (wb.Workbook && wb.Workbook.Names)
        wb.Workbook.Names.forEach(function(n) {
          var d2 = { name: n.Name };
          if (n.Comment)
            d2.comment = n.Comment;
          if (n.Sheet != null)
            d2.localSheetId = "" + n.Sheet;
          if (n.Hidden)
            d2.hidden = "1";
          if (!n.Ref)
            return;
          o2[o2.length] = writextag("definedName", escapexml(n.Ref), d2);
        });
      o2[o2.length] = "</definedNames>";
    }
    if (o2.length > 2) {
      o2[o2.length] = "</workbook>";
      o2[1] = o2[1].replace("/>", ">");
    }
    return o2.join("");
  }
  function parse_BrtBundleSh(data, length) {
    var z = {};
    z.Hidden = data.read_shift(4);
    z.iTabID = data.read_shift(4);
    z.strRelID = parse_RelID(data);
    z.name = parse_XLWideString(data);
    return z;
  }
  function write_BrtBundleSh(data, o2) {
    if (!o2)
      o2 = new_buf(127);
    o2.write_shift(4, data.Hidden);
    o2.write_shift(4, data.iTabID);
    write_RelID(data.strRelID, o2);
    write_XLWideString(data.name.slice(0, 31), o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function parse_BrtWbProp(data, length) {
    var o2 = {};
    var flags = data.read_shift(4);
    o2.defaultThemeVersion = data.read_shift(4);
    var strName = length > 8 ? parse_XLWideString(data) : "";
    if (strName.length > 0)
      o2.CodeName = strName;
    o2.autoCompressPictures = !!(flags & 65536);
    o2.backupFile = !!(flags & 64);
    o2.checkCompatibility = !!(flags & 4096);
    o2.date1904 = !!(flags & 1);
    o2.filterPrivacy = !!(flags & 8);
    o2.hidePivotFieldList = !!(flags & 1024);
    o2.promptedSolutions = !!(flags & 16);
    o2.publishItems = !!(flags & 2048);
    o2.refreshAllConnections = !!(flags & 262144);
    o2.saveExternalLinkValues = !!(flags & 128);
    o2.showBorderUnselectedTables = !!(flags & 4);
    o2.showInkAnnotation = !!(flags & 32);
    o2.showObjects = ["all", "placeholders", "none"][flags >> 13 & 3];
    o2.showPivotChartFilter = !!(flags & 32768);
    o2.updateLinks = ["userSet", "never", "always"][flags >> 8 & 3];
    return o2;
  }
  function write_BrtWbProp(data, o2) {
    if (!o2)
      o2 = new_buf(72);
    var flags = 0;
    if (data) {
      if (data.filterPrivacy)
        flags |= 8;
    }
    o2.write_shift(4, flags);
    o2.write_shift(4, 0);
    write_XLSBCodeName(data && data.CodeName || "ThisWorkbook", o2);
    return o2.slice(0, o2.l);
  }
  function parse_BrtFRTArchID$(data, length) {
    var o2 = {};
    data.read_shift(4);
    o2.ArchID = data.read_shift(4);
    data.l += length - 8;
    return o2;
  }
  function parse_BrtName(data, length, opts) {
    var end = data.l + length;
    data.l += 4;
    data.l += 1;
    var itab = data.read_shift(4);
    var name = parse_XLNameWideString(data);
    var formula = parse_XLSBNameParsedFormula(data, 0, opts);
    var comment = parse_XLNullableWideString(data);
    data.l = end;
    var out = { Name: name, Ptg: formula };
    if (itab < 268435455)
      out.Sheet = itab;
    if (comment)
      out.Comment = comment;
    return out;
  }
  function parse_wb_bin(data, opts) {
    var wb = { AppVersion: {}, WBProps: {}, WBView: [], Sheets: [], CalcPr: {}, xmlns: "" };
    var state = [];
    var pass = false;
    if (!opts)
      opts = {};
    opts.biff = 12;
    var Names = [];
    var supbooks = [[]];
    supbooks.SheetNames = [];
    supbooks.XTI = [];
    XLSBRecordEnum[16] = { n: "BrtFRTArchID$", f: parse_BrtFRTArchID$ };
    recordhopper(data, function hopper_wb(val, R2, RT) {
      switch (RT) {
        case 156:
          supbooks.SheetNames.push(val.name);
          wb.Sheets.push(val);
          break;
        case 153:
          wb.WBProps = val;
          break;
        case 39:
          if (val.Sheet != null)
            opts.SID = val.Sheet;
          val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
          delete opts.SID;
          delete val.Ptg;
          Names.push(val);
          break;
        case 1036:
          break;
        case 357:
        case 358:
        case 355:
        case 667:
          if (!supbooks[0].length)
            supbooks[0] = [RT, val];
          else
            supbooks.push([RT, val]);
          supbooks[supbooks.length - 1].XTI = [];
          break;
        case 362:
          if (supbooks.length === 0) {
            supbooks[0] = [];
            supbooks[0].XTI = [];
          }
          supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
          supbooks.XTI = supbooks.XTI.concat(val);
          break;
        case 361:
          break;
        case 2071:
        case 158:
        case 143:
        case 664:
        case 353:
          break;
        case 3072:
        case 3073:
        case 534:
        case 677:
        case 157:
        case 610:
        case 2050:
        case 155:
        case 548:
        case 676:
        case 128:
        case 665:
        case 2128:
        case 2125:
        case 549:
        case 2053:
        case 596:
        case 2076:
        case 2075:
        case 2082:
        case 397:
        case 154:
        case 1117:
        case 553:
        case 2091:
          break;
        case 35:
          state.push(RT);
          pass = true;
          break;
        case 36:
          state.pop();
          pass = false;
          break;
        case 37:
          state.push(RT);
          pass = true;
          break;
        case 38:
          state.pop();
          pass = false;
          break;
        case 16:
          break;
        default:
          if (R2.T)
            ;
          else if (!pass || opts.WTF && state[state.length - 1] != 37 && state[state.length - 1] != 35)
            throw new Error("Unexpected record 0x" + RT.toString(16));
      }
    }, opts);
    parse_wb_defaults(wb);
    wb.Names = Names;
    wb.supbooks = supbooks;
    return wb;
  }
  function write_BUNDLESHS(ba, wb) {
    write_record(ba, 143);
    for (var idx = 0; idx != wb.SheetNames.length; ++idx) {
      var viz = wb.Workbook && wb.Workbook.Sheets && wb.Workbook.Sheets[idx] && wb.Workbook.Sheets[idx].Hidden || 0;
      var d2 = { Hidden: viz, iTabID: idx + 1, strRelID: "rId" + (idx + 1), name: wb.SheetNames[idx] };
      write_record(ba, 156, write_BrtBundleSh(d2));
    }
    write_record(ba, 144);
  }
  function write_BrtFileVersion(data, o2) {
    if (!o2)
      o2 = new_buf(127);
    for (var i = 0; i != 4; ++i)
      o2.write_shift(4, 0);
    write_XLWideString("SheetJS", o2);
    write_XLWideString(XLSX.version, o2);
    write_XLWideString(XLSX.version, o2);
    write_XLWideString("7262", o2);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function write_BrtBookView(idx, o2) {
    if (!o2)
      o2 = new_buf(29);
    o2.write_shift(-4, 0);
    o2.write_shift(-4, 460);
    o2.write_shift(4, 28800);
    o2.write_shift(4, 17600);
    o2.write_shift(4, 500);
    o2.write_shift(4, idx);
    o2.write_shift(4, idx);
    var flags = 120;
    o2.write_shift(1, flags);
    return o2.length > o2.l ? o2.slice(0, o2.l) : o2;
  }
  function write_BOOKVIEWS(ba, wb) {
    if (!wb.Workbook || !wb.Workbook.Sheets)
      return;
    var sheets = wb.Workbook.Sheets;
    var i = 0, vistab = -1, hidden = -1;
    for (; i < sheets.length; ++i) {
      if (!sheets[i] || !sheets[i].Hidden && vistab == -1)
        vistab = i;
      else if (sheets[i].Hidden == 1 && hidden == -1)
        hidden = i;
    }
    if (hidden > vistab)
      return;
    write_record(ba, 135);
    write_record(ba, 158, write_BrtBookView(vistab));
    write_record(ba, 136);
  }
  function write_wb_bin(wb, opts) {
    var ba = buf_array();
    write_record(ba, 131);
    write_record(ba, 128, write_BrtFileVersion());
    write_record(ba, 153, write_BrtWbProp(wb.Workbook && wb.Workbook.WBProps || null));
    write_BOOKVIEWS(ba, wb);
    write_BUNDLESHS(ba, wb);
    write_record(ba, 132);
    return ba.end();
  }
  function parse_wb(data, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_wb_bin(data, opts);
    return parse_wb_xml(data, opts);
  }
  function parse_ws(data, name, idx, opts, rels, wb, themes, styles) {
    if (name.slice(-4) === ".bin")
      return parse_ws_bin(data, opts, idx, rels, wb, themes, styles);
    return parse_ws_xml(data, opts, idx, rels, wb, themes, styles);
  }
  function parse_cs(data, name, idx, opts, rels, wb, themes, styles) {
    if (name.slice(-4) === ".bin")
      return parse_cs_bin(data, opts, idx, rels, wb);
    return parse_cs_xml(data, opts, idx, rels, wb);
  }
  function parse_ms(data, name, idx, opts, rels, wb, themes, styles) {
    if (name.slice(-4) === ".bin")
      return parse_ms_bin();
    return parse_ms_xml();
  }
  function parse_ds(data, name, idx, opts, rels, wb, themes, styles) {
    if (name.slice(-4) === ".bin")
      return parse_ds_bin();
    return parse_ds_xml();
  }
  function parse_sty(data, name, themes, opts) {
    if (name.slice(-4) === ".bin")
      return parse_sty_bin(data, themes, opts);
    return parse_sty_xml(data, themes, opts);
  }
  function parse_theme(data, name, opts) {
    return parse_theme_xml(data, opts);
  }
  function parse_sst(data, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_sst_bin(data, opts);
    return parse_sst_xml(data, opts);
  }
  function parse_cmnt(data, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_comments_bin(data, opts);
    return parse_comments_xml(data, opts);
  }
  function parse_cc(data, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_cc_bin(data);
    return parse_cc_xml(data);
  }
  function parse_xlink(data, rel, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_xlink_bin(data, rel, name, opts);
    return parse_xlink_xml();
  }
  function parse_xlmeta(data, name, opts) {
    if (name.slice(-4) === ".bin")
      return parse_xlmeta_bin(data, name, opts);
    return parse_xlmeta_xml(data, name, opts);
  }
  function write_wb(wb, name, opts) {
    return (name.slice(-4) === ".bin" ? write_wb_bin : write_wb_xml)(wb);
  }
  function write_ws(data, name, opts, wb, rels) {
    return (name.slice(-4) === ".bin" ? write_ws_bin : write_ws_xml)(data, opts, wb, rels);
  }
  function write_sty(data, name, opts) {
    return (name.slice(-4) === ".bin" ? write_sty_bin : write_sty_xml)(data, opts);
  }
  function write_sst(data, name, opts) {
    return (name.slice(-4) === ".bin" ? write_sst_bin : write_sst_xml)(data, opts);
  }
  function write_cmnt(data, name, opts) {
    return (name.slice(-4) === ".bin" ? write_comments_bin : write_comments_xml)(data);
  }
  function write_xlmeta(name) {
    return (name.slice(-4) === ".bin" ? write_xlmeta_bin : write_xlmeta_xml)();
  }
  var attregexg2 = /([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
  var attregex2 = /([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
  function xlml_parsexmltag(tag, skip_root) {
    var words = tag.split(/\s+/);
    var z = [];
    if (!skip_root)
      z[0] = words[0];
    if (words.length === 1)
      return z;
    var m2 = tag.match(attregexg2), y, j, w2, i;
    if (m2)
      for (i = 0; i != m2.length; ++i) {
        y = m2[i].match(attregex2);
        if ((j = y[1].indexOf(":")) === -1)
          z[y[1]] = y[2].slice(1, y[2].length - 1);
        else {
          if (y[1].slice(0, 6) === "xmlns:")
            w2 = "xmlns" + y[1].slice(6);
          else
            w2 = y[1].slice(j + 1);
          z[w2] = y[2].slice(1, y[2].length - 1);
        }
      }
    return z;
  }
  function xlml_parsexmltagobj(tag) {
    var words = tag.split(/\s+/);
    var z = {};
    if (words.length === 1)
      return z;
    var m2 = tag.match(attregexg2), y, j, w2, i;
    if (m2)
      for (i = 0; i != m2.length; ++i) {
        y = m2[i].match(attregex2);
        if ((j = y[1].indexOf(":")) === -1)
          z[y[1]] = y[2].slice(1, y[2].length - 1);
        else {
          if (y[1].slice(0, 6) === "xmlns:")
            w2 = "xmlns" + y[1].slice(6);
          else
            w2 = y[1].slice(j + 1);
          z[w2] = y[2].slice(1, y[2].length - 1);
        }
      }
    return z;
  }
  var XLMLFormatMap;
  function xlml_format(format, value) {
    var fmt = XLMLFormatMap[format] || unescapexml(format);
    if (fmt === "General")
      return SSF_general(value);
    return SSF_format(fmt, value);
  }
  function xlml_set_custprop(Custprops, key, cp, val) {
    var oval = val;
    switch ((cp[0].match(/dt:dt="([\w.]+)"/) || ["", ""])[1]) {
      case "boolean":
        oval = parsexmlbool(val);
        break;
      case "i2":
      case "int":
        oval = parseInt(val, 10);
        break;
      case "r4":
      case "float":
        oval = parseFloat(val);
        break;
      case "date":
      case "dateTime.tz":
        oval = parseDate(val);
        break;
      case "i8":
      case "string":
      case "fixed":
      case "uuid":
      case "bin.base64":
        break;
      default:
        throw new Error("bad custprop:" + cp[0]);
    }
    Custprops[unescapexml(key)] = oval;
  }
  function safe_format_xlml(cell, nf, o2) {
    if (cell.t === "z")
      return;
    if (!o2 || o2.cellText !== false)
      try {
        if (cell.t === "e") {
          cell.w = cell.w || BErr[cell.v];
        } else if (nf === "General") {
          if (cell.t === "n") {
            if ((cell.v | 0) === cell.v)
              cell.w = cell.v.toString(10);
            else
              cell.w = SSF_general_num(cell.v);
          } else
            cell.w = SSF_general(cell.v);
        } else
          cell.w = xlml_format(nf || "General", cell.v);
      } catch (e) {
        if (o2.WTF)
          throw e;
      }
    try {
      var z = XLMLFormatMap[nf] || nf || "General";
      if (o2.cellNF)
        cell.z = z;
      if (o2.cellDates && cell.t == "n" && fmt_is_date(z)) {
        var _d = SSF_parse_date_code(cell.v);
        if (_d) {
          cell.t = "d";
          cell.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);
        }
      }
    } catch (e) {
      if (o2.WTF)
        throw e;
    }
  }
  function process_style_xlml(styles, stag, opts) {
    if (opts.cellStyles) {
      if (stag.Interior) {
        var I2 = stag.Interior;
        if (I2.Pattern)
          I2.patternType = XLMLPatternTypeMap[I2.Pattern] || I2.Pattern;
      }
    }
    styles[stag.ID] = stag;
  }
  function parse_xlml_data(xml, ss, data, cell, base, styles, csty, row, arrayf, o2) {
    var nf = "General", sid = cell.StyleID, S2 = {};
    o2 = o2 || {};
    var interiors = [];
    var i = 0;
    if (sid === void 0 && row)
      sid = row.StyleID;
    if (sid === void 0 && csty)
      sid = csty.StyleID;
    while (styles[sid] !== void 0) {
      if (styles[sid].nf)
        nf = styles[sid].nf;
      if (styles[sid].Interior)
        interiors.push(styles[sid].Interior);
      if (!styles[sid].Parent)
        break;
      sid = styles[sid].Parent;
    }
    switch (data.Type) {
      case "Boolean":
        cell.t = "b";
        cell.v = parsexmlbool(xml);
        break;
      case "String":
        cell.t = "s";
        cell.r = xlml_fixstr(unescapexml(xml));
        cell.v = xml.indexOf("<") > -1 ? unescapexml(ss || xml).replace(/<.*?>/g, "") : cell.r;
        break;
      case "DateTime":
        if (xml.slice(-1) != "Z")
          xml += "Z";
        cell.v = (parseDate(xml) - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1e3);
        if (cell.v !== cell.v)
          cell.v = unescapexml(xml);
        else if (cell.v < 60)
          cell.v = cell.v - 1;
        if (!nf || nf == "General")
          nf = "yyyy-mm-dd";
      case "Number":
        if (cell.v === void 0)
          cell.v = +xml;
        if (!cell.t)
          cell.t = "n";
        break;
      case "Error":
        cell.t = "e";
        cell.v = RBErr[xml];
        if (o2.cellText !== false)
          cell.w = xml;
        break;
      default:
        if (xml == "" && ss == "") {
          cell.t = "z";
        } else {
          cell.t = "s";
          cell.v = xlml_fixstr(ss || xml);
        }
        break;
    }
    safe_format_xlml(cell, nf, o2);
    if (o2.cellFormula !== false) {
      if (cell.Formula) {
        var fstr = unescapexml(cell.Formula);
        if (fstr.charCodeAt(0) == 61)
          fstr = fstr.slice(1);
        cell.f = rc_to_a1(fstr, base);
        delete cell.Formula;
        if (cell.ArrayRange == "RC")
          cell.F = rc_to_a1("RC:RC", base);
        else if (cell.ArrayRange) {
          cell.F = rc_to_a1(cell.ArrayRange, base);
          arrayf.push([safe_decode_range(cell.F), cell.F]);
        }
      } else {
        for (i = 0; i < arrayf.length; ++i)
          if (base.r >= arrayf[i][0].s.r && base.r <= arrayf[i][0].e.r) {
            if (base.c >= arrayf[i][0].s.c && base.c <= arrayf[i][0].e.c)
              cell.F = arrayf[i][1];
          }
      }
    }
    if (o2.cellStyles) {
      interiors.forEach(function(x2) {
        if (!S2.patternType && x2.patternType)
          S2.patternType = x2.patternType;
      });
      cell.s = S2;
    }
    if (cell.StyleID !== void 0)
      cell.ixfe = cell.StyleID;
  }
  function xlml_clean_comment(comment) {
    comment.t = comment.v || "";
    comment.t = comment.t.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
    comment.v = comment.w = comment.ixfe = void 0;
  }
  function parse_xlml_xml(d2, _opts) {
    var opts = _opts || {};
    make_ssf();
    var str = debom(xlml_normalize(d2));
    if (opts.type == "binary" || opts.type == "array" || opts.type == "base64") {
      str = utf8read(str);
    }
    var opening = str.slice(0, 1024).toLowerCase(), ishtml = false;
    opening = opening.replace(/".*?"/g, "");
    if ((opening.indexOf(">") & 1023) > Math.min(opening.indexOf(",") & 1023, opening.indexOf(";") & 1023)) {
      var _o = dup(opts);
      _o.type = "string";
      return PRN.to_workbook(str, _o);
    }
    if (opening.indexOf("<?xml") == -1)
      ["html", "table", "head", "meta", "script", "style", "div"].forEach(function(tag) {
        if (opening.indexOf("<" + tag) >= 0)
          ishtml = true;
      });
    if (ishtml)
      return html_to_workbook(str, opts);
    XLMLFormatMap = {
      "General Number": "General",
      "General Date": table_fmt[22],
      "Long Date": "dddd, mmmm dd, yyyy",
      "Medium Date": table_fmt[15],
      "Short Date": table_fmt[14],
      "Long Time": table_fmt[19],
      "Medium Time": table_fmt[18],
      "Short Time": table_fmt[20],
      "Currency": '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
      "Fixed": table_fmt[2],
      "Standard": table_fmt[4],
      "Percent": table_fmt[10],
      "Scientific": table_fmt[11],
      "Yes/No": '"Yes";"Yes";"No";@',
      "True/False": '"True";"True";"False";@',
      "On/Off": '"Yes";"Yes";"No";@'
    };
    var Rn;
    var state = [], tmp;
    var sheets = {}, sheetnames = [], cursheet = opts.dense ? [] : {}, sheetname = "";
    var cell = {}, row = {};
    var dtag = xlml_parsexmltag('<Data ss:Type="String">'), didx = 0;
    var c2 = 0, r = 0;
    var refguess = { s: { r: 2e6, c: 2e6 }, e: { r: 0, c: 0 } };
    var styles = {}, stag = {};
    var ss = "", fidx = 0;
    var merges = [];
    var Props = {}, Custprops = {}, pidx = 0, cp = [];
    var comments = [], comment = {};
    var cstys = [], csty, seencol = false;
    var arrayf = [];
    var rowinfo = [], rowobj = {}, cc = 0, rr = 0;
    var Workbook = { Sheets: [], WBProps: { date1904: false } }, wsprops = {};
    xlmlregex.lastIndex = 0;
    str = str.replace(/<!--([\s\S]*?)-->/mg, "");
    var raw_Rn3 = "";
    while (Rn = xlmlregex.exec(str))
      switch (Rn[3] = (raw_Rn3 = Rn[3]).toLowerCase()) {
        case "data":
          if (raw_Rn3 == "data") {
            if (Rn[1] === "/") {
              if ((tmp = state.pop())[0] !== Rn[3])
                throw new Error("Bad state: " + tmp.join("|"));
            } else if (Rn[0].charAt(Rn[0].length - 2) !== "/")
              state.push([Rn[3], true]);
            break;
          }
          if (state[state.length - 1][1])
            break;
          if (Rn[1] === "/")
            parse_xlml_data(str.slice(didx, Rn.index), ss, dtag, state[state.length - 1][0] == "comment" ? comment : cell, { c: c2, r }, styles, cstys[c2], row, arrayf, opts);
          else {
            ss = "";
            dtag = xlml_parsexmltag(Rn[0]);
            didx = Rn.index + Rn[0].length;
          }
          break;
        case "cell":
          if (Rn[1] === "/") {
            if (comments.length > 0)
              cell.c = comments;
            if ((!opts.sheetRows || opts.sheetRows > r) && cell.v !== void 0) {
              if (opts.dense) {
                if (!cursheet[r])
                  cursheet[r] = [];
                cursheet[r][c2] = cell;
              } else
                cursheet[encode_col(c2) + encode_row(r)] = cell;
            }
            if (cell.HRef) {
              cell.l = { Target: unescapexml(cell.HRef) };
              if (cell.HRefScreenTip)
                cell.l.Tooltip = cell.HRefScreenTip;
              delete cell.HRef;
              delete cell.HRefScreenTip;
            }
            if (cell.MergeAcross || cell.MergeDown) {
              cc = c2 + (parseInt(cell.MergeAcross, 10) | 0);
              rr = r + (parseInt(cell.MergeDown, 10) | 0);
              merges.push({ s: { c: c2, r }, e: { c: cc, r: rr } });
            }
            if (!opts.sheetStubs) {
              if (cell.MergeAcross)
                c2 = cc + 1;
              else
                ++c2;
            } else if (cell.MergeAcross || cell.MergeDown) {
              for (var cma = c2; cma <= cc; ++cma) {
                for (var cmd = r; cmd <= rr; ++cmd) {
                  if (cma > c2 || cmd > r) {
                    if (opts.dense) {
                      if (!cursheet[cmd])
                        cursheet[cmd] = [];
                      cursheet[cmd][cma] = { t: "z" };
                    } else
                      cursheet[encode_col(cma) + encode_row(cmd)] = { t: "z" };
                  }
                }
              }
              c2 = cc + 1;
            } else
              ++c2;
          } else {
            cell = xlml_parsexmltagobj(Rn[0]);
            if (cell.Index)
              c2 = +cell.Index - 1;
            if (c2 < refguess.s.c)
              refguess.s.c = c2;
            if (c2 > refguess.e.c)
              refguess.e.c = c2;
            if (Rn[0].slice(-2) === "/>")
              ++c2;
            comments = [];
          }
          break;
        case "row":
          if (Rn[1] === "/" || Rn[0].slice(-2) === "/>") {
            if (r < refguess.s.r)
              refguess.s.r = r;
            if (r > refguess.e.r)
              refguess.e.r = r;
            if (Rn[0].slice(-2) === "/>") {
              row = xlml_parsexmltag(Rn[0]);
              if (row.Index)
                r = +row.Index - 1;
            }
            c2 = 0;
            ++r;
          } else {
            row = xlml_parsexmltag(Rn[0]);
            if (row.Index)
              r = +row.Index - 1;
            rowobj = {};
            if (row.AutoFitHeight == "0" || row.Height) {
              rowobj.hpx = parseInt(row.Height, 10);
              rowobj.hpt = px2pt(rowobj.hpx);
              rowinfo[r] = rowobj;
            }
            if (row.Hidden == "1") {
              rowobj.hidden = true;
              rowinfo[r] = rowobj;
            }
          }
          break;
        case "worksheet":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
            sheetnames.push(sheetname);
            if (refguess.s.r <= refguess.e.r && refguess.s.c <= refguess.e.c) {
              cursheet["!ref"] = encode_range(refguess);
              if (opts.sheetRows && opts.sheetRows <= refguess.e.r) {
                cursheet["!fullref"] = cursheet["!ref"];
                refguess.e.r = opts.sheetRows - 1;
                cursheet["!ref"] = encode_range(refguess);
              }
            }
            if (merges.length)
              cursheet["!merges"] = merges;
            if (cstys.length > 0)
              cursheet["!cols"] = cstys;
            if (rowinfo.length > 0)
              cursheet["!rows"] = rowinfo;
            sheets[sheetname] = cursheet;
          } else {
            refguess = { s: { r: 2e6, c: 2e6 }, e: { r: 0, c: 0 } };
            r = c2 = 0;
            state.push([Rn[3], false]);
            tmp = xlml_parsexmltag(Rn[0]);
            sheetname = unescapexml(tmp.Name);
            cursheet = opts.dense ? [] : {};
            merges = [];
            arrayf = [];
            rowinfo = [];
            wsprops = { name: sheetname, Hidden: 0 };
            Workbook.Sheets.push(wsprops);
          }
          break;
        case "table":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
          } else if (Rn[0].slice(-2) == "/>")
            break;
          else {
            state.push([Rn[3], false]);
            cstys = [];
            seencol = false;
          }
          break;
        case "style":
          if (Rn[1] === "/")
            process_style_xlml(styles, stag, opts);
          else
            stag = xlml_parsexmltag(Rn[0]);
          break;
        case "numberformat":
          stag.nf = unescapexml(xlml_parsexmltag(Rn[0]).Format || "General");
          if (XLMLFormatMap[stag.nf])
            stag.nf = XLMLFormatMap[stag.nf];
          for (var ssfidx = 0; ssfidx != 392; ++ssfidx)
            if (table_fmt[ssfidx] == stag.nf)
              break;
          if (ssfidx == 392) {
            for (ssfidx = 57; ssfidx != 392; ++ssfidx)
              if (table_fmt[ssfidx] == null) {
                SSF_load(stag.nf, ssfidx);
                break;
              }
          }
          break;
        case "column":
          if (state[state.length - 1][0] !== "table")
            break;
          csty = xlml_parsexmltag(Rn[0]);
          if (csty.Hidden) {
            csty.hidden = true;
            delete csty.Hidden;
          }
          if (csty.Width)
            csty.wpx = parseInt(csty.Width, 10);
          if (!seencol && csty.wpx > 10) {
            seencol = true;
            MDW = DEF_MDW;
            for (var _col = 0; _col < cstys.length; ++_col)
              if (cstys[_col])
                process_col(cstys[_col]);
          }
          if (seencol)
            process_col(csty);
          cstys[csty.Index - 1 || cstys.length] = csty;
          for (var i = 0; i < +csty.Span; ++i)
            cstys[cstys.length] = dup(csty);
          break;
        case "namedrange":
          if (Rn[1] === "/")
            break;
          if (!Workbook.Names)
            Workbook.Names = [];
          var _NamedRange = parsexmltag(Rn[0]);
          var _DefinedName = {
            Name: _NamedRange.Name,
            Ref: rc_to_a1(_NamedRange.RefersTo.slice(1), { r: 0, c: 0 })
          };
          if (Workbook.Sheets.length > 0)
            _DefinedName.Sheet = Workbook.Sheets.length - 1;
          Workbook.Names.push(_DefinedName);
          break;
        case "namedcell":
          break;
        case "b":
          break;
        case "i":
          break;
        case "u":
          break;
        case "s":
          break;
        case "em":
          break;
        case "h2":
          break;
        case "h3":
          break;
        case "sub":
          break;
        case "sup":
          break;
        case "span":
          break;
        case "alignment":
          break;
        case "borders":
          break;
        case "border":
          break;
        case "font":
          if (Rn[0].slice(-2) === "/>")
            break;
          else if (Rn[1] === "/")
            ss += str.slice(fidx, Rn.index);
          else
            fidx = Rn.index + Rn[0].length;
          break;
        case "interior":
          if (!opts.cellStyles)
            break;
          stag.Interior = xlml_parsexmltag(Rn[0]);
          break;
        case "protection":
          break;
        case "author":
        case "title":
        case "description":
        case "created":
        case "keywords":
        case "subject":
        case "category":
        case "company":
        case "lastauthor":
        case "lastsaved":
        case "lastprinted":
        case "version":
        case "revision":
        case "totaltime":
        case "hyperlinkbase":
        case "manager":
        case "contentstatus":
        case "identifier":
        case "language":
        case "appname":
          if (Rn[0].slice(-2) === "/>")
            break;
          else if (Rn[1] === "/")
            xlml_set_prop(Props, raw_Rn3, str.slice(pidx, Rn.index));
          else
            pidx = Rn.index + Rn[0].length;
          break;
        case "paragraphs":
          break;
        case "styles":
        case "workbook":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
          } else
            state.push([Rn[3], false]);
          break;
        case "comment":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
            xlml_clean_comment(comment);
            comments.push(comment);
          } else {
            state.push([Rn[3], false]);
            tmp = xlml_parsexmltag(Rn[0]);
            comment = { a: tmp.Author };
          }
          break;
        case "autofilter":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/") {
            var AutoFilter = xlml_parsexmltag(Rn[0]);
            cursheet["!autofilter"] = { ref: rc_to_a1(AutoFilter.Range).replace(/\$/g, "") };
            state.push([Rn[3], true]);
          }
          break;
        case "name":
          break;
        case "datavalidation":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
          } else {
            if (Rn[0].charAt(Rn[0].length - 2) !== "/")
              state.push([Rn[3], true]);
          }
          break;
        case "pixelsperinch":
          break;
        case "componentoptions":
        case "documentproperties":
        case "customdocumentproperties":
        case "officedocumentsettings":
        case "pivottable":
        case "pivotcache":
        case "names":
        case "mapinfo":
        case "pagebreaks":
        case "querytable":
        case "sorting":
        case "schema":
        case "conditionalformatting":
        case "smarttagtype":
        case "smarttags":
        case "excelworkbook":
        case "workbookoptions":
        case "worksheetoptions":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw new Error("Bad state: " + tmp.join("|"));
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/")
            state.push([Rn[3], true]);
          break;
        case "null":
          break;
        default:
          if (state.length == 0 && Rn[3] == "document")
            return parse_fods(str, opts);
          if (state.length == 0 && Rn[3] == "uof")
            return parse_fods(str, opts);
          var seen = true;
          switch (state[state.length - 1][0]) {
            case "officedocumentsettings":
              switch (Rn[3]) {
                case "allowpng":
                  break;
                case "removepersonalinformation":
                  break;
                case "downloadcomponents":
                  break;
                case "locationofcomponents":
                  break;
                case "colors":
                  break;
                case "color":
                  break;
                case "index":
                  break;
                case "rgb":
                  break;
                case "targetscreensize":
                  break;
                case "readonlyrecommended":
                  break;
                default:
                  seen = false;
              }
              break;
            case "componentoptions":
              switch (Rn[3]) {
                case "toolbar":
                  break;
                case "hideofficelogo":
                  break;
                case "spreadsheetautofit":
                  break;
                case "label":
                  break;
                case "caption":
                  break;
                case "maxheight":
                  break;
                case "maxwidth":
                  break;
                case "nextsheetnumber":
                  break;
                default:
                  seen = false;
              }
              break;
            case "excelworkbook":
              switch (Rn[3]) {
                case "date1904":
                  Workbook.WBProps.date1904 = true;
                  break;
                case "windowheight":
                  break;
                case "windowwidth":
                  break;
                case "windowtopx":
                  break;
                case "windowtopy":
                  break;
                case "tabratio":
                  break;
                case "protectstructure":
                  break;
                case "protectwindow":
                  break;
                case "protectwindows":
                  break;
                case "activesheet":
                  break;
                case "displayinknotes":
                  break;
                case "firstvisiblesheet":
                  break;
                case "supbook":
                  break;
                case "sheetname":
                  break;
                case "sheetindex":
                  break;
                case "sheetindexfirst":
                  break;
                case "sheetindexlast":
                  break;
                case "dll":
                  break;
                case "acceptlabelsinformulas":
                  break;
                case "donotsavelinkvalues":
                  break;
                case "iteration":
                  break;
                case "maxiterations":
                  break;
                case "maxchange":
                  break;
                case "path":
                  break;
                case "xct":
                  break;
                case "count":
                  break;
                case "selectedsheets":
                  break;
                case "calculation":
                  break;
                case "uncalced":
                  break;
                case "startupprompt":
                  break;
                case "crn":
                  break;
                case "externname":
                  break;
                case "formula":
                  break;
                case "colfirst":
                  break;
                case "collast":
                  break;
                case "wantadvise":
                  break;
                case "boolean":
                  break;
                case "error":
                  break;
                case "text":
                  break;
                case "ole":
                  break;
                case "noautorecover":
                  break;
                case "publishobjects":
                  break;
                case "donotcalculatebeforesave":
                  break;
                case "number":
                  break;
                case "refmoder1c1":
                  break;
                case "embedsavesmarttags":
                  break;
                default:
                  seen = false;
              }
              break;
            case "workbookoptions":
              switch (Rn[3]) {
                case "owcversion":
                  break;
                case "height":
                  break;
                case "width":
                  break;
                default:
                  seen = false;
              }
              break;
            case "worksheetoptions":
              switch (Rn[3]) {
                case "visible":
                  if (Rn[0].slice(-2) === "/>")
                    ;
                  else if (Rn[1] === "/")
                    switch (str.slice(pidx, Rn.index)) {
                      case "SheetHidden":
                        wsprops.Hidden = 1;
                        break;
                      case "SheetVeryHidden":
                        wsprops.Hidden = 2;
                        break;
                    }
                  else
                    pidx = Rn.index + Rn[0].length;
                  break;
                case "header":
                  if (!cursheet["!margins"])
                    default_margins(cursheet["!margins"] = {}, "xlml");
                  if (!isNaN(+parsexmltag(Rn[0]).Margin))
                    cursheet["!margins"].header = +parsexmltag(Rn[0]).Margin;
                  break;
                case "footer":
                  if (!cursheet["!margins"])
                    default_margins(cursheet["!margins"] = {}, "xlml");
                  if (!isNaN(+parsexmltag(Rn[0]).Margin))
                    cursheet["!margins"].footer = +parsexmltag(Rn[0]).Margin;
                  break;
                case "pagemargins":
                  var pagemargins = parsexmltag(Rn[0]);
                  if (!cursheet["!margins"])
                    default_margins(cursheet["!margins"] = {}, "xlml");
                  if (!isNaN(+pagemargins.Top))
                    cursheet["!margins"].top = +pagemargins.Top;
                  if (!isNaN(+pagemargins.Left))
                    cursheet["!margins"].left = +pagemargins.Left;
                  if (!isNaN(+pagemargins.Right))
                    cursheet["!margins"].right = +pagemargins.Right;
                  if (!isNaN(+pagemargins.Bottom))
                    cursheet["!margins"].bottom = +pagemargins.Bottom;
                  break;
                case "displayrighttoleft":
                  if (!Workbook.Views)
                    Workbook.Views = [];
                  if (!Workbook.Views[0])
                    Workbook.Views[0] = {};
                  Workbook.Views[0].RTL = true;
                  break;
                case "freezepanes":
                  break;
                case "frozennosplit":
                  break;
                case "splithorizontal":
                case "splitvertical":
                  break;
                case "donotdisplaygridlines":
                  break;
                case "activerow":
                  break;
                case "activecol":
                  break;
                case "toprowbottompane":
                  break;
                case "leftcolumnrightpane":
                  break;
                case "unsynced":
                  break;
                case "print":
                  break;
                case "printerrors":
                  break;
                case "panes":
                  break;
                case "scale":
                  break;
                case "pane":
                  break;
                case "number":
                  break;
                case "layout":
                  break;
                case "pagesetup":
                  break;
                case "selected":
                  break;
                case "protectobjects":
                  break;
                case "enableselection":
                  break;
                case "protectscenarios":
                  break;
                case "validprinterinfo":
                  break;
                case "horizontalresolution":
                  break;
                case "verticalresolution":
                  break;
                case "numberofcopies":
                  break;
                case "activepane":
                  break;
                case "toprowvisible":
                  break;
                case "leftcolumnvisible":
                  break;
                case "fittopage":
                  break;
                case "rangeselection":
                  break;
                case "papersizeindex":
                  break;
                case "pagelayoutzoom":
                  break;
                case "pagebreakzoom":
                  break;
                case "filteron":
                  break;
                case "fitwidth":
                  break;
                case "fitheight":
                  break;
                case "commentslayout":
                  break;
                case "zoom":
                  break;
                case "lefttoright":
                  break;
                case "gridlines":
                  break;
                case "allowsort":
                  break;
                case "allowfilter":
                  break;
                case "allowinsertrows":
                  break;
                case "allowdeleterows":
                  break;
                case "allowinsertcols":
                  break;
                case "allowdeletecols":
                  break;
                case "allowinserthyperlinks":
                  break;
                case "allowformatcells":
                  break;
                case "allowsizecols":
                  break;
                case "allowsizerows":
                  break;
                case "nosummaryrowsbelowdetail":
                  if (!cursheet["!outline"])
                    cursheet["!outline"] = {};
                  cursheet["!outline"].above = true;
                  break;
                case "tabcolorindex":
                  break;
                case "donotdisplayheadings":
                  break;
                case "showpagelayoutzoom":
                  break;
                case "nosummarycolumnsrightdetail":
                  if (!cursheet["!outline"])
                    cursheet["!outline"] = {};
                  cursheet["!outline"].left = true;
                  break;
                case "blackandwhite":
                  break;
                case "donotdisplayzeros":
                  break;
                case "displaypagebreak":
                  break;
                case "rowcolheadings":
                  break;
                case "donotdisplayoutline":
                  break;
                case "noorientation":
                  break;
                case "allowusepivottables":
                  break;
                case "zeroheight":
                  break;
                case "viewablerange":
                  break;
                case "selection":
                  break;
                case "protectcontents":
                  break;
                default:
                  seen = false;
              }
              break;
            case "pivottable":
            case "pivotcache":
              switch (Rn[3]) {
                case "immediateitemsondrop":
                  break;
                case "showpagemultipleitemlabel":
                  break;
                case "compactrowindent":
                  break;
                case "location":
                  break;
                case "pivotfield":
                  break;
                case "orientation":
                  break;
                case "layoutform":
                  break;
                case "layoutsubtotallocation":
                  break;
                case "layoutcompactrow":
                  break;
                case "position":
                  break;
                case "pivotitem":
                  break;
                case "datatype":
                  break;
                case "datafield":
                  break;
                case "sourcename":
                  break;
                case "parentfield":
                  break;
                case "ptlineitems":
                  break;
                case "ptlineitem":
                  break;
                case "countofsameitems":
                  break;
                case "item":
                  break;
                case "itemtype":
                  break;
                case "ptsource":
                  break;
                case "cacheindex":
                  break;
                case "consolidationreference":
                  break;
                case "filename":
                  break;
                case "reference":
                  break;
                case "nocolumngrand":
                  break;
                case "norowgrand":
                  break;
                case "blanklineafteritems":
                  break;
                case "hidden":
                  break;
                case "subtotal":
                  break;
                case "basefield":
                  break;
                case "mapchilditems":
                  break;
                case "function":
                  break;
                case "refreshonfileopen":
                  break;
                case "printsettitles":
                  break;
                case "mergelabels":
                  break;
                case "defaultversion":
                  break;
                case "refreshname":
                  break;
                case "refreshdate":
                  break;
                case "refreshdatecopy":
                  break;
                case "versionlastrefresh":
                  break;
                case "versionlastupdate":
                  break;
                case "versionupdateablemin":
                  break;
                case "versionrefreshablemin":
                  break;
                case "calculation":
                  break;
                default:
                  seen = false;
              }
              break;
            case "pagebreaks":
              switch (Rn[3]) {
                case "colbreaks":
                  break;
                case "colbreak":
                  break;
                case "rowbreaks":
                  break;
                case "rowbreak":
                  break;
                case "colstart":
                  break;
                case "colend":
                  break;
                case "rowend":
                  break;
                default:
                  seen = false;
              }
              break;
            case "autofilter":
              switch (Rn[3]) {
                case "autofiltercolumn":
                  break;
                case "autofiltercondition":
                  break;
                case "autofilterand":
                  break;
                case "autofilteror":
                  break;
                default:
                  seen = false;
              }
              break;
            case "querytable":
              switch (Rn[3]) {
                case "id":
                  break;
                case "autoformatfont":
                  break;
                case "autoformatpattern":
                  break;
                case "querysource":
                  break;
                case "querytype":
                  break;
                case "enableredirections":
                  break;
                case "refreshedinxl9":
                  break;
                case "urlstring":
                  break;
                case "htmltables":
                  break;
                case "connection":
                  break;
                case "commandtext":
                  break;
                case "refreshinfo":
                  break;
                case "notitles":
                  break;
                case "nextid":
                  break;
                case "columninfo":
                  break;
                case "overwritecells":
                  break;
                case "donotpromptforfile":
                  break;
                case "textwizardsettings":
                  break;
                case "source":
                  break;
                case "number":
                  break;
                case "decimal":
                  break;
                case "thousandseparator":
                  break;
                case "trailingminusnumbers":
                  break;
                case "formatsettings":
                  break;
                case "fieldtype":
                  break;
                case "delimiters":
                  break;
                case "tab":
                  break;
                case "comma":
                  break;
                case "autoformatname":
                  break;
                case "versionlastedit":
                  break;
                case "versionlastrefresh":
                  break;
                default:
                  seen = false;
              }
              break;
            case "datavalidation":
              switch (Rn[3]) {
                case "range":
                  break;
                case "type":
                  break;
                case "min":
                  break;
                case "max":
                  break;
                case "sort":
                  break;
                case "descending":
                  break;
                case "order":
                  break;
                case "casesensitive":
                  break;
                case "value":
                  break;
                case "errorstyle":
                  break;
                case "errormessage":
                  break;
                case "errortitle":
                  break;
                case "inputmessage":
                  break;
                case "inputtitle":
                  break;
                case "combohide":
                  break;
                case "inputhide":
                  break;
                case "condition":
                  break;
                case "qualifier":
                  break;
                case "useblank":
                  break;
                case "value1":
                  break;
                case "value2":
                  break;
                case "format":
                  break;
                case "cellrangelist":
                  break;
                default:
                  seen = false;
              }
              break;
            case "sorting":
            case "conditionalformatting":
              switch (Rn[3]) {
                case "range":
                  break;
                case "type":
                  break;
                case "min":
                  break;
                case "max":
                  break;
                case "sort":
                  break;
                case "descending":
                  break;
                case "order":
                  break;
                case "casesensitive":
                  break;
                case "value":
                  break;
                case "errorstyle":
                  break;
                case "errormessage":
                  break;
                case "errortitle":
                  break;
                case "cellrangelist":
                  break;
                case "inputmessage":
                  break;
                case "inputtitle":
                  break;
                case "combohide":
                  break;
                case "inputhide":
                  break;
                case "condition":
                  break;
                case "qualifier":
                  break;
                case "useblank":
                  break;
                case "value1":
                  break;
                case "value2":
                  break;
                case "format":
                  break;
                default:
                  seen = false;
              }
              break;
            case "mapinfo":
            case "schema":
            case "data":
              switch (Rn[3]) {
                case "map":
                  break;
                case "entry":
                  break;
                case "range":
                  break;
                case "xpath":
                  break;
                case "field":
                  break;
                case "xsdtype":
                  break;
                case "filteron":
                  break;
                case "aggregate":
                  break;
                case "elementtype":
                  break;
                case "attributetype":
                  break;
                case "schema":
                case "element":
                case "complextype":
                case "datatype":
                case "all":
                case "attribute":
                case "extends":
                  break;
                case "row":
                  break;
                default:
                  seen = false;
              }
              break;
            case "smarttags":
              break;
            default:
              seen = false;
              break;
          }
          if (seen)
            break;
          if (Rn[3].match(/!\[CDATA/))
            break;
          if (!state[state.length - 1][1])
            throw "Unrecognized tag: " + Rn[3] + "|" + state.join("|");
          if (state[state.length - 1][0] === "customdocumentproperties") {
            if (Rn[0].slice(-2) === "/>")
              break;
            else if (Rn[1] === "/")
              xlml_set_custprop(Custprops, raw_Rn3, cp, str.slice(pidx, Rn.index));
            else {
              cp = Rn;
              pidx = Rn.index + Rn[0].length;
            }
            break;
          }
          if (opts.WTF)
            throw "Unrecognized tag: " + Rn[3] + "|" + state.join("|");
      }
    var out = {};
    if (!opts.bookSheets && !opts.bookProps)
      out.Sheets = sheets;
    out.SheetNames = sheetnames;
    out.Workbook = Workbook;
    out.SSF = dup(table_fmt);
    out.Props = Props;
    out.Custprops = Custprops;
    return out;
  }
  function parse_xlml(data, opts) {
    fix_read_opts(opts = opts || {});
    switch (opts.type || "base64") {
      case "base64":
        return parse_xlml_xml(Base64_decode(data), opts);
      case "binary":
      case "buffer":
      case "file":
        return parse_xlml_xml(data, opts);
      case "array":
        return parse_xlml_xml(a2s(data), opts);
    }
  }
  function write_props_xlml(wb, opts) {
    var o2 = [];
    if (wb.Props)
      o2.push(xlml_write_docprops(wb.Props, opts));
    if (wb.Custprops)
      o2.push(xlml_write_custprops(wb.Props, wb.Custprops));
    return o2.join("");
  }
  function write_wb_xlml() {
    return "";
  }
  function write_sty_xlml(wb, opts) {
    var styles = ['<Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style>'];
    opts.cellXfs.forEach(function(xf, id) {
      var payload = [];
      payload.push(writextag("NumberFormat", null, { "ss:Format": escapexml(table_fmt[xf.numFmtId]) }));
      var o2 = { "ss:ID": "s" + (21 + id) };
      styles.push(writextag("Style", payload.join(""), o2));
    });
    return writextag("Styles", styles.join(""));
  }
  function write_name_xlml(n) {
    return writextag("NamedRange", null, { "ss:Name": n.Name, "ss:RefersTo": "=" + a1_to_rc(n.Ref, { r: 0, c: 0 }) });
  }
  function write_names_xlml(wb) {
    if (!((wb || {}).Workbook || {}).Names)
      return "";
    var names2 = wb.Workbook.Names;
    var out = [];
    for (var i = 0; i < names2.length; ++i) {
      var n = names2[i];
      if (n.Sheet != null)
        continue;
      if (n.Name.match(/^_xlfn\./))
        continue;
      out.push(write_name_xlml(n));
    }
    return writextag("Names", out.join(""));
  }
  function write_ws_xlml_names(ws, opts, idx, wb) {
    if (!ws)
      return "";
    if (!((wb || {}).Workbook || {}).Names)
      return "";
    var names2 = wb.Workbook.Names;
    var out = [];
    for (var i = 0; i < names2.length; ++i) {
      var n = names2[i];
      if (n.Sheet != idx)
        continue;
      if (n.Name.match(/^_xlfn\./))
        continue;
      out.push(write_name_xlml(n));
    }
    return out.join("");
  }
  function write_ws_xlml_wsopts(ws, opts, idx, wb) {
    if (!ws)
      return "";
    var o2 = [];
    if (ws["!margins"]) {
      o2.push("<PageSetup>");
      if (ws["!margins"].header)
        o2.push(writextag("Header", null, { "x:Margin": ws["!margins"].header }));
      if (ws["!margins"].footer)
        o2.push(writextag("Footer", null, { "x:Margin": ws["!margins"].footer }));
      o2.push(writextag("PageMargins", null, {
        "x:Bottom": ws["!margins"].bottom || "0.75",
        "x:Left": ws["!margins"].left || "0.7",
        "x:Right": ws["!margins"].right || "0.7",
        "x:Top": ws["!margins"].top || "0.75"
      }));
      o2.push("</PageSetup>");
    }
    if (wb && wb.Workbook && wb.Workbook.Sheets && wb.Workbook.Sheets[idx]) {
      if (wb.Workbook.Sheets[idx].Hidden)
        o2.push(writextag("Visible", wb.Workbook.Sheets[idx].Hidden == 1 ? "SheetHidden" : "SheetVeryHidden", {}));
      else {
        for (var i = 0; i < idx; ++i)
          if (wb.Workbook.Sheets[i] && !wb.Workbook.Sheets[i].Hidden)
            break;
        if (i == idx)
          o2.push("<Selected/>");
      }
    }
    if (((((wb || {}).Workbook || {}).Views || [])[0] || {}).RTL)
      o2.push("<DisplayRightToLeft/>");
    if (ws["!protect"]) {
      o2.push(writetag("ProtectContents", "True"));
      if (ws["!protect"].objects)
        o2.push(writetag("ProtectObjects", "True"));
      if (ws["!protect"].scenarios)
        o2.push(writetag("ProtectScenarios", "True"));
      if (ws["!protect"].selectLockedCells != null && !ws["!protect"].selectLockedCells)
        o2.push(writetag("EnableSelection", "NoSelection"));
      else if (ws["!protect"].selectUnlockedCells != null && !ws["!protect"].selectUnlockedCells)
        o2.push(writetag("EnableSelection", "UnlockedCells"));
      [
        ["formatCells", "AllowFormatCells"],
        ["formatColumns", "AllowSizeCols"],
        ["formatRows", "AllowSizeRows"],
        ["insertColumns", "AllowInsertCols"],
        ["insertRows", "AllowInsertRows"],
        ["insertHyperlinks", "AllowInsertHyperlinks"],
        ["deleteColumns", "AllowDeleteCols"],
        ["deleteRows", "AllowDeleteRows"],
        ["sort", "AllowSort"],
        ["autoFilter", "AllowFilter"],
        ["pivotTables", "AllowUsePivotTables"]
      ].forEach(function(x2) {
        if (ws["!protect"][x2[0]])
          o2.push("<" + x2[1] + "/>");
      });
    }
    if (o2.length == 0)
      return "";
    return writextag("WorksheetOptions", o2.join(""), { xmlns: XLMLNS.x });
  }
  function write_ws_xlml_comment(comments) {
    return comments.map(function(c2) {
      var t = xlml_unfixstr(c2.t || "");
      var d2 = writextag("ss:Data", t, { "xmlns": "http://www.w3.org/TR/REC-html40" });
      return writextag("Comment", d2, { "ss:Author": c2.a });
    }).join("");
  }
  function write_ws_xlml_cell(cell, ref2, ws, opts, idx, wb, addr) {
    if (!cell || cell.v == void 0 && cell.f == void 0)
      return "";
    var attr = {};
    if (cell.f)
      attr["ss:Formula"] = "=" + escapexml(a1_to_rc(cell.f, addr));
    if (cell.F && cell.F.slice(0, ref2.length) == ref2) {
      var end = decode_cell(cell.F.slice(ref2.length + 1));
      attr["ss:ArrayRange"] = "RC:R" + (end.r == addr.r ? "" : "[" + (end.r - addr.r) + "]") + "C" + (end.c == addr.c ? "" : "[" + (end.c - addr.c) + "]");
    }
    if (cell.l && cell.l.Target) {
      attr["ss:HRef"] = escapexml(cell.l.Target);
      if (cell.l.Tooltip)
        attr["x:HRefScreenTip"] = escapexml(cell.l.Tooltip);
    }
    if (ws["!merges"]) {
      var marr = ws["!merges"];
      for (var mi = 0; mi != marr.length; ++mi) {
        if (marr[mi].s.c != addr.c || marr[mi].s.r != addr.r)
          continue;
        if (marr[mi].e.c > marr[mi].s.c)
          attr["ss:MergeAcross"] = marr[mi].e.c - marr[mi].s.c;
        if (marr[mi].e.r > marr[mi].s.r)
          attr["ss:MergeDown"] = marr[mi].e.r - marr[mi].s.r;
      }
    }
    var t = "", p2 = "";
    switch (cell.t) {
      case "z":
        if (!opts.sheetStubs)
          return "";
        break;
      case "n":
        t = "Number";
        p2 = String(cell.v);
        break;
      case "b":
        t = "Boolean";
        p2 = cell.v ? "1" : "0";
        break;
      case "e":
        t = "Error";
        p2 = BErr[cell.v];
        break;
      case "d":
        t = "DateTime";
        p2 = new Date(cell.v).toISOString();
        if (cell.z == null)
          cell.z = cell.z || table_fmt[14];
        break;
      case "s":
        t = "String";
        p2 = escapexlml(cell.v || "");
        break;
    }
    var os = get_cell_style(opts.cellXfs, cell, opts);
    attr["ss:StyleID"] = "s" + (21 + os);
    attr["ss:Index"] = addr.c + 1;
    var _v = cell.v != null ? p2 : "";
    var m2 = cell.t == "z" ? "" : '<Data ss:Type="' + t + '">' + _v + "</Data>";
    if ((cell.c || []).length > 0)
      m2 += write_ws_xlml_comment(cell.c);
    return writextag("Cell", m2, attr);
  }
  function write_ws_xlml_row(R2, row) {
    var o2 = '<Row ss:Index="' + (R2 + 1) + '"';
    if (row) {
      if (row.hpt && !row.hpx)
        row.hpx = pt2px(row.hpt);
      if (row.hpx)
        o2 += ' ss:AutoFitHeight="0" ss:Height="' + row.hpx + '"';
      if (row.hidden)
        o2 += ' ss:Hidden="1"';
    }
    return o2 + ">";
  }
  function write_ws_xlml_table(ws, opts, idx, wb) {
    if (!ws["!ref"])
      return "";
    var range = safe_decode_range(ws["!ref"]);
    var marr = ws["!merges"] || [], mi = 0;
    var o2 = [];
    if (ws["!cols"])
      ws["!cols"].forEach(function(n, i) {
        process_col(n);
        var w2 = !!n.width;
        var p2 = col_obj_w(i, n);
        var k = { "ss:Index": i + 1 };
        if (w2)
          k["ss:Width"] = width2px(p2.width);
        if (n.hidden)
          k["ss:Hidden"] = "1";
        o2.push(writextag("Column", null, k));
      });
    var dense = Array.isArray(ws);
    for (var R2 = range.s.r; R2 <= range.e.r; ++R2) {
      var row = [write_ws_xlml_row(R2, (ws["!rows"] || [])[R2])];
      for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
        var skip = false;
        for (mi = 0; mi != marr.length; ++mi) {
          if (marr[mi].s.c > C2)
            continue;
          if (marr[mi].s.r > R2)
            continue;
          if (marr[mi].e.c < C2)
            continue;
          if (marr[mi].e.r < R2)
            continue;
          if (marr[mi].s.c != C2 || marr[mi].s.r != R2)
            skip = true;
          break;
        }
        if (skip)
          continue;
        var addr = { r: R2, c: C2 };
        var ref2 = encode_cell(addr), cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
        row.push(write_ws_xlml_cell(cell, ref2, ws, opts, idx, wb, addr));
      }
      row.push("</Row>");
      if (row.length > 2)
        o2.push(row.join(""));
    }
    return o2.join("");
  }
  function write_ws_xlml(idx, opts, wb) {
    var o2 = [];
    var s2 = wb.SheetNames[idx];
    var ws = wb.Sheets[s2];
    var t = ws ? write_ws_xlml_names(ws, opts, idx, wb) : "";
    if (t.length > 0)
      o2.push("<Names>" + t + "</Names>");
    t = ws ? write_ws_xlml_table(ws, opts, idx, wb) : "";
    if (t.length > 0)
      o2.push("<Table>" + t + "</Table>");
    o2.push(write_ws_xlml_wsopts(ws, opts, idx, wb));
    return o2.join("");
  }
  function write_xlml(wb, opts) {
    if (!opts)
      opts = {};
    if (!wb.SSF)
      wb.SSF = dup(table_fmt);
    if (wb.SSF) {
      make_ssf();
      SSF_load_table(wb.SSF);
      opts.revssf = evert_num(wb.SSF);
      opts.revssf[wb.SSF[65535]] = 0;
      opts.ssf = wb.SSF;
      opts.cellXfs = [];
      get_cell_style(opts.cellXfs, {}, { revssf: { "General": 0 } });
    }
    var d2 = [];
    d2.push(write_props_xlml(wb, opts));
    d2.push(write_wb_xlml());
    d2.push("");
    d2.push("");
    for (var i = 0; i < wb.SheetNames.length; ++i)
      d2.push(writextag("Worksheet", write_ws_xlml(i, opts, wb), { "ss:Name": escapexml(wb.SheetNames[i]) }));
    d2[2] = write_sty_xlml(wb, opts);
    d2[3] = write_names_xlml(wb);
    return XML_HEADER + writextag("Workbook", d2.join(""), {
      "xmlns": XLMLNS.ss,
      "xmlns:o": XLMLNS.o,
      "xmlns:x": XLMLNS.x,
      "xmlns:ss": XLMLNS.ss,
      "xmlns:dt": XLMLNS.dt,
      "xmlns:html": XLMLNS.html
    });
  }
  function parse_compobj(obj) {
    var v2 = {};
    var o2 = obj.content;
    o2.l = 28;
    v2.AnsiUserType = o2.read_shift(0, "lpstr-ansi");
    v2.AnsiClipboardFormat = parse_ClipboardFormatOrAnsiString(o2);
    if (o2.length - o2.l <= 4)
      return v2;
    var m2 = o2.read_shift(4);
    if (m2 == 0 || m2 > 40)
      return v2;
    o2.l -= 4;
    v2.Reserved1 = o2.read_shift(0, "lpstr-ansi");
    if (o2.length - o2.l <= 4)
      return v2;
    m2 = o2.read_shift(4);
    if (m2 !== 1907505652)
      return v2;
    v2.UnicodeClipboardFormat = parse_ClipboardFormatOrUnicodeString(o2);
    m2 = o2.read_shift(4);
    if (m2 == 0 || m2 > 40)
      return v2;
    o2.l -= 4;
    v2.Reserved2 = o2.read_shift(0, "lpwstr");
  }
  var CONTINUE_RT = [60, 1084, 2066, 2165, 2175];
  function slurp(RecordType, R2, blob, length, opts) {
    var l2 = length;
    var bufs = [];
    var d2 = blob.slice(blob.l, blob.l + l2);
    if (opts && opts.enc && opts.enc.insitu && d2.length > 0)
      switch (RecordType) {
        case 9:
        case 521:
        case 1033:
        case 2057:
        case 47:
        case 405:
        case 225:
        case 406:
        case 312:
        case 404:
        case 10:
          break;
        case 133:
          break;
        default:
          opts.enc.insitu(d2);
      }
    bufs.push(d2);
    blob.l += l2;
    var nextrt = __readUInt16LE(blob, blob.l), next = XLSRecordEnum[nextrt];
    var start = 0;
    while (next != null && CONTINUE_RT.indexOf(nextrt) > -1) {
      l2 = __readUInt16LE(blob, blob.l + 2);
      start = blob.l + 4;
      if (nextrt == 2066)
        start += 4;
      else if (nextrt == 2165 || nextrt == 2175) {
        start += 12;
      }
      d2 = blob.slice(start, blob.l + 4 + l2);
      bufs.push(d2);
      blob.l += 4 + l2;
      next = XLSRecordEnum[nextrt = __readUInt16LE(blob, blob.l)];
    }
    var b2 = bconcat(bufs);
    prep_blob(b2, 0);
    var ll = 0;
    b2.lens = [];
    for (var j = 0; j < bufs.length; ++j) {
      b2.lens.push(ll);
      ll += bufs[j].length;
    }
    if (b2.length < length)
      throw "XLS Record 0x" + RecordType.toString(16) + " Truncated: " + b2.length + " < " + length;
    return R2.f(b2, b2.length, opts);
  }
  function safe_format_xf(p2, opts, date1904) {
    if (p2.t === "z")
      return;
    if (!p2.XF)
      return;
    var fmtid = 0;
    try {
      fmtid = p2.z || p2.XF.numFmtId || 0;
      if (opts.cellNF)
        p2.z = table_fmt[fmtid];
    } catch (e) {
      if (opts.WTF)
        throw e;
    }
    if (!opts || opts.cellText !== false)
      try {
        if (p2.t === "e") {
          p2.w = p2.w || BErr[p2.v];
        } else if (fmtid === 0 || fmtid == "General") {
          if (p2.t === "n") {
            if ((p2.v | 0) === p2.v)
              p2.w = p2.v.toString(10);
            else
              p2.w = SSF_general_num(p2.v);
          } else
            p2.w = SSF_general(p2.v);
        } else
          p2.w = SSF_format(fmtid, p2.v, { date1904: !!date1904, dateNF: opts && opts.dateNF });
      } catch (e) {
        if (opts.WTF)
          throw e;
      }
    if (opts.cellDates && fmtid && p2.t == "n" && fmt_is_date(table_fmt[fmtid] || String(fmtid))) {
      var _d = SSF_parse_date_code(p2.v);
      if (_d) {
        p2.t = "d";
        p2.v = new Date(_d.y, _d.m - 1, _d.d, _d.H, _d.M, _d.S, _d.u);
      }
    }
  }
  function make_cell(val, ixfe, t) {
    return { v: val, ixfe, t };
  }
  function parse_workbook(blob, options) {
    var wb = { opts: {} };
    var Sheets = {};
    var out = options.dense ? [] : {};
    var Directory = {};
    var range = {};
    var last_formula = null;
    var sst = [];
    var cur_sheet = "";
    var Preamble = {};
    var lastcell, last_cell = "", cc, cmnt, rngC, rngR;
    var sharedf = {};
    var arrayf = [];
    var temp_val;
    var country;
    var XFs = [];
    var palette = [];
    var Workbook = { Sheets: [], WBProps: { date1904: false }, Views: [{}] }, wsprops = {};
    var get_rgb = function getrgb(icv) {
      if (icv < 8)
        return XLSIcv[icv];
      if (icv < 64)
        return palette[icv - 8] || XLSIcv[icv];
      return XLSIcv[icv];
    };
    var process_cell_style = function pcs(cell, line, options2) {
      var xfd = line.XF.data;
      if (!xfd || !xfd.patternType || !options2 || !options2.cellStyles)
        return;
      line.s = {};
      line.s.patternType = xfd.patternType;
      var t;
      if (t = rgb2Hex(get_rgb(xfd.icvFore))) {
        line.s.fgColor = { rgb: t };
      }
      if (t = rgb2Hex(get_rgb(xfd.icvBack))) {
        line.s.bgColor = { rgb: t };
      }
    };
    var addcell = function addcell2(cell, line, options2) {
      if (file_depth > 1)
        return;
      if (options2.sheetRows && cell.r >= options2.sheetRows)
        return;
      if (options2.cellStyles && line.XF && line.XF.data)
        process_cell_style(cell, line, options2);
      delete line.ixfe;
      delete line.XF;
      lastcell = cell;
      last_cell = encode_cell(cell);
      if (!range || !range.s || !range.e)
        range = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
      if (cell.r < range.s.r)
        range.s.r = cell.r;
      if (cell.c < range.s.c)
        range.s.c = cell.c;
      if (cell.r + 1 > range.e.r)
        range.e.r = cell.r + 1;
      if (cell.c + 1 > range.e.c)
        range.e.c = cell.c + 1;
      if (options2.cellFormula && line.f) {
        for (var afi = 0; afi < arrayf.length; ++afi) {
          if (arrayf[afi][0].s.c > cell.c || arrayf[afi][0].s.r > cell.r)
            continue;
          if (arrayf[afi][0].e.c < cell.c || arrayf[afi][0].e.r < cell.r)
            continue;
          line.F = encode_range(arrayf[afi][0]);
          if (arrayf[afi][0].s.c != cell.c || arrayf[afi][0].s.r != cell.r)
            delete line.f;
          if (line.f)
            line.f = "" + stringify_formula(arrayf[afi][1], range, cell, supbooks, opts);
          break;
        }
      }
      {
        if (options2.dense) {
          if (!out[cell.r])
            out[cell.r] = [];
          out[cell.r][cell.c] = line;
        } else
          out[last_cell] = line;
      }
    };
    var opts = {
      enc: false,
      sbcch: 0,
      snames: [],
      sharedf,
      arrayf,
      rrtabid: [],
      lastuser: "",
      biff: 8,
      codepage: 0,
      winlocked: 0,
      cellStyles: !!options && !!options.cellStyles,
      WTF: !!options && !!options.wtf
    };
    if (options.password)
      opts.password = options.password;
    var themes;
    var merges = [];
    var objects = [];
    var colinfo = [], rowinfo = [];
    var seencol = false;
    var supbooks = [];
    supbooks.SheetNames = opts.snames;
    supbooks.sharedf = opts.sharedf;
    supbooks.arrayf = opts.arrayf;
    supbooks.names = [];
    supbooks.XTI = [];
    var last_RT = 0;
    var file_depth = 0;
    var BIFF2Fmt = 0, BIFF2FmtTable = [];
    var FilterDatabases = [];
    var last_lbl;
    opts.codepage = 1200;
    set_cp(1200);
    var seen_codepage = false;
    while (blob.l < blob.length - 1) {
      var s2 = blob.l;
      var RecordType = blob.read_shift(2);
      if (RecordType === 0 && last_RT === 10)
        break;
      var length = blob.l === blob.length ? 0 : blob.read_shift(2);
      var R2 = XLSRecordEnum[RecordType];
      if (R2 && R2.f) {
        if (options.bookSheets) {
          if (last_RT === 133 && RecordType !== 133)
            break;
        }
        last_RT = RecordType;
        if (R2.r === 2 || R2.r == 12) {
          var rt2 = blob.read_shift(2);
          length -= 2;
          if (!opts.enc && rt2 !== RecordType && ((rt2 & 255) << 8 | rt2 >> 8) !== RecordType)
            throw new Error("rt mismatch: " + rt2 + "!=" + RecordType);
          if (R2.r == 12) {
            blob.l += 10;
            length -= 10;
          }
        }
        var val = {};
        if (RecordType === 10)
          val = R2.f(blob, length, opts);
        else
          val = slurp(RecordType, R2, blob, length, opts);
        if (file_depth == 0 && [9, 521, 1033, 2057].indexOf(last_RT) === -1)
          continue;
        switch (RecordType) {
          case 34:
            wb.opts.Date1904 = Workbook.WBProps.date1904 = val;
            break;
          case 134:
            wb.opts.WriteProtect = true;
            break;
          case 47:
            if (!opts.enc)
              blob.l = 0;
            opts.enc = val;
            if (!options.password)
              throw new Error("File is password-protected");
            if (val.valid == null)
              throw new Error("Encryption scheme unsupported");
            if (!val.valid)
              throw new Error("Password is incorrect");
            break;
          case 92:
            opts.lastuser = val;
            break;
          case 66:
            var cpval = Number(val);
            switch (cpval) {
              case 21010:
                cpval = 1200;
                break;
              case 32768:
                cpval = 1e4;
                break;
              case 32769:
                cpval = 1252;
                break;
            }
            set_cp(opts.codepage = cpval);
            seen_codepage = true;
            break;
          case 317:
            opts.rrtabid = val;
            break;
          case 25:
            opts.winlocked = val;
            break;
          case 439:
            wb.opts["RefreshAll"] = val;
            break;
          case 12:
            wb.opts["CalcCount"] = val;
            break;
          case 16:
            wb.opts["CalcDelta"] = val;
            break;
          case 17:
            wb.opts["CalcIter"] = val;
            break;
          case 13:
            wb.opts["CalcMode"] = val;
            break;
          case 14:
            wb.opts["CalcPrecision"] = val;
            break;
          case 95:
            wb.opts["CalcSaveRecalc"] = val;
            break;
          case 15:
            opts.CalcRefMode = val;
            break;
          case 2211:
            wb.opts.FullCalc = val;
            break;
          case 129:
            if (val.fDialog)
              out["!type"] = "dialog";
            if (!val.fBelow)
              (out["!outline"] || (out["!outline"] = {})).above = true;
            if (!val.fRight)
              (out["!outline"] || (out["!outline"] = {})).left = true;
            break;
          case 224:
            XFs.push(val);
            break;
          case 430:
            supbooks.push([val]);
            supbooks[supbooks.length - 1].XTI = [];
            break;
          case 35:
          case 547:
            supbooks[supbooks.length - 1].push(val);
            break;
          case 24:
          case 536:
            last_lbl = {
              Name: val.Name,
              Ref: stringify_formula(val.rgce, range, null, supbooks, opts)
            };
            if (val.itab > 0)
              last_lbl.Sheet = val.itab - 1;
            supbooks.names.push(last_lbl);
            if (!supbooks[0]) {
              supbooks[0] = [];
              supbooks[0].XTI = [];
            }
            supbooks[supbooks.length - 1].push(val);
            if (val.Name == "_xlnm._FilterDatabase" && val.itab > 0) {
              if (val.rgce && val.rgce[0] && val.rgce[0][0] && val.rgce[0][0][0] == "PtgArea3d")
                FilterDatabases[val.itab - 1] = { ref: encode_range(val.rgce[0][0][1][2]) };
            }
            break;
          case 22:
            opts.ExternCount = val;
            break;
          case 23:
            if (supbooks.length == 0) {
              supbooks[0] = [];
              supbooks[0].XTI = [];
            }
            supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
            supbooks.XTI = supbooks.XTI.concat(val);
            break;
          case 2196:
            if (opts.biff < 8)
              break;
            if (last_lbl != null)
              last_lbl.Comment = val[1];
            break;
          case 18:
            out["!protect"] = val;
            break;
          case 19:
            if (val !== 0 && opts.WTF)
              console.error("Password verifier: " + val);
            break;
          case 133:
            {
              Directory[val.pos] = val;
              opts.snames.push(val.name);
            }
            break;
          case 10:
            {
              if (--file_depth)
                break;
              if (range.e) {
                if (range.e.r > 0 && range.e.c > 0) {
                  range.e.r--;
                  range.e.c--;
                  out["!ref"] = encode_range(range);
                  if (options.sheetRows && options.sheetRows <= range.e.r) {
                    var tmpri = range.e.r;
                    range.e.r = options.sheetRows - 1;
                    out["!fullref"] = out["!ref"];
                    out["!ref"] = encode_range(range);
                    range.e.r = tmpri;
                  }
                  range.e.r++;
                  range.e.c++;
                }
                if (merges.length > 0)
                  out["!merges"] = merges;
                if (objects.length > 0)
                  out["!objects"] = objects;
                if (colinfo.length > 0)
                  out["!cols"] = colinfo;
                if (rowinfo.length > 0)
                  out["!rows"] = rowinfo;
                Workbook.Sheets.push(wsprops);
              }
              if (cur_sheet === "")
                Preamble = out;
              else
                Sheets[cur_sheet] = out;
              out = options.dense ? [] : {};
            }
            break;
          case 9:
          case 521:
          case 1033:
          case 2057:
            {
              if (opts.biff === 8)
                opts.biff = {
                  9: 2,
                  521: 3,
                  1033: 4
                }[RecordType] || {
                  512: 2,
                  768: 3,
                  1024: 4,
                  1280: 5,
                  1536: 8,
                  2: 2,
                  7: 2
                }[val.BIFFVer] || 8;
              opts.biffguess = val.BIFFVer == 0;
              if (val.BIFFVer == 0 && val.dt == 4096) {
                opts.biff = 5;
                seen_codepage = true;
                set_cp(opts.codepage = 28591);
              }
              if (opts.biff == 8 && val.BIFFVer == 0 && val.dt == 16)
                opts.biff = 2;
              if (file_depth++)
                break;
              out = options.dense ? [] : {};
              if (opts.biff < 8 && !seen_codepage) {
                seen_codepage = true;
                set_cp(opts.codepage = options.codepage || 1252);
              }
              if (opts.biff < 5 || val.BIFFVer == 0 && val.dt == 4096) {
                if (cur_sheet === "")
                  cur_sheet = "Sheet1";
                range = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
                var fakebs8 = { pos: blob.l - length, name: cur_sheet };
                Directory[fakebs8.pos] = fakebs8;
                opts.snames.push(cur_sheet);
              } else
                cur_sheet = (Directory[s2] || { name: "" }).name;
              if (val.dt == 32)
                out["!type"] = "chart";
              if (val.dt == 64)
                out["!type"] = "macro";
              merges = [];
              objects = [];
              opts.arrayf = arrayf = [];
              colinfo = [];
              rowinfo = [];
              seencol = false;
              wsprops = { Hidden: (Directory[s2] || { hs: 0 }).hs, name: cur_sheet };
            }
            break;
          case 515:
          case 3:
          case 2:
            {
              if (out["!type"] == "chart") {
                if (options.dense ? (out[val.r] || [])[val.c] : out[encode_cell({ c: val.c, r: val.r })])
                  ++val.c;
              }
              temp_val = { ixfe: val.ixfe, XF: XFs[val.ixfe] || {}, v: val.val, t: "n" };
              if (BIFF2Fmt > 0)
                temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
              safe_format_xf(temp_val, options, wb.opts.Date1904);
              addcell({ c: val.c, r: val.r }, temp_val, options);
            }
            break;
          case 5:
          case 517:
            {
              temp_val = { ixfe: val.ixfe, XF: XFs[val.ixfe], v: val.val, t: val.t };
              if (BIFF2Fmt > 0)
                temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
              safe_format_xf(temp_val, options, wb.opts.Date1904);
              addcell({ c: val.c, r: val.r }, temp_val, options);
            }
            break;
          case 638:
            {
              temp_val = { ixfe: val.ixfe, XF: XFs[val.ixfe], v: val.rknum, t: "n" };
              if (BIFF2Fmt > 0)
                temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
              safe_format_xf(temp_val, options, wb.opts.Date1904);
              addcell({ c: val.c, r: val.r }, temp_val, options);
            }
            break;
          case 189:
            {
              for (var j = val.c; j <= val.C; ++j) {
                var ixfe = val.rkrec[j - val.c][0];
                temp_val = { ixfe, XF: XFs[ixfe], v: val.rkrec[j - val.c][1], t: "n" };
                if (BIFF2Fmt > 0)
                  temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
                safe_format_xf(temp_val, options, wb.opts.Date1904);
                addcell({ c: j, r: val.r }, temp_val, options);
              }
            }
            break;
          case 6:
          case 518:
          case 1030:
            {
              if (val.val == "String") {
                last_formula = val;
                break;
              }
              temp_val = make_cell(val.val, val.cell.ixfe, val.tt);
              temp_val.XF = XFs[temp_val.ixfe];
              if (options.cellFormula) {
                var _f = val.formula;
                if (_f && _f[0] && _f[0][0] && _f[0][0][0] == "PtgExp") {
                  var _fr = _f[0][0][1][0], _fc = _f[0][0][1][1];
                  var _fe = encode_cell({ r: _fr, c: _fc });
                  if (sharedf[_fe])
                    temp_val.f = "" + stringify_formula(val.formula, range, val.cell, supbooks, opts);
                  else
                    temp_val.F = ((options.dense ? (out[_fr] || [])[_fc] : out[_fe]) || {}).F;
                } else
                  temp_val.f = "" + stringify_formula(val.formula, range, val.cell, supbooks, opts);
              }
              if (BIFF2Fmt > 0)
                temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
              safe_format_xf(temp_val, options, wb.opts.Date1904);
              addcell(val.cell, temp_val, options);
              last_formula = val;
            }
            break;
          case 7:
          case 519:
            {
              if (last_formula) {
                last_formula.val = val;
                temp_val = make_cell(val, last_formula.cell.ixfe, "s");
                temp_val.XF = XFs[temp_val.ixfe];
                if (options.cellFormula) {
                  temp_val.f = "" + stringify_formula(last_formula.formula, range, last_formula.cell, supbooks, opts);
                }
                if (BIFF2Fmt > 0)
                  temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
                safe_format_xf(temp_val, options, wb.opts.Date1904);
                addcell(last_formula.cell, temp_val, options);
                last_formula = null;
              } else
                throw new Error("String record expects Formula");
            }
            break;
          case 33:
          case 545:
            {
              arrayf.push(val);
              var _arraystart = encode_cell(val[0].s);
              cc = options.dense ? (out[val[0].s.r] || [])[val[0].s.c] : out[_arraystart];
              if (options.cellFormula && cc) {
                if (!last_formula)
                  break;
                if (!_arraystart || !cc)
                  break;
                cc.f = "" + stringify_formula(val[1], range, val[0], supbooks, opts);
                cc.F = encode_range(val[0]);
              }
            }
            break;
          case 1212:
            {
              if (!options.cellFormula)
                break;
              if (last_cell) {
                if (!last_formula)
                  break;
                sharedf[encode_cell(last_formula.cell)] = val[0];
                cc = options.dense ? (out[last_formula.cell.r] || [])[last_formula.cell.c] : out[encode_cell(last_formula.cell)];
                (cc || {}).f = "" + stringify_formula(val[0], range, lastcell, supbooks, opts);
              }
            }
            break;
          case 253:
            temp_val = make_cell(sst[val.isst].t, val.ixfe, "s");
            if (sst[val.isst].h)
              temp_val.h = sst[val.isst].h;
            temp_val.XF = XFs[temp_val.ixfe];
            if (BIFF2Fmt > 0)
              temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
            safe_format_xf(temp_val, options, wb.opts.Date1904);
            addcell({ c: val.c, r: val.r }, temp_val, options);
            break;
          case 513:
            if (options.sheetStubs) {
              temp_val = { ixfe: val.ixfe, XF: XFs[val.ixfe], t: "z" };
              if (BIFF2Fmt > 0)
                temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
              safe_format_xf(temp_val, options, wb.opts.Date1904);
              addcell({ c: val.c, r: val.r }, temp_val, options);
            }
            break;
          case 190:
            if (options.sheetStubs) {
              for (var _j = val.c; _j <= val.C; ++_j) {
                var _ixfe = val.ixfe[_j - val.c];
                temp_val = { ixfe: _ixfe, XF: XFs[_ixfe], t: "z" };
                if (BIFF2Fmt > 0)
                  temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
                safe_format_xf(temp_val, options, wb.opts.Date1904);
                addcell({ c: _j, r: val.r }, temp_val, options);
              }
            }
            break;
          case 214:
          case 516:
          case 4:
            temp_val = make_cell(val.val, val.ixfe, "s");
            temp_val.XF = XFs[temp_val.ixfe];
            if (BIFF2Fmt > 0)
              temp_val.z = BIFF2FmtTable[temp_val.ixfe >> 8 & 63];
            safe_format_xf(temp_val, options, wb.opts.Date1904);
            addcell({ c: val.c, r: val.r }, temp_val, options);
            break;
          case 0:
          case 512:
            {
              if (file_depth === 1)
                range = val;
            }
            break;
          case 252:
            {
              sst = val;
            }
            break;
          case 1054:
            {
              if (opts.biff == 4) {
                BIFF2FmtTable[BIFF2Fmt++] = val[1];
                for (var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx)
                  if (table_fmt[b4idx] == val[1])
                    break;
                if (b4idx >= 163)
                  SSF_load(val[1], BIFF2Fmt + 163);
              } else
                SSF_load(val[1], val[0]);
            }
            break;
          case 30:
            {
              BIFF2FmtTable[BIFF2Fmt++] = val;
              for (var b2idx = 0; b2idx < BIFF2Fmt + 163; ++b2idx)
                if (table_fmt[b2idx] == val)
                  break;
              if (b2idx >= 163)
                SSF_load(val, BIFF2Fmt + 163);
            }
            break;
          case 229:
            merges = merges.concat(val);
            break;
          case 93:
            objects[val.cmo[0]] = opts.lastobj = val;
            break;
          case 438:
            opts.lastobj.TxO = val;
            break;
          case 127:
            opts.lastobj.ImData = val;
            break;
          case 440:
            {
              for (rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR)
                for (rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {
                  cc = options.dense ? (out[rngR] || [])[rngC] : out[encode_cell({ c: rngC, r: rngR })];
                  if (cc)
                    cc.l = val[1];
                }
            }
            break;
          case 2048:
            {
              for (rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR)
                for (rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {
                  cc = options.dense ? (out[rngR] || [])[rngC] : out[encode_cell({ c: rngC, r: rngR })];
                  if (cc && cc.l)
                    cc.l.Tooltip = val[1];
                }
            }
            break;
          case 28:
            {
              if (opts.biff <= 5 && opts.biff >= 2)
                break;
              cc = options.dense ? (out[val[0].r] || [])[val[0].c] : out[encode_cell(val[0])];
              var noteobj = objects[val[2]];
              if (!cc) {
                if (options.dense) {
                  if (!out[val[0].r])
                    out[val[0].r] = [];
                  cc = out[val[0].r][val[0].c] = { t: "z" };
                } else {
                  cc = out[encode_cell(val[0])] = { t: "z" };
                }
                range.e.r = Math.max(range.e.r, val[0].r);
                range.s.r = Math.min(range.s.r, val[0].r);
                range.e.c = Math.max(range.e.c, val[0].c);
                range.s.c = Math.min(range.s.c, val[0].c);
              }
              if (!cc.c)
                cc.c = [];
              cmnt = { a: val[1], t: noteobj.TxO.t };
              cc.c.push(cmnt);
            }
            break;
          case 2173:
            update_xfext(XFs[val.ixfe], val.ext);
            break;
          case 125:
            {
              if (!opts.cellStyles)
                break;
              while (val.e >= val.s) {
                colinfo[val.e--] = { width: val.w / 256, level: val.level || 0, hidden: !!(val.flags & 1) };
                if (!seencol) {
                  seencol = true;
                  find_mdw_colw(val.w / 256);
                }
                process_col(colinfo[val.e + 1]);
              }
            }
            break;
          case 520:
            {
              var rowobj = {};
              if (val.level != null) {
                rowinfo[val.r] = rowobj;
                rowobj.level = val.level;
              }
              if (val.hidden) {
                rowinfo[val.r] = rowobj;
                rowobj.hidden = true;
              }
              if (val.hpt) {
                rowinfo[val.r] = rowobj;
                rowobj.hpt = val.hpt;
                rowobj.hpx = pt2px(val.hpt);
              }
            }
            break;
          case 38:
          case 39:
          case 40:
          case 41:
            if (!out["!margins"])
              default_margins(out["!margins"] = {});
            out["!margins"][{ 38: "left", 39: "right", 40: "top", 41: "bottom" }[RecordType]] = val;
            break;
          case 161:
            if (!out["!margins"])
              default_margins(out["!margins"] = {});
            out["!margins"].header = val.header;
            out["!margins"].footer = val.footer;
            break;
          case 574:
            if (val.RTL)
              Workbook.Views[0].RTL = true;
            break;
          case 146:
            palette = val;
            break;
          case 2198:
            themes = val;
            break;
          case 140:
            country = val;
            break;
          case 442:
            {
              if (!cur_sheet)
                Workbook.WBProps.CodeName = val || "ThisWorkbook";
              else
                wsprops.CodeName = val || wsprops.name;
            }
            break;
        }
      } else {
        if (!R2)
          console.error("Missing Info for XLS Record 0x" + RecordType.toString(16));
        blob.l += length;
      }
    }
    wb.SheetNames = keys$1(Directory).sort(function(a2, b2) {
      return Number(a2) - Number(b2);
    }).map(function(x2) {
      return Directory[x2].name;
    });
    if (!options.bookSheets)
      wb.Sheets = Sheets;
    if (!wb.SheetNames.length && Preamble["!ref"]) {
      wb.SheetNames.push("Sheet1");
      if (wb.Sheets)
        wb.Sheets["Sheet1"] = Preamble;
    } else
      wb.Preamble = Preamble;
    if (wb.Sheets)
      FilterDatabases.forEach(function(r, i) {
        wb.Sheets[wb.SheetNames[i]]["!autofilter"] = r;
      });
    wb.Strings = sst;
    wb.SSF = dup(table_fmt);
    if (opts.enc)
      wb.Encryption = opts.enc;
    if (themes)
      wb.Themes = themes;
    wb.Metadata = {};
    if (country !== void 0)
      wb.Metadata.Country = country;
    if (supbooks.names.length > 0)
      Workbook.Names = supbooks.names;
    wb.Workbook = Workbook;
    return wb;
  }
  var PSCLSID = {
    SI: "e0859ff2f94f6810ab9108002b27b3d9",
    DSI: "02d5cdd59c2e1b10939708002b2cf9ae",
    UDI: "05d5cdd59c2e1b10939708002b2cf9ae"
  };
  function parse_xls_props(cfb, props, o2) {
    var DSI = CFB.find(cfb, "/!DocumentSummaryInformation");
    if (DSI && DSI.size > 0)
      try {
        var DocSummary = parse_PropertySetStream(DSI, DocSummaryPIDDSI, PSCLSID.DSI);
        for (var d2 in DocSummary)
          props[d2] = DocSummary[d2];
      } catch (e) {
        if (o2.WTF)
          throw e;
      }
    var SI = CFB.find(cfb, "/!SummaryInformation");
    if (SI && SI.size > 0)
      try {
        var Summary = parse_PropertySetStream(SI, SummaryPIDSI, PSCLSID.SI);
        for (var s2 in Summary)
          if (props[s2] == null)
            props[s2] = Summary[s2];
      } catch (e) {
        if (o2.WTF)
          throw e;
      }
    if (props.HeadingPairs && props.TitlesOfParts) {
      load_props_pairs(props.HeadingPairs, props.TitlesOfParts, props, o2);
      delete props.HeadingPairs;
      delete props.TitlesOfParts;
    }
  }
  function write_xls_props(wb, cfb) {
    var DSEntries = [], SEntries = [], CEntries = [];
    var i = 0, Keys;
    var DocSummaryRE = evert_key(DocSummaryPIDDSI, "n");
    var SummaryRE = evert_key(SummaryPIDSI, "n");
    if (wb.Props) {
      Keys = keys$1(wb.Props);
      for (i = 0; i < Keys.length; ++i)
        (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);
    }
    if (wb.Custprops) {
      Keys = keys$1(wb.Custprops);
      for (i = 0; i < Keys.length; ++i)
        if (!Object.prototype.hasOwnProperty.call(wb.Props || {}, Keys[i]))
          (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);
    }
    var CEntries2 = [];
    for (i = 0; i < CEntries.length; ++i) {
      if (XLSPSSkip.indexOf(CEntries[i][0]) > -1 || PseudoPropsPairs.indexOf(CEntries[i][0]) > -1)
        continue;
      if (CEntries[i][1] == null)
        continue;
      CEntries2.push(CEntries[i]);
    }
    if (SEntries.length)
      CFB.utils.cfb_add(cfb, "/SummaryInformation", write_PropertySetStream(SEntries, PSCLSID.SI, SummaryRE, SummaryPIDSI));
    if (DSEntries.length || CEntries2.length)
      CFB.utils.cfb_add(cfb, "/DocumentSummaryInformation", write_PropertySetStream(DSEntries, PSCLSID.DSI, DocSummaryRE, DocSummaryPIDDSI, CEntries2.length ? CEntries2 : null, PSCLSID.UDI));
  }
  function parse_xlscfb(cfb, options) {
    if (!options)
      options = {};
    fix_read_opts(options);
    reset_cp();
    if (options.codepage)
      set_ansi(options.codepage);
    var CompObj, WB;
    if (cfb.FullPaths) {
      if (CFB.find(cfb, "/encryption"))
        throw new Error("File is password-protected");
      CompObj = CFB.find(cfb, "!CompObj");
      WB = CFB.find(cfb, "/Workbook") || CFB.find(cfb, "/Book");
    } else {
      switch (options.type) {
        case "base64":
          cfb = s2a(Base64_decode(cfb));
          break;
        case "binary":
          cfb = s2a(cfb);
          break;
        case "buffer":
          break;
        case "array":
          if (!Array.isArray(cfb))
            cfb = Array.prototype.slice.call(cfb);
          break;
      }
      prep_blob(cfb, 0);
      WB = { content: cfb };
    }
    var WorkbookP;
    var _data;
    if (CompObj)
      parse_compobj(CompObj);
    if (options.bookProps && !options.bookSheets)
      WorkbookP = {};
    else {
      var T2 = has_buf ? "buffer" : "array";
      if (WB && WB.content)
        WorkbookP = parse_workbook(WB.content, options);
      else if ((_data = CFB.find(cfb, "PerfectOffice_MAIN")) && _data.content)
        WorkbookP = WK_.to_workbook(_data.content, (options.type = T2, options));
      else if ((_data = CFB.find(cfb, "NativeContent_MAIN")) && _data.content)
        WorkbookP = WK_.to_workbook(_data.content, (options.type = T2, options));
      else if ((_data = CFB.find(cfb, "MN0")) && _data.content)
        throw new Error("Unsupported Works 4 for Mac file");
      else
        throw new Error("Cannot find Workbook stream");
      if (options.bookVBA && cfb.FullPaths && CFB.find(cfb, "/_VBA_PROJECT_CUR/VBA/dir"))
        WorkbookP.vbaraw = make_vba_xls(cfb);
    }
    var props = {};
    if (cfb.FullPaths)
      parse_xls_props(cfb, props, options);
    WorkbookP.Props = WorkbookP.Custprops = props;
    if (options.bookFiles)
      WorkbookP.cfb = cfb;
    return WorkbookP;
  }
  function write_xlscfb(wb, opts) {
    var o2 = opts || {};
    var cfb = CFB.utils.cfb_new({ root: "R" });
    var wbpath = "/Workbook";
    switch (o2.bookType || "xls") {
      case "xls":
        o2.bookType = "biff8";
      case "xla":
        if (!o2.bookType)
          o2.bookType = "xla";
      case "biff8":
        wbpath = "/Workbook";
        o2.biff = 8;
        break;
      case "biff5":
        wbpath = "/Book";
        o2.biff = 5;
        break;
      default:
        throw new Error("invalid type " + o2.bookType + " for XLS CFB");
    }
    CFB.utils.cfb_add(cfb, wbpath, write_biff_buf(wb, o2));
    if (o2.biff == 8 && (wb.Props || wb.Custprops))
      write_xls_props(wb, cfb);
    if (o2.biff == 8 && wb.vbaraw)
      fill_vba_xls(cfb, CFB.read(wb.vbaraw, { type: typeof wb.vbaraw == "string" ? "binary" : "buffer" }));
    return cfb;
  }
  var XLSBRecordEnum = {
    0: { f: parse_BrtRowHdr },
    1: { f: parse_BrtCellBlank },
    2: { f: parse_BrtCellRk },
    3: { f: parse_BrtCellError },
    4: { f: parse_BrtCellBool },
    5: { f: parse_BrtCellReal },
    6: { f: parse_BrtCellSt },
    7: { f: parse_BrtCellIsst },
    8: { f: parse_BrtFmlaString },
    9: { f: parse_BrtFmlaNum },
    10: { f: parse_BrtFmlaBool },
    11: { f: parse_BrtFmlaError },
    12: { f: parse_BrtShortBlank },
    13: { f: parse_BrtShortRk },
    14: { f: parse_BrtShortError },
    15: { f: parse_BrtShortBool },
    16: { f: parse_BrtShortReal },
    17: { f: parse_BrtShortSt },
    18: { f: parse_BrtShortIsst },
    19: { f: parse_RichStr },
    20: {},
    21: {},
    22: {},
    23: {},
    24: {},
    25: {},
    26: {},
    27: {},
    28: {},
    29: {},
    30: {},
    31: {},
    32: {},
    33: {},
    34: {},
    35: { T: 1 },
    36: { T: -1 },
    37: { T: 1 },
    38: { T: -1 },
    39: { f: parse_BrtName },
    40: {},
    42: {},
    43: { f: parse_BrtFont },
    44: { f: parse_BrtFmt },
    45: { f: parse_BrtFill },
    46: { f: parse_BrtBorder },
    47: { f: parse_BrtXF },
    48: {},
    49: { f: parse_Int32LE },
    50: {},
    51: { f: parse_BrtMdb },
    52: { T: 1 },
    53: { T: -1 },
    54: { T: 1 },
    55: { T: -1 },
    56: { T: 1 },
    57: { T: -1 },
    58: {},
    59: {},
    60: { f: parse_ColInfo },
    62: { f: parse_BrtCellRString },
    63: { f: parse_BrtCalcChainItem$ },
    64: { f: parse_BrtDVal },
    65: {},
    66: {},
    67: {},
    68: {},
    69: {},
    70: {},
    128: {},
    129: { T: 1 },
    130: { T: -1 },
    131: { T: 1, f: parsenoop, p: 0 },
    132: { T: -1 },
    133: { T: 1 },
    134: { T: -1 },
    135: { T: 1 },
    136: { T: -1 },
    137: { T: 1, f: parse_BrtBeginWsView },
    138: { T: -1 },
    139: { T: 1 },
    140: { T: -1 },
    141: { T: 1 },
    142: { T: -1 },
    143: { T: 1 },
    144: { T: -1 },
    145: { T: 1 },
    146: { T: -1 },
    147: { f: parse_BrtWsProp },
    148: { f: parse_BrtWsDim, p: 16 },
    151: { f: parse_BrtPane },
    152: {},
    153: { f: parse_BrtWbProp },
    154: {},
    155: {},
    156: { f: parse_BrtBundleSh },
    157: {},
    158: {},
    159: { T: 1, f: parse_BrtBeginSst },
    160: { T: -1 },
    161: { T: 1, f: parse_UncheckedRfX },
    162: { T: -1 },
    163: { T: 1 },
    164: { T: -1 },
    165: { T: 1 },
    166: { T: -1 },
    167: {},
    168: {},
    169: {},
    170: {},
    171: {},
    172: { T: 1 },
    173: { T: -1 },
    174: {},
    175: {},
    176: { f: parse_BrtMergeCell },
    177: { T: 1 },
    178: { T: -1 },
    179: { T: 1 },
    180: { T: -1 },
    181: { T: 1 },
    182: { T: -1 },
    183: { T: 1 },
    184: { T: -1 },
    185: { T: 1 },
    186: { T: -1 },
    187: { T: 1 },
    188: { T: -1 },
    189: { T: 1 },
    190: { T: -1 },
    191: { T: 1 },
    192: { T: -1 },
    193: { T: 1 },
    194: { T: -1 },
    195: { T: 1 },
    196: { T: -1 },
    197: { T: 1 },
    198: { T: -1 },
    199: { T: 1 },
    200: { T: -1 },
    201: { T: 1 },
    202: { T: -1 },
    203: { T: 1 },
    204: { T: -1 },
    205: { T: 1 },
    206: { T: -1 },
    207: { T: 1 },
    208: { T: -1 },
    209: { T: 1 },
    210: { T: -1 },
    211: { T: 1 },
    212: { T: -1 },
    213: { T: 1 },
    214: { T: -1 },
    215: { T: 1 },
    216: { T: -1 },
    217: { T: 1 },
    218: { T: -1 },
    219: { T: 1 },
    220: { T: -1 },
    221: { T: 1 },
    222: { T: -1 },
    223: { T: 1 },
    224: { T: -1 },
    225: { T: 1 },
    226: { T: -1 },
    227: { T: 1 },
    228: { T: -1 },
    229: { T: 1 },
    230: { T: -1 },
    231: { T: 1 },
    232: { T: -1 },
    233: { T: 1 },
    234: { T: -1 },
    235: { T: 1 },
    236: { T: -1 },
    237: { T: 1 },
    238: { T: -1 },
    239: { T: 1 },
    240: { T: -1 },
    241: { T: 1 },
    242: { T: -1 },
    243: { T: 1 },
    244: { T: -1 },
    245: { T: 1 },
    246: { T: -1 },
    247: { T: 1 },
    248: { T: -1 },
    249: { T: 1 },
    250: { T: -1 },
    251: { T: 1 },
    252: { T: -1 },
    253: { T: 1 },
    254: { T: -1 },
    255: { T: 1 },
    256: { T: -1 },
    257: { T: 1 },
    258: { T: -1 },
    259: { T: 1 },
    260: { T: -1 },
    261: { T: 1 },
    262: { T: -1 },
    263: { T: 1 },
    264: { T: -1 },
    265: { T: 1 },
    266: { T: -1 },
    267: { T: 1 },
    268: { T: -1 },
    269: { T: 1 },
    270: { T: -1 },
    271: { T: 1 },
    272: { T: -1 },
    273: { T: 1 },
    274: { T: -1 },
    275: { T: 1 },
    276: { T: -1 },
    277: {},
    278: { T: 1 },
    279: { T: -1 },
    280: { T: 1 },
    281: { T: -1 },
    282: { T: 1 },
    283: { T: 1 },
    284: { T: -1 },
    285: { T: 1 },
    286: { T: -1 },
    287: { T: 1 },
    288: { T: -1 },
    289: { T: 1 },
    290: { T: -1 },
    291: { T: 1 },
    292: { T: -1 },
    293: { T: 1 },
    294: { T: -1 },
    295: { T: 1 },
    296: { T: -1 },
    297: { T: 1 },
    298: { T: -1 },
    299: { T: 1 },
    300: { T: -1 },
    301: { T: 1 },
    302: { T: -1 },
    303: { T: 1 },
    304: { T: -1 },
    305: { T: 1 },
    306: { T: -1 },
    307: { T: 1 },
    308: { T: -1 },
    309: { T: 1 },
    310: { T: -1 },
    311: { T: 1 },
    312: { T: -1 },
    313: { T: -1 },
    314: { T: 1 },
    315: { T: -1 },
    316: { T: 1 },
    317: { T: -1 },
    318: { T: 1 },
    319: { T: -1 },
    320: { T: 1 },
    321: { T: -1 },
    322: { T: 1 },
    323: { T: -1 },
    324: { T: 1 },
    325: { T: -1 },
    326: { T: 1 },
    327: { T: -1 },
    328: { T: 1 },
    329: { T: -1 },
    330: { T: 1 },
    331: { T: -1 },
    332: { T: 1 },
    333: { T: -1 },
    334: { T: 1 },
    335: { f: parse_BrtMdtinfo },
    336: { T: -1 },
    337: { f: parse_BrtBeginEsmdb, T: 1 },
    338: { T: -1 },
    339: { T: 1 },
    340: { T: -1 },
    341: { T: 1 },
    342: { T: -1 },
    343: { T: 1 },
    344: { T: -1 },
    345: { T: 1 },
    346: { T: -1 },
    347: { T: 1 },
    348: { T: -1 },
    349: { T: 1 },
    350: { T: -1 },
    351: {},
    352: {},
    353: { T: 1 },
    354: { T: -1 },
    355: { f: parse_RelID },
    357: {},
    358: {},
    359: {},
    360: { T: 1 },
    361: {},
    362: { f: parse_ExternSheet },
    363: {},
    364: {},
    366: {},
    367: {},
    368: {},
    369: {},
    370: {},
    371: {},
    372: { T: 1 },
    373: { T: -1 },
    374: { T: 1 },
    375: { T: -1 },
    376: { T: 1 },
    377: { T: -1 },
    378: { T: 1 },
    379: { T: -1 },
    380: { T: 1 },
    381: { T: -1 },
    382: { T: 1 },
    383: { T: -1 },
    384: { T: 1 },
    385: { T: -1 },
    386: { T: 1 },
    387: { T: -1 },
    388: { T: 1 },
    389: { T: -1 },
    390: { T: 1 },
    391: { T: -1 },
    392: { T: 1 },
    393: { T: -1 },
    394: { T: 1 },
    395: { T: -1 },
    396: {},
    397: {},
    398: {},
    399: {},
    400: {},
    401: { T: 1 },
    403: {},
    404: {},
    405: {},
    406: {},
    407: {},
    408: {},
    409: {},
    410: {},
    411: {},
    412: {},
    413: {},
    414: {},
    415: {},
    416: {},
    417: {},
    418: {},
    419: {},
    420: {},
    421: {},
    422: { T: 1 },
    423: { T: 1 },
    424: { T: -1 },
    425: { T: -1 },
    426: { f: parse_BrtArrFmla },
    427: { f: parse_BrtShrFmla },
    428: {},
    429: { T: 1 },
    430: { T: -1 },
    431: { T: 1 },
    432: { T: -1 },
    433: { T: 1 },
    434: { T: -1 },
    435: { T: 1 },
    436: { T: -1 },
    437: { T: 1 },
    438: { T: -1 },
    439: { T: 1 },
    440: { T: -1 },
    441: { T: 1 },
    442: { T: -1 },
    443: { T: 1 },
    444: { T: -1 },
    445: { T: 1 },
    446: { T: -1 },
    447: { T: 1 },
    448: { T: -1 },
    449: { T: 1 },
    450: { T: -1 },
    451: { T: 1 },
    452: { T: -1 },
    453: { T: 1 },
    454: { T: -1 },
    455: { T: 1 },
    456: { T: -1 },
    457: { T: 1 },
    458: { T: -1 },
    459: { T: 1 },
    460: { T: -1 },
    461: { T: 1 },
    462: { T: -1 },
    463: { T: 1 },
    464: { T: -1 },
    465: { T: 1 },
    466: { T: -1 },
    467: { T: 1 },
    468: { T: -1 },
    469: { T: 1 },
    470: { T: -1 },
    471: {},
    472: {},
    473: { T: 1 },
    474: { T: -1 },
    475: {},
    476: { f: parse_BrtMargins },
    477: {},
    478: {},
    479: { T: 1 },
    480: { T: -1 },
    481: { T: 1 },
    482: { T: -1 },
    483: { T: 1 },
    484: { T: -1 },
    485: { f: parse_BrtWsFmtInfo },
    486: { T: 1 },
    487: { T: -1 },
    488: { T: 1 },
    489: { T: -1 },
    490: { T: 1 },
    491: { T: -1 },
    492: { T: 1 },
    493: { T: -1 },
    494: { f: parse_BrtHLink },
    495: { T: 1 },
    496: { T: -1 },
    497: { T: 1 },
    498: { T: -1 },
    499: {},
    500: { T: 1 },
    501: { T: -1 },
    502: { T: 1 },
    503: { T: -1 },
    504: {},
    505: { T: 1 },
    506: { T: -1 },
    507: {},
    508: { T: 1 },
    509: { T: -1 },
    510: { T: 1 },
    511: { T: -1 },
    512: {},
    513: {},
    514: { T: 1 },
    515: { T: -1 },
    516: { T: 1 },
    517: { T: -1 },
    518: { T: 1 },
    519: { T: -1 },
    520: { T: 1 },
    521: { T: -1 },
    522: {},
    523: {},
    524: {},
    525: {},
    526: {},
    527: {},
    528: { T: 1 },
    529: { T: -1 },
    530: { T: 1 },
    531: { T: -1 },
    532: { T: 1 },
    533: { T: -1 },
    534: {},
    535: {},
    536: {},
    537: {},
    538: { T: 1 },
    539: { T: -1 },
    540: { T: 1 },
    541: { T: -1 },
    542: { T: 1 },
    548: {},
    549: {},
    550: { f: parse_RelID },
    551: {},
    552: {},
    553: {},
    554: { T: 1 },
    555: { T: -1 },
    556: { T: 1 },
    557: { T: -1 },
    558: { T: 1 },
    559: { T: -1 },
    560: { T: 1 },
    561: { T: -1 },
    562: {},
    564: {},
    565: { T: 1 },
    566: { T: -1 },
    569: { T: 1 },
    570: { T: -1 },
    572: {},
    573: { T: 1 },
    574: { T: -1 },
    577: {},
    578: {},
    579: {},
    580: {},
    581: {},
    582: {},
    583: {},
    584: {},
    585: {},
    586: {},
    587: {},
    588: { T: -1 },
    589: {},
    590: { T: 1 },
    591: { T: -1 },
    592: { T: 1 },
    593: { T: -1 },
    594: { T: 1 },
    595: { T: -1 },
    596: {},
    597: { T: 1 },
    598: { T: -1 },
    599: { T: 1 },
    600: { T: -1 },
    601: { T: 1 },
    602: { T: -1 },
    603: { T: 1 },
    604: { T: -1 },
    605: { T: 1 },
    606: { T: -1 },
    607: {},
    608: { T: 1 },
    609: { T: -1 },
    610: {},
    611: { T: 1 },
    612: { T: -1 },
    613: { T: 1 },
    614: { T: -1 },
    615: { T: 1 },
    616: { T: -1 },
    617: { T: 1 },
    618: { T: -1 },
    619: { T: 1 },
    620: { T: -1 },
    625: {},
    626: { T: 1 },
    627: { T: -1 },
    628: { T: 1 },
    629: { T: -1 },
    630: { T: 1 },
    631: { T: -1 },
    632: { f: parse_BrtCommentAuthor },
    633: { T: 1 },
    634: { T: -1 },
    635: { T: 1, f: parse_BrtBeginComment },
    636: { T: -1 },
    637: { f: parse_BrtCommentText },
    638: { T: 1 },
    639: {},
    640: { T: -1 },
    641: { T: 1 },
    642: { T: -1 },
    643: { T: 1 },
    644: {},
    645: { T: -1 },
    646: { T: 1 },
    648: { T: 1 },
    649: {},
    650: { T: -1 },
    651: { f: parse_BrtCsProp },
    652: {},
    653: { T: 1 },
    654: { T: -1 },
    655: { T: 1 },
    656: { T: -1 },
    657: { T: 1 },
    658: { T: -1 },
    659: {},
    660: { T: 1 },
    661: {},
    662: { T: -1 },
    663: {},
    664: { T: 1 },
    665: {},
    666: { T: -1 },
    667: {},
    668: {},
    669: {},
    671: { T: 1 },
    672: { T: -1 },
    673: { T: 1 },
    674: { T: -1 },
    675: {},
    676: {},
    677: {},
    678: {},
    679: {},
    680: {},
    681: {},
    1024: {},
    1025: {},
    1026: { T: 1 },
    1027: { T: -1 },
    1028: { T: 1 },
    1029: { T: -1 },
    1030: {},
    1031: { T: 1 },
    1032: { T: -1 },
    1033: { T: 1 },
    1034: { T: -1 },
    1035: {},
    1036: {},
    1037: {},
    1038: { T: 1 },
    1039: { T: -1 },
    1040: {},
    1041: { T: 1 },
    1042: { T: -1 },
    1043: {},
    1044: {},
    1045: {},
    1046: { T: 1 },
    1047: { T: -1 },
    1048: { T: 1 },
    1049: { T: -1 },
    1050: {},
    1051: { T: 1 },
    1052: { T: 1 },
    1053: { f: parse_BrtDVal14 },
    1054: { T: 1 },
    1055: {},
    1056: { T: 1 },
    1057: { T: -1 },
    1058: { T: 1 },
    1059: { T: -1 },
    1061: {},
    1062: { T: 1 },
    1063: { T: -1 },
    1064: { T: 1 },
    1065: { T: -1 },
    1066: { T: 1 },
    1067: { T: -1 },
    1068: { T: 1 },
    1069: { T: -1 },
    1070: { T: 1 },
    1071: { T: -1 },
    1072: { T: 1 },
    1073: { T: -1 },
    1075: { T: 1 },
    1076: { T: -1 },
    1077: { T: 1 },
    1078: { T: -1 },
    1079: { T: 1 },
    1080: { T: -1 },
    1081: { T: 1 },
    1082: { T: -1 },
    1083: { T: 1 },
    1084: { T: -1 },
    1085: {},
    1086: { T: 1 },
    1087: { T: -1 },
    1088: { T: 1 },
    1089: { T: -1 },
    1090: { T: 1 },
    1091: { T: -1 },
    1092: { T: 1 },
    1093: { T: -1 },
    1094: { T: 1 },
    1095: { T: -1 },
    1096: {},
    1097: { T: 1 },
    1098: {},
    1099: { T: -1 },
    1100: { T: 1 },
    1101: { T: -1 },
    1102: {},
    1103: {},
    1104: {},
    1105: {},
    1111: {},
    1112: {},
    1113: { T: 1 },
    1114: { T: -1 },
    1115: { T: 1 },
    1116: { T: -1 },
    1117: {},
    1118: { T: 1 },
    1119: { T: -1 },
    1120: { T: 1 },
    1121: { T: -1 },
    1122: { T: 1 },
    1123: { T: -1 },
    1124: { T: 1 },
    1125: { T: -1 },
    1126: {},
    1128: { T: 1 },
    1129: { T: -1 },
    1130: {},
    1131: { T: 1 },
    1132: { T: -1 },
    1133: { T: 1 },
    1134: { T: -1 },
    1135: { T: 1 },
    1136: { T: -1 },
    1137: { T: 1 },
    1138: { T: -1 },
    1139: { T: 1 },
    1140: { T: -1 },
    1141: {},
    1142: { T: 1 },
    1143: { T: -1 },
    1144: { T: 1 },
    1145: { T: -1 },
    1146: {},
    1147: { T: 1 },
    1148: { T: -1 },
    1149: { T: 1 },
    1150: { T: -1 },
    1152: { T: 1 },
    1153: { T: -1 },
    1154: { T: -1 },
    1155: { T: -1 },
    1156: { T: -1 },
    1157: { T: 1 },
    1158: { T: -1 },
    1159: { T: 1 },
    1160: { T: -1 },
    1161: { T: 1 },
    1162: { T: -1 },
    1163: { T: 1 },
    1164: { T: -1 },
    1165: { T: 1 },
    1166: { T: -1 },
    1167: { T: 1 },
    1168: { T: -1 },
    1169: { T: 1 },
    1170: { T: -1 },
    1171: {},
    1172: { T: 1 },
    1173: { T: -1 },
    1177: {},
    1178: { T: 1 },
    1180: {},
    1181: {},
    1182: {},
    2048: { T: 1 },
    2049: { T: -1 },
    2050: {},
    2051: { T: 1 },
    2052: { T: -1 },
    2053: {},
    2054: {},
    2055: { T: 1 },
    2056: { T: -1 },
    2057: { T: 1 },
    2058: { T: -1 },
    2060: {},
    2067: {},
    2068: { T: 1 },
    2069: { T: -1 },
    2070: {},
    2071: {},
    2072: { T: 1 },
    2073: { T: -1 },
    2075: {},
    2076: {},
    2077: { T: 1 },
    2078: { T: -1 },
    2079: {},
    2080: { T: 1 },
    2081: { T: -1 },
    2082: {},
    2083: { T: 1 },
    2084: { T: -1 },
    2085: { T: 1 },
    2086: { T: -1 },
    2087: { T: 1 },
    2088: { T: -1 },
    2089: { T: 1 },
    2090: { T: -1 },
    2091: {},
    2092: {},
    2093: { T: 1 },
    2094: { T: -1 },
    2095: {},
    2096: { T: 1 },
    2097: { T: -1 },
    2098: { T: 1 },
    2099: { T: -1 },
    2100: { T: 1 },
    2101: { T: -1 },
    2102: {},
    2103: { T: 1 },
    2104: { T: -1 },
    2105: {},
    2106: { T: 1 },
    2107: { T: -1 },
    2108: {},
    2109: { T: 1 },
    2110: { T: -1 },
    2111: { T: 1 },
    2112: { T: -1 },
    2113: { T: 1 },
    2114: { T: -1 },
    2115: {},
    2116: {},
    2117: {},
    2118: { T: 1 },
    2119: { T: -1 },
    2120: {},
    2121: { T: 1 },
    2122: { T: -1 },
    2123: { T: 1 },
    2124: { T: -1 },
    2125: {},
    2126: { T: 1 },
    2127: { T: -1 },
    2128: {},
    2129: { T: 1 },
    2130: { T: -1 },
    2131: { T: 1 },
    2132: { T: -1 },
    2133: { T: 1 },
    2134: {},
    2135: {},
    2136: {},
    2137: { T: 1 },
    2138: { T: -1 },
    2139: { T: 1 },
    2140: { T: -1 },
    2141: {},
    3072: {},
    3073: {},
    4096: { T: 1 },
    4097: { T: -1 },
    5002: { T: 1 },
    5003: { T: -1 },
    5081: { T: 1 },
    5082: { T: -1 },
    5083: {},
    5084: { T: 1 },
    5085: { T: -1 },
    5086: { T: 1 },
    5087: { T: -1 },
    5088: {},
    5089: {},
    5090: {},
    5092: { T: 1 },
    5093: { T: -1 },
    5094: {},
    5095: { T: 1 },
    5096: { T: -1 },
    5097: {},
    5099: {},
    65535: { n: "" }
  };
  var XLSRecordEnum = {
    6: { f: parse_Formula },
    10: { f: parsenoop2 },
    12: { f: parseuint16 },
    13: { f: parseuint16 },
    14: { f: parsebool },
    15: { f: parsebool },
    16: { f: parse_Xnum },
    17: { f: parsebool },
    18: { f: parsebool },
    19: { f: parseuint16 },
    20: { f: parse_XLHeaderFooter },
    21: { f: parse_XLHeaderFooter },
    23: { f: parse_ExternSheet },
    24: { f: parse_Lbl },
    25: { f: parsebool },
    26: {},
    27: {},
    28: { f: parse_Note },
    29: {},
    34: { f: parsebool },
    35: { f: parse_ExternName },
    38: { f: parse_Xnum },
    39: { f: parse_Xnum },
    40: { f: parse_Xnum },
    41: { f: parse_Xnum },
    42: { f: parsebool },
    43: { f: parsebool },
    47: { f: parse_FilePass },
    49: { f: parse_Font },
    51: { f: parseuint16 },
    60: {},
    61: { f: parse_Window1 },
    64: { f: parsebool },
    65: { f: parse_Pane },
    66: { f: parseuint16 },
    77: {},
    80: {},
    81: {},
    82: {},
    85: { f: parseuint16 },
    89: {},
    90: {},
    91: {},
    92: { f: parse_WriteAccess },
    93: { f: parse_Obj },
    94: {},
    95: { f: parsebool },
    96: {},
    97: {},
    99: { f: parsebool },
    125: { f: parse_ColInfo },
    128: { f: parse_Guts },
    129: { f: parse_WsBool },
    130: { f: parseuint16 },
    131: { f: parsebool },
    132: { f: parsebool },
    133: { f: parse_BoundSheet8 },
    134: {},
    140: { f: parse_Country },
    141: { f: parseuint16 },
    144: {},
    146: { f: parse_Palette },
    151: {},
    152: {},
    153: {},
    154: {},
    155: {},
    156: { f: parseuint16 },
    157: {},
    158: {},
    160: { f: parse_Scl },
    161: { f: parse_Setup },
    174: {},
    175: {},
    176: {},
    177: {},
    178: {},
    180: {},
    181: {},
    182: {},
    184: {},
    185: {},
    189: { f: parse_MulRk },
    190: { f: parse_MulBlank },
    193: { f: parsenoop2 },
    197: {},
    198: {},
    199: {},
    200: {},
    201: {},
    202: { f: parsebool },
    203: {},
    204: {},
    205: {},
    206: {},
    207: {},
    208: {},
    209: {},
    210: {},
    211: {},
    213: {},
    215: {},
    216: {},
    217: {},
    218: { f: parseuint16 },
    220: {},
    221: { f: parsebool },
    222: {},
    224: { f: parse_XF },
    225: { f: parse_InterfaceHdr },
    226: { f: parsenoop2 },
    227: {},
    229: { f: parse_MergeCells },
    233: {},
    235: {},
    236: {},
    237: {},
    239: {},
    240: {},
    241: {},
    242: {},
    244: {},
    245: {},
    246: {},
    247: {},
    248: {},
    249: {},
    251: {},
    252: { f: parse_SST },
    253: { f: parse_LabelSst },
    255: { f: parse_ExtSST },
    256: {},
    259: {},
    290: {},
    311: {},
    312: {},
    315: {},
    317: { f: parseuint16a },
    318: {},
    319: {},
    320: {},
    330: {},
    331: {},
    333: {},
    334: {},
    335: {},
    336: {},
    337: {},
    338: {},
    339: {},
    340: {},
    351: {},
    352: { f: parsebool },
    353: { f: parsenoop2 },
    401: {},
    402: {},
    403: {},
    404: {},
    405: {},
    406: {},
    407: {},
    408: {},
    425: {},
    426: {},
    427: {},
    428: {},
    429: {},
    430: { f: parse_SupBook },
    431: { f: parsebool },
    432: {},
    433: {},
    434: {},
    437: {},
    438: { f: parse_TxO },
    439: { f: parsebool },
    440: { f: parse_HLink },
    441: {},
    442: { f: parse_XLUnicodeString },
    443: {},
    444: { f: parseuint16 },
    445: {},
    446: {},
    448: { f: parsenoop2 },
    449: { f: parse_RecalcId, r: 2 },
    450: { f: parsenoop2 },
    512: { f: parse_Dimensions },
    513: { f: parse_Blank },
    515: { f: parse_Number },
    516: { f: parse_Label },
    517: { f: parse_BoolErr },
    519: { f: parse_String },
    520: { f: parse_Row },
    523: {},
    545: { f: parse_Array },
    549: { f: parse_DefaultRowHeight },
    566: {},
    574: { f: parse_Window2 },
    638: { f: parse_RK },
    659: {},
    1048: {},
    1054: { f: parse_Format },
    1084: {},
    1212: { f: parse_ShrFmla },
    2048: { f: parse_HLinkTooltip },
    2049: {},
    2050: {},
    2051: {},
    2052: {},
    2053: {},
    2054: {},
    2055: {},
    2056: {},
    2057: { f: parse_BOF },
    2058: {},
    2059: {},
    2060: {},
    2061: {},
    2062: {},
    2063: {},
    2064: {},
    2066: {},
    2067: {},
    2128: {},
    2129: {},
    2130: {},
    2131: {},
    2132: {},
    2133: {},
    2134: {},
    2135: {},
    2136: {},
    2137: {},
    2138: {},
    2146: {},
    2147: { r: 12 },
    2148: {},
    2149: {},
    2150: {},
    2151: { f: parsenoop2 },
    2152: {},
    2154: {},
    2155: {},
    2156: {},
    2161: {},
    2162: {},
    2164: {},
    2165: {},
    2166: {},
    2167: {},
    2168: {},
    2169: {},
    2170: {},
    2171: {},
    2172: { f: parse_XFCRC, r: 12 },
    2173: { f: parse_XFExt, r: 12 },
    2174: {},
    2175: {},
    2180: {},
    2181: {},
    2182: {},
    2183: {},
    2184: {},
    2185: {},
    2186: {},
    2187: {},
    2188: { f: parsebool, r: 12 },
    2189: {},
    2190: { r: 12 },
    2191: {},
    2192: {},
    2194: {},
    2195: {},
    2196: { f: parse_NameCmt, r: 12 },
    2197: {},
    2198: { f: parse_Theme, r: 12 },
    2199: {},
    2200: {},
    2201: {},
    2202: { f: parse_MTRSettings, r: 12 },
    2203: { f: parsenoop2 },
    2204: {},
    2205: {},
    2206: {},
    2207: {},
    2211: { f: parse_ForceFullCalculation },
    2212: {},
    2213: {},
    2214: {},
    2215: {},
    4097: {},
    4098: {},
    4099: {},
    4102: {},
    4103: {},
    4105: {},
    4106: {},
    4107: {},
    4108: {},
    4109: {},
    4116: {},
    4117: {},
    4118: {},
    4119: {},
    4120: {},
    4121: {},
    4122: {},
    4123: {},
    4124: {},
    4125: {},
    4126: {},
    4127: {},
    4128: {},
    4129: {},
    4130: {},
    4132: {},
    4133: {},
    4134: { f: parseuint16 },
    4135: {},
    4146: {},
    4147: {},
    4148: {},
    4149: {},
    4154: {},
    4156: {},
    4157: {},
    4158: {},
    4159: {},
    4160: {},
    4161: {},
    4163: {},
    4164: { f: parse_ShtProps },
    4165: {},
    4166: {},
    4168: {},
    4170: {},
    4171: {},
    4174: {},
    4175: {},
    4176: {},
    4177: {},
    4187: {},
    4188: { f: parse_ClrtClient },
    4189: {},
    4191: {},
    4192: {},
    4193: {},
    4194: {},
    4195: {},
    4196: {},
    4197: {},
    4198: {},
    4199: {},
    4200: {},
    0: { f: parse_Dimensions },
    1: {},
    2: { f: parse_BIFF2INT },
    3: { f: parse_BIFF2NUM },
    4: { f: parse_BIFF2STR },
    5: { f: parse_BoolErr },
    7: { f: parse_BIFF2STRING },
    8: {},
    9: { f: parse_BOF },
    11: {},
    22: { f: parseuint16 },
    30: { f: parse_BIFF2Format },
    31: {},
    32: {},
    33: { f: parse_Array },
    36: {},
    37: { f: parse_DefaultRowHeight },
    50: { f: parse_BIFF2FONTXTRA },
    62: {},
    52: {},
    67: {},
    68: { f: parseuint16 },
    69: {},
    86: {},
    126: {},
    127: { f: parse_ImData },
    135: {},
    136: {},
    137: {},
    145: {},
    148: {},
    149: {},
    150: {},
    169: {},
    171: {},
    188: {},
    191: {},
    192: {},
    194: {},
    195: {},
    214: { f: parse_RString },
    223: {},
    234: {},
    354: {},
    421: {},
    518: { f: parse_Formula },
    521: { f: parse_BOF },
    536: { f: parse_Lbl },
    547: { f: parse_ExternName },
    561: {},
    579: {},
    1030: { f: parse_Formula },
    1033: { f: parse_BOF },
    1091: {},
    2157: {},
    2163: {},
    2177: {},
    2240: {},
    2241: {},
    2242: {},
    2243: {},
    2244: {},
    2245: {},
    2246: {},
    2247: {},
    2248: {},
    2249: {},
    2250: {},
    2251: {},
    2262: { r: 12 },
    29282: {}
  };
  function write_biff_rec(ba, type, payload, length) {
    var t = type;
    if (isNaN(t))
      return;
    var len = length || (payload || []).length || 0;
    var o2 = ba.next(4);
    o2.write_shift(2, t);
    o2.write_shift(2, len);
    if (len > 0 && is_buf(payload))
      ba.push(payload);
  }
  function write_biff_continue(ba, type, payload, length) {
    var len = length || (payload || []).length || 0;
    if (len <= 8224)
      return write_biff_rec(ba, type, payload, len);
    var t = type;
    if (isNaN(t))
      return;
    var parts = payload.parts || [], sidx = 0;
    var i = 0, w2 = 0;
    while (w2 + (parts[sidx] || 8224) <= 8224) {
      w2 += parts[sidx] || 8224;
      sidx++;
    }
    var o2 = ba.next(4);
    o2.write_shift(2, t);
    o2.write_shift(2, w2);
    ba.push(payload.slice(i, i + w2));
    i += w2;
    while (i < len) {
      o2 = ba.next(4);
      o2.write_shift(2, 60);
      w2 = 0;
      while (w2 + (parts[sidx] || 8224) <= 8224) {
        w2 += parts[sidx] || 8224;
        sidx++;
      }
      o2.write_shift(2, w2);
      ba.push(payload.slice(i, i + w2));
      i += w2;
    }
  }
  function write_BIFF2Cell(out, r, c2) {
    if (!out)
      out = new_buf(7);
    out.write_shift(2, r);
    out.write_shift(2, c2);
    out.write_shift(2, 0);
    out.write_shift(1, 0);
    return out;
  }
  function write_BIFF2BERR(r, c2, val, t) {
    var out = new_buf(9);
    write_BIFF2Cell(out, r, c2);
    write_Bes(val, t || "b", out);
    return out;
  }
  function write_BIFF2LABEL(r, c2, val) {
    var out = new_buf(8 + 2 * val.length);
    write_BIFF2Cell(out, r, c2);
    out.write_shift(1, val.length);
    out.write_shift(val.length, val, "sbcs");
    return out.l < out.length ? out.slice(0, out.l) : out;
  }
  function write_ws_biff2_cell(ba, cell, R2, C2) {
    if (cell.v != null)
      switch (cell.t) {
        case "d":
        case "n":
          var v2 = cell.t == "d" ? datenum(parseDate(cell.v)) : cell.v;
          if (v2 == (v2 | 0) && v2 >= 0 && v2 < 65536)
            write_biff_rec(ba, 2, write_BIFF2INT(R2, C2, v2));
          else
            write_biff_rec(ba, 3, write_BIFF2NUM(R2, C2, v2));
          return;
        case "b":
        case "e":
          write_biff_rec(ba, 5, write_BIFF2BERR(R2, C2, cell.v, cell.t));
          return;
        case "s":
        case "str":
          write_biff_rec(ba, 4, write_BIFF2LABEL(R2, C2, (cell.v || "").slice(0, 255)));
          return;
      }
    write_biff_rec(ba, 1, write_BIFF2Cell(null, R2, C2));
  }
  function write_ws_biff2(ba, ws, idx, opts) {
    var dense = Array.isArray(ws);
    var range = safe_decode_range(ws["!ref"] || "A1"), ref2, rr = "", cols = [];
    if (range.e.c > 255 || range.e.r > 16383) {
      if (opts.WTF)
        throw new Error("Range " + (ws["!ref"] || "A1") + " exceeds format limit A1:IV16384");
      range.e.c = Math.min(range.e.c, 255);
      range.e.r = Math.min(range.e.c, 16383);
      ref2 = encode_range(range);
    }
    for (var R2 = range.s.r; R2 <= range.e.r; ++R2) {
      rr = encode_row(R2);
      for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
        if (R2 === range.s.r)
          cols[C2] = encode_col(C2);
        ref2 = cols[C2] + rr;
        var cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
        if (!cell)
          continue;
        write_ws_biff2_cell(ba, cell, R2, C2);
      }
    }
  }
  function write_biff2_buf(wb, opts) {
    var o2 = opts || {};
    var ba = buf_array();
    var idx = 0;
    for (var i = 0; i < wb.SheetNames.length; ++i)
      if (wb.SheetNames[i] == o2.sheet)
        idx = i;
    if (idx == 0 && !!o2.sheet && wb.SheetNames[0] != o2.sheet)
      throw new Error("Sheet not found: " + o2.sheet);
    write_biff_rec(ba, o2.biff == 4 ? 1033 : o2.biff == 3 ? 521 : 9, write_BOF(wb, 16, o2));
    write_ws_biff2(ba, wb.Sheets[wb.SheetNames[idx]], idx, o2);
    write_biff_rec(ba, 10);
    return ba.end();
  }
  function write_FONTS_biff8(ba, data, opts) {
    write_biff_rec(ba, 49, write_Font({
      sz: 12,
      color: { theme: 1 },
      name: "Arial",
      family: 2,
      scheme: "minor"
    }, opts));
  }
  function write_FMTS_biff8(ba, NF, opts) {
    if (!NF)
      return;
    [[5, 8], [23, 26], [41, 44], [50, 392]].forEach(function(r) {
      for (var i = r[0]; i <= r[1]; ++i)
        if (NF[i] != null)
          write_biff_rec(ba, 1054, write_Format(i, NF[i], opts));
    });
  }
  function write_FEAT(ba, ws) {
    var o2 = new_buf(19);
    o2.write_shift(4, 2151);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(2, 3);
    o2.write_shift(1, 1);
    o2.write_shift(4, 0);
    write_biff_rec(ba, 2151, o2);
    o2 = new_buf(39);
    o2.write_shift(4, 2152);
    o2.write_shift(4, 0);
    o2.write_shift(4, 0);
    o2.write_shift(2, 3);
    o2.write_shift(1, 0);
    o2.write_shift(4, 0);
    o2.write_shift(2, 1);
    o2.write_shift(4, 4);
    o2.write_shift(2, 0);
    write_Ref8U(safe_decode_range(ws["!ref"] || "A1"), o2);
    o2.write_shift(4, 4);
    write_biff_rec(ba, 2152, o2);
  }
  function write_CELLXFS_biff8(ba, opts) {
    for (var i = 0; i < 16; ++i)
      write_biff_rec(ba, 224, write_XF({ numFmtId: 0, style: true }, 0, opts));
    opts.cellXfs.forEach(function(c2) {
      write_biff_rec(ba, 224, write_XF(c2, 0, opts));
    });
  }
  function write_ws_biff8_hlinks(ba, ws) {
    for (var R2 = 0; R2 < ws["!links"].length; ++R2) {
      var HL = ws["!links"][R2];
      write_biff_rec(ba, 440, write_HLink(HL));
      if (HL[1].Tooltip)
        write_biff_rec(ba, 2048, write_HLinkTooltip(HL));
    }
    delete ws["!links"];
  }
  function write_ws_cols_biff8(ba, cols) {
    if (!cols)
      return;
    var cnt = 0;
    cols.forEach(function(col, idx) {
      if (++cnt <= 256 && col) {
        write_biff_rec(ba, 125, write_ColInfo(col_obj_w(idx, col), idx));
      }
    });
  }
  function write_ws_biff8_cell(ba, cell, R2, C2, opts) {
    var os = 16 + get_cell_style(opts.cellXfs, cell, opts);
    if (cell.v == null && !cell.bf) {
      write_biff_rec(ba, 513, write_XLSCell(R2, C2, os));
      return;
    }
    if (cell.bf)
      write_biff_rec(ba, 6, write_Formula(cell, R2, C2, opts, os));
    else
      switch (cell.t) {
        case "d":
        case "n":
          var v2 = cell.t == "d" ? datenum(parseDate(cell.v)) : cell.v;
          write_biff_rec(ba, 515, write_Number(R2, C2, v2, os));
          break;
        case "b":
        case "e":
          write_biff_rec(ba, 517, write_BoolErr(R2, C2, cell.v, os, opts, cell.t));
          break;
        case "s":
        case "str":
          if (opts.bookSST) {
            var isst = get_sst_id(opts.Strings, cell.v, opts.revStrings);
            write_biff_rec(ba, 253, write_LabelSst(R2, C2, isst, os));
          } else
            write_biff_rec(ba, 516, write_Label(R2, C2, (cell.v || "").slice(0, 255), os, opts));
          break;
        default:
          write_biff_rec(ba, 513, write_XLSCell(R2, C2, os));
      }
  }
  function write_ws_biff8(idx, opts, wb) {
    var ba = buf_array();
    var s2 = wb.SheetNames[idx], ws = wb.Sheets[s2] || {};
    var _WB = (wb || {}).Workbook || {};
    var _sheet = (_WB.Sheets || [])[idx] || {};
    var dense = Array.isArray(ws);
    var b8 = opts.biff == 8;
    var ref2, rr = "", cols = [];
    var range = safe_decode_range(ws["!ref"] || "A1");
    var MAX_ROWS = b8 ? 65536 : 16384;
    if (range.e.c > 255 || range.e.r >= MAX_ROWS) {
      if (opts.WTF)
        throw new Error("Range " + (ws["!ref"] || "A1") + " exceeds format limit A1:IV16384");
      range.e.c = Math.min(range.e.c, 255);
      range.e.r = Math.min(range.e.c, MAX_ROWS - 1);
    }
    write_biff_rec(ba, 2057, write_BOF(wb, 16, opts));
    write_biff_rec(ba, 13, writeuint16(1));
    write_biff_rec(ba, 12, writeuint16(100));
    write_biff_rec(ba, 15, writebool(true));
    write_biff_rec(ba, 17, writebool(false));
    write_biff_rec(ba, 16, write_Xnum(1e-3));
    write_biff_rec(ba, 95, writebool(true));
    write_biff_rec(ba, 42, writebool(false));
    write_biff_rec(ba, 43, writebool(false));
    write_biff_rec(ba, 130, writeuint16(1));
    write_biff_rec(ba, 128, write_Guts([0, 0]));
    write_biff_rec(ba, 131, writebool(false));
    write_biff_rec(ba, 132, writebool(false));
    if (b8)
      write_ws_cols_biff8(ba, ws["!cols"]);
    write_biff_rec(ba, 512, write_Dimensions(range, opts));
    if (b8)
      ws["!links"] = [];
    for (var R2 = range.s.r; R2 <= range.e.r; ++R2) {
      rr = encode_row(R2);
      for (var C2 = range.s.c; C2 <= range.e.c; ++C2) {
        if (R2 === range.s.r)
          cols[C2] = encode_col(C2);
        ref2 = cols[C2] + rr;
        var cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
        if (!cell)
          continue;
        write_ws_biff8_cell(ba, cell, R2, C2, opts);
        if (b8 && cell.l)
          ws["!links"].push([ref2, cell.l]);
      }
    }
    var cname = _sheet.CodeName || _sheet.name || s2;
    if (b8)
      write_biff_rec(ba, 574, write_Window2((_WB.Views || [])[0]));
    if (b8 && (ws["!merges"] || []).length)
      write_biff_rec(ba, 229, write_MergeCells(ws["!merges"]));
    if (b8)
      write_ws_biff8_hlinks(ba, ws);
    write_biff_rec(ba, 442, write_XLUnicodeString(cname));
    if (b8)
      write_FEAT(ba, ws);
    write_biff_rec(ba, 10);
    return ba.end();
  }
  function write_biff8_global(wb, bufs, opts) {
    var A2 = buf_array();
    var _WB = (wb || {}).Workbook || {};
    var _sheets = _WB.Sheets || [];
    var _wb = _WB.WBProps || {};
    var b8 = opts.biff == 8, b5 = opts.biff == 5;
    write_biff_rec(A2, 2057, write_BOF(wb, 5, opts));
    if (opts.bookType == "xla")
      write_biff_rec(A2, 135);
    write_biff_rec(A2, 225, b8 ? writeuint16(1200) : null);
    write_biff_rec(A2, 193, writezeroes(2));
    if (b5)
      write_biff_rec(A2, 191);
    if (b5)
      write_biff_rec(A2, 192);
    write_biff_rec(A2, 226);
    write_biff_rec(A2, 92, write_WriteAccess("SheetJS", opts));
    write_biff_rec(A2, 66, writeuint16(b8 ? 1200 : 1252));
    if (b8)
      write_biff_rec(A2, 353, writeuint16(0));
    if (b8)
      write_biff_rec(A2, 448);
    write_biff_rec(A2, 317, write_RRTabId(wb.SheetNames.length));
    if (b8 && wb.vbaraw)
      write_biff_rec(A2, 211);
    if (b8 && wb.vbaraw) {
      var cname = _wb.CodeName || "ThisWorkbook";
      write_biff_rec(A2, 442, write_XLUnicodeString(cname));
    }
    write_biff_rec(A2, 156, writeuint16(17));
    write_biff_rec(A2, 25, writebool(false));
    write_biff_rec(A2, 18, writebool(false));
    write_biff_rec(A2, 19, writeuint16(0));
    if (b8)
      write_biff_rec(A2, 431, writebool(false));
    if (b8)
      write_biff_rec(A2, 444, writeuint16(0));
    write_biff_rec(A2, 61, write_Window1());
    write_biff_rec(A2, 64, writebool(false));
    write_biff_rec(A2, 141, writeuint16(0));
    write_biff_rec(A2, 34, writebool(safe1904(wb) == "true"));
    write_biff_rec(A2, 14, writebool(true));
    if (b8)
      write_biff_rec(A2, 439, writebool(false));
    write_biff_rec(A2, 218, writeuint16(0));
    write_FONTS_biff8(A2, wb, opts);
    write_FMTS_biff8(A2, wb.SSF, opts);
    write_CELLXFS_biff8(A2, opts);
    if (b8)
      write_biff_rec(A2, 352, writebool(false));
    var a2 = A2.end();
    var C2 = buf_array();
    if (b8)
      write_biff_rec(C2, 140, write_Country());
    if (b8 && opts.Strings)
      write_biff_continue(C2, 252, write_SST(opts.Strings));
    write_biff_rec(C2, 10);
    var c2 = C2.end();
    var B2 = buf_array();
    var blen = 0, j = 0;
    for (j = 0; j < wb.SheetNames.length; ++j)
      blen += (b8 ? 12 : 11) + (b8 ? 2 : 1) * wb.SheetNames[j].length;
    var start = a2.length + blen + c2.length;
    for (j = 0; j < wb.SheetNames.length; ++j) {
      var _sheet = _sheets[j] || {};
      write_biff_rec(B2, 133, write_BoundSheet8({ pos: start, hs: _sheet.Hidden || 0, dt: 0, name: wb.SheetNames[j] }, opts));
      start += bufs[j].length;
    }
    var b2 = B2.end();
    if (blen != b2.length)
      throw new Error("BS8 " + blen + " != " + b2.length);
    var out = [];
    if (a2.length)
      out.push(a2);
    if (b2.length)
      out.push(b2);
    if (c2.length)
      out.push(c2);
    return bconcat(out);
  }
  function write_biff8_buf(wb, opts) {
    var o2 = opts || {};
    var bufs = [];
    if (wb && !wb.SSF) {
      wb.SSF = dup(table_fmt);
    }
    if (wb && wb.SSF) {
      make_ssf();
      SSF_load_table(wb.SSF);
      o2.revssf = evert_num(wb.SSF);
      o2.revssf[wb.SSF[65535]] = 0;
      o2.ssf = wb.SSF;
    }
    o2.Strings = [];
    o2.Strings.Count = 0;
    o2.Strings.Unique = 0;
    fix_write_opts(o2);
    o2.cellXfs = [];
    get_cell_style(o2.cellXfs, {}, { revssf: { "General": 0 } });
    if (!wb.Props)
      wb.Props = {};
    for (var i = 0; i < wb.SheetNames.length; ++i)
      bufs[bufs.length] = write_ws_biff8(i, o2, wb);
    bufs.unshift(write_biff8_global(wb, bufs, o2));
    return bconcat(bufs);
  }
  function write_biff_buf(wb, opts) {
    for (var i = 0; i <= wb.SheetNames.length; ++i) {
      var ws = wb.Sheets[wb.SheetNames[i]];
      if (!ws || !ws["!ref"])
        continue;
      var range = decode_range(ws["!ref"]);
      if (range.e.c > 255) {
        if (typeof console != "undefined" && console.error)
          console.error("Worksheet '" + wb.SheetNames[i] + "' extends beyond column IV (255).  Data may be lost.");
      }
    }
    var o2 = opts || {};
    switch (o2.biff || 2) {
      case 8:
      case 5:
        return write_biff8_buf(wb, opts);
      case 4:
      case 3:
      case 2:
        return write_biff2_buf(wb, opts);
    }
    throw new Error("invalid type " + o2.bookType + " for BIFF");
  }
  function html_to_sheet(str, _opts) {
    var opts = _opts || {};
    var ws = opts.dense ? [] : {};
    str = str.replace(/<!--.*?-->/g, "");
    var mtch = str.match(/<table/i);
    if (!mtch)
      throw new Error("Invalid HTML: could not find <table>");
    var mtch2 = str.match(/<\/table/i);
    var i = mtch.index, j = mtch2 && mtch2.index || str.length;
    var rows = split_regex(str.slice(i, j), /(:?<tr[^>]*>)/i, "<tr>");
    var R2 = -1, C2 = 0, RS = 0, CS = 0;
    var range = { s: { r: 1e7, c: 1e7 }, e: { r: 0, c: 0 } };
    var merges = [];
    for (i = 0; i < rows.length; ++i) {
      var row = rows[i].trim();
      var hd = row.slice(0, 3).toLowerCase();
      if (hd == "<tr") {
        ++R2;
        if (opts.sheetRows && opts.sheetRows <= R2) {
          --R2;
          break;
        }
        C2 = 0;
        continue;
      }
      if (hd != "<td" && hd != "<th")
        continue;
      var cells = row.split(/<\/t[dh]>/i);
      for (j = 0; j < cells.length; ++j) {
        var cell = cells[j].trim();
        if (!cell.match(/<t[dh]/i))
          continue;
        var m2 = cell, cc = 0;
        while (m2.charAt(0) == "<" && (cc = m2.indexOf(">")) > -1)
          m2 = m2.slice(cc + 1);
        for (var midx = 0; midx < merges.length; ++midx) {
          var _merge = merges[midx];
          if (_merge.s.c == C2 && _merge.s.r < R2 && R2 <= _merge.e.r) {
            C2 = _merge.e.c + 1;
            midx = -1;
          }
        }
        var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
        CS = tag.colspan ? +tag.colspan : 1;
        if ((RS = +tag.rowspan) > 1 || CS > 1)
          merges.push({ s: { r: R2, c: C2 }, e: { r: R2 + (RS || 1) - 1, c: C2 + CS - 1 } });
        var _t2 = tag.t || tag["data-t"] || "";
        if (!m2.length) {
          C2 += CS;
          continue;
        }
        m2 = htmldecode(m2);
        if (range.s.r > R2)
          range.s.r = R2;
        if (range.e.r < R2)
          range.e.r = R2;
        if (range.s.c > C2)
          range.s.c = C2;
        if (range.e.c < C2)
          range.e.c = C2;
        if (!m2.length) {
          C2 += CS;
          continue;
        }
        var o2 = { t: "s", v: m2 };
        if (opts.raw || !m2.trim().length || _t2 == "s")
          ;
        else if (m2 === "TRUE")
          o2 = { t: "b", v: true };
        else if (m2 === "FALSE")
          o2 = { t: "b", v: false };
        else if (!isNaN(fuzzynum(m2)))
          o2 = { t: "n", v: fuzzynum(m2) };
        else if (!isNaN(fuzzydate(m2).getDate())) {
          o2 = { t: "d", v: parseDate(m2) };
          if (!opts.cellDates)
            o2 = { t: "n", v: datenum(o2.v) };
          o2.z = opts.dateNF || table_fmt[14];
        }
        if (opts.dense) {
          if (!ws[R2])
            ws[R2] = [];
          ws[R2][C2] = o2;
        } else
          ws[encode_cell({ r: R2, c: C2 })] = o2;
        C2 += CS;
      }
    }
    ws["!ref"] = encode_range(range);
    if (merges.length)
      ws["!merges"] = merges;
    return ws;
  }
  function make_html_row(ws, r, R2, o2) {
    var M2 = ws["!merges"] || [];
    var oo = [];
    for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
      var RS = 0, CS = 0;
      for (var j = 0; j < M2.length; ++j) {
        if (M2[j].s.r > R2 || M2[j].s.c > C2)
          continue;
        if (M2[j].e.r < R2 || M2[j].e.c < C2)
          continue;
        if (M2[j].s.r < R2 || M2[j].s.c < C2) {
          RS = -1;
          break;
        }
        RS = M2[j].e.r - M2[j].s.r + 1;
        CS = M2[j].e.c - M2[j].s.c + 1;
        break;
      }
      if (RS < 0)
        continue;
      var coord = encode_cell({ r: R2, c: C2 });
      var cell = o2.dense ? (ws[R2] || [])[C2] : ws[coord];
      var w2 = cell && cell.v != null && (cell.h || escapehtml(cell.w || (format_cell(cell), cell.w) || "")) || "";
      var sp = {};
      if (RS > 1)
        sp.rowspan = RS;
      if (CS > 1)
        sp.colspan = CS;
      if (o2.editable)
        w2 = '<span contenteditable="true">' + w2 + "</span>";
      else if (cell) {
        sp["data-t"] = cell && cell.t || "z";
        if (cell.v != null)
          sp["data-v"] = cell.v;
        if (cell.z != null)
          sp["data-z"] = cell.z;
        if (cell.l && (cell.l.Target || "#").charAt(0) != "#")
          w2 = '<a href="' + cell.l.Target + '">' + w2 + "</a>";
      }
      sp.id = (o2.id || "sjs") + "-" + coord;
      oo.push(writextag("td", w2, sp));
    }
    var preamble = "<tr>";
    return preamble + oo.join("") + "</tr>";
  }
  var HTML_BEGIN = '<html><head><meta charset="utf-8"/><title>SheetJS Table Export</title></head><body>';
  var HTML_END = "</body></html>";
  function html_to_workbook(str, opts) {
    var mtch = str.match(/<table[\s\S]*?>[\s\S]*?<\/table>/gi);
    if (!mtch || mtch.length == 0)
      throw new Error("Invalid HTML: could not find <table>");
    if (mtch.length == 1)
      return sheet_to_workbook(html_to_sheet(mtch[0], opts), opts);
    var wb = book_new();
    mtch.forEach(function(s2, idx) {
      book_append_sheet(wb, html_to_sheet(s2, opts), "Sheet" + (idx + 1));
    });
    return wb;
  }
  function make_html_preamble(ws, R2, o2) {
    var out = [];
    return out.join("") + "<table" + (o2 && o2.id ? ' id="' + o2.id + '"' : "") + ">";
  }
  function sheet_to_html(ws, opts) {
    var o2 = opts || {};
    var header = o2.header != null ? o2.header : HTML_BEGIN;
    var footer = o2.footer != null ? o2.footer : HTML_END;
    var out = [header];
    var r = decode_range(ws["!ref"]);
    o2.dense = Array.isArray(ws);
    out.push(make_html_preamble(ws, r, o2));
    for (var R2 = r.s.r; R2 <= r.e.r; ++R2)
      out.push(make_html_row(ws, r, R2, o2));
    out.push("</table>" + footer);
    return out.join("");
  }
  function sheet_add_dom(ws, table, _opts) {
    var opts = _opts || {};
    var or_R = 0, or_C = 0;
    if (opts.origin != null) {
      if (typeof opts.origin == "number")
        or_R = opts.origin;
      else {
        var _origin = typeof opts.origin == "string" ? decode_cell(opts.origin) : opts.origin;
        or_R = _origin.r;
        or_C = _origin.c;
      }
    }
    var rows = table.getElementsByTagName("tr");
    var sheetRows = Math.min(opts.sheetRows || 1e7, rows.length);
    var range = { s: { r: 0, c: 0 }, e: { r: or_R, c: or_C } };
    if (ws["!ref"]) {
      var _range = decode_range(ws["!ref"]);
      range.s.r = Math.min(range.s.r, _range.s.r);
      range.s.c = Math.min(range.s.c, _range.s.c);
      range.e.r = Math.max(range.e.r, _range.e.r);
      range.e.c = Math.max(range.e.c, _range.e.c);
      if (or_R == -1)
        range.e.r = or_R = _range.e.r + 1;
    }
    var merges = [], midx = 0;
    var rowinfo = ws["!rows"] || (ws["!rows"] = []);
    var _R = 0, R2 = 0, _C = 0, C2 = 0, RS = 0, CS = 0;
    if (!ws["!cols"])
      ws["!cols"] = [];
    for (; _R < rows.length && R2 < sheetRows; ++_R) {
      var row = rows[_R];
      if (is_dom_element_hidden(row)) {
        if (opts.display)
          continue;
        rowinfo[R2] = { hidden: true };
      }
      var elts = row.children;
      for (_C = C2 = 0; _C < elts.length; ++_C) {
        var elt = elts[_C];
        if (opts.display && is_dom_element_hidden(elt))
          continue;
        var v2 = elt.hasAttribute("data-v") ? elt.getAttribute("data-v") : elt.hasAttribute("v") ? elt.getAttribute("v") : htmldecode(elt.innerHTML);
        var z = elt.getAttribute("data-z") || elt.getAttribute("z");
        for (midx = 0; midx < merges.length; ++midx) {
          var m2 = merges[midx];
          if (m2.s.c == C2 + or_C && m2.s.r < R2 + or_R && R2 + or_R <= m2.e.r) {
            C2 = m2.e.c + 1 - or_C;
            midx = -1;
          }
        }
        CS = +elt.getAttribute("colspan") || 1;
        if ((RS = +elt.getAttribute("rowspan") || 1) > 1 || CS > 1)
          merges.push({ s: { r: R2 + or_R, c: C2 + or_C }, e: { r: R2 + or_R + (RS || 1) - 1, c: C2 + or_C + (CS || 1) - 1 } });
        var o2 = { t: "s", v: v2 };
        var _t2 = elt.getAttribute("data-t") || elt.getAttribute("t") || "";
        if (v2 != null) {
          if (v2.length == 0)
            o2.t = _t2 || "z";
          else if (opts.raw || v2.trim().length == 0 || _t2 == "s")
            ;
          else if (v2 === "TRUE")
            o2 = { t: "b", v: true };
          else if (v2 === "FALSE")
            o2 = { t: "b", v: false };
          else if (!isNaN(fuzzynum(v2)))
            o2 = { t: "n", v: fuzzynum(v2) };
          else if (!isNaN(fuzzydate(v2).getDate())) {
            o2 = { t: "d", v: parseDate(v2) };
            if (!opts.cellDates)
              o2 = { t: "n", v: datenum(o2.v) };
            o2.z = opts.dateNF || table_fmt[14];
          }
        }
        if (o2.z === void 0 && z != null)
          o2.z = z;
        var l2 = "", Aelts = elt.getElementsByTagName("A");
        if (Aelts && Aelts.length) {
          for (var Aelti = 0; Aelti < Aelts.length; ++Aelti)
            if (Aelts[Aelti].hasAttribute("href")) {
              l2 = Aelts[Aelti].getAttribute("href");
              if (l2.charAt(0) != "#")
                break;
            }
        }
        if (l2 && l2.charAt(0) != "#")
          o2.l = { Target: l2 };
        if (opts.dense) {
          if (!ws[R2 + or_R])
            ws[R2 + or_R] = [];
          ws[R2 + or_R][C2 + or_C] = o2;
        } else
          ws[encode_cell({ c: C2 + or_C, r: R2 + or_R })] = o2;
        if (range.e.c < C2 + or_C)
          range.e.c = C2 + or_C;
        C2 += CS;
      }
      ++R2;
    }
    if (merges.length)
      ws["!merges"] = (ws["!merges"] || []).concat(merges);
    range.e.r = Math.max(range.e.r, R2 - 1 + or_R);
    ws["!ref"] = encode_range(range);
    if (R2 >= sheetRows)
      ws["!fullref"] = encode_range((range.e.r = rows.length - _R + R2 - 1 + or_R, range));
    return ws;
  }
  function parse_dom_table(table, _opts) {
    var opts = _opts || {};
    var ws = opts.dense ? [] : {};
    return sheet_add_dom(ws, table, _opts);
  }
  function table_to_book(table, opts) {
    return sheet_to_workbook(parse_dom_table(table, opts), opts);
  }
  function is_dom_element_hidden(element) {
    var display = "";
    var get_computed_style = get_get_computed_style_function(element);
    if (get_computed_style)
      display = get_computed_style(element).getPropertyValue("display");
    if (!display)
      display = element.style && element.style.display;
    return display === "none";
  }
  function get_get_computed_style_function(element) {
    if (element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === "function")
      return element.ownerDocument.defaultView.getComputedStyle;
    if (typeof getComputedStyle === "function")
      return getComputedStyle;
    return null;
  }
  function parse_text_p(text) {
    var fixed = text.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ").replace(/<text:s\/>/g, " ").replace(/<text:s text:c="(\d+)"\/>/g, function($$, $1) {
      return Array(parseInt($1, 10) + 1).join(" ");
    }).replace(/<text:tab[^>]*\/>/g, "	").replace(/<text:line-break\/>/g, "\n");
    var v2 = unescapexml(fixed.replace(/<[^>]*>/g, ""));
    return [v2];
  }
  var number_formats_ods = {
    day: ["d", "dd"],
    month: ["m", "mm"],
    year: ["y", "yy"],
    hours: ["h", "hh"],
    minutes: ["m", "mm"],
    seconds: ["s", "ss"],
    "am-pm": ["A/P", "AM/PM"],
    "day-of-week": ["ddd", "dddd"],
    era: ["e", "ee"],
    quarter: ["\\Qm", 'm\\"th quarter"']
  };
  function parse_content_xml(d2, _opts) {
    var opts = _opts || {};
    var str = xlml_normalize(d2);
    var state = [], tmp;
    var tag;
    var NFtag = { name: "" }, NF = "", pidx = 0;
    var sheetag;
    var rowtag;
    var Sheets = {}, SheetNames = [];
    var ws = opts.dense ? [] : {};
    var Rn, q2;
    var ctag = { value: "" };
    var textp = "", textpidx = 0;
    var textR = [];
    var R2 = -1, C2 = -1, range = { s: { r: 1e6, c: 1e7 }, e: { r: 0, c: 0 } };
    var row_ol = 0;
    var number_format_map = {};
    var merges = [], mrange = {}, mR = 0, mC = 0;
    var rowinfo = [], rowpeat = 1, colpeat = 1;
    var arrayf = [];
    var WB = { Names: [] };
    var atag = {};
    var _Ref = ["", ""];
    var comments = [], comment = {};
    var creator = "", creatoridx = 0;
    var isstub = false, intable = false;
    var i = 0;
    xlmlregex.lastIndex = 0;
    str = str.replace(/<!--([\s\S]*?)-->/mg, "").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm, "");
    while (Rn = xlmlregex.exec(str))
      switch (Rn[3] = Rn[3].replace(/_.*$/, "")) {
        case "table":
        case "\u5DE5\u4F5C\u8868":
          if (Rn[1] === "/") {
            if (range.e.c >= range.s.c && range.e.r >= range.s.r)
              ws["!ref"] = encode_range(range);
            else
              ws["!ref"] = "A1:A1";
            if (opts.sheetRows > 0 && opts.sheetRows <= range.e.r) {
              ws["!fullref"] = ws["!ref"];
              range.e.r = opts.sheetRows - 1;
              ws["!ref"] = encode_range(range);
            }
            if (merges.length)
              ws["!merges"] = merges;
            if (rowinfo.length)
              ws["!rows"] = rowinfo;
            sheetag.name = sheetag["\u540D\u79F0"] || sheetag.name;
            if (typeof JSON !== "undefined")
              JSON.stringify(sheetag);
            SheetNames.push(sheetag.name);
            Sheets[sheetag.name] = ws;
            intable = false;
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/") {
            sheetag = parsexmltag(Rn[0], false);
            R2 = C2 = -1;
            range.s.r = range.s.c = 1e7;
            range.e.r = range.e.c = 0;
            ws = opts.dense ? [] : {};
            merges = [];
            rowinfo = [];
            intable = true;
          }
          break;
        case "table-row-group":
          if (Rn[1] === "/")
            --row_ol;
          else
            ++row_ol;
          break;
        case "table-row":
        case "\u884C":
          if (Rn[1] === "/") {
            R2 += rowpeat;
            rowpeat = 1;
            break;
          }
          rowtag = parsexmltag(Rn[0], false);
          if (rowtag["\u884C\u53F7"])
            R2 = rowtag["\u884C\u53F7"] - 1;
          else if (R2 == -1)
            R2 = 0;
          rowpeat = +rowtag["number-rows-repeated"] || 1;
          if (rowpeat < 10) {
            for (i = 0; i < rowpeat; ++i)
              if (row_ol > 0)
                rowinfo[R2 + i] = { level: row_ol };
          }
          C2 = -1;
          break;
        case "covered-table-cell":
          if (Rn[1] !== "/")
            ++C2;
          if (opts.sheetStubs) {
            if (opts.dense) {
              if (!ws[R2])
                ws[R2] = [];
              ws[R2][C2] = { t: "z" };
            } else
              ws[encode_cell({ r: R2, c: C2 })] = { t: "z" };
          }
          textp = "";
          textR = [];
          break;
        case "table-cell":
        case "\u6570\u636E":
          if (Rn[0].charAt(Rn[0].length - 2) === "/") {
            ++C2;
            ctag = parsexmltag(Rn[0], false);
            colpeat = parseInt(ctag["number-columns-repeated"] || "1", 10);
            q2 = { t: "z", v: null };
            if (ctag.formula && opts.cellFormula != false)
              q2.f = ods_to_csf_formula(unescapexml(ctag.formula));
            if ((ctag["\u6570\u636E\u7C7B\u578B"] || ctag["value-type"]) == "string") {
              q2.t = "s";
              q2.v = unescapexml(ctag["string-value"] || "");
              if (opts.dense) {
                if (!ws[R2])
                  ws[R2] = [];
                ws[R2][C2] = q2;
              } else {
                ws[encode_cell({ r: R2, c: C2 })] = q2;
              }
            }
            C2 += colpeat - 1;
          } else if (Rn[1] !== "/") {
            ++C2;
            textp = "";
            textpidx = 0;
            textR = [];
            colpeat = 1;
            var rptR = rowpeat ? R2 + rowpeat - 1 : R2;
            if (C2 > range.e.c)
              range.e.c = C2;
            if (C2 < range.s.c)
              range.s.c = C2;
            if (R2 < range.s.r)
              range.s.r = R2;
            if (rptR > range.e.r)
              range.e.r = rptR;
            ctag = parsexmltag(Rn[0], false);
            comments = [];
            comment = {};
            q2 = { t: ctag["\u6570\u636E\u7C7B\u578B"] || ctag["value-type"], v: null };
            if (opts.cellFormula) {
              if (ctag.formula)
                ctag.formula = unescapexml(ctag.formula);
              if (ctag["number-matrix-columns-spanned"] && ctag["number-matrix-rows-spanned"]) {
                mR = parseInt(ctag["number-matrix-rows-spanned"], 10) || 0;
                mC = parseInt(ctag["number-matrix-columns-spanned"], 10) || 0;
                mrange = { s: { r: R2, c: C2 }, e: { r: R2 + mR - 1, c: C2 + mC - 1 } };
                q2.F = encode_range(mrange);
                arrayf.push([mrange, q2.F]);
              }
              if (ctag.formula)
                q2.f = ods_to_csf_formula(ctag.formula);
              else
                for (i = 0; i < arrayf.length; ++i)
                  if (R2 >= arrayf[i][0].s.r && R2 <= arrayf[i][0].e.r) {
                    if (C2 >= arrayf[i][0].s.c && C2 <= arrayf[i][0].e.c)
                      q2.F = arrayf[i][1];
                  }
            }
            if (ctag["number-columns-spanned"] || ctag["number-rows-spanned"]) {
              mR = parseInt(ctag["number-rows-spanned"], 10) || 0;
              mC = parseInt(ctag["number-columns-spanned"], 10) || 0;
              mrange = { s: { r: R2, c: C2 }, e: { r: R2 + mR - 1, c: C2 + mC - 1 } };
              merges.push(mrange);
            }
            if (ctag["number-columns-repeated"])
              colpeat = parseInt(ctag["number-columns-repeated"], 10);
            switch (q2.t) {
              case "boolean":
                q2.t = "b";
                q2.v = parsexmlbool(ctag["boolean-value"]);
                break;
              case "float":
                q2.t = "n";
                q2.v = parseFloat(ctag.value);
                break;
              case "percentage":
                q2.t = "n";
                q2.v = parseFloat(ctag.value);
                break;
              case "currency":
                q2.t = "n";
                q2.v = parseFloat(ctag.value);
                break;
              case "date":
                q2.t = "d";
                q2.v = parseDate(ctag["date-value"]);
                if (!opts.cellDates) {
                  q2.t = "n";
                  q2.v = datenum(q2.v);
                }
                q2.z = "m/d/yy";
                break;
              case "time":
                q2.t = "n";
                q2.v = parse_isodur(ctag["time-value"]) / 86400;
                if (opts.cellDates) {
                  q2.t = "d";
                  q2.v = numdate(q2.v);
                }
                q2.z = "HH:MM:SS";
                break;
              case "number":
                q2.t = "n";
                q2.v = parseFloat(ctag["\u6570\u636E\u6570\u503C"]);
                break;
              default:
                if (q2.t === "string" || q2.t === "text" || !q2.t) {
                  q2.t = "s";
                  if (ctag["string-value"] != null) {
                    textp = unescapexml(ctag["string-value"]);
                    textR = [];
                  }
                } else
                  throw new Error("Unsupported value type " + q2.t);
            }
          } else {
            isstub = false;
            if (q2.t === "s") {
              q2.v = textp || "";
              if (textR.length)
                q2.R = textR;
              isstub = textpidx == 0;
            }
            if (atag.Target)
              q2.l = atag;
            if (comments.length > 0) {
              q2.c = comments;
              comments = [];
            }
            if (textp && opts.cellText !== false)
              q2.w = textp;
            if (isstub) {
              q2.t = "z";
              delete q2.v;
            }
            if (!isstub || opts.sheetStubs) {
              if (!(opts.sheetRows && opts.sheetRows <= R2)) {
                for (var rpt = 0; rpt < rowpeat; ++rpt) {
                  colpeat = parseInt(ctag["number-columns-repeated"] || "1", 10);
                  if (opts.dense) {
                    if (!ws[R2 + rpt])
                      ws[R2 + rpt] = [];
                    ws[R2 + rpt][C2] = rpt == 0 ? q2 : dup(q2);
                    while (--colpeat > 0)
                      ws[R2 + rpt][C2 + colpeat] = dup(q2);
                  } else {
                    ws[encode_cell({ r: R2 + rpt, c: C2 })] = q2;
                    while (--colpeat > 0)
                      ws[encode_cell({ r: R2 + rpt, c: C2 + colpeat })] = dup(q2);
                  }
                  if (range.e.c <= C2)
                    range.e.c = C2;
                }
              }
            }
            colpeat = parseInt(ctag["number-columns-repeated"] || "1", 10);
            C2 += colpeat - 1;
            colpeat = 0;
            q2 = {};
            textp = "";
            textR = [];
          }
          atag = {};
          break;
        case "document":
        case "document-content":
        case "\u7535\u5B50\u8868\u683C\u6587\u6863":
        case "spreadsheet":
        case "\u4E3B\u4F53":
        case "scripts":
        case "styles":
        case "font-face-decls":
        case "master-styles":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw "Bad state: " + tmp;
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/")
            state.push([Rn[3], true]);
          break;
        case "annotation":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw "Bad state: " + tmp;
            comment.t = textp;
            if (textR.length)
              comment.R = textR;
            comment.a = creator;
            comments.push(comment);
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/") {
            state.push([Rn[3], false]);
          }
          creator = "";
          creatoridx = 0;
          textp = "";
          textpidx = 0;
          textR = [];
          break;
        case "creator":
          if (Rn[1] === "/") {
            creator = str.slice(creatoridx, Rn.index);
          } else
            creatoridx = Rn.index + Rn[0].length;
          break;
        case "meta":
        case "\u5143\u6570\u636E":
        case "settings":
        case "config-item-set":
        case "config-item-map-indexed":
        case "config-item-map-entry":
        case "config-item-map-named":
        case "shapes":
        case "frame":
        case "text-box":
        case "image":
        case "data-pilot-tables":
        case "list-style":
        case "form":
        case "dde-links":
        case "event-listeners":
        case "chart":
          if (Rn[1] === "/") {
            if ((tmp = state.pop())[0] !== Rn[3])
              throw "Bad state: " + tmp;
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/")
            state.push([Rn[3], false]);
          textp = "";
          textpidx = 0;
          textR = [];
          break;
        case "scientific-number":
          break;
        case "currency-symbol":
          break;
        case "currency-style":
          break;
        case "number-style":
        case "percentage-style":
        case "date-style":
        case "time-style":
          if (Rn[1] === "/") {
            number_format_map[NFtag.name] = NF;
            if ((tmp = state.pop())[0] !== Rn[3])
              throw "Bad state: " + tmp;
          } else if (Rn[0].charAt(Rn[0].length - 2) !== "/") {
            NF = "";
            NFtag = parsexmltag(Rn[0], false);
            state.push([Rn[3], true]);
          }
          break;
        case "script":
          break;
        case "libraries":
          break;
        case "automatic-styles":
          break;
        case "default-style":
        case "page-layout":
          break;
        case "style":
          break;
        case "map":
          break;
        case "font-face":
          break;
        case "paragraph-properties":
          break;
        case "table-properties":
          break;
        case "table-column-properties":
          break;
        case "table-row-properties":
          break;
        case "table-cell-properties":
          break;
        case "number":
          switch (state[state.length - 1][0]) {
            case "time-style":
            case "date-style":
              tag = parsexmltag(Rn[0], false);
              NF += number_formats_ods[Rn[3]][tag.style === "long" ? 1 : 0];
              break;
          }
          break;
        case "fraction":
          break;
        case "day":
        case "month":
        case "year":
        case "era":
        case "day-of-week":
        case "week-of-year":
        case "quarter":
        case "hours":
        case "minutes":
        case "seconds":
        case "am-pm":
          switch (state[state.length - 1][0]) {
            case "time-style":
            case "date-style":
              tag = parsexmltag(Rn[0], false);
              NF += number_formats_ods[Rn[3]][tag.style === "long" ? 1 : 0];
              break;
          }
          break;
        case "boolean-style":
          break;
        case "boolean":
          break;
        case "text-style":
          break;
        case "text":
          if (Rn[0].slice(-2) === "/>")
            break;
          else if (Rn[1] === "/")
            switch (state[state.length - 1][0]) {
              case "number-style":
              case "date-style":
              case "time-style":
                NF += str.slice(pidx, Rn.index);
                break;
            }
          else
            pidx = Rn.index + Rn[0].length;
          break;
        case "named-range":
          tag = parsexmltag(Rn[0], false);
          _Ref = ods_to_csf_3D(tag["cell-range-address"]);
          var nrange = { Name: tag.name, Ref: _Ref[0] + "!" + _Ref[1] };
          if (intable)
            nrange.Sheet = SheetNames.length;
          WB.Names.push(nrange);
          break;
        case "text-content":
          break;
        case "text-properties":
          break;
        case "embedded-text":
          break;
        case "body":
        case "\u7535\u5B50\u8868\u683C":
          break;
        case "forms":
          break;
        case "table-column":
          break;
        case "table-header-rows":
          break;
        case "table-rows":
          break;
        case "table-column-group":
          break;
        case "table-header-columns":
          break;
        case "table-columns":
          break;
        case "null-date":
          break;
        case "graphic-properties":
          break;
        case "calculation-settings":
          break;
        case "named-expressions":
          break;
        case "label-range":
          break;
        case "label-ranges":
          break;
        case "named-expression":
          break;
        case "sort":
          break;
        case "sort-by":
          break;
        case "sort-groups":
          break;
        case "tab":
          break;
        case "line-break":
          break;
        case "span":
          break;
        case "p":
        case "\u6587\u672C\u4E32":
          if (["master-styles"].indexOf(state[state.length - 1][0]) > -1)
            break;
          if (Rn[1] === "/" && (!ctag || !ctag["string-value"])) {
            var ptp = parse_text_p(str.slice(textpidx, Rn.index));
            textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
          } else {
            parsexmltag(Rn[0], false);
            textpidx = Rn.index + Rn[0].length;
          }
          break;
        case "s":
          break;
        case "database-range":
          if (Rn[1] === "/")
            break;
          try {
            _Ref = ods_to_csf_3D(parsexmltag(Rn[0])["target-range-address"]);
            Sheets[_Ref[0]]["!autofilter"] = { ref: _Ref[1] };
          } catch (e) {
          }
          break;
        case "date":
          break;
        case "object":
          break;
        case "title":
        case "\u6807\u9898":
          break;
        case "desc":
          break;
        case "binary-data":
          break;
        case "table-source":
          break;
        case "scenario":
          break;
        case "iteration":
          break;
        case "content-validations":
          break;
        case "content-validation":
          break;
        case "help-message":
          break;
        case "error-message":
          break;
        case "database-ranges":
          break;
        case "filter":
          break;
        case "filter-and":
          break;
        case "filter-or":
          break;
        case "filter-condition":
          break;
        case "list-level-style-bullet":
          break;
        case "list-level-style-number":
          break;
        case "list-level-properties":
          break;
        case "sender-firstname":
        case "sender-lastname":
        case "sender-initials":
        case "sender-title":
        case "sender-position":
        case "sender-email":
        case "sender-phone-private":
        case "sender-fax":
        case "sender-company":
        case "sender-phone-work":
        case "sender-street":
        case "sender-city":
        case "sender-postal-code":
        case "sender-country":
        case "sender-state-or-province":
        case "author-name":
        case "author-initials":
        case "chapter":
        case "file-name":
        case "template-name":
        case "sheet-name":
          break;
        case "event-listener":
          break;
        case "initial-creator":
        case "creation-date":
        case "print-date":
        case "generator":
        case "document-statistic":
        case "user-defined":
        case "editing-duration":
        case "editing-cycles":
          break;
        case "config-item":
          break;
        case "page-number":
          break;
        case "page-count":
          break;
        case "time":
          break;
        case "cell-range-source":
          break;
        case "detective":
          break;
        case "operation":
          break;
        case "highlighted-range":
          break;
        case "data-pilot-table":
        case "source-cell-range":
        case "source-service":
        case "data-pilot-field":
        case "data-pilot-level":
        case "data-pilot-subtotals":
        case "data-pilot-subtotal":
        case "data-pilot-members":
        case "data-pilot-member":
        case "data-pilot-display-info":
        case "data-pilot-sort-info":
        case "data-pilot-layout-info":
        case "data-pilot-field-reference":
        case "data-pilot-groups":
        case "data-pilot-group":
        case "data-pilot-group-member":
          break;
        case "rect":
          break;
        case "dde-connection-decls":
        case "dde-connection-decl":
        case "dde-link":
        case "dde-source":
          break;
        case "properties":
          break;
        case "property":
          break;
        case "a":
          if (Rn[1] !== "/") {
            atag = parsexmltag(Rn[0], false);
            if (!atag.href)
              break;
            atag.Target = unescapexml(atag.href);
            delete atag.href;
            if (atag.Target.charAt(0) == "#" && atag.Target.indexOf(".") > -1) {
              _Ref = ods_to_csf_3D(atag.Target.slice(1));
              atag.Target = "#" + _Ref[0] + "!" + _Ref[1];
            } else if (atag.Target.match(/^\.\.[\\\/]/))
              atag.Target = atag.Target.slice(3);
          }
          break;
        case "table-protection":
          break;
        case "data-pilot-grand-total":
          break;
        case "office-document-common-attrs":
          break;
        default:
          switch (Rn[2]) {
            case "dc:":
            case "calcext:":
            case "loext:":
            case "ooo:":
            case "chartooo:":
            case "draw:":
            case "style:":
            case "chart:":
            case "form:":
            case "uof:":
            case "\u8868:":
            case "\u5B57:":
              break;
            default:
              if (opts.WTF)
                throw new Error(Rn);
          }
      }
    var out = {
      Sheets,
      SheetNames,
      Workbook: WB
    };
    if (opts.bookSheets)
      delete out.Sheets;
    return out;
  }
  function parse_ods(zip, opts) {
    opts = opts || {};
    if (safegetzipfile(zip, "META-INF/manifest.xml"))
      parse_manifest(getzipdata(zip, "META-INF/manifest.xml"), opts);
    var content = getzipstr(zip, "content.xml");
    if (!content)
      throw new Error("Missing content.xml in ODS / UOF file");
    var wb = parse_content_xml(utf8read(content), opts);
    if (safegetzipfile(zip, "meta.xml"))
      wb.Props = parse_core_props(getzipdata(zip, "meta.xml"));
    return wb;
  }
  function parse_fods(data, opts) {
    return parse_content_xml(data, opts);
  }
  var write_styles_ods = /* @__PURE__ */ function() {
    var master_styles = [
      "<office:master-styles>",
      '<style:master-page style:name="mp1" style:page-layout-name="mp1">',
      "<style:header/>",
      '<style:header-left style:display="false"/>',
      "<style:footer/>",
      '<style:footer-left style:display="false"/>',
      "</style:master-page>",
      "</office:master-styles>"
    ].join("");
    var payload = "<office:document-styles " + wxt_helper({
      "xmlns:office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
      "xmlns:table": "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
      "xmlns:style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
      "xmlns:text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
      "xmlns:draw": "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",
      "xmlns:fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
      "xmlns:xlink": "http://www.w3.org/1999/xlink",
      "xmlns:dc": "http://purl.org/dc/elements/1.1/",
      "xmlns:number": "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",
      "xmlns:svg": "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",
      "xmlns:of": "urn:oasis:names:tc:opendocument:xmlns:of:1.2",
      "office:version": "1.2"
    }) + ">" + master_styles + "</office:document-styles>";
    return function wso() {
      return XML_HEADER + payload;
    };
  }();
  var write_content_ods = /* @__PURE__ */ function() {
    var write_text_p = function(text) {
      return escapexml(text).replace(/  +/g, function($$) {
        return '<text:s text:c="' + $$.length + '"/>';
      }).replace(/\t/g, "<text:tab/>").replace(/\n/g, "</text:p><text:p>").replace(/^ /, "<text:s/>").replace(/ $/, "<text:s/>");
    };
    var null_cell_xml = "          <table:table-cell />\n";
    var covered_cell_xml = "          <table:covered-table-cell/>\n";
    var write_ws2 = function(ws, wb, i) {
      var o2 = [];
      o2.push('      <table:table table:name="' + escapexml(wb.SheetNames[i]) + '" table:style-name="ta1">\n');
      var R2 = 0, C2 = 0, range = decode_range(ws["!ref"] || "A1");
      var marr = ws["!merges"] || [], mi = 0;
      var dense = Array.isArray(ws);
      if (ws["!cols"]) {
        for (C2 = 0; C2 <= range.e.c; ++C2)
          o2.push("        <table:table-column" + (ws["!cols"][C2] ? ' table:style-name="co' + ws["!cols"][C2].ods + '"' : "") + "></table:table-column>\n");
      }
      var H2 = "", ROWS = ws["!rows"] || [];
      for (R2 = 0; R2 < range.s.r; ++R2) {
        H2 = ROWS[R2] ? ' table:style-name="ro' + ROWS[R2].ods + '"' : "";
        o2.push("        <table:table-row" + H2 + "></table:table-row>\n");
      }
      for (; R2 <= range.e.r; ++R2) {
        H2 = ROWS[R2] ? ' table:style-name="ro' + ROWS[R2].ods + '"' : "";
        o2.push("        <table:table-row" + H2 + ">\n");
        for (C2 = 0; C2 < range.s.c; ++C2)
          o2.push(null_cell_xml);
        for (; C2 <= range.e.c; ++C2) {
          var skip = false, ct2 = {}, textp = "";
          for (mi = 0; mi != marr.length; ++mi) {
            if (marr[mi].s.c > C2)
              continue;
            if (marr[mi].s.r > R2)
              continue;
            if (marr[mi].e.c < C2)
              continue;
            if (marr[mi].e.r < R2)
              continue;
            if (marr[mi].s.c != C2 || marr[mi].s.r != R2)
              skip = true;
            ct2["table:number-columns-spanned"] = marr[mi].e.c - marr[mi].s.c + 1;
            ct2["table:number-rows-spanned"] = marr[mi].e.r - marr[mi].s.r + 1;
            break;
          }
          if (skip) {
            o2.push(covered_cell_xml);
            continue;
          }
          var ref2 = encode_cell({ r: R2, c: C2 }), cell = dense ? (ws[R2] || [])[C2] : ws[ref2];
          if (cell && cell.f) {
            ct2["table:formula"] = escapexml(csf_to_ods_formula(cell.f));
            if (cell.F) {
              if (cell.F.slice(0, ref2.length) == ref2) {
                var _Fref = decode_range(cell.F);
                ct2["table:number-matrix-columns-spanned"] = _Fref.e.c - _Fref.s.c + 1;
                ct2["table:number-matrix-rows-spanned"] = _Fref.e.r - _Fref.s.r + 1;
              }
            }
          }
          if (!cell) {
            o2.push(null_cell_xml);
            continue;
          }
          switch (cell.t) {
            case "b":
              textp = cell.v ? "TRUE" : "FALSE";
              ct2["office:value-type"] = "boolean";
              ct2["office:boolean-value"] = cell.v ? "true" : "false";
              break;
            case "n":
              textp = cell.w || String(cell.v || 0);
              ct2["office:value-type"] = "float";
              ct2["office:value"] = cell.v || 0;
              break;
            case "s":
            case "str":
              textp = cell.v == null ? "" : cell.v;
              ct2["office:value-type"] = "string";
              break;
            case "d":
              textp = cell.w || parseDate(cell.v).toISOString();
              ct2["office:value-type"] = "date";
              ct2["office:date-value"] = parseDate(cell.v).toISOString();
              ct2["table:style-name"] = "ce1";
              break;
            default:
              o2.push(null_cell_xml);
              continue;
          }
          var text_p = write_text_p(textp);
          if (cell.l && cell.l.Target) {
            var _tgt = cell.l.Target;
            _tgt = _tgt.charAt(0) == "#" ? "#" + csf_to_ods_3D(_tgt.slice(1)) : _tgt;
            if (_tgt.charAt(0) != "#" && !_tgt.match(/^\w+:/))
              _tgt = "../" + _tgt;
            text_p = writextag("text:a", text_p, { "xlink:href": _tgt.replace(/&/g, "&amp;") });
          }
          o2.push("          " + writextag("table:table-cell", writextag("text:p", text_p, {}), ct2) + "\n");
        }
        o2.push("        </table:table-row>\n");
      }
      o2.push("      </table:table>\n");
      return o2.join("");
    };
    var write_automatic_styles_ods = function(o2, wb) {
      o2.push(" <office:automatic-styles>\n");
      o2.push('  <number:date-style style:name="N37" number:automatic-order="true">\n');
      o2.push('   <number:month number:style="long"/>\n');
      o2.push("   <number:text>/</number:text>\n");
      o2.push('   <number:day number:style="long"/>\n');
      o2.push("   <number:text>/</number:text>\n");
      o2.push("   <number:year/>\n");
      o2.push("  </number:date-style>\n");
      var cidx = 0;
      wb.SheetNames.map(function(n) {
        return wb.Sheets[n];
      }).forEach(function(ws) {
        if (!ws)
          return;
        if (ws["!cols"]) {
          for (var C2 = 0; C2 < ws["!cols"].length; ++C2)
            if (ws["!cols"][C2]) {
              var colobj = ws["!cols"][C2];
              if (colobj.width == null && colobj.wpx == null && colobj.wch == null)
                continue;
              process_col(colobj);
              colobj.ods = cidx;
              var w2 = ws["!cols"][C2].wpx + "px";
              o2.push('  <style:style style:name="co' + cidx + '" style:family="table-column">\n');
              o2.push('   <style:table-column-properties fo:break-before="auto" style:column-width="' + w2 + '"/>\n');
              o2.push("  </style:style>\n");
              ++cidx;
            }
        }
      });
      var ridx = 0;
      wb.SheetNames.map(function(n) {
        return wb.Sheets[n];
      }).forEach(function(ws) {
        if (!ws)
          return;
        if (ws["!rows"]) {
          for (var R2 = 0; R2 < ws["!rows"].length; ++R2)
            if (ws["!rows"][R2]) {
              ws["!rows"][R2].ods = ridx;
              var h2 = ws["!rows"][R2].hpx + "px";
              o2.push('  <style:style style:name="ro' + ridx + '" style:family="table-row">\n');
              o2.push('   <style:table-row-properties fo:break-before="auto" style:row-height="' + h2 + '"/>\n');
              o2.push("  </style:style>\n");
              ++ridx;
            }
        }
      });
      o2.push('  <style:style style:name="ta1" style:family="table" style:master-page-name="mp1">\n');
      o2.push('   <style:table-properties table:display="true" style:writing-mode="lr-tb"/>\n');
      o2.push("  </style:style>\n");
      o2.push('  <style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>\n');
      o2.push(" </office:automatic-styles>\n");
    };
    return function wcx(wb, opts) {
      var o2 = [XML_HEADER];
      var attr = wxt_helper({
        "xmlns:office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
        "xmlns:table": "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
        "xmlns:style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
        "xmlns:text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
        "xmlns:draw": "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",
        "xmlns:fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
        "xmlns:xlink": "http://www.w3.org/1999/xlink",
        "xmlns:dc": "http://purl.org/dc/elements/1.1/",
        "xmlns:meta": "urn:oasis:names:tc:opendocument:xmlns:meta:1.0",
        "xmlns:number": "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",
        "xmlns:presentation": "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",
        "xmlns:svg": "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",
        "xmlns:chart": "urn:oasis:names:tc:opendocument:xmlns:chart:1.0",
        "xmlns:dr3d": "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",
        "xmlns:math": "http://www.w3.org/1998/Math/MathML",
        "xmlns:form": "urn:oasis:names:tc:opendocument:xmlns:form:1.0",
        "xmlns:script": "urn:oasis:names:tc:opendocument:xmlns:script:1.0",
        "xmlns:ooo": "http://openoffice.org/2004/office",
        "xmlns:ooow": "http://openoffice.org/2004/writer",
        "xmlns:oooc": "http://openoffice.org/2004/calc",
        "xmlns:dom": "http://www.w3.org/2001/xml-events",
        "xmlns:xforms": "http://www.w3.org/2002/xforms",
        "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
        "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
        "xmlns:sheet": "urn:oasis:names:tc:opendocument:sh33tjs:1.0",
        "xmlns:rpt": "http://openoffice.org/2005/report",
        "xmlns:of": "urn:oasis:names:tc:opendocument:xmlns:of:1.2",
        "xmlns:xhtml": "http://www.w3.org/1999/xhtml",
        "xmlns:grddl": "http://www.w3.org/2003/g/data-view#",
        "xmlns:tableooo": "http://openoffice.org/2009/table",
        "xmlns:drawooo": "http://openoffice.org/2010/draw",
        "xmlns:calcext": "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0",
        "xmlns:loext": "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0",
        "xmlns:field": "urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0",
        "xmlns:formx": "urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0",
        "xmlns:css3t": "http://www.w3.org/TR/css3-text/",
        "office:version": "1.2"
      });
      var fods = wxt_helper({
        "xmlns:config": "urn:oasis:names:tc:opendocument:xmlns:config:1.0",
        "office:mimetype": "application/vnd.oasis.opendocument.spreadsheet"
      });
      if (opts.bookType == "fods") {
        o2.push("<office:document" + attr + fods + ">\n");
        o2.push(write_meta_ods().replace(/office:document-meta/g, "office:meta"));
      } else
        o2.push("<office:document-content" + attr + ">\n");
      write_automatic_styles_ods(o2, wb);
      o2.push("  <office:body>\n");
      o2.push("    <office:spreadsheet>\n");
      for (var i = 0; i != wb.SheetNames.length; ++i)
        o2.push(write_ws2(wb.Sheets[wb.SheetNames[i]], wb, i));
      o2.push("    </office:spreadsheet>\n");
      o2.push("  </office:body>\n");
      if (opts.bookType == "fods")
        o2.push("</office:document>");
      else
        o2.push("</office:document-content>");
      return o2.join("");
    };
  }();
  function write_ods(wb, opts) {
    if (opts.bookType == "fods")
      return write_content_ods(wb, opts);
    var zip = zip_new();
    var f2 = "";
    var manifest = [];
    var rdf = [];
    f2 = "mimetype";
    zip_add_file(zip, f2, "application/vnd.oasis.opendocument.spreadsheet");
    f2 = "content.xml";
    zip_add_file(zip, f2, write_content_ods(wb, opts));
    manifest.push([f2, "text/xml"]);
    rdf.push([f2, "ContentFile"]);
    f2 = "styles.xml";
    zip_add_file(zip, f2, write_styles_ods(wb, opts));
    manifest.push([f2, "text/xml"]);
    rdf.push([f2, "StylesFile"]);
    f2 = "meta.xml";
    zip_add_file(zip, f2, XML_HEADER + write_meta_ods());
    manifest.push([f2, "text/xml"]);
    rdf.push([f2, "MetadataFile"]);
    f2 = "manifest.rdf";
    zip_add_file(zip, f2, write_rdf(rdf));
    manifest.push([f2, "application/rdf+xml"]);
    f2 = "META-INF/manifest.xml";
    zip_add_file(zip, f2, write_manifest(manifest));
    return zip;
  }
  /*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */
  function u8_to_dataview(array) {
    return new DataView(array.buffer, array.byteOffset, array.byteLength);
  }
  function u8str(u8) {
    return typeof TextDecoder != "undefined" ? new TextDecoder().decode(u8) : utf8read(a2s(u8));
  }
  function stru8(str) {
    return typeof TextEncoder != "undefined" ? new TextEncoder().encode(str) : s2a(utf8write(str));
  }
  function u8contains(body, search) {
    outer:
      for (var L = 0; L <= body.length - search.length; ++L) {
        for (var j = 0; j < search.length; ++j)
          if (body[L + j] != search[j])
            continue outer;
        return true;
      }
    return false;
  }
  function u8concat(u8a) {
    var len = u8a.reduce(function(acc, x2) {
      return acc + x2.length;
    }, 0);
    var out = new Uint8Array(len);
    var off = 0;
    u8a.forEach(function(u8) {
      out.set(u8, off);
      off += u8.length;
    });
    return out;
  }
  function popcnt(x2) {
    x2 -= x2 >> 1 & 1431655765;
    x2 = (x2 & 858993459) + (x2 >> 2 & 858993459);
    return (x2 + (x2 >> 4) & 252645135) * 16843009 >>> 24;
  }
  function readDecimal128LE(buf, offset) {
    var exp = (buf[offset + 15] & 127) << 7 | buf[offset + 14] >> 1;
    var mantissa = buf[offset + 14] & 1;
    for (var j = offset + 13; j >= offset; --j)
      mantissa = mantissa * 256 + buf[j];
    return (buf[offset + 15] & 128 ? -mantissa : mantissa) * Math.pow(10, exp - 6176);
  }
  function writeDecimal128LE(buf, offset, value) {
    var exp = Math.floor(value == 0 ? 0 : Math.LOG10E * Math.log(Math.abs(value))) + 6176 - 20;
    var mantissa = value / Math.pow(10, exp - 6176);
    buf[offset + 15] |= exp >> 7;
    buf[offset + 14] |= (exp & 127) << 1;
    for (var i = 0; mantissa >= 1; ++i, mantissa /= 256)
      buf[offset + i] = mantissa & 255;
    buf[offset + 15] |= value >= 0 ? 0 : 128;
  }
  function parse_varint49(buf, ptr) {
    var l2 = ptr ? ptr[0] : 0;
    var usz = buf[l2] & 127;
    varint:
      if (buf[l2++] >= 128) {
        usz |= (buf[l2] & 127) << 7;
        if (buf[l2++] < 128)
          break varint;
        usz |= (buf[l2] & 127) << 14;
        if (buf[l2++] < 128)
          break varint;
        usz |= (buf[l2] & 127) << 21;
        if (buf[l2++] < 128)
          break varint;
        usz += (buf[l2] & 127) * Math.pow(2, 28);
        ++l2;
        if (buf[l2++] < 128)
          break varint;
        usz += (buf[l2] & 127) * Math.pow(2, 35);
        ++l2;
        if (buf[l2++] < 128)
          break varint;
        usz += (buf[l2] & 127) * Math.pow(2, 42);
        ++l2;
        if (buf[l2++] < 128)
          break varint;
      }
    if (ptr)
      ptr[0] = l2;
    return usz;
  }
  function write_varint49(v2) {
    var usz = new Uint8Array(7);
    usz[0] = v2 & 127;
    var L = 1;
    sz:
      if (v2 > 127) {
        usz[L - 1] |= 128;
        usz[L] = v2 >> 7 & 127;
        ++L;
        if (v2 <= 16383)
          break sz;
        usz[L - 1] |= 128;
        usz[L] = v2 >> 14 & 127;
        ++L;
        if (v2 <= 2097151)
          break sz;
        usz[L - 1] |= 128;
        usz[L] = v2 >> 21 & 127;
        ++L;
        if (v2 <= 268435455)
          break sz;
        usz[L - 1] |= 128;
        usz[L] = v2 / 256 >>> 21 & 127;
        ++L;
        if (v2 <= 34359738367)
          break sz;
        usz[L - 1] |= 128;
        usz[L] = v2 / 65536 >>> 21 & 127;
        ++L;
        if (v2 <= 4398046511103)
          break sz;
        usz[L - 1] |= 128;
        usz[L] = v2 / 16777216 >>> 21 & 127;
        ++L;
      }
    return usz.slice(0, L);
  }
  function varint_to_i32(buf) {
    var l2 = 0, i32 = buf[l2] & 127;
    varint:
      if (buf[l2++] >= 128) {
        i32 |= (buf[l2] & 127) << 7;
        if (buf[l2++] < 128)
          break varint;
        i32 |= (buf[l2] & 127) << 14;
        if (buf[l2++] < 128)
          break varint;
        i32 |= (buf[l2] & 127) << 21;
        if (buf[l2++] < 128)
          break varint;
        i32 |= (buf[l2] & 127) << 28;
      }
    return i32;
  }
  function parse_shallow(buf) {
    var out = [], ptr = [0];
    while (ptr[0] < buf.length) {
      var off = ptr[0];
      var num = parse_varint49(buf, ptr);
      var type = num & 7;
      num = Math.floor(num / 8);
      var len = 0;
      var res;
      if (num == 0)
        break;
      switch (type) {
        case 0:
          {
            var l2 = ptr[0];
            while (buf[ptr[0]++] >= 128)
              ;
            res = buf.slice(l2, ptr[0]);
          }
          break;
        case 5:
          len = 4;
          res = buf.slice(ptr[0], ptr[0] + len);
          ptr[0] += len;
          break;
        case 1:
          len = 8;
          res = buf.slice(ptr[0], ptr[0] + len);
          ptr[0] += len;
          break;
        case 2:
          len = parse_varint49(buf, ptr);
          res = buf.slice(ptr[0], ptr[0] + len);
          ptr[0] += len;
          break;
        case 3:
        case 4:
        default:
          throw new Error("PB Type ".concat(type, " for Field ").concat(num, " at offset ").concat(off));
      }
      var v2 = { data: res, type };
      if (out[num] == null)
        out[num] = [v2];
      else
        out[num].push(v2);
    }
    return out;
  }
  function write_shallow(proto) {
    var out = [];
    proto.forEach(function(field, idx) {
      field.forEach(function(item) {
        if (!item.data)
          return;
        out.push(write_varint49(idx * 8 + item.type));
        if (item.type == 2)
          out.push(write_varint49(item.data.length));
        out.push(item.data);
      });
    });
    return u8concat(out);
  }
  function mappa(data, cb) {
    return (data == null ? void 0 : data.map(function(d2) {
      return cb(d2.data);
    })) || [];
  }
  function parse_iwa_file(buf) {
    var _a2;
    var out = [], ptr = [0];
    while (ptr[0] < buf.length) {
      var len = parse_varint49(buf, ptr);
      var ai = parse_shallow(buf.slice(ptr[0], ptr[0] + len));
      ptr[0] += len;
      var res = {
        id: varint_to_i32(ai[1][0].data),
        messages: []
      };
      ai[2].forEach(function(b2) {
        var mi = parse_shallow(b2.data);
        var fl = varint_to_i32(mi[3][0].data);
        res.messages.push({
          meta: mi,
          data: buf.slice(ptr[0], ptr[0] + fl)
        });
        ptr[0] += fl;
      });
      if ((_a2 = ai[3]) == null ? void 0 : _a2[0])
        res.merge = varint_to_i32(ai[3][0].data) >>> 0 > 0;
      out.push(res);
    }
    return out;
  }
  function write_iwa_file(ias) {
    var bufs = [];
    ias.forEach(function(ia) {
      var ai = [];
      ai[1] = [{ data: write_varint49(ia.id), type: 0 }];
      ai[2] = [];
      if (ia.merge != null)
        ai[3] = [{ data: write_varint49(+!!ia.merge), type: 0 }];
      var midata = [];
      ia.messages.forEach(function(mi) {
        midata.push(mi.data);
        mi.meta[3] = [{ type: 0, data: write_varint49(mi.data.length) }];
        ai[2].push({ data: write_shallow(mi.meta), type: 2 });
      });
      var aipayload = write_shallow(ai);
      bufs.push(write_varint49(aipayload.length));
      bufs.push(aipayload);
      midata.forEach(function(mid) {
        return bufs.push(mid);
      });
    });
    return u8concat(bufs);
  }
  function parse_snappy_chunk(type, buf) {
    if (type != 0)
      throw new Error("Unexpected Snappy chunk type ".concat(type));
    var ptr = [0];
    var usz = parse_varint49(buf, ptr);
    var chunks = [];
    while (ptr[0] < buf.length) {
      var tag = buf[ptr[0]] & 3;
      if (tag == 0) {
        var len = buf[ptr[0]++] >> 2;
        if (len < 60)
          ++len;
        else {
          var c2 = len - 59;
          len = buf[ptr[0]];
          if (c2 > 1)
            len |= buf[ptr[0] + 1] << 8;
          if (c2 > 2)
            len |= buf[ptr[0] + 2] << 16;
          if (c2 > 3)
            len |= buf[ptr[0] + 3] << 24;
          len >>>= 0;
          len++;
          ptr[0] += c2;
        }
        chunks.push(buf.slice(ptr[0], ptr[0] + len));
        ptr[0] += len;
        continue;
      } else {
        var offset = 0, length = 0;
        if (tag == 1) {
          length = (buf[ptr[0]] >> 2 & 7) + 4;
          offset = (buf[ptr[0]++] & 224) << 3;
          offset |= buf[ptr[0]++];
        } else {
          length = (buf[ptr[0]++] >> 2) + 1;
          if (tag == 2) {
            offset = buf[ptr[0]] | buf[ptr[0] + 1] << 8;
            ptr[0] += 2;
          } else {
            offset = (buf[ptr[0]] | buf[ptr[0] + 1] << 8 | buf[ptr[0] + 2] << 16 | buf[ptr[0] + 3] << 24) >>> 0;
            ptr[0] += 4;
          }
        }
        chunks = [u8concat(chunks)];
        if (offset == 0)
          throw new Error("Invalid offset 0");
        if (offset > chunks[0].length)
          throw new Error("Invalid offset beyond length");
        if (length >= offset) {
          chunks.push(chunks[0].slice(-offset));
          length -= offset;
          while (length >= chunks[chunks.length - 1].length) {
            chunks.push(chunks[chunks.length - 1]);
            length -= chunks[chunks.length - 1].length;
          }
        }
        chunks.push(chunks[0].slice(-offset, -offset + length));
      }
    }
    var o2 = u8concat(chunks);
    if (o2.length != usz)
      throw new Error("Unexpected length: ".concat(o2.length, " != ").concat(usz));
    return o2;
  }
  function decompress_iwa_file(buf) {
    var out = [];
    var l2 = 0;
    while (l2 < buf.length) {
      var t = buf[l2++];
      var len = buf[l2] | buf[l2 + 1] << 8 | buf[l2 + 2] << 16;
      l2 += 3;
      out.push(parse_snappy_chunk(t, buf.slice(l2, l2 + len)));
      l2 += len;
    }
    if (l2 !== buf.length)
      throw new Error("data is not a valid framed stream!");
    return u8concat(out);
  }
  function compress_iwa_file(buf) {
    var out = [];
    var l2 = 0;
    while (l2 < buf.length) {
      var c2 = Math.min(buf.length - l2, 268435455);
      var frame = new Uint8Array(4);
      out.push(frame);
      var usz = write_varint49(c2);
      var L = usz.length;
      out.push(usz);
      if (c2 <= 60) {
        L++;
        out.push(new Uint8Array([c2 - 1 << 2]));
      } else if (c2 <= 256) {
        L += 2;
        out.push(new Uint8Array([240, c2 - 1 & 255]));
      } else if (c2 <= 65536) {
        L += 3;
        out.push(new Uint8Array([244, c2 - 1 & 255, c2 - 1 >> 8 & 255]));
      } else if (c2 <= 16777216) {
        L += 4;
        out.push(new Uint8Array([248, c2 - 1 & 255, c2 - 1 >> 8 & 255, c2 - 1 >> 16 & 255]));
      } else if (c2 <= 4294967296) {
        L += 5;
        out.push(new Uint8Array([252, c2 - 1 & 255, c2 - 1 >> 8 & 255, c2 - 1 >> 16 & 255, c2 - 1 >>> 24 & 255]));
      }
      out.push(buf.slice(l2, l2 + c2));
      L += c2;
      frame[0] = 0;
      frame[1] = L & 255;
      frame[2] = L >> 8 & 255;
      frame[3] = L >> 16 & 255;
      l2 += c2;
    }
    return u8concat(out);
  }
  function parse_old_storage(buf, sst, rsst, v2) {
    var dv = u8_to_dataview(buf);
    var flags = dv.getUint32(4, true);
    var data_offset = (v2 > 1 ? 12 : 8) + popcnt(flags & (v2 > 1 ? 3470 : 398)) * 4;
    var ridx = -1, sidx = -1, ieee = NaN, dt2 = new Date(2001, 0, 1);
    if (flags & 512) {
      ridx = dv.getUint32(data_offset, true);
      data_offset += 4;
    }
    data_offset += popcnt(flags & (v2 > 1 ? 12288 : 4096)) * 4;
    if (flags & 16) {
      sidx = dv.getUint32(data_offset, true);
      data_offset += 4;
    }
    if (flags & 32) {
      ieee = dv.getFloat64(data_offset, true);
      data_offset += 8;
    }
    if (flags & 64) {
      dt2.setTime(dt2.getTime() + dv.getFloat64(data_offset, true) * 1e3);
      data_offset += 8;
    }
    var ret;
    switch (buf[2]) {
      case 0:
        break;
      case 2:
        ret = { t: "n", v: ieee };
        break;
      case 3:
        ret = { t: "s", v: sst[sidx] };
        break;
      case 5:
        ret = { t: "d", v: dt2 };
        break;
      case 6:
        ret = { t: "b", v: ieee > 0 };
        break;
      case 7:
        ret = { t: "n", v: ieee / 86400 };
        break;
      case 8:
        ret = { t: "e", v: 0 };
        break;
      case 9:
        {
          if (ridx > -1)
            ret = { t: "s", v: rsst[ridx] };
          else if (sidx > -1)
            ret = { t: "s", v: sst[sidx] };
          else if (!isNaN(ieee))
            ret = { t: "n", v: ieee };
          else
            throw new Error("Unsupported cell type ".concat(buf.slice(0, 4)));
        }
        break;
      default:
        throw new Error("Unsupported cell type ".concat(buf.slice(0, 4)));
    }
    return ret;
  }
  function parse_new_storage(buf, sst, rsst) {
    var dv = u8_to_dataview(buf);
    var flags = dv.getUint32(8, true);
    var data_offset = 12;
    var ridx = -1, sidx = -1, d128 = NaN, ieee = NaN, dt2 = new Date(2001, 0, 1);
    if (flags & 1) {
      d128 = readDecimal128LE(buf, data_offset);
      data_offset += 16;
    }
    if (flags & 2) {
      ieee = dv.getFloat64(data_offset, true);
      data_offset += 8;
    }
    if (flags & 4) {
      dt2.setTime(dt2.getTime() + dv.getFloat64(data_offset, true) * 1e3);
      data_offset += 8;
    }
    if (flags & 8) {
      sidx = dv.getUint32(data_offset, true);
      data_offset += 4;
    }
    if (flags & 16) {
      ridx = dv.getUint32(data_offset, true);
      data_offset += 4;
    }
    var ret;
    switch (buf[1]) {
      case 0:
        break;
      case 2:
        ret = { t: "n", v: d128 };
        break;
      case 3:
        ret = { t: "s", v: sst[sidx] };
        break;
      case 5:
        ret = { t: "d", v: dt2 };
        break;
      case 6:
        ret = { t: "b", v: ieee > 0 };
        break;
      case 7:
        ret = { t: "n", v: ieee / 86400 };
        break;
      case 8:
        ret = { t: "e", v: 0 };
        break;
      case 9:
        {
          if (ridx > -1)
            ret = { t: "s", v: rsst[ridx] };
          else
            throw new Error("Unsupported cell type ".concat(buf[1], " : ").concat(flags & 31, " : ").concat(buf.slice(0, 4)));
        }
        break;
      case 10:
        ret = { t: "n", v: d128 };
        break;
      default:
        throw new Error("Unsupported cell type ".concat(buf[1], " : ").concat(flags & 31, " : ").concat(buf.slice(0, 4)));
    }
    return ret;
  }
  function write_new_storage(cell, sst) {
    var out = new Uint8Array(32), dv = u8_to_dataview(out), l2 = 12, flags = 0;
    out[0] = 5;
    switch (cell.t) {
      case "n":
        out[1] = 2;
        writeDecimal128LE(out, l2, cell.v);
        flags |= 1;
        l2 += 16;
        break;
      case "b":
        out[1] = 6;
        dv.setFloat64(l2, cell.v ? 1 : 0, true);
        flags |= 2;
        l2 += 8;
        break;
      case "s":
        if (sst.indexOf(cell.v) == -1)
          throw new Error("Value ".concat(cell.v, " missing from SST!"));
        out[1] = 3;
        dv.setUint32(l2, sst.indexOf(cell.v), true);
        flags |= 8;
        l2 += 4;
        break;
      default:
        throw "unsupported cell type " + cell.t;
    }
    dv.setUint32(8, flags, true);
    return out.slice(0, l2);
  }
  function write_old_storage(cell, sst) {
    var out = new Uint8Array(32), dv = u8_to_dataview(out), l2 = 12, flags = 0;
    out[0] = 3;
    switch (cell.t) {
      case "n":
        out[2] = 2;
        dv.setFloat64(l2, cell.v, true);
        flags |= 32;
        l2 += 8;
        break;
      case "b":
        out[2] = 6;
        dv.setFloat64(l2, cell.v ? 1 : 0, true);
        flags |= 32;
        l2 += 8;
        break;
      case "s":
        if (sst.indexOf(cell.v) == -1)
          throw new Error("Value ".concat(cell.v, " missing from SST!"));
        out[2] = 3;
        dv.setUint32(l2, sst.indexOf(cell.v), true);
        flags |= 16;
        l2 += 4;
        break;
      default:
        throw "unsupported cell type " + cell.t;
    }
    dv.setUint32(4, flags, true);
    return out.slice(0, l2);
  }
  function parse_cell_storage(buf, sst, rsst) {
    switch (buf[0]) {
      case 0:
      case 1:
      case 2:
      case 3:
        return parse_old_storage(buf, sst, rsst, buf[0]);
      case 5:
        return parse_new_storage(buf, sst, rsst);
      default:
        throw new Error("Unsupported payload version ".concat(buf[0]));
    }
  }
  function parse_TSP_Reference(buf) {
    var pb = parse_shallow(buf);
    return parse_varint49(pb[1][0].data);
  }
  function parse_TST_TableDataList(M2, root2) {
    var pb = parse_shallow(root2.data);
    var type = varint_to_i32(pb[1][0].data);
    var entries = pb[3];
    var data = [];
    (entries || []).forEach(function(entry) {
      var le = parse_shallow(entry.data);
      var key = varint_to_i32(le[1][0].data) >>> 0;
      switch (type) {
        case 1:
          data[key] = u8str(le[3][0].data);
          break;
        case 8:
          {
            var rt2 = M2[parse_TSP_Reference(le[9][0].data)][0];
            var rtp = parse_shallow(rt2.data);
            var rtpref = M2[parse_TSP_Reference(rtp[1][0].data)][0];
            var mtype = varint_to_i32(rtpref.meta[1][0].data);
            if (mtype != 2001)
              throw new Error("2000 unexpected reference to ".concat(mtype));
            var tswpsa = parse_shallow(rtpref.data);
            data[key] = tswpsa[3].map(function(x2) {
              return u8str(x2.data);
            }).join("");
          }
          break;
      }
    });
    return data;
  }
  function parse_TST_TileRowInfo(u8, type) {
    var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
    var pb = parse_shallow(u8);
    var R2 = varint_to_i32(pb[1][0].data) >>> 0;
    var cnt = varint_to_i32(pb[2][0].data) >>> 0;
    var wide_offsets = ((_b = (_a2 = pb[8]) == null ? void 0 : _a2[0]) == null ? void 0 : _b.data) && varint_to_i32(pb[8][0].data) > 0 || false;
    var used_storage_u8, used_storage;
    if (((_d = (_c = pb[7]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && type != 0) {
      used_storage_u8 = (_f = (_e = pb[7]) == null ? void 0 : _e[0]) == null ? void 0 : _f.data;
      used_storage = (_h = (_g = pb[6]) == null ? void 0 : _g[0]) == null ? void 0 : _h.data;
    } else if (((_j = (_i = pb[4]) == null ? void 0 : _i[0]) == null ? void 0 : _j.data) && type != 1) {
      used_storage_u8 = (_l = (_k = pb[4]) == null ? void 0 : _k[0]) == null ? void 0 : _l.data;
      used_storage = (_n = (_m = pb[3]) == null ? void 0 : _m[0]) == null ? void 0 : _n.data;
    } else
      throw "NUMBERS Tile missing ".concat(type, " cell storage");
    var width = wide_offsets ? 4 : 1;
    var used_storage_offsets = u8_to_dataview(used_storage_u8);
    var offsets = [];
    for (var C2 = 0; C2 < used_storage_u8.length / 2; ++C2) {
      var off = used_storage_offsets.getUint16(C2 * 2, true);
      if (off < 65535)
        offsets.push([C2, off]);
    }
    if (offsets.length != cnt)
      throw "Expected ".concat(cnt, " cells, found ").concat(offsets.length);
    var cells = [];
    for (C2 = 0; C2 < offsets.length - 1; ++C2)
      cells[offsets[C2][0]] = used_storage.subarray(offsets[C2][1] * width, offsets[C2 + 1][1] * width);
    if (offsets.length >= 1)
      cells[offsets[offsets.length - 1][0]] = used_storage.subarray(offsets[offsets.length - 1][1] * width);
    return { R: R2, cells };
  }
  function parse_TST_Tile(M2, root2) {
    var _a2;
    var pb = parse_shallow(root2.data);
    var storage = ((_a2 = pb == null ? void 0 : pb[7]) == null ? void 0 : _a2[0]) ? varint_to_i32(pb[7][0].data) >>> 0 > 0 ? 1 : 0 : -1;
    var ri = mappa(pb[5], function(u8) {
      return parse_TST_TileRowInfo(u8, storage);
    });
    return {
      nrows: varint_to_i32(pb[4][0].data) >>> 0,
      data: ri.reduce(function(acc, x2) {
        if (!acc[x2.R])
          acc[x2.R] = [];
        x2.cells.forEach(function(cell, C2) {
          if (acc[x2.R][C2])
            throw new Error("Duplicate cell r=".concat(x2.R, " c=").concat(C2));
          acc[x2.R][C2] = cell;
        });
        return acc;
      }, [])
    };
  }
  function parse_TST_TableModelArchive(M2, root2, ws) {
    var _a2;
    var pb = parse_shallow(root2.data);
    var range = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
    range.e.r = (varint_to_i32(pb[6][0].data) >>> 0) - 1;
    if (range.e.r < 0)
      throw new Error("Invalid row varint ".concat(pb[6][0].data));
    range.e.c = (varint_to_i32(pb[7][0].data) >>> 0) - 1;
    if (range.e.c < 0)
      throw new Error("Invalid col varint ".concat(pb[7][0].data));
    ws["!ref"] = encode_range(range);
    var store = parse_shallow(pb[4][0].data);
    var sst = parse_TST_TableDataList(M2, M2[parse_TSP_Reference(store[4][0].data)][0]);
    var rsst = ((_a2 = store[17]) == null ? void 0 : _a2[0]) ? parse_TST_TableDataList(M2, M2[parse_TSP_Reference(store[17][0].data)][0]) : [];
    var tile = parse_shallow(store[3][0].data);
    var _R = 0;
    tile[1].forEach(function(t) {
      var tl = parse_shallow(t.data);
      var ref2 = M2[parse_TSP_Reference(tl[2][0].data)][0];
      var mtype = varint_to_i32(ref2.meta[1][0].data);
      if (mtype != 6002)
        throw new Error("6001 unexpected reference to ".concat(mtype));
      var _tile = parse_TST_Tile(M2, ref2);
      _tile.data.forEach(function(row, R2) {
        row.forEach(function(buf, C2) {
          var addr = encode_cell({ r: _R + R2, c: C2 });
          var res = parse_cell_storage(buf, sst, rsst);
          if (res)
            ws[addr] = res;
        });
      });
      _R += _tile.nrows;
    });
  }
  function parse_TST_TableInfoArchive(M2, root2) {
    var pb = parse_shallow(root2.data);
    var out = { "!ref": "A1" };
    var tableref = M2[parse_TSP_Reference(pb[2][0].data)];
    var mtype = varint_to_i32(tableref[0].meta[1][0].data);
    if (mtype != 6001)
      throw new Error("6000 unexpected reference to ".concat(mtype));
    parse_TST_TableModelArchive(M2, tableref[0], out);
    return out;
  }
  function parse_TN_SheetArchive(M2, root2) {
    var _a2;
    var pb = parse_shallow(root2.data);
    var out = {
      name: ((_a2 = pb[1]) == null ? void 0 : _a2[0]) ? u8str(pb[1][0].data) : "",
      sheets: []
    };
    var shapeoffs = mappa(pb[2], parse_TSP_Reference);
    shapeoffs.forEach(function(off) {
      M2[off].forEach(function(m2) {
        var mtype = varint_to_i32(m2.meta[1][0].data);
        if (mtype == 6e3)
          out.sheets.push(parse_TST_TableInfoArchive(M2, m2));
      });
    });
    return out;
  }
  function parse_TN_DocumentArchive(M2, root2) {
    var out = book_new();
    var pb = parse_shallow(root2.data);
    var sheetoffs = mappa(pb[1], parse_TSP_Reference);
    sheetoffs.forEach(function(off) {
      M2[off].forEach(function(m2) {
        var mtype = varint_to_i32(m2.meta[1][0].data);
        if (mtype == 2) {
          var root22 = parse_TN_SheetArchive(M2, m2);
          root22.sheets.forEach(function(sheet, idx) {
            book_append_sheet(out, sheet, idx == 0 ? root22.name : root22.name + "_" + idx, true);
          });
        }
      });
    });
    if (out.SheetNames.length == 0)
      throw new Error("Empty NUMBERS file");
    return out;
  }
  function parse_numbers_iwa(cfb) {
    var _a2, _b, _c, _d;
    var M2 = {}, indices = [];
    cfb.FullPaths.forEach(function(p2) {
      if (p2.match(/\.iwpv2/))
        throw new Error("Unsupported password protection");
    });
    cfb.FileIndex.forEach(function(s2) {
      if (!s2.name.match(/\.iwa$/))
        return;
      var o2;
      try {
        o2 = decompress_iwa_file(s2.content);
      } catch (e) {
        return console.log("?? " + s2.content.length + " " + (e.message || e));
      }
      var packets;
      try {
        packets = parse_iwa_file(o2);
      } catch (e) {
        return console.log("## " + (e.message || e));
      }
      packets.forEach(function(packet) {
        M2[packet.id] = packet.messages;
        indices.push(packet.id);
      });
    });
    if (!indices.length)
      throw new Error("File has no messages");
    var docroot = ((_d = (_c = (_b = (_a2 = M2 == null ? void 0 : M2[1]) == null ? void 0 : _a2[0]) == null ? void 0 : _b.meta) == null ? void 0 : _c[1]) == null ? void 0 : _d[0].data) && varint_to_i32(M2[1][0].meta[1][0].data) == 1 && M2[1][0];
    if (!docroot)
      indices.forEach(function(idx) {
        M2[idx].forEach(function(iwam) {
          var mtype = varint_to_i32(iwam.meta[1][0].data) >>> 0;
          if (mtype == 1) {
            if (!docroot)
              docroot = iwam;
            else
              throw new Error("Document has multiple roots");
          }
        });
      });
    if (!docroot)
      throw new Error("Cannot find Document root");
    return parse_TN_DocumentArchive(M2, docroot);
  }
  function write_tile_row(tri, data, SST) {
    var _a2, _b, _c, _d;
    if (!((_a2 = tri[6]) == null ? void 0 : _a2[0]) || !((_b = tri[7]) == null ? void 0 : _b[0]))
      throw "Mutation only works on post-BNC storages!";
    var wide_offsets = ((_d = (_c = tri[8]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && varint_to_i32(tri[8][0].data) > 0 || false;
    if (wide_offsets)
      throw "Math only works with normal offsets";
    var cnt = 0;
    var dv = u8_to_dataview(tri[7][0].data), last_offset = 0, cell_storage = [];
    var _dv = u8_to_dataview(tri[4][0].data), _last_offset = 0, _cell_storage = [];
    for (var C2 = 0; C2 < data.length; ++C2) {
      if (data[C2] == null) {
        dv.setUint16(C2 * 2, 65535, true);
        _dv.setUint16(C2 * 2, 65535);
        continue;
      }
      dv.setUint16(C2 * 2, last_offset, true);
      _dv.setUint16(C2 * 2, _last_offset, true);
      var celload, _celload;
      switch (typeof data[C2]) {
        case "string":
          celload = write_new_storage({ t: "s", v: data[C2] }, SST);
          _celload = write_old_storage({ t: "s", v: data[C2] }, SST);
          break;
        case "number":
          celload = write_new_storage({ t: "n", v: data[C2] }, SST);
          _celload = write_old_storage({ t: "n", v: data[C2] }, SST);
          break;
        case "boolean":
          celload = write_new_storage({ t: "b", v: data[C2] }, SST);
          _celload = write_old_storage({ t: "b", v: data[C2] }, SST);
          break;
        default:
          throw new Error("Unsupported value " + data[C2]);
      }
      cell_storage.push(celload);
      last_offset += celload.length;
      _cell_storage.push(_celload);
      _last_offset += _celload.length;
      ++cnt;
    }
    tri[2][0].data = write_varint49(cnt);
    for (; C2 < tri[7][0].data.length / 2; ++C2) {
      dv.setUint16(C2 * 2, 65535, true);
      _dv.setUint16(C2 * 2, 65535, true);
    }
    tri[6][0].data = u8concat(cell_storage);
    tri[3][0].data = u8concat(_cell_storage);
    return cnt;
  }
  function write_numbers_iwa(wb, opts) {
    if (!opts || !opts.numbers)
      throw new Error("Must pass a `numbers` option -- check the README");
    var ws = wb.Sheets[wb.SheetNames[0]];
    if (wb.SheetNames.length > 1)
      console.error("The Numbers writer currently writes only the first table");
    var range = decode_range(ws["!ref"]);
    range.s.r = range.s.c = 0;
    var trunc = false;
    if (range.e.c > 9) {
      trunc = true;
      range.e.c = 9;
    }
    if (range.e.r > 49) {
      trunc = true;
      range.e.r = 49;
    }
    if (trunc)
      console.error("The Numbers writer is currently limited to ".concat(encode_range(range)));
    var data = sheet_to_json(ws, { range, header: 1 });
    var SST = ["~Sh33tJ5~"];
    data.forEach(function(row) {
      return row.forEach(function(cell) {
        if (typeof cell == "string")
          SST.push(cell);
      });
    });
    var dependents = {};
    var indices = [];
    var cfb = CFB.read(opts.numbers, { type: "base64" });
    cfb.FileIndex.map(function(fi, idx) {
      return [fi, cfb.FullPaths[idx]];
    }).forEach(function(row) {
      var fi = row[0], fp = row[1];
      if (fi.type != 2)
        return;
      if (!fi.name.match(/\.iwa/))
        return;
      var old_content = fi.content;
      var raw1 = decompress_iwa_file(old_content);
      var x22 = parse_iwa_file(raw1);
      x22.forEach(function(packet2) {
        indices.push(packet2.id);
        dependents[packet2.id] = { deps: [], location: fp, type: varint_to_i32(packet2.messages[0].meta[1][0].data) };
      });
    });
    indices.sort(function(x22, y2) {
      return x22 - y2;
    });
    var indices_varint = indices.filter(function(x22) {
      return x22 > 1;
    }).map(function(x22) {
      return [x22, write_varint49(x22)];
    });
    cfb.FileIndex.map(function(fi, idx) {
      return [fi, cfb.FullPaths[idx]];
    }).forEach(function(row) {
      var fi = row[0];
      row[1];
      if (!fi.name.match(/\.iwa/))
        return;
      var x22 = parse_iwa_file(decompress_iwa_file(fi.content));
      x22.forEach(function(ia) {
        ia.messages.forEach(function(m2) {
          indices_varint.forEach(function(ivi) {
            if (ia.messages.some(function(mess) {
              return varint_to_i32(mess.meta[1][0].data) != 11006 && u8contains(mess.data, ivi[1]);
            })) {
              dependents[ivi[0]].deps.push(ia.id);
            }
          });
        });
      });
    });
    var entry = CFB.find(cfb, dependents[1].location);
    var x2 = parse_iwa_file(decompress_iwa_file(entry.content));
    var docroot;
    for (var xi = 0; xi < x2.length; ++xi) {
      var packet = x2[xi];
      if (packet.id == 1)
        docroot = packet;
    }
    var sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[1][0].data);
    entry = CFB.find(cfb, dependents[sheetrootref].location);
    x2 = parse_iwa_file(decompress_iwa_file(entry.content));
    for (xi = 0; xi < x2.length; ++xi) {
      packet = x2[xi];
      if (packet.id == sheetrootref)
        docroot = packet;
    }
    sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);
    entry = CFB.find(cfb, dependents[sheetrootref].location);
    x2 = parse_iwa_file(decompress_iwa_file(entry.content));
    for (xi = 0; xi < x2.length; ++xi) {
      packet = x2[xi];
      if (packet.id == sheetrootref)
        docroot = packet;
    }
    sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);
    entry = CFB.find(cfb, dependents[sheetrootref].location);
    x2 = parse_iwa_file(decompress_iwa_file(entry.content));
    for (xi = 0; xi < x2.length; ++xi) {
      packet = x2[xi];
      if (packet.id == sheetrootref)
        docroot = packet;
    }
    var pb = parse_shallow(docroot.messages[0].data);
    {
      pb[6][0].data = write_varint49(range.e.r + 1);
      pb[7][0].data = write_varint49(range.e.c + 1);
      var cruidsref = parse_TSP_Reference(pb[46][0].data);
      var oldbucket = CFB.find(cfb, dependents[cruidsref].location);
      var _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));
      {
        for (var j = 0; j < _x.length; ++j) {
          if (_x[j].id == cruidsref)
            break;
        }
        if (_x[j].id != cruidsref)
          throw "Bad ColumnRowUIDMapArchive";
        var cruids = parse_shallow(_x[j].messages[0].data);
        cruids[1] = [];
        cruids[2] = [], cruids[3] = [];
        for (var C2 = 0; C2 <= range.e.c; ++C2) {
          var uuid = [];
          uuid[1] = uuid[2] = [{ type: 0, data: write_varint49(C2 + 420690) }];
          cruids[1].push({ type: 2, data: write_shallow(uuid) });
          cruids[2].push({ type: 0, data: write_varint49(C2) });
          cruids[3].push({ type: 0, data: write_varint49(C2) });
        }
        cruids[4] = [];
        cruids[5] = [], cruids[6] = [];
        for (var R2 = 0; R2 <= range.e.r; ++R2) {
          uuid = [];
          uuid[1] = uuid[2] = [{ type: 0, data: write_varint49(R2 + 726270) }];
          cruids[4].push({ type: 2, data: write_shallow(uuid) });
          cruids[5].push({ type: 0, data: write_varint49(R2) });
          cruids[6].push({ type: 0, data: write_varint49(R2) });
        }
        _x[j].messages[0].data = write_shallow(cruids);
      }
      oldbucket.content = compress_iwa_file(write_iwa_file(_x));
      oldbucket.size = oldbucket.content.length;
      delete pb[46];
      var store = parse_shallow(pb[4][0].data);
      {
        store[7][0].data = write_varint49(range.e.r + 1);
        var row_headers = parse_shallow(store[1][0].data);
        var row_header_ref = parse_TSP_Reference(row_headers[2][0].data);
        oldbucket = CFB.find(cfb, dependents[row_header_ref].location);
        _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));
        {
          if (_x[0].id != row_header_ref)
            throw "Bad HeaderStorageBucket";
          var base_bucket = parse_shallow(_x[0].messages[0].data);
          for (R2 = 0; R2 < data.length; ++R2) {
            var _bucket = parse_shallow(base_bucket[2][0].data);
            _bucket[1][0].data = write_varint49(R2);
            _bucket[4][0].data = write_varint49(data[R2].length);
            base_bucket[2][R2] = { type: base_bucket[2][0].type, data: write_shallow(_bucket) };
          }
          _x[0].messages[0].data = write_shallow(base_bucket);
        }
        oldbucket.content = compress_iwa_file(write_iwa_file(_x));
        oldbucket.size = oldbucket.content.length;
        var col_header_ref = parse_TSP_Reference(store[2][0].data);
        oldbucket = CFB.find(cfb, dependents[col_header_ref].location);
        _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));
        {
          if (_x[0].id != col_header_ref)
            throw "Bad HeaderStorageBucket";
          base_bucket = parse_shallow(_x[0].messages[0].data);
          for (C2 = 0; C2 <= range.e.c; ++C2) {
            _bucket = parse_shallow(base_bucket[2][0].data);
            _bucket[1][0].data = write_varint49(C2);
            _bucket[4][0].data = write_varint49(range.e.r + 1);
            base_bucket[2][C2] = { type: base_bucket[2][0].type, data: write_shallow(_bucket) };
          }
          _x[0].messages[0].data = write_shallow(base_bucket);
        }
        oldbucket.content = compress_iwa_file(write_iwa_file(_x));
        oldbucket.size = oldbucket.content.length;
        var sstref = parse_TSP_Reference(store[4][0].data);
        (function() {
          var sentry = CFB.find(cfb, dependents[sstref].location);
          var sx = parse_iwa_file(decompress_iwa_file(sentry.content));
          var sstroot;
          for (var sxi = 0; sxi < sx.length; ++sxi) {
            var packet2 = sx[sxi];
            if (packet2.id == sstref)
              sstroot = packet2;
          }
          var sstdata = parse_shallow(sstroot.messages[0].data);
          {
            sstdata[3] = [];
            var newsst = [];
            SST.forEach(function(str, i) {
              newsst[1] = [{ type: 0, data: write_varint49(i) }];
              newsst[2] = [{ type: 0, data: write_varint49(1) }];
              newsst[3] = [{ type: 2, data: stru8(str) }];
              sstdata[3].push({ type: 2, data: write_shallow(newsst) });
            });
          }
          sstroot.messages[0].data = write_shallow(sstdata);
          var sy = write_iwa_file(sx);
          var raw32 = compress_iwa_file(sy);
          sentry.content = raw32;
          sentry.size = sentry.content.length;
        })();
        var tile = parse_shallow(store[3][0].data);
        {
          var t = tile[1][0];
          delete tile[2];
          var tl = parse_shallow(t.data);
          {
            var tileref = parse_TSP_Reference(tl[2][0].data);
            (function() {
              var tentry = CFB.find(cfb, dependents[tileref].location);
              var tx = parse_iwa_file(decompress_iwa_file(tentry.content));
              var tileroot;
              for (var sxi = 0; sxi < tx.length; ++sxi) {
                var packet2 = tx[sxi];
                if (packet2.id == tileref)
                  tileroot = packet2;
              }
              var tiledata = parse_shallow(tileroot.messages[0].data);
              {
                delete tiledata[6];
                delete tile[7];
                var rowload = new Uint8Array(tiledata[5][0].data);
                tiledata[5] = [];
                var cnt = 0;
                for (var R22 = 0; R22 <= range.e.r; ++R22) {
                  var tilerow = parse_shallow(rowload);
                  cnt += write_tile_row(tilerow, data[R22], SST);
                  tilerow[1][0].data = write_varint49(R22);
                  tiledata[5].push({ data: write_shallow(tilerow), type: 2 });
                }
                tiledata[1] = [{ type: 0, data: write_varint49(range.e.c + 1) }];
                tiledata[2] = [{ type: 0, data: write_varint49(range.e.r + 1) }];
                tiledata[3] = [{ type: 0, data: write_varint49(cnt) }];
                tiledata[4] = [{ type: 0, data: write_varint49(range.e.r + 1) }];
              }
              tileroot.messages[0].data = write_shallow(tiledata);
              var ty = write_iwa_file(tx);
              var raw32 = compress_iwa_file(ty);
              tentry.content = raw32;
              tentry.size = tentry.content.length;
            })();
          }
          t.data = write_shallow(tl);
        }
        store[3][0].data = write_shallow(tile);
      }
      pb[4][0].data = write_shallow(store);
    }
    docroot.messages[0].data = write_shallow(pb);
    var y = write_iwa_file(x2);
    var raw3 = compress_iwa_file(y);
    entry.content = raw3;
    entry.size = entry.content.length;
    return cfb;
  }
  function fix_opts_func(defaults) {
    return function fix_opts(opts) {
      for (var i = 0; i != defaults.length; ++i) {
        var d2 = defaults[i];
        if (opts[d2[0]] === void 0)
          opts[d2[0]] = d2[1];
        if (d2[2] === "n")
          opts[d2[0]] = Number(opts[d2[0]]);
      }
    };
  }
  function fix_read_opts(opts) {
    fix_opts_func([
      ["cellNF", false],
      ["cellHTML", true],
      ["cellFormula", true],
      ["cellStyles", false],
      ["cellText", true],
      ["cellDates", false],
      ["sheetStubs", false],
      ["sheetRows", 0, "n"],
      ["bookDeps", false],
      ["bookSheets", false],
      ["bookProps", false],
      ["bookFiles", false],
      ["bookVBA", false],
      ["password", ""],
      ["WTF", false]
    ])(opts);
  }
  function fix_write_opts(opts) {
    fix_opts_func([
      ["cellDates", false],
      ["bookSST", false],
      ["bookType", "xlsx"],
      ["compression", false],
      ["WTF", false]
    ])(opts);
  }
  function get_sheet_type(n) {
    if (RELS.WS.indexOf(n) > -1)
      return "sheet";
    if (n == RELS.CS)
      return "chart";
    if (n == RELS.DS)
      return "dialog";
    if (n == RELS.MS)
      return "macro";
    return n && n.length ? n : "sheet";
  }
  function safe_parse_wbrels(wbrels, sheets) {
    if (!wbrels)
      return 0;
    try {
      wbrels = sheets.map(function pwbr(w2) {
        if (!w2.id)
          w2.id = w2.strRelID;
        return [w2.name, wbrels["!id"][w2.id].Target, get_sheet_type(wbrels["!id"][w2.id].Type)];
      });
    } catch (e) {
      return null;
    }
    return !wbrels || wbrels.length === 0 ? null : wbrels;
  }
  function safe_parse_sheet(zip, path, relsPath, sheet, idx, sheetRels, sheets, stype, opts, wb, themes, styles) {
    try {
      sheetRels[sheet] = parse_rels(getzipstr(zip, relsPath, true), path);
      var data = getzipdata(zip, path);
      var _ws;
      switch (stype) {
        case "sheet":
          _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
          break;
        case "chart":
          _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
          if (!_ws || !_ws["!drawel"])
            break;
          var dfile = resolve_path(_ws["!drawel"].Target, path);
          var drelsp = get_rels_path(dfile);
          var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
          var chartp = resolve_path(draw, dfile);
          var crelsp = get_rels_path(chartp);
          _ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
          break;
        case "macro":
          _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
          break;
        case "dialog":
          _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
          break;
        default:
          throw new Error("Unrecognized sheet type " + stype);
      }
      sheets[sheet] = _ws;
      var tcomments = [];
      if (sheetRels && sheetRels[sheet])
        keys$1(sheetRels[sheet]).forEach(function(n) {
          var dfile2 = "";
          if (sheetRels[sheet][n].Type == RELS.CMNT) {
            dfile2 = resolve_path(sheetRels[sheet][n].Target, path);
            var comments = parse_cmnt(getzipdata(zip, dfile2, true), dfile2, opts);
            if (!comments || !comments.length)
              return;
            sheet_insert_comments(_ws, comments, false);
          }
          if (sheetRels[sheet][n].Type == RELS.TCMNT) {
            dfile2 = resolve_path(sheetRels[sheet][n].Target, path);
            tcomments = tcomments.concat(parse_tcmnt_xml(getzipdata(zip, dfile2, true), opts));
          }
        });
      if (tcomments && tcomments.length)
        sheet_insert_comments(_ws, tcomments, true, opts.people || []);
    } catch (e) {
      if (opts.WTF)
        throw e;
    }
  }
  function strip_front_slash(x2) {
    return x2.charAt(0) == "/" ? x2.slice(1) : x2;
  }
  function parse_zip(zip, opts) {
    make_ssf();
    opts = opts || {};
    fix_read_opts(opts);
    if (safegetzipfile(zip, "META-INF/manifest.xml"))
      return parse_ods(zip, opts);
    if (safegetzipfile(zip, "objectdata.xml"))
      return parse_ods(zip, opts);
    if (safegetzipfile(zip, "Index/Document.iwa")) {
      if (typeof Uint8Array == "undefined")
        throw new Error("NUMBERS file parsing requires Uint8Array support");
      if (typeof parse_numbers_iwa != "undefined") {
        if (zip.FileIndex)
          return parse_numbers_iwa(zip);
        var _zip = CFB.utils.cfb_new();
        zipentries(zip).forEach(function(e) {
          zip_add_file(_zip, e, getzipbin(zip, e));
        });
        return parse_numbers_iwa(_zip);
      }
      throw new Error("Unsupported NUMBERS file");
    }
    if (!safegetzipfile(zip, "[Content_Types].xml")) {
      if (safegetzipfile(zip, "index.xml.gz"))
        throw new Error("Unsupported NUMBERS 08 file");
      if (safegetzipfile(zip, "index.xml"))
        throw new Error("Unsupported NUMBERS 09 file");
      throw new Error("Unsupported ZIP file");
    }
    var entries = zipentries(zip);
    var dir = parse_ct(getzipstr(zip, "[Content_Types].xml"));
    var xlsb = false;
    var sheets, binname;
    if (dir.workbooks.length === 0) {
      binname = "xl/workbook.xml";
      if (getzipdata(zip, binname, true))
        dir.workbooks.push(binname);
    }
    if (dir.workbooks.length === 0) {
      binname = "xl/workbook.bin";
      if (!getzipdata(zip, binname, true))
        throw new Error("Could not find workbook");
      dir.workbooks.push(binname);
      xlsb = true;
    }
    if (dir.workbooks[0].slice(-3) == "bin")
      xlsb = true;
    var themes = {};
    var styles = {};
    if (!opts.bookSheets && !opts.bookProps) {
      strs = [];
      if (dir.sst)
        try {
          strs = parse_sst(getzipdata(zip, strip_front_slash(dir.sst)), dir.sst, opts);
        } catch (e) {
          if (opts.WTF)
            throw e;
        }
      if (opts.cellStyles && dir.themes.length)
        themes = parse_theme(getzipstr(zip, dir.themes[0].replace(/^\//, ""), true) || "", dir.themes[0], opts);
      if (dir.style)
        styles = parse_sty(getzipdata(zip, strip_front_slash(dir.style)), dir.style, themes, opts);
    }
    dir.links.map(function(link) {
      try {
        var rels = parse_rels(getzipstr(zip, get_rels_path(strip_front_slash(link))), link);
        return parse_xlink(getzipdata(zip, strip_front_slash(link)), rels, link, opts);
      } catch (e) {
      }
    });
    var wb = parse_wb(getzipdata(zip, strip_front_slash(dir.workbooks[0])), dir.workbooks[0], opts);
    var props = {}, propdata = "";
    if (dir.coreprops.length) {
      propdata = getzipdata(zip, strip_front_slash(dir.coreprops[0]), true);
      if (propdata)
        props = parse_core_props(propdata);
      if (dir.extprops.length !== 0) {
        propdata = getzipdata(zip, strip_front_slash(dir.extprops[0]), true);
        if (propdata)
          parse_ext_props(propdata, props, opts);
      }
    }
    var custprops = {};
    if (!opts.bookSheets || opts.bookProps) {
      if (dir.custprops.length !== 0) {
        propdata = getzipstr(zip, strip_front_slash(dir.custprops[0]), true);
        if (propdata)
          custprops = parse_cust_props(propdata, opts);
      }
    }
    var out = {};
    if (opts.bookSheets || opts.bookProps) {
      if (wb.Sheets)
        sheets = wb.Sheets.map(function pluck(x2) {
          return x2.name;
        });
      else if (props.Worksheets && props.SheetNames.length > 0)
        sheets = props.SheetNames;
      if (opts.bookProps) {
        out.Props = props;
        out.Custprops = custprops;
      }
      if (opts.bookSheets && typeof sheets !== "undefined")
        out.SheetNames = sheets;
      if (opts.bookSheets ? out.SheetNames : opts.bookProps)
        return out;
    }
    sheets = {};
    var deps = {};
    if (opts.bookDeps && dir.calcchain)
      deps = parse_cc(getzipdata(zip, strip_front_slash(dir.calcchain)), dir.calcchain);
    var i = 0;
    var sheetRels = {};
    var path, relsPath;
    {
      var wbsheets = wb.Sheets;
      props.Worksheets = wbsheets.length;
      props.SheetNames = [];
      for (var j = 0; j != wbsheets.length; ++j) {
        props.SheetNames[j] = wbsheets[j].name;
      }
    }
    var wbext = xlsb ? "bin" : "xml";
    var wbrelsi = dir.workbooks[0].lastIndexOf("/");
    var wbrelsfile = (dir.workbooks[0].slice(0, wbrelsi + 1) + "_rels/" + dir.workbooks[0].slice(wbrelsi + 1) + ".rels").replace(/^\//, "");
    if (!safegetzipfile(zip, wbrelsfile))
      wbrelsfile = "xl/_rels/workbook." + wbext + ".rels";
    var wbrels = parse_rels(getzipstr(zip, wbrelsfile, true), wbrelsfile.replace(/_rels.*/, "s5s"));
    if ((dir.metadata || []).length >= 1) {
      opts.xlmeta = parse_xlmeta(getzipdata(zip, strip_front_slash(dir.metadata[0])), dir.metadata[0], opts);
    }
    if ((dir.people || []).length >= 1) {
      opts.people = parse_people_xml(getzipdata(zip, strip_front_slash(dir.people[0])), opts);
    }
    if (wbrels)
      wbrels = safe_parse_wbrels(wbrels, wb.Sheets);
    var nmode = getzipdata(zip, "xl/worksheets/sheet.xml", true) ? 1 : 0;
    wsloop:
      for (i = 0; i != props.Worksheets; ++i) {
        var stype = "sheet";
        if (wbrels && wbrels[i]) {
          path = "xl/" + wbrels[i][1].replace(/[\/]?xl\//, "");
          if (!safegetzipfile(zip, path))
            path = wbrels[i][1];
          if (!safegetzipfile(zip, path))
            path = wbrelsfile.replace(/_rels\/.*$/, "") + wbrels[i][1];
          stype = wbrels[i][2];
        } else {
          path = "xl/worksheets/sheet" + (i + 1 - nmode) + "." + wbext;
          path = path.replace(/sheet0\./, "sheet.");
        }
        relsPath = path.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
        if (opts && opts.sheets != null)
          switch (typeof opts.sheets) {
            case "number":
              if (i != opts.sheets)
                continue wsloop;
              break;
            case "string":
              if (props.SheetNames[i].toLowerCase() != opts.sheets.toLowerCase())
                continue wsloop;
              break;
            default:
              if (Array.isArray && Array.isArray(opts.sheets)) {
                var snjseen = false;
                for (var snj = 0; snj != opts.sheets.length; ++snj) {
                  if (typeof opts.sheets[snj] == "number" && opts.sheets[snj] == i)
                    snjseen = 1;
                  if (typeof opts.sheets[snj] == "string" && opts.sheets[snj].toLowerCase() == props.SheetNames[i].toLowerCase())
                    snjseen = 1;
                }
                if (!snjseen)
                  continue wsloop;
              }
          }
        safe_parse_sheet(zip, path, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles);
      }
    out = {
      Directory: dir,
      Workbook: wb,
      Props: props,
      Custprops: custprops,
      Deps: deps,
      Sheets: sheets,
      SheetNames: props.SheetNames,
      Strings: strs,
      Styles: styles,
      Themes: themes,
      SSF: dup(table_fmt)
    };
    if (opts && opts.bookFiles) {
      if (zip.files) {
        out.keys = entries;
        out.files = zip.files;
      } else {
        out.keys = [];
        out.files = {};
        zip.FullPaths.forEach(function(p2, idx) {
          p2 = p2.replace(/^Root Entry[\/]/, "");
          out.keys.push(p2);
          out.files[p2] = zip.FileIndex[idx];
        });
      }
    }
    if (opts && opts.bookVBA) {
      if (dir.vba.length > 0)
        out.vbaraw = getzipdata(zip, strip_front_slash(dir.vba[0]), true);
      else if (dir.defaults && dir.defaults.bin === CT_VBA)
        out.vbaraw = getzipdata(zip, "xl/vbaProject.bin", true);
    }
    return out;
  }
  function parse_xlsxcfb(cfb, _opts) {
    var opts = _opts || {};
    var f2 = "Workbook", data = CFB.find(cfb, f2);
    try {
      f2 = "/!DataSpaces/Version";
      data = CFB.find(cfb, f2);
      if (!data || !data.content)
        throw new Error("ECMA-376 Encrypted file missing " + f2);
      parse_DataSpaceVersionInfo(data.content);
      f2 = "/!DataSpaces/DataSpaceMap";
      data = CFB.find(cfb, f2);
      if (!data || !data.content)
        throw new Error("ECMA-376 Encrypted file missing " + f2);
      var dsm = parse_DataSpaceMap(data.content);
      if (dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== "StrongEncryptionDataSpace" || dsm[0].comps[0].v !== "EncryptedPackage")
        throw new Error("ECMA-376 Encrypted file bad " + f2);
      f2 = "/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace";
      data = CFB.find(cfb, f2);
      if (!data || !data.content)
        throw new Error("ECMA-376 Encrypted file missing " + f2);
      var seds = parse_DataSpaceDefinition(data.content);
      if (seds.length != 1 || seds[0] != "StrongEncryptionTransform")
        throw new Error("ECMA-376 Encrypted file bad " + f2);
      f2 = "/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary";
      data = CFB.find(cfb, f2);
      if (!data || !data.content)
        throw new Error("ECMA-376 Encrypted file missing " + f2);
      parse_Primary(data.content);
    } catch (e) {
    }
    f2 = "/EncryptionInfo";
    data = CFB.find(cfb, f2);
    if (!data || !data.content)
      throw new Error("ECMA-376 Encrypted file missing " + f2);
    var einfo = parse_EncryptionInfo(data.content);
    f2 = "/EncryptedPackage";
    data = CFB.find(cfb, f2);
    if (!data || !data.content)
      throw new Error("ECMA-376 Encrypted file missing " + f2);
    if (einfo[0] == 4 && typeof decrypt_agile !== "undefined")
      return decrypt_agile(einfo[1], data.content, opts.password || "", opts);
    if (einfo[0] == 2 && typeof decrypt_std76 !== "undefined")
      return decrypt_std76(einfo[1], data.content, opts.password || "", opts);
    throw new Error("File is password-protected");
  }
  function write_zip(wb, opts) {
    if (opts.bookType == "ods")
      return write_ods(wb, opts);
    if (opts.bookType == "numbers")
      return write_numbers_iwa(wb, opts);
    if (opts.bookType == "xlsb")
      return write_zip_xlsxb(wb, opts);
    return write_zip_xlsx(wb, opts);
  }
  function write_zip_xlsxb(wb, opts) {
    _shapeid = 1024;
    if (wb && !wb.SSF) {
      wb.SSF = dup(table_fmt);
    }
    if (wb && wb.SSF) {
      make_ssf();
      SSF_load_table(wb.SSF);
      opts.revssf = evert_num(wb.SSF);
      opts.revssf[wb.SSF[65535]] = 0;
      opts.ssf = wb.SSF;
    }
    opts.rels = {};
    opts.wbrels = {};
    opts.Strings = [];
    opts.Strings.Count = 0;
    opts.Strings.Unique = 0;
    if (browser_has_Map)
      opts.revStrings = /* @__PURE__ */ new Map();
    else {
      opts.revStrings = {};
      opts.revStrings.foo = [];
      delete opts.revStrings.foo;
    }
    var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
    var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
    var ct2 = new_ct();
    fix_write_opts(opts = opts || {});
    var zip = zip_new();
    var f2 = "", rId = 0;
    opts.cellXfs = [];
    get_cell_style(opts.cellXfs, {}, { revssf: { "General": 0 } });
    if (!wb.Props)
      wb.Props = {};
    f2 = "docProps/core.xml";
    zip_add_file(zip, f2, write_core_props(wb.Props, opts));
    ct2.coreprops.push(f2);
    add_rels(opts.rels, 2, f2, RELS.CORE_PROPS);
    f2 = "docProps/app.xml";
    if (wb.Props && wb.Props.SheetNames)
      ;
    else if (!wb.Workbook || !wb.Workbook.Sheets)
      wb.Props.SheetNames = wb.SheetNames;
    else {
      var _sn = [];
      for (var _i = 0; _i < wb.SheetNames.length; ++_i)
        if ((wb.Workbook.Sheets[_i] || {}).Hidden != 2)
          _sn.push(wb.SheetNames[_i]);
      wb.Props.SheetNames = _sn;
    }
    wb.Props.Worksheets = wb.Props.SheetNames.length;
    zip_add_file(zip, f2, write_ext_props(wb.Props));
    ct2.extprops.push(f2);
    add_rels(opts.rels, 3, f2, RELS.EXT_PROPS);
    if (wb.Custprops !== wb.Props && keys$1(wb.Custprops || {}).length > 0) {
      f2 = "docProps/custom.xml";
      zip_add_file(zip, f2, write_cust_props(wb.Custprops));
      ct2.custprops.push(f2);
      add_rels(opts.rels, 4, f2, RELS.CUST_PROPS);
    }
    for (rId = 1; rId <= wb.SheetNames.length; ++rId) {
      var wsrels = { "!id": {} };
      var ws = wb.Sheets[wb.SheetNames[rId - 1]];
      var _type = (ws || {})["!type"] || "sheet";
      switch (_type) {
        case "chart":
        default:
          f2 = "xl/worksheets/sheet" + rId + "." + wbext;
          zip_add_file(zip, f2, write_ws(rId - 1, f2, opts, wb, wsrels));
          ct2.sheets.push(f2);
          add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
      }
      if (ws) {
        var comments = ws["!comments"];
        var need_vml = false;
        var cf = "";
        if (comments && comments.length > 0) {
          cf = "xl/comments" + rId + "." + wbext;
          zip_add_file(zip, cf, write_cmnt(comments, cf));
          ct2.comments.push(cf);
          add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
          need_vml = true;
        }
        if (ws["!legacy"]) {
          if (need_vml)
            zip_add_file(zip, "xl/drawings/vmlDrawing" + rId + ".vml", write_comments_vml(rId, ws["!comments"]));
        }
        delete ws["!comments"];
        delete ws["!legacy"];
      }
      if (wsrels["!id"].rId1)
        zip_add_file(zip, get_rels_path(f2), write_rels(wsrels));
    }
    if (opts.Strings != null && opts.Strings.length > 0) {
      f2 = "xl/sharedStrings." + wbext;
      zip_add_file(zip, f2, write_sst(opts.Strings, f2, opts));
      ct2.strs.push(f2);
      add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
    }
    f2 = "xl/workbook." + wbext;
    zip_add_file(zip, f2, write_wb(wb, f2));
    ct2.workbooks.push(f2);
    add_rels(opts.rels, 1, f2, RELS.WB);
    f2 = "xl/theme/theme1.xml";
    zip_add_file(zip, f2, write_theme(wb.Themes, opts));
    ct2.themes.push(f2);
    add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
    f2 = "xl/styles." + wbext;
    zip_add_file(zip, f2, write_sty(wb, f2, opts));
    ct2.styles.push(f2);
    add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
    if (wb.vbaraw && vbafmt) {
      f2 = "xl/vbaProject.bin";
      zip_add_file(zip, f2, wb.vbaraw);
      ct2.vba.push(f2);
      add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
    }
    f2 = "xl/metadata." + wbext;
    zip_add_file(zip, f2, write_xlmeta(f2));
    ct2.metadata.push(f2);
    add_rels(opts.wbrels, -1, "metadata." + wbext, RELS.XLMETA);
    zip_add_file(zip, "[Content_Types].xml", write_ct(ct2, opts));
    zip_add_file(zip, "_rels/.rels", write_rels(opts.rels));
    zip_add_file(zip, "xl/_rels/workbook." + wbext + ".rels", write_rels(opts.wbrels));
    delete opts.revssf;
    delete opts.ssf;
    return zip;
  }
  function write_zip_xlsx(wb, opts) {
    _shapeid = 1024;
    if (wb && !wb.SSF) {
      wb.SSF = dup(table_fmt);
    }
    if (wb && wb.SSF) {
      make_ssf();
      SSF_load_table(wb.SSF);
      opts.revssf = evert_num(wb.SSF);
      opts.revssf[wb.SSF[65535]] = 0;
      opts.ssf = wb.SSF;
    }
    opts.rels = {};
    opts.wbrels = {};
    opts.Strings = [];
    opts.Strings.Count = 0;
    opts.Strings.Unique = 0;
    if (browser_has_Map)
      opts.revStrings = /* @__PURE__ */ new Map();
    else {
      opts.revStrings = {};
      opts.revStrings.foo = [];
      delete opts.revStrings.foo;
    }
    var wbext = "xml";
    var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
    var ct2 = new_ct();
    fix_write_opts(opts = opts || {});
    var zip = zip_new();
    var f2 = "", rId = 0;
    opts.cellXfs = [];
    get_cell_style(opts.cellXfs, {}, { revssf: { "General": 0 } });
    if (!wb.Props)
      wb.Props = {};
    f2 = "docProps/core.xml";
    zip_add_file(zip, f2, write_core_props(wb.Props, opts));
    ct2.coreprops.push(f2);
    add_rels(opts.rels, 2, f2, RELS.CORE_PROPS);
    f2 = "docProps/app.xml";
    if (wb.Props && wb.Props.SheetNames)
      ;
    else if (!wb.Workbook || !wb.Workbook.Sheets)
      wb.Props.SheetNames = wb.SheetNames;
    else {
      var _sn = [];
      for (var _i = 0; _i < wb.SheetNames.length; ++_i)
        if ((wb.Workbook.Sheets[_i] || {}).Hidden != 2)
          _sn.push(wb.SheetNames[_i]);
      wb.Props.SheetNames = _sn;
    }
    wb.Props.Worksheets = wb.Props.SheetNames.length;
    zip_add_file(zip, f2, write_ext_props(wb.Props));
    ct2.extprops.push(f2);
    add_rels(opts.rels, 3, f2, RELS.EXT_PROPS);
    if (wb.Custprops !== wb.Props && keys$1(wb.Custprops || {}).length > 0) {
      f2 = "docProps/custom.xml";
      zip_add_file(zip, f2, write_cust_props(wb.Custprops));
      ct2.custprops.push(f2);
      add_rels(opts.rels, 4, f2, RELS.CUST_PROPS);
    }
    var people = ["SheetJ5"];
    opts.tcid = 0;
    for (rId = 1; rId <= wb.SheetNames.length; ++rId) {
      var wsrels = { "!id": {} };
      var ws = wb.Sheets[wb.SheetNames[rId - 1]];
      var _type = (ws || {})["!type"] || "sheet";
      switch (_type) {
        case "chart":
        default:
          f2 = "xl/worksheets/sheet" + rId + "." + wbext;
          zip_add_file(zip, f2, write_ws_xml(rId - 1, opts, wb, wsrels));
          ct2.sheets.push(f2);
          add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
      }
      if (ws) {
        var comments = ws["!comments"];
        var need_vml = false;
        var cf = "";
        if (comments && comments.length > 0) {
          var needtc = false;
          comments.forEach(function(carr) {
            carr[1].forEach(function(c2) {
              if (c2.T == true)
                needtc = true;
            });
          });
          if (needtc) {
            cf = "xl/threadedComments/threadedComment" + rId + "." + wbext;
            zip_add_file(zip, cf, write_tcmnt_xml(comments, people, opts));
            ct2.threadedcomments.push(cf);
            add_rels(wsrels, -1, "../threadedComments/threadedComment" + rId + "." + wbext, RELS.TCMNT);
          }
          cf = "xl/comments" + rId + "." + wbext;
          zip_add_file(zip, cf, write_comments_xml(comments));
          ct2.comments.push(cf);
          add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
          need_vml = true;
        }
        if (ws["!legacy"]) {
          if (need_vml)
            zip_add_file(zip, "xl/drawings/vmlDrawing" + rId + ".vml", write_comments_vml(rId, ws["!comments"]));
        }
        delete ws["!comments"];
        delete ws["!legacy"];
      }
      if (wsrels["!id"].rId1)
        zip_add_file(zip, get_rels_path(f2), write_rels(wsrels));
    }
    if (opts.Strings != null && opts.Strings.length > 0) {
      f2 = "xl/sharedStrings." + wbext;
      zip_add_file(zip, f2, write_sst_xml(opts.Strings, opts));
      ct2.strs.push(f2);
      add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
    }
    f2 = "xl/workbook." + wbext;
    zip_add_file(zip, f2, write_wb_xml(wb));
    ct2.workbooks.push(f2);
    add_rels(opts.rels, 1, f2, RELS.WB);
    f2 = "xl/theme/theme1.xml";
    zip_add_file(zip, f2, write_theme(wb.Themes, opts));
    ct2.themes.push(f2);
    add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
    f2 = "xl/styles." + wbext;
    zip_add_file(zip, f2, write_sty_xml(wb, opts));
    ct2.styles.push(f2);
    add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
    if (wb.vbaraw && vbafmt) {
      f2 = "xl/vbaProject.bin";
      zip_add_file(zip, f2, wb.vbaraw);
      ct2.vba.push(f2);
      add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
    }
    f2 = "xl/metadata." + wbext;
    zip_add_file(zip, f2, write_xlmeta_xml());
    ct2.metadata.push(f2);
    add_rels(opts.wbrels, -1, "metadata." + wbext, RELS.XLMETA);
    if (people.length > 1) {
      f2 = "xl/persons/person.xml";
      zip_add_file(zip, f2, write_people_xml(people));
      ct2.people.push(f2);
      add_rels(opts.wbrels, -1, "persons/person.xml", RELS.PEOPLE);
    }
    zip_add_file(zip, "[Content_Types].xml", write_ct(ct2, opts));
    zip_add_file(zip, "_rels/.rels", write_rels(opts.rels));
    zip_add_file(zip, "xl/_rels/workbook." + wbext + ".rels", write_rels(opts.wbrels));
    delete opts.revssf;
    delete opts.ssf;
    return zip;
  }
  function firstbyte(f2, o2) {
    var x2 = "";
    switch ((o2 || {}).type || "base64") {
      case "buffer":
        return [f2[0], f2[1], f2[2], f2[3], f2[4], f2[5], f2[6], f2[7]];
      case "base64":
        x2 = Base64_decode(f2.slice(0, 12));
        break;
      case "binary":
        x2 = f2;
        break;
      case "array":
        return [f2[0], f2[1], f2[2], f2[3], f2[4], f2[5], f2[6], f2[7]];
      default:
        throw new Error("Unrecognized type " + (o2 && o2.type || "undefined"));
    }
    return [x2.charCodeAt(0), x2.charCodeAt(1), x2.charCodeAt(2), x2.charCodeAt(3), x2.charCodeAt(4), x2.charCodeAt(5), x2.charCodeAt(6), x2.charCodeAt(7)];
  }
  function read_cfb(cfb, opts) {
    if (CFB.find(cfb, "EncryptedPackage"))
      return parse_xlsxcfb(cfb, opts);
    return parse_xlscfb(cfb, opts);
  }
  function read_zip(data, opts) {
    var zip, d2 = data;
    var o2 = opts || {};
    if (!o2.type)
      o2.type = has_buf && Buffer.isBuffer(data) ? "buffer" : "base64";
    zip = zip_read(d2, o2);
    return parse_zip(zip, o2);
  }
  function read_plaintext(data, o2) {
    var i = 0;
    main:
      while (i < data.length)
        switch (data.charCodeAt(i)) {
          case 10:
          case 13:
          case 32:
            ++i;
            break;
          case 60:
            return parse_xlml(data.slice(i), o2);
          default:
            break main;
        }
    return PRN.to_workbook(data, o2);
  }
  function read_plaintext_raw(data, o2) {
    var str = "", bytes = firstbyte(data, o2);
    switch (o2.type) {
      case "base64":
        str = Base64_decode(data);
        break;
      case "binary":
        str = data;
        break;
      case "buffer":
        str = data.toString("binary");
        break;
      case "array":
        str = cc2str(data);
        break;
      default:
        throw new Error("Unrecognized type " + o2.type);
    }
    if (bytes[0] == 239 && bytes[1] == 187 && bytes[2] == 191)
      str = utf8read(str);
    o2.type = "binary";
    return read_plaintext(str, o2);
  }
  function read_utf16(data, o2) {
    var d2 = data;
    if (o2.type == "base64")
      d2 = Base64_decode(d2);
    d2 = $cptable.utils.decode(1200, d2.slice(2), "str");
    o2.type = "binary";
    return read_plaintext(d2, o2);
  }
  function bstrify(data) {
    return !data.match(/[^\x00-\x7F]/) ? data : utf8write(data);
  }
  function read_prn(data, d2, o2, str) {
    if (str) {
      o2.type = "string";
      return PRN.to_workbook(data, o2);
    }
    return PRN.to_workbook(d2, o2);
  }
  function readSync(data, opts) {
    reset_cp();
    var o2 = opts || {};
    if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer)
      return readSync(new Uint8Array(data), (o2 = dup(o2), o2.type = "array", o2));
    if (typeof Uint8Array !== "undefined" && data instanceof Uint8Array && !o2.type)
      o2.type = typeof Deno !== "undefined" ? "buffer" : "array";
    var d2 = data, n = [0, 0, 0, 0], str = false;
    if (o2.cellStyles) {
      o2.cellNF = true;
      o2.sheetStubs = true;
    }
    _ssfopts = {};
    if (o2.dateNF)
      _ssfopts.dateNF = o2.dateNF;
    if (!o2.type)
      o2.type = has_buf && Buffer.isBuffer(data) ? "buffer" : "base64";
    if (o2.type == "file") {
      o2.type = has_buf ? "buffer" : "binary";
      d2 = read_binary(data);
      if (typeof Uint8Array !== "undefined" && !has_buf)
        o2.type = "array";
    }
    if (o2.type == "string") {
      str = true;
      o2.type = "binary";
      o2.codepage = 65001;
      d2 = bstrify(data);
    }
    if (o2.type == "array" && typeof Uint8Array !== "undefined" && data instanceof Uint8Array && typeof ArrayBuffer !== "undefined") {
      var ab = new ArrayBuffer(3), vu = new Uint8Array(ab);
      vu.foo = "bar";
      if (!vu.foo) {
        o2 = dup(o2);
        o2.type = "array";
        return readSync(ab2a(d2), o2);
      }
    }
    switch ((n = firstbyte(d2, o2))[0]) {
      case 208:
        if (n[1] === 207 && n[2] === 17 && n[3] === 224 && n[4] === 161 && n[5] === 177 && n[6] === 26 && n[7] === 225)
          return read_cfb(CFB.read(d2, o2), o2);
        break;
      case 9:
        if (n[1] <= 8)
          return parse_xlscfb(d2, o2);
        break;
      case 60:
        return parse_xlml(d2, o2);
      case 73:
        if (n[1] === 73 && n[2] === 42 && n[3] === 0)
          throw new Error("TIFF Image File is not a spreadsheet");
        if (n[1] === 68)
          return read_wb_ID(d2, o2);
        break;
      case 84:
        if (n[1] === 65 && n[2] === 66 && n[3] === 76)
          return DIF.to_workbook(d2, o2);
        break;
      case 80:
        return n[1] === 75 && n[2] < 9 && n[3] < 9 ? read_zip(d2, o2) : read_prn(data, d2, o2, str);
      case 239:
        return n[3] === 60 ? parse_xlml(d2, o2) : read_prn(data, d2, o2, str);
      case 255:
        if (n[1] === 254) {
          return read_utf16(d2, o2);
        } else if (n[1] === 0 && n[2] === 2 && n[3] === 0)
          return WK_.to_workbook(d2, o2);
        break;
      case 0:
        if (n[1] === 0) {
          if (n[2] >= 2 && n[3] === 0)
            return WK_.to_workbook(d2, o2);
          if (n[2] === 0 && (n[3] === 8 || n[3] === 9))
            return WK_.to_workbook(d2, o2);
        }
        break;
      case 3:
      case 131:
      case 139:
      case 140:
        return DBF.to_workbook(d2, o2);
      case 123:
        if (n[1] === 92 && n[2] === 114 && n[3] === 116)
          return RTF.to_workbook(d2, o2);
        break;
      case 10:
      case 13:
      case 32:
        return read_plaintext_raw(d2, o2);
      case 137:
        if (n[1] === 80 && n[2] === 78 && n[3] === 71)
          throw new Error("PNG Image File is not a spreadsheet");
        break;
    }
    if (DBF_SUPPORTED_VERSIONS.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31)
      return DBF.to_workbook(d2, o2);
    return read_prn(data, d2, o2, str);
  }
  function write_cfb_ctr(cfb, o2) {
    switch (o2.type) {
      case "base64":
      case "binary":
        break;
      case "buffer":
      case "array":
        o2.type = "";
        break;
      case "file":
        return write_dl(o2.file, CFB.write(cfb, { type: has_buf ? "buffer" : "" }));
      case "string":
        throw new Error("'string' output type invalid for '" + o2.bookType + "' files");
      default:
        throw new Error("Unrecognized type " + o2.type);
    }
    return CFB.write(cfb, o2);
  }
  function write_zip_type(wb, opts) {
    var o2 = dup(opts || {});
    var z = write_zip(wb, o2);
    return write_zip_denouement(z, o2);
  }
  function write_zip_denouement(z, o2) {
    var oopts = {};
    var ftype = has_buf ? "nodebuffer" : typeof Uint8Array !== "undefined" ? "array" : "string";
    if (o2.compression)
      oopts.compression = "DEFLATE";
    if (o2.password)
      oopts.type = ftype;
    else
      switch (o2.type) {
        case "base64":
          oopts.type = "base64";
          break;
        case "binary":
          oopts.type = "string";
          break;
        case "string":
          throw new Error("'string' output type invalid for '" + o2.bookType + "' files");
        case "buffer":
        case "file":
          oopts.type = ftype;
          break;
        default:
          throw new Error("Unrecognized type " + o2.type);
      }
    var out = z.FullPaths ? CFB.write(z, { fileType: "zip", type: { "nodebuffer": "buffer", "string": "binary" }[oopts.type] || oopts.type, compression: !!o2.compression }) : z.generate(oopts);
    if (typeof Deno !== "undefined") {
      if (typeof out == "string") {
        if (o2.type == "binary" || o2.type == "base64")
          return out;
        out = new Uint8Array(s2ab(out));
      }
    }
    if (o2.password && typeof encrypt_agile !== "undefined")
      return write_cfb_ctr(encrypt_agile(out, o2.password), o2);
    if (o2.type === "file")
      return write_dl(o2.file, out);
    return o2.type == "string" ? utf8read(out) : out;
  }
  function write_cfb_type(wb, opts) {
    var o2 = opts || {};
    var cfb = write_xlscfb(wb, o2);
    return write_cfb_ctr(cfb, o2);
  }
  function write_string_type(out, opts, bom) {
    if (!bom)
      bom = "";
    var o2 = bom + out;
    switch (opts.type) {
      case "base64":
        return Base64_encode(utf8write(o2));
      case "binary":
        return utf8write(o2);
      case "string":
        return out;
      case "file":
        return write_dl(opts.file, o2, "utf8");
      case "buffer": {
        if (has_buf)
          return Buffer_from(o2, "utf8");
        else if (typeof TextEncoder !== "undefined")
          return new TextEncoder().encode(o2);
        else
          return write_string_type(o2, { type: "binary" }).split("").map(function(c2) {
            return c2.charCodeAt(0);
          });
      }
    }
    throw new Error("Unrecognized type " + opts.type);
  }
  function write_stxt_type(out, opts) {
    switch (opts.type) {
      case "base64":
        return Base64_encode(out);
      case "binary":
        return out;
      case "string":
        return out;
      case "file":
        return write_dl(opts.file, out, "binary");
      case "buffer": {
        if (has_buf)
          return Buffer_from(out, "binary");
        else
          return out.split("").map(function(c2) {
            return c2.charCodeAt(0);
          });
      }
    }
    throw new Error("Unrecognized type " + opts.type);
  }
  function write_binary_type(out, opts) {
    switch (opts.type) {
      case "string":
      case "base64":
      case "binary":
        var bstr = "";
        for (var i = 0; i < out.length; ++i)
          bstr += String.fromCharCode(out[i]);
        return opts.type == "base64" ? Base64_encode(bstr) : opts.type == "string" ? utf8read(bstr) : bstr;
      case "file":
        return write_dl(opts.file, out);
      case "buffer":
        return out;
      default:
        throw new Error("Unrecognized type " + opts.type);
    }
  }
  function writeSync(wb, opts) {
    reset_cp();
    check_wb(wb);
    var o2 = dup(opts || {});
    if (o2.cellStyles) {
      o2.cellNF = true;
      o2.sheetStubs = true;
    }
    if (o2.type == "array") {
      o2.type = "binary";
      var out = writeSync(wb, o2);
      o2.type = "array";
      return s2ab(out);
    }
    var idx = 0;
    if (o2.sheet) {
      if (typeof o2.sheet == "number")
        idx = o2.sheet;
      else
        idx = wb.SheetNames.indexOf(o2.sheet);
      if (!wb.SheetNames[idx])
        throw new Error("Sheet not found: " + o2.sheet + " : " + typeof o2.sheet);
    }
    switch (o2.bookType || "xlsb") {
      case "xml":
      case "xlml":
        return write_string_type(write_xlml(wb, o2), o2);
      case "slk":
      case "sylk":
        return write_string_type(SYLK.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "htm":
      case "html":
        return write_string_type(sheet_to_html(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "txt":
        return write_stxt_type(sheet_to_txt(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "csv":
        return write_string_type(sheet_to_csv(wb.Sheets[wb.SheetNames[idx]], o2), o2, "\uFEFF");
      case "dif":
        return write_string_type(DIF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "dbf":
        return write_binary_type(DBF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "prn":
        return write_string_type(PRN.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "rtf":
        return write_string_type(RTF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "eth":
        return write_string_type(ETH.from_sheet(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "fods":
        return write_string_type(write_ods(wb, o2), o2);
      case "wk1":
        return write_binary_type(WK_.sheet_to_wk1(wb.Sheets[wb.SheetNames[idx]], o2), o2);
      case "wk3":
        return write_binary_type(WK_.book_to_wk3(wb, o2), o2);
      case "biff2":
        if (!o2.biff)
          o2.biff = 2;
      case "biff3":
        if (!o2.biff)
          o2.biff = 3;
      case "biff4":
        if (!o2.biff)
          o2.biff = 4;
        return write_binary_type(write_biff_buf(wb, o2), o2);
      case "biff5":
        if (!o2.biff)
          o2.biff = 5;
      case "biff8":
      case "xla":
      case "xls":
        if (!o2.biff)
          o2.biff = 8;
        return write_cfb_type(wb, o2);
      case "xlsx":
      case "xlsm":
      case "xlam":
      case "xlsb":
      case "numbers":
      case "ods":
        return write_zip_type(wb, o2);
      default:
        throw new Error("Unrecognized bookType |" + o2.bookType + "|");
    }
  }
  function resolve_book_type(o2) {
    if (o2.bookType)
      return;
    var _BT = {
      "xls": "biff8",
      "htm": "html",
      "slk": "sylk",
      "socialcalc": "eth",
      "Sh33tJS": "WTF"
    };
    var ext = o2.file.slice(o2.file.lastIndexOf(".")).toLowerCase();
    if (ext.match(/^\.[a-z]+$/))
      o2.bookType = ext.slice(1);
    o2.bookType = _BT[o2.bookType] || o2.bookType;
  }
  function writeFileSync(wb, filename, opts) {
    var o2 = opts || {};
    o2.type = "file";
    o2.file = filename;
    resolve_book_type(o2);
    return writeSync(wb, o2);
  }
  function make_json_row(sheet, r, R2, cols, header, hdr, dense, o2) {
    var rr = encode_row(R2);
    var defval = o2.defval, raw = o2.raw || !Object.prototype.hasOwnProperty.call(o2, "raw");
    var isempty = true;
    var row = header === 1 ? [] : {};
    if (header !== 1) {
      if (Object.defineProperty)
        try {
          Object.defineProperty(row, "__rowNum__", { value: R2, enumerable: false });
        } catch (e) {
          row.__rowNum__ = R2;
        }
      else
        row.__rowNum__ = R2;
    }
    if (!dense || sheet[R2])
      for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
        var val = dense ? sheet[R2][C2] : sheet[cols[C2] + rr];
        if (val === void 0 || val.t === void 0) {
          if (defval === void 0)
            continue;
          if (hdr[C2] != null) {
            row[hdr[C2]] = defval;
          }
          continue;
        }
        var v2 = val.v;
        switch (val.t) {
          case "z":
            if (v2 == null)
              break;
            continue;
          case "e":
            v2 = v2 == 0 ? null : void 0;
            break;
          case "s":
          case "d":
          case "b":
          case "n":
            break;
          default:
            throw new Error("unrecognized type " + val.t);
        }
        if (hdr[C2] != null) {
          if (v2 == null) {
            if (val.t == "e" && v2 === null)
              row[hdr[C2]] = null;
            else if (defval !== void 0)
              row[hdr[C2]] = defval;
            else if (raw && v2 === null)
              row[hdr[C2]] = null;
            else
              continue;
          } else {
            row[hdr[C2]] = raw && (val.t !== "n" || val.t === "n" && o2.rawNumbers !== false) ? v2 : format_cell(val, v2, o2);
          }
          if (v2 != null)
            isempty = false;
        }
      }
    return { row, isempty };
  }
  function sheet_to_json(sheet, opts) {
    if (sheet == null || sheet["!ref"] == null)
      return [];
    var val = { t: "n", v: 0 }, header = 0, offset = 1, hdr = [], v2 = 0, vv = "";
    var r = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };
    var o2 = opts || {};
    var range = o2.range != null ? o2.range : sheet["!ref"];
    if (o2.header === 1)
      header = 1;
    else if (o2.header === "A")
      header = 2;
    else if (Array.isArray(o2.header))
      header = 3;
    else if (o2.header == null)
      header = 0;
    switch (typeof range) {
      case "string":
        r = safe_decode_range(range);
        break;
      case "number":
        r = safe_decode_range(sheet["!ref"]);
        r.s.r = range;
        break;
      default:
        r = range;
    }
    if (header > 0)
      offset = 0;
    var rr = encode_row(r.s.r);
    var cols = [];
    var out = [];
    var outi = 0, counter = 0;
    var dense = Array.isArray(sheet);
    var R2 = r.s.r, C2 = 0;
    var header_cnt = {};
    if (dense && !sheet[R2])
      sheet[R2] = [];
    var colinfo = o2.skipHidden && sheet["!cols"] || [];
    var rowinfo = o2.skipHidden && sheet["!rows"] || [];
    for (C2 = r.s.c; C2 <= r.e.c; ++C2) {
      if ((colinfo[C2] || {}).hidden)
        continue;
      cols[C2] = encode_col(C2);
      val = dense ? sheet[R2][C2] : sheet[cols[C2] + rr];
      switch (header) {
        case 1:
          hdr[C2] = C2 - r.s.c;
          break;
        case 2:
          hdr[C2] = cols[C2];
          break;
        case 3:
          hdr[C2] = o2.header[C2 - r.s.c];
          break;
        default:
          if (val == null)
            val = { w: "__EMPTY", t: "s" };
          vv = v2 = format_cell(val, null, o2);
          counter = header_cnt[v2] || 0;
          if (!counter)
            header_cnt[v2] = 1;
          else {
            do {
              vv = v2 + "_" + counter++;
            } while (header_cnt[vv]);
            header_cnt[v2] = counter;
            header_cnt[vv] = 1;
          }
          hdr[C2] = vv;
      }
    }
    for (R2 = r.s.r + offset; R2 <= r.e.r; ++R2) {
      if ((rowinfo[R2] || {}).hidden)
        continue;
      var row = make_json_row(sheet, r, R2, cols, header, hdr, dense, o2);
      if (row.isempty === false || (header === 1 ? o2.blankrows !== false : !!o2.blankrows))
        out[outi++] = row.row;
    }
    out.length = outi;
    return out;
  }
  var qreg = /"/g;
  function make_csv_row(sheet, r, R2, cols, fs, rs, FS, o2) {
    var isempty = true;
    var row = [], txt = "", rr = encode_row(R2);
    for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
      if (!cols[C2])
        continue;
      var val = o2.dense ? (sheet[R2] || [])[C2] : sheet[cols[C2] + rr];
      if (val == null)
        txt = "";
      else if (val.v != null) {
        isempty = false;
        txt = "" + (o2.rawNumbers && val.t == "n" ? val.v : format_cell(val, null, o2));
        for (var i = 0, cc = 0; i !== txt.length; ++i)
          if ((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o2.forceQuotes) {
            txt = '"' + txt.replace(qreg, '""') + '"';
            break;
          }
        if (txt == "ID")
          txt = '"ID"';
      } else if (val.f != null && !val.F) {
        isempty = false;
        txt = "=" + val.f;
        if (txt.indexOf(",") >= 0)
          txt = '"' + txt.replace(qreg, '""') + '"';
      } else
        txt = "";
      row.push(txt);
    }
    if (o2.blankrows === false && isempty)
      return null;
    return row.join(FS);
  }
  function sheet_to_csv(sheet, opts) {
    var out = [];
    var o2 = opts == null ? {} : opts;
    if (sheet == null || sheet["!ref"] == null)
      return "";
    var r = safe_decode_range(sheet["!ref"]);
    var FS = o2.FS !== void 0 ? o2.FS : ",", fs = FS.charCodeAt(0);
    var RS = o2.RS !== void 0 ? o2.RS : "\n", rs = RS.charCodeAt(0);
    var endregex = new RegExp((FS == "|" ? "\\|" : FS) + "+$");
    var row = "", cols = [];
    o2.dense = Array.isArray(sheet);
    var colinfo = o2.skipHidden && sheet["!cols"] || [];
    var rowinfo = o2.skipHidden && sheet["!rows"] || [];
    for (var C2 = r.s.c; C2 <= r.e.c; ++C2)
      if (!(colinfo[C2] || {}).hidden)
        cols[C2] = encode_col(C2);
    var w2 = 0;
    for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
      if ((rowinfo[R2] || {}).hidden)
        continue;
      row = make_csv_row(sheet, r, R2, cols, fs, rs, FS, o2);
      if (row == null) {
        continue;
      }
      if (o2.strip)
        row = row.replace(endregex, "");
      if (row || o2.blankrows !== false)
        out.push((w2++ ? RS : "") + row);
    }
    delete o2.dense;
    return out.join("");
  }
  function sheet_to_txt(sheet, opts) {
    if (!opts)
      opts = {};
    opts.FS = "	";
    opts.RS = "\n";
    var s2 = sheet_to_csv(sheet, opts);
    return s2;
  }
  function sheet_to_formulae(sheet) {
    var y = "", x2, val = "";
    if (sheet == null || sheet["!ref"] == null)
      return [];
    var r = safe_decode_range(sheet["!ref"]), rr = "", cols = [], C2;
    var cmds = [];
    var dense = Array.isArray(sheet);
    for (C2 = r.s.c; C2 <= r.e.c; ++C2)
      cols[C2] = encode_col(C2);
    for (var R2 = r.s.r; R2 <= r.e.r; ++R2) {
      rr = encode_row(R2);
      for (C2 = r.s.c; C2 <= r.e.c; ++C2) {
        y = cols[C2] + rr;
        x2 = dense ? (sheet[R2] || [])[C2] : sheet[y];
        val = "";
        if (x2 === void 0)
          continue;
        else if (x2.F != null) {
          y = x2.F;
          if (!x2.f)
            continue;
          val = x2.f;
          if (y.indexOf(":") == -1)
            y = y + ":" + y;
        }
        if (x2.f != null)
          val = x2.f;
        else if (x2.t == "z")
          continue;
        else if (x2.t == "n" && x2.v != null)
          val = "" + x2.v;
        else if (x2.t == "b")
          val = x2.v ? "TRUE" : "FALSE";
        else if (x2.w !== void 0)
          val = "'" + x2.w;
        else if (x2.v === void 0)
          continue;
        else if (x2.t == "s")
          val = "'" + x2.v;
        else
          val = "" + x2.v;
        cmds[cmds.length] = y + "=" + val;
      }
    }
    return cmds;
  }
  function sheet_add_json(_ws, js, opts) {
    var o2 = opts || {};
    var offset = +!o2.skipHeader;
    var ws = _ws || {};
    var _R = 0, _C = 0;
    if (ws && o2.origin != null) {
      if (typeof o2.origin == "number")
        _R = o2.origin;
      else {
        var _origin = typeof o2.origin == "string" ? decode_cell(o2.origin) : o2.origin;
        _R = _origin.r;
        _C = _origin.c;
      }
    }
    var cell;
    var range = { s: { c: 0, r: 0 }, e: { c: _C, r: _R + js.length - 1 + offset } };
    if (ws["!ref"]) {
      var _range = safe_decode_range(ws["!ref"]);
      range.e.c = Math.max(range.e.c, _range.e.c);
      range.e.r = Math.max(range.e.r, _range.e.r);
      if (_R == -1) {
        _R = _range.e.r + 1;
        range.e.r = _R + js.length - 1 + offset;
      }
    } else {
      if (_R == -1) {
        _R = 0;
        range.e.r = js.length - 1 + offset;
      }
    }
    var hdr = o2.header || [], C2 = 0;
    js.forEach(function(JS, R2) {
      keys$1(JS).forEach(function(k) {
        if ((C2 = hdr.indexOf(k)) == -1)
          hdr[C2 = hdr.length] = k;
        var v2 = JS[k];
        var t = "z";
        var z = "";
        var ref2 = encode_cell({ c: _C + C2, r: _R + R2 + offset });
        cell = ws_get_cell_stub(ws, ref2);
        if (v2 && typeof v2 === "object" && !(v2 instanceof Date)) {
          ws[ref2] = v2;
        } else {
          if (typeof v2 == "number")
            t = "n";
          else if (typeof v2 == "boolean")
            t = "b";
          else if (typeof v2 == "string")
            t = "s";
          else if (v2 instanceof Date) {
            t = "d";
            if (!o2.cellDates) {
              t = "n";
              v2 = datenum(v2);
            }
            z = o2.dateNF || table_fmt[14];
          } else if (v2 === null && o2.nullError) {
            t = "e";
            v2 = 0;
          }
          if (!cell)
            ws[ref2] = cell = { t, v: v2 };
          else {
            cell.t = t;
            cell.v = v2;
            delete cell.w;
            delete cell.R;
            if (z)
              cell.z = z;
          }
          if (z)
            cell.z = z;
        }
      });
    });
    range.e.c = Math.max(range.e.c, _C + hdr.length - 1);
    var __R = encode_row(_R);
    if (offset)
      for (C2 = 0; C2 < hdr.length; ++C2)
        ws[encode_col(C2 + _C) + __R] = { t: "s", v: hdr[C2] };
    ws["!ref"] = encode_range(range);
    return ws;
  }
  function json_to_sheet(js, opts) {
    return sheet_add_json(null, js, opts);
  }
  function ws_get_cell_stub(ws, R2, C2) {
    if (typeof R2 == "string") {
      if (Array.isArray(ws)) {
        var RC = decode_cell(R2);
        if (!ws[RC.r])
          ws[RC.r] = [];
        return ws[RC.r][RC.c] || (ws[RC.r][RC.c] = { t: "z" });
      }
      return ws[R2] || (ws[R2] = { t: "z" });
    }
    if (typeof R2 != "number")
      return ws_get_cell_stub(ws, encode_cell(R2));
    return ws_get_cell_stub(ws, encode_cell({ r: R2, c: C2 || 0 }));
  }
  function wb_sheet_idx(wb, sh) {
    if (typeof sh == "number") {
      if (sh >= 0 && wb.SheetNames.length > sh)
        return sh;
      throw new Error("Cannot find sheet # " + sh);
    } else if (typeof sh == "string") {
      var idx = wb.SheetNames.indexOf(sh);
      if (idx > -1)
        return idx;
      throw new Error("Cannot find sheet name |" + sh + "|");
    } else
      throw new Error("Cannot find sheet |" + sh + "|");
  }
  function book_new() {
    return { SheetNames: [], Sheets: {} };
  }
  function book_append_sheet(wb, ws, name, roll) {
    var i = 1;
    if (!name) {
      for (; i <= 65535; ++i, name = void 0)
        if (wb.SheetNames.indexOf(name = "Sheet" + i) == -1)
          break;
    }
    if (!name || wb.SheetNames.length >= 65535)
      throw new Error("Too many worksheets");
    if (roll && wb.SheetNames.indexOf(name) >= 0) {
      var m2 = name.match(/(^.*?)(\d+)$/);
      i = m2 && +m2[2] || 0;
      var root2 = m2 && m2[1] || name;
      for (++i; i <= 65535; ++i)
        if (wb.SheetNames.indexOf(name = root2 + i) == -1)
          break;
    }
    check_ws_name(name);
    if (wb.SheetNames.indexOf(name) >= 0)
      throw new Error("Worksheet with name |" + name + "| already exists!");
    wb.SheetNames.push(name);
    wb.Sheets[name] = ws;
    return name;
  }
  function book_set_sheet_visibility(wb, sh, vis) {
    if (!wb.Workbook)
      wb.Workbook = {};
    if (!wb.Workbook.Sheets)
      wb.Workbook.Sheets = [];
    var idx = wb_sheet_idx(wb, sh);
    if (!wb.Workbook.Sheets[idx])
      wb.Workbook.Sheets[idx] = {};
    switch (vis) {
      case 0:
      case 1:
      case 2:
        break;
      default:
        throw new Error("Bad sheet visibility setting " + vis);
    }
    wb.Workbook.Sheets[idx].Hidden = vis;
  }
  function cell_set_number_format(cell, fmt) {
    cell.z = fmt;
    return cell;
  }
  function cell_set_hyperlink(cell, target, tooltip) {
    if (!target) {
      delete cell.l;
    } else {
      cell.l = { Target: target };
      if (tooltip)
        cell.l.Tooltip = tooltip;
    }
    return cell;
  }
  function cell_set_internal_link(cell, range, tooltip) {
    return cell_set_hyperlink(cell, "#" + range, tooltip);
  }
  function cell_add_comment(cell, text, author) {
    if (!cell.c)
      cell.c = [];
    cell.c.push({ t: text, a: author || "SheetJS" });
  }
  function sheet_set_array_formula(ws, range, formula, dynamic) {
    var rng = typeof range != "string" ? range : safe_decode_range(range);
    var rngstr = typeof range == "string" ? range : encode_range(range);
    for (var R2 = rng.s.r; R2 <= rng.e.r; ++R2)
      for (var C2 = rng.s.c; C2 <= rng.e.c; ++C2) {
        var cell = ws_get_cell_stub(ws, R2, C2);
        cell.t = "n";
        cell.F = rngstr;
        delete cell.v;
        if (R2 == rng.s.r && C2 == rng.s.c) {
          cell.f = formula;
          if (dynamic)
            cell.D = true;
        }
      }
    return ws;
  }
  var utils = {
    encode_col,
    encode_row,
    encode_cell,
    encode_range,
    decode_col,
    decode_row,
    split_cell,
    decode_cell,
    decode_range,
    format_cell,
    sheet_add_aoa,
    sheet_add_json,
    sheet_add_dom,
    aoa_to_sheet,
    json_to_sheet,
    table_to_sheet: parse_dom_table,
    table_to_book,
    sheet_to_csv,
    sheet_to_txt,
    sheet_to_json,
    sheet_to_html,
    sheet_to_formulae,
    sheet_to_row_object_array: sheet_to_json,
    sheet_get_cell: ws_get_cell_stub,
    book_new,
    book_append_sheet,
    book_set_sheet_visibility,
    cell_set_number_format,
    cell_set_hyperlink,
    cell_set_internal_link,
    cell_add_comment,
    sheet_set_array_formula,
    consts: {
      SHEET_VISIBLE: 0,
      SHEET_HIDDEN: 1,
      SHEET_VERY_HIDDEN: 2
    }
  };
  function getStatus(id) {
    let encodeId = id.replace(/\//g, "%2F").replace(/ /g, "+");
    const url = `http://www.csres.com/s.jsp?keyword=${encodeId}&submit12=%B1%EA%D7%BC%CB%D1%CB%F7&xx=on&wss=on&zf=on&fz=on&pageSize=25&pageNum=1&SortIndex=1&WayIndex=0&nowUrl=`;
    return fetch(url, {
      "headers": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
        "cache-control": "max-age=0",
        "upgrade-insecure-requests": "1"
      },
      "referrer": url,
      "referrerPolicy": "strict-origin-when-cross-origin",
      "body": null,
      "method": "GET",
      "mode": "cors",
      "credentials": "include"
    }).then((res) => res.arrayBuffer()).then((res) => new TextDecoder("gbk").decode(res)).then((text) => {
      const div2 = document.createElement("div");
      div2.style.display = "none";
      const bodyStart = text.indexOf("<body");
      const bodyEnd = text.indexOf("</body>") + 7;
      const bodyText = text.substring(bodyStart, bodyEnd + 7);
      div2.insertAdjacentHTML("beforeend", bodyText);
      document.body.insertAdjacentHTML("beforeend", bodyText);
      const result = div2.querySelector(".heng tr:nth-child(2) td:last-child").textContent;
      div2.remove();
      return {
        status: 1,
        result
      };
    }).catch((err) => {
      console.log(err);
      return {
        status: 0,
        result: id
      };
    });
  }
  var Actions_vue_vue_type_style_index_0_scoped_true_lang = "";
  var _export_sfc$1 = (sfc, props) => {
    const target = sfc.__vccOpts || sfc;
    for (const [key, val] of props) {
      target[key] = val;
    }
    return target;
  };
  const _hoisted_1$f = { class: "actions" };
  const _hoisted_2$c = { class: "page" };
  const _hoisted_3$5 = /* @__PURE__ */ Vue.createTextVNode(" \u4ECE\u7B2C");
  const _hoisted_4$2 = /* @__PURE__ */ Vue.createTextVNode("\u6761\u5F00\u59CB\uFF0C\u68C0\u67E5");
  const _hoisted_5$2 = /* @__PURE__ */ Vue.createTextVNode("\u6761\u6570\u636E ");
  const _hoisted_6 = /* @__PURE__ */ Vue.createTextVNode(" \u68C0\u67E5\u66F4\u65B0 ");
  const _hoisted_7 = { key: 0 };
  const _hoisted_8 = /* @__PURE__ */ Vue.createTextVNode(" \u4E0B\u8F7D\u66F4\u65B0\u540E\u7684\u6587\u6863 ");
  const _sfc_main$u = {
    props: {
      data: Object,
      onSuccessChecked: Function,
      onExportFile: Function
    },
    setup(__props) {
      const props = __props;
      const percentage = Vue.ref(0);
      const percentageText = Vue.ref("");
      const isFetching = Vue.ref(false);
      const start = Vue.ref(1);
      const size2 = Vue.ref(200);
      const checkItemStatus = (id) => {
        return new Promise((resolve) => {
          setTimeout(() => {
            getStatus(id).then((res) => resolve(res));
          }, 500);
        });
      };
      const checkUpdate = async () => {
        if (isFetching.value) {
          return;
        }
        isFetching.value = true;
        const results = {};
        const fails = [];
        const checkItems = props.data.filter((_2, index) => index + 1 >= start.value && index + 1 < start.value + size2.value);
        console.log(checkItems.map((item) => item["\u6807\u51C6\u4EE3\u53F7"]).join(","));
        let current = 0;
        percentageText.value = "";
        for (const item of checkItems) {
          current += 1;
          if (item["\u5907\u6CE8"] || (item["\u6807\u51C6\u4EE3\u53F7"] || "").length > 2) {
            continue;
          }
          const { status, result } = await checkItemStatus(item["\u6807\u51C6\u4EE3\u53F7"]);
          if (status) {
            if (result !== item["\u5907\u6CE8"] && result !== "\u73B0\u884C") {
              results[item.index] = result;
            }
          } else {
            fails.push(result);
          }
          percentage.value = Math.ceil(current * 100 / checkItems.length);
          percentageText.value = `${current}/${checkItems.length}`;
        }
        if (props.onSuccessChecked) {
          props.onSuccessChecked(results, fails);
        }
        isFetching.value = false;
      };
      return (_ctx, _cache) => {
        const _component_el_progress = Vue.resolveComponent("el-progress");
        const _component_el_input_number = Vue.resolveComponent("el-input-number");
        const _component_el_button = Vue.resolveComponent("el-button");
        return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1$f, [
          isFetching.value ? (Vue.openBlock(), Vue.createBlock(_component_el_progress, {
            key: 0,
            "text-inside": false,
            "stroke-width": 4,
            percentage: percentage.value
          }, null, 8, ["percentage"])) : Vue.createCommentVNode("v-if", true),
          Vue.createElementVNode("span", _hoisted_2$c, [
            _hoisted_3$5,
            Vue.createVNode(_component_el_input_number, {
              modelValue: start.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => start.value = $event),
              min: 1,
              max: props.data.length
            }, null, 8, ["modelValue", "max"]),
            _hoisted_4$2,
            Vue.createVNode(_component_el_input_number, {
              modelValue: size2.value,
              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => size2.value = $event),
              min: 1,
              max: 300
            }, null, 8, ["modelValue"]),
            _hoisted_5$2
          ]),
          Vue.createVNode(_component_el_button, {
            type: "primary",
            primary: "",
            onClick: checkUpdate
          }, {
            default: Vue.withCtx(() => [
              _hoisted_6,
              percentageText.value ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_7, ", \u8FDB\u5EA6" + Vue.toDisplayString(percentageText.value), 1)) : Vue.createCommentVNode("v-if", true)
            ]),
            _: 1
          }),
          Vue.createVNode(_component_el_button, {
            type: "primary",
            primary: "",
            onClick: props.onExportFile
          }, {
            default: Vue.withCtx(() => [
              _hoisted_8
            ]),
            _: 1
          }, 8, ["onClick"])
        ]);
      };
    }
  };
  var Actions = /* @__PURE__ */ _export_sfc$1(_sfc_main$u, [["__scopeId", "data-v-15629706"]]);
  var Upload_vue_vue_type_style_index_0_scoped_true_lang = "";
  const _sfc_main$t = {
    props: {
      onSuccess: Function
    },
    data() {
      return {
        loading: false,
        excelData: {
          header: null,
          results: null
        },
        fileList: [],
        uploader: null
      };
    },
    methods: {
      handleChangeFile(file) {
        console.log("%c \u{1F680}  [file] -> ", "font-size:13px; background:#42b883; color:#fff;", file);
        this.readerData(file.raw);
      },
      handleExceed(files) {
        console.log(this.$refs);
        this.$refs.uploader.clearFiles();
        const file = files[0];
        this.$refs.uploader.handleStart(file);
      },
      generateData({ header, results }) {
        this.excelData.header = header;
        this.excelData.results = results;
        this.onSuccess && this.onSuccess(this.excelData);
      },
      readerData(rawFile) {
        this.loading = true;
        return new Promise((resolve, reject) => {
          const reader = new FileReader();
          reader.onload = (e) => {
            const data = e.target.result;
            const workbook = readSync(data, { type: "array" });
            const firstSheetName = workbook.SheetNames[0];
            const worksheet = workbook.Sheets[firstSheetName];
            const header = this.getHeaderRow(worksheet);
            const results = utils.sheet_to_json(worksheet, { raw: false });
            this.generateData({ header, results });
            this.loading = false;
            resolve();
          };
          reader.readAsArrayBuffer(rawFile);
        });
      },
      getHeaderRow(sheet) {
        const headers = [];
        const range = utils.decode_range(sheet["!ref"]);
        let C2;
        const R2 = range.s.r;
        for (C2 = range.s.c; C2 <= range.e.c; ++C2) {
          const cell = sheet[utils.encode_cell({ c: C2, r: R2 })];
          let hdr = "UNKNOWN " + C2;
          if (cell && cell.t)
            hdr = utils.format_cell(cell);
          headers.push(hdr);
        }
        return headers;
      },
      isExcel(file) {
        return /\.(xlsx|xls|csv)$/.test(file.name);
      }
    }
  };
  const _withScopeId = (n) => (Vue.pushScopeId("data-v-44fc689e"), n = n(), Vue.popScopeId(), n);
  const _hoisted_1$e = { class: "uploader-wrapper" };
  const _hoisted_2$b = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ Vue.createElementVNode("div", { class: "el-upload__text" }, [
    /* @__PURE__ */ Vue.createTextVNode(" \u62D6\u52A8\u89C4\u8303\u6587\u4EF6\u5230\u8FD9\u91CC\u6216 "),
    /* @__PURE__ */ Vue.createElementVNode("em", null, "\u70B9\u51FB\u9009\u62E9\u6587\u4EF6")
  ], -1));
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
    const _component_el_upload = Vue.resolveComponent("el-upload");
    return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1$e, [
      Vue.createVNode(_component_el_upload, {
        ref: "uploader",
        class: "upload-demo",
        drag: "",
        limit: 1,
        "file-list": $data.fileList,
        "onUpdate:file-list": _cache[0] || (_cache[0] = ($event) => $data.fileList = $event),
        "on-change": $options.handleChangeFile,
        "on-exceed": $options.handleExceed,
        "auto-upload": false
      }, {
        default: Vue.withCtx(() => [
          _hoisted_2$b
        ]),
        _: 1
      }, 8, ["file-list", "on-change", "on-exceed"])
    ]);
  }
  var Uploader = /* @__PURE__ */ _export_sfc$1(_sfc_main$t, [["render", _sfc_render$3], ["__scopeId", "data-v-44fc689e"]]);
  var Table_vue_vue_type_style_index_0_lang = "";
  const _hoisted_1$d = { class: "table-wrapper" };
  const _sfc_main$s = {
    props: {
      tableData: Object
    },
    setup(__props) {
      const props = __props;
      const tableRowClassName = ({
        row,
        rowIndex
      }) => {
        return row.changed ? "warning-row" : "";
      };
      const columns = [
        "\u5E8F\u53F7",
        "\u6807\u51C6\u4EE3\u53F7",
        "\u6807\u51C6\u540D\u79F0",
        "\u53D7\u63A7\u7F16\u53F7",
        "\u53D1\u5E03\u65E5\u671F",
        "\u5B9E\u65BD\u65E5\u671F",
        "\u5907\u6CE8"
      ];
      const width = [60, 160, 0, 160, 120, 120, 60];
      return (_ctx, _cache) => {
        const _component_el_table_column = Vue.resolveComponent("el-table-column");
        const _component_el_table = Vue.resolveComponent("el-table");
        return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1$d, [
          Vue.createVNode(_component_el_table, {
            data: props.tableData.data,
            style: { "width": "100%" },
            border: "",
            "row-class-name": tableRowClassName
          }, {
            default: Vue.withCtx(() => [
              (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(columns, (column, idx) => {
                return Vue.createVNode(_component_el_table_column, {
                  key: column,
                  prop: column,
                  label: column,
                  width: width[idx]
                }, null, 8, ["prop", "label", "width"]);
              }), 64))
            ]),
            _: 1
          }, 8, ["data"])
        ]);
      };
    }
  };
  var App_vue_vue_type_style_index_0_scoped_true_lang = "";
  const _hoisted_1$c = { class: "app-inner" };
  const _hoisted_2$a = { class: "wrapper-inner" };
  const _sfc_main$r = {
    setup(__props) {
      const tableData = Vue.reactive({
        columns: [],
        data: []
      });
      const success = Vue.ref("");
      const error = Vue.ref("");
      const visible = Vue.ref(false);
      const handleUploadSuccess = (data) => {
        tableData.columns = data.header;
        data.results.forEach((item, index) => item.index = index);
        tableData.data = data.results;
        console.log("%c \u{1F680}  [tableData] -> ", "font-size:13px; background:#42b883; color:#fff;", tableData);
      };
      const handleSuccessChecked = (changedData, fails) => {
        console.log("%c \u{1F680}  [changedData] -> ", "font-size:13px; background:#42b883; color:#fff;", changedData);
        let changedCount = 0;
        Object.keys(changedData).forEach((item) => {
          console.log("%c \u{1F680}  [item] -> ", "font-size:13px; background:#42b883; color:#fff;", item);
          tableData.data[item]["\u5907\u6CE8"] = changedData[item];
          tableData.data[item].changed = 1;
          changedCount++;
        });
        success.value = `\u68C0\u67E5\u66F4\u65B0\u5B8C\u6210\uFF0C\u5171\u6709${changedCount}\u6761\u6570\u636E\u6539\u53D8\uFF0C\u66F4\u65B0\u7684\u6570\u636E\u662F\u9EC4\u8272\u80CC\u666F`;
        if (fails && fails.length > 0) {
          error.value = `\u4EE5\u4E0B${fails.length}\u6761\u6570\u636E\u68C0\u67E5\u66F4\u65B0\u5931\u8D25: ${fails.join(", ")}`;
        }
      };
      const handleExportFile = () => {
        const data = tableData.data.map((item) => __spreadValues({}, item));
        data.forEach((item) => {
          delete item.changed;
          delete item.index;
        });
        const ws = utils.json_to_sheet(data);
        ws["!cols"] = [
          { wch: 6 },
          { wch: 20 },
          { wch: 35 },
          { wch: 20 },
          { wch: 12 },
          { wch: 12 },
          { wch: 8 }
        ];
        ws["!rows"] = [{ hpx: 25 }];
        data.forEach(() => {
          ws["!rows"].push({ hpx: 25 });
        });
        for (const key in ws) {
          if (key.startsWith("!")) {
            continue;
          }
          console.log("%c \u{1F680}  [key] -> ", "font-size:13px; background:#42b883; color:#fff;", key);
          ws[key].s = {
            border: {
              bottom: {
                style: "thin",
                color: "000000"
              },
              left: {
                style: "thin",
                color: "000000"
              },
              right: {
                style: "thin",
                color: "000000"
              },
              top: {
                style: "thin",
                color: "000000"
              }
            },
            alignment: {
              horizontal: "center",
              vertical: "center",
              wrapText: 1,
              indent: 0
            }
          };
          if (key.replace(/[A-Z]/ig, "") === "1") {
            console.log("%c \u{1F680}  [keykeykeykeykey] -> ", "font-size:13px; background:#42b883; color:#fff;", key);
            ws[key].s = __spreadProps(__spreadValues({}, ws[key].s), {
              fill: {
                fgColor: { rgb: "EBF1DE" }
              }
            });
          }
        }
        console.log(ws);
        const wb = utils.book_new();
        utils.book_append_sheet(wb, ws, "Sheet1");
        writeFileSync(wb, "\u89C4\u8303.xlsx");
      };
      return (_ctx, _cache) => {
        const _component_el_alert = Vue.resolveComponent("el-alert");
        return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1$c, [
          Vue.createElementVNode("div", {
            class: "open-button",
            onClick: _cache[0] || (_cache[0] = ($event) => visible.value = true)
          }, "\u67E5\u8BE2"),
          Vue.createElementVNode("div", {
            class: Vue.normalizeClass(["wrapper", { show: visible.value }])
          }, [
            Vue.createElementVNode("div", _hoisted_2$a, [
              Vue.createVNode(Uploader, { onSuccess: handleUploadSuccess }),
              Vue.createVNode(Actions, {
                data: Vue.unref(tableData).data,
                onSuccessChecked: handleSuccessChecked,
                onExportFile: handleExportFile
              }, null, 8, ["data"]),
              success.value ? (Vue.openBlock(), Vue.createBlock(_component_el_alert, {
                key: 0,
                title: success.value,
                type: "success"
              }, null, 8, ["title"])) : Vue.createCommentVNode("v-if", true),
              error.value ? (Vue.openBlock(), Vue.createBlock(_component_el_alert, {
                key: 1,
                title: error.value,
                type: "error"
              }, null, 8, ["title"])) : Vue.createCommentVNode("v-if", true),
              Vue.createVNode(_sfc_main$s, { tableData: Vue.unref(tableData) }, null, 8, ["tableData"])
            ]),
            Vue.createElementVNode("div", {
              class: "close-button",
              onClick: _cache[1] || (_cache[1] = ($event) => visible.value = false)
            }, "\u5173\u95ED")
          ], 2)
        ]);
      };
    }
  };
  var App = /* @__PURE__ */ _export_sfc$1(_sfc_main$r, [["__scopeId", "data-v-7ba5bd90"]]);
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
  var freeGlobal$1 = freeGlobal;
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
  var root = freeGlobal$1 || freeSelf || Function("return this")();
  var root$1 = root;
  var Symbol$1 = root$1.Symbol;
  var Symbol$2 = Symbol$1;
  var objectProto$e = Object.prototype;
  var hasOwnProperty$c = objectProto$e.hasOwnProperty;
  var nativeObjectToString$1 = objectProto$e.toString;
  var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
  function getRawTag(value) {
    var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
    try {
      value[symToStringTag$1] = void 0;
      var unmasked = true;
    } catch (e) {
    }
    var result = nativeObjectToString$1.call(value);
    if (unmasked) {
      if (isOwn) {
        value[symToStringTag$1] = tag;
      } else {
        delete value[symToStringTag$1];
      }
    }
    return result;
  }
  var objectProto$d = Object.prototype;
  var nativeObjectToString = objectProto$d.toString;
  function objectToString$1(value) {
    return nativeObjectToString.call(value);
  }
  var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
  var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
  function baseGetTag(value) {
    if (value == null) {
      return value === void 0 ? undefinedTag : nullTag;
    }
    return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString$1(value);
  }
  function isObjectLike(value) {
    return value != null && typeof value == "object";
  }
  var symbolTag$1 = "[object Symbol]";
  function isSymbol$1(value) {
    return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$1;
  }
  function arrayMap(array, iteratee) {
    var index = -1, length = array == null ? 0 : array.length, result = Array(length);
    while (++index < length) {
      result[index] = iteratee(array[index], index, array);
    }
    return result;
  }
  var isArray$1 = Array.isArray;
  var isArray$2 = isArray$1;
  var INFINITY$1 = 1 / 0;
  var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
  function baseToString(value) {
    if (typeof value == "string") {
      return value;
    }
    if (isArray$2(value)) {
      return arrayMap(value, baseToString) + "";
    }
    if (isSymbol$1(value)) {
      return symbolToString ? symbolToString.call(value) : "";
    }
    var result = value + "";
    return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
  }
  var reWhitespace = /\s/;
  function trimmedEndIndex(string) {
    var index = string.length;
    while (index-- && reWhitespace.test(string.charAt(index))) {
    }
    return index;
  }
  var reTrimStart = /^\s+/;
  function baseTrim(string) {
    return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
  }
  function isObject$1(value) {
    var type = typeof value;
    return value != null && (type == "object" || type == "function");
  }
  var NAN = 0 / 0;
  var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  var reIsBinary = /^0b[01]+$/i;
  var reIsOctal = /^0o[0-7]+$/i;
  var freeParseInt = parseInt;
  function toNumber(value) {
    if (typeof value == "number") {
      return value;
    }
    if (isSymbol$1(value)) {
      return NAN;
    }
    if (isObject$1(value)) {
      var other = typeof value.valueOf == "function" ? value.valueOf() : value;
      value = isObject$1(other) ? other + "" : other;
    }
    if (typeof value != "string") {
      return value === 0 ? value : +value;
    }
    value = baseTrim(value);
    var isBinary = reIsBinary.test(value);
    return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
  }
  function identity$1(value) {
    return value;
  }
  var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
  function isFunction$2(value) {
    if (!isObject$1(value)) {
      return false;
    }
    var tag = baseGetTag(value);
    return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  }
  var coreJsData = root$1["__core-js_shared__"];
  var coreJsData$1 = coreJsData;
  var maskSrcKey = function() {
    var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || "");
    return uid ? "Symbol(src)_1." + uid : "";
  }();
  function isMasked(func) {
    return !!maskSrcKey && maskSrcKey in func;
  }
  var funcProto$2 = Function.prototype;
  var funcToString$2 = funcProto$2.toString;
  function toSource(func) {
    if (func != null) {
      try {
        return funcToString$2.call(func);
      } catch (e) {
      }
      try {
        return func + "";
      } catch (e) {
      }
    }
    return "";
  }
  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  var reIsHostCtor = /^\[object .+?Constructor\]$/;
  var funcProto$1 = Function.prototype, objectProto$c = Object.prototype;
  var funcToString$1 = funcProto$1.toString;
  var hasOwnProperty$b = objectProto$c.hasOwnProperty;
  var reIsNative = RegExp("^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
  function baseIsNative(value) {
    if (!isObject$1(value) || isMasked(value)) {
      return false;
    }
    var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
    return pattern.test(toSource(value));
  }
  function getValue(object, key) {
    return object == null ? void 0 : object[key];
  }
  function getNative(object, key) {
    var value = getValue(object, key);
    return baseIsNative(value) ? value : void 0;
  }
  var WeakMap$1 = getNative(root$1, "WeakMap");
  var WeakMap$2 = WeakMap$1;
  var objectCreate = Object.create;
  var baseCreate = function() {
    function object() {
    }
    return function(proto) {
      if (!isObject$1(proto)) {
        return {};
      }
      if (objectCreate) {
        return objectCreate(proto);
      }
      object.prototype = proto;
      var result = new object();
      object.prototype = void 0;
      return result;
    };
  }();
  var baseCreate$1 = baseCreate;
  function apply(func, thisArg, args) {
    switch (args.length) {
      case 0:
        return func.call(thisArg);
      case 1:
        return func.call(thisArg, args[0]);
      case 2:
        return func.call(thisArg, args[0], args[1]);
      case 3:
        return func.call(thisArg, args[0], args[1], args[2]);
    }
    return func.apply(thisArg, args);
  }
  function copyArray(source, array) {
    var index = -1, length = source.length;
    array || (array = Array(length));
    while (++index < length) {
      array[index] = source[index];
    }
    return array;
  }
  var HOT_COUNT = 800, HOT_SPAN = 16;
  var nativeNow = Date.now;
  function shortOut(func) {
    var count = 0, lastCalled = 0;
    return function() {
      var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
      lastCalled = stamp;
      if (remaining > 0) {
        if (++count >= HOT_COUNT) {
          return arguments[0];
        }
      } else {
        count = 0;
      }
      return func.apply(void 0, arguments);
    };
  }
  function constant(value) {
    return function() {
      return value;
    };
  }
  var defineProperty = function() {
    try {
      var func = getNative(Object, "defineProperty");
      func({}, "", {});
      return func;
    } catch (e) {
    }
  }();
  var defineProperty$1 = defineProperty;
  var baseSetToString = !defineProperty$1 ? identity$1 : function(func, string) {
    return defineProperty$1(func, "toString", {
      "configurable": true,
      "enumerable": false,
      "value": constant(string),
      "writable": true
    });
  };
  var baseSetToString$1 = baseSetToString;
  var setToString = shortOut(baseSetToString$1);
  var setToString$1 = setToString;
  var MAX_SAFE_INTEGER$1 = 9007199254740991;
  var reIsUint = /^(?:0|[1-9]\d*)$/;
  function isIndex(value, length) {
    var type = typeof value;
    length = length == null ? MAX_SAFE_INTEGER$1 : length;
    return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
  }
  function baseAssignValue(object, key, value) {
    if (key == "__proto__" && defineProperty$1) {
      defineProperty$1(object, key, {
        "configurable": true,
        "enumerable": true,
        "value": value,
        "writable": true
      });
    } else {
      object[key] = value;
    }
  }
  function eq(value, other) {
    return value === other || value !== value && other !== other;
  }
  var objectProto$b = Object.prototype;
  var hasOwnProperty$a = objectProto$b.hasOwnProperty;
  function assignValue(object, key, value) {
    var objValue = object[key];
    if (!(hasOwnProperty$a.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
      baseAssignValue(object, key, value);
    }
  }
  function copyObject(source, props, object, customizer) {
    var isNew = !object;
    object || (object = {});
    var index = -1, length = props.length;
    while (++index < length) {
      var key = props[index];
      var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
      if (newValue === void 0) {
        newValue = source[key];
      }
      if (isNew) {
        baseAssignValue(object, key, newValue);
      } else {
        assignValue(object, key, newValue);
      }
    }
    return object;
  }
  var nativeMax$1 = Math.max;
  function overRest(func, start, transform) {
    start = nativeMax$1(start === void 0 ? func.length - 1 : start, 0);
    return function() {
      var args = arguments, index = -1, length = nativeMax$1(args.length - start, 0), array = Array(length);
      while (++index < length) {
        array[index] = args[start + index];
      }
      index = -1;
      var otherArgs = Array(start + 1);
      while (++index < start) {
        otherArgs[index] = args[index];
      }
      otherArgs[start] = transform(array);
      return apply(func, this, otherArgs);
    };
  }
  function baseRest(func, start) {
    return setToString$1(overRest(func, start, identity$1), func + "");
  }
  var MAX_SAFE_INTEGER = 9007199254740991;
  function isLength(value) {
    return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  }
  function isArrayLike(value) {
    return value != null && isLength(value.length) && !isFunction$2(value);
  }
  function isIterateeCall(value, index, object) {
    if (!isObject$1(object)) {
      return false;
    }
    var type = typeof index;
    if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
      return eq(object[index], value);
    }
    return false;
  }
  function createAssigner(assigner) {
    return baseRest(function(object, sources) {
      var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
      customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
      if (guard && isIterateeCall(sources[0], sources[1], guard)) {
        customizer = length < 3 ? void 0 : customizer;
        length = 1;
      }
      object = Object(object);
      while (++index < length) {
        var source = sources[index];
        if (source) {
          assigner(object, source, index, customizer);
        }
      }
      return object;
    });
  }
  var objectProto$a = Object.prototype;
  function isPrototype(value) {
    var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$a;
    return value === proto;
  }
  function baseTimes(n, iteratee) {
    var index = -1, result = Array(n);
    while (++index < n) {
      result[index] = iteratee(index);
    }
    return result;
  }
  var argsTag$2 = "[object Arguments]";
  function baseIsArguments(value) {
    return isObjectLike(value) && baseGetTag(value) == argsTag$2;
  }
  var objectProto$9 = Object.prototype;
  var hasOwnProperty$9 = objectProto$9.hasOwnProperty;
  var propertyIsEnumerable$1 = objectProto$9.propertyIsEnumerable;
  var isArguments = baseIsArguments(function() {
    return arguments;
  }()) ? baseIsArguments : function(value) {
    return isObjectLike(value) && hasOwnProperty$9.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
  };
  var isArguments$1 = isArguments;
  function stubFalse() {
    return false;
  }
  var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
  var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
  var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
  var Buffer$2 = moduleExports$2 ? root$1.Buffer : void 0;
  var nativeIsBuffer = Buffer$2 ? Buffer$2.isBuffer : void 0;
  var isBuffer = nativeIsBuffer || stubFalse;
  var isBuffer$1 = isBuffer;
  var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", weakMapTag$1 = "[object WeakMap]";
  var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
  var typedArrayTags = {};
  typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
  function baseIsTypedArray(value) {
    return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  }
  function baseUnary(func) {
    return function(value) {
      return func(value);
    };
  }
  var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
  var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
  var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  var freeProcess = moduleExports$1 && freeGlobal$1.process;
  var nodeUtil = function() {
    try {
      var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
      if (types) {
        return types;
      }
      return freeProcess && freeProcess.binding && freeProcess.binding("util");
    } catch (e) {
    }
  }();
  var nodeUtil$1 = nodeUtil;
  var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
  var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  var isTypedArray$1 = isTypedArray;
  var objectProto$8 = Object.prototype;
  var hasOwnProperty$8 = objectProto$8.hasOwnProperty;
  function arrayLikeKeys(value, inherited) {
    var isArr = isArray$2(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
    for (var key in value) {
      if ((inherited || hasOwnProperty$8.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) {
        result.push(key);
      }
    }
    return result;
  }
  function overArg(func, transform) {
    return function(arg) {
      return func(transform(arg));
    };
  }
  var nativeKeys = overArg(Object.keys, Object);
  var nativeKeys$1 = nativeKeys;
  var objectProto$7 = Object.prototype;
  var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
  function baseKeys(object) {
    if (!isPrototype(object)) {
      return nativeKeys$1(object);
    }
    var result = [];
    for (var key in Object(object)) {
      if (hasOwnProperty$7.call(object, key) && key != "constructor") {
        result.push(key);
      }
    }
    return result;
  }
  function keys(object) {
    return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  }
  function nativeKeysIn(object) {
    var result = [];
    if (object != null) {
      for (var key in Object(object)) {
        result.push(key);
      }
    }
    return result;
  }
  var objectProto$6 = Object.prototype;
  var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
  function baseKeysIn(object) {
    if (!isObject$1(object)) {
      return nativeKeysIn(object);
    }
    var isProto = isPrototype(object), result = [];
    for (var key in object) {
      if (!(key == "constructor" && (isProto || !hasOwnProperty$6.call(object, key)))) {
        result.push(key);
      }
    }
    return result;
  }
  function keysIn(object) {
    return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  }
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
  function isKey(value, object) {
    if (isArray$2(value)) {
      return false;
    }
    var type = typeof value;
    if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$1(value)) {
      return true;
    }
    return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  }
  var nativeCreate = getNative(Object, "create");
  var nativeCreate$1 = nativeCreate;
  function hashClear() {
    this.__data__ = nativeCreate$1 ? nativeCreate$1(null) : {};
    this.size = 0;
  }
  function hashDelete(key) {
    var result = this.has(key) && delete this.__data__[key];
    this.size -= result ? 1 : 0;
    return result;
  }
  var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
  var objectProto$5 = Object.prototype;
  var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
  function hashGet(key) {
    var data = this.__data__;
    if (nativeCreate$1) {
      var result = data[key];
      return result === HASH_UNDEFINED$2 ? void 0 : result;
    }
    return hasOwnProperty$5.call(data, key) ? data[key] : void 0;
  }
  var objectProto$4 = Object.prototype;
  var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  function hashHas(key) {
    var data = this.__data__;
    return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$4.call(data, key);
  }
  var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
  function hashSet(key, value) {
    var data = this.__data__;
    this.size += this.has(key) ? 0 : 1;
    data[key] = nativeCreate$1 && value === void 0 ? HASH_UNDEFINED$1 : value;
    return this;
  }
  function Hash(entries) {
    var index = -1, length = entries == null ? 0 : entries.length;
    this.clear();
    while (++index < length) {
      var entry = entries[index];
      this.set(entry[0], entry[1]);
    }
  }
  Hash.prototype.clear = hashClear;
  Hash.prototype["delete"] = hashDelete;
  Hash.prototype.get = hashGet;
  Hash.prototype.has = hashHas;
  Hash.prototype.set = hashSet;
  function listCacheClear() {
    this.__data__ = [];
    this.size = 0;
  }
  function assocIndexOf(array, key) {
    var length = array.length;
    while (length--) {
      if (eq(array[length][0], key)) {
        return length;
      }
    }
    return -1;
  }
  var arrayProto = Array.prototype;
  var splice = arrayProto.splice;
  function listCacheDelete(key) {
    var data = this.__data__, index = assocIndexOf(data, key);
    if (index < 0) {
      return false;
    }
    var lastIndex = data.length - 1;
    if (index == lastIndex) {
      data.pop();
    } else {
      splice.call(data, index, 1);
    }
    --this.size;
    return true;
  }
  function listCacheGet(key) {
    var data = this.__data__, index = assocIndexOf(data, key);
    return index < 0 ? void 0 : data[index][1];
  }
  function listCacheHas(key) {
    return assocIndexOf(this.__data__, key) > -1;
  }
  function listCacheSet(key, value) {
    var data = this.__data__, index = assocIndexOf(data, key);
    if (index < 0) {
      ++this.size;
      data.push([key, value]);
    } else {
      data[index][1] = value;
    }
    return this;
  }
  function ListCache(entries) {
    var index = -1, length = entries == null ? 0 : entries.length;
    this.clear();
    while (++index < length) {
      var entry = entries[index];
      this.set(entry[0], entry[1]);
    }
  }
  ListCache.prototype.clear = listCacheClear;
  ListCache.prototype["delete"] = listCacheDelete;
  ListCache.prototype.get = listCacheGet;
  ListCache.prototype.has = listCacheHas;
  ListCache.prototype.set = listCacheSet;
  var Map$1 = getNative(root$1, "Map");
  var Map$2 = Map$1;
  function mapCacheClear() {
    this.size = 0;
    this.__data__ = {
      "hash": new Hash(),
      "map": new (Map$2 || ListCache)(),
      "string": new Hash()
    };
  }
  function isKeyable(value) {
    var type = typeof value;
    return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
  }
  function getMapData(map2, key) {
    var data = map2.__data__;
    return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
  }
  function mapCacheDelete(key) {
    var result = getMapData(this, key)["delete"](key);
    this.size -= result ? 1 : 0;
    return result;
  }
  function mapCacheGet(key) {
    return getMapData(this, key).get(key);
  }
  function mapCacheHas(key) {
    return getMapData(this, key).has(key);
  }
  function mapCacheSet(key, value) {
    var data = getMapData(this, key), size2 = data.size;
    data.set(key, value);
    this.size += data.size == size2 ? 0 : 1;
    return this;
  }
  function MapCache(entries) {
    var index = -1, length = entries == null ? 0 : entries.length;
    this.clear();
    while (++index < length) {
      var entry = entries[index];
      this.set(entry[0], entry[1]);
    }
  }
  MapCache.prototype.clear = mapCacheClear;
  MapCache.prototype["delete"] = mapCacheDelete;
  MapCache.prototype.get = mapCacheGet;
  MapCache.prototype.has = mapCacheHas;
  MapCache.prototype.set = mapCacheSet;
  var FUNC_ERROR_TEXT$1 = "Expected a function";
  function memoize(func, resolver) {
    if (typeof func != "function" || resolver != null && typeof resolver != "function") {
      throw new TypeError(FUNC_ERROR_TEXT$1);
    }
    var memoized = function() {
      var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
      if (cache.has(key)) {
        return cache.get(key);
      }
      var result = func.apply(this, args);
      memoized.cache = cache.set(key, result) || cache;
      return result;
    };
    memoized.cache = new (memoize.Cache || MapCache)();
    return memoized;
  }
  memoize.Cache = MapCache;
  var MAX_MEMOIZE_SIZE = 500;
  function memoizeCapped(func) {
    var result = memoize(func, function(key) {
      if (cache.size === MAX_MEMOIZE_SIZE) {
        cache.clear();
      }
      return key;
    });
    var cache = result.cache;
    return result;
  }
  var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  var reEscapeChar = /\\(\\)?/g;
  var stringToPath = memoizeCapped(function(string) {
    var result = [];
    if (string.charCodeAt(0) === 46) {
      result.push("");
    }
    string.replace(rePropName, function(match, number, quote, subString) {
      result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
    });
    return result;
  });
  var stringToPath$1 = stringToPath;
  function toString(value) {
    return value == null ? "" : baseToString(value);
  }
  function castPath(value, object) {
    if (isArray$2(value)) {
      return value;
    }
    return isKey(value, object) ? [value] : stringToPath$1(toString(value));
  }
  var INFINITY = 1 / 0;
  function toKey(value) {
    if (typeof value == "string" || isSymbol$1(value)) {
      return value;
    }
    var result = value + "";
    return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  }
  function baseGet(object, path) {
    path = castPath(path, object);
    var index = 0, length = path.length;
    while (object != null && index < length) {
      object = object[toKey(path[index++])];
    }
    return index && index == length ? object : void 0;
  }
  function get$2(object, path, defaultValue) {
    var result = object == null ? void 0 : baseGet(object, path);
    return result === void 0 ? defaultValue : result;
  }
  function arrayPush(array, values) {
    var index = -1, length = values.length, offset = array.length;
    while (++index < length) {
      array[offset + index] = values[index];
    }
    return array;
  }
  var spreadableSymbol = Symbol$2 ? Symbol$2.isConcatSpreadable : void 0;
  function isFlattenable(value) {
    return isArray$2(value) || isArguments$1(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
  }
  function baseFlatten(array, depth, predicate, isStrict, result) {
    var index = -1, length = array.length;
    predicate || (predicate = isFlattenable);
    result || (result = []);
    while (++index < length) {
      var value = array[index];
      if (depth > 0 && predicate(value)) {
        if (depth > 1) {
          baseFlatten(value, depth - 1, predicate, isStrict, result);
        } else {
          arrayPush(result, value);
        }
      } else if (!isStrict) {
        result[result.length] = value;
      }
    }
    return result;
  }
  function flatten(array) {
    var length = array == null ? 0 : array.length;
    return length ? baseFlatten(array, 1) : [];
  }
  function flatRest(func) {
    return setToString$1(overRest(func, void 0, flatten), func + "");
  }
  var getPrototype = overArg(Object.getPrototypeOf, Object);
  var getPrototype$1 = getPrototype;
  var objectTag$2 = "[object Object]";
  var funcProto = Function.prototype, objectProto$3 = Object.prototype;
  var funcToString = funcProto.toString;
  var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  var objectCtorString = funcToString.call(Object);
  function isPlainObject$1(value) {
    if (!isObjectLike(value) || baseGetTag(value) != objectTag$2) {
      return false;
    }
    var proto = getPrototype$1(value);
    if (proto === null) {
      return true;
    }
    var Ctor = hasOwnProperty$3.call(proto, "constructor") && proto.constructor;
    return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
  }
  function stackClear() {
    this.__data__ = new ListCache();
    this.size = 0;
  }
  function stackDelete(key) {
    var data = this.__data__, result = data["delete"](key);
    this.size = data.size;
    return result;
  }
  function stackGet(key) {
    return this.__data__.get(key);
  }
  function stackHas(key) {
    return this.__data__.has(key);
  }
  var LARGE_ARRAY_SIZE = 200;
  function stackSet(key, value) {
    var data = this.__data__;
    if (data instanceof ListCache) {
      var pairs = data.__data__;
      if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
        pairs.push([key, value]);
        this.size = ++data.size;
        return this;
      }
      data = this.__data__ = new MapCache(pairs);
    }
    data.set(key, value);
    this.size = data.size;
    return this;
  }
  function Stack(entries) {
    var data = this.__data__ = new ListCache(entries);
    this.size = data.size;
  }
  Stack.prototype.clear = stackClear;
  Stack.prototype["delete"] = stackDelete;
  Stack.prototype.get = stackGet;
  Stack.prototype.has = stackHas;
  Stack.prototype.set = stackSet;
  var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
  var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
  var moduleExports = freeModule && freeModule.exports === freeExports;
  var Buffer$1 = moduleExports ? root$1.Buffer : void 0, allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : void 0;
  function cloneBuffer(buffer, isDeep) {
    if (isDeep) {
      return buffer.slice();
    }
    var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
    buffer.copy(result);
    return result;
  }
  function arrayFilter(array, predicate) {
    var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
    while (++index < length) {
      var value = array[index];
      if (predicate(value, index, array)) {
        result[resIndex++] = value;
      }
    }
    return result;
  }
  function stubArray() {
    return [];
  }
  var objectProto$2 = Object.prototype;
  var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
  var nativeGetSymbols = Object.getOwnPropertySymbols;
  var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
    if (object == null) {
      return [];
    }
    object = Object(object);
    return arrayFilter(nativeGetSymbols(object), function(symbol) {
      return propertyIsEnumerable.call(object, symbol);
    });
  };
  var getSymbols$1 = getSymbols;
  function baseGetAllKeys(object, keysFunc, symbolsFunc) {
    var result = keysFunc(object);
    return isArray$2(object) ? result : arrayPush(result, symbolsFunc(object));
  }
  function getAllKeys(object) {
    return baseGetAllKeys(object, keys, getSymbols$1);
  }
  var DataView$1 = getNative(root$1, "DataView");
  var DataView$2 = DataView$1;
  var Promise$1 = getNative(root$1, "Promise");
  var Promise$2 = Promise$1;
  var Set$1 = getNative(root$1, "Set");
  var Set$2 = Set$1;
  var mapTag$1 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$1 = "[object Set]", weakMapTag = "[object WeakMap]";
  var dataViewTag$1 = "[object DataView]";
  var dataViewCtorString = toSource(DataView$2), mapCtorString = toSource(Map$2), promiseCtorString = toSource(Promise$2), setCtorString = toSource(Set$2), weakMapCtorString = toSource(WeakMap$2);
  var getTag = baseGetTag;
  if (DataView$2 && getTag(new DataView$2(new ArrayBuffer(1))) != dataViewTag$1 || Map$2 && getTag(new Map$2()) != mapTag$1 || Promise$2 && getTag(Promise$2.resolve()) != promiseTag || Set$2 && getTag(new Set$2()) != setTag$1 || WeakMap$2 && getTag(new WeakMap$2()) != weakMapTag) {
    getTag = function(value) {
      var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
      if (ctorString) {
        switch (ctorString) {
          case dataViewCtorString:
            return dataViewTag$1;
          case mapCtorString:
            return mapTag$1;
          case promiseCtorString:
            return promiseTag;
          case setCtorString:
            return setTag$1;
          case weakMapCtorString:
            return weakMapTag;
        }
      }
      return result;
    };
  }
  var getTag$1 = getTag;
  var Uint8Array$1 = root$1.Uint8Array;
  var Uint8Array$2 = Uint8Array$1;
  function cloneArrayBuffer(arrayBuffer) {
    var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
    new Uint8Array$2(result).set(new Uint8Array$2(arrayBuffer));
    return result;
  }
  function cloneTypedArray(typedArray, isDeep) {
    var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
    return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  }
  function initCloneObject(object) {
    return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate$1(getPrototype$1(object)) : {};
  }
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
  function setCacheAdd(value) {
    this.__data__.set(value, HASH_UNDEFINED);
    return this;
  }
  function setCacheHas(value) {
    return this.__data__.has(value);
  }
  function SetCache(values) {
    var index = -1, length = values == null ? 0 : values.length;
    this.__data__ = new MapCache();
    while (++index < length) {
      this.add(values[index]);
    }
  }
  SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  SetCache.prototype.has = setCacheHas;
  function arraySome(array, predicate) {
    var index = -1, length = array == null ? 0 : array.length;
    while (++index < length) {
      if (predicate(array[index], index, array)) {
        return true;
      }
    }
    return false;
  }
  function cacheHas(cache, key) {
    return cache.has(key);
  }
  var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2;
  function equalArrays(array, other, bitmask, customizer, equalFunc, stack2) {
    var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array.length, othLength = other.length;
    if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
      return false;
    }
    var arrStacked = stack2.get(array);
    var othStacked = stack2.get(other);
    if (arrStacked && othStacked) {
      return arrStacked == other && othStacked == array;
    }
    var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0;
    stack2.set(array, other);
    stack2.set(other, array);
    while (++index < arrLength) {
      var arrValue = array[index], othValue = other[index];
      if (customizer) {
        var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack2) : customizer(arrValue, othValue, index, array, other, stack2);
      }
      if (compared !== void 0) {
        if (compared) {
          continue;
        }
        result = false;
        break;
      }
      if (seen) {
        if (!arraySome(other, function(othValue2, othIndex) {
          if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack2))) {
            return seen.push(othIndex);
          }
        })) {
          result = false;
          break;
        }
      } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack2))) {
        result = false;
        break;
      }
    }
    stack2["delete"](array);
    stack2["delete"](other);
    return result;
  }
  function mapToArray(map2) {
    var index = -1, result = Array(map2.size);
    map2.forEach(function(value, key) {
      result[++index] = [key, value];
    });
    return result;
  }
  function setToArray(set2) {
    var index = -1, result = Array(set2.size);
    set2.forEach(function(value) {
      result[++index] = value;
    });
    return result;
  }
  var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
  var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
  var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
  var symbolProto = Symbol$2 ? Symbol$2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
  function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack2) {
    switch (tag) {
      case dataViewTag:
        if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
          return false;
        }
        object = object.buffer;
        other = other.buffer;
      case arrayBufferTag:
        if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$2(object), new Uint8Array$2(other))) {
          return false;
        }
        return true;
      case boolTag:
      case dateTag:
      case numberTag:
        return eq(+object, +other);
      case errorTag:
        return object.name == other.name && object.message == other.message;
      case regexpTag:
      case stringTag:
        return object == other + "";
      case mapTag:
        var convert = mapToArray;
      case setTag:
        var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
        convert || (convert = setToArray);
        if (object.size != other.size && !isPartial) {
          return false;
        }
        var stacked = stack2.get(object);
        if (stacked) {
          return stacked == other;
        }
        bitmask |= COMPARE_UNORDERED_FLAG$2;
        stack2.set(object, other);
        var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack2);
        stack2["delete"](object);
        return result;
      case symbolTag:
        if (symbolValueOf) {
          return symbolValueOf.call(object) == symbolValueOf.call(other);
        }
    }
    return false;
  }
  var COMPARE_PARTIAL_FLAG$3 = 1;
  var objectProto$1 = Object.prototype;
  var hasOwnProperty$2 = objectProto$1.hasOwnProperty;
  function equalObjects(object, other, bitmask, customizer, equalFunc, stack2) {
    var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
    if (objLength != othLength && !isPartial) {
      return false;
    }
    var index = objLength;
    while (index--) {
      var key = objProps[index];
      if (!(isPartial ? key in other : hasOwnProperty$2.call(other, key))) {
        return false;
      }
    }
    var objStacked = stack2.get(object);
    var othStacked = stack2.get(other);
    if (objStacked && othStacked) {
      return objStacked == other && othStacked == object;
    }
    var result = true;
    stack2.set(object, other);
    stack2.set(other, object);
    var skipCtor = isPartial;
    while (++index < objLength) {
      key = objProps[index];
      var objValue = object[key], othValue = other[key];
      if (customizer) {
        var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack2) : customizer(objValue, othValue, key, object, other, stack2);
      }
      if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack2) : compared)) {
        result = false;
        break;
      }
      skipCtor || (skipCtor = key == "constructor");
    }
    if (result && !skipCtor) {
      var objCtor = object.constructor, othCtor = other.constructor;
      if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
        result = false;
      }
    }
    stack2["delete"](object);
    stack2["delete"](other);
    return result;
  }
  var COMPARE_PARTIAL_FLAG$2 = 1;
  var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
  var objectProto = Object.prototype;
  var hasOwnProperty$1 = objectProto.hasOwnProperty;
  function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack2) {
    var objIsArr = isArray$2(object), othIsArr = isArray$2(other), objTag = objIsArr ? arrayTag : getTag$1(object), othTag = othIsArr ? arrayTag : getTag$1(other);
    objTag = objTag == argsTag ? objectTag : objTag;
    othTag = othTag == argsTag ? objectTag : othTag;
    var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
    if (isSameTag && isBuffer$1(object)) {
      if (!isBuffer$1(other)) {
        return false;
      }
      objIsArr = true;
      objIsObj = false;
    }
    if (isSameTag && !objIsObj) {
      stack2 || (stack2 = new Stack());
      return objIsArr || isTypedArray$1(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack2) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack2);
    }
    if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
      var objIsWrapped = objIsObj && hasOwnProperty$1.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$1.call(other, "__wrapped__");
      if (objIsWrapped || othIsWrapped) {
        var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
        stack2 || (stack2 = new Stack());
        return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack2);
      }
    }
    if (!isSameTag) {
      return false;
    }
    stack2 || (stack2 = new Stack());
    return equalObjects(object, other, bitmask, customizer, equalFunc, stack2);
  }
  function baseIsEqual(value, other, bitmask, customizer, stack2) {
    if (value === other) {
      return true;
    }
    if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
      return value !== value && other !== other;
    }
    return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack2);
  }
  var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
  function baseIsMatch(object, source, matchData, customizer) {
    var index = matchData.length, length = index, noCustomizer = !customizer;
    if (object == null) {
      return !length;
    }
    object = Object(object);
    while (index--) {
      var data = matchData[index];
      if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
        return false;
      }
    }
    while (++index < length) {
      data = matchData[index];
      var key = data[0], objValue = object[key], srcValue = data[1];
      if (noCustomizer && data[2]) {
        if (objValue === void 0 && !(key in object)) {
          return false;
        }
      } else {
        var stack2 = new Stack();
        if (customizer) {
          var result = customizer(objValue, srcValue, key, object, source, stack2);
        }
        if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack2) : result)) {
          return false;
        }
      }
    }
    return true;
  }
  function isStrictComparable(value) {
    return value === value && !isObject$1(value);
  }
  function getMatchData(object) {
    var result = keys(object), length = result.length;
    while (length--) {
      var key = result[length], value = object[key];
      result[length] = [key, value, isStrictComparable(value)];
    }
    return result;
  }
  function matchesStrictComparable(key, srcValue) {
    return function(object) {
      if (object == null) {
        return false;
      }
      return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
    };
  }
  function baseMatches(source) {
    var matchData = getMatchData(source);
    if (matchData.length == 1 && matchData[0][2]) {
      return matchesStrictComparable(matchData[0][0], matchData[0][1]);
    }
    return function(object) {
      return object === source || baseIsMatch(object, source, matchData);
    };
  }
  function baseHasIn(object, key) {
    return object != null && key in Object(object);
  }
  function hasPath(object, path, hasFunc) {
    path = castPath(path, object);
    var index = -1, length = path.length, result = false;
    while (++index < length) {
      var key = toKey(path[index]);
      if (!(result = object != null && hasFunc(object, key))) {
        break;
      }
      object = object[key];
    }
    if (result || ++index != length) {
      return result;
    }
    length = object == null ? 0 : object.length;
    return !!length && isLength(length) && isIndex(key, length) && (isArray$2(object) || isArguments$1(object));
  }
  function hasIn(object, path) {
    return object != null && hasPath(object, path, baseHasIn);
  }
  var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
  function baseMatchesProperty(path, srcValue) {
    if (isKey(path) && isStrictComparable(srcValue)) {
      return matchesStrictComparable(toKey(path), srcValue);
    }
    return function(object) {
      var objValue = get$2(object, path);
      return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
    };
  }
  function baseProperty(key) {
    return function(object) {
      return object == null ? void 0 : object[key];
    };
  }
  function basePropertyDeep(path) {
    return function(object) {
      return baseGet(object, path);
    };
  }
  function property(path) {
    return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  }
  function baseIteratee(value) {
    if (typeof value == "function") {
      return value;
    }
    if (value == null) {
      return identity$1;
    }
    if (typeof value == "object") {
      return isArray$2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
    }
    return property(value);
  }
  function createBaseFor(fromRight) {
    return function(object, iteratee, keysFunc) {
      var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
      while (length--) {
        var key = props[fromRight ? length : ++index];
        if (iteratee(iterable[key], key, iterable) === false) {
          break;
        }
      }
      return object;
    };
  }
  var baseFor = createBaseFor();
  var baseFor$1 = baseFor;
  function baseForOwn(object, iteratee) {
    return object && baseFor$1(object, iteratee, keys);
  }
  function createBaseEach(eachFunc, fromRight) {
    return function(collection, iteratee) {
      if (collection == null) {
        return collection;
      }
      if (!isArrayLike(collection)) {
        return eachFunc(collection, iteratee);
      }
      var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
      while (fromRight ? index-- : ++index < length) {
        if (iteratee(iterable[index], index, iterable) === false) {
          break;
        }
      }
      return collection;
    };
  }
  var baseEach = createBaseEach(baseForOwn);
  var baseEach$1 = baseEach;
  var now = function() {
    return root$1.Date.now();
  };
  var now$1 = now;
  var FUNC_ERROR_TEXT = "Expected a function";
  var nativeMax = Math.max, nativeMin = Math.min;
  function debounce(func, wait, options) {
    var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
    if (typeof func != "function") {
      throw new TypeError(FUNC_ERROR_TEXT);
    }
    wait = toNumber(wait) || 0;
    if (isObject$1(options)) {
      leading = !!options.leading;
      maxing = "maxWait" in options;
      maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
      trailing = "trailing" in options ? !!options.trailing : trailing;
    }
    function invokeFunc(time) {
      var args = lastArgs, thisArg = lastThis;
      lastArgs = lastThis = void 0;
      lastInvokeTime = time;
      result = func.apply(thisArg, args);
      return result;
    }
    function leadingEdge(time) {
      lastInvokeTime = time;
      timerId = setTimeout(timerExpired, wait);
      return leading ? invokeFunc(time) : result;
    }
    function remainingWait(time) {
      var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
      return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
    }
    function shouldInvoke(time) {
      var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
      return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
    }
    function timerExpired() {
      var time = now$1();
      if (shouldInvoke(time)) {
        return trailingEdge(time);
      }
      timerId = setTimeout(timerExpired, remainingWait(time));
    }
    function trailingEdge(time) {
      timerId = void 0;
      if (trailing && lastArgs) {
        return invokeFunc(time);
      }
      lastArgs = lastThis = void 0;
      return result;
    }
    function cancel() {
      if (timerId !== void 0) {
        clearTimeout(timerId);
      }
      lastInvokeTime = 0;
      lastArgs = lastCallTime = lastThis = timerId = void 0;
    }
    function flush() {
      return timerId === void 0 ? result : trailingEdge(now$1());
    }
    function debounced() {
      var time = now$1(), isInvoking = shouldInvoke(time);
      lastArgs = arguments;
      lastThis = this;
      lastCallTime = time;
      if (isInvoking) {
        if (timerId === void 0) {
          return leadingEdge(lastCallTime);
        }
        if (maxing) {
          clearTimeout(timerId);
          timerId = setTimeout(timerExpired, wait);
          return invokeFunc(lastCallTime);
        }
      }
      if (timerId === void 0) {
        timerId = setTimeout(timerExpired, wait);
      }
      return result;
    }
    debounced.cancel = cancel;
    debounced.flush = flush;
    return debounced;
  }
  function assignMergeValue(object, key, value) {
    if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) {
      baseAssignValue(object, key, value);
    }
  }
  function isArrayLikeObject(value) {
    return isObjectLike(value) && isArrayLike(value);
  }
  function safeGet(object, key) {
    if (key === "constructor" && typeof object[key] === "function") {
      return;
    }
    if (key == "__proto__") {
      return;
    }
    return object[key];
  }
  function toPlainObject(value) {
    return copyObject(value, keysIn(value));
  }
  function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack2) {
    var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack2.get(srcValue);
    if (stacked) {
      assignMergeValue(object, key, stacked);
      return;
    }
    var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack2) : void 0;
    var isCommon = newValue === void 0;
    if (isCommon) {
      var isArr = isArray$2(srcValue), isBuff = !isArr && isBuffer$1(srcValue), isTyped = !isArr && !isBuff && isTypedArray$1(srcValue);
      newValue = srcValue;
      if (isArr || isBuff || isTyped) {
        if (isArray$2(objValue)) {
          newValue = objValue;
        } else if (isArrayLikeObject(objValue)) {
          newValue = copyArray(objValue);
        } else if (isBuff) {
          isCommon = false;
          newValue = cloneBuffer(srcValue, true);
        } else if (isTyped) {
          isCommon = false;
          newValue = cloneTypedArray(srcValue, true);
        } else {
          newValue = [];
        }
      } else if (isPlainObject$1(srcValue) || isArguments$1(srcValue)) {
        newValue = objValue;
        if (isArguments$1(objValue)) {
          newValue = toPlainObject(objValue);
        } else if (!isObject$1(objValue) || isFunction$2(objValue)) {
          newValue = initCloneObject(srcValue);
        }
      } else {
        isCommon = false;
      }
    }
    if (isCommon) {
      stack2.set(srcValue, newValue);
      mergeFunc(newValue, srcValue, srcIndex, customizer, stack2);
      stack2["delete"](srcValue);
    }
    assignMergeValue(object, key, newValue);
  }
  function baseMerge(object, source, srcIndex, customizer, stack2) {
    if (object === source) {
      return;
    }
    baseFor$1(source, function(srcValue, key) {
      stack2 || (stack2 = new Stack());
      if (isObject$1(srcValue)) {
        baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack2);
      } else {
        var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack2) : void 0;
        if (newValue === void 0) {
          newValue = srcValue;
        }
        assignMergeValue(object, key, newValue);
      }
    }, keysIn);
  }
  function baseMap(collection, iteratee) {
    var index = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
    baseEach$1(collection, function(value, key, collection2) {
      result[++index] = iteratee(value, key, collection2);
    });
    return result;
  }
  function map$1(collection, iteratee) {
    var func = isArray$2(collection) ? arrayMap : baseMap;
    return func(collection, baseIteratee(iteratee));
  }
  function flatMap(collection, iteratee) {
    return baseFlatten(map$1(collection, iteratee), 1);
  }
  function fromPairs(pairs) {
    var index = -1, length = pairs == null ? 0 : pairs.length, result = {};
    while (++index < length) {
      var pair = pairs[index];
      result[pair[0]] = pair[1];
    }
    return result;
  }
  function isEqual(value, other) {
    return baseIsEqual(value, other);
  }
  function isNil(value) {
    return value == null;
  }
  var merge = createAssigner(function(object, source, srcIndex) {
    baseMerge(object, source, srcIndex);
  });
  var merge$1 = merge;
  function baseSet(object, path, value, customizer) {
    if (!isObject$1(object)) {
      return object;
    }
    path = castPath(path, object);
    var index = -1, length = path.length, lastIndex = length - 1, nested = object;
    while (nested != null && ++index < length) {
      var key = toKey(path[index]), newValue = value;
      if (key === "__proto__" || key === "constructor" || key === "prototype") {
        return object;
      }
      if (index != lastIndex) {
        var objValue = nested[key];
        newValue = customizer ? customizer(objValue, key, nested) : void 0;
        if (newValue === void 0) {
          newValue = isObject$1(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
        }
      }
      assignValue(nested, key, newValue);
      nested = nested[key];
    }
    return object;
  }
  function basePickBy(object, paths, predicate) {
    var index = -1, length = paths.length, result = {};
    while (++index < length) {
      var path = paths[index], value = baseGet(object, path);
      if (predicate(value, path)) {
        baseSet(result, castPath(path, object), value);
      }
    }
    return result;
  }
  function basePick(object, paths) {
    return basePickBy(object, paths, function(value, path) {
      return hasIn(object, path);
    });
  }
  var pick = flatRest(function(object, paths) {
    return object == null ? {} : basePick(object, paths);
  });
  var pick$1 = pick;
  function set$2(object, path, value) {
    return object == null ? object : baseSet(object, path, value);
  }
  const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
    const handleEvent = (event) => {
      const shouldPrevent = theirsHandler == null ? void 0 : theirsHandler(event);
      if (checkForDefaultPrevented === false || !shouldPrevent) {
        return oursHandler == null ? void 0 : oursHandler(event);
      }
    };
    return handleEvent;
  };
  function makeMap(str, expectsLowerCase) {
    const map2 = /* @__PURE__ */ Object.create(null);
    const list = str.split(",");
    for (let i = 0; i < list.length; i++) {
      map2[list[i]] = true;
    }
    return expectsLowerCase ? (val) => !!map2[val.toLowerCase()] : (val) => !!map2[val];
  }
  const EMPTY_OBJ = Object.freeze({});
  Object.freeze([]);
  const NOOP = () => {
  };
  const extend = Object.assign;
  const remove = (arr, el) => {
    const i = arr.indexOf(el);
    if (i > -1) {
      arr.splice(i, 1);
    }
  };
  const hasOwnProperty = Object.prototype.hasOwnProperty;
  const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  const isArray = Array.isArray;
  const isMap = (val) => toTypeString(val) === "[object Map]";
  const isSet = (val) => toTypeString(val) === "[object Set]";
  const isFunction$1 = (val) => typeof val === "function";
  const isString$1 = (val) => typeof val === "string";
  const isSymbol = (val) => typeof val === "symbol";
  const isObject = (val) => val !== null && typeof val === "object";
  const isPromise = (val) => {
    return isObject(val) && isFunction$1(val.then) && isFunction$1(val.catch);
  };
  const objectToString = Object.prototype.toString;
  const toTypeString = (value) => objectToString.call(value);
  const toRawType = (value) => {
    return toTypeString(value).slice(8, -1);
  };
  const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  const isIntegerKey = (key) => isString$1(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  const cacheStringFunction = (fn2) => {
    const cache = /* @__PURE__ */ Object.create(null);
    return (str) => {
      const hit = cache[str];
      return hit || (cache[str] = fn2(str));
    };
  };
  const camelizeRE = /-(\w)/g;
  const camelize = cacheStringFunction((str) => {
    return str.replace(camelizeRE, (_2, c2) => c2 ? c2.toUpperCase() : "");
  });
  const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  const def = (obj, key, value) => {
    Object.defineProperty(obj, key, {
      configurable: true,
      enumerable: false,
      value
    });
  };
  let _globalThis;
  const getGlobalThis = () => {
    return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  };
  function warn$1(msg, ...args) {
    console.warn(`[Vue warn] ${msg}`, ...args);
  }
  let activeEffectScope;
  function recordEffectScope(effect, scope = activeEffectScope) {
    if (scope && scope.active) {
      scope.effects.push(effect);
    }
  }
  function getCurrentScope() {
    return activeEffectScope;
  }
  function onScopeDispose(fn2) {
    {
      warn$1(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
    }
  }
  const createDep = (effects) => {
    const dep = new Set(effects);
    dep.w = 0;
    dep.n = 0;
    return dep;
  };
  const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  const initDepMarkers = ({ deps }) => {
    if (deps.length) {
      for (let i = 0; i < deps.length; i++) {
        deps[i].w |= trackOpBit;
      }
    }
  };
  const finalizeDepMarkers = (effect) => {
    const { deps } = effect;
    if (deps.length) {
      let ptr = 0;
      for (let i = 0; i < deps.length; i++) {
        const dep = deps[i];
        if (wasTracked(dep) && !newTracked(dep)) {
          dep.delete(effect);
        } else {
          deps[ptr++] = dep;
        }
        dep.w &= ~trackOpBit;
        dep.n &= ~trackOpBit;
      }
      deps.length = ptr;
    }
  };
  const targetMap = /* @__PURE__ */ new WeakMap();
  let effectTrackDepth = 0;
  let trackOpBit = 1;
  const maxMarkerBits = 30;
  let activeEffect;
  const ITERATE_KEY = Symbol("iterate");
  const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
  class ReactiveEffect {
    constructor(fn2, scheduler = null, scope) {
      this.fn = fn2;
      this.scheduler = scheduler;
      this.active = true;
      this.deps = [];
      this.parent = void 0;
      recordEffectScope(this, scope);
    }
    run() {
      if (!this.active) {
        return this.fn();
      }
      let parent = activeEffect;
      let lastShouldTrack = shouldTrack;
      while (parent) {
        if (parent === this) {
          return;
        }
        parent = parent.parent;
      }
      try {
        this.parent = activeEffect;
        activeEffect = this;
        shouldTrack = true;
        trackOpBit = 1 << ++effectTrackDepth;
        if (effectTrackDepth <= maxMarkerBits) {
          initDepMarkers(this);
        } else {
          cleanupEffect(this);
        }
        return this.fn();
      } finally {
        if (effectTrackDepth <= maxMarkerBits) {
          finalizeDepMarkers(this);
        }
        trackOpBit = 1 << --effectTrackDepth;
        activeEffect = this.parent;
        shouldTrack = lastShouldTrack;
        this.parent = void 0;
      }
    }
    stop() {
      if (this.active) {
        cleanupEffect(this);
        if (this.onStop) {
          this.onStop();
        }
        this.active = false;
      }
    }
  }
  function cleanupEffect(effect) {
    const { deps } = effect;
    if (deps.length) {
      for (let i = 0; i < deps.length; i++) {
        deps[i].delete(effect);
      }
      deps.length = 0;
    }
  }
  let shouldTrack = true;
  const trackStack = [];
  function pauseTracking() {
    trackStack.push(shouldTrack);
    shouldTrack = false;
  }
  function resetTracking() {
    const last = trackStack.pop();
    shouldTrack = last === void 0 ? true : last;
  }
  function track(target, type, key) {
    if (shouldTrack && activeEffect) {
      let depsMap = targetMap.get(target);
      if (!depsMap) {
        targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
      }
      let dep = depsMap.get(key);
      if (!dep) {
        depsMap.set(key, dep = createDep());
      }
      const eventInfo = { effect: activeEffect, target, type, key };
      trackEffects(dep, eventInfo);
    }
  }
  function trackEffects(dep, debuggerEventExtraInfo) {
    let shouldTrack2 = false;
    if (effectTrackDepth <= maxMarkerBits) {
      if (!newTracked(dep)) {
        dep.n |= trackOpBit;
        shouldTrack2 = !wasTracked(dep);
      }
    } else {
      shouldTrack2 = !dep.has(activeEffect);
    }
    if (shouldTrack2) {
      dep.add(activeEffect);
      activeEffect.deps.push(dep);
      if (activeEffect.onTrack) {
        activeEffect.onTrack(Object.assign({
          effect: activeEffect
        }, debuggerEventExtraInfo));
      }
    }
  }
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
    const depsMap = targetMap.get(target);
    if (!depsMap) {
      return;
    }
    let deps = [];
    if (type === "clear") {
      deps = [...depsMap.values()];
    } else if (key === "length" && isArray(target)) {
      depsMap.forEach((dep, key2) => {
        if (key2 === "length" || key2 >= newValue) {
          deps.push(dep);
        }
      });
    } else {
      if (key !== void 0) {
        deps.push(depsMap.get(key));
      }
      switch (type) {
        case "add":
          if (!isArray(target)) {
            deps.push(depsMap.get(ITERATE_KEY));
            if (isMap(target)) {
              deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
            }
          } else if (isIntegerKey(key)) {
            deps.push(depsMap.get("length"));
          }
          break;
        case "delete":
          if (!isArray(target)) {
            deps.push(depsMap.get(ITERATE_KEY));
            if (isMap(target)) {
              deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
            }
          }
          break;
        case "set":
          if (isMap(target)) {
            deps.push(depsMap.get(ITERATE_KEY));
          }
          break;
      }
    }
    const eventInfo = { target, type, key, newValue, oldValue, oldTarget };
    if (deps.length === 1) {
      if (deps[0]) {
        {
          triggerEffects(deps[0], eventInfo);
        }
      }
    } else {
      const effects = [];
      for (const dep of deps) {
        if (dep) {
          effects.push(...dep);
        }
      }
      {
        triggerEffects(createDep(effects), eventInfo);
      }
    }
  }
  function triggerEffects(dep, debuggerEventExtraInfo) {
    for (const effect of isArray(dep) ? dep : [...dep]) {
      if (effect !== activeEffect || effect.allowRecurse) {
        if (effect.onTrigger) {
          effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
        }
        if (effect.scheduler) {
          effect.scheduler();
        } else {
          effect.run();
        }
      }
    }
  }
  const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol));
  const get = /* @__PURE__ */ createGetter();
  const readonlyGet = /* @__PURE__ */ createGetter(true);
  const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
  const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  function createArrayInstrumentations() {
    const instrumentations = {};
    ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
      instrumentations[key] = function(...args) {
        const arr = toRaw(this);
        for (let i = 0, l2 = this.length; i < l2; i++) {
          track(arr, "get", i + "");
        }
        const res = arr[key](...args);
        if (res === -1 || res === false) {
          return arr[key](...args.map(toRaw));
        } else {
          return res;
        }
      };
    });
    ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
      instrumentations[key] = function(...args) {
        pauseTracking();
        const res = toRaw(this)[key].apply(this, args);
        resetTracking();
        return res;
      };
    });
    return instrumentations;
  }
  function createGetter(isReadonly2 = false, shallow = false) {
    return function get2(target, key, receiver) {
      if (key === "__v_isReactive") {
        return !isReadonly2;
      } else if (key === "__v_isReadonly") {
        return isReadonly2;
      } else if (key === "__v_isShallow") {
        return shallow;
      } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
        return target;
      }
      const targetIsArray = isArray(target);
      if (!isReadonly2 && targetIsArray && hasOwn(arrayInstrumentations, key)) {
        return Reflect.get(arrayInstrumentations, key, receiver);
      }
      const res = Reflect.get(target, key, receiver);
      if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
        return res;
      }
      if (!isReadonly2) {
        track(target, "get", key);
      }
      if (shallow) {
        return res;
      }
      if (isRef(res)) {
        const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
        return shouldUnwrap ? res.value : res;
      }
      if (isObject(res)) {
        return isReadonly2 ? readonly(res) : reactive(res);
      }
      return res;
    };
  }
  const set = /* @__PURE__ */ createSetter();
  function createSetter(shallow = false) {
    return function set2(target, key, value, receiver) {
      let oldValue = target[key];
      if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
        return false;
      }
      if (!shallow && !isReadonly(value)) {
        if (!isShallow$1(value)) {
          value = toRaw(value);
          oldValue = toRaw(oldValue);
        }
        if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
          oldValue.value = value;
          return true;
        }
      }
      const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
      const result = Reflect.set(target, key, value, receiver);
      if (target === toRaw(receiver)) {
        if (!hadKey) {
          trigger(target, "add", key, value);
        } else if (hasChanged(value, oldValue)) {
          trigger(target, "set", key, value, oldValue);
        }
      }
      return result;
    };
  }
  function deleteProperty(target, key) {
    const hadKey = hasOwn(target, key);
    const oldValue = target[key];
    const result = Reflect.deleteProperty(target, key);
    if (result && hadKey) {
      trigger(target, "delete", key, void 0, oldValue);
    }
    return result;
  }
  function has(target, key) {
    const result = Reflect.has(target, key);
    if (!isSymbol(key) || !builtInSymbols.has(key)) {
      track(target, "has", key);
    }
    return result;
  }
  function ownKeys(target) {
    track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
    return Reflect.ownKeys(target);
  }
  const mutableHandlers = {
    get,
    set,
    deleteProperty,
    has,
    ownKeys
  };
  const readonlyHandlers = {
    get: readonlyGet,
    set(target, key) {
      {
        console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
      }
      return true;
    },
    deleteProperty(target, key) {
      {
        console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
      }
      return true;
    }
  };
  const shallowReadonlyHandlers = /* @__PURE__ */ extend({}, readonlyHandlers, {
    get: shallowReadonlyGet
  });
  const toShallow = (value) => value;
  const getProto = (v2) => Reflect.getPrototypeOf(v2);
  function get$1(target, key, isReadonly2 = false, isShallow2 = false) {
    target = target["__v_raw"];
    const rawTarget = toRaw(target);
    const rawKey = toRaw(key);
    if (key !== rawKey) {
      !isReadonly2 && track(rawTarget, "get", key);
    }
    !isReadonly2 && track(rawTarget, "get", rawKey);
    const { has: has2 } = getProto(rawTarget);
    const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
    if (has2.call(rawTarget, key)) {
      return wrap(target.get(key));
    } else if (has2.call(rawTarget, rawKey)) {
      return wrap(target.get(rawKey));
    } else if (target !== rawTarget) {
      target.get(key);
    }
  }
  function has$1(key, isReadonly2 = false) {
    const target = this["__v_raw"];
    const rawTarget = toRaw(target);
    const rawKey = toRaw(key);
    if (key !== rawKey) {
      !isReadonly2 && track(rawTarget, "has", key);
    }
    !isReadonly2 && track(rawTarget, "has", rawKey);
    return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  }
  function size(target, isReadonly2 = false) {
    target = target["__v_raw"];
    !isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
    return Reflect.get(target, "size", target);
  }
  function add(value) {
    value = toRaw(value);
    const target = toRaw(this);
    const proto = getProto(target);
    const hadKey = proto.has.call(target, value);
    if (!hadKey) {
      target.add(value);
      trigger(target, "add", value, value);
    }
    return this;
  }
  function set$1(key, value) {
    value = toRaw(value);
    const target = toRaw(this);
    const { has: has2, get: get2 } = getProto(target);
    let hadKey = has2.call(target, key);
    if (!hadKey) {
      key = toRaw(key);
      hadKey = has2.call(target, key);
    } else {
      checkIdentityKeys(target, has2, key);
    }
    const oldValue = get2.call(target, key);
    target.set(key, value);
    if (!hadKey) {
      trigger(target, "add", key, value);
    } else if (hasChanged(value, oldValue)) {
      trigger(target, "set", key, value, oldValue);
    }
    return this;
  }
  function deleteEntry(key) {
    const target = toRaw(this);
    const { has: has2, get: get2 } = getProto(target);
    let hadKey = has2.call(target, key);
    if (!hadKey) {
      key = toRaw(key);
      hadKey = has2.call(target, key);
    } else {
      checkIdentityKeys(target, has2, key);
    }
    const oldValue = get2 ? get2.call(target, key) : void 0;
    const result = target.delete(key);
    if (hadKey) {
      trigger(target, "delete", key, void 0, oldValue);
    }
    return result;
  }
  function clear() {
    const target = toRaw(this);
    const hadItems = target.size !== 0;
    const oldTarget = isMap(target) ? new Map(target) : new Set(target);
    const result = target.clear();
    if (hadItems) {
      trigger(target, "clear", void 0, void 0, oldTarget);
    }
    return result;
  }
  function createForEach(isReadonly2, isShallow2) {
    return function forEach(callback, thisArg) {
      const observed = this;
      const target = observed["__v_raw"];
      const rawTarget = toRaw(target);
      const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
      !isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
      return target.forEach((value, key) => {
        return callback.call(thisArg, wrap(value), wrap(key), observed);
      });
    };
  }
  function createIterableMethod(method, isReadonly2, isShallow2) {
    return function(...args) {
      const target = this["__v_raw"];
      const rawTarget = toRaw(target);
      const targetIsMap = isMap(rawTarget);
      const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
      const isKeyOnly = method === "keys" && targetIsMap;
      const innerIterator = target[method](...args);
      const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
      !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
      return {
        next() {
          const { value, done } = innerIterator.next();
          return done ? { value, done } : {
            value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
            done
          };
        },
        [Symbol.iterator]() {
          return this;
        }
      };
    };
  }
  function createReadonlyMethod(type) {
    return function(...args) {
      {
        const key = args[0] ? `on key "${args[0]}" ` : ``;
        console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
      }
      return type === "delete" ? false : this;
    };
  }
  function createInstrumentations() {
    const mutableInstrumentations2 = {
      get(key) {
        return get$1(this, key);
      },
      get size() {
        return size(this);
      },
      has: has$1,
      add,
      set: set$1,
      delete: deleteEntry,
      clear,
      forEach: createForEach(false, false)
    };
    const shallowInstrumentations2 = {
      get(key) {
        return get$1(this, key, false, true);
      },
      get size() {
        return size(this);
      },
      has: has$1,
      add,
      set: set$1,
      delete: deleteEntry,
      clear,
      forEach: createForEach(false, true)
    };
    const readonlyInstrumentations2 = {
      get(key) {
        return get$1(this, key, true);
      },
      get size() {
        return size(this, true);
      },
      has(key) {
        return has$1.call(this, key, true);
      },
      add: createReadonlyMethod("add"),
      set: createReadonlyMethod("set"),
      delete: createReadonlyMethod("delete"),
      clear: createReadonlyMethod("clear"),
      forEach: createForEach(true, false)
    };
    const shallowReadonlyInstrumentations2 = {
      get(key) {
        return get$1(this, key, true, true);
      },
      get size() {
        return size(this, true);
      },
      has(key) {
        return has$1.call(this, key, true);
      },
      add: createReadonlyMethod("add"),
      set: createReadonlyMethod("set"),
      delete: createReadonlyMethod("delete"),
      clear: createReadonlyMethod("clear"),
      forEach: createForEach(true, true)
    };
    const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
    iteratorMethods.forEach((method) => {
      mutableInstrumentations2[method] = createIterableMethod(method, false, false);
      readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
      shallowInstrumentations2[method] = createIterableMethod(method, false, true);
      shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true);
    });
    return [
      mutableInstrumentations2,
      readonlyInstrumentations2,
      shallowInstrumentations2,
      shallowReadonlyInstrumentations2
    ];
  }
  const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations();
  function createInstrumentationGetter(isReadonly2, shallow) {
    const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
    return (target, key, receiver) => {
      if (key === "__v_isReactive") {
        return !isReadonly2;
      } else if (key === "__v_isReadonly") {
        return isReadonly2;
      } else if (key === "__v_raw") {
        return target;
      }
      return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
    };
  }
  const mutableCollectionHandlers = {
    get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  };
  const readonlyCollectionHandlers = {
    get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  };
  const shallowReadonlyCollectionHandlers = {
    get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  };
  function checkIdentityKeys(target, has2, key) {
    const rawKey = toRaw(key);
    if (rawKey !== key && has2.call(target, rawKey)) {
      const type = toRawType(target);
      console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
    }
  }
  const reactiveMap = /* @__PURE__ */ new WeakMap();
  const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  const readonlyMap = /* @__PURE__ */ new WeakMap();
  const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  function targetTypeMap(rawType) {
    switch (rawType) {
      case "Object":
      case "Array":
        return 1;
      case "Map":
      case "Set":
      case "WeakMap":
      case "WeakSet":
        return 2;
      default:
        return 0;
    }
  }
  function getTargetType(value) {
    return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
  }
  function reactive(target) {
    if (isReadonly(target)) {
      return target;
    }
    return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  }
  function readonly(target) {
    return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  }
  function shallowReadonly(target) {
    return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  }
  function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
    if (!isObject(target)) {
      {
        console.warn(`value cannot be made reactive: ${String(target)}`);
      }
      return target;
    }
    if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
      return target;
    }
    const existingProxy = proxyMap.get(target);
    if (existingProxy) {
      return existingProxy;
    }
    const targetType = getTargetType(target);
    if (targetType === 0) {
      return target;
    }
    const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
    proxyMap.set(target, proxy);
    return proxy;
  }
  function isReactive(value) {
    if (isReadonly(value)) {
      return isReactive(value["__v_raw"]);
    }
    return !!(value && value["__v_isReactive"]);
  }
  function isReadonly(value) {
    return !!(value && value["__v_isReadonly"]);
  }
  function isShallow$1(value) {
    return !!(value && value["__v_isShallow"]);
  }
  function toRaw(observed) {
    const raw = observed && observed["__v_raw"];
    return raw ? toRaw(raw) : observed;
  }
  function markRaw(value) {
    def(value, "__v_skip", true);
    return value;
  }
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  function trackRefValue(ref2) {
    if (shouldTrack && activeEffect) {
      ref2 = toRaw(ref2);
      {
        trackEffects(ref2.dep || (ref2.dep = createDep()), {
          target: ref2,
          type: "get",
          key: "value"
        });
      }
    }
  }
  function triggerRefValue(ref2, newVal) {
    ref2 = toRaw(ref2);
    if (ref2.dep) {
      {
        triggerEffects(ref2.dep, {
          target: ref2,
          type: "set",
          key: "value",
          newValue: newVal
        });
      }
    }
  }
  function isRef(r) {
    return !!(r && r.__v_isRef === true);
  }
  function ref(value) {
    return createRef(value, false);
  }
  function createRef(rawValue, shallow) {
    if (isRef(rawValue)) {
      return rawValue;
    }
    return new RefImpl(rawValue, shallow);
  }
  class RefImpl {
    constructor(value, __v_isShallow) {
      this.__v_isShallow = __v_isShallow;
      this.dep = void 0;
      this.__v_isRef = true;
      this._rawValue = __v_isShallow ? value : toRaw(value);
      this._value = __v_isShallow ? value : toReactive(value);
    }
    get value() {
      trackRefValue(this);
      return this._value;
    }
    set value(newVal) {
      newVal = this.__v_isShallow ? newVal : toRaw(newVal);
      if (hasChanged(newVal, this._rawValue)) {
        this._rawValue = newVal;
        this._value = this.__v_isShallow ? newVal : toReactive(newVal);
        triggerRefValue(this, newVal);
      }
    }
  }
  function unref(ref2) {
    return isRef(ref2) ? ref2.value : ref2;
  }
  const shallowUnwrapHandlers = {
    get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
    set: (target, key, value, receiver) => {
      const oldValue = target[key];
      if (isRef(oldValue) && !isRef(value)) {
        oldValue.value = value;
        return true;
      } else {
        return Reflect.set(target, key, value, receiver);
      }
    }
  };
  function proxyRefs(objectWithRefs) {
    return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  }
  class ComputedRefImpl {
    constructor(getter, _setter, isReadonly2, isSSR) {
      this._setter = _setter;
      this.dep = void 0;
      this.__v_isRef = true;
      this._dirty = true;
      this.effect = new ReactiveEffect(getter, () => {
        if (!this._dirty) {
          this._dirty = true;
          triggerRefValue(this);
        }
      });
      this.effect.computed = this;
      this.effect.active = this._cacheable = !isSSR;
      this["__v_isReadonly"] = isReadonly2;
    }
    get value() {
      const self2 = toRaw(this);
      trackRefValue(self2);
      if (self2._dirty || !self2._cacheable) {
        self2._dirty = false;
        self2._value = self2.effect.run();
      }
      return self2._value;
    }
    set value(newValue) {
      this._setter(newValue);
    }
  }
  function computed$1(getterOrOptions, debugOptions, isSSR = false) {
    let getter;
    let setter;
    const onlyGetter = isFunction$1(getterOrOptions);
    if (onlyGetter) {
      getter = getterOrOptions;
      setter = () => {
        console.warn("Write operation failed: computed value is readonly");
      };
    } else {
      getter = getterOrOptions.get;
      setter = getterOrOptions.set;
    }
    const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
    if (debugOptions && !isSSR) {
      cRef.effect.onTrack = debugOptions.onTrack;
      cRef.effect.onTrigger = debugOptions.onTrigger;
    }
    return cRef;
  }
  Promise.resolve();
  const stack = [];
  function pushWarningContext(vnode) {
    stack.push(vnode);
  }
  function popWarningContext() {
    stack.pop();
  }
  function warn(msg, ...args) {
    pauseTracking();
    const instance = stack.length ? stack[stack.length - 1].component : null;
    const appWarnHandler = instance && instance.appContext.config.warnHandler;
    const trace = getComponentTrace();
    if (appWarnHandler) {
      callWithErrorHandling(appWarnHandler, instance, 11, [
        msg + args.join(""),
        instance && instance.proxy,
        trace.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`).join("\n"),
        trace
      ]);
    } else {
      const warnArgs = [`[Vue warn]: ${msg}`, ...args];
      if (trace.length && true) {
        warnArgs.push(`
`, ...formatTrace(trace));
      }
      console.warn(...warnArgs);
    }
    resetTracking();
  }
  function getComponentTrace() {
    let currentVNode = stack[stack.length - 1];
    if (!currentVNode) {
      return [];
    }
    const normalizedStack = [];
    while (currentVNode) {
      const last = normalizedStack[0];
      if (last && last.vnode === currentVNode) {
        last.recurseCount++;
      } else {
        normalizedStack.push({
          vnode: currentVNode,
          recurseCount: 0
        });
      }
      const parentInstance = currentVNode.component && currentVNode.component.parent;
      currentVNode = parentInstance && parentInstance.vnode;
    }
    return normalizedStack;
  }
  function formatTrace(trace) {
    const logs = [];
    trace.forEach((entry, i) => {
      logs.push(...i === 0 ? [] : [`
`], ...formatTraceEntry(entry));
    });
    return logs;
  }
  function formatTraceEntry({ vnode, recurseCount }) {
    const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
    const isRoot = vnode.component ? vnode.component.parent == null : false;
    const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
    const close = `>` + postfix;
    return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  }
  function formatProps(props) {
    const res = [];
    const keys2 = Object.keys(props);
    keys2.slice(0, 3).forEach((key) => {
      res.push(...formatProp(key, props[key]));
    });
    if (keys2.length > 3) {
      res.push(` ...`);
    }
    return res;
  }
  function formatProp(key, value, raw) {
    if (isString$1(value)) {
      value = JSON.stringify(value);
      return raw ? value : [`${key}=${value}`];
    } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
      return raw ? value : [`${key}=${value}`];
    } else if (isRef(value)) {
      value = formatProp(key, toRaw(value.value), true);
      return raw ? value : [`${key}=Ref<`, value, `>`];
    } else if (isFunction$1(value)) {
      return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
    } else {
      value = toRaw(value);
      return raw ? value : [`${key}=`, value];
    }
  }
  const ErrorTypeStrings = {
    ["sp"]: "serverPrefetch hook",
    ["bc"]: "beforeCreate hook",
    ["c"]: "created hook",
    ["bm"]: "beforeMount hook",
    ["m"]: "mounted hook",
    ["bu"]: "beforeUpdate hook",
    ["u"]: "updated",
    ["bum"]: "beforeUnmount hook",
    ["um"]: "unmounted hook",
    ["a"]: "activated hook",
    ["da"]: "deactivated hook",
    ["ec"]: "errorCaptured hook",
    ["rtc"]: "renderTracked hook",
    ["rtg"]: "renderTriggered hook",
    [0]: "setup function",
    [1]: "render function",
    [2]: "watcher getter",
    [3]: "watcher callback",
    [4]: "watcher cleanup function",
    [5]: "native event handler",
    [6]: "component event handler",
    [7]: "vnode hook",
    [8]: "directive hook",
    [9]: "transition hook",
    [10]: "app errorHandler",
    [11]: "app warnHandler",
    [12]: "ref function",
    [13]: "async component loader",
    [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
  };
  function callWithErrorHandling(fn2, instance, type, args) {
    let res;
    try {
      res = args ? fn2(...args) : fn2();
    } catch (err) {
      handleError(err, instance, type);
    }
    return res;
  }
  function callWithAsyncErrorHandling(fn2, instance, type, args) {
    if (isFunction$1(fn2)) {
      const res = callWithErrorHandling(fn2, instance, type, args);
      if (res && isPromise(res)) {
        res.catch((err) => {
          handleError(err, instance, type);
        });
      }
      return res;
    }
    const values = [];
    for (let i = 0; i < fn2.length; i++) {
      values.push(callWithAsyncErrorHandling(fn2[i], instance, type, args));
    }
    return values;
  }
  function handleError(err, instance, type, throwInDev = true) {
    const contextVNode = instance ? instance.vnode : null;
    if (instance) {
      let cur = instance.parent;
      const exposedInstance = instance.proxy;
      const errorInfo = ErrorTypeStrings[type];
      while (cur) {
        const errorCapturedHooks = cur.ec;
        if (errorCapturedHooks) {
          for (let i = 0; i < errorCapturedHooks.length; i++) {
            if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
              return;
            }
          }
        }
        cur = cur.parent;
      }
      const appErrorHandler = instance.appContext.config.errorHandler;
      if (appErrorHandler) {
        callWithErrorHandling(appErrorHandler, null, 10, [err, exposedInstance, errorInfo]);
        return;
      }
    }
    logError(err, type, contextVNode, throwInDev);
  }
  function logError(err, type, contextVNode, throwInDev = true) {
    {
      const info = ErrorTypeStrings[type];
      if (contextVNode) {
        pushWarningContext(contextVNode);
      }
      warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
      if (contextVNode) {
        popWarningContext();
      }
      if (throwInDev) {
        throw err;
      } else {
        console.error(err);
      }
    }
  }
  let isFlushing = false;
  let isFlushPending = false;
  const queue = [];
  let flushIndex = 0;
  const pendingPreFlushCbs = [];
  let activePreFlushCbs = null;
  let preFlushIndex = 0;
  const pendingPostFlushCbs = [];
  let activePostFlushCbs = null;
  let postFlushIndex = 0;
  const resolvedPromise = Promise.resolve();
  let currentFlushPromise = null;
  let currentPreFlushParentJob = null;
  const RECURSION_LIMIT = 100;
  function nextTick(fn2) {
    const p2 = currentFlushPromise || resolvedPromise;
    return fn2 ? p2.then(this ? fn2.bind(this) : fn2) : p2;
  }
  function findInsertionIndex(id) {
    let start = flushIndex + 1;
    let end = queue.length;
    while (start < end) {
      const middle = start + end >>> 1;
      const middleJobId = getId(queue[middle]);
      middleJobId < id ? start = middle + 1 : end = middle;
    }
    return start;
  }
  function queueJob(job) {
    if ((!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) && job !== currentPreFlushParentJob) {
      if (job.id == null) {
        queue.push(job);
      } else {
        queue.splice(findInsertionIndex(job.id), 0, job);
      }
      queueFlush();
    }
  }
  function queueFlush() {
    if (!isFlushing && !isFlushPending) {
      isFlushPending = true;
      currentFlushPromise = resolvedPromise.then(flushJobs);
    }
  }
  function queueCb(cb, activeQueue, pendingQueue, index) {
    if (!isArray(cb)) {
      if (!activeQueue || !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
        pendingQueue.push(cb);
      }
    } else {
      pendingQueue.push(...cb);
    }
    queueFlush();
  }
  function queuePreFlushCb(cb) {
    queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  }
  function queuePostFlushCb(cb) {
    queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  }
  function flushPreFlushCbs(seen, parentJob = null) {
    if (pendingPreFlushCbs.length) {
      currentPreFlushParentJob = parentJob;
      activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
      pendingPreFlushCbs.length = 0;
      {
        seen = seen || /* @__PURE__ */ new Map();
      }
      for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
        if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
          continue;
        }
        activePreFlushCbs[preFlushIndex]();
      }
      activePreFlushCbs = null;
      preFlushIndex = 0;
      currentPreFlushParentJob = null;
      flushPreFlushCbs(seen, parentJob);
    }
  }
  function flushPostFlushCbs(seen) {
    if (pendingPostFlushCbs.length) {
      const deduped = [...new Set(pendingPostFlushCbs)];
      pendingPostFlushCbs.length = 0;
      if (activePostFlushCbs) {
        activePostFlushCbs.push(...deduped);
        return;
      }
      activePostFlushCbs = deduped;
      {
        seen = seen || /* @__PURE__ */ new Map();
      }
      activePostFlushCbs.sort((a2, b2) => getId(a2) - getId(b2));
      for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
        if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
          continue;
        }
        activePostFlushCbs[postFlushIndex]();
      }
      activePostFlushCbs = null;
      postFlushIndex = 0;
    }
  }
  const getId = (job) => job.id == null ? Infinity : job.id;
  function flushJobs(seen) {
    isFlushPending = false;
    isFlushing = true;
    {
      seen = seen || /* @__PURE__ */ new Map();
    }
    flushPreFlushCbs(seen);
    queue.sort((a2, b2) => getId(a2) - getId(b2));
    const check = (job) => checkRecursiveUpdates(seen, job);
    try {
      for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
        const job = queue[flushIndex];
        if (job && job.active !== false) {
          if (check(job)) {
            continue;
          }
          callWithErrorHandling(job, null, 14);
        }
      }
    } finally {
      flushIndex = 0;
      queue.length = 0;
      flushPostFlushCbs(seen);
      isFlushing = false;
      currentFlushPromise = null;
      if (queue.length || pendingPreFlushCbs.length || pendingPostFlushCbs.length) {
        flushJobs(seen);
      }
    }
  }
  function checkRecursiveUpdates(seen, fn2) {
    if (!seen.has(fn2)) {
      seen.set(fn2, 1);
    } else {
      const count = seen.get(fn2);
      if (count > RECURSION_LIMIT) {
        const instance = fn2.ownerInstance;
        const componentName = instance && getComponentName(instance.type);
        warn(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`);
        return true;
      } else {
        seen.set(fn2, count + 1);
      }
    }
  }
  const hmrDirtyComponents = /* @__PURE__ */ new Set();
  {
    getGlobalThis().__VUE_HMR_RUNTIME__ = {
      createRecord: tryWrap(createRecord),
      rerender: tryWrap(rerender),
      reload: tryWrap(reload)
    };
  }
  const map = /* @__PURE__ */ new Map();
  function createRecord(id, initialDef) {
    if (map.has(id)) {
      return false;
    }
    map.set(id, {
      initialDef: normalizeClassComponent(initialDef),
      instances: /* @__PURE__ */ new Set()
    });
    return true;
  }
  function normalizeClassComponent(component) {
    return isClassComponent(component) ? component.__vccOpts : component;
  }
  function rerender(id, newRender) {
    const record = map.get(id);
    if (!record) {
      return;
    }
    record.initialDef.render = newRender;
    [...record.instances].forEach((instance) => {
      if (newRender) {
        instance.render = newRender;
        normalizeClassComponent(instance.type).render = newRender;
      }
      instance.renderCache = [];
      instance.update();
    });
  }
  function reload(id, newComp) {
    const record = map.get(id);
    if (!record)
      return;
    newComp = normalizeClassComponent(newComp);
    updateComponentDef(record.initialDef, newComp);
    const instances = [...record.instances];
    for (const instance of instances) {
      const oldComp = normalizeClassComponent(instance.type);
      if (!hmrDirtyComponents.has(oldComp)) {
        if (oldComp !== record.initialDef) {
          updateComponentDef(oldComp, newComp);
        }
        hmrDirtyComponents.add(oldComp);
      }
      instance.appContext.optionsCache.delete(instance.type);
      if (instance.ceReload) {
        hmrDirtyComponents.add(oldComp);
        instance.ceReload(newComp.styles);
        hmrDirtyComponents.delete(oldComp);
      } else if (instance.parent) {
        queueJob(instance.parent.update);
        if (instance.parent.type.__asyncLoader && instance.parent.ceReload) {
          instance.parent.ceReload(newComp.styles);
        }
      } else if (instance.appContext.reload) {
        instance.appContext.reload();
      } else if (typeof window !== "undefined") {
        window.location.reload();
      } else {
        console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
      }
    }
    queuePostFlushCb(() => {
      for (const instance of instances) {
        hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
      }
    });
  }
  function updateComponentDef(oldComp, newComp) {
    extend(oldComp, newComp);
    for (const key in oldComp) {
      if (key !== "__file" && !(key in newComp)) {
        delete oldComp[key];
      }
    }
  }
  function tryWrap(fn2) {
    return (id, arg) => {
      try {
        return fn2(id, arg);
      } catch (e) {
        console.error(e);
        console.warn(`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`);
      }
    };
  }
  let currentRenderingInstance = null;
  function queueEffectWithSuspense(fn2, suspense) {
    if (suspense && suspense.pendingBranch) {
      if (isArray(fn2)) {
        suspense.effects.push(...fn2);
      } else {
        suspense.effects.push(fn2);
      }
    } else {
      queuePostFlushCb(fn2);
    }
  }
  const INITIAL_WATCHER_VALUE = {};
  function watch(source, cb, options) {
    if (!isFunction$1(cb)) {
      warn(`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`);
    }
    return doWatch(source, cb, options);
  }
  function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
    if (!cb) {
      if (immediate !== void 0) {
        warn(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`);
      }
      if (deep !== void 0) {
        warn(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`);
      }
    }
    const warnInvalidSource = (s2) => {
      warn(`Invalid watch source: `, s2, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
    };
    const instance = currentInstance;
    let getter;
    let forceTrigger = false;
    let isMultiSource = false;
    if (isRef(source)) {
      getter = () => source.value;
      forceTrigger = isShallow$1(source);
    } else if (isReactive(source)) {
      getter = () => source;
      deep = true;
    } else if (isArray(source)) {
      isMultiSource = true;
      forceTrigger = source.some(isReactive);
      getter = () => source.map((s2) => {
        if (isRef(s2)) {
          return s2.value;
        } else if (isReactive(s2)) {
          return traverse(s2);
        } else if (isFunction$1(s2)) {
          return callWithErrorHandling(s2, instance, 2);
        } else {
          warnInvalidSource(s2);
        }
      });
    } else if (isFunction$1(source)) {
      if (cb) {
        getter = () => callWithErrorHandling(source, instance, 2);
      } else {
        getter = () => {
          if (instance && instance.isUnmounted) {
            return;
          }
          if (cleanup) {
            cleanup();
          }
          return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]);
        };
      }
    } else {
      getter = NOOP;
      warnInvalidSource(source);
    }
    if (cb && deep) {
      const baseGetter = getter;
      getter = () => traverse(baseGetter());
    }
    let cleanup;
    let onCleanup = (fn2) => {
      cleanup = effect.onStop = () => {
        callWithErrorHandling(fn2, instance, 4);
      };
    };
    if (isInSSRComponentSetup) {
      onCleanup = NOOP;
      if (!cb) {
        getter();
      } else if (immediate) {
        callWithAsyncErrorHandling(cb, instance, 3, [
          getter(),
          isMultiSource ? [] : void 0,
          onCleanup
        ]);
      }
      return NOOP;
    }
    let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
    const job = () => {
      if (!effect.active) {
        return;
      }
      if (cb) {
        const newValue = effect.run();
        if (deep || forceTrigger || (isMultiSource ? newValue.some((v2, i) => hasChanged(v2, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
          if (cleanup) {
            cleanup();
          }
          callWithAsyncErrorHandling(cb, instance, 3, [
            newValue,
            oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue,
            onCleanup
          ]);
          oldValue = newValue;
        }
      } else {
        effect.run();
      }
    };
    job.allowRecurse = !!cb;
    let scheduler;
    if (flush === "sync") {
      scheduler = job;
    } else if (flush === "post") {
      scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
    } else {
      scheduler = () => {
        if (!instance || instance.isMounted) {
          queuePreFlushCb(job);
        } else {
          job();
        }
      };
    }
    const effect = new ReactiveEffect(getter, scheduler);
    {
      effect.onTrack = onTrack;
      effect.onTrigger = onTrigger;
    }
    if (cb) {
      if (immediate) {
        job();
      } else {
        oldValue = effect.run();
      }
    } else if (flush === "post") {
      queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
    } else {
      effect.run();
    }
    return () => {
      effect.stop();
      if (instance && instance.scope) {
        remove(instance.scope.effects, effect);
      }
    };
  }
  function instanceWatch(source, value, options) {
    const publicThis = this.proxy;
    const getter = isString$1(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
    let cb;
    if (isFunction$1(value)) {
      cb = value;
    } else {
      cb = value.handler;
      options = value;
    }
    const cur = currentInstance;
    setCurrentInstance(this);
    const res = doWatch(getter, cb.bind(publicThis), options);
    if (cur) {
      setCurrentInstance(cur);
    } else {
      unsetCurrentInstance();
    }
    return res;
  }
  function createPathGetter(ctx, path) {
    const segments = path.split(".");
    return () => {
      let cur = ctx;
      for (let i = 0; i < segments.length && cur; i++) {
        cur = cur[segments[i]];
      }
      return cur;
    };
  }
  function traverse(value, seen) {
    if (!isObject(value) || value["__v_skip"]) {
      return value;
    }
    seen = seen || /* @__PURE__ */ new Set();
    if (seen.has(value)) {
      return value;
    }
    seen.add(value);
    if (isRef(value)) {
      traverse(value.value, seen);
    } else if (isArray(value)) {
      for (let i = 0; i < value.length; i++) {
        traverse(value[i], seen);
      }
    } else if (isSet(value) || isMap(value)) {
      value.forEach((v2) => {
        traverse(v2, seen);
      });
    } else if (isPlainObject(value)) {
      for (const key in value) {
        traverse(value[key], seen);
      }
    }
    return value;
  }
  function injectHook(type, hook, target = currentInstance, prepend = false) {
    if (target) {
      const hooks = target[type] || (target[type] = []);
      const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
        if (target.isUnmounted) {
          return;
        }
        pauseTracking();
        setCurrentInstance(target);
        const res = callWithAsyncErrorHandling(hook, target, type, args);
        unsetCurrentInstance();
        resetTracking();
        return res;
      });
      if (prepend) {
        hooks.unshift(wrappedHook);
      } else {
        hooks.push(wrappedHook);
      }
      return wrappedHook;
    } else {
      const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
      warn(`${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
    }
  }
  const createHook = (lifecycle) => (hook, target = currentInstance) => injectHook(lifecycle, hook, target);
  const onMounted = createHook("m");
  function resolveMergedOptions(instance) {
    const base = instance.type;
    const { mixins, extends: extendsOptions } = base;
    const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
    const cached = cache.get(base);
    let resolved;
    if (cached) {
      resolved = cached;
    } else if (!globalMixins.length && !mixins && !extendsOptions) {
      {
        resolved = base;
      }
    } else {
      resolved = {};
      if (globalMixins.length) {
        globalMixins.forEach((m2) => mergeOptions$1(resolved, m2, optionMergeStrategies, true));
      }
      mergeOptions$1(resolved, base, optionMergeStrategies);
    }
    cache.set(base, resolved);
    return resolved;
  }
  function mergeOptions$1(to, from, strats, asMixin = false) {
    const { mixins, extends: extendsOptions } = from;
    if (extendsOptions) {
      mergeOptions$1(to, extendsOptions, strats, true);
    }
    if (mixins) {
      mixins.forEach((m2) => mergeOptions$1(to, m2, strats, true));
    }
    for (const key in from) {
      if (asMixin && key === "expose") {
        warn(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);
      } else {
        const strat = internalOptionMergeStrats[key] || strats && strats[key];
        to[key] = strat ? strat(to[key], from[key]) : from[key];
      }
    }
    return to;
  }
  const internalOptionMergeStrats = {
    data: mergeDataFn,
    props: mergeObjectOptions,
    emits: mergeObjectOptions,
    methods: mergeObjectOptions,
    computed: mergeObjectOptions,
    beforeCreate: mergeAsArray,
    created: mergeAsArray,
    beforeMount: mergeAsArray,
    mounted: mergeAsArray,
    beforeUpdate: mergeAsArray,
    updated: mergeAsArray,
    beforeDestroy: mergeAsArray,
    beforeUnmount: mergeAsArray,
    destroyed: mergeAsArray,
    unmounted: mergeAsArray,
    activated: mergeAsArray,
    deactivated: mergeAsArray,
    errorCaptured: mergeAsArray,
    serverPrefetch: mergeAsArray,
    components: mergeObjectOptions,
    directives: mergeObjectOptions,
    watch: mergeWatchOptions,
    provide: mergeDataFn,
    inject: mergeInject
  };
  function mergeDataFn(to, from) {
    if (!from) {
      return to;
    }
    if (!to) {
      return from;
    }
    return function mergedDataFn() {
      return extend(isFunction$1(to) ? to.call(this, this) : to, isFunction$1(from) ? from.call(this, this) : from);
    };
  }
  function mergeInject(to, from) {
    return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  }
  function normalizeInject(raw) {
    if (isArray(raw)) {
      const res = {};
      for (let i = 0; i < raw.length; i++) {
        res[raw[i]] = raw[i];
      }
      return res;
    }
    return raw;
  }
  function mergeAsArray(to, from) {
    return to ? [...new Set([].concat(to, from))] : from;
  }
  function mergeObjectOptions(to, from) {
    return to ? extend(extend(/* @__PURE__ */ Object.create(null), to), from) : from;
  }
  function mergeWatchOptions(to, from) {
    if (!to)
      return from;
    if (!from)
      return to;
    const merged = extend(/* @__PURE__ */ Object.create(null), to);
    for (const key in from) {
      merged[key] = mergeAsArray(to[key], from[key]);
    }
    return merged;
  }
  const queuePostRenderEffect = queueEffectWithSuspense;
  const getPublicInstance = (i) => {
    if (!i)
      return null;
    if (isStatefulComponent(i))
      return getExposeProxy(i) || i.proxy;
    return getPublicInstance(i.parent);
  };
  const publicPropertiesMap = extend(/* @__PURE__ */ Object.create(null), {
    $: (i) => i,
    $el: (i) => i.vnode.el,
    $data: (i) => i.data,
    $props: (i) => shallowReadonly(i.props),
    $attrs: (i) => shallowReadonly(i.attrs),
    $slots: (i) => shallowReadonly(i.slots),
    $refs: (i) => shallowReadonly(i.refs),
    $parent: (i) => getPublicInstance(i.parent),
    $root: (i) => getPublicInstance(i.root),
    $emit: (i) => i.emit,
    $options: (i) => resolveMergedOptions(i),
    $forceUpdate: (i) => () => queueJob(i.update),
    $nextTick: (i) => nextTick.bind(i.proxy),
    $watch: (i) => instanceWatch.bind(i)
  });
  const PublicInstanceProxyHandlers = {
    get({ _: instance }, key) {
      const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
      if (key === "__isVue") {
        return true;
      }
      if (setupState !== EMPTY_OBJ && setupState.__isScriptSetup && hasOwn(setupState, key)) {
        return setupState[key];
      }
      let normalizedProps;
      if (key[0] !== "$") {
        const n = accessCache[key];
        if (n !== void 0) {
          switch (n) {
            case 1:
              return setupState[key];
            case 2:
              return data[key];
            case 4:
              return ctx[key];
            case 3:
              return props[key];
          }
        } else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
          accessCache[key] = 1;
          return setupState[key];
        } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
          accessCache[key] = 2;
          return data[key];
        } else if ((normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) {
          accessCache[key] = 3;
          return props[key];
        } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
          accessCache[key] = 4;
          return ctx[key];
        } else {
          accessCache[key] = 0;
        }
      }
      const publicGetter = publicPropertiesMap[key];
      let cssModule, globalProperties;
      if (publicGetter) {
        if (key === "$attrs") {
          track(instance, "get", key);
        }
        return publicGetter(instance);
      } else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) {
        return cssModule;
      } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
        accessCache[key] = 4;
        return ctx[key];
      } else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
        {
          return globalProperties[key];
        }
      } else
        ;
    },
    set({ _: instance }, key, value) {
      const { data, setupState, ctx } = instance;
      if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
        setupState[key] = value;
        return true;
      } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
        data[key] = value;
        return true;
      } else if (hasOwn(instance.props, key)) {
        warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
        return false;
      }
      if (key[0] === "$" && key.slice(1) in instance) {
        warn(`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`, instance);
        return false;
      } else {
        if (key in instance.appContext.config.globalProperties) {
          Object.defineProperty(ctx, key, {
            enumerable: true,
            configurable: true,
            value
          });
        } else {
          ctx[key] = value;
        }
      }
      return true;
    },
    has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
      let normalizedProps;
      return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || setupState !== EMPTY_OBJ && hasOwn(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
    },
    defineProperty(target, key, descriptor) {
      if (descriptor.get != null) {
        this.set(target, key, descriptor.get(), null);
      } else if (descriptor.value != null) {
        this.set(target, key, descriptor.value, null);
      }
      return Reflect.defineProperty(target, key, descriptor);
    }
  };
  {
    PublicInstanceProxyHandlers.ownKeys = (target) => {
      warn(`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`);
      return Reflect.ownKeys(target);
    };
  }
  let currentInstance = null;
  const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  const setCurrentInstance = (instance) => {
    currentInstance = instance;
    instance.scope.on();
  };
  const unsetCurrentInstance = () => {
    currentInstance && currentInstance.scope.off();
    currentInstance = null;
  };
  function isStatefulComponent(instance) {
    return instance.vnode.shapeFlag & 4;
  }
  let isInSSRComponentSetup = false;
  function getExposeProxy(instance) {
    if (instance.exposed) {
      return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
        get(target, key) {
          if (key in target) {
            return target[key];
          } else if (key in publicPropertiesMap) {
            return publicPropertiesMap[key](instance);
          }
        }
      }));
    }
  }
  const classifyRE = /(?:^|[-_])(\w)/g;
  const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
  function getComponentName(Component) {
    return isFunction$1(Component) ? Component.displayName || Component.name : Component.name;
  }
  function formatComponentName(instance, Component, isRoot = false) {
    let name = getComponentName(Component);
    if (!name && Component.__file) {
      const match = Component.__file.match(/([^/\\]+)\.\w+$/);
      if (match) {
        name = match[1];
      }
    }
    if (!name && instance && instance.parent) {
      const inferFromRegistry = (registry) => {
        for (const key in registry) {
          if (registry[key] === Component) {
            return key;
          }
        }
      };
      name = inferFromRegistry(instance.components || instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
    }
    return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  }
  function isClassComponent(value) {
    return isFunction$1(value) && "__vccOpts" in value;
  }
  const computed = (getterOrOptions, debugOptions) => {
    return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  };
  function isShallow(value) {
    return !!(value && value["__v_isShallow"]);
  }
  function initCustomFormatter() {
    if (typeof window === "undefined") {
      return;
    }
    const vueStyle = { style: "color:#3ba776" };
    const numberStyle = { style: "color:#0b1bc9" };
    const stringStyle = { style: "color:#b62e24" };
    const keywordStyle = { style: "color:#9d288c" };
    const formatter = {
      header(obj) {
        if (!isObject(obj)) {
          return null;
        }
        if (obj.__isVue) {
          return ["div", vueStyle, `VueInstance`];
        } else if (isRef(obj)) {
          return [
            "div",
            {},
            ["span", vueStyle, genRefFlag(obj)],
            "<",
            formatValue(obj.value),
            `>`
          ];
        } else if (isReactive(obj)) {
          return [
            "div",
            {},
            ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
            "<",
            formatValue(obj),
            `>${isReadonly(obj) ? ` (readonly)` : ``}`
          ];
        } else if (isReadonly(obj)) {
          return [
            "div",
            {},
            ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
            "<",
            formatValue(obj),
            ">"
          ];
        }
        return null;
      },
      hasBody(obj) {
        return obj && obj.__isVue;
      },
      body(obj) {
        if (obj && obj.__isVue) {
          return [
            "div",
            {},
            ...formatInstance(obj.$)
          ];
        }
      }
    };
    function formatInstance(instance) {
      const blocks = [];
      if (instance.type.props && instance.props) {
        blocks.push(createInstanceBlock("props", toRaw(instance.props)));
      }
      if (instance.setupState !== EMPTY_OBJ) {
        blocks.push(createInstanceBlock("setup", instance.setupState));
      }
      if (instance.data !== EMPTY_OBJ) {
        blocks.push(createInstanceBlock("data", toRaw(instance.data)));
      }
      const computed2 = extractKeys(instance, "computed");
      if (computed2) {
        blocks.push(createInstanceBlock("computed", computed2));
      }
      const injected = extractKeys(instance, "inject");
      if (injected) {
        blocks.push(createInstanceBlock("injected", injected));
      }
      blocks.push([
        "div",
        {},
        [
          "span",
          {
            style: keywordStyle.style + ";opacity:0.66"
          },
          "$ (internal): "
        ],
        ["object", { object: instance }]
      ]);
      return blocks;
    }
    function createInstanceBlock(type, target) {
      target = extend({}, target);
      if (!Object.keys(target).length) {
        return ["span", {}];
      }
      return [
        "div",
        { style: "line-height:1.25em;margin-bottom:0.6em" },
        [
          "div",
          {
            style: "color:#476582"
          },
          type
        ],
        [
          "div",
          {
            style: "padding-left:1.25em"
          },
          ...Object.keys(target).map((key) => {
            return [
              "div",
              {},
              ["span", keywordStyle, key + ": "],
              formatValue(target[key], false)
            ];
          })
        ]
      ];
    }
    function formatValue(v2, asRaw = true) {
      if (typeof v2 === "number") {
        return ["span", numberStyle, v2];
      } else if (typeof v2 === "string") {
        return ["span", stringStyle, JSON.stringify(v2)];
      } else if (typeof v2 === "boolean") {
        return ["span", keywordStyle, v2];
      } else if (isObject(v2)) {
        return ["object", { object: asRaw ? toRaw(v2) : v2 }];
      } else {
        return ["span", stringStyle, String(v2)];
      }
    }
    function extractKeys(instance, type) {
      const Comp = instance.type;
      if (isFunction$1(Comp)) {
        return;
      }
      const extracted = {};
      for (const key in instance.ctx) {
        if (isKeyOfType(Comp, key, type)) {
          extracted[key] = instance.ctx[key];
        }
      }
      return extracted;
    }
    function isKeyOfType(Comp, key, type) {
      const opts = Comp[type];
      if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
        return true;
      }
      if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
        return true;
      }
      if (Comp.mixins && Comp.mixins.some((m2) => isKeyOfType(m2, key, type))) {
        return true;
      }
    }
    function genRefFlag(v2) {
      if (isShallow(v2)) {
        return `ShallowRef`;
      }
      if (v2.effect) {
        return `ComputedRef`;
      }
      return `Ref`;
    }
    if (window.devtoolsFormatters) {
      window.devtoolsFormatters.push(formatter);
    } else {
      window.devtoolsFormatters = [formatter];
    }
  }
  function initDev() {
    {
      initCustomFormatter();
    }
  }
  {
    initDev();
  }
  Vue;
  var _a;
  const isClient = typeof window !== "undefined";
  const isDef = (val) => typeof val !== "undefined";
  const isBoolean = (val) => typeof val === "boolean";
  const isFunction = (val) => typeof val === "function";
  const isNumber = (val) => typeof val === "number";
  const isString = (val) => typeof val === "string";
  const noop = () => {
  };
  isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
  function resolveUnref(r) {
    return typeof r === "function" ? r() : unref(r);
  }
  function identity(arg) {
    return arg;
  }
  function tryOnScopeDispose(fn2) {
    if (getCurrentScope()) {
      onScopeDispose();
      return true;
    }
    return false;
  }
  function tryOnMounted(fn2, sync = true) {
    if (getCurrentInstance())
      onMounted(fn2);
    else if (sync)
      fn2();
    else
      nextTick(fn2);
  }
  Vue;
  function unrefElement(elRef) {
    var _a2;
    const plain = resolveUnref(elRef);
    return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain;
  }
  const defaultWindow = isClient ? window : void 0;
  function useEventListener(...args) {
    let target;
    let events;
    let listeners;
    let options;
    if (isString(args[0]) || Array.isArray(args[0])) {
      [events, listeners, options] = args;
      target = defaultWindow;
    } else {
      [target, events, listeners, options] = args;
    }
    if (!target)
      return noop;
    if (!Array.isArray(events))
      events = [events];
    if (!Array.isArray(listeners))
      listeners = [listeners];
    const cleanups = [];
    const cleanup = () => {
      cleanups.forEach((fn2) => fn2());
      cleanups.length = 0;
    };
    const register = (el, event, listener) => {
      el.addEventListener(event, listener, options);
      return () => el.removeEventListener(event, listener, options);
    };
    const stopWatch = watch(() => unrefElement(target), (el) => {
      cleanup();
      if (!el)
        return;
      cleanups.push(...events.flatMap((event) => {
        return listeners.map((listener) => register(el, event, listener));
      }));
    }, { immediate: true, flush: "post" });
    const stop = () => {
      stopWatch();
      cleanup();
    };
    tryOnScopeDispose();
    return stop;
  }
  function onClickOutside(target, handler, options = {}) {
    const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
    if (!window2)
      return;
    let shouldListen = true;
    let fallback;
    const shouldIgnore = (event) => {
      return ignore.some((target2) => {
        if (typeof target2 === "string") {
          return Array.from(window2.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
        } else {
          const el = unrefElement(target2);
          return el && (event.target === el || event.composedPath().includes(el));
        }
      });
    };
    const listener = (event) => {
      window2.clearTimeout(fallback);
      const el = unrefElement(target);
      if (!el || el === event.target || event.composedPath().includes(el))
        return;
      if (event.detail === 0)
        shouldListen = !shouldIgnore(event);
      if (!shouldListen) {
        shouldListen = true;
        return;
      }
      handler(event);
    };
    const cleanup = [
      useEventListener(window2, "click", listener, { passive: true, capture }),
      useEventListener(window2, "pointerdown", (e) => {
        const el = unrefElement(target);
        if (el)
          shouldListen = !e.composedPath().includes(el) && !shouldIgnore(e);
      }, { passive: true }),
      useEventListener(window2, "pointerup", (e) => {
        if (e.button === 0) {
          const path = e.composedPath();
          e.composedPath = () => path;
          fallback = window2.setTimeout(() => listener(e), 50);
        }
      }, { passive: true }),
      detectIframe && useEventListener(window2, "blur", (event) => {
        var _a2;
        const el = unrefElement(target);
        if (((_a2 = window2.document.activeElement) == null ? void 0 : _a2.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window2.document.activeElement)))
          handler(event);
      })
    ].filter(Boolean);
    const stop = () => cleanup.forEach((fn2) => fn2());
    return stop;
  }
  function useSupported(callback, sync = false) {
    const isSupported = ref();
    const update = () => isSupported.value = Boolean(callback());
    update();
    tryOnMounted(update, sync);
    return isSupported;
  }
  function cloneFnJSON(source) {
    return JSON.parse(JSON.stringify(source));
  }
  const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  const globalKey = "__vueuse_ssr_handlers__";
  _global[globalKey] = _global[globalKey] || {};
  _global[globalKey];
  var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
  var __hasOwnProp$f = Object.prototype.hasOwnProperty;
  var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
  var __objRest$2 = (source, exclude) => {
    var target = {};
    for (var prop in source)
      if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
        target[prop] = source[prop];
    if (source != null && __getOwnPropSymbols$f)
      for (var prop of __getOwnPropSymbols$f(source)) {
        if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
          target[prop] = source[prop];
      }
    return target;
  };
  function useResizeObserver(target, callback, options = {}) {
    const _a2 = options, { window: window2 = defaultWindow } = _a2, observerOptions = __objRest$2(_a2, ["window"]);
    let observer;
    const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
    const cleanup = () => {
      if (observer) {
        observer.disconnect();
        observer = void 0;
      }
    };
    const stopWatch = watch(() => unrefElement(target), (el) => {
      cleanup();
      if (isSupported.value && window2 && el) {
        observer = new ResizeObserver(callback);
        observer.observe(el, observerOptions);
      }
    }, { immediate: true, flush: "post" });
    const stop = () => {
      cleanup();
      stopWatch();
    };
    tryOnScopeDispose();
    return {
      isSupported,
      stop
    };
  }
  var SwipeDirection;
  (function(SwipeDirection2) {
    SwipeDirection2["UP"] = "UP";
    SwipeDirection2["RIGHT"] = "RIGHT";
    SwipeDirection2["DOWN"] = "DOWN";
    SwipeDirection2["LEFT"] = "LEFT";
    SwipeDirection2["NONE"] = "NONE";
  })(SwipeDirection || (SwipeDirection = {}));
  var __defProp2 = Object.defineProperty;
  var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
  var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  var __spreadValues2 = (a2, b2) => {
    for (var prop in b2 || (b2 = {}))
      if (__hasOwnProp2.call(b2, prop))
        __defNormalProp2(a2, prop, b2[prop]);
    if (__getOwnPropSymbols2)
      for (var prop of __getOwnPropSymbols2(b2)) {
        if (__propIsEnum2.call(b2, prop))
          __defNormalProp2(a2, prop, b2[prop]);
      }
    return a2;
  };
  const _TransitionPresets = {
    easeInSine: [0.12, 0, 0.39, 0],
    easeOutSine: [0.61, 1, 0.88, 1],
    easeInOutSine: [0.37, 0, 0.63, 1],
    easeInQuad: [0.11, 0, 0.5, 0],
    easeOutQuad: [0.5, 1, 0.89, 1],
    easeInOutQuad: [0.45, 0, 0.55, 1],
    easeInCubic: [0.32, 0, 0.67, 0],
    easeOutCubic: [0.33, 1, 0.68, 1],
    easeInOutCubic: [0.65, 0, 0.35, 1],
    easeInQuart: [0.5, 0, 0.75, 0],
    easeOutQuart: [0.25, 1, 0.5, 1],
    easeInOutQuart: [0.76, 0, 0.24, 1],
    easeInQuint: [0.64, 0, 0.78, 0],
    easeOutQuint: [0.22, 1, 0.36, 1],
    easeInOutQuint: [0.83, 0, 0.17, 1],
    easeInExpo: [0.7, 0, 0.84, 0],
    easeOutExpo: [0.16, 1, 0.3, 1],
    easeInOutExpo: [0.87, 0, 0.13, 1],
    easeInCirc: [0.55, 0, 1, 0.45],
    easeOutCirc: [0, 0.55, 0.45, 1],
    easeInOutCirc: [0.85, 0, 0.15, 1],
    easeInBack: [0.36, 0, 0.66, -0.56],
    easeOutBack: [0.34, 1.56, 0.64, 1],
    easeInOutBack: [0.68, -0.6, 0.32, 1.6]
  };
  __spreadValues2({
    linear: identity
  }, _TransitionPresets);
  function useVModel(props, key, emit, options = {}) {
    var _a2, _b, _c;
    const {
      clone = false,
      passive = false,
      eventName,
      deep = false,
      defaultValue
    } = options;
    const vm = getCurrentInstance();
    const _emit = emit || (vm == null ? void 0 : vm.emit) || ((_a2 = vm == null ? void 0 : vm.$emit) == null ? void 0 : _a2.bind(vm)) || ((_c = (_b = vm == null ? void 0 : vm.proxy) == null ? void 0 : _b.$emit) == null ? void 0 : _c.bind(vm == null ? void 0 : vm.proxy));
    let event = eventName;
    if (!key) {
      {
        key = "modelValue";
      }
    }
    event = eventName || event || `update:${key.toString()}`;
    const cloneFn = (val) => !clone ? val : isFunction(clone) ? clone(val) : cloneFnJSON(val);
    const getValue2 = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue;
    if (passive) {
      const initialValue = getValue2();
      const proxy = ref(initialValue);
      watch(() => props[key], (v2) => proxy.value = cloneFn(v2));
      watch(proxy, (v2) => {
        if (v2 !== props[key] || deep)
          _emit(event, v2);
      }, { deep });
      return proxy;
    } else {
      return computed({
        get() {
          return getValue2();
        },
        set(value) {
          _emit(event, value);
        }
      });
    }
  }
  Vue.isVNode;
  const isUndefined = (val) => val === void 0;
  const isElement = (e) => {
    if (typeof Element === "undefined")
      return false;
    return e instanceof Element;
  };
  const isStringNumber = (val) => {
    if (!isString$1(val)) {
      return false;
    }
    return !Number.isNaN(Number(val));
  };
  const keysOf = (arr) => Object.keys(arr);
  const entriesOf = (arr) => Object.entries(arr);
  const getProp = (obj, path, defaultValue) => {
    return {
      get value() {
        return get$2(obj, path, defaultValue);
      },
      set value(val) {
        set$2(obj, path, val);
      }
    };
  };
  class ElementPlusError extends Error {
    constructor(m2) {
      super(m2);
      this.name = "ElementPlusError";
    }
  }
  function throwError(scope, m2) {
    throw new ElementPlusError(`[${scope}] ${m2}`);
  }
  function debugWarn(scope, message) {
    {
      const error = isString$1(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
      console.warn(error);
    }
  }
  const SCOPE$2 = "utils/dom/style";
  const classNameToArray = (cls = "") => cls.split(" ").filter((item) => !!item.trim());
  const hasClass = (el, cls) => {
    if (!el || !cls)
      return false;
    if (cls.includes(" "))
      throw new Error("className should not contain space.");
    return el.classList.contains(cls);
  };
  const addClass = (el, cls) => {
    if (!el || !cls.trim())
      return;
    el.classList.add(...classNameToArray(cls));
  };
  const removeClass = (el, cls) => {
    if (!el || !cls.trim())
      return;
    el.classList.remove(...classNameToArray(cls));
  };
  const getStyle = (element, styleName) => {
    var _a2;
    if (!isClient || !element || !styleName)
      return "";
    let key = camelize(styleName);
    if (key === "float")
      key = "cssFloat";
    try {
      const style2 = element.style[key];
      if (style2)
        return style2;
      const computed2 = (_a2 = document.defaultView) == null ? void 0 : _a2.getComputedStyle(element, "");
      return computed2 ? computed2[key] : "";
    } catch (e) {
      return element.style[key];
    }
  };
  function addUnit(value, defaultUnit = "px") {
    if (!value)
      return "";
    if (isNumber(value) || isStringNumber(value)) {
      return `${value}${defaultUnit}`;
    } else if (isString$1(value)) {
      return value;
    }
    debugWarn(SCOPE$2, "binding value must be a string or number");
  }
  /*! Element Plus Icons Vue v2.0.10 */
  var export_helper_default = (sfc, props) => {
    let target = sfc.__vccOpts || sfc;
    for (let [key, val] of props)
      target[key] = val;
    return target;
  };
  var arrow_down_vue_vue_type_script_lang_default = {
    name: "ArrowDown"
  };
  var _hoisted_16 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_26 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
  }, null, -1), _hoisted_36 = [
    _hoisted_26
  ];
  function _sfc_render6(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_16, _hoisted_36);
  }
  var arrow_down_default = /* @__PURE__ */ export_helper_default(arrow_down_vue_vue_type_script_lang_default, [["render", _sfc_render6], ["__file", "arrow-down.vue"]]);
  var arrow_right_vue_vue_type_script_lang_default = {
    name: "ArrowRight"
  };
  var _hoisted_110 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_210 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"
  }, null, -1), _hoisted_310 = [
    _hoisted_210
  ];
  function _sfc_render10(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_110, _hoisted_310);
  }
  var arrow_right_default = /* @__PURE__ */ export_helper_default(arrow_right_vue_vue_type_script_lang_default, [["render", _sfc_render10], ["__file", "arrow-right.vue"]]);
  var arrow_up_vue_vue_type_script_lang_default = {
    name: "ArrowUp"
  };
  var _hoisted_112 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_212 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "m488.832 344.32-339.84 356.672a32 32 0 0 0 0 44.16l.384.384a29.44 29.44 0 0 0 42.688 0l320-335.872 319.872 335.872a29.44 29.44 0 0 0 42.688 0l.384-.384a32 32 0 0 0 0-44.16L535.168 344.32a32 32 0 0 0-46.336 0z"
  }, null, -1), _hoisted_312 = [
    _hoisted_212
  ];
  function _sfc_render12(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_112, _hoisted_312);
  }
  var arrow_up_default = /* @__PURE__ */ export_helper_default(arrow_up_vue_vue_type_script_lang_default, [["render", _sfc_render12], ["__file", "arrow-up.vue"]]);
  var check_vue_vue_type_script_lang_default = {
    name: "Check"
  };
  var _hoisted_143 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_243 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M406.656 706.944 195.84 496.256a32 32 0 1 0-45.248 45.248l256 256 512-512a32 32 0 0 0-45.248-45.248L406.592 706.944z"
  }, null, -1), _hoisted_342 = [
    _hoisted_243
  ];
  function _sfc_render43(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_143, _hoisted_342);
  }
  var check_default = /* @__PURE__ */ export_helper_default(check_vue_vue_type_script_lang_default, [["render", _sfc_render43], ["__file", "check.vue"]]);
  var circle_check_vue_vue_type_script_lang_default = {
    name: "CircleCheck"
  };
  var _hoisted_149 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_249 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"
  }, null, -1), _hoisted_348 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M745.344 361.344a32 32 0 0 1 45.312 45.312l-288 288a32 32 0 0 1-45.312 0l-160-160a32 32 0 1 1 45.312-45.312L480 626.752l265.344-265.408z"
  }, null, -1), _hoisted_415 = [
    _hoisted_249,
    _hoisted_348
  ];
  function _sfc_render49(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_149, _hoisted_415);
  }
  var circle_check_default = /* @__PURE__ */ export_helper_default(circle_check_vue_vue_type_script_lang_default, [["render", _sfc_render49], ["__file", "circle-check.vue"]]);
  var circle_close_filled_vue_vue_type_script_lang_default = {
    name: "CircleCloseFilled"
  };
  var _hoisted_150 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_250 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"
  }, null, -1), _hoisted_349 = [
    _hoisted_250
  ];
  function _sfc_render50(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_150, _hoisted_349);
  }
  var circle_close_filled_default = /* @__PURE__ */ export_helper_default(circle_close_filled_vue_vue_type_script_lang_default, [["render", _sfc_render50], ["__file", "circle-close-filled.vue"]]);
  var circle_close_vue_vue_type_script_lang_default = {
    name: "CircleClose"
  };
  var _hoisted_151 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_251 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"
  }, null, -1), _hoisted_350 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"
  }, null, -1), _hoisted_416 = [
    _hoisted_251,
    _hoisted_350
  ];
  function _sfc_render51(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_151, _hoisted_416);
  }
  var circle_close_default = /* @__PURE__ */ export_helper_default(circle_close_vue_vue_type_script_lang_default, [["render", _sfc_render51], ["__file", "circle-close.vue"]]);
  var close_vue_vue_type_script_lang_default = {
    name: "Close"
  };
  var _hoisted_156 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_256 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
  }, null, -1), _hoisted_355 = [
    _hoisted_256
  ];
  function _sfc_render56(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_156, _hoisted_355);
  }
  var close_default = /* @__PURE__ */ export_helper_default(close_vue_vue_type_script_lang_default, [["render", _sfc_render56], ["__file", "close.vue"]]);
  var delete_vue_vue_type_script_lang_default = {
    name: "Delete"
  };
  var _hoisted_180 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_280 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32V256zm448-64v-64H416v64h192zM224 896h576V256H224v640zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32zm192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32z"
  }, null, -1), _hoisted_379 = [
    _hoisted_280
  ];
  function _sfc_render80(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_180, _hoisted_379);
  }
  var delete_default = /* @__PURE__ */ export_helper_default(delete_vue_vue_type_script_lang_default, [["render", _sfc_render80], ["__file", "delete.vue"]]);
  var document_vue_vue_type_script_lang_default = {
    name: "Document"
  };
  var _hoisted_190 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_290 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M832 384H576V128H192v768h640V384zm-26.496-64L640 154.496V320h165.504zM160 64h480l256 256v608a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V96a32 32 0 0 1 32-32zm160 448h384v64H320v-64zm0-192h160v64H320v-64zm0 384h384v64H320v-64z"
  }, null, -1), _hoisted_389 = [
    _hoisted_290
  ];
  function _sfc_render90(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_190, _hoisted_389);
  }
  var document_default = /* @__PURE__ */ export_helper_default(document_vue_vue_type_script_lang_default, [["render", _sfc_render90], ["__file", "document.vue"]]);
  var hide_vue_vue_type_script_lang_default = {
    name: "Hide"
  };
  var _hoisted_1133 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2133 = /* @__PURE__ */ Vue.createElementVNode("path", {
    d: "M876.8 156.8c0-9.6-3.2-16-9.6-22.4-6.4-6.4-12.8-9.6-22.4-9.6-9.6 0-16 3.2-22.4 9.6L736 220.8c-64-32-137.6-51.2-224-60.8-160 16-288 73.6-377.6 176C44.8 438.4 0 496 0 512s48 73.6 134.4 176c22.4 25.6 44.8 48 73.6 67.2l-86.4 89.6c-6.4 6.4-9.6 12.8-9.6 22.4 0 9.6 3.2 16 9.6 22.4 6.4 6.4 12.8 9.6 22.4 9.6 9.6 0 16-3.2 22.4-9.6l704-710.4c3.2-6.4 6.4-12.8 6.4-22.4Zm-646.4 528c-76.8-70.4-128-128-153.6-172.8 28.8-48 80-105.6 153.6-172.8C304 272 400 230.4 512 224c64 3.2 124.8 19.2 176 44.8l-54.4 54.4C598.4 300.8 560 288 512 288c-64 0-115.2 22.4-160 64s-64 96-64 160c0 48 12.8 89.6 35.2 124.8L256 707.2c-9.6-6.4-19.2-16-25.6-22.4Zm140.8-96c-12.8-22.4-19.2-48-19.2-76.8 0-44.8 16-83.2 48-112 32-28.8 67.2-48 112-48 28.8 0 54.4 6.4 73.6 19.2L371.2 588.8ZM889.599 336c-12.8-16-28.8-28.8-41.6-41.6l-48 48c73.6 67.2 124.8 124.8 150.4 169.6-28.8 48-80 105.6-153.6 172.8-73.6 67.2-172.8 108.8-284.8 115.2-51.2-3.2-99.2-12.8-140.8-28.8l-48 48c57.6 22.4 118.4 38.4 188.8 44.8 160-16 288-73.6 377.6-176C979.199 585.6 1024 528 1024 512s-48.001-73.6-134.401-176Z",
    fill: "currentColor"
  }, null, -1), _hoisted_3132 = /* @__PURE__ */ Vue.createElementVNode("path", {
    d: "M511.998 672c-12.8 0-25.6-3.2-38.4-6.4l-51.2 51.2c28.8 12.8 57.6 19.2 89.6 19.2 64 0 115.2-22.4 160-64 41.6-41.6 64-96 64-160 0-32-6.4-64-19.2-89.6l-51.2 51.2c3.2 12.8 6.4 25.6 6.4 38.4 0 44.8-16 83.2-48 112-32 28.8-67.2 48-112 48Z",
    fill: "currentColor"
  }, null, -1), _hoisted_438 = [
    _hoisted_2133,
    _hoisted_3132
  ];
  function _sfc_render133(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1133, _hoisted_438);
  }
  var hide_default = /* @__PURE__ */ export_helper_default(hide_vue_vue_type_script_lang_default, [["render", _sfc_render133], ["__file", "hide.vue"]]);
  var info_filled_vue_vue_type_script_lang_default = {
    name: "InfoFilled"
  };
  var _hoisted_1143 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2143 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64zm67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344zM590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"
  }, null, -1), _hoisted_3142 = [
    _hoisted_2143
  ];
  function _sfc_render143(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1143, _hoisted_3142);
  }
  var info_filled_default = /* @__PURE__ */ export_helper_default(info_filled_vue_vue_type_script_lang_default, [["render", _sfc_render143], ["__file", "info-filled.vue"]]);
  var loading_vue_vue_type_script_lang_default = {
    name: "Loading"
  };
  var _hoisted_1150 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2150 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"
  }, null, -1), _hoisted_3149 = [
    _hoisted_2150
  ];
  function _sfc_render150(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1150, _hoisted_3149);
  }
  var loading_default = /* @__PURE__ */ export_helper_default(loading_vue_vue_type_script_lang_default, [["render", _sfc_render150], ["__file", "loading.vue"]]);
  var minus_vue_vue_type_script_lang_default = {
    name: "Minus"
  };
  var _hoisted_1169 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2169 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z"
  }, null, -1), _hoisted_3168 = [
    _hoisted_2169
  ];
  function _sfc_render169(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1169, _hoisted_3168);
  }
  var minus_default = /* @__PURE__ */ export_helper_default(minus_vue_vue_type_script_lang_default, [["render", _sfc_render169], ["__file", "minus.vue"]]);
  var plus_vue_vue_type_script_lang_default = {
    name: "Plus"
  };
  var _hoisted_1201 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2201 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"
  }, null, -1), _hoisted_3200 = [
    _hoisted_2201
  ];
  function _sfc_render201(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1201, _hoisted_3200);
  }
  var plus_default = /* @__PURE__ */ export_helper_default(plus_vue_vue_type_script_lang_default, [["render", _sfc_render201], ["__file", "plus.vue"]]);
  var success_filled_vue_vue_type_script_lang_default = {
    name: "SuccessFilled"
  };
  var _hoisted_1249 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2249 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.272 38.272 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336L456.192 600.384z"
  }, null, -1), _hoisted_3248 = [
    _hoisted_2249
  ];
  function _sfc_render249(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1249, _hoisted_3248);
  }
  var success_filled_default = /* @__PURE__ */ export_helper_default(success_filled_vue_vue_type_script_lang_default, [["render", _sfc_render249], ["__file", "success-filled.vue"]]);
  var view_vue_vue_type_script_lang_default = {
    name: "View"
  };
  var _hoisted_1283 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2283 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448zm0 64a160.192 160.192 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"
  }, null, -1), _hoisted_3282 = [
    _hoisted_2283
  ];
  function _sfc_render283(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1283, _hoisted_3282);
  }
  var view_default = /* @__PURE__ */ export_helper_default(view_vue_vue_type_script_lang_default, [["render", _sfc_render283], ["__file", "view.vue"]]);
  var warning_filled_vue_vue_type_script_lang_default = {
    name: "WarningFilled"
  };
  var _hoisted_1287 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2287 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 192a58.432 58.432 0 0 0-58.24 63.744l23.36 256.384a35.072 35.072 0 0 0 69.76 0l23.296-256.384A58.432 58.432 0 0 0 512 256zm0 512a51.2 51.2 0 1 0 0-102.4 51.2 51.2 0 0 0 0 102.4z"
  }, null, -1), _hoisted_3286 = [
    _hoisted_2287
  ];
  function _sfc_render287(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1287, _hoisted_3286);
  }
  var warning_filled_default = /* @__PURE__ */ export_helper_default(warning_filled_vue_vue_type_script_lang_default, [["render", _sfc_render287], ["__file", "warning-filled.vue"]]);
  var zoom_in_vue_vue_type_script_lang_default = {
    name: "ZoomIn"
  };
  var _hoisted_1292 = {
    viewBox: "0 0 1024 1024",
    xmlns: "http://www.w3.org/2000/svg"
  }, _hoisted_2292 = /* @__PURE__ */ Vue.createElementVNode("path", {
    fill: "currentColor",
    d: "m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704zm-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64h96z"
  }, null, -1), _hoisted_3291 = [
    _hoisted_2292
  ];
  function _sfc_render292(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_1292, _hoisted_3291);
  }
  var zoom_in_default = /* @__PURE__ */ export_helper_default(zoom_in_vue_vue_type_script_lang_default, [["render", _sfc_render292], ["__file", "zoom-in.vue"]]);
  const epPropKey = "__epPropKey";
  const definePropType = (val) => val;
  const isEpProp = (val) => isObject(val) && !!val[epPropKey];
  const buildProp = (prop, key) => {
    if (!isObject(prop) || isEpProp(prop))
      return prop;
    const { values, required, default: defaultValue, type, validator } = prop;
    const _validator = values || validator ? (val) => {
      let valid = false;
      let allowedValues = [];
      if (values) {
        allowedValues = Array.from(values);
        if (hasOwn(prop, "default")) {
          allowedValues.push(defaultValue);
        }
        valid || (valid = allowedValues.includes(val));
      }
      if (validator)
        valid || (valid = validator(val));
      if (!valid && allowedValues.length > 0) {
        const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
        Vue.warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
      }
      return valid;
    } : void 0;
    const epProp = {
      type,
      required: !!required,
      validator: _validator,
      [epPropKey]: true
    };
    if (hasOwn(prop, "default"))
      epProp.default = defaultValue;
    return epProp;
  };
  const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
    key,
    buildProp(option, key)
  ]));
  const iconPropType = definePropType([
    String,
    Object,
    Function
  ]);
  const TypeComponents = {
    Close: close_default,
    SuccessFilled: success_filled_default,
    InfoFilled: info_filled_default,
    WarningFilled: warning_filled_default,
    CircleCloseFilled: circle_close_filled_default
  };
  const TypeComponentsMap = {
    success: success_filled_default,
    warning: warning_filled_default,
    error: circle_close_filled_default,
    info: info_filled_default
  };
  const ValidateComponentsMap = {
    validating: loading_default,
    success: circle_check_default,
    error: circle_close_default
  };
  const withInstall = (main, extra) => {
    main.install = (app2) => {
      for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
        app2.component(comp.name, comp);
      }
    };
    if (extra) {
      for (const [key, comp] of Object.entries(extra)) {
        main[key] = comp;
      }
    }
    return main;
  };
  const withNoopInstall = (component) => {
    component.install = NOOP;
    return component;
  };
  const EVENT_CODE = {
    tab: "Tab",
    enter: "Enter",
    space: "Space",
    left: "ArrowLeft",
    up: "ArrowUp",
    right: "ArrowRight",
    down: "ArrowDown",
    esc: "Escape",
    delete: "Delete",
    backspace: "Backspace",
    numpadEnter: "NumpadEnter",
    pageUp: "PageUp",
    pageDown: "PageDown",
    home: "Home",
    end: "End"
  };
  const UPDATE_MODEL_EVENT = "update:modelValue";
  const CHANGE_EVENT = "change";
  const INPUT_EVENT = "input";
  const componentSizes = ["", "default", "small", "large"];
  const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
  const mutable = (val) => val;
  const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
  const LISTENER_PREFIX = /^on[A-Z]/;
  const useAttrs = (params = {}) => {
    const { excludeListeners = false, excludeKeys } = params;
    const allExcludeKeys = Vue.computed(() => {
      return ((excludeKeys == null ? void 0 : excludeKeys.value) || []).concat(DEFAULT_EXCLUDE_KEYS);
    });
    const instance = Vue.getCurrentInstance();
    if (!instance) {
      debugWarn("use-attrs", "getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function");
      return Vue.computed(() => ({}));
    }
    return Vue.computed(() => {
      var _a2;
      return fromPairs(Object.entries((_a2 = instance.proxy) == null ? void 0 : _a2.$attrs).filter(([key]) => !allExcludeKeys.value.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key))));
    });
  };
  const buttonGroupContextKey = Symbol("buttonGroupContextKey");
  const checkboxGroupContextKey = Symbol("checkboxGroupContextKey");
  const configProviderContextKey = Symbol();
  const formContextKey = Symbol("formContextKey");
  const formItemContextKey = Symbol("formItemContextKey");
  const scrollbarContextKey = Symbol("scrollbarContextKey");
  const uploadContextKey = Symbol("uploadContextKey");
  const POPPER_INJECTION_KEY = Symbol("popper");
  const POPPER_CONTENT_INJECTION_KEY = Symbol("popperContent");
  const TOOLTIP_INJECTION_KEY = Symbol("elTooltip");
  const useProp = (name) => {
    const vm = Vue.getCurrentInstance();
    return Vue.computed(() => {
      var _a2, _b;
      return (_b = ((_a2 = vm.proxy) == null ? void 0 : _a2.$props)[name]) != null ? _b : void 0;
    });
  };
  const globalConfig = Vue.ref();
  function useGlobalConfig(key, defaultValue = void 0) {
    const config = Vue.getCurrentInstance() ? Vue.inject(configProviderContextKey, globalConfig) : globalConfig;
    if (key) {
      return Vue.computed(() => {
        var _a2, _b;
        return (_b = (_a2 = config.value) == null ? void 0 : _a2[key]) != null ? _b : defaultValue;
      });
    } else {
      return config;
    }
  }
  const useSizeProp = buildProp({
    type: String,
    values: componentSizes,
    required: false
  });
  const useSize = (fallback, ignore = {}) => {
    const emptyRef = Vue.ref(void 0);
    const size2 = ignore.prop ? emptyRef : useProp("size");
    const globalConfig2 = ignore.global ? emptyRef : useGlobalConfig("size");
    const form = ignore.form ? { size: void 0 } : Vue.inject(formContextKey, void 0);
    const formItem = ignore.formItem ? { size: void 0 } : Vue.inject(formItemContextKey, void 0);
    return Vue.computed(() => size2.value || Vue.unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig2.value || "");
  };
  const useDisabled = (fallback) => {
    const disabled = useProp("disabled");
    const form = Vue.inject(formContextKey, void 0);
    return Vue.computed(() => disabled.value || Vue.unref(fallback) || (form == null ? void 0 : form.disabled) || false);
  };
  const useDeprecated = ({ from, replacement, scope, version, ref: ref2, type = "API" }, condition) => {
    Vue.watch(() => Vue.unref(condition), (val) => {
      if (val) {
        debugWarn(scope, `[${type}] ${from} is about to be deprecated in version ${version}, please use ${replacement} instead.
For more detail, please visit: ${ref2}
`);
      }
    }, {
      immediate: true
    });
  };
  const defaultNamespace = "el";
  const statePrefix = "is-";
  const _bem = (namespace, block, blockSuffix, element, modifier) => {
    let cls = `${namespace}-${block}`;
    if (blockSuffix) {
      cls += `-${blockSuffix}`;
    }
    if (element) {
      cls += `__${element}`;
    }
    if (modifier) {
      cls += `--${modifier}`;
    }
    return cls;
  };
  const useNamespace = (block) => {
    const namespace = useGlobalConfig("namespace", defaultNamespace);
    const b2 = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
    const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
    const m2 = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
    const be2 = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
    const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
    const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
    const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
    const is = (name, ...args) => {
      const state = args.length >= 1 ? args[0] : true;
      return name && state ? `${statePrefix}${name}` : "";
    };
    const cssVar = (object) => {
      const styles = {};
      for (const key in object) {
        if (object[key]) {
          styles[`--${namespace.value}-${key}`] = object[key];
        }
      }
      return styles;
    };
    const cssVarBlock = (object) => {
      const styles = {};
      for (const key in object) {
        if (object[key]) {
          styles[`--${namespace.value}-${block}-${key}`] = object[key];
        }
      }
      return styles;
    };
    const cssVarName = (name) => `--${namespace.value}-${name}`;
    const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
    return {
      namespace,
      b: b2,
      e,
      m: m2,
      be: be2,
      em,
      bm,
      bem,
      is,
      cssVar,
      cssVarName,
      cssVarBlock,
      cssVarBlockName
    };
  };
  const defaultIdInjection = {
    prefix: Math.floor(Math.random() * 1e4),
    current: 0
  };
  const ID_INJECTION_KEY = Symbol("elIdInjection");
  const useIdInjection = () => {
    return Vue.getCurrentInstance() ? Vue.inject(ID_INJECTION_KEY, defaultIdInjection) : defaultIdInjection;
  };
  const useId = (deterministicId) => {
    const idInjection = useIdInjection();
    if (!isClient && idInjection === defaultIdInjection) {
      debugWarn("IdInjection", `Looks like you are using server rendering, you must provide a id provider to ensure the hydration process to be succeed
usage: app.provide(ID_INJECTION_KEY, {
  prefix: number,
  current: number,
})`);
    }
    const namespace = useGlobalConfig("namespace", defaultNamespace);
    const idRef = Vue.computed(() => Vue.unref(deterministicId) || `${namespace.value}-id-${idInjection.prefix}-${idInjection.current++}`);
    return idRef;
  };
  const useFormItem = () => {
    const form = Vue.inject(formContextKey, void 0);
    const formItem = Vue.inject(formItemContextKey, void 0);
    return {
      form,
      formItem
    };
  };
  const useFormItemInputId = (props, {
    formItemContext,
    disableIdGeneration,
    disableIdManagement
  }) => {
    if (!disableIdGeneration) {
      disableIdGeneration = Vue.ref(false);
    }
    if (!disableIdManagement) {
      disableIdManagement = Vue.ref(false);
    }
    const inputId = Vue.ref();
    let idUnwatch = void 0;
    const isLabeledByFormItem = Vue.computed(() => {
      var _a2;
      return !!(!props.label && formItemContext && formItemContext.inputIds && ((_a2 = formItemContext.inputIds) == null ? void 0 : _a2.length) <= 1);
    });
    Vue.onMounted(() => {
      idUnwatch = Vue.watch([Vue.toRef(props, "id"), disableIdGeneration], ([id, disableIdGeneration2]) => {
        const newId = id != null ? id : !disableIdGeneration2 ? useId().value : void 0;
        if (newId !== inputId.value) {
          if (formItemContext == null ? void 0 : formItemContext.removeInputId) {
            inputId.value && formItemContext.removeInputId(inputId.value);
            if (!(disableIdManagement == null ? void 0 : disableIdManagement.value) && !disableIdGeneration2 && newId) {
              formItemContext.addInputId(newId);
            }
          }
          inputId.value = newId;
        }
      }, { immediate: true });
    });
    Vue.onUnmounted(() => {
      idUnwatch && idUnwatch();
      if (formItemContext == null ? void 0 : formItemContext.removeInputId) {
        inputId.value && formItemContext.removeInputId(inputId.value);
      }
    });
    return {
      isLabeledByFormItem,
      inputId
    };
  };
  var English = {
    name: "en",
    el: {
      colorpicker: {
        confirm: "OK",
        clear: "Clear",
        defaultLabel: "color picker",
        description: "current color is {color}. press enter to select a new color."
      },
      datepicker: {
        now: "Now",
        today: "Today",
        cancel: "Cancel",
        clear: "Clear",
        confirm: "OK",
        dateTablePrompt: "Use the arrow keys and enter to select the day of the month",
        monthTablePrompt: "Use the arrow keys and enter to select the month",
        yearTablePrompt: "Use the arrow keys and enter to select the year",
        selectedDate: "Selected date",
        selectDate: "Select date",
        selectTime: "Select time",
        startDate: "Start Date",
        startTime: "Start Time",
        endDate: "End Date",
        endTime: "End Time",
        prevYear: "Previous Year",
        nextYear: "Next Year",
        prevMonth: "Previous Month",
        nextMonth: "Next Month",
        year: "",
        month1: "January",
        month2: "February",
        month3: "March",
        month4: "April",
        month5: "May",
        month6: "June",
        month7: "July",
        month8: "August",
        month9: "September",
        month10: "October",
        month11: "November",
        month12: "December",
        week: "week",
        weeks: {
          sun: "Sun",
          mon: "Mon",
          tue: "Tue",
          wed: "Wed",
          thu: "Thu",
          fri: "Fri",
          sat: "Sat"
        },
        weeksFull: {
          sun: "Sunday",
          mon: "Monday",
          tue: "Tuesday",
          wed: "Wednesday",
          thu: "Thursday",
          fri: "Friday",
          sat: "Saturday"
        },
        months: {
          jan: "Jan",
          feb: "Feb",
          mar: "Mar",
          apr: "Apr",
          may: "May",
          jun: "Jun",
          jul: "Jul",
          aug: "Aug",
          sep: "Sep",
          oct: "Oct",
          nov: "Nov",
          dec: "Dec"
        }
      },
      inputNumber: {
        decrease: "decrease number",
        increase: "increase number"
      },
      select: {
        loading: "Loading",
        noMatch: "No matching data",
        noData: "No data",
        placeholder: "Select"
      },
      dropdown: {
        toggleDropdown: "Toggle Dropdown"
      },
      cascader: {
        noMatch: "No matching data",
        loading: "Loading",
        placeholder: "Select",
        noData: "No data"
      },
      pagination: {
        goto: "Go to",
        pagesize: "/page",
        total: "Total {total}",
        pageClassifier: "",
        deprecationWarning: "Deprecated usages detected, please refer to the el-pagination documentation for more details"
      },
      dialog: {
        close: "Close this dialog"
      },
      drawer: {
        close: "Close this dialog"
      },
      messagebox: {
        title: "Message",
        confirm: "OK",
        cancel: "Cancel",
        error: "Illegal input",
        close: "Close this dialog"
      },
      upload: {
        deleteTip: "press delete to remove",
        delete: "Delete",
        preview: "Preview",
        continue: "Continue"
      },
      slider: {
        defaultLabel: "slider between {min} and {max}",
        defaultRangeStartLabel: "pick start value",
        defaultRangeEndLabel: "pick end value"
      },
      table: {
        emptyText: "No Data",
        confirmFilter: "Confirm",
        resetFilter: "Reset",
        clearFilter: "All",
        sumText: "Sum"
      },
      tree: {
        emptyText: "No Data"
      },
      transfer: {
        noMatch: "No matching data",
        noData: "No data",
        titles: ["List 1", "List 2"],
        filterPlaceholder: "Enter keyword",
        noCheckedFormat: "{total} items",
        hasCheckedFormat: "{checked}/{total} checked"
      },
      image: {
        error: "FAILED"
      },
      pageHeader: {
        title: "Back"
      },
      popconfirm: {
        confirmButtonText: "Yes",
        cancelButtonText: "No"
      }
    }
  };
  const buildTranslator = (locale) => (path, option) => translate(path, option, Vue.unref(locale));
  const translate = (path, option, locale) => get$2(locale, path, path).replace(/\{(\w+)\}/g, (_2, key) => {
    var _a2;
    return `${(_a2 = option == null ? void 0 : option[key]) != null ? _a2 : `{${key}}`}`;
  });
  const buildLocaleContext = (locale) => {
    const lang = Vue.computed(() => Vue.unref(locale).name);
    const localeRef = Vue.isRef(locale) ? locale : Vue.ref(locale);
    return {
      lang,
      locale: localeRef,
      t: buildTranslator(locale)
    };
  };
  const useLocale = () => {
    const locale = useGlobalConfig("locale");
    return buildLocaleContext(Vue.computed(() => locale.value || English));
  };
  const _prop = buildProp({
    type: definePropType(Boolean),
    default: null
  });
  const _event = buildProp({
    type: definePropType(Function)
  });
  const createModelToggleComposable = (name) => {
    const updateEventKey = `update:${name}`;
    const updateEventKeyRaw = `onUpdate:${name}`;
    const useModelToggleEmits2 = [updateEventKey];
    const useModelToggleProps2 = {
      [name]: _prop,
      [updateEventKeyRaw]: _event
    };
    const useModelToggle2 = ({
      indicator,
      toggleReason,
      shouldHideWhenRouteChanges,
      shouldProceed,
      onShow,
      onHide
    }) => {
      const instance = Vue.getCurrentInstance();
      const { emit } = instance;
      const props = instance.props;
      const hasUpdateHandler = Vue.computed(() => isFunction$1(props[updateEventKeyRaw]));
      const isModelBindingAbsent = Vue.computed(() => props[name] === null);
      const doShow = (event) => {
        if (indicator.value === true) {
          return;
        }
        indicator.value = true;
        if (toggleReason) {
          toggleReason.value = event;
        }
        if (isFunction$1(onShow)) {
          onShow(event);
        }
      };
      const doHide = (event) => {
        if (indicator.value === false) {
          return;
        }
        indicator.value = false;
        if (toggleReason) {
          toggleReason.value = event;
        }
        if (isFunction$1(onHide)) {
          onHide(event);
        }
      };
      const show = (event) => {
        if (props.disabled === true || isFunction$1(shouldProceed) && !shouldProceed())
          return;
        const shouldEmit = hasUpdateHandler.value && isClient;
        if (shouldEmit) {
          emit(updateEventKey, true);
        }
        if (isModelBindingAbsent.value || !shouldEmit) {
          doShow(event);
        }
      };
      const hide = (event) => {
        if (props.disabled === true || !isClient)
          return;
        const shouldEmit = hasUpdateHandler.value && isClient;
        if (shouldEmit) {
          emit(updateEventKey, false);
        }
        if (isModelBindingAbsent.value || !shouldEmit) {
          doHide(event);
        }
      };
      const onChange = (val) => {
        if (!isBoolean(val))
          return;
        if (props.disabled && val) {
          if (hasUpdateHandler.value) {
            emit(updateEventKey, false);
          }
        } else if (indicator.value !== val) {
          if (val) {
            doShow();
          } else {
            doHide();
          }
        }
      };
      const toggle = () => {
        if (indicator.value) {
          hide();
        } else {
          show();
        }
      };
      Vue.watch(() => props[name], onChange);
      if (shouldHideWhenRouteChanges && instance.appContext.config.globalProperties.$route !== void 0) {
        Vue.watch(() => __spreadValues({}, instance.proxy.$route), () => {
          if (shouldHideWhenRouteChanges.value && indicator.value) {
            hide();
          }
        });
      }
      Vue.onMounted(() => {
        onChange(props[name]);
      });
      return {
        hide,
        show,
        toggle,
        hasUpdateHandler
      };
    };
    return {
      useModelToggle: useModelToggle2,
      useModelToggleProps: useModelToggleProps2,
      useModelToggleEmits: useModelToggleEmits2
    };
  };
  var E$1 = "top", R = "bottom", W = "right", P$1 = "left", me = "auto", G = [E$1, R, W, P$1], U$1 = "start", J = "end", Xe = "clippingParents", je = "viewport", K = "popper", Ye = "reference", De = G.reduce(function(t, e) {
    return t.concat([e + "-" + U$1, e + "-" + J]);
  }, []), Ee = [].concat(G, [me]).reduce(function(t, e) {
    return t.concat([e, e + "-" + U$1, e + "-" + J]);
  }, []), Ge = "beforeRead", Je = "read", Ke = "afterRead", Qe = "beforeMain", Ze = "main", et = "afterMain", tt = "beforeWrite", nt = "write", rt = "afterWrite", ot = [Ge, Je, Ke, Qe, Ze, et, tt, nt, rt];
  function C(t) {
    return t ? (t.nodeName || "").toLowerCase() : null;
  }
  function H(t) {
    if (t == null)
      return window;
    if (t.toString() !== "[object Window]") {
      var e = t.ownerDocument;
      return e && e.defaultView || window;
    }
    return t;
  }
  function Q(t) {
    var e = H(t).Element;
    return t instanceof e || t instanceof Element;
  }
  function B(t) {
    var e = H(t).HTMLElement;
    return t instanceof e || t instanceof HTMLElement;
  }
  function Pe(t) {
    if (typeof ShadowRoot == "undefined")
      return false;
    var e = H(t).ShadowRoot;
    return t instanceof e || t instanceof ShadowRoot;
  }
  function Mt(t) {
    var e = t.state;
    Object.keys(e.elements).forEach(function(n) {
      var r = e.styles[n] || {}, o2 = e.attributes[n] || {}, i = e.elements[n];
      !B(i) || !C(i) || (Object.assign(i.style, r), Object.keys(o2).forEach(function(a2) {
        var s2 = o2[a2];
        s2 === false ? i.removeAttribute(a2) : i.setAttribute(a2, s2 === true ? "" : s2);
      }));
    });
  }
  function Rt(t) {
    var e = t.state, n = { popper: { position: e.options.strategy, left: "0", top: "0", margin: "0" }, arrow: { position: "absolute" }, reference: {} };
    return Object.assign(e.elements.popper.style, n.popper), e.styles = n, e.elements.arrow && Object.assign(e.elements.arrow.style, n.arrow), function() {
      Object.keys(e.elements).forEach(function(r) {
        var o2 = e.elements[r], i = e.attributes[r] || {}, a2 = Object.keys(e.styles.hasOwnProperty(r) ? e.styles[r] : n[r]), s2 = a2.reduce(function(f2, c2) {
          return f2[c2] = "", f2;
        }, {});
        !B(o2) || !C(o2) || (Object.assign(o2.style, s2), Object.keys(i).forEach(function(f2) {
          o2.removeAttribute(f2);
        }));
      });
    };
  }
  var Ae = { name: "applyStyles", enabled: true, phase: "write", fn: Mt, effect: Rt, requires: ["computeStyles"] };
  function q(t) {
    return t.split("-")[0];
  }
  var X$1 = Math.max, ve = Math.min, Z = Math.round;
  function ee(t, e) {
    e === void 0 && (e = false);
    var n = t.getBoundingClientRect(), r = 1, o2 = 1;
    if (B(t) && e) {
      var i = t.offsetHeight, a2 = t.offsetWidth;
      a2 > 0 && (r = Z(n.width) / a2 || 1), i > 0 && (o2 = Z(n.height) / i || 1);
    }
    return { width: n.width / r, height: n.height / o2, top: n.top / o2, right: n.right / r, bottom: n.bottom / o2, left: n.left / r, x: n.left / r, y: n.top / o2 };
  }
  function ke(t) {
    var e = ee(t), n = t.offsetWidth, r = t.offsetHeight;
    return Math.abs(e.width - n) <= 1 && (n = e.width), Math.abs(e.height - r) <= 1 && (r = e.height), { x: t.offsetLeft, y: t.offsetTop, width: n, height: r };
  }
  function it(t, e) {
    var n = e.getRootNode && e.getRootNode();
    if (t.contains(e))
      return true;
    if (n && Pe(n)) {
      var r = e;
      do {
        if (r && t.isSameNode(r))
          return true;
        r = r.parentNode || r.host;
      } while (r);
    }
    return false;
  }
  function N$1(t) {
    return H(t).getComputedStyle(t);
  }
  function Wt(t) {
    return ["table", "td", "th"].indexOf(C(t)) >= 0;
  }
  function I$1(t) {
    return ((Q(t) ? t.ownerDocument : t.document) || window.document).documentElement;
  }
  function ge(t) {
    return C(t) === "html" ? t : t.assignedSlot || t.parentNode || (Pe(t) ? t.host : null) || I$1(t);
  }
  function at(t) {
    return !B(t) || N$1(t).position === "fixed" ? null : t.offsetParent;
  }
  function Bt(t) {
    var e = navigator.userAgent.toLowerCase().indexOf("firefox") !== -1, n = navigator.userAgent.indexOf("Trident") !== -1;
    if (n && B(t)) {
      var r = N$1(t);
      if (r.position === "fixed")
        return null;
    }
    var o2 = ge(t);
    for (Pe(o2) && (o2 = o2.host); B(o2) && ["html", "body"].indexOf(C(o2)) < 0; ) {
      var i = N$1(o2);
      if (i.transform !== "none" || i.perspective !== "none" || i.contain === "paint" || ["transform", "perspective"].indexOf(i.willChange) !== -1 || e && i.willChange === "filter" || e && i.filter && i.filter !== "none")
        return o2;
      o2 = o2.parentNode;
    }
    return null;
  }
  function se(t) {
    for (var e = H(t), n = at(t); n && Wt(n) && N$1(n).position === "static"; )
      n = at(n);
    return n && (C(n) === "html" || C(n) === "body" && N$1(n).position === "static") ? e : n || Bt(t) || e;
  }
  function Le(t) {
    return ["top", "bottom"].indexOf(t) >= 0 ? "x" : "y";
  }
  function fe(t, e, n) {
    return X$1(t, ve(e, n));
  }
  function St(t, e, n) {
    var r = fe(t, e, n);
    return r > n ? n : r;
  }
  function st() {
    return { top: 0, right: 0, bottom: 0, left: 0 };
  }
  function ft(t) {
    return Object.assign({}, st(), t);
  }
  function ct(t, e) {
    return e.reduce(function(n, r) {
      return n[r] = t, n;
    }, {});
  }
  var Tt = function(t, e) {
    return t = typeof t == "function" ? t(Object.assign({}, e.rects, { placement: e.placement })) : t, ft(typeof t != "number" ? t : ct(t, G));
  };
  function Ht(t) {
    var e, n = t.state, r = t.name, o2 = t.options, i = n.elements.arrow, a2 = n.modifiersData.popperOffsets, s2 = q(n.placement), f2 = Le(s2), c2 = [P$1, W].indexOf(s2) >= 0, u2 = c2 ? "height" : "width";
    if (!(!i || !a2)) {
      var m2 = Tt(o2.padding, n), v2 = ke(i), l2 = f2 === "y" ? E$1 : P$1, h2 = f2 === "y" ? R : W, p2 = n.rects.reference[u2] + n.rects.reference[f2] - a2[f2] - n.rects.popper[u2], g = a2[f2] - n.rects.reference[f2], x2 = se(i), y = x2 ? f2 === "y" ? x2.clientHeight || 0 : x2.clientWidth || 0 : 0, $2 = p2 / 2 - g / 2, d2 = m2[l2], b2 = y - v2[u2] - m2[h2], w2 = y / 2 - v2[u2] / 2 + $2, O2 = fe(d2, w2, b2), j = f2;
      n.modifiersData[r] = (e = {}, e[j] = O2, e.centerOffset = O2 - w2, e);
    }
  }
  function Ct(t) {
    var e = t.state, n = t.options, r = n.element, o2 = r === void 0 ? "[data-popper-arrow]" : r;
    o2 != null && (typeof o2 == "string" && (o2 = e.elements.popper.querySelector(o2), !o2) || !it(e.elements.popper, o2) || (e.elements.arrow = o2));
  }
  var pt = { name: "arrow", enabled: true, phase: "main", fn: Ht, effect: Ct, requires: ["popperOffsets"], requiresIfExists: ["preventOverflow"] };
  function te(t) {
    return t.split("-")[1];
  }
  var qt = { top: "auto", right: "auto", bottom: "auto", left: "auto" };
  function Vt(t) {
    var e = t.x, n = t.y, r = window, o2 = r.devicePixelRatio || 1;
    return { x: Z(e * o2) / o2 || 0, y: Z(n * o2) / o2 || 0 };
  }
  function ut(t) {
    var e, n = t.popper, r = t.popperRect, o2 = t.placement, i = t.variation, a2 = t.offsets, s2 = t.position, f2 = t.gpuAcceleration, c2 = t.adaptive, u2 = t.roundOffsets, m2 = t.isFixed, v2 = a2.x, l2 = v2 === void 0 ? 0 : v2, h2 = a2.y, p2 = h2 === void 0 ? 0 : h2, g = typeof u2 == "function" ? u2({ x: l2, y: p2 }) : { x: l2, y: p2 };
    l2 = g.x, p2 = g.y;
    var x2 = a2.hasOwnProperty("x"), y = a2.hasOwnProperty("y"), $2 = P$1, d2 = E$1, b2 = window;
    if (c2) {
      var w2 = se(n), O2 = "clientHeight", j = "clientWidth";
      if (w2 === H(n) && (w2 = I$1(n), N$1(w2).position !== "static" && s2 === "absolute" && (O2 = "scrollHeight", j = "scrollWidth")), w2 = w2, o2 === E$1 || (o2 === P$1 || o2 === W) && i === J) {
        d2 = R;
        var A2 = m2 && w2 === b2 && b2.visualViewport ? b2.visualViewport.height : w2[O2];
        p2 -= A2 - r.height, p2 *= f2 ? 1 : -1;
      }
      if (o2 === P$1 || (o2 === E$1 || o2 === R) && i === J) {
        $2 = W;
        var k = m2 && w2 === b2 && b2.visualViewport ? b2.visualViewport.width : w2[j];
        l2 -= k - r.width, l2 *= f2 ? 1 : -1;
      }
    }
    var D2 = Object.assign({ position: s2 }, c2 && qt), S2 = u2 === true ? Vt({ x: l2, y: p2 }) : { x: l2, y: p2 };
    if (l2 = S2.x, p2 = S2.y, f2) {
      var L;
      return Object.assign({}, D2, (L = {}, L[d2] = y ? "0" : "", L[$2] = x2 ? "0" : "", L.transform = (b2.devicePixelRatio || 1) <= 1 ? "translate(" + l2 + "px, " + p2 + "px)" : "translate3d(" + l2 + "px, " + p2 + "px, 0)", L));
    }
    return Object.assign({}, D2, (e = {}, e[d2] = y ? p2 + "px" : "", e[$2] = x2 ? l2 + "px" : "", e.transform = "", e));
  }
  function Nt(t) {
    var e = t.state, n = t.options, r = n.gpuAcceleration, o2 = r === void 0 ? true : r, i = n.adaptive, a2 = i === void 0 ? true : i, s2 = n.roundOffsets, f2 = s2 === void 0 ? true : s2, c2 = { placement: q(e.placement), variation: te(e.placement), popper: e.elements.popper, popperRect: e.rects.popper, gpuAcceleration: o2, isFixed: e.options.strategy === "fixed" };
    e.modifiersData.popperOffsets != null && (e.styles.popper = Object.assign({}, e.styles.popper, ut(Object.assign({}, c2, { offsets: e.modifiersData.popperOffsets, position: e.options.strategy, adaptive: a2, roundOffsets: f2 })))), e.modifiersData.arrow != null && (e.styles.arrow = Object.assign({}, e.styles.arrow, ut(Object.assign({}, c2, { offsets: e.modifiersData.arrow, position: "absolute", adaptive: false, roundOffsets: f2 })))), e.attributes.popper = Object.assign({}, e.attributes.popper, { "data-popper-placement": e.placement });
  }
  var Me = { name: "computeStyles", enabled: true, phase: "beforeWrite", fn: Nt, data: {} }, ye = { passive: true };
  function It(t) {
    var e = t.state, n = t.instance, r = t.options, o2 = r.scroll, i = o2 === void 0 ? true : o2, a2 = r.resize, s2 = a2 === void 0 ? true : a2, f2 = H(e.elements.popper), c2 = [].concat(e.scrollParents.reference, e.scrollParents.popper);
    return i && c2.forEach(function(u2) {
      u2.addEventListener("scroll", n.update, ye);
    }), s2 && f2.addEventListener("resize", n.update, ye), function() {
      i && c2.forEach(function(u2) {
        u2.removeEventListener("scroll", n.update, ye);
      }), s2 && f2.removeEventListener("resize", n.update, ye);
    };
  }
  var Re = { name: "eventListeners", enabled: true, phase: "write", fn: function() {
  }, effect: It, data: {} }, _t = { left: "right", right: "left", bottom: "top", top: "bottom" };
  function be(t) {
    return t.replace(/left|right|bottom|top/g, function(e) {
      return _t[e];
    });
  }
  var zt = { start: "end", end: "start" };
  function lt(t) {
    return t.replace(/start|end/g, function(e) {
      return zt[e];
    });
  }
  function We(t) {
    var e = H(t), n = e.pageXOffset, r = e.pageYOffset;
    return { scrollLeft: n, scrollTop: r };
  }
  function Be(t) {
    return ee(I$1(t)).left + We(t).scrollLeft;
  }
  function Ft(t) {
    var e = H(t), n = I$1(t), r = e.visualViewport, o2 = n.clientWidth, i = n.clientHeight, a2 = 0, s2 = 0;
    return r && (o2 = r.width, i = r.height, /^((?!chrome|android).)*safari/i.test(navigator.userAgent) || (a2 = r.offsetLeft, s2 = r.offsetTop)), { width: o2, height: i, x: a2 + Be(t), y: s2 };
  }
  function Ut(t) {
    var e, n = I$1(t), r = We(t), o2 = (e = t.ownerDocument) == null ? void 0 : e.body, i = X$1(n.scrollWidth, n.clientWidth, o2 ? o2.scrollWidth : 0, o2 ? o2.clientWidth : 0), a2 = X$1(n.scrollHeight, n.clientHeight, o2 ? o2.scrollHeight : 0, o2 ? o2.clientHeight : 0), s2 = -r.scrollLeft + Be(t), f2 = -r.scrollTop;
    return N$1(o2 || n).direction === "rtl" && (s2 += X$1(n.clientWidth, o2 ? o2.clientWidth : 0) - i), { width: i, height: a2, x: s2, y: f2 };
  }
  function Se(t) {
    var e = N$1(t), n = e.overflow, r = e.overflowX, o2 = e.overflowY;
    return /auto|scroll|overlay|hidden/.test(n + o2 + r);
  }
  function dt(t) {
    return ["html", "body", "#document"].indexOf(C(t)) >= 0 ? t.ownerDocument.body : B(t) && Se(t) ? t : dt(ge(t));
  }
  function ce(t, e) {
    var n;
    e === void 0 && (e = []);
    var r = dt(t), o2 = r === ((n = t.ownerDocument) == null ? void 0 : n.body), i = H(r), a2 = o2 ? [i].concat(i.visualViewport || [], Se(r) ? r : []) : r, s2 = e.concat(a2);
    return o2 ? s2 : s2.concat(ce(ge(a2)));
  }
  function Te(t) {
    return Object.assign({}, t, { left: t.x, top: t.y, right: t.x + t.width, bottom: t.y + t.height });
  }
  function Xt(t) {
    var e = ee(t);
    return e.top = e.top + t.clientTop, e.left = e.left + t.clientLeft, e.bottom = e.top + t.clientHeight, e.right = e.left + t.clientWidth, e.width = t.clientWidth, e.height = t.clientHeight, e.x = e.left, e.y = e.top, e;
  }
  function ht(t, e) {
    return e === je ? Te(Ft(t)) : Q(e) ? Xt(e) : Te(Ut(I$1(t)));
  }
  function Yt(t) {
    var e = ce(ge(t)), n = ["absolute", "fixed"].indexOf(N$1(t).position) >= 0, r = n && B(t) ? se(t) : t;
    return Q(r) ? e.filter(function(o2) {
      return Q(o2) && it(o2, r) && C(o2) !== "body";
    }) : [];
  }
  function Gt(t, e, n) {
    var r = e === "clippingParents" ? Yt(t) : [].concat(e), o2 = [].concat(r, [n]), i = o2[0], a2 = o2.reduce(function(s2, f2) {
      var c2 = ht(t, f2);
      return s2.top = X$1(c2.top, s2.top), s2.right = ve(c2.right, s2.right), s2.bottom = ve(c2.bottom, s2.bottom), s2.left = X$1(c2.left, s2.left), s2;
    }, ht(t, i));
    return a2.width = a2.right - a2.left, a2.height = a2.bottom - a2.top, a2.x = a2.left, a2.y = a2.top, a2;
  }
  function mt(t) {
    var e = t.reference, n = t.element, r = t.placement, o2 = r ? q(r) : null, i = r ? te(r) : null, a2 = e.x + e.width / 2 - n.width / 2, s2 = e.y + e.height / 2 - n.height / 2, f2;
    switch (o2) {
      case E$1:
        f2 = { x: a2, y: e.y - n.height };
        break;
      case R:
        f2 = { x: a2, y: e.y + e.height };
        break;
      case W:
        f2 = { x: e.x + e.width, y: s2 };
        break;
      case P$1:
        f2 = { x: e.x - n.width, y: s2 };
        break;
      default:
        f2 = { x: e.x, y: e.y };
    }
    var c2 = o2 ? Le(o2) : null;
    if (c2 != null) {
      var u2 = c2 === "y" ? "height" : "width";
      switch (i) {
        case U$1:
          f2[c2] = f2[c2] - (e[u2] / 2 - n[u2] / 2);
          break;
        case J:
          f2[c2] = f2[c2] + (e[u2] / 2 - n[u2] / 2);
          break;
      }
    }
    return f2;
  }
  function ne(t, e) {
    e === void 0 && (e = {});
    var n = e, r = n.placement, o2 = r === void 0 ? t.placement : r, i = n.boundary, a2 = i === void 0 ? Xe : i, s2 = n.rootBoundary, f2 = s2 === void 0 ? je : s2, c2 = n.elementContext, u2 = c2 === void 0 ? K : c2, m2 = n.altBoundary, v2 = m2 === void 0 ? false : m2, l2 = n.padding, h2 = l2 === void 0 ? 0 : l2, p2 = ft(typeof h2 != "number" ? h2 : ct(h2, G)), g = u2 === K ? Ye : K, x2 = t.rects.popper, y = t.elements[v2 ? g : u2], $2 = Gt(Q(y) ? y : y.contextElement || I$1(t.elements.popper), a2, f2), d2 = ee(t.elements.reference), b2 = mt({ reference: d2, element: x2, strategy: "absolute", placement: o2 }), w2 = Te(Object.assign({}, x2, b2)), O2 = u2 === K ? w2 : d2, j = { top: $2.top - O2.top + p2.top, bottom: O2.bottom - $2.bottom + p2.bottom, left: $2.left - O2.left + p2.left, right: O2.right - $2.right + p2.right }, A2 = t.modifiersData.offset;
    if (u2 === K && A2) {
      var k = A2[o2];
      Object.keys(j).forEach(function(D2) {
        var S2 = [W, R].indexOf(D2) >= 0 ? 1 : -1, L = [E$1, R].indexOf(D2) >= 0 ? "y" : "x";
        j[D2] += k[L] * S2;
      });
    }
    return j;
  }
  function Jt(t, e) {
    e === void 0 && (e = {});
    var n = e, r = n.placement, o2 = n.boundary, i = n.rootBoundary, a2 = n.padding, s2 = n.flipVariations, f2 = n.allowedAutoPlacements, c2 = f2 === void 0 ? Ee : f2, u2 = te(r), m2 = u2 ? s2 ? De : De.filter(function(h2) {
      return te(h2) === u2;
    }) : G, v2 = m2.filter(function(h2) {
      return c2.indexOf(h2) >= 0;
    });
    v2.length === 0 && (v2 = m2);
    var l2 = v2.reduce(function(h2, p2) {
      return h2[p2] = ne(t, { placement: p2, boundary: o2, rootBoundary: i, padding: a2 })[q(p2)], h2;
    }, {});
    return Object.keys(l2).sort(function(h2, p2) {
      return l2[h2] - l2[p2];
    });
  }
  function Kt(t) {
    if (q(t) === me)
      return [];
    var e = be(t);
    return [lt(t), e, lt(e)];
  }
  function Qt(t) {
    var e = t.state, n = t.options, r = t.name;
    if (!e.modifiersData[r]._skip) {
      for (var o2 = n.mainAxis, i = o2 === void 0 ? true : o2, a2 = n.altAxis, s2 = a2 === void 0 ? true : a2, f2 = n.fallbackPlacements, c2 = n.padding, u2 = n.boundary, m2 = n.rootBoundary, v2 = n.altBoundary, l2 = n.flipVariations, h2 = l2 === void 0 ? true : l2, p2 = n.allowedAutoPlacements, g = e.options.placement, x2 = q(g), y = x2 === g, $2 = f2 || (y || !h2 ? [be(g)] : Kt(g)), d2 = [g].concat($2).reduce(function(z, V) {
        return z.concat(q(V) === me ? Jt(e, { placement: V, boundary: u2, rootBoundary: m2, padding: c2, flipVariations: h2, allowedAutoPlacements: p2 }) : V);
      }, []), b2 = e.rects.reference, w2 = e.rects.popper, O2 = /* @__PURE__ */ new Map(), j = true, A2 = d2[0], k = 0; k < d2.length; k++) {
        var D2 = d2[k], S2 = q(D2), L = te(D2) === U$1, re = [E$1, R].indexOf(S2) >= 0, oe = re ? "width" : "height", M2 = ne(e, { placement: D2, boundary: u2, rootBoundary: m2, altBoundary: v2, padding: c2 }), T2 = re ? L ? W : P$1 : L ? R : E$1;
        b2[oe] > w2[oe] && (T2 = be(T2));
        var pe = be(T2), _2 = [];
        if (i && _2.push(M2[S2] <= 0), s2 && _2.push(M2[T2] <= 0, M2[pe] <= 0), _2.every(function(z) {
          return z;
        })) {
          A2 = D2, j = false;
          break;
        }
        O2.set(D2, _2);
      }
      if (j)
        for (var ue = h2 ? 3 : 1, xe = function(z) {
          var V = d2.find(function(de) {
            var ae = O2.get(de);
            if (ae)
              return ae.slice(0, z).every(function(Y2) {
                return Y2;
              });
          });
          if (V)
            return A2 = V, "break";
        }, ie = ue; ie > 0; ie--) {
          var le = xe(ie);
          if (le === "break")
            break;
        }
      e.placement !== A2 && (e.modifiersData[r]._skip = true, e.placement = A2, e.reset = true);
    }
  }
  var vt = { name: "flip", enabled: true, phase: "main", fn: Qt, requiresIfExists: ["offset"], data: { _skip: false } };
  function gt(t, e, n) {
    return n === void 0 && (n = { x: 0, y: 0 }), { top: t.top - e.height - n.y, right: t.right - e.width + n.x, bottom: t.bottom - e.height + n.y, left: t.left - e.width - n.x };
  }
  function yt(t) {
    return [E$1, W, R, P$1].some(function(e) {
      return t[e] >= 0;
    });
  }
  function Zt(t) {
    var e = t.state, n = t.name, r = e.rects.reference, o2 = e.rects.popper, i = e.modifiersData.preventOverflow, a2 = ne(e, { elementContext: "reference" }), s2 = ne(e, { altBoundary: true }), f2 = gt(a2, r), c2 = gt(s2, o2, i), u2 = yt(f2), m2 = yt(c2);
    e.modifiersData[n] = { referenceClippingOffsets: f2, popperEscapeOffsets: c2, isReferenceHidden: u2, hasPopperEscaped: m2 }, e.attributes.popper = Object.assign({}, e.attributes.popper, { "data-popper-reference-hidden": u2, "data-popper-escaped": m2 });
  }
  var bt = { name: "hide", enabled: true, phase: "main", requiresIfExists: ["preventOverflow"], fn: Zt };
  function en(t, e, n) {
    var r = q(t), o2 = [P$1, E$1].indexOf(r) >= 0 ? -1 : 1, i = typeof n == "function" ? n(Object.assign({}, e, { placement: t })) : n, a2 = i[0], s2 = i[1];
    return a2 = a2 || 0, s2 = (s2 || 0) * o2, [P$1, W].indexOf(r) >= 0 ? { x: s2, y: a2 } : { x: a2, y: s2 };
  }
  function tn(t) {
    var e = t.state, n = t.options, r = t.name, o2 = n.offset, i = o2 === void 0 ? [0, 0] : o2, a2 = Ee.reduce(function(u2, m2) {
      return u2[m2] = en(m2, e.rects, i), u2;
    }, {}), s2 = a2[e.placement], f2 = s2.x, c2 = s2.y;
    e.modifiersData.popperOffsets != null && (e.modifiersData.popperOffsets.x += f2, e.modifiersData.popperOffsets.y += c2), e.modifiersData[r] = a2;
  }
  var wt = { name: "offset", enabled: true, phase: "main", requires: ["popperOffsets"], fn: tn };
  function nn(t) {
    var e = t.state, n = t.name;
    e.modifiersData[n] = mt({ reference: e.rects.reference, element: e.rects.popper, strategy: "absolute", placement: e.placement });
  }
  var He = { name: "popperOffsets", enabled: true, phase: "read", fn: nn, data: {} };
  function rn(t) {
    return t === "x" ? "y" : "x";
  }
  function on(t) {
    var e = t.state, n = t.options, r = t.name, o2 = n.mainAxis, i = o2 === void 0 ? true : o2, a2 = n.altAxis, s2 = a2 === void 0 ? false : a2, f2 = n.boundary, c2 = n.rootBoundary, u2 = n.altBoundary, m2 = n.padding, v2 = n.tether, l2 = v2 === void 0 ? true : v2, h2 = n.tetherOffset, p2 = h2 === void 0 ? 0 : h2, g = ne(e, { boundary: f2, rootBoundary: c2, padding: m2, altBoundary: u2 }), x2 = q(e.placement), y = te(e.placement), $2 = !y, d2 = Le(x2), b2 = rn(d2), w2 = e.modifiersData.popperOffsets, O2 = e.rects.reference, j = e.rects.popper, A2 = typeof p2 == "function" ? p2(Object.assign({}, e.rects, { placement: e.placement })) : p2, k = typeof A2 == "number" ? { mainAxis: A2, altAxis: A2 } : Object.assign({ mainAxis: 0, altAxis: 0 }, A2), D2 = e.modifiersData.offset ? e.modifiersData.offset[e.placement] : null, S2 = { x: 0, y: 0 };
    if (w2) {
      if (i) {
        var L, re = d2 === "y" ? E$1 : P$1, oe = d2 === "y" ? R : W, M2 = d2 === "y" ? "height" : "width", T2 = w2[d2], pe = T2 + g[re], _2 = T2 - g[oe], ue = l2 ? -j[M2] / 2 : 0, xe = y === U$1 ? O2[M2] : j[M2], ie = y === U$1 ? -j[M2] : -O2[M2], le = e.elements.arrow, z = l2 && le ? ke(le) : { width: 0, height: 0 }, V = e.modifiersData["arrow#persistent"] ? e.modifiersData["arrow#persistent"].padding : st(), de = V[re], ae = V[oe], Y2 = fe(0, O2[M2], z[M2]), jt = $2 ? O2[M2] / 2 - ue - Y2 - de - k.mainAxis : xe - Y2 - de - k.mainAxis, Dt = $2 ? -O2[M2] / 2 + ue + Y2 + ae + k.mainAxis : ie + Y2 + ae + k.mainAxis, Oe = e.elements.arrow && se(e.elements.arrow), Et = Oe ? d2 === "y" ? Oe.clientTop || 0 : Oe.clientLeft || 0 : 0, Ce = (L = D2 == null ? void 0 : D2[d2]) != null ? L : 0, Pt = T2 + jt - Ce - Et, At = T2 + Dt - Ce, qe = fe(l2 ? ve(pe, Pt) : pe, T2, l2 ? X$1(_2, At) : _2);
        w2[d2] = qe, S2[d2] = qe - T2;
      }
      if (s2) {
        var Ve, kt = d2 === "x" ? E$1 : P$1, Lt = d2 === "x" ? R : W, F2 = w2[b2], he = b2 === "y" ? "height" : "width", Ne = F2 + g[kt], Ie = F2 - g[Lt], $e = [E$1, P$1].indexOf(x2) !== -1, _e = (Ve = D2 == null ? void 0 : D2[b2]) != null ? Ve : 0, ze = $e ? Ne : F2 - O2[he] - j[he] - _e + k.altAxis, Fe = $e ? F2 + O2[he] + j[he] - _e - k.altAxis : Ie, Ue = l2 && $e ? St(ze, F2, Fe) : fe(l2 ? ze : Ne, F2, l2 ? Fe : Ie);
        w2[b2] = Ue, S2[b2] = Ue - F2;
      }
      e.modifiersData[r] = S2;
    }
  }
  var xt = { name: "preventOverflow", enabled: true, phase: "main", fn: on, requiresIfExists: ["offset"] };
  function an(t) {
    return { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop };
  }
  function sn(t) {
    return t === H(t) || !B(t) ? We(t) : an(t);
  }
  function fn(t) {
    var e = t.getBoundingClientRect(), n = Z(e.width) / t.offsetWidth || 1, r = Z(e.height) / t.offsetHeight || 1;
    return n !== 1 || r !== 1;
  }
  function cn(t, e, n) {
    n === void 0 && (n = false);
    var r = B(e), o2 = B(e) && fn(e), i = I$1(e), a2 = ee(t, o2), s2 = { scrollLeft: 0, scrollTop: 0 }, f2 = { x: 0, y: 0 };
    return (r || !r && !n) && ((C(e) !== "body" || Se(i)) && (s2 = sn(e)), B(e) ? (f2 = ee(e, true), f2.x += e.clientLeft, f2.y += e.clientTop) : i && (f2.x = Be(i))), { x: a2.left + s2.scrollLeft - f2.x, y: a2.top + s2.scrollTop - f2.y, width: a2.width, height: a2.height };
  }
  function pn(t) {
    var e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [];
    t.forEach(function(i) {
      e.set(i.name, i);
    });
    function o2(i) {
      n.add(i.name);
      var a2 = [].concat(i.requires || [], i.requiresIfExists || []);
      a2.forEach(function(s2) {
        if (!n.has(s2)) {
          var f2 = e.get(s2);
          f2 && o2(f2);
        }
      }), r.push(i);
    }
    return t.forEach(function(i) {
      n.has(i.name) || o2(i);
    }), r;
  }
  function un(t) {
    var e = pn(t);
    return ot.reduce(function(n, r) {
      return n.concat(e.filter(function(o2) {
        return o2.phase === r;
      }));
    }, []);
  }
  function ln(t) {
    var e;
    return function() {
      return e || (e = new Promise(function(n) {
        Promise.resolve().then(function() {
          e = void 0, n(t());
        });
      })), e;
    };
  }
  function dn(t) {
    var e = t.reduce(function(n, r) {
      var o2 = n[r.name];
      return n[r.name] = o2 ? Object.assign({}, o2, r, { options: Object.assign({}, o2.options, r.options), data: Object.assign({}, o2.data, r.data) }) : r, n;
    }, {});
    return Object.keys(e).map(function(n) {
      return e[n];
    });
  }
  var Ot = { placement: "bottom", modifiers: [], strategy: "absolute" };
  function $t() {
    for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
      e[n] = arguments[n];
    return !e.some(function(r) {
      return !(r && typeof r.getBoundingClientRect == "function");
    });
  }
  function we(t) {
    t === void 0 && (t = {});
    var e = t, n = e.defaultModifiers, r = n === void 0 ? [] : n, o2 = e.defaultOptions, i = o2 === void 0 ? Ot : o2;
    return function(a2, s2, f2) {
      f2 === void 0 && (f2 = i);
      var c2 = { placement: "bottom", orderedModifiers: [], options: Object.assign({}, Ot, i), modifiersData: {}, elements: { reference: a2, popper: s2 }, attributes: {}, styles: {} }, u2 = [], m2 = false, v2 = { state: c2, setOptions: function(p2) {
        var g = typeof p2 == "function" ? p2(c2.options) : p2;
        h2(), c2.options = Object.assign({}, i, c2.options, g), c2.scrollParents = { reference: Q(a2) ? ce(a2) : a2.contextElement ? ce(a2.contextElement) : [], popper: ce(s2) };
        var x2 = un(dn([].concat(r, c2.options.modifiers)));
        return c2.orderedModifiers = x2.filter(function(y) {
          return y.enabled;
        }), l2(), v2.update();
      }, forceUpdate: function() {
        if (!m2) {
          var p2 = c2.elements, g = p2.reference, x2 = p2.popper;
          if ($t(g, x2)) {
            c2.rects = { reference: cn(g, se(x2), c2.options.strategy === "fixed"), popper: ke(x2) }, c2.reset = false, c2.placement = c2.options.placement, c2.orderedModifiers.forEach(function(j) {
              return c2.modifiersData[j.name] = Object.assign({}, j.data);
            });
            for (var y = 0; y < c2.orderedModifiers.length; y++) {
              if (c2.reset === true) {
                c2.reset = false, y = -1;
                continue;
              }
              var $2 = c2.orderedModifiers[y], d2 = $2.fn, b2 = $2.options, w2 = b2 === void 0 ? {} : b2, O2 = $2.name;
              typeof d2 == "function" && (c2 = d2({ state: c2, options: w2, name: O2, instance: v2 }) || c2);
            }
          }
        }
      }, update: ln(function() {
        return new Promise(function(p2) {
          v2.forceUpdate(), p2(c2);
        });
      }), destroy: function() {
        h2(), m2 = true;
      } };
      if (!$t(a2, s2))
        return v2;
      v2.setOptions(f2).then(function(p2) {
        !m2 && f2.onFirstUpdate && f2.onFirstUpdate(p2);
      });
      function l2() {
        c2.orderedModifiers.forEach(function(p2) {
          var g = p2.name, x2 = p2.options, y = x2 === void 0 ? {} : x2, $2 = p2.effect;
          if (typeof $2 == "function") {
            var d2 = $2({ state: c2, name: g, instance: v2, options: y }), b2 = function() {
            };
            u2.push(d2 || b2);
          }
        });
      }
      function h2() {
        u2.forEach(function(p2) {
          return p2();
        }), u2 = [];
      }
      return v2;
    };
  }
  we();
  var mn = [Re, He, Me, Ae];
  we({ defaultModifiers: mn });
  var gn = [Re, He, Me, Ae, wt, vt, xt, pt, bt], yn = we({ defaultModifiers: gn });
  function useTimeout() {
    let timeoutHandle;
    const registerTimeout = (fn2, delay) => {
      cancelTimeout();
      timeoutHandle = window.setTimeout(fn2, delay);
    };
    const cancelTimeout = () => window.clearTimeout(timeoutHandle);
    tryOnScopeDispose();
    return {
      registerTimeout,
      cancelTimeout
    };
  }
  let registeredEscapeHandlers = [];
  const cachedHandler = (e) => {
    const event = e;
    if (event.key === EVENT_CODE.esc) {
      registeredEscapeHandlers.forEach((registeredHandler) => registeredHandler(event));
    }
  };
  const useEscapeKeydown = (handler) => {
    Vue.onMounted(() => {
      if (registeredEscapeHandlers.length === 0) {
        document.addEventListener("keydown", cachedHandler);
      }
      if (isClient)
        registeredEscapeHandlers.push(handler);
    });
    Vue.onBeforeUnmount(() => {
      registeredEscapeHandlers = registeredEscapeHandlers.filter((registeredHandler) => registeredHandler !== handler);
      if (registeredEscapeHandlers.length === 0) {
        if (isClient)
          document.removeEventListener("keydown", cachedHandler);
      }
    });
  };
  let cachedContainer;
  const usePopperContainerId = () => {
    const namespace = useGlobalConfig("namespace", defaultNamespace);
    const idInjection = useIdInjection();
    const id = Vue.computed(() => {
      return `${namespace.value}-popper-container-${idInjection.prefix}`;
    });
    const selector = Vue.computed(() => `#${id.value}`);
    return {
      id,
      selector
    };
  };
  const createContainer = (id) => {
    const container = document.createElement("div");
    container.id = id;
    document.body.appendChild(container);
    return container;
  };
  const usePopperContainer = () => {
    Vue.onBeforeMount(() => {
      if (!isClient)
        return;
      const { id, selector } = usePopperContainerId();
      if (!cachedContainer && !document.body.querySelector(selector.value)) {
        cachedContainer = createContainer(id.value);
      }
    });
  };
  const useDelayedToggleProps = buildProps({
    showAfter: {
      type: Number,
      default: 0
    },
    hideAfter: {
      type: Number,
      default: 200
    }
  });
  const useDelayedToggle = ({
    showAfter,
    hideAfter,
    open,
    close
  }) => {
    const { registerTimeout } = useTimeout();
    const onOpen = (event) => {
      registerTimeout(() => {
        open(event);
      }, Vue.unref(showAfter));
    };
    const onClose = (event) => {
      registerTimeout(() => {
        close(event);
      }, Vue.unref(hideAfter));
    };
    return {
      onOpen,
      onClose
    };
  };
  const FORWARD_REF_INJECTION_KEY = Symbol("elForwardRef");
  const useForwardRef = (forwardRef) => {
    const setForwardRef = (el) => {
      forwardRef.value = el;
    };
    Vue.provide(FORWARD_REF_INJECTION_KEY, {
      setForwardRef
    });
  };
  const useForwardRefDirective = (setForwardRef) => {
    return {
      mounted(el) {
        setForwardRef(el);
      },
      updated(el) {
        setForwardRef(el);
      },
      unmounted() {
        setForwardRef(null);
      }
    };
  };
  const zIndex = Vue.ref(0);
  const useZIndex = () => {
    const initialZIndex = useGlobalConfig("zIndex", 2e3);
    const currentZIndex = Vue.computed(() => initialZIndex.value + zIndex.value);
    const nextZIndex = () => {
      zIndex.value++;
      return currentZIndex.value;
    };
    return {
      initialZIndex,
      currentZIndex,
      nextZIndex
    };
  };
  function useCursor(input) {
    const selectionRef = Vue.ref();
    function recordCursor() {
      if (input.value == void 0)
        return;
      const { selectionStart, selectionEnd, value } = input.value;
      if (selectionStart == null || selectionEnd == null)
        return;
      const beforeTxt = value.slice(0, Math.max(0, selectionStart));
      const afterTxt = value.slice(Math.max(0, selectionEnd));
      selectionRef.value = {
        selectionStart,
        selectionEnd,
        value,
        beforeTxt,
        afterTxt
      };
    }
    function setCursor() {
      if (input.value == void 0 || selectionRef.value == void 0)
        return;
      const { value } = input.value;
      const { beforeTxt, afterTxt, selectionStart } = selectionRef.value;
      if (beforeTxt == void 0 || afterTxt == void 0 || selectionStart == void 0)
        return;
      let startPos = value.length;
      if (value.endsWith(afterTxt)) {
        startPos = value.length - afterTxt.length;
      } else if (value.startsWith(beforeTxt)) {
        startPos = beforeTxt.length;
      } else {
        const beforeLastChar = beforeTxt[selectionStart - 1];
        const newIndex = value.indexOf(beforeLastChar, selectionStart - 1);
        if (newIndex !== -1) {
          startPos = newIndex + 1;
        }
      }
      input.value.setSelectionRange(startPos, startPos);
    }
    return [recordCursor, setCursor];
  }
  var _export_sfc = (sfc, props) => {
    const target = sfc.__vccOpts || sfc;
    for (const [key, val] of props) {
      target[key] = val;
    }
    return target;
  };
  const iconProps = buildProps({
    size: {
      type: definePropType([Number, String])
    },
    color: {
      type: String
    }
  });
  const __default__$l = Vue.defineComponent({
    name: "ElIcon",
    inheritAttrs: false
  });
  const _sfc_main$q = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$l), {
    props: iconProps,
    setup(__props) {
      const props = __props;
      const ns2 = useNamespace("icon");
      const style2 = Vue.computed(() => {
        const { size: size2, color } = props;
        if (!size2 && !color)
          return {};
        return {
          fontSize: isUndefined(size2) ? void 0 : addUnit(size2),
          "--color": color
        };
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("i", Vue.mergeProps({
          class: Vue.unref(ns2).b(),
          style: Vue.unref(style2)
        }, _ctx.$attrs), [
          Vue.renderSlot(_ctx.$slots, "default")
        ], 16);
      };
    }
  }));
  var Icon = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/icon/src/icon.vue"]]);
  const ElIcon = withInstall(Icon);
  const alertEffects = ["light", "dark"];
  const alertProps = buildProps({
    title: {
      type: String,
      default: ""
    },
    description: {
      type: String,
      default: ""
    },
    type: {
      type: String,
      values: keysOf(TypeComponentsMap),
      default: "info"
    },
    closable: {
      type: Boolean,
      default: true
    },
    closeText: {
      type: String,
      default: ""
    },
    showIcon: Boolean,
    center: Boolean,
    effect: {
      type: String,
      values: alertEffects,
      default: "light"
    }
  });
  const alertEmits = {
    close: (evt) => evt instanceof MouseEvent
  };
  const __default__$k = Vue.defineComponent({
    name: "ElAlert"
  });
  const _sfc_main$p = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$k), {
    props: alertProps,
    emits: alertEmits,
    setup(__props, { emit }) {
      const props = __props;
      const { Close } = TypeComponents;
      const slots = Vue.useSlots();
      const ns2 = useNamespace("alert");
      const visible = Vue.ref(true);
      const iconComponent = Vue.computed(() => TypeComponentsMap[props.type]);
      const iconClass = Vue.computed(() => [
        ns2.e("icon"),
        { [ns2.is("big")]: !!props.description || !!slots.default }
      ]);
      const isBoldTitle = Vue.computed(() => {
        return { [ns2.is("bold")]: props.description || slots.default };
      });
      const close = (evt) => {
        visible.value = false;
        emit("close", evt);
      };
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.Transition, {
          name: Vue.unref(ns2).b("fade"),
          persisted: ""
        }, {
          default: Vue.withCtx(() => [
            Vue.withDirectives(Vue.createElementVNode("div", {
              class: Vue.normalizeClass([Vue.unref(ns2).b(), Vue.unref(ns2).m(_ctx.type), Vue.unref(ns2).is("center", _ctx.center), Vue.unref(ns2).is(_ctx.effect)]),
              role: "alert"
            }, [
              _ctx.showIcon && Vue.unref(iconComponent) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                key: 0,
                class: Vue.normalizeClass(Vue.unref(iconClass))
              }, {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(iconComponent))))
                ]),
                _: 1
              }, 8, ["class"])) : Vue.createCommentVNode("v-if", true),
              Vue.createElementVNode("div", {
                class: Vue.normalizeClass(Vue.unref(ns2).e("content"))
              }, [
                _ctx.title || _ctx.$slots.title ? (Vue.openBlock(), Vue.createElementBlock("span", {
                  key: 0,
                  class: Vue.normalizeClass([Vue.unref(ns2).e("title"), Vue.unref(isBoldTitle)])
                }, [
                  Vue.renderSlot(_ctx.$slots, "title", {}, () => [
                    Vue.createTextVNode(Vue.toDisplayString(_ctx.title), 1)
                  ])
                ], 2)) : Vue.createCommentVNode("v-if", true),
                _ctx.$slots.default || _ctx.description ? (Vue.openBlock(), Vue.createElementBlock("p", {
                  key: 1,
                  class: Vue.normalizeClass(Vue.unref(ns2).e("description"))
                }, [
                  Vue.renderSlot(_ctx.$slots, "default", {}, () => [
                    Vue.createTextVNode(Vue.toDisplayString(_ctx.description), 1)
                  ])
                ], 2)) : Vue.createCommentVNode("v-if", true),
                _ctx.closable ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 2 }, [
                  _ctx.closeText ? (Vue.openBlock(), Vue.createElementBlock("div", {
                    key: 0,
                    class: Vue.normalizeClass([Vue.unref(ns2).e("close-btn"), Vue.unref(ns2).is("customed")]),
                    onClick: close
                  }, Vue.toDisplayString(_ctx.closeText), 3)) : (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 1,
                    class: Vue.normalizeClass(Vue.unref(ns2).e("close-btn")),
                    onClick: close
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(Close))
                    ]),
                    _: 1
                  }, 8, ["class"]))
                ], 64)) : Vue.createCommentVNode("v-if", true)
              ], 2)
            ], 2), [
              [Vue.vShow, visible.value]
            ])
          ]),
          _: 3
        }, 8, ["name"]);
      };
    }
  }));
  var Alert = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/alert/src/alert.vue"]]);
  const ElAlert = withInstall(Alert);
  let hiddenTextarea = void 0;
  const HIDDEN_STYLE = `
  height:0 !important;
  visibility:hidden !important;
  overflow:hidden !important;
  position:absolute !important;
  z-index:-1000 !important;
  top:0 !important;
  right:0 !important;
`;
  const CONTEXT_STYLE = [
    "letter-spacing",
    "line-height",
    "padding-top",
    "padding-bottom",
    "font-family",
    "font-weight",
    "font-size",
    "text-rendering",
    "text-transform",
    "width",
    "text-indent",
    "padding-left",
    "padding-right",
    "border-width",
    "box-sizing"
  ];
  function calculateNodeStyling(targetElement) {
    const style2 = window.getComputedStyle(targetElement);
    const boxSizing = style2.getPropertyValue("box-sizing");
    const paddingSize = Number.parseFloat(style2.getPropertyValue("padding-bottom")) + Number.parseFloat(style2.getPropertyValue("padding-top"));
    const borderSize = Number.parseFloat(style2.getPropertyValue("border-bottom-width")) + Number.parseFloat(style2.getPropertyValue("border-top-width"));
    const contextStyle = CONTEXT_STYLE.map((name) => `${name}:${style2.getPropertyValue(name)}`).join(";");
    return { contextStyle, paddingSize, borderSize, boxSizing };
  }
  function calcTextareaHeight(targetElement, minRows = 1, maxRows) {
    var _a2;
    if (!hiddenTextarea) {
      hiddenTextarea = document.createElement("textarea");
      document.body.appendChild(hiddenTextarea);
    }
    const { paddingSize, borderSize, boxSizing, contextStyle } = calculateNodeStyling(targetElement);
    hiddenTextarea.setAttribute("style", `${contextStyle};${HIDDEN_STYLE}`);
    hiddenTextarea.value = targetElement.value || targetElement.placeholder || "";
    let height = hiddenTextarea.scrollHeight;
    const result = {};
    if (boxSizing === "border-box") {
      height = height + borderSize;
    } else if (boxSizing === "content-box") {
      height = height - paddingSize;
    }
    hiddenTextarea.value = "";
    const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
    if (isNumber(minRows)) {
      let minHeight = singleRowHeight * minRows;
      if (boxSizing === "border-box") {
        minHeight = minHeight + paddingSize + borderSize;
      }
      height = Math.max(minHeight, height);
      result.minHeight = `${minHeight}px`;
    }
    if (isNumber(maxRows)) {
      let maxHeight = singleRowHeight * maxRows;
      if (boxSizing === "border-box") {
        maxHeight = maxHeight + paddingSize + borderSize;
      }
      height = Math.min(maxHeight, height);
    }
    result.height = `${height}px`;
    (_a2 = hiddenTextarea.parentNode) == null ? void 0 : _a2.removeChild(hiddenTextarea);
    hiddenTextarea = void 0;
    return result;
  }
  const inputProps = buildProps({
    id: {
      type: String,
      default: void 0
    },
    size: useSizeProp,
    disabled: Boolean,
    modelValue: {
      type: definePropType([
        String,
        Number,
        Object
      ]),
      default: ""
    },
    type: {
      type: String,
      default: "text"
    },
    resize: {
      type: String,
      values: ["none", "both", "horizontal", "vertical"]
    },
    autosize: {
      type: definePropType([Boolean, Object]),
      default: false
    },
    autocomplete: {
      type: String,
      default: "off"
    },
    formatter: {
      type: Function
    },
    parser: {
      type: Function
    },
    placeholder: {
      type: String
    },
    form: {
      type: String
    },
    readonly: {
      type: Boolean,
      default: false
    },
    clearable: {
      type: Boolean,
      default: false
    },
    showPassword: {
      type: Boolean,
      default: false
    },
    showWordLimit: {
      type: Boolean,
      default: false
    },
    suffixIcon: {
      type: iconPropType
    },
    prefixIcon: {
      type: iconPropType
    },
    containerRole: {
      type: String,
      default: void 0
    },
    label: {
      type: String,
      default: void 0
    },
    tabindex: {
      type: [String, Number],
      default: 0
    },
    validateEvent: {
      type: Boolean,
      default: true
    },
    inputStyle: {
      type: definePropType([Object, Array, String]),
      default: () => mutable({})
    }
  });
  const inputEmits = {
    [UPDATE_MODEL_EVENT]: (value) => isString$1(value),
    input: (value) => isString$1(value),
    change: (value) => isString$1(value),
    focus: (evt) => evt instanceof FocusEvent,
    blur: (evt) => evt instanceof FocusEvent,
    clear: () => true,
    mouseleave: (evt) => evt instanceof MouseEvent,
    mouseenter: (evt) => evt instanceof MouseEvent,
    keydown: (evt) => evt instanceof Event,
    compositionstart: (evt) => evt instanceof CompositionEvent,
    compositionupdate: (evt) => evt instanceof CompositionEvent,
    compositionend: (evt) => evt instanceof CompositionEvent
  };
  const _hoisted_1$b = ["role"];
  const _hoisted_2$9 = ["id", "type", "disabled", "formatter", "parser", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder", "form"];
  const _hoisted_3$4 = ["id", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form"];
  const __default__$j = Vue.defineComponent({
    name: "ElInput",
    inheritAttrs: false
  });
  const _sfc_main$o = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$j), {
    props: inputProps,
    emits: inputEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      const rawAttrs = Vue.useAttrs();
      const slots = Vue.useSlots();
      const containerAttrs = Vue.computed(() => {
        const comboBoxAttrs = {};
        if (props.containerRole === "combobox") {
          comboBoxAttrs["aria-haspopup"] = rawAttrs["aria-haspopup"];
          comboBoxAttrs["aria-owns"] = rawAttrs["aria-owns"];
          comboBoxAttrs["aria-expanded"] = rawAttrs["aria-expanded"];
        }
        return comboBoxAttrs;
      });
      const containerKls = Vue.computed(() => [
        props.type === "textarea" ? nsTextarea.b() : nsInput.b(),
        nsInput.m(inputSize.value),
        nsInput.is("disabled", inputDisabled.value),
        nsInput.is("exceed", inputExceed.value),
        {
          [nsInput.b("group")]: slots.prepend || slots.append,
          [nsInput.bm("group", "append")]: slots.append,
          [nsInput.bm("group", "prepend")]: slots.prepend,
          [nsInput.m("prefix")]: slots.prefix || props.prefixIcon,
          [nsInput.m("suffix")]: slots.suffix || props.suffixIcon || props.clearable || props.showPassword,
          [nsInput.bm("suffix", "password-clear")]: showClear.value && showPwdVisible.value
        },
        rawAttrs.class
      ]);
      const wrapperKls = Vue.computed(() => [
        nsInput.e("wrapper"),
        nsInput.is("focus", focused.value)
      ]);
      const attrs = useAttrs({
        excludeKeys: Vue.computed(() => {
          return Object.keys(containerAttrs.value);
        })
      });
      const { form, formItem } = useFormItem();
      const { inputId } = useFormItemInputId(props, {
        formItemContext: formItem
      });
      const inputSize = useSize();
      const inputDisabled = useDisabled();
      const nsInput = useNamespace("input");
      const nsTextarea = useNamespace("textarea");
      const input = Vue.shallowRef();
      const textarea = Vue.shallowRef();
      const focused = Vue.ref(false);
      const hovering = Vue.ref(false);
      const isComposing = Vue.ref(false);
      const passwordVisible = Vue.ref(false);
      const countStyle = Vue.ref();
      const textareaCalcStyle = Vue.shallowRef(props.inputStyle);
      const _ref = Vue.computed(() => input.value || textarea.value);
      const needStatusIcon = Vue.computed(() => {
        var _a2;
        return (_a2 = form == null ? void 0 : form.statusIcon) != null ? _a2 : false;
      });
      const validateState = Vue.computed(() => (formItem == null ? void 0 : formItem.validateState) || "");
      const validateIcon = Vue.computed(() => validateState.value && ValidateComponentsMap[validateState.value]);
      const passwordIcon = Vue.computed(() => passwordVisible.value ? view_default : hide_default);
      const containerStyle = Vue.computed(() => [
        rawAttrs.style,
        props.inputStyle
      ]);
      const textareaStyle = Vue.computed(() => [
        props.inputStyle,
        textareaCalcStyle.value,
        { resize: props.resize }
      ]);
      const nativeInputValue = Vue.computed(() => isNil(props.modelValue) ? "" : String(props.modelValue));
      const showClear = Vue.computed(() => props.clearable && !inputDisabled.value && !props.readonly && !!nativeInputValue.value && (focused.value || hovering.value));
      const showPwdVisible = Vue.computed(() => props.showPassword && !inputDisabled.value && !props.readonly && !!nativeInputValue.value && (!!nativeInputValue.value || focused.value));
      const isWordLimitVisible = Vue.computed(() => props.showWordLimit && !!attrs.value.maxlength && (props.type === "text" || props.type === "textarea") && !inputDisabled.value && !props.readonly && !props.showPassword);
      const textLength = Vue.computed(() => Array.from(nativeInputValue.value).length);
      const inputExceed = Vue.computed(() => !!isWordLimitVisible.value && textLength.value > Number(attrs.value.maxlength));
      const suffixVisible = Vue.computed(() => !!slots.suffix || !!props.suffixIcon || showClear.value || props.showPassword || isWordLimitVisible.value || !!validateState.value && needStatusIcon.value);
      const [recordCursor, setCursor] = useCursor(input);
      useResizeObserver(textarea, (entries) => {
        if (!isWordLimitVisible.value || props.resize !== "both")
          return;
        const entry = entries[0];
        const { width } = entry.contentRect;
        countStyle.value = {
          right: `calc(100% - ${width + 15 + 6}px)`
        };
      });
      const resizeTextarea = () => {
        const { type, autosize } = props;
        if (!isClient || type !== "textarea")
          return;
        if (autosize) {
          const minRows = isObject(autosize) ? autosize.minRows : void 0;
          const maxRows = isObject(autosize) ? autosize.maxRows : void 0;
          textareaCalcStyle.value = __spreadValues({}, calcTextareaHeight(textarea.value, minRows, maxRows));
        } else {
          textareaCalcStyle.value = {
            minHeight: calcTextareaHeight(textarea.value).minHeight
          };
        }
      };
      const setNativeInputValue = () => {
        const input2 = _ref.value;
        if (!input2 || input2.value === nativeInputValue.value)
          return;
        input2.value = nativeInputValue.value;
      };
      const handleInput = async (event) => {
        recordCursor();
        let { value } = event.target;
        if (props.formatter) {
          value = props.parser ? props.parser(value) : value;
          value = props.formatter(value);
        }
        if (isComposing.value)
          return;
        if (value === nativeInputValue.value) {
          setNativeInputValue();
          return;
        }
        emit(UPDATE_MODEL_EVENT, value);
        emit("input", value);
        await Vue.nextTick();
        setNativeInputValue();
        setCursor();
      };
      const handleChange = (event) => {
        emit("change", event.target.value);
      };
      const handleCompositionStart = (event) => {
        emit("compositionstart", event);
        isComposing.value = true;
      };
      const handleCompositionUpdate = (event) => {
        var _a2;
        emit("compositionupdate", event);
        const text = (_a2 = event.target) == null ? void 0 : _a2.value;
        const lastCharacter = text[text.length - 1] || "";
        isComposing.value = !isKorean(lastCharacter);
      };
      const handleCompositionEnd = (event) => {
        emit("compositionend", event);
        if (isComposing.value) {
          isComposing.value = false;
          handleInput(event);
        }
      };
      const handlePasswordVisible = () => {
        passwordVisible.value = !passwordVisible.value;
        focus();
      };
      const focus = async () => {
        var _a2;
        await Vue.nextTick();
        (_a2 = _ref.value) == null ? void 0 : _a2.focus();
      };
      const blur = () => {
        var _a2;
        return (_a2 = _ref.value) == null ? void 0 : _a2.blur();
      };
      const handleFocus = (event) => {
        focused.value = true;
        emit("focus", event);
      };
      const handleBlur = (event) => {
        var _a2;
        focused.value = false;
        emit("blur", event);
        if (props.validateEvent) {
          (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "blur").catch((err) => debugWarn(err));
        }
      };
      const handleMouseLeave = (evt) => {
        hovering.value = false;
        emit("mouseleave", evt);
      };
      const handleMouseEnter = (evt) => {
        hovering.value = true;
        emit("mouseenter", evt);
      };
      const handleKeydown = (evt) => {
        emit("keydown", evt);
      };
      const select = () => {
        var _a2;
        (_a2 = _ref.value) == null ? void 0 : _a2.select();
      };
      const clear2 = () => {
        emit(UPDATE_MODEL_EVENT, "");
        emit("change", "");
        emit("clear");
        emit("input", "");
      };
      Vue.watch(() => props.modelValue, () => {
        var _a2;
        Vue.nextTick(() => resizeTextarea());
        if (props.validateEvent) {
          (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "change").catch((err) => debugWarn(err));
        }
      });
      Vue.watch(nativeInputValue, () => setNativeInputValue());
      Vue.watch(() => props.type, async () => {
        await Vue.nextTick();
        setNativeInputValue();
        resizeTextarea();
      });
      Vue.onMounted(() => {
        if (!props.formatter && props.parser) {
          debugWarn("ElInput", "If you set the parser, you also need to set the formatter.");
        }
        setNativeInputValue();
        Vue.nextTick(resizeTextarea);
      });
      expose({
        input,
        textarea,
        ref: _ref,
        textareaStyle,
        autosize: Vue.toRef(props, "autosize"),
        focus,
        blur,
        select,
        clear: clear2,
        resizeTextarea
      });
      return (_ctx, _cache) => {
        return Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", Vue.mergeProps(Vue.unref(containerAttrs), {
          class: Vue.unref(containerKls),
          style: Vue.unref(containerStyle),
          role: _ctx.containerRole,
          onMouseenter: handleMouseEnter,
          onMouseleave: handleMouseLeave
        }), [
          Vue.createCommentVNode(" input "),
          _ctx.type !== "textarea" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
            Vue.createCommentVNode(" prepend slot "),
            _ctx.$slots.prepend ? (Vue.openBlock(), Vue.createElementBlock("div", {
              key: 0,
              class: Vue.normalizeClass(Vue.unref(nsInput).be("group", "prepend"))
            }, [
              Vue.renderSlot(_ctx.$slots, "prepend")
            ], 2)) : Vue.createCommentVNode("v-if", true),
            Vue.createElementVNode("div", {
              class: Vue.normalizeClass(Vue.unref(wrapperKls))
            }, [
              Vue.createCommentVNode(" prefix slot "),
              _ctx.$slots.prefix || _ctx.prefixIcon ? (Vue.openBlock(), Vue.createElementBlock("span", {
                key: 0,
                class: Vue.normalizeClass(Vue.unref(nsInput).e("prefix"))
              }, [
                Vue.createElementVNode("span", {
                  class: Vue.normalizeClass(Vue.unref(nsInput).e("prefix-inner")),
                  onClick: focus
                }, [
                  Vue.renderSlot(_ctx.$slots, "prefix"),
                  _ctx.prefixIcon ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 0,
                    class: Vue.normalizeClass(Vue.unref(nsInput).e("icon"))
                  }, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.prefixIcon)))
                    ]),
                    _: 1
                  }, 8, ["class"])) : Vue.createCommentVNode("v-if", true)
                ], 2)
              ], 2)) : Vue.createCommentVNode("v-if", true),
              Vue.createElementVNode("input", Vue.mergeProps({
                id: Vue.unref(inputId),
                ref_key: "input",
                ref: input,
                class: Vue.unref(nsInput).e("inner")
              }, Vue.unref(attrs), {
                type: _ctx.showPassword ? passwordVisible.value ? "text" : "password" : _ctx.type,
                disabled: Vue.unref(inputDisabled),
                formatter: _ctx.formatter,
                parser: _ctx.parser,
                readonly: _ctx.readonly,
                autocomplete: _ctx.autocomplete,
                tabindex: _ctx.tabindex,
                "aria-label": _ctx.label,
                placeholder: _ctx.placeholder,
                style: _ctx.inputStyle,
                form: props.form,
                onCompositionstart: handleCompositionStart,
                onCompositionupdate: handleCompositionUpdate,
                onCompositionend: handleCompositionEnd,
                onInput: handleInput,
                onFocus: handleFocus,
                onBlur: handleBlur,
                onChange: handleChange,
                onKeydown: handleKeydown
              }), null, 16, _hoisted_2$9),
              Vue.createCommentVNode(" suffix slot "),
              Vue.unref(suffixVisible) ? (Vue.openBlock(), Vue.createElementBlock("span", {
                key: 1,
                class: Vue.normalizeClass(Vue.unref(nsInput).e("suffix"))
              }, [
                Vue.createElementVNode("span", {
                  class: Vue.normalizeClass(Vue.unref(nsInput).e("suffix-inner")),
                  onClick: focus
                }, [
                  !Vue.unref(showClear) || !Vue.unref(showPwdVisible) || !Vue.unref(isWordLimitVisible) ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
                    Vue.renderSlot(_ctx.$slots, "suffix"),
                    _ctx.suffixIcon ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                      key: 0,
                      class: Vue.normalizeClass(Vue.unref(nsInput).e("icon"))
                    }, {
                      default: Vue.withCtx(() => [
                        (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.suffixIcon)))
                      ]),
                      _: 1
                    }, 8, ["class"])) : Vue.createCommentVNode("v-if", true)
                  ], 64)) : Vue.createCommentVNode("v-if", true),
                  Vue.unref(showClear) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 1,
                    class: Vue.normalizeClass([Vue.unref(nsInput).e("icon"), Vue.unref(nsInput).e("clear")]),
                    onMousedown: Vue.withModifiers(Vue.unref(NOOP), ["prevent"]),
                    onClick: clear2
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(circle_close_default))
                    ]),
                    _: 1
                  }, 8, ["class", "onMousedown"])) : Vue.createCommentVNode("v-if", true),
                  Vue.unref(showPwdVisible) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 2,
                    class: Vue.normalizeClass([Vue.unref(nsInput).e("icon"), Vue.unref(nsInput).e("password")]),
                    onClick: handlePasswordVisible
                  }, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(passwordIcon))))
                    ]),
                    _: 1
                  }, 8, ["class"])) : Vue.createCommentVNode("v-if", true),
                  Vue.unref(isWordLimitVisible) ? (Vue.openBlock(), Vue.createElementBlock("span", {
                    key: 3,
                    class: Vue.normalizeClass(Vue.unref(nsInput).e("count"))
                  }, [
                    Vue.createElementVNode("span", {
                      class: Vue.normalizeClass(Vue.unref(nsInput).e("count-inner"))
                    }, Vue.toDisplayString(Vue.unref(textLength)) + " / " + Vue.toDisplayString(Vue.unref(attrs).maxlength), 3)
                  ], 2)) : Vue.createCommentVNode("v-if", true),
                  Vue.unref(validateState) && Vue.unref(validateIcon) && Vue.unref(needStatusIcon) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 4,
                    class: Vue.normalizeClass([
                      Vue.unref(nsInput).e("icon"),
                      Vue.unref(nsInput).e("validateIcon"),
                      Vue.unref(nsInput).is("loading", Vue.unref(validateState) === "validating")
                    ])
                  }, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(validateIcon))))
                    ]),
                    _: 1
                  }, 8, ["class"])) : Vue.createCommentVNode("v-if", true)
                ], 2)
              ], 2)) : Vue.createCommentVNode("v-if", true)
            ], 2),
            Vue.createCommentVNode(" append slot "),
            _ctx.$slots.append ? (Vue.openBlock(), Vue.createElementBlock("div", {
              key: 1,
              class: Vue.normalizeClass(Vue.unref(nsInput).be("group", "append"))
            }, [
              Vue.renderSlot(_ctx.$slots, "append")
            ], 2)) : Vue.createCommentVNode("v-if", true)
          ], 64)) : (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 1 }, [
            Vue.createCommentVNode(" textarea "),
            Vue.createElementVNode("textarea", Vue.mergeProps({
              id: Vue.unref(inputId),
              ref_key: "textarea",
              ref: textarea,
              class: Vue.unref(nsTextarea).e("inner")
            }, Vue.unref(attrs), {
              tabindex: _ctx.tabindex,
              disabled: Vue.unref(inputDisabled),
              readonly: _ctx.readonly,
              autocomplete: _ctx.autocomplete,
              style: Vue.unref(textareaStyle),
              "aria-label": _ctx.label,
              placeholder: _ctx.placeholder,
              form: props.form,
              onCompositionstart: handleCompositionStart,
              onCompositionupdate: handleCompositionUpdate,
              onCompositionend: handleCompositionEnd,
              onInput: handleInput,
              onFocus: handleFocus,
              onBlur: handleBlur,
              onChange: handleChange,
              onKeydown: handleKeydown
            }), null, 16, _hoisted_3$4),
            Vue.unref(isWordLimitVisible) ? (Vue.openBlock(), Vue.createElementBlock("span", {
              key: 0,
              style: Vue.normalizeStyle(countStyle.value),
              class: Vue.normalizeClass(Vue.unref(nsInput).e("count"))
            }, Vue.toDisplayString(Vue.unref(textLength)) + " / " + Vue.toDisplayString(Vue.unref(attrs).maxlength), 7)) : Vue.createCommentVNode("v-if", true)
          ], 64))
        ], 16, _hoisted_1$b)), [
          [Vue.vShow, _ctx.type !== "hidden"]
        ]);
      };
    }
  }));
  var Input = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/input/src/input.vue"]]);
  const ElInput = withInstall(Input);
  const GAP = 4;
  const BAR_MAP = {
    vertical: {
      offset: "offsetHeight",
      scroll: "scrollTop",
      scrollSize: "scrollHeight",
      size: "height",
      key: "vertical",
      axis: "Y",
      client: "clientY",
      direction: "top"
    },
    horizontal: {
      offset: "offsetWidth",
      scroll: "scrollLeft",
      scrollSize: "scrollWidth",
      size: "width",
      key: "horizontal",
      axis: "X",
      client: "clientX",
      direction: "left"
    }
  };
  const renderThumbStyle = ({
    move,
    size: size2,
    bar
  }) => ({
    [bar.size]: size2,
    transform: `translate${bar.axis}(${move}%)`
  });
  const thumbProps = buildProps({
    vertical: Boolean,
    size: String,
    move: Number,
    ratio: {
      type: Number,
      required: true
    },
    always: Boolean
  });
  const COMPONENT_NAME$2 = "Thumb";
  const _sfc_main$n = /* @__PURE__ */ Vue.defineComponent({
    __name: "thumb",
    props: thumbProps,
    setup(__props) {
      const props = __props;
      const scrollbar = Vue.inject(scrollbarContextKey);
      const ns2 = useNamespace("scrollbar");
      if (!scrollbar)
        throwError(COMPONENT_NAME$2, "can not inject scrollbar context");
      const instance = Vue.ref();
      const thumb = Vue.ref();
      const thumbState = Vue.ref({});
      const visible = Vue.ref(false);
      let cursorDown = false;
      let cursorLeave = false;
      let originalOnSelectStart = isClient ? document.onselectstart : null;
      const bar = Vue.computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
      const thumbStyle = Vue.computed(() => renderThumbStyle({
        size: props.size,
        move: props.move,
        bar: bar.value
      }));
      const offsetRatio = Vue.computed(() => instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset]);
      const clickThumbHandler = (e) => {
        var _a2;
        e.stopPropagation();
        if (e.ctrlKey || [1, 2].includes(e.button))
          return;
        (_a2 = window.getSelection()) == null ? void 0 : _a2.removeAllRanges();
        startDrag(e);
        const el = e.currentTarget;
        if (!el)
          return;
        thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
      };
      const clickTrackHandler = (e) => {
        if (!thumb.value || !instance.value || !scrollbar.wrapElement)
          return;
        const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
        const thumbHalf = thumb.value[bar.value.offset] / 2;
        const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
        scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
      };
      const startDrag = (e) => {
        e.stopImmediatePropagation();
        cursorDown = true;
        document.addEventListener("mousemove", mouseMoveDocumentHandler);
        document.addEventListener("mouseup", mouseUpDocumentHandler);
        originalOnSelectStart = document.onselectstart;
        document.onselectstart = () => false;
      };
      const mouseMoveDocumentHandler = (e) => {
        if (!instance.value || !thumb.value)
          return;
        if (cursorDown === false)
          return;
        const prevPage = thumbState.value[bar.value.axis];
        if (!prevPage)
          return;
        const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
        const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
        const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
        scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
      };
      const mouseUpDocumentHandler = () => {
        cursorDown = false;
        thumbState.value[bar.value.axis] = 0;
        document.removeEventListener("mousemove", mouseMoveDocumentHandler);
        document.removeEventListener("mouseup", mouseUpDocumentHandler);
        restoreOnselectstart();
        if (cursorLeave)
          visible.value = false;
      };
      const mouseMoveScrollbarHandler = () => {
        cursorLeave = false;
        visible.value = !!props.size;
      };
      const mouseLeaveScrollbarHandler = () => {
        cursorLeave = true;
        visible.value = cursorDown;
      };
      Vue.onBeforeUnmount(() => {
        restoreOnselectstart();
        document.removeEventListener("mouseup", mouseUpDocumentHandler);
      });
      const restoreOnselectstart = () => {
        if (document.onselectstart !== originalOnSelectStart)
          document.onselectstart = originalOnSelectStart;
      };
      useEventListener(Vue.toRef(scrollbar, "scrollbarElement"), "mousemove", mouseMoveScrollbarHandler);
      useEventListener(Vue.toRef(scrollbar, "scrollbarElement"), "mouseleave", mouseLeaveScrollbarHandler);
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.Transition, {
          name: Vue.unref(ns2).b("fade"),
          persisted: ""
        }, {
          default: Vue.withCtx(() => [
            Vue.withDirectives(Vue.createElementVNode("div", {
              ref_key: "instance",
              ref: instance,
              class: Vue.normalizeClass([Vue.unref(ns2).e("bar"), Vue.unref(ns2).is(Vue.unref(bar).key)]),
              onMousedown: clickTrackHandler
            }, [
              Vue.createElementVNode("div", {
                ref_key: "thumb",
                ref: thumb,
                class: Vue.normalizeClass(Vue.unref(ns2).e("thumb")),
                style: Vue.normalizeStyle(Vue.unref(thumbStyle)),
                onMousedown: clickThumbHandler
              }, null, 38)
            ], 34), [
              [Vue.vShow, _ctx.always || visible.value]
            ])
          ]),
          _: 1
        }, 8, ["name"]);
      };
    }
  });
  var Thumb = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/thumb.vue"]]);
  const barProps = buildProps({
    always: {
      type: Boolean,
      default: true
    },
    width: String,
    height: String,
    ratioX: {
      type: Number,
      default: 1
    },
    ratioY: {
      type: Number,
      default: 1
    }
  });
  const _sfc_main$m = /* @__PURE__ */ Vue.defineComponent({
    __name: "bar",
    props: barProps,
    setup(__props, { expose }) {
      const props = __props;
      const moveX = Vue.ref(0);
      const moveY = Vue.ref(0);
      const handleScroll = (wrap) => {
        if (wrap) {
          const offsetHeight = wrap.offsetHeight - GAP;
          const offsetWidth = wrap.offsetWidth - GAP;
          moveY.value = wrap.scrollTop * 100 / offsetHeight * props.ratioY;
          moveX.value = wrap.scrollLeft * 100 / offsetWidth * props.ratioX;
        }
      };
      expose({
        handleScroll
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
          Vue.createVNode(Thumb, {
            move: moveX.value,
            ratio: _ctx.ratioX,
            size: _ctx.width,
            always: _ctx.always
          }, null, 8, ["move", "ratio", "size", "always"]),
          Vue.createVNode(Thumb, {
            move: moveY.value,
            ratio: _ctx.ratioY,
            size: _ctx.height,
            vertical: "",
            always: _ctx.always
          }, null, 8, ["move", "ratio", "size", "always"])
        ], 64);
      };
    }
  });
  var Bar = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/bar.vue"]]);
  const scrollbarProps = buildProps({
    height: {
      type: [String, Number],
      default: ""
    },
    maxHeight: {
      type: [String, Number],
      default: ""
    },
    native: {
      type: Boolean,
      default: false
    },
    wrapStyle: {
      type: definePropType([String, Object, Array]),
      default: ""
    },
    wrapClass: {
      type: [String, Array],
      default: ""
    },
    viewClass: {
      type: [String, Array],
      default: ""
    },
    viewStyle: {
      type: [String, Array, Object],
      default: ""
    },
    noresize: Boolean,
    tag: {
      type: String,
      default: "div"
    },
    always: Boolean,
    minSize: {
      type: Number,
      default: 20
    }
  });
  const scrollbarEmits = {
    scroll: ({
      scrollTop,
      scrollLeft
    }) => [scrollTop, scrollLeft].every(isNumber)
  };
  const COMPONENT_NAME$1 = "ElScrollbar";
  const __default__$i = Vue.defineComponent({
    name: COMPONENT_NAME$1
  });
  const _sfc_main$l = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$i), {
    props: scrollbarProps,
    emits: scrollbarEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      const ns2 = useNamespace("scrollbar");
      let stopResizeObserver = void 0;
      let stopResizeListener = void 0;
      const scrollbarRef = Vue.ref();
      const wrapRef = Vue.ref();
      const resizeRef = Vue.ref();
      const sizeWidth = Vue.ref("0");
      const sizeHeight = Vue.ref("0");
      const barRef = Vue.ref();
      const ratioY = Vue.ref(1);
      const ratioX = Vue.ref(1);
      const style2 = Vue.computed(() => {
        const style22 = {};
        if (props.height)
          style22.height = addUnit(props.height);
        if (props.maxHeight)
          style22.maxHeight = addUnit(props.maxHeight);
        return [props.wrapStyle, style22];
      });
      const wrapKls = Vue.computed(() => {
        return [
          props.wrapClass,
          ns2.e("wrap"),
          { [ns2.em("wrap", "hidden-default")]: !props.native }
        ];
      });
      const resizeKls = Vue.computed(() => {
        return [ns2.e("view"), props.viewClass];
      });
      const handleScroll = () => {
        var _a2;
        if (wrapRef.value) {
          (_a2 = barRef.value) == null ? void 0 : _a2.handleScroll(wrapRef.value);
          emit("scroll", {
            scrollTop: wrapRef.value.scrollTop,
            scrollLeft: wrapRef.value.scrollLeft
          });
        }
      };
      function scrollTo(arg1, arg2) {
        if (isObject(arg1)) {
          wrapRef.value.scrollTo(arg1);
        } else if (isNumber(arg1) && isNumber(arg2)) {
          wrapRef.value.scrollTo(arg1, arg2);
        }
      }
      const setScrollTop = (value) => {
        if (!isNumber(value)) {
          debugWarn(COMPONENT_NAME$1, "value must be a number");
          return;
        }
        wrapRef.value.scrollTop = value;
      };
      const setScrollLeft = (value) => {
        if (!isNumber(value)) {
          debugWarn(COMPONENT_NAME$1, "value must be a number");
          return;
        }
        wrapRef.value.scrollLeft = value;
      };
      const update = () => {
        if (!wrapRef.value)
          return;
        const offsetHeight = wrapRef.value.offsetHeight - GAP;
        const offsetWidth = wrapRef.value.offsetWidth - GAP;
        const originalHeight = offsetHeight ** 2 / wrapRef.value.scrollHeight;
        const originalWidth = offsetWidth ** 2 / wrapRef.value.scrollWidth;
        const height = Math.max(originalHeight, props.minSize);
        const width = Math.max(originalWidth, props.minSize);
        ratioY.value = originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height));
        ratioX.value = originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width));
        sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : "";
        sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : "";
      };
      Vue.watch(() => props.noresize, (noresize) => {
        if (noresize) {
          stopResizeObserver == null ? void 0 : stopResizeObserver();
          stopResizeListener == null ? void 0 : stopResizeListener();
        } else {
          ({ stop: stopResizeObserver } = useResizeObserver(resizeRef, update));
          stopResizeListener = useEventListener("resize", update);
        }
      }, { immediate: true });
      Vue.watch(() => [props.maxHeight, props.height], () => {
        if (!props.native)
          Vue.nextTick(() => {
            var _a2;
            update();
            if (wrapRef.value) {
              (_a2 = barRef.value) == null ? void 0 : _a2.handleScroll(wrapRef.value);
            }
          });
      });
      Vue.provide(scrollbarContextKey, Vue.reactive({
        scrollbarElement: scrollbarRef,
        wrapElement: wrapRef
      }));
      Vue.onMounted(() => {
        if (!props.native)
          Vue.nextTick(() => {
            update();
          });
      });
      Vue.onUpdated(() => update());
      expose({
        wrapRef,
        update,
        scrollTo,
        setScrollTop,
        setScrollLeft,
        handleScroll
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          ref_key: "scrollbarRef",
          ref: scrollbarRef,
          class: Vue.normalizeClass(Vue.unref(ns2).b())
        }, [
          Vue.createElementVNode("div", {
            ref_key: "wrapRef",
            ref: wrapRef,
            class: Vue.normalizeClass(Vue.unref(wrapKls)),
            style: Vue.normalizeStyle(Vue.unref(style2)),
            onScroll: handleScroll
          }, [
            (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.tag), {
              ref_key: "resizeRef",
              ref: resizeRef,
              class: Vue.normalizeClass(Vue.unref(resizeKls)),
              style: Vue.normalizeStyle(_ctx.viewStyle)
            }, {
              default: Vue.withCtx(() => [
                Vue.renderSlot(_ctx.$slots, "default")
              ]),
              _: 3
            }, 8, ["class", "style"]))
          ], 38),
          !_ctx.native ? (Vue.openBlock(), Vue.createBlock(Bar, {
            key: 0,
            ref_key: "barRef",
            ref: barRef,
            height: sizeHeight.value,
            width: sizeWidth.value,
            always: _ctx.always,
            "ratio-x": ratioX.value,
            "ratio-y": ratioY.value
          }, null, 8, ["height", "width", "always", "ratio-x", "ratio-y"])) : Vue.createCommentVNode("v-if", true)
        ], 2);
      };
    }
  }));
  var Scrollbar = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/scrollbar.vue"]]);
  const ElScrollbar = withInstall(Scrollbar);
  const roleTypes = [
    "dialog",
    "grid",
    "group",
    "listbox",
    "menu",
    "navigation",
    "tooltip",
    "tree"
  ];
  const popperProps = buildProps({
    role: {
      type: String,
      values: roleTypes,
      default: "tooltip"
    }
  });
  const __default__$h = Vue.defineComponent({
    name: "ElPopperRoot",
    inheritAttrs: false
  });
  const _sfc_main$k = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$h), {
    props: popperProps,
    setup(__props, { expose }) {
      const props = __props;
      const triggerRef = Vue.ref();
      const popperInstanceRef = Vue.ref();
      const contentRef = Vue.ref();
      const referenceRef = Vue.ref();
      const role = Vue.computed(() => props.role);
      const popperProvides = {
        triggerRef,
        popperInstanceRef,
        contentRef,
        referenceRef,
        role
      };
      expose(popperProvides);
      Vue.provide(POPPER_INJECTION_KEY, popperProvides);
      return (_ctx, _cache) => {
        return Vue.renderSlot(_ctx.$slots, "default");
      };
    }
  }));
  var Popper = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/popper.vue"]]);
  const popperArrowProps = buildProps({
    arrowOffset: {
      type: Number,
      default: 5
    }
  });
  const __default__$g = Vue.defineComponent({
    name: "ElPopperArrow",
    inheritAttrs: false
  });
  const _sfc_main$j = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$g), {
    props: popperArrowProps,
    setup(__props, { expose }) {
      const props = __props;
      const ns2 = useNamespace("popper");
      const { arrowOffset, arrowRef } = Vue.inject(POPPER_CONTENT_INJECTION_KEY, void 0);
      Vue.watch(() => props.arrowOffset, (val) => {
        arrowOffset.value = val;
      });
      Vue.onBeforeUnmount(() => {
        arrowRef.value = void 0;
      });
      expose({
        arrowRef
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("span", {
          ref_key: "arrowRef",
          ref: arrowRef,
          class: Vue.normalizeClass(Vue.unref(ns2).e("arrow")),
          "data-popper-arrow": ""
        }, null, 2);
      };
    }
  }));
  var ElPopperArrow = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/arrow.vue"]]);
  const NAME = "ElOnlyChild";
  const OnlyChild = Vue.defineComponent({
    name: NAME,
    setup(_2, {
      slots,
      attrs
    }) {
      var _a2;
      const forwardRefInjection = Vue.inject(FORWARD_REF_INJECTION_KEY);
      const forwardRefDirective = useForwardRefDirective((_a2 = forwardRefInjection == null ? void 0 : forwardRefInjection.setForwardRef) != null ? _a2 : NOOP);
      return () => {
        var _a22;
        const defaultSlot = (_a22 = slots.default) == null ? void 0 : _a22.call(slots, attrs);
        if (!defaultSlot)
          return null;
        if (defaultSlot.length > 1) {
          debugWarn(NAME, "requires exact only one valid child.");
          return null;
        }
        const firstLegitNode = findFirstLegitChild(defaultSlot);
        if (!firstLegitNode) {
          debugWarn(NAME, "no valid child node found");
          return null;
        }
        return Vue.withDirectives(Vue.cloneVNode(firstLegitNode, attrs), [[forwardRefDirective]]);
      };
    }
  });
  function findFirstLegitChild(node) {
    if (!node)
      return null;
    const children = node;
    for (const child of children) {
      if (isObject(child)) {
        switch (child.type) {
          case Vue.Comment:
            continue;
          case Vue.Text:
          case "svg":
            return wrapTextContent(child);
          case Vue.Fragment:
            return findFirstLegitChild(child.children);
          default:
            return child;
        }
      }
      return wrapTextContent(child);
    }
    return null;
  }
  function wrapTextContent(s2) {
    const ns2 = useNamespace("only-child");
    return Vue.createVNode("span", {
      "class": ns2.e("content")
    }, [s2]);
  }
  const popperTriggerProps = buildProps({
    virtualRef: {
      type: definePropType(Object)
    },
    virtualTriggering: Boolean,
    onMouseenter: {
      type: definePropType(Function)
    },
    onMouseleave: {
      type: definePropType(Function)
    },
    onClick: {
      type: definePropType(Function)
    },
    onKeydown: {
      type: definePropType(Function)
    },
    onFocus: {
      type: definePropType(Function)
    },
    onBlur: {
      type: definePropType(Function)
    },
    onContextmenu: {
      type: definePropType(Function)
    },
    id: String,
    open: Boolean
  });
  const __default__$f = Vue.defineComponent({
    name: "ElPopperTrigger",
    inheritAttrs: false
  });
  const _sfc_main$i = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$f), {
    props: popperTriggerProps,
    setup(__props, { expose }) {
      const props = __props;
      const { role, triggerRef } = Vue.inject(POPPER_INJECTION_KEY, void 0);
      useForwardRef(triggerRef);
      const ariaControls = Vue.computed(() => {
        return ariaHaspopup.value ? props.id : void 0;
      });
      const ariaDescribedby = Vue.computed(() => {
        if (role && role.value === "tooltip") {
          return props.open && props.id ? props.id : void 0;
        }
        return void 0;
      });
      const ariaHaspopup = Vue.computed(() => {
        if (role && role.value !== "tooltip") {
          return role.value;
        }
        return void 0;
      });
      const ariaExpanded = Vue.computed(() => {
        return ariaHaspopup.value ? `${props.open}` : void 0;
      });
      let virtualTriggerAriaStopWatch = void 0;
      Vue.onMounted(() => {
        Vue.watch(() => props.virtualRef, (virtualEl) => {
          if (virtualEl) {
            triggerRef.value = unrefElement(virtualEl);
          }
        }, {
          immediate: true
        });
        Vue.watch(triggerRef, (el, prevEl) => {
          virtualTriggerAriaStopWatch == null ? void 0 : virtualTriggerAriaStopWatch();
          virtualTriggerAriaStopWatch = void 0;
          if (isElement(el)) {
            [
              "onMouseenter",
              "onMouseleave",
              "onClick",
              "onKeydown",
              "onFocus",
              "onBlur",
              "onContextmenu"
            ].forEach((eventName) => {
              var _a2;
              const handler = props[eventName];
              if (handler) {
                el.addEventListener(eventName.slice(2).toLowerCase(), handler);
                (_a2 = prevEl == null ? void 0 : prevEl.removeEventListener) == null ? void 0 : _a2.call(prevEl, eventName.slice(2).toLowerCase(), handler);
              }
            });
            virtualTriggerAriaStopWatch = Vue.watch([ariaControls, ariaDescribedby, ariaHaspopup, ariaExpanded], (watches) => {
              [
                "aria-controls",
                "aria-describedby",
                "aria-haspopup",
                "aria-expanded"
              ].forEach((key, idx) => {
                isNil(watches[idx]) ? el.removeAttribute(key) : el.setAttribute(key, watches[idx]);
              });
            }, { immediate: true });
          }
          if (isElement(prevEl)) {
            [
              "aria-controls",
              "aria-describedby",
              "aria-haspopup",
              "aria-expanded"
            ].forEach((key) => prevEl.removeAttribute(key));
          }
        }, {
          immediate: true
        });
      });
      Vue.onBeforeUnmount(() => {
        virtualTriggerAriaStopWatch == null ? void 0 : virtualTriggerAriaStopWatch();
        virtualTriggerAriaStopWatch = void 0;
      });
      expose({
        triggerRef
      });
      return (_ctx, _cache) => {
        return !_ctx.virtualTriggering ? (Vue.openBlock(), Vue.createBlock(Vue.unref(OnlyChild), Vue.mergeProps({ key: 0 }, _ctx.$attrs, {
          "aria-controls": Vue.unref(ariaControls),
          "aria-describedby": Vue.unref(ariaDescribedby),
          "aria-expanded": Vue.unref(ariaExpanded),
          "aria-haspopup": Vue.unref(ariaHaspopup)
        }), {
          default: Vue.withCtx(() => [
            Vue.renderSlot(_ctx.$slots, "default")
          ]),
          _: 3
        }, 16, ["aria-controls", "aria-describedby", "aria-expanded", "aria-haspopup"])) : Vue.createCommentVNode("v-if", true);
      };
    }
  }));
  var ElPopperTrigger = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/trigger.vue"]]);
  const FOCUS_AFTER_TRAPPED = "focus-trap.focus-after-trapped";
  const FOCUS_AFTER_RELEASED = "focus-trap.focus-after-released";
  const FOCUSOUT_PREVENTED = "focus-trap.focusout-prevented";
  const FOCUS_AFTER_TRAPPED_OPTS = {
    cancelable: true,
    bubbles: false
  };
  const FOCUSOUT_PREVENTED_OPTS = {
    cancelable: true,
    bubbles: false
  };
  const ON_TRAP_FOCUS_EVT = "focusAfterTrapped";
  const ON_RELEASE_FOCUS_EVT = "focusAfterReleased";
  const FOCUS_TRAP_INJECTION_KEY = Symbol("elFocusTrap");
  const focusReason = Vue.ref();
  const lastUserFocusTimestamp = Vue.ref(0);
  const lastAutomatedFocusTimestamp = Vue.ref(0);
  let focusReasonUserCount = 0;
  const obtainAllFocusableElements = (element) => {
    const nodes = [];
    const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, {
      acceptNode: (node) => {
        const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
        if (node.disabled || node.hidden || isHiddenInput)
          return NodeFilter.FILTER_SKIP;
        return node.tabIndex >= 0 || node === document.activeElement ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
      }
    });
    while (walker.nextNode())
      nodes.push(walker.currentNode);
    return nodes;
  };
  const getVisibleElement = (elements, container) => {
    for (const element of elements) {
      if (!isHidden(element, container))
        return element;
    }
  };
  const isHidden = (element, container) => {
    if (getComputedStyle(element).visibility === "hidden")
      return true;
    while (element) {
      if (container && element === container)
        return false;
      if (getComputedStyle(element).display === "none")
        return true;
      element = element.parentElement;
    }
    return false;
  };
  const getEdges = (container) => {
    const focusable = obtainAllFocusableElements(container);
    const first = getVisibleElement(focusable, container);
    const last = getVisibleElement(focusable.reverse(), container);
    return [first, last];
  };
  const isSelectable = (element) => {
    return element instanceof HTMLInputElement && "select" in element;
  };
  const tryFocus = (element, shouldSelect) => {
    if (element && element.focus) {
      const prevFocusedElement = document.activeElement;
      element.focus({ preventScroll: true });
      lastAutomatedFocusTimestamp.value = window.performance.now();
      if (element !== prevFocusedElement && isSelectable(element) && shouldSelect) {
        element.select();
      }
    }
  };
  function removeFromStack(list, item) {
    const copy = [...list];
    const idx = list.indexOf(item);
    if (idx !== -1) {
      copy.splice(idx, 1);
    }
    return copy;
  }
  const createFocusableStack = () => {
    let stack2 = [];
    const push = (layer) => {
      const currentLayer = stack2[0];
      if (currentLayer && layer !== currentLayer) {
        currentLayer.pause();
      }
      stack2 = removeFromStack(stack2, layer);
      stack2.unshift(layer);
    };
    const remove2 = (layer) => {
      var _a2, _b;
      stack2 = removeFromStack(stack2, layer);
      (_b = (_a2 = stack2[0]) == null ? void 0 : _a2.resume) == null ? void 0 : _b.call(_a2);
    };
    return {
      push,
      remove: remove2
    };
  };
  const focusFirstDescendant = (elements, shouldSelect = false) => {
    const prevFocusedElement = document.activeElement;
    for (const element of elements) {
      tryFocus(element, shouldSelect);
      if (document.activeElement !== prevFocusedElement)
        return;
    }
  };
  const focusableStack = createFocusableStack();
  const isFocusCausedByUserEvent = () => {
    return lastUserFocusTimestamp.value > lastAutomatedFocusTimestamp.value;
  };
  const notifyFocusReasonPointer = () => {
    focusReason.value = "pointer";
    lastUserFocusTimestamp.value = window.performance.now();
  };
  const notifyFocusReasonKeydown = () => {
    focusReason.value = "keyboard";
    lastUserFocusTimestamp.value = window.performance.now();
  };
  const useFocusReason = () => {
    Vue.onMounted(() => {
      if (focusReasonUserCount === 0) {
        document.addEventListener("mousedown", notifyFocusReasonPointer);
        document.addEventListener("touchstart", notifyFocusReasonPointer);
        document.addEventListener("keydown", notifyFocusReasonKeydown);
      }
      focusReasonUserCount++;
    });
    Vue.onBeforeUnmount(() => {
      focusReasonUserCount--;
      if (focusReasonUserCount <= 0) {
        document.removeEventListener("mousedown", notifyFocusReasonPointer);
        document.removeEventListener("touchstart", notifyFocusReasonPointer);
        document.removeEventListener("keydown", notifyFocusReasonKeydown);
      }
    });
    return {
      focusReason,
      lastUserFocusTimestamp,
      lastAutomatedFocusTimestamp
    };
  };
  const createFocusOutPreventedEvent = (detail) => {
    return new CustomEvent(FOCUSOUT_PREVENTED, __spreadProps(__spreadValues({}, FOCUSOUT_PREVENTED_OPTS), {
      detail
    }));
  };
  const _sfc_main$h = Vue.defineComponent({
    name: "ElFocusTrap",
    inheritAttrs: false,
    props: {
      loop: Boolean,
      trapped: Boolean,
      focusTrapEl: Object,
      focusStartEl: {
        type: [Object, String],
        default: "first"
      }
    },
    emits: [
      ON_TRAP_FOCUS_EVT,
      ON_RELEASE_FOCUS_EVT,
      "focusin",
      "focusout",
      "focusout-prevented",
      "release-requested"
    ],
    setup(props, { emit }) {
      const forwardRef = Vue.ref();
      let lastFocusBeforeTrapped;
      let lastFocusAfterTrapped;
      const { focusReason: focusReason2 } = useFocusReason();
      useEscapeKeydown((event) => {
        if (props.trapped && !focusLayer.paused) {
          emit("release-requested", event);
        }
      });
      const focusLayer = {
        paused: false,
        pause() {
          this.paused = true;
        },
        resume() {
          this.paused = false;
        }
      };
      const onKeydown = (e) => {
        if (!props.loop && !props.trapped)
          return;
        if (focusLayer.paused)
          return;
        const { key, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e;
        const { loop } = props;
        const isTabbing = key === EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey;
        const currentFocusingEl = document.activeElement;
        if (isTabbing && currentFocusingEl) {
          const container = currentTarget;
          const [first, last] = getEdges(container);
          const isTabbable = first && last;
          if (!isTabbable) {
            if (currentFocusingEl === container) {
              const focusoutPreventedEvent = createFocusOutPreventedEvent({
                focusReason: focusReason2.value
              });
              emit("focusout-prevented", focusoutPreventedEvent);
              if (!focusoutPreventedEvent.defaultPrevented) {
                e.preventDefault();
              }
            }
          } else {
            if (!shiftKey && currentFocusingEl === last) {
              const focusoutPreventedEvent = createFocusOutPreventedEvent({
                focusReason: focusReason2.value
              });
              emit("focusout-prevented", focusoutPreventedEvent);
              if (!focusoutPreventedEvent.defaultPrevented) {
                e.preventDefault();
                if (loop)
                  tryFocus(first, true);
              }
            } else if (shiftKey && [first, container].includes(currentFocusingEl)) {
              const focusoutPreventedEvent = createFocusOutPreventedEvent({
                focusReason: focusReason2.value
              });
              emit("focusout-prevented", focusoutPreventedEvent);
              if (!focusoutPreventedEvent.defaultPrevented) {
                e.preventDefault();
                if (loop)
                  tryFocus(last, true);
              }
            }
          }
        }
      };
      Vue.provide(FOCUS_TRAP_INJECTION_KEY, {
        focusTrapRef: forwardRef,
        onKeydown
      });
      Vue.watch(() => props.focusTrapEl, (focusTrapEl) => {
        if (focusTrapEl) {
          forwardRef.value = focusTrapEl;
        }
      }, { immediate: true });
      Vue.watch([forwardRef], ([forwardRef2], [oldForwardRef]) => {
        if (forwardRef2) {
          forwardRef2.addEventListener("keydown", onKeydown);
          forwardRef2.addEventListener("focusin", onFocusIn);
          forwardRef2.addEventListener("focusout", onFocusOut);
        }
        if (oldForwardRef) {
          oldForwardRef.removeEventListener("keydown", onKeydown);
          oldForwardRef.removeEventListener("focusin", onFocusIn);
          oldForwardRef.removeEventListener("focusout", onFocusOut);
        }
      });
      const trapOnFocus = (e) => {
        emit(ON_TRAP_FOCUS_EVT, e);
      };
      const releaseOnFocus = (e) => emit(ON_RELEASE_FOCUS_EVT, e);
      const onFocusIn = (e) => {
        const trapContainer = Vue.unref(forwardRef);
        if (!trapContainer)
          return;
        const target = e.target;
        const relatedTarget = e.relatedTarget;
        const isFocusedInTrap = target && trapContainer.contains(target);
        if (!props.trapped) {
          const isPrevFocusedInTrap = relatedTarget && trapContainer.contains(relatedTarget);
          if (!isPrevFocusedInTrap) {
            lastFocusBeforeTrapped = relatedTarget;
          }
        }
        if (isFocusedInTrap)
          emit("focusin", e);
        if (focusLayer.paused)
          return;
        if (props.trapped) {
          if (isFocusedInTrap) {
            lastFocusAfterTrapped = target;
          } else {
            tryFocus(lastFocusAfterTrapped, true);
          }
        }
      };
      const onFocusOut = (e) => {
        const trapContainer = Vue.unref(forwardRef);
        if (focusLayer.paused || !trapContainer)
          return;
        if (props.trapped) {
          const relatedTarget = e.relatedTarget;
          if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {
            setTimeout(() => {
              if (!focusLayer.paused && props.trapped) {
                const focusoutPreventedEvent = createFocusOutPreventedEvent({
                  focusReason: focusReason2.value
                });
                emit("focusout-prevented", focusoutPreventedEvent);
                if (!focusoutPreventedEvent.defaultPrevented) {
                  tryFocus(lastFocusAfterTrapped, true);
                }
              }
            }, 0);
          }
        } else {
          const target = e.target;
          const isFocusedInTrap = target && trapContainer.contains(target);
          if (!isFocusedInTrap)
            emit("focusout", e);
        }
      };
      async function startTrap() {
        await Vue.nextTick();
        const trapContainer = Vue.unref(forwardRef);
        if (trapContainer) {
          focusableStack.push(focusLayer);
          const prevFocusedElement = trapContainer.contains(document.activeElement) ? lastFocusBeforeTrapped : document.activeElement;
          lastFocusBeforeTrapped = prevFocusedElement;
          const isPrevFocusContained = trapContainer.contains(prevFocusedElement);
          if (!isPrevFocusContained) {
            const focusEvent = new Event(FOCUS_AFTER_TRAPPED, FOCUS_AFTER_TRAPPED_OPTS);
            trapContainer.addEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus);
            trapContainer.dispatchEvent(focusEvent);
            if (!focusEvent.defaultPrevented) {
              Vue.nextTick(() => {
                let focusStartEl = props.focusStartEl;
                if (!isString$1(focusStartEl)) {
                  tryFocus(focusStartEl);
                  if (document.activeElement !== focusStartEl) {
                    focusStartEl = "first";
                  }
                }
                if (focusStartEl === "first") {
                  focusFirstDescendant(obtainAllFocusableElements(trapContainer), true);
                }
                if (document.activeElement === prevFocusedElement || focusStartEl === "container") {
                  tryFocus(trapContainer);
                }
              });
            }
          }
        }
      }
      function stopTrap() {
        const trapContainer = Vue.unref(forwardRef);
        if (trapContainer) {
          trapContainer.removeEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus);
          const releasedEvent = new CustomEvent(FOCUS_AFTER_RELEASED, __spreadProps(__spreadValues({}, FOCUS_AFTER_TRAPPED_OPTS), {
            detail: {
              focusReason: focusReason2.value
            }
          }));
          trapContainer.addEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus);
          trapContainer.dispatchEvent(releasedEvent);
          if (!releasedEvent.defaultPrevented && (focusReason2.value == "keyboard" || !isFocusCausedByUserEvent())) {
            tryFocus(lastFocusBeforeTrapped != null ? lastFocusBeforeTrapped : document.body);
          }
          trapContainer.removeEventListener(FOCUS_AFTER_RELEASED, trapOnFocus);
          focusableStack.remove(focusLayer);
        }
      }
      Vue.onMounted(() => {
        if (props.trapped) {
          startTrap();
        }
        Vue.watch(() => props.trapped, (trapped) => {
          if (trapped) {
            startTrap();
          } else {
            stopTrap();
          }
        });
      });
      Vue.onBeforeUnmount(() => {
        if (props.trapped) {
          stopTrap();
        }
      });
      return {
        onKeydown
      };
    }
  });
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
    return Vue.renderSlot(_ctx.$slots, "default", { handleKeydown: _ctx.onKeydown });
  }
  var ElFocusTrap = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$2], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/focus-trap/src/focus-trap.vue"]]);
  const POSITIONING_STRATEGIES = ["fixed", "absolute"];
  const popperCoreConfigProps = buildProps({
    boundariesPadding: {
      type: Number,
      default: 0
    },
    fallbackPlacements: {
      type: definePropType(Array),
      default: void 0
    },
    gpuAcceleration: {
      type: Boolean,
      default: true
    },
    offset: {
      type: Number,
      default: 12
    },
    placement: {
      type: String,
      values: Ee,
      default: "bottom"
    },
    popperOptions: {
      type: definePropType(Object),
      default: () => ({})
    },
    strategy: {
      type: String,
      values: POSITIONING_STRATEGIES,
      default: "absolute"
    }
  });
  const popperContentProps = buildProps(__spreadProps(__spreadValues({}, popperCoreConfigProps), {
    id: String,
    style: {
      type: definePropType([String, Array, Object])
    },
    className: {
      type: definePropType([String, Array, Object])
    },
    effect: {
      type: String,
      default: "dark"
    },
    visible: Boolean,
    enterable: {
      type: Boolean,
      default: true
    },
    pure: Boolean,
    focusOnShow: {
      type: Boolean,
      default: false
    },
    trapping: {
      type: Boolean,
      default: false
    },
    popperClass: {
      type: definePropType([String, Array, Object])
    },
    popperStyle: {
      type: definePropType([String, Array, Object])
    },
    referenceEl: {
      type: definePropType(Object)
    },
    triggerTargetEl: {
      type: definePropType(Object)
    },
    stopPopperMouseEvent: {
      type: Boolean,
      default: true
    },
    ariaLabel: {
      type: String,
      default: void 0
    },
    virtualTriggering: Boolean,
    zIndex: Number
  }));
  const popperContentEmits = {
    mouseenter: (evt) => evt instanceof MouseEvent,
    mouseleave: (evt) => evt instanceof MouseEvent,
    focus: () => true,
    blur: () => true,
    close: () => true
  };
  const buildPopperOptions = (props, arrowProps) => {
    const { placement, strategy, popperOptions } = props;
    const options = __spreadProps(__spreadValues({
      placement,
      strategy
    }, popperOptions), {
      modifiers: genModifiers(props)
    });
    attachArrow(options, arrowProps);
    deriveExtraModifiers(options, popperOptions == null ? void 0 : popperOptions.modifiers);
    return options;
  };
  const unwrapMeasurableEl = ($el) => {
    if (!isClient)
      return;
    return unrefElement($el);
  };
  function genModifiers(options) {
    const { offset, gpuAcceleration, fallbackPlacements } = options;
    return [
      {
        name: "offset",
        options: {
          offset: [0, offset != null ? offset : 12]
        }
      },
      {
        name: "preventOverflow",
        options: {
          padding: {
            top: 2,
            bottom: 2,
            left: 5,
            right: 5
          }
        }
      },
      {
        name: "flip",
        options: {
          padding: 5,
          fallbackPlacements
        }
      },
      {
        name: "computeStyles",
        options: {
          gpuAcceleration
        }
      }
    ];
  }
  function attachArrow(options, { arrowEl, arrowOffset }) {
    options.modifiers.push({
      name: "arrow",
      options: {
        element: arrowEl,
        padding: arrowOffset != null ? arrowOffset : 5
      }
    });
  }
  function deriveExtraModifiers(options, modifiers) {
    if (modifiers) {
      options.modifiers = [...options.modifiers, ...modifiers != null ? modifiers : []];
    }
  }
  const __default__$e = Vue.defineComponent({
    name: "ElPopperContent"
  });
  const _sfc_main$g = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$e), {
    props: popperContentProps,
    emits: popperContentEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      const { popperInstanceRef, contentRef, triggerRef, role } = Vue.inject(POPPER_INJECTION_KEY, void 0);
      const formItemContext = Vue.inject(formItemContextKey, void 0);
      const { nextZIndex } = useZIndex();
      const ns2 = useNamespace("popper");
      const popperContentRef = Vue.ref();
      const focusStartRef = Vue.ref("first");
      const arrowRef = Vue.ref();
      const arrowOffset = Vue.ref();
      Vue.provide(POPPER_CONTENT_INJECTION_KEY, {
        arrowRef,
        arrowOffset
      });
      if (formItemContext && (formItemContext.addInputId || formItemContext.removeInputId)) {
        Vue.provide(formItemContextKey, __spreadProps(__spreadValues({}, formItemContext), {
          addInputId: NOOP,
          removeInputId: NOOP
        }));
      }
      const contentZIndex = Vue.ref(props.zIndex || nextZIndex());
      const trapped = Vue.ref(false);
      let triggerTargetAriaStopWatch = void 0;
      const computedReference = Vue.computed(() => unwrapMeasurableEl(props.referenceEl) || Vue.unref(triggerRef));
      const contentStyle = Vue.computed(() => [{ zIndex: Vue.unref(contentZIndex) }, props.popperStyle]);
      const contentClass = Vue.computed(() => [
        ns2.b(),
        ns2.is("pure", props.pure),
        ns2.is(props.effect),
        props.popperClass
      ]);
      const ariaModal = Vue.computed(() => {
        return role && role.value === "dialog" ? "false" : void 0;
      });
      const createPopperInstance = ({
        referenceEl,
        popperContentEl,
        arrowEl
      }) => {
        const options = buildPopperOptions(props, {
          arrowEl,
          arrowOffset: Vue.unref(arrowOffset)
        });
        return yn(referenceEl, popperContentEl, options);
      };
      const updatePopper = (shouldUpdateZIndex = true) => {
        var _a2;
        (_a2 = Vue.unref(popperInstanceRef)) == null ? void 0 : _a2.update();
        shouldUpdateZIndex && (contentZIndex.value = props.zIndex || nextZIndex());
      };
      const togglePopperAlive = () => {
        var _a2, _b;
        const monitorable = { name: "eventListeners", enabled: props.visible };
        (_b = (_a2 = Vue.unref(popperInstanceRef)) == null ? void 0 : _a2.setOptions) == null ? void 0 : _b.call(_a2, (options) => __spreadProps(__spreadValues({}, options), {
          modifiers: [...options.modifiers || [], monitorable]
        }));
        updatePopper(false);
        if (props.visible && props.focusOnShow) {
          trapped.value = true;
        } else if (props.visible === false) {
          trapped.value = false;
        }
      };
      const onFocusAfterTrapped = () => {
        emit("focus");
      };
      const onFocusAfterReleased = (event) => {
        var _a2;
        if (((_a2 = event.detail) == null ? void 0 : _a2.focusReason) !== "pointer") {
          focusStartRef.value = "first";
          emit("blur");
        }
      };
      const onFocusInTrap = (event) => {
        if (props.visible && !trapped.value) {
          if (event.target) {
            focusStartRef.value = event.target;
          }
          trapped.value = true;
        }
      };
      const onFocusoutPrevented = (event) => {
        if (!props.trapping) {
          if (event.detail.focusReason === "pointer") {
            event.preventDefault();
          }
          trapped.value = false;
        }
      };
      const onReleaseRequested = () => {
        trapped.value = false;
        emit("close");
      };
      Vue.onMounted(() => {
        let updateHandle;
        Vue.watch(computedReference, (referenceEl) => {
          var _a2;
          updateHandle == null ? void 0 : updateHandle();
          const popperInstance = Vue.unref(popperInstanceRef);
          (_a2 = popperInstance == null ? void 0 : popperInstance.destroy) == null ? void 0 : _a2.call(popperInstance);
          if (referenceEl) {
            const popperContentEl = Vue.unref(popperContentRef);
            contentRef.value = popperContentEl;
            popperInstanceRef.value = createPopperInstance({
              referenceEl,
              popperContentEl,
              arrowEl: Vue.unref(arrowRef)
            });
            updateHandle = Vue.watch(() => referenceEl.getBoundingClientRect(), () => updatePopper(), {
              immediate: true
            });
          } else {
            popperInstanceRef.value = void 0;
          }
        }, {
          immediate: true
        });
        Vue.watch(() => props.triggerTargetEl, (triggerTargetEl, prevTriggerTargetEl) => {
          triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
          triggerTargetAriaStopWatch = void 0;
          const el = Vue.unref(triggerTargetEl || popperContentRef.value);
          const prevEl = Vue.unref(prevTriggerTargetEl || popperContentRef.value);
          if (isElement(el)) {
            triggerTargetAriaStopWatch = Vue.watch([role, () => props.ariaLabel, ariaModal, () => props.id], (watches) => {
              ["role", "aria-label", "aria-modal", "id"].forEach((key, idx) => {
                isNil(watches[idx]) ? el.removeAttribute(key) : el.setAttribute(key, watches[idx]);
              });
            }, { immediate: true });
          }
          if (prevEl !== el && isElement(prevEl)) {
            ["role", "aria-label", "aria-modal", "id"].forEach((key) => {
              prevEl.removeAttribute(key);
            });
          }
        }, { immediate: true });
        Vue.watch(() => props.visible, togglePopperAlive, { immediate: true });
        Vue.watch(() => buildPopperOptions(props, {
          arrowEl: Vue.unref(arrowRef),
          arrowOffset: Vue.unref(arrowOffset)
        }), (option) => {
          var _a2;
          return (_a2 = popperInstanceRef.value) == null ? void 0 : _a2.setOptions(option);
        });
      });
      Vue.onBeforeUnmount(() => {
        triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
        triggerTargetAriaStopWatch = void 0;
      });
      expose({
        popperContentRef,
        popperInstanceRef,
        updatePopper,
        contentStyle
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          ref_key: "popperContentRef",
          ref: popperContentRef,
          style: Vue.normalizeStyle(Vue.unref(contentStyle)),
          class: Vue.normalizeClass(Vue.unref(contentClass)),
          tabindex: "-1",
          onMouseenter: _cache[0] || (_cache[0] = (e) => _ctx.$emit("mouseenter", e)),
          onMouseleave: _cache[1] || (_cache[1] = (e) => _ctx.$emit("mouseleave", e))
        }, [
          Vue.createVNode(Vue.unref(ElFocusTrap), {
            trapped: trapped.value,
            "trap-on-focus-in": true,
            "focus-trap-el": popperContentRef.value,
            "focus-start-el": focusStartRef.value,
            onFocusAfterTrapped,
            onFocusAfterReleased,
            onFocusin: onFocusInTrap,
            onFocusoutPrevented,
            onReleaseRequested
          }, {
            default: Vue.withCtx(() => [
              Vue.renderSlot(_ctx.$slots, "default")
            ]),
            _: 3
          }, 8, ["trapped", "focus-trap-el", "focus-start-el"])
        ], 38);
      };
    }
  }));
  var ElPopperContent = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/content.vue"]]);
  const ElPopper = withInstall(Popper);
  const ns = useNamespace("tooltip");
  const useTooltipContentProps = buildProps(__spreadProps(__spreadValues(__spreadValues({}, useDelayedToggleProps), popperContentProps), {
    appendTo: {
      type: definePropType([String, Object])
    },
    content: {
      type: String,
      default: ""
    },
    rawContent: {
      type: Boolean,
      default: false
    },
    persistent: Boolean,
    ariaLabel: String,
    visible: {
      type: definePropType(Boolean),
      default: null
    },
    transition: {
      type: String,
      default: `${ns.namespace.value}-fade-in-linear`
    },
    teleported: {
      type: Boolean,
      default: true
    },
    disabled: {
      type: Boolean
    }
  }));
  const useTooltipTriggerProps = buildProps(__spreadProps(__spreadValues({}, popperTriggerProps), {
    disabled: Boolean,
    trigger: {
      type: definePropType([String, Array]),
      default: "hover"
    },
    triggerKeys: {
      type: definePropType(Array),
      default: () => [EVENT_CODE.enter, EVENT_CODE.space]
    }
  }));
  const {
    useModelToggleProps: useTooltipModelToggleProps,
    useModelToggleEmits: useTooltipModelToggleEmits,
    useModelToggle: useTooltipModelToggle
  } = createModelToggleComposable("visible");
  const useTooltipProps = buildProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, popperProps), useTooltipModelToggleProps), useTooltipContentProps), useTooltipTriggerProps), popperArrowProps), {
    showArrow: {
      type: Boolean,
      default: true
    }
  }));
  const tooltipEmits = [
    ...useTooltipModelToggleEmits,
    "before-show",
    "before-hide",
    "show",
    "hide",
    "open",
    "close"
  ];
  const isTriggerType = (trigger2, type) => {
    if (isArray(trigger2)) {
      return trigger2.includes(type);
    }
    return trigger2 === type;
  };
  const whenTrigger = (trigger2, type, handler) => {
    return (e) => {
      isTriggerType(Vue.unref(trigger2), type) && handler(e);
    };
  };
  const __default__$d = Vue.defineComponent({
    name: "ElTooltipTrigger"
  });
  const _sfc_main$f = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$d), {
    props: useTooltipTriggerProps,
    setup(__props, { expose }) {
      const props = __props;
      const ns2 = useNamespace("tooltip");
      const { controlled, id, open, onOpen, onClose, onToggle } = Vue.inject(TOOLTIP_INJECTION_KEY, void 0);
      const triggerRef = Vue.ref(null);
      const stopWhenControlledOrDisabled = () => {
        if (Vue.unref(controlled) || props.disabled) {
          return true;
        }
      };
      const trigger2 = Vue.toRef(props, "trigger");
      const onMouseenter = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "hover", onOpen));
      const onMouseleave = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "hover", onClose));
      const onClick = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "click", (e) => {
        if (e.button === 0) {
          onToggle(e);
        }
      }));
      const onFocus = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "focus", onOpen));
      const onBlur = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "focus", onClose));
      const onContextMenu = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger2, "contextmenu", (e) => {
        e.preventDefault();
        onToggle(e);
      }));
      const onKeydown = composeEventHandlers(stopWhenControlledOrDisabled, (e) => {
        const { code } = e;
        if (props.triggerKeys.includes(code)) {
          e.preventDefault();
          onToggle(e);
        }
      });
      expose({
        triggerRef
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.unref(ElPopperTrigger), {
          id: Vue.unref(id),
          "virtual-ref": _ctx.virtualRef,
          open: Vue.unref(open),
          "virtual-triggering": _ctx.virtualTriggering,
          class: Vue.normalizeClass(Vue.unref(ns2).e("trigger")),
          onBlur: Vue.unref(onBlur),
          onClick: Vue.unref(onClick),
          onContextmenu: Vue.unref(onContextMenu),
          onFocus: Vue.unref(onFocus),
          onMouseenter: Vue.unref(onMouseenter),
          onMouseleave: Vue.unref(onMouseleave),
          onKeydown: Vue.unref(onKeydown)
        }, {
          default: Vue.withCtx(() => [
            Vue.renderSlot(_ctx.$slots, "default")
          ]),
          _: 3
        }, 8, ["id", "virtual-ref", "open", "virtual-triggering", "class", "onBlur", "onClick", "onContextmenu", "onFocus", "onMouseenter", "onMouseleave", "onKeydown"]);
      };
    }
  }));
  var ElTooltipTrigger = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/trigger.vue"]]);
  const __default__$c = Vue.defineComponent({
    name: "ElTooltipContent",
    inheritAttrs: false
  });
  const _sfc_main$e = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$c), {
    props: useTooltipContentProps,
    setup(__props, { expose }) {
      const props = __props;
      const { selector } = usePopperContainerId();
      const contentRef = Vue.ref(null);
      const destroyed = Vue.ref(false);
      const {
        controlled,
        id,
        open,
        trigger: trigger2,
        onClose,
        onOpen,
        onShow,
        onHide,
        onBeforeShow,
        onBeforeHide
      } = Vue.inject(TOOLTIP_INJECTION_KEY, void 0);
      const persistentRef = Vue.computed(() => {
        return props.persistent;
      });
      Vue.onBeforeUnmount(() => {
        destroyed.value = true;
      });
      const shouldRender = Vue.computed(() => {
        return Vue.unref(persistentRef) ? true : Vue.unref(open);
      });
      const shouldShow = Vue.computed(() => {
        return props.disabled ? false : Vue.unref(open);
      });
      const appendTo = Vue.computed(() => {
        return props.appendTo || selector.value;
      });
      const contentStyle = Vue.computed(() => {
        var _a2;
        return (_a2 = props.style) != null ? _a2 : {};
      });
      const ariaHidden = Vue.computed(() => !Vue.unref(open));
      const onTransitionLeave = () => {
        onHide();
      };
      const stopWhenControlled = () => {
        if (Vue.unref(controlled))
          return true;
      };
      const onContentEnter = composeEventHandlers(stopWhenControlled, () => {
        if (props.enterable && Vue.unref(trigger2) === "hover") {
          onOpen();
        }
      });
      const onContentLeave = composeEventHandlers(stopWhenControlled, () => {
        if (Vue.unref(trigger2) === "hover") {
          onClose();
        }
      });
      const onBeforeEnter = () => {
        var _a2, _b;
        (_b = (_a2 = contentRef.value) == null ? void 0 : _a2.updatePopper) == null ? void 0 : _b.call(_a2);
        onBeforeShow == null ? void 0 : onBeforeShow();
      };
      const onBeforeLeave = () => {
        onBeforeHide == null ? void 0 : onBeforeHide();
      };
      const onAfterShow = () => {
        onShow();
        stopHandle = onClickOutside(Vue.computed(() => {
          var _a2;
          return (_a2 = contentRef.value) == null ? void 0 : _a2.popperContentRef;
        }), () => {
          if (Vue.unref(controlled))
            return;
          const $trigger = Vue.unref(trigger2);
          if ($trigger !== "hover") {
            onClose();
          }
        });
      };
      const onBlur = () => {
        if (!props.virtualTriggering) {
          onClose();
        }
      };
      let stopHandle;
      Vue.watch(() => Vue.unref(open), (val) => {
        if (!val) {
          stopHandle == null ? void 0 : stopHandle();
        }
      }, {
        flush: "post"
      });
      Vue.watch(() => props.content, () => {
        var _a2, _b;
        (_b = (_a2 = contentRef.value) == null ? void 0 : _a2.updatePopper) == null ? void 0 : _b.call(_a2);
      });
      expose({
        contentRef
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.Teleport, {
          disabled: !_ctx.teleported,
          to: Vue.unref(appendTo)
        }, [
          Vue.createVNode(Vue.Transition, {
            name: _ctx.transition,
            onAfterLeave: onTransitionLeave,
            onBeforeEnter,
            onAfterEnter: onAfterShow,
            onBeforeLeave
          }, {
            default: Vue.withCtx(() => [
              Vue.unref(shouldRender) ? Vue.withDirectives((Vue.openBlock(), Vue.createBlock(Vue.unref(ElPopperContent), Vue.mergeProps({
                key: 0,
                id: Vue.unref(id),
                ref_key: "contentRef",
                ref: contentRef
              }, _ctx.$attrs, {
                "aria-label": _ctx.ariaLabel,
                "aria-hidden": Vue.unref(ariaHidden),
                "boundaries-padding": _ctx.boundariesPadding,
                "fallback-placements": _ctx.fallbackPlacements,
                "gpu-acceleration": _ctx.gpuAcceleration,
                offset: _ctx.offset,
                placement: _ctx.placement,
                "popper-options": _ctx.popperOptions,
                strategy: _ctx.strategy,
                effect: _ctx.effect,
                enterable: _ctx.enterable,
                pure: _ctx.pure,
                "popper-class": _ctx.popperClass,
                "popper-style": [_ctx.popperStyle, Vue.unref(contentStyle)],
                "reference-el": _ctx.referenceEl,
                "trigger-target-el": _ctx.triggerTargetEl,
                visible: Vue.unref(shouldShow),
                "z-index": _ctx.zIndex,
                onMouseenter: Vue.unref(onContentEnter),
                onMouseleave: Vue.unref(onContentLeave),
                onBlur,
                onClose: Vue.unref(onClose)
              }), {
                default: Vue.withCtx(() => [
                  !destroyed.value ? Vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : Vue.createCommentVNode("v-if", true)
                ]),
                _: 3
              }, 16, ["id", "aria-label", "aria-hidden", "boundaries-padding", "fallback-placements", "gpu-acceleration", "offset", "placement", "popper-options", "strategy", "effect", "enterable", "pure", "popper-class", "popper-style", "reference-el", "trigger-target-el", "visible", "z-index", "onMouseenter", "onMouseleave", "onClose"])), [
                [Vue.vShow, Vue.unref(shouldShow)]
              ]) : Vue.createCommentVNode("v-if", true)
            ]),
            _: 3
          }, 8, ["name"])
        ], 8, ["disabled", "to"]);
      };
    }
  }));
  var ElTooltipContent = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/content.vue"]]);
  const _hoisted_1$a = ["innerHTML"];
  const _hoisted_2$8 = { key: 1 };
  const __default__$b = Vue.defineComponent({
    name: "ElTooltip"
  });
  const _sfc_main$d = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$b), {
    props: useTooltipProps,
    emits: tooltipEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      usePopperContainer();
      const id = useId();
      const popperRef = Vue.ref();
      const contentRef = Vue.ref();
      const updatePopper = () => {
        var _a2;
        const popperComponent = Vue.unref(popperRef);
        if (popperComponent) {
          (_a2 = popperComponent.popperInstanceRef) == null ? void 0 : _a2.update();
        }
      };
      const open = Vue.ref(false);
      const toggleReason = Vue.ref();
      const { show, hide, hasUpdateHandler } = useTooltipModelToggle({
        indicator: open,
        toggleReason
      });
      const { onOpen, onClose } = useDelayedToggle({
        showAfter: Vue.toRef(props, "showAfter"),
        hideAfter: Vue.toRef(props, "hideAfter"),
        open: show,
        close: hide
      });
      const controlled = Vue.computed(() => isBoolean(props.visible) && !hasUpdateHandler.value);
      Vue.provide(TOOLTIP_INJECTION_KEY, {
        controlled,
        id,
        open: Vue.readonly(open),
        trigger: Vue.toRef(props, "trigger"),
        onOpen: (event) => {
          onOpen(event);
        },
        onClose: (event) => {
          onClose(event);
        },
        onToggle: (event) => {
          if (Vue.unref(open)) {
            onClose(event);
          } else {
            onOpen(event);
          }
        },
        onShow: () => {
          emit("show", toggleReason.value);
        },
        onHide: () => {
          emit("hide", toggleReason.value);
        },
        onBeforeShow: () => {
          emit("before-show", toggleReason.value);
        },
        onBeforeHide: () => {
          emit("before-hide", toggleReason.value);
        },
        updatePopper
      });
      Vue.watch(() => props.disabled, (disabled) => {
        if (disabled && open.value) {
          open.value = false;
        }
      });
      const isFocusInsideContent = () => {
        var _a2, _b;
        const popperContent = (_b = (_a2 = contentRef.value) == null ? void 0 : _a2.contentRef) == null ? void 0 : _b.popperContentRef;
        return popperContent && popperContent.contains(document.activeElement);
      };
      Vue.onDeactivated(() => open.value && hide());
      expose({
        popperRef,
        contentRef,
        isFocusInsideContent,
        updatePopper,
        onOpen,
        onClose,
        hide
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.unref(ElPopper), {
          ref_key: "popperRef",
          ref: popperRef,
          role: _ctx.role
        }, {
          default: Vue.withCtx(() => [
            Vue.createVNode(ElTooltipTrigger, {
              disabled: _ctx.disabled,
              trigger: _ctx.trigger,
              "trigger-keys": _ctx.triggerKeys,
              "virtual-ref": _ctx.virtualRef,
              "virtual-triggering": _ctx.virtualTriggering
            }, {
              default: Vue.withCtx(() => [
                _ctx.$slots.default ? Vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : Vue.createCommentVNode("v-if", true)
              ]),
              _: 3
            }, 8, ["disabled", "trigger", "trigger-keys", "virtual-ref", "virtual-triggering"]),
            Vue.createVNode(ElTooltipContent, {
              ref_key: "contentRef",
              ref: contentRef,
              "aria-label": _ctx.ariaLabel,
              "boundaries-padding": _ctx.boundariesPadding,
              content: _ctx.content,
              disabled: _ctx.disabled,
              effect: _ctx.effect,
              enterable: _ctx.enterable,
              "fallback-placements": _ctx.fallbackPlacements,
              "hide-after": _ctx.hideAfter,
              "gpu-acceleration": _ctx.gpuAcceleration,
              offset: _ctx.offset,
              persistent: _ctx.persistent,
              "popper-class": _ctx.popperClass,
              "popper-style": _ctx.popperStyle,
              placement: _ctx.placement,
              "popper-options": _ctx.popperOptions,
              pure: _ctx.pure,
              "raw-content": _ctx.rawContent,
              "reference-el": _ctx.referenceEl,
              "trigger-target-el": _ctx.triggerTargetEl,
              "show-after": _ctx.showAfter,
              strategy: _ctx.strategy,
              teleported: _ctx.teleported,
              transition: _ctx.transition,
              "virtual-triggering": _ctx.virtualTriggering,
              "z-index": _ctx.zIndex,
              "append-to": _ctx.appendTo
            }, {
              default: Vue.withCtx(() => [
                Vue.renderSlot(_ctx.$slots, "content", {}, () => [
                  _ctx.rawContent ? (Vue.openBlock(), Vue.createElementBlock("span", {
                    key: 0,
                    innerHTML: _ctx.content
                  }, null, 8, _hoisted_1$a)) : (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_2$8, Vue.toDisplayString(_ctx.content), 1))
                ]),
                _ctx.showArrow ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElPopperArrow), {
                  key: 0,
                  "arrow-offset": _ctx.arrowOffset
                }, null, 8, ["arrow-offset"])) : Vue.createCommentVNode("v-if", true)
              ]),
              _: 3
            }, 8, ["aria-label", "boundaries-padding", "content", "disabled", "effect", "enterable", "fallback-placements", "hide-after", "gpu-acceleration", "offset", "persistent", "popper-class", "popper-style", "placement", "popper-options", "pure", "raw-content", "reference-el", "trigger-target-el", "show-after", "strategy", "teleported", "transition", "virtual-triggering", "z-index", "append-to"])
          ]),
          _: 3
        }, 8, ["role"]);
      };
    }
  }));
  var Tooltip = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/tooltip.vue"]]);
  const ElTooltip = withInstall(Tooltip);
  const useButton = (props, emit) => {
    useDeprecated({
      from: "type.text",
      replacement: "link",
      version: "3.0.0",
      scope: "props",
      ref: "https://element-plus.org/en-US/component/button.html#button-attributes"
    }, Vue.computed(() => props.type === "text"));
    const buttonGroupContext = Vue.inject(buttonGroupContextKey, void 0);
    const globalConfig2 = useGlobalConfig("button");
    const { form } = useFormItem();
    const _size = useSize(Vue.computed(() => buttonGroupContext == null ? void 0 : buttonGroupContext.size));
    const _disabled = useDisabled();
    const _ref = Vue.ref();
    const slots = Vue.useSlots();
    const _type = Vue.computed(() => props.type || (buttonGroupContext == null ? void 0 : buttonGroupContext.type) || "");
    const autoInsertSpace = Vue.computed(() => {
      var _a2, _b, _c;
      return (_c = (_b = props.autoInsertSpace) != null ? _b : (_a2 = globalConfig2.value) == null ? void 0 : _a2.autoInsertSpace) != null ? _c : false;
    });
    const shouldAddSpace = Vue.computed(() => {
      var _a2;
      const defaultSlot = (_a2 = slots.default) == null ? void 0 : _a2.call(slots);
      if (autoInsertSpace.value && (defaultSlot == null ? void 0 : defaultSlot.length) === 1) {
        const slot = defaultSlot[0];
        if ((slot == null ? void 0 : slot.type) === Vue.Text) {
          const text = slot.children;
          return /^\p{Unified_Ideograph}{2}$/u.test(text.trim());
        }
      }
      return false;
    });
    const handleClick = (evt) => {
      if (props.nativeType === "reset") {
        form == null ? void 0 : form.resetFields();
      }
      emit("click", evt);
    };
    return {
      _disabled,
      _size,
      _type,
      _ref,
      shouldAddSpace,
      handleClick
    };
  };
  const buttonTypes = [
    "default",
    "primary",
    "success",
    "warning",
    "info",
    "danger",
    "text",
    ""
  ];
  const buttonNativeTypes = ["button", "submit", "reset"];
  const buttonProps = buildProps({
    size: useSizeProp,
    disabled: Boolean,
    type: {
      type: String,
      values: buttonTypes,
      default: ""
    },
    icon: {
      type: iconPropType
    },
    nativeType: {
      type: String,
      values: buttonNativeTypes,
      default: "button"
    },
    loading: Boolean,
    loadingIcon: {
      type: iconPropType,
      default: () => loading_default
    },
    plain: Boolean,
    text: Boolean,
    link: Boolean,
    bg: Boolean,
    autofocus: Boolean,
    round: Boolean,
    circle: Boolean,
    color: String,
    dark: Boolean,
    autoInsertSpace: {
      type: Boolean,
      default: void 0
    }
  });
  const buttonEmits = {
    click: (evt) => evt instanceof MouseEvent
  };
  function bound01(n, max) {
    if (isOnePointZero(n)) {
      n = "100%";
    }
    var isPercent = isPercentage(n);
    n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
    if (isPercent) {
      n = parseInt(String(n * max), 10) / 100;
    }
    if (Math.abs(n - max) < 1e-6) {
      return 1;
    }
    if (max === 360) {
      n = (n < 0 ? n % max + max : n % max) / parseFloat(String(max));
    } else {
      n = n % max / parseFloat(String(max));
    }
    return n;
  }
  function clamp01(val) {
    return Math.min(1, Math.max(0, val));
  }
  function isOnePointZero(n) {
    return typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1;
  }
  function isPercentage(n) {
    return typeof n === "string" && n.indexOf("%") !== -1;
  }
  function boundAlpha(a2) {
    a2 = parseFloat(a2);
    if (isNaN(a2) || a2 < 0 || a2 > 1) {
      a2 = 1;
    }
    return a2;
  }
  function convertToPercentage(n) {
    if (n <= 1) {
      return "".concat(Number(n) * 100, "%");
    }
    return n;
  }
  function pad2(c2) {
    return c2.length === 1 ? "0" + c2 : String(c2);
  }
  function rgbToRgb(r, g, b2) {
    return {
      r: bound01(r, 255) * 255,
      g: bound01(g, 255) * 255,
      b: bound01(b2, 255) * 255
    };
  }
  function rgbToHsl(r, g, b2) {
    r = bound01(r, 255);
    g = bound01(g, 255);
    b2 = bound01(b2, 255);
    var max = Math.max(r, g, b2);
    var min = Math.min(r, g, b2);
    var h2 = 0;
    var s2 = 0;
    var l2 = (max + min) / 2;
    if (max === min) {
      s2 = 0;
      h2 = 0;
    } else {
      var d2 = max - min;
      s2 = l2 > 0.5 ? d2 / (2 - max - min) : d2 / (max + min);
      switch (max) {
        case r:
          h2 = (g - b2) / d2 + (g < b2 ? 6 : 0);
          break;
        case g:
          h2 = (b2 - r) / d2 + 2;
          break;
        case b2:
          h2 = (r - g) / d2 + 4;
          break;
      }
      h2 /= 6;
    }
    return { h: h2, s: s2, l: l2 };
  }
  function hue2rgb(p2, q2, t) {
    if (t < 0) {
      t += 1;
    }
    if (t > 1) {
      t -= 1;
    }
    if (t < 1 / 6) {
      return p2 + (q2 - p2) * (6 * t);
    }
    if (t < 1 / 2) {
      return q2;
    }
    if (t < 2 / 3) {
      return p2 + (q2 - p2) * (2 / 3 - t) * 6;
    }
    return p2;
  }
  function hslToRgb(h2, s2, l2) {
    var r;
    var g;
    var b2;
    h2 = bound01(h2, 360);
    s2 = bound01(s2, 100);
    l2 = bound01(l2, 100);
    if (s2 === 0) {
      g = l2;
      b2 = l2;
      r = l2;
    } else {
      var q2 = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2;
      var p2 = 2 * l2 - q2;
      r = hue2rgb(p2, q2, h2 + 1 / 3);
      g = hue2rgb(p2, q2, h2);
      b2 = hue2rgb(p2, q2, h2 - 1 / 3);
    }
    return { r: r * 255, g: g * 255, b: b2 * 255 };
  }
  function rgbToHsv(r, g, b2) {
    r = bound01(r, 255);
    g = bound01(g, 255);
    b2 = bound01(b2, 255);
    var max = Math.max(r, g, b2);
    var min = Math.min(r, g, b2);
    var h2 = 0;
    var v2 = max;
    var d2 = max - min;
    var s2 = max === 0 ? 0 : d2 / max;
    if (max === min) {
      h2 = 0;
    } else {
      switch (max) {
        case r:
          h2 = (g - b2) / d2 + (g < b2 ? 6 : 0);
          break;
        case g:
          h2 = (b2 - r) / d2 + 2;
          break;
        case b2:
          h2 = (r - g) / d2 + 4;
          break;
      }
      h2 /= 6;
    }
    return { h: h2, s: s2, v: v2 };
  }
  function hsvToRgb(h2, s2, v2) {
    h2 = bound01(h2, 360) * 6;
    s2 = bound01(s2, 100);
    v2 = bound01(v2, 100);
    var i = Math.floor(h2);
    var f2 = h2 - i;
    var p2 = v2 * (1 - s2);
    var q2 = v2 * (1 - f2 * s2);
    var t = v2 * (1 - (1 - f2) * s2);
    var mod = i % 6;
    var r = [v2, q2, p2, p2, t, v2][mod];
    var g = [t, v2, v2, q2, p2, p2][mod];
    var b2 = [p2, p2, t, v2, v2, q2][mod];
    return { r: r * 255, g: g * 255, b: b2 * 255 };
  }
  function rgbToHex(r, g, b2, allow3Char) {
    var hex = [
      pad2(Math.round(r).toString(16)),
      pad2(Math.round(g).toString(16)),
      pad2(Math.round(b2).toString(16))
    ];
    if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) {
      return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
    }
    return hex.join("");
  }
  function rgbaToHex(r, g, b2, a2, allow4Char) {
    var hex = [
      pad2(Math.round(r).toString(16)),
      pad2(Math.round(g).toString(16)),
      pad2(Math.round(b2).toString(16)),
      pad2(convertDecimalToHex(a2))
    ];
    if (allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1))) {
      return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
    }
    return hex.join("");
  }
  function convertDecimalToHex(d2) {
    return Math.round(parseFloat(d2) * 255).toString(16);
  }
  function convertHexToDecimal(h2) {
    return parseIntFromHex(h2) / 255;
  }
  function parseIntFromHex(val) {
    return parseInt(val, 16);
  }
  function numberInputToObject(color) {
    return {
      r: color >> 16,
      g: (color & 65280) >> 8,
      b: color & 255
    };
  }
  var names = {
    aliceblue: "#f0f8ff",
    antiquewhite: "#faebd7",
    aqua: "#00ffff",
    aquamarine: "#7fffd4",
    azure: "#f0ffff",
    beige: "#f5f5dc",
    bisque: "#ffe4c4",
    black: "#000000",
    blanchedalmond: "#ffebcd",
    blue: "#0000ff",
    blueviolet: "#8a2be2",
    brown: "#a52a2a",
    burlywood: "#deb887",
    cadetblue: "#5f9ea0",
    chartreuse: "#7fff00",
    chocolate: "#d2691e",
    coral: "#ff7f50",
    cornflowerblue: "#6495ed",
    cornsilk: "#fff8dc",
    crimson: "#dc143c",
    cyan: "#00ffff",
    darkblue: "#00008b",
    darkcyan: "#008b8b",
    darkgoldenrod: "#b8860b",
    darkgray: "#a9a9a9",
    darkgreen: "#006400",
    darkgrey: "#a9a9a9",
    darkkhaki: "#bdb76b",
    darkmagenta: "#8b008b",
    darkolivegreen: "#556b2f",
    darkorange: "#ff8c00",
    darkorchid: "#9932cc",
    darkred: "#8b0000",
    darksalmon: "#e9967a",
    darkseagreen: "#8fbc8f",
    darkslateblue: "#483d8b",
    darkslategray: "#2f4f4f",
    darkslategrey: "#2f4f4f",
    darkturquoise: "#00ced1",
    darkviolet: "#9400d3",
    deeppink: "#ff1493",
    deepskyblue: "#00bfff",
    dimgray: "#696969",
    dimgrey: "#696969",
    dodgerblue: "#1e90ff",
    firebrick: "#b22222",
    floralwhite: "#fffaf0",
    forestgreen: "#228b22",
    fuchsia: "#ff00ff",
    gainsboro: "#dcdcdc",
    ghostwhite: "#f8f8ff",
    goldenrod: "#daa520",
    gold: "#ffd700",
    gray: "#808080",
    green: "#008000",
    greenyellow: "#adff2f",
    grey: "#808080",
    honeydew: "#f0fff0",
    hotpink: "#ff69b4",
    indianred: "#cd5c5c",
    indigo: "#4b0082",
    ivory: "#fffff0",
    khaki: "#f0e68c",
    lavenderblush: "#fff0f5",
    lavender: "#e6e6fa",
    lawngreen: "#7cfc00",
    lemonchiffon: "#fffacd",
    lightblue: "#add8e6",
    lightcoral: "#f08080",
    lightcyan: "#e0ffff",
    lightgoldenrodyellow: "#fafad2",
    lightgray: "#d3d3d3",
    lightgreen: "#90ee90",
    lightgrey: "#d3d3d3",
    lightpink: "#ffb6c1",
    lightsalmon: "#ffa07a",
    lightseagreen: "#20b2aa",
    lightskyblue: "#87cefa",
    lightslategray: "#778899",
    lightslategrey: "#778899",
    lightsteelblue: "#b0c4de",
    lightyellow: "#ffffe0",
    lime: "#00ff00",
    limegreen: "#32cd32",
    linen: "#faf0e6",
    magenta: "#ff00ff",
    maroon: "#800000",
    mediumaquamarine: "#66cdaa",
    mediumblue: "#0000cd",
    mediumorchid: "#ba55d3",
    mediumpurple: "#9370db",
    mediumseagreen: "#3cb371",
    mediumslateblue: "#7b68ee",
    mediumspringgreen: "#00fa9a",
    mediumturquoise: "#48d1cc",
    mediumvioletred: "#c71585",
    midnightblue: "#191970",
    mintcream: "#f5fffa",
    mistyrose: "#ffe4e1",
    moccasin: "#ffe4b5",
    navajowhite: "#ffdead",
    navy: "#000080",
    oldlace: "#fdf5e6",
    olive: "#808000",
    olivedrab: "#6b8e23",
    orange: "#ffa500",
    orangered: "#ff4500",
    orchid: "#da70d6",
    palegoldenrod: "#eee8aa",
    palegreen: "#98fb98",
    paleturquoise: "#afeeee",
    palevioletred: "#db7093",
    papayawhip: "#ffefd5",
    peachpuff: "#ffdab9",
    peru: "#cd853f",
    pink: "#ffc0cb",
    plum: "#dda0dd",
    powderblue: "#b0e0e6",
    purple: "#800080",
    rebeccapurple: "#663399",
    red: "#ff0000",
    rosybrown: "#bc8f8f",
    royalblue: "#4169e1",
    saddlebrown: "#8b4513",
    salmon: "#fa8072",
    sandybrown: "#f4a460",
    seagreen: "#2e8b57",
    seashell: "#fff5ee",
    sienna: "#a0522d",
    silver: "#c0c0c0",
    skyblue: "#87ceeb",
    slateblue: "#6a5acd",
    slategray: "#708090",
    slategrey: "#708090",
    snow: "#fffafa",
    springgreen: "#00ff7f",
    steelblue: "#4682b4",
    tan: "#d2b48c",
    teal: "#008080",
    thistle: "#d8bfd8",
    tomato: "#ff6347",
    turquoise: "#40e0d0",
    violet: "#ee82ee",
    wheat: "#f5deb3",
    white: "#ffffff",
    whitesmoke: "#f5f5f5",
    yellow: "#ffff00",
    yellowgreen: "#9acd32"
  };
  function inputToRGB(color) {
    var rgb = { r: 0, g: 0, b: 0 };
    var a2 = 1;
    var s2 = null;
    var v2 = null;
    var l2 = null;
    var ok = false;
    var format = false;
    if (typeof color === "string") {
      color = stringInputToObject(color);
    }
    if (typeof color === "object") {
      if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
        rgb = rgbToRgb(color.r, color.g, color.b);
        ok = true;
        format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
      } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
        s2 = convertToPercentage(color.s);
        v2 = convertToPercentage(color.v);
        rgb = hsvToRgb(color.h, s2, v2);
        ok = true;
        format = "hsv";
      } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
        s2 = convertToPercentage(color.s);
        l2 = convertToPercentage(color.l);
        rgb = hslToRgb(color.h, s2, l2);
        ok = true;
        format = "hsl";
      }
      if (Object.prototype.hasOwnProperty.call(color, "a")) {
        a2 = color.a;
      }
    }
    a2 = boundAlpha(a2);
    return {
      ok,
      format: color.format || format,
      r: Math.min(255, Math.max(rgb.r, 0)),
      g: Math.min(255, Math.max(rgb.g, 0)),
      b: Math.min(255, Math.max(rgb.b, 0)),
      a: a2
    };
  }
  var CSS_INTEGER = "[-\\+]?\\d+%?";
  var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
  var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
  var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
  var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
  var matchers = {
    CSS_UNIT: new RegExp(CSS_UNIT),
    rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
    rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
    hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
    hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
    hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
    hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
    hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
    hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  };
  function stringInputToObject(color) {
    color = color.trim().toLowerCase();
    if (color.length === 0) {
      return false;
    }
    var named = false;
    if (names[color]) {
      color = names[color];
      named = true;
    } else if (color === "transparent") {
      return { r: 0, g: 0, b: 0, a: 0, format: "name" };
    }
    var match = matchers.rgb.exec(color);
    if (match) {
      return { r: match[1], g: match[2], b: match[3] };
    }
    match = matchers.rgba.exec(color);
    if (match) {
      return { r: match[1], g: match[2], b: match[3], a: match[4] };
    }
    match = matchers.hsl.exec(color);
    if (match) {
      return { h: match[1], s: match[2], l: match[3] };
    }
    match = matchers.hsla.exec(color);
    if (match) {
      return { h: match[1], s: match[2], l: match[3], a: match[4] };
    }
    match = matchers.hsv.exec(color);
    if (match) {
      return { h: match[1], s: match[2], v: match[3] };
    }
    match = matchers.hsva.exec(color);
    if (match) {
      return { h: match[1], s: match[2], v: match[3], a: match[4] };
    }
    match = matchers.hex8.exec(color);
    if (match) {
      return {
        r: parseIntFromHex(match[1]),
        g: parseIntFromHex(match[2]),
        b: parseIntFromHex(match[3]),
        a: convertHexToDecimal(match[4]),
        format: named ? "name" : "hex8"
      };
    }
    match = matchers.hex6.exec(color);
    if (match) {
      return {
        r: parseIntFromHex(match[1]),
        g: parseIntFromHex(match[2]),
        b: parseIntFromHex(match[3]),
        format: named ? "name" : "hex"
      };
    }
    match = matchers.hex4.exec(color);
    if (match) {
      return {
        r: parseIntFromHex(match[1] + match[1]),
        g: parseIntFromHex(match[2] + match[2]),
        b: parseIntFromHex(match[3] + match[3]),
        a: convertHexToDecimal(match[4] + match[4]),
        format: named ? "name" : "hex8"
      };
    }
    match = matchers.hex3.exec(color);
    if (match) {
      return {
        r: parseIntFromHex(match[1] + match[1]),
        g: parseIntFromHex(match[2] + match[2]),
        b: parseIntFromHex(match[3] + match[3]),
        format: named ? "name" : "hex"
      };
    }
    return false;
  }
  function isValidCSSUnit(color) {
    return Boolean(matchers.CSS_UNIT.exec(String(color)));
  }
  var TinyColor = function() {
    function TinyColor2(color, opts) {
      if (color === void 0) {
        color = "";
      }
      if (opts === void 0) {
        opts = {};
      }
      var _a2;
      if (color instanceof TinyColor2) {
        return color;
      }
      if (typeof color === "number") {
        color = numberInputToObject(color);
      }
      this.originalInput = color;
      var rgb = inputToRGB(color);
      this.originalInput = color;
      this.r = rgb.r;
      this.g = rgb.g;
      this.b = rgb.b;
      this.a = rgb.a;
      this.roundA = Math.round(100 * this.a) / 100;
      this.format = (_a2 = opts.format) !== null && _a2 !== void 0 ? _a2 : rgb.format;
      this.gradientType = opts.gradientType;
      if (this.r < 1) {
        this.r = Math.round(this.r);
      }
      if (this.g < 1) {
        this.g = Math.round(this.g);
      }
      if (this.b < 1) {
        this.b = Math.round(this.b);
      }
      this.isValid = rgb.ok;
    }
    TinyColor2.prototype.isDark = function() {
      return this.getBrightness() < 128;
    };
    TinyColor2.prototype.isLight = function() {
      return !this.isDark();
    };
    TinyColor2.prototype.getBrightness = function() {
      var rgb = this.toRgb();
      return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
    };
    TinyColor2.prototype.getLuminance = function() {
      var rgb = this.toRgb();
      var R2;
      var G2;
      var B2;
      var RsRGB = rgb.r / 255;
      var GsRGB = rgb.g / 255;
      var BsRGB = rgb.b / 255;
      if (RsRGB <= 0.03928) {
        R2 = RsRGB / 12.92;
      } else {
        R2 = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
      }
      if (GsRGB <= 0.03928) {
        G2 = GsRGB / 12.92;
      } else {
        G2 = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
      }
      if (BsRGB <= 0.03928) {
        B2 = BsRGB / 12.92;
      } else {
        B2 = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
      }
      return 0.2126 * R2 + 0.7152 * G2 + 0.0722 * B2;
    };
    TinyColor2.prototype.getAlpha = function() {
      return this.a;
    };
    TinyColor2.prototype.setAlpha = function(alpha) {
      this.a = boundAlpha(alpha);
      this.roundA = Math.round(100 * this.a) / 100;
      return this;
    };
    TinyColor2.prototype.isMonochrome = function() {
      var s2 = this.toHsl().s;
      return s2 === 0;
    };
    TinyColor2.prototype.toHsv = function() {
      var hsv = rgbToHsv(this.r, this.g, this.b);
      return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
    };
    TinyColor2.prototype.toHsvString = function() {
      var hsv = rgbToHsv(this.r, this.g, this.b);
      var h2 = Math.round(hsv.h * 360);
      var s2 = Math.round(hsv.s * 100);
      var v2 = Math.round(hsv.v * 100);
      return this.a === 1 ? "hsv(".concat(h2, ", ").concat(s2, "%, ").concat(v2, "%)") : "hsva(".concat(h2, ", ").concat(s2, "%, ").concat(v2, "%, ").concat(this.roundA, ")");
    };
    TinyColor2.prototype.toHsl = function() {
      var hsl = rgbToHsl(this.r, this.g, this.b);
      return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
    };
    TinyColor2.prototype.toHslString = function() {
      var hsl = rgbToHsl(this.r, this.g, this.b);
      var h2 = Math.round(hsl.h * 360);
      var s2 = Math.round(hsl.s * 100);
      var l2 = Math.round(hsl.l * 100);
      return this.a === 1 ? "hsl(".concat(h2, ", ").concat(s2, "%, ").concat(l2, "%)") : "hsla(".concat(h2, ", ").concat(s2, "%, ").concat(l2, "%, ").concat(this.roundA, ")");
    };
    TinyColor2.prototype.toHex = function(allow3Char) {
      if (allow3Char === void 0) {
        allow3Char = false;
      }
      return rgbToHex(this.r, this.g, this.b, allow3Char);
    };
    TinyColor2.prototype.toHexString = function(allow3Char) {
      if (allow3Char === void 0) {
        allow3Char = false;
      }
      return "#" + this.toHex(allow3Char);
    };
    TinyColor2.prototype.toHex8 = function(allow4Char) {
      if (allow4Char === void 0) {
        allow4Char = false;
      }
      return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
    };
    TinyColor2.prototype.toHex8String = function(allow4Char) {
      if (allow4Char === void 0) {
        allow4Char = false;
      }
      return "#" + this.toHex8(allow4Char);
    };
    TinyColor2.prototype.toRgb = function() {
      return {
        r: Math.round(this.r),
        g: Math.round(this.g),
        b: Math.round(this.b),
        a: this.a
      };
    };
    TinyColor2.prototype.toRgbString = function() {
      var r = Math.round(this.r);
      var g = Math.round(this.g);
      var b2 = Math.round(this.b);
      return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b2, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b2, ", ").concat(this.roundA, ")");
    };
    TinyColor2.prototype.toPercentageRgb = function() {
      var fmt = function(x2) {
        return "".concat(Math.round(bound01(x2, 255) * 100), "%");
      };
      return {
        r: fmt(this.r),
        g: fmt(this.g),
        b: fmt(this.b),
        a: this.a
      };
    };
    TinyColor2.prototype.toPercentageRgbString = function() {
      var rnd2 = function(x2) {
        return Math.round(bound01(x2, 255) * 100);
      };
      return this.a === 1 ? "rgb(".concat(rnd2(this.r), "%, ").concat(rnd2(this.g), "%, ").concat(rnd2(this.b), "%)") : "rgba(".concat(rnd2(this.r), "%, ").concat(rnd2(this.g), "%, ").concat(rnd2(this.b), "%, ").concat(this.roundA, ")");
    };
    TinyColor2.prototype.toName = function() {
      if (this.a === 0) {
        return "transparent";
      }
      if (this.a < 1) {
        return false;
      }
      var hex = "#" + rgbToHex(this.r, this.g, this.b, false);
      for (var _i = 0, _a2 = Object.entries(names); _i < _a2.length; _i++) {
        var _b = _a2[_i], key = _b[0], value = _b[1];
        if (hex === value) {
          return key;
        }
      }
      return false;
    };
    TinyColor2.prototype.toString = function(format) {
      var formatSet = Boolean(format);
      format = format !== null && format !== void 0 ? format : this.format;
      var formattedString = false;
      var hasAlpha = this.a < 1 && this.a >= 0;
      var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith("hex") || format === "name");
      if (needsAlphaFormat) {
        if (format === "name" && this.a === 0) {
          return this.toName();
        }
        return this.toRgbString();
      }
      if (format === "rgb") {
        formattedString = this.toRgbString();
      }
      if (format === "prgb") {
        formattedString = this.toPercentageRgbString();
      }
      if (format === "hex" || format === "hex6") {
        formattedString = this.toHexString();
      }
      if (format === "hex3") {
        formattedString = this.toHexString(true);
      }
      if (format === "hex4") {
        formattedString = this.toHex8String(true);
      }
      if (format === "hex8") {
        formattedString = this.toHex8String();
      }
      if (format === "name") {
        formattedString = this.toName();
      }
      if (format === "hsl") {
        formattedString = this.toHslString();
      }
      if (format === "hsv") {
        formattedString = this.toHsvString();
      }
      return formattedString || this.toHexString();
    };
    TinyColor2.prototype.toNumber = function() {
      return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
    };
    TinyColor2.prototype.clone = function() {
      return new TinyColor2(this.toString());
    };
    TinyColor2.prototype.lighten = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      var hsl = this.toHsl();
      hsl.l += amount / 100;
      hsl.l = clamp01(hsl.l);
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.brighten = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      var rgb = this.toRgb();
      rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
      rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
      rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
      return new TinyColor2(rgb);
    };
    TinyColor2.prototype.darken = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      var hsl = this.toHsl();
      hsl.l -= amount / 100;
      hsl.l = clamp01(hsl.l);
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.tint = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      return this.mix("white", amount);
    };
    TinyColor2.prototype.shade = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      return this.mix("black", amount);
    };
    TinyColor2.prototype.desaturate = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      var hsl = this.toHsl();
      hsl.s -= amount / 100;
      hsl.s = clamp01(hsl.s);
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.saturate = function(amount) {
      if (amount === void 0) {
        amount = 10;
      }
      var hsl = this.toHsl();
      hsl.s += amount / 100;
      hsl.s = clamp01(hsl.s);
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.greyscale = function() {
      return this.desaturate(100);
    };
    TinyColor2.prototype.spin = function(amount) {
      var hsl = this.toHsl();
      var hue = (hsl.h + amount) % 360;
      hsl.h = hue < 0 ? 360 + hue : hue;
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.mix = function(color, amount) {
      if (amount === void 0) {
        amount = 50;
      }
      var rgb1 = this.toRgb();
      var rgb2 = new TinyColor2(color).toRgb();
      var p2 = amount / 100;
      var rgba = {
        r: (rgb2.r - rgb1.r) * p2 + rgb1.r,
        g: (rgb2.g - rgb1.g) * p2 + rgb1.g,
        b: (rgb2.b - rgb1.b) * p2 + rgb1.b,
        a: (rgb2.a - rgb1.a) * p2 + rgb1.a
      };
      return new TinyColor2(rgba);
    };
    TinyColor2.prototype.analogous = function(results, slices) {
      if (results === void 0) {
        results = 6;
      }
      if (slices === void 0) {
        slices = 30;
      }
      var hsl = this.toHsl();
      var part = 360 / slices;
      var ret = [this];
      for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
        hsl.h = (hsl.h + part) % 360;
        ret.push(new TinyColor2(hsl));
      }
      return ret;
    };
    TinyColor2.prototype.complement = function() {
      var hsl = this.toHsl();
      hsl.h = (hsl.h + 180) % 360;
      return new TinyColor2(hsl);
    };
    TinyColor2.prototype.monochromatic = function(results) {
      if (results === void 0) {
        results = 6;
      }
      var hsv = this.toHsv();
      var h2 = hsv.h;
      var s2 = hsv.s;
      var v2 = hsv.v;
      var res = [];
      var modification = 1 / results;
      while (results--) {
        res.push(new TinyColor2({ h: h2, s: s2, v: v2 }));
        v2 = (v2 + modification) % 1;
      }
      return res;
    };
    TinyColor2.prototype.splitcomplement = function() {
      var hsl = this.toHsl();
      var h2 = hsl.h;
      return [
        this,
        new TinyColor2({ h: (h2 + 72) % 360, s: hsl.s, l: hsl.l }),
        new TinyColor2({ h: (h2 + 216) % 360, s: hsl.s, l: hsl.l })
      ];
    };
    TinyColor2.prototype.onBackground = function(background) {
      var fg = this.toRgb();
      var bg = new TinyColor2(background).toRgb();
      return new TinyColor2({
        r: bg.r + (fg.r - bg.r) * fg.a,
        g: bg.g + (fg.g - bg.g) * fg.a,
        b: bg.b + (fg.b - bg.b) * fg.a
      });
    };
    TinyColor2.prototype.triad = function() {
      return this.polyad(3);
    };
    TinyColor2.prototype.tetrad = function() {
      return this.polyad(4);
    };
    TinyColor2.prototype.polyad = function(n) {
      var hsl = this.toHsl();
      var h2 = hsl.h;
      var result = [this];
      var increment = 360 / n;
      for (var i = 1; i < n; i++) {
        result.push(new TinyColor2({ h: (h2 + i * increment) % 360, s: hsl.s, l: hsl.l }));
      }
      return result;
    };
    TinyColor2.prototype.equals = function(color) {
      return this.toRgbString() === new TinyColor2(color).toRgbString();
    };
    return TinyColor2;
  }();
  function darken(color, amount = 20) {
    return color.mix("#141414", amount).toString();
  }
  function useButtonCustomStyle(props) {
    const _disabled = useDisabled();
    const ns2 = useNamespace("button");
    return Vue.computed(() => {
      let styles = {};
      const buttonColor = props.color;
      if (buttonColor) {
        const color = new TinyColor(buttonColor);
        const activeBgColor = props.dark ? color.tint(20).toString() : darken(color, 20);
        if (props.plain) {
          styles = ns2.cssVarBlock({
            "bg-color": props.dark ? darken(color, 90) : color.tint(90).toString(),
            "text-color": buttonColor,
            "border-color": props.dark ? darken(color, 50) : color.tint(50).toString(),
            "hover-text-color": `var(${ns2.cssVarName("color-white")})`,
            "hover-bg-color": buttonColor,
            "hover-border-color": buttonColor,
            "active-bg-color": activeBgColor,
            "active-text-color": `var(${ns2.cssVarName("color-white")})`,
            "active-border-color": activeBgColor
          });
          if (_disabled.value) {
            styles[ns2.cssVarBlockName("disabled-bg-color")] = props.dark ? darken(color, 90) : color.tint(90).toString();
            styles[ns2.cssVarBlockName("disabled-text-color")] = props.dark ? darken(color, 50) : color.tint(50).toString();
            styles[ns2.cssVarBlockName("disabled-border-color")] = props.dark ? darken(color, 80) : color.tint(80).toString();
          }
        } else {
          const hoverBgColor = props.dark ? darken(color, 30) : color.tint(30).toString();
          const textColor = color.isDark() ? `var(${ns2.cssVarName("color-white")})` : `var(${ns2.cssVarName("color-black")})`;
          styles = ns2.cssVarBlock({
            "bg-color": buttonColor,
            "text-color": textColor,
            "border-color": buttonColor,
            "hover-bg-color": hoverBgColor,
            "hover-text-color": textColor,
            "hover-border-color": hoverBgColor,
            "active-bg-color": activeBgColor,
            "active-border-color": activeBgColor
          });
          if (_disabled.value) {
            const disabledButtonColor = props.dark ? darken(color, 50) : color.tint(50).toString();
            styles[ns2.cssVarBlockName("disabled-bg-color")] = disabledButtonColor;
            styles[ns2.cssVarBlockName("disabled-text-color")] = props.dark ? "rgba(255, 255, 255, 0.5)" : `var(${ns2.cssVarName("color-white")})`;
            styles[ns2.cssVarBlockName("disabled-border-color")] = disabledButtonColor;
          }
        }
      }
      return styles;
    });
  }
  const _hoisted_1$9 = ["aria-disabled", "disabled", "autofocus", "type"];
  const __default__$a = Vue.defineComponent({
    name: "ElButton"
  });
  const _sfc_main$c = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$a), {
    props: buttonProps,
    emits: buttonEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      const buttonStyle = useButtonCustomStyle(props);
      const ns2 = useNamespace("button");
      const { _ref, _size, _type, _disabled, shouldAddSpace, handleClick } = useButton(props, emit);
      expose({
        ref: _ref,
        size: _size,
        type: _type,
        disabled: _disabled,
        shouldAddSpace
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("button", {
          ref_key: "_ref",
          ref: _ref,
          class: Vue.normalizeClass([
            Vue.unref(ns2).b(),
            Vue.unref(ns2).m(Vue.unref(_type)),
            Vue.unref(ns2).m(Vue.unref(_size)),
            Vue.unref(ns2).is("disabled", Vue.unref(_disabled)),
            Vue.unref(ns2).is("loading", _ctx.loading),
            Vue.unref(ns2).is("plain", _ctx.plain),
            Vue.unref(ns2).is("round", _ctx.round),
            Vue.unref(ns2).is("circle", _ctx.circle),
            Vue.unref(ns2).is("text", _ctx.text),
            Vue.unref(ns2).is("link", _ctx.link),
            Vue.unref(ns2).is("has-bg", _ctx.bg)
          ]),
          "aria-disabled": Vue.unref(_disabled) || _ctx.loading,
          disabled: Vue.unref(_disabled) || _ctx.loading,
          autofocus: _ctx.autofocus,
          type: _ctx.nativeType,
          style: Vue.normalizeStyle(Vue.unref(buttonStyle)),
          onClick: _cache[0] || (_cache[0] = (...args) => Vue.unref(handleClick) && Vue.unref(handleClick)(...args))
        }, [
          _ctx.loading ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
            _ctx.$slots.loading ? Vue.renderSlot(_ctx.$slots, "loading", { key: 0 }) : (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
              key: 1,
              class: Vue.normalizeClass(Vue.unref(ns2).is("loading"))
            }, {
              default: Vue.withCtx(() => [
                (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.loadingIcon)))
              ]),
              _: 1
            }, 8, ["class"]))
          ], 64)) : _ctx.icon || _ctx.$slots.icon ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), { key: 1 }, {
            default: Vue.withCtx(() => [
              _ctx.icon ? (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.icon), { key: 0 })) : Vue.renderSlot(_ctx.$slots, "icon", { key: 1 })
            ]),
            _: 3
          })) : Vue.createCommentVNode("v-if", true),
          _ctx.$slots.default ? (Vue.openBlock(), Vue.createElementBlock("span", {
            key: 2,
            class: Vue.normalizeClass({ [Vue.unref(ns2).em("text", "expand")]: Vue.unref(shouldAddSpace) })
          }, [
            Vue.renderSlot(_ctx.$slots, "default")
          ], 2)) : Vue.createCommentVNode("v-if", true)
        ], 14, _hoisted_1$9);
      };
    }
  }));
  var Button = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button.vue"]]);
  const buttonGroupProps = {
    size: buttonProps.size,
    type: buttonProps.type
  };
  const __default__$9 = Vue.defineComponent({
    name: "ElButtonGroup"
  });
  const _sfc_main$b = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$9), {
    props: buttonGroupProps,
    setup(__props) {
      const props = __props;
      Vue.provide(buttonGroupContextKey, Vue.reactive({
        size: Vue.toRef(props, "size"),
        type: Vue.toRef(props, "type")
      }));
      const ns2 = useNamespace("button");
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          class: Vue.normalizeClass(`${Vue.unref(ns2).b("group")}`)
        }, [
          Vue.renderSlot(_ctx.$slots, "default")
        ], 2);
      };
    }
  }));
  var ButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button-group.vue"]]);
  const ElButton = withInstall(Button, {
    ButtonGroup
  });
  withNoopInstall(ButtonGroup);
  const nodeList = /* @__PURE__ */ new Map();
  let startClick;
  if (isClient) {
    document.addEventListener("mousedown", (e) => startClick = e);
    document.addEventListener("mouseup", (e) => {
      for (const handlers of nodeList.values()) {
        for (const { documentHandler } of handlers) {
          documentHandler(e, startClick);
        }
      }
    });
  }
  function createDocumentHandler(el, binding) {
    let excludes = [];
    if (Array.isArray(binding.arg)) {
      excludes = binding.arg;
    } else if (isElement(binding.arg)) {
      excludes.push(binding.arg);
    }
    return function(mouseup, mousedown) {
      const popperRef = binding.instance.popperRef;
      const mouseUpTarget = mouseup.target;
      const mouseDownTarget = mousedown == null ? void 0 : mousedown.target;
      const isBound = !binding || !binding.instance;
      const isTargetExists = !mouseUpTarget || !mouseDownTarget;
      const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget);
      const isSelf = el === mouseUpTarget;
      const isTargetExcluded = excludes.length && excludes.some((item) => item == null ? void 0 : item.contains(mouseUpTarget)) || excludes.length && excludes.includes(mouseDownTarget);
      const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget));
      if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) {
        return;
      }
      binding.value(mouseup, mousedown);
    };
  }
  const ClickOutside = {
    beforeMount(el, binding) {
      if (!nodeList.has(el)) {
        nodeList.set(el, []);
      }
      nodeList.get(el).push({
        documentHandler: createDocumentHandler(el, binding),
        bindingFn: binding.value
      });
    },
    updated(el, binding) {
      if (!nodeList.has(el)) {
        nodeList.set(el, []);
      }
      const handlers = nodeList.get(el);
      const oldHandlerIndex = handlers.findIndex((item) => item.bindingFn === binding.oldValue);
      const newHandler = {
        documentHandler: createDocumentHandler(el, binding),
        bindingFn: binding.value
      };
      if (oldHandlerIndex >= 0) {
        handlers.splice(oldHandlerIndex, 1, newHandler);
      } else {
        handlers.push(newHandler);
      }
    },
    unmounted(el) {
      nodeList.delete(el);
    }
  };
  const REPEAT_INTERVAL = 100;
  const REPEAT_DELAY = 600;
  const vRepeatClick = {
    beforeMount(el, binding) {
      const value = binding.value;
      const { interval = REPEAT_INTERVAL, delay = REPEAT_DELAY } = isFunction$1(value) ? {} : value;
      let intervalId;
      let delayId;
      const handler = () => isFunction$1(value) ? value() : value.handler();
      const clear2 = () => {
        if (delayId) {
          clearTimeout(delayId);
          delayId = void 0;
        }
        if (intervalId) {
          clearInterval(intervalId);
          intervalId = void 0;
        }
      };
      el.addEventListener("mousedown", (evt) => {
        if (evt.button !== 0)
          return;
        clear2();
        handler();
        document.addEventListener("mouseup", () => clear2(), {
          once: true
        });
        delayId = setTimeout(() => {
          intervalId = setInterval(() => {
            handler();
          }, interval);
        }, delay);
      });
    }
  };
  var v = false, o, f, s, u, d, N, l, p, m, w, D, x, E, M, F;
  function a() {
    if (!v) {
      v = true;
      var e = navigator.userAgent, n = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e), i = /(Mac OS X)|(Windows)|(Linux)/.exec(e);
      if (x = /\b(iPhone|iP[ao]d)/.exec(e), E = /\b(iP[ao]d)/.exec(e), w = /Android/i.exec(e), M = /FBAN\/\w+;/i.exec(e), F = /Mobile/i.exec(e), D = !!/Win64/.exec(e), n) {
        o = n[1] ? parseFloat(n[1]) : n[5] ? parseFloat(n[5]) : NaN, o && document && document.documentMode && (o = document.documentMode);
        var r = /(?:Trident\/(\d+.\d+))/.exec(e);
        N = r ? parseFloat(r[1]) + 4 : o, f = n[2] ? parseFloat(n[2]) : NaN, s = n[3] ? parseFloat(n[3]) : NaN, u = n[4] ? parseFloat(n[4]) : NaN, u ? (n = /(?:Chrome\/(\d+\.\d+))/.exec(e), d = n && n[1] ? parseFloat(n[1]) : NaN) : d = NaN;
      } else
        o = f = s = d = u = NaN;
      if (i) {
        if (i[1]) {
          var t = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);
          l = t ? parseFloat(t[1].replace("_", ".")) : true;
        } else
          l = false;
        p = !!i[2], m = !!i[3];
      } else
        l = p = m = false;
    }
  }
  var _ = { ie: function() {
    return a() || o;
  }, ieCompatibilityMode: function() {
    return a() || N > o;
  }, ie64: function() {
    return _.ie() && D;
  }, firefox: function() {
    return a() || f;
  }, opera: function() {
    return a() || s;
  }, webkit: function() {
    return a() || u;
  }, safari: function() {
    return _.webkit();
  }, chrome: function() {
    return a() || d;
  }, windows: function() {
    return a() || p;
  }, osx: function() {
    return a() || l;
  }, linux: function() {
    return a() || m;
  }, iphone: function() {
    return a() || x;
  }, mobile: function() {
    return a() || x || E || w || F;
  }, nativeApp: function() {
    return a() || M;
  }, android: function() {
    return a() || w;
  }, ipad: function() {
    return a() || E;
  } }, A = _;
  var c = !!(typeof window < "u" && window.document && window.document.createElement), U = { canUseDOM: c, canUseWorkers: typeof Worker < "u", canUseEventListeners: c && !!(window.addEventListener || window.attachEvent), canUseViewport: c && !!window.screen, isInWorker: !c }, h = U;
  var X;
  h.canUseDOM && (X = document.implementation && document.implementation.hasFeature && document.implementation.hasFeature("", "") !== true);
  function S(e, n) {
    if (!h.canUseDOM || n && !("addEventListener" in document))
      return false;
    var i = "on" + e, r = i in document;
    if (!r) {
      var t = document.createElement("div");
      t.setAttribute(i, "return;"), r = typeof t[i] == "function";
    }
    return !r && X && e === "wheel" && (r = document.implementation.hasFeature("Events.wheel", "3.0")), r;
  }
  var b = S;
  var O = 10, I = 40, P = 800;
  function T(e) {
    var n = 0, i = 0, r = 0, t = 0;
    return "detail" in e && (i = e.detail), "wheelDelta" in e && (i = -e.wheelDelta / 120), "wheelDeltaY" in e && (i = -e.wheelDeltaY / 120), "wheelDeltaX" in e && (n = -e.wheelDeltaX / 120), "axis" in e && e.axis === e.HORIZONTAL_AXIS && (n = i, i = 0), r = n * O, t = i * O, "deltaY" in e && (t = e.deltaY), "deltaX" in e && (r = e.deltaX), (r || t) && e.deltaMode && (e.deltaMode == 1 ? (r *= I, t *= I) : (r *= P, t *= P)), r && !n && (n = r < 1 ? -1 : 1), t && !i && (i = t < 1 ? -1 : 1), { spinX: n, spinY: i, pixelX: r, pixelY: t };
  }
  T.getEventType = function() {
    return A.firefox() ? "DOMMouseScroll" : b("wheel") ? "wheel" : "mousewheel";
  };
  var Y = T;
  /**
  * Checks if an event is supported in the current execution environment.
  *
  * NOTE: This will not work correctly for non-generic events such as `change`,
  * `reset`, `load`, `error`, and `select`.
  *
  * Borrows from Modernizr.
  *
  * @param {string} eventNameSuffix Event name, e.g. "click".
  * @param {?boolean} capture Check if the capture phase is supported.
  * @return {boolean} True if the event is supported.
  * @internal
  * @license Modernizr 3.0.0pre (Custom Build) | MIT
  */
  const mousewheel = function(element, callback) {
    if (element && element.addEventListener) {
      const fn2 = function(event) {
        const normalized = Y(event);
        callback && Reflect.apply(callback, this, [event, normalized]);
      };
      element.addEventListener("wheel", fn2, { passive: true });
    }
  };
  const Mousewheel = {
    beforeMount(el, binding) {
      mousewheel(el, binding.value);
    }
  };
  const checkboxProps = {
    modelValue: {
      type: [Number, String, Boolean],
      default: void 0
    },
    label: {
      type: [String, Boolean, Number, Object]
    },
    indeterminate: Boolean,
    disabled: Boolean,
    checked: Boolean,
    name: {
      type: String,
      default: void 0
    },
    trueLabel: {
      type: [String, Number],
      default: void 0
    },
    falseLabel: {
      type: [String, Number],
      default: void 0
    },
    id: {
      type: String,
      default: void 0
    },
    controls: {
      type: String,
      default: void 0
    },
    border: Boolean,
    size: useSizeProp,
    tabindex: [String, Number],
    validateEvent: {
      type: Boolean,
      default: true
    }
  };
  const checkboxEmits = {
    [UPDATE_MODEL_EVENT]: (val) => isString$1(val) || isNumber(val) || isBoolean(val),
    change: (val) => isString$1(val) || isNumber(val) || isBoolean(val)
  };
  const useCheckboxDisabled = ({
    model,
    isChecked
  }) => {
    const checkboxGroup = Vue.inject(checkboxGroupContextKey, void 0);
    const isLimitDisabled = Vue.computed(() => {
      var _a2, _b;
      const max = (_a2 = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a2.value;
      const min = (_b = checkboxGroup == null ? void 0 : checkboxGroup.min) == null ? void 0 : _b.value;
      return !isUndefined(max) && model.value.length >= max && !isChecked.value || !isUndefined(min) && model.value.length <= min && isChecked.value;
    });
    const isDisabled = useDisabled(Vue.computed(() => (checkboxGroup == null ? void 0 : checkboxGroup.disabled.value) || isLimitDisabled.value));
    return {
      isDisabled,
      isLimitDisabled
    };
  };
  const useCheckboxEvent = (props, {
    model,
    isLimitExceeded,
    hasOwnLabel,
    isDisabled,
    isLabeledByFormItem
  }) => {
    const checkboxGroup = Vue.inject(checkboxGroupContextKey, void 0);
    const { formItem } = useFormItem();
    const { emit } = Vue.getCurrentInstance();
    function getLabeledValue(value) {
      var _a2, _b;
      return value === props.trueLabel || value === true ? (_a2 = props.trueLabel) != null ? _a2 : true : (_b = props.falseLabel) != null ? _b : false;
    }
    function emitChangeEvent(checked, e) {
      emit("change", getLabeledValue(checked), e);
    }
    function handleChange(e) {
      if (isLimitExceeded.value)
        return;
      const target = e.target;
      emit("change", getLabeledValue(target.checked), e);
    }
    async function onClickRoot(e) {
      if (isLimitExceeded.value)
        return;
      if (!hasOwnLabel.value && !isDisabled.value && isLabeledByFormItem.value) {
        const eventTargets = e.composedPath();
        const hasLabel = eventTargets.some((item) => item.tagName === "LABEL");
        if (!hasLabel) {
          model.value = getLabeledValue([false, props.falseLabel].includes(model.value));
          await Vue.nextTick();
          emitChangeEvent(model.value, e);
        }
      }
    }
    const validateEvent = Vue.computed(() => (checkboxGroup == null ? void 0 : checkboxGroup.validateEvent) || props.validateEvent);
    Vue.watch(() => props.modelValue, () => {
      if (validateEvent.value) {
        formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
      }
    });
    return {
      handleChange,
      onClickRoot
    };
  };
  const useCheckboxModel = (props) => {
    const selfModel = Vue.ref(false);
    const { emit } = Vue.getCurrentInstance();
    const checkboxGroup = Vue.inject(checkboxGroupContextKey, void 0);
    const isGroup = Vue.computed(() => isUndefined(checkboxGroup) === false);
    const isLimitExceeded = Vue.ref(false);
    const model = Vue.computed({
      get() {
        var _a2, _b;
        return isGroup.value ? (_a2 = checkboxGroup == null ? void 0 : checkboxGroup.modelValue) == null ? void 0 : _a2.value : (_b = props.modelValue) != null ? _b : selfModel.value;
      },
      set(val) {
        var _a2, _b;
        if (isGroup.value && isArray(val)) {
          isLimitExceeded.value = ((_a2 = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a2.value) !== void 0 && val.length > (checkboxGroup == null ? void 0 : checkboxGroup.max.value);
          isLimitExceeded.value === false && ((_b = checkboxGroup == null ? void 0 : checkboxGroup.changeEvent) == null ? void 0 : _b.call(checkboxGroup, val));
        } else {
          emit(UPDATE_MODEL_EVENT, val);
          selfModel.value = val;
        }
      }
    });
    return {
      model,
      isGroup,
      isLimitExceeded
    };
  };
  const useCheckboxStatus = (props, slots, { model }) => {
    const checkboxGroup = Vue.inject(checkboxGroupContextKey, void 0);
    const isFocused = Vue.ref(false);
    const isChecked = Vue.computed(() => {
      const value = model.value;
      if (isBoolean(value)) {
        return value;
      } else if (isArray(value)) {
        if (isObject(props.label)) {
          return value.map(Vue.toRaw).some((o2) => isEqual(o2, props.label));
        } else {
          return value.map(Vue.toRaw).includes(props.label);
        }
      } else if (value !== null && value !== void 0) {
        return value === props.trueLabel;
      } else {
        return !!value;
      }
    });
    const checkboxButtonSize = useSize(Vue.computed(() => {
      var _a2;
      return (_a2 = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a2.value;
    }), {
      prop: true
    });
    const checkboxSize = useSize(Vue.computed(() => {
      var _a2;
      return (_a2 = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a2.value;
    }));
    const hasOwnLabel = Vue.computed(() => {
      return !!(slots.default || props.label);
    });
    return {
      checkboxButtonSize,
      isChecked,
      isFocused,
      checkboxSize,
      hasOwnLabel
    };
  };
  const setStoreValue = (props, { model }) => {
    function addToStore() {
      if (isArray(model.value) && !model.value.includes(props.label)) {
        model.value.push(props.label);
      } else {
        model.value = props.trueLabel || true;
      }
    }
    props.checked && addToStore();
  };
  const useCheckbox = (props, slots) => {
    const { formItem: elFormItem } = useFormItem();
    const { model, isGroup, isLimitExceeded } = useCheckboxModel(props);
    const {
      isFocused,
      isChecked,
      checkboxButtonSize,
      checkboxSize,
      hasOwnLabel
    } = useCheckboxStatus(props, slots, { model });
    const { isDisabled } = useCheckboxDisabled({ model, isChecked });
    const { inputId, isLabeledByFormItem } = useFormItemInputId(props, {
      formItemContext: elFormItem,
      disableIdGeneration: hasOwnLabel,
      disableIdManagement: isGroup
    });
    const { handleChange, onClickRoot } = useCheckboxEvent(props, {
      model,
      isLimitExceeded,
      hasOwnLabel,
      isDisabled,
      isLabeledByFormItem
    });
    setStoreValue(props, { model });
    return {
      inputId,
      isLabeledByFormItem,
      isChecked,
      isDisabled,
      isFocused,
      checkboxButtonSize,
      checkboxSize,
      hasOwnLabel,
      model,
      handleChange,
      onClickRoot
    };
  };
  const _hoisted_1$8 = ["tabindex", "role", "aria-checked"];
  const _hoisted_2$7 = ["id", "aria-hidden", "name", "tabindex", "disabled", "true-value", "false-value"];
  const _hoisted_3$3 = ["id", "aria-hidden", "disabled", "value", "name", "tabindex"];
  const __default__$8 = Vue.defineComponent({
    name: "ElCheckbox"
  });
  const _sfc_main$a = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$8), {
    props: checkboxProps,
    emits: checkboxEmits,
    setup(__props) {
      const props = __props;
      const slots = Vue.useSlots();
      const {
        inputId,
        isLabeledByFormItem,
        isChecked,
        isDisabled,
        isFocused,
        checkboxSize,
        hasOwnLabel,
        model,
        handleChange,
        onClickRoot
      } = useCheckbox(props, slots);
      const ns2 = useNamespace("checkbox");
      const compKls = Vue.computed(() => {
        return [
          ns2.b(),
          ns2.m(checkboxSize.value),
          ns2.is("disabled", isDisabled.value),
          ns2.is("bordered", props.border),
          ns2.is("checked", isChecked.value)
        ];
      });
      const spanKls = Vue.computed(() => {
        return [
          ns2.e("input"),
          ns2.is("disabled", isDisabled.value),
          ns2.is("checked", isChecked.value),
          ns2.is("indeterminate", props.indeterminate),
          ns2.is("focus", isFocused.value)
        ];
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(!Vue.unref(hasOwnLabel) && Vue.unref(isLabeledByFormItem) ? "span" : "label"), {
          class: Vue.normalizeClass(Vue.unref(compKls)),
          "aria-controls": _ctx.indeterminate ? _ctx.controls : null,
          onClick: Vue.unref(onClickRoot)
        }, {
          default: Vue.withCtx(() => [
            Vue.createElementVNode("span", {
              class: Vue.normalizeClass(Vue.unref(spanKls)),
              tabindex: _ctx.indeterminate ? 0 : void 0,
              role: _ctx.indeterminate ? "checkbox" : void 0,
              "aria-checked": _ctx.indeterminate ? "mixed" : void 0
            }, [
              _ctx.trueLabel || _ctx.falseLabel ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("input", {
                key: 0,
                id: Vue.unref(inputId),
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(model) ? model.value = $event : null),
                class: Vue.normalizeClass(Vue.unref(ns2).e("original")),
                type: "checkbox",
                "aria-hidden": _ctx.indeterminate ? "true" : "false",
                name: _ctx.name,
                tabindex: _ctx.tabindex,
                disabled: Vue.unref(isDisabled),
                "true-value": _ctx.trueLabel,
                "false-value": _ctx.falseLabel,
                onChange: _cache[1] || (_cache[1] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
                onFocus: _cache[2] || (_cache[2] = ($event) => isFocused.value = true),
                onBlur: _cache[3] || (_cache[3] = ($event) => isFocused.value = false)
              }, null, 42, _hoisted_2$7)), [
                [Vue.vModelCheckbox, Vue.unref(model)]
              ]) : Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("input", {
                key: 1,
                id: Vue.unref(inputId),
                "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => Vue.isRef(model) ? model.value = $event : null),
                class: Vue.normalizeClass(Vue.unref(ns2).e("original")),
                type: "checkbox",
                "aria-hidden": _ctx.indeterminate ? "true" : "false",
                disabled: Vue.unref(isDisabled),
                value: _ctx.label,
                name: _ctx.name,
                tabindex: _ctx.tabindex,
                onChange: _cache[5] || (_cache[5] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
                onFocus: _cache[6] || (_cache[6] = ($event) => isFocused.value = true),
                onBlur: _cache[7] || (_cache[7] = ($event) => isFocused.value = false)
              }, null, 42, _hoisted_3$3)), [
                [Vue.vModelCheckbox, Vue.unref(model)]
              ]),
              Vue.createElementVNode("span", {
                class: Vue.normalizeClass(Vue.unref(ns2).e("inner"))
              }, null, 2)
            ], 10, _hoisted_1$8),
            Vue.unref(hasOwnLabel) ? (Vue.openBlock(), Vue.createElementBlock("span", {
              key: 0,
              class: Vue.normalizeClass(Vue.unref(ns2).e("label"))
            }, [
              Vue.renderSlot(_ctx.$slots, "default"),
              !_ctx.$slots.default ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
                Vue.createTextVNode(Vue.toDisplayString(_ctx.label), 1)
              ], 64)) : Vue.createCommentVNode("v-if", true)
            ], 2)) : Vue.createCommentVNode("v-if", true)
          ]),
          _: 3
        }, 8, ["class", "aria-controls", "onClick"]);
      };
    }
  }));
  var Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/checkbox/src/checkbox.vue"]]);
  const _hoisted_1$7 = ["name", "tabindex", "disabled", "true-value", "false-value"];
  const _hoisted_2$6 = ["name", "tabindex", "disabled", "value"];
  const __default__$7 = Vue.defineComponent({
    name: "ElCheckboxButton"
  });
  const _sfc_main$9 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$7), {
    props: checkboxProps,
    emits: checkboxEmits,
    setup(__props) {
      const props = __props;
      const slots = Vue.useSlots();
      const {
        isFocused,
        isChecked,
        isDisabled,
        checkboxButtonSize,
        model,
        handleChange
      } = useCheckbox(props, slots);
      const checkboxGroup = Vue.inject(checkboxGroupContextKey, void 0);
      const ns2 = useNamespace("checkbox");
      const activeStyle = Vue.computed(() => {
        var _a2, _b, _c, _d;
        const fillValue = (_b = (_a2 = checkboxGroup == null ? void 0 : checkboxGroup.fill) == null ? void 0 : _a2.value) != null ? _b : "";
        return {
          backgroundColor: fillValue,
          borderColor: fillValue,
          color: (_d = (_c = checkboxGroup == null ? void 0 : checkboxGroup.textColor) == null ? void 0 : _c.value) != null ? _d : "",
          boxShadow: fillValue ? `-1px 0 0 0 ${fillValue}` : void 0
        };
      });
      const lableKls = Vue.computed(() => {
        return [
          ns2.b("button"),
          ns2.bm("button", checkboxButtonSize.value),
          ns2.is("disabled", isDisabled.value),
          ns2.is("checked", isChecked.value),
          ns2.is("focus", isFocused.value)
        ];
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("label", {
          class: Vue.normalizeClass(Vue.unref(lableKls))
        }, [
          _ctx.trueLabel || _ctx.falseLabel ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("input", {
            key: 0,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(model) ? model.value = $event : null),
            class: Vue.normalizeClass(Vue.unref(ns2).be("button", "original")),
            type: "checkbox",
            name: _ctx.name,
            tabindex: _ctx.tabindex,
            disabled: Vue.unref(isDisabled),
            "true-value": _ctx.trueLabel,
            "false-value": _ctx.falseLabel,
            onChange: _cache[1] || (_cache[1] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
            onFocus: _cache[2] || (_cache[2] = ($event) => isFocused.value = true),
            onBlur: _cache[3] || (_cache[3] = ($event) => isFocused.value = false)
          }, null, 42, _hoisted_1$7)), [
            [Vue.vModelCheckbox, Vue.unref(model)]
          ]) : Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("input", {
            key: 1,
            "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => Vue.isRef(model) ? model.value = $event : null),
            class: Vue.normalizeClass(Vue.unref(ns2).be("button", "original")),
            type: "checkbox",
            name: _ctx.name,
            tabindex: _ctx.tabindex,
            disabled: Vue.unref(isDisabled),
            value: _ctx.label,
            onChange: _cache[5] || (_cache[5] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
            onFocus: _cache[6] || (_cache[6] = ($event) => isFocused.value = true),
            onBlur: _cache[7] || (_cache[7] = ($event) => isFocused.value = false)
          }, null, 42, _hoisted_2$6)), [
            [Vue.vModelCheckbox, Vue.unref(model)]
          ]),
          _ctx.$slots.default || _ctx.label ? (Vue.openBlock(), Vue.createElementBlock("span", {
            key: 2,
            class: Vue.normalizeClass(Vue.unref(ns2).be("button", "inner")),
            style: Vue.normalizeStyle(Vue.unref(isChecked) ? Vue.unref(activeStyle) : void 0)
          }, [
            Vue.renderSlot(_ctx.$slots, "default", {}, () => [
              Vue.createTextVNode(Vue.toDisplayString(_ctx.label), 1)
            ])
          ], 6)) : Vue.createCommentVNode("v-if", true)
        ], 2);
      };
    }
  }));
  var CheckboxButton = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/checkbox/src/checkbox-button.vue"]]);
  const checkboxGroupProps = buildProps({
    modelValue: {
      type: definePropType(Array),
      default: () => []
    },
    disabled: Boolean,
    min: Number,
    max: Number,
    size: useSizeProp,
    label: String,
    fill: String,
    textColor: String,
    tag: {
      type: String,
      default: "div"
    },
    validateEvent: {
      type: Boolean,
      default: true
    }
  });
  const checkboxGroupEmits = {
    [UPDATE_MODEL_EVENT]: (val) => isArray(val),
    change: (val) => isArray(val)
  };
  const __default__$6 = Vue.defineComponent({
    name: "ElCheckboxGroup"
  });
  const _sfc_main$8 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$6), {
    props: checkboxGroupProps,
    emits: checkboxGroupEmits,
    setup(__props, { emit }) {
      const props = __props;
      const ns2 = useNamespace("checkbox");
      const { formItem } = useFormItem();
      const { inputId: groupId, isLabeledByFormItem } = useFormItemInputId(props, {
        formItemContext: formItem
      });
      const changeEvent = async (value) => {
        emit(UPDATE_MODEL_EVENT, value);
        await Vue.nextTick();
        emit("change", value);
      };
      const modelValue = Vue.computed({
        get() {
          return props.modelValue;
        },
        set(val) {
          changeEvent(val);
        }
      });
      Vue.provide(checkboxGroupContextKey, __spreadProps(__spreadValues({}, pick$1(Vue.toRefs(props), [
        "size",
        "min",
        "max",
        "disabled",
        "validateEvent",
        "fill",
        "textColor"
      ])), {
        modelValue,
        changeEvent
      }));
      Vue.watch(() => props.modelValue, () => {
        if (props.validateEvent) {
          formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
        }
      });
      return (_ctx, _cache) => {
        var _a2;
        return Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(_ctx.tag), {
          id: Vue.unref(groupId),
          class: Vue.normalizeClass(Vue.unref(ns2).b("group")),
          role: "group",
          "aria-label": !Vue.unref(isLabeledByFormItem) ? _ctx.label || "checkbox-group" : void 0,
          "aria-labelledby": Vue.unref(isLabeledByFormItem) ? (_a2 = Vue.unref(formItem)) == null ? void 0 : _a2.labelId : void 0
        }, {
          default: Vue.withCtx(() => [
            Vue.renderSlot(_ctx.$slots, "default")
          ]),
          _: 3
        }, 8, ["id", "class", "aria-label", "aria-labelledby"]);
      };
    }
  }));
  var CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/checkbox/src/checkbox-group.vue"]]);
  const ElCheckbox = withInstall(Checkbox, {
    CheckboxButton,
    CheckboxGroup
  });
  withNoopInstall(CheckboxButton);
  withNoopInstall(CheckboxGroup);
  const inputNumberProps = buildProps({
    id: {
      type: String,
      default: void 0
    },
    step: {
      type: Number,
      default: 1
    },
    stepStrictly: Boolean,
    max: {
      type: Number,
      default: Number.POSITIVE_INFINITY
    },
    min: {
      type: Number,
      default: Number.NEGATIVE_INFINITY
    },
    modelValue: Number,
    readonly: Boolean,
    disabled: Boolean,
    size: useSizeProp,
    controls: {
      type: Boolean,
      default: true
    },
    controlsPosition: {
      type: String,
      default: "",
      values: ["", "right"]
    },
    valueOnClear: {
      type: [String, Number, null],
      validator: (val) => val === null || isNumber(val) || ["min", "max"].includes(val),
      default: null
    },
    name: String,
    label: String,
    placeholder: String,
    precision: {
      type: Number,
      validator: (val) => val >= 0 && val === Number.parseInt(`${val}`, 10)
    },
    validateEvent: {
      type: Boolean,
      default: true
    }
  });
  const inputNumberEmits = {
    [CHANGE_EVENT]: (cur, prev) => prev !== cur,
    blur: (e) => e instanceof FocusEvent,
    focus: (e) => e instanceof FocusEvent,
    [INPUT_EVENT]: (val) => isNumber(val) || isNil(val),
    [UPDATE_MODEL_EVENT]: (val) => isNumber(val) || isNil(val)
  };
  const _hoisted_1$6 = ["aria-label", "onKeydown"];
  const _hoisted_2$5 = ["aria-label", "onKeydown"];
  const __default__$5 = Vue.defineComponent({
    name: "ElInputNumber"
  });
  const _sfc_main$7 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$5), {
    props: inputNumberProps,
    emits: inputNumberEmits,
    setup(__props, { expose, emit }) {
      const props = __props;
      const { t } = useLocale();
      const ns2 = useNamespace("input-number");
      const input = Vue.ref();
      const data = Vue.reactive({
        currentValue: props.modelValue,
        userInput: null
      });
      const { formItem } = useFormItem();
      const minDisabled = Vue.computed(() => isNumber(props.modelValue) && props.modelValue <= props.min);
      const maxDisabled = Vue.computed(() => isNumber(props.modelValue) && props.modelValue >= props.max);
      const numPrecision = Vue.computed(() => {
        const stepPrecision = getPrecision(props.step);
        if (!isUndefined(props.precision)) {
          if (stepPrecision > props.precision) {
            debugWarn("InputNumber", "precision should not be less than the decimal places of step");
          }
          return props.precision;
        } else {
          return Math.max(getPrecision(props.modelValue), stepPrecision);
        }
      });
      const controlsAtRight = Vue.computed(() => {
        return props.controls && props.controlsPosition === "right";
      });
      const inputNumberSize = useSize();
      const inputNumberDisabled = useDisabled();
      const displayValue = Vue.computed(() => {
        if (data.userInput !== null) {
          return data.userInput;
        }
        let currentValue = data.currentValue;
        if (isNil(currentValue))
          return "";
        if (isNumber(currentValue)) {
          if (Number.isNaN(currentValue))
            return "";
          if (!isUndefined(props.precision)) {
            currentValue = currentValue.toFixed(props.precision);
          }
        }
        return currentValue;
      });
      const toPrecision = (num, pre) => {
        if (isUndefined(pre))
          pre = numPrecision.value;
        if (pre === 0)
          return Math.round(num);
        let snum = String(num);
        const pointPos = snum.indexOf(".");
        if (pointPos === -1)
          return num;
        const nums = snum.replace(".", "").split("");
        const datum = nums[pointPos + pre];
        if (!datum)
          return num;
        const length = snum.length;
        if (snum.charAt(length - 1) === "5") {
          snum = `${snum.slice(0, Math.max(0, length - 1))}6`;
        }
        return Number.parseFloat(Number(snum).toFixed(pre));
      };
      const getPrecision = (value) => {
        if (isNil(value))
          return 0;
        const valueString = value.toString();
        const dotPosition = valueString.indexOf(".");
        let precision = 0;
        if (dotPosition !== -1) {
          precision = valueString.length - dotPosition - 1;
        }
        return precision;
      };
      const ensurePrecision = (val, coefficient = 1) => {
        if (!isNumber(val))
          return data.currentValue;
        return toPrecision(val + props.step * coefficient);
      };
      const increase = () => {
        if (props.readonly || inputNumberDisabled.value || maxDisabled.value)
          return;
        const value = Number(displayValue.value) || 0;
        const newVal = ensurePrecision(value);
        setCurrentValue(newVal);
        emit(INPUT_EVENT, data.currentValue);
      };
      const decrease = () => {
        if (props.readonly || inputNumberDisabled.value || minDisabled.value)
          return;
        const value = Number(displayValue.value) || 0;
        const newVal = ensurePrecision(value, -1);
        setCurrentValue(newVal);
        emit(INPUT_EVENT, data.currentValue);
      };
      const verifyValue = (value, update) => {
        const { max, min, step, precision, stepStrictly, valueOnClear } = props;
        let newVal = Number(value);
        if (isNil(value) || Number.isNaN(newVal)) {
          return null;
        }
        if (value === "") {
          if (valueOnClear === null) {
            return null;
          }
          newVal = isString$1(valueOnClear) ? { min, max }[valueOnClear] : valueOnClear;
        }
        if (stepStrictly) {
          newVal = toPrecision(Math.round(newVal / step) * step, precision);
        }
        if (!isUndefined(precision)) {
          newVal = toPrecision(newVal, precision);
        }
        if (newVal > max || newVal < min) {
          newVal = newVal > max ? max : min;
          update && emit(UPDATE_MODEL_EVENT, newVal);
        }
        return newVal;
      };
      const setCurrentValue = (value, emitChange = true) => {
        var _a2;
        const oldVal = data.currentValue;
        const newVal = verifyValue(value);
        if (oldVal === newVal)
          return;
        if (!emitChange) {
          emit(UPDATE_MODEL_EVENT, newVal);
          return;
        }
        data.userInput = null;
        emit(UPDATE_MODEL_EVENT, newVal);
        emit(CHANGE_EVENT, newVal, oldVal);
        if (props.validateEvent) {
          (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "change").catch((err) => debugWarn(err));
        }
        data.currentValue = newVal;
      };
      const handleInput = (value) => {
        data.userInput = value;
        const newVal = value === "" ? null : Number(value);
        emit(INPUT_EVENT, newVal);
        setCurrentValue(newVal, false);
      };
      const handleInputChange = (value) => {
        const newVal = value !== "" ? Number(value) : "";
        if (isNumber(newVal) && !Number.isNaN(newVal) || value === "") {
          setCurrentValue(newVal);
        }
        data.userInput = null;
      };
      const focus = () => {
        var _a2, _b;
        (_b = (_a2 = input.value) == null ? void 0 : _a2.focus) == null ? void 0 : _b.call(_a2);
      };
      const blur = () => {
        var _a2, _b;
        (_b = (_a2 = input.value) == null ? void 0 : _a2.blur) == null ? void 0 : _b.call(_a2);
      };
      const handleFocus = (event) => {
        emit("focus", event);
      };
      const handleBlur = (event) => {
        var _a2;
        emit("blur", event);
        if (props.validateEvent) {
          (_a2 = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a2.call(formItem, "blur").catch((err) => debugWarn(err));
        }
      };
      Vue.watch(() => props.modelValue, (value) => {
        const userInput = verifyValue(data.userInput);
        const newValue = verifyValue(value, true);
        if (!isNumber(userInput) && (!userInput || userInput !== newValue)) {
          data.currentValue = newValue;
          data.userInput = null;
        }
      }, { immediate: true });
      Vue.onMounted(() => {
        var _a2;
        const { min, max, modelValue } = props;
        const innerInput = (_a2 = input.value) == null ? void 0 : _a2.input;
        innerInput.setAttribute("role", "spinbutton");
        if (Number.isFinite(max)) {
          innerInput.setAttribute("aria-valuemax", String(max));
        } else {
          innerInput.removeAttribute("aria-valuemax");
        }
        if (Number.isFinite(min)) {
          innerInput.setAttribute("aria-valuemin", String(min));
        } else {
          innerInput.removeAttribute("aria-valuemin");
        }
        innerInput.setAttribute("aria-valuenow", String(data.currentValue));
        innerInput.setAttribute("aria-disabled", String(inputNumberDisabled.value));
        if (!isNumber(modelValue) && modelValue != null) {
          let val = Number(modelValue);
          if (Number.isNaN(val)) {
            val = null;
          }
          emit(UPDATE_MODEL_EVENT, val);
        }
      });
      Vue.onUpdated(() => {
        var _a2;
        const innerInput = (_a2 = input.value) == null ? void 0 : _a2.input;
        innerInput == null ? void 0 : innerInput.setAttribute("aria-valuenow", `${data.currentValue}`);
      });
      expose({
        focus,
        blur
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          class: Vue.normalizeClass([
            Vue.unref(ns2).b(),
            Vue.unref(ns2).m(Vue.unref(inputNumberSize)),
            Vue.unref(ns2).is("disabled", Vue.unref(inputNumberDisabled)),
            Vue.unref(ns2).is("without-controls", !_ctx.controls),
            Vue.unref(ns2).is("controls-right", Vue.unref(controlsAtRight))
          ]),
          onDragstart: _cache[0] || (_cache[0] = Vue.withModifiers(() => {
          }, ["prevent"]))
        }, [
          _ctx.controls ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("span", {
            key: 0,
            role: "button",
            "aria-label": Vue.unref(t)("el.inputNumber.decrease"),
            class: Vue.normalizeClass([Vue.unref(ns2).e("decrease"), Vue.unref(ns2).is("disabled", Vue.unref(minDisabled))]),
            onKeydown: Vue.withKeys(decrease, ["enter"])
          }, [
            Vue.createVNode(Vue.unref(ElIcon), null, {
              default: Vue.withCtx(() => [
                Vue.unref(controlsAtRight) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(arrow_down_default), { key: 0 })) : (Vue.openBlock(), Vue.createBlock(Vue.unref(minus_default), { key: 1 }))
              ]),
              _: 1
            })
          ], 42, _hoisted_1$6)), [
            [Vue.unref(vRepeatClick), decrease]
          ]) : Vue.createCommentVNode("v-if", true),
          _ctx.controls ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("span", {
            key: 1,
            role: "button",
            "aria-label": Vue.unref(t)("el.inputNumber.increase"),
            class: Vue.normalizeClass([Vue.unref(ns2).e("increase"), Vue.unref(ns2).is("disabled", Vue.unref(maxDisabled))]),
            onKeydown: Vue.withKeys(increase, ["enter"])
          }, [
            Vue.createVNode(Vue.unref(ElIcon), null, {
              default: Vue.withCtx(() => [
                Vue.unref(controlsAtRight) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(arrow_up_default), { key: 0 })) : (Vue.openBlock(), Vue.createBlock(Vue.unref(plus_default), { key: 1 }))
              ]),
              _: 1
            })
          ], 42, _hoisted_2$5)), [
            [Vue.unref(vRepeatClick), increase]
          ]) : Vue.createCommentVNode("v-if", true),
          Vue.createVNode(Vue.unref(ElInput), {
            id: _ctx.id,
            ref_key: "input",
            ref: input,
            type: "number",
            step: _ctx.step,
            "model-value": Vue.unref(displayValue),
            placeholder: _ctx.placeholder,
            readonly: _ctx.readonly,
            disabled: Vue.unref(inputNumberDisabled),
            size: Vue.unref(inputNumberSize),
            max: _ctx.max,
            min: _ctx.min,
            name: _ctx.name,
            label: _ctx.label,
            "validate-event": false,
            onKeydown: [
              Vue.withKeys(Vue.withModifiers(increase, ["prevent"]), ["up"]),
              Vue.withKeys(Vue.withModifiers(decrease, ["prevent"]), ["down"])
            ],
            onBlur: handleBlur,
            onFocus: handleFocus,
            onInput: handleInput,
            onChange: handleInputChange
          }, null, 8, ["id", "step", "model-value", "placeholder", "readonly", "disabled", "size", "max", "min", "name", "label", "onKeydown"])
        ], 34);
      };
    }
  }));
  var InputNumber = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/input-number/src/input-number.vue"]]);
  const ElInputNumber = withInstall(InputNumber);
  const progressProps = buildProps({
    type: {
      type: String,
      default: "line",
      values: ["line", "circle", "dashboard"]
    },
    percentage: {
      type: Number,
      default: 0,
      validator: (val) => val >= 0 && val <= 100
    },
    status: {
      type: String,
      default: "",
      values: ["", "success", "exception", "warning"]
    },
    indeterminate: {
      type: Boolean,
      default: false
    },
    duration: {
      type: Number,
      default: 3
    },
    strokeWidth: {
      type: Number,
      default: 6
    },
    strokeLinecap: {
      type: definePropType(String),
      default: "round"
    },
    textInside: {
      type: Boolean,
      default: false
    },
    width: {
      type: Number,
      default: 126
    },
    showText: {
      type: Boolean,
      default: true
    },
    color: {
      type: definePropType([
        String,
        Array,
        Function
      ]),
      default: ""
    },
    format: {
      type: definePropType(Function),
      default: (percentage) => `${percentage}%`
    }
  });
  const _hoisted_1$5 = ["aria-valuenow"];
  const _hoisted_2$4 = { viewBox: "0 0 100 100" };
  const _hoisted_3$2 = ["d", "stroke", "stroke-width"];
  const _hoisted_4$1 = ["d", "stroke", "opacity", "stroke-linecap", "stroke-width"];
  const _hoisted_5$1 = { key: 0 };
  const __default__$4 = Vue.defineComponent({
    name: "ElProgress"
  });
  const _sfc_main$6 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$4), {
    props: progressProps,
    setup(__props) {
      const props = __props;
      const STATUS_COLOR_MAP = {
        success: "#13ce66",
        exception: "#ff4949",
        warning: "#e6a23c",
        default: "#20a0ff"
      };
      const ns2 = useNamespace("progress");
      const barStyle = Vue.computed(() => ({
        width: `${props.percentage}%`,
        animationDuration: `${props.duration}s`,
        backgroundColor: getCurrentColor(props.percentage)
      }));
      const relativeStrokeWidth = Vue.computed(() => (props.strokeWidth / props.width * 100).toFixed(1));
      const radius = Vue.computed(() => {
        if (["circle", "dashboard"].includes(props.type)) {
          return Number.parseInt(`${50 - Number.parseFloat(relativeStrokeWidth.value) / 2}`, 10);
        }
        return 0;
      });
      const trackPath = Vue.computed(() => {
        const r = radius.value;
        const isDashboard = props.type === "dashboard";
        return `
          M 50 50
          m 0 ${isDashboard ? "" : "-"}${r}
          a ${r} ${r} 0 1 1 0 ${isDashboard ? "-" : ""}${r * 2}
          a ${r} ${r} 0 1 1 0 ${isDashboard ? "" : "-"}${r * 2}
          `;
      });
      const perimeter = Vue.computed(() => 2 * Math.PI * radius.value);
      const rate = Vue.computed(() => props.type === "dashboard" ? 0.75 : 1);
      const strokeDashoffset = Vue.computed(() => {
        const offset = -1 * perimeter.value * (1 - rate.value) / 2;
        return `${offset}px`;
      });
      const trailPathStyle = Vue.computed(() => ({
        strokeDasharray: `${perimeter.value * rate.value}px, ${perimeter.value}px`,
        strokeDashoffset: strokeDashoffset.value
      }));
      const circlePathStyle = Vue.computed(() => ({
        strokeDasharray: `${perimeter.value * rate.value * (props.percentage / 100)}px, ${perimeter.value}px`,
        strokeDashoffset: strokeDashoffset.value,
        transition: "stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s"
      }));
      const stroke = Vue.computed(() => {
        let ret;
        if (props.color) {
          ret = getCurrentColor(props.percentage);
        } else {
          ret = STATUS_COLOR_MAP[props.status] || STATUS_COLOR_MAP.default;
        }
        return ret;
      });
      const statusIcon = Vue.computed(() => {
        if (props.status === "warning") {
          return warning_filled_default;
        }
        if (props.type === "line") {
          return props.status === "success" ? circle_check_default : circle_close_default;
        } else {
          return props.status === "success" ? check_default : close_default;
        }
      });
      const progressTextSize = Vue.computed(() => {
        return props.type === "line" ? 12 + props.strokeWidth * 0.4 : props.width * 0.111111 + 2;
      });
      const content = Vue.computed(() => props.format(props.percentage));
      function getColors(color) {
        const span = 100 / color.length;
        const seriesColors = color.map((seriesColor, index) => {
          if (isString$1(seriesColor)) {
            return {
              color: seriesColor,
              percentage: (index + 1) * span
            };
          }
          return seriesColor;
        });
        return seriesColors.sort((a2, b2) => a2.percentage - b2.percentage);
      }
      const getCurrentColor = (percentage) => {
        var _a2;
        const { color } = props;
        if (isFunction$1(color)) {
          return color(percentage);
        } else if (isString$1(color)) {
          return color;
        } else {
          const colors = getColors(color);
          for (const color2 of colors) {
            if (color2.percentage > percentage)
              return color2.color;
          }
          return (_a2 = colors[colors.length - 1]) == null ? void 0 : _a2.color;
        }
      };
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          class: Vue.normalizeClass([
            Vue.unref(ns2).b(),
            Vue.unref(ns2).m(_ctx.type),
            Vue.unref(ns2).is(_ctx.status),
            {
              [Vue.unref(ns2).m("without-text")]: !_ctx.showText,
              [Vue.unref(ns2).m("text-inside")]: _ctx.textInside
            }
          ]),
          role: "progressbar",
          "aria-valuenow": _ctx.percentage,
          "aria-valuemin": "0",
          "aria-valuemax": "100"
        }, [
          _ctx.type === "line" ? (Vue.openBlock(), Vue.createElementBlock("div", {
            key: 0,
            class: Vue.normalizeClass(Vue.unref(ns2).b("bar"))
          }, [
            Vue.createElementVNode("div", {
              class: Vue.normalizeClass(Vue.unref(ns2).be("bar", "outer")),
              style: Vue.normalizeStyle({ height: `${_ctx.strokeWidth}px` })
            }, [
              Vue.createElementVNode("div", {
                class: Vue.normalizeClass([
                  Vue.unref(ns2).be("bar", "inner"),
                  { [Vue.unref(ns2).bem("bar", "inner", "indeterminate")]: _ctx.indeterminate }
                ]),
                style: Vue.normalizeStyle(Vue.unref(barStyle))
              }, [
                (_ctx.showText || _ctx.$slots.default) && _ctx.textInside ? (Vue.openBlock(), Vue.createElementBlock("div", {
                  key: 0,
                  class: Vue.normalizeClass(Vue.unref(ns2).be("bar", "innerText"))
                }, [
                  Vue.renderSlot(_ctx.$slots, "default", { percentage: _ctx.percentage }, () => [
                    Vue.createElementVNode("span", null, Vue.toDisplayString(Vue.unref(content)), 1)
                  ])
                ], 2)) : Vue.createCommentVNode("v-if", true)
              ], 6)
            ], 6)
          ], 2)) : (Vue.openBlock(), Vue.createElementBlock("div", {
            key: 1,
            class: Vue.normalizeClass(Vue.unref(ns2).b("circle")),
            style: Vue.normalizeStyle({ height: `${_ctx.width}px`, width: `${_ctx.width}px` })
          }, [
            (Vue.openBlock(), Vue.createElementBlock("svg", _hoisted_2$4, [
              Vue.createElementVNode("path", {
                class: Vue.normalizeClass(Vue.unref(ns2).be("circle", "track")),
                d: Vue.unref(trackPath),
                stroke: `var(${Vue.unref(ns2).cssVarName("fill-color-light")}, #e5e9f2)`,
                "stroke-width": Vue.unref(relativeStrokeWidth),
                fill: "none",
                style: Vue.normalizeStyle(Vue.unref(trailPathStyle))
              }, null, 14, _hoisted_3$2),
              Vue.createElementVNode("path", {
                class: Vue.normalizeClass(Vue.unref(ns2).be("circle", "path")),
                d: Vue.unref(trackPath),
                stroke: Vue.unref(stroke),
                fill: "none",
                opacity: _ctx.percentage ? 1 : 0,
                "stroke-linecap": _ctx.strokeLinecap,
                "stroke-width": Vue.unref(relativeStrokeWidth),
                style: Vue.normalizeStyle(Vue.unref(circlePathStyle))
              }, null, 14, _hoisted_4$1)
            ]))
          ], 6)),
          (_ctx.showText || _ctx.$slots.default) && !_ctx.textInside ? (Vue.openBlock(), Vue.createElementBlock("div", {
            key: 2,
            class: Vue.normalizeClass(Vue.unref(ns2).e("text")),
            style: Vue.normalizeStyle({ fontSize: `${Vue.unref(progressTextSize)}px` })
          }, [
            Vue.renderSlot(_ctx.$slots, "default", { percentage: _ctx.percentage }, () => [
              !_ctx.status ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_5$1, Vue.toDisplayString(Vue.unref(content)), 1)) : (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), { key: 1 }, {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(statusIcon))))
                ]),
                _: 1
              }))
            ])
          ], 6)) : Vue.createCommentVNode("v-if", true)
        ], 10, _hoisted_1$5);
      };
    }
  }));
  var Progress = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/progress/src/progress.vue"]]);
  const ElProgress = withInstall(Progress);
  /*!
   * escape-html
   * Copyright(c) 2012-2013 TJ Holowaychuk
   * Copyright(c) 2015 Andreas Lubbe
   * Copyright(c) 2015 Tiancheng "Timothy" Gu
   * MIT Licensed
   */
  var matchHtmlRegExp = /["'&<>]/;
  var escapeHtml_1 = escapeHtml;
  function escapeHtml(string) {
    var str = "" + string;
    var match = matchHtmlRegExp.exec(str);
    if (!match) {
      return str;
    }
    var escape;
    var html = "";
    var index = 0;
    var lastIndex = 0;
    for (index = match.index; index < str.length; index++) {
      switch (str.charCodeAt(index)) {
        case 34:
          escape = "&quot;";
          break;
        case 38:
          escape = "&amp;";
          break;
        case 39:
          escape = "&#39;";
          break;
        case 60:
          escape = "&lt;";
          break;
        case 62:
          escape = "&gt;";
          break;
        default:
          continue;
      }
      if (lastIndex !== index) {
        html += str.substring(lastIndex, index);
      }
      lastIndex = index + 1;
      html += escape;
    }
    return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
  }
  const getCell = function(event) {
    var _a2;
    return (_a2 = event.target) == null ? void 0 : _a2.closest("td");
  };
  const orderBy = function(array, sortKey, reverse, sortMethod, sortBy) {
    if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) {
      return array;
    }
    if (typeof reverse === "string") {
      reverse = reverse === "descending" ? -1 : 1;
    } else {
      reverse = reverse && reverse < 0 ? -1 : 1;
    }
    const getKey = sortMethod ? null : function(value, index) {
      if (sortBy) {
        if (!Array.isArray(sortBy)) {
          sortBy = [sortBy];
        }
        return sortBy.map((by) => {
          if (typeof by === "string") {
            return get$2(value, by);
          } else {
            return by(value, index, array);
          }
        });
      }
      if (sortKey !== "$key") {
        if (isObject(value) && "$value" in value)
          value = value.$value;
      }
      return [isObject(value) ? get$2(value, sortKey) : value];
    };
    const compare = function(a2, b2) {
      if (sortMethod) {
        return sortMethod(a2.value, b2.value);
      }
      for (let i = 0, len = a2.key.length; i < len; i++) {
        if (a2.key[i] < b2.key[i]) {
          return -1;
        }
        if (a2.key[i] > b2.key[i]) {
          return 1;
        }
      }
      return 0;
    };
    return array.map((value, index) => {
      return {
        value,
        index,
        key: getKey ? getKey(value, index) : null
      };
    }).sort((a2, b2) => {
      let order = compare(a2, b2);
      if (!order) {
        order = a2.index - b2.index;
      }
      return order * +reverse;
    }).map((item) => item.value);
  };
  const getColumnById = function(table, columnId) {
    let column = null;
    table.columns.forEach((item) => {
      if (item.id === columnId) {
        column = item;
      }
    });
    return column;
  };
  const getColumnByKey = function(table, columnKey) {
    let column = null;
    for (let i = 0; i < table.columns.length; i++) {
      const item = table.columns[i];
      if (item.columnKey === columnKey) {
        column = item;
        break;
      }
    }
    if (!column)
      throwError("ElTable", `No column matching with column-key: ${columnKey}`);
    return column;
  };
  const getColumnByCell = function(table, cell, namespace) {
    const matches = (cell.className || "").match(new RegExp(`${namespace}-table_[^\\s]+`, "gm"));
    if (matches) {
      return getColumnById(table, matches[0]);
    }
    return null;
  };
  const getRowIdentity = (row, rowKey) => {
    if (!row)
      throw new Error("Row is required when get row identity");
    if (typeof rowKey === "string") {
      if (!rowKey.includes(".")) {
        return `${row[rowKey]}`;
      }
      const key = rowKey.split(".");
      let current = row;
      for (const element of key) {
        current = current[element];
      }
      return `${current}`;
    } else if (typeof rowKey === "function") {
      return rowKey.call(null, row);
    }
  };
  const getKeysMap = function(array, rowKey) {
    const arrayMap2 = {};
    (array || []).forEach((row, index) => {
      arrayMap2[getRowIdentity(row, rowKey)] = { row, index };
    });
    return arrayMap2;
  };
  function mergeOptions(defaults, config) {
    const options = {};
    let key;
    for (key in defaults) {
      options[key] = defaults[key];
    }
    for (key in config) {
      if (hasOwn(config, key)) {
        const value = config[key];
        if (typeof value !== "undefined") {
          options[key] = value;
        }
      }
    }
    return options;
  }
  function parseWidth(width) {
    if (width === "")
      return width;
    if (width !== void 0) {
      width = Number.parseInt(width, 10);
      if (Number.isNaN(width)) {
        width = "";
      }
    }
    return width;
  }
  function parseMinWidth(minWidth) {
    if (minWidth === "")
      return minWidth;
    if (minWidth !== void 0) {
      minWidth = parseWidth(minWidth);
      if (Number.isNaN(minWidth)) {
        minWidth = 80;
      }
    }
    return minWidth;
  }
  function parseHeight(height) {
    if (typeof height === "number") {
      return height;
    }
    if (typeof height === "string") {
      if (/^\d+(?:px)?$/.test(height)) {
        return Number.parseInt(height, 10);
      } else {
        return height;
      }
    }
    return null;
  }
  function compose(...funcs) {
    if (funcs.length === 0) {
      return (arg) => arg;
    }
    if (funcs.length === 1) {
      return funcs[0];
    }
    return funcs.reduce((a2, b2) => (...args) => a2(b2(...args)));
  }
  function toggleRowStatus(statusArr, row, newVal) {
    let changed = false;
    const index = statusArr.indexOf(row);
    const included = index !== -1;
    const toggleStatus = (type) => {
      if (type === "add") {
        statusArr.push(row);
      } else {
        statusArr.splice(index, 1);
      }
      changed = true;
      if (isArray(row.children)) {
        row.children.forEach((item) => {
          toggleRowStatus(statusArr, item, newVal != null ? newVal : !included);
        });
      }
    };
    if (isBoolean(newVal)) {
      if (newVal && !included) {
        toggleStatus("add");
      } else if (!newVal && included) {
        toggleStatus("remove");
      }
    } else {
      included ? toggleStatus("remove") : toggleStatus("add");
    }
    return changed;
  }
  function walkTreeNode(root2, cb, childrenKey = "children", lazyKey = "hasChildren") {
    const isNil2 = (array) => !(Array.isArray(array) && array.length);
    function _walker(parent, children, level) {
      cb(parent, children, level);
      children.forEach((item) => {
        if (item[lazyKey]) {
          cb(item, null, level + 1);
          return;
        }
        const children2 = item[childrenKey];
        if (!isNil2(children2)) {
          _walker(item, children2, level + 1);
        }
      });
    }
    root2.forEach((item) => {
      if (item[lazyKey]) {
        cb(item, null, 0);
        return;
      }
      const children = item[childrenKey];
      if (!isNil2(children)) {
        _walker(item, children, 0);
      }
    });
  }
  let removePopper;
  function createTablePopper(parentNode, trigger2, popperContent, tooltipOptions) {
    tooltipOptions = merge$1({
      enterable: true,
      showArrow: true
    }, tooltipOptions);
    const { nextZIndex } = useZIndex();
    const ns2 = parentNode == null ? void 0 : parentNode.dataset.prefix;
    const scrollContainer = parentNode == null ? void 0 : parentNode.querySelector(`.${ns2}-scrollbar__wrap`);
    function renderContent() {
      const isLight = tooltipOptions.effect === "light";
      const content2 = document.createElement("div");
      content2.className = [
        `${ns2}-popper`,
        isLight ? "is-light" : "is-dark",
        tooltipOptions.popperClass || ""
      ].join(" ");
      popperContent = escapeHtml_1(popperContent);
      content2.innerHTML = popperContent;
      content2.style.zIndex = String(nextZIndex());
      parentNode == null ? void 0 : parentNode.appendChild(content2);
      return content2;
    }
    function renderArrow() {
      const arrow = document.createElement("div");
      arrow.className = `${ns2}-popper__arrow`;
      return arrow;
    }
    function showPopper() {
      popperInstance && popperInstance.update();
    }
    removePopper == null ? void 0 : removePopper();
    removePopper = () => {
      try {
        popperInstance && popperInstance.destroy();
        content && (parentNode == null ? void 0 : parentNode.removeChild(content));
        trigger2.removeEventListener("mouseenter", onOpen);
        trigger2.removeEventListener("mouseleave", onClose);
        scrollContainer == null ? void 0 : scrollContainer.removeEventListener("scroll", removePopper);
        removePopper = void 0;
      } catch (e) {
      }
    };
    let popperInstance = null;
    let onOpen = showPopper;
    let onClose = removePopper;
    if (tooltipOptions.enterable) {
      ({ onOpen, onClose } = useDelayedToggle({
        showAfter: tooltipOptions.showAfter,
        hideAfter: tooltipOptions.hideAfter,
        open: showPopper,
        close: removePopper
      }));
    }
    const content = renderContent();
    content.onmouseenter = onOpen;
    content.onmouseleave = onClose;
    const modifiers = [];
    if (tooltipOptions.offset) {
      modifiers.push({
        name: "offset",
        options: {
          offset: [0, tooltipOptions.offset]
        }
      });
    }
    if (tooltipOptions.showArrow) {
      const arrow = content.appendChild(renderArrow());
      modifiers.push({
        name: "arrow",
        options: {
          element: arrow,
          padding: 10
        }
      });
    }
    const popperOptions = tooltipOptions.popperOptions || {};
    popperInstance = yn(trigger2, content, __spreadProps(__spreadValues({
      placement: tooltipOptions.placement || "top",
      strategy: "fixed"
    }, popperOptions), {
      modifiers: popperOptions.modifiers ? modifiers.concat(popperOptions.modifiers) : modifiers
    }));
    trigger2.addEventListener("mouseenter", onOpen);
    trigger2.addEventListener("mouseleave", onClose);
    scrollContainer == null ? void 0 : scrollContainer.addEventListener("scroll", removePopper);
    return popperInstance;
  }
  function getCurrentColumns(column) {
    if (column.children) {
      return flatMap(column.children, getCurrentColumns);
    } else {
      return [column];
    }
  }
  function getColSpan(colSpan, column) {
    return colSpan + column.colSpan;
  }
  const isFixedColumn = (index, fixed, store, realColumns) => {
    let start = 0;
    let after = index;
    const columns = store.states.columns.value;
    if (realColumns) {
      const curColumns = getCurrentColumns(realColumns[index]);
      const preColumns = columns.slice(0, columns.indexOf(curColumns[0]));
      start = preColumns.reduce(getColSpan, 0);
      after = start + curColumns.reduce(getColSpan, 0) - 1;
    } else {
      start = index;
    }
    let fixedLayout;
    switch (fixed) {
      case "left":
        if (after < store.states.fixedLeafColumnsLength.value) {
          fixedLayout = "left";
        }
        break;
      case "right":
        if (start >= columns.length - store.states.rightFixedLeafColumnsLength.value) {
          fixedLayout = "right";
        }
        break;
      default:
        if (after < store.states.fixedLeafColumnsLength.value) {
          fixedLayout = "left";
        } else if (start >= columns.length - store.states.rightFixedLeafColumnsLength.value) {
          fixedLayout = "right";
        }
    }
    return fixedLayout ? {
      direction: fixedLayout,
      start,
      after
    } : {};
  };
  const getFixedColumnsClass = (namespace, index, fixed, store, realColumns, offset = 0) => {
    const classes = [];
    const { direction, start, after } = isFixedColumn(index, fixed, store, realColumns);
    if (direction) {
      const isLeft = direction === "left";
      classes.push(`${namespace}-fixed-column--${direction}`);
      if (isLeft && after + offset === store.states.fixedLeafColumnsLength.value - 1) {
        classes.push("is-last-column");
      } else if (!isLeft && start - offset === store.states.columns.value.length - store.states.rightFixedLeafColumnsLength.value) {
        classes.push("is-first-column");
      }
    }
    return classes;
  };
  function getOffset(offset, column) {
    return offset + (column.realWidth === null || Number.isNaN(column.realWidth) ? Number(column.width) : column.realWidth);
  }
  const getFixedColumnOffset = (index, fixed, store, realColumns) => {
    const {
      direction,
      start = 0,
      after = 0
    } = isFixedColumn(index, fixed, store, realColumns);
    if (!direction) {
      return;
    }
    const styles = {};
    const isLeft = direction === "left";
    const columns = store.states.columns.value;
    if (isLeft) {
      styles.left = columns.slice(0, start).reduce(getOffset, 0);
    } else {
      styles.right = columns.slice(after + 1).reverse().reduce(getOffset, 0);
    }
    return styles;
  };
  const ensurePosition = (style2, key) => {
    if (!style2)
      return;
    if (!Number.isNaN(style2[key])) {
      style2[key] = `${style2[key]}px`;
    }
  };
  function useExpand(watcherData) {
    const instance = Vue.getCurrentInstance();
    const defaultExpandAll = Vue.ref(false);
    const expandRows = Vue.ref([]);
    const updateExpandRows = () => {
      const data = watcherData.data.value || [];
      const rowKey = watcherData.rowKey.value;
      if (defaultExpandAll.value) {
        expandRows.value = data.slice();
      } else if (rowKey) {
        const expandRowsMap = getKeysMap(expandRows.value, rowKey);
        expandRows.value = data.reduce((prev, row) => {
          const rowId = getRowIdentity(row, rowKey);
          const rowInfo = expandRowsMap[rowId];
          if (rowInfo) {
            prev.push(row);
          }
          return prev;
        }, []);
      } else {
        expandRows.value = [];
      }
    };
    const toggleRowExpansion = (row, expanded) => {
      const changed = toggleRowStatus(expandRows.value, row, expanded);
      if (changed) {
        instance.emit("expand-change", row, expandRows.value.slice());
      }
    };
    const setExpandRowKeys = (rowKeys) => {
      instance.store.assertRowKey();
      const data = watcherData.data.value || [];
      const rowKey = watcherData.rowKey.value;
      const keysMap = getKeysMap(data, rowKey);
      expandRows.value = rowKeys.reduce((prev, cur) => {
        const info = keysMap[cur];
        if (info) {
          prev.push(info.row);
        }
        return prev;
      }, []);
    };
    const isRowExpanded = (row) => {
      const rowKey = watcherData.rowKey.value;
      if (rowKey) {
        const expandMap = getKeysMap(expandRows.value, rowKey);
        return !!expandMap[getRowIdentity(row, rowKey)];
      }
      return expandRows.value.includes(row);
    };
    return {
      updateExpandRows,
      toggleRowExpansion,
      setExpandRowKeys,
      isRowExpanded,
      states: {
        expandRows,
        defaultExpandAll
      }
    };
  }
  function useCurrent(watcherData) {
    const instance = Vue.getCurrentInstance();
    const _currentRowKey = Vue.ref(null);
    const currentRow = Vue.ref(null);
    const setCurrentRowKey = (key) => {
      instance.store.assertRowKey();
      _currentRowKey.value = key;
      setCurrentRowByKey(key);
    };
    const restoreCurrentRowKey = () => {
      _currentRowKey.value = null;
    };
    const setCurrentRowByKey = (key) => {
      const { data, rowKey } = watcherData;
      let _currentRow = null;
      if (rowKey.value) {
        _currentRow = (Vue.unref(data) || []).find((item) => getRowIdentity(item, rowKey.value) === key);
      }
      currentRow.value = _currentRow;
      instance.emit("current-change", currentRow.value, null);
    };
    const updateCurrentRow = (_currentRow) => {
      const oldCurrentRow = currentRow.value;
      if (_currentRow && _currentRow !== oldCurrentRow) {
        currentRow.value = _currentRow;
        instance.emit("current-change", currentRow.value, oldCurrentRow);
        return;
      }
      if (!_currentRow && oldCurrentRow) {
        currentRow.value = null;
        instance.emit("current-change", null, oldCurrentRow);
      }
    };
    const updateCurrentRowData = () => {
      const rowKey = watcherData.rowKey.value;
      const data = watcherData.data.value || [];
      const oldCurrentRow = currentRow.value;
      if (!data.includes(oldCurrentRow) && oldCurrentRow) {
        if (rowKey) {
          const currentRowKey = getRowIdentity(oldCurrentRow, rowKey);
          setCurrentRowByKey(currentRowKey);
        } else {
          currentRow.value = null;
        }
        if (currentRow.value === null) {
          instance.emit("current-change", null, oldCurrentRow);
        }
      } else if (_currentRowKey.value) {
        setCurrentRowByKey(_currentRowKey.value);
        restoreCurrentRowKey();
      }
    };
    return {
      setCurrentRowKey,
      restoreCurrentRowKey,
      setCurrentRowByKey,
      updateCurrentRow,
      updateCurrentRowData,
      states: {
        _currentRowKey,
        currentRow
      }
    };
  }
  function useTree(watcherData) {
    const expandRowKeys = Vue.ref([]);
    const treeData = Vue.ref({});
    const indent = Vue.ref(16);
    const lazy = Vue.ref(false);
    const lazyTreeNodeMap = Vue.ref({});
    const lazyColumnIdentifier = Vue.ref("hasChildren");
    const childrenColumnName = Vue.ref("children");
    const instance = Vue.getCurrentInstance();
    const normalizedData = Vue.computed(() => {
      if (!watcherData.rowKey.value)
        return {};
      const data = watcherData.data.value || [];
      return normalize(data);
    });
    const normalizedLazyNode = Vue.computed(() => {
      const rowKey = watcherData.rowKey.value;
      const keys2 = Object.keys(lazyTreeNodeMap.value);
      const res = {};
      if (!keys2.length)
        return res;
      keys2.forEach((key) => {
        if (lazyTreeNodeMap.value[key].length) {
          const item = { children: [] };
          lazyTreeNodeMap.value[key].forEach((row) => {
            const currentRowKey = getRowIdentity(row, rowKey);
            item.children.push(currentRowKey);
            if (row[lazyColumnIdentifier.value] && !res[currentRowKey]) {
              res[currentRowKey] = { children: [] };
            }
          });
          res[key] = item;
        }
      });
      return res;
    });
    const normalize = (data) => {
      const rowKey = watcherData.rowKey.value;
      const res = {};
      walkTreeNode(data, (parent, children, level) => {
        const parentId = getRowIdentity(parent, rowKey);
        if (Array.isArray(children)) {
          res[parentId] = {
            children: children.map((row) => getRowIdentity(row, rowKey)),
            level
          };
        } else if (lazy.value) {
          res[parentId] = {
            children: [],
            lazy: true,
            level
          };
        }
      }, childrenColumnName.value, lazyColumnIdentifier.value);
      return res;
    };
    const updateTreeData = (ifChangeExpandRowKeys = false, ifExpandAll = ((_a2) => (_a2 = instance.store) == null ? void 0 : _a2.states.defaultExpandAll.value)()) => {
      var _a2;
      const nested = normalizedData.value;
      const normalizedLazyNode_ = normalizedLazyNode.value;
      const keys2 = Object.keys(nested);
      const newTreeData = {};
      if (keys2.length) {
        const oldTreeData = Vue.unref(treeData);
        const rootLazyRowKeys = [];
        const getExpanded = (oldValue, key) => {
          if (ifChangeExpandRowKeys) {
            if (expandRowKeys.value) {
              return ifExpandAll || expandRowKeys.value.includes(key);
            } else {
              return !!(ifExpandAll || (oldValue == null ? void 0 : oldValue.expanded));
            }
          } else {
            const included = ifExpandAll || expandRowKeys.value && expandRowKeys.value.includes(key);
            return !!((oldValue == null ? void 0 : oldValue.expanded) || included);
          }
        };
        keys2.forEach((key) => {
          const oldValue = oldTreeData[key];
          const newValue = __spreadValues({}, nested[key]);
          newValue.expanded = getExpanded(oldValue, key);
          if (newValue.lazy) {
            const { loaded = false, loading = false } = oldValue || {};
            newValue.loaded = !!loaded;
            newValue.loading = !!loading;
            rootLazyRowKeys.push(key);
          }
          newTreeData[key] = newValue;
        });
        const lazyKeys = Object.keys(normalizedLazyNode_);
        if (lazy.value && lazyKeys.length && rootLazyRowKeys.length) {
          lazyKeys.forEach((key) => {
            const oldValue = oldTreeData[key];
            const lazyNodeChildren = normalizedLazyNode_[key].children;
            if (rootLazyRowKeys.includes(key)) {
              if (newTreeData[key].children.length !== 0) {
                throw new Error("[ElTable]children must be an empty array.");
              }
              newTreeData[key].children = lazyNodeChildren;
            } else {
              const { loaded = false, loading = false } = oldValue || {};
              newTreeData[key] = {
                lazy: true,
                loaded: !!loaded,
                loading: !!loading,
                expanded: getExpanded(oldValue, key),
                children: lazyNodeChildren,
                level: ""
              };
            }
          });
        }
      }
      treeData.value = newTreeData;
      (_a2 = instance.store) == null ? void 0 : _a2.updateTableScrollY();
    };
    Vue.watch(() => expandRowKeys.value, () => {
      updateTreeData(true);
    });
    Vue.watch(() => normalizedData.value, () => {
      updateTreeData();
    });
    Vue.watch(() => normalizedLazyNode.value, () => {
      updateTreeData();
    });
    const updateTreeExpandKeys = (value) => {
      expandRowKeys.value = value;
      updateTreeData();
    };
    const toggleTreeExpansion = (row, expanded) => {
      instance.store.assertRowKey();
      const rowKey = watcherData.rowKey.value;
      const id = getRowIdentity(row, rowKey);
      const data = id && treeData.value[id];
      if (id && data && "expanded" in data) {
        const oldExpanded = data.expanded;
        expanded = typeof expanded === "undefined" ? !data.expanded : expanded;
        treeData.value[id].expanded = expanded;
        if (oldExpanded !== expanded) {
          instance.emit("expand-change", row, expanded);
        }
        instance.store.updateTableScrollY();
      }
    };
    const loadOrToggle = (row) => {
      instance.store.assertRowKey();
      const rowKey = watcherData.rowKey.value;
      const id = getRowIdentity(row, rowKey);
      const data = treeData.value[id];
      if (lazy.value && data && "loaded" in data && !data.loaded) {
        loadData(row, id, data);
      } else {
        toggleTreeExpansion(row, void 0);
      }
    };
    const loadData = (row, key, treeNode) => {
      const { load } = instance.props;
      if (load && !treeData.value[key].loaded) {
        treeData.value[key].loading = true;
        load(row, treeNode, (data) => {
          if (!Array.isArray(data)) {
            throw new TypeError("[ElTable] data must be an array");
          }
          treeData.value[key].loading = false;
          treeData.value[key].loaded = true;
          treeData.value[key].expanded = true;
          if (data.length) {
            lazyTreeNodeMap.value[key] = data;
          }
          instance.emit("expand-change", row, true);
        });
      }
    };
    return {
      loadData,
      loadOrToggle,
      toggleTreeExpansion,
      updateTreeExpandKeys,
      updateTreeData,
      normalize,
      states: {
        expandRowKeys,
        treeData,
        indent,
        lazy,
        lazyTreeNodeMap,
        lazyColumnIdentifier,
        childrenColumnName
      }
    };
  }
  const sortData = (data, states) => {
    const sortingColumn = states.sortingColumn;
    if (!sortingColumn || typeof sortingColumn.sortable === "string") {
      return data;
    }
    return orderBy(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);
  };
  const doFlattenColumns = (columns) => {
    const result = [];
    columns.forEach((column) => {
      if (column.children) {
        result.push.apply(result, doFlattenColumns(column.children));
      } else {
        result.push(column);
      }
    });
    return result;
  };
  function useWatcher$1() {
    var _a2;
    const instance = Vue.getCurrentInstance();
    const { size: tableSize } = Vue.toRefs((_a2 = instance.proxy) == null ? void 0 : _a2.$props);
    const rowKey = Vue.ref(null);
    const data = Vue.ref([]);
    const _data = Vue.ref([]);
    const isComplex = Vue.ref(false);
    const _columns = Vue.ref([]);
    const originColumns = Vue.ref([]);
    const columns = Vue.ref([]);
    const fixedColumns = Vue.ref([]);
    const rightFixedColumns = Vue.ref([]);
    const leafColumns = Vue.ref([]);
    const fixedLeafColumns = Vue.ref([]);
    const rightFixedLeafColumns = Vue.ref([]);
    const leafColumnsLength = Vue.ref(0);
    const fixedLeafColumnsLength = Vue.ref(0);
    const rightFixedLeafColumnsLength = Vue.ref(0);
    const isAllSelected = Vue.ref(false);
    const selection = Vue.ref([]);
    const reserveSelection = Vue.ref(false);
    const selectOnIndeterminate = Vue.ref(false);
    const selectable = Vue.ref(null);
    const filters = Vue.ref({});
    const filteredData = Vue.ref(null);
    const sortingColumn = Vue.ref(null);
    const sortProp = Vue.ref(null);
    const sortOrder = Vue.ref(null);
    const hoverRow = Vue.ref(null);
    Vue.watch(data, () => instance.state && scheduleLayout(false), {
      deep: true
    });
    const assertRowKey = () => {
      if (!rowKey.value)
        throw new Error("[ElTable] prop row-key is required");
    };
    const updateChildFixed = (column) => {
      var _a22;
      (_a22 = column.children) == null ? void 0 : _a22.forEach((childColumn) => {
        childColumn.fixed = column.fixed;
        updateChildFixed(childColumn);
      });
    };
    const updateColumns = () => {
      _columns.value.forEach((column) => {
        updateChildFixed(column);
      });
      fixedColumns.value = _columns.value.filter((column) => column.fixed === true || column.fixed === "left");
      rightFixedColumns.value = _columns.value.filter((column) => column.fixed === "right");
      if (fixedColumns.value.length > 0 && _columns.value[0] && _columns.value[0].type === "selection" && !_columns.value[0].fixed) {
        _columns.value[0].fixed = true;
        fixedColumns.value.unshift(_columns.value[0]);
      }
      const notFixedColumns = _columns.value.filter((column) => !column.fixed);
      originColumns.value = [].concat(fixedColumns.value).concat(notFixedColumns).concat(rightFixedColumns.value);
      const leafColumns2 = doFlattenColumns(notFixedColumns);
      const fixedLeafColumns2 = doFlattenColumns(fixedColumns.value);
      const rightFixedLeafColumns2 = doFlattenColumns(rightFixedColumns.value);
      leafColumnsLength.value = leafColumns2.length;
      fixedLeafColumnsLength.value = fixedLeafColumns2.length;
      rightFixedLeafColumnsLength.value = rightFixedLeafColumns2.length;
      columns.value = [].concat(fixedLeafColumns2).concat(leafColumns2).concat(rightFixedLeafColumns2);
      isComplex.value = fixedColumns.value.length > 0 || rightFixedColumns.value.length > 0;
    };
    const scheduleLayout = (needUpdateColumns, immediate = false) => {
      if (needUpdateColumns) {
        updateColumns();
      }
      if (immediate) {
        instance.state.doLayout();
      } else {
        instance.state.debouncedUpdateLayout();
      }
    };
    const isSelected = (row) => {
      return selection.value.includes(row);
    };
    const clearSelection = () => {
      isAllSelected.value = false;
      const oldSelection = selection.value;
      if (oldSelection.length) {
        selection.value = [];
        instance.emit("selection-change", []);
      }
    };
    const cleanSelection = () => {
      let deleted;
      if (rowKey.value) {
        deleted = [];
        const selectedMap = getKeysMap(selection.value, rowKey.value);
        const dataMap = getKeysMap(data.value, rowKey.value);
        for (const key in selectedMap) {
          if (hasOwn(selectedMap, key) && !dataMap[key]) {
            deleted.push(selectedMap[key].row);
          }
        }
      } else {
        deleted = selection.value.filter((item) => !data.value.includes(item));
      }
      if (deleted.length) {
        const newSelection = selection.value.filter((item) => !deleted.includes(item));
        selection.value = newSelection;
        instance.emit("selection-change", newSelection.slice());
      }
    };
    const getSelectionRows = () => {
      return (selection.value || []).slice();
    };
    const toggleRowSelection = (row, selected = void 0, emitChange = true) => {
      const changed = toggleRowStatus(selection.value, row, selected);
      if (changed) {
        const newSelection = (selection.value || []).slice();
        if (emitChange) {
          instance.emit("select", newSelection, row);
        }
        instance.emit("selection-change", newSelection);
      }
    };
    const _toggleAllSelection = () => {
      var _a22, _b;
      const value = selectOnIndeterminate.value ? !isAllSelected.value : !(isAllSelected.value || selection.value.length);
      isAllSelected.value = value;
      let selectionChanged = false;
      let childrenCount = 0;
      const rowKey2 = (_b = (_a22 = instance == null ? void 0 : instance.store) == null ? void 0 : _a22.states) == null ? void 0 : _b.rowKey.value;
      data.value.forEach((row, index) => {
        const rowIndex = index + childrenCount;
        if (selectable.value) {
          if (selectable.value.call(null, row, rowIndex) && toggleRowStatus(selection.value, row, value)) {
            selectionChanged = true;
          }
        } else {
          if (toggleRowStatus(selection.value, row, value)) {
            selectionChanged = true;
          }
        }
        childrenCount += getChildrenCount(getRowIdentity(row, rowKey2));
      });
      if (selectionChanged) {
        instance.emit("selection-change", selection.value ? selection.value.slice() : []);
      }
      instance.emit("select-all", selection.value);
    };
    const updateSelectionByRowKey = () => {
      const selectedMap = getKeysMap(selection.value, rowKey.value);
      data.value.forEach((row) => {
        const rowId = getRowIdentity(row, rowKey.value);
        const rowInfo = selectedMap[rowId];
        if (rowInfo) {
          selection.value[rowInfo.index] = row;
        }
      });
    };
    const updateAllSelected = () => {
      var _a22, _b, _c;
      if (((_a22 = data.value) == null ? void 0 : _a22.length) === 0) {
        isAllSelected.value = false;
        return;
      }
      let selectedMap;
      if (rowKey.value) {
        selectedMap = getKeysMap(selection.value, rowKey.value);
      }
      const isSelected2 = function(row) {
        if (selectedMap) {
          return !!selectedMap[getRowIdentity(row, rowKey.value)];
        } else {
          return selection.value.includes(row);
        }
      };
      let isAllSelected_ = true;
      let selectedCount = 0;
      let childrenCount = 0;
      for (let i = 0, j = (data.value || []).length; i < j; i++) {
        const keyProp = (_c = (_b = instance == null ? void 0 : instance.store) == null ? void 0 : _b.states) == null ? void 0 : _c.rowKey.value;
        const rowIndex = i + childrenCount;
        const item = data.value[i];
        const isRowSelectable = selectable.value && selectable.value.call(null, item, rowIndex);
        if (!isSelected2(item)) {
          if (!selectable.value || isRowSelectable) {
            isAllSelected_ = false;
            break;
          }
        } else {
          selectedCount++;
        }
        childrenCount += getChildrenCount(getRowIdentity(item, keyProp));
      }
      if (selectedCount === 0)
        isAllSelected_ = false;
      isAllSelected.value = isAllSelected_;
    };
    const getChildrenCount = (rowKey2) => {
      var _a22;
      if (!instance || !instance.store)
        return 0;
      const { treeData } = instance.store.states;
      let count = 0;
      const children = (_a22 = treeData.value[rowKey2]) == null ? void 0 : _a22.children;
      if (children) {
        count += children.length;
        children.forEach((childKey) => {
          count += getChildrenCount(childKey);
        });
      }
      return count;
    };
    const updateFilters = (columns2, values) => {
      if (!Array.isArray(columns2)) {
        columns2 = [columns2];
      }
      const filters_ = {};
      columns2.forEach((col) => {
        filters.value[col.id] = values;
        filters_[col.columnKey || col.id] = values;
      });
      return filters_;
    };
    const updateSort = (column, prop, order) => {
      if (sortingColumn.value && sortingColumn.value !== column) {
        sortingColumn.value.order = null;
      }
      sortingColumn.value = column;
      sortProp.value = prop;
      sortOrder.value = order;
    };
    const execFilter = () => {
      let sourceData = Vue.unref(_data);
      Object.keys(filters.value).forEach((columnId) => {
        const values = filters.value[columnId];
        if (!values || values.length === 0)
          return;
        const column = getColumnById({
          columns: columns.value
        }, columnId);
        if (column && column.filterMethod) {
          sourceData = sourceData.filter((row) => {
            return values.some((value) => column.filterMethod.call(null, value, row, column));
          });
        }
      });
      filteredData.value = sourceData;
    };
    const execSort = () => {
      data.value = sortData(filteredData.value, {
        sortingColumn: sortingColumn.value,
        sortProp: sortProp.value,
        sortOrder: sortOrder.value
      });
    };
    const execQuery = (ignore = void 0) => {
      if (!(ignore && ignore.filter)) {
        execFilter();
      }
      execSort();
    };
    const clearFilter = (columnKeys) => {
      const { tableHeaderRef } = instance.refs;
      if (!tableHeaderRef)
        return;
      const panels = Object.assign({}, tableHeaderRef.filterPanels);
      const keys2 = Object.keys(panels);
      if (!keys2.length)
        return;
      if (typeof columnKeys === "string") {
        columnKeys = [columnKeys];
      }
      if (Array.isArray(columnKeys)) {
        const columns_ = columnKeys.map((key) => getColumnByKey({
          columns: columns.value
        }, key));
        keys2.forEach((key) => {
          const column = columns_.find((col) => col.id === key);
          if (column) {
            column.filteredValue = [];
          }
        });
        instance.store.commit("filterChange", {
          column: columns_,
          values: [],
          silent: true,
          multi: true
        });
      } else {
        keys2.forEach((key) => {
          const column = columns.value.find((col) => col.id === key);
          if (column) {
            column.filteredValue = [];
          }
        });
        filters.value = {};
        instance.store.commit("filterChange", {
          column: {},
          values: [],
          silent: true
        });
      }
    };
    const clearSort = () => {
      if (!sortingColumn.value)
        return;
      updateSort(null, null, null);
      instance.store.commit("changeSortCondition", {
        silent: true
      });
    };
    const {
      setExpandRowKeys,
      toggleRowExpansion,
      updateExpandRows,
      states: expandStates,
      isRowExpanded
    } = useExpand({
      data,
      rowKey
    });
    const {
      updateTreeExpandKeys,
      toggleTreeExpansion,
      updateTreeData,
      loadOrToggle,
      states: treeStates
    } = useTree({
      data,
      rowKey
    });
    const {
      updateCurrentRowData,
      updateCurrentRow,
      setCurrentRowKey,
      states: currentData
    } = useCurrent({
      data,
      rowKey
    });
    const setExpandRowKeysAdapter = (val) => {
      setExpandRowKeys(val);
      updateTreeExpandKeys(val);
    };
    const toggleRowExpansionAdapter = (row, expanded) => {
      const hasExpandColumn = columns.value.some(({ type }) => type === "expand");
      if (hasExpandColumn) {
        toggleRowExpansion(row, expanded);
      } else {
        toggleTreeExpansion(row, expanded);
      }
    };
    return {
      assertRowKey,
      updateColumns,
      scheduleLayout,
      isSelected,
      clearSelection,
      cleanSelection,
      getSelectionRows,
      toggleRowSelection,
      _toggleAllSelection,
      toggleAllSelection: null,
      updateSelectionByRowKey,
      updateAllSelected,
      updateFilters,
      updateCurrentRow,
      updateSort,
      execFilter,
      execSort,
      execQuery,
      clearFilter,
      clearSort,
      toggleRowExpansion,
      setExpandRowKeysAdapter,
      setCurrentRowKey,
      toggleRowExpansionAdapter,
      isRowExpanded,
      updateExpandRows,
      updateCurrentRowData,
      loadOrToggle,
      updateTreeData,
      states: __spreadValues(__spreadValues(__spreadValues({
        tableSize,
        rowKey,
        data,
        _data,
        isComplex,
        _columns,
        originColumns,
        columns,
        fixedColumns,
        rightFixedColumns,
        leafColumns,
        fixedLeafColumns,
        rightFixedLeafColumns,
        leafColumnsLength,
        fixedLeafColumnsLength,
        rightFixedLeafColumnsLength,
        isAllSelected,
        selection,
        reserveSelection,
        selectOnIndeterminate,
        selectable,
        filters,
        filteredData,
        sortingColumn,
        sortProp,
        sortOrder,
        hoverRow
      }, expandStates), treeStates), currentData)
    };
  }
  function replaceColumn(array, column) {
    return array.map((item) => {
      var _a2;
      if (item.id === column.id) {
        return column;
      } else if ((_a2 = item.children) == null ? void 0 : _a2.length) {
        item.children = replaceColumn(item.children, column);
      }
      return item;
    });
  }
  function sortColumn(array) {
    array.forEach((item) => {
      var _a2, _b;
      item.no = (_a2 = item.getColumnIndex) == null ? void 0 : _a2.call(item);
      if ((_b = item.children) == null ? void 0 : _b.length) {
        sortColumn(item.children);
      }
    });
    array.sort((cur, pre) => cur.no - pre.no);
  }
  function useStore() {
    const instance = Vue.getCurrentInstance();
    const watcher = useWatcher$1();
    const ns2 = useNamespace("table");
    const mutations = {
      setData(states, data) {
        const dataInstanceChanged = Vue.unref(states._data) !== data;
        states.data.value = data;
        states._data.value = data;
        instance.store.execQuery();
        instance.store.updateCurrentRowData();
        instance.store.updateExpandRows();
        instance.store.updateTreeData(instance.store.states.defaultExpandAll.value);
        if (Vue.unref(states.reserveSelection)) {
          instance.store.assertRowKey();
          instance.store.updateSelectionByRowKey();
        } else {
          if (dataInstanceChanged) {
            instance.store.clearSelection();
          } else {
            instance.store.cleanSelection();
          }
        }
        instance.store.updateAllSelected();
        if (instance.$ready) {
          instance.store.scheduleLayout();
        }
      },
      insertColumn(states, column, parent) {
        const array = Vue.unref(states._columns);
        let newColumns = [];
        if (!parent) {
          array.push(column);
          newColumns = array;
        } else {
          if (parent && !parent.children) {
            parent.children = [];
          }
          parent.children.push(column);
          newColumns = replaceColumn(array, parent);
        }
        sortColumn(newColumns);
        states._columns.value = newColumns;
        if (column.type === "selection") {
          states.selectable.value = column.selectable;
          states.reserveSelection.value = column.reserveSelection;
        }
        if (instance.$ready) {
          instance.store.updateColumns();
          instance.store.scheduleLayout();
        }
      },
      removeColumn(states, column, parent) {
        const array = Vue.unref(states._columns) || [];
        if (parent) {
          parent.children.splice(parent.children.findIndex((item) => item.id === column.id), 1);
          Vue.nextTick(() => {
            var _a2;
            if (((_a2 = parent.children) == null ? void 0 : _a2.length) === 0) {
              delete parent.children;
            }
          });
          states._columns.value = replaceColumn(array, parent);
        } else {
          const index = array.indexOf(column);
          if (index > -1) {
            array.splice(index, 1);
            states._columns.value = array;
          }
        }
        if (instance.$ready) {
          instance.store.updateColumns();
          instance.store.scheduleLayout();
        }
      },
      sort(states, options) {
        const { prop, order, init } = options;
        if (prop) {
          const column = Vue.unref(states.columns).find((column2) => column2.property === prop);
          if (column) {
            column.order = order;
            instance.store.updateSort(column, prop, order);
            instance.store.commit("changeSortCondition", { init });
          }
        }
      },
      changeSortCondition(states, options) {
        const { sortingColumn, sortProp, sortOrder } = states;
        const columnValue = Vue.unref(sortingColumn), propValue = Vue.unref(sortProp), orderValue = Vue.unref(sortOrder);
        if (orderValue === null) {
          states.sortingColumn.value = null;
          states.sortProp.value = null;
        }
        const ignore = { filter: true };
        instance.store.execQuery(ignore);
        if (!options || !(options.silent || options.init)) {
          instance.emit("sort-change", {
            column: columnValue,
            prop: propValue,
            order: orderValue
          });
        }
        instance.store.updateTableScrollY();
      },
      filterChange(_states, options) {
        const { column, values, silent } = options;
        const newFilters = instance.store.updateFilters(column, values);
        instance.store.execQuery();
        if (!silent) {
          instance.emit("filter-change", newFilters);
        }
        instance.store.updateTableScrollY();
      },
      toggleAllSelection() {
        instance.store.toggleAllSelection();
      },
      rowSelectedChanged(_states, row) {
        instance.store.toggleRowSelection(row);
        instance.store.updateAllSelected();
      },
      setHoverRow(states, row) {
        states.hoverRow.value = row;
      },
      setCurrentRow(_states, row) {
        instance.store.updateCurrentRow(row);
      }
    };
    const commit = function(name, ...args) {
      const mutations2 = instance.store.mutations;
      if (mutations2[name]) {
        mutations2[name].apply(instance, [instance.store.states].concat(args));
      } else {
        throw new Error(`Action not found: ${name}`);
      }
    };
    const updateTableScrollY = function() {
      Vue.nextTick(() => instance.layout.updateScrollY.apply(instance.layout));
    };
    return __spreadProps(__spreadValues({
      ns: ns2
    }, watcher), {
      mutations,
      commit,
      updateTableScrollY
    });
  }
  const InitialStateMap = {
    rowKey: "rowKey",
    defaultExpandAll: "defaultExpandAll",
    selectOnIndeterminate: "selectOnIndeterminate",
    indent: "indent",
    lazy: "lazy",
    data: "data",
    ["treeProps.hasChildren"]: {
      key: "lazyColumnIdentifier",
      default: "hasChildren"
    },
    ["treeProps.children"]: {
      key: "childrenColumnName",
      default: "children"
    }
  };
  function createStore(table, props) {
    if (!table) {
      throw new Error("Table is required.");
    }
    const store = useStore();
    store.toggleAllSelection = debounce(store._toggleAllSelection, 10);
    Object.keys(InitialStateMap).forEach((key) => {
      handleValue(getArrKeysValue(props, key), key, store);
    });
    proxyTableProps(store, props);
    return store;
  }
  function proxyTableProps(store, props) {
    Object.keys(InitialStateMap).forEach((key) => {
      Vue.watch(() => getArrKeysValue(props, key), (value) => {
        handleValue(value, key, store);
      });
    });
  }
  function handleValue(value, propsKey, store) {
    let newVal = value;
    let storeKey = InitialStateMap[propsKey];
    if (typeof InitialStateMap[propsKey] === "object") {
      storeKey = storeKey.key;
      newVal = newVal || InitialStateMap[propsKey].default;
    }
    store.states[storeKey].value = newVal;
  }
  function getArrKeysValue(props, keys2) {
    if (keys2.includes(".")) {
      const keyList = keys2.split(".");
      let value = props;
      keyList.forEach((key) => {
        value = value[key];
      });
      return value;
    } else {
      return props[keys2];
    }
  }
  class TableLayout {
    constructor(options) {
      this.observers = [];
      this.table = null;
      this.store = null;
      this.columns = [];
      this.fit = true;
      this.showHeader = true;
      this.height = Vue.ref(null);
      this.scrollX = Vue.ref(false);
      this.scrollY = Vue.ref(false);
      this.bodyWidth = Vue.ref(null);
      this.fixedWidth = Vue.ref(null);
      this.rightFixedWidth = Vue.ref(null);
      this.gutterWidth = 0;
      for (const name in options) {
        if (hasOwn(options, name)) {
          if (Vue.isRef(this[name])) {
            this[name].value = options[name];
          } else {
            this[name] = options[name];
          }
        }
      }
      if (!this.table) {
        throw new Error("Table is required for Table Layout");
      }
      if (!this.store) {
        throw new Error("Store is required for Table Layout");
      }
    }
    updateScrollY() {
      const height = this.height.value;
      if (height === null)
        return false;
      const scrollBarRef = this.table.refs.scrollBarRef;
      if (this.table.vnode.el && scrollBarRef) {
        let scrollY = true;
        const prevScrollY = this.scrollY.value;
        scrollY = scrollBarRef.wrapRef.scrollHeight > scrollBarRef.wrapRef.clientHeight;
        this.scrollY.value = scrollY;
        return prevScrollY !== scrollY;
      }
      return false;
    }
    setHeight(value, prop = "height") {
      if (!isClient)
        return;
      const el = this.table.vnode.el;
      value = parseHeight(value);
      this.height.value = Number(value);
      if (!el && (value || value === 0))
        return Vue.nextTick(() => this.setHeight(value, prop));
      if (typeof value === "number") {
        el.style[prop] = `${value}px`;
        this.updateElsHeight();
      } else if (typeof value === "string") {
        el.style[prop] = value;
        this.updateElsHeight();
      }
    }
    setMaxHeight(value) {
      this.setHeight(value, "max-height");
    }
    getFlattenColumns() {
      const flattenColumns = [];
      const columns = this.table.store.states.columns.value;
      columns.forEach((column) => {
        if (column.isColumnGroup) {
          flattenColumns.push.apply(flattenColumns, column.columns);
        } else {
          flattenColumns.push(column);
        }
      });
      return flattenColumns;
    }
    updateElsHeight() {
      this.updateScrollY();
      this.notifyObservers("scrollable");
    }
    headerDisplayNone(elm) {
      if (!elm)
        return true;
      let headerChild = elm;
      while (headerChild.tagName !== "DIV") {
        if (getComputedStyle(headerChild).display === "none") {
          return true;
        }
        headerChild = headerChild.parentElement;
      }
      return false;
    }
    updateColumnsWidth() {
      if (!isClient)
        return;
      const fit = this.fit;
      const bodyWidth = this.table.vnode.el.clientWidth;
      let bodyMinWidth = 0;
      const flattenColumns = this.getFlattenColumns();
      const flexColumns = flattenColumns.filter((column) => typeof column.width !== "number");
      flattenColumns.forEach((column) => {
        if (typeof column.width === "number" && column.realWidth)
          column.realWidth = null;
      });
      if (flexColumns.length > 0 && fit) {
        flattenColumns.forEach((column) => {
          bodyMinWidth += Number(column.width || column.minWidth || 80);
        });
        if (bodyMinWidth <= bodyWidth) {
          this.scrollX.value = false;
          const totalFlexWidth = bodyWidth - bodyMinWidth;
          if (flexColumns.length === 1) {
            flexColumns[0].realWidth = Number(flexColumns[0].minWidth || 80) + totalFlexWidth;
          } else {
            const allColumnsWidth = flexColumns.reduce((prev, column) => prev + Number(column.minWidth || 80), 0);
            const flexWidthPerPixel = totalFlexWidth / allColumnsWidth;
            let noneFirstWidth = 0;
            flexColumns.forEach((column, index) => {
              if (index === 0)
                return;
              const flexWidth = Math.floor(Number(column.minWidth || 80) * flexWidthPerPixel);
              noneFirstWidth += flexWidth;
              column.realWidth = Number(column.minWidth || 80) + flexWidth;
            });
            flexColumns[0].realWidth = Number(flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth;
          }
        } else {
          this.scrollX.value = true;
          flexColumns.forEach((column) => {
            column.realWidth = Number(column.minWidth);
          });
        }
        this.bodyWidth.value = Math.max(bodyMinWidth, bodyWidth);
        this.table.state.resizeState.value.width = this.bodyWidth.value;
      } else {
        flattenColumns.forEach((column) => {
          if (!column.width && !column.minWidth) {
            column.realWidth = 80;
          } else {
            column.realWidth = Number(column.width || column.minWidth);
          }
          bodyMinWidth += column.realWidth;
        });
        this.scrollX.value = bodyMinWidth > bodyWidth;
        this.bodyWidth.value = bodyMinWidth;
      }
      const fixedColumns = this.store.states.fixedColumns.value;
      if (fixedColumns.length > 0) {
        let fixedWidth = 0;
        fixedColumns.forEach((column) => {
          fixedWidth += Number(column.realWidth || column.width);
        });
        this.fixedWidth.value = fixedWidth;
      }
      const rightFixedColumns = this.store.states.rightFixedColumns.value;
      if (rightFixedColumns.length > 0) {
        let rightFixedWidth = 0;
        rightFixedColumns.forEach((column) => {
          rightFixedWidth += Number(column.realWidth || column.width);
        });
        this.rightFixedWidth.value = rightFixedWidth;
      }
      this.notifyObservers("columns");
    }
    addObserver(observer) {
      this.observers.push(observer);
    }
    removeObserver(observer) {
      const index = this.observers.indexOf(observer);
      if (index !== -1) {
        this.observers.splice(index, 1);
      }
    }
    notifyObservers(event) {
      const observers = this.observers;
      observers.forEach((observer) => {
        var _a2, _b;
        switch (event) {
          case "columns":
            (_a2 = observer.state) == null ? void 0 : _a2.onColumnsChange(this);
            break;
          case "scrollable":
            (_b = observer.state) == null ? void 0 : _b.onScrollableChange(this);
            break;
          default:
            throw new Error(`Table Layout don't have event ${event}.`);
        }
      });
    }
  }
  const { CheckboxGroup: ElCheckboxGroup } = ElCheckbox;
  const _sfc_main$5 = Vue.defineComponent({
    name: "ElTableFilterPanel",
    components: {
      ElCheckbox,
      ElCheckboxGroup,
      ElScrollbar,
      ElTooltip,
      ElIcon,
      ArrowDown: arrow_down_default,
      ArrowUp: arrow_up_default
    },
    directives: { ClickOutside },
    props: {
      placement: {
        type: String,
        default: "bottom-start"
      },
      store: {
        type: Object
      },
      column: {
        type: Object
      },
      upDataColumn: {
        type: Function
      }
    },
    setup(props) {
      const instance = Vue.getCurrentInstance();
      const { t } = useLocale();
      const ns2 = useNamespace("table-filter");
      const parent = instance == null ? void 0 : instance.parent;
      if (!parent.filterPanels.value[props.column.id]) {
        parent.filterPanels.value[props.column.id] = instance;
      }
      const tooltipVisible = Vue.ref(false);
      const tooltip = Vue.ref(null);
      const filters = Vue.computed(() => {
        return props.column && props.column.filters;
      });
      const filterValue = Vue.computed({
        get: () => {
          var _a2;
          return (((_a2 = props.column) == null ? void 0 : _a2.filteredValue) || [])[0];
        },
        set: (value) => {
          if (filteredValue.value) {
            if (typeof value !== "undefined" && value !== null) {
              filteredValue.value.splice(0, 1, value);
            } else {
              filteredValue.value.splice(0, 1);
            }
          }
        }
      });
      const filteredValue = Vue.computed({
        get() {
          if (props.column) {
            return props.column.filteredValue || [];
          }
          return [];
        },
        set(value) {
          if (props.column) {
            props.upDataColumn("filteredValue", value);
          }
        }
      });
      const multiple = Vue.computed(() => {
        if (props.column) {
          return props.column.filterMultiple;
        }
        return true;
      });
      const isActive = (filter) => {
        return filter.value === filterValue.value;
      };
      const hidden = () => {
        tooltipVisible.value = false;
      };
      const showFilterPanel = (e) => {
        e.stopPropagation();
        tooltipVisible.value = !tooltipVisible.value;
      };
      const hideFilterPanel = () => {
        tooltipVisible.value = false;
      };
      const handleConfirm = () => {
        confirmFilter(filteredValue.value);
        hidden();
      };
      const handleReset = () => {
        filteredValue.value = [];
        confirmFilter(filteredValue.value);
        hidden();
      };
      const handleSelect = (_filterValue) => {
        filterValue.value = _filterValue;
        if (typeof _filterValue !== "undefined" && _filterValue !== null) {
          confirmFilter(filteredValue.value);
        } else {
          confirmFilter([]);
        }
        hidden();
      };
      const confirmFilter = (filteredValue2) => {
        props.store.commit("filterChange", {
          column: props.column,
          values: filteredValue2
        });
        props.store.updateAllSelected();
      };
      Vue.watch(tooltipVisible, (value) => {
        if (props.column) {
          props.upDataColumn("filterOpened", value);
        }
      }, {
        immediate: true
      });
      const popperPaneRef = Vue.computed(() => {
        var _a2, _b;
        return (_b = (_a2 = tooltip.value) == null ? void 0 : _a2.popperRef) == null ? void 0 : _b.contentRef;
      });
      return {
        tooltipVisible,
        multiple,
        filteredValue,
        filterValue,
        filters,
        handleConfirm,
        handleReset,
        handleSelect,
        isActive,
        t,
        ns: ns2,
        showFilterPanel,
        hideFilterPanel,
        popperPaneRef,
        tooltip
      };
    }
  });
  const _hoisted_1$4 = { key: 0 };
  const _hoisted_2$3 = ["disabled"];
  const _hoisted_3$1 = ["label", "onClick"];
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
    const _component_el_checkbox = Vue.resolveComponent("el-checkbox");
    const _component_el_checkbox_group = Vue.resolveComponent("el-checkbox-group");
    const _component_el_scrollbar = Vue.resolveComponent("el-scrollbar");
    const _component_arrow_up = Vue.resolveComponent("arrow-up");
    const _component_arrow_down = Vue.resolveComponent("arrow-down");
    const _component_el_icon = Vue.resolveComponent("el-icon");
    const _component_el_tooltip = Vue.resolveComponent("el-tooltip");
    const _directive_click_outside = Vue.resolveDirective("click-outside");
    return Vue.openBlock(), Vue.createBlock(_component_el_tooltip, {
      ref: "tooltip",
      visible: _ctx.tooltipVisible,
      offset: 0,
      placement: _ctx.placement,
      "show-arrow": false,
      "stop-popper-mouse-event": false,
      teleported: "",
      effect: "light",
      pure: "",
      "popper-class": _ctx.ns.b(),
      persistent: ""
    }, {
      content: Vue.withCtx(() => [
        _ctx.multiple ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1$4, [
          Vue.createElementVNode("div", {
            class: Vue.normalizeClass(_ctx.ns.e("content"))
          }, [
            Vue.createVNode(_component_el_scrollbar, {
              "wrap-class": _ctx.ns.e("wrap")
            }, {
              default: Vue.withCtx(() => [
                Vue.createVNode(_component_el_checkbox_group, {
                  modelValue: _ctx.filteredValue,
                  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.filteredValue = $event),
                  class: Vue.normalizeClass(_ctx.ns.e("checkbox-group"))
                }, {
                  default: Vue.withCtx(() => [
                    (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(_ctx.filters, (filter) => {
                      return Vue.openBlock(), Vue.createBlock(_component_el_checkbox, {
                        key: filter.value,
                        label: filter.value
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createTextVNode(Vue.toDisplayString(filter.text), 1)
                        ]),
                        _: 2
                      }, 1032, ["label"]);
                    }), 128))
                  ]),
                  _: 1
                }, 8, ["modelValue", "class"])
              ]),
              _: 1
            }, 8, ["wrap-class"])
          ], 2),
          Vue.createElementVNode("div", {
            class: Vue.normalizeClass(_ctx.ns.e("bottom"))
          }, [
            Vue.createElementVNode("button", {
              class: Vue.normalizeClass({ [_ctx.ns.is("disabled")]: _ctx.filteredValue.length === 0 }),
              disabled: _ctx.filteredValue.length === 0,
              type: "button",
              onClick: _cache[1] || (_cache[1] = (...args) => _ctx.handleConfirm && _ctx.handleConfirm(...args))
            }, Vue.toDisplayString(_ctx.t("el.table.confirmFilter")), 11, _hoisted_2$3),
            Vue.createElementVNode("button", {
              type: "button",
              onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleReset && _ctx.handleReset(...args))
            }, Vue.toDisplayString(_ctx.t("el.table.resetFilter")), 1)
          ], 2)
        ])) : (Vue.openBlock(), Vue.createElementBlock("ul", {
          key: 1,
          class: Vue.normalizeClass(_ctx.ns.e("list"))
        }, [
          Vue.createElementVNode("li", {
            class: Vue.normalizeClass([
              _ctx.ns.e("list-item"),
              {
                [_ctx.ns.is("active")]: _ctx.filterValue === void 0 || _ctx.filterValue === null
              }
            ]),
            onClick: _cache[3] || (_cache[3] = ($event) => _ctx.handleSelect(null))
          }, Vue.toDisplayString(_ctx.t("el.table.clearFilter")), 3),
          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(_ctx.filters, (filter) => {
            return Vue.openBlock(), Vue.createElementBlock("li", {
              key: filter.value,
              class: Vue.normalizeClass([_ctx.ns.e("list-item"), _ctx.ns.is("active", _ctx.isActive(filter))]),
              label: filter.value,
              onClick: ($event) => _ctx.handleSelect(filter.value)
            }, Vue.toDisplayString(filter.text), 11, _hoisted_3$1);
          }), 128))
        ], 2))
      ]),
      default: Vue.withCtx(() => [
        Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("span", {
          class: Vue.normalizeClass([
            `${_ctx.ns.namespace.value}-table__column-filter-trigger`,
            `${_ctx.ns.namespace.value}-none-outline`
          ]),
          onClick: _cache[4] || (_cache[4] = (...args) => _ctx.showFilterPanel && _ctx.showFilterPanel(...args))
        }, [
          Vue.createVNode(_component_el_icon, null, {
            default: Vue.withCtx(() => [
              _ctx.column.filterOpened ? (Vue.openBlock(), Vue.createBlock(_component_arrow_up, { key: 0 })) : (Vue.openBlock(), Vue.createBlock(_component_arrow_down, { key: 1 }))
            ]),
            _: 1
          })
        ], 2)), [
          [_directive_click_outside, _ctx.hideFilterPanel, _ctx.popperPaneRef]
        ])
      ]),
      _: 1
    }, 8, ["visible", "placement", "popper-class"]);
  }
  var FilterPanel = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/table/src/filter-panel.vue"]]);
  function useLayoutObserver(root2) {
    const instance = Vue.getCurrentInstance();
    Vue.onBeforeMount(() => {
      tableLayout.value.addObserver(instance);
    });
    Vue.onMounted(() => {
      onColumnsChange(tableLayout.value);
      onScrollableChange(tableLayout.value);
    });
    Vue.onUpdated(() => {
      onColumnsChange(tableLayout.value);
      onScrollableChange(tableLayout.value);
    });
    Vue.onUnmounted(() => {
      tableLayout.value.removeObserver(instance);
    });
    const tableLayout = Vue.computed(() => {
      const layout = root2.layout;
      if (!layout) {
        throw new Error("Can not find table layout.");
      }
      return layout;
    });
    const onColumnsChange = (layout) => {
      var _a2;
      const cols = ((_a2 = root2.vnode.el) == null ? void 0 : _a2.querySelectorAll("colgroup > col")) || [];
      if (!cols.length)
        return;
      const flattenColumns = layout.getFlattenColumns();
      const columnsMap = {};
      flattenColumns.forEach((column) => {
        columnsMap[column.id] = column;
      });
      for (let i = 0, j = cols.length; i < j; i++) {
        const col = cols[i];
        const name = col.getAttribute("name");
        const column = columnsMap[name];
        if (column) {
          col.setAttribute("width", column.realWidth || column.width);
        }
      }
    };
    const onScrollableChange = (layout) => {
      var _a2, _b;
      const cols = ((_a2 = root2.vnode.el) == null ? void 0 : _a2.querySelectorAll("colgroup > col[name=gutter]")) || [];
      for (let i = 0, j = cols.length; i < j; i++) {
        const col = cols[i];
        col.setAttribute("width", layout.scrollY.value ? layout.gutterWidth : "0");
      }
      const ths = ((_b = root2.vnode.el) == null ? void 0 : _b.querySelectorAll("th.gutter")) || [];
      for (let i = 0, j = ths.length; i < j; i++) {
        const th = ths[i];
        th.style.width = layout.scrollY.value ? `${layout.gutterWidth}px` : "0";
        th.style.display = layout.scrollY.value ? "" : "none";
      }
    };
    return {
      tableLayout: tableLayout.value,
      onColumnsChange,
      onScrollableChange
    };
  }
  const TABLE_INJECTION_KEY = Symbol("ElTable");
  function useEvent(props, emit) {
    const instance = Vue.getCurrentInstance();
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const handleFilterClick = (event) => {
      event.stopPropagation();
      return;
    };
    const handleHeaderClick = (event, column) => {
      if (!column.filters && column.sortable) {
        handleSortClick(event, column, false);
      } else if (column.filterable && !column.sortable) {
        handleFilterClick(event);
      }
      parent == null ? void 0 : parent.emit("header-click", column, event);
    };
    const handleHeaderContextMenu = (event, column) => {
      parent == null ? void 0 : parent.emit("header-contextmenu", column, event);
    };
    const draggingColumn = Vue.ref(null);
    const dragging = Vue.ref(false);
    const dragState = Vue.ref({});
    const handleMouseDown = (event, column) => {
      if (!isClient)
        return;
      if (column.children && column.children.length > 0)
        return;
      if (draggingColumn.value && props.border) {
        dragging.value = true;
        const table = parent;
        emit("set-drag-visible", true);
        const tableEl = table == null ? void 0 : table.vnode.el;
        const tableLeft = tableEl.getBoundingClientRect().left;
        const columnEl = instance.vnode.el.querySelector(`th.${column.id}`);
        const columnRect = columnEl.getBoundingClientRect();
        const minLeft = columnRect.left - tableLeft + 30;
        addClass(columnEl, "noclick");
        dragState.value = {
          startMouseLeft: event.clientX,
          startLeft: columnRect.right - tableLeft,
          startColumnLeft: columnRect.left - tableLeft,
          tableLeft
        };
        const resizeProxy = table == null ? void 0 : table.refs.resizeProxy;
        resizeProxy.style.left = `${dragState.value.startLeft}px`;
        document.onselectstart = function() {
          return false;
        };
        document.ondragstart = function() {
          return false;
        };
        const handleMouseMove2 = (event2) => {
          const deltaLeft = event2.clientX - dragState.value.startMouseLeft;
          const proxyLeft = dragState.value.startLeft + deltaLeft;
          resizeProxy.style.left = `${Math.max(minLeft, proxyLeft)}px`;
        };
        const handleMouseUp = () => {
          if (dragging.value) {
            const { startColumnLeft, startLeft } = dragState.value;
            const finalLeft = Number.parseInt(resizeProxy.style.left, 10);
            const columnWidth = finalLeft - startColumnLeft;
            column.width = column.realWidth = columnWidth;
            table == null ? void 0 : table.emit("header-dragend", column.width, startLeft - startColumnLeft, column, event);
            requestAnimationFrame(() => {
              props.store.scheduleLayout(false, true);
            });
            document.body.style.cursor = "";
            dragging.value = false;
            draggingColumn.value = null;
            dragState.value = {};
            emit("set-drag-visible", false);
          }
          document.removeEventListener("mousemove", handleMouseMove2);
          document.removeEventListener("mouseup", handleMouseUp);
          document.onselectstart = null;
          document.ondragstart = null;
          setTimeout(() => {
            removeClass(columnEl, "noclick");
          }, 0);
        };
        document.addEventListener("mousemove", handleMouseMove2);
        document.addEventListener("mouseup", handleMouseUp);
      }
    };
    const handleMouseMove = (event, column) => {
      var _a2;
      if (column.children && column.children.length > 0)
        return;
      const target = (_a2 = event.target) == null ? void 0 : _a2.closest("th");
      if (!column || !column.resizable)
        return;
      if (!dragging.value && props.border) {
        const rect = target.getBoundingClientRect();
        const bodyStyle = document.body.style;
        if (rect.width > 12 && rect.right - event.pageX < 8) {
          bodyStyle.cursor = "col-resize";
          if (hasClass(target, "is-sortable")) {
            target.style.cursor = "col-resize";
          }
          draggingColumn.value = column;
        } else if (!dragging.value) {
          bodyStyle.cursor = "";
          if (hasClass(target, "is-sortable")) {
            target.style.cursor = "pointer";
          }
          draggingColumn.value = null;
        }
      }
    };
    const handleMouseOut = () => {
      if (!isClient)
        return;
      document.body.style.cursor = "";
    };
    const toggleOrder = ({ order, sortOrders }) => {
      if (order === "")
        return sortOrders[0];
      const index = sortOrders.indexOf(order || null);
      return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1];
    };
    const handleSortClick = (event, column, givenOrder) => {
      var _a2;
      event.stopPropagation();
      const order = column.order === givenOrder ? null : givenOrder || toggleOrder(column);
      const target = (_a2 = event.target) == null ? void 0 : _a2.closest("th");
      if (target) {
        if (hasClass(target, "noclick")) {
          removeClass(target, "noclick");
          return;
        }
      }
      if (!column.sortable)
        return;
      const states = props.store.states;
      let sortProp = states.sortProp.value;
      let sortOrder;
      const sortingColumn = states.sortingColumn.value;
      if (sortingColumn !== column || sortingColumn === column && sortingColumn.order === null) {
        if (sortingColumn) {
          sortingColumn.order = null;
        }
        states.sortingColumn.value = column;
        sortProp = column.property;
      }
      if (!order) {
        sortOrder = column.order = null;
      } else {
        sortOrder = column.order = order;
      }
      states.sortProp.value = sortProp;
      states.sortOrder.value = sortOrder;
      parent == null ? void 0 : parent.store.commit("changeSortCondition");
    };
    return {
      handleHeaderClick,
      handleHeaderContextMenu,
      handleMouseDown,
      handleMouseMove,
      handleMouseOut,
      handleSortClick,
      handleFilterClick
    };
  }
  function useStyle$2(props) {
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const ns2 = useNamespace("table");
    const getHeaderRowStyle = (rowIndex) => {
      const headerRowStyle = parent == null ? void 0 : parent.props.headerRowStyle;
      if (typeof headerRowStyle === "function") {
        return headerRowStyle.call(null, { rowIndex });
      }
      return headerRowStyle;
    };
    const getHeaderRowClass = (rowIndex) => {
      const classes = [];
      const headerRowClassName = parent == null ? void 0 : parent.props.headerRowClassName;
      if (typeof headerRowClassName === "string") {
        classes.push(headerRowClassName);
      } else if (typeof headerRowClassName === "function") {
        classes.push(headerRowClassName.call(null, { rowIndex }));
      }
      return classes.join(" ");
    };
    const getHeaderCellStyle = (rowIndex, columnIndex, row, column) => {
      var _a2;
      let headerCellStyles = (_a2 = parent == null ? void 0 : parent.props.headerCellStyle) != null ? _a2 : {};
      if (typeof headerCellStyles === "function") {
        headerCellStyles = headerCellStyles.call(null, {
          rowIndex,
          columnIndex,
          row,
          column
        });
      }
      const fixedStyle = getFixedColumnOffset(columnIndex, column.fixed, props.store, row);
      ensurePosition(fixedStyle, "left");
      ensurePosition(fixedStyle, "right");
      return Object.assign({}, headerCellStyles, fixedStyle);
    };
    const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {
      const fixedClasses = getFixedColumnsClass(ns2.b(), columnIndex, column.fixed, props.store, row);
      const classes = [
        column.id,
        column.order,
        column.headerAlign,
        column.className,
        column.labelClassName,
        ...fixedClasses
      ];
      if (!column.children) {
        classes.push("is-leaf");
      }
      if (column.sortable) {
        classes.push("is-sortable");
      }
      const headerCellClassName = parent == null ? void 0 : parent.props.headerCellClassName;
      if (typeof headerCellClassName === "string") {
        classes.push(headerCellClassName);
      } else if (typeof headerCellClassName === "function") {
        classes.push(headerCellClassName.call(null, {
          rowIndex,
          columnIndex,
          row,
          column
        }));
      }
      classes.push(ns2.e("cell"));
      return classes.filter((className) => Boolean(className)).join(" ");
    };
    return {
      getHeaderRowStyle,
      getHeaderRowClass,
      getHeaderCellStyle,
      getHeaderCellClass
    };
  }
  const getAllColumns = (columns) => {
    const result = [];
    columns.forEach((column) => {
      if (column.children) {
        result.push(column);
        result.push.apply(result, getAllColumns(column.children));
      } else {
        result.push(column);
      }
    });
    return result;
  };
  const convertToRows = (originColumns) => {
    let maxLevel = 1;
    const traverse2 = (column, parent) => {
      if (parent) {
        column.level = parent.level + 1;
        if (maxLevel < column.level) {
          maxLevel = column.level;
        }
      }
      if (column.children) {
        let colSpan = 0;
        column.children.forEach((subColumn) => {
          traverse2(subColumn, column);
          colSpan += subColumn.colSpan;
        });
        column.colSpan = colSpan;
      } else {
        column.colSpan = 1;
      }
    };
    originColumns.forEach((column) => {
      column.level = 1;
      traverse2(column, void 0);
    });
    const rows = [];
    for (let i = 0; i < maxLevel; i++) {
      rows.push([]);
    }
    const allColumns = getAllColumns(originColumns);
    allColumns.forEach((column) => {
      if (!column.children) {
        column.rowSpan = maxLevel - column.level + 1;
      } else {
        column.rowSpan = 1;
        column.children.forEach((col) => col.isSubColumn = true);
      }
      rows[column.level - 1].push(column);
    });
    return rows;
  };
  function useUtils$1(props) {
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const columnRows = Vue.computed(() => {
      return convertToRows(props.store.states.originColumns.value);
    });
    const isGroup = Vue.computed(() => {
      const result = columnRows.value.length > 1;
      if (result && parent) {
        parent.state.isGroup.value = true;
      }
      return result;
    });
    const toggleAllSelection = (event) => {
      event.stopPropagation();
      parent == null ? void 0 : parent.store.commit("toggleAllSelection");
    };
    return {
      isGroup,
      toggleAllSelection,
      columnRows
    };
  }
  var TableHeader = Vue.defineComponent({
    name: "ElTableHeader",
    components: {
      ElCheckbox
    },
    props: {
      fixed: {
        type: String,
        default: ""
      },
      store: {
        required: true,
        type: Object
      },
      border: Boolean,
      defaultSort: {
        type: Object,
        default: () => {
          return {
            prop: "",
            order: ""
          };
        }
      }
    },
    setup(props, { emit }) {
      const instance = Vue.getCurrentInstance();
      const parent = Vue.inject(TABLE_INJECTION_KEY);
      const ns2 = useNamespace("table");
      const filterPanels = Vue.ref({});
      const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent);
      Vue.onMounted(async () => {
        await Vue.nextTick();
        await Vue.nextTick();
        const { prop, order } = props.defaultSort;
        parent == null ? void 0 : parent.store.commit("sort", { prop, order, init: true });
      });
      const {
        handleHeaderClick,
        handleHeaderContextMenu,
        handleMouseDown,
        handleMouseMove,
        handleMouseOut,
        handleSortClick,
        handleFilterClick
      } = useEvent(props, emit);
      const {
        getHeaderRowStyle,
        getHeaderRowClass,
        getHeaderCellStyle,
        getHeaderCellClass
      } = useStyle$2(props);
      const { isGroup, toggleAllSelection, columnRows } = useUtils$1(props);
      instance.state = {
        onColumnsChange,
        onScrollableChange
      };
      instance.filterPanels = filterPanels;
      return {
        ns: ns2,
        filterPanels,
        onColumnsChange,
        onScrollableChange,
        columnRows,
        getHeaderRowClass,
        getHeaderRowStyle,
        getHeaderCellClass,
        getHeaderCellStyle,
        handleHeaderClick,
        handleHeaderContextMenu,
        handleMouseDown,
        handleMouseMove,
        handleMouseOut,
        handleSortClick,
        handleFilterClick,
        isGroup,
        toggleAllSelection
      };
    },
    render() {
      const {
        ns: ns2,
        isGroup,
        columnRows,
        getHeaderCellStyle,
        getHeaderCellClass,
        getHeaderRowClass,
        getHeaderRowStyle,
        handleHeaderClick,
        handleHeaderContextMenu,
        handleMouseDown,
        handleMouseMove,
        handleSortClick,
        handleMouseOut,
        store,
        $parent
      } = this;
      let rowSpan = 1;
      return Vue.h("thead", {
        class: { [ns2.is("group")]: isGroup }
      }, columnRows.map((subColumns, rowIndex) => Vue.h("tr", {
        class: getHeaderRowClass(rowIndex),
        key: rowIndex,
        style: getHeaderRowStyle(rowIndex)
      }, subColumns.map((column, cellIndex) => {
        if (column.rowSpan > rowSpan) {
          rowSpan = column.rowSpan;
        }
        return Vue.h("th", {
          class: getHeaderCellClass(rowIndex, cellIndex, subColumns, column),
          colspan: column.colSpan,
          key: `${column.id}-thead`,
          rowspan: column.rowSpan,
          style: getHeaderCellStyle(rowIndex, cellIndex, subColumns, column),
          onClick: ($event) => handleHeaderClick($event, column),
          onContextmenu: ($event) => handleHeaderContextMenu($event, column),
          onMousedown: ($event) => handleMouseDown($event, column),
          onMousemove: ($event) => handleMouseMove($event, column),
          onMouseout: handleMouseOut
        }, [
          Vue.h("div", {
            class: [
              "cell",
              column.filteredValue && column.filteredValue.length > 0 ? "highlight" : ""
            ]
          }, [
            column.renderHeader ? column.renderHeader({
              column,
              $index: cellIndex,
              store,
              _self: $parent
            }) : column.label,
            column.sortable && Vue.h("span", {
              onClick: ($event) => handleSortClick($event, column),
              class: "caret-wrapper"
            }, [
              Vue.h("i", {
                onClick: ($event) => handleSortClick($event, column, "ascending"),
                class: "sort-caret ascending"
              }),
              Vue.h("i", {
                onClick: ($event) => handleSortClick($event, column, "descending"),
                class: "sort-caret descending"
              })
            ]),
            column.filterable && Vue.h(FilterPanel, {
              store,
              placement: column.filterPlacement || "bottom-start",
              column,
              upDataColumn: (key, value) => {
                column[key] = value;
              }
            })
          ])
        ]);
      }))));
    }
  });
  function useEvents(props) {
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const tooltipContent = Vue.ref("");
    const tooltipTrigger = Vue.ref(Vue.h("div"));
    const handleEvent = (event, row, name) => {
      var _a2;
      const table = parent;
      const cell = getCell(event);
      let column;
      const namespace = (_a2 = table == null ? void 0 : table.vnode.el) == null ? void 0 : _a2.dataset.prefix;
      if (cell) {
        column = getColumnByCell({
          columns: props.store.states.columns.value
        }, cell, namespace);
        if (column) {
          table == null ? void 0 : table.emit(`cell-${name}`, row, column, cell, event);
        }
      }
      table == null ? void 0 : table.emit(`row-${name}`, row, column, event);
    };
    const handleDoubleClick = (event, row) => {
      handleEvent(event, row, "dblclick");
    };
    const handleClick = (event, row) => {
      props.store.commit("setCurrentRow", row);
      handleEvent(event, row, "click");
    };
    const handleContextMenu = (event, row) => {
      handleEvent(event, row, "contextmenu");
    };
    const handleMouseEnter = debounce((index) => {
      props.store.commit("setHoverRow", index);
    }, 30);
    const handleMouseLeave = debounce(() => {
      props.store.commit("setHoverRow", null);
    }, 30);
    const handleCellMouseEnter = (event, row, tooltipOptions) => {
      var _a2;
      const table = parent;
      const cell = getCell(event);
      const namespace = (_a2 = table == null ? void 0 : table.vnode.el) == null ? void 0 : _a2.dataset.prefix;
      if (cell) {
        const column = getColumnByCell({
          columns: props.store.states.columns.value
        }, cell, namespace);
        const hoverState = table.hoverState = { cell, column, row };
        table == null ? void 0 : table.emit("cell-mouse-enter", hoverState.row, hoverState.column, hoverState.cell, event);
      }
      if (!tooltipOptions) {
        return;
      }
      const cellChild = event.target.querySelector(".cell");
      if (!(hasClass(cellChild, `${namespace}-tooltip`) && cellChild.childNodes.length)) {
        return;
      }
      const range = document.createRange();
      range.setStart(cellChild, 0);
      range.setEnd(cellChild, cellChild.childNodes.length);
      const rangeWidth = Math.round(range.getBoundingClientRect().width);
      const padding = (Number.parseInt(getStyle(cellChild, "paddingLeft"), 10) || 0) + (Number.parseInt(getStyle(cellChild, "paddingRight"), 10) || 0);
      if (rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) {
        createTablePopper(parent == null ? void 0 : parent.refs.tableWrapper, cell, cell.innerText || cell.textContent, tooltipOptions);
      }
    };
    const handleCellMouseLeave = (event) => {
      const cell = getCell(event);
      if (!cell)
        return;
      const oldHoverState = parent == null ? void 0 : parent.hoverState;
      parent == null ? void 0 : parent.emit("cell-mouse-leave", oldHoverState == null ? void 0 : oldHoverState.row, oldHoverState == null ? void 0 : oldHoverState.column, oldHoverState == null ? void 0 : oldHoverState.cell, event);
    };
    return {
      handleDoubleClick,
      handleClick,
      handleContextMenu,
      handleMouseEnter,
      handleMouseLeave,
      handleCellMouseEnter,
      handleCellMouseLeave,
      tooltipContent,
      tooltipTrigger
    };
  }
  function useStyles(props) {
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const ns2 = useNamespace("table");
    const getRowStyle = (row, rowIndex) => {
      const rowStyle = parent == null ? void 0 : parent.props.rowStyle;
      if (typeof rowStyle === "function") {
        return rowStyle.call(null, {
          row,
          rowIndex
        });
      }
      return rowStyle || null;
    };
    const getRowClass = (row, rowIndex) => {
      const classes = [ns2.e("row")];
      if ((parent == null ? void 0 : parent.props.highlightCurrentRow) && row === props.store.states.currentRow.value) {
        classes.push("current-row");
      }
      if (props.stripe && rowIndex % 2 === 1) {
        classes.push(ns2.em("row", "striped"));
      }
      const rowClassName = parent == null ? void 0 : parent.props.rowClassName;
      if (typeof rowClassName === "string") {
        classes.push(rowClassName);
      } else if (typeof rowClassName === "function") {
        classes.push(rowClassName.call(null, {
          row,
          rowIndex
        }));
      }
      return classes;
    };
    const getCellStyle = (rowIndex, columnIndex, row, column) => {
      const cellStyle = parent == null ? void 0 : parent.props.cellStyle;
      let cellStyles = cellStyle != null ? cellStyle : {};
      if (typeof cellStyle === "function") {
        cellStyles = cellStyle.call(null, {
          rowIndex,
          columnIndex,
          row,
          column
        });
      }
      const fixedStyle = getFixedColumnOffset(columnIndex, props == null ? void 0 : props.fixed, props.store);
      ensurePosition(fixedStyle, "left");
      ensurePosition(fixedStyle, "right");
      return Object.assign({}, cellStyles, fixedStyle);
    };
    const getCellClass = (rowIndex, columnIndex, row, column, offset) => {
      const fixedClasses = getFixedColumnsClass(ns2.b(), columnIndex, props == null ? void 0 : props.fixed, props.store, void 0, offset);
      const classes = [column.id, column.align, column.className, ...fixedClasses];
      const cellClassName = parent == null ? void 0 : parent.props.cellClassName;
      if (typeof cellClassName === "string") {
        classes.push(cellClassName);
      } else if (typeof cellClassName === "function") {
        classes.push(cellClassName.call(null, {
          rowIndex,
          columnIndex,
          row,
          column
        }));
      }
      classes.push(ns2.e("cell"));
      return classes.filter((className) => Boolean(className)).join(" ");
    };
    const getSpan = (row, column, rowIndex, columnIndex) => {
      let rowspan = 1;
      let colspan = 1;
      const fn2 = parent == null ? void 0 : parent.props.spanMethod;
      if (typeof fn2 === "function") {
        const result = fn2({
          row,
          column,
          rowIndex,
          columnIndex
        });
        if (Array.isArray(result)) {
          rowspan = result[0];
          colspan = result[1];
        } else if (typeof result === "object") {
          rowspan = result.rowspan;
          colspan = result.colspan;
        }
      }
      return { rowspan, colspan };
    };
    const getColspanRealWidth = (columns, colspan, index) => {
      if (colspan < 1) {
        return columns[index].realWidth;
      }
      const widthArr = columns.map(({ realWidth, width }) => realWidth || width).slice(index, index + colspan);
      return Number(widthArr.reduce((acc, width) => Number(acc) + Number(width), -1));
    };
    return {
      getRowStyle,
      getRowClass,
      getCellStyle,
      getCellClass,
      getSpan,
      getColspanRealWidth
    };
  }
  function useRender$1(props) {
    const parent = Vue.inject(TABLE_INJECTION_KEY);
    const ns2 = useNamespace("table");
    const {
      handleDoubleClick,
      handleClick,
      handleContextMenu,
      handleMouseEnter,
      handleMouseLeave,
      handleCellMouseEnter,
      handleCellMouseLeave,
      tooltipContent,
      tooltipTrigger
    } = useEvents(props);
    const {
      getRowStyle,
      getRowClass,
      getCellStyle,
      getCellClass,
      getSpan,
      getColspanRealWidth
    } = useStyles(props);
    const firstDefaultColumnIndex = Vue.computed(() => {
      return props.store.states.columns.value.findIndex(({ type }) => type === "default");
    });
    const getKeyOfRow = (row, index) => {
      const rowKey = parent.props.rowKey;
      if (rowKey) {
        return getRowIdentity(row, rowKey);
      }
      return index;
    };
    const rowRender = (row, $index, treeRowData, expanded = false) => {
      const { tooltipEffect, tooltipOptions, store } = props;
      const { indent, columns } = store.states;
      const rowClasses = getRowClass(row, $index);
      let display = true;
      if (treeRowData) {
        rowClasses.push(ns2.em("row", `level-${treeRowData.level}`));
        display = treeRowData.display;
      }
      const displayStyle = display ? null : {
        display: "none"
      };
      return Vue.h("tr", {
        style: [displayStyle, getRowStyle(row, $index)],
        class: rowClasses,
        key: getKeyOfRow(row, $index),
        onDblclick: ($event) => handleDoubleClick($event, row),
        onClick: ($event) => handleClick($event, row),
        onContextmenu: ($event) => handleContextMenu($event, row),
        onMouseenter: () => handleMouseEnter($index),
        onMouseleave: handleMouseLeave
      }, columns.value.map((column, cellIndex) => {
        const { rowspan, colspan } = getSpan(row, column, $index, cellIndex);
        if (!rowspan || !colspan) {
          return null;
        }
        const columnData = __spreadValues({}, column);
        columnData.realWidth = getColspanRealWidth(columns.value, colspan, cellIndex);
        const data = {
          store: props.store,
          _self: props.context || parent,
          column: columnData,
          row,
          $index,
          cellIndex,
          expanded
        };
        if (cellIndex === firstDefaultColumnIndex.value && treeRowData) {
          data.treeNode = {
            indent: treeRowData.level * indent.value,
            level: treeRowData.level
          };
          if (typeof treeRowData.expanded === "boolean") {
            data.treeNode.expanded = treeRowData.expanded;
            if ("loading" in treeRowData) {
              data.treeNode.loading = treeRowData.loading;
            }
            if ("noLazyChildren" in treeRowData) {
              data.treeNode.noLazyChildren = treeRowData.noLazyChildren;
            }
          }
        }
        const baseKey = `${$index},${cellIndex}`;
        const patchKey = columnData.columnKey || columnData.rawColumnKey || "";
        const tdChildren = cellChildren(cellIndex, column, data);
        const mergedTooltipOptions = column.showOverflowTooltip && merge$1({
          effect: tooltipEffect
        }, tooltipOptions, column.showOverflowTooltip);
        return Vue.h("td", {
          style: getCellStyle($index, cellIndex, row, column),
          class: getCellClass($index, cellIndex, row, column, colspan - 1),
          key: `${patchKey}${baseKey}`,
          rowspan,
          colspan,
          onMouseenter: ($event) => handleCellMouseEnter($event, row, mergedTooltipOptions),
          onMouseleave: handleCellMouseLeave
        }, [tdChildren]);
      }));
    };
    const cellChildren = (cellIndex, column, data) => {
      return column.renderCell(data);
    };
    const wrappedRowRender = (row, $index) => {
      const store = props.store;
      const { isRowExpanded, assertRowKey } = store;
      const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } = store.states;
      const columns = store.states.columns.value;
      const hasExpandColumn = columns.some(({ type }) => type === "expand");
      if (hasExpandColumn) {
        const expanded = isRowExpanded(row);
        const tr = rowRender(row, $index, void 0, expanded);
        const renderExpanded = parent.renderExpanded;
        if (expanded) {
          if (!renderExpanded) {
            console.error("[Element Error]renderExpanded is required.");
            return tr;
          }
          return [
            [
              tr,
              Vue.h("tr", {
                key: `expanded-row__${tr.key}`
              }, [
                Vue.h("td", {
                  colspan: columns.length,
                  class: `${ns2.e("cell")} ${ns2.e("expanded-cell")}`
                }, [renderExpanded({ row, $index, store, expanded })])
              ])
            ]
          ];
        } else {
          return [[tr]];
        }
      } else if (Object.keys(treeData.value).length) {
        assertRowKey();
        const key = getRowIdentity(row, rowKey.value);
        let cur = treeData.value[key];
        let treeRowData = null;
        if (cur) {
          treeRowData = {
            expanded: cur.expanded,
            level: cur.level,
            display: true
          };
          if (typeof cur.lazy === "boolean") {
            if (typeof cur.loaded === "boolean" && cur.loaded) {
              treeRowData.noLazyChildren = !(cur.children && cur.children.length);
            }
            treeRowData.loading = cur.loading;
          }
        }
        const tmp = [rowRender(row, $index, treeRowData)];
        if (cur) {
          let i = 0;
          const traverse2 = (children, parent2) => {
            if (!(children && children.length && parent2))
              return;
            children.forEach((node) => {
              const innerTreeRowData = {
                display: parent2.display && parent2.expanded,
                level: parent2.level + 1,
                expanded: false,
                noLazyChildren: false,
                loading: false
              };
              const childKey = getRowIdentity(node, rowKey.value);
              if (childKey === void 0 || childKey === null) {
                throw new Error("For nested data item, row-key is required.");
              }
              cur = __spreadValues({}, treeData.value[childKey]);
              if (cur) {
                innerTreeRowData.expanded = cur.expanded;
                cur.level = cur.level || innerTreeRowData.level;
                cur.display = !!(cur.expanded && innerTreeRowData.display);
                if (typeof cur.lazy === "boolean") {
                  if (typeof cur.loaded === "boolean" && cur.loaded) {
                    innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
                  }
                  innerTreeRowData.loading = cur.loading;
                }
              }
              i++;
              tmp.push(rowRender(node, $index + i, innerTreeRowData));
              if (cur) {
                const nodes2 = lazyTreeNodeMap.value[childKey] || node[childrenColumnName.value];
                traverse2(nodes2, cur);
              }
            });
          };
          cur.display = true;
          const nodes = lazyTreeNodeMap.value[key] || row[childrenColumnName.value];
          traverse2(nodes, cur);
        }
        return tmp;
      } else {
        return rowRender(row, $index, void 0);
      }
    };
    return {
      wrappedRowRender,
      tooltipContent,
      tooltipTrigger
    };
  }
  const defaultProps$2 = {
    store: {
      required: true,
      type: Object
    },
    stripe: Boolean,
    tooltipEffect: String,
    tooltipOptions: {
      type: Object
    },
    context: {
      default: () => ({}),
      type: Object
    },
    rowClassName: [String, Function],
    rowStyle: [Object, Function],
    fixed: {
      type: String,
      default: ""
    },
    highlight: Boolean
  };
  var TableBody = Vue.defineComponent({
    name: "ElTableBody",
    props: defaultProps$2,
    setup(props) {
      const instance = Vue.getCurrentInstance();
      const parent = Vue.inject(TABLE_INJECTION_KEY);
      const ns2 = useNamespace("table");
      const { wrappedRowRender, tooltipContent, tooltipTrigger } = useRender$1(props);
      const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent);
      Vue.watch(props.store.states.hoverRow, (newVal, oldVal) => {
        if (!props.store.states.isComplex.value || !isClient)
          return;
        let raf = window.requestAnimationFrame;
        if (!raf) {
          raf = (fn2) => window.setTimeout(fn2, 16);
        }
        raf(() => {
          const el = instance == null ? void 0 : instance.vnode.el;
          const rows = Array.from((el == null ? void 0 : el.children) || []).filter((e) => e == null ? void 0 : e.classList.contains(`${ns2.e("row")}`));
          const oldRow = rows[oldVal];
          const newRow = rows[newVal];
          if (oldRow) {
            removeClass(oldRow, "hover-row");
          }
          if (newRow) {
            addClass(newRow, "hover-row");
          }
        });
      });
      Vue.onUnmounted(() => {
        var _a2;
        (_a2 = removePopper) == null ? void 0 : _a2();
      });
      return {
        ns: ns2,
        onColumnsChange,
        onScrollableChange,
        wrappedRowRender,
        tooltipContent,
        tooltipTrigger
      };
    },
    render() {
      const { wrappedRowRender, store } = this;
      const data = store.states.data.value || [];
      return Vue.h("tbody", {}, [
        data.reduce((acc, row) => {
          return acc.concat(wrappedRowRender(row, acc.length));
        }, [])
      ]);
    }
  });
  function hColgroup(props) {
    const isAuto = props.tableLayout === "auto";
    let columns = props.columns || [];
    if (isAuto) {
      if (columns.every((column) => column.width === void 0)) {
        columns = [];
      }
    }
    const getPropsData = (column) => {
      const propsData = {
        key: `${props.tableLayout}_${column.id}`,
        style: {},
        name: void 0
      };
      if (isAuto) {
        propsData.style = {
          width: `${column.width}px`
        };
      } else {
        propsData.name = column.id;
      }
      return propsData;
    };
    return Vue.h("colgroup", {}, columns.map((column) => Vue.h("col", getPropsData(column))));
  }
  hColgroup.props = ["columns", "tableLayout"];
  function useMapState() {
    const table = Vue.inject(TABLE_INJECTION_KEY);
    const store = table == null ? void 0 : table.store;
    const leftFixedLeafCount = Vue.computed(() => {
      return store.states.fixedLeafColumnsLength.value;
    });
    const rightFixedLeafCount = Vue.computed(() => {
      return store.states.rightFixedColumns.value.length;
    });
    const columnsCount = Vue.computed(() => {
      return store.states.columns.value.length;
    });
    const leftFixedCount = Vue.computed(() => {
      return store.states.fixedColumns.value.length;
    });
    const rightFixedCount = Vue.computed(() => {
      return store.states.rightFixedColumns.value.length;
    });
    return {
      leftFixedLeafCount,
      rightFixedLeafCount,
      columnsCount,
      leftFixedCount,
      rightFixedCount,
      columns: store.states.columns
    };
  }
  function useStyle$1(props) {
    const { columns } = useMapState();
    const ns2 = useNamespace("table");
    const getCellClasses = (columns2, cellIndex) => {
      const column = columns2[cellIndex];
      const classes = [
        ns2.e("cell"),
        column.id,
        column.align,
        column.labelClassName,
        ...getFixedColumnsClass(ns2.b(), cellIndex, column.fixed, props.store)
      ];
      if (column.className) {
        classes.push(column.className);
      }
      if (!column.children) {
        classes.push(ns2.is("leaf"));
      }
      return classes;
    };
    const getCellStyles = (column, cellIndex) => {
      const fixedStyle = getFixedColumnOffset(cellIndex, column.fixed, props.store);
      ensurePosition(fixedStyle, "left");
      ensurePosition(fixedStyle, "right");
      return fixedStyle;
    };
    return {
      getCellClasses,
      getCellStyles,
      columns
    };
  }
  var TableFooter = Vue.defineComponent({
    name: "ElTableFooter",
    props: {
      fixed: {
        type: String,
        default: ""
      },
      store: {
        required: true,
        type: Object
      },
      summaryMethod: Function,
      sumText: String,
      border: Boolean,
      defaultSort: {
        type: Object,
        default: () => {
          return {
            prop: "",
            order: ""
          };
        }
      }
    },
    setup(props) {
      const { getCellClasses, getCellStyles, columns } = useStyle$1(props);
      const ns2 = useNamespace("table");
      return {
        ns: ns2,
        getCellClasses,
        getCellStyles,
        columns
      };
    },
    render() {
      const {
        columns,
        getCellStyles,
        getCellClasses,
        summaryMethod,
        sumText,
        ns: ns2
      } = this;
      const data = this.store.states.data.value;
      let sums = [];
      if (summaryMethod) {
        sums = summaryMethod({
          columns,
          data
        });
      } else {
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = sumText;
            return;
          }
          const values = data.map((item) => Number(item[column.property]));
          const precisions = [];
          let notNumber = true;
          values.forEach((value) => {
            if (!Number.isNaN(+value)) {
              notNumber = false;
              const decimal = `${value}`.split(".")[1];
              precisions.push(decimal ? decimal.length : 0);
            }
          });
          const precision = Math.max.apply(null, precisions);
          if (!notNumber) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!Number.isNaN(+value)) {
                return Number.parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
              } else {
                return prev;
              }
            }, 0);
          } else {
            sums[index] = "";
          }
        });
      }
      return Vue.h("table", {
        class: ns2.e("footer"),
        cellspacing: "0",
        cellpadding: "0",
        border: "0"
      }, [
        hColgroup({
          columns
        }),
        Vue.h("tbody", [
          Vue.h("tr", {}, [
            ...columns.map((column, cellIndex) => Vue.h("td", {
              key: cellIndex,
              colspan: column.colSpan,
              rowspan: column.rowSpan,
              class: getCellClasses(columns, cellIndex),
              style: getCellStyles(column, cellIndex)
            }, [
              Vue.h("div", {
                class: ["cell", column.labelClassName]
              }, [sums[cellIndex]])
            ]))
          ])
        ])
      ]);
    }
  });
  function useUtils(store) {
    const setCurrentRow = (row) => {
      store.commit("setCurrentRow", row);
    };
    const getSelectionRows = () => {
      return store.getSelectionRows();
    };
    const toggleRowSelection = (row, selected) => {
      store.toggleRowSelection(row, selected, false);
      store.updateAllSelected();
    };
    const clearSelection = () => {
      store.clearSelection();
    };
    const clearFilter = (columnKeys) => {
      store.clearFilter(columnKeys);
    };
    const toggleAllSelection = () => {
      store.commit("toggleAllSelection");
    };
    const toggleRowExpansion = (row, expanded) => {
      store.toggleRowExpansionAdapter(row, expanded);
    };
    const clearSort = () => {
      store.clearSort();
    };
    const sort = (prop, order) => {
      store.commit("sort", { prop, order });
    };
    return {
      setCurrentRow,
      getSelectionRows,
      toggleRowSelection,
      clearSelection,
      clearFilter,
      toggleAllSelection,
      toggleRowExpansion,
      clearSort,
      sort
    };
  }
  function useStyle(props, layout, store, table) {
    const isHidden2 = Vue.ref(false);
    const renderExpanded = Vue.ref(null);
    const resizeProxyVisible = Vue.ref(false);
    const setDragVisible = (visible) => {
      resizeProxyVisible.value = visible;
    };
    const resizeState = Vue.ref({
      width: null,
      height: null,
      headerHeight: null
    });
    const isGroup = Vue.ref(false);
    const scrollbarViewStyle = {
      display: "inline-block",
      verticalAlign: "middle"
    };
    const tableWidth = Vue.ref();
    const tableScrollHeight = Vue.ref(0);
    const bodyScrollHeight = Vue.ref(0);
    const headerScrollHeight = Vue.ref(0);
    const footerScrollHeight = Vue.ref(0);
    Vue.watchEffect(() => {
      layout.setHeight(props.height);
    });
    Vue.watchEffect(() => {
      layout.setMaxHeight(props.maxHeight);
    });
    Vue.watch(() => [props.currentRowKey, store.states.rowKey], ([currentRowKey, rowKey]) => {
      if (!Vue.unref(rowKey) || !Vue.unref(currentRowKey))
        return;
      store.setCurrentRowKey(`${currentRowKey}`);
    }, {
      immediate: true
    });
    Vue.watch(() => props.data, (data) => {
      table.store.commit("setData", data);
    }, {
      immediate: true,
      deep: true
    });
    Vue.watchEffect(() => {
      if (props.expandRowKeys) {
        store.setExpandRowKeysAdapter(props.expandRowKeys);
      }
    });
    const handleMouseLeave = () => {
      table.store.commit("setHoverRow", null);
      if (table.hoverState)
        table.hoverState = null;
    };
    const handleHeaderFooterMousewheel = (event, data) => {
      const { pixelX, pixelY } = data;
      if (Math.abs(pixelX) >= Math.abs(pixelY)) {
        table.refs.bodyWrapper.scrollLeft += data.pixelX / 5;
      }
    };
    const shouldUpdateHeight = Vue.computed(() => {
      return props.height || props.maxHeight || store.states.fixedColumns.value.length > 0 || store.states.rightFixedColumns.value.length > 0;
    });
    const tableBodyStyles = Vue.computed(() => {
      return {
        width: layout.bodyWidth.value ? `${layout.bodyWidth.value}px` : ""
      };
    });
    const doLayout = () => {
      if (shouldUpdateHeight.value) {
        layout.updateElsHeight();
      }
      layout.updateColumnsWidth();
      requestAnimationFrame(syncPosition);
    };
    Vue.onMounted(async () => {
      await Vue.nextTick();
      store.updateColumns();
      bindEvents();
      requestAnimationFrame(doLayout);
      const el = table.vnode.el;
      const tableHeader = table.refs.headerWrapper;
      if (props.flexible && el && el.parentElement) {
        el.parentElement.style.minWidth = "0";
      }
      resizeState.value = {
        width: tableWidth.value = el.offsetWidth,
        height: el.offsetHeight,
        headerHeight: props.showHeader && tableHeader ? tableHeader.offsetHeight : null
      };
      store.states.columns.value.forEach((column) => {
        if (column.filteredValue && column.filteredValue.length) {
          table.store.commit("filterChange", {
            column,
            values: column.filteredValue,
            silent: true
          });
        }
      });
      table.$ready = true;
    });
    const setScrollClassByEl = (el, className) => {
      if (!el)
        return;
      const classList = Array.from(el.classList).filter((item) => !item.startsWith("is-scrolling-"));
      classList.push(layout.scrollX.value ? className : "is-scrolling-none");
      el.className = classList.join(" ");
    };
    const setScrollClass = (className) => {
      const { tableWrapper } = table.refs;
      setScrollClassByEl(tableWrapper, className);
    };
    const hasScrollClass = (className) => {
      const { tableWrapper } = table.refs;
      return !!(tableWrapper && tableWrapper.classList.contains(className));
    };
    const syncPosition = function() {
      if (!table.refs.scrollBarRef)
        return;
      if (!layout.scrollX.value) {
        const scrollingNoneClass = "is-scrolling-none";
        if (!hasScrollClass(scrollingNoneClass)) {
          setScrollClass(scrollingNoneClass);
        }
        return;
      }
      const scrollContainer = table.refs.scrollBarRef.wrapRef;
      if (!scrollContainer)
        return;
      const { scrollLeft, offsetWidth, scrollWidth } = scrollContainer;
      const { headerWrapper, footerWrapper } = table.refs;
      if (headerWrapper)
        headerWrapper.scrollLeft = scrollLeft;
      if (footerWrapper)
        footerWrapper.scrollLeft = scrollLeft;
      const maxScrollLeftPosition = scrollWidth - offsetWidth - 1;
      if (scrollLeft >= maxScrollLeftPosition) {
        setScrollClass("is-scrolling-right");
      } else if (scrollLeft === 0) {
        setScrollClass("is-scrolling-left");
      } else {
        setScrollClass("is-scrolling-middle");
      }
    };
    const bindEvents = () => {
      if (!table.refs.scrollBarRef)
        return;
      if (table.refs.scrollBarRef.wrapRef) {
        useEventListener(table.refs.scrollBarRef.wrapRef, "scroll", syncPosition, {
          passive: true
        });
      }
      if (props.fit) {
        useResizeObserver(table.vnode.el, resizeListener);
      } else {
        useEventListener(window, "resize", resizeListener);
      }
      useResizeObserver(table.refs.bodyWrapper, () => {
        var _a2, _b;
        resizeListener();
        (_b = (_a2 = table.refs) == null ? void 0 : _a2.scrollBarRef) == null ? void 0 : _b.update();
      });
    };
    const resizeListener = () => {
      var _a2, _b, _c;
      const el = table.vnode.el;
      if (!table.$ready || !el)
        return;
      let shouldUpdateLayout = false;
      const {
        width: oldWidth,
        height: oldHeight,
        headerHeight: oldHeaderHeight
      } = resizeState.value;
      const width = tableWidth.value = el.offsetWidth;
      if (oldWidth !== width) {
        shouldUpdateLayout = true;
      }
      const height = el.offsetHeight;
      if ((props.height || shouldUpdateHeight.value) && oldHeight !== height) {
        shouldUpdateLayout = true;
      }
      const tableHeader = props.tableLayout === "fixed" ? table.refs.headerWrapper : (_a2 = table.refs.tableHeaderRef) == null ? void 0 : _a2.$el;
      if (props.showHeader && (tableHeader == null ? void 0 : tableHeader.offsetHeight) !== oldHeaderHeight) {
        shouldUpdateLayout = true;
      }
      tableScrollHeight.value = ((_b = table.refs.tableWrapper) == null ? void 0 : _b.scrollHeight) || 0;
      headerScrollHeight.value = (tableHeader == null ? void 0 : tableHeader.scrollHeight) || 0;
      footerScrollHeight.value = ((_c = table.refs.footerWrapper) == null ? void 0 : _c.offsetHeight) || 0;
      bodyScrollHeight.value = tableScrollHeight.value - headerScrollHeight.value - footerScrollHeight.value;
      if (shouldUpdateLayout) {
        resizeState.value = {
          width,
          height,
          headerHeight: props.showHeader && (tableHeader == null ? void 0 : tableHeader.offsetHeight) || 0
        };
        doLayout();
      }
    };
    const tableSize = useSize();
    const bodyWidth = Vue.computed(() => {
      const { bodyWidth: bodyWidth_, scrollY, gutterWidth } = layout;
      return bodyWidth_.value ? `${bodyWidth_.value - (scrollY.value ? gutterWidth : 0)}px` : "";
    });
    const tableLayout = Vue.computed(() => {
      if (props.maxHeight)
        return "fixed";
      return props.tableLayout;
    });
    const emptyBlockStyle = Vue.computed(() => {
      if (props.data && props.data.length)
        return null;
      let height = "100%";
      if (props.height && bodyScrollHeight.value) {
        height = `${bodyScrollHeight.value}px`;
      }
      const width = tableWidth.value;
      return {
        width: width ? `${width}px` : "",
        height
      };
    });
    const tableInnerStyle = Vue.computed(() => {
      if (props.height) {
        return {
          height: !Number.isNaN(Number(props.height)) ? `${props.height}px` : props.height
        };
      }
      if (props.maxHeight) {
        return {
          maxHeight: !Number.isNaN(Number(props.maxHeight)) ? `${props.maxHeight}px` : props.maxHeight
        };
      }
      return {};
    });
    const scrollbarStyle = Vue.computed(() => {
      if (props.height) {
        return {
          height: "100%"
        };
      }
      if (props.maxHeight) {
        if (!Number.isNaN(Number(props.maxHeight))) {
          const maxHeight = props.maxHeight;
          const reachMaxHeight = tableScrollHeight.value >= Number(maxHeight);
          if (reachMaxHeight) {
            return {
              maxHeight: `${tableScrollHeight.value - headerScrollHeight.value - footerScrollHeight.value}px`
            };
          }
        } else {
          return {
            maxHeight: `calc(${props.maxHeight} - ${headerScrollHeight.value + footerScrollHeight.value}px)`
          };
        }
      }
      return {};
    });
    const handleFixedMousewheel = (event, data) => {
      const bodyWrapper = table.refs.bodyWrapper;
      if (Math.abs(data.spinY) > 0) {
        const currentScrollTop = bodyWrapper.scrollTop;
        if (data.pixelY < 0 && currentScrollTop !== 0) {
          event.preventDefault();
        }
        if (data.pixelY > 0 && bodyWrapper.scrollHeight - bodyWrapper.clientHeight > currentScrollTop) {
          event.preventDefault();
        }
        bodyWrapper.scrollTop += Math.ceil(data.pixelY / 5);
      } else {
        bodyWrapper.scrollLeft += Math.ceil(data.pixelX / 5);
      }
    };
    return {
      isHidden: isHidden2,
      renderExpanded,
      setDragVisible,
      isGroup,
      handleMouseLeave,
      handleHeaderFooterMousewheel,
      tableSize,
      emptyBlockStyle,
      handleFixedMousewheel,
      resizeProxyVisible,
      bodyWidth,
      resizeState,
      doLayout,
      tableBodyStyles,
      tableLayout,
      scrollbarViewStyle,
      tableInnerStyle,
      scrollbarStyle
    };
  }
  var defaultProps$1 = {
    data: {
      type: Array,
      default: () => []
    },
    size: String,
    width: [String, Number],
    height: [String, Number],
    maxHeight: [String, Number],
    fit: {
      type: Boolean,
      default: true
    },
    stripe: Boolean,
    border: Boolean,
    rowKey: [String, Function],
    showHeader: {
      type: Boolean,
      default: true
    },
    showSummary: Boolean,
    sumText: String,
    summaryMethod: Function,
    rowClassName: [String, Function],
    rowStyle: [Object, Function],
    cellClassName: [String, Function],
    cellStyle: [Object, Function],
    headerRowClassName: [String, Function],
    headerRowStyle: [Object, Function],
    headerCellClassName: [String, Function],
    headerCellStyle: [Object, Function],
    highlightCurrentRow: Boolean,
    currentRowKey: [String, Number],
    emptyText: String,
    expandRowKeys: Array,
    defaultExpandAll: Boolean,
    defaultSort: Object,
    tooltipEffect: String,
    tooltipOptions: Object,
    spanMethod: Function,
    selectOnIndeterminate: {
      type: Boolean,
      default: true
    },
    indent: {
      type: Number,
      default: 16
    },
    treeProps: {
      type: Object,
      default: () => {
        return {
          hasChildren: "hasChildren",
          children: "children"
        };
      }
    },
    lazy: Boolean,
    load: Function,
    style: {
      type: Object,
      default: () => ({})
    },
    className: {
      type: String,
      default: ""
    },
    tableLayout: {
      type: String,
      default: "fixed"
    },
    scrollbarAlwaysOn: {
      type: Boolean,
      default: false
    },
    flexible: Boolean
  };
  const useScrollbar = () => {
    const scrollBarRef = Vue.ref();
    const scrollTo = (options, yCoord) => {
      const scrollbar = scrollBarRef.value;
      if (scrollbar) {
        scrollbar.scrollTo(options, yCoord);
      }
    };
    const setScrollPosition = (position, offset) => {
      const scrollbar = scrollBarRef.value;
      if (scrollbar && isNumber(offset) && ["Top", "Left"].includes(position)) {
        scrollbar[`setScroll${position}`](offset);
      }
    };
    const setScrollTop = (top) => setScrollPosition("Top", top);
    const setScrollLeft = (left) => setScrollPosition("Left", left);
    return {
      scrollBarRef,
      scrollTo,
      setScrollTop,
      setScrollLeft
    };
  };
  let tableIdSeed = 1;
  const _sfc_main$4 = Vue.defineComponent({
    name: "ElTable",
    directives: {
      Mousewheel
    },
    components: {
      TableHeader,
      TableBody,
      TableFooter,
      ElScrollbar,
      hColgroup
    },
    props: defaultProps$1,
    emits: [
      "select",
      "select-all",
      "selection-change",
      "cell-mouse-enter",
      "cell-mouse-leave",
      "cell-contextmenu",
      "cell-click",
      "cell-dblclick",
      "row-click",
      "row-contextmenu",
      "row-dblclick",
      "header-click",
      "header-contextmenu",
      "sort-change",
      "filter-change",
      "current-change",
      "header-dragend",
      "expand-change"
    ],
    setup(props) {
      const { t } = useLocale();
      const ns2 = useNamespace("table");
      const table = Vue.getCurrentInstance();
      Vue.provide(TABLE_INJECTION_KEY, table);
      const store = createStore(table, props);
      table.store = store;
      const layout = new TableLayout({
        store: table.store,
        table,
        fit: props.fit,
        showHeader: props.showHeader
      });
      table.layout = layout;
      const isEmpty = Vue.computed(() => (store.states.data.value || []).length === 0);
      const {
        setCurrentRow,
        getSelectionRows,
        toggleRowSelection,
        clearSelection,
        clearFilter,
        toggleAllSelection,
        toggleRowExpansion,
        clearSort,
        sort
      } = useUtils(store);
      const {
        isHidden: isHidden2,
        renderExpanded,
        setDragVisible,
        isGroup,
        handleMouseLeave,
        handleHeaderFooterMousewheel,
        tableSize,
        emptyBlockStyle,
        handleFixedMousewheel,
        resizeProxyVisible,
        bodyWidth,
        resizeState,
        doLayout,
        tableBodyStyles,
        tableLayout,
        scrollbarViewStyle,
        tableInnerStyle,
        scrollbarStyle
      } = useStyle(props, layout, store, table);
      const { scrollBarRef, scrollTo, setScrollLeft, setScrollTop } = useScrollbar();
      const debouncedUpdateLayout = debounce(doLayout, 50);
      const tableId = `${ns2.namespace.value}-table_${tableIdSeed++}`;
      table.tableId = tableId;
      table.state = {
        isGroup,
        resizeState,
        doLayout,
        debouncedUpdateLayout
      };
      const computedSumText = Vue.computed(() => props.sumText || t("el.table.sumText"));
      const computedEmptyText = Vue.computed(() => {
        return props.emptyText || t("el.table.emptyText");
      });
      return {
        ns: ns2,
        layout,
        store,
        handleHeaderFooterMousewheel,
        handleMouseLeave,
        tableId,
        tableSize,
        isHidden: isHidden2,
        isEmpty,
        renderExpanded,
        resizeProxyVisible,
        resizeState,
        isGroup,
        bodyWidth,
        tableBodyStyles,
        emptyBlockStyle,
        debouncedUpdateLayout,
        handleFixedMousewheel,
        setCurrentRow,
        getSelectionRows,
        toggleRowSelection,
        clearSelection,
        clearFilter,
        toggleAllSelection,
        toggleRowExpansion,
        clearSort,
        doLayout,
        sort,
        t,
        setDragVisible,
        context: table,
        computedSumText,
        computedEmptyText,
        tableLayout,
        scrollbarViewStyle,
        tableInnerStyle,
        scrollbarStyle,
        scrollBarRef,
        scrollTo,
        setScrollLeft,
        setScrollTop
      };
    }
  });
  const _hoisted_1$3 = ["data-prefix"];
  const _hoisted_2$2 = {
    ref: "hiddenColumns",
    class: "hidden-columns"
  };
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
    const _component_hColgroup = Vue.resolveComponent("hColgroup");
    const _component_table_header = Vue.resolveComponent("table-header");
    const _component_table_body = Vue.resolveComponent("table-body");
    const _component_el_scrollbar = Vue.resolveComponent("el-scrollbar");
    const _component_table_footer = Vue.resolveComponent("table-footer");
    const _directive_mousewheel = Vue.resolveDirective("mousewheel");
    return Vue.openBlock(), Vue.createElementBlock("div", {
      ref: "tableWrapper",
      class: Vue.normalizeClass([
        {
          [_ctx.ns.m("fit")]: _ctx.fit,
          [_ctx.ns.m("striped")]: _ctx.stripe,
          [_ctx.ns.m("border")]: _ctx.border || _ctx.isGroup,
          [_ctx.ns.m("hidden")]: _ctx.isHidden,
          [_ctx.ns.m("group")]: _ctx.isGroup,
          [_ctx.ns.m("fluid-height")]: _ctx.maxHeight,
          [_ctx.ns.m("scrollable-x")]: _ctx.layout.scrollX.value,
          [_ctx.ns.m("scrollable-y")]: _ctx.layout.scrollY.value,
          [_ctx.ns.m("enable-row-hover")]: !_ctx.store.states.isComplex.value,
          [_ctx.ns.m("enable-row-transition")]: (_ctx.store.states.data.value || []).length !== 0 && (_ctx.store.states.data.value || []).length < 100,
          "has-footer": _ctx.showSummary
        },
        _ctx.ns.m(_ctx.tableSize),
        _ctx.className,
        _ctx.ns.b(),
        _ctx.ns.m(`layout-${_ctx.tableLayout}`)
      ]),
      style: Vue.normalizeStyle(_ctx.style),
      "data-prefix": _ctx.ns.namespace.value,
      onMouseleave: _cache[0] || (_cache[0] = ($event) => _ctx.handleMouseLeave())
    }, [
      Vue.createElementVNode("div", {
        class: Vue.normalizeClass(_ctx.ns.e("inner-wrapper")),
        style: Vue.normalizeStyle(_ctx.tableInnerStyle)
      }, [
        Vue.createElementVNode("div", _hoisted_2$2, [
          Vue.renderSlot(_ctx.$slots, "default")
        ], 512),
        _ctx.showHeader && _ctx.tableLayout === "fixed" ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", {
          key: 0,
          ref: "headerWrapper",
          class: Vue.normalizeClass(_ctx.ns.e("header-wrapper"))
        }, [
          Vue.createElementVNode("table", {
            ref: "tableHeader",
            class: Vue.normalizeClass(_ctx.ns.e("header")),
            style: Vue.normalizeStyle(_ctx.tableBodyStyles),
            border: "0",
            cellpadding: "0",
            cellspacing: "0"
          }, [
            Vue.createVNode(_component_hColgroup, {
              columns: _ctx.store.states.columns.value,
              "table-layout": _ctx.tableLayout
            }, null, 8, ["columns", "table-layout"]),
            Vue.createVNode(_component_table_header, {
              ref: "tableHeaderRef",
              border: _ctx.border,
              "default-sort": _ctx.defaultSort,
              store: _ctx.store,
              onSetDragVisible: _ctx.setDragVisible
            }, null, 8, ["border", "default-sort", "store", "onSetDragVisible"])
          ], 6)
        ], 2)), [
          [_directive_mousewheel, _ctx.handleHeaderFooterMousewheel]
        ]) : Vue.createCommentVNode("v-if", true),
        Vue.createElementVNode("div", {
          ref: "bodyWrapper",
          class: Vue.normalizeClass(_ctx.ns.e("body-wrapper"))
        }, [
          Vue.createVNode(_component_el_scrollbar, {
            ref: "scrollBarRef",
            "view-style": _ctx.scrollbarViewStyle,
            "wrap-style": _ctx.scrollbarStyle,
            always: _ctx.scrollbarAlwaysOn
          }, {
            default: Vue.withCtx(() => [
              Vue.createElementVNode("table", {
                ref: "tableBody",
                class: Vue.normalizeClass(_ctx.ns.e("body")),
                cellspacing: "0",
                cellpadding: "0",
                border: "0",
                style: Vue.normalizeStyle({
                  width: _ctx.bodyWidth,
                  tableLayout: _ctx.tableLayout
                })
              }, [
                Vue.createVNode(_component_hColgroup, {
                  columns: _ctx.store.states.columns.value,
                  "table-layout": _ctx.tableLayout
                }, null, 8, ["columns", "table-layout"]),
                _ctx.showHeader && _ctx.tableLayout === "auto" ? (Vue.openBlock(), Vue.createBlock(_component_table_header, {
                  key: 0,
                  ref: "tableHeaderRef",
                  border: _ctx.border,
                  "default-sort": _ctx.defaultSort,
                  store: _ctx.store,
                  onSetDragVisible: _ctx.setDragVisible
                }, null, 8, ["border", "default-sort", "store", "onSetDragVisible"])) : Vue.createCommentVNode("v-if", true),
                Vue.createVNode(_component_table_body, {
                  context: _ctx.context,
                  highlight: _ctx.highlightCurrentRow,
                  "row-class-name": _ctx.rowClassName,
                  "tooltip-effect": _ctx.tooltipEffect,
                  "tooltip-options": _ctx.tooltipOptions,
                  "row-style": _ctx.rowStyle,
                  store: _ctx.store,
                  stripe: _ctx.stripe
                }, null, 8, ["context", "highlight", "row-class-name", "tooltip-effect", "tooltip-options", "row-style", "store", "stripe"])
              ], 6),
              _ctx.isEmpty ? (Vue.openBlock(), Vue.createElementBlock("div", {
                key: 0,
                ref: "emptyBlock",
                style: Vue.normalizeStyle(_ctx.emptyBlockStyle),
                class: Vue.normalizeClass(_ctx.ns.e("empty-block"))
              }, [
                Vue.createElementVNode("span", {
                  class: Vue.normalizeClass(_ctx.ns.e("empty-text"))
                }, [
                  Vue.renderSlot(_ctx.$slots, "empty", {}, () => [
                    Vue.createTextVNode(Vue.toDisplayString(_ctx.computedEmptyText), 1)
                  ])
                ], 2)
              ], 6)) : Vue.createCommentVNode("v-if", true),
              _ctx.$slots.append ? (Vue.openBlock(), Vue.createElementBlock("div", {
                key: 1,
                ref: "appendWrapper",
                class: Vue.normalizeClass(_ctx.ns.e("append-wrapper"))
              }, [
                Vue.renderSlot(_ctx.$slots, "append")
              ], 2)) : Vue.createCommentVNode("v-if", true)
            ]),
            _: 3
          }, 8, ["view-style", "wrap-style", "always"])
        ], 2),
        _ctx.showSummary ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", {
          key: 1,
          ref: "footerWrapper",
          class: Vue.normalizeClass(_ctx.ns.e("footer-wrapper"))
        }, [
          Vue.createVNode(_component_table_footer, {
            border: _ctx.border,
            "default-sort": _ctx.defaultSort,
            store: _ctx.store,
            style: Vue.normalizeStyle(_ctx.tableBodyStyles),
            "sum-text": _ctx.computedSumText,
            "summary-method": _ctx.summaryMethod
          }, null, 8, ["border", "default-sort", "store", "style", "sum-text", "summary-method"])
        ], 2)), [
          [Vue.vShow, !_ctx.isEmpty],
          [_directive_mousewheel, _ctx.handleHeaderFooterMousewheel]
        ]) : Vue.createCommentVNode("v-if", true),
        _ctx.border || _ctx.isGroup ? (Vue.openBlock(), Vue.createElementBlock("div", {
          key: 2,
          class: Vue.normalizeClass(_ctx.ns.e("border-left-patch"))
        }, null, 2)) : Vue.createCommentVNode("v-if", true)
      ], 6),
      Vue.withDirectives(Vue.createElementVNode("div", {
        ref: "resizeProxy",
        class: Vue.normalizeClass(_ctx.ns.e("column-resize-proxy"))
      }, null, 2), [
        [Vue.vShow, _ctx.resizeProxyVisible]
      ])
    ], 46, _hoisted_1$3);
  }
  var Table = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/table/src/table.vue"]]);
  const defaultClassNames = {
    selection: "table-column--selection",
    expand: "table__expand-column"
  };
  const cellStarts = {
    default: {
      order: ""
    },
    selection: {
      width: 48,
      minWidth: 48,
      realWidth: 48,
      order: ""
    },
    expand: {
      width: 48,
      minWidth: 48,
      realWidth: 48,
      order: ""
    },
    index: {
      width: 48,
      minWidth: 48,
      realWidth: 48,
      order: ""
    }
  };
  const getDefaultClassName = (type) => {
    return defaultClassNames[type] || "";
  };
  const cellForced = {
    selection: {
      renderHeader({ store }) {
        function isDisabled() {
          return store.states.data.value && store.states.data.value.length === 0;
        }
        return Vue.h(ElCheckbox, {
          disabled: isDisabled(),
          size: store.states.tableSize.value,
          indeterminate: store.states.selection.value.length > 0 && !store.states.isAllSelected.value,
          "onUpdate:modelValue": store.toggleAllSelection,
          modelValue: store.states.isAllSelected.value
        });
      },
      renderCell({
        row,
        column,
        store,
        $index
      }) {
        return Vue.h(ElCheckbox, {
          disabled: column.selectable ? !column.selectable.call(null, row, $index) : false,
          size: store.states.tableSize.value,
          onChange: () => {
            store.commit("rowSelectedChanged", row);
          },
          onClick: (event) => event.stopPropagation(),
          modelValue: store.isSelected(row)
        });
      },
      sortable: false,
      resizable: false
    },
    index: {
      renderHeader({ column }) {
        return column.label || "#";
      },
      renderCell({
        column,
        $index
      }) {
        let i = $index + 1;
        const index = column.index;
        if (typeof index === "number") {
          i = $index + index;
        } else if (typeof index === "function") {
          i = index($index);
        }
        return Vue.h("div", {}, [i]);
      },
      sortable: false
    },
    expand: {
      renderHeader({ column }) {
        return column.label || "";
      },
      renderCell({
        row,
        store,
        expanded
      }) {
        const { ns: ns2 } = store;
        const classes = [ns2.e("expand-icon")];
        if (expanded) {
          classes.push(ns2.em("expand-icon", "expanded"));
        }
        const callback = function(e) {
          e.stopPropagation();
          store.toggleRowExpansion(row);
        };
        return Vue.h("div", {
          class: classes,
          onClick: callback
        }, {
          default: () => {
            return [
              Vue.h(ElIcon, null, {
                default: () => {
                  return [Vue.h(arrow_right_default)];
                }
              })
            ];
          }
        });
      },
      sortable: false,
      resizable: false
    }
  };
  function defaultRenderCell({
    row,
    column,
    $index
  }) {
    var _a2;
    const property2 = column.property;
    const value = property2 && getProp(row, property2).value;
    if (column && column.formatter) {
      return column.formatter(row, column, value, $index);
    }
    return ((_a2 = value == null ? void 0 : value.toString) == null ? void 0 : _a2.call(value)) || "";
  }
  function treeCellPrefix({
    row,
    treeNode,
    store
  }, createPlacehoder = false) {
    const { ns: ns2 } = store;
    if (!treeNode) {
      if (createPlacehoder) {
        return [
          Vue.h("span", {
            class: ns2.e("placeholder")
          })
        ];
      }
      return null;
    }
    const ele = [];
    const callback = function(e) {
      e.stopPropagation();
      if (treeNode.loading) {
        return;
      }
      store.loadOrToggle(row);
    };
    if (treeNode.indent) {
      ele.push(Vue.h("span", {
        class: ns2.e("indent"),
        style: { "padding-left": `${treeNode.indent}px` }
      }));
    }
    if (typeof treeNode.expanded === "boolean" && !treeNode.noLazyChildren) {
      const expandClasses = [
        ns2.e("expand-icon"),
        treeNode.expanded ? ns2.em("expand-icon", "expanded") : ""
      ];
      let icon = arrow_right_default;
      if (treeNode.loading) {
        icon = loading_default;
      }
      ele.push(Vue.h("div", {
        class: expandClasses,
        onClick: callback
      }, {
        default: () => {
          return [
            Vue.h(ElIcon, { class: { [ns2.is("loading")]: treeNode.loading } }, {
              default: () => [Vue.h(icon)]
            })
          ];
        }
      }));
    } else {
      ele.push(Vue.h("span", {
        class: ns2.e("placeholder")
      }));
    }
    return ele;
  }
  function getAllAliases(props, aliases) {
    return props.reduce((prev, cur) => {
      prev[cur] = cur;
      return prev;
    }, aliases);
  }
  function useWatcher(owner, props_) {
    const instance = Vue.getCurrentInstance();
    const registerComplexWatchers = () => {
      const props = ["fixed"];
      const aliases = {
        realWidth: "width",
        realMinWidth: "minWidth"
      };
      const allAliases = getAllAliases(props, aliases);
      Object.keys(allAliases).forEach((key) => {
        const columnKey = aliases[key];
        if (hasOwn(props_, columnKey)) {
          Vue.watch(() => props_[columnKey], (newVal) => {
            let value = newVal;
            if (columnKey === "width" && key === "realWidth") {
              value = parseWidth(newVal);
            }
            if (columnKey === "minWidth" && key === "realMinWidth") {
              value = parseMinWidth(newVal);
            }
            instance.columnConfig.value[columnKey] = value;
            instance.columnConfig.value[key] = value;
            const updateColumns = columnKey === "fixed";
            owner.value.store.scheduleLayout(updateColumns);
          });
        }
      });
    };
    const registerNormalWatchers = () => {
      const props = [
        "label",
        "filters",
        "filterMultiple",
        "sortable",
        "index",
        "formatter",
        "className",
        "labelClassName",
        "showOverflowTooltip"
      ];
      const aliases = {
        property: "prop",
        align: "realAlign",
        headerAlign: "realHeaderAlign"
      };
      const allAliases = getAllAliases(props, aliases);
      Object.keys(allAliases).forEach((key) => {
        const columnKey = aliases[key];
        if (hasOwn(props_, columnKey)) {
          Vue.watch(() => props_[columnKey], (newVal) => {
            instance.columnConfig.value[key] = newVal;
          });
        }
      });
    };
    return {
      registerComplexWatchers,
      registerNormalWatchers
    };
  }
  function useRender(props, slots, owner) {
    const instance = Vue.getCurrentInstance();
    const columnId = Vue.ref("");
    const isSubColumn = Vue.ref(false);
    const realAlign = Vue.ref();
    const realHeaderAlign = Vue.ref();
    const ns2 = useNamespace("table");
    Vue.watchEffect(() => {
      realAlign.value = props.align ? `is-${props.align}` : null;
      realAlign.value;
    });
    Vue.watchEffect(() => {
      realHeaderAlign.value = props.headerAlign ? `is-${props.headerAlign}` : realAlign.value;
      realHeaderAlign.value;
    });
    const columnOrTableParent = Vue.computed(() => {
      let parent = instance.vnode.vParent || instance.parent;
      while (parent && !parent.tableId && !parent.columnId) {
        parent = parent.vnode.vParent || parent.parent;
      }
      return parent;
    });
    const hasTreeColumn = Vue.computed(() => {
      const { store } = instance.parent;
      if (!store)
        return false;
      const { treeData } = store.states;
      const treeDataValue = treeData.value;
      return treeDataValue && Object.keys(treeDataValue).length > 0;
    });
    const realWidth = Vue.ref(parseWidth(props.width));
    const realMinWidth = Vue.ref(parseMinWidth(props.minWidth));
    const setColumnWidth = (column) => {
      if (realWidth.value)
        column.width = realWidth.value;
      if (realMinWidth.value) {
        column.minWidth = realMinWidth.value;
      }
      if (!realWidth.value && realMinWidth.value) {
        column.width = void 0;
      }
      if (!column.minWidth) {
        column.minWidth = 80;
      }
      column.realWidth = Number(column.width === void 0 ? column.minWidth : column.width);
      return column;
    };
    const setColumnForcedProps = (column) => {
      const type = column.type;
      const source = cellForced[type] || {};
      Object.keys(source).forEach((prop) => {
        const value = source[prop];
        if (prop !== "className" && value !== void 0) {
          column[prop] = value;
        }
      });
      const className = getDefaultClassName(type);
      if (className) {
        const forceClass = `${Vue.unref(ns2.namespace)}-${className}`;
        column.className = column.className ? `${column.className} ${forceClass}` : forceClass;
      }
      return column;
    };
    const checkSubColumn = (children) => {
      if (Array.isArray(children)) {
        children.forEach((child) => check(child));
      } else {
        check(children);
      }
      function check(item) {
        var _a2;
        if (((_a2 = item == null ? void 0 : item.type) == null ? void 0 : _a2.name) === "ElTableColumn") {
          item.vParent = instance;
        }
      }
    };
    const setColumnRenders = (column) => {
      if (props.renderHeader) {
        debugWarn("TableColumn", "Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header.");
      } else if (column.type !== "selection") {
        column.renderHeader = (scope) => {
          instance.columnConfig.value["label"];
          const renderHeader = slots.header;
          return renderHeader ? renderHeader(scope) : column.label;
        };
      }
      let originRenderCell = column.renderCell;
      if (column.type === "expand") {
        column.renderCell = (data) => Vue.h("div", {
          class: "cell"
        }, [originRenderCell(data)]);
        owner.value.renderExpanded = (data) => {
          return slots.default ? slots.default(data) : slots.default;
        };
      } else {
        originRenderCell = originRenderCell || defaultRenderCell;
        column.renderCell = (data) => {
          let children = null;
          if (slots.default) {
            const vnodes = slots.default(data);
            children = vnodes.some((v2) => v2.type !== Vue.Comment) ? vnodes : originRenderCell(data);
          } else {
            children = originRenderCell(data);
          }
          const shouldCreatePlaceholder = hasTreeColumn.value && data.cellIndex === 0 && data.column.type !== "selection";
          const prefix = treeCellPrefix(data, shouldCreatePlaceholder);
          const props2 = {
            class: "cell",
            style: {}
          };
          if (column.showOverflowTooltip) {
            props2.class = `${props2.class} ${Vue.unref(ns2.namespace)}-tooltip`;
            props2.style = {
              width: `${(data.column.realWidth || Number(data.column.width)) - 1}px`
            };
          }
          checkSubColumn(children);
          return Vue.h("div", props2, [prefix, children]);
        };
      }
      return column;
    };
    const getPropsData = (...propsKey) => {
      return propsKey.reduce((prev, cur) => {
        if (Array.isArray(cur)) {
          cur.forEach((key) => {
            prev[key] = props[key];
          });
        }
        return prev;
      }, {});
    };
    const getColumnElIndex = (children, child) => {
      return Array.prototype.indexOf.call(children, child);
    };
    return {
      columnId,
      realAlign,
      isSubColumn,
      realHeaderAlign,
      columnOrTableParent,
      setColumnWidth,
      setColumnForcedProps,
      setColumnRenders,
      getPropsData,
      getColumnElIndex
    };
  }
  var defaultProps = {
    type: {
      type: String,
      default: "default"
    },
    label: String,
    className: String,
    labelClassName: String,
    property: String,
    prop: String,
    width: {
      type: [String, Number],
      default: ""
    },
    minWidth: {
      type: [String, Number],
      default: ""
    },
    renderHeader: Function,
    sortable: {
      type: [Boolean, String],
      default: false
    },
    sortMethod: Function,
    sortBy: [String, Function, Array],
    resizable: {
      type: Boolean,
      default: true
    },
    columnKey: String,
    align: String,
    headerAlign: String,
    showOverflowTooltip: [Boolean, Object],
    fixed: [Boolean, String],
    formatter: Function,
    selectable: Function,
    reserveSelection: Boolean,
    filterMethod: Function,
    filteredValue: Array,
    filters: Array,
    filterPlacement: String,
    filterMultiple: {
      type: Boolean,
      default: true
    },
    index: [Number, Function],
    sortOrders: {
      type: Array,
      default: () => {
        return ["ascending", "descending", null];
      },
      validator: (val) => {
        return val.every((order) => ["ascending", "descending", null].includes(order));
      }
    }
  };
  let columnIdSeed = 1;
  var ElTableColumn$1 = Vue.defineComponent({
    name: "ElTableColumn",
    components: {
      ElCheckbox
    },
    props: defaultProps,
    setup(props, { slots }) {
      const instance = Vue.getCurrentInstance();
      const columnConfig = Vue.ref({});
      const owner = Vue.computed(() => {
        let parent2 = instance.parent;
        while (parent2 && !parent2.tableId) {
          parent2 = parent2.parent;
        }
        return parent2;
      });
      const { registerNormalWatchers, registerComplexWatchers } = useWatcher(owner, props);
      const {
        columnId,
        isSubColumn,
        realHeaderAlign,
        columnOrTableParent,
        setColumnWidth,
        setColumnForcedProps,
        setColumnRenders,
        getPropsData,
        getColumnElIndex,
        realAlign
      } = useRender(props, slots, owner);
      const parent = columnOrTableParent.value;
      columnId.value = `${parent.tableId || parent.columnId}_column_${columnIdSeed++}`;
      Vue.onBeforeMount(() => {
        isSubColumn.value = owner.value !== parent;
        const type = props.type || "default";
        const sortable = props.sortable === "" ? true : props.sortable;
        const defaults = __spreadProps(__spreadValues({}, cellStarts[type]), {
          id: columnId.value,
          type,
          property: props.prop || props.property,
          align: realAlign,
          headerAlign: realHeaderAlign,
          showOverflowTooltip: props.showOverflowTooltip,
          filterable: props.filters || props.filterMethod,
          filteredValue: [],
          filterPlacement: "",
          isColumnGroup: false,
          isSubColumn: false,
          filterOpened: false,
          sortable,
          index: props.index,
          rawColumnKey: instance.vnode.key
        });
        const basicProps = [
          "columnKey",
          "label",
          "className",
          "labelClassName",
          "type",
          "renderHeader",
          "formatter",
          "fixed",
          "resizable"
        ];
        const sortProps = ["sortMethod", "sortBy", "sortOrders"];
        const selectProps = ["selectable", "reserveSelection"];
        const filterProps = [
          "filterMethod",
          "filters",
          "filterMultiple",
          "filterOpened",
          "filteredValue",
          "filterPlacement"
        ];
        let column = getPropsData(basicProps, sortProps, selectProps, filterProps);
        column = mergeOptions(defaults, column);
        const chains = compose(setColumnRenders, setColumnWidth, setColumnForcedProps);
        column = chains(column);
        columnConfig.value = column;
        registerNormalWatchers();
        registerComplexWatchers();
      });
      Vue.onMounted(() => {
        var _a2;
        const parent2 = columnOrTableParent.value;
        const children = isSubColumn.value ? parent2.vnode.el.children : (_a2 = parent2.refs.hiddenColumns) == null ? void 0 : _a2.children;
        const getColumnIndex = () => getColumnElIndex(children || [], instance.vnode.el);
        columnConfig.value.getColumnIndex = getColumnIndex;
        const columnIndex = getColumnIndex();
        columnIndex > -1 && owner.value.store.commit("insertColumn", columnConfig.value, isSubColumn.value ? parent2.columnConfig.value : null);
      });
      Vue.onBeforeUnmount(() => {
        owner.value.store.commit("removeColumn", columnConfig.value, isSubColumn.value ? parent.columnConfig.value : null);
      });
      instance.columnId = columnId.value;
      instance.columnConfig = columnConfig;
      return;
    },
    render() {
      var _a2, _b, _c;
      try {
        const renderDefault = (_b = (_a2 = this.$slots).default) == null ? void 0 : _b.call(_a2, {
          row: {},
          column: {},
          $index: -1
        });
        const children = [];
        if (Array.isArray(renderDefault)) {
          for (const childNode of renderDefault) {
            if (((_c = childNode.type) == null ? void 0 : _c.name) === "ElTableColumn" || childNode.shapeFlag & 2) {
              children.push(childNode);
            } else if (childNode.type === Vue.Fragment && Array.isArray(childNode.children)) {
              childNode.children.forEach((vnode2) => {
                if ((vnode2 == null ? void 0 : vnode2.patchFlag) !== 1024 && !isString$1(vnode2 == null ? void 0 : vnode2.children)) {
                  children.push(vnode2);
                }
              });
            }
          }
        }
        const vnode = Vue.h("div", children);
        return vnode;
      } catch (e) {
        return Vue.h("div", []);
      }
    }
  });
  const ElTable = withInstall(Table, {
    TableColumn: ElTableColumn$1
  });
  const ElTableColumn = withNoopInstall(ElTableColumn$1);
  const SCOPE$1 = "ElUpload";
  class UploadAjaxError extends Error {
    constructor(message, status, method, url) {
      super(message);
      this.name = "UploadAjaxError";
      this.status = status;
      this.method = method;
      this.url = url;
    }
  }
  function getError(action, option, xhr) {
    let msg;
    if (xhr.response) {
      msg = `${xhr.response.error || xhr.response}`;
    } else if (xhr.responseText) {
      msg = `${xhr.responseText}`;
    } else {
      msg = `fail to ${option.method} ${action} ${xhr.status}`;
    }
    return new UploadAjaxError(msg, xhr.status, option.method, action);
  }
  function getBody(xhr) {
    const text = xhr.responseText || xhr.response;
    if (!text) {
      return text;
    }
    try {
      return JSON.parse(text);
    } catch (e) {
      return text;
    }
  }
  const ajaxUpload = (option) => {
    if (typeof XMLHttpRequest === "undefined")
      throwError(SCOPE$1, "XMLHttpRequest is undefined");
    const xhr = new XMLHttpRequest();
    const action = option.action;
    if (xhr.upload) {
      xhr.upload.addEventListener("progress", (evt) => {
        const progressEvt = evt;
        progressEvt.percent = evt.total > 0 ? evt.loaded / evt.total * 100 : 0;
        option.onProgress(progressEvt);
      });
    }
    const formData = new FormData();
    if (option.data) {
      for (const [key, value] of Object.entries(option.data)) {
        if (Array.isArray(value))
          formData.append(key, ...value);
        else
          formData.append(key, value);
      }
    }
    formData.append(option.filename, option.file, option.file.name);
    xhr.addEventListener("error", () => {
      option.onError(getError(action, option, xhr));
    });
    xhr.addEventListener("load", () => {
      if (xhr.status < 200 || xhr.status >= 300) {
        return option.onError(getError(action, option, xhr));
      }
      option.onSuccess(getBody(xhr));
    });
    xhr.open(option.method, action, true);
    if (option.withCredentials && "withCredentials" in xhr) {
      xhr.withCredentials = true;
    }
    const headers = option.headers || {};
    if (headers instanceof Headers) {
      headers.forEach((value, key) => xhr.setRequestHeader(key, value));
    } else {
      for (const [key, value] of Object.entries(headers)) {
        if (isNil(value))
          continue;
        xhr.setRequestHeader(key, String(value));
      }
    }
    xhr.send(formData);
    return xhr;
  };
  const uploadListTypes = ["text", "picture", "picture-card"];
  let fileId = 1;
  const genFileId = () => Date.now() + fileId++;
  const uploadBaseProps = buildProps({
    action: {
      type: String,
      default: "#"
    },
    headers: {
      type: definePropType(Object)
    },
    method: {
      type: String,
      default: "post"
    },
    data: {
      type: Object,
      default: () => mutable({})
    },
    multiple: {
      type: Boolean,
      default: false
    },
    name: {
      type: String,
      default: "file"
    },
    drag: {
      type: Boolean,
      default: false
    },
    withCredentials: Boolean,
    showFileList: {
      type: Boolean,
      default: true
    },
    accept: {
      type: String,
      default: ""
    },
    type: {
      type: String,
      default: "select"
    },
    fileList: {
      type: definePropType(Array),
      default: () => mutable([])
    },
    autoUpload: {
      type: Boolean,
      default: true
    },
    listType: {
      type: String,
      values: uploadListTypes,
      default: "text"
    },
    httpRequest: {
      type: definePropType(Function),
      default: ajaxUpload
    },
    disabled: Boolean,
    limit: Number
  });
  const uploadProps = buildProps(__spreadProps(__spreadValues({}, uploadBaseProps), {
    beforeUpload: {
      type: definePropType(Function),
      default: NOOP
    },
    beforeRemove: {
      type: definePropType(Function)
    },
    onRemove: {
      type: definePropType(Function),
      default: NOOP
    },
    onChange: {
      type: definePropType(Function),
      default: NOOP
    },
    onPreview: {
      type: definePropType(Function),
      default: NOOP
    },
    onSuccess: {
      type: definePropType(Function),
      default: NOOP
    },
    onProgress: {
      type: definePropType(Function),
      default: NOOP
    },
    onError: {
      type: definePropType(Function),
      default: NOOP
    },
    onExceed: {
      type: definePropType(Function),
      default: NOOP
    }
  }));
  const uploadListProps = buildProps({
    files: {
      type: definePropType(Array),
      default: () => mutable([])
    },
    disabled: {
      type: Boolean,
      default: false
    },
    handlePreview: {
      type: definePropType(Function),
      default: NOOP
    },
    listType: {
      type: String,
      values: uploadListTypes,
      default: "text"
    }
  });
  const uploadListEmits = {
    remove: (file) => !!file
  };
  const _hoisted_1$2 = ["onKeydown"];
  const _hoisted_2$1 = ["src"];
  const _hoisted_3 = ["onClick"];
  const _hoisted_4 = ["onClick"];
  const _hoisted_5 = ["onClick"];
  const __default__$3 = Vue.defineComponent({
    name: "ElUploadList"
  });
  const _sfc_main$3 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$3), {
    props: uploadListProps,
    emits: uploadListEmits,
    setup(__props, { emit }) {
      const { t } = useLocale();
      const nsUpload = useNamespace("upload");
      const nsIcon = useNamespace("icon");
      const nsList = useNamespace("list");
      const disabled = useDisabled();
      const focusing = Vue.ref(false);
      const handleRemove = (file) => {
        emit("remove", file);
      };
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createBlock(Vue.TransitionGroup, {
          tag: "ul",
          class: Vue.normalizeClass([
            Vue.unref(nsUpload).b("list"),
            Vue.unref(nsUpload).bm("list", _ctx.listType),
            Vue.unref(nsUpload).is("disabled", Vue.unref(disabled))
          ]),
          name: Vue.unref(nsList).b()
        }, {
          default: Vue.withCtx(() => [
            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(_ctx.files, (file) => {
              return Vue.openBlock(), Vue.createElementBlock("li", {
                key: file.uid || file.name,
                class: Vue.normalizeClass([
                  Vue.unref(nsUpload).be("list", "item"),
                  Vue.unref(nsUpload).is(file.status),
                  { focusing: focusing.value }
                ]),
                tabindex: "0",
                onKeydown: Vue.withKeys(($event) => !Vue.unref(disabled) && handleRemove(file), ["delete"]),
                onFocus: _cache[0] || (_cache[0] = ($event) => focusing.value = true),
                onBlur: _cache[1] || (_cache[1] = ($event) => focusing.value = false),
                onClick: _cache[2] || (_cache[2] = ($event) => focusing.value = false)
              }, [
                Vue.renderSlot(_ctx.$slots, "default", { file }, () => [
                  _ctx.listType === "picture" || file.status !== "uploading" && _ctx.listType === "picture-card" ? (Vue.openBlock(), Vue.createElementBlock("img", {
                    key: 0,
                    class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-thumbnail")),
                    src: file.url,
                    alt: ""
                  }, null, 10, _hoisted_2$1)) : Vue.createCommentVNode("v-if", true),
                  file.status === "uploading" || _ctx.listType !== "picture-card" ? (Vue.openBlock(), Vue.createElementBlock("div", {
                    key: 1,
                    class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-info"))
                  }, [
                    Vue.createElementVNode("a", {
                      class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-name")),
                      onClick: Vue.withModifiers(($event) => _ctx.handlePreview(file), ["prevent"])
                    }, [
                      Vue.createVNode(Vue.unref(ElIcon), {
                        class: Vue.normalizeClass(Vue.unref(nsIcon).m("document"))
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(Vue.unref(document_default))
                        ]),
                        _: 1
                      }, 8, ["class"]),
                      Vue.createElementVNode("span", {
                        class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-file-name"))
                      }, Vue.toDisplayString(file.name), 3)
                    ], 10, _hoisted_3),
                    file.status === "uploading" ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElProgress), {
                      key: 0,
                      type: _ctx.listType === "picture-card" ? "circle" : "line",
                      "stroke-width": _ctx.listType === "picture-card" ? 6 : 2,
                      percentage: Number(file.percentage),
                      style: Vue.normalizeStyle(_ctx.listType === "picture-card" ? "" : "margin-top: 0.5rem")
                    }, null, 8, ["type", "stroke-width", "percentage", "style"])) : Vue.createCommentVNode("v-if", true)
                  ], 2)) : Vue.createCommentVNode("v-if", true),
                  Vue.createElementVNode("label", {
                    class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-status-label"))
                  }, [
                    _ctx.listType === "text" ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                      key: 0,
                      class: Vue.normalizeClass([Vue.unref(nsIcon).m("upload-success"), Vue.unref(nsIcon).m("circle-check")])
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(Vue.unref(circle_check_default))
                      ]),
                      _: 1
                    }, 8, ["class"])) : ["picture-card", "picture"].includes(_ctx.listType) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                      key: 1,
                      class: Vue.normalizeClass([Vue.unref(nsIcon).m("upload-success"), Vue.unref(nsIcon).m("check")])
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(Vue.unref(check_default))
                      ]),
                      _: 1
                    }, 8, ["class"])) : Vue.createCommentVNode("v-if", true)
                  ], 2),
                  !Vue.unref(disabled) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(ElIcon), {
                    key: 2,
                    class: Vue.normalizeClass(Vue.unref(nsIcon).m("close")),
                    onClick: ($event) => handleRemove(file)
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(close_default))
                    ]),
                    _: 2
                  }, 1032, ["class", "onClick"])) : Vue.createCommentVNode("v-if", true),
                  Vue.createCommentVNode(" Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn"),
                  Vue.createCommentVNode(" This is a bug which needs to be fixed "),
                  Vue.createCommentVNode(" TODO: Fix the incorrect navigation interaction "),
                  !Vue.unref(disabled) ? (Vue.openBlock(), Vue.createElementBlock("i", {
                    key: 3,
                    class: Vue.normalizeClass(Vue.unref(nsIcon).m("close-tip"))
                  }, Vue.toDisplayString(Vue.unref(t)("el.upload.deleteTip")), 3)) : Vue.createCommentVNode("v-if", true),
                  _ctx.listType === "picture-card" ? (Vue.openBlock(), Vue.createElementBlock("span", {
                    key: 4,
                    class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-actions"))
                  }, [
                    Vue.createElementVNode("span", {
                      class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-preview")),
                      onClick: ($event) => _ctx.handlePreview(file)
                    }, [
                      Vue.createVNode(Vue.unref(ElIcon), {
                        class: Vue.normalizeClass(Vue.unref(nsIcon).m("zoom-in"))
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(Vue.unref(zoom_in_default))
                        ]),
                        _: 1
                      }, 8, ["class"])
                    ], 10, _hoisted_4),
                    !Vue.unref(disabled) ? (Vue.openBlock(), Vue.createElementBlock("span", {
                      key: 0,
                      class: Vue.normalizeClass(Vue.unref(nsUpload).be("list", "item-delete")),
                      onClick: ($event) => handleRemove(file)
                    }, [
                      Vue.createVNode(Vue.unref(ElIcon), {
                        class: Vue.normalizeClass(Vue.unref(nsIcon).m("delete"))
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(Vue.unref(delete_default))
                        ]),
                        _: 1
                      }, 8, ["class"])
                    ], 10, _hoisted_5)) : Vue.createCommentVNode("v-if", true)
                  ], 2)) : Vue.createCommentVNode("v-if", true)
                ])
              ], 42, _hoisted_1$2);
            }), 128)),
            Vue.renderSlot(_ctx.$slots, "append")
          ]),
          _: 3
        }, 8, ["class", "name"]);
      };
    }
  }));
  var UploadList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-list.vue"]]);
  const uploadDraggerProps = buildProps({
    disabled: {
      type: Boolean,
      default: false
    }
  });
  const uploadDraggerEmits = {
    file: (file) => isArray(file)
  };
  const _hoisted_1$1 = ["onDrop", "onDragover"];
  const COMPONENT_NAME = "ElUploadDrag";
  const __default__$2 = Vue.defineComponent({
    name: COMPONENT_NAME
  });
  const _sfc_main$2 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$2), {
    props: uploadDraggerProps,
    emits: uploadDraggerEmits,
    setup(__props, { emit }) {
      const uploaderContext = Vue.inject(uploadContextKey);
      if (!uploaderContext) {
        throwError(COMPONENT_NAME, "usage: <el-upload><el-upload-dragger /></el-upload>");
      }
      const ns2 = useNamespace("upload");
      const dragover = Vue.ref(false);
      const disabled = useDisabled();
      const onDrop = (e) => {
        if (disabled.value)
          return;
        dragover.value = false;
        const files = Array.from(e.dataTransfer.files);
        const accept = uploaderContext.accept.value;
        if (!accept) {
          emit("file", files);
          return;
        }
        const filesFiltered = files.filter((file) => {
          const { type, name } = file;
          const extension = name.includes(".") ? `.${name.split(".").pop()}` : "";
          const baseType = type.replace(/\/.*$/, "");
          return accept.split(",").map((type2) => type2.trim()).filter((type2) => type2).some((acceptedType) => {
            if (acceptedType.startsWith(".")) {
              return extension === acceptedType;
            }
            if (/\/\*$/.test(acceptedType)) {
              return baseType === acceptedType.replace(/\/\*$/, "");
            }
            if (/^[^/]+\/[^/]+$/.test(acceptedType)) {
              return type === acceptedType;
            }
            return false;
          });
        });
        emit("file", filesFiltered);
      };
      const onDragover = () => {
        if (!disabled.value)
          dragover.value = true;
      };
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          class: Vue.normalizeClass([Vue.unref(ns2).b("dragger"), Vue.unref(ns2).is("dragover", dragover.value)]),
          onDrop: Vue.withModifiers(onDrop, ["prevent"]),
          onDragover: Vue.withModifiers(onDragover, ["prevent"]),
          onDragleave: _cache[0] || (_cache[0] = Vue.withModifiers(($event) => dragover.value = false, ["prevent"]))
        }, [
          Vue.renderSlot(_ctx.$slots, "default")
        ], 42, _hoisted_1$1);
      };
    }
  }));
  var UploadDragger = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-dragger.vue"]]);
  const uploadContentProps = buildProps(__spreadProps(__spreadValues({}, uploadBaseProps), {
    beforeUpload: {
      type: definePropType(Function),
      default: NOOP
    },
    onRemove: {
      type: definePropType(Function),
      default: NOOP
    },
    onStart: {
      type: definePropType(Function),
      default: NOOP
    },
    onSuccess: {
      type: definePropType(Function),
      default: NOOP
    },
    onProgress: {
      type: definePropType(Function),
      default: NOOP
    },
    onError: {
      type: definePropType(Function),
      default: NOOP
    },
    onExceed: {
      type: definePropType(Function),
      default: NOOP
    }
  }));
  const _hoisted_1 = ["onKeydown"];
  const _hoisted_2 = ["name", "multiple", "accept"];
  const __default__$1 = Vue.defineComponent({
    name: "ElUploadContent",
    inheritAttrs: false
  });
  const _sfc_main$1 = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__$1), {
    props: uploadContentProps,
    setup(__props, { expose }) {
      const props = __props;
      const ns2 = useNamespace("upload");
      const disabled = useDisabled();
      const requests = Vue.shallowRef({});
      const inputRef = Vue.shallowRef();
      const uploadFiles = (files) => {
        if (files.length === 0)
          return;
        const { autoUpload, limit, fileList, multiple, onStart, onExceed } = props;
        if (limit && fileList.length + files.length > limit) {
          onExceed(files, fileList);
          return;
        }
        if (!multiple) {
          files = files.slice(0, 1);
        }
        for (const file of files) {
          const rawFile = file;
          rawFile.uid = genFileId();
          onStart(rawFile);
          if (autoUpload)
            upload(rawFile);
        }
      };
      const upload = async (rawFile) => {
        inputRef.value.value = "";
        if (!props.beforeUpload) {
          return doUpload(rawFile);
        }
        let hookResult;
        try {
          hookResult = await props.beforeUpload(rawFile);
        } catch (e) {
          hookResult = false;
        }
        if (hookResult === false) {
          props.onRemove(rawFile);
          return;
        }
        let file = rawFile;
        if (hookResult instanceof Blob) {
          if (hookResult instanceof File) {
            file = hookResult;
          } else {
            file = new File([hookResult], rawFile.name, {
              type: rawFile.type
            });
          }
        }
        doUpload(Object.assign(file, {
          uid: rawFile.uid
        }));
      };
      const doUpload = (rawFile) => {
        const {
          headers,
          data,
          method,
          withCredentials,
          name: filename,
          action,
          onProgress,
          onSuccess,
          onError,
          httpRequest
        } = props;
        const { uid } = rawFile;
        const options = {
          headers: headers || {},
          withCredentials,
          file: rawFile,
          data,
          method,
          filename,
          action,
          onProgress: (evt) => {
            onProgress(evt, rawFile);
          },
          onSuccess: (res) => {
            onSuccess(res, rawFile);
            delete requests.value[uid];
          },
          onError: (err) => {
            onError(err, rawFile);
            delete requests.value[uid];
          }
        };
        const request = httpRequest(options);
        requests.value[uid] = request;
        if (request instanceof Promise) {
          request.then(options.onSuccess, options.onError);
        }
      };
      const handleChange = (e) => {
        const files = e.target.files;
        if (!files)
          return;
        uploadFiles(Array.from(files));
      };
      const handleClick = () => {
        if (!disabled.value) {
          inputRef.value.value = "";
          inputRef.value.click();
        }
      };
      const handleKeydown = () => {
        handleClick();
      };
      const abort = (file) => {
        const _reqs = entriesOf(requests.value).filter(file ? ([uid]) => String(file.uid) === uid : () => true);
        _reqs.forEach(([uid, req]) => {
          if (req instanceof XMLHttpRequest)
            req.abort();
          delete requests.value[uid];
        });
      };
      expose({
        abort,
        upload
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", {
          class: Vue.normalizeClass([Vue.unref(ns2).b(), Vue.unref(ns2).m(_ctx.listType), Vue.unref(ns2).is("drag", _ctx.drag)]),
          tabindex: "0",
          onClick: handleClick,
          onKeydown: Vue.withKeys(Vue.withModifiers(handleKeydown, ["self"]), ["enter", "space"])
        }, [
          _ctx.drag ? (Vue.openBlock(), Vue.createBlock(UploadDragger, {
            key: 0,
            disabled: Vue.unref(disabled),
            onFile: uploadFiles
          }, {
            default: Vue.withCtx(() => [
              Vue.renderSlot(_ctx.$slots, "default")
            ]),
            _: 3
          }, 8, ["disabled"])) : Vue.renderSlot(_ctx.$slots, "default", { key: 1 }),
          Vue.createElementVNode("input", {
            ref_key: "inputRef",
            ref: inputRef,
            class: Vue.normalizeClass(Vue.unref(ns2).e("input")),
            name: _ctx.name,
            multiple: _ctx.multiple,
            accept: _ctx.accept,
            type: "file",
            onChange: handleChange,
            onClick: _cache[0] || (_cache[0] = Vue.withModifiers(() => {
            }, ["stop"]))
          }, null, 42, _hoisted_2)
        ], 42, _hoisted_1);
      };
    }
  }));
  var UploadContent = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload-content.vue"]]);
  const SCOPE = "ElUpload";
  const revokeObjectURL = (file) => {
    var _a2;
    if ((_a2 = file.url) == null ? void 0 : _a2.startsWith("blob:")) {
      URL.revokeObjectURL(file.url);
    }
  };
  const useHandlers = (props, uploadRef) => {
    const uploadFiles = useVModel(props, "fileList", void 0, { passive: true });
    const getFile = (rawFile) => uploadFiles.value.find((file) => file.uid === rawFile.uid);
    function abort(file) {
      var _a2;
      (_a2 = uploadRef.value) == null ? void 0 : _a2.abort(file);
    }
    function clearFiles(states = ["ready", "uploading", "success", "fail"]) {
      uploadFiles.value = uploadFiles.value.filter((row) => !states.includes(row.status));
    }
    const handleError2 = (err, rawFile) => {
      const file = getFile(rawFile);
      if (!file)
        return;
      console.error(err);
      file.status = "fail";
      uploadFiles.value.splice(uploadFiles.value.indexOf(file), 1);
      props.onError(err, file, uploadFiles.value);
      props.onChange(file, uploadFiles.value);
    };
    const handleProgress = (evt, rawFile) => {
      const file = getFile(rawFile);
      if (!file)
        return;
      props.onProgress(evt, file, uploadFiles.value);
      file.status = "uploading";
      file.percentage = Math.round(evt.percent);
    };
    const handleSuccess = (response, rawFile) => {
      const file = getFile(rawFile);
      if (!file)
        return;
      file.status = "success";
      file.response = response;
      props.onSuccess(response, file, uploadFiles.value);
      props.onChange(file, uploadFiles.value);
    };
    const handleStart = (file) => {
      if (isNil(file.uid))
        file.uid = genFileId();
      const uploadFile = {
        name: file.name,
        percentage: 0,
        status: "ready",
        size: file.size,
        raw: file,
        uid: file.uid
      };
      if (props.listType === "picture-card" || props.listType === "picture") {
        try {
          uploadFile.url = URL.createObjectURL(file);
        } catch (err) {
          debugWarn(SCOPE, err.message);
          props.onError(err, uploadFile, uploadFiles.value);
        }
      }
      uploadFiles.value = [...uploadFiles.value, uploadFile];
      props.onChange(uploadFile, uploadFiles.value);
    };
    const handleRemove = async (file) => {
      const uploadFile = file instanceof File ? getFile(file) : file;
      if (!uploadFile)
        throwError(SCOPE, "file to be removed not found");
      const doRemove = (file2) => {
        abort(file2);
        const fileList = uploadFiles.value;
        fileList.splice(fileList.indexOf(file2), 1);
        props.onRemove(file2, fileList);
        revokeObjectURL(file2);
      };
      if (props.beforeRemove) {
        const before = await props.beforeRemove(uploadFile, uploadFiles.value);
        if (before !== false)
          doRemove(uploadFile);
      } else {
        doRemove(uploadFile);
      }
    };
    function submit() {
      uploadFiles.value.filter(({ status }) => status === "ready").forEach(({ raw }) => {
        var _a2;
        return raw && ((_a2 = uploadRef.value) == null ? void 0 : _a2.upload(raw));
      });
    }
    Vue.watch(() => props.listType, (val) => {
      if (val !== "picture-card" && val !== "picture") {
        return;
      }
      uploadFiles.value = uploadFiles.value.map((file) => {
        const { raw, url } = file;
        if (!url && raw) {
          try {
            file.url = URL.createObjectURL(raw);
          } catch (err) {
            props.onError(err, file, uploadFiles.value);
          }
        }
        return file;
      });
    });
    Vue.watch(uploadFiles, (files) => {
      for (const file of files) {
        file.uid || (file.uid = genFileId());
        file.status || (file.status = "success");
      }
    }, { immediate: true, deep: true });
    return {
      uploadFiles,
      abort,
      clearFiles,
      handleError: handleError2,
      handleProgress,
      handleStart,
      handleSuccess,
      handleRemove,
      submit
    };
  };
  const __default__ = Vue.defineComponent({
    name: "ElUpload"
  });
  const _sfc_main = /* @__PURE__ */ Vue.defineComponent(__spreadProps(__spreadValues({}, __default__), {
    props: uploadProps,
    setup(__props, { expose }) {
      const props = __props;
      const slots = Vue.useSlots();
      const disabled = useDisabled();
      const uploadRef = Vue.shallowRef();
      const {
        abort,
        submit,
        clearFiles,
        uploadFiles,
        handleStart,
        handleError: handleError2,
        handleRemove,
        handleSuccess,
        handleProgress
      } = useHandlers(props, uploadRef);
      const isPictureCard = Vue.computed(() => props.listType === "picture-card");
      const uploadContentProps2 = Vue.computed(() => __spreadProps(__spreadValues({}, props), {
        fileList: uploadFiles.value,
        onStart: handleStart,
        onProgress: handleProgress,
        onSuccess: handleSuccess,
        onError: handleError2,
        onRemove: handleRemove
      }));
      Vue.onBeforeUnmount(() => {
        uploadFiles.value.forEach(({ url }) => {
          if (url == null ? void 0 : url.startsWith("blob:"))
            URL.revokeObjectURL(url);
        });
      });
      Vue.provide(uploadContextKey, {
        accept: Vue.toRef(props, "accept")
      });
      expose({
        abort,
        submit,
        clearFiles,
        handleStart,
        handleRemove
      });
      return (_ctx, _cache) => {
        return Vue.openBlock(), Vue.createElementBlock("div", null, [
          Vue.unref(isPictureCard) && _ctx.showFileList ? (Vue.openBlock(), Vue.createBlock(UploadList, {
            key: 0,
            disabled: Vue.unref(disabled),
            "list-type": _ctx.listType,
            files: Vue.unref(uploadFiles),
            "handle-preview": _ctx.onPreview,
            onRemove: Vue.unref(handleRemove)
          }, Vue.createSlots({
            append: Vue.withCtx(() => [
              Vue.createVNode(UploadContent, Vue.mergeProps({
                ref_key: "uploadRef",
                ref: uploadRef
              }, Vue.unref(uploadContentProps2)), {
                default: Vue.withCtx(() => [
                  Vue.unref(slots).trigger ? Vue.renderSlot(_ctx.$slots, "trigger", { key: 0 }) : Vue.createCommentVNode("v-if", true),
                  !Vue.unref(slots).trigger && Vue.unref(slots).default ? Vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : Vue.createCommentVNode("v-if", true)
                ]),
                _: 3
              }, 16)
            ]),
            _: 2
          }, [
            _ctx.$slots.file ? {
              name: "default",
              fn: Vue.withCtx(({ file }) => [
                Vue.renderSlot(_ctx.$slots, "file", { file })
              ])
            } : void 0
          ]), 1032, ["disabled", "list-type", "files", "handle-preview", "onRemove"])) : Vue.createCommentVNode("v-if", true),
          !Vue.unref(isPictureCard) || Vue.unref(isPictureCard) && !_ctx.showFileList ? (Vue.openBlock(), Vue.createBlock(UploadContent, Vue.mergeProps({
            key: 1,
            ref_key: "uploadRef",
            ref: uploadRef
          }, Vue.unref(uploadContentProps2)), {
            default: Vue.withCtx(() => [
              Vue.unref(slots).trigger ? Vue.renderSlot(_ctx.$slots, "trigger", { key: 0 }) : Vue.createCommentVNode("v-if", true),
              !Vue.unref(slots).trigger && Vue.unref(slots).default ? Vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : Vue.createCommentVNode("v-if", true)
            ]),
            _: 3
          }, 16)) : Vue.createCommentVNode("v-if", true),
          _ctx.$slots.trigger ? Vue.renderSlot(_ctx.$slots, "default", { key: 2 }) : Vue.createCommentVNode("v-if", true),
          Vue.renderSlot(_ctx.$slots, "tip"),
          !Vue.unref(isPictureCard) && _ctx.showFileList ? (Vue.openBlock(), Vue.createBlock(UploadList, {
            key: 3,
            disabled: Vue.unref(disabled),
            "list-type": _ctx.listType,
            files: Vue.unref(uploadFiles),
            "handle-preview": _ctx.onPreview,
            onRemove: Vue.unref(handleRemove)
          }, Vue.createSlots({ _: 2 }, [
            _ctx.$slots.file ? {
              name: "default",
              fn: Vue.withCtx(({ file }) => [
                Vue.renderSlot(_ctx.$slots, "file", { file })
              ])
            } : void 0
          ]), 1032, ["disabled", "list-type", "files", "handle-preview", "onRemove"])) : Vue.createCommentVNode("v-if", true)
        ]);
      };
    }
  }));
  var Upload = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/upload/src/upload.vue"]]);
  const ElUpload = withInstall(Upload);
  const app = Vue.createApp(App);
  [ElTable, ElTableColumn, ElButton, ElProgress, ElUpload, ElAlert, ElInputNumber].forEach((element) => app.use(element));
  const style = document.createElement("link");
  style.href = "//unpkg.com/element-plus/dist/index.css";
  style.rel = "stylesheet";
  document.head.appendChild(style);
  const div = document.createElement("div");
  div.id = "csres-app-root";
  document.body.appendChild(div);
  app.mount("#csres-app-root");
})();