thunderous 0.6.3 → 1.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.
package/dist/index.js CHANGED
@@ -1,19 +1,438 @@
1
- // src/html-helpers.ts
2
- var clearHTML = (element) => {
3
- while (element.childNodes.length > 0) {
4
- element.childNodes[0].remove();
1
+ // vendor/@webcomponents/scoped-custom-element-registry/src/scoped-custom-element-registry.js
2
+ if (typeof window !== "undefined") {
3
+ if (!ShadowRoot.prototype.createElement) {
4
+ const NativeHTMLElement = window.HTMLElement;
5
+ const nativeDefine = window.customElements.define;
6
+ const nativeGet = window.customElements.get;
7
+ const nativeRegistry = window.customElements;
8
+ const definitionForElement = /* @__PURE__ */ new WeakMap();
9
+ const pendingRegistryForElement = /* @__PURE__ */ new WeakMap();
10
+ const globalDefinitionForConstructor = /* @__PURE__ */ new WeakMap();
11
+ const scopeForElement = /* @__PURE__ */ new WeakMap();
12
+ window.CustomElementRegistry = class {
13
+ constructor() {
14
+ this._definitionsByTag = /* @__PURE__ */ new Map();
15
+ this._definitionsByClass = /* @__PURE__ */ new Map();
16
+ this._whenDefinedPromises = /* @__PURE__ */ new Map();
17
+ this._awaitingUpgrade = /* @__PURE__ */ new Map();
18
+ }
19
+ define(tagName, elementClass) {
20
+ tagName = tagName.toLowerCase();
21
+ if (this._getDefinition(tagName) !== void 0) {
22
+ throw new DOMException(
23
+ `Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`
24
+ );
25
+ }
26
+ if (this._definitionsByClass.get(elementClass) !== void 0) {
27
+ throw new DOMException(
28
+ `Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`
29
+ );
30
+ }
31
+ const attributeChangedCallback = elementClass.prototype.attributeChangedCallback;
32
+ const observedAttributes = new Set(elementClass.observedAttributes || []);
33
+ patchAttributes(
34
+ elementClass,
35
+ observedAttributes,
36
+ attributeChangedCallback
37
+ );
38
+ const definition = {
39
+ elementClass,
40
+ connectedCallback: elementClass.prototype.connectedCallback,
41
+ disconnectedCallback: elementClass.prototype.disconnectedCallback,
42
+ adoptedCallback: elementClass.prototype.adoptedCallback,
43
+ attributeChangedCallback,
44
+ "formAssociated": elementClass["formAssociated"],
45
+ "formAssociatedCallback": elementClass.prototype["formAssociatedCallback"],
46
+ "formDisabledCallback": elementClass.prototype["formDisabledCallback"],
47
+ "formResetCallback": elementClass.prototype["formResetCallback"],
48
+ "formStateRestoreCallback": elementClass.prototype["formStateRestoreCallback"],
49
+ observedAttributes
50
+ };
51
+ this._definitionsByTag.set(tagName, definition);
52
+ this._definitionsByClass.set(elementClass, definition);
53
+ let standInClass = nativeGet.call(nativeRegistry, tagName);
54
+ if (!standInClass) {
55
+ standInClass = createStandInElement(tagName);
56
+ nativeDefine.call(nativeRegistry, tagName, standInClass);
57
+ }
58
+ if (this === window.customElements) {
59
+ globalDefinitionForConstructor.set(elementClass, definition);
60
+ definition.standInClass = standInClass;
61
+ }
62
+ const awaiting = this._awaitingUpgrade.get(tagName);
63
+ if (awaiting) {
64
+ this._awaitingUpgrade.delete(tagName);
65
+ for (const element of awaiting) {
66
+ pendingRegistryForElement.delete(element);
67
+ customize(element, definition, true);
68
+ }
69
+ }
70
+ const info = this._whenDefinedPromises.get(tagName);
71
+ if (info !== void 0) {
72
+ info.resolve(elementClass);
73
+ this._whenDefinedPromises.delete(tagName);
74
+ }
75
+ return elementClass;
76
+ }
77
+ upgrade() {
78
+ creationContext.push(this);
79
+ nativeRegistry.upgrade.apply(nativeRegistry, arguments);
80
+ creationContext.pop();
81
+ }
82
+ get(tagName) {
83
+ const definition = this._definitionsByTag.get(tagName);
84
+ return definition?.elementClass;
85
+ }
86
+ _getDefinition(tagName) {
87
+ return this._definitionsByTag.get(tagName);
88
+ }
89
+ whenDefined(tagName) {
90
+ const definition = this._getDefinition(tagName);
91
+ if (definition !== void 0) {
92
+ return Promise.resolve(definition.elementClass);
93
+ }
94
+ let info = this._whenDefinedPromises.get(tagName);
95
+ if (info === void 0) {
96
+ info = {};
97
+ info.promise = new Promise((r) => info.resolve = r);
98
+ this._whenDefinedPromises.set(tagName, info);
99
+ }
100
+ return info.promise;
101
+ }
102
+ _upgradeWhenDefined(element, tagName, shouldUpgrade) {
103
+ let awaiting = this._awaitingUpgrade.get(tagName);
104
+ if (!awaiting) {
105
+ this._awaitingUpgrade.set(tagName, awaiting = /* @__PURE__ */ new Set());
106
+ }
107
+ if (shouldUpgrade) {
108
+ awaiting.add(element);
109
+ } else {
110
+ awaiting.delete(element);
111
+ }
112
+ }
113
+ };
114
+ let upgradingInstance;
115
+ window.HTMLElement = function HTMLElement2() {
116
+ let instance = upgradingInstance;
117
+ if (instance) {
118
+ upgradingInstance = void 0;
119
+ return instance;
120
+ }
121
+ const definition = globalDefinitionForConstructor.get(this.constructor);
122
+ if (!definition) {
123
+ throw new TypeError(
124
+ "Illegal constructor (custom element class must be registered with global customElements registry to be newable)"
125
+ );
126
+ }
127
+ instance = Reflect.construct(
128
+ NativeHTMLElement,
129
+ [],
130
+ definition.standInClass
131
+ );
132
+ Object.setPrototypeOf(instance, this.constructor.prototype);
133
+ definitionForElement.set(instance, definition);
134
+ return instance;
135
+ };
136
+ window.HTMLElement.prototype = NativeHTMLElement.prototype;
137
+ const isValidScope = (node) => node === document || node instanceof ShadowRoot;
138
+ const registryForNode = (node) => {
139
+ let scope = node.getRootNode();
140
+ if (!isValidScope(scope)) {
141
+ const context = creationContext[creationContext.length - 1];
142
+ if (context instanceof CustomElementRegistry) {
143
+ return context;
144
+ }
145
+ scope = context.getRootNode();
146
+ if (!isValidScope(scope)) {
147
+ scope = scopeForElement.get(scope)?.getRootNode() || document;
148
+ }
149
+ }
150
+ return scope.customElements;
151
+ };
152
+ const createStandInElement = (tagName) => {
153
+ return class ScopedCustomElementBase {
154
+ static get ["formAssociated"]() {
155
+ return true;
156
+ }
157
+ constructor() {
158
+ const instance = Reflect.construct(
159
+ NativeHTMLElement,
160
+ [],
161
+ this.constructor
162
+ );
163
+ Object.setPrototypeOf(instance, HTMLElement.prototype);
164
+ const registry = registryForNode(instance) || window.customElements;
165
+ const definition = registry._getDefinition(tagName);
166
+ if (definition) {
167
+ customize(instance, definition);
168
+ } else {
169
+ pendingRegistryForElement.set(instance, registry);
170
+ }
171
+ return instance;
172
+ }
173
+ connectedCallback() {
174
+ const definition = definitionForElement.get(this);
175
+ if (definition) {
176
+ definition.connectedCallback && definition.connectedCallback.apply(this, arguments);
177
+ } else {
178
+ pendingRegistryForElement.get(this)._upgradeWhenDefined(this, tagName, true);
179
+ }
180
+ }
181
+ disconnectedCallback() {
182
+ const definition = definitionForElement.get(this);
183
+ if (definition) {
184
+ definition.disconnectedCallback && definition.disconnectedCallback.apply(this, arguments);
185
+ } else {
186
+ pendingRegistryForElement.get(this)._upgradeWhenDefined(this, tagName, false);
187
+ }
188
+ }
189
+ adoptedCallback() {
190
+ const definition = definitionForElement.get(this);
191
+ definition?.adoptedCallback?.apply(this, arguments);
192
+ }
193
+ // Form-associated custom elements lifecycle methods
194
+ ["formAssociatedCallback"]() {
195
+ const definition = definitionForElement.get(this);
196
+ if (definition && definition["formAssociated"]) {
197
+ definition?.["formAssociatedCallback"]?.apply(this, arguments);
198
+ }
199
+ }
200
+ ["formDisabledCallback"]() {
201
+ const definition = definitionForElement.get(this);
202
+ if (definition?.["formAssociated"]) {
203
+ definition?.["formDisabledCallback"]?.apply(this, arguments);
204
+ }
205
+ }
206
+ ["formResetCallback"]() {
207
+ const definition = definitionForElement.get(this);
208
+ if (definition?.["formAssociated"]) {
209
+ definition?.["formResetCallback"]?.apply(this, arguments);
210
+ }
211
+ }
212
+ ["formStateRestoreCallback"]() {
213
+ const definition = definitionForElement.get(this);
214
+ if (definition?.["formAssociated"]) {
215
+ definition?.["formStateRestoreCallback"]?.apply(this, arguments);
216
+ }
217
+ }
218
+ // no attributeChangedCallback or observedAttributes since these
219
+ // are simulated via setAttribute/removeAttribute patches
220
+ };
221
+ };
222
+ const patchAttributes = (elementClass, observedAttributes, attributeChangedCallback) => {
223
+ if (observedAttributes.size === 0 || attributeChangedCallback === void 0) {
224
+ return;
225
+ }
226
+ const setAttribute = elementClass.prototype.setAttribute;
227
+ if (setAttribute) {
228
+ elementClass.prototype.setAttribute = function(n, value) {
229
+ const name = n.toLowerCase();
230
+ if (observedAttributes.has(name)) {
231
+ const old = this.getAttribute(name);
232
+ setAttribute.call(this, name, value);
233
+ attributeChangedCallback.call(this, name, old, value);
234
+ } else {
235
+ setAttribute.call(this, name, value);
236
+ }
237
+ };
238
+ }
239
+ const removeAttribute = elementClass.prototype.removeAttribute;
240
+ if (removeAttribute) {
241
+ elementClass.prototype.removeAttribute = function(n) {
242
+ const name = n.toLowerCase();
243
+ if (observedAttributes.has(name)) {
244
+ const old = this.getAttribute(name);
245
+ removeAttribute.call(this, name);
246
+ attributeChangedCallback.call(this, name, old, null);
247
+ } else {
248
+ removeAttribute.call(this, name);
249
+ }
250
+ };
251
+ }
252
+ const toggleAttribute = elementClass.prototype.toggleAttribute;
253
+ if (toggleAttribute) {
254
+ elementClass.prototype.toggleAttribute = function(n, force) {
255
+ const name = n.toLowerCase();
256
+ if (observedAttributes.has(name)) {
257
+ const old = this.getAttribute(name);
258
+ toggleAttribute.call(this, name, force);
259
+ const newValue = this.getAttribute(name);
260
+ attributeChangedCallback.call(this, name, old, newValue);
261
+ } else {
262
+ toggleAttribute.call(this, name, force);
263
+ }
264
+ };
265
+ }
266
+ };
267
+ const patchHTMLElement = (elementClass) => {
268
+ const parentClass = Object.getPrototypeOf(elementClass);
269
+ if (parentClass !== window.HTMLElement) {
270
+ if (parentClass === NativeHTMLElement) {
271
+ return Object.setPrototypeOf(elementClass, window.HTMLElement);
272
+ }
273
+ return patchHTMLElement(parentClass);
274
+ }
275
+ };
276
+ const customize = (instance, definition, isUpgrade = false) => {
277
+ Object.setPrototypeOf(instance, definition.elementClass.prototype);
278
+ definitionForElement.set(instance, definition);
279
+ upgradingInstance = instance;
280
+ try {
281
+ new definition.elementClass();
282
+ } catch (_) {
283
+ patchHTMLElement(definition.elementClass);
284
+ new definition.elementClass();
285
+ }
286
+ if (definition.attributeChangedCallback) {
287
+ definition.observedAttributes.forEach((attr) => {
288
+ if (instance.hasAttribute(attr)) {
289
+ definition.attributeChangedCallback.call(
290
+ instance,
291
+ attr,
292
+ null,
293
+ instance.getAttribute(attr)
294
+ );
295
+ }
296
+ });
297
+ }
298
+ if (isUpgrade && definition.connectedCallback && instance.isConnected) {
299
+ definition.connectedCallback.call(instance);
300
+ }
301
+ };
302
+ const nativeAttachShadow = Element.prototype.attachShadow;
303
+ Element.prototype.attachShadow = function(init) {
304
+ const shadowRoot = nativeAttachShadow.apply(this, arguments);
305
+ if (init.customElements) {
306
+ shadowRoot.customElements = init.customElements;
307
+ }
308
+ return shadowRoot;
309
+ };
310
+ let creationContext = [document];
311
+ const installScopedCreationMethod = (ctor, method, from = void 0) => {
312
+ const native = (from ? Object.getPrototypeOf(from) : ctor.prototype)[method];
313
+ ctor.prototype[method] = function() {
314
+ creationContext.push(this);
315
+ const ret = native.apply(from || this, arguments);
316
+ if (ret !== void 0) {
317
+ scopeForElement.set(ret, this);
318
+ }
319
+ creationContext.pop();
320
+ return ret;
321
+ };
322
+ };
323
+ installScopedCreationMethod(ShadowRoot, "createElement", document);
324
+ installScopedCreationMethod(ShadowRoot, "importNode", document);
325
+ installScopedCreationMethod(Element, "insertAdjacentHTML");
326
+ installScopedCreationMethod(Node, "appendChild");
327
+ installScopedCreationMethod(Element, "append");
328
+ const installScopedCreationSetter = (ctor, name) => {
329
+ const descriptor = Object.getOwnPropertyDescriptor(ctor.prototype, name);
330
+ Object.defineProperty(ctor.prototype, name, {
331
+ ...descriptor,
332
+ set(value) {
333
+ creationContext.push(this);
334
+ descriptor.set.call(this, value);
335
+ creationContext.pop();
336
+ }
337
+ });
338
+ };
339
+ installScopedCreationSetter(Element, "innerHTML");
340
+ installScopedCreationSetter(ShadowRoot, "innerHTML");
341
+ Object.defineProperty(window, "customElements", {
342
+ value: new CustomElementRegistry(),
343
+ configurable: true,
344
+ writable: true
345
+ });
346
+ if (!!window["ElementInternals"] && !!window["ElementInternals"].prototype["setFormValue"]) {
347
+ const internalsToHostMap = /* @__PURE__ */ new WeakMap();
348
+ const attachInternals = HTMLElement.prototype["attachInternals"];
349
+ const methods = [
350
+ "setFormValue",
351
+ "setValidity",
352
+ "checkValidity",
353
+ "reportValidity"
354
+ ];
355
+ HTMLElement.prototype["attachInternals"] = function(...args) {
356
+ const internals = attachInternals.call(this, ...args);
357
+ internalsToHostMap.set(internals, this);
358
+ return internals;
359
+ };
360
+ methods.forEach((method) => {
361
+ const proto = window["ElementInternals"].prototype;
362
+ const originalMethod = proto[method];
363
+ proto[method] = function(...args) {
364
+ const host = internalsToHostMap.get(this);
365
+ const definition = definitionForElement.get(host);
366
+ if (definition["formAssociated"] === true) {
367
+ return originalMethod?.call(this, ...args);
368
+ } else {
369
+ throw new DOMException(
370
+ `Failed to execute ${originalMethod} on 'ElementInternals': The target element is not a form-associated custom element.`
371
+ );
372
+ }
373
+ };
374
+ });
375
+ class RadioNodeList extends Array {
376
+ constructor(elements) {
377
+ super(...elements);
378
+ this._elements = elements;
379
+ }
380
+ get ["value"]() {
381
+ return this._elements.find((element) => element["checked"] === true)?.value || "";
382
+ }
383
+ }
384
+ class HTMLFormControlsCollection {
385
+ constructor(elements) {
386
+ const entries = /* @__PURE__ */ new Map();
387
+ elements.forEach((element, index) => {
388
+ const name = element.getAttribute("name");
389
+ const nameReference = entries.get(name) || [];
390
+ this[+index] = element;
391
+ nameReference.push(element);
392
+ entries.set(name, nameReference);
393
+ });
394
+ this["length"] = elements.length;
395
+ entries.forEach((value, key) => {
396
+ if (!value) return;
397
+ if (value.length === 1) {
398
+ this[key] = value[0];
399
+ } else {
400
+ this[key] = new RadioNodeList(value);
401
+ }
402
+ });
403
+ }
404
+ ["namedItem"](key) {
405
+ return this[key];
406
+ }
407
+ }
408
+ const formElementsDescriptor = Object.getOwnPropertyDescriptor(
409
+ HTMLFormElement.prototype,
410
+ "elements"
411
+ );
412
+ Object.defineProperty(HTMLFormElement.prototype, "elements", {
413
+ get: function() {
414
+ const nativeElements = formElementsDescriptor.get.call(this, []);
415
+ const include = [];
416
+ for (const element of nativeElements) {
417
+ const definition = definitionForElement.get(element);
418
+ if (!definition || definition["formAssociated"] === true) {
419
+ include.push(element);
420
+ }
421
+ }
422
+ return new HTMLFormControlsCollection(include);
423
+ }
424
+ });
425
+ }
5
426
  }
6
- };
7
- var parseFragment = (htmlStr) => {
8
- const range = document.createRange();
9
- range.selectNode(document.body);
10
- return range.createContextualFragment(htmlStr);
11
- };
12
- var setInnerHTML = (element, html3) => {
13
- clearHTML(element);
14
- const fragment = typeof html3 === "string" ? parseFragment(html3) : html3;
15
- element.append(fragment);
16
- };
427
+ class TrackableCustomElementRegistry extends window.CustomElementRegistry {
428
+ __tagNames = /* @__PURE__ */ new Set();
429
+ define(tagName, constructor, options) {
430
+ super.define(tagName, constructor, options);
431
+ this.__tagNames.add(tagName);
432
+ }
433
+ }
434
+ window.CustomElementRegistry = TrackableCustomElementRegistry;
435
+ }
17
436
 
18
437
  // src/signals.ts
19
438
  var subscriber = null;
@@ -27,7 +446,7 @@ var createSignal = (initVal, options) => {
27
446
  subscribers.add(subscriber);
28
447
  }
29
448
  if (options?.debugMode || getterOptions?.debugMode) {
30
- requestAnimationFrame(() => {
449
+ queueMicrotask(() => {
31
450
  let label = "anonymous signal";
32
451
  if (options?.label !== void 0) {
33
452
  label = `(${options.label})`;
@@ -52,7 +471,7 @@ var createSignal = (initVal, options) => {
52
471
  }
53
472
  if (!isBatchingUpdates) {
54
473
  isBatchingUpdates = true;
55
- requestAnimationFrame(() => {
474
+ queueMicrotask(() => {
56
475
  for (const fn of updateQueue) {
57
476
  try {
58
477
  fn();
@@ -100,973 +519,154 @@ var createEffect = (fn) => {
100
519
  subscriber = null;
101
520
  };
102
521
 
103
- // node_modules/dompurify/dist/purify.es.mjs
104
- var {
105
- entries,
106
- setPrototypeOf,
107
- isFrozen,
108
- getPrototypeOf,
109
- getOwnPropertyDescriptor
110
- } = Object;
111
- var {
112
- freeze,
113
- seal,
114
- create
115
- } = Object;
116
- var {
117
- apply,
118
- construct
119
- } = typeof Reflect !== "undefined" && Reflect;
120
- if (!freeze) {
121
- freeze = function freeze2(x) {
122
- return x;
123
- };
124
- }
125
- if (!seal) {
126
- seal = function seal2(x) {
127
- return x;
128
- };
129
- }
130
- if (!apply) {
131
- apply = function apply2(fun, thisValue, args) {
132
- return fun.apply(thisValue, args);
133
- };
134
- }
135
- if (!construct) {
136
- construct = function construct2(Func, args) {
137
- return new Func(...args);
138
- };
139
- }
140
- var arrayForEach = unapply(Array.prototype.forEach);
141
- var arrayPop = unapply(Array.prototype.pop);
142
- var arrayPush = unapply(Array.prototype.push);
143
- var stringToLowerCase = unapply(String.prototype.toLowerCase);
144
- var stringToString = unapply(String.prototype.toString);
145
- var stringMatch = unapply(String.prototype.match);
146
- var stringReplace = unapply(String.prototype.replace);
147
- var stringIndexOf = unapply(String.prototype.indexOf);
148
- var stringTrim = unapply(String.prototype.trim);
149
- var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
150
- var regExpTest = unapply(RegExp.prototype.test);
151
- var typeErrorCreate = unconstruct(TypeError);
152
- function unapply(func) {
153
- return function(thisArg) {
154
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
155
- args[_key - 1] = arguments[_key];
156
- }
157
- return apply(func, thisArg, args);
158
- };
159
- }
160
- function unconstruct(func) {
161
- return function() {
162
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
163
- args[_key2] = arguments[_key2];
164
- }
165
- return construct(func, args);
166
- };
167
- }
168
- function addToSet(set, array) {
169
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
170
- if (setPrototypeOf) {
171
- setPrototypeOf(set, null);
172
- }
173
- let l = array.length;
174
- while (l--) {
175
- let element = array[l];
176
- if (typeof element === "string") {
177
- const lcElement = transformCaseFunc(element);
178
- if (lcElement !== element) {
179
- if (!isFrozen(array)) {
180
- array[l] = lcElement;
181
- }
182
- element = lcElement;
183
- }
184
- }
185
- set[element] = true;
186
- }
187
- return set;
188
- }
189
- function cleanArray(array) {
190
- for (let index = 0; index < array.length; index++) {
191
- const isPropertyExist = objectHasOwnProperty(array, index);
192
- if (!isPropertyExist) {
193
- array[index] = null;
194
- }
195
- }
196
- return array;
197
- }
198
- function clone(object) {
199
- const newObject = create(null);
200
- for (const [property, value] of entries(object)) {
201
- const isPropertyExist = objectHasOwnProperty(object, property);
202
- if (isPropertyExist) {
203
- if (Array.isArray(value)) {
204
- newObject[property] = cleanArray(value);
205
- } else if (value && typeof value === "object" && value.constructor === Object) {
206
- newObject[property] = clone(value);
207
- } else {
208
- newObject[property] = value;
209
- }
210
- }
522
+ // src/server-side.ts
523
+ var isServer = typeof window === "undefined";
524
+ var serverDefineFns = /* @__PURE__ */ new Set();
525
+ var onServerDefine = (fn) => {
526
+ serverDefineFns.add(fn);
527
+ };
528
+ var serverDefine = ({ tagName, serverRender, options, scopedRegistry, parentRegistry }) => {
529
+ if (parentRegistry !== void 0) {
530
+ parentRegistry.__serverRenderOpts.set(tagName, { serverRender, ...options });
531
+ if (parentRegistry.scoped) return;
211
532
  }
212
- return newObject;
213
- }
214
- function lookupGetter(object, prop) {
215
- while (object !== null) {
216
- const desc = getOwnPropertyDescriptor(object, prop);
217
- if (desc) {
218
- if (desc.get) {
219
- return unapply(desc.get);
220
- }
221
- if (typeof desc.value === "function") {
222
- return unapply(desc.value);
533
+ for (const fn of serverDefineFns) {
534
+ let result = serverRender(getServerRenderArgs(tagName));
535
+ result = wrapTemplate({
536
+ tagName,
537
+ serverRender,
538
+ options
539
+ });
540
+ if (scopedRegistry !== void 0) {
541
+ for (const [scopedTagName, scopedRenderOptions] of scopedRegistry.__serverRenderOpts) {
542
+ const { serverRender: serverRender2, ...scopedOptions } = scopedRenderOptions;
543
+ let template = serverRender2(getServerRenderArgs(scopedTagName, scopedRegistry));
544
+ template = wrapTemplate({
545
+ tagName: scopedTagName,
546
+ serverRender: serverRender2,
547
+ options: scopedOptions
548
+ });
549
+ result = insertTemplates(scopedTagName, template, result);
223
550
  }
224
551
  }
225
- object = getPrototypeOf(object);
226
- }
227
- function fallbackValue() {
228
- return null;
552
+ fn(tagName, result);
229
553
  }
230
- return fallbackValue;
231
- }
232
- var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
233
- var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
234
- var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
235
- var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
236
- var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
237
- var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
238
- var text = freeze(["#text"]);
239
- var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
240
- var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
241
- var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
242
- var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
243
- var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
244
- var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
245
- var TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
246
- var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/);
247
- var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
248
- var IS_ALLOWED_URI = seal(
249
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
250
- // eslint-disable-line no-useless-escape
251
- );
252
- var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
253
- var ATTR_WHITESPACE = seal(
254
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
255
- // eslint-disable-line no-control-regex
256
- );
257
- var DOCTYPE_NAME = seal(/^html$/i);
258
- var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
259
- var EXPRESSIONS = /* @__PURE__ */ Object.freeze({
260
- __proto__: null,
261
- ARIA_ATTR,
262
- ATTR_WHITESPACE,
263
- CUSTOM_ELEMENT,
264
- DATA_ATTR,
265
- DOCTYPE_NAME,
266
- ERB_EXPR,
267
- IS_ALLOWED_URI,
268
- IS_SCRIPT_OR_DATA,
269
- MUSTACHE_EXPR,
270
- TMPLIT_EXPR
271
- });
272
- var NODE_TYPE = {
273
- element: 1,
274
- attribute: 2,
275
- text: 3,
276
- cdataSection: 4,
277
- entityReference: 5,
278
- // Deprecated
279
- entityNode: 6,
280
- // Deprecated
281
- progressingInstruction: 7,
282
- comment: 8,
283
- document: 9,
284
- documentType: 10,
285
- documentFragment: 11,
286
- notation: 12
287
- // Deprecated
288
- };
289
- var getGlobal = function getGlobal2() {
290
- return typeof window === "undefined" ? null : window;
291
554
  };
292
- var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
293
- if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
294
- return null;
295
- }
296
- let suffix = null;
297
- const ATTR_NAME = "data-tt-policy-suffix";
298
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
299
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
300
- }
301
- const policyName = "dompurify" + (suffix ? "#" + suffix : "");
302
- try {
303
- return trustedTypes.createPolicy(policyName, {
304
- createHTML(html3) {
305
- return html3;
306
- },
307
- createScriptURL(scriptUrl) {
308
- return scriptUrl;
555
+ var serverCss = /* @__PURE__ */ new Map();
556
+ var getServerRenderArgs = (tagName, registry) => ({
557
+ get elementRef() {
558
+ return new Proxy({}, {
559
+ get: () => {
560
+ throw new Error("The `elementRef` property is not available on the server.");
309
561
  }
310
562
  });
311
- } catch (_) {
312
- console.warn("TrustedTypes policy " + policyName + " could not be created.");
313
- return null;
314
- }
315
- };
316
- function createDOMPurify() {
317
- let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
318
- const DOMPurify = (root) => createDOMPurify(root);
319
- DOMPurify.version = "3.2.1";
320
- DOMPurify.removed = [];
321
- if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document) {
322
- DOMPurify.isSupported = false;
323
- return DOMPurify;
324
- }
325
- let {
326
- document: document2
327
- } = window2;
328
- const originalDocument = document2;
329
- const currentScript = originalDocument.currentScript;
330
- const {
331
- DocumentFragment: DocumentFragment2,
332
- HTMLTemplateElement,
333
- Node,
334
- Element: Element2,
335
- NodeFilter,
336
- NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
337
- HTMLFormElement,
338
- DOMParser,
339
- trustedTypes
340
- } = window2;
341
- const ElementPrototype = Element2.prototype;
342
- const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
343
- const remove = lookupGetter(ElementPrototype, "remove");
344
- const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
345
- const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
346
- const getParentNode = lookupGetter(ElementPrototype, "parentNode");
347
- if (typeof HTMLTemplateElement === "function") {
348
- const template = document2.createElement("template");
349
- if (template.content && template.content.ownerDocument) {
350
- document2 = template.content.ownerDocument;
351
- }
352
- }
353
- let trustedTypesPolicy;
354
- let emptyHTML = "";
355
- const {
356
- implementation,
357
- createNodeIterator,
358
- createDocumentFragment,
359
- getElementsByTagName
360
- } = document2;
361
- const {
362
- importNode
363
- } = originalDocument;
364
- let hooks = {};
365
- DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
366
- const {
367
- MUSTACHE_EXPR: MUSTACHE_EXPR2,
368
- ERB_EXPR: ERB_EXPR2,
369
- TMPLIT_EXPR: TMPLIT_EXPR2,
370
- DATA_ATTR: DATA_ATTR2,
371
- ARIA_ATTR: ARIA_ATTR2,
372
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
373
- ATTR_WHITESPACE: ATTR_WHITESPACE2,
374
- CUSTOM_ELEMENT: CUSTOM_ELEMENT2
375
- } = EXPRESSIONS;
376
- let {
377
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
378
- } = EXPRESSIONS;
379
- let ALLOWED_TAGS = null;
380
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
381
- let ALLOWED_ATTR = null;
382
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
383
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
384
- tagNameCheck: {
385
- writable: true,
386
- configurable: false,
387
- enumerable: true,
388
- value: null
389
- },
390
- attributeNameCheck: {
391
- writable: true,
392
- configurable: false,
393
- enumerable: true,
394
- value: null
395
- },
396
- allowCustomizedBuiltInElements: {
397
- writable: true,
398
- configurable: false,
399
- enumerable: true,
400
- value: false
401
- }
402
- }));
403
- let FORBID_TAGS = null;
404
- let FORBID_ATTR = null;
405
- let ALLOW_ARIA_ATTR = true;
406
- let ALLOW_DATA_ATTR = true;
407
- let ALLOW_UNKNOWN_PROTOCOLS = false;
408
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
409
- let SAFE_FOR_TEMPLATES = false;
410
- let SAFE_FOR_XML = true;
411
- let WHOLE_DOCUMENT = false;
412
- let SET_CONFIG = false;
413
- let FORCE_BODY = false;
414
- let RETURN_DOM = false;
415
- let RETURN_DOM_FRAGMENT = false;
416
- let RETURN_TRUSTED_TYPE = false;
417
- let SANITIZE_DOM = true;
418
- let SANITIZE_NAMED_PROPS = false;
419
- const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
420
- let KEEP_CONTENT = true;
421
- let IN_PLACE = false;
422
- let USE_PROFILES = {};
423
- let FORBID_CONTENTS = null;
424
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
425
- let DATA_URI_TAGS = null;
426
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
427
- let URI_SAFE_ATTRIBUTES = null;
428
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
429
- const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
430
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
431
- const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
432
- let NAMESPACE = HTML_NAMESPACE;
433
- let IS_EMPTY_INPUT = false;
434
- let ALLOWED_NAMESPACES = null;
435
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
436
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
437
- let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
438
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
439
- let PARSER_MEDIA_TYPE = null;
440
- const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
441
- const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
442
- let transformCaseFunc = null;
443
- let CONFIG = null;
444
- const formElement = document2.createElement("form");
445
- const isRegexOrFunction = function isRegexOrFunction2(testValue) {
446
- return testValue instanceof RegExp || testValue instanceof Function;
447
- };
448
- const _parseConfig = function _parseConfig2() {
449
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
450
- if (CONFIG && CONFIG === cfg) {
451
- return;
452
- }
453
- if (!cfg || typeof cfg !== "object") {
454
- cfg = {};
455
- }
456
- cfg = clone(cfg);
457
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
458
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
459
- transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
460
- ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
461
- ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
462
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
463
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
464
- DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
465
- FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
466
- FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
467
- FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
468
- USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
469
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
470
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
471
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
472
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
473
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
474
- SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
475
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
476
- RETURN_DOM = cfg.RETURN_DOM || false;
477
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
478
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
479
- FORCE_BODY = cfg.FORCE_BODY || false;
480
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
481
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
482
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
483
- IN_PLACE = cfg.IN_PLACE || false;
484
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
485
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
486
- MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
487
- HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
488
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
489
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
490
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
491
- }
492
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
493
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
494
- }
495
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
496
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
497
- }
498
- if (SAFE_FOR_TEMPLATES) {
499
- ALLOW_DATA_ATTR = false;
500
- }
501
- if (RETURN_DOM_FRAGMENT) {
502
- RETURN_DOM = true;
503
- }
504
- if (USE_PROFILES) {
505
- ALLOWED_TAGS = addToSet({}, text);
506
- ALLOWED_ATTR = [];
507
- if (USE_PROFILES.html === true) {
508
- addToSet(ALLOWED_TAGS, html$1);
509
- addToSet(ALLOWED_ATTR, html);
510
- }
511
- if (USE_PROFILES.svg === true) {
512
- addToSet(ALLOWED_TAGS, svg$1);
513
- addToSet(ALLOWED_ATTR, svg);
514
- addToSet(ALLOWED_ATTR, xml);
515
- }
516
- if (USE_PROFILES.svgFilters === true) {
517
- addToSet(ALLOWED_TAGS, svgFilters);
518
- addToSet(ALLOWED_ATTR, svg);
519
- addToSet(ALLOWED_ATTR, xml);
520
- }
521
- if (USE_PROFILES.mathMl === true) {
522
- addToSet(ALLOWED_TAGS, mathMl$1);
523
- addToSet(ALLOWED_ATTR, mathMl);
524
- addToSet(ALLOWED_ATTR, xml);
525
- }
526
- }
527
- if (cfg.ADD_TAGS) {
528
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
529
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
530
- }
531
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
532
- }
533
- if (cfg.ADD_ATTR) {
534
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
535
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
536
- }
537
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
538
- }
539
- if (cfg.ADD_URI_SAFE_ATTR) {
540
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
541
- }
542
- if (cfg.FORBID_CONTENTS) {
543
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
544
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
545
- }
546
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
547
- }
548
- if (KEEP_CONTENT) {
549
- ALLOWED_TAGS["#text"] = true;
550
- }
551
- if (WHOLE_DOCUMENT) {
552
- addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
553
- }
554
- if (ALLOWED_TAGS.table) {
555
- addToSet(ALLOWED_TAGS, ["tbody"]);
556
- delete FORBID_TAGS.tbody;
557
- }
558
- if (cfg.TRUSTED_TYPES_POLICY) {
559
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
560
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
561
- }
562
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
563
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
564
- }
565
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
566
- emptyHTML = trustedTypesPolicy.createHTML("");
567
- } else {
568
- if (trustedTypesPolicy === void 0) {
569
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
570
- }
571
- if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
572
- emptyHTML = trustedTypesPolicy.createHTML("");
563
+ },
564
+ get root() {
565
+ return new Proxy({}, {
566
+ get: () => {
567
+ throw new Error("The `root` property is not available on the server.");
573
568
  }
574
- }
575
- if (freeze) {
576
- freeze(cfg);
577
- }
578
- CONFIG = cfg;
579
- };
580
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
581
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
582
- const _checkValidNamespace = function _checkValidNamespace2(element) {
583
- let parent = getParentNode(element);
584
- if (!parent || !parent.tagName) {
585
- parent = {
586
- namespaceURI: NAMESPACE,
587
- tagName: "template"
588
- };
589
- }
590
- const tagName = stringToLowerCase(element.tagName);
591
- const parentTagName = stringToLowerCase(parent.tagName);
592
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
593
- return false;
594
- }
595
- if (element.namespaceURI === SVG_NAMESPACE) {
596
- if (parent.namespaceURI === HTML_NAMESPACE) {
597
- return tagName === "svg";
598
- }
599
- if (parent.namespaceURI === MATHML_NAMESPACE) {
600
- return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
601
- }
602
- return Boolean(ALL_SVG_TAGS[tagName]);
603
- }
604
- if (element.namespaceURI === MATHML_NAMESPACE) {
605
- if (parent.namespaceURI === HTML_NAMESPACE) {
606
- return tagName === "math";
607
- }
608
- if (parent.namespaceURI === SVG_NAMESPACE) {
609
- return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
610
- }
611
- return Boolean(ALL_MATHML_TAGS[tagName]);
612
- }
613
- if (element.namespaceURI === HTML_NAMESPACE) {
614
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
615
- return false;
616
- }
617
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
618
- return false;
619
- }
620
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
621
- }
622
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
623
- return true;
624
- }
625
- return false;
626
- };
627
- const _forceRemove = function _forceRemove2(node) {
628
- arrayPush(DOMPurify.removed, {
629
- element: node
630
569
  });
631
- try {
632
- getParentNode(node).removeChild(node);
633
- } catch (_) {
634
- remove(node);
635
- }
636
- };
637
- const _removeAttribute = function _removeAttribute2(name, element) {
638
- try {
639
- arrayPush(DOMPurify.removed, {
640
- attribute: element.getAttributeNode(name),
641
- from: element
642
- });
643
- } catch (_) {
644
- arrayPush(DOMPurify.removed, {
645
- attribute: null,
646
- from: element
647
- });
648
- }
649
- element.removeAttribute(name);
650
- if (name === "is" && !ALLOWED_ATTR[name]) {
651
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
652
- try {
653
- _forceRemove(element);
654
- } catch (_) {
655
- }
656
- } else {
657
- try {
658
- element.setAttribute(name, "");
659
- } catch (_) {
660
- }
661
- }
662
- }
663
- };
664
- const _initDocument = function _initDocument2(dirty) {
665
- let doc = null;
666
- let leadingWhitespace = null;
667
- if (FORCE_BODY) {
668
- dirty = "<remove></remove>" + dirty;
669
- } else {
670
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
671
- leadingWhitespace = matches && matches[0];
672
- }
673
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
674
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
675
- }
676
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
677
- if (NAMESPACE === HTML_NAMESPACE) {
678
- try {
679
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
680
- } catch (_) {
681
- }
682
- }
683
- if (!doc || !doc.documentElement) {
684
- doc = implementation.createDocument(NAMESPACE, "template", null);
685
- try {
686
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
687
- } catch (_) {
570
+ },
571
+ get internals() {
572
+ return new Proxy({}, {
573
+ get: () => {
574
+ throw new Error("The `internals` property is not available on the server.");
688
575
  }
689
- }
690
- const body = doc.body || doc.documentElement;
691
- if (dirty && leadingWhitespace) {
692
- body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
693
- }
694
- if (NAMESPACE === HTML_NAMESPACE) {
695
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
696
- }
697
- return WHOLE_DOCUMENT ? doc.documentElement : body;
698
- };
699
- const _createNodeIterator = function _createNodeIterator2(root) {
700
- return createNodeIterator.call(
701
- root.ownerDocument || root,
702
- root,
703
- // eslint-disable-next-line no-bitwise
704
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
705
- null
706
- );
707
- };
708
- const _isClobbered = function _isClobbered2(element) {
709
- return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
710
- };
711
- const _isNode = function _isNode2(value) {
712
- return typeof Node === "function" && value instanceof Node;
713
- };
714
- function _executeHook(entryPoint, currentNode, data) {
715
- if (!hooks[entryPoint]) {
716
- return;
717
- }
718
- arrayForEach(hooks[entryPoint], (hook) => {
719
- hook.call(DOMPurify, currentNode, data, CONFIG);
720
576
  });
577
+ },
578
+ attributeChangedCallback: () => {
579
+ },
580
+ connectedCallback: () => {
581
+ },
582
+ disconnectedCallback: () => {
583
+ },
584
+ adoptedCallback: () => {
585
+ },
586
+ formDisabledCallback: () => {
587
+ },
588
+ formResetCallback: () => {
589
+ },
590
+ formStateRestoreCallback: () => {
591
+ },
592
+ formAssociatedCallback: () => {
593
+ },
594
+ clientOnlyCallback: () => {
595
+ },
596
+ customCallback: () => `{{callback:unavailable-on-server}}`,
597
+ attrSignals: new Proxy({}, { get: (_, attr) => createSignal(`{{attr:${String(attr)}}}`) }),
598
+ propSignals: new Proxy({}, { get: () => createSignal(null) }),
599
+ refs: {},
600
+ // @ts-expect-error // this should be a string for server-side rendering
601
+ adoptStyleSheet: (cssStr) => {
602
+ const _serverCss = registry !== void 0 ? registry.__serverCss : serverCss;
603
+ const cssArr = _serverCss.get(tagName) ?? [];
604
+ cssArr.push(cssStr);
605
+ _serverCss.set(tagName, cssArr);
721
606
  }
722
- const _sanitizeElements = function _sanitizeElements2(currentNode) {
723
- let content = null;
724
- _executeHook("beforeSanitizeElements", currentNode, null);
725
- if (_isClobbered(currentNode)) {
726
- _forceRemove(currentNode);
727
- return true;
728
- }
729
- const tagName = transformCaseFunc(currentNode.nodeName);
730
- _executeHook("uponSanitizeElement", currentNode, {
731
- tagName,
732
- allowedTags: ALLOWED_TAGS
607
+ });
608
+ var wrapTemplate = ({ tagName, serverRender, options }) => {
609
+ const { registry } = options.shadowRootOptions;
610
+ const scopedRegistry = registry !== void 0 && "scoped" in registry ? registry : void 0;
611
+ const initialRenderString = serverRender(getServerRenderArgs(tagName, scopedRegistry));
612
+ const _serverCss = scopedRegistry?.__serverCss ?? serverCss;
613
+ const cssRenderString = (_serverCss.get(tagName) ?? []).map((cssStr) => `<style>${cssStr}</style>`).join("");
614
+ const finalScopedRenderString = options.attachShadow ? (
615
+ /* html */
616
+ `
617
+ <template
618
+ shadowrootmode="${options.shadowRootOptions.mode}"
619
+ shadowrootdelegatesfocus="${options.shadowRootOptions.delegatesFocus}"
620
+ shadowrootclonable="${options.shadowRootOptions.clonable}"
621
+ shadowrootserializable="${options.shadowRootOptions.serializable}"
622
+ >
623
+ ${cssRenderString + initialRenderString}
624
+ </template>
625
+ `
626
+ ) : cssRenderString + initialRenderString;
627
+ return finalScopedRenderString;
628
+ };
629
+ var insertTemplates = (tagName, template, inputString) => {
630
+ return inputString.replace(new RegExp(`(<s*${tagName}([^>]*)>)`, "gm"), ($1, _, $3) => {
631
+ const attrs = $3.split(/(?!=")\s+/).filter((attr) => attr !== "").map((attr) => {
632
+ const [key, _value] = attr.split("=");
633
+ const value = _value?.replace(/"/g, "") ?? "";
634
+ return [key, value];
733
635
  });
734
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
735
- _forceRemove(currentNode);
736
- return true;
737
- }
738
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
739
- _forceRemove(currentNode);
740
- return true;
741
- }
742
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
743
- _forceRemove(currentNode);
744
- return true;
745
- }
746
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
747
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
748
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
749
- return false;
750
- }
751
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
752
- return false;
753
- }
754
- }
755
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
756
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
757
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
758
- if (childNodes && parentNode) {
759
- const childCount = childNodes.length;
760
- for (let i = childCount - 1; i >= 0; --i) {
761
- const childClone = cloneNode(childNodes[i], true);
762
- childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
763
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
764
- }
765
- }
766
- }
767
- _forceRemove(currentNode);
768
- return true;
769
- }
770
- if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
771
- _forceRemove(currentNode);
772
- return true;
773
- }
774
- if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
775
- _forceRemove(currentNode);
776
- return true;
777
- }
778
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
779
- content = currentNode.textContent;
780
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
781
- content = stringReplace(content, expr, " ");
782
- });
783
- if (currentNode.textContent !== content) {
784
- arrayPush(DOMPurify.removed, {
785
- element: currentNode.cloneNode()
786
- });
787
- currentNode.textContent = content;
788
- }
789
- }
790
- _executeHook("afterSanitizeElements", currentNode, null);
791
- return false;
792
- };
793
- const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
794
- if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
795
- return false;
796
- }
797
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
798
- else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
799
- else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
800
- if (
801
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
802
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
803
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
804
- _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
805
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
806
- lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
807
- ) ;
808
- else {
809
- return false;
810
- }
811
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
812
- else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
813
- else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
814
- else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
815
- else if (value) {
816
- return false;
817
- } else ;
818
- return true;
819
- };
820
- const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
821
- return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
822
- };
823
- const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
824
- _executeHook("beforeSanitizeAttributes", currentNode, null);
825
- const {
826
- attributes
827
- } = currentNode;
828
- if (!attributes) {
829
- return;
830
- }
831
- const hookEvent = {
832
- attrName: "",
833
- attrValue: "",
834
- keepAttr: true,
835
- allowedAttributes: ALLOWED_ATTR,
836
- forceKeepAttr: void 0
837
- };
838
- let l = attributes.length;
839
- while (l--) {
840
- const attr = attributes[l];
841
- const {
842
- name,
843
- namespaceURI,
844
- value: attrValue
845
- } = attr;
846
- const lcName = transformCaseFunc(name);
847
- let value = name === "value" ? attrValue : stringTrim(attrValue);
848
- hookEvent.attrName = lcName;
849
- hookEvent.attrValue = value;
850
- hookEvent.keepAttr = true;
851
- hookEvent.forceKeepAttr = void 0;
852
- _executeHook("uponSanitizeAttribute", currentNode, hookEvent);
853
- value = hookEvent.attrValue;
854
- if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
855
- _removeAttribute(name, currentNode);
856
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
857
- }
858
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
859
- _removeAttribute(name, currentNode);
860
- continue;
861
- }
862
- if (hookEvent.forceKeepAttr) {
863
- continue;
864
- }
865
- _removeAttribute(name, currentNode);
866
- if (!hookEvent.keepAttr) {
867
- continue;
868
- }
869
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
870
- _removeAttribute(name, currentNode);
871
- continue;
872
- }
873
- if (SAFE_FOR_TEMPLATES) {
874
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
875
- value = stringReplace(value, expr, " ");
876
- });
877
- }
878
- const lcTag = transformCaseFunc(currentNode.nodeName);
879
- if (!_isValidAttribute(lcTag, lcName, value)) {
880
- continue;
881
- }
882
- if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
883
- if (namespaceURI) ;
884
- else {
885
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
886
- case "TrustedHTML": {
887
- value = trustedTypesPolicy.createHTML(value);
888
- break;
889
- }
890
- case "TrustedScriptURL": {
891
- value = trustedTypesPolicy.createScriptURL(value);
892
- break;
893
- }
894
- }
895
- }
896
- }
897
- try {
898
- if (namespaceURI) {
899
- currentNode.setAttributeNS(namespaceURI, name, value);
900
- } else {
901
- currentNode.setAttribute(name, value);
902
- }
903
- if (_isClobbered(currentNode)) {
904
- _forceRemove(currentNode);
905
- } else {
906
- arrayPop(DOMPurify.removed);
907
- }
908
- } catch (_) {
909
- }
910
- }
911
- _executeHook("afterSanitizeAttributes", currentNode, null);
912
- };
913
- const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
914
- let shadowNode = null;
915
- const shadowIterator = _createNodeIterator(fragment);
916
- _executeHook("beforeSanitizeShadowDOM", fragment, null);
917
- while (shadowNode = shadowIterator.nextNode()) {
918
- _executeHook("uponSanitizeShadowNode", shadowNode, null);
919
- if (_sanitizeElements(shadowNode)) {
920
- continue;
921
- }
922
- if (shadowNode.content instanceof DocumentFragment2) {
923
- _sanitizeShadowDOM2(shadowNode.content);
924
- }
925
- _sanitizeAttributes(shadowNode);
926
- }
927
- _executeHook("afterSanitizeShadowDOM", fragment, null);
928
- };
929
- DOMPurify.sanitize = function(dirty) {
930
- let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
931
- let body = null;
932
- let importedNode = null;
933
- let currentNode = null;
934
- let returnNode = null;
935
- IS_EMPTY_INPUT = !dirty;
936
- if (IS_EMPTY_INPUT) {
937
- dirty = "<!-->";
938
- }
939
- if (typeof dirty !== "string" && !_isNode(dirty)) {
940
- if (typeof dirty.toString === "function") {
941
- dirty = dirty.toString();
942
- if (typeof dirty !== "string") {
943
- throw typeErrorCreate("dirty is not a string, aborting");
944
- }
945
- } else {
946
- throw typeErrorCreate("toString is not a function");
947
- }
948
- }
949
- if (!DOMPurify.isSupported) {
950
- return dirty;
951
- }
952
- if (!SET_CONFIG) {
953
- _parseConfig(cfg);
954
- }
955
- DOMPurify.removed = [];
956
- if (typeof dirty === "string") {
957
- IN_PLACE = false;
958
- }
959
- if (IN_PLACE) {
960
- if (dirty.nodeName) {
961
- const tagName = transformCaseFunc(dirty.nodeName);
962
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
963
- throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
964
- }
965
- }
966
- } else if (dirty instanceof Node) {
967
- body = _initDocument("<!---->");
968
- importedNode = body.ownerDocument.importNode(dirty, true);
969
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
970
- body = importedNode;
971
- } else if (importedNode.nodeName === "HTML") {
972
- body = importedNode;
973
- } else {
974
- body.appendChild(importedNode);
975
- }
976
- } else {
977
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
978
- dirty.indexOf("<") === -1) {
979
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
980
- }
981
- body = _initDocument(dirty);
982
- if (!body) {
983
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
984
- }
985
- }
986
- if (body && FORCE_BODY) {
987
- _forceRemove(body.firstChild);
988
- }
989
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
990
- while (currentNode = nodeIterator.nextNode()) {
991
- if (_sanitizeElements(currentNode)) {
992
- continue;
993
- }
994
- if (currentNode.content instanceof DocumentFragment2) {
995
- _sanitizeShadowDOM(currentNode.content);
996
- }
997
- _sanitizeAttributes(currentNode);
998
- }
999
- if (IN_PLACE) {
1000
- return dirty;
1001
- }
1002
- if (RETURN_DOM) {
1003
- if (RETURN_DOM_FRAGMENT) {
1004
- returnNode = createDocumentFragment.call(body.ownerDocument);
1005
- while (body.firstChild) {
1006
- returnNode.appendChild(body.firstChild);
1007
- }
1008
- } else {
1009
- returnNode = body;
1010
- }
1011
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1012
- returnNode = importNode.call(originalDocument, returnNode, true);
1013
- }
1014
- return returnNode;
1015
- }
1016
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1017
- if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1018
- serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
1019
- }
1020
- if (SAFE_FOR_TEMPLATES) {
1021
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
1022
- serializedHTML = stringReplace(serializedHTML, expr, " ");
1023
- });
1024
- }
1025
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1026
- };
1027
- DOMPurify.setConfig = function() {
1028
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1029
- _parseConfig(cfg);
1030
- SET_CONFIG = true;
1031
- };
1032
- DOMPurify.clearConfig = function() {
1033
- CONFIG = null;
1034
- SET_CONFIG = false;
1035
- };
1036
- DOMPurify.isValidAttribute = function(tag, attr, value) {
1037
- if (!CONFIG) {
1038
- _parseConfig({});
1039
- }
1040
- const lcTag = transformCaseFunc(tag);
1041
- const lcName = transformCaseFunc(attr);
1042
- return _isValidAttribute(lcTag, lcName, value);
1043
- };
1044
- DOMPurify.addHook = function(entryPoint, hookFunction) {
1045
- if (typeof hookFunction !== "function") {
1046
- return;
1047
- }
1048
- hooks[entryPoint] = hooks[entryPoint] || [];
1049
- arrayPush(hooks[entryPoint], hookFunction);
1050
- };
1051
- DOMPurify.removeHook = function(entryPoint) {
1052
- if (hooks[entryPoint]) {
1053
- return arrayPop(hooks[entryPoint]);
636
+ let scopedResult = template;
637
+ for (const [key, value] of attrs) {
638
+ scopedResult = scopedResult.replace(new RegExp(`{{attr:${key}}}`, "gm"), value);
1054
639
  }
1055
- };
1056
- DOMPurify.removeHooks = function(entryPoint) {
1057
- if (hooks[entryPoint]) {
1058
- hooks[entryPoint] = [];
1059
- }
1060
- };
1061
- DOMPurify.removeAllHooks = function() {
1062
- hooks = {};
1063
- };
1064
- return DOMPurify;
1065
- }
1066
- var purify = createDOMPurify();
640
+ return $1 + scopedResult;
641
+ });
642
+ };
643
+ var clientOnlyCallback = (fn) => {
644
+ if (!isServer) return fn();
645
+ };
1067
646
 
