html-react-parser 4.2.9 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,172 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HTMLReactParser = factory(global.React));
5
5
  })(this, (function (require$$0) { 'use strict';
6
6
 
7
+ function _mergeNamespaces(n, m) {
8
+ m.forEach(function (e) {
9
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default' && !(k in n)) {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ });
19
+ return Object.freeze(n);
20
+ }
21
+
7
22
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
23
 
9
24
  function getDefaultExportFromCjs (x) {
10
25
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
26
  }
12
27
 
28
+ var lib$3 = {};
29
+
30
+ var htmlToDom = {};
31
+
32
+ var domparser$1 = {};
33
+
34
+ Object.defineProperty(domparser$1, "__esModule", { value: true });
35
+ // constants
36
+ var HTML = 'html';
37
+ var HEAD = 'head';
38
+ var BODY = 'body';
39
+ var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
40
+ // match-all-characters in case of newlines (DOTALL)
41
+ var HEAD_TAG_REGEX = /<head[^]*>/i;
42
+ var BODY_TAG_REGEX = /<body[^]*>/i;
43
+ // falls back to `parseFromString` if `createHTMLDocument` cannot be used
44
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
+ var parseFromDocument = function (html, tagName) {
46
+ /* istanbul ignore next */
47
+ throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
48
+ };
49
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
+ var parseFromString = function (html, tagName) {
51
+ /* istanbul ignore next */
52
+ throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
53
+ };
54
+ var DOMParser = typeof window === 'object' && window.DOMParser;
55
+ /**
56
+ * DOMParser (performance: slow).
57
+ *
58
+ * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
59
+ */
60
+ if (typeof DOMParser === 'function') {
61
+ var domParser_1 = new DOMParser();
62
+ var mimeType_1 = 'text/html';
63
+ /**
64
+ * Creates an HTML document using `DOMParser.parseFromString`.
65
+ *
66
+ * @param html - The HTML string.
67
+ * @param tagName - The element to render the HTML (with 'body' as fallback).
68
+ * @returns - Document.
69
+ */
70
+ parseFromString = function (html, tagName) {
71
+ if (tagName) {
72
+ /* istanbul ignore next */
73
+ html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
74
+ }
75
+ return domParser_1.parseFromString(html, mimeType_1);
76
+ };
77
+ parseFromDocument = parseFromString;
78
+ }
79
+ /**
80
+ * DOMImplementation (performance: fair).
81
+ *
82
+ * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
83
+ */
84
+ if (typeof document === 'object' && document.implementation) {
85
+ var htmlDocument_1 = document.implementation.createHTMLDocument();
86
+ /**
87
+ * Use HTML document created by `document.implementation.createHTMLDocument`.
88
+ *
89
+ * @param html - The HTML string.
90
+ * @param tagName - The element to render the HTML (with 'body' as fallback).
91
+ * @returns - Document
92
+ */
93
+ parseFromDocument = function (html, tagName) {
94
+ if (tagName) {
95
+ var element = htmlDocument_1.documentElement.querySelector(tagName);
96
+ if (element) {
97
+ element.innerHTML = html;
98
+ }
99
+ return htmlDocument_1;
100
+ }
101
+ htmlDocument_1.documentElement.innerHTML = html;
102
+ return htmlDocument_1;
103
+ };
104
+ }
105
+ /**
106
+ * Template (performance: fast).
107
+ *
108
+ * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
109
+ */
110
+ var template = typeof document === 'object' && document.createElement('template');
111
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
+ var parseFromTemplate;
113
+ if (template && template.content) {
114
+ /**
115
+ * Uses a template element (content fragment) to parse HTML.
116
+ *
117
+ * @param html - HTML string.
118
+ * @returns - Nodes.
119
+ */
120
+ parseFromTemplate = function (html) {
121
+ template.innerHTML = html;
122
+ return template.content.childNodes;
123
+ };
124
+ }
125
+ /**
126
+ * Parses HTML string to DOM nodes.
127
+ *
128
+ * @param html - HTML markup.
129
+ * @returns - DOM nodes.
130
+ */
131
+ function domparser(html) {
132
+ var _a, _b;
133
+ var match = html.match(FIRST_TAG_REGEX);
134
+ var firstTagName = match && match[1] ? match[1].toLowerCase() : '';
135
+ switch (firstTagName) {
136
+ case HTML: {
137
+ var doc = parseFromString(html);
138
+ // the created document may come with filler head/body elements,
139
+ // so make sure to remove them if they don't actually exist
140
+ if (!HEAD_TAG_REGEX.test(html)) {
141
+ var element = doc.querySelector(HEAD);
142
+ (_a = element === null || element === void 0 ? void 0 : element.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(element);
143
+ }
144
+ if (!BODY_TAG_REGEX.test(html)) {
145
+ var element = doc.querySelector(BODY);
146
+ (_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
147
+ }
148
+ return doc.querySelectorAll(HTML);
149
+ }
150
+ case HEAD:
151
+ case BODY: {
152
+ var elements = parseFromDocument(html).querySelectorAll(firstTagName);
153
+ // if there's a sibling element, then return both elements
154
+ if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
155
+ return elements[0].parentNode.childNodes;
156
+ }
157
+ return elements;
158
+ }
159
+ // low-level tag or text
160
+ default: {
161
+ if (parseFromTemplate) {
162
+ return parseFromTemplate(html);
163
+ }
164
+ var element = parseFromDocument(html, BODY).querySelector(BODY);
165
+ return element.childNodes;
166
+ }
167
+ }
168
+ }
169
+ domparser$1.default = domparser;
170
+
171
+ var utilities$2 = {};
172
+
13
173
  var lib$2 = {};
14
174
 
15
175
  var lib$1 = {};
@@ -714,148 +874,6 @@
714
874
  exports.default = DomHandler;
715
875
  } (lib$2));
716
876
 
717
- var htmlToDom = {};
718
-
719
- var domparser$1 = {};
720
-
721
- Object.defineProperty(domparser$1, "__esModule", { value: true });
722
- // constants
723
- var HTML = 'html';
724
- var HEAD = 'head';
725
- var BODY = 'body';
726
- var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
727
- // match-all-characters in case of newlines (DOTALL)
728
- var HEAD_TAG_REGEX = /<head[^]*>/i;
729
- var BODY_TAG_REGEX = /<body[^]*>/i;
730
- // falls back to `parseFromString` if `createHTMLDocument` cannot be used
731
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
732
- var parseFromDocument = function (html, tagName) {
733
- /* istanbul ignore next */
734
- throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
735
- };
736
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
737
- var parseFromString = function (html, tagName) {
738
- /* istanbul ignore next */
739
- throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
740
- };
741
- var DOMParser = typeof window === 'object' && window.DOMParser;
742
- /**
743
- * DOMParser (performance: slow).
744
- *
745
- * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
746
- */
747
- if (typeof DOMParser === 'function') {
748
- var domParser_1 = new DOMParser();
749
- var mimeType_1 = 'text/html';
750
- /**
751
- * Creates an HTML document using `DOMParser.parseFromString`.
752
- *
753
- * @param html - The HTML string.
754
- * @param tagName - The element to render the HTML (with 'body' as fallback).
755
- * @returns - Document.
756
- */
757
- parseFromString = function (html, tagName) {
758
- if (tagName) {
759
- html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
760
- }
761
- return domParser_1.parseFromString(html, mimeType_1);
762
- };
763
- parseFromDocument = parseFromString;
764
- }
765
- /**
766
- * DOMImplementation (performance: fair).
767
- *
768
- * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
769
- */
770
- if (typeof document === 'object' && document.implementation) {
771
- var htmlDocument_1 = document.implementation.createHTMLDocument();
772
- /**
773
- * Use HTML document created by `document.implementation.createHTMLDocument`.
774
- *
775
- * @param html - The HTML string.
776
- * @param tagName - The element to render the HTML (with 'body' as fallback).
777
- * @returns - Document
778
- */
779
- parseFromDocument = function (html, tagName) {
780
- if (tagName) {
781
- var element = htmlDocument_1.documentElement.querySelector(tagName);
782
- if (element) {
783
- element.innerHTML = html;
784
- }
785
- return htmlDocument_1;
786
- }
787
- htmlDocument_1.documentElement.innerHTML = html;
788
- return htmlDocument_1;
789
- };
790
- }
791
- /**
792
- * Template (performance: fast).
793
- *
794
- * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
795
- */
796
- var template = typeof document === 'object' && document.createElement('template');
797
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
798
- var parseFromTemplate;
799
- if (template && template.content) {
800
- /**
801
- * Uses a template element (content fragment) to parse HTML.
802
- *
803
- * @param html - HTML string.
804
- * @returns - Nodes.
805
- */
806
- parseFromTemplate = function (html) {
807
- template.innerHTML = html;
808
- return template.content.childNodes;
809
- };
810
- }
811
- /**
812
- * Parses HTML string to DOM nodes.
813
- *
814
- * @param html - HTML markup.
815
- * @returns - DOM nodes.
816
- */
817
- function domparser(html) {
818
- var _a, _b;
819
- var match = html.match(FIRST_TAG_REGEX);
820
- var firstTagName = match && match[1] ? match[1].toLowerCase() : '';
821
- switch (firstTagName) {
822
- case HTML: {
823
- var doc = parseFromString(html);
824
- // the created document may come with filler head/body elements,
825
- // so make sure to remove them if they don't actually exist
826
- if (!HEAD_TAG_REGEX.test(html)) {
827
- var element = doc.querySelector(HEAD);
828
- (_a = element === null || element === void 0 ? void 0 : element.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(element);
829
- }
830
- if (!BODY_TAG_REGEX.test(html)) {
831
- var element = doc.querySelector(BODY);
832
- (_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
833
- }
834
- return doc.querySelectorAll(HTML);
835
- }
836
- case HEAD:
837
- case BODY: {
838
- var elements = parseFromDocument(html).querySelectorAll(firstTagName);
839
- // if there's a sibling element, then return both elements
840
- if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
841
- return elements[0].parentNode.childNodes;
842
- }
843
- return elements;
844
- }
845
- // low-level tag or text
846
- default: {
847
- if (parseFromTemplate) {
848
- return parseFromTemplate(html);
849
- }
850
- var element = parseFromDocument(html, BODY).querySelector(BODY);
851
- return element.childNodes;
852
- }
853
- }
854
- }
855
- domparser$1.default = domparser;
856
-
857
- var utilities$4 = {};
858
-
859
877
  var constants = {};
860
878
 
861
879
  (function (exports) {
@@ -906,8 +924,8 @@
906
924
 
907
925
  } (constants));
908
926
 
909
- Object.defineProperty(utilities$4, "__esModule", { value: true });
910
- utilities$4.formatDOM = utilities$4.formatAttributes = void 0;
927
+ Object.defineProperty(utilities$2, "__esModule", { value: true });
928
+ utilities$2.formatDOM = utilities$2.formatAttributes = void 0;
911
929
  var domhandler_1 = lib$2;
912
930
  var constants_1 = constants;
913
931
  /**
@@ -936,7 +954,7 @@
936
954
  }
937
955
  return map;
938
956
  }
939
- utilities$4.formatAttributes = formatAttributes;
957
+ utilities$2.formatAttributes = formatAttributes;
940
958
  /**
941
959
  * Corrects the tag name if it is case-sensitive (SVG).
942
960
  * Otherwise, returns the lowercase tag name (HTML).
@@ -962,7 +980,7 @@
962
980
  */
963
981
  function formatDOM(nodes, parent, directive) {
964
982
  if (parent === void 0) { parent = null; }
965
- var result = [];
983
+ var domNodes = [];
966
984
  var current;
967
985
  var index = 0;
968
986
  var nodesLength = nodes.length;
@@ -991,7 +1009,7 @@
991
1009
  continue;
992
1010
  }
993
1011
  // set previous node next
994
- var prev = result[index - 1] || null;
1012
+ var prev = domNodes[index - 1] || null;
995
1013
  if (prev) {
996
1014
  prev.next = current;
997
1015
  }
@@ -999,27 +1017,27 @@
999
1017
  current.parent = parent;
1000
1018
  current.prev = prev;
1001
1019
  current.next = null;
1002
- result.push(current);
1020
+ domNodes.push(current);
1003
1021
  }
1004
1022
  if (directive) {
1005
1023
  current = new domhandler_1.ProcessingInstruction(directive.substring(0, directive.indexOf(' ')).toLowerCase(), directive);
1006
- current.next = result[0] || null;
1024
+ current.next = domNodes[0] || null;
1007
1025
  current.parent = parent;
1008
- result.unshift(current);
1009
- if (result[1]) {
1010
- result[1].prev = result[0];
1026
+ domNodes.unshift(current);
1027
+ if (domNodes[1]) {
1028
+ domNodes[1].prev = domNodes[0];
1011
1029
  }
1012
1030
  }
1013
- return result;
1031
+ return domNodes;
1014
1032
  }
1015
- utilities$4.formatDOM = formatDOM;
1033
+ utilities$2.formatDOM = formatDOM;
1016
1034
 
1017
- var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1035
+ var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1018
1036
  return (mod && mod.__esModule) ? mod : { "default": mod };
1019
1037
  };
1020
1038
  Object.defineProperty(htmlToDom, "__esModule", { value: true });
1021
- var domparser_1 = __importDefault$2(domparser$1);
1022
- var utilities_1$1 = utilities$4;
1039
+ var domparser_1 = __importDefault$3(domparser$1);
1040
+ var utilities_1$3 = utilities$2;
1023
1041
  var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
1024
1042
  /**
1025
1043
  * Parses HTML string to DOM nodes in browser.
@@ -1031,16 +1049,18 @@
1031
1049
  if (typeof html !== 'string') {
1032
1050
  throw new TypeError('First argument must be a string');
1033
1051
  }
1034
- if (html === '') {
1052
+ if (!html) {
1035
1053
  return [];
1036
1054
  }
1037
1055
  // match directive
1038
1056
  var match = html.match(DIRECTIVE_REGEX);
1039
1057
  var directive = match ? match[1] : undefined;
1040
- return (0, utilities_1$1.formatDOM)((0, domparser_1.default)(html), null, directive);
1058
+ return (0, utilities_1$3.formatDOM)((0, domparser_1.default)(html), null, directive);
1041
1059
  }
1042
1060
  htmlToDom.default = HTMLDOMParser;
1043
1061
 
1062
+ var attributesToProps$1 = {};
1063
+
1044
1064
  var lib = {};
1045
1065
 
1046
1066
  var possibleStandardNamesOptimized$1 = {};
@@ -2058,6 +2078,8 @@
2058
2078
  lib.isCustomAttribute = isCustomAttribute;
2059
2079
  lib.possibleStandardNames = possibleStandardNames;
2060
2080
 
2081
+ var utilities$1 = {};
2082
+
2061
2083
  var cjs$1 = {};
2062
2084
 
2063
2085
  var cjs = {};
@@ -2320,11 +2342,11 @@
2320
2342
  return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
2321
2343
  }
2322
2344
 
2323
- var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2345
+ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2324
2346
  return (mod && mod.__esModule) ? mod : { "default": mod };
2325
2347
  };
2326
2348
  Object.defineProperty(cjs, "__esModule", { value: true });
2327
- var inline_style_parser_1 = __importDefault$1(inlineStyleParser);
2349
+ var inline_style_parser_1 = __importDefault$2(inlineStyleParser);
2328
2350
  /**
2329
2351
  * Parses inline style to object.
2330
2352
  *
@@ -2363,10 +2385,10 @@
2363
2385
  }
2364
2386
  cjs.default = StyleToObject;
2365
2387
 
2366
- var utilities$3 = {};
2388
+ var utilities = {};
2367
2389
 
2368
- Object.defineProperty(utilities$3, "__esModule", { value: true });
2369
- utilities$3.camelCase = void 0;
2390
+ Object.defineProperty(utilities, "__esModule", { value: true });
2391
+ utilities.camelCase = void 0;
2370
2392
  var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/;
2371
2393
  var HYPHEN_REGEX = /-([a-z])/g;
2372
2394
  var NO_HYPHEN_REGEX = /^[^-]+$/;
@@ -2409,14 +2431,14 @@
2409
2431
  }
2410
2432
  return property.replace(HYPHEN_REGEX, capitalize);
2411
2433
  };
2412
- utilities$3.camelCase = camelCase;
2434
+ utilities.camelCase = camelCase;
2413
2435
 
2414
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2436
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2415
2437
  return (mod && mod.__esModule) ? mod : { "default": mod };
2416
2438
  };
2417
2439
  Object.defineProperty(cjs$1, "__esModule", { value: true });
2418
- var style_to_object_1 = __importDefault(cjs);
2419
- var utilities_1 = utilities$3;
2440
+ var style_to_object_1 = __importDefault$1(cjs);
2441
+ var utilities_1$2 = utilities;
2420
2442
  /**
2421
2443
  * Parses CSS inline style to JavaScript object (camelCased).
2422
2444
  */
@@ -2428,408 +2450,364 @@
2428
2450
  (0, style_to_object_1.default)(style, function (property, value) {
2429
2451
  // skip CSS comment
2430
2452
  if (property && value) {
2431
- output[(0, utilities_1.camelCase)(property, options)] = value;
2453
+ output[(0, utilities_1$2.camelCase)(property, options)] = value;
2432
2454
  }
2433
2455
  });
2434
2456
  return output;
2435
2457
  }
2436
2458
  cjs$1.default = StyleToJS;
2437
2459
 
2438
- var React$1 = require$$0;
2439
- var styleToJS = cjs$1.default;
2440
-
2441
- var RESERVED_SVG_MATHML_ELEMENTS = new Set([
2442
- 'annotation-xml',
2443
- 'color-profile',
2444
- 'font-face',
2445
- 'font-face-src',
2446
- 'font-face-uri',
2447
- 'font-face-format',
2448
- 'font-face-name',
2449
- 'missing-glyph'
2450
- ]);
2451
-
2452
- /**
2453
- * Check if a given tag is a custom component.
2454
- *
2455
- * @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
2456
- *
2457
- * @param {string} tagName - The name of the html tag.
2458
- * @param {object} props - The props being passed to the element.
2459
- * @returns {boolean} - Whether tag is custom component.
2460
- */
2461
- function isCustomComponent(tagName, props) {
2462
- if (tagName.indexOf('-') === -1) {
2463
- return props && typeof props.is === 'string';
2464
- }
2465
- // These are reserved SVG and MathML elements.
2466
- // We don't mind this whitelist too much because we expect it to never grow.
2467
- // The alternative is to track the namespace in a few places which is convoluted.
2468
- // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
2469
- if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
2470
- return false;
2471
- }
2472
- return true;
2473
- }
2474
-
2475
- // styleToJSOptions
2476
- var STYLE_TO_JS_OPTIONS = { reactCompat: true };
2477
-
2478
- /**
2479
- * Sets style prop.
2480
- *
2481
- * @param {null|undefined|string} style
2482
- * @param {object} props
2483
- */
2484
- function setStyleProp$1(style, props) {
2485
- if (style === null || style === undefined) {
2486
- return;
2487
- }
2488
- try {
2489
- props.style = styleToJS(style, STYLE_TO_JS_OPTIONS);
2490
- } catch (err) {
2491
- props.style = {};
2492
- }
2493
- }
2494
-
2495
- /**
2496
- * @constant {boolean}
2497
- * @see {@link https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html}
2498
- */
2499
- var PRESERVE_CUSTOM_ATTRIBUTES = React$1.version.split('.')[0] >= 16;
2500
-
2501
- // Taken from
2502
- // https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
2503
- var ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
2504
- 'tr',
2505
- 'tbody',
2506
- 'thead',
2507
- 'tfoot',
2508
- 'colgroup',
2509
- 'table',
2510
- 'head',
2511
- 'html',
2512
- 'frameset'
2513
- ]);
2514
-
2515
- /**
2516
- * Checks if the given node can contain text nodes
2517
- *
2518
- * @param {DomElement} node - Node.
2519
- * @returns - Whether node can contain text nodes.
2520
- */
2521
- function canTextBeChildOfNode$1(node) {
2522
- return !ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
2523
- }
2524
-
2525
- /**
2526
- * Returns the first argument as is.
2527
- *
2528
- * @param {any} arg - The argument to be returned.
2529
- * @returns {any} The input argument `arg`.
2530
- */
2531
- function returnFirstArg(arg) {
2532
- return arg;
2533
- }
2534
-
2535
- var utilities$2 = {
2536
- PRESERVE_CUSTOM_ATTRIBUTES: PRESERVE_CUSTOM_ATTRIBUTES,
2537
- ELEMENTS_WITH_NO_TEXT_CHILDREN: ELEMENTS_WITH_NO_TEXT_CHILDREN,
2538
- isCustomComponent: isCustomComponent,
2539
- setStyleProp: setStyleProp$1,
2540
- canTextBeChildOfNode: canTextBeChildOfNode$1,
2541
- returnFirstArg: returnFirstArg
2542
- };
2543
-
2544
- var reactProperty = lib;
2545
- var utilities$1 = utilities$2;
2460
+ (function (exports) {
2461
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2462
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2463
+ };
2464
+ Object.defineProperty(exports, "__esModule", { value: true });
2465
+ exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = exports.setStyleProp = exports.isCustomComponent = void 0;
2466
+ var react_1 = require$$0;
2467
+ var style_to_js_1 = __importDefault(cjs$1);
2468
+ var RESERVED_SVG_MATHML_ELEMENTS = new Set([
2469
+ 'annotation-xml',
2470
+ 'color-profile',
2471
+ 'font-face',
2472
+ 'font-face-src',
2473
+ 'font-face-uri',
2474
+ 'font-face-format',
2475
+ 'font-face-name',
2476
+ 'missing-glyph',
2477
+ ]);
2478
+ /**
2479
+ * Check if a tag is a custom component.
2480
+ *
2481
+ * @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
2482
+ *
2483
+ * @param tagName - Tag name.
2484
+ * @param props - Props passed to the element.
2485
+ * @returns - Whether the tag is custom component.
2486
+ */
2487
+ function isCustomComponent(tagName, props) {
2488
+ if (tagName.indexOf('-') === -1) {
2489
+ return Boolean(props && typeof props.is === 'string');
2490
+ }
2491
+ // These are reserved SVG and MathML elements.
2492
+ // We don't mind this whitelist too much because we expect it to never grow.
2493
+ // The alternative is to track the namespace in a few places which is convoluted.
2494
+ // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
2495
+ if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
2496
+ return false;
2497
+ }
2498
+ return true;
2499
+ }
2500
+ exports.isCustomComponent = isCustomComponent;
2501
+ var styleOptions = {
2502
+ reactCompat: true,
2503
+ };
2504
+ /**
2505
+ * Sets style prop.
2506
+ *
2507
+ * @param style - Inline style.
2508
+ * @param props - Props object.
2509
+ */
2510
+ function setStyleProp(style, props) {
2511
+ if (typeof style !== 'string') {
2512
+ return;
2513
+ }
2514
+ if (!style.trim()) {
2515
+ props.style = {};
2516
+ return;
2517
+ }
2518
+ try {
2519
+ props.style = (0, style_to_js_1.default)(style, styleOptions);
2520
+ }
2521
+ catch (error) {
2522
+ props.style = {};
2523
+ }
2524
+ }
2525
+ exports.setStyleProp = setStyleProp;
2526
+ /**
2527
+ * @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
2528
+ */
2529
+ exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
2530
+ /**
2531
+ * @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
2532
+ */
2533
+ exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
2534
+ 'tr',
2535
+ 'tbody',
2536
+ 'thead',
2537
+ 'tfoot',
2538
+ 'colgroup',
2539
+ 'table',
2540
+ 'head',
2541
+ 'html',
2542
+ 'frameset',
2543
+ ]);
2544
+ /**
2545
+ * Checks if the given node can contain text nodes
2546
+ *
2547
+ * @param node - Element node.
2548
+ * @returns - Whether the node can contain text nodes.
2549
+ */
2550
+ var canTextBeChildOfNode = function (node) {
2551
+ return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
2552
+ };
2553
+ exports.canTextBeChildOfNode = canTextBeChildOfNode;
2554
+ /**
2555
+ * Returns the first argument as is.
2556
+ *
2557
+ * @param arg - The argument to be returned.
2558
+ * @returns - The input argument `arg`.
2559
+ */
2560
+ var returnFirstArg = function (arg) { return arg; };
2561
+ exports.returnFirstArg = returnFirstArg;
2562
+
2563
+ } (utilities$1));
2546
2564
 
