@epa-wg/custom-element-dist 0.0.23 → 0.0.25

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 (93) hide show
  1. package/.storybook/main.ts +21 -21
  2. package/.vscode/settings.json +24 -0
  3. package/README.md +4 -4
  4. package/coverage/coverage-final.json +7 -5
  5. package/coverage/index.html +26 -26
  6. package/coverage/src/custom-element/coverage.svg +1 -1
  7. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  8. package/coverage/src/custom-element/custom-element.js.html +439 -379
  9. package/coverage/src/custom-element/http-request.js.html +12 -12
  10. package/coverage/src/custom-element/index.html +23 -23
  11. package/coverage/src/custom-element/local-storage.js.html +1 -1
  12. package/coverage/src/custom-element/location-element.js/coverage.svg +1 -1
  13. package/coverage/src/custom-element/location-element.js.html +116 -47
  14. package/coverage/src/index.html +1 -1
  15. package/coverage/src/mocks/handlers.ts.html +1 -1
  16. package/coverage/src/mocks/index.html +1 -1
  17. package/coverage/src/stories/attributes.test.stories.ts.html +1 -1
  18. package/coverage/src/stories/coverage.svg +1 -1
  19. package/coverage/src/stories/css.test.stories.ts.html +1 -1
  20. package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +1 -1
  21. package/coverage/src/stories/dom-merge.test.stories.ts.html +238 -10
  22. package/coverage/src/stories/external-template.test.stories.ts.html +1 -1
  23. package/coverage/src/stories/form.test.stories.ts.html +1 -1
  24. package/coverage/src/stories/http-request.stories.ts.html +1 -1
  25. package/coverage/src/stories/index.html +46 -16
  26. package/coverage/src/stories/local-storage.test.stories.ts.html +1 -1
  27. package/coverage/src/stories/location-element.test.stories.ts.html +1 -1
  28. package/coverage/src/stories/set-url.test.stories.ts/coverage.svg +10 -0
  29. package/coverage/src/stories/set-url.test.stories.ts.html +427 -0
  30. package/coverage/src/stories/slice-events.test.stories.ts.html +1 -1
  31. package/coverage/src/stories/slots.test.stories.ts.html +1 -1
  32. package/coverage/src/stories/testStoryBook.ts.html +12 -12
  33. package/coverage/src/stories/version-select.test.stories.ts/coverage.svg +10 -0
  34. package/coverage/src/stories/version-select.test.stories.ts.html +313 -0
  35. package/coverage/src/sum.ts.html +1 -1
  36. package/dist/{custom-element-BISbI4SU.js → custom-element-DAe7uvIt.js} +187 -173
  37. package/dist/custom-element-DZvvhscI.cjs +53 -0
  38. package/dist/custom-element-bundle.cjs +1 -1
  39. package/dist/custom-element-bundle.js +23 -22
  40. package/dist/location-element-DRB7hCwA.cjs +1 -0
  41. package/dist/location-element-FJlONi2n.js +65 -0
  42. package/package.json +2 -2
  43. package/src/custom-element/custom-element.js +25 -5
  44. package/src/custom-element/demo/form.html +2 -3
  45. package/src/custom-element/demo/location-element.html +17 -4
  46. package/src/custom-element/demo/s.xml +31 -6
  47. package/src/custom-element/demo/s.xslt +59 -22
  48. package/src/custom-element/demo/set-url.html +141 -0
  49. package/src/custom-element/ide/customData-dce.json +56 -0
  50. package/src/custom-element/ide/web-types-dce.json +153 -110
  51. package/src/custom-element/ide/web-types-xsl.json +1 -1
  52. package/src/custom-element/index.html +1 -0
  53. package/src/custom-element/location-element.js +25 -2
  54. package/src/custom-element.test.ts +26 -26
  55. package/src/stories/dom-merge.test.stories.ts +76 -0
  56. package/src/stories/set-url.test.stories.ts +114 -0
  57. package/src/stories/version-select.test.stories.ts +76 -0
  58. package/storybook-static/assets/{Color-PRSJMWNM-BD_Ds9NW.js → Color-PRSJMWNM-CRSv4C7i.js} +1 -1
  59. package/storybook-static/assets/{Configure-70I_VApa.js → Configure-D0qG3gR9.js} +1 -1
  60. package/storybook-static/assets/{DocsRenderer-K4EAMTCU-9dn0-HCP.js → DocsRenderer-K4EAMTCU-CG_P5zRZ.js} +2 -2
  61. package/storybook-static/assets/{WithTooltip-KJL26V4Q-C6g5GOU9.js → WithTooltip-KJL26V4Q-CUqUi5E8.js} +1 -1
  62. package/storybook-static/assets/{attributes.test.stories-BEOraI4E.js → attributes.test.stories-W34tZdUt.js} +1 -1
  63. package/storybook-static/assets/{css.test.stories-D9WaxrEv.js → css.test.stories-BZFYx1TQ.js} +1 -1
  64. package/storybook-static/assets/{custom-element-BV8-hRQS.js → custom-element-DpIq8E2p.js} +79 -79
  65. package/storybook-static/assets/dom-merge.test.stories-S-7U5N3h.js +258 -0
  66. package/storybook-static/assets/{external-template.test.stories-Bpr_wxBo.js → external-template.test.stories-QIO3lAFz.js} +1 -1
  67. package/storybook-static/assets/{form.test.stories-3tURbEdv.js → form.test.stories-ClYhj9F1.js} +1 -1
  68. package/storybook-static/assets/{formatter-2WMMO6ZP-6IvBq34u.js → formatter-2WMMO6ZP-C-UiBIma.js} +1 -1
  69. package/storybook-static/assets/http-request-DNq59pnj.js +1 -0
  70. package/storybook-static/assets/{http-request.stories-8K_qSs8C.js → http-request.stories-DCqY5s2i.js} +9 -9
  71. package/storybook-static/assets/iframe-CURpvmVV.js +2 -0
  72. package/storybook-static/assets/{index-DhXZyjEd.js → index-CKw1EbdP.js} +1 -1
  73. package/storybook-static/assets/{index-B3oZkK3F.js → index-DYpTqTNu.js} +1 -1
  74. package/storybook-static/assets/{index-C30JwJMK.js → index-DsWii_Ep.js} +5 -5
  75. package/storybook-static/assets/{local-storage.test.stories-CtisAQBB.js → local-storage.test.stories-BqgYwqr-.js} +1 -1
  76. package/storybook-static/assets/location-element-hKpcXCdn.js +1 -0
  77. package/storybook-static/assets/{location-element.test.stories-5O_t_m4Y.js → location-element.test.stories-DvH1TWK4.js} +9 -9
  78. package/storybook-static/assets/{preview-D0eCfQft.js → preview-DjDbQHPa.js} +2 -2
  79. package/storybook-static/assets/set-url.test.stories-GlJOh31I.js +81 -0
  80. package/storybook-static/assets/{slice-events.test.stories-BSXCLIA5.js → slice-events.test.stories-VoNjuPCX.js} +1 -1
  81. package/storybook-static/assets/{slots.test.stories-B1vqfHmN.js → slots.test.stories-Da2j9YuO.js} +1 -1
  82. package/storybook-static/assets/{syntaxhighlighter-BP7B2CQK-DpPBKyTO.js → syntaxhighlighter-BP7B2CQK-CDpEe51g.js} +1 -1
  83. package/storybook-static/assets/version-select.test.stories-DLwf-TPB.js +60 -0
  84. package/storybook-static/iframe.html +1 -1
  85. package/storybook-static/index.json +1 -1
  86. package/storybook-static/project.json +1 -1
  87. package/.idea/.gitignore +0 -8
  88. package/dist/custom-element-N-sWiqGK.cjs +0 -53
  89. package/dist/location-element-2m0gWq_d.cjs +0 -1
  90. package/dist/location-element-nA_wsqBt.js +0 -49
  91. package/storybook-static/assets/dom-merge.test.stories-BhbNeum_.js +0 -137
  92. package/storybook-static/assets/iframe-zdt9kuj6.js +0 -2
  93. package/yarn.lock +0 -10242