1068
647
  // src/render.ts
1069
- var html2 = (strings, ...values) => {
648
+ var clearHTML = (element) => {
649
+ while (element.childNodes.length > 0) {
650
+ element.childNodes[0].remove();
651
+ }
652
+ };
653
+ var parseFragment = (htmlStr) => {
654
+ const range = document.createRange();
655
+ range.selectNode(document.body);
656
+ return range.createContextualFragment(htmlStr);
657
+ };
658
+ var setInnerHTML = (element, html2) => {
659
+ clearHTML(element);
660
+ const fragment = typeof html2 === "string" ? parseFragment(html2) : html2;
661
+ element.append(fragment);
662
+ };
663
+ var logValueError = (value) => {
664
+ console.error(
665
+ "An invalid value was passed to a template function. Non-primitive values are not supported.\n\nValue:\n",
666
+ value
667
+ );
668
+ };
669
+ var html = (strings, ...values) => {
1070
670
  let innerHTML = "";
1071
671
  const signalMap = /* @__PURE__ */ new Map();
1072
672
  strings.forEach((string, i) => {
@@ -1074,11 +674,17 @@ var html2 = (strings, ...values) => {
1074
674
  if (typeof value === "function") {
1075
675
  const uniqueKey = crypto.randomUUID();
1076
676
  signalMap.set(uniqueKey, value);
1077
- value = `{{signal:${uniqueKey}}}`;
677
+ value = isServer ? value() : `{{signal:${uniqueKey}}}`;
678
+ }
679
+ if (typeof value === "object" && value !== null) {
680
+ logValueError(value);
681
+ value = "";
1078
682
  }
1079
683
  innerHTML += string + String(value);
1080
684
  });
1081
- purify.sanitize(innerHTML);
685
+ if (isServer) {
686
+ return innerHTML;
687
+ }
1082
688
  const fragment = parseFragment(innerHTML);
1083
689
  const callbackBindingRegex = /(\{\{callback:.+\}\})/;
1084
690
  const signalBindingRegex = /(\{\{signal:.+\}\})/;
@@ -1086,10 +692,10 @@ var html2 = (strings, ...values) => {
1086
692
  for (const child of element.childNodes) {
1087
693
  if (child instanceof Text && signalBindingRegex.test(child.data)) {
1088
694
  const textList = child.data.split(signalBindingRegex);
1089
- textList.forEach((text2, i) => {
1090
- const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1091
- const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : void 0;
1092
- const newValue = signal !== void 0 ? signal() : text2;
695
+ textList.forEach((text, i) => {
696
+ const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
697
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
698
+ const newValue = signal !== void 0 ? signal() : text;
1093
699
  const newNode = (() => {
1094
700
  if (typeof newValue === "string") return new Text(newValue);
1095
701
  if (newValue instanceof DocumentFragment) return newValue;
@@ -1114,10 +720,10 @@ var html2 = (strings, ...values) => {
1114
720
  createEffect(() => {
1115
721
  let newText = "";
1116
722
  let hasNull = false;
1117
- for (const text2 of textList) {
1118
- const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1119
- const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : void 0;
1120
- const value = signal !== void 0 ? signal() : text2;
723
+ for (const text of textList) {
724
+ const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
725
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
726
+ const value = signal !== void 0 ? signal() : text;
1121
727
  if (value === null) hasNull = true;
1122
728
  newText += value;
1123
729
  }
@@ -1157,18 +763,25 @@ var css = (strings, ...values) => {
1157
763
  if (typeof value === "function") {
1158
764
  const uniqueKey = crypto.randomUUID();
1159
765
  signalMap.set(uniqueKey, value);
1160
- value = `{{signal:${uniqueKey}}}`;
766
+ value = isServer ? value() : `{{signal:${uniqueKey}}}`;
767
+ }
768
+ if (typeof value === "object" && value !== null) {
769
+ logValueError(value);
770
+ value = "";
1161
771
  }
1162
772
  cssText += string + String(value);
1163
773
  });
774
+ if (isServer) {
775
+ return cssText;
776
+ }
1164
777
  let stylesheet = adoptedStylesSupported ? new CSSStyleSheet() : document.createElement("style");
1165
778
  const textList = cssText.split(signalBindingRegex);
1166
779
  createEffect(() => {
1167
780
  const newCSSTextList = [];
1168
- for (const text2 of textList) {
1169
- const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1170
- const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : null;
1171
- const newText = signal !== null ? signal() : text2;
781
+ for (const text of textList) {
782
+ const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
783
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
784
+ const newText = signal !== null ? signal() : text;
1172
785
  newCSSTextList.push(newText);
1173
786
  }
1174
787
  const newCSSText = newCSSTextList.join("");
@@ -1188,34 +801,70 @@ var DEFAULT_RENDER_OPTIONS = {
1188
801
  attributesAsProperties: [],
1189
802
  attachShadow: true,
1190
803
  shadowRootOptions: {
1191
- mode: "closed"
1192
- }
1193
- };
1194
- var TrackableCustomElementRegistry = class extends CustomElementRegistry {
1195
- __tagNames = /* @__PURE__ */ new Set();
1196
- define(tagName, constructor) {
1197
- super.define(tagName, constructor);
1198
- this.__tagNames.add(tagName);
804
+ mode: "closed",
805
+ delegatesFocus: false,
806
+ clonable: false,
807
+ serializable: false,
808
+ slotAssignment: "named"
1199
809
  }
1200
810
  };
1201
- window.CustomElementRegistry = TrackableCustomElementRegistry;
1202
- var getPropName = (attrName) => attrName.replace(/^([A-Z]+)/, (_, letter) => letter.toLowerCase()).replace(/(-|_| )([a-zA-Z])/g, (_, letter) => letter.toUpperCase());
1203
811
  var customElement = (render, options) => {
812
+ const _options = { ...DEFAULT_RENDER_OPTIONS, ...options };
1204
813
  const {
1205
814
  formAssociated,
1206
815
  observedAttributes: _observedAttributes,
1207
816
  attributesAsProperties,
1208
817
  attachShadow,
1209
818
  shadowRootOptions: _shadowRootOptions
1210
- } = { ...DEFAULT_RENDER_OPTIONS, ...options };
819
+ } = _options;
1211
820
  const shadowRootOptions = { ...DEFAULT_RENDER_OPTIONS.shadowRootOptions, ..._shadowRootOptions };
821
+ const allOptions = { ..._options, shadowRootOptions };
822
+ if (isServer) {
823
+ const serverRender = render;
824
+ let _tagName2;
825
+ let _registry2;
826
+ const scopedRegistry = (() => {
827
+ if (shadowRootOptions.registry !== void 0 && "scoped" in shadowRootOptions.registry && shadowRootOptions.registry.scoped) {
828
+ return shadowRootOptions.registry;
829
+ }
830
+ })();
831
+ return {
832
+ define(tagName) {
833
+ _tagName2 = tagName;
834
+ serverDefine({
835
+ tagName,
836
+ serverRender,
837
+ options: allOptions,
838
+ scopedRegistry,
839
+ parentRegistry: _registry2
840
+ });
841
+ return this;
842
+ },
843
+ register(registry) {
844
+ if (_tagName2 !== void 0 && "eject" in registry && registry.scoped) {
845
+ console.error("Must call `register()` before `define()` for scoped registries.");
846
+ return this;
847
+ }
848
+ if ("eject" in registry) {
849
+ _registry2 = registry;
850
+ } else {
851
+ console.error("Registry must be created with `createRegistry()` for SSR.");
852
+ }
853
+ return this;
854
+ },
855
+ eject() {
856
+ throw new Error("Cannot eject a custom element on the server.");
857
+ }
858
+ };
859
+ }
1212
860
  shadowRootOptions.registry = shadowRootOptions.customElements = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
1213
861
  const observedAttributesSet = new Set(_observedAttributes);
1214
862
  const attributesAsPropertiesMap = /* @__PURE__ */ new Map();
1215
863
  for (const [attrName, coerce] of attributesAsProperties) {
1216
864
  observedAttributesSet.add(attrName);
1217
865
  attributesAsPropertiesMap.set(attrName, {
1218
- prop: getPropName(attrName),
866
+ // convert kebab-case attribute names to camelCase property names
867
+ prop: attrName.replace(/^([A-Z]+)/, (_, letter) => letter.toLowerCase()).replace(/(-|_| )([a-zA-Z])/g, (_, letter) => letter.toUpperCase()),
1219
868
  coerce,
1220
869
  value: null
1221
870
  });
@@ -1233,6 +882,7 @@ var customElement = (render, options) => {
1233
882
  #formDisabledCallbackFns = /* @__PURE__ */ new Set();
1234
883
  #formResetCallbackFns = /* @__PURE__ */ new Set();
1235
884
  #formStateRestoreCallbackFns = /* @__PURE__ */ new Set();
885
+ #clientOnlyCallbackFns = /* @__PURE__ */ new Set();
1236
886
  __customCallbackFns = /* @__PURE__ */ new Map();
1237
887
  #shadowRoot = attachShadow ? this.attachShadow(shadowRootOptions) : null;
1238
888
  #internals = this.attachInternals();
@@ -1265,6 +915,7 @@ var customElement = (render, options) => {
1265
915
  formDisabledCallback: (fn) => this.#formDisabledCallbackFns.add(fn),
1266
916
  formResetCallback: (fn) => this.#formResetCallbackFns.add(fn),
1267
917
  formStateRestoreCallback: (fn) => this.#formStateRestoreCallbackFns.add(fn),
918
+ clientOnlyCallback: (fn) => this.#clientOnlyCallbackFns.add(fn),
1268
919
  customCallback: (fn) => {
1269
920
  const key = crypto.randomUUID();
1270
921
  this.__customCallbackFns.set(key, fn);
@@ -1363,6 +1014,9 @@ You must set an initial value before calling a property signal's getter.
1363
1014
  });
1364
1015
  }
1365
1016
  }
1017
+ for (const fn of this.#clientOnlyCallbackFns) {
1018
+ fn();
1019
+ }
1366
1020
  setInnerHTML(root, fragment);
1367
1021
  }
1368
1022
  static get formAssociated() {
@@ -1459,78 +1113,106 @@ You must set an initial value before calling a property signal's getter.
1459
1113
  }
1460
1114
  }
1461
1115
  }
1462
- let _tagName = null;
1463
- let _registry = null;
1464
- let _registered = false;
1465
- const register = () => {
1466
- if (_tagName === null || _registry === null || _registered) return;
1467
- _registry.register(_tagName, CustomElement);
1468
- _registry.register(_tagName, elementResult);
1469
- _registered = true;
1470
- };
1116
+ let _tagName;
1117
+ let _registry;
1471
1118
  const elementResult = {
1472
- define(tagName) {
1473
- const registry = _registry?.scoped ? _registry.eject() : customElements;
1474
- if (registry.get(tagName) !== void 0) {
1119
+ define(tagName, options2) {
1120
+ const registry = _registry !== void 0 ? _registry : customElements;
1121
+ const nativeRegistry = "eject" in registry ? registry.eject() : registry;
1122
+ if (nativeRegistry.get(tagName) !== void 0) {
1475
1123
  console.warn(`Custom element "${tagName}" was already defined. Skipping...`);
1476
1124
  return this;
1477
1125
  }
1478
- registry.define(tagName, CustomElement);
1126
+ registry.define(tagName, CustomElement, options2);
1479
1127
  _tagName = tagName;
1480
- register();
1481
1128
  return this;
1482
1129
  },
1483
1130
  register(registry) {
1484
- if (_tagName !== null && registry.scoped) {
1131
+ if (_tagName !== void 0 && "eject" in registry && registry.scoped) {
1485
1132
  console.error("Must call `register()` before `define()` for scoped registries.");
1486
1133
  return this;
1487
1134
  }
1488
1135
  _registry = registry;
1489
- register();
1490
1136
  return this;
1491
1137
  },
1492
1138
  eject: () => CustomElement
1493
1139
  };
1494
1140
  return elementResult;
1495
1141
  };
1142
+
1143
+ // src/registry.ts
1496
1144
  var createRegistry = (args) => {
1497
1145
  const { scoped = false } = args ?? {};
1498
- const registryResult = /* @__PURE__ */ new Map();
1499
- const registry = (() => {
1500
- try {
1501
- return new CustomElementRegistry();
1502
- } catch (error) {
1503
- if (scoped)
1504
- console.error(
1505
- "Scoped custom element registries are not supported in this environment. Please install `@webcomponents/scoped-custom-element-registry` to use this feature."
1506
- );
1507
- return customElements;
1508
- }
1146
+ const customElementMap = /* @__PURE__ */ new Map();
1147
+ const customElementTags = /* @__PURE__ */ new Set();
1148
+ const nativeRegistry = (() => {
1149
+ if (isServer) return;
1150
+ if (scoped) return new CustomElementRegistry();
1151
+ return customElements;
1509
1152
  })();
1510
1153
  return {
1511
- register: (tagName, element) => {
1512
- if (registryResult.has(element)) {
1513
- console.warn(`Custom element class "${element.constructor.name}" was already registered. Skipping...`);
1514
- return;
1154
+ __serverCss: /* @__PURE__ */ new Map(),
1155
+ __serverRenderOpts: /* @__PURE__ */ new Map(),
1156
+ define(tagName, ElementResult, options) {
1157
+ const isResult = "eject" in ElementResult;
1158
+ if (isServer) {
1159
+ if (isResult) ElementResult.register(this).define(tagName, options);
1160
+ return this;
1161
+ }
1162
+ const CustomElement = isResult ? ElementResult.eject() : ElementResult;
1163
+ if (customElementMap.has(CustomElement)) {
1164
+ console.warn(`Custom element class "${CustomElement.constructor.name}" was already defined. Skipping...`);
1165
+ return this;
1166
+ }
1167
+ if (customElementTags.has(tagName)) {
1168
+ console.warn(`Custom element tag name "${tagName}" was already defined. Skipping...`);
1169
+ return this;
1170
+ }
1171
+ customElementMap.set(CustomElement, tagName.toUpperCase());
1172
+ customElementTags.add(tagName);
1173
+ if (CustomElement === void 0) {
1174
+ console.error(`Custom element class for tag name "${tagName}" was not found. You must register it first.`);
1175
+ return this;
1176
+ }
1177
+ nativeRegistry?.define(tagName, CustomElement, options);
1178
+ return this;
1179
+ },
1180
+ getTagName: (ElementResult) => {
1181
+ const CustomElement = "eject" in ElementResult ? ElementResult.eject() : ElementResult;
1182
+ return customElementMap.get(CustomElement);
1183
+ },
1184
+ getAllTagNames: () => Array.from(customElementTags),
1185
+ eject: () => {
1186
+ if (nativeRegistry === void 0) {
1187
+ throw new Error("Cannot eject a registry on the server.");
1515
1188
  }
1516
- registryResult.set(element, tagName.toUpperCase());
1189
+ return nativeRegistry;
1517
1190
  },
1518
- getTagName: (element) => registryResult.get(element),
1519
- eject: () => registry,
1520
1191
  scoped
1521
1192
  };
1522
1193
  };
1523
1194
  export {
1195
+ clientOnlyCallback,
1524
1196
  createEffect,
1525
1197
  createRegistry,
1526
1198
  createSignal,
1527
1199
  css,
1528
1200
  customElement,
1529
1201
  derived,
1530
- html2 as html
1202
+ html,
1203
+ insertTemplates,
1204
+ onServerDefine
1531
1205
  };
1532
- /*! Bundled license information:
1533
-
1534
- dompurify/dist/purify.es.mjs:
1535
- (*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE *)
1536
- */
1206
+ /**
1207
+ * @license
1208
+ * Copyright (c) 2020 The Polymer Project Authors. All rights reserved.
1209
+ * This code may only be used under the BSD style license found at
1210
+ * http://polymer.github.io/LICENSE.txt
1211
+ * The complete set of authors may be found at
1212
+ * http://polymer.github.io/AUTHORS.txt
1213
+ * The complete set of contributors may be found at
1214
+ * http://polymer.github.io/CONTRIBUTORS.txt
1215
+ * Code distributed by Google as part of the polymer project is also
1216
+ * subject to an additional IP rights grant found at
1217
+ * http://polymer.github.io/PATENTS.txt
1218
+ */