2547
- // https://reactjs.org/docs/uncontrolled-components.html
2565
+ Object.defineProperty(attributesToProps$1, "__esModule", { value: true });
2566
+ var react_property_1 = lib;
2567
+ var utilities_1$1 = utilities$1;
2568
+ // https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
2548
2569
  // https://developer.mozilla.org/docs/Web/HTML/Attributes
2549
2570
  var UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
2550
2571
  var UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
2551
-
2552
- var VALUE_ONLY_INPUTS = {
2553
- reset: true,
2554
- submit: true
2572
+ var valueOnlyInputs = {
2573
+ reset: true,
2574
+ submit: true,
2555
2575
  };
2556
-
2557
2576
  /**
2558
2577
  * Converts HTML/SVG DOM attributes to React props.
2559
2578
  *
2560
- * @param {object} [attributes={}] - HTML/SVG DOM attributes.
2561
- * @param {string} [nodeName] - DOM node name.
2579
+ * @param attributes - HTML/SVG DOM attributes.
2580
+ * @param nodeName - DOM node name.
2562
2581
  * @returns - React props.
2563
2582
  */
2564
- var attributesToProps$2 = function attributesToProps(attributes, nodeName) {
2565
- attributes = attributes || {};
2566
-
2567
- var attributeName;
2568
- var attributeNameLowerCased;
2569
- var attributeValue;
2570
- var propName;
2571
- var propertyInfo;
2572
- var props = {};
2573
- var inputIsValueOnly = attributes.type && VALUE_ONLY_INPUTS[attributes.type];
2574
-
2575
- for (attributeName in attributes) {
2576
- attributeValue = attributes[attributeName];
2577
-
2578
- // ARIA (aria-*) or custom data (data-*) attribute
2579
- if (reactProperty.isCustomAttribute(attributeName)) {
2580
- props[attributeName] = attributeValue;
2581
- continue;
2582
- }
2583
-
2584
- // convert HTML/SVG attribute to React prop
2585
- attributeNameLowerCased = attributeName.toLowerCase();
2586
- propName = getPropName(attributeNameLowerCased);
2587
-
2588
- if (propName) {
2589
- propertyInfo = reactProperty.getPropertyInfo(propName);
2590
-
2591
- // convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
2592
- if (
2593
- UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf(propName) !== -1 &&
2594
- UNCONTROLLED_COMPONENT_NAMES.indexOf(nodeName) !== -1 &&
2595
- !inputIsValueOnly
2596
- ) {
2597
- propName = getPropName('default' + attributeNameLowerCased);
2598
- }
2599
-
2600
- props[propName] = attributeValue;
2601
-
2602
- switch (propertyInfo && propertyInfo.type) {
2603
- case reactProperty.BOOLEAN:
2604
- props[propName] = true;
2605
- break;
2606
- case reactProperty.OVERLOADED_BOOLEAN:
2607
- if (attributeValue === '') {
2608
- props[propName] = true;
2609
- }
2610
- break;
2611
- }
2612
- continue;
2613
- }
2614
-
2615
- // preserve custom attribute if React >=16
2616
- if (utilities$1.PRESERVE_CUSTOM_ATTRIBUTES) {
2617
- props[attributeName] = attributeValue;
2583
+ function attributesToProps(attributes, nodeName) {
2584
+ if (attributes === void 0) { attributes = {}; }
2585
+ var props = {};
2586
+ var isInputValueOnly = Boolean(attributes.type &&
2587
+ valueOnlyInputs[attributes.type]);
2588
+ for (var attributeName in attributes) {
2589
+ var attributeValue = attributes[attributeName];
2590
+ // ARIA (aria-*) or custom data (data-*) attribute
2591
+ if ((0, react_property_1.isCustomAttribute)(attributeName)) {
2592
+ props[attributeName] = attributeValue;
2593
+ continue;
2594
+ }
2595
+ // convert HTML/SVG attribute to React prop
2596
+ var attributeNameLowerCased = attributeName.toLowerCase();
2597
+ var propName = getPropName(attributeNameLowerCased);
2598
+ if (propName) {
2599
+ var propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
2600
+ // convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
2601
+ if (UNCONTROLLED_COMPONENT_ATTRIBUTES.indexOf(propName) !== -1 &&
2602
+ UNCONTROLLED_COMPONENT_NAMES.indexOf(nodeName) !== -1 &&
2603
+ !isInputValueOnly) {
2604
+ propName = getPropName('default' + attributeNameLowerCased);
2605
+ }
2606
+ props[propName] = attributeValue;
2607
+ switch (propertyInfo && propertyInfo.type) {
2608
+ case react_property_1.BOOLEAN:
2609
+ props[propName] = true;
2610
+ break;
2611
+ case react_property_1.OVERLOADED_BOOLEAN:
2612
+ if (attributeValue === '') {
2613
+ props[propName] = true;
2614
+ }
2615
+ break;
2616
+ }
2617
+ continue;
2618
+ }
2619
+ // preserve custom attribute if React >=16
2620
+ if (utilities_1$1.PRESERVE_CUSTOM_ATTRIBUTES) {
2621
+ props[attributeName] = attributeValue;
2622
+ }
2618
2623
  }
2619
- }
2620
-
2621
- // transform inline style to object
2622
- utilities$1.setStyleProp(attributes.style, props);
2623
-
2624
- return props;
2625
- };
2626
-
2624
+ // transform inline style to object
2625
+ (0, utilities_1$1.setStyleProp)(attributes.style, props);
2626
+ return props;
2627
+ }
2628
+ attributesToProps$1.default = attributesToProps;
2627
2629
  /**
2628
2630
  * Gets prop name from lowercased attribute name.
2629
2631
  *
2630
- * @param {string} attributeName - Lowercased attribute name.
2632
+ * @param attributeName - Lowercased attribute name.
2631
2633
  * @returns - Prop name.
2632
2634
  */
2633
2635
  function getPropName(attributeName) {
2634
- return reactProperty.possibleStandardNames[attributeName];
2636
+ return react_property_1.possibleStandardNames[attributeName];
2635
2637
  }
2636
2638
 
2637
- var React = require$$0;
2638
- var attributesToProps$1 = attributesToProps$2;
2639
- var utilities = utilities$2;
2640
-
2641
- var setStyleProp = utilities.setStyleProp;
2642
- var canTextBeChildOfNode = utilities.canTextBeChildOfNode;
2639
+ var domToReact$1 = {};
2643
2640
 
2641
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2642
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2643
+ };
2644
+ Object.defineProperty(domToReact$1, "__esModule", { value: true });
2645
+ var react_1 = require$$0;
2646
+ var attributes_to_props_1 = __importDefault(attributesToProps$1);
2647
+ var utilities_1 = utilities$1;
2648
+ var React = {
2649
+ cloneElement: react_1.cloneElement,
2650
+ createElement: react_1.createElement,
2651
+ isValidElement: react_1.isValidElement,
2652
+ };
2644
2653
  /**
2645
2654
  * Converts DOM nodes to JSX element(s).
2646
2655
  *
2647
- * @param {DomElement[]} nodes - DOM nodes.
2648
- * @param {object} [options={}] - Options.
2649
- * @param {Function} [options.replace] - Replacer.
2650
- * @param {Function} [options.transform] - Transform.
2651
- * @param {object} [options.library] - Library (React, Preact, etc.).
2656
+ * @param nodes - DOM nodes.
2657
+ * @param options - Options.
2652
2658
  * @returns - String or JSX element(s).
2653
2659
  */
2654
- function domToReact$1(nodes, options) {
2655
- options = options || {};
2656
-
2657
- var library = options.library || React;
2658
- var cloneElement = library.cloneElement;
2659
- var createElement = library.createElement;
2660
- var isValidElement = library.isValidElement;
2661
-
2662
- var result = [];
2663
- var node;
2664
- var isWhitespace;
2665
- var hasReplace = typeof options.replace === 'function';
2666
- var transform = options.transform || utilities.returnFirstArg;
2667
- var replaceElement;
2668
- var props;
2669
- var children;
2670
- var trim = options.trim;
2671
-
2672
- for (var i = 0, len = nodes.length; i < len; i++) {
2673
- node = nodes[i];
2674
-
2675
- // replace with custom React element (if present)
2676
- if (hasReplace) {
2677
- replaceElement = options.replace(node);
2678
-
2679
- if (isValidElement(replaceElement)) {
2680
- // set "key" prop for sibling elements
2681
- // https://fb.me/react-warning-keys
2682
- if (len > 1) {
2683
- replaceElement = cloneElement(replaceElement, {
2684
- key: replaceElement.key || i
2685
- });
2660
+ function domToReact(nodes, options) {
2661
+ var reactElements = [];
2662
+ var hasReplace = typeof (options === null || options === void 0 ? void 0 : options.replace) === 'function';
2663
+ var transform = (options === null || options === void 0 ? void 0 : options.transform) || utilities_1.returnFirstArg;
2664
+ var _a = (options === null || options === void 0 ? void 0 : options.library) || React, cloneElement = _a.cloneElement, createElement = _a.createElement, isValidElement = _a.isValidElement;
2665
+ var index = 0;
2666
+ var nodesLength = nodes.length;
2667
+ for (; index < nodesLength; index++) {
2668
+ var node = nodes[index];
2669
+ // replace with custom React element (if present)
2670
+ if (hasReplace) {
2671
+ var replaceElement = options.replace(node);
2672
+ if (isValidElement(replaceElement)) {
2673
+ // set "key" prop for sibling elements
2674
+ // https://react.dev/learn/rendering-lists#rules-of-keys
2675
+ if (nodesLength > 1) {
2676
+ replaceElement = cloneElement(replaceElement, {
2677
+ key: replaceElement.key || index,
2678
+ });
2679
+ }
2680
+ reactElements.push(transform(replaceElement, node, index));
2681
+ continue;
2682
+ }
2686
2683
  }
2687
- result.push(transform(replaceElement, node, i));
2688
- continue;
2689
- }
2690
- }
2691
-
2692
- if (node.type === 'text') {
2693
- isWhitespace = !node.data.trim().length;
2694
-
2695
- if (isWhitespace && node.parent && !canTextBeChildOfNode(node.parent)) {
2696
- // We have a whitespace node that can't be nested in its parent
2697
- // so skip it
2698
- continue;
2699
- }
2700
-
2701
- if (trim && isWhitespace) {
2702
- // Trim is enabled and we have a whitespace node
2703
- // so skip it
2704
- continue;
2705
- }
2706
-
2707
- // We have a text node that's not whitespace and it can be nested
2708
- // in its parent so add it to the results
2709
- result.push(transform(node.data, node, i));
2710
- continue;
2711
- }
2712
-
2713
- props = node.attribs;
2714
- if (skipAttributesToProps(node)) {
2715
- setStyleProp(props.style, props);
2716
- } else if (props) {
2717
- props = attributesToProps$1(props, node.name);
2718
- }
2719
-
2720
- children = null;
2721
-
2722
- switch (node.type) {
2723
- case 'script':
2724
- case 'style':
2725
- // prevent text in <script> or <style> from being escaped
2726
- // https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
2727
- if (node.children[0]) {
2728
- props.dangerouslySetInnerHTML = {
2729
- __html: node.children[0].data
2730
- };
2684
+ if (node.type === 'text') {
2685
+ var isWhitespace = !node.data.trim().length;
2686
+ // We have a whitespace node that can't be nested in its parent
2687
+ // so skip it
2688
+ if (isWhitespace &&
2689
+ node.parent &&
2690
+ !(0, utilities_1.canTextBeChildOfNode)(node.parent)) {
2691
+ continue;
2692
+ }
2693
+ // Trim is enabled and we have a whitespace node
2694
+ // so skip it
2695
+ if ((options === null || options === void 0 ? void 0 : options.trim) && isWhitespace) {
2696
+ continue;
2697
+ }
2698
+ // We have a text node that's not whitespace and it can be nested
2699
+ // in its parent so add it to the results
2700
+ reactElements.push(transform(node.data, node, index));
2701
+ continue;
2731
2702
  }
2732
- break;
2733
-
2734
- case 'tag':
2735
- // setting textarea value in children is an antipattern in React
2736
- // https://reactjs.org/docs/forms.html#the-textarea-tag
2737
- if (node.name === 'textarea' && node.children[0]) {
2738
- props.defaultValue = node.children[0].data;
2739
- } else if (node.children && node.children.length) {
2740
- // continue recursion of creating React elements (if applicable)
2741
- children = domToReact$1(node.children, options);
2703
+ var element = node;
2704
+ var props = {};
2705
+ if (skipAttributesToProps(element)) {
2706
+ (0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
2707
+ props = element.attribs;
2742
2708
  }
2743
- break;
2744
-
2745
- // skip all other cases (e.g., comment)
2746
- default:
2747
- continue;
2748
- }
2749
-
2750
- // set "key" prop for sibling elements
2751
- // https://fb.me/react-warning-keys
2752
- if (len > 1) {
2753
- props.key = i;
2709
+ else if (element.attribs) {
2710
+ props = (0, attributes_to_props_1.default)(element.attribs, element.name);
2711
+ }
2712
+ var children = null;
2713
+ switch (node.type) {
2714
+ case 'script':
2715
+ case 'style':
2716
+ // prevent text in <script> or <style> from being escaped
2717
+ // https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html
2718
+ if (node.children[0]) {
2719
+ props.dangerouslySetInnerHTML = {
2720
+ __html: node.children[0].data,
2721
+ };
2722
+ }
2723
+ break;
2724
+ case 'tag':
2725
+ // setting textarea value in children is an antipattern in React
2726
+ // https://react.dev/reference/react-dom/components/textarea#caveats
2727
+ if (node.name === 'textarea' && node.children[0]) {
2728
+ props.defaultValue = node.children[0].data;
2729
+ }
2730
+ else if (node.children && node.children.length) {
2731
+ // continue recursion of creating React elements (if applicable)
2732
+ children = domToReact(node.children, options);
2733
+ }
2734
+ break;
2735
+ // skip all other cases (e.g., comment)
2736
+ default:
2737
+ continue;
2738
+ }
2739
+ // set "key" prop for sibling elements
2740
+ // https://react.dev/learn/rendering-lists#rules-of-keys
2741
+ if (nodesLength > 1) {
2742
+ props.key = index;
2743
+ }
2744
+ reactElements.push(transform(createElement(node.name, props, children), node, index));
2754
2745
  }
2755
-
2756
- result.push(transform(createElement(node.name, props, children), node, i));
2757
- }
2758
-
2759
- return result.length === 1 ? result[0] : result;
2746
+ return reactElements.length === 1 ? reactElements[0] : reactElements;
2760
2747
  }
2761
-
2748
+ domToReact$1.default = domToReact;
2762
2749
  /**
2763
2750
  * Determines whether DOM element attributes should be transformed to props.
2764
2751
  * Web Components should not have their attributes transformed except for `style`.
2765
2752
  *
2766
- * @param {DomElement} node
2767
- * @returns - Whether node attributes should be converted to props.
2753
+ * @param node - Element node.
2754
+ * @returns - Whether the node attributes should be converted to props.
2768
2755
  */
2769
2756
  function skipAttributesToProps(node) {
2770
- return (
2771
- utilities.PRESERVE_CUSTOM_ATTRIBUTES &&
2772
- node.type === 'tag' &&
2773
- utilities.isCustomComponent(node.name, node.attribs)
2774
- );
2775
- }
2776
-
2777
- var domToReact_1 = domToReact$1;
2778
-
2779
- var domhandler = lib$2;
2780
- var htmlToDOM = htmlToDom.default;
2781
-
2782
- var attributesToProps = attributesToProps$2;
2783
- var domToReact = domToReact_1;
2784
-
2785
- // support backwards compatibility for ES Module
2786
- htmlToDOM =
2787
- /* istanbul ignore next */
2788
- typeof htmlToDOM.default === 'function' ? htmlToDOM.default : htmlToDOM;
2789
-
2790
- var domParserOptions = { lowerCaseAttributeNames: false };
2791
-
2792
- /**
2793
- * Converts HTML string to React elements.
2794
- *
2795
- * @param {string} html - HTML string.
2796
- * @param {object} [options] - Parser options.
2797
- * @param {object} [options.htmlparser2] - htmlparser2 options.
2798
- * @param {object} [options.library] - Library for React, Preact, etc.
2799
- * @param {Function} [options.replace] - Replace method.
2800
- * @returns {JSX.Element|JSX.Element[]|string} - React element(s), empty array, or string.
2801
- */
2802
- function HTMLReactParser(html, options) {
2803
- if (typeof html !== 'string') {
2804
- throw new TypeError('First argument must be a string');
2805
- }
2806
- if (html === '') {
2807
- return [];
2808
- }
2809
- options = options || {};
2810
- return domToReact(
2811
- htmlToDOM(html, options.htmlparser2 || domParserOptions),
2812
- options
2813
- );
2757
+ return (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES &&
2758
+ node.type === 'tag' &&
2759
+ (0, utilities_1.isCustomComponent)(node.name, node.attribs));
2814
2760
  }
2815
2761
 
2816
- HTMLReactParser.domToReact = domToReact;
2817
- HTMLReactParser.htmlToDOM = htmlToDOM;
2818
- HTMLReactParser.attributesToProps = attributesToProps;
2762
+ (function (exports) {
2763
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2764
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2765
+ };
2766
+ Object.defineProperty(exports, "__esModule", { value: true });
2767
+ exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
2768
+ var html_dom_parser_1 = __importDefault(htmlToDom);
2769
+ exports.htmlToDOM = html_dom_parser_1.default;
2770
+ var attributes_to_props_1 = __importDefault(attributesToProps$1);
2771
+ exports.attributesToProps = attributes_to_props_1.default;
2772
+ var dom_to_react_1 = __importDefault(domToReact$1);
2773
+ exports.domToReact = dom_to_react_1.default;
2774
+ var domhandler_1 = lib$2;
2775
+ Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
2776
+ Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
2777
+ Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
2778
+ Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
2779
+ var domParserOptions = { lowerCaseAttributeNames: false };
2780
+ /**
2781
+ * Converts HTML string to React elements.
2782
+ *
2783
+ * @param html - HTML string.
2784
+ * @param options - Parser options.
2785
+ * @returns - React element(s), empty array, or string.
2786
+ */
2787
+ function HTMLReactParser(html, options) {
2788
+ if (typeof html !== 'string') {
2789
+ throw new TypeError('First argument must be a string');
2790
+ }
2791
+ if (!html) {
2792
+ return [];
2793
+ }
2794
+ return (0, dom_to_react_1.default)((0, html_dom_parser_1.default)(html, (options === null || options === void 0 ? void 0 : options.htmlparser2) || domParserOptions), options);
2795
+ }
2796
+ exports.default = HTMLReactParser;
2797
+
2798
+ } (lib$3));
2819
2799
 
2820
- // domhandler
2821
- HTMLReactParser.Comment = domhandler.Comment;
2822
- HTMLReactParser.Element = domhandler.Element;
2823
- HTMLReactParser.ProcessingInstruction = domhandler.ProcessingInstruction;
2824
- HTMLReactParser.Text = domhandler.Text;
2800
+ var index = /*@__PURE__*/getDefaultExportFromCjs(lib$3);
2825
2801
 
2826
- // support CommonJS and ES Modules
2827
- var htmlReactParser = HTMLReactParser;
2828
- HTMLReactParser.default = HTMLReactParser;
2802
+ var HTMLReactParser = /*#__PURE__*/_mergeNamespaces({
2803
+ __proto__: null,
2804
+ default: index
2805
+ }, [lib$3]);
2829
2806
 
2830
- var index = /*@__PURE__*/getDefaultExportFromCjs(htmlReactParser);
2807
+ const parse = index;
2808
+ Object.assign(parse, HTMLReactParser);
2831
2809
 
2832
- return index;
2810
+ return parse;
2833
2811
 
2834
2812
  }));
2835
2813
  //# sourceMappingURL=html-react-parser.js.map