@lotics/cli 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/cli.js CHANGED
@@ -120,7 +120,7 @@ var require_helpers = __commonJS({
120
120
  * @returns {*}
121
121
  */
122
122
  flattenDeep(arr1) {
123
- return arr1.reduce((acc, val2) => Array.isArray(val2) ? acc.concat(this.flattenDeep(val2)) : acc.concat(val2), []);
123
+ return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(this.flattenDeep(val)) : acc.concat(val), []);
124
124
  }
125
125
  /**
126
126
  *
@@ -768,11 +768,11 @@ var require_ssf = __commonJS({
768
768
  function fix_hijri() {
769
769
  return 0;
770
770
  }
771
- function write_date(type, fmt, val2, ss0) {
772
- let o = "", ss = 0, tt = 0, y = val2.y, out, outl = 0;
771
+ function write_date(type, fmt, val, ss0) {
772
+ let o = "", ss = 0, tt = 0, y = val.y, out, outl = 0;
773
773
  switch (type) {
774
774
  case 98:
775
- y = val2.y + 543;
775
+ y = val.y + 543;
776
776
  /* falls through */
777
777
  case 121:
778
778
  switch (fmt.length) {
@@ -791,35 +791,35 @@ var require_ssf = __commonJS({
791
791
  switch (fmt.length) {
792
792
  case 1:
793
793
  case 2:
794
- out = val2.m;
794
+ out = val.m;
795
795
  outl = fmt.length;
796
796
  break;
797
797
  case 3:
798
- return months[val2.m - 1][1];
798
+ return months[val.m - 1][1];
799
799
  case 5:
800
- return months[val2.m - 1][0];
800
+ return months[val.m - 1][0];
801
801
  default:
802
- return months[val2.m - 1][2];
802
+ return months[val.m - 1][2];
803
803
  }
804
804
  break;
805
805
  case 100:
806
806
  switch (fmt.length) {
807
807
  case 1:
808
808
  case 2:
809
- out = val2.d;
809
+ out = val.d;
810
810
  outl = fmt.length;
811
811
  break;
812
812
  case 3:
813
- return days[val2.q][0];
813
+ return days[val.q][0];
814
814
  default:
815
- return days[val2.q][1];
815
+ return days[val.q][1];
816
816
  }
817
817
  break;
818
818
  case 104:
819
819
  switch (fmt.length) {
820
820
  case 1:
821
821
  case 2:
822
- out = 1 + (val2.H + 11) % 12;
822
+ out = 1 + (val.H + 11) % 12;
823
823
  outl = fmt.length;
824
824
  break;
825
825
  default:
@@ -830,7 +830,7 @@ var require_ssf = __commonJS({
830
830
  switch (fmt.length) {
831
831
  case 1:
832
832
  case 2:
833
- out = val2.H;
833
+ out = val.H;
834
834
  outl = fmt.length;
835
835
  break;
836
836
  default:
@@ -841,7 +841,7 @@ var require_ssf = __commonJS({
841
841
  switch (fmt.length) {
842
842
  case 1:
843
843
  case 2:
844
- out = val2.M;
844
+ out = val.M;
845
845
  outl = fmt.length;
846
846
  break;
847
847
  default:
@@ -850,10 +850,10 @@ var require_ssf = __commonJS({
850
850
  break;
851
851
  case 115:
852
852
  if (fmt !== "s" && fmt !== "ss" && fmt !== ".0" && fmt !== ".00" && fmt !== ".000") throw "bad second format: " + fmt;
853
- if (val2.u === 0 && (fmt === "s" || fmt === "ss")) return pad0(val2.S, fmt.length);
853
+ if (val.u === 0 && (fmt === "s" || fmt === "ss")) return pad0(val.S, fmt.length);
854
854
  if (ss0 >= 2) tt = ss0 === 3 ? 1e3 : 100;
855
855
  else tt = ss0 === 1 ? 10 : 1;
856
- ss = Math.round(tt * (val2.S + val2.u));
856
+ ss = Math.round(tt * (val.S + val.u));
857
857
  if (ss >= 60 * tt) ss = 0;
858
858
  if (fmt === "s") return ss === 0 ? "0" : "" + ss / tt;
859
859
  o = pad0(ss, 2 + ss0);
@@ -863,15 +863,15 @@ var require_ssf = __commonJS({
863
863
  switch (fmt) {
864
864
  case "[h]":
865
865
  case "[hh]":
866
- out = val2.D * 24 + val2.H;
866
+ out = val.D * 24 + val.H;
867
867
  break;
868
868
  case "[m]":
869
869
  case "[mm]":
870
- out = (val2.D * 24 + val2.H) * 60 + val2.M;
870
+ out = (val.D * 24 + val.H) * 60 + val.M;
871
871
  break;
872
872
  case "[s]":
873
873
  case "[ss]":
874
- out = ((val2.D * 24 + val2.H) * 60 + val2.M) * 60 + Math.round(val2.S + val2.u);
874
+ out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);
875
875
  break;
876
876
  default:
877
877
  throw "bad abstime format: " + fmt;
@@ -894,28 +894,28 @@ var require_ssf = __commonJS({
894
894
  }
895
895
  var write_num = /* @__PURE__ */ (function make_write_num() {
896
896
  const pct1 = /%/g;
897
- function write_num_pct(type, fmt, val2) {
897
+ function write_num_pct(type, fmt, val) {
898
898
  const sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
899
- return write_num(type, sfmt, val2 * Math.pow(10, 2 * mul)) + fill("%", mul);
899
+ return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
900
900
  }
901
- function write_num_cm(type, fmt, val2) {
901
+ function write_num_cm(type, fmt, val) {
902
902
  let idx = fmt.length - 1;
903
903
  while (fmt.charCodeAt(idx - 1) === 44) --idx;
904
- return write_num(type, fmt.substr(0, idx), val2 / Math.pow(10, 3 * (fmt.length - idx)));
904
+ return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
905
905
  }
906
- function write_num_exp(fmt, val2) {
906
+ function write_num_exp(fmt, val) {
907
907
  let o;
908
908
  let idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
909
909
  if (fmt.match(/^#+0.0E\+0$/)) {
910
- if (val2 === 0) return "0.0E+0";
911
- else if (val2 < 0) return "-" + write_num_exp(fmt, -val2);
910
+ if (val === 0) return "0.0E+0";
911
+ else if (val < 0) return "-" + write_num_exp(fmt, -val);
912
912
  let period = fmt.indexOf(".");
913
913
  if (period === -1) period = fmt.indexOf("E");
914
- let ee = Math.floor(Math.log(val2) * Math.LOG10E) % period;
914
+ let ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
915
915
  if (ee < 0) ee += period;
916
- o = (val2 / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
916
+ o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
917
917
  if (o.indexOf("e") === -1) {
918
- const fakee = Math.floor(Math.log(val2) * Math.LOG10E);
918
+ const fakee = Math.floor(Math.log(val) * Math.LOG10E);
919
919
  if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);
920
920
  else o += "E+" + (fakee - ee);
921
921
  while (o.substr(0, 2) === "0.") {
@@ -927,7 +927,7 @@ var require_ssf = __commonJS({
927
927
  o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
928
928
  return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
929
929
  });
930
- } else o = val2.toExponential(idx);
930
+ } else o = val.toExponential(idx);
931
931
  if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
932
932
  if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
933
933
  return o.replace("e", "E");
@@ -960,48 +960,48 @@ var require_ssf = __commonJS({
960
960
  }
961
961
  return o;
962
962
  }
963
- function rnd(val2, d) {
963
+ function rnd(val, d) {
964
964
  const dd = Math.pow(10, d);
965
- return "" + Math.round(val2 * dd) / dd;
965
+ return "" + Math.round(val * dd) / dd;
966
966
  }
967
- function dec(val2, d) {
968
- if (d < ("" + Math.round((val2 - Math.floor(val2)) * Math.pow(10, d))).length) {
967
+ function dec(val, d) {
968
+ if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
969
969
  return 0;
970
970
  }
971
- return Math.round((val2 - Math.floor(val2)) * Math.pow(10, d));
971
+ return Math.round((val - Math.floor(val)) * Math.pow(10, d));
972
972
  }
973
- function carry(val2, d) {
974
- if (d < ("" + Math.round((val2 - Math.floor(val2)) * Math.pow(10, d))).length) {
973
+ function carry(val, d) {
974
+ if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
975
975
  return 1;
976
976
  }
977
977
  return 0;
978
978
  }
979
- function flr(val2) {
980
- if (val2 < 2147483647 && val2 > -2147483648) return "" + (val2 >= 0 ? val2 | 0 : val2 - 1 | 0);
981
- return "" + Math.floor(val2);
979
+ function flr(val) {
980
+ if (val < 2147483647 && val > -2147483648) return "" + (val >= 0 ? val | 0 : val - 1 | 0);
981
+ return "" + Math.floor(val);
982
982
  }
983
- function write_num_flt(type, fmt, val2) {
983
+ function write_num_flt(type, fmt, val) {
984
984
  if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
985
985
  const ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
986
- if (val2 >= 0) return write_num_flt("n", ffmt, val2);
987
- return "(" + write_num_flt("n", ffmt, -val2) + ")";
986
+ if (val >= 0) return write_num_flt("n", ffmt, val);
987
+ return "(" + write_num_flt("n", ffmt, -val) + ")";
988
988
  }
989
- if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val2);
990
- if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt, val2);
991
- if (fmt.indexOf("E") !== -1) return write_num_exp(fmt, val2);
992
- if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val2);
989
+ if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
990
+ if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt, val);
991
+ if (fmt.indexOf("E") !== -1) return write_num_exp(fmt, val);
992
+ if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
993
993
  let o;
994
- let r, ri, ff, aval = Math.abs(val2), sign = val2 < 0 ? "-" : "";
994
+ let r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
995
995
  if (fmt.match(/^00+$/)) return sign + pad0r(aval, fmt.length);
996
996
  if (fmt.match(/^[#?]+$/)) {
997
- o = pad0r(val2, 0);
997
+ o = pad0r(val, 0);
998
998
  if (o === "0") o = "";
999
999
  return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
1000
1000
  }
1001
1001
  if (r = fmt.match(frac1)) return write_num_f1(r, aval, sign);
1002
1002
  if (fmt.match(/^#+0+$/)) return sign + pad0r(aval, fmt.length - fmt.indexOf("0"));
1003
1003
  if (r = fmt.match(dec1)) {
1004
- o = rnd(val2, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function($$, $1) {
1004
+ o = rnd(val, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function($$, $1) {
1005
1005
  return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
1006
1006
  });
1007
1007
  return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
@@ -1012,18 +1012,18 @@ var require_ssf = __commonJS({
1012
1012
  }
1013
1013
  if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify(pad0r(aval, 0));
1014
1014
  if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
1015
- return val2 < 0 ? "-" + write_num_flt(type, fmt, -val2) : commaify("" + (Math.floor(val2) + carry(val2, r[1].length))) + "." + pad0(dec(val2, r[1].length), r[1].length);
1015
+ 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);
1016
1016
  }
1017
- if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val2);
1017
+ if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val);
1018
1018
  if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
1019
- o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val2));
1019
+ o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val));
1020
1020
  ri = 0;
1021
1021
  return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x) {
1022
1022
  return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
1023
1023
  }));
1024
1024
  }
1025
1025
  if (fmt.match(phone)) {
1026
- o = write_num_flt(type, "##########", val2);
1026
+ o = write_num_flt(type, "##########", val);
1027
1027
  return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
1028
1028
  }
1029
1029
  let oa = "";
@@ -1045,60 +1045,60 @@ var require_ssf = __commonJS({
1045
1045
  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));
1046
1046
  }
1047
1047
  if (r = fmt.match(/^[#0?]+$/)) {
1048
- o = pad0r(val2, 0);
1048
+ o = pad0r(val, 0);
1049
1049
  if (fmt.length <= o.length) return o;
1050
1050
  return hashq(fmt.substr(0, fmt.length - o.length)) + o;
1051
1051
  }
1052
1052
  if (r = fmt.match(/^([#0?]+)\.([#0]+)$/)) {
1053
- o = "" + val2.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
1053
+ o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
1054
1054
  ri = o.indexOf(".");
1055
1055
  const lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
1056
1056
  return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
1057
1057
  }
1058
1058
  if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
1059
- ri = dec(val2, r[1].length);
1060
- return val2 < 0 ? "-" + write_num_flt(type, fmt, -val2) : commaify(flr(val2)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
1059
+ ri = dec(val, r[1].length);
1060
+ return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
1061
1061
  return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
1062
1062
  }) + "." + pad0(ri, r[1].length);
1063
1063
  }
1064
1064
  switch (fmt) {
1065
1065
  case "###,##0.00":
1066
- return write_num_flt(type, "#,##0.00", val2);
1066
+ return write_num_flt(type, "#,##0.00", val);
1067
1067
  case "###,###":
1068
1068
  case "##,###":
1069
1069
  case "#,###":
1070
1070
  const x = commaify(pad0r(aval, 0));
1071
1071
  return x !== "0" ? sign + x : "";
1072
1072
  case "###,###.00":
1073
- return write_num_flt(type, "###,##0.00", val2).replace(/^0\./, ".");
1073
+ return write_num_flt(type, "###,##0.00", val).replace(/^0\./, ".");
1074
1074
  case "#,###.00":
1075
- return write_num_flt(type, "#,##0.00", val2).replace(/^0\./, ".");
1075
+ return write_num_flt(type, "#,##0.00", val).replace(/^0\./, ".");
1076
1076
  default:
1077
1077
  }
1078
1078
  throw new Error("unsupported format |" + fmt + "|");
1079
1079
  }
1080
- function write_num_cm2(type, fmt, val2) {
1080
+ function write_num_cm2(type, fmt, val) {
1081
1081
  let idx = fmt.length - 1;
1082
1082
  while (fmt.charCodeAt(idx - 1) === 44) --idx;
1083
- return write_num(type, fmt.substr(0, idx), val2 / Math.pow(10, 3 * (fmt.length - idx)));
1083
+ return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
1084
1084
  }
1085
- function write_num_pct2(type, fmt, val2) {
1085
+ function write_num_pct2(type, fmt, val) {
1086
1086
  const sfmt = fmt.replace(pct1, ""), mul = fmt.length - sfmt.length;
1087
- return write_num(type, sfmt, val2 * Math.pow(10, 2 * mul)) + fill("%", mul);
1087
+ return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
1088
1088
  }
1089
- function write_num_exp2(fmt, val2) {
1089
+ function write_num_exp2(fmt, val) {
1090
1090
  let o;
1091
1091
  let idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
1092
1092
  if (fmt.match(/^#+0.0E\+0$/)) {
1093
- if (val2 === 0) return "0.0E+0";
1094
- else if (val2 < 0) return "-" + write_num_exp2(fmt, -val2);
1093
+ if (val === 0) return "0.0E+0";
1094
+ else if (val < 0) return "-" + write_num_exp2(fmt, -val);
1095
1095
  let period = fmt.indexOf(".");
1096
1096
  if (period === -1) period = fmt.indexOf("E");
1097
- let ee = Math.floor(Math.log(val2) * Math.LOG10E) % period;
1097
+ let ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
1098
1098
  if (ee < 0) ee += period;
1099
- o = (val2 / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
1099
+ o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
1100
1100
  if (!o.match(/[Ee]/)) {
1101
- const fakee = Math.floor(Math.log(val2) * Math.LOG10E);
1101
+ const fakee = Math.floor(Math.log(val) * Math.LOG10E);
1102
1102
  if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);
1103
1103
  else o += "E+" + (fakee - ee);
1104
1104
  o = o.replace(/\+-/, "-");
@@ -1106,33 +1106,33 @@ var require_ssf = __commonJS({
1106
1106
  o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function($$, $1, $2, $3) {
1107
1107
  return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
1108
1108
  });
1109
- } else o = val2.toExponential(idx);
1109
+ } else o = val.toExponential(idx);
1110
1110
  if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
1111
1111
  if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
1112
1112
  return o.replace("e", "E");
1113
1113
  }
1114
- function write_num_int(type, fmt, val2) {
1114
+ function write_num_int(type, fmt, val) {
1115
1115
  if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
1116
1116
  const ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
1117
- if (val2 >= 0) return write_num_int("n", ffmt, val2);
1118
- return "(" + write_num_int("n", ffmt, -val2) + ")";
1117
+ if (val >= 0) return write_num_int("n", ffmt, val);
1118
+ return "(" + write_num_int("n", ffmt, -val) + ")";
1119
1119
  }
1120
- if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val2);
1121
- if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt, val2);
1122
- if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt, val2);
1123
- if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val2);
1120
+ if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
1121
+ if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt, val);
1122
+ if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt, val);
1123
+ if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
1124
1124
  let o;
1125
- let r, ri, ff, aval = Math.abs(val2), sign = val2 < 0 ? "-" : "";
1125
+ let r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
1126
1126
  if (fmt.match(/^00+$/)) return sign + pad0(aval, fmt.length);
1127
1127
  if (fmt.match(/^[#?]+$/)) {
1128
- o = "" + val2;
1129
- if (val2 === 0) o = "";
1128
+ o = "" + val;
1129
+ if (val === 0) o = "";
1130
1130
  return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
1131
1131
  }
1132
1132
  if (r = fmt.match(frac1)) return write_num_f2(r, aval, sign);
1133
1133
  if (fmt.match(/^#+0+$/)) return sign + pad0(aval, fmt.length - fmt.indexOf("0"));
1134
1134
  if (r = fmt.match(dec1)) {
1135
- o = ("" + val2).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
1135
+ o = ("" + val).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
1136
1136
  o = o.replace(/\.(\d*)$/, function($$, $1) {
1137
1137
  return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
1138
1138
  });
@@ -1144,18 +1144,18 @@ var require_ssf = __commonJS({
1144
1144
  }
1145
1145
  if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify("" + aval);
1146
1146
  if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
1147
- return val2 < 0 ? "-" + write_num_int(type, fmt, -val2) : commaify("" + val2) + "." + fill("0", r[1].length);
1147
+ return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val) + "." + fill("0", r[1].length);
1148
1148
  }
1149
- if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""), val2);
1149
+ if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""), val);
1150
1150
  if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
1151
- o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val2));
1151
+ o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val));
1152
1152
  ri = 0;
1153
1153
  return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function(x) {
1154
1154
  return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
1155
1155
  }));
1156
1156
  }
1157
1157
  if (fmt.match(phone)) {
1158
- o = write_num_int(type, "##########", val2);
1158
+ o = write_num_int(type, "##########", val);
1159
1159
  return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
1160
1160
  }
1161
1161
  let oa = "";
@@ -1177,18 +1177,18 @@ var require_ssf = __commonJS({
1177
1177
  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));
1178
1178
  }
1179
1179
  if (r = fmt.match(/^[#0?]+$/)) {
1180
- o = "" + val2;
1180
+ o = "" + val;
1181
1181
  if (fmt.length <= o.length) return o;
1182
1182
  return hashq(fmt.substr(0, fmt.length - o.length)) + o;
1183
1183
  }
1184
1184
  if (r = fmt.match(/^([#0]+)\.([#0]+)$/)) {
1185
- o = "" + val2.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
1185
+ o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
1186
1186
  ri = o.indexOf(".");
1187
1187
  let lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
1188
1188
  return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
1189
1189
  }
1190
1190
  if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
1191
- return val2 < 0 ? "-" + write_num_int(type, fmt, -val2) : commaify("" + val2).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
1191
+ return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function($$) {
1192
1192
  return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
1193
1193
  }) + "." + pad0(0, r[1].length);
1194
1194
  }
@@ -1199,12 +1199,12 @@ var require_ssf = __commonJS({
1199
1199
  const x = commaify("" + aval);
1200
1200
  return x !== "0" ? sign + x : "";
1201
1201
  default:
1202
- if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val2) + hashq(fmt.slice(fmt.lastIndexOf(".")));
1202
+ if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val) + hashq(fmt.slice(fmt.lastIndexOf(".")));
1203
1203
  }
1204
1204
  throw new Error("unsupported format |" + fmt + "|");
1205
1205
  }
1206
- return function write_num2(type, fmt, val2) {
1207
- return (val2 | 0) === val2 ? write_num_int(type, fmt, val2) : write_num_flt(type, fmt, val2);
1206
+ return function write_num2(type, fmt, val) {
1207
+ return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
1208
1208
  };
1209
1209
  })();
1210
1210
  function split_fmt(fmt) {
@@ -3061,17 +3061,17 @@ var require_logical = __commonJS({
3061
3061
  var H = FormulaHelpers;
3062
3062
  function getNumLogicalValue(params) {
3063
3063
  let numTrue = 0, numFalse = 0;
3064
- H.flattenParams(params, null, true, (val2) => {
3065
- const type = typeof val2;
3064
+ H.flattenParams(params, null, true, (val) => {
3065
+ const type = typeof val;
3066
3066
  if (type === "string") {
3067
- if (val2 === "TRUE")
3068
- val2 = true;
3069
- else if (val2 === "FALSE")
3070
- val2 = false;
3067
+ if (val === "TRUE")
3068
+ val = true;
3069
+ else if (val === "FALSE")
3070
+ val = false;
3071
3071
  } else if (type === "number")
3072
- val2 = Boolean(val2);
3073
- if (typeof val2 === "boolean") {
3074
- if (val2 === true)
3072
+ val = Boolean(val);
3073
+ if (typeof val === "boolean") {
3074
+ if (val === true)
3075
3075
  numTrue++;
3076
3076
  else
3077
3077
  numFalse++;
@@ -3387,10 +3387,10 @@ var require_jstat = __commonJS({
3387
3387
  var slice = Array.prototype.slice;
3388
3388
  var toString = Object.prototype.toString;
3389
3389
  function calcRdx(n, m) {
3390
- var val2 = n > m ? n : m;
3390
+ var val = n > m ? n : m;
3391
3391
  return Math2.pow(
3392
3392
  10,
3393
- 17 - ~~(Math2.log(val2 > 0 ? val2 : -val2) * Math2.LOG10E)
3393
+ 17 - ~~(Math2.log(val > 0 ? val : -val) * Math2.LOG10E)
3394
3394
  );
3395
3395
  }
3396
3396
  var isArray2 = Array.isArray || function isArray3(arg) {
@@ -10243,10 +10243,10 @@ var require_utils = __commonJS({
10243
10243
  exports.peek = peek;
10244
10244
  function timer(func) {
10245
10245
  var start = (/* @__PURE__ */ new Date()).getTime();
10246
- var val2 = func();
10246
+ var val = func();
10247
10247
  var end = (/* @__PURE__ */ new Date()).getTime();
10248
10248
  var total = end - start;
10249
- return { time: total, value: val2 };
10249
+ return { time: total, value: val };
10250
10250
  }
10251
10251
  exports.timer = timer;
10252
10252
  }
@@ -12227,7 +12227,7 @@ var require_tokens = __commonJS({
12227
12227
  function assignCategoriesTokensProp(tokenTypes) {
12228
12228
  utils_1.forEach(tokenTypes, function(currTokType) {
12229
12229
  currTokType.categoryMatches = [];
12230
- utils_1.forEach(currTokType.categoryMatchesMap, function(val2, key) {
12230
+ utils_1.forEach(currTokType.categoryMatchesMap, function(val, key) {
12231
12231
  currTokType.categoryMatches.push(exports2.tokenIdxToClass[key].tokenTypeIdx);
12232
12232
  });
12233
12233
  });
@@ -18825,14 +18825,14 @@ var require_utils2 = __commonJS({
18825
18825
  }
18826
18826
  };
18827
18827
  }
18828
- _applyPrefix(prefixes, val2, isArray2) {
18829
- if (this.isFormulaError(val2))
18830
- return val2;
18831
- return Prefix.unaryOp(prefixes, val2, isArray2);
18828
+ _applyPrefix(prefixes, val, isArray2) {
18829
+ if (this.isFormulaError(val))
18830
+ return val;
18831
+ return Prefix.unaryOp(prefixes, val, isArray2);
18832
18832
  }
18833
18833
  async applyPrefixAsync(prefixes, value) {
18834
- const { val: val2, isArray: isArray2 } = this.extractRefValue(await value);
18835
- return this._applyPrefix(prefixes, val2, isArray2);
18834
+ const { val, isArray: isArray2 } = this.extractRefValue(await value);
18835
+ return this._applyPrefix(prefixes, val, isArray2);
18836
18836
  }
18837
18837
  /**
18838
18838
  * Apply + or - unary prefix.
@@ -18844,25 +18844,25 @@ var require_utils2 = __commonJS({
18844
18844
  if (this.context.async) {
18845
18845
  return this.applyPrefixAsync(prefixes, value);
18846
18846
  } else {
18847
- const { val: val2, isArray: isArray2 } = this.extractRefValue(value);
18848
- return this._applyPrefix(prefixes, val2, isArray2);
18847
+ const { val, isArray: isArray2 } = this.extractRefValue(value);
18848
+ return this._applyPrefix(prefixes, val, isArray2);
18849
18849
  }
18850
18850
  }
18851
- _applyPostfix(val2, isArray2, postfix) {
18852
- if (this.isFormulaError(val2))
18853
- return val2;
18854
- return Postfix.percentOp(val2, postfix, isArray2);
18851
+ _applyPostfix(val, isArray2, postfix) {
18852
+ if (this.isFormulaError(val))
18853
+ return val;
18854
+ return Postfix.percentOp(val, postfix, isArray2);
18855
18855
  }
18856
18856
  async applyPostfixAsync(value, postfix) {
18857
- const { val: val2, isArray: isArray2 } = this.extractRefValue(await value);
18858
- return this._applyPostfix(val2, isArray2, postfix);
18857
+ const { val, isArray: isArray2 } = this.extractRefValue(await value);
18858
+ return this._applyPostfix(val, isArray2, postfix);
18859
18859
  }
18860
18860
  applyPostfix(value, postfix) {
18861
18861
  if (this.context.async) {
18862
18862
  return this.applyPostfixAsync(value, postfix);
18863
18863
  } else {
18864
- const { val: val2, isArray: isArray2 } = this.extractRefValue(value);
18865
- return this._applyPostfix(val2, isArray2, postfix);
18864
+ const { val, isArray: isArray2 } = this.extractRefValue(value);
18865
+ return this._applyPostfix(val, isArray2, postfix);
18866
18866
  }
18867
18867
  }
18868
18868
  _applyInfix(res1, infix, res2) {
@@ -25328,7 +25328,7 @@ var require_deflate = __commonJS({
25328
25328
  }
25329
25329
  function deflate(strm, flush) {
25330
25330
  var old_flush, s;
25331
- var beg, val2;
25331
+ var beg, val;
25332
25332
  if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
25333
25333
  return strm ? err2(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
25334
25334
  }
@@ -25440,21 +25440,21 @@ var require_deflate = __commonJS({
25440
25440
  flush_pending(strm);
25441
25441
  beg = s.pending;
25442
25442
  if (s.pending === s.pending_buf_size) {
25443
- val2 = 1;
25443
+ val = 1;
25444
25444
  break;
25445
25445
  }
25446
25446
  }
25447
25447
  if (s.gzindex < s.gzhead.name.length) {
25448
- val2 = s.gzhead.name.charCodeAt(s.gzindex++) & 255;
25448
+ val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;
25449
25449
  } else {
25450
- val2 = 0;
25450
+ val = 0;
25451
25451
  }
25452
- put_byte(s, val2);
25453
- } while (val2 !== 0);
25452
+ put_byte(s, val);
25453
+ } while (val !== 0);
25454
25454
  if (s.gzhead.hcrc && s.pending > beg) {
25455
25455
  strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
25456
25456
  }
25457
- if (val2 === 0) {
25457
+ if (val === 0) {
25458
25458
  s.gzindex = 0;
25459
25459
  s.status = COMMENT_STATE;
25460
25460
  }
@@ -25473,21 +25473,21 @@ var require_deflate = __commonJS({
25473
25473
  flush_pending(strm);
25474
25474
  beg = s.pending;
25475
25475
  if (s.pending === s.pending_buf_size) {
25476
- val2 = 1;
25476
+ val = 1;
25477
25477
  break;
25478
25478
  }
25479
25479
  }
25480
25480
  if (s.gzindex < s.gzhead.comment.length) {
25481
- val2 = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;
25481
+ val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;
25482
25482
  } else {
25483
- val2 = 0;
25483
+ val = 0;
25484
25484
  }
25485
- put_byte(s, val2);
25486
- } while (val2 !== 0);
25485
+ put_byte(s, val);
25486
+ } while (val !== 0);
25487
25487
  if (s.gzhead.hcrc && s.pending > beg) {
25488
25488
  strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
25489
25489
  }
25490
- if (val2 === 0) {
25490
+ if (val === 0) {
25491
25491
  s.status = HCRC_STATE;
25492
25492
  }
25493
25493
  } else {
@@ -29627,9 +29627,24 @@ var require_util2 = __commonJS({
29627
29627
  return "";
29628
29628
  }
29629
29629
  };
29630
+ var DANGEROUS_PROPERTY_NAMES2 = [
29631
+ // '__proto__',
29632
+ // 'constructor',
29633
+ // 'prototype',
29634
+ "hasOwnProperty",
29635
+ "toString",
29636
+ "valueOf",
29637
+ "__defineGetter__",
29638
+ "__defineSetter__",
29639
+ "__lookupGetter__",
29640
+ "__lookupSetter__"
29641
+ ];
29642
+ var criticalProperties2 = ["__proto__", "constructor", "prototype"];
29630
29643
  exports2.isName = isName2;
29631
29644
  exports2.getAllMatches = getAllMatches2;
29632
29645
  exports2.nameRegexp = nameRegexp2;
29646
+ exports2.DANGEROUS_PROPERTY_NAMES = DANGEROUS_PROPERTY_NAMES2;
29647
+ exports2.criticalProperties = criticalProperties2;
29633
29648
  }
29634
29649
  });
29635
29650
 
@@ -29948,6 +29963,13 @@ var require_validator = __commonJS({
29948
29963
  // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
29949
29964
  var require_OptionsBuilder = __commonJS({
29950
29965
  "../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports2) {
29966
+ var { DANGEROUS_PROPERTY_NAMES: DANGEROUS_PROPERTY_NAMES2, criticalProperties: criticalProperties2 } = require_util2();
29967
+ var defaultOnDangerousProperty2 = (name) => {
29968
+ if (DANGEROUS_PROPERTY_NAMES2.includes(name)) {
29969
+ return "__" + name;
29970
+ }
29971
+ return name;
29972
+ };
29951
29973
  var defaultOptions3 = {
29952
29974
  preserveOrder: false,
29953
29975
  attributeNamePrefix: "@_",
@@ -29969,11 +29991,11 @@ var require_OptionsBuilder = __commonJS({
29969
29991
  leadingZeros: true,
29970
29992
  eNotation: true
29971
29993
  },
29972
- tagValueProcessor: function(tagName, val2) {
29973
- return val2;
29994
+ tagValueProcessor: function(tagName, val) {
29995
+ return val;
29974
29996
  },
29975
- attributeValueProcessor: function(attrName, val2) {
29976
- return val2;
29997
+ attributeValueProcessor: function(attrName, val) {
29998
+ return val;
29977
29999
  },
29978
30000
  stopNodes: [],
29979
30001
  //nested tags will not be parsed even for errors
@@ -29989,11 +30011,75 @@ var require_OptionsBuilder = __commonJS({
29989
30011
  transformAttributeName: false,
29990
30012
  updateTag: function(tagName, jPath, attrs) {
29991
30013
  return tagName;
29992
- }
30014
+ },
29993
30015
  // skipEmptyListItem: false
30016
+ captureMetaData: false,
30017
+ maxNestedTags: 100,
30018
+ strictReservedNames: true,
30019
+ onDangerousProperty: defaultOnDangerousProperty2
29994
30020
  };
30021
+ function validatePropertyName2(propertyName, optionName) {
30022
+ if (typeof propertyName !== "string") {
30023
+ return;
30024
+ }
30025
+ const normalized = propertyName.toLowerCase();
30026
+ if (DANGEROUS_PROPERTY_NAMES2.some((dangerous) => normalized === dangerous.toLowerCase())) {
30027
+ throw new Error(
30028
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
30029
+ );
30030
+ }
30031
+ if (criticalProperties2.some((dangerous) => normalized === dangerous.toLowerCase())) {
30032
+ throw new Error(
30033
+ `[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
30034
+ );
30035
+ }
30036
+ }
30037
+ function normalizeProcessEntities2(value) {
30038
+ if (typeof value === "boolean") {
30039
+ return {
30040
+ enabled: value,
30041
+ // true or false
30042
+ maxEntitySize: 1e4,
30043
+ maxExpansionDepth: 10,
30044
+ maxTotalExpansions: 1e3,
30045
+ maxExpandedLength: 1e5,
30046
+ allowedTags: null,
30047
+ tagFilter: null
30048
+ };
30049
+ }
30050
+ if (typeof value === "object" && value !== null) {
30051
+ return {
30052
+ enabled: value.enabled !== false,
30053
+ maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
30054
+ maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 1e4),
30055
+ maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? Infinity),
30056
+ maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
30057
+ maxEntityCount: Math.max(1, value.maxEntityCount ?? 1e3),
30058
+ allowedTags: value.allowedTags ?? null,
30059
+ tagFilter: value.tagFilter ?? null
30060
+ };
30061
+ }
30062
+ return normalizeProcessEntities2(true);
30063
+ }
29995
30064
  var buildOptions2 = function(options) {
29996
- return Object.assign({}, defaultOptions3, options);
30065
+ const built = Object.assign({}, defaultOptions3, options);
30066
+ const propertyNameOptions = [
30067
+ { value: built.attributeNamePrefix, name: "attributeNamePrefix" },
30068
+ { value: built.attributesGroupName, name: "attributesGroupName" },
30069
+ { value: built.textNodeName, name: "textNodeName" },
30070
+ { value: built.cdataPropName, name: "cdataPropName" },
30071
+ { value: built.commentPropName, name: "commentPropName" }
30072
+ ];
30073
+ for (const { value, name } of propertyNameOptions) {
30074
+ if (value) {
30075
+ validatePropertyName2(value, name);
30076
+ }
30077
+ }
30078
+ if (built.onDangerousProperty === null) {
30079
+ built.onDangerousProperty = defaultOnDangerousProperty2;
30080
+ }
30081
+ built.processEntities = normalizeProcessEntities2(built.processEntities);
30082
+ return built;
29997
30083
  };
29998
30084
  exports2.buildOptions = buildOptions2;
29999
30085
  exports2.defaultOptions = defaultOptions3;
@@ -30010,9 +30096,9 @@ var require_xmlNode = __commonJS({
30010
30096
  this.child = [];
30011
30097
  this[":@"] = {};
30012
30098
  }
30013
- add(key, val2) {
30099
+ add(key, val) {
30014
30100
  if (key === "__proto__") key = "#__proto__";
30015
- this.child.push({ [key]: val2 });
30101
+ this.child.push({ [key]: val });
30016
30102
  }
30017
30103
  addChild(node) {
30018
30104
  if (node.tagname === "__proto__") node.tagname = "#__proto__";
@@ -30031,89 +30117,279 @@ var require_xmlNode = __commonJS({
30031
30117
  var require_DocTypeReader = __commonJS({
30032
30118
  "../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports2, module2) {
30033
30119
  var util = require_util2();
30034
- function readDocType(xmlData, i) {
30035
- const entities = {};
30036
- if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
30037
- i = i + 9;
30038
- let angleBracketsCount = 1;
30039
- let hasBody = false, comment = false;
30040
- let exp = "";
30041
- for (; i < xmlData.length; i++) {
30042
- if (xmlData[i] === "<" && !comment) {
30043
- if (hasBody && isEntity(xmlData, i)) {
30044
- i += 7;
30045
- [entityName, val, i] = readEntityExp(xmlData, i + 1);
30046
- if (val.indexOf("&") === -1)
30047
- entities[validateEntityName3(entityName)] = {
30048
- regx: RegExp(`&${entityName};`, "g"),
30049
- val
30050
- };
30051
- } else if (hasBody && isElement(xmlData, i)) i += 8;
30052
- else if (hasBody && isAttlist(xmlData, i)) i += 8;
30053
- else if (hasBody && isNotation(xmlData, i)) i += 9;
30054
- else if (isComment) comment = true;
30055
- else throw new Error("Invalid DOCTYPE");
30056
- angleBracketsCount++;
30057
- exp = "";
30058
- } else if (xmlData[i] === ">") {
30059
- if (comment) {
30060
- if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
30061
- comment = false;
30120
+ var DocTypeReader2 = class {
30121
+ constructor(options) {
30122
+ this.suppressValidationErr = !options;
30123
+ this.options = options || {};
30124
+ }
30125
+ readDocType(xmlData, i) {
30126
+ const entities = /* @__PURE__ */ Object.create(null);
30127
+ let entityCount = 0;
30128
+ if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
30129
+ i = i + 9;
30130
+ let angleBracketsCount = 1;
30131
+ let hasBody = false, comment = false;
30132
+ let exp = "";
30133
+ for (; i < xmlData.length; i++) {
30134
+ if (xmlData[i] === "<" && !comment) {
30135
+ if (hasBody && hasSeq2(xmlData, "!ENTITY", i)) {
30136
+ i += 7;
30137
+ let entityName, val;
30138
+ [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
30139
+ if (val.indexOf("&") === -1) {
30140
+ if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
30141
+ throw new Error(
30142
+ `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
30143
+ );
30144
+ }
30145
+ const escaped = entityName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
30146
+ entities[entityName] = {
30147
+ regx: RegExp(`&${escaped};`, "g"),
30148
+ val
30149
+ };
30150
+ entityCount++;
30151
+ }
30152
+ } else if (hasBody && hasSeq2(xmlData, "!ELEMENT", i)) {
30153
+ i += 8;
30154
+ const { index } = this.readElementExp(xmlData, i + 1);
30155
+ i = index;
30156
+ } else if (hasBody && hasSeq2(xmlData, "!ATTLIST", i)) {
30157
+ i += 8;
30158
+ } else if (hasBody && hasSeq2(xmlData, "!NOTATION", i)) {
30159
+ i += 9;
30160
+ const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
30161
+ i = index;
30162
+ } else if (hasSeq2(xmlData, "!--", i)) {
30163
+ comment = true;
30164
+ } else {
30165
+ throw new Error(`Invalid DOCTYPE`);
30166
+ }
30167
+ angleBracketsCount++;
30168
+ exp = "";
30169
+ } else if (xmlData[i] === ">") {
30170
+ if (comment) {
30171
+ if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
30172
+ comment = false;
30173
+ angleBracketsCount--;
30174
+ }
30175
+ } else {
30062
30176
  angleBracketsCount--;
30063
30177
  }
30178
+ if (angleBracketsCount === 0) {
30179
+ break;
30180
+ }
30181
+ } else if (xmlData[i] === "[") {
30182
+ hasBody = true;
30064
30183
  } else {
30065
- angleBracketsCount--;
30184
+ exp += xmlData[i];
30066
30185
  }
30067
- if (angleBracketsCount === 0) {
30068
- break;
30186
+ }
30187
+ if (angleBracketsCount !== 0) {
30188
+ throw new Error(`Unclosed DOCTYPE`);
30189
+ }
30190
+ } else {
30191
+ throw new Error(`Invalid Tag instead of DOCTYPE`);
30192
+ }
30193
+ return { entities, i };
30194
+ }
30195
+ readEntityExp(xmlData, i) {
30196
+ i = skipWhitespace2(xmlData, i);
30197
+ let entityName = "";
30198
+ while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
30199
+ entityName += xmlData[i];
30200
+ i++;
30201
+ }
30202
+ validateEntityName3(entityName);
30203
+ i = skipWhitespace2(xmlData, i);
30204
+ if (!this.suppressValidationErr) {
30205
+ if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
30206
+ throw new Error("External entities are not supported");
30207
+ } else if (xmlData[i] === "%") {
30208
+ throw new Error("Parameter entities are not supported");
30209
+ }
30210
+ }
30211
+ let entityValue = "";
30212
+ [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
30213
+ if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
30214
+ throw new Error(
30215
+ `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
30216
+ );
30217
+ }
30218
+ i--;
30219
+ return [entityName, entityValue, i];
30220
+ }
30221
+ readNotationExp(xmlData, i) {
30222
+ i = skipWhitespace2(xmlData, i);
30223
+ let notationName = "";
30224
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
30225
+ notationName += xmlData[i];
30226
+ i++;
30227
+ }
30228
+ !this.suppressValidationErr && validateEntityName3(notationName);
30229
+ i = skipWhitespace2(xmlData, i);
30230
+ const identifierType = xmlData.substring(i, i + 6).toUpperCase();
30231
+ if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
30232
+ throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
30233
+ }
30234
+ i += identifierType.length;
30235
+ i = skipWhitespace2(xmlData, i);
30236
+ let publicIdentifier = null;
30237
+ let systemIdentifier = null;
30238
+ if (identifierType === "PUBLIC") {
30239
+ [i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
30240
+ i = skipWhitespace2(xmlData, i);
30241
+ if (xmlData[i] === '"' || xmlData[i] === "'") {
30242
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
30243
+ }
30244
+ } else if (identifierType === "SYSTEM") {
30245
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
30246
+ if (!this.suppressValidationErr && !systemIdentifier) {
30247
+ throw new Error("Missing mandatory system identifier for SYSTEM notation");
30248
+ }
30249
+ }
30250
+ return { notationName, publicIdentifier, systemIdentifier, index: --i };
30251
+ }
30252
+ readIdentifierVal(xmlData, i, type) {
30253
+ let identifierVal = "";
30254
+ const startChar = xmlData[i];
30255
+ if (startChar !== '"' && startChar !== "'") {
30256
+ throw new Error(`Expected quoted string, found "${startChar}"`);
30257
+ }
30258
+ i++;
30259
+ while (i < xmlData.length && xmlData[i] !== startChar) {
30260
+ identifierVal += xmlData[i];
30261
+ i++;
30262
+ }
30263
+ if (xmlData[i] !== startChar) {
30264
+ throw new Error(`Unterminated ${type} value`);
30265
+ }
30266
+ i++;
30267
+ return [i, identifierVal];
30268
+ }
30269
+ readElementExp(xmlData, i) {
30270
+ i = skipWhitespace2(xmlData, i);
30271
+ let elementName = "";
30272
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
30273
+ elementName += xmlData[i];
30274
+ i++;
30275
+ }
30276
+ if (!this.suppressValidationErr && !util.isName(elementName)) {
30277
+ throw new Error(`Invalid element name: "${elementName}"`);
30278
+ }
30279
+ i = skipWhitespace2(xmlData, i);
30280
+ let contentModel = "";
30281
+ if (xmlData[i] === "E" && hasSeq2(xmlData, "MPTY", i)) {
30282
+ i += 4;
30283
+ } else if (xmlData[i] === "A" && hasSeq2(xmlData, "NY", i)) {
30284
+ i += 2;
30285
+ } else if (xmlData[i] === "(") {
30286
+ i++;
30287
+ while (i < xmlData.length && xmlData[i] !== ")") {
30288
+ contentModel += xmlData[i];
30289
+ i++;
30290
+ }
30291
+ if (xmlData[i] !== ")") {
30292
+ throw new Error("Unterminated content model");
30293
+ }
30294
+ } else if (!this.suppressValidationErr) {
30295
+ throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
30296
+ }
30297
+ return {
30298
+ elementName,
30299
+ contentModel: contentModel.trim(),
30300
+ index: i
30301
+ };
30302
+ }
30303
+ readAttlistExp(xmlData, i) {
30304
+ i = skipWhitespace2(xmlData, i);
30305
+ let elementName = "";
30306
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
30307
+ elementName += xmlData[i];
30308
+ i++;
30309
+ }
30310
+ validateEntityName3(elementName);
30311
+ i = skipWhitespace2(xmlData, i);
30312
+ let attributeName = "";
30313
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
30314
+ attributeName += xmlData[i];
30315
+ i++;
30316
+ }
30317
+ if (!validateEntityName3(attributeName)) {
30318
+ throw new Error(`Invalid attribute name: "${attributeName}"`);
30319
+ }
30320
+ i = skipWhitespace2(xmlData, i);
30321
+ let attributeType = "";
30322
+ if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
30323
+ attributeType = "NOTATION";
30324
+ i += 8;
30325
+ i = skipWhitespace2(xmlData, i);
30326
+ if (xmlData[i] !== "(") {
30327
+ throw new Error(`Expected '(', found "${xmlData[i]}"`);
30328
+ }
30329
+ i++;
30330
+ let allowedNotations = [];
30331
+ while (i < xmlData.length && xmlData[i] !== ")") {
30332
+ let notation = "";
30333
+ while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
30334
+ notation += xmlData[i];
30335
+ i++;
30069
30336
  }
30070
- } else if (xmlData[i] === "[") {
30071
- hasBody = true;
30072
- } else {
30073
- exp += xmlData[i];
30337
+ notation = notation.trim();
30338
+ if (!validateEntityName3(notation)) {
30339
+ throw new Error(`Invalid notation name: "${notation}"`);
30340
+ }
30341
+ allowedNotations.push(notation);
30342
+ if (xmlData[i] === "|") {
30343
+ i++;
30344
+ i = skipWhitespace2(xmlData, i);
30345
+ }
30346
+ }
30347
+ if (xmlData[i] !== ")") {
30348
+ throw new Error("Unterminated list of notations");
30349
+ }
30350
+ i++;
30351
+ attributeType += " (" + allowedNotations.join("|") + ")";
30352
+ } else {
30353
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
30354
+ attributeType += xmlData[i];
30355
+ i++;
30356
+ }
30357
+ const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
30358
+ if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
30359
+ throw new Error(`Invalid attribute type: "${attributeType}"`);
30074
30360
  }
30075
30361
  }
30076
- if (angleBracketsCount !== 0) {
30077
- throw new Error(`Unclosed DOCTYPE`);
30362
+ i = skipWhitespace2(xmlData, i);
30363
+ let defaultValue = "";
30364
+ if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
30365
+ defaultValue = "#REQUIRED";
30366
+ i += 8;
30367
+ } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
30368
+ defaultValue = "#IMPLIED";
30369
+ i += 7;
30370
+ } else {
30371
+ [i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
30078
30372
  }
30079
- } else {
30080
- throw new Error(`Invalid Tag instead of DOCTYPE`);
30373
+ return {
30374
+ elementName,
30375
+ attributeName,
30376
+ attributeType,
30377
+ defaultValue,
30378
+ index: i
30379
+ };
30081
30380
  }
30082
- return { entities, i };
30083
- }
30084
- function readEntityExp(xmlData, i) {
30085
- let entityName2 = "";
30086
- for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
30087
- entityName2 += xmlData[i];
30381
+ };
30382
+ var skipWhitespace2 = (data, index) => {
30383
+ while (index < data.length && /\s/.test(data[index])) {
30384
+ index++;
30088
30385
  }
30089
- entityName2 = entityName2.trim();
30090
- if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
30091
- const startChar = xmlData[i++];
30092
- let val2 = "";
30093
- for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
30094
- val2 += xmlData[i];
30386
+ return index;
30387
+ };
30388
+ function hasSeq2(data, seq, i) {
30389
+ for (let j = 0; j < seq.length; j++) {
30390
+ if (seq[j] !== data[i + j + 1]) return false;
30095
30391
  }
30096
- return [entityName2, val2, i];
30097
- }
30098
- function isComment(xmlData, i) {
30099
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
30100
- return false;
30101
- }
30102
- function isEntity(xmlData, i) {
30103
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") return true;
30104
- return false;
30105
- }
30106
- function isElement(xmlData, i) {
30107
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") return true;
30108
- return false;
30109
- }
30110
- function isAttlist(xmlData, i) {
30111
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") return true;
30112
- return false;
30113
- }
30114
- function isNotation(xmlData, i) {
30115
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") return true;
30116
- return false;
30392
+ return true;
30117
30393
  }
30118
30394
  function validateEntityName3(name) {
30119
30395
  if (util.isName(name))
@@ -30121,7 +30397,7 @@ var require_DocTypeReader = __commonJS({
30121
30397
  else
30122
30398
  throw new Error(`Invalid entity name ${name}`);
30123
30399
  }
30124
- module2.exports = readDocType;
30400
+ module2.exports = DocTypeReader2;
30125
30401
  }
30126
30402
  });
30127
30403
 
@@ -30213,14 +30489,40 @@ var require_strnum = __commonJS({
30213
30489
  }
30214
30490
  });
30215
30491
 
30492
+ // ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
30493
+ var require_ignoreAttributes = __commonJS({
30494
+ "../../node_modules/fast-xml-parser/src/ignoreAttributes.js"(exports2, module2) {
30495
+ function getIgnoreAttributesFn2(ignoreAttributes) {
30496
+ if (typeof ignoreAttributes === "function") {
30497
+ return ignoreAttributes;
30498
+ }
30499
+ if (Array.isArray(ignoreAttributes)) {
30500
+ return (attrName) => {
30501
+ for (const pattern of ignoreAttributes) {
30502
+ if (typeof pattern === "string" && attrName === pattern) {
30503
+ return true;
30504
+ }
30505
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
30506
+ return true;
30507
+ }
30508
+ }
30509
+ };
30510
+ }
30511
+ return () => false;
30512
+ }
30513
+ module2.exports = getIgnoreAttributesFn2;
30514
+ }
30515
+ });
30516
+
30216
30517
  // ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
30217
30518
  var require_OrderedObjParser = __commonJS({
30218
30519
  "../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js"(exports2, module2) {
30219
30520
  "use strict";
30220
30521
  var util = require_util2();
30221
30522
  var xmlNode = require_xmlNode();
30222
- var readDocType = require_DocTypeReader();
30523
+ var DocTypeReader2 = require_DocTypeReader();
30223
30524
  var toNumber2 = require_strnum();
30525
+ var getIgnoreAttributesFn2 = require_ignoreAttributes();
30224
30526
  var OrderedObjParser2 = class {
30225
30527
  constructor(options) {
30226
30528
  this.options = options;
@@ -30248,8 +30550,8 @@ var require_OrderedObjParser = __commonJS({
30248
30550
  "copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
30249
30551
  "reg": { regex: /&(reg|#174);/g, val: "\xAE" },
30250
30552
  "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
30251
- "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
30252
- "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
30553
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => fromCodePoint(str, 10, "&#") },
30554
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => fromCodePoint(str, 16, "&#x") }
30253
30555
  };
30254
30556
  this.addExternalEntities = addExternalEntities;
30255
30557
  this.parseXml = parseXml3;
@@ -30261,38 +30563,55 @@ var require_OrderedObjParser = __commonJS({
30261
30563
  this.readStopNodeData = readStopNodeData2;
30262
30564
  this.saveTextToParentTag = saveTextToParentTag2;
30263
30565
  this.addChild = addChild2;
30566
+ this.ignoreAttributesFn = getIgnoreAttributesFn2(this.options.ignoreAttributes);
30567
+ this.entityExpansionCount = 0;
30568
+ this.currentExpandedLength = 0;
30569
+ if (this.options.stopNodes && this.options.stopNodes.length > 0) {
30570
+ this.stopNodesExact = /* @__PURE__ */ new Set();
30571
+ this.stopNodesWildcard = /* @__PURE__ */ new Set();
30572
+ for (let i = 0; i < this.options.stopNodes.length; i++) {
30573
+ const stopNodeExp = this.options.stopNodes[i];
30574
+ if (typeof stopNodeExp !== "string") continue;
30575
+ if (stopNodeExp.startsWith("*.")) {
30576
+ this.stopNodesWildcard.add(stopNodeExp.substring(2));
30577
+ } else {
30578
+ this.stopNodesExact.add(stopNodeExp);
30579
+ }
30580
+ }
30581
+ }
30264
30582
  }
30265
30583
  };
30266
30584
  function addExternalEntities(externalEntities) {
30267
30585
  const entKeys = Object.keys(externalEntities);
30268
30586
  for (let i = 0; i < entKeys.length; i++) {
30269
30587
  const ent = entKeys[i];
30588
+ const escaped = ent.replace(/[.\-+*:]/g, "\\.");
30270
30589
  this.lastEntities[ent] = {
30271
- regex: new RegExp("&" + ent + ";", "g"),
30590
+ regex: new RegExp("&" + escaped + ";", "g"),
30272
30591
  val: externalEntities[ent]
30273
30592
  };
30274
30593
  }
30275
30594
  }
30276
- function parseTextData2(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
30277
- if (val2 !== void 0) {
30595
+ function parseTextData2(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
30596
+ if (val !== void 0) {
30278
30597
  if (this.options.trimValues && !dontTrim) {
30279
- val2 = val2.trim();
30598
+ val = val.trim();
30280
30599
  }
30281
- if (val2.length > 0) {
30282
- if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
30283
- const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
30600
+ if (val.length > 0) {
30601
+ if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
30602
+ const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
30284
30603
  if (newval === null || newval === void 0) {
30285
- return val2;
30286
- } else if (typeof newval !== typeof val2 || newval !== val2) {
30604
+ return val;
30605
+ } else if (typeof newval !== typeof val || newval !== val) {
30287
30606
  return newval;
30288
30607
  } else if (this.options.trimValues) {
30289
- return parseValue2(val2, this.options.parseTagValue, this.options.numberParseOptions);
30608
+ return parseValue2(val, this.options.parseTagValue, this.options.numberParseOptions);
30290
30609
  } else {
30291
- const trimmedVal = val2.trim();
30292
- if (trimmedVal === val2) {
30293
- return parseValue2(val2, this.options.parseTagValue, this.options.numberParseOptions);
30610
+ const trimmedVal = val.trim();
30611
+ if (trimmedVal === val) {
30612
+ return parseValue2(val, this.options.parseTagValue, this.options.numberParseOptions);
30294
30613
  } else {
30295
- return val2;
30614
+ return val;
30296
30615
  }
30297
30616
  }
30298
30617
  }
@@ -30313,24 +30632,27 @@ var require_OrderedObjParser = __commonJS({
30313
30632
  }
30314
30633
  var attrsRegx2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
30315
30634
  function buildAttributesMap2(attrStr, jPath, tagName) {
30316
- if (!this.options.ignoreAttributes && typeof attrStr === "string") {
30635
+ if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
30317
30636
  const matches = util.getAllMatches(attrStr, attrsRegx2);
30318
30637
  const len = matches.length;
30319
30638
  const attrs = {};
30320
30639
  for (let i = 0; i < len; i++) {
30321
30640
  const attrName = this.resolveNameSpace(matches[i][1]);
30641
+ if (this.ignoreAttributesFn(attrName, jPath)) {
30642
+ continue;
30643
+ }
30322
30644
  let oldVal = matches[i][4];
30323
30645
  let aName = this.options.attributeNamePrefix + attrName;
30324
30646
  if (attrName.length) {
30325
30647
  if (this.options.transformAttributeName) {
30326
30648
  aName = this.options.transformAttributeName(aName);
30327
30649
  }
30328
- if (aName === "__proto__") aName = "#__proto__";
30650
+ aName = sanitizeName2(aName, this.options);
30329
30651
  if (oldVal !== void 0) {
30330
30652
  if (this.options.trimValues) {
30331
30653
  oldVal = oldVal.trim();
30332
30654
  }
30333
- oldVal = this.replaceEntitiesValue(oldVal);
30655
+ oldVal = this.replaceEntitiesValue(oldVal, tagName, jPath);
30334
30656
  const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
30335
30657
  if (newVal === null || newVal === void 0) {
30336
30658
  attrs[aName] = oldVal;
@@ -30365,6 +30687,9 @@ var require_OrderedObjParser = __commonJS({
30365
30687
  let currentNode = xmlObj;
30366
30688
  let textData = "";
30367
30689
  let jPath = "";
30690
+ this.entityExpansionCount = 0;
30691
+ this.currentExpandedLength = 0;
30692
+ const docTypeReader = new DocTypeReader2(this.options.processEntities);
30368
30693
  for (let i = 0; i < xmlData.length; i++) {
30369
30694
  const ch = xmlData[i];
30370
30695
  if (ch === "<") {
@@ -30409,7 +30734,7 @@ var require_OrderedObjParser = __commonJS({
30409
30734
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
30410
30735
  childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
30411
30736
  }
30412
- this.addChild(currentNode, childNode, jPath);
30737
+ this.addChild(currentNode, childNode, jPath, i);
30413
30738
  }
30414
30739
  i = tagData.closeIndex + 1;
30415
30740
  } else if (xmlData.substr(i + 1, 3) === "!--") {
@@ -30421,19 +30746,19 @@ var require_OrderedObjParser = __commonJS({
30421
30746
  }
30422
30747
  i = endIndex;
30423
30748
  } else if (xmlData.substr(i + 1, 2) === "!D") {
30424
- const result = readDocType(xmlData, i);
30749
+ const result = docTypeReader.readDocType(xmlData, i);
30425
30750
  this.docTypeEntities = result.entities;
30426
30751
  i = result.i;
30427
30752
  } else if (xmlData.substr(i + 1, 2) === "![") {
30428
30753
  const closeIndex = findClosingIndex2(xmlData, "]]>", i, "CDATA is not closed.") - 2;
30429
30754
  const tagExp = xmlData.substring(i + 9, closeIndex);
30430
30755
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
30431
- let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
30432
- if (val2 == void 0) val2 = "";
30756
+ let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
30757
+ if (val == void 0) val = "";
30433
30758
  if (this.options.cdataPropName) {
30434
30759
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
30435
30760
  } else {
30436
- currentNode.add(this.options.textNodeName, val2);
30761
+ currentNode.add(this.options.textNodeName, val);
30437
30762
  }
30438
30763
  i = closeIndex + 2;
30439
30764
  } else {
@@ -30444,7 +30769,14 @@ var require_OrderedObjParser = __commonJS({
30444
30769
  let attrExpPresent = result.attrExpPresent;
30445
30770
  let closeIndex = result.closeIndex;
30446
30771
  if (this.options.transformTagName) {
30447
- tagName = this.options.transformTagName(tagName);
30772
+ const newTagName = this.options.transformTagName(tagName);
30773
+ if (tagExp === tagName) {
30774
+ tagExp = newTagName;
30775
+ }
30776
+ tagName = newTagName;
30777
+ }
30778
+ if (this.options.strictReservedNames && (tagName === this.options.commentPropName || tagName === this.options.cdataPropName || tagName === this.options.textNodeName || tagName === this.options.attributesGroupName)) {
30779
+ throw new Error(`Invalid tag name: ${tagName}`);
30448
30780
  }
30449
30781
  if (currentNode && textData) {
30450
30782
  if (currentNode.tagname !== "!xml") {
@@ -30459,7 +30791,8 @@ var require_OrderedObjParser = __commonJS({
30459
30791
  if (tagName !== xmlObj.tagname) {
30460
30792
  jPath += jPath ? "." + tagName : tagName;
30461
30793
  }
30462
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
30794
+ const startIndex = i;
30795
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
30463
30796
  let tagContent = "";
30464
30797
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
30465
30798
  if (tagName[tagName.length - 1] === "/") {
@@ -30487,7 +30820,7 @@ var require_OrderedObjParser = __commonJS({
30487
30820
  }
30488
30821
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
30489
30822
  childNode.add(this.options.textNodeName, tagContent);
30490
- this.addChild(currentNode, childNode, jPath);
30823
+ this.addChild(currentNode, childNode, jPath, startIndex);
30491
30824
  } else {
30492
30825
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
30493
30826
  if (tagName[tagName.length - 1] === "/") {
@@ -30498,16 +30831,32 @@ var require_OrderedObjParser = __commonJS({
30498
30831
  tagExp = tagExp.substr(0, tagExp.length - 1);
30499
30832
  }
30500
30833
  if (this.options.transformTagName) {
30501
- tagName = this.options.transformTagName(tagName);
30834
+ const newTagName = this.options.transformTagName(tagName);
30835
+ if (tagExp === tagName) {
30836
+ tagExp = newTagName;
30837
+ }
30838
+ tagName = newTagName;
30502
30839
  }
30503
30840
  const childNode = new xmlNode(tagName);
30504
30841
  if (tagName !== tagExp && attrExpPresent) {
30505
30842
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
30506
30843
  }
30507
- this.addChild(currentNode, childNode, jPath);
30844
+ this.addChild(currentNode, childNode, jPath, startIndex);
30845
+ jPath = jPath.substr(0, jPath.lastIndexOf("."));
30846
+ } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
30847
+ const childNode = new xmlNode(tagName);
30848
+ if (tagName !== tagExp && attrExpPresent) {
30849
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
30850
+ }
30851
+ this.addChild(currentNode, childNode, jPath, startIndex);
30508
30852
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
30853
+ i = result.closeIndex;
30854
+ continue;
30509
30855
  } else {
30510
30856
  const childNode = new xmlNode(tagName);
30857
+ if (this.tagsNodeStack.length > this.options.maxNestedTags) {
30858
+ throw new Error("Maximum nested tags exceeded");
30859
+ }
30511
30860
  this.tagsNodeStack.push(currentNode);
30512
30861
  if (tagName !== tagExp && attrExpPresent) {
30513
30862
  childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
@@ -30525,59 +30874,110 @@ var require_OrderedObjParser = __commonJS({
30525
30874
  }
30526
30875
  return xmlObj.child;
30527
30876
  };
30528
- function addChild2(currentNode, childNode, jPath) {
30877
+ function addChild2(currentNode, childNode, jPath, startIndex) {
30878
+ if (!this.options.captureMetaData) startIndex = void 0;
30529
30879
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
30530
30880
  if (result === false) {
30531
30881
  } else if (typeof result === "string") {
30532
30882
  childNode.tagname = result;
30533
- currentNode.addChild(childNode);
30883
+ currentNode.addChild(childNode, startIndex);
30534
30884
  } else {
30535
- currentNode.addChild(childNode);
30885
+ currentNode.addChild(childNode, startIndex);
30536
30886
  }
30537
30887
  }
30538
- var replaceEntitiesValue2 = function(val2) {
30539
- if (this.options.processEntities) {
30540
- for (let entityName2 in this.docTypeEntities) {
30541
- const entity = this.docTypeEntities[entityName2];
30542
- val2 = val2.replace(entity.regx, entity.val);
30888
+ var replaceEntitiesValue2 = function(val, tagName, jPath) {
30889
+ if (val.indexOf("&") === -1) {
30890
+ return val;
30891
+ }
30892
+ const entityConfig = this.options.processEntities;
30893
+ if (!entityConfig.enabled) {
30894
+ return val;
30895
+ }
30896
+ if (entityConfig.allowedTags) {
30897
+ if (!entityConfig.allowedTags.includes(tagName)) {
30898
+ return val;
30543
30899
  }
30544
- for (let entityName2 in this.lastEntities) {
30545
- const entity = this.lastEntities[entityName2];
30546
- val2 = val2.replace(entity.regex, entity.val);
30900
+ }
30901
+ if (entityConfig.tagFilter) {
30902
+ if (!entityConfig.tagFilter(tagName, jPath)) {
30903
+ return val;
30547
30904
  }
30548
- if (this.options.htmlEntities) {
30549
- for (let entityName2 in this.htmlEntities) {
30550
- const entity = this.htmlEntities[entityName2];
30551
- val2 = val2.replace(entity.regex, entity.val);
30905
+ }
30906
+ for (let entityName in this.docTypeEntities) {
30907
+ const entity = this.docTypeEntities[entityName];
30908
+ const matches = val.match(entity.regx);
30909
+ if (matches) {
30910
+ this.entityExpansionCount += matches.length;
30911
+ if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
30912
+ throw new Error(
30913
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
30914
+ );
30915
+ }
30916
+ const lengthBefore = val.length;
30917
+ val = val.replace(entity.regx, entity.val);
30918
+ if (entityConfig.maxExpandedLength) {
30919
+ this.currentExpandedLength += val.length - lengthBefore;
30920
+ if (this.currentExpandedLength > entityConfig.maxExpandedLength) {
30921
+ throw new Error(
30922
+ `Total expanded content size exceeded: ${this.currentExpandedLength} > ${entityConfig.maxExpandedLength}`
30923
+ );
30924
+ }
30552
30925
  }
30553
30926
  }
30554
- val2 = val2.replace(this.ampEntity.regex, this.ampEntity.val);
30555
30927
  }
30556
- return val2;
30928
+ if (val.indexOf("&") === -1) return val;
30929
+ for (const entityName of Object.keys(this.lastEntities)) {
30930
+ const entity = this.lastEntities[entityName];
30931
+ const matches = val.match(entity.regex);
30932
+ if (matches) {
30933
+ this.entityExpansionCount += matches.length;
30934
+ if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
30935
+ throw new Error(
30936
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
30937
+ );
30938
+ }
30939
+ }
30940
+ val = val.replace(entity.regex, entity.val);
30941
+ }
30942
+ if (val.indexOf("&") === -1) return val;
30943
+ if (this.options.htmlEntities) {
30944
+ for (const entityName of Object.keys(this.htmlEntities)) {
30945
+ const entity = this.htmlEntities[entityName];
30946
+ const matches = val.match(entity.regex);
30947
+ if (matches) {
30948
+ this.entityExpansionCount += matches.length;
30949
+ if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
30950
+ throw new Error(
30951
+ `Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
30952
+ );
30953
+ }
30954
+ }
30955
+ val = val.replace(entity.regex, entity.val);
30956
+ }
30957
+ }
30958
+ val = val.replace(this.ampEntity.regex, this.ampEntity.val);
30959
+ return val;
30557
30960
  };
30558
- function saveTextToParentTag2(textData, currentNode, jPath, isLeafNode) {
30961
+ function saveTextToParentTag2(textData, parentNode, jPath, isLeafNode) {
30559
30962
  if (textData) {
30560
- if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
30963
+ if (isLeafNode === void 0) isLeafNode = parentNode.child.length === 0;
30561
30964
  textData = this.parseTextData(
30562
30965
  textData,
30563
- currentNode.tagname,
30966
+ parentNode.tagname,
30564
30967
  jPath,
30565
30968
  false,
30566
- currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
30969
+ parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
30567
30970
  isLeafNode
30568
30971
  );
30569
30972
  if (textData !== void 0 && textData !== "")
30570
- currentNode.add(this.options.textNodeName, textData);
30973
+ parentNode.add(this.options.textNodeName, textData);
30571
30974
  textData = "";
30572
30975
  }
30573
30976
  return textData;
30574
30977
  }
30575
- function isItStopNode2(stopNodes, jPath, currentTagName) {
30576
- const allNodesExp = "*." + currentTagName;
30577
- for (const stopNodePath in stopNodes) {
30578
- const stopNodeExp = stopNodes[stopNodePath];
30579
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
30580
- }
30978
+ function isItStopNode2(stopNodesExact, stopNodesWildcard, jPath, currentTagName) {
30979
+ if (stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
30980
+ if (stopNodesExact && stopNodesExact.has(jPath)) return true;
30581
30981
  return false;
30582
30982
  }
30583
30983
  function tagExpWithClosingIndex2(xmlData, i, closingChar = ">") {
@@ -30685,20 +31085,36 @@ var require_OrderedObjParser = __commonJS({
30685
31085
  }
30686
31086
  }
30687
31087
  }
30688
- function parseValue2(val2, shouldParse, options) {
30689
- if (shouldParse && typeof val2 === "string") {
30690
- const newval = val2.trim();
31088
+ function parseValue2(val, shouldParse, options) {
31089
+ if (shouldParse && typeof val === "string") {
31090
+ const newval = val.trim();
30691
31091
  if (newval === "true") return true;
30692
31092
  else if (newval === "false") return false;
30693
- else return toNumber2(val2, options);
31093
+ else return toNumber2(val, options);
30694
31094
  } else {
30695
- if (util.isExist(val2)) {
30696
- return val2;
31095
+ if (util.isExist(val)) {
31096
+ return val;
30697
31097
  } else {
30698
31098
  return "";
30699
31099
  }
30700
31100
  }
30701
31101
  }
31102
+ function fromCodePoint(str, base, prefix) {
31103
+ const codePoint = Number.parseInt(str, base);
31104
+ if (codePoint >= 0 && codePoint <= 1114111) {
31105
+ return String.fromCodePoint(codePoint);
31106
+ } else {
31107
+ return prefix + str + ";";
31108
+ }
31109
+ }
31110
+ function sanitizeName2(name, options) {
31111
+ if (util.criticalProperties.includes(name)) {
31112
+ throw new Error(`[SECURITY] Invalid name: "${name}" is a reserved JavaScript keyword that could cause prototype pollution`);
31113
+ } else if (util.DANGEROUS_PROPERTY_NAMES.includes(name)) {
31114
+ return options.onDangerousProperty(name);
31115
+ }
31116
+ return name;
31117
+ }
30702
31118
  module2.exports = OrderedObjParser2;
30703
31119
  }
30704
31120
  });
@@ -30725,26 +31141,26 @@ var require_node2json = __commonJS({
30725
31141
  } else if (property === void 0) {
30726
31142
  continue;
30727
31143
  } else if (tagObj[property]) {
30728
- let val2 = compress2(tagObj[property], options, newJpath);
30729
- const isLeaf = isLeafTag2(val2, options);
31144
+ let val = compress2(tagObj[property], options, newJpath);
31145
+ const isLeaf = isLeafTag2(val, options);
30730
31146
  if (tagObj[":@"]) {
30731
- assignAttributes2(val2, tagObj[":@"], newJpath, options);
30732
- } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
30733
- val2 = val2[options.textNodeName];
30734
- } else if (Object.keys(val2).length === 0) {
30735
- if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
30736
- else val2 = "";
31147
+ assignAttributes2(val, tagObj[":@"], newJpath, options);
31148
+ } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
31149
+ val = val[options.textNodeName];
31150
+ } else if (Object.keys(val).length === 0) {
31151
+ if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
31152
+ else val = "";
30737
31153
  }
30738
31154
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
30739
31155
  if (!Array.isArray(compressedObj[property])) {
30740
31156
  compressedObj[property] = [compressedObj[property]];
30741
31157
  }
30742
- compressedObj[property].push(val2);
31158
+ compressedObj[property].push(val);
30743
31159
  } else {
30744
31160
  if (options.isArray(property, newJpath, isLeaf)) {
30745
- compressedObj[property] = [val2];
31161
+ compressedObj[property] = [val];
30746
31162
  } else {
30747
- compressedObj[property] = val2;
31163
+ compressedObj[property] = val;
30748
31164
  }
30749
31165
  }
30750
31166
  }
@@ -30862,6 +31278,14 @@ var require_orderedJs2Xml = __commonJS({
30862
31278
  function arrToStr(arr, options, jPath, indentation) {
30863
31279
  let xmlStr = "";
30864
31280
  let isPreviousElementTag = false;
31281
+ if (!Array.isArray(arr)) {
31282
+ if (arr !== void 0 && arr !== null) {
31283
+ let text = arr.toString();
31284
+ text = replaceEntitiesValue2(text, options);
31285
+ return text;
31286
+ }
31287
+ return "";
31288
+ }
30865
31289
  for (let i = 0; i < arr.length; i++) {
30866
31290
  const tagObj = arr[i];
30867
31291
  const tagName = propName2(tagObj);
@@ -30932,7 +31356,7 @@ var require_orderedJs2Xml = __commonJS({
30932
31356
  const keys2 = Object.keys(obj);
30933
31357
  for (let i = 0; i < keys2.length; i++) {
30934
31358
  const key = keys2[i];
30935
- if (!obj.hasOwnProperty(key)) continue;
31359
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
30936
31360
  if (key !== ":@") return key;
30937
31361
  }
30938
31362
  }
@@ -30940,7 +31364,7 @@ var require_orderedJs2Xml = __commonJS({
30940
31364
  let attrStr = "";
30941
31365
  if (attrMap && !options.ignoreAttributes) {
30942
31366
  for (let attr in attrMap) {
30943
- if (!attrMap.hasOwnProperty(attr)) continue;
31367
+ if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
30944
31368
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
30945
31369
  attrVal = replaceEntitiesValue2(attrVal, options);
30946
31370
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -30978,6 +31402,7 @@ var require_json2xml = __commonJS({
30978
31402
  "../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(exports2, module2) {
30979
31403
  "use strict";
30980
31404
  var buildFromOrderedJs = require_orderedJs2Xml();
31405
+ var getIgnoreAttributesFn2 = require_ignoreAttributes();
30981
31406
  var defaultOptions3 = {
30982
31407
  attributeNamePrefix: "@_",
30983
31408
  attributesGroupName: false,
@@ -31014,11 +31439,12 @@ var require_json2xml = __commonJS({
31014
31439
  };
31015
31440
  function Builder(options) {
31016
31441
  this.options = Object.assign({}, defaultOptions3, options);
31017
- if (this.options.ignoreAttributes || this.options.attributesGroupName) {
31442
+ if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
31018
31443
  this.isAttribute = function() {
31019
31444
  return false;
31020
31445
  };
31021
31446
  } else {
31447
+ this.ignoreAttributesFn = getIgnoreAttributesFn2(this.options.ignoreAttributes);
31022
31448
  this.attrPrefixLen = this.options.attributeNamePrefix.length;
31023
31449
  this.isAttribute = isAttribute;
31024
31450
  }
@@ -31044,38 +31470,41 @@ var require_json2xml = __commonJS({
31044
31470
  [this.options.arrayNodeName]: jObj
31045
31471
  };
31046
31472
  }
31047
- return this.j2x(jObj, 0).val;
31473
+ return this.j2x(jObj, 0, []).val;
31048
31474
  }
31049
31475
  };
31050
- Builder.prototype.j2x = function(jObj, level) {
31476
+ Builder.prototype.j2x = function(jObj, level, ajPath) {
31051
31477
  let attrStr = "";
31052
- let val2 = "";
31478
+ let val = "";
31479
+ const jPath = ajPath.join(".");
31053
31480
  for (let key in jObj) {
31054
31481
  if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
31055
31482
  if (typeof jObj[key] === "undefined") {
31056
31483
  if (this.isAttribute(key)) {
31057
- val2 += "";
31484
+ val += "";
31058
31485
  }
31059
31486
  } else if (jObj[key] === null) {
31060
31487
  if (this.isAttribute(key)) {
31061
- val2 += "";
31488
+ val += "";
31489
+ } else if (key === this.options.cdataPropName) {
31490
+ val += "";
31062
31491
  } else if (key[0] === "?") {
31063
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
31492
+ val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
31064
31493
  } else {
31065
- val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
31494
+ val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
31066
31495
  }
31067
31496
  } else if (jObj[key] instanceof Date) {
31068
- val2 += this.buildTextValNode(jObj[key], key, "", level);
31497
+ val += this.buildTextValNode(jObj[key], key, "", level);
31069
31498
  } else if (typeof jObj[key] !== "object") {
31070
31499
  const attr = this.isAttribute(key);
31071
- if (attr) {
31500
+ if (attr && !this.ignoreAttributesFn(attr, jPath)) {
31072
31501
  attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
31073
- } else {
31502
+ } else if (!attr) {
31074
31503
  if (key === this.options.textNodeName) {
31075
31504
  let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
31076
- val2 += this.replaceEntitiesValue(newval);
31505
+ val += this.replaceEntitiesValue(newval);
31077
31506
  } else {
31078
- val2 += this.buildTextValNode(jObj[key], key, "", level);
31507
+ val += this.buildTextValNode(jObj[key], key, "", level);
31079
31508
  }
31080
31509
  }
31081
31510
  } else if (Array.isArray(jObj[key])) {
@@ -31086,17 +31515,17 @@ var require_json2xml = __commonJS({
31086
31515
  const item = jObj[key][j];
31087
31516
  if (typeof item === "undefined") {
31088
31517
  } else if (item === null) {
31089
- if (key[0] === "?") val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
31090
- else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
31518
+ if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
31519
+ else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
31091
31520
  } else if (typeof item === "object") {
31092
31521
  if (this.options.oneListGroup) {
31093
- const result = this.j2x(item, level + 1);
31522
+ const result = this.j2x(item, level + 1, ajPath.concat(key));
31094
31523
  listTagVal += result.val;
31095
31524
  if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
31096
31525
  listTagAttr += result.attrStr;
31097
31526
  }
31098
31527
  } else {
31099
- listTagVal += this.processTextOrObjNode(item, key, level);
31528
+ listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
31100
31529
  }
31101
31530
  } else {
31102
31531
  if (this.options.oneListGroup) {
@@ -31111,7 +31540,7 @@ var require_json2xml = __commonJS({
31111
31540
  if (this.options.oneListGroup) {
31112
31541
  listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
31113
31542
  }
31114
- val2 += listTagVal;
31543
+ val += listTagVal;
31115
31544
  } else {
31116
31545
  if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
31117
31546
  const Ks = Object.keys(jObj[key]);
@@ -31120,29 +31549,29 @@ var require_json2xml = __commonJS({
31120
31549
  attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
31121
31550
  }
31122
31551
  } else {
31123
- val2 += this.processTextOrObjNode(jObj[key], key, level);
31552
+ val += this.processTextOrObjNode(jObj[key], key, level, ajPath);
31124
31553
  }
31125
31554
  }
31126
31555
  }
31127
- return { attrStr, val: val2 };
31556
+ return { attrStr, val };
31128
31557
  };
31129
- Builder.prototype.buildAttrPairStr = function(attrName, val2) {
31130
- val2 = this.options.attributeValueProcessor(attrName, "" + val2);
31131
- val2 = this.replaceEntitiesValue(val2);
31132
- if (this.options.suppressBooleanAttributes && val2 === "true") {
31558
+ Builder.prototype.buildAttrPairStr = function(attrName, val) {
31559
+ val = this.options.attributeValueProcessor(attrName, "" + val);
31560
+ val = this.replaceEntitiesValue(val);
31561
+ if (this.options.suppressBooleanAttributes && val === "true") {
31133
31562
  return " " + attrName;
31134
- } else return " " + attrName + '="' + val2 + '"';
31563
+ } else return " " + attrName + '="' + val + '"';
31135
31564
  };
31136
- function processTextOrObjNode(object, key, level) {
31137
- const result = this.j2x(object, level + 1);
31565
+ function processTextOrObjNode(object, key, level, ajPath) {
31566
+ const result = this.j2x(object, level + 1, ajPath.concat(key));
31138
31567
  if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
31139
31568
  return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
31140
31569
  } else {
31141
31570
  return this.buildObjectNode(result.val, key, result.attrStr, level);
31142
31571
  }
31143
31572
  }
31144
- Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
31145
- if (val2 === "") {
31573
+ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
31574
+ if (val === "") {
31146
31575
  if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
31147
31576
  else {
31148
31577
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
@@ -31154,12 +31583,12 @@ var require_json2xml = __commonJS({
31154
31583
  piClosingChar = "?";
31155
31584
  tagEndExp = "";
31156
31585
  }
31157
- if ((attrStr || attrStr === "") && val2.indexOf("<") === -1) {
31158
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
31586
+ if ((attrStr || attrStr === "") && val.indexOf("<") === -1) {
31587
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
31159
31588
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
31160
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
31589
+ return this.indentate(level) + `<!--${val}-->` + this.newLine;
31161
31590
  } else {
31162
- return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val2 + this.indentate(level) + tagEndExp;
31591
+ return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
31163
31592
  }
31164
31593
  }
31165
31594
  };
@@ -31174,15 +31603,15 @@ var require_json2xml = __commonJS({
31174
31603
  }
31175
31604
  return closeTag;
31176
31605
  };
31177
- Builder.prototype.buildTextValNode = function(val2, key, attrStr, level) {
31606
+ Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
31178
31607
  if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
31179
- return this.indentate(level) + `<![CDATA[${val2}]]>` + this.newLine;
31608
+ return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
31180
31609
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
31181
- return this.indentate(level) + `<!--${val2}-->` + this.newLine;
31610
+ return this.indentate(level) + `<!--${val}-->` + this.newLine;
31182
31611
  } else if (key[0] === "?") {
31183
31612
  return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
31184
31613
  } else {
31185
- let textValue = this.options.tagValueProcessor(key, val2);
31614
+ let textValue = this.options.tagValueProcessor(key, val);
31186
31615
  textValue = this.replaceEntitiesValue(textValue);
31187
31616
  if (textValue === "") {
31188
31617
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
@@ -31504,10 +31933,13 @@ var LoticsClient = class {
31504
31933
  return absolutePath;
31505
31934
  }
31506
31935
  async downloadFileById(fileId, outputDir, options) {
31507
- const url = `${this.baseUrl}/v1/files/${encodeURIComponent(fileId)}/download`;
31508
- const response = await fetch(url, {
31509
- headers: this.buildHeaders()
31510
- });
31936
+ const signedUrlRes = await fetch(
31937
+ `${this.baseUrl}/v1/files/${encodeURIComponent(fileId)}/signed_url`,
31938
+ { headers: this.buildHeaders() }
31939
+ );
31940
+ if (!signedUrlRes.ok) await this.throwResponseError(signedUrlRes);
31941
+ const { url } = await signedUrlRes.json();
31942
+ const response = await fetch(url);
31511
31943
  if (!response.ok) await this.throwResponseError(response);
31512
31944
  const disposition = response.headers.get("content-disposition") ?? "";
31513
31945
  const match = disposition.match(/filename="?([^";\n]+)"?/);
@@ -31566,6 +31998,9 @@ var LoticsClient = class {
31566
31998
  import fs2 from "node:fs";
31567
31999
  import path2 from "node:path";
31568
32000
  import os from "node:os";
32001
+ function globalConfigFile() {
32002
+ return path2.join(os.homedir(), ".lotics", "config.json");
32003
+ }
31569
32004
  function configFileForScope(scope) {
31570
32005
  if (scope === "local") {
31571
32006
  return path2.join(process.cwd(), ".lotics", "config.json");
@@ -31582,21 +32017,25 @@ function configFileForScope(scope) {
31582
32017
  }
31583
32018
  dir = parent;
31584
32019
  }
31585
- return path2.join(os.homedir(), ".lotics", "config.json");
32020
+ return globalConfigFile();
31586
32021
  }
31587
- function loadConfig(scope = "auto") {
32022
+ function readConfigFile(file) {
31588
32023
  try {
31589
- const raw = fs2.readFileSync(configFileForScope(scope), "utf-8");
32024
+ const raw = fs2.readFileSync(file, "utf-8");
31590
32025
  return JSON.parse(raw);
31591
32026
  } catch {
31592
32027
  return null;
31593
32028
  }
31594
32029
  }
31595
- function saveConfig(config, scope = "auto") {
31596
- const file = configFileForScope(scope);
32030
+ function writeConfigFile(file, config) {
31597
32031
  fs2.mkdirSync(path2.dirname(file), { recursive: true, mode: 448 });
31598
- fs2.writeFileSync(file, JSON.stringify(config, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
31599
- fs2.chmodSync(file, 384);
32032
+ const tmp = `${file}.${process.pid}.tmp`;
32033
+ fs2.writeFileSync(tmp, JSON.stringify(config, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
32034
+ fs2.chmodSync(tmp, 384);
32035
+ fs2.renameSync(tmp, file);
32036
+ }
32037
+ function saveConfig(config, scope = "auto") {
32038
+ writeConfigFile(configFileForScope(scope), config);
31600
32039
  }
31601
32040
  function deleteConfig(scope = "auto") {
31602
32041
  try {
@@ -31607,9 +32046,154 @@ function deleteConfig(scope = "auto") {
31607
32046
  function getConfigPath(scope = "auto") {
31608
32047
  return configFileForScope(scope);
31609
32048
  }
32049
+ function loadGlobalConfig() {
32050
+ return readConfigFile(globalConfigFile());
32051
+ }
32052
+ function saveGlobalConfig(config) {
32053
+ writeConfigFile(globalConfigFile(), config);
32054
+ }
32055
+ function loadLocalConfig() {
32056
+ const file = configFileForScope("auto");
32057
+ if (file === globalConfigFile()) return null;
32058
+ return readConfigFile(file);
32059
+ }
32060
+ function resolveProfileByNameOrId(profiles, nameOrId) {
32061
+ const byId = profiles[nameOrId];
32062
+ if (byId) return [nameOrId, byId];
32063
+ const matches = Object.entries(profiles).filter(
32064
+ ([, p]) => p.org_name.toLowerCase() === nameOrId.toLowerCase()
32065
+ );
32066
+ if (matches.length === 1) return matches[0];
32067
+ if (matches.length > 1) {
32068
+ throw new Error(
32069
+ `"${nameOrId}" matches multiple saved orgs: ${matches.map(([id]) => id).join(", ")}. Use the org id.`
32070
+ );
32071
+ }
32072
+ return null;
32073
+ }
32074
+ function resolveContext(flags) {
32075
+ const envKey = process.env.LOTICS_API_KEY;
32076
+ const envOrg = process.env.LOTICS_ORG;
32077
+ const envWorkspace = process.env.LOTICS_WORKSPACE;
32078
+ const wsOverride = flags.workspace ?? envWorkspace;
32079
+ if (flags.apiKey) {
32080
+ return { apiKey: flags.apiKey, workspaceId: wsOverride, source: "flag" };
32081
+ }
32082
+ if (envKey) {
32083
+ return { apiKey: envKey, workspaceId: wsOverride, source: "env_key" };
32084
+ }
32085
+ const global2 = loadGlobalConfig();
32086
+ const profiles = global2?.profiles ?? {};
32087
+ if (envOrg) {
32088
+ const resolved = resolveProfileByNameOrId(profiles, envOrg);
32089
+ if (!resolved) {
32090
+ throw new Error(
32091
+ `LOTICS_ORG="${envOrg}" matches no saved credential. Run "lotics org" to list, or "lotics auth api-key <key>" to add one.`
32092
+ );
32093
+ }
32094
+ const [orgId, profile] = resolved;
32095
+ return {
32096
+ apiKey: profile.api_key,
32097
+ orgId,
32098
+ orgName: profile.org_name,
32099
+ workspaceId: wsOverride ?? profile.workspace_id,
32100
+ source: "env_org"
32101
+ };
32102
+ }
32103
+ const local = loadLocalConfig();
32104
+ if (local?.active_org) {
32105
+ const profile = profiles[local.active_org];
32106
+ if (!profile) {
32107
+ throw new Error(
32108
+ `This directory is pinned to org "${local.active_org}" (.lotics/config.json) but no saved credential exists for it. Run "lotics auth api-key <key>" while authenticated to that org.`
32109
+ );
32110
+ }
32111
+ return {
32112
+ apiKey: profile.api_key,
32113
+ orgId: local.active_org,
32114
+ orgName: profile.org_name,
32115
+ workspaceId: wsOverride ?? local.workspace_id ?? profile.workspace_id,
32116
+ source: "local_pointer"
32117
+ };
32118
+ }
32119
+ if (local && "api_key" in local) {
32120
+ throw new Error(
32121
+ `This directory's .lotics/config.json uses the old self-contained format (inline key), which is no longer supported. Re-pin with "lotics auth api-key <key> --local" (or "lotics org use <name|id> --local").`
32122
+ );
32123
+ }
32124
+ if (global2?.active_org) {
32125
+ const profile = profiles[global2.active_org];
32126
+ if (!profile) {
32127
+ throw new Error(
32128
+ `Active org "${global2.active_org}" has no saved credential. Run "lotics org use <name|id>" to pick one, or "lotics auth api-key <key>".`
32129
+ );
32130
+ }
32131
+ return {
32132
+ apiKey: profile.api_key,
32133
+ orgId: global2.active_org,
32134
+ orgName: profile.org_name,
32135
+ workspaceId: wsOverride ?? profile.workspace_id,
32136
+ source: "global_profile"
32137
+ };
32138
+ }
32139
+ return null;
32140
+ }
32141
+ function upsertProfile(orgId, fields) {
32142
+ const config = loadGlobalConfig() ?? {};
32143
+ const existing = config.profiles?.[orgId];
32144
+ const profile = {
32145
+ api_key: fields.api_key,
32146
+ org_name: fields.org_name,
32147
+ workspace_id: fields.workspace_id ?? existing?.workspace_id
32148
+ };
32149
+ saveGlobalConfig({
32150
+ profiles: { ...config.profiles, [orgId]: profile },
32151
+ active_org: config.active_org,
32152
+ email: config.email,
32153
+ last_update_check: config.last_update_check,
32154
+ latest_version: config.latest_version
32155
+ });
32156
+ }
32157
+ function removeProfile(orgId) {
32158
+ const config = loadGlobalConfig();
32159
+ if (!config?.profiles?.[orgId]) return;
32160
+ const { [orgId]: _removed, ...rest } = config.profiles;
32161
+ const remaining = Object.keys(rest);
32162
+ saveGlobalConfig({
32163
+ ...config,
32164
+ profiles: rest,
32165
+ active_org: config.active_org === orgId ? remaining[0] : config.active_org
32166
+ });
32167
+ }
32168
+ function setActiveOrg(orgId, scope) {
32169
+ if (scope === "local") {
32170
+ saveConfig({ active_org: orgId }, "local");
32171
+ return;
32172
+ }
32173
+ const config = loadGlobalConfig() ?? {};
32174
+ saveGlobalConfig({ ...config, active_org: orgId });
32175
+ }
32176
+ function setSelectedWorkspace(workspaceId) {
32177
+ const local = loadLocalConfig();
32178
+ if (local?.active_org) {
32179
+ saveConfig({ ...local, workspace_id: workspaceId }, "auto");
32180
+ return { scope: "local", orgId: local.active_org };
32181
+ }
32182
+ const config = loadGlobalConfig() ?? {};
32183
+ const orgId = config.active_org;
32184
+ const profile = orgId ? config.profiles?.[orgId] : void 0;
32185
+ if (!orgId || !profile) {
32186
+ return null;
32187
+ }
32188
+ saveGlobalConfig({
32189
+ ...config,
32190
+ profiles: { ...config.profiles, [orgId]: { ...profile, workspace_id: workspaceId } }
32191
+ });
32192
+ return { scope: "global", orgId };
32193
+ }
31610
32194
  var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
31611
32195
  function checkForUpdate(currentVersion) {
31612
- const config = loadConfig();
32196
+ const config = loadGlobalConfig();
31613
32197
  const lastCheck = config?.last_update_check ?? 0;
31614
32198
  if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) {
31615
32199
  if (config?.latest_version && config.latest_version !== currentVersion) {
@@ -31619,8 +32203,8 @@ function checkForUpdate(currentVersion) {
31619
32203
  }
31620
32204
  fetchLatestVersion().then((latest) => {
31621
32205
  if (!latest) return;
31622
- const existing = loadConfig() ?? {};
31623
- saveConfig({ ...existing, last_update_check: Date.now(), latest_version: latest });
32206
+ const existing = loadGlobalConfig() ?? {};
32207
+ saveGlobalConfig({ ...existing, last_update_check: Date.now(), latest_version: latest });
31624
32208
  }).catch(() => {
31625
32209
  });
31626
32210
  }
@@ -31655,12 +32239,6 @@ Update available: ${current} \u2192 ${latest}`);
31655
32239
  console.error(`Run: npm i -g @lotics/cli
31656
32240
  `);
31657
32241
  }
31658
- function resolveAuth(flags) {
31659
- const config = loadConfig();
31660
- const apiKey = flags.apiKey ?? process.env.LOTICS_API_KEY ?? config?.api_key;
31661
- if (!apiKey) return null;
31662
- return { apiKey };
31663
- }
31664
32242
 
31665
32243
  // src/version.ts
31666
32244
  import { readFileSync } from "node:fs";
@@ -32773,6 +33351,12 @@ async function appSetSubdomain(client, args) {
32773
33351
  const result = await client.setAppSubdomain(meta.app_id, args.subdomain);
32774
33352
  console.error(`Public address set: https://${result.public_subdomain}.lotics.app`);
32775
33353
  }
33354
+ async function appRename(client, args) {
33355
+ const meta = readAppMeta(process.cwd());
33356
+ const res = await client.execute("update_app", { app_id: meta.app_id, name: args.name });
33357
+ if (res.error) throw new Error(res.error);
33358
+ console.error(`App renamed: "${args.name}" (${meta.app_id})`);
33359
+ }
32776
33360
  async function appPull(client, args) {
32777
33361
  const app = await client.getApp(args.app_id);
32778
33362
  if (!app.current_version_id) {
@@ -32933,11 +33517,13 @@ function parseArgs(argv) {
32933
33517
  output: void 0,
32934
33518
  as: void 0,
32935
33519
  apiKey: void 0,
33520
+ workspace: void 0,
32936
33521
  name: void 0,
32937
33522
  timezone: void 0,
32938
33523
  message: void 0,
32939
33524
  forceWorkflowSync: false,
32940
33525
  local: false,
33526
+ all: false,
32941
33527
  version: false,
32942
33528
  help: false
32943
33529
  };
@@ -32965,6 +33551,10 @@ function parseArgs(argv) {
32965
33551
  case "--api-key":
32966
33552
  flags.apiKey = argv[++i];
32967
33553
  break;
33554
+ case "--workspace":
33555
+ case "-w":
33556
+ flags.workspace = argv[++i];
33557
+ break;
32968
33558
  case "--name":
32969
33559
  flags.name = argv[++i];
32970
33560
  break;
@@ -32981,6 +33571,9 @@ function parseArgs(argv) {
32981
33571
  case "--local":
32982
33572
  flags.local = true;
32983
33573
  break;
33574
+ case "--all":
33575
+ flags.all = true;
33576
+ break;
32984
33577
  case "--version":
32985
33578
  case "-v":
32986
33579
  flags.version = true;
@@ -34506,9 +35099,9 @@ function mergeEntityMaps(...maps) {
34506
35099
  if (typeof raw === "string") {
34507
35100
  out[key] = raw;
34508
35101
  } else if (raw && typeof raw === "object" && raw.val !== void 0) {
34509
- const val2 = raw.val;
34510
- if (typeof val2 === "string") {
34511
- out[key] = val2;
35102
+ const val = raw.val;
35103
+ if (typeof val === "string") {
35104
+ out[key] = val;
34512
35105
  }
34513
35106
  }
34514
35107
  }
@@ -34881,11 +35474,11 @@ var defaultOptions2 = {
34881
35474
  leadingZeros: true,
34882
35475
  eNotation: true
34883
35476
  },
34884
- tagValueProcessor: function(tagName, val2) {
34885
- return val2;
35477
+ tagValueProcessor: function(tagName, val) {
35478
+ return val;
34886
35479
  },
34887
- attributeValueProcessor: function(attrName, val2) {
34888
- return val2;
35480
+ attributeValueProcessor: function(attrName, val) {
35481
+ return val;
34889
35482
  },
34890
35483
  stopNodes: [],
34891
35484
  //nested tags will not be parsed even for errors
@@ -35000,9 +35593,9 @@ var XmlNode = class {
35000
35593
  this.child = [];
35001
35594
  this[":@"] = /* @__PURE__ */ Object.create(null);
35002
35595
  }
35003
- add(key, val2) {
35596
+ add(key, val) {
35004
35597
  if (key === "__proto__") key = "#__proto__";
35005
- this.child.push({ [key]: val2 });
35598
+ this.child.push({ [key]: val });
35006
35599
  }
35007
35600
  addChild(node, startIndex) {
35008
35601
  if (node.tagname === "__proto__") node.tagname = "#__proto__";
@@ -35065,15 +35658,15 @@ var DocTypeReader = class {
35065
35658
  if (xmlData[i] === "<" && !comment) {
35066
35659
  if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
35067
35660
  i += 7;
35068
- let entityName2, val2;
35069
- [entityName2, val2, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
35070
- if (val2.indexOf("&") === -1) {
35661
+ let entityName, val;
35662
+ [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
35663
+ if (val.indexOf("&") === -1) {
35071
35664
  if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
35072
35665
  throw new Error(
35073
35666
  `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
35074
35667
  );
35075
35668
  }
35076
- entities[entityName2] = val2;
35669
+ entities[entityName] = val;
35077
35670
  entityCount++;
35078
35671
  }
35079
35672
  } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
@@ -35122,8 +35715,8 @@ var DocTypeReader = class {
35122
35715
  while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
35123
35716
  i++;
35124
35717
  }
35125
- let entityName2 = xmlData.substring(startIndex, i);
35126
- validateEntityName2(entityName2, { xmlVersion: this.xmlVersion });
35718
+ let entityName = xmlData.substring(startIndex, i);
35719
+ validateEntityName2(entityName, { xmlVersion: this.xmlVersion });
35127
35720
  i = skipWhitespace(xmlData, i);
35128
35721
  if (!this.suppressValidationErr) {
35129
35722
  if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
@@ -35136,11 +35729,11 @@ var DocTypeReader = class {
35136
35729
  [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
35137
35730
  if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
35138
35731
  throw new Error(
35139
- `Entity "${entityName2}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
35732
+ `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
35140
35733
  );
35141
35734
  }
35142
35735
  i--;
35143
- return [entityName2, entityValue, i];
35736
+ return [entityName, entityValue, i];
35144
35737
  }
35145
35738
  readNotationExp(xmlData, i) {
35146
35739
  i = skipWhitespace(xmlData, i);
@@ -36321,28 +36914,28 @@ var OrderedObjParser = class {
36321
36914
  }
36322
36915
  }
36323
36916
  };
36324
- function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
36917
+ function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
36325
36918
  const options = this.options;
36326
- if (val2 !== void 0) {
36919
+ if (val !== void 0) {
36327
36920
  if (options.trimValues && !dontTrim) {
36328
- val2 = val2.trim();
36921
+ val = val.trim();
36329
36922
  }
36330
- if (val2.length > 0) {
36331
- if (!escapeEntities) val2 = this.replaceEntitiesValue(val2, tagName, jPath);
36923
+ if (val.length > 0) {
36924
+ if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath);
36332
36925
  const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
36333
- const newval = options.tagValueProcessor(tagName, val2, jPathOrMatcher, hasAttributes, isLeafNode);
36926
+ const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
36334
36927
  if (newval === null || newval === void 0) {
36335
- return val2;
36336
- } else if (typeof newval !== typeof val2 || newval !== val2) {
36928
+ return val;
36929
+ } else if (typeof newval !== typeof val || newval !== val) {
36337
36930
  return newval;
36338
36931
  } else if (options.trimValues) {
36339
- return parseValue(val2, options.parseTagValue, options.numberParseOptions);
36932
+ return parseValue(val, options.parseTagValue, options.numberParseOptions);
36340
36933
  } else {
36341
- const trimmedVal = val2.trim();
36342
- if (trimmedVal === val2) {
36343
- return parseValue(val2, options.parseTagValue, options.numberParseOptions);
36934
+ const trimmedVal = val.trim();
36935
+ if (trimmedVal === val) {
36936
+ return parseValue(val, options.parseTagValue, options.numberParseOptions);
36344
36937
  } else {
36345
- return val2;
36938
+ return val;
36346
36939
  }
36347
36940
  }
36348
36941
  }
@@ -36375,11 +36968,11 @@ function buildAttributesMap(attrStr, jPath, tagName, force = false) {
36375
36968
  const attrName = this.resolveNameSpace(matches[i][1]);
36376
36969
  const oldVal = matches[i][4];
36377
36970
  if (attrName.length && oldVal !== void 0) {
36378
- let val2 = oldVal;
36379
- if (options.trimValues) val2 = val2.trim();
36380
- val2 = this.replaceEntitiesValue(val2, tagName, this.readonlyMatcher);
36381
- processedVals[i] = val2;
36382
- rawAttrsForMatcher[attrName] = val2;
36971
+ let val = oldVal;
36972
+ if (options.trimValues) val = val.trim();
36973
+ val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
36974
+ processedVals[i] = val;
36975
+ rawAttrsForMatcher[attrName] = val;
36383
36976
  hasRawAttrs = true;
36384
36977
  }
36385
36978
  }
@@ -36501,12 +37094,12 @@ var parseXml = function(xmlData) {
36501
37094
  const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
36502
37095
  const tagExp = xmlData.substring(i + 9, closeIndex);
36503
37096
  textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
36504
- let val2 = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
36505
- if (val2 == void 0) val2 = "";
37097
+ let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
37098
+ if (val == void 0) val = "";
36506
37099
  if (options.cdataPropName) {
36507
37100
  currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
36508
37101
  } else {
36509
- currentNode.add(options.textNodeName, val2);
37102
+ currentNode.add(options.textNodeName, val);
36510
37103
  }
36511
37104
  i = closeIndex + 2;
36512
37105
  } else {
@@ -36636,25 +37229,25 @@ function addChild(currentNode, childNode, matcher, startIndex) {
36636
37229
  currentNode.addChild(childNode, startIndex);
36637
37230
  }
36638
37231
  }
36639
- function replaceEntitiesValue(val2, tagName, jPath) {
37232
+ function replaceEntitiesValue(val, tagName, jPath) {
36640
37233
  const entityConfig = this.options.processEntities;
36641
37234
  if (!entityConfig || !entityConfig.enabled) {
36642
- return val2;
37235
+ return val;
36643
37236
  }
36644
37237
  if (entityConfig.allowedTags) {
36645
37238
  const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
36646
37239
  const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
36647
37240
  if (!allowed) {
36648
- return val2;
37241
+ return val;
36649
37242
  }
36650
37243
  }
36651
37244
  if (entityConfig.tagFilter) {
36652
37245
  const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
36653
37246
  if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
36654
- return val2;
37247
+ return val;
36655
37248
  }
36656
37249
  }
36657
- return this.entityDecoder.decode(val2);
37250
+ return this.entityDecoder.decode(val);
36658
37251
  }
36659
37252
  function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
36660
37253
  if (textData) {
@@ -36789,15 +37382,15 @@ function readStopNodeData(xmlData, tagName, i) {
36789
37382
  }
36790
37383
  }
36791
37384
  }
36792
- function parseValue(val2, shouldParse, options) {
36793
- if (shouldParse && typeof val2 === "string") {
36794
- const newval = val2.trim();
37385
+ function parseValue(val, shouldParse, options) {
37386
+ if (shouldParse && typeof val === "string") {
37387
+ const newval = val.trim();
36795
37388
  if (newval === "true") return true;
36796
37389
  else if (newval === "false") return false;
36797
- else return toNumber(val2, options);
37390
+ else return toNumber(val, options);
36798
37391
  } else {
36799
- if (isExist(val2)) {
36800
- return val2;
37392
+ if (isExist(val)) {
37393
+ return val;
36801
37394
  } else {
36802
37395
  return "";
36803
37396
  }
@@ -36861,33 +37454,33 @@ function compress(arr, options, matcher, readonlyMatcher) {
36861
37454
  } else if (property === void 0) {
36862
37455
  continue;
36863
37456
  } else if (tagObj[property]) {
36864
- let val2 = compress(tagObj[property], options, matcher, readonlyMatcher);
36865
- const isLeaf = isLeafTag(val2, options);
36866
- if (Object.keys(val2).length === 0 && options.alwaysCreateTextNode) {
36867
- val2[options.textNodeName] = "";
37457
+ let val = compress(tagObj[property], options, matcher, readonlyMatcher);
37458
+ const isLeaf = isLeafTag(val, options);
37459
+ if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
37460
+ val[options.textNodeName] = "";
36868
37461
  }
36869
37462
  if (tagObj[":@"]) {
36870
- assignAttributes(val2, tagObj[":@"], readonlyMatcher, options);
36871
- } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
36872
- val2 = val2[options.textNodeName];
36873
- } else if (Object.keys(val2).length === 0) {
36874
- if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
36875
- else val2 = "";
37463
+ assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
37464
+ } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
37465
+ val = val[options.textNodeName];
37466
+ } else if (Object.keys(val).length === 0) {
37467
+ if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
37468
+ else val = "";
36876
37469
  }
36877
- if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val2 === "object" && val2 !== null) {
36878
- val2[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
37470
+ if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
37471
+ val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
36879
37472
  }
36880
37473
  if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
36881
37474
  if (!Array.isArray(compressedObj[property])) {
36882
37475
  compressedObj[property] = [compressedObj[property]];
36883
37476
  }
36884
- compressedObj[property].push(val2);
37477
+ compressedObj[property].push(val);
36885
37478
  } else {
36886
37479
  const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
36887
37480
  if (options.isArray(property, jPathOrMatcher, isLeaf)) {
36888
- compressedObj[property] = [val2];
37481
+ compressedObj[property] = [val];
36889
37482
  } else {
36890
- compressedObj[property] = val2;
37483
+ compressedObj[property] = val;
36891
37484
  }
36892
37485
  }
36893
37486
  if (property !== void 0 && property !== options.textNodeName) {
@@ -37725,14 +38318,14 @@ function inflateSync(data, opts) {
37725
38318
  }
37726
38319
  var fltn = function(d, p, t, o) {
37727
38320
  for (var k in d) {
37728
- var val2 = d[k], n = p + k, op = o;
37729
- if (Array.isArray(val2))
37730
- op = mrg(o, val2[1]), val2 = val2[0];
37731
- if (val2 instanceof u8)
37732
- t[n] = [val2, op];
38321
+ var val = d[k], n = p + k, op = o;
38322
+ if (Array.isArray(val))
38323
+ op = mrg(o, val[1]), val = val[0];
38324
+ if (val instanceof u8)
38325
+ t[n] = [val, op];
37733
38326
  else {
37734
38327
  t[n += "/"] = [new u8(0), op];
37735
- fltn(val2, n, t, o);
38328
+ fltn(val, n, t, o);
37736
38329
  }
37737
38330
  }
37738
38331
  };
@@ -38119,14 +38712,14 @@ function extractSchemeColor(el) {
38119
38712
  if (!el) return "000000";
38120
38713
  const srgb = el["a:srgbClr"];
38121
38714
  if (srgb) {
38122
- const val2 = Array.isArray(srgb) ? srgb[0] : srgb;
38123
- const hex = typeof val2 === "object" && val2 !== null ? val2["@_val"] : void 0;
38715
+ const val = Array.isArray(srgb) ? srgb[0] : srgb;
38716
+ const hex = typeof val === "object" && val !== null ? val["@_val"] : void 0;
38124
38717
  if (hex) return hex;
38125
38718
  }
38126
38719
  const sys = el["a:sysClr"];
38127
38720
  if (sys) {
38128
- const val2 = Array.isArray(sys) ? sys[0] : sys;
38129
- const lastClr = typeof val2 === "object" && val2 !== null ? val2["@_lastClr"] : void 0;
38721
+ const val = Array.isArray(sys) ? sys[0] : sys;
38722
+ const lastClr = typeof val === "object" && val !== null ? val["@_lastClr"] : void 0;
38130
38723
  if (lastClr) return lastClr;
38131
38724
  }
38132
38725
  return "000000";
@@ -39906,9 +40499,9 @@ function parsePageSetupElement(worksheet) {
39906
40499
  for (const [key, def] of fields) {
39907
40500
  const raw = pm[`@_${key}`];
39908
40501
  if (raw === void 0) continue;
39909
- const val2 = parseFloat(raw);
39910
- if (!Number.isNaN(val2) && Math.abs(val2 - def) > 1e-6) {
39911
- margins[key] = val2;
40502
+ const val = parseFloat(raw);
40503
+ if (!Number.isNaN(val) && Math.abs(val - def) > 1e-6) {
40504
+ margins[key] = val;
39912
40505
  anyNonDefault = true;
39913
40506
  }
39914
40507
  }
@@ -39921,11 +40514,11 @@ function parseHeaderFooterElement(worksheet) {
39921
40514
  if (!hf) return void 0;
39922
40515
  const out = {};
39923
40516
  const readText = (key) => {
39924
- const val2 = hf[key];
40517
+ const val = hf[key];
39925
40518
  let raw;
39926
- if (typeof val2 === "string") raw = val2;
39927
- else if (val2 && typeof val2 === "object" && "#text" in val2 && typeof val2["#text"] === "string") {
39928
- raw = val2["#text"];
40519
+ if (typeof val === "string") raw = val;
40520
+ else if (val && typeof val === "object" && "#text" in val && typeof val["#text"] === "string") {
40521
+ raw = val["#text"];
39929
40522
  }
39930
40523
  return raw !== void 0 ? decodeXmlEntities(raw) : void 0;
39931
40524
  };
@@ -40496,9 +41089,9 @@ function extractSparklineColor(group) {
40496
41089
  if (!rgb) return void 0;
40497
41090
  return `#${rgb.length === 8 ? rgb.slice(2) : rgb}`;
40498
41091
  }
40499
- function ensureSparkArray(val2) {
40500
- if (val2 === void 0 || val2 === null) return [];
40501
- return Array.isArray(val2) ? val2 : [val2];
41092
+ function ensureSparkArray(val) {
41093
+ if (val === void 0 || val === null) return [];
41094
+ return Array.isArray(val) ? val : [val];
40502
41095
  }
40503
41096
  function parsePageBreaks(worksheet) {
40504
41097
  const rowPageBreaks = [];
@@ -40523,9 +41116,9 @@ function parsePageBreaks(worksheet) {
40523
41116
  }
40524
41117
  return { rowPageBreaks: rowPageBreaks.sort((a, b) => a - b), colPageBreaks: colPageBreaks.sort((a, b) => a - b) };
40525
41118
  }
40526
- function ensureBreakArray(val2) {
40527
- if (val2 === void 0 || val2 === null) return [];
40528
- return Array.isArray(val2) ? val2 : [val2];
41119
+ function ensureBreakArray(val) {
41120
+ if (val === void 0 || val === null) return [];
41121
+ return Array.isArray(val) ? val : [val];
40529
41122
  }
40530
41123
  function parseAutoFilter(worksheet) {
40531
41124
  const afEl = worksheet["autoFilter"];
@@ -40543,8 +41136,8 @@ function parseAutoFilter(worksheet) {
40543
41136
  const filterArr = filtersEl["filter"];
40544
41137
  if (filterArr) {
40545
41138
  for (const f of filterArr) {
40546
- const val2 = f["@_val"];
40547
- if (val2 !== void 0) filterValues.push(decodeXmlEntities(val2));
41139
+ const val = f["@_val"];
41140
+ if (val !== void 0) filterValues.push(decodeXmlEntities(val));
40548
41141
  }
40549
41142
  }
40550
41143
  }
@@ -40737,9 +41330,9 @@ function extractSeriesName(txNode) {
40737
41330
  }
40738
41331
  function extractNumericValues(valNode) {
40739
41332
  if (!valNode || typeof valNode !== "object") return [];
40740
- const val2 = valNode;
40741
- const numRef = getObj(val2, "c:numRef") ?? getObj(val2, "numRef");
40742
- const cache = numRef ? getObj(numRef, "c:numCache") ?? getObj(numRef, "numCache") : getObj(val2, "c:numLit") ?? getObj(val2, "numLit");
41333
+ const val = valNode;
41334
+ const numRef = getObj(val, "c:numRef") ?? getObj(val, "numRef");
41335
+ const cache = numRef ? getObj(numRef, "c:numCache") ?? getObj(numRef, "numCache") : getObj(val, "c:numLit") ?? getObj(val, "numLit");
40743
41336
  if (!cache || typeof cache !== "object") return [];
40744
41337
  const pts = ensureArray(cache["c:pt"] ?? cache["pt"]);
40745
41338
  const values2 = [];
@@ -40783,8 +41376,8 @@ function extractColor2(spPr) {
40783
41376
  if (!solidFill || typeof solidFill !== "object") return void 0;
40784
41377
  const srgb = getObj(solidFill, "a:srgbClr") ?? getObj(solidFill, "srgbClr");
40785
41378
  if (srgb && typeof srgb === "object") {
40786
- const val2 = srgb["@_val"];
40787
- if (typeof val2 === "string") return `#${val2}`;
41379
+ const val = srgb["@_val"];
41380
+ if (typeof val === "string") return `#${val}`;
40788
41381
  }
40789
41382
  return void 0;
40790
41383
  }
@@ -40811,9 +41404,9 @@ function extractLegendPosition(legendNode) {
40811
41404
  if (!legendNode || typeof legendNode !== "object") return void 0;
40812
41405
  const pos = getObj(legendNode, "c:legendPos") ?? getObj(legendNode, "legendPos");
40813
41406
  if (!pos || typeof pos !== "object") return void 0;
40814
- const val2 = pos["@_val"];
41407
+ const val = pos["@_val"];
40815
41408
  const map2 = { t: "top", b: "bottom", l: "left", r: "right" };
40816
- return typeof val2 === "string" ? map2[val2] ?? "right" : "right";
41409
+ return typeof val === "string" ? map2[val] ?? "right" : "right";
40817
41410
  }
40818
41411
  function parseAxes(plotArea) {
40819
41412
  const axes = [];
@@ -40862,12 +41455,12 @@ function getObj(parent, key) {
40862
41455
  function getAttr(obj, childKey, attr) {
40863
41456
  const child = childKey ? obj[childKey] : obj;
40864
41457
  if (!child || typeof child !== "object") return void 0;
40865
- const val2 = child[`@_${attr}`];
40866
- return typeof val2 === "string" ? val2 : void 0;
41458
+ const val = child[`@_${attr}`];
41459
+ return typeof val === "string" ? val : void 0;
40867
41460
  }
40868
- function ensureArray(val2) {
40869
- if (val2 === void 0 || val2 === null) return [];
40870
- return Array.isArray(val2) ? val2 : [val2];
41461
+ function ensureArray(val) {
41462
+ if (val === void 0 || val === null) return [];
41463
+ return Array.isArray(val) ? val : [val];
40871
41464
  }
40872
41465
 
40873
41466
  // ../xlsx/src/ooxml_drawing.ts
@@ -40996,8 +41589,8 @@ function extractOutlineColor(spPr) {
40996
41589
  function extractSrgb(fill) {
40997
41590
  const srgb = fill["a:srgbClr"] ?? fill["srgbClr"];
40998
41591
  if (srgb && typeof srgb === "object") {
40999
- const val2 = srgb["@_val"];
41000
- if (typeof val2 === "string") return `#${val2}`;
41592
+ const val = srgb["@_val"];
41593
+ if (typeof val === "string") return `#${val}`;
41001
41594
  }
41002
41595
  return void 0;
41003
41596
  }
@@ -41034,14 +41627,14 @@ function extractPicRId(pic) {
41034
41627
  const rId = blip["@_r:embed"] ?? blip["@_embed"];
41035
41628
  return typeof rId === "string" ? rId : void 0;
41036
41629
  }
41037
- function ensureArray2(val2) {
41038
- if (val2 === void 0 || val2 === null) return [];
41039
- return Array.isArray(val2) ? val2 : [val2];
41630
+ function ensureArray2(val) {
41631
+ if (val === void 0 || val === null) return [];
41632
+ return Array.isArray(val) ? val : [val];
41040
41633
  }
41041
- function parseIntVal(val2) {
41042
- if (typeof val2 === "number") return val2;
41043
- if (typeof val2 === "string") {
41044
- const n = parseInt(val2, 10);
41634
+ function parseIntVal(val) {
41635
+ if (typeof val === "number") return val;
41636
+ if (typeof val === "string") {
41637
+ const n = parseInt(val, 10);
41045
41638
  return isNaN(n) ? void 0 : n;
41046
41639
  }
41047
41640
  return void 0;
@@ -41113,12 +41706,12 @@ function extractTableRIds(rels) {
41113
41706
  return result;
41114
41707
  }
41115
41708
  function strAttr(obj, attr) {
41116
- const val2 = obj[`@_${attr}`];
41117
- return typeof val2 === "string" ? val2 : void 0;
41709
+ const val = obj[`@_${attr}`];
41710
+ return typeof val === "string" ? val : void 0;
41118
41711
  }
41119
- function ensureArray3(val2) {
41120
- if (val2 === void 0 || val2 === null) return [];
41121
- return Array.isArray(val2) ? val2 : [val2];
41712
+ function ensureArray3(val) {
41713
+ if (val === void 0 || val === null) return [];
41714
+ return Array.isArray(val) ? val : [val];
41122
41715
  }
41123
41716
 
41124
41717
  // ../xlsx/src/ooxml_pivot.ts
@@ -41414,9 +42007,9 @@ function extractWorkbookPivotCaches(workbook) {
41414
42007
  return out;
41415
42008
  }
41416
42009
  function strAttr2(obj, attr) {
41417
- const val2 = obj[`@_${attr}`];
41418
- if (typeof val2 === "string") return val2;
41419
- if (typeof val2 === "number") return String(val2);
42010
+ const val = obj[`@_${attr}`];
42011
+ if (typeof val === "string") return val;
42012
+ if (typeof val === "number") return String(val);
41420
42013
  return void 0;
41421
42014
  }
41422
42015
  function intAttr(obj, attr) {
@@ -41432,12 +42025,12 @@ function boolAttr(obj, attr, fallback) {
41432
42025
  if (v === "0" || v === "false") return false;
41433
42026
  return fallback;
41434
42027
  }
41435
- function ensureArray4(val2) {
41436
- if (val2 === void 0 || val2 === null) return [];
41437
- return Array.isArray(val2) ? val2 : [val2];
42028
+ function ensureArray4(val) {
42029
+ if (val === void 0 || val === null) return [];
42030
+ return Array.isArray(val) ? val : [val];
41438
42031
  }
41439
- function asObj(val2) {
41440
- return val2 && typeof val2 === "object" ? val2 : {};
42032
+ function asObj(val) {
42033
+ return val && typeof val === "object" ? val : {};
41441
42034
  }
41442
42035
 
41443
42036
  // ../xlsx/src/ooxml_shape.ts
@@ -41700,9 +42293,9 @@ function extractVmlText(textbox) {
41700
42293
  }
41701
42294
  return void 0;
41702
42295
  }
41703
- function ensureVmlArray(val2) {
41704
- if (val2 === void 0 || val2 === null) return [];
41705
- return Array.isArray(val2) ? val2 : [val2];
42296
+ function ensureVmlArray(val) {
42297
+ if (val === void 0 || val === null) return [];
42298
+ return Array.isArray(val) ? val : [val];
41706
42299
  }
41707
42300
 
41708
42301
  // ../xlsx/src/excel_parser.ts
@@ -46304,20 +46897,31 @@ Lotics is an AI-powered operations platform. Through this CLI you can:
46304
46897
  AUTHENTICATION
46305
46898
  lotics auth Show auth help
46306
46899
  lotics auth signup <email> Create account (run "lotics auth" for details)
46900
+ lotics auth api-key <key> Save a key \u2014 registers its org as a profile
46901
+
46902
+ ORGANIZATIONS
46903
+ Each saved API key belongs to one org. Register a key per org once, then
46904
+ switch between them with no re-pasting. Workspaces live inside an org.
46905
+ lotics org List saved orgs (marks active)
46906
+ lotics org use <name|id> Switch the active org
46907
+ lotics org use <name|id> --local Pin THIS directory to an org (worktrees)
46307
46908
 
46308
46909
  USAGE
46309
46910
  1. lotics auth signup <email> Create account or authenticate
46310
- 2. lotics workspace Check current workspace (auto-selects if only one)
46311
- 3. lotics tools List available tools by category
46312
- 4. lotics tools <name> Show tool description and full input schema
46313
- 5. lotics run <tool> '<json>' Execute a tool with JSON arguments
46911
+ 2. lotics org See saved orgs / which one is active
46912
+ 3. lotics workspace Check current workspace (auto-selects if only one)
46913
+ 4. lotics tools List available tools by category
46914
+ 5. lotics tools <name> Show tool description and full input schema
46915
+ 6. lotics run <tool> '<json>' Execute a tool with JSON arguments
46314
46916
 
46315
46917
  Always inspect the schema (step 4) before calling a tool.
46316
46918
  Tools are grouped by category (tables, records, views, etc.).
46317
46919
  Query tools return IDs used as arguments to other tools.
46318
46920
 
46319
46921
  COMMANDS
46320
- lotics workspace List workspaces (marks current)
46922
+ lotics org List saved orgs (marks active)
46923
+ lotics org use <name|id> [--local] Switch active org (--local pins this dir)
46924
+ lotics workspace List workspaces in the active org (marks current)
46321
46925
  lotics workspace select <id> Switch to a different workspace
46322
46926
  lotics workspace create <name> Create a new workspace (admin only)
46323
46927
  lotics tools List all available tools
@@ -46334,6 +46938,7 @@ COMMANDS
46334
46938
  (--force-workflow-sync wipes server-only
46335
46939
  workflow aliases; default refuses)
46336
46940
  lotics app subdomain <new-subdomain> Rename the app's public <slug>.lotics.app address
46941
+ lotics app rename "<new name>" Rename the app's display name (launcher title)
46337
46942
  lotics app dev [path] Run the app locally with HMR (RPC forwarded to prod)
46338
46943
  lotics xlsx <subcommand> ... Read/write/edit .xlsx files on your local filesystem
46339
46944
  (uses the bundled Lotics xlsx engine; prefer over
@@ -46347,15 +46952,23 @@ FLAGS
46347
46952
  --timeout <ms> Timeout for tool execution (default: 60000)
46348
46953
  -o <path> Output dir for downloads
46349
46954
  --as <name> Override upload filename
46350
- --api-key <key> API key (overrides saved config and LOTICS_API_KEY)
46351
- --local (lotics auth) Save credentials to ./.lotics/config.json
46955
+ --api-key <key> One-off API key (overrides saved config + env)
46956
+ --workspace <id> One-off workspace override (alias: -w)
46957
+ --local Pin the current directory (lotics org use / auth api-key)
46958
+ --all (lotics auth logout) Remove every saved credential
46352
46959
  --version Show version
46353
46960
 
46354
46961
  CONFIG
46355
- Credentials resolve from a .lotics/config.json found by walking up from the
46356
- current directory, else the global ~/.lotics/config.json. Run "lotics auth
46357
- api-key <key> --local" inside a directory (e.g. a worktree) to pin it to its
46358
- own account and workspace.
46962
+ API keys are stored once per org in the global ~/.lotics/config.json as named
46963
+ profiles. Switch with "lotics org use <name|id>" \u2014 no re-pasting. A directory
46964
+ (e.g. a git worktree) can pin its own org/workspace with "lotics org use
46965
+ <name|id> --local", which writes a .lotics/config.json pointer (the key is
46966
+ resolved from the global store) \u2014 so a global switch never disturbs it.
46967
+
46968
+ Resolution precedence (highest first):
46969
+ --api-key flag > LOTICS_API_KEY env > LOTICS_ORG env >
46970
+ local .lotics/config.json > global active profile
46971
+ LOTICS_WORKSPACE (or --workspace) overrides the workspace at any level.
46359
46972
 
46360
46973
  OUTPUT
46361
46974
  Default output is a compact text summary optimized for AI agents \u2014
@@ -46384,25 +46997,27 @@ function printAuthHelp() {
46384
46997
  console.log(`Authentication commands:
46385
46998
 
46386
46999
  lotics auth signup <email> Create account, org, workspace, and API key
46387
- lotics auth api-key [key] Save an existing API key (e.g. from the web app)
47000
+ lotics auth api-key [key] Save an API key \u2014 registers its org as a profile
46388
47001
  lotics auth web Send a magic link email to access the web app
46389
- lotics auth whoami Show the current account's name, email, and organization
46390
- lotics auth logout Remove saved credentials
47002
+ lotics auth whoami Show the active account, org, workspace, and source
47003
+ lotics auth logout [<name|id>] Remove a saved credential (default: the active org,
47004
+ or unpin the current directory)
47005
+ lotics auth logout --all Remove every saved credential
46391
47006
 
46392
47007
  Auth flags:
46393
- --local Save credentials to ./.lotics/config.json (this directory)
46394
- instead of the global ~/.lotics \u2014 applies to signup + api-key
47008
+ --local Pin the current directory instead of the global store.
47009
+ signup/api-key write a self-contained ./.lotics/config.json
47010
+ (inline key) \u2014 for a hermetic worktree or CI.
46395
47011
  --name <name> (signup) Display name (defaults to email prefix)
46396
47012
  --timezone <timezone> (signup) Workspace timezone (defaults to UTC, e.g. Asia/Ho_Chi_Minh)
46397
47013
 
46398
- Signup sends a magic link email so you can access the Lotics web app.
46399
- Use lotics auth web to request a new magic link at any time.
47014
+ API keys are stored once per org as named profiles in ~/.lotics/config.json.
47015
+ Registering a second key adds a profile \u2014 it does not overwrite the first.
47016
+ Switch active org with "lotics org use <name|id>".
46400
47017
 
46401
- Auth priority: --api-key flag > LOTICS_API_KEY env > config file.
46402
- Config file: .lotics/config.json found by walking up from the current directory,
46403
- else ~/.lotics/config.json. A per-directory config pins a project or worktree to
46404
- its own account and workspace; --local creates one. Note: an exported
46405
- LOTICS_API_KEY env var overrides the config file's key.`);
47018
+ Resolution precedence (highest first):
47019
+ --api-key flag > LOTICS_API_KEY env > LOTICS_ORG env > local .lotics/config.json
47020
+ > global active profile. LOTICS_WORKSPACE / --workspace override the workspace.`);
46406
47021
  }
46407
47022
  function readStdin() {
46408
47023
  return new Promise((resolve, reject2) => {
@@ -46454,17 +47069,18 @@ async function handleSignup(positionalEmail, flags) {
46454
47069
  }
46455
47070
  process.exit(1);
46456
47071
  }
46457
- const scope = flags.local ? "local" : "auto";
46458
- const existing = loadConfig(scope) ?? {};
46459
- saveConfig({
46460
- ...existing,
46461
- api_key: data.api_key,
46462
- email: data.email,
46463
- workspace_id: data.workspace_id
46464
- }, scope);
47072
+ const apiKey = data.api_key;
47073
+ const orgId = data.organization_id;
47074
+ const workspaceId = data.workspace_id;
47075
+ const orgName = name || email.split("@")[0];
47076
+ upsertProfile(orgId, { api_key: apiKey, org_name: orgName, workspace_id: workspaceId });
47077
+ const existing = loadGlobalConfig() ?? {};
47078
+ saveGlobalConfig({ ...existing, email });
47079
+ setActiveOrg(orgId, flags.local ? "local" : "global");
46465
47080
  console.error(`Account created. You can now use the CLI.`);
46466
- console.error(` Email: ${data.email}`);
46467
- console.error(` Config: ${getConfigPath(scope)}`);
47081
+ console.error(` Email: ${email}`);
47082
+ console.error(` Org: ${orgName} (${orgId})`);
47083
+ console.error(flags.local ? ` Pinned this directory: ${getConfigPath("local")}` : ` Saved to the "${orgName}" profile in ~/.lotics (now active)`);
46468
47084
  console.error(`
46469
47085
  Check your email for a magic link to access the Lotics web app.`);
46470
47086
  console.error(`Run "lotics auth web" to request a new link at any time.`);
@@ -46476,53 +47092,70 @@ async function handleSetup(providedKey, local) {
46476
47092
  process.exit(1);
46477
47093
  }
46478
47094
  const client = new LoticsClient({ apiKey });
46479
- let email;
47095
+ let info;
46480
47096
  try {
46481
- const info = await client.whoami();
46482
- email = info.email;
47097
+ info = await client.whoami();
46483
47098
  } catch (error) {
46484
47099
  const message = error instanceof Error ? error.message : String(error);
46485
47100
  console.error(`Authentication failed: ${message}`);
46486
47101
  process.exit(1);
46487
47102
  }
46488
- const scope = local ? "local" : "auto";
46489
- const existing = loadConfig(scope) ?? {};
46490
- const newConfig = { ...existing, api_key: apiKey, email };
47103
+ let workspaceId;
46491
47104
  try {
46492
47105
  const workspaces = await client.listWorkspaces();
46493
47106
  if (workspaces.length === 1) {
46494
- newConfig.workspace_id = workspaces[0].id;
47107
+ workspaceId = workspaces[0].id;
46495
47108
  } else if (workspaces.length > 1) {
46496
47109
  console.error(`
46497
- Multiple workspaces found. Run "lotics workspace select <id>" to choose one:`);
47110
+ Multiple workspaces in ${info.organization_name}. Run "lotics workspace select <id>" to choose one:`);
46498
47111
  printWorkspaceList(workspaces);
46499
47112
  }
46500
47113
  } catch (error) {
46501
47114
  const msg = error instanceof Error ? error.message : String(error);
46502
47115
  console.error(`Warning: could not resolve workspace: ${msg}`);
46503
47116
  }
46504
- saveConfig(newConfig, scope);
46505
- console.error("Authenticated.");
46506
- console.error(` Config: ${getConfigPath(scope)}`);
47117
+ upsertProfile(info.organization_id, {
47118
+ api_key: apiKey,
47119
+ org_name: info.organization_name,
47120
+ workspace_id: workspaceId
47121
+ });
47122
+ const existing = loadGlobalConfig() ?? {};
47123
+ saveGlobalConfig({ ...existing, email: info.email });
47124
+ setActiveOrg(info.organization_id, local ? "local" : "global");
47125
+ if (local) {
47126
+ console.error(`Authenticated as ${info.email} in ${info.organization_name}.`);
47127
+ console.error(` Pinned this directory: ${getConfigPath("local")}`);
47128
+ } else {
47129
+ console.error(`Authenticated as ${info.email} in ${info.organization_name} (now active).`);
47130
+ console.error(` Saved to the "${info.organization_name}" profile in ~/.lotics`);
47131
+ }
46507
47132
  }
46508
47133
  function requireClient(flags) {
46509
- const auth = resolveAuth(flags);
46510
- if (!auth) {
46511
- console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
47134
+ const ctx = resolveContext(flags);
47135
+ if (!ctx) {
47136
+ console.error('Not authenticated. Run "lotics auth signup", "lotics auth api-key <key>", or set LOTICS_API_KEY.');
46512
47137
  process.exit(1);
46513
47138
  }
46514
- const config = loadConfig();
46515
- return new LoticsClient({ apiKey: auth.apiKey, workspaceId: config?.workspace_id });
47139
+ return { client: new LoticsClient({ apiKey: ctx.apiKey, workspaceId: ctx.workspaceId }), ctx };
46516
47140
  }
47141
+ var SOURCE_LABELS = {
47142
+ flag: "--api-key flag",
47143
+ env_key: "LOTICS_API_KEY env",
47144
+ env_org: "LOTICS_ORG env",
47145
+ local_pointer: "local .lotics/config.json (pin)",
47146
+ global_profile: "global active profile"
47147
+ };
46517
47148
  function printWorkspaceList(workspaces, currentId) {
46518
47149
  for (const ws of workspaces) {
46519
47150
  const marker = ws.id === currentId ? " (current)" : "";
46520
47151
  console.error(` ${ws.id} ${ws.name} ${ws.timezone} ${ws.default_currency}${marker}`);
46521
47152
  }
46522
47153
  }
46523
- async function resolveWorkspace(client) {
46524
- const config = loadConfig();
46525
- if (config?.workspace_id) return;
47154
+ async function resolveWorkspace(client, ctx) {
47155
+ if (ctx.workspaceId) {
47156
+ client.setWorkspaceId(ctx.workspaceId);
47157
+ return;
47158
+ }
46526
47159
  let workspaces;
46527
47160
  try {
46528
47161
  workspaces = await client.listWorkspaces();
@@ -46536,8 +47169,7 @@ async function resolveWorkspace(client) {
46536
47169
  process.exit(1);
46537
47170
  }
46538
47171
  if (workspaces.length === 1) {
46539
- const existing = config ?? {};
46540
- saveConfig({ ...existing, workspace_id: workspaces[0].id });
47172
+ setSelectedWorkspace(workspaces[0].id);
46541
47173
  client.setWorkspaceId(workspaces[0].id);
46542
47174
  return;
46543
47175
  }
@@ -46585,32 +47217,60 @@ async function main() {
46585
47217
  return;
46586
47218
  }
46587
47219
  if (subcommand === "whoami") {
46588
- const auth = resolveAuth(flags);
46589
- if (!auth) {
46590
- console.error('Not authenticated. Run "lotics auth signup" or set LOTICS_API_KEY.');
47220
+ const ctx2 = resolveContext(flags);
47221
+ if (!ctx2) {
47222
+ console.error('Not authenticated. Run "lotics auth signup", "lotics auth api-key <key>", or set LOTICS_API_KEY.');
46591
47223
  process.exit(1);
46592
47224
  }
46593
- const client2 = new LoticsClient({ apiKey: auth.apiKey });
47225
+ const client2 = new LoticsClient({ apiKey: ctx2.apiKey });
46594
47226
  const info = await client2.whoami();
46595
- const existing = loadConfig() ?? {};
46596
- saveConfig({ ...existing, email: info.email });
47227
+ const existing = loadGlobalConfig() ?? {};
47228
+ saveGlobalConfig({ ...existing, email: info.email });
46597
47229
  if (flags.json) {
46598
- console.log(JSON.stringify(info, null, 2));
47230
+ console.log(JSON.stringify({ ...info, workspace_id: ctx2.workspaceId ?? null, source: ctx2.source }, null, 2));
46599
47231
  } else {
46600
- console.log(`Name: ${info.name}`);
46601
- console.log(`Email: ${info.email}`);
46602
- console.log(`Org: ${info.organization_name} (${info.organization_id})`);
47232
+ console.log(`Name: ${info.name}`);
47233
+ console.log(`Email: ${info.email}`);
47234
+ console.log(`Org: ${info.organization_name} (${info.organization_id})`);
47235
+ console.log(`Workspace: ${ctx2.workspaceId ?? "(none selected)"}`);
47236
+ console.log(`Source: ${SOURCE_LABELS[ctx2.source]}`);
46603
47237
  }
46604
- console.error(`Config: ${getConfigPath()}`);
46605
47238
  return;
46606
47239
  }
46607
47240
  if (subcommand === "logout") {
46608
- deleteConfig();
46609
- console.error("Logged out. Credentials removed.");
47241
+ const local = loadLocalConfig();
47242
+ if (local && !flags.all && !toolArgs) {
47243
+ deleteConfig();
47244
+ console.error("Removed the local pin for this directory.");
47245
+ return;
47246
+ }
47247
+ if (flags.all) {
47248
+ const g2 = loadGlobalConfig();
47249
+ saveGlobalConfig({ last_update_check: g2?.last_update_check, latest_version: g2?.latest_version });
47250
+ console.error("Removed all saved credentials.");
47251
+ return;
47252
+ }
47253
+ const g = loadGlobalConfig() ?? {};
47254
+ const profiles = g.profiles ?? {};
47255
+ let resolved;
47256
+ if (toolArgs) {
47257
+ resolved = resolveProfileByNameOrId(profiles, toolArgs);
47258
+ } else if (g.active_org && profiles[g.active_org]) {
47259
+ resolved = [g.active_org, profiles[g.active_org]];
47260
+ } else {
47261
+ resolved = null;
47262
+ }
47263
+ if (!resolved) {
47264
+ console.error(toolArgs ? `No saved credential matches "${toolArgs}".` : "No active credential to remove. Pass an org name/id, or use --all.");
47265
+ process.exit(1);
47266
+ }
47267
+ const [orgId, profile] = resolved;
47268
+ removeProfile(orgId);
47269
+ console.error(`Removed the "${profile.org_name}" credential (${orgId}).`);
46610
47270
  return;
46611
47271
  }
46612
47272
  if (subcommand === "web") {
46613
- const client2 = requireClient(flags);
47273
+ const { client: client2 } = requireClient(flags);
46614
47274
  const { email } = await client2.login();
46615
47275
  console.error(`Magic link sent to ${email}. Check your email to access the Lotics web app.`);
46616
47276
  return;
@@ -46630,6 +47290,63 @@ async function main() {
46630
47290
  await runDocxCommand(subcommand, toolArgs, restArgs);
46631
47291
  return;
46632
47292
  }
47293
+ if (command === "org") {
47294
+ const global2 = loadGlobalConfig() ?? {};
47295
+ const profiles = global2.profiles ?? {};
47296
+ const local = loadLocalConfig();
47297
+ if (subcommand === "use") {
47298
+ if (!toolArgs) {
47299
+ console.error("Usage: lotics org use <name|id> [--local]");
47300
+ process.exit(1);
47301
+ }
47302
+ const resolved = resolveProfileByNameOrId(profiles, toolArgs);
47303
+ if (!resolved) {
47304
+ console.error(`No saved credential for "${toolArgs}". Run "lotics auth api-key <key>" while authenticated to that org, or "lotics org" to list.`);
47305
+ process.exit(1);
47306
+ }
47307
+ const [orgId, profile] = resolved;
47308
+ if (flags.local) {
47309
+ setActiveOrg(orgId, "local");
47310
+ console.error(`Pinned this directory to ${profile.org_name} (${orgId}).`);
47311
+ } else {
47312
+ setActiveOrg(orgId, "global");
47313
+ console.error(`Switched active org to ${profile.org_name} (${orgId}).`);
47314
+ if (local?.active_org) {
47315
+ console.error("Note: a local pin (.lotics/config.json) overrides the global default in this directory. Use --local to change the pin here.");
47316
+ }
47317
+ }
47318
+ return;
47319
+ }
47320
+ if (subcommand && subcommand !== "list") {
47321
+ console.error(`Unknown org subcommand: ${subcommand}`);
47322
+ console.error("Usage: lotics org [list | use <name|id> [--local]]");
47323
+ process.exit(1);
47324
+ }
47325
+ const orgIds = Object.keys(profiles);
47326
+ if (orgIds.length === 0) {
47327
+ console.error('No saved orgs. Run "lotics auth api-key <key>" to add one.');
47328
+ return;
47329
+ }
47330
+ const effectiveActive = local?.active_org ?? global2.active_org;
47331
+ if (flags.json) {
47332
+ console.log(JSON.stringify(
47333
+ orgIds.map((id) => ({
47334
+ org_id: id,
47335
+ org_name: profiles[id].org_name,
47336
+ workspace_id: profiles[id].workspace_id ?? null,
47337
+ active: id === effectiveActive
47338
+ })),
47339
+ null,
47340
+ 2
47341
+ ));
47342
+ } else {
47343
+ for (const id of orgIds) {
47344
+ const marker = id === effectiveActive ? " (active)" : "";
47345
+ console.log(`${id} ${profiles[id].org_name}${marker}`);
47346
+ }
47347
+ }
47348
+ return;
47349
+ }
46633
47350
  if (command !== "tools" && command !== "upload" && command !== "run" && command !== "download" && command !== "workspace" && command !== "app") {
46634
47351
  console.error(`Unknown command: ${command}`);
46635
47352
  console.error('Run "lotics --help" for usage.');
@@ -46642,6 +47359,7 @@ async function main() {
46642
47359
  console.error(" lotics app deploy [-m <message>] [--force-workflow-sync]");
46643
47360
  console.error(" Build + upload the current directory");
46644
47361
  console.error(" lotics app subdomain <new-subdomain> Rename the app's public <slug>.lotics.app address");
47362
+ console.error(` lotics app rename "<new name>" Rename the app's display name (launcher title)`);
46645
47363
  console.error(" lotics app dev [path] Run the app locally with HMR + RPC forwarding");
46646
47364
  process.exit(1);
46647
47365
  }
@@ -46667,10 +47385,10 @@ async function main() {
46667
47385
  console.error("Downloads every file on the given file field into the output dir.");
46668
47386
  process.exit(1);
46669
47387
  }
46670
- const client = requireClient(flags);
47388
+ const { client, ctx } = requireClient(flags);
46671
47389
  if (command === "workspace") {
46672
47390
  const workspaces = await client.listWorkspaces();
46673
- const config = loadConfig();
47391
+ const currentWorkspaceId = ctx.workspaceId;
46674
47392
  if (subcommand === "select") {
46675
47393
  const targetId = toolArgs;
46676
47394
  if (!targetId) {
@@ -46682,12 +47400,16 @@ async function main() {
46682
47400
  console.error(`Workspace not found: ${targetId}
46683
47401
 
46684
47402
  Available workspaces:`);
46685
- printWorkspaceList(workspaces, config?.workspace_id);
47403
+ printWorkspaceList(workspaces, currentWorkspaceId);
46686
47404
  process.exit(1);
46687
47405
  }
46688
- const existing = config ?? {};
46689
- saveConfig({ ...existing, workspace_id: target.id });
46690
- console.error(`Switched to workspace: ${target.name} (${target.id})`);
47406
+ const written = setSelectedWorkspace(target.id);
47407
+ if (!written) {
47408
+ console.error(`Switched to ${target.name} (${target.id}) for this command, but it could not be saved \u2014 credentials came from --api-key/LOTICS_API_KEY with no saved profile. Run "lotics auth api-key <key>" to persist a default.`);
47409
+ return;
47410
+ }
47411
+ const where = written.scope === "local" ? " (pinned to this directory)" : "";
47412
+ console.error(`Switched to workspace: ${target.name} (${target.id})${where}`);
46691
47413
  return;
46692
47414
  }
46693
47415
  if (subcommand === "create") {
@@ -46698,8 +47420,7 @@ Available workspaces:`);
46698
47420
  }
46699
47421
  const timezone = flags.timezone;
46700
47422
  const created = await client.createWorkspace({ name, timezone });
46701
- const existing = config ?? {};
46702
- saveConfig({ ...existing, workspace_id: created.id });
47423
+ setSelectedWorkspace(created.id);
46703
47424
  client.setWorkspaceId(created.id);
46704
47425
  if (flags.json) {
46705
47426
  console.log(JSON.stringify(created, null, 2));
@@ -46721,15 +47442,15 @@ Available workspaces:`);
46721
47442
  console.error("No workspaces found.");
46722
47443
  } else {
46723
47444
  for (const ws of workspaces) {
46724
- const marker = ws.id === config?.workspace_id ? " (current)" : "";
47445
+ const marker = ws.id === currentWorkspaceId ? " (current)" : "";
46725
47446
  console.log(`${ws.id} ${ws.name} ${ws.timezone} ${ws.default_currency}${marker}`);
46726
47447
  }
46727
47448
  }
46728
47449
  }
46729
- console.error(`Config: ${getConfigPath()}`);
47450
+ if (ctx.orgName) console.error(`Org: ${ctx.orgName}`);
46730
47451
  return;
46731
47452
  }
46732
- await resolveWorkspace(client);
47453
+ await resolveWorkspace(client, ctx);
46733
47454
  if (command === "app") {
46734
47455
  if (subcommand === "create") {
46735
47456
  const name = toolArgs;
@@ -46766,6 +47487,16 @@ Available workspaces:`);
46766
47487
  await appSetSubdomain(client, { subdomain: newSubdomain });
46767
47488
  return;
46768
47489
  }
47490
+ if (subcommand === "rename") {
47491
+ const newName = toolArgs;
47492
+ if (!newName) {
47493
+ console.error('Usage: lotics app rename "<new name>"');
47494
+ console.error("Changes the app's display name (run inside the app directory).");
47495
+ process.exit(1);
47496
+ }
47497
+ await appRename(client, { name: newName });
47498
+ return;
47499
+ }
46769
47500
  if (subcommand === "dev") {
46770
47501
  const projectDir = toolArgs;
46771
47502
  let port;