@stacksjs/ts-cloud 0.2.1 → 0.2.2

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.
Files changed (3) hide show
  1. package/dist/bin/cli.js +580 -583
  2. package/dist/index.js +1094 -1968
  3. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -693,2047 +693,1173 @@ var init_signature = __esm(async () => {
693
693
  };
694
694
  });
695
695
 
696
- // ../../node_modules/fast-xml-parser/src/util.js
697
- function getAllMatches(string, regex) {
698
- const matches = [];
699
- let match = regex.exec(string);
700
- while (match) {
701
- const allmatches = [];
702
- allmatches.startIndex = regex.lastIndex - match[0].length;
703
- const len = match.length;
704
- for (let index = 0;index < len; index++) {
705
- allmatches.push(match[index]);
706
- }
707
- matches.push(allmatches);
708
- match = regex.exec(string);
709
- }
710
- return matches;
711
- }
712
- function isExist(v) {
713
- return typeof v !== "undefined";
714
- }
715
- var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", nameChar, nameRegexp, regexName, isName = function(string) {
716
- const match = regexName.exec(string);
717
- return !(match === null || typeof match === "undefined");
718
- };
719
- var init_util = __esm(() => {
720
- nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
721
- nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
722
- regexName = new RegExp("^" + nameRegexp + "$");
723
- });
724
-
725
- // ../../node_modules/fast-xml-parser/src/validator.js
726
- function validate(xmlData, options) {
727
- options = Object.assign({}, defaultOptions, options);
728
- const tags = [];
729
- let tagFound = false;
730
- let reachedRoot = false;
731
- if (xmlData[0] === "\uFEFF") {
732
- xmlData = xmlData.substr(1);
733
- }
734
- for (let i = 0;i < xmlData.length; i++) {
735
- if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
736
- i += 2;
737
- i = readPI(xmlData, i);
738
- if (i.err)
739
- return i;
740
- } else if (xmlData[i] === "<") {
741
- let tagStartPos = i;
742
- i++;
743
- if (xmlData[i] === "!") {
744
- i = readCommentAndCDATA(xmlData, i);
696
+ // ../../node_modules/@stacksjs/ts-xml/dist/index.js
697
+ class EntityDecoder {
698
+ customEntities = {};
699
+ useHtmlEntities;
700
+ constructor(useHtmlEntities = false) {
701
+ this.useHtmlEntities = useHtmlEntities;
702
+ }
703
+ addEntity(name, value) {
704
+ this.customEntities[name] = value;
705
+ }
706
+ decodeEntities(text) {
707
+ let ampIdx = text.indexOf("&");
708
+ if (ampIdx === -1)
709
+ return text;
710
+ const len = text.length;
711
+ let result = "";
712
+ let lastPos = 0;
713
+ while (ampIdx !== -1 && ampIdx < len) {
714
+ if (ampIdx > lastPos)
715
+ result += text.substring(lastPos, ampIdx);
716
+ const semiIdx = text.indexOf(";", ampIdx + 1);
717
+ if (semiIdx === -1 || semiIdx - ampIdx > 32) {
718
+ result += "&";
719
+ lastPos = ampIdx + 1;
720
+ ampIdx = text.indexOf("&", lastPos);
745
721
  continue;
746
- } else {
747
- let closingTag = false;
748
- if (xmlData[i] === "/") {
749
- closingTag = true;
750
- i++;
751
- }
752
- let tagName = "";
753
- for (;i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== "\t" && xmlData[i] !== `
754
- ` && xmlData[i] !== "\r"; i++) {
755
- tagName += xmlData[i];
756
- }
757
- tagName = tagName.trim();
758
- if (tagName[tagName.length - 1] === "/") {
759
- tagName = tagName.substring(0, tagName.length - 1);
760
- i--;
761
- }
762
- if (!validateTagName(tagName)) {
763
- let msg;
764
- if (tagName.trim().length === 0) {
765
- msg = "Invalid space after '<'.";
766
- } else {
767
- msg = "Tag '" + tagName + "' is an invalid name.";
768
- }
769
- return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
770
- }
771
- const result = readAttributeStr(xmlData, i);
772
- if (result === false) {
773
- return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
774
- }
775
- let attrStr = result.value;
776
- i = result.index;
777
- if (attrStr[attrStr.length - 1] === "/") {
778
- const attrStrStart = i - attrStr.length;
779
- attrStr = attrStr.substring(0, attrStr.length - 1);
780
- const isValid = validateAttributeString(attrStr, options);
781
- if (isValid === true) {
782
- tagFound = true;
783
- } else {
784
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
785
- }
786
- } else if (closingTag) {
787
- if (!result.tagClosed) {
788
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
789
- } else if (attrStr.trim().length > 0) {
790
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
791
- } else if (tags.length === 0) {
792
- return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
793
- } else {
794
- const otg = tags.pop();
795
- if (tagName !== otg.tagName) {
796
- let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
797
- return getErrorObject("InvalidTag", "Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.", getLineNumberForPosition(xmlData, tagStartPos));
798
- }
799
- if (tags.length == 0) {
800
- reachedRoot = true;
722
+ }
723
+ const entity = text.substring(ampIdx + 1, semiIdx);
724
+ if (entity.charCodeAt(0) === 35) {
725
+ const elen = entity.length;
726
+ let code = 0;
727
+ let valid = false;
728
+ if (elen > 2 && (entity.charCodeAt(1) === 120 || entity.charCodeAt(1) === 88)) {
729
+ valid = true;
730
+ for (let k = 2;k < elen; k++) {
731
+ const d = entity.charCodeAt(k);
732
+ if (d >= 48 && d <= 57)
733
+ code = code << 4 | d - 48;
734
+ else if (d >= 65 && d <= 70)
735
+ code = code << 4 | d - 55;
736
+ else if (d >= 97 && d <= 102)
737
+ code = code << 4 | d - 87;
738
+ else {
739
+ valid = false;
740
+ break;
801
741
  }
802
742
  }
803
- } else {
804
- const isValid = validateAttributeString(attrStr, options);
805
- if (isValid !== true) {
806
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
807
- }
808
- if (reachedRoot === true) {
809
- return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
810
- } else if (options.unpairedTags.indexOf(tagName) !== -1) {} else {
811
- tags.push({ tagName, tagStartPos });
812
- }
813
- tagFound = true;
814
- }
815
- for (i++;i < xmlData.length; i++) {
816
- if (xmlData[i] === "<") {
817
- if (xmlData[i + 1] === "!") {
818
- i++;
819
- i = readCommentAndCDATA(xmlData, i);
820
- continue;
821
- } else if (xmlData[i + 1] === "?") {
822
- i = readPI(xmlData, ++i);
823
- if (i.err)
824
- return i;
825
- } else {
743
+ } else if (elen > 1) {
744
+ valid = true;
745
+ for (let k = 1;k < elen; k++) {
746
+ const d = entity.charCodeAt(k);
747
+ if (d >= 48 && d <= 57)
748
+ code = code * 10 + (d - 48);
749
+ else {
750
+ valid = false;
826
751
  break;
827
752
  }
828
- } else if (xmlData[i] === "&") {
829
- const afterAmp = validateAmpersand(xmlData, i);
830
- if (afterAmp == -1)
831
- return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
832
- i = afterAmp;
833
- } else {
834
- if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
835
- return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
836
- }
837
753
  }
838
754
  }
839
- if (xmlData[i] === "<") {
840
- i--;
841
- }
842
- }
843
- } else {
844
- if (isWhiteSpace(xmlData[i])) {
845
- continue;
846
- }
847
- return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
848
- }
849
- }
850
- if (!tagFound) {
851
- return getErrorObject("InvalidXml", "Start tag expected.", 1);
852
- } else if (tags.length == 1) {
853
- return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
854
- } else if (tags.length > 0) {
855
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
856
- }
857
- return true;
858
- }
859
- function isWhiteSpace(char) {
860
- return char === " " || char === "\t" || char === `
861
- ` || char === "\r";
862
- }
863
- function readPI(xmlData, i) {
864
- const start = i;
865
- for (;i < xmlData.length; i++) {
866
- if (xmlData[i] == "?" || xmlData[i] == " ") {
867
- const tagname = xmlData.substr(start, i - start);
868
- if (i > 5 && tagname === "xml") {
869
- return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
870
- } else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
871
- i++;
872
- break;
873
- } else {
874
- continue;
875
- }
876
- }
877
- }
878
- return i;
879
- }
880
- function readCommentAndCDATA(xmlData, i) {
881
- if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
882
- for (i += 3;i < xmlData.length; i++) {
883
- if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
884
- i += 2;
885
- break;
886
- }
887
- }
888
- } else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
889
- let angleBracketsCount = 1;
890
- for (i += 8;i < xmlData.length; i++) {
891
- if (xmlData[i] === "<") {
892
- angleBracketsCount++;
893
- } else if (xmlData[i] === ">") {
894
- angleBracketsCount--;
895
- if (angleBracketsCount === 0) {
896
- break;
897
- }
898
- }
899
- }
900
- } else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
901
- for (i += 8;i < xmlData.length; i++) {
902
- if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
903
- i += 2;
904
- break;
905
- }
906
- }
907
- }
908
- return i;
909
- }
910
- function readAttributeStr(xmlData, i) {
911
- let attrStr = "";
912
- let startChar = "";
913
- let tagClosed = false;
914
- for (;i < xmlData.length; i++) {
915
- if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
916
- if (startChar === "") {
917
- startChar = xmlData[i];
918
- } else if (startChar !== xmlData[i]) {} else {
919
- startChar = "";
920
- }
921
- } else if (xmlData[i] === ">") {
922
- if (startChar === "") {
923
- tagClosed = true;
924
- break;
925
- }
926
- }
927
- attrStr += xmlData[i];
928
- }
929
- if (startChar !== "") {
930
- return false;
931
- }
932
- return {
933
- value: attrStr,
934
- index: i,
935
- tagClosed
936
- };
937
- }
938
- function validateAttributeString(attrStr, options) {
939
- const matches = getAllMatches(attrStr, validAttrStrRegxp);
940
- const attrNames = {};
941
- for (let i = 0;i < matches.length; i++) {
942
- if (matches[i][1].length === 0) {
943
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
944
- } else if (matches[i][3] !== undefined && matches[i][4] === undefined) {
945
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
946
- } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {
947
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
948
- }
949
- const attrName = matches[i][2];
950
- if (!validateAttrName(attrName)) {
951
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
952
- }
953
- if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
954
- attrNames[attrName] = 1;
955
- } else {
956
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
957
- }
958
- }
959
- return true;
960
- }
961
- function validateNumberAmpersand(xmlData, i) {
962
- let re = /\d/;
963
- if (xmlData[i] === "x") {
964
- i++;
965
- re = /[\da-fA-F]/;
966
- }
967
- for (;i < xmlData.length; i++) {
968
- if (xmlData[i] === ";")
969
- return i;
970
- if (!xmlData[i].match(re))
971
- break;
972
- }
973
- return -1;
974
- }
975
- function validateAmpersand(xmlData, i) {
976
- i++;
977
- if (xmlData[i] === ";")
978
- return -1;
979
- if (xmlData[i] === "#") {
980
- i++;
981
- return validateNumberAmpersand(xmlData, i);
982
- }
983
- let count = 0;
984
- for (;i < xmlData.length; i++, count++) {
985
- if (xmlData[i].match(/\w/) && count < 20)
986
- continue;
987
- if (xmlData[i] === ";")
988
- break;
989
- return -1;
990
- }
991
- return i;
992
- }
993
- function getErrorObject(code, message, lineNumber) {
994
- return {
995
- err: {
996
- code,
997
- msg: message,
998
- line: lineNumber.line || lineNumber,
999
- col: lineNumber.col
1000
- }
1001
- };
1002
- }
1003
- function validateAttrName(attrName) {
1004
- return isName(attrName);
1005
- }
1006
- function validateTagName(tagname) {
1007
- return isName(tagname);
1008
- }
1009
- function getLineNumberForPosition(xmlData, index) {
1010
- const lines = xmlData.substring(0, index).split(/\r?\n/);
1011
- return {
1012
- line: lines.length,
1013
- col: lines[lines.length - 1].length + 1
1014
- };
1015
- }
1016
- function getPositionFromMatch(match) {
1017
- return match.startIndex + match[1].length;
1018
- }
1019
- var defaultOptions, doubleQuote = '"', singleQuote = "'", validAttrStrRegxp;
1020
- var init_validator = __esm(() => {
1021
- init_util();
1022
- defaultOptions = {
1023
- allowBooleanAttributes: false,
1024
- unpairedTags: []
1025
- };
1026
- validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
1027
- });
1028
-
1029
- // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
1030
- function normalizeProcessEntities(value) {
1031
- if (typeof value === "boolean") {
1032
- return {
1033
- enabled: value,
1034
- maxEntitySize: 1e4,
1035
- maxExpansionDepth: 10,
1036
- maxTotalExpansions: 1000,
1037
- maxExpandedLength: 1e5,
1038
- maxEntityCount: 100,
1039
- allowedTags: null,
1040
- tagFilter: null
1041
- };
1042
- }
1043
- if (typeof value === "object" && value !== null) {
1044
- return {
1045
- enabled: value.enabled !== false,
1046
- maxEntitySize: value.maxEntitySize ?? 1e4,
1047
- maxExpansionDepth: value.maxExpansionDepth ?? 10,
1048
- maxTotalExpansions: value.maxTotalExpansions ?? 1000,
1049
- maxExpandedLength: value.maxExpandedLength ?? 1e5,
1050
- maxEntityCount: value.maxEntityCount ?? 100,
1051
- allowedTags: value.allowedTags ?? null,
1052
- tagFilter: value.tagFilter ?? null
1053
- };
1054
- }
1055
- return normalizeProcessEntities(true);
1056
- }
1057
- var defaultOptions2, buildOptions = function(options) {
1058
- const built = Object.assign({}, defaultOptions2, options);
1059
- built.processEntities = normalizeProcessEntities(built.processEntities);
1060
- if (built.stopNodes && Array.isArray(built.stopNodes)) {
1061
- built.stopNodes = built.stopNodes.map((node) => {
1062
- if (typeof node === "string" && node.startsWith("*.")) {
1063
- return ".." + node.substring(2);
1064
- }
1065
- return node;
1066
- });
1067
- }
1068
- return built;
1069
- };
1070
- var init_OptionsBuilder = __esm(() => {
1071
- defaultOptions2 = {
1072
- preserveOrder: false,
1073
- attributeNamePrefix: "@_",
1074
- attributesGroupName: false,
1075
- textNodeName: "#text",
1076
- ignoreAttributes: true,
1077
- removeNSPrefix: false,
1078
- allowBooleanAttributes: false,
1079
- parseTagValue: true,
1080
- parseAttributeValue: false,
1081
- trimValues: true,
1082
- cdataPropName: false,
1083
- numberParseOptions: {
1084
- hex: true,
1085
- leadingZeros: true,
1086
- eNotation: true
1087
- },
1088
- tagValueProcessor: function(tagName, val) {
1089
- return val;
1090
- },
1091
- attributeValueProcessor: function(attrName, val) {
1092
- return val;
1093
- },
1094
- stopNodes: [],
1095
- alwaysCreateTextNode: false,
1096
- isArray: () => false,
1097
- commentPropName: false,
1098
- unpairedTags: [],
1099
- processEntities: true,
1100
- htmlEntities: false,
1101
- ignoreDeclaration: false,
1102
- ignorePiTags: false,
1103
- transformTagName: false,
1104
- transformAttributeName: false,
1105
- updateTag: function(tagName, jPath, attrs) {
1106
- return tagName;
1107
- },
1108
- captureMetaData: false,
1109
- maxNestedTags: 100,
1110
- strictReservedNames: true,
1111
- jPath: true
1112
- };
1113
- });
1114
-
1115
- // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
1116
- class XmlNode {
1117
- constructor(tagname) {
1118
- this.tagname = tagname;
1119
- this.child = [];
1120
- this[":@"] = Object.create(null);
1121
- }
1122
- add(key, val) {
1123
- if (key === "__proto__")
1124
- key = "#__proto__";
1125
- this.child.push({ [key]: val });
1126
- }
1127
- addChild(node, startIndex) {
1128
- if (node.tagname === "__proto__")
1129
- node.tagname = "#__proto__";
1130
- if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1131
- this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1132
- } else {
1133
- this.child.push({ [node.tagname]: node.child });
1134
- }
1135
- if (startIndex !== undefined) {
1136
- this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
1137
- }
1138
- }
1139
- static getMetaDataSymbol() {
1140
- return METADATA_SYMBOL;
1141
- }
1142
- }
1143
- var METADATA_SYMBOL;
1144
- var init_xmlNode = __esm(() => {
1145
- if (typeof Symbol !== "function") {
1146
- METADATA_SYMBOL = "@@xmlMetadata";
1147
- } else {
1148
- METADATA_SYMBOL = Symbol("XML Node Metadata");
1149
- }
1150
- });
1151
-
1152
- // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
1153
- class DocTypeReader {
1154
- constructor(options) {
1155
- this.suppressValidationErr = !options;
1156
- this.options = options;
1157
- }
1158
- readDocType(xmlData, i) {
1159
- const entities = Object.create(null);
1160
- let entityCount = 0;
1161
- 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") {
1162
- i = i + 9;
1163
- let angleBracketsCount = 1;
1164
- let hasBody = false, comment = false;
1165
- let exp = "";
1166
- for (;i < xmlData.length; i++) {
1167
- if (xmlData[i] === "<" && !comment) {
1168
- if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
1169
- i += 7;
1170
- let entityName, val;
1171
- [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
1172
- if (val.indexOf("&") === -1) {
1173
- if (this.options.enabled !== false && this.options.maxEntityCount && entityCount >= this.options.maxEntityCount) {
1174
- throw new Error(`Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`);
1175
- }
1176
- const escaped = entityName.replace(/[.\-+*:]/g, "\\.");
1177
- entities[entityName] = {
1178
- regx: RegExp(`&${escaped};`, "g"),
1179
- val
1180
- };
1181
- entityCount++;
1182
- }
1183
- } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
1184
- i += 8;
1185
- const { index } = this.readElementExp(xmlData, i + 1);
1186
- i = index;
1187
- } else if (hasBody && hasSeq(xmlData, "!ATTLIST", i)) {
1188
- i += 8;
1189
- } else if (hasBody && hasSeq(xmlData, "!NOTATION", i)) {
1190
- i += 9;
1191
- const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
1192
- i = index;
1193
- } else if (hasSeq(xmlData, "!--", i))
1194
- comment = true;
1195
- else
1196
- throw new Error(`Invalid DOCTYPE`);
1197
- angleBracketsCount++;
1198
- exp = "";
1199
- } else if (xmlData[i] === ">") {
1200
- if (comment) {
1201
- if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
1202
- comment = false;
1203
- angleBracketsCount--;
1204
- }
1205
- } else {
1206
- angleBracketsCount--;
1207
- }
1208
- if (angleBracketsCount === 0) {
1209
- break;
1210
- }
1211
- } else if (xmlData[i] === "[") {
1212
- hasBody = true;
755
+ if (valid) {
756
+ result += String.fromCodePoint(code);
1213
757
  } else {
1214
- exp += xmlData[i];
1215
- }
1216
- }
1217
- if (angleBracketsCount !== 0) {
1218
- throw new Error(`Unclosed DOCTYPE`);
1219
- }
1220
- } else {
1221
- throw new Error(`Invalid Tag instead of DOCTYPE`);
1222
- }
1223
- return { entities, i };
1224
- }
1225
- readEntityExp(xmlData, i) {
1226
- i = skipWhitespace(xmlData, i);
1227
- let entityName = "";
1228
- while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
1229
- entityName += xmlData[i];
1230
- i++;
1231
- }
1232
- validateEntityName(entityName);
1233
- i = skipWhitespace(xmlData, i);
1234
- if (!this.suppressValidationErr) {
1235
- if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
1236
- throw new Error("External entities are not supported");
1237
- } else if (xmlData[i] === "%") {
1238
- throw new Error("Parameter entities are not supported");
1239
- }
1240
- }
1241
- let entityValue = "";
1242
- [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
1243
- if (this.options.enabled !== false && this.options.maxEntitySize && entityValue.length > this.options.maxEntitySize) {
1244
- throw new Error(`Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);
1245
- }
1246
- i--;
1247
- return [entityName, entityValue, i];
1248
- }
1249
- readNotationExp(xmlData, i) {
1250
- i = skipWhitespace(xmlData, i);
1251
- let notationName = "";
1252
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1253
- notationName += xmlData[i];
1254
- i++;
1255
- }
1256
- !this.suppressValidationErr && validateEntityName(notationName);
1257
- i = skipWhitespace(xmlData, i);
1258
- const identifierType = xmlData.substring(i, i + 6).toUpperCase();
1259
- if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
1260
- throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
1261
- }
1262
- i += identifierType.length;
1263
- i = skipWhitespace(xmlData, i);
1264
- let publicIdentifier = null;
1265
- let systemIdentifier = null;
1266
- if (identifierType === "PUBLIC") {
1267
- [i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
1268
- i = skipWhitespace(xmlData, i);
1269
- if (xmlData[i] === '"' || xmlData[i] === "'") {
1270
- [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
1271
- }
1272
- } else if (identifierType === "SYSTEM") {
1273
- [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
1274
- if (!this.suppressValidationErr && !systemIdentifier) {
1275
- throw new Error("Missing mandatory system identifier for SYSTEM notation");
1276
- }
1277
- }
1278
- return { notationName, publicIdentifier, systemIdentifier, index: --i };
1279
- }
1280
- readIdentifierVal(xmlData, i, type) {
1281
- let identifierVal = "";
1282
- const startChar = xmlData[i];
1283
- if (startChar !== '"' && startChar !== "'") {
1284
- throw new Error(`Expected quoted string, found "${startChar}"`);
1285
- }
1286
- i++;
1287
- while (i < xmlData.length && xmlData[i] !== startChar) {
1288
- identifierVal += xmlData[i];
1289
- i++;
1290
- }
1291
- if (xmlData[i] !== startChar) {
1292
- throw new Error(`Unterminated ${type} value`);
1293
- }
1294
- i++;
1295
- return [i, identifierVal];
1296
- }
1297
- readElementExp(xmlData, i) {
1298
- i = skipWhitespace(xmlData, i);
1299
- let elementName = "";
1300
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1301
- elementName += xmlData[i];
1302
- i++;
1303
- }
1304
- if (!this.suppressValidationErr && !isName(elementName)) {
1305
- throw new Error(`Invalid element name: "${elementName}"`);
1306
- }
1307
- i = skipWhitespace(xmlData, i);
1308
- let contentModel = "";
1309
- if (xmlData[i] === "E" && hasSeq(xmlData, "MPTY", i))
1310
- i += 4;
1311
- else if (xmlData[i] === "A" && hasSeq(xmlData, "NY", i))
1312
- i += 2;
1313
- else if (xmlData[i] === "(") {
1314
- i++;
1315
- while (i < xmlData.length && xmlData[i] !== ")") {
1316
- contentModel += xmlData[i];
1317
- i++;
1318
- }
1319
- if (xmlData[i] !== ")") {
1320
- throw new Error("Unterminated content model");
1321
- }
1322
- } else if (!this.suppressValidationErr) {
1323
- throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
1324
- }
1325
- return {
1326
- elementName,
1327
- contentModel: contentModel.trim(),
1328
- index: i
1329
- };
1330
- }
1331
- readAttlistExp(xmlData, i) {
1332
- i = skipWhitespace(xmlData, i);
1333
- let elementName = "";
1334
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1335
- elementName += xmlData[i];
1336
- i++;
1337
- }
1338
- validateEntityName(elementName);
1339
- i = skipWhitespace(xmlData, i);
1340
- let attributeName = "";
1341
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1342
- attributeName += xmlData[i];
1343
- i++;
1344
- }
1345
- if (!validateEntityName(attributeName)) {
1346
- throw new Error(`Invalid attribute name: "${attributeName}"`);
1347
- }
1348
- i = skipWhitespace(xmlData, i);
1349
- let attributeType = "";
1350
- if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
1351
- attributeType = "NOTATION";
1352
- i += 8;
1353
- i = skipWhitespace(xmlData, i);
1354
- if (xmlData[i] !== "(") {
1355
- throw new Error(`Expected '(', found "${xmlData[i]}"`);
1356
- }
1357
- i++;
1358
- let allowedNotations = [];
1359
- while (i < xmlData.length && xmlData[i] !== ")") {
1360
- let notation = "";
1361
- while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
1362
- notation += xmlData[i];
1363
- i++;
1364
- }
1365
- notation = notation.trim();
1366
- if (!validateEntityName(notation)) {
1367
- throw new Error(`Invalid notation name: "${notation}"`);
758
+ result += text.substring(ampIdx, semiIdx + 1);
1368
759
  }
1369
- allowedNotations.push(notation);
1370
- if (xmlData[i] === "|") {
1371
- i++;
1372
- i = skipWhitespace(xmlData, i);
1373
- }
1374
- }
1375
- if (xmlData[i] !== ")") {
1376
- throw new Error("Unterminated list of notations");
1377
- }
1378
- i++;
1379
- attributeType += " (" + allowedNotations.join("|") + ")";
1380
- } else {
1381
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
1382
- attributeType += xmlData[i];
1383
- i++;
1384
- }
1385
- const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
1386
- if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
1387
- throw new Error(`Invalid attribute type: "${attributeType}"`);
1388
- }
1389
- }
1390
- i = skipWhitespace(xmlData, i);
1391
- let defaultValue = "";
1392
- if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
1393
- defaultValue = "#REQUIRED";
1394
- i += 8;
1395
- } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
1396
- defaultValue = "#IMPLIED";
1397
- i += 7;
1398
- } else {
1399
- [i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
1400
- }
1401
- return {
1402
- elementName,
1403
- attributeName,
1404
- attributeType,
1405
- defaultValue,
1406
- index: i
1407
- };
1408
- }
1409
- }
1410
- function hasSeq(data, seq, i) {
1411
- for (let j = 0;j < seq.length; j++) {
1412
- if (seq[j] !== data[i + j + 1])
1413
- return false;
1414
- }
1415
- return true;
1416
- }
1417
- function validateEntityName(name) {
1418
- if (isName(name))
1419
- return name;
1420
- else
1421
- throw new Error(`Invalid entity name ${name}`);
1422
- }
1423
- var skipWhitespace = (data, index) => {
1424
- while (index < data.length && /\s/.test(data[index])) {
1425
- index++;
1426
- }
1427
- return index;
1428
- };
1429
- var init_DocTypeReader = __esm(() => {
1430
- init_util();
1431
- });
1432
-
1433
- // ../../node_modules/strnum/strnum.js
1434
- function toNumber(str, options = {}) {
1435
- options = Object.assign({}, consider, options);
1436
- if (!str || typeof str !== "string")
1437
- return str;
1438
- let trimmedStr = str.trim();
1439
- if (options.skipLike !== undefined && options.skipLike.test(trimmedStr))
1440
- return str;
1441
- else if (str === "0")
1442
- return 0;
1443
- else if (options.hex && hexRegex.test(trimmedStr)) {
1444
- return parse_int(trimmedStr, 16);
1445
- } else if (!isFinite(trimmedStr)) {
1446
- return handleInfinity(str, Number(trimmedStr), options);
1447
- } else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
1448
- return resolveEnotation(str, trimmedStr, options);
1449
- } else {
1450
- const match = numRegex.exec(trimmedStr);
1451
- if (match) {
1452
- const sign = match[1] || "";
1453
- const leadingZeros = match[2];
1454
- let numTrimmedByZeros = trimZeros(match[3]);
1455
- const decimalAdjacentToLeadingZeros = sign ? str[leadingZeros.length + 1] === "." : str[leadingZeros.length] === ".";
1456
- if (!options.leadingZeros && (leadingZeros.length > 1 || leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros)) {
1457
- return str;
1458
- } else {
1459
- const num = Number(trimmedStr);
1460
- const parsedStr = String(num);
1461
- if (num === 0)
1462
- return num;
1463
- if (parsedStr.search(/[eE]/) !== -1) {
1464
- if (options.eNotation)
1465
- return num;
1466
- else
1467
- return str;
1468
- } else if (trimmedStr.indexOf(".") !== -1) {
1469
- if (parsedStr === "0")
1470
- return num;
1471
- else if (parsedStr === numTrimmedByZeros)
1472
- return num;
1473
- else if (parsedStr === `${sign}${numTrimmedByZeros}`)
1474
- return num;
1475
- else
1476
- return str;
1477
- }
1478
- let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
1479
- if (leadingZeros) {
1480
- return n === parsedStr || sign + n === parsedStr ? num : str;
1481
- } else {
1482
- return n === parsedStr || n === sign + parsedStr ? num : str;
1483
- }
1484
- }
1485
- } else {
1486
- return str;
1487
- }
1488
- }
1489
- }
1490
- function resolveEnotation(str, trimmedStr, options) {
1491
- if (!options.eNotation)
1492
- return str;
1493
- const notation = trimmedStr.match(eNotationRegx);
1494
- if (notation) {
1495
- let sign = notation[1] || "";
1496
- const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
1497
- const leadingZeros = notation[2];
1498
- const eAdjacentToLeadingZeros = sign ? str[leadingZeros.length + 1] === eChar : str[leadingZeros.length] === eChar;
1499
- if (leadingZeros.length > 1 && eAdjacentToLeadingZeros)
1500
- return str;
1501
- else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
1502
- return Number(trimmedStr);
1503
- } else if (options.leadingZeros && !eAdjacentToLeadingZeros) {
1504
- trimmedStr = (notation[1] || "") + notation[3];
1505
- return Number(trimmedStr);
1506
- } else
1507
- return str;
1508
- } else {
1509
- return str;
1510
- }
1511
- }
1512
- function trimZeros(numStr) {
1513
- if (numStr && numStr.indexOf(".") !== -1) {
1514
- numStr = numStr.replace(/0+$/, "");
1515
- if (numStr === ".")
1516
- numStr = "0";
1517
- else if (numStr[0] === ".")
1518
- numStr = "0" + numStr;
1519
- else if (numStr[numStr.length - 1] === ".")
1520
- numStr = numStr.substring(0, numStr.length - 1);
1521
- return numStr;
1522
- }
1523
- return numStr;
1524
- }
1525
- function parse_int(numStr, base) {
1526
- if (parseInt)
1527
- return parseInt(numStr, base);
1528
- else if (Number.parseInt)
1529
- return Number.parseInt(numStr, base);
1530
- else if (window && window.parseInt)
1531
- return window.parseInt(numStr, base);
1532
- else
1533
- throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
1534
- }
1535
- function handleInfinity(str, num, options) {
1536
- const isPositive = num === Infinity;
1537
- switch (options.infinity.toLowerCase()) {
1538
- case "null":
1539
- return null;
1540
- case "infinity":
1541
- return num;
1542
- case "string":
1543
- return isPositive ? "Infinity" : "-Infinity";
1544
- case "original":
1545
- default:
1546
- return str;
1547
- }
1548
- }
1549
- var hexRegex, numRegex, consider, eNotationRegx;
1550
- var init_strnum = __esm(() => {
1551
- hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
1552
- numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
1553
- consider = {
1554
- hex: true,
1555
- leadingZeros: true,
1556
- decimalPoint: ".",
1557
- eNotation: true,
1558
- infinity: "original"
1559
- };
1560
- eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
1561
- });
1562
-
1563
- // ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
1564
- function getIgnoreAttributesFn(ignoreAttributes) {
1565
- if (typeof ignoreAttributes === "function") {
1566
- return ignoreAttributes;
1567
- }
1568
- if (Array.isArray(ignoreAttributes)) {
1569
- return (attrName) => {
1570
- for (const pattern of ignoreAttributes) {
1571
- if (typeof pattern === "string" && attrName === pattern) {
1572
- return true;
1573
- }
1574
- if (pattern instanceof RegExp && pattern.test(attrName)) {
1575
- return true;
1576
- }
1577
- }
1578
- };
1579
- }
1580
- return () => false;
1581
- }
1582
-
1583
- // ../../node_modules/path-expression-matcher/src/Expression.js
1584
- class Expression {
1585
- constructor(pattern, options = {}) {
1586
- this.pattern = pattern;
1587
- this.separator = options.separator || ".";
1588
- this.segments = this._parse(pattern);
1589
- this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
1590
- this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== undefined);
1591
- this._hasPositionSelector = this.segments.some((seg) => seg.position !== undefined);
1592
- }
1593
- _parse(pattern) {
1594
- const segments = [];
1595
- let i = 0;
1596
- let currentPart = "";
1597
- while (i < pattern.length) {
1598
- if (pattern[i] === this.separator) {
1599
- if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
1600
- if (currentPart.trim()) {
1601
- segments.push(this._parseSegment(currentPart.trim()));
1602
- currentPart = "";
1603
- }
1604
- segments.push({ type: "deep-wildcard" });
1605
- i += 2;
1606
- } else {
1607
- if (currentPart.trim()) {
1608
- segments.push(this._parseSegment(currentPart.trim()));
1609
- }
1610
- currentPart = "";
1611
- i++;
1612
- }
1613
- } else {
1614
- currentPart += pattern[i];
1615
- i++;
1616
- }
1617
- }
1618
- if (currentPart.trim()) {
1619
- segments.push(this._parseSegment(currentPart.trim()));
1620
- }
1621
- return segments;
1622
- }
1623
- _parseSegment(part) {
1624
- const segment = { type: "tag" };
1625
- let bracketContent = null;
1626
- let withoutBrackets = part;
1627
- const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
1628
- if (bracketMatch) {
1629
- withoutBrackets = bracketMatch[1] + bracketMatch[3];
1630
- if (bracketMatch[2]) {
1631
- const content = bracketMatch[2].slice(1, -1);
1632
- if (content) {
1633
- bracketContent = content;
1634
- }
1635
- }
1636
- }
1637
- let namespace = undefined;
1638
- let tagAndPosition = withoutBrackets;
1639
- if (withoutBrackets.includes("::")) {
1640
- const nsIndex = withoutBrackets.indexOf("::");
1641
- namespace = withoutBrackets.substring(0, nsIndex).trim();
1642
- tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
1643
- if (!namespace) {
1644
- throw new Error(`Invalid namespace in pattern: ${part}`);
1645
- }
1646
- }
1647
- let tag = undefined;
1648
- let positionMatch = null;
1649
- if (tagAndPosition.includes(":")) {
1650
- const colonIndex = tagAndPosition.lastIndexOf(":");
1651
- const tagPart = tagAndPosition.substring(0, colonIndex).trim();
1652
- const posPart = tagAndPosition.substring(colonIndex + 1).trim();
1653
- const isPositionKeyword = ["first", "last", "odd", "even"].includes(posPart) || /^nth\(\d+\)$/.test(posPart);
1654
- if (isPositionKeyword) {
1655
- tag = tagPart;
1656
- positionMatch = posPart;
1657
- } else {
1658
- tag = tagAndPosition;
1659
- }
1660
- } else {
1661
- tag = tagAndPosition;
1662
- }
1663
- if (!tag) {
1664
- throw new Error(`Invalid segment pattern: ${part}`);
1665
- }
1666
- segment.tag = tag;
1667
- if (namespace) {
1668
- segment.namespace = namespace;
1669
- }
1670
- if (bracketContent) {
1671
- if (bracketContent.includes("=")) {
1672
- const eqIndex = bracketContent.indexOf("=");
1673
- segment.attrName = bracketContent.substring(0, eqIndex).trim();
1674
- segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
1675
- } else {
1676
- segment.attrName = bracketContent.trim();
1677
- }
1678
- }
1679
- if (positionMatch) {
1680
- const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
1681
- if (nthMatch) {
1682
- segment.position = "nth";
1683
- segment.positionValue = parseInt(nthMatch[1], 10);
1684
- } else {
1685
- segment.position = positionMatch;
1686
- }
1687
- }
1688
- return segment;
1689
- }
1690
- get length() {
1691
- return this.segments.length;
1692
- }
1693
- hasDeepWildcard() {
1694
- return this._hasDeepWildcard;
1695
- }
1696
- hasAttributeCondition() {
1697
- return this._hasAttributeCondition;
1698
- }
1699
- hasPositionSelector() {
1700
- return this._hasPositionSelector;
1701
- }
1702
- toString() {
1703
- return this.pattern;
1704
- }
1705
- }
1706
-
1707
- // ../../node_modules/path-expression-matcher/src/Matcher.js
1708
- class Matcher {
1709
- constructor(options = {}) {
1710
- this.separator = options.separator || ".";
1711
- this.path = [];
1712
- this.siblingStacks = [];
1713
- }
1714
- push(tagName, attrValues = null, namespace = null) {
1715
- if (this.path.length > 0) {
1716
- const prev = this.path[this.path.length - 1];
1717
- prev.values = undefined;
1718
- }
1719
- const currentLevel = this.path.length;
1720
- if (!this.siblingStacks[currentLevel]) {
1721
- this.siblingStacks[currentLevel] = new Map;
1722
- }
1723
- const siblings = this.siblingStacks[currentLevel];
1724
- const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;
1725
- const counter = siblings.get(siblingKey) || 0;
1726
- let position = 0;
1727
- for (const count of siblings.values()) {
1728
- position += count;
1729
- }
1730
- siblings.set(siblingKey, counter + 1);
1731
- const node = {
1732
- tag: tagName,
1733
- position,
1734
- counter
1735
- };
1736
- if (namespace !== null && namespace !== undefined) {
1737
- node.namespace = namespace;
1738
- }
1739
- if (attrValues !== null && attrValues !== undefined) {
1740
- node.values = attrValues;
1741
- }
1742
- this.path.push(node);
1743
- }
1744
- pop() {
1745
- if (this.path.length === 0) {
1746
- return;
1747
- }
1748
- const node = this.path.pop();
1749
- if (this.siblingStacks.length > this.path.length + 1) {
1750
- this.siblingStacks.length = this.path.length + 1;
1751
- }
1752
- return node;
1753
- }
1754
- updateCurrent(attrValues) {
1755
- if (this.path.length > 0) {
1756
- const current = this.path[this.path.length - 1];
1757
- if (attrValues !== null && attrValues !== undefined) {
1758
- current.values = attrValues;
1759
- }
1760
- }
1761
- }
1762
- getCurrentTag() {
1763
- return this.path.length > 0 ? this.path[this.path.length - 1].tag : undefined;
1764
- }
1765
- getCurrentNamespace() {
1766
- return this.path.length > 0 ? this.path[this.path.length - 1].namespace : undefined;
1767
- }
1768
- getAttrValue(attrName) {
1769
- if (this.path.length === 0)
1770
- return;
1771
- const current = this.path[this.path.length - 1];
1772
- return current.values?.[attrName];
1773
- }
1774
- hasAttr(attrName) {
1775
- if (this.path.length === 0)
1776
- return false;
1777
- const current = this.path[this.path.length - 1];
1778
- return current.values !== undefined && attrName in current.values;
1779
- }
1780
- getPosition() {
1781
- if (this.path.length === 0)
1782
- return -1;
1783
- return this.path[this.path.length - 1].position ?? 0;
1784
- }
1785
- getCounter() {
1786
- if (this.path.length === 0)
1787
- return -1;
1788
- return this.path[this.path.length - 1].counter ?? 0;
1789
- }
1790
- getIndex() {
1791
- return this.getPosition();
1792
- }
1793
- getDepth() {
1794
- return this.path.length;
1795
- }
1796
- toString(separator, includeNamespace = true) {
1797
- const sep = separator || this.separator;
1798
- return this.path.map((n) => {
1799
- if (includeNamespace && n.namespace) {
1800
- return `${n.namespace}:${n.tag}`;
1801
- }
1802
- return n.tag;
1803
- }).join(sep);
1804
- }
1805
- toArray() {
1806
- return this.path.map((n) => n.tag);
1807
- }
1808
- reset() {
1809
- this.path = [];
1810
- this.siblingStacks = [];
1811
- }
1812
- matches(expression) {
1813
- const segments = expression.segments;
1814
- if (segments.length === 0) {
1815
- return false;
1816
- }
1817
- if (expression.hasDeepWildcard()) {
1818
- return this._matchWithDeepWildcard(segments);
1819
- }
1820
- return this._matchSimple(segments);
1821
- }
1822
- _matchSimple(segments) {
1823
- if (this.path.length !== segments.length) {
1824
- return false;
1825
- }
1826
- for (let i = 0;i < segments.length; i++) {
1827
- const segment = segments[i];
1828
- const node = this.path[i];
1829
- const isCurrentNode = i === this.path.length - 1;
1830
- if (!this._matchSegment(segment, node, isCurrentNode)) {
1831
- return false;
1832
- }
1833
- }
1834
- return true;
1835
- }
1836
- _matchWithDeepWildcard(segments) {
1837
- let pathIdx = this.path.length - 1;
1838
- let segIdx = segments.length - 1;
1839
- while (segIdx >= 0 && pathIdx >= 0) {
1840
- const segment = segments[segIdx];
1841
- if (segment.type === "deep-wildcard") {
1842
- segIdx--;
1843
- if (segIdx < 0) {
1844
- return true;
1845
- }
1846
- const nextSeg = segments[segIdx];
1847
- let found = false;
1848
- for (let i = pathIdx;i >= 0; i--) {
1849
- const isCurrentNode = i === this.path.length - 1;
1850
- if (this._matchSegment(nextSeg, this.path[i], isCurrentNode)) {
1851
- pathIdx = i - 1;
1852
- segIdx--;
1853
- found = true;
1854
- break;
1855
- }
1856
- }
1857
- if (!found) {
1858
- return false;
1859
- }
1860
- } else {
1861
- const isCurrentNode = pathIdx === this.path.length - 1;
1862
- if (!this._matchSegment(segment, this.path[pathIdx], isCurrentNode)) {
1863
- return false;
1864
- }
1865
- pathIdx--;
1866
- segIdx--;
1867
- }
1868
- }
1869
- return segIdx < 0;
1870
- }
1871
- _matchSegment(segment, node, isCurrentNode) {
1872
- if (segment.tag !== "*" && segment.tag !== node.tag) {
1873
- return false;
1874
- }
1875
- if (segment.namespace !== undefined) {
1876
- if (segment.namespace !== "*" && segment.namespace !== node.namespace) {
1877
- return false;
1878
- }
1879
- }
1880
- if (segment.attrName !== undefined) {
1881
- if (!isCurrentNode) {
1882
- return false;
1883
- }
1884
- if (!node.values || !(segment.attrName in node.values)) {
1885
- return false;
1886
- }
1887
- if (segment.attrValue !== undefined) {
1888
- const actualValue = node.values[segment.attrName];
1889
- if (String(actualValue) !== String(segment.attrValue)) {
1890
- return false;
1891
- }
1892
- }
1893
- }
1894
- if (segment.position !== undefined) {
1895
- if (!isCurrentNode) {
1896
- return false;
1897
- }
1898
- const counter = node.counter ?? 0;
1899
- if (segment.position === "first" && counter !== 0) {
1900
- return false;
1901
- } else if (segment.position === "odd" && counter % 2 !== 1) {
1902
- return false;
1903
- } else if (segment.position === "even" && counter % 2 !== 0) {
1904
- return false;
1905
- } else if (segment.position === "nth") {
1906
- if (counter !== segment.positionValue) {
1907
- return false;
1908
- }
1909
- }
1910
- }
1911
- return true;
1912
- }
1913
- snapshot() {
1914
- return {
1915
- path: this.path.map((node) => ({ ...node })),
1916
- siblingStacks: this.siblingStacks.map((map) => new Map(map))
1917
- };
1918
- }
1919
- restore(snapshot) {
1920
- this.path = snapshot.path.map((node) => ({ ...node }));
1921
- this.siblingStacks = snapshot.siblingStacks.map((map) => new Map(map));
1922
- }
1923
- }
1924
-
1925
- // ../../node_modules/path-expression-matcher/src/index.js
1926
- var init_src = () => {};
1927
-
1928
- // ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
1929
- function extractRawAttributes(prefixedAttrs, options) {
1930
- if (!prefixedAttrs)
1931
- return {};
1932
- const attrs = options.attributesGroupName ? prefixedAttrs[options.attributesGroupName] : prefixedAttrs;
1933
- if (!attrs)
1934
- return {};
1935
- const rawAttrs = {};
1936
- for (const key in attrs) {
1937
- if (key.startsWith(options.attributeNamePrefix)) {
1938
- const rawName = key.substring(options.attributeNamePrefix.length);
1939
- rawAttrs[rawName] = attrs[key];
1940
- } else {
1941
- rawAttrs[key] = attrs[key];
1942
- }
1943
- }
1944
- return rawAttrs;
1945
- }
1946
- function extractNamespace(rawTagName) {
1947
- if (!rawTagName || typeof rawTagName !== "string")
1948
- return;
1949
- const colonIndex = rawTagName.indexOf(":");
1950
- if (colonIndex !== -1 && colonIndex > 0) {
1951
- const ns = rawTagName.substring(0, colonIndex);
1952
- if (ns !== "xmlns") {
1953
- return ns;
1954
- }
1955
- }
1956
- return;
1957
- }
1958
-
1959
- class OrderedObjParser {
1960
- constructor(options) {
1961
- this.options = options;
1962
- this.currentNode = null;
1963
- this.tagsNodeStack = [];
1964
- this.docTypeEntities = {};
1965
- this.lastEntities = {
1966
- apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
1967
- gt: { regex: /&(gt|#62|#x3E);/g, val: ">" },
1968
- lt: { regex: /&(lt|#60|#x3C);/g, val: "<" },
1969
- quot: { regex: /&(quot|#34|#x22);/g, val: '"' }
1970
- };
1971
- this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
1972
- this.htmlEntities = {
1973
- space: { regex: /&(nbsp|#160);/g, val: " " },
1974
- cent: { regex: /&(cent|#162);/g, val: "¢" },
1975
- pound: { regex: /&(pound|#163);/g, val: "£" },
1976
- yen: { regex: /&(yen|#165);/g, val: "¥" },
1977
- euro: { regex: /&(euro|#8364);/g, val: "€" },
1978
- copyright: { regex: /&(copy|#169);/g, val: "©" },
1979
- reg: { regex: /&(reg|#174);/g, val: "®" },
1980
- inr: { regex: /&(inr|#8377);/g, val: "₹" },
1981
- num_dec: { regex: /&#([0-9]{1,7});/g, val: (_, str) => fromCodePoint(str, 10, "&#") },
1982
- num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => fromCodePoint(str, 16, "&#x") }
1983
- };
1984
- this.addExternalEntities = addExternalEntities;
1985
- this.parseXml = parseXml;
1986
- this.parseTextData = parseTextData;
1987
- this.resolveNameSpace = resolveNameSpace;
1988
- this.buildAttributesMap = buildAttributesMap;
1989
- this.isItStopNode = isItStopNode;
1990
- this.replaceEntitiesValue = replaceEntitiesValue;
1991
- this.readStopNodeData = readStopNodeData;
1992
- this.saveTextToParentTag = saveTextToParentTag;
1993
- this.addChild = addChild;
1994
- this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
1995
- this.entityExpansionCount = 0;
1996
- this.currentExpandedLength = 0;
1997
- this.matcher = new Matcher;
1998
- this.isCurrentNodeStopNode = false;
1999
- if (this.options.stopNodes && this.options.stopNodes.length > 0) {
2000
- this.stopNodeExpressions = [];
2001
- for (let i = 0;i < this.options.stopNodes.length; i++) {
2002
- const stopNodeExp = this.options.stopNodes[i];
2003
- if (typeof stopNodeExp === "string") {
2004
- this.stopNodeExpressions.push(new Expression(stopNodeExp));
2005
- } else if (stopNodeExp instanceof Expression) {
2006
- this.stopNodeExpressions.push(stopNodeExp);
2007
- }
2008
- }
2009
- }
2010
- }
2011
- }
2012
- function addExternalEntities(externalEntities) {
2013
- const entKeys = Object.keys(externalEntities);
2014
- for (let i = 0;i < entKeys.length; i++) {
2015
- const ent = entKeys[i];
2016
- const escaped = ent.replace(/[.\-+*:]/g, "\\.");
2017
- this.lastEntities[ent] = {
2018
- regex: new RegExp("&" + escaped + ";", "g"),
2019
- val: externalEntities[ent]
2020
- };
2021
- }
2022
- }
2023
- function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
2024
- if (val !== undefined) {
2025
- if (this.options.trimValues && !dontTrim) {
2026
- val = val.trim();
2027
- }
2028
- if (val.length > 0) {
2029
- if (!escapeEntities)
2030
- val = this.replaceEntitiesValue(val, tagName, jPath);
2031
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
2032
- const newval = this.options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
2033
- if (newval === null || newval === undefined) {
2034
- return val;
2035
- } else if (typeof newval !== typeof val || newval !== val) {
2036
- return newval;
2037
- } else if (this.options.trimValues) {
2038
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
2039
- } else {
2040
- const trimmedVal = val.trim();
2041
- if (trimmedVal === val) {
2042
- return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
2043
- } else {
2044
- return val;
2045
- }
2046
- }
2047
- }
2048
- }
2049
- }
2050
- function resolveNameSpace(tagname) {
2051
- if (this.options.removeNSPrefix) {
2052
- const tags = tagname.split(":");
2053
- const prefix = tagname.charAt(0) === "/" ? "/" : "";
2054
- if (tags[0] === "xmlns") {
2055
- return "";
2056
- }
2057
- if (tags.length === 2) {
2058
- tagname = prefix + tags[1];
2059
- }
2060
- }
2061
- return tagname;
2062
- }
2063
- function buildAttributesMap(attrStr, jPath, tagName) {
2064
- if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
2065
- const matches = getAllMatches(attrStr, attrsRegx);
2066
- const len = matches.length;
2067
- const attrs = {};
2068
- const rawAttrsForMatcher = {};
2069
- for (let i = 0;i < len; i++) {
2070
- const attrName = this.resolveNameSpace(matches[i][1]);
2071
- const oldVal = matches[i][4];
2072
- if (attrName.length && oldVal !== undefined) {
2073
- let parsedVal = oldVal;
2074
- if (this.options.trimValues) {
2075
- parsedVal = parsedVal.trim();
2076
- }
2077
- parsedVal = this.replaceEntitiesValue(parsedVal, tagName, jPath);
2078
- rawAttrsForMatcher[attrName] = parsedVal;
2079
- }
2080
- }
2081
- if (Object.keys(rawAttrsForMatcher).length > 0 && typeof jPath === "object" && jPath.updateCurrent) {
2082
- jPath.updateCurrent(rawAttrsForMatcher);
2083
- }
2084
- for (let i = 0;i < len; i++) {
2085
- const attrName = this.resolveNameSpace(matches[i][1]);
2086
- const jPathStr = this.options.jPath ? jPath.toString() : jPath;
2087
- if (this.ignoreAttributesFn(attrName, jPathStr)) {
2088
- continue;
2089
- }
2090
- let oldVal = matches[i][4];
2091
- let aName = this.options.attributeNamePrefix + attrName;
2092
- if (attrName.length) {
2093
- if (this.options.transformAttributeName) {
2094
- aName = this.options.transformAttributeName(aName);
2095
- }
2096
- if (aName === "__proto__")
2097
- aName = "#__proto__";
2098
- if (oldVal !== undefined) {
2099
- if (this.options.trimValues) {
2100
- oldVal = oldVal.trim();
2101
- }
2102
- oldVal = this.replaceEntitiesValue(oldVal, tagName, jPath);
2103
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
2104
- const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPathOrMatcher);
2105
- if (newVal === null || newVal === undefined) {
2106
- attrs[aName] = oldVal;
2107
- } else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
2108
- attrs[aName] = newVal;
2109
- } else {
2110
- attrs[aName] = parseValue(oldVal, this.options.parseAttributeValue, this.options.numberParseOptions);
760
+ } else {
761
+ let replacement = this.customEntities[entity];
762
+ if (replacement === undefined) {
763
+ const elen = entity.length;
764
+ if (elen >= 2 && elen <= 4) {
765
+ const e0 = entity.charCodeAt(0);
766
+ if (e0 === 108 && elen === 2 && entity.charCodeAt(1) === 116)
767
+ replacement = "<";
768
+ else if (e0 === 103 && elen === 2 && entity.charCodeAt(1) === 116)
769
+ replacement = ">";
770
+ else if (e0 === 97 && elen === 3 && entity.charCodeAt(1) === 109 && entity.charCodeAt(2) === 112)
771
+ replacement = "&";
772
+ else if (e0 === 113 && elen === 4)
773
+ replacement = entity === "quot" ? '"' : undefined;
774
+ else if (e0 === 97 && elen === 4)
775
+ replacement = entity === "apos" ? "'" : undefined;
2111
776
  }
2112
- } else if (this.options.allowBooleanAttributes) {
2113
- attrs[aName] = true;
777
+ if (replacement === undefined)
778
+ replacement = xmlEntities[entity] ?? (this.useHtmlEntities ? htmlEntities[entity] : undefined);
779
+ }
780
+ if (replacement !== undefined) {
781
+ result += replacement;
782
+ } else {
783
+ result += text.substring(ampIdx, semiIdx + 1);
2114
784
  }
2115
785
  }
786
+ lastPos = semiIdx + 1;
787
+ ampIdx = text.indexOf("&", lastPos);
2116
788
  }
2117
- if (!Object.keys(attrs).length) {
2118
- return;
2119
- }
2120
- if (this.options.attributesGroupName) {
2121
- const attrCollection = {};
2122
- attrCollection[this.options.attributesGroupName] = attrs;
2123
- return attrCollection;
2124
- }
2125
- return attrs;
789
+ if (lastPos < len)
790
+ result += text.substring(lastPos);
791
+ return result;
2126
792
  }
2127
793
  }
2128
- function addChild(currentNode, childNode, matcher, startIndex) {
2129
- if (!this.options.captureMetaData)
2130
- startIndex = undefined;
2131
- const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher;
2132
- const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]);
2133
- if (result === false) {} else if (typeof result === "string") {
2134
- childNode.tagname = result;
2135
- currentNode.addChild(childNode, startIndex);
2136
- } else {
2137
- currentNode.addChild(childNode, startIndex);
2138
- }
794
+ function isWhitespace(ch) {
795
+ return ch === 32 || ch === 9 || ch === 10 || ch === 13;
2139
796
  }
2140
- function replaceEntitiesValue(val, tagName, jPath) {
2141
- const entityConfig = this.options.processEntities;
2142
- if (!entityConfig || !entityConfig.enabled) {
2143
- return val;
797
+ function isNameStartChar(ch) {
798
+ return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 95 || ch === 58 || ch >= 192 && ch <= 214 || ch >= 216 && ch <= 246 || ch >= 248 && ch <= 767 || ch >= 880 && ch <= 893 || ch >= 895 && ch <= 8191 || ch >= 8204 && ch <= 8205 || ch >= 8304 && ch <= 8591 || ch >= 11264 && ch <= 12271 || ch >= 12289 && ch <= 55295 || ch >= 63744 && ch <= 64975 || ch >= 65008 && ch <= 65533;
799
+ }
800
+ function isNameChar(ch) {
801
+ return isNameStartChar(ch) || ch === 45 || ch === 46 || ch >= 48 && ch <= 57 || ch === 183 || ch >= 768 && ch <= 879 || ch >= 8255 && ch <= 8256;
802
+ }
803
+ function isCDATA(xml, pos) {
804
+ return xml.charCodeAt(pos) === 91 && xml.charCodeAt(pos + 1) === 67 && xml.charCodeAt(pos + 2) === 68 && xml.charCodeAt(pos + 3) === 65 && xml.charCodeAt(pos + 4) === 84 && xml.charCodeAt(pos + 5) === 65 && xml.charCodeAt(pos + 6) === 91;
805
+ }
806
+ function isDOCTYPE(xml, pos) {
807
+ const c0 = xml.charCodeAt(pos);
808
+ const c1 = xml.charCodeAt(pos + 1);
809
+ const c2 = xml.charCodeAt(pos + 2);
810
+ const c3 = xml.charCodeAt(pos + 3);
811
+ const c4 = xml.charCodeAt(pos + 4);
812
+ const c5 = xml.charCodeAt(pos + 5);
813
+ const c6 = xml.charCodeAt(pos + 6);
814
+ return (c0 === 68 || c0 === 100) && (c1 === 79 || c1 === 111) && (c2 === 67 || c2 === 99) && (c3 === 84 || c3 === 116) && (c4 === 89 || c4 === 121) && (c5 === 80 || c5 === 112) && (c6 === 69 || c6 === 101);
815
+ }
816
+ function readNameEnd(xml, pos, len) {
817
+ if (pos >= len || !isNameStartChar(xml.charCodeAt(pos)))
818
+ return pos;
819
+ pos++;
820
+ while (pos < len && isNameChar(xml.charCodeAt(pos)))
821
+ pos++;
822
+ return pos;
823
+ }
824
+
825
+ class XMLParser {
826
+ options;
827
+ entityDecoder;
828
+ unpairedSet;
829
+ exactStopNodes;
830
+ wildcardStopSuffixes;
831
+ needsJPath;
832
+ _ignoreAttributes = true;
833
+ _textNodeName = "#text";
834
+ _commentPropName = false;
835
+ _cdataPropName = false;
836
+ _piPropName = false;
837
+ _alwaysCreateTextNode = false;
838
+ _trimValues = true;
839
+ _processEntities = true;
840
+ _parseTagValue = true;
841
+ _parseAttributeValue = false;
842
+ _removeNSPrefix = false;
843
+ _attrPrefix = "@_";
844
+ _attrsGroupName = false;
845
+ _ignorePiTags = false;
846
+ _ignoreDeclaration = false;
847
+ constructor(options) {
848
+ this.options = { ...defaultParserOptions, ...options };
849
+ this.entityDecoder = new EntityDecoder(this.options.htmlEntities);
850
+ this.unpairedSet = new Set(this.options.unpairedTags);
851
+ this.exactStopNodes = new Set;
852
+ this.wildcardStopSuffixes = [];
853
+ for (const stopNode of this.options.stopNodes) {
854
+ if (stopNode.startsWith("*.")) {
855
+ this.wildcardStopSuffixes.push(stopNode.substring(2));
856
+ } else {
857
+ this.exactStopNodes.add(stopNode);
858
+ }
859
+ }
860
+ this._ignoreAttributes = this.options.ignoreAttributes;
861
+ this._textNodeName = this.options.textNodeName;
862
+ this._commentPropName = this.options.commentPropName;
863
+ this._cdataPropName = this.options.cdataPropName;
864
+ this._piPropName = this.options.piPropName;
865
+ this._alwaysCreateTextNode = this.options.alwaysCreateTextNode;
866
+ this._trimValues = this.options.trimValues;
867
+ this._processEntities = this.options.processEntities;
868
+ this._parseTagValue = this.options.parseTagValue;
869
+ this._parseAttributeValue = this.options.parseAttributeValue;
870
+ this._removeNSPrefix = this.options.removeNSPrefix;
871
+ this._attrPrefix = this.options.attributeNamePrefix;
872
+ this._attrsGroupName = this.options.attributesGroupName;
873
+ this._ignorePiTags = this.options.ignorePiTags;
874
+ this._ignoreDeclaration = this.options.ignoreDeclaration;
875
+ this.needsJPath = this.options.stopNodes.length > 0 || this.options.isArray !== undefined || this.options.updateTag !== undefined || this.options.tagValueProcessor !== undefined || this.options.attributeValueProcessor !== undefined;
876
+ }
877
+ addEntity(name, value) {
878
+ this.entityDecoder.addEntity(name, value);
879
+ }
880
+ parse(xmlData) {
881
+ if (xmlData instanceof Uint8Array) {
882
+ xmlData = new TextDecoder().decode(xmlData);
883
+ }
884
+ const xml = xmlData;
885
+ if (this.options.preserveOrder) {
886
+ return this.parseOrdered(xml);
887
+ }
888
+ return this.parseUnordered(xml);
889
+ }
890
+ parseUnordered(xml) {
891
+ const result = {};
892
+ const len = xml.length;
893
+ let i = 0;
894
+ if (len > 0 && xml.charCodeAt(0) === 65279)
895
+ i = 1;
896
+ i = this.parseChildren(xml, i, len, result, "", []);
897
+ return result;
2144
898
  }
2145
- if (entityConfig.allowedTags) {
2146
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
2147
- const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
2148
- if (!allowed) {
2149
- return val;
2150
- }
899
+ parseOrdered(xml) {
900
+ const len = xml.length;
901
+ let i = 0;
902
+ if (len > 0 && xml.charCodeAt(0) === 65279)
903
+ i = 1;
904
+ const result = [];
905
+ this.parseChildrenOrdered(xml, i, len, result, "");
906
+ return result;
2151
907
  }
2152
- if (entityConfig.tagFilter) {
2153
- const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
2154
- if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
2155
- return val;
908
+ readTagName(xml, pos, len) {
909
+ const end = readNameEnd(xml, pos, len);
910
+ return end;
911
+ }
912
+ extractTagName(xml, start, end) {
913
+ let name = xml.substring(start, end);
914
+ if (this._removeNSPrefix) {
915
+ const colonIdx = name.indexOf(":");
916
+ if (colonIdx !== -1)
917
+ name = name.substring(colonIdx + 1);
2156
918
  }
919
+ if (this.options.transformTagName)
920
+ name = this.options.transformTagName(name);
921
+ return name;
2157
922
  }
2158
- for (let entityName in this.docTypeEntities) {
2159
- const entity = this.docTypeEntities[entityName];
2160
- const matches = val.match(entity.regx);
2161
- if (matches) {
2162
- this.entityExpansionCount += matches.length;
2163
- if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
2164
- throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`);
923
+ parseAttributes(xml, pos, len, jPath, outAttrs) {
924
+ let count = 0;
925
+ const removeNS = this._removeNSPrefix;
926
+ const transformAttr = this.options.transformAttributeName;
927
+ const trimVals = this._trimValues;
928
+ const processEnts = this._processEntities;
929
+ const attrProcessor = this.options.attributeValueProcessor;
930
+ while (pos < len) {
931
+ let ch = xml.charCodeAt(pos);
932
+ while (ch === 32 || ch === 9 || ch === 10 || ch === 13) {
933
+ pos++;
934
+ if (pos >= len)
935
+ break;
936
+ ch = xml.charCodeAt(pos);
2165
937
  }
2166
- const lengthBefore = val.length;
2167
- val = val.replace(entity.regx, entity.val);
2168
- if (entityConfig.maxExpandedLength) {
2169
- this.currentExpandedLength += val.length - lengthBefore;
2170
- if (this.currentExpandedLength > entityConfig.maxExpandedLength) {
2171
- throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${entityConfig.maxExpandedLength}`);
938
+ if (pos >= len)
939
+ break;
940
+ if (ch === 62 || ch === 47)
941
+ break;
942
+ const attrStart = pos;
943
+ if (!isNameStartChar(ch))
944
+ break;
945
+ pos++;
946
+ while (pos < len && isNameChar(xml.charCodeAt(pos)))
947
+ pos++;
948
+ let attrName = xml.substring(attrStart, pos);
949
+ if (removeNS) {
950
+ const colonIdx = attrName.indexOf(":");
951
+ if (colonIdx !== -1)
952
+ attrName = attrName.substring(colonIdx + 1);
953
+ }
954
+ if (transformAttr)
955
+ attrName = transformAttr(attrName);
956
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
957
+ pos++;
958
+ if (pos < len && xml.charCodeAt(pos) === 61) {
959
+ pos++;
960
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
961
+ pos++;
962
+ if (pos >= len)
963
+ break;
964
+ const quoteChar = xml.charCodeAt(pos);
965
+ if (quoteChar === 34 || quoteChar === 39) {
966
+ pos++;
967
+ const valueStart = pos;
968
+ while (pos < len && xml.charCodeAt(pos) !== quoteChar)
969
+ pos++;
970
+ let value = xml.substring(valueStart, pos);
971
+ if (trimVals && value.length > 0) {
972
+ const f = value.charCodeAt(0);
973
+ const l = value.charCodeAt(value.length - 1);
974
+ if (f <= 32 || l <= 32)
975
+ value = value.trim();
976
+ }
977
+ if (processEnts)
978
+ value = this.entityDecoder.decodeEntities(value);
979
+ if (attrProcessor)
980
+ value = attrProcessor(attrName, value, jPath) ?? value;
981
+ outAttrs[attrName] = value;
982
+ count++;
983
+ if (pos < len)
984
+ pos++;
2172
985
  }
986
+ } else {
987
+ outAttrs[attrName] = "true";
988
+ count++;
2173
989
  }
2174
990
  }
991
+ return count > 0 ? -pos - 1 : pos;
2175
992
  }
2176
- if (val.indexOf("&") === -1)
2177
- return val;
2178
- for (let entityName in this.lastEntities) {
2179
- const entity = this.lastEntities[entityName];
2180
- val = val.replace(entity.regex, entity.val);
2181
- }
2182
- if (val.indexOf("&") === -1)
2183
- return val;
2184
- if (this.options.htmlEntities) {
2185
- for (let entityName in this.htmlEntities) {
2186
- const entity = this.htmlEntities[entityName];
2187
- val = val.replace(entity.regex, entity.val);
993
+ processTagValue(value, tagName, jPath, hasAttributes, isLeaf) {
994
+ if (this._trimValues) {
995
+ const vlen = value.length;
996
+ if (vlen > 0) {
997
+ const first = value.charCodeAt(0);
998
+ const last = value.charCodeAt(vlen - 1);
999
+ if (first <= 32 || last <= 32)
1000
+ value = value.trim();
1001
+ }
2188
1002
  }
1003
+ if (this._processEntities)
1004
+ value = this.entityDecoder.decodeEntities(value);
1005
+ if (this.options.tagValueProcessor) {
1006
+ const processed = this.options.tagValueProcessor(tagName, value, jPath, hasAttributes, isLeaf);
1007
+ if (processed !== undefined)
1008
+ value = processed;
1009
+ }
1010
+ if (!value)
1011
+ return value;
1012
+ if (this._parseTagValue)
1013
+ return this.parseValue(value);
1014
+ return value;
2189
1015
  }
2190
- val = val.replace(this.ampEntity.regex, this.ampEntity.val);
2191
- return val;
2192
- }
2193
- function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
2194
- if (textData) {
2195
- if (isLeafNode === undefined)
2196
- isLeafNode = parentNode.child.length === 0;
2197
- textData = this.parseTextData(textData, parentNode.tagname, matcher, false, parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false, isLeafNode);
2198
- if (textData !== undefined && textData !== "")
2199
- parentNode.add(this.options.textNodeName, textData);
2200
- textData = "";
2201
- }
2202
- return textData;
2203
- }
2204
- function isItStopNode(stopNodeExpressions, matcher) {
2205
- if (!stopNodeExpressions || stopNodeExpressions.length === 0)
2206
- return false;
2207
- for (let i = 0;i < stopNodeExpressions.length; i++) {
2208
- if (matcher.matches(stopNodeExpressions[i])) {
1016
+ parseValue(val) {
1017
+ if (val === "true")
2209
1018
  return true;
1019
+ if (val === "false")
1020
+ return false;
1021
+ if (!val)
1022
+ return val;
1023
+ const firstCh = val.charCodeAt(0);
1024
+ const isNumStart = firstCh >= 48 && firstCh <= 57 || firstCh === 43 || firstCh === 45 || firstCh === 46;
1025
+ if (!isNumStart)
1026
+ return val;
1027
+ const opts = this.options.numberParseOptions;
1028
+ if (opts.skipLike?.test(val))
1029
+ return val;
1030
+ if (opts.hex && firstCh === 48 && RE_HEX.test(val))
1031
+ return Number.parseInt(val, 16);
1032
+ if (val.length > 1 && firstCh === 48 && val.charCodeAt(1) !== 46) {
1033
+ if (opts.leadingZeros)
1034
+ return val;
2210
1035
  }
2211
- }
2212
- return false;
2213
- }
2214
- function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
2215
- let attrBoundary;
2216
- let tagExp = "";
2217
- for (let index = i;index < xmlData.length; index++) {
2218
- let ch = xmlData[index];
2219
- if (attrBoundary) {
2220
- if (ch === attrBoundary)
2221
- attrBoundary = "";
2222
- } else if (ch === '"' || ch === "'") {
2223
- attrBoundary = ch;
2224
- } else if (ch === closingChar[0]) {
2225
- if (closingChar[1]) {
2226
- if (xmlData[index + 1] === closingChar[1]) {
2227
- return {
2228
- data: tagExp,
2229
- index
2230
- };
2231
- }
2232
- } else {
2233
- return {
2234
- data: tagExp,
2235
- index
2236
- };
2237
- }
2238
- } else if (ch === "\t") {
2239
- ch = " ";
1036
+ if (opts.scientific && RE_SCIENTIFIC.test(val)) {
1037
+ const num = Number(val);
1038
+ if (!Number.isNaN(num))
1039
+ return num;
1040
+ }
1041
+ if (RE_NUMBER.test(val)) {
1042
+ const num = Number(val);
1043
+ if (!Number.isNaN(num))
1044
+ return num;
2240
1045
  }
2241
- tagExp += ch;
1046
+ return val;
2242
1047
  }
2243
- }
2244
- function findClosingIndex(xmlData, str, i, errMsg) {
2245
- const closingIndex = xmlData.indexOf(str, i);
2246
- if (closingIndex === -1) {
2247
- throw new Error(errMsg);
2248
- } else {
2249
- return closingIndex + str.length - 1;
1048
+ parseAttributeValue(val) {
1049
+ if (!this._parseAttributeValue)
1050
+ return val;
1051
+ return this.parseValue(val);
2250
1052
  }
2251
- }
2252
- function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
2253
- const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
2254
- if (!result)
2255
- return;
2256
- let tagExp = result.data;
2257
- const closeIndex = result.index;
2258
- const separatorIndex = tagExp.search(/\s/);
2259
- let tagName = tagExp;
2260
- let attrExpPresent = true;
2261
- if (separatorIndex !== -1) {
2262
- tagName = tagExp.substring(0, separatorIndex);
2263
- tagExp = tagExp.substring(separatorIndex + 1).trimStart();
2264
- }
2265
- const rawTagName = tagName;
2266
- if (removeNSPrefix) {
2267
- const colonIndex = tagName.indexOf(":");
2268
- if (colonIndex !== -1) {
2269
- tagName = tagName.substr(colonIndex + 1);
2270
- attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
1053
+ isStopNode(jPath) {
1054
+ if (this.exactStopNodes.has(jPath))
1055
+ return true;
1056
+ for (const suffix of this.wildcardStopSuffixes) {
1057
+ if (jPath.endsWith(`.${suffix}`) || jPath === suffix)
1058
+ return true;
2271
1059
  }
1060
+ return false;
2272
1061
  }
2273
- return {
2274
- tagName,
2275
- tagExp,
2276
- closeIndex,
2277
- attrExpPresent,
2278
- rawTagName
2279
- };
2280
- }
2281
- function readStopNodeData(xmlData, tagName, i) {
2282
- const startIndex = i;
2283
- let openTagCount = 1;
2284
- for (;i < xmlData.length; i++) {
2285
- if (xmlData[i] === "<") {
2286
- if (xmlData[i + 1] === "/") {
2287
- const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
2288
- let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
2289
- if (closeTagName === tagName) {
2290
- openTagCount--;
2291
- if (openTagCount === 0) {
2292
- return {
2293
- tagContent: xmlData.substring(startIndex, i),
2294
- i: closeIndex
2295
- };
2296
- }
2297
- }
2298
- i = closeIndex;
2299
- } else if (xmlData[i + 1] === "?") {
2300
- const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
2301
- i = closeIndex;
2302
- } else if (xmlData.substr(i + 1, 3) === "!--") {
2303
- const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
2304
- i = closeIndex;
2305
- } else if (xmlData.substr(i + 1, 2) === "![") {
2306
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
2307
- i = closeIndex;
1062
+ readStopNodeContent(xml, pos, len, tagName) {
1063
+ const closingTag = `</${tagName}`;
1064
+ const idx = xml.indexOf(closingTag, pos);
1065
+ if (idx === -1) {
1066
+ return { content: xml.substring(pos), pos: len };
1067
+ }
1068
+ const content = xml.substring(pos, idx);
1069
+ let endPos = idx + closingTag.length;
1070
+ while (endPos < len && xml.charCodeAt(endPos) !== 62)
1071
+ endPos++;
1072
+ if (endPos < len)
1073
+ endPos++;
1074
+ return { content, pos: endPos };
1075
+ }
1076
+ addToObj(obj, key, value, jPath, isLeaf, isAttribute) {
1077
+ const existing = obj[key];
1078
+ if (existing !== undefined) {
1079
+ if (!Array.isArray(existing)) {
1080
+ obj[key] = [existing, value];
2308
1081
  } else {
2309
- const tagData = readTagExp(xmlData, i, ">");
2310
- if (tagData) {
2311
- const openTagName = tagData && tagData.tagName;
2312
- if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
2313
- openTagCount++;
2314
- }
2315
- i = tagData.closeIndex;
2316
- }
1082
+ existing.push(value);
2317
1083
  }
2318
- }
2319
- }
2320
- }
2321
- function parseValue(val, shouldParse, options) {
2322
- if (shouldParse && typeof val === "string") {
2323
- const newval = val.trim();
2324
- if (newval === "true")
2325
- return true;
2326
- else if (newval === "false")
2327
- return false;
2328
- else
2329
- return toNumber(val, options);
2330
- } else {
2331
- if (isExist(val)) {
2332
- return val;
1084
+ } else if (this.options.isArray?.(key, jPath, isLeaf, isAttribute)) {
1085
+ obj[key] = [value];
2333
1086
  } else {
2334
- return "";
1087
+ obj[key] = value;
2335
1088
  }
2336
1089
  }
2337
- }
2338
- function fromCodePoint(str, base, prefix) {
2339
- const codePoint = Number.parseInt(str, base);
2340
- if (codePoint >= 0 && codePoint <= 1114111) {
2341
- return String.fromCodePoint(codePoint);
2342
- } else {
2343
- return prefix + str + ";";
2344
- }
2345
- }
2346
- var attrsRegx, parseXml = function(xmlData) {
2347
- xmlData = xmlData.replace(/\r\n?/g, `
2348
- `);
2349
- const xmlObj = new XmlNode("!xml");
2350
- let currentNode = xmlObj;
2351
- let textData = "";
2352
- this.matcher.reset();
2353
- this.entityExpansionCount = 0;
2354
- this.currentExpandedLength = 0;
2355
- const docTypeReader = new DocTypeReader(this.options.processEntities);
2356
- for (let i = 0;i < xmlData.length; i++) {
2357
- const ch = xmlData[i];
2358
- if (ch === "<") {
2359
- if (xmlData[i + 1] === "/") {
2360
- const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
2361
- let tagName = xmlData.substring(i + 2, closeIndex).trim();
2362
- if (this.options.removeNSPrefix) {
2363
- const colonIndex = tagName.indexOf(":");
2364
- if (colonIndex !== -1) {
2365
- tagName = tagName.substr(colonIndex + 1);
2366
- }
1090
+ flushText(textContent, cdataBuffer, jPath, parent) {
1091
+ if (!textContent && !cdataBuffer)
1092
+ return;
1093
+ const textNodeName = this._textNodeName;
1094
+ if (cdataBuffer) {
1095
+ let decodedText = textContent;
1096
+ if (decodedText && this._processEntities)
1097
+ decodedText = this.entityDecoder.decodeEntities(decodedText);
1098
+ let value = cdataBuffer + decodedText;
1099
+ if (this._trimValues && value.length > 0) {
1100
+ const f = value.charCodeAt(0);
1101
+ const l = value.charCodeAt(value.length - 1);
1102
+ if (f <= 32 || l <= 32)
1103
+ value = value.trim();
1104
+ }
1105
+ if (this.options.tagValueProcessor) {
1106
+ const processed = this.options.tagValueProcessor(textNodeName, value, jPath, false, true);
1107
+ if (processed !== undefined)
1108
+ value = processed;
1109
+ }
1110
+ if (value) {
1111
+ const parsed = this._parseTagValue ? this.parseValue(value) : value;
1112
+ if (parsed !== undefined && parsed !== "")
1113
+ this.addToObj(parent, textNodeName, parsed, jPath, true, false);
1114
+ }
1115
+ } else {
1116
+ const processed = this.processTagValue(textContent, textNodeName, jPath, false, true);
1117
+ if (processed !== undefined && processed !== "")
1118
+ this.addToObj(parent, textNodeName, processed, jPath, true, false);
1119
+ }
1120
+ }
1121
+ parseChildren(xml, pos, len, parent, jPath, unpairedStack) {
1122
+ let textContent = "";
1123
+ let cdataBuffer = "";
1124
+ const needsJPath = this.needsJPath;
1125
+ while (pos < len) {
1126
+ const ch = xml.charCodeAt(pos);
1127
+ if (ch !== 60) {
1128
+ const textStart = pos;
1129
+ pos++;
1130
+ while (pos < len && xml.charCodeAt(pos) !== 60)
1131
+ pos++;
1132
+ if (!textContent)
1133
+ textContent = xml.substring(textStart, pos);
1134
+ else
1135
+ textContent += xml.substring(textStart, pos);
1136
+ continue;
1137
+ }
1138
+ if (pos + 1 >= len)
1139
+ break;
1140
+ const nextCh = xml.charCodeAt(pos + 1);
1141
+ if (nextCh === 33 && pos + 3 < len && xml.charCodeAt(pos + 2) === 45 && xml.charCodeAt(pos + 3) === 45) {
1142
+ if (textContent || cdataBuffer) {
1143
+ this.flushText(textContent, cdataBuffer, jPath, parent);
1144
+ textContent = "";
1145
+ cdataBuffer = "";
1146
+ }
1147
+ pos += 4;
1148
+ const endComment = xml.indexOf("-->", pos);
1149
+ if (endComment === -1) {
1150
+ pos = len;
1151
+ break;
2367
1152
  }
2368
- if (this.options.transformTagName) {
2369
- tagName = this.options.transformTagName(tagName);
2370
- }
2371
- if (currentNode) {
2372
- textData = this.saveTextToParentTag(textData, currentNode, this.matcher);
2373
- }
2374
- const lastTagName = this.matcher.getCurrentTag();
2375
- if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
2376
- throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
2377
- }
2378
- if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
2379
- this.matcher.pop();
2380
- this.tagsNodeStack.pop();
2381
- }
2382
- this.matcher.pop();
2383
- this.isCurrentNodeStopNode = false;
2384
- currentNode = this.tagsNodeStack.pop();
2385
- textData = "";
2386
- i = closeIndex;
2387
- } else if (xmlData[i + 1] === "?") {
2388
- let tagData = readTagExp(xmlData, i, false, "?>");
2389
- if (!tagData)
2390
- throw new Error("Pi Tag is not closed.");
2391
- textData = this.saveTextToParentTag(textData, currentNode, this.matcher);
2392
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {} else {
2393
- const childNode = new XmlNode(tagData.tagName);
2394
- childNode.add(this.options.textNodeName, "");
2395
- if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
2396
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
2397
- }
2398
- this.addChild(currentNode, childNode, this.matcher, i);
2399
- }
2400
- i = tagData.closeIndex + 1;
2401
- } else if (xmlData.substr(i + 1, 3) === "!--") {
2402
- const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
2403
- if (this.options.commentPropName) {
2404
- const comment = xmlData.substring(i + 4, endIndex - 2);
2405
- textData = this.saveTextToParentTag(textData, currentNode, this.matcher);
2406
- currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
2407
- }
2408
- i = endIndex;
2409
- } else if (xmlData.substr(i + 1, 2) === "!D") {
2410
- const result = docTypeReader.readDocType(xmlData, i);
2411
- this.docTypeEntities = result.entities;
2412
- i = result.i;
2413
- } else if (xmlData.substr(i + 1, 2) === "![") {
2414
- const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
2415
- const tagExp = xmlData.substring(i + 9, closeIndex);
2416
- textData = this.saveTextToParentTag(textData, currentNode, this.matcher);
2417
- let val = this.parseTextData(tagExp, currentNode.tagname, this.matcher, true, false, true, true);
2418
- if (val == undefined)
2419
- val = "";
2420
- if (this.options.cdataPropName) {
2421
- currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2422
- } else {
2423
- currentNode.add(this.options.textNodeName, val);
1153
+ if (this._commentPropName) {
1154
+ const comment = xml.substring(pos, endComment);
1155
+ this.addToObj(parent, this._commentPropName, comment, jPath, true, false);
2424
1156
  }
2425
- i = closeIndex + 2;
2426
- } else {
2427
- let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
2428
- if (!result) {
2429
- const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlData.length, i + 50));
2430
- throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
2431
- }
2432
- let tagName = result.tagName;
2433
- const rawTagName = result.rawTagName;
2434
- let tagExp = result.tagExp;
2435
- let attrExpPresent = result.attrExpPresent;
2436
- let closeIndex = result.closeIndex;
2437
- if (this.options.transformTagName) {
2438
- const newTagName = this.options.transformTagName(tagName);
2439
- if (tagExp === tagName) {
2440
- tagExp = newTagName;
1157
+ pos = endComment + 3;
1158
+ continue;
1159
+ }
1160
+ if (nextCh === 33 && pos + 8 < len && isCDATA(xml, pos + 2)) {
1161
+ pos += 9;
1162
+ const endCdata = xml.indexOf("]]>", pos);
1163
+ if (endCdata === -1) {
1164
+ pos = len;
1165
+ break;
1166
+ }
1167
+ const cdataContent = xml.substring(pos, endCdata);
1168
+ if (this._cdataPropName) {
1169
+ this.flushText(textContent, cdataBuffer, jPath, parent);
1170
+ textContent = "";
1171
+ cdataBuffer = "";
1172
+ this.addToObj(parent, this._cdataPropName, cdataContent, jPath, true, false);
1173
+ } else {
1174
+ if (textContent) {
1175
+ let decoded = textContent;
1176
+ if (this._processEntities)
1177
+ decoded = this.entityDecoder.decodeEntities(decoded);
1178
+ cdataBuffer += decoded;
1179
+ textContent = "";
2441
1180
  }
2442
- tagName = newTagName;
1181
+ cdataBuffer += cdataContent;
1182
+ }
1183
+ pos = endCdata + 3;
1184
+ continue;
1185
+ }
1186
+ if (nextCh === 33 && pos + 9 < len && isDOCTYPE(xml, pos + 2)) {
1187
+ pos += 9;
1188
+ let depth = 1;
1189
+ while (pos < len && depth > 0) {
1190
+ const c = xml.charCodeAt(pos);
1191
+ if (c === 60)
1192
+ depth++;
1193
+ else if (c === 62)
1194
+ depth--;
1195
+ pos++;
2443
1196
  }
2444
- if (this.options.strictReservedNames && (tagName === this.options.commentPropName || tagName === this.options.cdataPropName)) {
2445
- throw new Error(`Invalid tag name: ${tagName}`);
1197
+ continue;
1198
+ }
1199
+ if (nextCh === 63) {
1200
+ pos += 2;
1201
+ const piNameStart = pos;
1202
+ while (pos < len && !isWhitespace(xml.charCodeAt(pos)) && xml.charCodeAt(pos) !== 63)
1203
+ pos++;
1204
+ const piTarget = xml.substring(piNameStart, pos);
1205
+ const endPi = xml.indexOf("?>", pos);
1206
+ if (endPi === -1) {
1207
+ pos = len;
1208
+ break;
2446
1209
  }
2447
- if (currentNode && textData) {
2448
- if (currentNode.tagname !== "!xml") {
2449
- textData = this.saveTextToParentTag(textData, currentNode, this.matcher, false);
1210
+ const piContent = xml.substring(pos, endPi).trim();
1211
+ if (piTarget === "xml") {
1212
+ if (!this._ignoreDeclaration && this._piPropName) {
1213
+ const declAttrs = this.parsePiAttributes(piContent);
1214
+ this.addToObj(parent, this._piPropName, { [piTarget]: declAttrs }, jPath, true, false);
2450
1215
  }
1216
+ } else if (!this._ignorePiTags && this._piPropName) {
1217
+ this.addToObj(parent, this._piPropName, { [piTarget]: piContent }, jPath, true, false);
2451
1218
  }
2452
- const lastTag = currentNode;
2453
- if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
2454
- currentNode = this.tagsNodeStack.pop();
2455
- this.matcher.pop();
2456
- }
2457
- let isSelfClosing = false;
2458
- if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
2459
- isSelfClosing = true;
2460
- if (tagName[tagName.length - 1] === "/") {
2461
- tagName = tagName.substr(0, tagName.length - 1);
2462
- tagExp = tagName;
2463
- } else {
2464
- tagExp = tagExp.substr(0, tagExp.length - 1);
1219
+ pos = endPi + 2;
1220
+ continue;
1221
+ }
1222
+ if (nextCh === 47) {
1223
+ if (textContent || cdataBuffer) {
1224
+ this.flushText(textContent, cdataBuffer, jPath, parent);
1225
+ textContent = "";
1226
+ cdataBuffer = "";
1227
+ }
1228
+ pos += 2;
1229
+ const nameStart2 = pos;
1230
+ const nameEnd2 = this.readTagName(xml, pos, len);
1231
+ const closingName = this.extractTagName(xml, nameStart2, nameEnd2);
1232
+ pos = nameEnd2;
1233
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
1234
+ pos++;
1235
+ if (pos < len && xml.charCodeAt(pos) === 62)
1236
+ pos++;
1237
+ if (unpairedStack.length > 0 && unpairedStack[unpairedStack.length - 1] === closingName) {
1238
+ unpairedStack.pop();
1239
+ continue;
1240
+ }
1241
+ return pos;
1242
+ }
1243
+ if (textContent || cdataBuffer) {
1244
+ this.flushText(textContent, cdataBuffer, jPath, parent);
1245
+ textContent = "";
1246
+ cdataBuffer = "";
1247
+ }
1248
+ pos++;
1249
+ const nameStart = pos;
1250
+ const nameEnd = this.readTagName(xml, pos, len);
1251
+ const tagName = this.extractTagName(xml, nameStart, nameEnd);
1252
+ if (!tagName) {
1253
+ pos = nameEnd + 1;
1254
+ continue;
1255
+ }
1256
+ pos = nameEnd;
1257
+ const childJPath = needsJPath ? jPath ? `${jPath}.${tagName}` : tagName : "";
1258
+ let attrs = {};
1259
+ let hasAttrs = false;
1260
+ if (!this._ignoreAttributes) {
1261
+ const attrResult = this.parseAttributes(xml, pos, len, childJPath, attrs);
1262
+ if (attrResult < 0) {
1263
+ pos = -attrResult - 1;
1264
+ hasAttrs = true;
1265
+ } else {
1266
+ pos = attrResult;
1267
+ }
1268
+ } else {
1269
+ while (pos < len) {
1270
+ const c = xml.charCodeAt(pos);
1271
+ if (c === 62 || c === 47)
1272
+ break;
1273
+ if (c === 34 || c === 39) {
1274
+ pos++;
1275
+ while (pos < len && xml.charCodeAt(pos) !== c)
1276
+ pos++;
2465
1277
  }
2466
- attrExpPresent = tagName !== tagExp;
2467
- }
2468
- let prefixedAttrs = null;
2469
- let rawAttrs = {};
2470
- let namespace = undefined;
2471
- namespace = extractNamespace(rawTagName);
2472
- if (tagName !== xmlObj.tagname) {
2473
- this.matcher.push(tagName, {}, namespace);
2474
- }
2475
- if (tagName !== tagExp && attrExpPresent) {
2476
- prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
2477
- if (prefixedAttrs) {
2478
- rawAttrs = extractRawAttributes(prefixedAttrs, this.options);
1278
+ pos++;
1279
+ }
1280
+ }
1281
+ if (this.options.updateTag) {
1282
+ const newName = this.options.updateTag(tagName, childJPath, attrs);
1283
+ if (newName === false) {
1284
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
1285
+ pos++;
1286
+ if (pos < len && xml.charCodeAt(pos) === 47) {
1287
+ pos += 2;
1288
+ } else if (pos < len && xml.charCodeAt(pos) === 62) {
1289
+ pos++;
1290
+ const closingTag = `</${tagName}>`;
1291
+ const closeIdx = xml.indexOf(closingTag, pos);
1292
+ if (closeIdx !== -1)
1293
+ pos = closeIdx + closingTag.length;
2479
1294
  }
1295
+ continue;
2480
1296
  }
2481
- if (tagName !== xmlObj.tagname) {
2482
- this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher);
1297
+ }
1298
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
1299
+ pos++;
1300
+ if (pos < len && xml.charCodeAt(pos) === 47) {
1301
+ pos += 2;
1302
+ if (hasAttrs || this._alwaysCreateTextNode) {
1303
+ const childObj = {};
1304
+ if (hasAttrs)
1305
+ this.applyAttributes(childObj, attrs, childJPath);
1306
+ if (this._alwaysCreateTextNode)
1307
+ childObj[this._textNodeName] = "";
1308
+ this.addToObj(parent, tagName, childObj, childJPath, true, false);
1309
+ } else {
1310
+ this.addToObj(parent, tagName, "", childJPath, true, false);
2483
1311
  }
2484
- const startIndex = i;
2485
- if (this.isCurrentNodeStopNode) {
2486
- let tagContent = "";
2487
- if (isSelfClosing) {
2488
- i = result.closeIndex;
2489
- } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
2490
- i = result.closeIndex;
1312
+ continue;
1313
+ }
1314
+ if (pos < len && xml.charCodeAt(pos) === 62) {
1315
+ pos++;
1316
+ if (this.unpairedSet.has(tagName)) {
1317
+ if (hasAttrs) {
1318
+ const childObj2 = {};
1319
+ this.applyAttributes(childObj2, attrs, childJPath);
1320
+ this.addToObj(parent, tagName, childObj2, childJPath, true, false);
2491
1321
  } else {
2492
- const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
2493
- if (!result2)
2494
- throw new Error(`Unexpected end of ${rawTagName}`);
2495
- i = result2.i;
2496
- tagContent = result2.tagContent;
1322
+ this.addToObj(parent, tagName, "", childJPath, true, false);
2497
1323
  }
2498
- const childNode = new XmlNode(tagName);
2499
- if (prefixedAttrs) {
2500
- childNode[":@"] = prefixedAttrs;
1324
+ unpairedStack.push(tagName);
1325
+ continue;
1326
+ }
1327
+ if (this.exactStopNodes.size > 0 || this.wildcardStopSuffixes.length > 0) {
1328
+ if (this.isStopNode(childJPath)) {
1329
+ const stopResult = this.readStopNodeContent(xml, pos, len, tagName);
1330
+ const childObj2 = {};
1331
+ if (hasAttrs)
1332
+ this.applyAttributes(childObj2, attrs, childJPath);
1333
+ if (stopResult.content)
1334
+ childObj2[this._textNodeName] = stopResult.content;
1335
+ this.addToObj(parent, tagName, childObj2, childJPath, true, false);
1336
+ pos = stopResult.pos;
1337
+ continue;
2501
1338
  }
2502
- childNode.add(this.options.textNodeName, tagContent);
2503
- this.matcher.pop();
2504
- this.isCurrentNodeStopNode = false;
2505
- this.addChild(currentNode, childNode, this.matcher, startIndex);
2506
- } else {
2507
- if (isSelfClosing) {
2508
- if (this.options.transformTagName) {
2509
- const newTagName = this.options.transformTagName(tagName);
2510
- if (tagExp === tagName) {
2511
- tagExp = newTagName;
2512
- }
2513
- tagName = newTagName;
2514
- }
2515
- const childNode = new XmlNode(tagName);
2516
- if (prefixedAttrs) {
2517
- childNode[":@"] = prefixedAttrs;
2518
- }
2519
- this.addChild(currentNode, childNode, this.matcher, startIndex);
2520
- this.matcher.pop();
2521
- this.isCurrentNodeStopNode = false;
2522
- } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
2523
- const childNode = new XmlNode(tagName);
2524
- if (prefixedAttrs) {
2525
- childNode[":@"] = prefixedAttrs;
1339
+ }
1340
+ const childObj = {};
1341
+ if (hasAttrs)
1342
+ this.applyAttributes(childObj, attrs, childJPath);
1343
+ pos = this.parseChildren(xml, pos, len, childObj, childJPath, unpairedStack);
1344
+ const textNodeName = this._textNodeName;
1345
+ const textValue = childObj[textNodeName];
1346
+ if (!hasAttrs && !this._alwaysCreateTextNode) {
1347
+ let isLeaf = true;
1348
+ for (const k in childObj) {
1349
+ if (k !== textNodeName) {
1350
+ isLeaf = false;
1351
+ break;
2526
1352
  }
2527
- this.addChild(currentNode, childNode, this.matcher, startIndex);
2528
- this.matcher.pop();
2529
- this.isCurrentNodeStopNode = false;
2530
- i = result.closeIndex;
1353
+ }
1354
+ if (isLeaf) {
1355
+ this.addToObj(parent, tagName, textValue !== undefined ? textValue : "", childJPath, true, false);
2531
1356
  continue;
2532
- } else {
2533
- const childNode = new XmlNode(tagName);
2534
- if (this.tagsNodeStack.length > this.options.maxNestedTags) {
2535
- throw new Error("Maximum nested tags exceeded");
2536
- }
2537
- this.tagsNodeStack.push(currentNode);
2538
- if (prefixedAttrs) {
2539
- childNode[":@"] = prefixedAttrs;
2540
- }
2541
- this.addChild(currentNode, childNode, this.matcher, startIndex);
2542
- currentNode = childNode;
2543
1357
  }
2544
- textData = "";
2545
- i = closeIndex;
2546
1358
  }
1359
+ this.addToObj(parent, tagName, childObj, childJPath, false, false);
2547
1360
  }
2548
- } else {
2549
- textData += xmlData[i];
2550
1361
  }
1362
+ if (textContent || cdataBuffer) {
1363
+ this.flushText(textContent, cdataBuffer, jPath, parent);
1364
+ }
1365
+ return pos;
2551
1366
  }
2552
- return xmlObj.child;
2553
- };
2554
- var init_OrderedObjParser = __esm(() => {
2555
- init_util();
2556
- init_xmlNode();
2557
- init_DocTypeReader();
2558
- init_strnum();
2559
- init_src();
2560
- attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
2561
- });
2562
-
2563
- // ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
2564
- function stripAttributePrefix(attrs, prefix) {
2565
- if (!attrs || typeof attrs !== "object")
2566
- return {};
2567
- if (!prefix)
2568
- return attrs;
2569
- const rawAttrs = {};
2570
- for (const key in attrs) {
2571
- if (key.startsWith(prefix)) {
2572
- const rawName = key.substring(prefix.length);
2573
- rawAttrs[rawName] = attrs[key];
2574
- } else {
2575
- rawAttrs[key] = attrs[key];
2576
- }
2577
- }
2578
- return rawAttrs;
2579
- }
2580
- function prettify(node, options, matcher) {
2581
- return compress(node, options, matcher);
2582
- }
2583
- function compress(arr, options, matcher) {
2584
- let text;
2585
- const compressedObj = {};
2586
- for (let i = 0;i < arr.length; i++) {
2587
- const tagObj = arr[i];
2588
- const property = propName(tagObj);
2589
- if (property !== undefined && property !== options.textNodeName) {
2590
- const rawAttrs = stripAttributePrefix(tagObj[":@"] || {}, options.attributeNamePrefix);
2591
- matcher.push(property, rawAttrs);
2592
- }
2593
- if (property === options.textNodeName) {
2594
- if (text === undefined)
2595
- text = tagObj[property];
2596
- else
2597
- text += "" + tagObj[property];
2598
- } else if (property === undefined) {
2599
- continue;
2600
- } else if (tagObj[property]) {
2601
- let val = compress(tagObj[property], options, matcher);
2602
- const isLeaf = isLeafTag(val, options);
2603
- if (tagObj[":@"]) {
2604
- assignAttributes(val, tagObj[":@"], matcher, options);
2605
- } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode) {
2606
- val = val[options.textNodeName];
2607
- } else if (Object.keys(val).length === 0) {
2608
- if (options.alwaysCreateTextNode)
2609
- val[options.textNodeName] = "";
1367
+ parseChildrenOrdered(xml, pos, len, parent, jPath) {
1368
+ let textContent = "";
1369
+ const needsJPath = this.needsJPath;
1370
+ while (pos < len) {
1371
+ const ch = xml.charCodeAt(pos);
1372
+ if (ch !== 60) {
1373
+ const textStart = pos;
1374
+ pos++;
1375
+ while (pos < len && xml.charCodeAt(pos) !== 60)
1376
+ pos++;
1377
+ if (!textContent)
1378
+ textContent = xml.substring(textStart, pos);
2610
1379
  else
2611
- val = "";
1380
+ textContent += xml.substring(textStart, pos);
1381
+ continue;
2612
1382
  }
2613
- if (tagObj[METADATA_SYMBOL2] !== undefined && typeof val === "object" && val !== null) {
2614
- val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
1383
+ if (pos + 1 >= len)
1384
+ break;
1385
+ const nextCh = xml.charCodeAt(pos + 1);
1386
+ if (nextCh === 33 && pos + 3 < len && xml.charCodeAt(pos + 2) === 45 && xml.charCodeAt(pos + 3) === 45) {
1387
+ if (textContent) {
1388
+ const processed = this.processTagValue(textContent, this._textNodeName, jPath, false, true);
1389
+ if (processed !== undefined && processed !== "")
1390
+ parent.push({ [this._textNodeName]: processed });
1391
+ textContent = "";
1392
+ }
1393
+ pos += 4;
1394
+ const endComment = xml.indexOf("-->", pos);
1395
+ if (endComment === -1) {
1396
+ pos = len;
1397
+ break;
1398
+ }
1399
+ if (this._commentPropName) {
1400
+ parent.push({ [this._commentPropName]: [{ [this._textNodeName]: xml.substring(pos, endComment) }] });
1401
+ }
1402
+ pos = endComment + 3;
1403
+ continue;
2615
1404
  }
2616
- if (compressedObj[property] !== undefined && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
2617
- if (!Array.isArray(compressedObj[property])) {
2618
- compressedObj[property] = [compressedObj[property]];
1405
+ if (nextCh === 33 && pos + 8 < len && isCDATA(xml, pos + 2)) {
1406
+ pos += 9;
1407
+ const endCdata = xml.indexOf("]]>", pos);
1408
+ if (endCdata === -1) {
1409
+ pos = len;
1410
+ break;
2619
1411
  }
2620
- compressedObj[property].push(val);
2621
- } else {
2622
- const jPathOrMatcher = options.jPath ? matcher.toString() : matcher;
2623
- if (options.isArray(property, jPathOrMatcher, isLeaf)) {
2624
- compressedObj[property] = [val];
1412
+ const cdataContent = xml.substring(pos, endCdata);
1413
+ if (this._cdataPropName) {
1414
+ if (textContent) {
1415
+ const processed = this.processTagValue(textContent, this._textNodeName, jPath, false, true);
1416
+ if (processed !== undefined && processed !== "")
1417
+ parent.push({ [this._textNodeName]: processed });
1418
+ textContent = "";
1419
+ }
1420
+ parent.push({ [this._cdataPropName]: [{ [this._textNodeName]: cdataContent }] });
2625
1421
  } else {
2626
- compressedObj[property] = val;
1422
+ textContent += cdataContent;
2627
1423
  }
1424
+ pos = endCdata + 3;
1425
+ continue;
2628
1426
  }
2629
- if (property !== undefined && property !== options.textNodeName) {
2630
- matcher.pop();
1427
+ if (nextCh === 33 && pos + 9 < len && isDOCTYPE(xml, pos + 2)) {
1428
+ pos += 9;
1429
+ let depth = 1;
1430
+ while (pos < len && depth > 0) {
1431
+ const c = xml.charCodeAt(pos);
1432
+ if (c === 60)
1433
+ depth++;
1434
+ else if (c === 62)
1435
+ depth--;
1436
+ pos++;
1437
+ }
1438
+ continue;
2631
1439
  }
2632
- }
2633
- }
2634
- if (typeof text === "string") {
2635
- if (text.length > 0)
2636
- compressedObj[options.textNodeName] = text;
2637
- } else if (text !== undefined)
2638
- compressedObj[options.textNodeName] = text;
2639
- return compressedObj;
2640
- }
2641
- function propName(obj) {
2642
- const keys = Object.keys(obj);
2643
- for (let i = 0;i < keys.length; i++) {
2644
- const key = keys[i];
2645
- if (key !== ":@")
2646
- return key;
2647
- }
2648
- }
2649
- function assignAttributes(obj, attrMap, matcher, options) {
2650
- if (attrMap) {
2651
- const keys = Object.keys(attrMap);
2652
- const len = keys.length;
2653
- for (let i = 0;i < len; i++) {
2654
- const atrrName = keys[i];
2655
- const rawAttrName = atrrName.startsWith(options.attributeNamePrefix) ? atrrName.substring(options.attributeNamePrefix.length) : atrrName;
2656
- const jPathOrMatcher = options.jPath ? matcher.toString() + "." + rawAttrName : matcher;
2657
- if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
2658
- obj[atrrName] = [attrMap[atrrName]];
1440
+ if (nextCh === 63) {
1441
+ pos += 2;
1442
+ const endPi = xml.indexOf("?>", pos);
1443
+ if (endPi === -1) {
1444
+ pos = len;
1445
+ break;
1446
+ }
1447
+ pos = endPi + 2;
1448
+ continue;
1449
+ }
1450
+ if (nextCh === 47) {
1451
+ if (textContent) {
1452
+ const processed = this.processTagValue(textContent, this._textNodeName, jPath, false, true);
1453
+ if (processed !== undefined && processed !== "")
1454
+ parent.push({ [this._textNodeName]: processed });
1455
+ textContent = "";
1456
+ }
1457
+ pos += 2;
1458
+ const nameEnd2 = this.readTagName(xml, pos, len);
1459
+ pos = nameEnd2;
1460
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
1461
+ pos++;
1462
+ if (pos < len && xml.charCodeAt(pos) === 62)
1463
+ pos++;
1464
+ return pos;
1465
+ }
1466
+ if (textContent) {
1467
+ const processed = this.processTagValue(textContent, this._textNodeName, jPath, false, true);
1468
+ if (processed !== undefined && processed !== "")
1469
+ parent.push({ [this._textNodeName]: processed });
1470
+ textContent = "";
1471
+ }
1472
+ pos++;
1473
+ const nameStart = pos;
1474
+ const nameEnd = this.readTagName(xml, pos, len);
1475
+ const tagName = this.extractTagName(xml, nameStart, nameEnd);
1476
+ if (!tagName) {
1477
+ pos = nameEnd + 1;
1478
+ continue;
1479
+ }
1480
+ pos = nameEnd;
1481
+ const childJPath = needsJPath ? jPath ? `${jPath}.${tagName}` : tagName : "";
1482
+ let attrs = {};
1483
+ let hasAttrs = false;
1484
+ if (!this._ignoreAttributes) {
1485
+ const attrResult = this.parseAttributes(xml, pos, len, childJPath, attrs);
1486
+ if (attrResult < 0) {
1487
+ pos = -attrResult - 1;
1488
+ hasAttrs = true;
1489
+ } else {
1490
+ pos = attrResult;
1491
+ }
2659
1492
  } else {
2660
- obj[atrrName] = attrMap[atrrName];
1493
+ while (pos < len) {
1494
+ const c = xml.charCodeAt(pos);
1495
+ if (c === 62 || c === 47)
1496
+ break;
1497
+ if (c === 34 || c === 39) {
1498
+ pos++;
1499
+ while (pos < len && xml.charCodeAt(pos) !== c)
1500
+ pos++;
1501
+ }
1502
+ pos++;
1503
+ }
1504
+ }
1505
+ while (pos < len && isWhitespace(xml.charCodeAt(pos)))
1506
+ pos++;
1507
+ const orderedNode = { [tagName]: [] };
1508
+ if (hasAttrs) {
1509
+ const attrKey = ":@";
1510
+ orderedNode[attrKey] = {};
1511
+ for (const name in attrs) {
1512
+ orderedNode[attrKey][this._attrPrefix + name] = this.parseAttributeValue(attrs[name]);
1513
+ }
1514
+ }
1515
+ if (pos < len && xml.charCodeAt(pos) === 47) {
1516
+ pos += 2;
1517
+ parent.push(orderedNode);
1518
+ continue;
1519
+ }
1520
+ if (pos < len && xml.charCodeAt(pos) === 62) {
1521
+ pos++;
1522
+ pos = this.parseChildrenOrdered(xml, pos, len, orderedNode[tagName], childJPath);
1523
+ parent.push(orderedNode);
2661
1524
  }
2662
1525
  }
1526
+ if (textContent) {
1527
+ const processed = this.processTagValue(textContent, this._textNodeName, jPath, false, true);
1528
+ if (processed !== undefined && processed !== "")
1529
+ parent.push({ [this._textNodeName]: processed });
1530
+ }
1531
+ return pos;
2663
1532
  }
2664
- }
2665
- function isLeafTag(obj, options) {
2666
- const { textNodeName } = options;
2667
- const propCount = Object.keys(obj).length;
2668
- if (propCount === 0) {
2669
- return true;
2670
- }
2671
- if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
2672
- return true;
2673
- }
2674
- return false;
2675
- }
2676
- var METADATA_SYMBOL2;
2677
- var init_node2json = __esm(() => {
2678
- init_xmlNode();
2679
- init_src();
2680
- METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
2681
- });
2682
-
2683
- // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
2684
- class XMLParser {
2685
- constructor(options) {
2686
- this.externalEntities = {};
2687
- this.options = buildOptions(options);
2688
- }
2689
- parse(xmlData, validationOption) {
2690
- if (typeof xmlData !== "string" && xmlData.toString) {
2691
- xmlData = xmlData.toString();
2692
- } else if (typeof xmlData !== "string") {
2693
- throw new Error("XML data is accepted in String or Bytes[] form.");
2694
- }
2695
- if (validationOption) {
2696
- if (validationOption === true)
2697
- validationOption = {};
2698
- const result = validate(xmlData, validationOption);
2699
- if (result !== true) {
2700
- throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
2701
- }
2702
- }
2703
- const orderedObjParser = new OrderedObjParser(this.options);
2704
- orderedObjParser.addExternalEntities(this.externalEntities);
2705
- const orderedResult = orderedObjParser.parseXml(xmlData);
2706
- if (this.options.preserveOrder || orderedResult === undefined)
2707
- return orderedResult;
2708
- else
2709
- return prettify(orderedResult, this.options, orderedObjParser.matcher);
2710
- }
2711
- addEntity(key, value) {
2712
- if (value.indexOf("&") !== -1) {
2713
- throw new Error("Entity value can't have '&'");
2714
- } else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
2715
- throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
2716
- } else if (value === "&") {
2717
- throw new Error("An entity with value '&' is not permitted");
1533
+ applyAttributes(obj, attrs, jPath) {
1534
+ const prefix = this._attrPrefix;
1535
+ if (this._attrsGroupName) {
1536
+ const group = {};
1537
+ for (const name in attrs) {
1538
+ group[prefix + name] = this.parseAttributeValue(attrs[name]);
1539
+ }
1540
+ obj[this._attrsGroupName] = group;
2718
1541
  } else {
2719
- this.externalEntities[key] = value;
1542
+ for (const name in attrs) {
1543
+ obj[prefix + name] = this.parseAttributeValue(attrs[name]);
1544
+ }
2720
1545
  }
2721
1546
  }
2722
- static getMetaDataSymbol() {
2723
- return XmlNode.getMetaDataSymbol();
1547
+ parsePiAttributes(content) {
1548
+ const attrs = {};
1549
+ let i = 0;
1550
+ const len = content.length;
1551
+ while (i < len) {
1552
+ while (i < len && isWhitespace(content.charCodeAt(i)))
1553
+ i++;
1554
+ if (i >= len)
1555
+ break;
1556
+ const nameStart = i;
1557
+ while (i < len && !isWhitespace(content.charCodeAt(i)) && content.charCodeAt(i) !== 61)
1558
+ i++;
1559
+ const name = content.substring(nameStart, i);
1560
+ if (!name)
1561
+ break;
1562
+ while (i < len && isWhitespace(content.charCodeAt(i)))
1563
+ i++;
1564
+ if (i < len && content.charCodeAt(i) === 61) {
1565
+ i++;
1566
+ while (i < len && isWhitespace(content.charCodeAt(i)))
1567
+ i++;
1568
+ if (i < len) {
1569
+ const quote = content.charCodeAt(i);
1570
+ if (quote === 34 || quote === 39) {
1571
+ i++;
1572
+ const valueStart = i;
1573
+ while (i < len && content.charCodeAt(i) !== quote)
1574
+ i++;
1575
+ attrs[name] = content.substring(valueStart, i);
1576
+ if (i < len)
1577
+ i++;
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+ return attrs;
2724
1583
  }
2725
1584
  }
2726
- var init_XMLParser = __esm(() => {
2727
- init_OptionsBuilder();
2728
- init_OrderedObjParser();
2729
- init_node2json();
2730
- init_validator();
2731
- init_xmlNode();
2732
- });
2733
-
2734
- // ../../node_modules/fast-xml-parser/src/fxp.js
2735
- var init_fxp = __esm(() => {
2736
- init_XMLParser();
1585
+ var xmlEntities, htmlEntities, _encodeMap, defaultParserOptions, RE_HEX, RE_SCIENTIFIC, RE_NUMBER;
1586
+ var init_dist = __esm(() => {
1587
+ xmlEntities = {
1588
+ amp: "&",
1589
+ lt: "<",
1590
+ gt: ">",
1591
+ quot: '"',
1592
+ apos: "'"
1593
+ };
1594
+ htmlEntities = {
1595
+ nbsp: " ",
1596
+ copy: "©",
1597
+ reg: "®",
1598
+ trade: "™",
1599
+ euro: "€",
1600
+ pound: "£",
1601
+ yen: "¥",
1602
+ cent: "¢",
1603
+ deg: "°",
1604
+ micro: "µ",
1605
+ middot: "·",
1606
+ bull: "•",
1607
+ hellip: "…",
1608
+ prime: "′",
1609
+ Prime: "″",
1610
+ laquo: "«",
1611
+ raquo: "»",
1612
+ lsquo: "‘",
1613
+ rsquo: "’",
1614
+ ldquo: "“",
1615
+ rdquo: "”",
1616
+ ndash: "–",
1617
+ mdash: "—",
1618
+ iexcl: "¡",
1619
+ iquest: "¿",
1620
+ sect: "§",
1621
+ para: "¶",
1622
+ dagger: "†",
1623
+ Dagger: "‡",
1624
+ lsaquo: "‹",
1625
+ rsaquo: "›",
1626
+ oline: "‾",
1627
+ frasl: "⁄",
1628
+ ensp: " ",
1629
+ emsp: " ",
1630
+ thinsp: " ",
1631
+ zwnj: "‌",
1632
+ zwj: "‍",
1633
+ lrm: "‎",
1634
+ rlm: "‏",
1635
+ times: "×",
1636
+ divide: "÷",
1637
+ plusmn: "±",
1638
+ ne: "≠",
1639
+ le: "≤",
1640
+ ge: "≥",
1641
+ infin: "∞",
1642
+ fnof: "ƒ",
1643
+ Alpha: "Α",
1644
+ Beta: "Β",
1645
+ Gamma: "Γ",
1646
+ Delta: "Δ",
1647
+ Epsilon: "Ε",
1648
+ Zeta: "Ζ",
1649
+ Eta: "Η",
1650
+ Theta: "Θ",
1651
+ Iota: "Ι",
1652
+ Kappa: "Κ",
1653
+ Lambda: "Λ",
1654
+ Mu: "Μ",
1655
+ Nu: "Ν",
1656
+ Xi: "Ξ",
1657
+ Omicron: "Ο",
1658
+ Pi: "Π",
1659
+ Rho: "Ρ",
1660
+ Sigma: "Σ",
1661
+ Tau: "Τ",
1662
+ Upsilon: "Υ",
1663
+ Phi: "Φ",
1664
+ Chi: "Χ",
1665
+ Psi: "Ψ",
1666
+ Omega: "Ω",
1667
+ alpha: "α",
1668
+ beta: "β",
1669
+ gamma: "γ",
1670
+ delta: "δ",
1671
+ epsilon: "ε",
1672
+ zeta: "ζ",
1673
+ eta: "η",
1674
+ theta: "θ",
1675
+ iota: "ι",
1676
+ kappa: "κ",
1677
+ lambda: "λ",
1678
+ mu: "μ",
1679
+ nu: "ν",
1680
+ xi: "ξ",
1681
+ omicron: "ο",
1682
+ pi: "π",
1683
+ rho: "ρ",
1684
+ sigmaf: "ς",
1685
+ sigma: "σ",
1686
+ tau: "τ",
1687
+ upsilon: "υ",
1688
+ phi: "φ",
1689
+ chi: "χ",
1690
+ psi: "ψ",
1691
+ omega: "ω",
1692
+ thetasym: "ϑ",
1693
+ upsih: "ϒ",
1694
+ piv: "ϖ",
1695
+ larr: "←",
1696
+ uarr: "↑",
1697
+ rarr: "→",
1698
+ darr: "↓",
1699
+ harr: "↔",
1700
+ crarr: "↵",
1701
+ lArr: "⇐",
1702
+ uArr: "⇑",
1703
+ rArr: "⇒",
1704
+ dArr: "⇓",
1705
+ hArr: "⇔",
1706
+ forall: "∀",
1707
+ part: "∂",
1708
+ exist: "∃",
1709
+ empty: "∅",
1710
+ nabla: "∇",
1711
+ isin: "∈",
1712
+ notin: "∉",
1713
+ ni: "∋",
1714
+ prod: "∏",
1715
+ sum: "∑",
1716
+ minus: "−",
1717
+ lowast: "∗",
1718
+ radic: "√",
1719
+ prop: "∝",
1720
+ ang: "∠",
1721
+ and: "∧",
1722
+ or: "∨",
1723
+ cap: "∩",
1724
+ cup: "∪",
1725
+ int: "∫",
1726
+ there4: "∴",
1727
+ sim: "∼",
1728
+ cong: "≅",
1729
+ asymp: "≈",
1730
+ equiv: "≡",
1731
+ sub: "⊂",
1732
+ sup: "⊃",
1733
+ nsub: "⊄",
1734
+ sube: "⊆",
1735
+ supe: "⊇",
1736
+ oplus: "⊕",
1737
+ otimes: "⊗",
1738
+ perp: "⊥",
1739
+ sdot: "⋅",
1740
+ lceil: "⌈",
1741
+ rceil: "⌉",
1742
+ lfloor: "⌊",
1743
+ rfloor: "⌋",
1744
+ lang: "〈",
1745
+ rang: "〉",
1746
+ loz: "◊",
1747
+ spades: "♠",
1748
+ clubs: "♣",
1749
+ hearts: "♥",
1750
+ diams: "♦",
1751
+ Agrave: "À",
1752
+ Aacute: "Á",
1753
+ Acirc: "Â",
1754
+ Atilde: "Ã",
1755
+ Auml: "Ä",
1756
+ Aring: "Å",
1757
+ AElig: "Æ",
1758
+ Ccedil: "Ç",
1759
+ Egrave: "È",
1760
+ Eacute: "É",
1761
+ Ecirc: "Ê",
1762
+ Euml: "Ë",
1763
+ Igrave: "Ì",
1764
+ Iacute: "Í",
1765
+ Icirc: "Î",
1766
+ Iuml: "Ï",
1767
+ ETH: "Ð",
1768
+ Ntilde: "Ñ",
1769
+ Ograve: "Ò",
1770
+ Oacute: "Ó",
1771
+ Ocirc: "Ô",
1772
+ Otilde: "Õ",
1773
+ Ouml: "Ö",
1774
+ Oslash: "Ø",
1775
+ Ugrave: "Ù",
1776
+ Uacute: "Ú",
1777
+ Ucirc: "Û",
1778
+ Uuml: "Ü",
1779
+ Yacute: "Ý",
1780
+ THORN: "Þ",
1781
+ szlig: "ß",
1782
+ agrave: "à",
1783
+ aacute: "á",
1784
+ acirc: "â",
1785
+ atilde: "ã",
1786
+ auml: "ä",
1787
+ aring: "å",
1788
+ aelig: "æ",
1789
+ ccedil: "ç",
1790
+ egrave: "è",
1791
+ eacute: "é",
1792
+ ecirc: "ê",
1793
+ euml: "ë",
1794
+ igrave: "ì",
1795
+ iacute: "í",
1796
+ icirc: "î",
1797
+ iuml: "ï",
1798
+ eth: "ð",
1799
+ ntilde: "ñ",
1800
+ ograve: "ò",
1801
+ oacute: "ó",
1802
+ ocirc: "ô",
1803
+ otilde: "õ",
1804
+ ouml: "ö",
1805
+ oslash: "ø",
1806
+ ugrave: "ù",
1807
+ uacute: "ú",
1808
+ ucirc: "û",
1809
+ uuml: "ü",
1810
+ yacute: "ý",
1811
+ thorn: "þ",
1812
+ yuml: "ÿ",
1813
+ OElig: "Œ",
1814
+ oelig: "œ",
1815
+ Scaron: "Š",
1816
+ scaron: "š",
1817
+ Yuml: "Ÿ",
1818
+ circ: "ˆ",
1819
+ tilde: "˜"
1820
+ };
1821
+ _encodeMap = [];
1822
+ _encodeMap[38] = "&amp;";
1823
+ _encodeMap[60] = "&lt;";
1824
+ _encodeMap[62] = "&gt;";
1825
+ _encodeMap[34] = "&quot;";
1826
+ _encodeMap[39] = "&apos;";
1827
+ defaultParserOptions = {
1828
+ attributeNamePrefix: "@_",
1829
+ attributesGroupName: false,
1830
+ textNodeName: "#text",
1831
+ ignoreAttributes: true,
1832
+ removeNSPrefix: false,
1833
+ allowBooleanAttributes: false,
1834
+ alwaysCreateTextNode: false,
1835
+ trimValues: true,
1836
+ parseTagValue: true,
1837
+ parseAttributeValue: false,
1838
+ processEntities: true,
1839
+ htmlEntities: false,
1840
+ commentPropName: false,
1841
+ cdataPropName: false,
1842
+ piPropName: false,
1843
+ preserveOrder: false,
1844
+ stopNodes: [],
1845
+ unpairedTags: [],
1846
+ isArray: undefined,
1847
+ tagValueProcessor: undefined,
1848
+ attributeValueProcessor: undefined,
1849
+ updateTag: undefined,
1850
+ numberParseOptions: {
1851
+ hex: true,
1852
+ leadingZeros: true,
1853
+ scientific: true
1854
+ },
1855
+ ignorePiTags: false,
1856
+ transformAttributeName: undefined,
1857
+ transformTagName: undefined,
1858
+ ignoreDeclaration: false
1859
+ };
1860
+ RE_HEX = /^0x[\da-fA-F]+$/;
1861
+ RE_SCIENTIFIC = /^[+-]?\d+(\.\d+)?[eE][+-]?\d+$/;
1862
+ RE_NUMBER = /^[+-]?(\d+\.?\d*|\.\d+)$/;
2737
1863
  });
2738
1864
 
2739
1865
  // src/aws/client.ts
@@ -3268,7 +2394,7 @@ function buildQueryParams(params) {
3268
2394
  return result;
3269
2395
  }
3270
2396
  var init_client = __esm(() => {
3271
- init_fxp();
2397
+ init_dist();
3272
2398
  });
3273
2399
 
3274
2400
  // src/aws/cloudformation.ts
@@ -8395,7 +7521,7 @@ function createGoDaddyValidator(apiKey, apiSecret, acmRegion, environment) {
8395
7521
  function createRoute53Validator(region, hostedZoneId, acmRegion) {
8396
7522
  return new UnifiedDnsValidator({ provider: "route53", region, hostedZoneId }, acmRegion || region);
8397
7523
  }
8398
- var init_validator2 = __esm(() => {
7524
+ var init_validator = __esm(() => {
8399
7525
  init_acm();
8400
7526
  init_dns();
8401
7527
  });
@@ -8514,7 +7640,7 @@ class DnsProviderFactory {
8514
7640
  var dnsProviders;
8515
7641
  var init_dns = __esm(() => {
8516
7642
  init_route53_adapter();
8517
- init_validator2();
7643
+ init_validator();
8518
7644
  init_route53_adapter();
8519
7645
  dnsProviders = new DnsProviderFactory;
8520
7646
  });
@@ -9673,7 +8799,7 @@ var init_static_site_external_dns = __esm(() => {
9673
8799
  init_cloudfront();
9674
8800
  init_acm();
9675
8801
  init_dns();
9676
- init_validator2();
8802
+ init_validator();
9677
8803
  });
9678
8804
 
9679
8805
  // src/deploy/static-site.ts