@stencil/core 4.23.2 → 4.24.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Client Platform v4.23.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Client Platform v4.24.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -63,15 +63,15 @@ var reWireGetterSetter = (instance, hostRef) => {
63
63
  const cmpMeta = hostRef.$cmpMeta$;
64
64
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
65
65
  members.map(([memberName, [memberFlags]]) => {
66
- if (BUILD2.state && BUILD2.prop && (memberFlags & 2048 /* Getter */) === 0 && (memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
66
+ if ((BUILD2.state || BUILD2.prop) && (memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
67
67
  const ogValue = instance[memberName];
68
- const lazyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
68
+ const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
69
69
  Object.defineProperty(instance, memberName, {
70
70
  get() {
71
- return lazyDescriptor.get.call(this);
71
+ return ogDescriptor.get.call(this);
72
72
  },
73
73
  set(newValue) {
74
- lazyDescriptor.set.call(this, newValue);
74
+ ogDescriptor.set.call(this, newValue);
75
75
  },
76
76
  configurable: true,
77
77
  enumerable: true
@@ -358,10 +358,10 @@ var unwrapErr = (result) => {
358
358
  import { BUILD as BUILD23 } from "@stencil/core/internal/app-data";
359
359
 
360
360
  // src/runtime/client-hydrate.ts
361
- import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
361
+ import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
362
362
 
363
363
  // src/runtime/dom-extras.ts
364
- import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
364
+ import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
365
365
 
366
366
  // src/runtime/slot-polyfill-utils.ts
367
367
  import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
@@ -388,27 +388,27 @@ var updateFallbackSlotVisibility = (elm) => {
388
388
  var getSlottedChildNodes = (childNodes) => {
389
389
  const result = [];
390
390
  for (let i2 = 0; i2 < childNodes.length; i2++) {
391
- const slottedNode = childNodes[i2]["s-nr"];
391
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
392
392
  if (slottedNode && slottedNode.isConnected) {
393
393
  result.push(slottedNode);
394
394
  }
395
395
  }
396
396
  return result;
397
397
  };
398
- var getHostSlotNodes = (childNodes, hostName, slotName) => {
398
+ function getHostSlotNodes(childNodes, hostName, slotName) {
399
399
  let i2 = 0;
400
400
  let slottedNodes = [];
401
401
  let childNode;
402
402
  for (; i2 < childNodes.length; i2++) {
403
403
  childNode = childNodes[i2];
404
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
404
+ if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
405
405
  slottedNodes.push(childNode);
406
406
  if (typeof slotName !== "undefined") return slottedNodes;
407
407
  }
408
408
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
409
409
  }
410
410
  return slottedNodes;
411
- };
411
+ }
412
412
  var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
413
413
  const childNodes = [];
414
414
  if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
@@ -466,1801 +466,1881 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
466
466
  };
467
467
  var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
468
468
 
469
- // src/runtime/vdom/vdom-render.ts
470
- import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
471
-
472
- // src/runtime/vdom/h.ts
473
- import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
474
- var h = (nodeName, vnodeData, ...children) => {
475
- let child = null;
476
- let key = null;
477
- let slotName = null;
478
- let simple = false;
479
- let lastSimple = false;
480
- const vNodeChildren = [];
481
- const walk = (c) => {
482
- for (let i2 = 0; i2 < c.length; i2++) {
483
- child = c[i2];
484
- if (Array.isArray(child)) {
485
- walk(child);
486
- } else if (child != null && typeof child !== "boolean") {
487
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
488
- child = String(child);
489
- } else if (BUILD8.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
490
- consoleDevError(`vNode passed as children has unexpected type.
491
- Make sure it's using the correct h() function.
492
- Empty objects can also be the cause, look for JSX comments that became objects.`);
469
+ // src/runtime/dom-extras.ts
470
+ var patchPseudoShadowDom = (hostElementPrototype) => {
471
+ patchCloneNode(hostElementPrototype);
472
+ patchSlotAppendChild(hostElementPrototype);
473
+ patchSlotAppend(hostElementPrototype);
474
+ patchSlotPrepend(hostElementPrototype);
475
+ patchSlotInsertAdjacentElement(hostElementPrototype);
476
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
477
+ patchSlotInsertAdjacentText(hostElementPrototype);
478
+ patchInsertBefore(hostElementPrototype);
479
+ patchTextContent(hostElementPrototype);
480
+ patchChildSlotNodes(hostElementPrototype);
481
+ patchSlotRemoveChild(hostElementPrototype);
482
+ };
483
+ var patchCloneNode = (HostElementPrototype) => {
484
+ const orgCloneNode = HostElementPrototype.cloneNode;
485
+ HostElementPrototype.cloneNode = function(deep) {
486
+ const srcNode = this;
487
+ const isShadowDom = BUILD8.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
488
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
489
+ if (BUILD8.slot && !isShadowDom && deep) {
490
+ let i2 = 0;
491
+ let slotted, nonStencilNode;
492
+ const stencilPrivates = [
493
+ "s-id",
494
+ "s-cr",
495
+ "s-lr",
496
+ "s-rc",
497
+ "s-sc",
498
+ "s-p",
499
+ "s-cn",
500
+ "s-sr",
501
+ "s-sn",
502
+ "s-hn",
503
+ "s-ol",
504
+ "s-nr",
505
+ "s-si",
506
+ "s-rf",
507
+ "s-scs"
508
+ ];
509
+ const childNodes = this.__childNodes || this.childNodes;
510
+ for (; i2 < childNodes.length; i2++) {
511
+ slotted = childNodes[i2]["s-nr"];
512
+ nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i2][privateField]);
513
+ if (slotted) {
514
+ if (BUILD8.appendChildSlotFix && clonedNode.__appendChild) {
515
+ clonedNode.__appendChild(slotted.cloneNode(true));
516
+ } else {
517
+ clonedNode.appendChild(slotted.cloneNode(true));
518
+ }
493
519
  }
494
- if (simple && lastSimple) {
495
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
496
- } else {
497
- vNodeChildren.push(simple ? newVNode(null, child) : child);
520
+ if (nonStencilNode) {
521
+ clonedNode.appendChild(childNodes[i2].cloneNode(true));
498
522
  }
499
- lastSimple = simple;
500
523
  }
501
524
  }
525
+ return clonedNode;
502
526
  };
503
- walk(children);
504
- if (vnodeData) {
505
- if (BUILD8.isDev && nodeName === "input") {
506
- validateInputProperties(vnodeData);
507
- }
508
- if (BUILD8.vdomKey && vnodeData.key) {
509
- key = vnodeData.key;
510
- }
511
- if (BUILD8.slotRelocation && vnodeData.name) {
512
- slotName = vnodeData.name;
527
+ };
528
+ var patchSlotAppendChild = (HostElementPrototype) => {
529
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
530
+ HostElementPrototype.appendChild = function(newChild) {
531
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
532
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
533
+ if (slotNode) {
534
+ addSlotRelocateNode(newChild, slotNode);
535
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
536
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
537
+ const parent = intrnlCall(appendAfter, "parentNode");
538
+ let insertedNode;
539
+ if (parent.__insertBefore) {
540
+ insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
541
+ } else {
542
+ insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
543
+ }
544
+ updateFallbackSlotVisibility(this);
545
+ return insertedNode;
513
546
  }
514
- if (BUILD8.vdomClass) {
515
- const classData = vnodeData.className || vnodeData.class;
516
- if (classData) {
517
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
547
+ return this.__appendChild(newChild);
548
+ };
549
+ };
550
+ var patchSlotRemoveChild = (ElementPrototype) => {
551
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
552
+ ElementPrototype.removeChild = function(toRemove) {
553
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
554
+ const childNodes = this.__childNodes || this.childNodes;
555
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
556
+ if (slotNode && toRemove.isConnected) {
557
+ toRemove.remove();
558
+ updateFallbackSlotVisibility(this);
559
+ return;
518
560
  }
519
561
  }
520
- }
521
- if (BUILD8.isDev && vNodeChildren.some(isHost)) {
522
- consoleDevError(`The <Host> must be the single root component. Make sure:
523
- - You are NOT using hostData() and <Host> in the same component.
524
- - <Host> is used once, and it's the single root component of the render() function.`);
525
- }
526
- if (BUILD8.vdomFunctional && typeof nodeName === "function") {
527
- return nodeName(
528
- vnodeData === null ? {} : vnodeData,
529
- vNodeChildren,
530
- vdomFnUtils
531
- );
532
- }
533
- const vnode = newVNode(nodeName, null);
534
- vnode.$attrs$ = vnodeData;
535
- if (vNodeChildren.length > 0) {
536
- vnode.$children$ = vNodeChildren;
537
- }
538
- if (BUILD8.vdomKey) {
539
- vnode.$key$ = key;
540
- }
541
- if (BUILD8.slotRelocation) {
542
- vnode.$name$ = slotName;
543
- }
544
- return vnode;
562
+ return this.__removeChild(toRemove);
563
+ };
545
564
  };
546
- var newVNode = (tag, text) => {
547
- const vnode = {
548
- $flags$: 0,
549
- $tag$: tag,
550
- $text$: text,
551
- $elm$: null,
552
- $children$: null
565
+ var patchSlotPrepend = (HostElementPrototype) => {
566
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
567
+ HostElementPrototype.prepend = function(...newChildren) {
568
+ newChildren.forEach((newChild) => {
569
+ if (typeof newChild === "string") {
570
+ newChild = this.ownerDocument.createTextNode(newChild);
571
+ }
572
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
573
+ const childNodes = this.__childNodes || this.childNodes;
574
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
575
+ if (slotNode) {
576
+ addSlotRelocateNode(newChild, slotNode, true);
577
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
578
+ const appendAfter = slotChildNodes[0];
579
+ const parent = intrnlCall(appendAfter, "parentNode");
580
+ if (parent.__insertBefore) {
581
+ return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
582
+ } else {
583
+ return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
584
+ }
585
+ }
586
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
587
+ newChild.hidden = true;
588
+ }
589
+ return HostElementPrototype.__prepend(newChild);
590
+ });
553
591
  };
554
- if (BUILD8.vdomAttribute) {
555
- vnode.$attrs$ = null;
556
- }
557
- if (BUILD8.vdomKey) {
558
- vnode.$key$ = null;
559
- }
560
- if (BUILD8.slotRelocation) {
561
- vnode.$name$ = null;
562
- }
563
- return vnode;
564
592
  };
565
- var Host = {};
566
- var isHost = (node) => node && node.$tag$ === Host;
567
- var vdomFnUtils = {
568
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
569
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
593
+ var patchSlotAppend = (HostElementPrototype) => {
594
+ HostElementPrototype.__append = HostElementPrototype.append;
595
+ HostElementPrototype.append = function(...newChildren) {
596
+ newChildren.forEach((newChild) => {
597
+ if (typeof newChild === "string") {
598
+ newChild = this.ownerDocument.createTextNode(newChild);
599
+ }
600
+ this.appendChild(newChild);
601
+ });
602
+ };
570
603
  };
571
- var convertToPublic = (node) => ({
572
- vattrs: node.$attrs$,
573
- vchildren: node.$children$,
574
- vkey: node.$key$,
575
- vname: node.$name$,
576
- vtag: node.$tag$,
577
- vtext: node.$text$
578
- });
579
- var convertToPrivate = (node) => {
580
- if (typeof node.vtag === "function") {
581
- const vnodeData = { ...node.vattrs };
582
- if (node.vkey) {
583
- vnodeData.key = node.vkey;
604
+ var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
605
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
606
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
607
+ if (position !== "afterbegin" && position !== "beforeend") {
608
+ return originalInsertAdjacentHtml.call(this, position, text);
584
609
  }
585
- if (node.vname) {
586
- vnodeData.name = node.vname;
610
+ const container = this.ownerDocument.createElement("_");
611
+ let node;
612
+ container.innerHTML = text;
613
+ if (position === "afterbegin") {
614
+ while (node = container.firstChild) {
615
+ this.prepend(node);
616
+ }
617
+ } else if (position === "beforeend") {
618
+ while (node = container.firstChild) {
619
+ this.append(node);
620
+ }
587
621
  }
588
- return h(node.vtag, vnodeData, ...node.vchildren || []);
589
- }
590
- const vnode = newVNode(node.vtag, node.vtext);
591
- vnode.$attrs$ = node.vattrs;
592
- vnode.$children$ = node.vchildren;
593
- vnode.$key$ = node.vkey;
594
- vnode.$name$ = node.vname;
595
- return vnode;
622
+ };
596
623
  };
597
- var validateInputProperties = (inputElm) => {
598
- const props = Object.keys(inputElm);
599
- const value = props.indexOf("value");
600
- if (value === -1) {
601
- return;
602
- }
603
- const typeIndex = props.indexOf("type");
604
- const minIndex = props.indexOf("min");
605
- const maxIndex = props.indexOf("max");
606
- const stepIndex = props.indexOf("step");
607
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
608
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
609
- }
624
+ var patchSlotInsertAdjacentText = (HostElementPrototype) => {
625
+ HostElementPrototype.insertAdjacentText = function(position, text) {
626
+ this.insertAdjacentHTML(position, text);
627
+ };
610
628
  };
611
-
612
- // src/runtime/vdom/update-element.ts
613
- import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
614
-
615
- // src/runtime/vdom/set-accessor.ts
616
- import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
617
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
618
- if (oldValue !== newValue) {
619
- let isProp = isMemberInElement(elm, memberName);
620
- let ln = memberName.toLowerCase();
621
- if (BUILD9.vdomClass && memberName === "class") {
622
- const classList = elm.classList;
623
- const oldClasses = parseClassList(oldValue);
624
- let newClasses = parseClassList(newValue);
625
- if (elm["s-si"]) {
626
- newClasses.push(elm["s-si"]);
627
- oldClasses.forEach((c) => {
628
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
629
- });
630
- newClasses = [...new Set(newClasses)];
631
- classList.add(...newClasses);
632
- delete elm["s-si"];
633
- } else {
634
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
635
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
636
- }
637
- } else if (BUILD9.vdomStyle && memberName === "style") {
638
- if (BUILD9.updatable) {
639
- for (const prop in oldValue) {
640
- if (!newValue || newValue[prop] == null) {
641
- if (!BUILD9.hydrateServerSide && prop.includes("-")) {
642
- elm.style.removeProperty(prop);
643
- } else {
644
- elm.style[prop] = "";
645
- }
646
- }
647
- }
648
- }
649
- for (const prop in newValue) {
650
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
651
- if (!BUILD9.hydrateServerSide && prop.includes("-")) {
652
- elm.style.setProperty(prop, newValue[prop]);
653
- } else {
654
- elm.style[prop] = newValue[prop];
629
+ var patchInsertBefore = (HostElementPrototype) => {
630
+ const eleProto = HostElementPrototype;
631
+ if (eleProto.__insertBefore) return;
632
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
633
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
634
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
635
+ const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
636
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
637
+ if (slotNode) {
638
+ let found = false;
639
+ slottedNodes.forEach((childNode) => {
640
+ if (childNode === currentChild || currentChild === null) {
641
+ found = true;
642
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
643
+ this.appendChild(newChild);
644
+ return;
655
645
  }
656
- }
657
- }
658
- } else if (BUILD9.vdomKey && memberName === "key") {
659
- } else if (BUILD9.vdomRef && memberName === "ref") {
660
- if (newValue) {
661
- newValue(elm);
662
- }
663
- } else if (BUILD9.vdomListener && (BUILD9.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
664
- if (memberName[2] === "-") {
665
- memberName = memberName.slice(3);
666
- } else if (isMemberInElement(win, ln)) {
667
- memberName = ln.slice(2);
668
- } else {
669
- memberName = ln[2] + memberName.slice(3);
670
- }
671
- if (oldValue || newValue) {
672
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
673
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
674
- if (oldValue) {
675
- plt.rel(elm, memberName, oldValue, capture);
676
- }
677
- if (newValue) {
678
- plt.ael(elm, memberName, newValue, capture);
679
- }
680
- }
681
- } else if (BUILD9.vdomPropOrAttr) {
682
- const isComplex = isComplexType(newValue);
683
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
684
- try {
685
- if (!elm.tagName.includes("-")) {
686
- const n = newValue == null ? "" : newValue;
687
- if (memberName === "list") {
688
- isProp = false;
689
- } else if (oldValue == null || elm[memberName] != n) {
690
- if (typeof elm.__lookupSetter__(memberName) === "function") {
691
- elm[memberName] = n;
692
- } else {
693
- elm.setAttribute(memberName, n);
694
- }
646
+ if (slotName === currentChild["s-sn"]) {
647
+ addSlotRelocateNode(newChild, slotNode);
648
+ const parent = intrnlCall(currentChild, "parentNode");
649
+ if (parent.__insertBefore) {
650
+ parent.__insertBefore(newChild, currentChild);
651
+ } else {
652
+ parent.insertBefore(newChild, currentChild);
695
653
  }
696
- } else {
697
- elm[memberName] = newValue;
698
- }
699
- } catch (e) {
700
- }
701
- }
702
- let xlink = false;
703
- if (BUILD9.vdomXlink) {
704
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
705
- memberName = ln;
706
- xlink = true;
707
- }
708
- }
709
- if (newValue == null || newValue === false) {
710
- if (newValue !== false || elm.getAttribute(memberName) === "") {
711
- if (BUILD9.vdomXlink && xlink) {
712
- elm.removeAttributeNS(XLINK_NS, memberName);
713
- } else {
714
- elm.removeAttribute(memberName);
715
654
  }
655
+ return;
716
656
  }
717
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
718
- newValue = newValue === true ? "" : newValue;
719
- if (BUILD9.vdomXlink && xlink) {
720
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
721
- } else {
722
- elm.setAttribute(memberName, newValue);
723
- }
724
- }
657
+ });
658
+ if (found) return newChild;
725
659
  }
726
- }
660
+ return this.__insertBefore(newChild, currentChild);
661
+ };
727
662
  };
728
- var parseClassListRegex = /\s/;
729
- var parseClassList = (value) => {
730
- if (typeof value === "object" && "baseVal" in value) {
731
- value = value.baseVal;
732
- }
733
- if (!value) {
734
- return [];
735
- }
736
- return value.split(parseClassListRegex);
663
+ var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
664
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
665
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
666
+ if (position !== "afterbegin" && position !== "beforeend") {
667
+ return originalInsertAdjacentElement.call(this, position, element);
668
+ }
669
+ if (position === "afterbegin") {
670
+ this.prepend(element);
671
+ return element;
672
+ } else if (position === "beforeend") {
673
+ this.append(element);
674
+ return element;
675
+ }
676
+ return element;
677
+ };
737
678
  };
738
- var CAPTURE_EVENT_SUFFIX = "Capture";
739
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
740
-
741
- // src/runtime/vdom/update-element.ts
742
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
743
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
744
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
745
- const newVnodeAttrs = newVnode.$attrs$ || {};
746
- if (BUILD10.updatable) {
747
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
748
- if (!(memberName in newVnodeAttrs)) {
749
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
750
- }
679
+ var patchTextContent = (hostElementPrototype) => {
680
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
681
+ Object.defineProperty(hostElementPrototype, "textContent", {
682
+ get: function() {
683
+ let text = "";
684
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
685
+ childNodes.forEach((node) => text += node.textContent || "");
686
+ return text;
687
+ },
688
+ set: function(value) {
689
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
690
+ childNodes.forEach((node) => {
691
+ if (node["s-ol"]) node["s-ol"].remove();
692
+ node.remove();
693
+ });
694
+ this.insertAdjacentHTML("beforeend", value);
751
695
  }
752
- }
753
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
754
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
755
- }
696
+ });
756
697
  };
757
- function sortedAttrNames(attrNames) {
758
- return attrNames.includes("ref") ? (
759
- // we need to sort these to ensure that `'ref'` is the last attr
760
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
761
- ) : (
762
- // no need to sort, return the original array
763
- attrNames
764
- );
765
- }
766
-
767
- // src/runtime/vdom/vdom-render.ts
768
- var scopeId;
769
- var contentRef;
770
- var hostTagName;
771
- var useNativeShadowDom = false;
772
- var checkSlotFallbackVisibility = false;
773
- var checkSlotRelocate = false;
774
- var isSvgMode = false;
775
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
776
- var _a;
777
- const newVNode2 = newParentVNode.$children$[childIndex];
778
- let i2 = 0;
779
- let elm;
780
- let childNode;
781
- let oldVNode;
782
- if (BUILD11.slotRelocation && !useNativeShadowDom) {
783
- checkSlotRelocate = true;
784
- if (newVNode2.$tag$ === "slot") {
785
- newVNode2.$flags$ |= newVNode2.$children$ ? (
786
- // slot element has fallback content
787
- // still create an element that "mocks" the slot element
788
- 2 /* isSlotFallback */
789
- ) : (
790
- // slot element does not have fallback content
791
- // create an html comment we'll use to always reference
792
- // where actual slot content should sit next to
793
- 1 /* isSlotReference */
794
- );
698
+ var patchChildSlotNodes = (elm) => {
699
+ class FakeNodeList extends Array {
700
+ item(n) {
701
+ return this[n];
795
702
  }
796
703
  }
797
- if (BUILD11.isDev && newVNode2.$elm$) {
798
- consoleDevError(
799
- `The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
800
- );
801
- }
802
- if (BUILD11.vdomText && newVNode2.$text$ !== null) {
803
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
804
- } else if (BUILD11.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
805
- elm = newVNode2.$elm$ = BUILD11.isDebug || BUILD11.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
806
- } else {
807
- if (BUILD11.svg && !isSvgMode) {
808
- isSvgMode = newVNode2.$tag$ === "svg";
809
- }
810
- elm = newVNode2.$elm$ = BUILD11.svg ? doc.createElementNS(
811
- isSvgMode ? SVG_NS : HTML_NS,
812
- !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
813
- ) : doc.createElement(
814
- !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
815
- );
816
- if (BUILD11.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
817
- isSvgMode = false;
704
+ patchHostOriginalAccessor("children", elm);
705
+ Object.defineProperty(elm, "children", {
706
+ get() {
707
+ return this.childNodes.filter((n) => n.nodeType === 1);
818
708
  }
819
- if (BUILD11.vdomAttribute) {
820
- updateElement(null, newVNode2, isSvgMode);
709
+ });
710
+ Object.defineProperty(elm, "childElementCount", {
711
+ get() {
712
+ return this.children.length;
821
713
  }
822
- if (BUILD11.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
823
- elm.classList.add(elm["s-si"] = scopeId);
714
+ });
715
+ patchHostOriginalAccessor("firstChild", elm);
716
+ Object.defineProperty(elm, "firstChild", {
717
+ get() {
718
+ return this.childNodes[0];
824
719
  }
825
- if (newVNode2.$children$) {
826
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
827
- childNode = createElm(oldParentVNode, newVNode2, i2);
828
- if (childNode) {
829
- elm.appendChild(childNode);
830
- }
831
- }
720
+ });
721
+ patchHostOriginalAccessor("lastChild", elm);
722
+ Object.defineProperty(elm, "lastChild", {
723
+ get() {
724
+ return this.childNodes[this.childNodes.length - 1];
832
725
  }
833
- if (BUILD11.svg) {
834
- if (newVNode2.$tag$ === "svg") {
835
- isSvgMode = false;
836
- } else if (elm.tagName === "foreignObject") {
837
- isSvgMode = true;
838
- }
839
- }
840
- }
841
- elm["s-hn"] = hostTagName;
842
- if (BUILD11.slotRelocation) {
843
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
844
- elm["s-sr"] = true;
845
- elm["s-cr"] = contentRef;
846
- elm["s-sn"] = newVNode2.$name$ || "";
847
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
848
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
849
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
850
- if (BUILD11.experimentalSlotFixes) {
851
- relocateToHostRoot(oldParentVNode.$elm$);
852
- } else {
853
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
854
- }
855
- }
856
- if (BUILD11.scoped) {
857
- addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
858
- }
726
+ });
727
+ patchHostOriginalAccessor("childNodes", elm);
728
+ Object.defineProperty(elm, "childNodes", {
729
+ get() {
730
+ const result = new FakeNodeList();
731
+ result.push(...getSlottedChildNodes(this.__childNodes));
732
+ return result;
859
733
  }
734
+ });
735
+ };
736
+ var patchSlottedNode = (node) => {
737
+ if (!node || node.__nextSibling || !globalThis.Node) return;
738
+ patchNextSibling(node);
739
+ patchPreviousSibling(node);
740
+ patchParentNode(node);
741
+ if (node.nodeType === Node.ELEMENT_NODE) {
742
+ patchNextElementSibling(node);
743
+ patchPreviousElementSibling(node);
860
744
  }
861
- return elm;
862
745
  };
863
- var relocateToHostRoot = (parentElm) => {
864
- plt.$flags$ |= 1 /* isTmpDisconnected */;
865
- const host = parentElm.closest(hostTagName.toLowerCase());
866
- if (host != null) {
867
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
868
- (ref) => ref["s-cr"]
869
- );
870
- const childNodeArray = Array.from(
871
- parentElm.__childNodes || parentElm.childNodes
872
- );
873
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
874
- if (childNode["s-sh"] != null) {
875
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
876
- childNode["s-sh"] = void 0;
877
- checkSlotRelocate = true;
746
+ var patchNextSibling = (node) => {
747
+ if (!node || node.__nextSibling) return;
748
+ patchHostOriginalAccessor("nextSibling", node);
749
+ Object.defineProperty(node, "nextSibling", {
750
+ get: function() {
751
+ var _a;
752
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
753
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
754
+ if (parentNodes && index > -1) {
755
+ return parentNodes[index + 1];
878
756
  }
757
+ return this.__nextSibling;
879
758
  }
880
- }
881
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
759
+ });
882
760
  };
883
- var putBackInOriginalLocation = (parentElm, recursive) => {
884
- plt.$flags$ |= 1 /* isTmpDisconnected */;
885
- const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
886
- if (parentElm["s-sr"] && BUILD11.experimentalSlotFixes) {
887
- let node = parentElm;
888
- while (node = node.nextSibling) {
889
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
890
- oldSlotChildNodes.push(node);
761
+ var patchNextElementSibling = (element) => {
762
+ if (!element || element.__nextElementSibling) return;
763
+ patchHostOriginalAccessor("nextElementSibling", element);
764
+ Object.defineProperty(element, "nextElementSibling", {
765
+ get: function() {
766
+ var _a;
767
+ const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
768
+ const index = parentEles == null ? void 0 : parentEles.indexOf(this);
769
+ if (parentEles && index > -1) {
770
+ return parentEles[index + 1];
891
771
  }
772
+ return this.__nextElementSibling;
892
773
  }
893
- }
894
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
895
- const childNode = oldSlotChildNodes[i2];
896
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
897
- insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
898
- childNode["s-ol"].remove();
899
- childNode["s-ol"] = void 0;
900
- childNode["s-sh"] = void 0;
901
- checkSlotRelocate = true;
902
- }
903
- if (recursive) {
904
- putBackInOriginalLocation(childNode, recursive);
905
- }
906
- }
907
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
774
+ });
908
775
  };
909
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
910
- let containerElm = BUILD11.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
911
- let childNode;
912
- if (BUILD11.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
913
- containerElm = containerElm.shadowRoot;
914
- }
915
- for (; startIdx <= endIdx; ++startIdx) {
916
- if (vnodes[startIdx]) {
917
- childNode = createElm(null, parentVNode, startIdx);
918
- if (childNode) {
919
- vnodes[startIdx].$elm$ = childNode;
920
- insertBefore(containerElm, childNode, BUILD11.slotRelocation ? referenceNode(before) : before);
776
+ var patchPreviousSibling = (node) => {
777
+ if (!node || node.__previousSibling) return;
778
+ patchHostOriginalAccessor("previousSibling", node);
779
+ Object.defineProperty(node, "previousSibling", {
780
+ get: function() {
781
+ var _a;
782
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
783
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
784
+ if (parentNodes && index > -1) {
785
+ return parentNodes[index - 1];
921
786
  }
787
+ return this.__previousSibling;
922
788
  }
923
- }
789
+ });
924
790
  };
925
- var removeVnodes = (vnodes, startIdx, endIdx) => {
926
- for (let index = startIdx; index <= endIdx; ++index) {
927
- const vnode = vnodes[index];
928
- if (vnode) {
929
- const elm = vnode.$elm$;
930
- nullifyVNodeRefs(vnode);
931
- if (elm) {
932
- if (BUILD11.slotRelocation) {
933
- checkSlotFallbackVisibility = true;
934
- if (elm["s-ol"]) {
935
- elm["s-ol"].remove();
936
- } else {
937
- putBackInOriginalLocation(elm, true);
938
- }
939
- }
940
- elm.remove();
791
+ var patchPreviousElementSibling = (element) => {
792
+ if (!element || element.__previousElementSibling) return;
793
+ patchHostOriginalAccessor("previousElementSibling", element);
794
+ Object.defineProperty(element, "previousElementSibling", {
795
+ get: function() {
796
+ var _a;
797
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
798
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
799
+ if (parentNodes && index > -1) {
800
+ return parentNodes[index - 1];
941
801
  }
802
+ return this.__previousElementSibling;
942
803
  }
943
- }
804
+ });
944
805
  };
945
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
946
- let oldStartIdx = 0;
947
- let newStartIdx = 0;
948
- let idxInOld = 0;
949
- let i2 = 0;
950
- let oldEndIdx = oldCh.length - 1;
951
- let oldStartVnode = oldCh[0];
952
- let oldEndVnode = oldCh[oldEndIdx];
953
- let newEndIdx = newCh.length - 1;
954
- let newStartVnode = newCh[0];
955
- let newEndVnode = newCh[newEndIdx];
956
- let node;
957
- let elmToMove;
958
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
959
- if (oldStartVnode == null) {
960
- oldStartVnode = oldCh[++oldStartIdx];
961
- } else if (oldEndVnode == null) {
962
- oldEndVnode = oldCh[--oldEndIdx];
963
- } else if (newStartVnode == null) {
964
- newStartVnode = newCh[++newStartIdx];
965
- } else if (newEndVnode == null) {
966
- newEndVnode = newCh[--newEndIdx];
967
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
968
- patch(oldStartVnode, newStartVnode, isInitialRender);
969
- oldStartVnode = oldCh[++oldStartIdx];
970
- newStartVnode = newCh[++newStartIdx];
971
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
972
- patch(oldEndVnode, newEndVnode, isInitialRender);
973
- oldEndVnode = oldCh[--oldEndIdx];
974
- newEndVnode = newCh[--newEndIdx];
975
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
976
- if (BUILD11.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
977
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
978
- }
979
- patch(oldStartVnode, newEndVnode, isInitialRender);
980
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
981
- oldStartVnode = oldCh[++oldStartIdx];
982
- newEndVnode = newCh[--newEndIdx];
983
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
984
- if (BUILD11.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
985
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
986
- }
987
- patch(oldEndVnode, newStartVnode, isInitialRender);
988
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
989
- oldEndVnode = oldCh[--oldEndIdx];
990
- newStartVnode = newCh[++newStartIdx];
991
- } else {
992
- idxInOld = -1;
993
- if (BUILD11.vdomKey) {
994
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
995
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
996
- idxInOld = i2;
997
- break;
998
- }
999
- }
1000
- }
1001
- if (BUILD11.vdomKey && idxInOld >= 0) {
1002
- elmToMove = oldCh[idxInOld];
1003
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1004
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
1005
- } else {
1006
- patch(elmToMove, newStartVnode, isInitialRender);
1007
- oldCh[idxInOld] = void 0;
1008
- node = elmToMove.$elm$;
1009
- }
1010
- newStartVnode = newCh[++newStartIdx];
1011
- } else {
1012
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1013
- newStartVnode = newCh[++newStartIdx];
1014
- }
1015
- if (node) {
1016
- if (BUILD11.slotRelocation) {
1017
- insertBefore(
1018
- referenceNode(oldStartVnode.$elm$).parentNode,
1019
- node,
1020
- referenceNode(oldStartVnode.$elm$)
1021
- );
1022
- } else {
1023
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1024
- }
1025
- }
806
+ var patchParentNode = (node) => {
807
+ if (!node || node.__parentNode) return;
808
+ patchHostOriginalAccessor("parentNode", node);
809
+ Object.defineProperty(node, "parentNode", {
810
+ get: function() {
811
+ var _a;
812
+ return ((_a = this["s-ol"]) == null ? void 0 : _a.parentNode) || this.__parentNode;
813
+ },
814
+ set: function(value) {
815
+ this.__parentNode = value;
1026
816
  }
817
+ });
818
+ };
819
+ var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
820
+ var validNodesPatches = [
821
+ "childNodes",
822
+ "firstChild",
823
+ "lastChild",
824
+ "nextSibling",
825
+ "previousSibling",
826
+ "textContent",
827
+ "parentNode"
828
+ ];
829
+ function patchHostOriginalAccessor(accessorName, node) {
830
+ let accessor;
831
+ if (validElementPatches.includes(accessorName)) {
832
+ accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
833
+ } else if (validNodesPatches.includes(accessorName)) {
834
+ accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1027
835
  }
1028
- if (oldStartIdx > oldEndIdx) {
1029
- addVnodes(
1030
- parentElm,
1031
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1032
- newVNode2,
1033
- newCh,
1034
- newStartIdx,
1035
- newEndIdx
1036
- );
1037
- } else if (BUILD11.updatable && newStartIdx > newEndIdx) {
1038
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
836
+ if (!accessor) {
837
+ accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1039
838
  }
1040
- };
1041
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1042
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1043
- if (BUILD11.slotRelocation && leftVNode.$tag$ === "slot") {
1044
- return leftVNode.$name$ === rightVNode.$name$;
1045
- }
1046
- if (BUILD11.vdomKey && !isInitialRender) {
1047
- return leftVNode.$key$ === rightVNode.$key$;
1048
- }
1049
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1050
- leftVNode.$key$ = rightVNode.$key$;
1051
- }
1052
- return true;
839
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
840
+ }
841
+ function intrnlCall(node, method) {
842
+ if ("__" + method in node) {
843
+ return node["__" + method];
844
+ } else {
845
+ return node[method];
1053
846
  }
1054
- return false;
1055
- };
1056
- var referenceNode = (node) => node && node["s-ol"] || node;
1057
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1058
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
1059
- const oldChildren = oldVNode.$children$;
1060
- const newChildren = newVNode2.$children$;
1061
- const tag = newVNode2.$tag$;
1062
- const text = newVNode2.$text$;
1063
- let defaultHolder;
1064
- if (!BUILD11.vdomText || text === null) {
1065
- if (BUILD11.svg) {
1066
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1067
- }
1068
- if (BUILD11.vdomAttribute || BUILD11.reflect) {
1069
- if (BUILD11.slot && tag === "slot" && !useNativeShadowDom) {
1070
- if (BUILD11.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1071
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1072
- relocateToHostRoot(newVNode2.$elm$.parentElement);
1073
- }
1074
- } else {
1075
- updateElement(oldVNode, newVNode2, isSvgMode);
1076
- }
1077
- }
1078
- if (BUILD11.updatable && oldChildren !== null && newChildren !== null) {
1079
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1080
- } else if (newChildren !== null) {
1081
- if (BUILD11.updatable && BUILD11.vdomText && oldVNode.$text$ !== null) {
1082
- elm.textContent = "";
1083
- }
1084
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1085
- } else if (
1086
- // don't do this on initial render as it can cause non-hydrated content to be removed
1087
- !isInitialRender && BUILD11.updatable && oldChildren !== null
1088
- ) {
1089
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1090
- }
1091
- if (BUILD11.svg && isSvgMode && tag === "svg") {
1092
- isSvgMode = false;
1093
- }
1094
- } else if (BUILD11.vdomText && BUILD11.slotRelocation && (defaultHolder = elm["s-cr"])) {
1095
- defaultHolder.parentNode.textContent = text;
1096
- } else if (BUILD11.vdomText && oldVNode.$text$ !== text) {
1097
- elm.data = text;
847
+ }
848
+
849
+ // src/runtime/profile.ts
850
+ import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
851
+ var i = 0;
852
+ var createTime = (fnName, tagName = "") => {
853
+ if (BUILD9.profile && performance.mark) {
854
+ const key = `st:${fnName}:${tagName}:${i++}`;
855
+ performance.mark(key);
856
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
857
+ } else {
858
+ return () => {
859
+ return;
860
+ };
1098
861
  }
1099
862
  };
1100
- var relocateNodes = [];
1101
- var markSlotContentForRelocation = (elm) => {
1102
- let node;
1103
- let hostContentNodes;
1104
- let j;
1105
- const children = elm.__childNodes || elm.childNodes;
1106
- for (const childNode of children) {
1107
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1108
- hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1109
- const slotName = childNode["s-sn"];
1110
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1111
- node = hostContentNodes[j];
1112
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD11.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1113
- if (isNodeLocatedInSlot(node, slotName)) {
1114
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1115
- checkSlotFallbackVisibility = true;
1116
- node["s-sn"] = node["s-sn"] || slotName;
1117
- if (relocateNodeData) {
1118
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1119
- relocateNodeData.$slotRefNode$ = childNode;
1120
- } else {
1121
- node["s-sh"] = childNode["s-hn"];
1122
- relocateNodes.push({
1123
- $slotRefNode$: childNode,
1124
- $nodeToRelocate$: node
1125
- });
1126
- }
1127
- if (node["s-sr"]) {
1128
- relocateNodes.map((relocateNode) => {
1129
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1130
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1131
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1132
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1133
- }
1134
- }
1135
- });
1136
- }
1137
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1138
- relocateNodes.push({
1139
- $nodeToRelocate$: node
1140
- });
1141
- }
1142
- }
1143
- }
1144
- }
1145
- if (childNode.nodeType === 1 /* ElementNode */) {
1146
- markSlotContentForRelocation(childNode);
863
+ var uniqueTime = (key, measureText) => {
864
+ if (BUILD9.profile && performance.mark) {
865
+ if (performance.getEntriesByName(key, "mark").length === 0) {
866
+ performance.mark(key);
1147
867
  }
868
+ return () => {
869
+ if (performance.getEntriesByName(measureText, "measure").length === 0) {
870
+ performance.measure(measureText, key);
871
+ }
872
+ };
873
+ } else {
874
+ return () => {
875
+ return;
876
+ };
1148
877
  }
1149
878
  };
1150
- var nullifyVNodeRefs = (vNode) => {
1151
- if (BUILD11.vdomRef) {
1152
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1153
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
879
+ var inspect = (ref) => {
880
+ const hostRef = getHostRef(ref);
881
+ if (!hostRef) {
882
+ return void 0;
1154
883
  }
884
+ const flags = hostRef.$flags$;
885
+ const hostElement = hostRef.$hostElement$;
886
+ return {
887
+ renderCount: hostRef.$renderCount$,
888
+ flags: {
889
+ hasRendered: !!(flags & 2 /* hasRendered */),
890
+ hasConnected: !!(flags & 1 /* hasConnected */),
891
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
892
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
893
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
894
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
895
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
896
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
897
+ isListenReady: !!(flags & 256 /* isListenReady */),
898
+ needsRerender: !!(flags & 512 /* needsRerender */)
899
+ },
900
+ instanceValues: hostRef.$instanceValues$,
901
+ ancestorComponent: hostRef.$ancestorComponent$,
902
+ hostElement,
903
+ lazyInstance: hostRef.$lazyInstance$,
904
+ vnode: hostRef.$vnode$,
905
+ modeName: hostRef.$modeName$,
906
+ onReadyPromise: hostRef.$onReadyPromise$,
907
+ onReadyResolve: hostRef.$onReadyResolve$,
908
+ onInstancePromise: hostRef.$onInstancePromise$,
909
+ onInstanceResolve: hostRef.$onInstanceResolve$,
910
+ onRenderResolve: hostRef.$onRenderResolve$,
911
+ queuedListeners: hostRef.$queuedListeners$,
912
+ rmListeners: hostRef.$rmListeners$,
913
+ ["s-id"]: hostElement["s-id"],
914
+ ["s-cr"]: hostElement["s-cr"],
915
+ ["s-lr"]: hostElement["s-lr"],
916
+ ["s-p"]: hostElement["s-p"],
917
+ ["s-rc"]: hostElement["s-rc"],
918
+ ["s-sc"]: hostElement["s-sc"]
919
+ };
1155
920
  };
1156
- var insertBefore = (parent, newNode, reference) => {
1157
- if (BUILD11.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1158
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
921
+ var installDevTools = () => {
922
+ if (BUILD9.devTools) {
923
+ const stencil = win.stencil = win.stencil || {};
924
+ const originalInspect = stencil.inspect;
925
+ stencil.inspect = (ref) => {
926
+ let result = inspect(ref);
927
+ if (!result && typeof originalInspect === "function") {
928
+ result = originalInspect(ref);
929
+ }
930
+ return result;
931
+ };
1159
932
  }
1160
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1161
- return inserted;
1162
933
  };
1163
- function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1164
- var _a;
1165
- let scopeId2;
1166
- if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1167
- const scopeName = slotNode["s-sn"];
1168
- const hostName = slotNode["s-hn"];
1169
- (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1170
- if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
1171
- let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1172
- let found = false;
1173
- while (child) {
1174
- if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1175
- found = true;
1176
- break;
934
+
935
+ // src/runtime/vdom/h.ts
936
+ import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
937
+ var h = (nodeName, vnodeData, ...children) => {
938
+ let child = null;
939
+ let key = null;
940
+ let slotName = null;
941
+ let simple = false;
942
+ let lastSimple = false;
943
+ const vNodeChildren = [];
944
+ const walk = (c) => {
945
+ for (let i2 = 0; i2 < c.length; i2++) {
946
+ child = c[i2];
947
+ if (Array.isArray(child)) {
948
+ walk(child);
949
+ } else if (child != null && typeof child !== "boolean") {
950
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
951
+ child = String(child);
952
+ } else if (BUILD10.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
953
+ consoleDevError(`vNode passed as children has unexpected type.
954
+ Make sure it's using the correct h() function.
955
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
1177
956
  }
1178
- child = child.nextSibling;
957
+ if (simple && lastSimple) {
958
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
959
+ } else {
960
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
961
+ }
962
+ lastSimple = simple;
963
+ }
964
+ }
965
+ };
966
+ walk(children);
967
+ if (vnodeData) {
968
+ if (BUILD10.isDev && nodeName === "input") {
969
+ validateInputProperties(vnodeData);
970
+ }
971
+ if (BUILD10.vdomKey && vnodeData.key) {
972
+ key = vnodeData.key;
973
+ }
974
+ if (BUILD10.slotRelocation && vnodeData.name) {
975
+ slotName = vnodeData.name;
976
+ }
977
+ if (BUILD10.vdomClass) {
978
+ const classData = vnodeData.className || vnodeData.class;
979
+ if (classData) {
980
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
1179
981
  }
1180
- if (!found) oldParent.classList.remove(scopeId2 + "-s");
1181
982
  }
1182
983
  }
1183
- }
1184
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1185
- var _a, _b, _c, _d, _e;
1186
- const hostElm = hostRef.$hostElement$;
1187
- const cmpMeta = hostRef.$cmpMeta$;
1188
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1189
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1190
- hostTagName = hostElm.tagName;
1191
- if (BUILD11.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1192
- throw new Error(`The <Host> must be the single root component.
1193
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1194
-
1195
- The render() function should look like this instead:
1196
-
1197
- render() {
1198
- // Do not return an array
1199
- return (
1200
- <Host>{content}</Host>
1201
- );
1202
- }
1203
- `);
984
+ if (BUILD10.isDev && vNodeChildren.some(isHost)) {
985
+ consoleDevError(`The <Host> must be the single root component. Make sure:
986
+ - You are NOT using hostData() and <Host> in the same component.
987
+ - <Host> is used once, and it's the single root component of the render() function.`);
1204
988
  }
1205
- if (BUILD11.reflect && cmpMeta.$attrsToReflect$) {
1206
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1207
- cmpMeta.$attrsToReflect$.map(
1208
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
989
+ if (BUILD10.vdomFunctional && typeof nodeName === "function") {
990
+ return nodeName(
991
+ vnodeData === null ? {} : vnodeData,
992
+ vNodeChildren,
993
+ vdomFnUtils
1209
994
  );
1210
995
  }
1211
- if (isInitialLoad && rootVnode.$attrs$) {
1212
- for (const key of Object.keys(rootVnode.$attrs$)) {
1213
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1214
- rootVnode.$attrs$[key] = hostElm[key];
1215
- }
1216
- }
996
+ const vnode = newVNode(nodeName, null);
997
+ vnode.$attrs$ = vnodeData;
998
+ if (vNodeChildren.length > 0) {
999
+ vnode.$children$ = vNodeChildren;
1217
1000
  }
1218
- rootVnode.$tag$ = null;
1219
- rootVnode.$flags$ |= 4 /* isHost */;
1220
- hostRef.$vnode$ = rootVnode;
1221
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD11.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1222
- if (BUILD11.scoped || BUILD11.shadowDom) {
1223
- scopeId = hostElm["s-sc"];
1001
+ if (BUILD10.vdomKey) {
1002
+ vnode.$key$ = key;
1224
1003
  }
1225
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1226
- if (BUILD11.slotRelocation) {
1227
- contentRef = hostElm["s-cr"];
1228
- checkSlotFallbackVisibility = false;
1004
+ if (BUILD10.slotRelocation) {
1005
+ vnode.$name$ = slotName;
1229
1006
  }
1230
- patch(oldVNode, rootVnode, isInitialLoad);
1231
- if (BUILD11.slotRelocation) {
1232
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1233
- if (checkSlotRelocate) {
1234
- markSlotContentForRelocation(rootVnode.$elm$);
1235
- for (const relocateData of relocateNodes) {
1236
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1237
- if (!nodeToRelocate["s-ol"]) {
1238
- const orgLocationNode = BUILD11.isDebug || BUILD11.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1239
- orgLocationNode["s-nr"] = nodeToRelocate;
1240
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1241
- }
1007
+ return vnode;
1008
+ };
1009
+ var newVNode = (tag, text) => {
1010
+ const vnode = {
1011
+ $flags$: 0,
1012
+ $tag$: tag,
1013
+ $text$: text,
1014
+ $elm$: null,
1015
+ $children$: null
1016
+ };
1017
+ if (BUILD10.vdomAttribute) {
1018
+ vnode.$attrs$ = null;
1019
+ }
1020
+ if (BUILD10.vdomKey) {
1021
+ vnode.$key$ = null;
1022
+ }
1023
+ if (BUILD10.slotRelocation) {
1024
+ vnode.$name$ = null;
1025
+ }
1026
+ return vnode;
1027
+ };
1028
+ var Host = {};
1029
+ var isHost = (node) => node && node.$tag$ === Host;
1030
+ var vdomFnUtils = {
1031
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
1032
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
1033
+ };
1034
+ var convertToPublic = (node) => ({
1035
+ vattrs: node.$attrs$,
1036
+ vchildren: node.$children$,
1037
+ vkey: node.$key$,
1038
+ vname: node.$name$,
1039
+ vtag: node.$tag$,
1040
+ vtext: node.$text$
1041
+ });
1042
+ var convertToPrivate = (node) => {
1043
+ if (typeof node.vtag === "function") {
1044
+ const vnodeData = { ...node.vattrs };
1045
+ if (node.vkey) {
1046
+ vnodeData.key = node.vkey;
1047
+ }
1048
+ if (node.vname) {
1049
+ vnodeData.name = node.vname;
1050
+ }
1051
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
1052
+ }
1053
+ const vnode = newVNode(node.vtag, node.vtext);
1054
+ vnode.$attrs$ = node.vattrs;
1055
+ vnode.$children$ = node.vchildren;
1056
+ vnode.$key$ = node.vkey;
1057
+ vnode.$name$ = node.vname;
1058
+ return vnode;
1059
+ };
1060
+ var validateInputProperties = (inputElm) => {
1061
+ const props = Object.keys(inputElm);
1062
+ const value = props.indexOf("value");
1063
+ if (value === -1) {
1064
+ return;
1065
+ }
1066
+ const typeIndex = props.indexOf("type");
1067
+ const minIndex = props.indexOf("min");
1068
+ const maxIndex = props.indexOf("max");
1069
+ const stepIndex = props.indexOf("step");
1070
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
1071
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
1072
+ }
1073
+ };
1074
+
1075
+ // src/runtime/client-hydrate.ts
1076
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1077
+ const endHydrate = createTime("hydrateClient", tagName);
1078
+ const shadowRoot = hostElm.shadowRoot;
1079
+ const childRenderNodes = [];
1080
+ const slotNodes = [];
1081
+ const slottedNodes = [];
1082
+ const shadowRootNodes = BUILD11.shadowDom && shadowRoot ? [] : null;
1083
+ const vnode = newVNode(tagName, null);
1084
+ vnode.$elm$ = hostElm;
1085
+ let scopeId2;
1086
+ if (BUILD11.scoped) {
1087
+ const cmpMeta = hostRef.$cmpMeta$;
1088
+ if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1089
+ scopeId2 = hostElm["s-sc"];
1090
+ hostElm.classList.add(scopeId2 + "-h");
1091
+ } else if (hostElm["s-sc"]) {
1092
+ delete hostElm["s-sc"];
1093
+ }
1094
+ }
1095
+ if (!plt.$orgLocNodes$) {
1096
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1097
+ }
1098
+ hostElm[HYDRATE_ID] = hostId;
1099
+ hostElm.removeAttribute(HYDRATE_ID);
1100
+ hostRef.$vnode$ = clientHydrate(
1101
+ vnode,
1102
+ childRenderNodes,
1103
+ slotNodes,
1104
+ shadowRootNodes,
1105
+ hostElm,
1106
+ hostElm,
1107
+ hostId,
1108
+ slottedNodes
1109
+ );
1110
+ let crIndex = 0;
1111
+ const crLength = childRenderNodes.length;
1112
+ let childRenderNode;
1113
+ for (crIndex; crIndex < crLength; crIndex++) {
1114
+ childRenderNode = childRenderNodes[crIndex];
1115
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1116
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1117
+ const node = childRenderNode.$elm$;
1118
+ if (!shadowRoot) {
1119
+ node["s-hn"] = tagName.toUpperCase();
1120
+ if (childRenderNode.$tag$ === "slot") {
1121
+ node["s-cr"] = hostElm["s-cr"];
1242
1122
  }
1243
- for (const relocateData of relocateNodes) {
1244
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1245
- const slotRefNode = relocateData.$slotRefNode$;
1246
- if (slotRefNode) {
1247
- const parentNodeRef = slotRefNode.parentNode;
1248
- let insertBeforeNode = slotRefNode.nextSibling;
1249
- if (!BUILD11.hydrateServerSide && (!BUILD11.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
1250
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1251
- while (orgLocationNode) {
1252
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1253
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1254
- refNode = refNode.nextSibling;
1255
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1256
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1257
- }
1258
- if (!refNode || !refNode["s-nr"]) {
1259
- insertBeforeNode = refNode;
1260
- break;
1261
- }
1262
- }
1263
- orgLocationNode = orgLocationNode.previousSibling;
1264
- }
1265
- }
1266
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1267
- if (nodeToRelocate !== insertBeforeNode) {
1268
- if (!BUILD11.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1269
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1270
- }
1271
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1272
- if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1273
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1274
- }
1275
- }
1276
- }
1277
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1278
- } else {
1279
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1280
- if (isInitialLoad) {
1281
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1282
- }
1283
- nodeToRelocate.hidden = true;
1284
- }
1123
+ }
1124
+ if (childRenderNode.$tag$ === "slot") {
1125
+ if (childRenderNode.$children$) {
1126
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1127
+ if (!childRenderNode.$elm$.childNodes.length) {
1128
+ childRenderNode.$children$.forEach((c) => {
1129
+ childRenderNode.$elm$.appendChild(c.$elm$);
1130
+ });
1285
1131
  }
1132
+ } else {
1133
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
1286
1134
  }
1287
1135
  }
1288
- if (checkSlotFallbackVisibility) {
1289
- updateFallbackSlotVisibility(rootVnode.$elm$);
1136
+ if (orgLocationNode && orgLocationNode.isConnected) {
1137
+ if (shadowRoot && orgLocationNode["s-en"] === "") {
1138
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1139
+ }
1140
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
1141
+ if (!shadowRoot) {
1142
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1143
+ }
1290
1144
  }
1291
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1292
- relocateNodes.length = 0;
1145
+ plt.$orgLocNodes$.delete(orgLocationId);
1293
1146
  }
1294
- if (BUILD11.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1295
- const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1296
- for (const childNode of children) {
1297
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1298
- if (isInitialLoad && childNode["s-ih"] == null) {
1299
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1147
+ const hosts = [];
1148
+ const snLen = slottedNodes.length;
1149
+ let snIndex = 0;
1150
+ let slotGroup;
1151
+ let snGroupIdx;
1152
+ let snGroupLen;
1153
+ let slottedItem;
1154
+ for (snIndex; snIndex < snLen; snIndex++) {
1155
+ slotGroup = slottedNodes[snIndex];
1156
+ if (!slotGroup || !slotGroup.length) continue;
1157
+ snGroupLen = slotGroup.length;
1158
+ snGroupIdx = 0;
1159
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1160
+ slottedItem = slotGroup[snGroupIdx];
1161
+ if (!hosts[slottedItem.hostId]) {
1162
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1163
+ }
1164
+ if (!hosts[slottedItem.hostId]) continue;
1165
+ const hostEle = hosts[slottedItem.hostId];
1166
+ if (!hostEle.shadowRoot || !shadowRoot) {
1167
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1168
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1169
+ slottedItem.slot["s-cr"] = hostEle;
1170
+ } else {
1171
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1300
1172
  }
1301
- childNode.hidden = true;
1173
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1174
+ if (BUILD11.experimentalSlotFixes) {
1175
+ patchSlottedNode(slottedItem.node);
1176
+ }
1177
+ }
1178
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1179
+ hostEle.appendChild(slottedItem.node);
1302
1180
  }
1303
1181
  }
1304
1182
  }
1305
- contentRef = void 0;
1183
+ if (BUILD11.scoped && scopeId2 && slotNodes.length) {
1184
+ slotNodes.forEach((slot) => {
1185
+ slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1186
+ });
1187
+ }
1188
+ if (BUILD11.shadowDom && shadowRoot) {
1189
+ let rnIdex = 0;
1190
+ const rnLen = shadowRootNodes.length;
1191
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
1192
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1193
+ }
1194
+ Array.from(hostElm.childNodes).forEach((node) => {
1195
+ if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1196
+ node.parentNode.removeChild(node);
1197
+ }
1198
+ });
1199
+ }
1200
+ hostRef.$hostElement$ = hostElm;
1201
+ endHydrate();
1306
1202
  };
1307
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1308
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1309
- );
1310
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1311
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1312
- );
1313
-
1314
- // src/runtime/dom-extras.ts
1315
- var patchPseudoShadowDom = (hostElementPrototype) => {
1316
- patchCloneNode(hostElementPrototype);
1317
- patchSlotAppendChild(hostElementPrototype);
1318
- patchSlotAppend(hostElementPrototype);
1319
- patchSlotPrepend(hostElementPrototype);
1320
- patchSlotInsertAdjacentElement(hostElementPrototype);
1321
- patchSlotInsertAdjacentHTML(hostElementPrototype);
1322
- patchSlotInsertAdjacentText(hostElementPrototype);
1323
- patchTextContent(hostElementPrototype);
1324
- patchChildSlotNodes(hostElementPrototype);
1325
- patchSlotRemoveChild(hostElementPrototype);
1326
- };
1327
- var patchCloneNode = (HostElementPrototype) => {
1328
- const orgCloneNode = HostElementPrototype.cloneNode;
1329
- HostElementPrototype.cloneNode = function(deep) {
1330
- const srcNode = this;
1331
- const isShadowDom = BUILD12.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
1332
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1333
- if (BUILD12.slot && !isShadowDom && deep) {
1334
- let i2 = 0;
1335
- let slotted, nonStencilNode;
1336
- const stencilPrivates = [
1337
- "s-id",
1338
- "s-cr",
1339
- "s-lr",
1340
- "s-rc",
1341
- "s-sc",
1342
- "s-p",
1343
- "s-cn",
1344
- "s-sr",
1345
- "s-sn",
1346
- "s-hn",
1347
- "s-ol",
1348
- "s-nr",
1349
- "s-si",
1350
- "s-rf",
1351
- "s-scs"
1352
- ];
1353
- const childNodes = this.__childNodes || this.childNodes;
1354
- for (; i2 < childNodes.length; i2++) {
1355
- slotted = childNodes[i2]["s-nr"];
1356
- nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i2][privateField]);
1357
- if (slotted) {
1358
- if (BUILD12.appendChildSlotFix && clonedNode.__appendChild) {
1359
- clonedNode.__appendChild(slotted.cloneNode(true));
1360
- } else {
1361
- clonedNode.appendChild(slotted.cloneNode(true));
1203
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1204
+ let childNodeType;
1205
+ let childIdSplt;
1206
+ let childVNode;
1207
+ let i2;
1208
+ const scopeId2 = hostElm["s-sc"];
1209
+ if (node.nodeType === 1 /* ElementNode */) {
1210
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1211
+ if (childNodeType) {
1212
+ childIdSplt = childNodeType.split(".");
1213
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1214
+ childVNode = createSimpleVNode({
1215
+ $flags$: 0,
1216
+ $hostId$: childIdSplt[0],
1217
+ $nodeId$: childIdSplt[1],
1218
+ $depth$: childIdSplt[2],
1219
+ $index$: childIdSplt[3],
1220
+ $tag$: node.tagName.toLowerCase(),
1221
+ $elm$: node,
1222
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1223
+ // won't try to reconcile them. Classes set on the node will be blown away.
1224
+ $attrs$: { class: node.className || "" }
1225
+ });
1226
+ childRenderNodes.push(childVNode);
1227
+ node.removeAttribute(HYDRATE_CHILD_ID);
1228
+ if (!parentVNode.$children$) {
1229
+ parentVNode.$children$ = [];
1230
+ }
1231
+ if (BUILD11.scoped && scopeId2) {
1232
+ node["s-si"] = scopeId2;
1233
+ childVNode.$attrs$.class += " " + scopeId2;
1234
+ }
1235
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
1236
+ if (typeof slotName === "string") {
1237
+ if (childVNode.$tag$ === "slot-fb") {
1238
+ addSlot(
1239
+ slotName,
1240
+ childIdSplt[2],
1241
+ childVNode,
1242
+ node,
1243
+ parentVNode,
1244
+ childRenderNodes,
1245
+ slotNodes,
1246
+ shadowRootNodes,
1247
+ slottedNodes
1248
+ );
1249
+ if (BUILD11.scoped && scopeId2) {
1250
+ node.classList.add(scopeId2);
1251
+ }
1362
1252
  }
1253
+ childVNode.$elm$["s-sn"] = slotName;
1254
+ childVNode.$elm$.removeAttribute("s-sn");
1363
1255
  }
1364
- if (nonStencilNode) {
1365
- clonedNode.appendChild(childNodes[i2].cloneNode(true));
1256
+ if (childVNode.$index$ !== void 0) {
1257
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1258
+ }
1259
+ parentVNode = childVNode;
1260
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1261
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1366
1262
  }
1367
1263
  }
1368
1264
  }
1369
- return clonedNode;
1370
- };
1371
- };
1372
- var patchSlotAppendChild = (HostElementPrototype) => {
1373
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1374
- HostElementPrototype.appendChild = function(newChild) {
1375
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1376
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
1377
- if (slotNode) {
1378
- addSlotRelocateNode(newChild, slotNode);
1379
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1380
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1381
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1382
- updateFallbackSlotVisibility(this);
1383
- return insertedNode;
1265
+ if (node.shadowRoot) {
1266
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1267
+ clientHydrate(
1268
+ parentVNode,
1269
+ childRenderNodes,
1270
+ slotNodes,
1271
+ shadowRootNodes,
1272
+ hostElm,
1273
+ node.shadowRoot.childNodes[i2],
1274
+ hostId,
1275
+ slottedNodes
1276
+ );
1277
+ }
1384
1278
  }
1385
- return this.__appendChild(newChild);
1386
- };
1279
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1280
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1281
+ clientHydrate(
1282
+ parentVNode,
1283
+ childRenderNodes,
1284
+ slotNodes,
1285
+ shadowRootNodes,
1286
+ hostElm,
1287
+ nonShadowNodes[i2],
1288
+ hostId,
1289
+ slottedNodes
1290
+ );
1291
+ }
1292
+ } else if (node.nodeType === 8 /* CommentNode */) {
1293
+ childIdSplt = node.nodeValue.split(".");
1294
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1295
+ childNodeType = childIdSplt[0];
1296
+ childVNode = createSimpleVNode({
1297
+ $hostId$: childIdSplt[1],
1298
+ $nodeId$: childIdSplt[2],
1299
+ $depth$: childIdSplt[3],
1300
+ $index$: childIdSplt[4] || "0",
1301
+ $elm$: node,
1302
+ $attrs$: null,
1303
+ $children$: null,
1304
+ $key$: null,
1305
+ $name$: null,
1306
+ $tag$: null,
1307
+ $text$: null
1308
+ });
1309
+ if (childNodeType === TEXT_NODE_ID) {
1310
+ childVNode.$elm$ = node.nextSibling;
1311
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1312
+ childVNode.$text$ = childVNode.$elm$.textContent;
1313
+ childRenderNodes.push(childVNode);
1314
+ node.remove();
1315
+ if (hostId === childVNode.$hostId$) {
1316
+ if (!parentVNode.$children$) {
1317
+ parentVNode.$children$ = [];
1318
+ }
1319
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1320
+ }
1321
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1322
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1323
+ }
1324
+ }
1325
+ } else if (childNodeType === COMMENT_NODE_ID) {
1326
+ childVNode.$elm$ = node.nextSibling;
1327
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1328
+ childRenderNodes.push(childVNode);
1329
+ node.remove();
1330
+ }
1331
+ } else if (childVNode.$hostId$ === hostId) {
1332
+ if (childNodeType === SLOT_NODE_ID) {
1333
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
1334
+ addSlot(
1335
+ slotName,
1336
+ childIdSplt[2],
1337
+ childVNode,
1338
+ node,
1339
+ parentVNode,
1340
+ childRenderNodes,
1341
+ slotNodes,
1342
+ shadowRootNodes,
1343
+ slottedNodes
1344
+ );
1345
+ } else if (childNodeType === CONTENT_REF_ID) {
1346
+ if (BUILD11.shadowDom && shadowRootNodes) {
1347
+ node.remove();
1348
+ } else if (BUILD11.slotRelocation) {
1349
+ hostElm["s-cr"] = node;
1350
+ node["s-cn"] = true;
1351
+ }
1352
+ }
1353
+ }
1354
+ }
1355
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1356
+ const vnode = newVNode(null, node.textContent);
1357
+ vnode.$elm$ = node;
1358
+ vnode.$index$ = "0";
1359
+ parentVNode.$children$ = [vnode];
1360
+ }
1361
+ return parentVNode;
1387
1362
  };
1388
- var patchSlotRemoveChild = (ElementPrototype) => {
1389
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
1390
- ElementPrototype.removeChild = function(toRemove) {
1391
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
1392
- const childNodes = this.__childNodes || this.childNodes;
1393
- const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
1394
- if (slotNode && toRemove.isConnected) {
1395
- toRemove.remove();
1396
- updateFallbackSlotVisibility(this);
1397
- return;
1363
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
1364
+ if (node.nodeType === 1 /* ElementNode */) {
1365
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1366
+ if (componentId) {
1367
+ orgLocNodes.set(componentId, node);
1368
+ }
1369
+ let i2 = 0;
1370
+ if (node.shadowRoot) {
1371
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1372
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1398
1373
  }
1399
1374
  }
1400
- return this.__removeChild(toRemove);
1375
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1376
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1377
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1378
+ }
1379
+ } else if (node.nodeType === 8 /* CommentNode */) {
1380
+ const childIdSplt = node.nodeValue.split(".");
1381
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1382
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1383
+ node.nodeValue = "";
1384
+ node["s-en"] = childIdSplt[3];
1385
+ }
1386
+ }
1387
+ };
1388
+ var createSimpleVNode = (vnode) => {
1389
+ const defaultVNode = {
1390
+ $flags$: 0,
1391
+ $hostId$: null,
1392
+ $nodeId$: null,
1393
+ $depth$: null,
1394
+ $index$: "0",
1395
+ $elm$: null,
1396
+ $attrs$: null,
1397
+ $children$: null,
1398
+ $key$: null,
1399
+ $name$: null,
1400
+ $tag$: null,
1401
+ $text$: null
1401
1402
  };
1403
+ return { ...defaultVNode, ...vnode };
1402
1404
  };
1403
- var patchSlotPrepend = (HostElementPrototype) => {
1404
- HostElementPrototype.__prepend = HostElementPrototype.prepend;
1405
- HostElementPrototype.prepend = function(...newChildren) {
1406
- newChildren.forEach((newChild) => {
1407
- if (typeof newChild === "string") {
1408
- newChild = this.ownerDocument.createTextNode(newChild);
1409
- }
1410
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1411
- const childNodes = this.__childNodes || this.childNodes;
1412
- const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
1413
- if (slotNode) {
1414
- addSlotRelocateNode(newChild, slotNode, true);
1415
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1416
- const appendAfter = slotChildNodes[0];
1417
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1418
- }
1419
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
1420
- newChild.hidden = true;
1421
- }
1422
- return HostElementPrototype.__prepend(newChild);
1423
- });
1424
- };
1425
- };
1426
- var patchSlotAppend = (HostElementPrototype) => {
1427
- HostElementPrototype.__append = HostElementPrototype.append;
1428
- HostElementPrototype.append = function(...newChildren) {
1429
- newChildren.forEach((newChild) => {
1430
- if (typeof newChild === "string") {
1431
- newChild = this.ownerDocument.createTextNode(newChild);
1432
- }
1433
- this.appendChild(newChild);
1434
- });
1435
- };
1436
- };
1437
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
1438
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
1439
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
1440
- if (position !== "afterbegin" && position !== "beforeend") {
1441
- return originalInsertAdjacentHtml.call(this, position, text);
1442
- }
1443
- const container = this.ownerDocument.createElement("_");
1444
- let node;
1445
- container.innerHTML = text;
1446
- if (position === "afterbegin") {
1447
- while (node = container.firstChild) {
1448
- this.prepend(node);
1449
- }
1450
- } else if (position === "beforeend") {
1451
- while (node = container.firstChild) {
1452
- this.append(node);
1453
- }
1454
- }
1455
- };
1456
- };
1457
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
1458
- HostElementPrototype.insertAdjacentText = function(position, text) {
1459
- this.insertAdjacentHTML(position, text);
1460
- };
1461
- };
1462
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
1463
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
1464
- HostElementPrototype.insertAdjacentElement = function(position, element) {
1465
- if (position !== "afterbegin" && position !== "beforeend") {
1466
- return originalInsertAdjacentElement.call(this, position, element);
1405
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1406
+ node["s-sr"] = true;
1407
+ childVNode.$name$ = slotName || null;
1408
+ childVNode.$tag$ = "slot";
1409
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1410
+ if (BUILD11.shadowDom && shadowRootNodes) {
1411
+ const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1412
+ if (childVNode.$name$) {
1413
+ childVNode.$elm$.setAttribute("name", slotName);
1467
1414
  }
1468
- if (position === "afterbegin") {
1469
- this.prepend(element);
1470
- return element;
1471
- } else if (position === "beforeend") {
1472
- this.append(element);
1473
- return element;
1415
+ if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1416
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1417
+ } else {
1418
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1474
1419
  }
1475
- return element;
1476
- };
1477
- };
1478
- var patchTextContent = (hostElementPrototype) => {
1479
- patchHostOriginalAccessor("textContent", hostElementPrototype);
1480
- Object.defineProperty(hostElementPrototype, "textContent", {
1481
- get: function() {
1482
- let text = "";
1483
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1484
- childNodes.forEach((node) => text += node.textContent || "");
1485
- return text;
1486
- },
1487
- set: function(value) {
1488
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1489
- childNodes.forEach((node) => {
1490
- if (node["s-ol"]) node["s-ol"].remove();
1491
- node.remove();
1492
- });
1493
- this.insertAdjacentHTML("beforeend", value);
1420
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1421
+ node.remove();
1422
+ if (childVNode.$depth$ === "0") {
1423
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1494
1424
  }
1495
- });
1496
- };
1497
- var patchChildSlotNodes = (elm) => {
1498
- class FakeNodeList extends Array {
1499
- item(n) {
1500
- return this[n];
1425
+ } else {
1426
+ const slot = childVNode.$elm$;
1427
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1428
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1429
+ if (shouldMove) {
1430
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1501
1431
  }
1432
+ childRenderNodes.push(childVNode);
1502
1433
  }
1503
- patchHostOriginalAccessor("children", elm);
1504
- Object.defineProperty(elm, "children", {
1505
- get() {
1506
- return this.childNodes.filter((n) => n.nodeType === 1);
1507
- }
1508
- });
1509
- Object.defineProperty(elm, "childElementCount", {
1510
- get() {
1511
- return this.children.length;
1512
- }
1513
- });
1514
- patchHostOriginalAccessor("firstChild", elm);
1515
- Object.defineProperty(elm, "firstChild", {
1516
- get() {
1517
- return this.childNodes[0];
1434
+ slotNodes.push(childVNode);
1435
+ if (!parentVNode.$children$) {
1436
+ parentVNode.$children$ = [];
1437
+ }
1438
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1439
+ }
1440
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1441
+ let slottedNode = slotNode.nextSibling;
1442
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1443
+ while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
1444
+ slottedNode["s-sn"] = slotName;
1445
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1446
+ slottedNode = slottedNode.nextSibling;
1447
+ }
1448
+ };
1449
+
1450
+ // src/runtime/initialize-component.ts
1451
+ import { BUILD as BUILD22 } from "@stencil/core/internal/app-data";
1452
+
1453
+ // src/runtime/mode.ts
1454
+ var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1455
+ var setMode = (handler) => modeResolutionChain.push(handler);
1456
+ var getMode = (ref) => getHostRef(ref).$modeName$;
1457
+
1458
+ // src/runtime/proxy-component.ts
1459
+ import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
1460
+
1461
+ // src/runtime/set-value.ts
1462
+ import { BUILD as BUILD20 } from "@stencil/core/internal/app-data";
1463
+
1464
+ // src/runtime/parse-property-value.ts
1465
+ import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
1466
+ var parsePropertyValue = (propValue, propType) => {
1467
+ if (propValue != null && !isComplexType(propValue)) {
1468
+ if (BUILD12.propBoolean && propType & 4 /* Boolean */) {
1469
+ return propValue === "false" ? false : propValue === "" || !!propValue;
1518
1470
  }
1519
- });
1520
- patchHostOriginalAccessor("lastChild", elm);
1521
- Object.defineProperty(elm, "lastChild", {
1522
- get() {
1523
- return this.childNodes[this.childNodes.length - 1];
1471
+ if (BUILD12.propNumber && propType & 2 /* Number */) {
1472
+ return parseFloat(propValue);
1524
1473
  }
1525
- });
1526
- patchHostOriginalAccessor("childNodes", elm);
1527
- Object.defineProperty(elm, "childNodes", {
1528
- get() {
1529
- var _a, _b;
1530
- if (!plt.$flags$ || !((_a = getHostRef(this)) == null ? void 0 : _a.$flags$) || (plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && ((_b = getHostRef(this)) == null ? void 0 : _b.$flags$) & 2 /* hasRendered */) {
1531
- const result = new FakeNodeList();
1532
- const nodes = getSlottedChildNodes(this.__childNodes);
1533
- result.push(...nodes);
1534
- return result;
1535
- }
1536
- return FakeNodeList.from(this.__childNodes);
1474
+ if (BUILD12.propString && propType & 1 /* String */) {
1475
+ return String(propValue);
1537
1476
  }
1538
- });
1539
- };
1540
- var patchNextPrev = (node) => {
1541
- if (!node || node.__nextSibling || !globalThis.Node) return;
1542
- patchNextSibling(node);
1543
- patchPreviousSibling(node);
1544
- if (node.nodeType === Node.ELEMENT_NODE) {
1545
- patchNextElementSibling(node);
1546
- patchPreviousElementSibling(node);
1477
+ return propValue;
1547
1478
  }
1479
+ return propValue;
1548
1480
  };
1549
- var patchNextSibling = (node) => {
1550
- if (!node || node.__nextSibling) return;
1551
- patchHostOriginalAccessor("nextSibling", node);
1552
- Object.defineProperty(node, "nextSibling", {
1553
- get: function() {
1554
- var _a;
1555
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1556
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1557
- if (parentNodes && index > -1) {
1558
- return parentNodes[index + 1];
1481
+
1482
+ // src/runtime/update-component.ts
1483
+ import { BUILD as BUILD19, NAMESPACE } from "@stencil/core/internal/app-data";
1484
+
1485
+ // src/runtime/event-emitter.ts
1486
+ import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
1487
+
1488
+ // src/runtime/element.ts
1489
+ import { BUILD as BUILD13 } from "@stencil/core/internal/app-data";
1490
+ var getElement = (ref) => BUILD13.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1491
+
1492
+ // src/runtime/event-emitter.ts
1493
+ var createEvent = (ref, name, flags) => {
1494
+ const elm = getElement(ref);
1495
+ return {
1496
+ emit: (detail) => {
1497
+ if (BUILD14.isDev && !elm.isConnected) {
1498
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1559
1499
  }
1560
- return this.__nextSibling;
1500
+ return emitEvent(elm, name, {
1501
+ bubbles: !!(flags & 4 /* Bubbles */),
1502
+ composed: !!(flags & 2 /* Composed */),
1503
+ cancelable: !!(flags & 1 /* Cancellable */),
1504
+ detail
1505
+ });
1561
1506
  }
1562
- });
1507
+ };
1563
1508
  };
1564
- var patchNextElementSibling = (element) => {
1565
- if (!element || element.__nextElementSibling) return;
1566
- patchHostOriginalAccessor("nextElementSibling", element);
1567
- Object.defineProperty(element, "nextElementSibling", {
1568
- get: function() {
1569
- var _a;
1570
- const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1571
- const index = parentEles == null ? void 0 : parentEles.indexOf(this);
1572
- if (parentEles && index > -1) {
1573
- return parentEles[index + 1];
1574
- }
1575
- return this.__nextElementSibling;
1576
- }
1577
- });
1509
+ var emitEvent = (elm, name, opts) => {
1510
+ const ev = plt.ce(name, opts);
1511
+ elm.dispatchEvent(ev);
1512
+ return ev;
1578
1513
  };
1579
- var patchPreviousSibling = (node) => {
1580
- if (!node || node.__previousSibling) return;
1581
- patchHostOriginalAccessor("previousSibling", node);
1582
- Object.defineProperty(node, "previousSibling", {
1583
- get: function() {
1584
- var _a;
1585
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1586
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1587
- if (parentNodes && index > -1) {
1588
- return parentNodes[index - 1];
1589
- }
1590
- return this.__previousSibling;
1514
+
1515
+ // src/runtime/styles.ts
1516
+ import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
1517
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1518
+ var registerStyle = (scopeId2, cssText, allowCS) => {
1519
+ let style = styles.get(scopeId2);
1520
+ if (supportsConstructableStylesheets && allowCS) {
1521
+ style = style || new CSSStyleSheet();
1522
+ if (typeof style === "string") {
1523
+ style = cssText;
1524
+ } else {
1525
+ style.replaceSync(cssText);
1591
1526
  }
1592
- });
1527
+ } else {
1528
+ style = cssText;
1529
+ }
1530
+ styles.set(scopeId2, style);
1593
1531
  };
1594
- var patchPreviousElementSibling = (element) => {
1595
- if (!element || element.__previousElementSibling) return;
1596
- patchHostOriginalAccessor("previousElementSibling", element);
1597
- Object.defineProperty(element, "previousElementSibling", {
1598
- get: function() {
1599
- var _a;
1600
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1601
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1602
- if (parentNodes && index > -1) {
1603
- return parentNodes[index - 1];
1532
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1533
+ var _a;
1534
+ const scopeId2 = getScopeId(cmpMeta, mode);
1535
+ const style = styles.get(scopeId2);
1536
+ if (!BUILD15.attachStyles) {
1537
+ return scopeId2;
1538
+ }
1539
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1540
+ if (style) {
1541
+ if (typeof style === "string") {
1542
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
1543
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1544
+ let styleElm;
1545
+ if (!appliedStyles) {
1546
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1604
1547
  }
1605
- return this.__previousElementSibling;
1548
+ if (!appliedStyles.has(scopeId2)) {
1549
+ if (BUILD15.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1550
+ styleElm.innerHTML = style;
1551
+ } else {
1552
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1553
+ styleElm.innerHTML = style;
1554
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1555
+ if (nonce != null) {
1556
+ styleElm.setAttribute("nonce", nonce);
1557
+ }
1558
+ if ((BUILD15.hydrateServerSide || BUILD15.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1559
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1560
+ }
1561
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
1562
+ if (styleContainerNode.nodeName === "HEAD") {
1563
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1564
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1565
+ styleContainerNode.insertBefore(styleElm, referenceNode2);
1566
+ } else if ("host" in styleContainerNode) {
1567
+ if (supportsConstructableStylesheets) {
1568
+ const stylesheet = new CSSStyleSheet();
1569
+ stylesheet.replaceSync(style);
1570
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1571
+ } else {
1572
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1573
+ if (existingStyleContainer) {
1574
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
1575
+ } else {
1576
+ styleContainerNode.prepend(styleElm);
1577
+ }
1578
+ }
1579
+ } else {
1580
+ styleContainerNode.append(styleElm);
1581
+ }
1582
+ }
1583
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
1584
+ styleContainerNode.insertBefore(styleElm, null);
1585
+ }
1586
+ }
1587
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1588
+ styleElm.innerHTML += SLOT_FB_CSS;
1589
+ }
1590
+ if (appliedStyles) {
1591
+ appliedStyles.add(scopeId2);
1592
+ }
1593
+ }
1594
+ } else if (BUILD15.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1595
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1606
1596
  }
1607
- });
1608
- };
1609
- var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
1610
- var validNodesPatches = [
1611
- "childNodes",
1612
- "firstChild",
1613
- "lastChild",
1614
- "nextSibling",
1615
- "previousSibling",
1616
- "textContent"
1617
- ];
1618
- function patchHostOriginalAccessor(accessorName, node) {
1619
- let accessor;
1620
- if (validElementPatches.includes(accessorName)) {
1621
- accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1622
- } else if (validNodesPatches.includes(accessorName)) {
1623
- accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1624
1597
  }
1625
- if (!accessor) {
1626
- accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1627
- }
1628
- if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1629
- }
1630
-
1631
- // src/runtime/profile.ts
1632
- import { BUILD as BUILD13 } from "@stencil/core/internal/app-data";
1633
- var i = 0;
1634
- var createTime = (fnName, tagName = "") => {
1635
- if (BUILD13.profile && performance.mark) {
1636
- const key = `st:${fnName}:${tagName}:${i++}`;
1637
- performance.mark(key);
1638
- return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
1639
- } else {
1640
- return () => {
1641
- return;
1642
- };
1598
+ return scopeId2;
1599
+ };
1600
+ var attachStyles = (hostRef) => {
1601
+ const cmpMeta = hostRef.$cmpMeta$;
1602
+ const elm = hostRef.$hostElement$;
1603
+ const flags = cmpMeta.$flags$;
1604
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1605
+ const scopeId2 = addStyle(
1606
+ BUILD15.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
1607
+ cmpMeta,
1608
+ hostRef.$modeName$
1609
+ );
1610
+ if ((BUILD15.shadowDom || BUILD15.scoped) && BUILD15.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
1611
+ elm["s-sc"] = scopeId2;
1612
+ elm.classList.add(scopeId2 + "-h");
1643
1613
  }
1614
+ endAttachStyles();
1644
1615
  };
1645
- var uniqueTime = (key, measureText) => {
1646
- if (BUILD13.profile && performance.mark) {
1647
- if (performance.getEntriesByName(key, "mark").length === 0) {
1648
- performance.mark(key);
1649
- }
1650
- return () => {
1651
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
1652
- performance.measure(measureText, key);
1616
+ var getScopeId = (cmp, mode) => "sc-" + (BUILD15.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1617
+
1618
+ // src/runtime/vdom/vdom-render.ts
1619
+ import { BUILD as BUILD18 } from "@stencil/core/internal/app-data";
1620
+
1621
+ // src/runtime/vdom/update-element.ts
1622
+ import { BUILD as BUILD17 } from "@stencil/core/internal/app-data";
1623
+
1624
+ // src/runtime/vdom/set-accessor.ts
1625
+ import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
1626
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
1627
+ if (oldValue !== newValue) {
1628
+ let isProp = isMemberInElement(elm, memberName);
1629
+ let ln = memberName.toLowerCase();
1630
+ if (BUILD16.vdomClass && memberName === "class") {
1631
+ const classList = elm.classList;
1632
+ const oldClasses = parseClassList(oldValue);
1633
+ let newClasses = parseClassList(newValue);
1634
+ if (elm["s-si"]) {
1635
+ newClasses.push(elm["s-si"]);
1636
+ oldClasses.forEach((c) => {
1637
+ if (c.startsWith(elm["s-si"])) newClasses.push(c);
1638
+ });
1639
+ newClasses = [...new Set(newClasses)];
1640
+ classList.add(...newClasses);
1641
+ delete elm["s-si"];
1642
+ } else {
1643
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1644
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1645
+ }
1646
+ } else if (BUILD16.vdomStyle && memberName === "style") {
1647
+ if (BUILD16.updatable) {
1648
+ for (const prop in oldValue) {
1649
+ if (!newValue || newValue[prop] == null) {
1650
+ if (!BUILD16.hydrateServerSide && prop.includes("-")) {
1651
+ elm.style.removeProperty(prop);
1652
+ } else {
1653
+ elm.style[prop] = "";
1654
+ }
1655
+ }
1656
+ }
1657
+ }
1658
+ for (const prop in newValue) {
1659
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1660
+ if (!BUILD16.hydrateServerSide && prop.includes("-")) {
1661
+ elm.style.setProperty(prop, newValue[prop]);
1662
+ } else {
1663
+ elm.style[prop] = newValue[prop];
1664
+ }
1665
+ }
1666
+ }
1667
+ } else if (BUILD16.vdomKey && memberName === "key") {
1668
+ } else if (BUILD16.vdomRef && memberName === "ref") {
1669
+ if (newValue) {
1670
+ newValue(elm);
1671
+ }
1672
+ } else if (BUILD16.vdomListener && (BUILD16.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1673
+ if (memberName[2] === "-") {
1674
+ memberName = memberName.slice(3);
1675
+ } else if (isMemberInElement(win, ln)) {
1676
+ memberName = ln.slice(2);
1677
+ } else {
1678
+ memberName = ln[2] + memberName.slice(3);
1679
+ }
1680
+ if (oldValue || newValue) {
1681
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1682
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1683
+ if (oldValue) {
1684
+ plt.rel(elm, memberName, oldValue, capture);
1685
+ }
1686
+ if (newValue) {
1687
+ plt.ael(elm, memberName, newValue, capture);
1688
+ }
1689
+ }
1690
+ } else if (BUILD16.vdomPropOrAttr) {
1691
+ const isComplex = isComplexType(newValue);
1692
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1693
+ try {
1694
+ if (!elm.tagName.includes("-")) {
1695
+ const n = newValue == null ? "" : newValue;
1696
+ if (memberName === "list") {
1697
+ isProp = false;
1698
+ } else if (oldValue == null || elm[memberName] != n) {
1699
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1700
+ elm[memberName] = n;
1701
+ } else {
1702
+ elm.setAttribute(memberName, n);
1703
+ }
1704
+ }
1705
+ } else if (elm[memberName] !== newValue) {
1706
+ elm[memberName] = newValue;
1707
+ }
1708
+ } catch (e) {
1709
+ }
1653
1710
  }
1654
- };
1655
- } else {
1656
- return () => {
1657
- return;
1658
- };
1711
+ let xlink = false;
1712
+ if (BUILD16.vdomXlink) {
1713
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
1714
+ memberName = ln;
1715
+ xlink = true;
1716
+ }
1717
+ }
1718
+ if (newValue == null || newValue === false) {
1719
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1720
+ if (BUILD16.vdomXlink && xlink) {
1721
+ elm.removeAttributeNS(XLINK_NS, memberName);
1722
+ } else {
1723
+ elm.removeAttribute(memberName);
1724
+ }
1725
+ }
1726
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
1727
+ newValue = newValue === true ? "" : newValue;
1728
+ if (BUILD16.vdomXlink && xlink) {
1729
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
1730
+ } else {
1731
+ elm.setAttribute(memberName, newValue);
1732
+ }
1733
+ }
1734
+ }
1659
1735
  }
1660
1736
  };
1661
- var inspect = (ref) => {
1662
- const hostRef = getHostRef(ref);
1663
- if (!hostRef) {
1664
- return void 0;
1737
+ var parseClassListRegex = /\s/;
1738
+ var parseClassList = (value) => {
1739
+ if (typeof value === "object" && "baseVal" in value) {
1740
+ value = value.baseVal;
1665
1741
  }
1666
- const flags = hostRef.$flags$;
1667
- const hostElement = hostRef.$hostElement$;
1668
- return {
1669
- renderCount: hostRef.$renderCount$,
1670
- flags: {
1671
- hasRendered: !!(flags & 2 /* hasRendered */),
1672
- hasConnected: !!(flags & 1 /* hasConnected */),
1673
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1674
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1675
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1676
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1677
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1678
- isWatchReady: !!(flags & 128 /* isWatchReady */),
1679
- isListenReady: !!(flags & 256 /* isListenReady */),
1680
- needsRerender: !!(flags & 512 /* needsRerender */)
1681
- },
1682
- instanceValues: hostRef.$instanceValues$,
1683
- ancestorComponent: hostRef.$ancestorComponent$,
1684
- hostElement,
1685
- lazyInstance: hostRef.$lazyInstance$,
1686
- vnode: hostRef.$vnode$,
1687
- modeName: hostRef.$modeName$,
1688
- onReadyPromise: hostRef.$onReadyPromise$,
1689
- onReadyResolve: hostRef.$onReadyResolve$,
1690
- onInstancePromise: hostRef.$onInstancePromise$,
1691
- onInstanceResolve: hostRef.$onInstanceResolve$,
1692
- onRenderResolve: hostRef.$onRenderResolve$,
1693
- queuedListeners: hostRef.$queuedListeners$,
1694
- rmListeners: hostRef.$rmListeners$,
1695
- ["s-id"]: hostElement["s-id"],
1696
- ["s-cr"]: hostElement["s-cr"],
1697
- ["s-lr"]: hostElement["s-lr"],
1698
- ["s-p"]: hostElement["s-p"],
1699
- ["s-rc"]: hostElement["s-rc"],
1700
- ["s-sc"]: hostElement["s-sc"]
1701
- };
1742
+ if (!value) {
1743
+ return [];
1744
+ }
1745
+ return value.split(parseClassListRegex);
1702
1746
  };
1703
- var installDevTools = () => {
1704
- if (BUILD13.devTools) {
1705
- const stencil = win.stencil = win.stencil || {};
1706
- const originalInspect = stencil.inspect;
1707
- stencil.inspect = (ref) => {
1708
- let result = inspect(ref);
1709
- if (!result && typeof originalInspect === "function") {
1710
- result = originalInspect(ref);
1747
+ var CAPTURE_EVENT_SUFFIX = "Capture";
1748
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
1749
+
1750
+ // src/runtime/vdom/update-element.ts
1751
+ var updateElement = (oldVnode, newVnode, isSvgMode2) => {
1752
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
1753
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
1754
+ const newVnodeAttrs = newVnode.$attrs$ || {};
1755
+ if (BUILD17.updatable) {
1756
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
1757
+ if (!(memberName in newVnodeAttrs)) {
1758
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
1711
1759
  }
1712
- return result;
1713
- };
1760
+ }
1761
+ }
1762
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
1763
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
1714
1764
  }
1715
1765
  };
1766
+ function sortedAttrNames(attrNames) {
1767
+ return attrNames.includes("ref") ? (
1768
+ // we need to sort these to ensure that `'ref'` is the last attr
1769
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
1770
+ ) : (
1771
+ // no need to sort, return the original array
1772
+ attrNames
1773
+ );
1774
+ }
1716
1775
 
1717
- // src/runtime/client-hydrate.ts
1718
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1719
- const endHydrate = createTime("hydrateClient", tagName);
1720
- const shadowRoot = hostElm.shadowRoot;
1721
- const childRenderNodes = [];
1722
- const slotNodes = [];
1723
- const slottedNodes = [];
1724
- const shadowRootNodes = BUILD14.shadowDom && shadowRoot ? [] : null;
1725
- const vnode = newVNode(tagName, null);
1726
- vnode.$elm$ = hostElm;
1727
- let scopeId2;
1728
- if (BUILD14.scoped) {
1729
- const cmpMeta = hostRef.$cmpMeta$;
1730
- if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1731
- scopeId2 = hostElm["s-sc"];
1732
- hostElm.classList.add(scopeId2 + "-h");
1733
- } else if (hostElm["s-sc"]) {
1734
- delete hostElm["s-sc"];
1776
+ // src/runtime/vdom/vdom-render.ts
1777
+ var scopeId;
1778
+ var contentRef;
1779
+ var hostTagName;
1780
+ var useNativeShadowDom = false;
1781
+ var checkSlotFallbackVisibility = false;
1782
+ var checkSlotRelocate = false;
1783
+ var isSvgMode = false;
1784
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1785
+ var _a;
1786
+ const newVNode2 = newParentVNode.$children$[childIndex];
1787
+ let i2 = 0;
1788
+ let elm;
1789
+ let childNode;
1790
+ let oldVNode;
1791
+ if (BUILD18.slotRelocation && !useNativeShadowDom) {
1792
+ checkSlotRelocate = true;
1793
+ if (newVNode2.$tag$ === "slot") {
1794
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
1795
+ // slot element has fallback content
1796
+ // still create an element that "mocks" the slot element
1797
+ 2 /* isSlotFallback */
1798
+ ) : (
1799
+ // slot element does not have fallback content
1800
+ // create an html comment we'll use to always reference
1801
+ // where actual slot content should sit next to
1802
+ 1 /* isSlotReference */
1803
+ );
1735
1804
  }
1736
1805
  }
1737
- if (!plt.$orgLocNodes$) {
1738
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1806
+ if (BUILD18.isDev && newVNode2.$elm$) {
1807
+ consoleDevError(
1808
+ `The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
1809
+ );
1739
1810
  }
1740
- hostElm[HYDRATE_ID] = hostId;
1741
- hostElm.removeAttribute(HYDRATE_ID);
1742
- hostRef.$vnode$ = clientHydrate(
1743
- vnode,
1744
- childRenderNodes,
1745
- slotNodes,
1746
- shadowRootNodes,
1747
- hostElm,
1748
- hostElm,
1749
- hostId,
1750
- slottedNodes
1751
- );
1752
- let crIndex = 0;
1753
- const crLength = childRenderNodes.length;
1754
- let childRenderNode;
1755
- for (crIndex; crIndex < crLength; crIndex++) {
1756
- childRenderNode = childRenderNodes[crIndex];
1757
- const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1758
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1759
- const node = childRenderNode.$elm$;
1760
- if (!shadowRoot) {
1761
- node["s-hn"] = tagName.toUpperCase();
1762
- if (childRenderNode.$tag$ === "slot") {
1763
- node["s-cr"] = hostElm["s-cr"];
1764
- }
1811
+ if (BUILD18.vdomText && newVNode2.$text$ !== null) {
1812
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1813
+ } else if (BUILD18.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
1814
+ elm = newVNode2.$elm$ = BUILD18.isDebug || BUILD18.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
1815
+ } else {
1816
+ if (BUILD18.svg && !isSvgMode) {
1817
+ isSvgMode = newVNode2.$tag$ === "svg";
1765
1818
  }
1766
- if (childRenderNode.$tag$ === "slot") {
1767
- if (childRenderNode.$children$) {
1768
- childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1769
- if (!childRenderNode.$elm$.childNodes.length) {
1770
- childRenderNode.$children$.forEach((c) => {
1771
- childRenderNode.$elm$.appendChild(c.$elm$);
1772
- });
1819
+ elm = newVNode2.$elm$ = BUILD18.svg ? doc.createElementNS(
1820
+ isSvgMode ? SVG_NS : HTML_NS,
1821
+ !useNativeShadowDom && BUILD18.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1822
+ ) : doc.createElement(
1823
+ !useNativeShadowDom && BUILD18.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1824
+ );
1825
+ if (BUILD18.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
1826
+ isSvgMode = false;
1827
+ }
1828
+ if (BUILD18.vdomAttribute) {
1829
+ updateElement(null, newVNode2, isSvgMode);
1830
+ }
1831
+ if (BUILD18.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
1832
+ elm.classList.add(elm["s-si"] = scopeId);
1833
+ }
1834
+ if (newVNode2.$children$) {
1835
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
1836
+ childNode = createElm(oldParentVNode, newVNode2, i2);
1837
+ if (childNode) {
1838
+ elm.appendChild(childNode);
1773
1839
  }
1774
- } else {
1775
- childRenderNode.$flags$ |= 1 /* isSlotReference */;
1776
1840
  }
1777
1841
  }
1778
- if (orgLocationNode && orgLocationNode.isConnected) {
1779
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1780
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1781
- }
1782
- orgLocationNode.parentNode.removeChild(orgLocationNode);
1783
- if (!shadowRoot) {
1784
- node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1842
+ if (BUILD18.svg) {
1843
+ if (newVNode2.$tag$ === "svg") {
1844
+ isSvgMode = false;
1845
+ } else if (elm.tagName === "foreignObject") {
1846
+ isSvgMode = true;
1785
1847
  }
1786
1848
  }
1787
- plt.$orgLocNodes$.delete(orgLocationId);
1788
1849
  }
1789
- const hosts = [];
1790
- const snLen = slottedNodes.length;
1791
- let snIndex = 0;
1792
- let slotGroup;
1793
- let snGroupIdx;
1794
- let snGroupLen;
1795
- let slottedItem;
1796
- for (snIndex; snIndex < snLen; snIndex++) {
1797
- slotGroup = slottedNodes[snIndex];
1798
- if (!slotGroup || !slotGroup.length) continue;
1799
- snGroupLen = slotGroup.length;
1800
- snGroupIdx = 0;
1801
- for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1802
- slottedItem = slotGroup[snGroupIdx];
1803
- if (!hosts[slottedItem.hostId]) {
1804
- hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1805
- }
1806
- if (!hosts[slottedItem.hostId]) continue;
1807
- const hostEle = hosts[slottedItem.hostId];
1808
- if (!hostEle.shadowRoot || !shadowRoot) {
1809
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1810
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1811
- slottedItem.slot["s-cr"] = hostEle;
1812
- } else {
1813
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1814
- }
1815
- addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1816
- if (BUILD14.experimentalSlotFixes) {
1817
- patchNextPrev(slottedItem.node);
1850
+ elm["s-hn"] = hostTagName;
1851
+ if (BUILD18.slotRelocation) {
1852
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1853
+ elm["s-sr"] = true;
1854
+ elm["s-cr"] = contentRef;
1855
+ elm["s-sn"] = newVNode2.$name$ || "";
1856
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1857
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1858
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1859
+ if (BUILD18.experimentalSlotFixes) {
1860
+ relocateToHostRoot(oldParentVNode.$elm$);
1861
+ } else {
1862
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1818
1863
  }
1819
1864
  }
1820
- if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1821
- hostEle.appendChild(slottedItem.node);
1865
+ if (BUILD18.scoped) {
1866
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
1822
1867
  }
1823
1868
  }
1824
1869
  }
1825
- if (BUILD14.scoped && scopeId2 && slotNodes.length) {
1826
- slotNodes.forEach((slot) => {
1827
- slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1828
- });
1870
+ return elm;
1871
+ };
1872
+ var relocateToHostRoot = (parentElm) => {
1873
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1874
+ const host = parentElm.closest(hostTagName.toLowerCase());
1875
+ if (host != null) {
1876
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
1877
+ (ref) => ref["s-cr"]
1878
+ );
1879
+ const childNodeArray = Array.from(
1880
+ parentElm.__childNodes || parentElm.childNodes
1881
+ );
1882
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1883
+ if (childNode["s-sh"] != null) {
1884
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1885
+ childNode["s-sh"] = void 0;
1886
+ checkSlotRelocate = true;
1887
+ }
1888
+ }
1829
1889
  }
1830
- if (BUILD14.shadowDom && shadowRoot) {
1831
- let rnIdex = 0;
1832
- const rnLen = shadowRootNodes.length;
1833
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1834
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1890
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1891
+ };
1892
+ var putBackInOriginalLocation = (parentElm, recursive) => {
1893
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1894
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1895
+ if (parentElm["s-sr"] && BUILD18.experimentalSlotFixes) {
1896
+ let node = parentElm;
1897
+ while (node = node.nextSibling) {
1898
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1899
+ oldSlotChildNodes.push(node);
1900
+ }
1835
1901
  }
1836
- Array.from(hostElm.childNodes).forEach((node) => {
1837
- if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1838
- node.parentNode.removeChild(node);
1902
+ }
1903
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1904
+ const childNode = oldSlotChildNodes[i2];
1905
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1906
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1907
+ childNode["s-ol"].remove();
1908
+ childNode["s-ol"] = void 0;
1909
+ childNode["s-sh"] = void 0;
1910
+ checkSlotRelocate = true;
1911
+ }
1912
+ if (recursive) {
1913
+ putBackInOriginalLocation(childNode, recursive);
1914
+ }
1915
+ }
1916
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1917
+ };
1918
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1919
+ let containerElm = BUILD18.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1920
+ let childNode;
1921
+ if (BUILD18.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1922
+ containerElm = containerElm.shadowRoot;
1923
+ }
1924
+ for (; startIdx <= endIdx; ++startIdx) {
1925
+ if (vnodes[startIdx]) {
1926
+ childNode = createElm(null, parentVNode, startIdx);
1927
+ if (childNode) {
1928
+ vnodes[startIdx].$elm$ = childNode;
1929
+ insertBefore(containerElm, childNode, BUILD18.slotRelocation ? referenceNode(before) : before);
1839
1930
  }
1840
- });
1931
+ }
1841
1932
  }
1842
- hostRef.$hostElement$ = hostElm;
1843
- endHydrate();
1844
1933
  };
1845
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1846
- let childNodeType;
1847
- let childIdSplt;
1848
- let childVNode;
1849
- let i2;
1850
- const scopeId2 = hostElm["s-sc"];
1851
- if (node.nodeType === 1 /* ElementNode */) {
1852
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1853
- if (childNodeType) {
1854
- childIdSplt = childNodeType.split(".");
1855
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1856
- childVNode = createSimpleVNode({
1857
- $flags$: 0,
1858
- $hostId$: childIdSplt[0],
1859
- $nodeId$: childIdSplt[1],
1860
- $depth$: childIdSplt[2],
1861
- $index$: childIdSplt[3],
1862
- $tag$: node.tagName.toLowerCase(),
1863
- $elm$: node,
1864
- // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1865
- // won't try to reconcile them. Classes set on the node will be blown away.
1866
- $attrs$: { class: node.className || "" }
1867
- });
1868
- childRenderNodes.push(childVNode);
1869
- node.removeAttribute(HYDRATE_CHILD_ID);
1870
- if (!parentVNode.$children$) {
1871
- parentVNode.$children$ = [];
1872
- }
1873
- if (BUILD14.scoped && scopeId2) {
1874
- node["s-si"] = scopeId2;
1875
- childVNode.$attrs$.class += " " + scopeId2;
1876
- }
1877
- const slotName = childVNode.$elm$.getAttribute("s-sn");
1878
- if (typeof slotName === "string") {
1879
- if (childVNode.$tag$ === "slot-fb") {
1880
- addSlot(
1881
- slotName,
1882
- childIdSplt[2],
1883
- childVNode,
1884
- node,
1885
- parentVNode,
1886
- childRenderNodes,
1887
- slotNodes,
1888
- shadowRootNodes,
1889
- slottedNodes
1890
- );
1891
- if (BUILD14.scoped && scopeId2) {
1892
- node.classList.add(scopeId2);
1893
- }
1934
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
1935
+ for (let index = startIdx; index <= endIdx; ++index) {
1936
+ const vnode = vnodes[index];
1937
+ if (vnode) {
1938
+ const elm = vnode.$elm$;
1939
+ nullifyVNodeRefs(vnode);
1940
+ if (elm) {
1941
+ if (BUILD18.slotRelocation) {
1942
+ checkSlotFallbackVisibility = true;
1943
+ if (elm["s-ol"]) {
1944
+ elm["s-ol"].remove();
1945
+ } else {
1946
+ putBackInOriginalLocation(elm, true);
1894
1947
  }
1895
- childVNode.$elm$["s-sn"] = slotName;
1896
- childVNode.$elm$.removeAttribute("s-sn");
1897
- }
1898
- if (childVNode.$index$ !== void 0) {
1899
- parentVNode.$children$[childVNode.$index$] = childVNode;
1900
- }
1901
- parentVNode = childVNode;
1902
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1903
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1904
1948
  }
1949
+ elm.remove();
1905
1950
  }
1906
1951
  }
1907
- if (node.shadowRoot) {
1908
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1909
- clientHydrate(
1910
- parentVNode,
1911
- childRenderNodes,
1912
- slotNodes,
1913
- shadowRootNodes,
1914
- hostElm,
1915
- node.shadowRoot.childNodes[i2],
1916
- hostId,
1917
- slottedNodes
1918
- );
1952
+ }
1953
+ };
1954
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1955
+ let oldStartIdx = 0;
1956
+ let newStartIdx = 0;
1957
+ let idxInOld = 0;
1958
+ let i2 = 0;
1959
+ let oldEndIdx = oldCh.length - 1;
1960
+ let oldStartVnode = oldCh[0];
1961
+ let oldEndVnode = oldCh[oldEndIdx];
1962
+ let newEndIdx = newCh.length - 1;
1963
+ let newStartVnode = newCh[0];
1964
+ let newEndVnode = newCh[newEndIdx];
1965
+ let node;
1966
+ let elmToMove;
1967
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1968
+ if (oldStartVnode == null) {
1969
+ oldStartVnode = oldCh[++oldStartIdx];
1970
+ } else if (oldEndVnode == null) {
1971
+ oldEndVnode = oldCh[--oldEndIdx];
1972
+ } else if (newStartVnode == null) {
1973
+ newStartVnode = newCh[++newStartIdx];
1974
+ } else if (newEndVnode == null) {
1975
+ newEndVnode = newCh[--newEndIdx];
1976
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1977
+ patch(oldStartVnode, newStartVnode, isInitialRender);
1978
+ oldStartVnode = oldCh[++oldStartIdx];
1979
+ newStartVnode = newCh[++newStartIdx];
1980
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1981
+ patch(oldEndVnode, newEndVnode, isInitialRender);
1982
+ oldEndVnode = oldCh[--oldEndIdx];
1983
+ newEndVnode = newCh[--newEndIdx];
1984
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1985
+ if (BUILD18.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1986
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1919
1987
  }
1920
- }
1921
- const nonShadowNodes = node.__childNodes || node.childNodes;
1922
- for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1923
- clientHydrate(
1924
- parentVNode,
1925
- childRenderNodes,
1926
- slotNodes,
1927
- shadowRootNodes,
1928
- hostElm,
1929
- nonShadowNodes[i2],
1930
- hostId,
1931
- slottedNodes
1932
- );
1933
- }
1934
- } else if (node.nodeType === 8 /* CommentNode */) {
1935
- childIdSplt = node.nodeValue.split(".");
1936
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1937
- childNodeType = childIdSplt[0];
1938
- childVNode = createSimpleVNode({
1939
- $hostId$: childIdSplt[1],
1940
- $nodeId$: childIdSplt[2],
1941
- $depth$: childIdSplt[3],
1942
- $index$: childIdSplt[4] || "0",
1943
- $elm$: node,
1944
- $attrs$: null,
1945
- $children$: null,
1946
- $key$: null,
1947
- $name$: null,
1948
- $tag$: null,
1949
- $text$: null
1950
- });
1951
- if (childNodeType === TEXT_NODE_ID) {
1952
- childVNode.$elm$ = node.nextSibling;
1953
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1954
- childVNode.$text$ = childVNode.$elm$.textContent;
1955
- childRenderNodes.push(childVNode);
1956
- node.remove();
1957
- if (hostId === childVNode.$hostId$) {
1958
- if (!parentVNode.$children$) {
1959
- parentVNode.$children$ = [];
1960
- }
1961
- parentVNode.$children$[childVNode.$index$] = childVNode;
1962
- }
1963
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1964
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1988
+ patch(oldStartVnode, newEndVnode, isInitialRender);
1989
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1990
+ oldStartVnode = oldCh[++oldStartIdx];
1991
+ newEndVnode = newCh[--newEndIdx];
1992
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1993
+ if (BUILD18.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1994
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1995
+ }
1996
+ patch(oldEndVnode, newStartVnode, isInitialRender);
1997
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1998
+ oldEndVnode = oldCh[--oldEndIdx];
1999
+ newStartVnode = newCh[++newStartIdx];
2000
+ } else {
2001
+ idxInOld = -1;
2002
+ if (BUILD18.vdomKey) {
2003
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
2004
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
2005
+ idxInOld = i2;
2006
+ break;
1965
2007
  }
1966
2008
  }
1967
- } else if (childNodeType === COMMENT_NODE_ID) {
1968
- childVNode.$elm$ = node.nextSibling;
1969
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1970
- childRenderNodes.push(childVNode);
1971
- node.remove();
2009
+ }
2010
+ if (BUILD18.vdomKey && idxInOld >= 0) {
2011
+ elmToMove = oldCh[idxInOld];
2012
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
2013
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
2014
+ } else {
2015
+ patch(elmToMove, newStartVnode, isInitialRender);
2016
+ oldCh[idxInOld] = void 0;
2017
+ node = elmToMove.$elm$;
1972
2018
  }
1973
- } else if (childVNode.$hostId$ === hostId) {
1974
- if (childNodeType === SLOT_NODE_ID) {
1975
- const slotName = node["s-sn"] = childIdSplt[5] || "";
1976
- addSlot(
1977
- slotName,
1978
- childIdSplt[2],
1979
- childVNode,
2019
+ newStartVnode = newCh[++newStartIdx];
2020
+ } else {
2021
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
2022
+ newStartVnode = newCh[++newStartIdx];
2023
+ }
2024
+ if (node) {
2025
+ if (BUILD18.slotRelocation) {
2026
+ insertBefore(
2027
+ referenceNode(oldStartVnode.$elm$).parentNode,
1980
2028
  node,
1981
- parentVNode,
1982
- childRenderNodes,
1983
- slotNodes,
1984
- shadowRootNodes,
1985
- slottedNodes
2029
+ referenceNode(oldStartVnode.$elm$)
1986
2030
  );
1987
- } else if (childNodeType === CONTENT_REF_ID) {
1988
- if (BUILD14.shadowDom && shadowRootNodes) {
1989
- node.remove();
1990
- } else if (BUILD14.slotRelocation) {
1991
- hostElm["s-cr"] = node;
1992
- node["s-cn"] = true;
1993
- }
2031
+ } else {
2032
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1994
2033
  }
1995
2034
  }
1996
2035
  }
1997
- } else if (parentVNode && parentVNode.$tag$ === "style") {
1998
- const vnode = newVNode(null, node.textContent);
1999
- vnode.$elm$ = node;
2000
- vnode.$index$ = "0";
2001
- parentVNode.$children$ = [vnode];
2002
2036
  }
2003
- return parentVNode;
2004
- };
2005
- var initializeDocumentHydrate = (node, orgLocNodes) => {
2006
- if (node.nodeType === 1 /* ElementNode */) {
2007
- const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
2008
- if (componentId) {
2009
- orgLocNodes.set(componentId, node);
2010
- }
2011
- let i2 = 0;
2012
- if (node.shadowRoot) {
2013
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
2014
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
2015
- }
2016
- }
2017
- const nonShadowNodes = node.__childNodes || node.childNodes;
2018
- for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
2019
- initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
2020
- }
2021
- } else if (node.nodeType === 8 /* CommentNode */) {
2022
- const childIdSplt = node.nodeValue.split(".");
2023
- if (childIdSplt[0] === ORG_LOCATION_ID) {
2024
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
2025
- node.nodeValue = "";
2026
- node["s-en"] = childIdSplt[3];
2027
- }
2037
+ if (oldStartIdx > oldEndIdx) {
2038
+ addVnodes(
2039
+ parentElm,
2040
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
2041
+ newVNode2,
2042
+ newCh,
2043
+ newStartIdx,
2044
+ newEndIdx
2045
+ );
2046
+ } else if (BUILD18.updatable && newStartIdx > newEndIdx) {
2047
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
2028
2048
  }
2029
2049
  };
2030
- var createSimpleVNode = (vnode) => {
2031
- const defaultVNode = {
2032
- $flags$: 0,
2033
- $hostId$: null,
2034
- $nodeId$: null,
2035
- $depth$: null,
2036
- $index$: "0",
2037
- $elm$: null,
2038
- $attrs$: null,
2039
- $children$: null,
2040
- $key$: null,
2041
- $name$: null,
2042
- $tag$: null,
2043
- $text$: null
2044
- };
2045
- return { ...defaultVNode, ...vnode };
2046
- };
2047
- function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
2048
- node["s-sr"] = true;
2049
- childVNode.$name$ = slotName || null;
2050
- childVNode.$tag$ = "slot";
2051
- const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
2052
- if (BUILD14.shadowDom && shadowRootNodes) {
2053
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
2054
- if (childVNode.$name$) {
2055
- childVNode.$elm$.setAttribute("name", slotName);
2056
- }
2057
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
2058
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2059
- } else {
2060
- node.parentNode.insertBefore(childVNode.$elm$, node);
2050
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
2051
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
2052
+ if (BUILD18.slotRelocation && leftVNode.$tag$ === "slot") {
2053
+ return leftVNode.$name$ === rightVNode.$name$;
2061
2054
  }
2062
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
2063
- node.remove();
2064
- if (childVNode.$depth$ === "0") {
2065
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2055
+ if (BUILD18.vdomKey && !isInitialRender) {
2056
+ return leftVNode.$key$ === rightVNode.$key$;
2066
2057
  }
2067
- } else {
2068
- const slot = childVNode.$elm$;
2069
- const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
2070
- addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
2071
- if (shouldMove) {
2072
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2058
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
2059
+ leftVNode.$key$ = rightVNode.$key$;
2073
2060
  }
2074
- childRenderNodes.push(childVNode);
2075
- }
2076
- slotNodes.push(childVNode);
2077
- if (!parentVNode.$children$) {
2078
- parentVNode.$children$ = [];
2079
- }
2080
- parentVNode.$children$[childVNode.$index$] = childVNode;
2081
- }
2082
- var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
2083
- let slottedNode = slotNode.nextSibling;
2084
- slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
2085
- while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
2086
- slottedNode["s-sn"] = slotName;
2087
- slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
2088
- slottedNode = slottedNode.nextSibling;
2061
+ return true;
2089
2062
  }
2063
+ return false;
2090
2064
  };
2091
-
2092
- // src/runtime/initialize-component.ts
2093
- import { BUILD as BUILD22 } from "@stencil/core/internal/app-data";
2094
-
2095
- // src/runtime/mode.ts
2096
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
2097
- var setMode = (handler) => modeResolutionChain.push(handler);
2098
- var getMode = (ref) => getHostRef(ref).$modeName$;
2099
-
2100
- // src/runtime/proxy-component.ts
2101
- import { BUILD as BUILD21 } from "@stencil/core/internal/app-data";
2102
-
2103
- // src/runtime/set-value.ts
2104
- import { BUILD as BUILD20 } from "@stencil/core/internal/app-data";
2105
-
2106
- // src/runtime/parse-property-value.ts
2107
- import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
2108
- var parsePropertyValue = (propValue, propType) => {
2109
- if (propValue != null && !isComplexType(propValue)) {
2110
- if (BUILD15.propBoolean && propType & 4 /* Boolean */) {
2111
- return propValue === "false" ? false : propValue === "" || !!propValue;
2065
+ var referenceNode = (node) => node && node["s-ol"] || node;
2066
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2067
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
2068
+ const oldChildren = oldVNode.$children$;
2069
+ const newChildren = newVNode2.$children$;
2070
+ const tag = newVNode2.$tag$;
2071
+ const text = newVNode2.$text$;
2072
+ let defaultHolder;
2073
+ if (!BUILD18.vdomText || text === null) {
2074
+ if (BUILD18.svg) {
2075
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2112
2076
  }
2113
- if (BUILD15.propNumber && propType & 2 /* Number */) {
2114
- return parseFloat(propValue);
2077
+ if (BUILD18.vdomAttribute || BUILD18.reflect) {
2078
+ if (BUILD18.slot && tag === "slot" && !useNativeShadowDom) {
2079
+ if (BUILD18.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
2080
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
2081
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
2082
+ }
2083
+ } else {
2084
+ updateElement(oldVNode, newVNode2, isSvgMode);
2085
+ }
2115
2086
  }
2116
- if (BUILD15.propString && propType & 1 /* String */) {
2117
- return String(propValue);
2087
+ if (BUILD18.updatable && oldChildren !== null && newChildren !== null) {
2088
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
2089
+ } else if (newChildren !== null) {
2090
+ if (BUILD18.updatable && BUILD18.vdomText && oldVNode.$text$ !== null) {
2091
+ elm.textContent = "";
2092
+ }
2093
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
2094
+ } else if (
2095
+ // don't do this on initial render as it can cause non-hydrated content to be removed
2096
+ !isInitialRender && BUILD18.updatable && oldChildren !== null
2097
+ ) {
2098
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
2118
2099
  }
2119
- return propValue;
2100
+ if (BUILD18.svg && isSvgMode && tag === "svg") {
2101
+ isSvgMode = false;
2102
+ }
2103
+ } else if (BUILD18.vdomText && BUILD18.slotRelocation && (defaultHolder = elm["s-cr"])) {
2104
+ defaultHolder.parentNode.textContent = text;
2105
+ } else if (BUILD18.vdomText && oldVNode.$text$ !== text) {
2106
+ elm.data = text;
2120
2107
  }
2121
- return propValue;
2122
2108
  };
2123
-
2124
- // src/runtime/update-component.ts
2125
- import { BUILD as BUILD19, NAMESPACE } from "@stencil/core/internal/app-data";
2126
-
2127
- // src/runtime/event-emitter.ts
2128
- import { BUILD as BUILD17 } from "@stencil/core/internal/app-data";
2129
-
2130
- // src/runtime/element.ts
2131
- import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
2132
- var getElement = (ref) => BUILD16.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2133
-
2134
- // src/runtime/event-emitter.ts
2135
- var createEvent = (ref, name, flags) => {
2136
- const elm = getElement(ref);
2137
- return {
2138
- emit: (detail) => {
2139
- if (BUILD17.isDev && !elm.isConnected) {
2140
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2109
+ var relocateNodes = [];
2110
+ var markSlotContentForRelocation = (elm) => {
2111
+ let node;
2112
+ let hostContentNodes;
2113
+ let j;
2114
+ const children = elm.__childNodes || elm.childNodes;
2115
+ for (const childNode of children) {
2116
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
2117
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
2118
+ const slotName = childNode["s-sn"];
2119
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
2120
+ node = hostContentNodes[j];
2121
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD18.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2122
+ if (isNodeLocatedInSlot(node, slotName)) {
2123
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2124
+ checkSlotFallbackVisibility = true;
2125
+ node["s-sn"] = node["s-sn"] || slotName;
2126
+ if (relocateNodeData) {
2127
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
2128
+ relocateNodeData.$slotRefNode$ = childNode;
2129
+ } else {
2130
+ node["s-sh"] = childNode["s-hn"];
2131
+ relocateNodes.push({
2132
+ $slotRefNode$: childNode,
2133
+ $nodeToRelocate$: node
2134
+ });
2135
+ }
2136
+ if (node["s-sr"]) {
2137
+ relocateNodes.map((relocateNode) => {
2138
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
2139
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2140
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
2141
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
2142
+ }
2143
+ }
2144
+ });
2145
+ }
2146
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
2147
+ relocateNodes.push({
2148
+ $nodeToRelocate$: node
2149
+ });
2150
+ }
2151
+ }
2141
2152
  }
2142
- return emitEvent(elm, name, {
2143
- bubbles: !!(flags & 4 /* Bubbles */),
2144
- composed: !!(flags & 2 /* Composed */),
2145
- cancelable: !!(flags & 1 /* Cancellable */),
2146
- detail
2147
- });
2148
2153
  }
2149
- };
2154
+ if (childNode.nodeType === 1 /* ElementNode */) {
2155
+ markSlotContentForRelocation(childNode);
2156
+ }
2157
+ }
2150
2158
  };
2151
- var emitEvent = (elm, name, opts) => {
2152
- const ev = plt.ce(name, opts);
2153
- elm.dispatchEvent(ev);
2154
- return ev;
2159
+ var nullifyVNodeRefs = (vNode) => {
2160
+ if (BUILD18.vdomRef) {
2161
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
2162
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2163
+ }
2155
2164
  };
2156
-
2157
- // src/runtime/styles.ts
2158
- import { BUILD as BUILD18 } from "@stencil/core/internal/app-data";
2159
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
2160
- var registerStyle = (scopeId2, cssText, allowCS) => {
2161
- let style = styles.get(scopeId2);
2162
- if (supportsConstructableStylesheets && allowCS) {
2163
- style = style || new CSSStyleSheet();
2164
- if (typeof style === "string") {
2165
- style = cssText;
2166
- } else {
2167
- style.replaceSync(cssText);
2165
+ var insertBefore = (parent, newNode, reference) => {
2166
+ if (BUILD18.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2167
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2168
+ } else if (BUILD18.experimentalSlotFixes && typeof newNode["s-sn"] === "string") {
2169
+ if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
2170
+ patchParentNode(newNode);
2168
2171
  }
2172
+ return parent.insertBefore(newNode, reference);
2173
+ }
2174
+ if (BUILD18.experimentalSlotFixes && parent.__insertBefore) {
2175
+ return parent.__insertBefore(newNode, reference);
2169
2176
  } else {
2170
- style = cssText;
2177
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2171
2178
  }
2172
- styles.set(scopeId2, style);
2173
2179
  };
2174
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
2180
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
2175
2181
  var _a;
2176
- const scopeId2 = getScopeId(cmpMeta, mode);
2177
- const style = styles.get(scopeId2);
2178
- if (!BUILD18.attachStyles) {
2179
- return scopeId2;
2182
+ let scopeId2;
2183
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
2184
+ const scopeName = slotNode["s-sn"];
2185
+ const hostName = slotNode["s-hn"];
2186
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
2187
+ if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
2188
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
2189
+ let found = false;
2190
+ while (child) {
2191
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
2192
+ found = true;
2193
+ break;
2194
+ }
2195
+ child = child.nextSibling;
2196
+ }
2197
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
2198
+ }
2180
2199
  }
2181
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
2182
- if (style) {
2183
- if (typeof style === "string") {
2184
- styleContainerNode = styleContainerNode.head || styleContainerNode;
2185
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
2186
- let styleElm;
2187
- if (!appliedStyles) {
2188
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
2200
+ }
2201
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2202
+ var _a, _b, _c, _d, _e;
2203
+ const hostElm = hostRef.$hostElement$;
2204
+ const cmpMeta = hostRef.$cmpMeta$;
2205
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2206
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2207
+ hostTagName = hostElm.tagName;
2208
+ if (BUILD18.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
2209
+ throw new Error(`The <Host> must be the single root component.
2210
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2211
+
2212
+ The render() function should look like this instead:
2213
+
2214
+ render() {
2215
+ // Do not return an array
2216
+ return (
2217
+ <Host>{content}</Host>
2218
+ );
2219
+ }
2220
+ `);
2221
+ }
2222
+ if (BUILD18.reflect && cmpMeta.$attrsToReflect$) {
2223
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
2224
+ cmpMeta.$attrsToReflect$.map(
2225
+ ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
2226
+ );
2227
+ }
2228
+ if (isInitialLoad && rootVnode.$attrs$) {
2229
+ for (const key of Object.keys(rootVnode.$attrs$)) {
2230
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
2231
+ rootVnode.$attrs$[key] = hostElm[key];
2189
2232
  }
2190
- if (!appliedStyles.has(scopeId2)) {
2191
- if (BUILD18.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
2192
- styleElm.innerHTML = style;
2193
- } else {
2194
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
2195
- styleElm.innerHTML = style;
2196
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2197
- if (nonce != null) {
2198
- styleElm.setAttribute("nonce", nonce);
2199
- }
2200
- if ((BUILD18.hydrateServerSide || BUILD18.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2201
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
2202
- }
2203
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2204
- if (styleContainerNode.nodeName === "HEAD") {
2205
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2206
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2207
- styleContainerNode.insertBefore(styleElm, referenceNode2);
2208
- } else if ("host" in styleContainerNode) {
2209
- if (supportsConstructableStylesheets) {
2210
- const stylesheet = new CSSStyleSheet();
2211
- stylesheet.replaceSync(style);
2212
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2213
- } else {
2214
- const existingStyleContainer = styleContainerNode.querySelector("style");
2215
- if (existingStyleContainer) {
2216
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2217
- } else {
2218
- styleContainerNode.prepend(styleElm);
2233
+ }
2234
+ }
2235
+ rootVnode.$tag$ = null;
2236
+ rootVnode.$flags$ |= 4 /* isHost */;
2237
+ hostRef.$vnode$ = rootVnode;
2238
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD18.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
2239
+ if (BUILD18.scoped || BUILD18.shadowDom) {
2240
+ scopeId = hostElm["s-sc"];
2241
+ }
2242
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
2243
+ if (BUILD18.slotRelocation) {
2244
+ contentRef = hostElm["s-cr"];
2245
+ checkSlotFallbackVisibility = false;
2246
+ }
2247
+ patch(oldVNode, rootVnode, isInitialLoad);
2248
+ if (BUILD18.slotRelocation) {
2249
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2250
+ if (checkSlotRelocate) {
2251
+ markSlotContentForRelocation(rootVnode.$elm$);
2252
+ for (const relocateData of relocateNodes) {
2253
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2254
+ if (!nodeToRelocate["s-ol"]) {
2255
+ const orgLocationNode = BUILD18.isDebug || BUILD18.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2256
+ orgLocationNode["s-nr"] = nodeToRelocate;
2257
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2258
+ }
2259
+ }
2260
+ for (const relocateData of relocateNodes) {
2261
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2262
+ const slotRefNode = relocateData.$slotRefNode$;
2263
+ if (slotRefNode) {
2264
+ const parentNodeRef = slotRefNode.parentNode;
2265
+ let insertBeforeNode = slotRefNode.nextSibling;
2266
+ if (!BUILD18.hydrateServerSide && (!BUILD18.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
2267
+ let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
2268
+ while (orgLocationNode) {
2269
+ let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
2270
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
2271
+ refNode = refNode.nextSibling;
2272
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
2273
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
2274
+ }
2275
+ if (!refNode || !refNode["s-nr"]) {
2276
+ insertBeforeNode = refNode;
2277
+ break;
2219
2278
  }
2220
2279
  }
2221
- } else {
2222
- styleContainerNode.append(styleElm);
2280
+ orgLocationNode = orgLocationNode.previousSibling;
2223
2281
  }
2224
2282
  }
2225
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
2226
- styleContainerNode.insertBefore(styleElm, null);
2283
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
2284
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2285
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2286
+ if (nodeToRelocate !== insertBeforeNode) {
2287
+ if (!BUILD18.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2288
+ nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
2289
+ }
2290
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2291
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2292
+ nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
2293
+ }
2294
+ }
2295
+ }
2296
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2297
+ } else {
2298
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2299
+ if (isInitialLoad) {
2300
+ nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
2301
+ }
2302
+ nodeToRelocate.hidden = true;
2227
2303
  }
2228
- }
2229
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2230
- styleElm.innerHTML += SLOT_FB_CSS;
2231
- }
2232
- if (appliedStyles) {
2233
- appliedStyles.add(scopeId2);
2234
2304
  }
2235
2305
  }
2236
- } else if (BUILD18.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2237
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
2238
2306
  }
2307
+ if (checkSlotFallbackVisibility) {
2308
+ updateFallbackSlotVisibility(rootVnode.$elm$);
2309
+ }
2310
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2311
+ relocateNodes.length = 0;
2239
2312
  }
2240
- return scopeId2;
2241
- };
2242
- var attachStyles = (hostRef) => {
2243
- const cmpMeta = hostRef.$cmpMeta$;
2244
- const elm = hostRef.$hostElement$;
2245
- const flags = cmpMeta.$flags$;
2246
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2247
- const scopeId2 = addStyle(
2248
- BUILD18.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2249
- cmpMeta,
2250
- hostRef.$modeName$
2251
- );
2252
- if ((BUILD18.shadowDom || BUILD18.scoped) && BUILD18.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2253
- elm["s-sc"] = scopeId2;
2254
- elm.classList.add(scopeId2 + "-h");
2313
+ if (BUILD18.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2314
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2315
+ for (const childNode of children) {
2316
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2317
+ if (isInitialLoad && childNode["s-ih"] == null) {
2318
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2319
+ }
2320
+ childNode.hidden = true;
2321
+ }
2322
+ }
2255
2323
  }
2256
- endAttachStyles();
2324
+ contentRef = void 0;
2257
2325
  };
2258
- var getScopeId = (cmp, mode) => "sc-" + (BUILD18.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2326
+ var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2327
+ `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2328
+ );
2329
+ var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2330
+ `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2331
+ );
2259
2332
 
2260
2333
  // src/runtime/update-component.ts
2261
2334
  var attachToAncestor = (hostRef, ancestorComponent) => {
2262
2335
  if (BUILD19.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2263
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
2336
+ const index = ancestorComponent["s-p"].push(
2337
+ new Promise(
2338
+ (r) => hostRef.$onRenderResolve$ = () => {
2339
+ ancestorComponent["s-p"].splice(index - 1, 1);
2340
+ r();
2341
+ }
2342
+ )
2343
+ );
2264
2344
  }
2265
2345
  };
2266
2346
  var scheduleUpdate = (hostRef, isInitialLoad) => {
@@ -2631,77 +2711,91 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
2631
2711
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
2632
2712
  members.map(([memberName, [memberFlags]]) => {
2633
2713
  if ((BUILD21.prop || BUILD21.state) && (memberFlags & 31 /* Prop */ || (!BUILD21.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2634
- if ((memberFlags & 2048 /* Getter */) === 0) {
2714
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
2715
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
2716
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
2717
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
2635
2718
  Object.defineProperty(prototype, memberName, {
2636
2719
  get() {
2637
- return getValue(this, memberName);
2638
- },
2639
- set(newValue) {
2640
- if (BUILD21.isDev) {
2641
- const ref = getHostRef(this);
2642
- if (
2643
- // we are proxying the instance (not element)
2644
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
2645
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2646
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2647
- (memberFlags & 1024 /* Mutable */) === 0
2648
- ) {
2649
- consoleDevWarn(
2650
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2651
- More information: https://stenciljs.com/docs/properties#prop-mutability`
2652
- );
2720
+ if (BUILD21.lazyLoad) {
2721
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
2722
+ return getValue(this, memberName);
2653
2723
  }
2724
+ const ref = getHostRef(this);
2725
+ const instance = ref ? ref.$lazyInstance$ : prototype;
2726
+ if (!instance) return;
2727
+ return instance[memberName];
2728
+ }
2729
+ if (!BUILD21.lazyLoad) {
2730
+ return origGetter ? origGetter.apply(this) : getValue(this, memberName);
2654
2731
  }
2655
- setValue(this, memberName, newValue, cmpMeta);
2656
2732
  },
2657
2733
  configurable: true,
2658
2734
  enumerable: true
2659
2735
  });
2660
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 2048 /* Getter */) {
2661
- if (BUILD21.lazyLoad) {
2662
- Object.defineProperty(prototype, memberName, {
2663
- get() {
2664
- const ref = getHostRef(this);
2665
- const instance = BUILD21.lazyLoad && ref ? ref.$lazyInstance$ : prototype;
2666
- if (!instance) return;
2667
- return instance[memberName];
2668
- },
2669
- configurable: true,
2670
- enumerable: true
2671
- });
2672
- }
2673
- if (memberFlags & 4096 /* Setter */) {
2674
- const origSetter = Object.getOwnPropertyDescriptor(prototype, memberName).set;
2675
- Object.defineProperty(prototype, memberName, {
2676
- set(newValue) {
2677
- const ref = getHostRef(this);
2678
- if (origSetter) {
2679
- const currentValue = ref.$hostElement$[memberName];
2680
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2681
- ref.$instanceValues$.set(memberName, currentValue);
2682
- }
2683
- origSetter.apply(this, [parsePropertyValue(newValue, cmpMeta.$members$[memberName][0])]);
2684
- setValue(this, memberName, ref.$hostElement$[memberName], cmpMeta);
2685
- return;
2736
+ }
2737
+ Object.defineProperty(prototype, memberName, {
2738
+ set(newValue) {
2739
+ const ref = getHostRef(this);
2740
+ if (BUILD21.isDev) {
2741
+ if (
2742
+ // we are proxying the instance (not element)
2743
+ (flags & 1 /* isElementConstructor */) === 0 && // if the class has a setter, then the Element can update instance values, so ignore
2744
+ (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0 && // the element is not constructing
2745
+ (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2746
+ (cmpMeta.$members$[memberName][0] & 31 /* Prop */) !== 0 && // the member is not mutable
2747
+ (cmpMeta.$members$[memberName][0] & 1024 /* Mutable */) === 0
2748
+ ) {
2749
+ consoleDevWarn(
2750
+ `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2751
+ More information: https://stenciljs.com/docs/properties#prop-mutability`
2752
+ );
2753
+ }
2754
+ }
2755
+ if (origSetter) {
2756
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2757
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
2758
+ newValue = ref.$instanceValues$.get(memberName);
2759
+ } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
2760
+ ref.$instanceValues$.set(memberName, currentValue);
2761
+ }
2762
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
2763
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2764
+ setValue(this, memberName, newValue, cmpMeta);
2765
+ return;
2766
+ }
2767
+ if (!BUILD21.lazyLoad) {
2768
+ setValue(this, memberName, newValue, cmpMeta);
2769
+ return;
2770
+ }
2771
+ if (BUILD21.lazyLoad) {
2772
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
2773
+ setValue(this, memberName, newValue, cmpMeta);
2774
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
2775
+ ref.$onReadyPromise$.then(() => {
2776
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
2777
+ ref.$lazyInstance$[memberName] = newValue;
2778
+ }
2779
+ });
2686
2780
  }
2687
- if (!ref) return;
2688
- const setterSetVal = () => {
2689
- const currentValue = ref.$lazyInstance$[memberName];
2690
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2691
- ref.$instanceValues$.set(memberName, currentValue);
2692
- }
2693
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, cmpMeta.$members$[memberName][0]);
2694
- setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2695
- };
2696
- if (ref.$lazyInstance$) {
2697
- setterSetVal();
2698
- } else {
2699
- ref.$onReadyPromise$.then(() => setterSetVal());
2781
+ return;
2782
+ }
2783
+ const setterSetVal = () => {
2784
+ const currentValue = ref.$lazyInstance$[memberName];
2785
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
2786
+ ref.$instanceValues$.set(memberName, currentValue);
2700
2787
  }
2788
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags);
2789
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2790
+ };
2791
+ if (ref.$lazyInstance$) {
2792
+ setterSetVal();
2793
+ } else {
2794
+ ref.$onReadyPromise$.then(() => setterSetVal());
2701
2795
  }
2702
- });
2796
+ }
2703
2797
  }
2704
- }
2798
+ });
2705
2799
  } else if (BUILD21.lazyLoad && BUILD21.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2706
2800
  Object.defineProperty(prototype, memberName, {
2707
2801
  value(...args) {
@@ -2743,8 +2837,9 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
2743
2837
  return;
2744
2838
  }
2745
2839
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
2746
- if (!propDesc.get || !!propDesc.set) {
2747
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2840
+ newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2841
+ if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
2842
+ this[propName] = newValue;
2748
2843
  }
2749
2844
  });
2750
2845
  };