@@ -1,7 +1,13 @@
1
- const F = "http://www.w3.org/1999/XSL/Transform", q = "http://www.w3.org/1999/xhtml", se = "http://exslt.org/common", x = (e, l) => e.getAttribute?.(l), W = (e) => e.nodeType === 3, le = (e) => typeof e == "string", ne = (e) => e && typeof e.nodeType == "number", N = (e, l = "", t = document) => ((s) => (l && s.append(S(t.ownerDocument || t, l)), s))((t.ownerDocument || t).createElement(e)), S = (e, l) => (e.ownerDocument || e).createTextNode(l), K = (e) => {
1
+ const B = "http://www.w3.org/1999/XSL/Transform", q = "http://www.w3.org/1999/xhtml", ie = "http://exslt.org/common", x = (e, l) => e.getAttribute?.(l), Y = (e) => e.nodeType === 3, re = (e) => typeof e == "string", oe = (e) => e && typeof e.nodeType == "number", S = (e, l) => (e.ownerDocument || e).createTextNode(l), K = (e) => {
2
2
  for (; e.firstChild; ) e.firstChild.remove();
3
3
  return e;
4
- }, U = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), K(e)), ae = (e) => (e?.setAttribute("xmlns:xsl", F), e), ie = (e) => (e?.setAttribute("xmlns:xhtml", q), ae(e)), Y = (e, l) => {
4
+ }, U = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), K(e)), Q = (e) => (e?.setAttribute("xmlns:xsl", B), e), ee = (e) => (e?.setAttribute("xmlns:xhtml", q), Q(e)), te = (e) => /^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e), A = (e, l = "", t = document) => {
5
+ const s = (a) => ((o) => (l && o.append(S(t.ownerDocument || t, l)), o))((t.ownerDocument || t).createElement(a));
6
+ if (te(e))
7
+ return s(e);
8
+ const n = s("dce-object");
9
+ return n.setAttribute("dce-object-name", e), n;
10
+ }, G = (e, l) => {
5
11
  const t = e.ownerDocument.createElementNS(e.namespaceURI, l);
6
12
  for (let s of e.attributes)
7
13
  t.setAttribute(s.name, s.value);
@@ -16,44 +22,44 @@ function H(e) {
16
22
  return new XMLSerializer().serializeToString(e);
17
23
  }
18
24
  function X(e, l, t, s) {
19
- const n = (h) => e.ownerDocument.createElement(h), c = ((h, p, m) => (p.append(m = n(h)), m))(l, e);
20
- return [...t].forEach((h) => c.append(s(h))), c;
25
+ const n = (h) => e.ownerDocument.createElement(h), o = ((h, p, m) => (p.append(m = n(h)), m))(l, e);
26
+ return [...t].forEach((h) => o.append(s(h))), o;
21
27
  }
22
- function re(e) {
23
- return e.slot || (e.setAttribute || (e = N("span", e.textContent.replaceAll(`
28
+ function ce(e) {
29
+ return e.slot || (e.setAttribute || (e = A("span", e.textContent.replaceAll(`
24
30
  `, ""))), e.setAttribute("slot", "")), e;
25
31
  }
26
- function L(e, l, t) {
32
+ function D(e, l, t) {
27
33
  const s = typeof e;
28
34
  if (s === "string")
29
- return N(l, e, t);
35
+ return A(l, e, t);
30
36
  if (s === "number")
31
- return N(l, "" + e, t);
37
+ return A(l, "" + e, t);
32
38
  if (e instanceof Array) {
33
- const i = N("array", "", t);
34
- return e.map((c) => i.append(L(c, l, t))), i;
39
+ const a = A("array", "", t);
40
+ return e.map((o) => a.append(D(o, l, t))), a;
35
41
  }
36
42
  if (e instanceof FormData) {
37
- const i = N("form-data", "", t);
38
- for (const c of e)
39
- i.append(L(c[1], c[0], t));
40
- return i;
43
+ const a = A("form-data", "", t);
44
+ for (const o of e)
45
+ a.append(D(o[1], o[0], t));
46
+ return a;
41
47
  }
42
- const n = N(l, "", t);
43
- for (let i in e)
44
- ne(e[i]) || typeof e[i] == "function" || e[i] instanceof Window || (typeof e[i] != "object" ? n.setAttribute(i, e[i]) : n.append(L(e[i], i, t)));
48
+ const n = A(l, "", t);
49
+ for (let a in e)
50
+ oe(e[a]) || typeof e[a] == "function" || e[a] instanceof Window || (typeof e[a] != "object" && te(a) ? n.setAttribute(a, e[a]) : n.append(D(e[a], a, t)));
45
51
  return n;
46
52
  }
47
- function G(e) {
53
+ function Z(e) {
48
54
  if (C(e, "*", (l) => [...l.childNodes].filter((t) => t.nodeType === 3 && t.parentNode.localName !== "style" && t.data).forEach((t) => {
49
55
  const s = t.data, n = s.matchAll(/{([^}]*)}/g);
50
56
  if (n) {
51
- let i = 0, c = (p) => S(t, p), h = [];
57
+ let a = 0, o = (p) => S(t, p), h = [];
52
58
  if ([...n].forEach((p) => {
53
- p.index > i && h.push(c(p.input.substring(i, p.index)));
59
+ p.index > a && h.push(o(p.input.substring(a, p.index)));
54
60
  const m = e.querySelector("value-of").cloneNode();
55
- m.setAttribute("select", p[1]), h.push(m), i = p.index + p[0].length;
56
- }), i < s.length && h.push(c(s.substring(i, s.length))), h.length) {
61
+ m.setAttribute("select", p[1]), h.push(m), a = p.index + p[0].length;
62
+ }), a < s.length && h.push(o(s.substring(a, s.length))), h.length) {
57
63
  for (let p of h)
58
64
  l.insertBefore(p, t);
59
65
  l.removeChild(t);
@@ -66,10 +72,10 @@ function G(e) {
66
72
  }
67
73
  return e;
68
74
  }
69
- function oe(e, l = "xsl:stylesheet") {
75
+ function me(e, l = "xsl:stylesheet") {
70
76
  if (e.tagName === l || e.documentElement?.tagName === l)
71
- return G(e);
72
- const t = M(`<xsl:stylesheet version="1.0" xmlns:xsl="${F}" xmlns:xhtml="${q}" xmlns:exsl="${se}" exclude-result-prefixes="exsl" >
77
+ return Z(e);
78
+ const t = M(`<xsl:stylesheet version="1.0" xmlns:xsl="${B}" xmlns:xhtml="${q}" xmlns:exsl="${ie}" exclude-result-prefixes="exsl" >
73
79
  <xsl:output method="xml" />
74
80
  <xsl:template match="/"><dce-root xmlns="${q}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
75
81
  <xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
@@ -82,22 +88,22 @@ function oe(e, l = "xsl:stylesheet") {
82
88
  <xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
83
89
  <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
84
90
  <xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
85
- </xsl:stylesheet>`), s = new XSLTProcessor(), n = ((a) => {
86
- C(a, "script", (g) => g.remove());
87
- const o = a.content ?? a.firstElementChild?.content ?? a.body ?? a;
88
- xe.forEach((g) => C(o, g, (b) => ye(b, o)));
89
- const E = a.firstElementChild?.content || a.content, v = (g) => {
90
- const b = M("<xhtml/>"), $ = b.importNode(g, !0);
91
- return b.replaceChild($, b.documentElement), ie($);
91
+ </xsl:stylesheet>`), s = new XSLTProcessor(), n = ((i) => {
92
+ C(i, "script", (b) => b.remove());
93
+ const c = i.content ?? i.firstElementChild?.content ?? i.body ?? i;
94
+ ve.forEach((b) => C(c, b, (v) => ge(v, c)));
95
+ const E = i.firstElementChild?.content || i.content, g = (b) => {
96
+ const v = M("<xhtml/>"), $ = v.importNode(b, !0);
97
+ return v.replaceChild($, v.documentElement), ee($);
92
98
  };
93
99
  if (E) {
94
- const g = N("div");
95
- return [...E.childNodes].map((b) => g.append(b.cloneNode(!0))), v(g);
100
+ const b = A("div");
101
+ return [...E.childNodes].map((v) => b.append(v.cloneNode(!0))), g(b);
96
102
  }
97
- return v(a.documentElement || a.body || a);
98
- })(e), i = M(
103
+ return g(i.documentElement || i.body || i);
104
+ })(e), a = M(
99
105
  `<xsl:stylesheet version="1.0"
100
- xmlns:xsl="${F}"
106
+ xmlns:xsl="${B}"
101
107
  xmlns:xhtml="${q}"
102
108
  xmlns:dce="urn:schemas-epa-wg:dce"
103
109
  xmlns:exsl="http://exslt.org/common"
@@ -133,82 +139,82 @@ function oe(e, l = "xsl:stylesheet") {
133
139
  </xsl:stylesheet>`
134
140
  );
135
141
  s.importStylesheet(t);
136
- const c = s.transformToFragment(n, document), h = (a, o) => a.querySelector(o), p = h(i, 'template[mode="payload"]');
137
- if (!c)
142
+ const o = s.transformToFragment(n, document), h = (i, c) => i.querySelector(c), p = h(a, 'template[mode="payload"]');
143
+ if (!o)
138
144
  return console.error("transformation error", { xml: n.outerHTML, xsl: H(t) });
139
145
  const m = [];
140
- [...c.querySelectorAll("dce-root>attribute")].forEach((a) => {
141
- const o = Y(a, "xsl:param"), E = x(a, "name");
142
- p.append(o);
143
- let v = x(o, "select")?.split("??");
144
- v || (v = ["//" + E, `'${o.textContent}'`], U(o), o.setAttribute("name", E));
145
- let g;
146
- if (v?.length > 1) {
147
- o.removeAttribute("select");
148
- const b = h(i, 'template[match="ignore"]>choose').cloneNode(!0);
149
- U(b.firstElementChild).append(S(b, "{" + v[0] + "}")), U(b.lastElementChild).append(S(b, "{" + v[1] + "}")), b.firstElementChild.setAttribute("test", v[0]), o.append(b), g = b.cloneNode(!0);
146
+ [...o.querySelectorAll("dce-root>attribute")].forEach((i) => {
147
+ const c = G(i, "xsl:param"), E = x(i, "name");
148
+ p.append(c);
149
+ let g = x(c, "select")?.split("??");
150
+ g || (g = ["//" + E, `'${c.textContent}'`], U(c), c.setAttribute("name", E));
151
+ let b;
152
+ if (g?.length > 1) {
153
+ c.removeAttribute("select");
154
+ const v = h(a, 'template[match="ignore"]>choose').cloneNode(!0);
155
+ U(v.firstElementChild).append(S(v, "{" + g[0] + "}")), U(v.lastElementChild).append(S(v, "{" + g[1] + "}")), v.firstElementChild.setAttribute("test", g[0]), c.append(v), b = v.cloneNode(!0);
150
156
  } else
151
- g = Y(a, "xsl:value-of");
152
- g.removeAttribute("name"), a.append(g), a.removeAttribute("select"), m.push(o);
153
- }), [...c.querySelectorAll("[value]")].filter((a) => a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((a) => {
154
- const o = x(a, "value");
155
- o && a.setAttribute("value", he(o));
157
+ b = G(i, "xsl:value-of");
158
+ b.removeAttribute("name"), i.append(b), i.removeAttribute("select"), m.push(c);
159
+ }), [...o.querySelectorAll("[value]")].filter((i) => i.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((i) => {
160
+ const c = x(i, "value");
161
+ c && i.setAttribute("value", be(c));
156
162
  });
157
- for (const a of c.childNodes)
158
- p.append(i.importNode(a, !0));
159
- [...p.querySelectorAll("template")].forEach((a) => p.ownerDocument.documentElement.append(a));
160
- const P = h(i, 'call-template[name="slot"]'), d = (a) => {
161
- const o = P.cloneNode(!0), E = x(a, "name");
162
- E && o.firstElementChild.setAttribute("select", `'${E}'`);
163
- for (let v of a.childNodes)
164
- o.lastElementChild.append(v);
165
- return o;
163
+ for (const i of o.childNodes)
164
+ p.append(a.importNode(i, !0));
165
+ [...p.querySelectorAll("template")].forEach((i) => p.ownerDocument.documentElement.append(i));
166
+ const P = h(a, 'call-template[name="slot"]'), d = (i) => {
167
+ const c = P.cloneNode(!0), E = x(i, "name");
168
+ E && c.firstElementChild.setAttribute("select", `'${E}'`);
169
+ for (let g of i.childNodes)
170
+ c.lastElementChild.append(g);
171
+ return c;
166
172
  };
167
- C(p, "slot", (a) => a.parentNode.replaceChild(d(a), a));
168
- const u = G(i);
173
+ C(p, "slot", (i) => i.parentNode.replaceChild(d(i), i));
174
+ const u = Z(a);
169
175
  return u.params = m, u;
170
176
  }
171
- async function ce(e) {
177
+ async function ue(e) {
172
178
  return await new Promise((t, s) => {
173
179
  const n = new XMLHttpRequest();
174
180
  n.open("GET", e), n.responseType = "document", n.onload = () => {
175
- n.readyState === n.DONE && n.status === 200 && t(n.responseXML || N("div", n.responseText)), s(n.statusText);
176
- }, n.addEventListener("error", (i) => s(i)), n.send();
181
+ n.readyState === n.DONE && n.status === 200 && t(n.responseXML || A("div", n.responseText)), s(n.statusText);
182
+ }, n.addEventListener("error", (a) => s(a)), n.send();
177
183
  });
178
184
  }
179
- function me(e, l, t = !1) {
185
+ function de(e, l, t = !1) {
180
186
  if (e === l)
181
187
  return !0;
182
188
  if (typeof e != "object" || e === null || typeof l != "object" || l === null || Object.keys(e).length !== Object.keys(l).length)
183
189
  return t;
184
190
  for (let s in e)
185
- if (!(s in l) || !me(e[s], l[s]))
191
+ if (!(s in l) || !de(e[s], l[s]))
186
192
  return t;
187
193
  return !0;
188
194
  }
189
- const Q = (e) => e.split("|").map((l) => l.trim()).filter((l) => l), ue = (e, l) => Q(l).map((t) => {
190
- let s = e.ownerDocument, n = (i) => (e.append(i), i);
195
+ const se = (e) => e.split("|").map((l) => l.trim()).filter((l) => l), pe = (e, l) => se(l).map((t) => {
196
+ let s = e.ownerDocument, n = (a) => (e.append(a), a);
191
197
  if (t.includes("/")) {
192
- const i = [], c = s.evaluate(t, e);
193
- for (let h; h = c.iterateNext(); )
194
- i.push(h);
195
- return i;
198
+ const a = [], o = s.evaluate(t, e);
199
+ for (let h; h = o.iterateNext(); )
200
+ a.push(h);
201
+ return a;
196
202
  }
197
- return [...e.childNodes].find((i) => i.localName === t) || n(N(t, "", s));
203
+ return [...e.childNodes].find((a) => a.localName === t) || n(A(t, "", s));
198
204
  }).flat();
199
205
  function J(e, l, t, s) {
200
206
  if (!t.sliceProcessed)
201
- return t.sliceProcessed = 1, ue(e, l ?? "").map((n) => {
202
- const i = e.ownerDocument, c = t.sliceEventSource, h = t.sliceElement, p = () => [...n.childNodes].filter((m) => m.nodeType === 3 || m.localName === "value" || m.localName === "form-data").map((m) => m.remove());
203
- if (c.getAttributeNames().map((m) => n.setAttribute(m, x(c, m))), [...n.childNodes].filter((m) => m.localName === "event").map((m) => m.remove()), "validationMessage" in c && n.setAttribute("validation-message", c.validationMessage), t.type === "init" && p(), n.append(L(t, "event", i)), h.hasAttribute("slice-value")) {
204
- c.value === void 0 ? n.removeAttribute("value") : n.setAttribute("value", c.value);
205
- const m = D(x(h, "slice-value"), n);
206
- p(), n.append(S(i, m));
207
+ return t.sliceProcessed = 1, pe(e, l ?? "").map((n) => {
208
+ const a = e.ownerDocument, o = t.sliceEventSource, h = t.sliceElement, p = () => [...n.childNodes].filter((m) => m.nodeType === 3 || m.localName === "value" || m.localName === "form-data").map((m) => m.remove());
209
+ if (o.getAttributeNames().map((m) => n.setAttribute(m, x(o, m))), [...n.childNodes].filter((m) => m.localName === "event").map((m) => m.remove()), "validationMessage" in o && n.setAttribute("validation-message", o.validationMessage), t.type === "init" && p(), n.append(D(t, "event", a)), h.hasAttribute("slice-value")) {
210
+ o.value === void 0 ? n.removeAttribute("value") : n.setAttribute("value", o.value);
211
+ const m = L(x(h, "slice-value"), n);
212
+ p(), n.append(S(a, m));
207
213
  } else {
208
- if ("elements" in c)
209
- return p(), n.append(L(new FormData(c), "value", n.ownerDocument)), n;
210
- const m = c.value ?? x(h, "value");
211
- p(), m == null ? [...n.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()) : le(m) ? n.append(S(i, m)) : n.append(L(m, "value", n.ownerDocument));
214
+ if ("elements" in o)
215
+ return p(), n.append(D(new FormData(o), "value", n.ownerDocument)), n;
216
+ const m = o.value ?? x(h, "value");
217
+ p(), m == null ? [...n.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()) : re(m) ? n.append(S(a, m)) : n.append(D(m, "value", n.ownerDocument));
212
218
  }
213
219
  return n;
214
220
  });
@@ -216,7 +222,7 @@ function J(e, l, t, s) {
216
222
  function C(e, l, t) {
217
223
  e.querySelectorAll && [...e.querySelectorAll(l)].forEach(t);
218
224
  }
219
- const de = async (e, l) => {
225
+ const fe = async (e, l) => {
220
226
  if (!e || !e.trim())
221
227
  return [l];
222
228
  if (e.startsWith("#"))
@@ -229,7 +235,7 @@ const de = async (e, l) => {
229
235
  return n === t ? [] : getByHashId(n);
230
236
  })(l.parentElement);
231
237
  try {
232
- const t = await ce(e), s = new URL(e, location).hash;
238
+ const t = await ue(e), s = new URL(e, location).hash;
233
239
  if (s) {
234
240
  const n = t.querySelectorAll(s);
235
241
  return n.length ? [...n] : [l];
@@ -239,49 +245,56 @@ const de = async (e, l) => {
239
245
  return [l];
240
246
  }
241
247
  };
242
- function pe(e, l) {
248
+ function he(e, l) {
243
249
  for (let t of e.attributes)
244
250
  t.namespaceURI ? l.setAttributeNS(t.namespaceURI, t.name, t.value) : l.setAttribute(t.name, t.value), t.name === "value" && (l.value = t.value);
245
251
  }
246
- function Z(e, l = 0) {
252
+ function le(e, l = 0) {
247
253
  const t = {};
248
254
  for (const s of e.childNodes) {
249
255
  const n = x(s, "data-dce-id") || s.dceId || 0;
250
256
  if (!t[n])
251
257
  n ? t[n] = 1 : (t[n] = s.dceId = ++l, s.setAttribute && s.setAttribute("data-dce-id", s.dceId));
252
258
  else {
253
- const i = s.dceId = n + "-" + t[n]++;
254
- s.setAttribute && s.setAttribute("data-dce-id", i);
259
+ const a = s.dceId = n + "-" + t[n]++;
260
+ s.setAttribute && s.setAttribute("data-dce-id", a);
255
261
  }
256
- s.childNodes.length && Z(s);
262
+ s.childNodes.length && le(s);
257
263
  }
258
264
  }
259
- function ee(e, l) {
265
+ function xe(e, l, t) {
266
+ t = 1 * t;
267
+ for (let s of e.childNodes)
268
+ if ((s.dceId ?? s.getAttribute("data-dce-id") * 1) > t)
269
+ return e.insertBefore(l, s);
270
+ e.append(l);
271
+ }
272
+ function ne(e, l) {
260
273
  if (!l.length)
261
274
  return K(e);
262
275
  const t = {};
263
276
  for (let s of e.childNodes)
264
- t[s.dceId], W(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[x(s, "data-dce-id") || 0] = s;
277
+ t[s.dceId], Y(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[x(s, "data-dce-id") || 0] = s;
265
278
  for (let s of [...l]) {
266
- const n = x(s, "data-dce-id") || s.dceId, i = t[n];
267
- i ? (W(s) ? i.nodeValue !== s.nodeValue && (i.nodeValue = s.nodeValue) : (pe(s, i), (i.childNodes.length || s.childNodes.length) && ee(i, s.childNodes)), delete t[n]) : e.append(s);
279
+ const n = x(s, "data-dce-id") || s.dceId, a = t[n];
280
+ a ? (Y(s) ? a.nodeValue !== s.nodeValue && (a.nodeValue = s.nodeValue) : (he(s, a), (a.childNodes.length || s.childNodes.length) && ne(a, s.childNodes)), delete t[n]) : xe(e, s, n);
268
281
  }
269
282
  for (let s of Object.values(t))
270
283
  s.remove();
271
284
  }
272
- function fe(e, l) {
285
+ function ye(e, l) {
273
286
  return e.hasAttribute(l) || e.setAttribute(l, crypto.randomUUID()), e.getAttribute(l);
274
287
  }
275
- const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${B(t[3])}}${t[4]}`).join(""), B = (e) => {
288
+ const be = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${F(t[3])}}${t[4]}`).join(""), F = (e) => {
276
289
  if (!e.trim())
277
290
  return e;
278
- const l = e.split("??"), t = l.shift(), s = B(l.join("??"));
291
+ const l = e.split("??"), t = l.shift(), s = F(l.join("??"));
279
292
  return l.length ? `concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )` : e;
280
- }, D = (e, l) => {
293
+ }, L = (e, l) => {
281
294
  const t = e.split("??");
282
295
  if (t.length > 1)
283
- return D(t[0], l) || D(t[1], l);
284
- e = B(e);
296
+ return L(t[0], l) || L(t[1], l);
297
+ e = F(e);
285
298
  const s = l.ownerDocument.evaluate(e, l);
286
299
  switch (s.resultType) {
287
300
  case XPathResult.NUMBER_TYPE:
@@ -292,11 +305,11 @@ const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
292
305
  return s.booleanValue;
293
306
  }
294
307
  let n = "";
295
- for (let i; i = s.iterateNext(); )
296
- n += i.textContent;
308
+ for (let a; a = s.iterateNext(); )
309
+ n += a.textContent;
297
310
  return n;
298
- }, xe = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","), ye = (e, l) => {
299
- const t = N("xsl:" + e.localName);
311
+ }, ve = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","), ge = (e, l) => {
312
+ const t = A("xsl:" + e.localName);
300
313
  for (let s of e.attributes)
301
314
  t.setAttribute(s.name, s.value);
302
315
  for (; e.firstChild; )
@@ -305,24 +318,24 @@ const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
305
318
  e.parentElement.replaceChild(t, e);
306
319
  else {
307
320
  const s = e.parentElement || l, n = [...s.childNodes];
308
- n.forEach((i, c) => {
309
- i === e && (n[c] = t);
321
+ n.forEach((a, o) => {
322
+ a === e && (n[o] = t);
310
323
  }), s.replaceChildren(...n);
311
324
  }
312
325
  };
313
- class be extends HTMLElement {
326
+ class Ee extends HTMLElement {
314
327
  static observedAttributes = ["src", "tag", "hidden"];
315
328
  async connectedCallback() {
316
- const l = await de(x(this, "src"), this), t = x(this, "tag"), s = t || "dce-" + crypto.randomUUID();
329
+ const l = await fe(x(this, "src"), this), t = x(this, "tag"), s = t || "dce-" + crypto.randomUUID();
317
330
  for (const d of l)
318
331
  C(d.templateNode || d.content || d, "style", (u) => {
319
- const a = u.closest("slot"), o = a ? `slot[name="${a.name}"]` : "";
320
- u.innerHTML = `${s} ${o}{${u.innerHTML}}`, this.append(u);
332
+ const i = u.closest("slot"), c = i ? `slot[name="${i.name}"]` : "";
333
+ u.innerHTML = `${s} ${c}{${u.innerHTML}}`, this.append(u);
321
334
  });
322
- const n = l.map((d) => oe(d)), i = n.map((d, u) => (u = new XSLTProcessor(), u.importStylesheet(d), u));
335
+ const n = l.map((d) => me(d)), a = n.map((d, u) => (u = new XSLTProcessor(), u.importStylesheet(d), u));
323
336
  Object.defineProperty(this, "xsltString", { get: () => n.map((d) => H(d)).join(`
324
337
  `) });
325
- const c = this, h = [...this.templateNode.querySelectorAll("[slice]")], p = h.map((d) => x(d, "slice")).filter((d) => !d.includes("/")).filter((d, u, a) => a.indexOf(d) === u).map(Q).flat(), m = n.reduce((d, u) => (u.params && d.push(...u.params), d), []);
338
+ const o = this, h = [...this.templateNode.querySelectorAll("[slice]")], p = h.map((d) => x(d, "slice")).filter((d) => !d.includes("/")).filter((d, u, i) => i.indexOf(d) === u).map(se).flat(), m = n.reduce((d, u) => (u.params && d.push(...u.params), d), []);
326
339
  class w extends HTMLElement {
327
340
  static get observedAttributes() {
328
341
  return m.map((u) => x(u, "name"));
@@ -336,42 +349,42 @@ class be extends HTMLElement {
336
349
  f.remove(), u = f.content.childNodes;
337
350
  for (const r of [...f.content.childNodes])
338
351
  if (r.localName === "style") {
339
- const y = fe(this, "data-dce-style");
352
+ const y = ye(this, "data-dce-style");
340
353
  r.innerHTML = `${s}[data-dce-style="${y}"]{${r.innerHTML}}`, f.insertAdjacentElement("beforebegin", r);
341
354
  } else
342
355
  r.nodeType === 1 ? f.insertAdjacentElement("beforebegin", r) : r.nodeType === 3 && f.insertAdjacentText("beforebegin", r.data);
343
356
  }
344
- const a = M("<datadom/>").documentElement, o = (f, r = "") => ((y) => (r && y.append(S(a, r)), y))(a.ownerDocument.createElement(f));
345
- X(a, "payload", u, re), this.innerHTML = "";
346
- const E = X(a, "attributes", this.attributes, (f) => o(f.nodeName, f.value));
347
- X(a, "dataset", Object.keys(this.dataset), (f) => o(f, this.dataset[f]));
348
- const v = X(a, "slice", p, (f) => o(f, "")), g = (f) => D(f, v);
349
- this.xml = a;
350
- const b = [], $ = () => {
357
+ const i = M("<datadom/>").documentElement, c = (f, r = "") => ((y) => (r && y.append(S(i, r)), y))(i.ownerDocument.createElement(f)), E = X(i, "payload", u, ce);
358
+ Q(E), ee(E), this.innerHTML = "";
359
+ const g = X(i, "attributes", this.attributes, (f) => c(f.nodeName, f.value));
360
+ X(i, "dataset", Object.keys(this.dataset), (f) => c(f, this.dataset[f]));
361
+ const b = X(i, "slice", p, (f) => c(f, "")), v = (f) => L(f, b);
362
+ this.xml = i;
363
+ const $ = [], W = () => {
351
364
  const f = {};
352
- for (let r; r = b.pop(); ) {
365
+ for (let r; r = $.pop(); ) {
353
366
  const y = x(r.sliceElement, "slice");
354
- f[y] || (J(v, y, r), f[y] = r);
367
+ f[y] || (J(b, y, r), f[y] = r);
355
368
  }
356
- Object.keys(f).length !== 0 && R();
369
+ Object.keys(f).length !== 0 && I();
357
370
  };
358
- let k;
371
+ let V;
359
372
  this.onSlice = (f) => {
360
- b.push(f), k || (k = setTimeout(() => {
361
- $(), k = 0;
373
+ $.push(f), V || (V = setTimeout(() => {
374
+ W(), V = 0;
362
375
  }, 1));
363
376
  };
364
- const R = this.transform = () => {
377
+ const I = this.transform = () => {
365
378
  if (this.#e)
366
379
  debugger;
367
- this.#e = 1, i.map((r, y) => {
368
- const I = r.transformToFragment(a.ownerDocument, document);
369
- return I || console.error(`XSLT transformation error. xsl:
380
+ this.#e = 1, a.map((r, y) => {
381
+ const R = r.transformToFragment(i.ownerDocument, document);
382
+ return R || console.error(`XSLT transformation error. xsl:
370
383
  `, H(n[y]), `
371
384
  xml:
372
- `, H(a)), I;
385
+ `, H(i)), R;
373
386
  }).map((r) => {
374
- r && (Z(r), ee(this, r.childNodes));
387
+ r && (le(r), ne(this, r.childNodes));
375
388
  }), w.observedAttributes.map((r) => {
376
389
  let y = x(this.firstElementChild, r);
377
390
  y !== x(this, r) && (this.setAttribute(r, y), this.#t(r, y));
@@ -379,42 +392,42 @@ xml:
379
392
  if (!r.dceInitialized) {
380
393
  r.dceInitialized = 1;
381
394
  let y = x(r, "slice-event");
382
- x(r, "custom-validity") && (y += " change submit"), [...new Set((y || "change").split(" "))].forEach((I) => (r.localName === "slice" ? r.parentElement : r).addEventListener(I, (A) => {
383
- A.sliceElement = r, A.sliceEventSource = A.currentTarget || A.target;
384
- const te = J(v, x(A.sliceElement, "slice"), A);
395
+ r.hasAttribute("custom-validity") && (y += " change submit"), [...new Set((y || "change").split(" "))].forEach((R) => (r.localName === "slice" ? r.parentElement : r).addEventListener(R, (N) => {
396
+ N.sliceElement = r, N.sliceEventSource = N.currentTarget || N.target;
397
+ const ae = J(b, x(N.sliceElement, "slice"), N);
385
398
  C(this, "[custom-validity]", (z) => {
386
399
  if (!z.setCustomValidity)
387
400
  return;
388
401
  const _ = x(z, "custom-validity");
389
402
  try {
390
- const j = _ && D(_, E);
403
+ const j = _ && L(_, g);
391
404
  z.setCustomValidity(j === !0 ? "" : j === !1 ? "invalid" : j);
392
405
  } catch (j) {
393
406
  console.error(j, "xPath", _);
394
407
  }
395
408
  });
396
- const V = x(r, "custom-validity"), T = V && D(V, E), O = T === !0 ? "" : T;
397
- if (V) {
398
- if (r.setCustomValidity ? r.setCustomValidity(O) : r.validationMessage = O, te.map((z) => z.setAttribute("validation-message", O)), A.type === "submit")
399
- return T === !0 ? void 0 : (setTimeout(R, 1), !!T === T ? (T || A.preventDefault(), T) : T ? (A.preventDefault(), !1) : void 0);
400
- setTimeout(R, 1);
409
+ const k = x(r, "custom-validity"), T = k && L(k, g), O = T === !0 ? "" : T;
410
+ if (k) {
411
+ if (r.setCustomValidity ? r.setCustomValidity(O) : r.validationMessage = O, ae.map((z) => z.setAttribute("validation-message", O)), N.type === "submit")
412
+ return T === !0 ? void 0 : (setTimeout(I, 1), !!T === T ? (T || N.preventDefault(), T) : T ? (N.preventDefault(), !1) : void 0);
413
+ setTimeout(I, 1);
401
414
  }
402
- this.onSlice(A);
403
- })), (!y || y.includes("init")) && (r.hasAttribute("slice-value") || r.hasAttribute("value") || r.value ? this.onSlice({ type: "init", target: r, sliceElement: r, sliceEventSource: r }) : r.value = g(x(r, "slice")));
415
+ this.onSlice(N);
416
+ })), (!y || y.includes("init")) && (r.hasAttribute("slice-value") || r.hasAttribute("value") || r.value ? this.onSlice({ type: "init", target: r, sliceElement: r, sliceEventSource: r }) : r.value = v(x(r, "slice")));
404
417
  }
405
418
  }), this.#e = 0;
406
419
  };
407
- R(), $();
420
+ I(), W();
408
421
  }
409
- #t(u, a) {
410
- let o = this.xml.querySelector(`attributes>${u}`);
411
- o ? U(o).append(S(o, a)) : (o = N(u, a, this.xml), this.xml.querySelector("attributes").append(o));
422
+ #t(u, i) {
423
+ let c = this.xml.querySelector(`attributes>${u}`);
424
+ c ? U(c).append(S(c, i)) : (c = A(u, i, this.xml), this.xml.querySelector("attributes").append(c));
412
425
  }
413
- attributeChangedCallback(u, a, o) {
414
- !this.xml || this.#e || (this.#t(u, o), this.transform());
426
+ attributeChangedCallback(u, i, c) {
427
+ !this.xml || this.#e || (this.#t(u, c), this.transform());
415
428
  }
416
429
  get dce() {
417
- return c;
430
+ return o;
418
431
  }
419
432
  }
420
433
  const P = (d) => {
@@ -426,7 +439,7 @@ xml:
426
439
  const d = s;
427
440
  this.setAttribute("tag", d), P(d);
428
441
  const u = document.createElement(d);
429
- this.getAttributeNames().forEach((a) => u.setAttribute(a, this.getAttribute(a))), u.append(...[...this.childNodes].filter((a) => a.localName !== "style")), this.append(u);
442
+ this.getAttributeNames().forEach((i) => u.setAttribute(i, this.getAttribute(i))), u.append(...[...this.childNodes].filter((i) => i.localName !== "style")), this.append(u);
430
443
  }
431
444
  }
432
445
  get templateNode() {
@@ -439,25 +452,26 @@ xml:
439
452
  return M(this.xsltString);
440
453
  }
441
454
  }
442
- window.customElements.define("custom-element", be);
455
+ window.customElements.define("custom-element", Ee);
443
456
  export {
444
- be as C,
457
+ Ee as C,
445
458
  H as a,
446
- ce as b,
447
- oe as c,
448
- me as d,
449
- ue as e,
459
+ ue as b,
460
+ me as c,
461
+ de as d,
462
+ pe as e,
450
463
  J as f,
451
- Z as g,
452
- ee as h,
453
- fe as i,
454
- he as j,
455
- B as k,
456
- D as l,
457
- pe as m,
458
- xe as n,
459
- L as o,
460
- ye as p,
461
- G as t,
464
+ le as g,
465
+ xe as h,
466
+ ne as i,
467
+ ye as j,
468
+ be as k,
469
+ F as l,
470
+ he as m,
471
+ L as n,
472
+ D as o,
473
+ ve as p,
474
+ ge as q,
475
+ Z as t,
462
476
  M as x
463
477
  };