@rindo/core 4.23.2 → 4.25.3

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.
@@ -464,10 +464,13 @@ var unwrapErr = (result) => {
464
464
  var import_app_data17 = require("@rindo/core/internal/app-data");
465
465
 
466
466
  // src/runtime/client-hydrate.ts
467
- var import_app_data8 = require("@rindo/core/internal/app-data");
467
+ var import_app_data5 = require("@rindo/core/internal/app-data");
468
468
 
469
469
  // src/runtime/dom-extras.ts
470
- var import_app_data6 = require("@rindo/core/internal/app-data");
470
+ var import_app_data2 = require("@rindo/core/internal/app-data");
471
+
472
+ // src/runtime/slot-polyfill-utils.ts
473
+ var import_app_data = require("@rindo/core/internal/app-data");
471
474
 
472
475
  // src/runtime/runtime-constants.ts
473
476
  var CONTENT_REF_ID = "r";
@@ -495,7 +498,6 @@ var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
495
498
  ];
496
499
 
497
500
  // src/runtime/slot-polyfill-utils.ts
498
- var import_app_data = require("@rindo/core/internal/app-data");
499
501
  var updateFallbackSlotVisibility = (elm) => {
500
502
  const childNodes = elm.__childNodes || elm.childNodes;
501
503
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -519,27 +521,27 @@ var updateFallbackSlotVisibility = (elm) => {
519
521
  var getSlottedChildNodes = (childNodes) => {
520
522
  const result = [];
521
523
  for (let i2 = 0; i2 < childNodes.length; i2++) {
522
- const slottedNode = childNodes[i2]["s-nr"];
524
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
523
525
  if (slottedNode && slottedNode.isConnected) {
524
526
  result.push(slottedNode);
525
527
  }
526
528
  }
527
529
  return result;
528
530
  };
529
- var getHostSlotNodes = (childNodes, hostName, slotName) => {
531
+ function getHostSlotNodes(childNodes, hostName, slotName) {
530
532
  let i2 = 0;
531
533
  let slottedNodes = [];
532
534
  let childNode;
533
535
  for (; i2 < childNodes.length; i2++) {
534
536
  childNode = childNodes[i2];
535
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
537
+ if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
536
538
  slottedNodes.push(childNode);
537
539
  if (typeof slotName !== "undefined") return slottedNodes;
538
540
  }
539
541
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
540
542
  }
541
543
  return slottedNodes;
542
- };
544
+ }
543
545
  var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
544
546
  const childNodes = [];
545
547
  if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
@@ -597,1801 +599,1895 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
597
599
  };
598
600
  var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
599
601
 
600
- // src/runtime/vdom/vdom-render.ts
601
- var import_app_data5 = require("@rindo/core/internal/app-data");
602
-
603
- // src/runtime/vdom/h.ts
604
- var import_app_data2 = require("@rindo/core/internal/app-data");
605
- var h = (nodeName, vnodeData, ...children) => {
606
- let child = null;
607
- let key = null;
608
- let slotName = null;
609
- let simple = false;
610
- let lastSimple = false;
611
- const vNodeChildren = [];
612
- const walk = (c) => {
613
- for (let i2 = 0; i2 < c.length; i2++) {
614
- child = c[i2];
615
- if (Array.isArray(child)) {
616
- walk(child);
617
- } else if (child != null && typeof child !== "boolean") {
618
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
619
- child = String(child);
620
- } else if (import_app_data2.BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
621
- consoleDevError(`vNode passed as children has unexpected type.
622
- Make sure it's using the correct h() function.
623
- Empty objects can also be the cause, look for JSX comments that became objects.`);
602
+ // src/runtime/dom-extras.ts
603
+ var patchPseudoShadowDom = (hostElementPrototype) => {
604
+ patchCloneNode(hostElementPrototype);
605
+ patchSlotAppendChild(hostElementPrototype);
606
+ patchSlotAppend(hostElementPrototype);
607
+ patchSlotPrepend(hostElementPrototype);
608
+ patchSlotInsertAdjacentElement(hostElementPrototype);
609
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
610
+ patchSlotInsertAdjacentText(hostElementPrototype);
611
+ patchInsertBefore(hostElementPrototype);
612
+ patchTextContent(hostElementPrototype);
613
+ patchChildSlotNodes(hostElementPrototype);
614
+ patchSlotRemoveChild(hostElementPrototype);
615
+ };
616
+ var patchCloneNode = (HostElementPrototype) => {
617
+ const orgCloneNode = HostElementPrototype.cloneNode;
618
+ HostElementPrototype.cloneNode = function(deep) {
619
+ const srcNode = this;
620
+ const isShadowDom = import_app_data2.BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
621
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
622
+ if (import_app_data2.BUILD.slot && !isShadowDom && deep) {
623
+ let i2 = 0;
624
+ let slotted, nonRindoNode;
625
+ const rindoPrivates = [
626
+ "s-id",
627
+ "s-cr",
628
+ "s-lr",
629
+ "s-rc",
630
+ "s-sc",
631
+ "s-p",
632
+ "s-cn",
633
+ "s-sr",
634
+ "s-sn",
635
+ "s-hn",
636
+ "s-ol",
637
+ "s-nr",
638
+ "s-si",
639
+ "s-rf",
640
+ "s-scs"
641
+ ];
642
+ const childNodes = this.__childNodes || this.childNodes;
643
+ for (; i2 < childNodes.length; i2++) {
644
+ slotted = childNodes[i2]["s-nr"];
645
+ nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
646
+ if (slotted) {
647
+ if (import_app_data2.BUILD.appendChildSlotFix && clonedNode.__appendChild) {
648
+ clonedNode.__appendChild(slotted.cloneNode(true));
649
+ } else {
650
+ clonedNode.appendChild(slotted.cloneNode(true));
651
+ }
624
652
  }
625
- if (simple && lastSimple) {
626
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
627
- } else {
628
- vNodeChildren.push(simple ? newVNode(null, child) : child);
653
+ if (nonRindoNode) {
654
+ clonedNode.appendChild(childNodes[i2].cloneNode(true));
629
655
  }
630
- lastSimple = simple;
631
656
  }
632
657
  }
658
+ return clonedNode;
633
659
  };
634
- walk(children);
635
- if (vnodeData) {
636
- if (import_app_data2.BUILD.isDev && nodeName === "input") {
637
- validateInputProperties(vnodeData);
638
- }
639
- if (import_app_data2.BUILD.vdomKey && vnodeData.key) {
640
- key = vnodeData.key;
641
- }
642
- if (import_app_data2.BUILD.slotRelocation && vnodeData.name) {
643
- slotName = vnodeData.name;
660
+ };
661
+ var patchSlotAppendChild = (HostElementPrototype) => {
662
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
663
+ HostElementPrototype.appendChild = function(newChild) {
664
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
665
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
666
+ if (slotNode) {
667
+ addSlotRelocateNode(newChild, slotNode);
668
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
669
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
670
+ const parent = intrnlCall(appendAfter, "parentNode");
671
+ let insertedNode;
672
+ if (parent.__insertBefore) {
673
+ insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
674
+ } else {
675
+ insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
676
+ }
677
+ updateFallbackSlotVisibility(this);
678
+ return insertedNode;
644
679
  }
645
- if (import_app_data2.BUILD.vdomClass) {
646
- const classData = vnodeData.className || vnodeData.class;
647
- if (classData) {
648
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
680
+ return this.__appendChild(newChild);
681
+ };
682
+ };
683
+ var patchSlotRemoveChild = (ElementPrototype) => {
684
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
685
+ ElementPrototype.removeChild = function(toRemove) {
686
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
687
+ const childNodes = this.__childNodes || this.childNodes;
688
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
689
+ if (slotNode && toRemove.isConnected) {
690
+ toRemove.remove();
691
+ updateFallbackSlotVisibility(this);
692
+ return;
649
693
  }
650
694
  }
651
- }
652
- if (import_app_data2.BUILD.isDev && vNodeChildren.some(isHost)) {
653
- consoleDevError(`The <Host> must be the single root component. Make sure:
654
- - You are NOT using hostData() and <Host> in the same component.
655
- - <Host> is used once, and it's the single root component of the render() function.`);
656
- }
657
- if (import_app_data2.BUILD.vdomFunctional && typeof nodeName === "function") {
658
- return nodeName(
659
- vnodeData === null ? {} : vnodeData,
660
- vNodeChildren,
661
- vdomFnUtils
662
- );
663
- }
664
- const vnode = newVNode(nodeName, null);
665
- vnode.$attrs$ = vnodeData;
666
- if (vNodeChildren.length > 0) {
667
- vnode.$children$ = vNodeChildren;
668
- }
669
- if (import_app_data2.BUILD.vdomKey) {
670
- vnode.$key$ = key;
671
- }
672
- if (import_app_data2.BUILD.slotRelocation) {
673
- vnode.$name$ = slotName;
674
- }
675
- return vnode;
695
+ return this.__removeChild(toRemove);
696
+ };
676
697
  };
677
- var newVNode = (tag, text) => {
678
- const vnode = {
679
- $flags$: 0,
680
- $tag$: tag,
681
- $text$: text,
682
- $elm$: null,
683
- $children$: null
698
+ var patchSlotPrepend = (HostElementPrototype) => {
699
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
700
+ HostElementPrototype.prepend = function(...newChildren) {
701
+ newChildren.forEach((newChild) => {
702
+ if (typeof newChild === "string") {
703
+ newChild = this.ownerDocument.createTextNode(newChild);
704
+ }
705
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
706
+ const childNodes = this.__childNodes || this.childNodes;
707
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
708
+ if (slotNode) {
709
+ addSlotRelocateNode(newChild, slotNode, true);
710
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
711
+ const appendAfter = slotChildNodes[0];
712
+ const parent = intrnlCall(appendAfter, "parentNode");
713
+ if (parent.__insertBefore) {
714
+ return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
715
+ } else {
716
+ return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
717
+ }
718
+ }
719
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
720
+ newChild.hidden = true;
721
+ }
722
+ return HostElementPrototype.__prepend(newChild);
723
+ });
684
724
  };
685
- if (import_app_data2.BUILD.vdomAttribute) {
686
- vnode.$attrs$ = null;
687
- }
688
- if (import_app_data2.BUILD.vdomKey) {
689
- vnode.$key$ = null;
690
- }
691
- if (import_app_data2.BUILD.slotRelocation) {
692
- vnode.$name$ = null;
693
- }
694
- return vnode;
695
725
  };
696
- var Host = {};
697
- var isHost = (node) => node && node.$tag$ === Host;
698
- var vdomFnUtils = {
699
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
700
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
726
+ var patchSlotAppend = (HostElementPrototype) => {
727
+ HostElementPrototype.__append = HostElementPrototype.append;
728
+ HostElementPrototype.append = function(...newChildren) {
729
+ newChildren.forEach((newChild) => {
730
+ if (typeof newChild === "string") {
731
+ newChild = this.ownerDocument.createTextNode(newChild);
732
+ }
733
+ this.appendChild(newChild);
734
+ });
735
+ };
701
736
  };
702
- var convertToPublic = (node) => ({
703
- vattrs: node.$attrs$,
704
- vchildren: node.$children$,
705
- vkey: node.$key$,
706
- vname: node.$name$,
707
- vtag: node.$tag$,
708
- vtext: node.$text$
709
- });
710
- var convertToPrivate = (node) => {
711
- if (typeof node.vtag === "function") {
712
- const vnodeData = { ...node.vattrs };
713
- if (node.vkey) {
714
- vnodeData.key = node.vkey;
737
+ var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
738
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
739
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
740
+ if (position !== "afterbegin" && position !== "beforeend") {
741
+ return originalInsertAdjacentHtml.call(this, position, text);
715
742
  }
716
- if (node.vname) {
717
- vnodeData.name = node.vname;
743
+ const container = this.ownerDocument.createElement("_");
744
+ let node;
745
+ container.innerHTML = text;
746
+ if (position === "afterbegin") {
747
+ while (node = container.firstChild) {
748
+ this.prepend(node);
749
+ }
750
+ } else if (position === "beforeend") {
751
+ while (node = container.firstChild) {
752
+ this.append(node);
753
+ }
718
754
  }
719
- return h(node.vtag, vnodeData, ...node.vchildren || []);
720
- }
721
- const vnode = newVNode(node.vtag, node.vtext);
722
- vnode.$attrs$ = node.vattrs;
723
- vnode.$children$ = node.vchildren;
724
- vnode.$key$ = node.vkey;
725
- vnode.$name$ = node.vname;
726
- return vnode;
755
+ };
727
756
  };
728
- var validateInputProperties = (inputElm) => {
729
- const props = Object.keys(inputElm);
730
- const value = props.indexOf("value");
731
- if (value === -1) {
732
- return;
733
- }
734
- const typeIndex = props.indexOf("type");
735
- const minIndex = props.indexOf("min");
736
- const maxIndex = props.indexOf("max");
737
- const stepIndex = props.indexOf("step");
738
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
739
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
740
- }
757
+ var patchSlotInsertAdjacentText = (HostElementPrototype) => {
758
+ HostElementPrototype.insertAdjacentText = function(position, text) {
759
+ this.insertAdjacentHTML(position, text);
760
+ };
741
761
  };
742
-
743
- // src/runtime/vdom/update-element.ts
744
- var import_app_data4 = require("@rindo/core/internal/app-data");
745
-
746
- // src/runtime/vdom/set-accessor.ts
747
- var import_app_data3 = require("@rindo/core/internal/app-data");
748
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
749
- if (oldValue !== newValue) {
750
- let isProp = isMemberInElement(elm, memberName);
751
- let ln = memberName.toLowerCase();
752
- if (import_app_data3.BUILD.vdomClass && memberName === "class") {
753
- const classList = elm.classList;
754
- const oldClasses = parseClassList(oldValue);
755
- let newClasses = parseClassList(newValue);
756
- if (elm["s-si"]) {
757
- newClasses.push(elm["s-si"]);
758
- oldClasses.forEach((c) => {
759
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
760
- });
761
- newClasses = [...new Set(newClasses)];
762
- classList.add(...newClasses);
763
- delete elm["s-si"];
764
- } else {
765
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
766
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
767
- }
768
- } else if (import_app_data3.BUILD.vdomStyle && memberName === "style") {
769
- if (import_app_data3.BUILD.updatable) {
770
- for (const prop in oldValue) {
771
- if (!newValue || newValue[prop] == null) {
772
- if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
773
- elm.style.removeProperty(prop);
774
- } else {
775
- elm.style[prop] = "";
776
- }
777
- }
778
- }
779
- }
780
- for (const prop in newValue) {
781
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
782
- if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
783
- elm.style.setProperty(prop, newValue[prop]);
784
- } else {
785
- elm.style[prop] = newValue[prop];
762
+ var patchInsertBefore = (HostElementPrototype) => {
763
+ const eleProto = HostElementPrototype;
764
+ if (eleProto.__insertBefore) return;
765
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
766
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
767
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
768
+ const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
769
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
770
+ if (slotNode) {
771
+ let found = false;
772
+ slottedNodes.forEach((childNode) => {
773
+ if (childNode === currentChild || currentChild === null) {
774
+ found = true;
775
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
776
+ this.appendChild(newChild);
777
+ return;
786
778
  }
787
- }
788
- }
789
- } else if (import_app_data3.BUILD.vdomKey && memberName === "key") {
790
- } else if (import_app_data3.BUILD.vdomRef && memberName === "ref") {
791
- if (newValue) {
792
- newValue(elm);
793
- }
794
- } else if (import_app_data3.BUILD.vdomListener && (import_app_data3.BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
795
- if (memberName[2] === "-") {
796
- memberName = memberName.slice(3);
797
- } else if (isMemberInElement(win, ln)) {
798
- memberName = ln.slice(2);
799
- } else {
800
- memberName = ln[2] + memberName.slice(3);
801
- }
802
- if (oldValue || newValue) {
803
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
804
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
805
- if (oldValue) {
806
- plt.rel(elm, memberName, oldValue, capture);
807
- }
808
- if (newValue) {
809
- plt.ael(elm, memberName, newValue, capture);
810
- }
811
- }
812
- } else if (import_app_data3.BUILD.vdomPropOrAttr) {
813
- const isComplex = isComplexType(newValue);
814
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
815
- try {
816
- if (!elm.tagName.includes("-")) {
817
- const n = newValue == null ? "" : newValue;
818
- if (memberName === "list") {
819
- isProp = false;
820
- } else if (oldValue == null || elm[memberName] != n) {
821
- if (typeof elm.__lookupSetter__(memberName) === "function") {
822
- elm[memberName] = n;
823
- } else {
824
- elm.setAttribute(memberName, n);
825
- }
779
+ if (slotName === currentChild["s-sn"]) {
780
+ addSlotRelocateNode(newChild, slotNode);
781
+ const parent = intrnlCall(currentChild, "parentNode");
782
+ if (parent.__insertBefore) {
783
+ parent.__insertBefore(newChild, currentChild);
784
+ } else {
785
+ parent.insertBefore(newChild, currentChild);
826
786
  }
827
- } else {
828
- elm[memberName] = newValue;
829
- }
830
- } catch (e) {
831
- }
832
- }
833
- let xlink = false;
834
- if (import_app_data3.BUILD.vdomXlink) {
835
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
836
- memberName = ln;
837
- xlink = true;
838
- }
839
- }
840
- if (newValue == null || newValue === false) {
841
- if (newValue !== false || elm.getAttribute(memberName) === "") {
842
- if (import_app_data3.BUILD.vdomXlink && xlink) {
843
- elm.removeAttributeNS(XLINK_NS, memberName);
844
- } else {
845
- elm.removeAttribute(memberName);
846
787
  }
788
+ return;
847
789
  }
848
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
849
- newValue = newValue === true ? "" : newValue;
850
- if (import_app_data3.BUILD.vdomXlink && xlink) {
851
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
852
- } else {
853
- elm.setAttribute(memberName, newValue);
854
- }
855
- }
790
+ });
791
+ if (found) return newChild;
856
792
  }
857
- }
793
+ return this.__insertBefore(newChild, currentChild);
794
+ };
858
795
  };
859
- var parseClassListRegex = /\s/;
860
- var parseClassList = (value) => {
861
- if (typeof value === "object" && "baseVal" in value) {
862
- value = value.baseVal;
863
- }
864
- if (!value) {
865
- return [];
866
- }
867
- return value.split(parseClassListRegex);
796
+ var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
797
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
798
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
799
+ if (position !== "afterbegin" && position !== "beforeend") {
800
+ return originalInsertAdjacentElement.call(this, position, element);
801
+ }
802
+ if (position === "afterbegin") {
803
+ this.prepend(element);
804
+ return element;
805
+ } else if (position === "beforeend") {
806
+ this.append(element);
807
+ return element;
808
+ }
809
+ return element;
810
+ };
868
811
  };
869
- var CAPTURE_EVENT_SUFFIX = "Capture";
870
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
871
-
872
- // src/runtime/vdom/update-element.ts
873
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
874
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
875
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
876
- const newVnodeAttrs = newVnode.$attrs$ || {};
877
- if (import_app_data4.BUILD.updatable) {
878
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
879
- if (!(memberName in newVnodeAttrs)) {
880
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
881
- }
812
+ var patchTextContent = (hostElementPrototype) => {
813
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
814
+ Object.defineProperty(hostElementPrototype, "textContent", {
815
+ get: function() {
816
+ let text = "";
817
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
818
+ childNodes.forEach((node) => text += node.textContent || "");
819
+ return text;
820
+ },
821
+ set: function(value) {
822
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
823
+ childNodes.forEach((node) => {
824
+ if (node["s-ol"]) node["s-ol"].remove();
825
+ node.remove();
826
+ });
827
+ this.insertAdjacentHTML("beforeend", value);
882
828
  }
883
- }
884
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
885
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
886
- }
829
+ });
887
830
  };
888
- function sortedAttrNames(attrNames) {
889
- return attrNames.includes("ref") ? (
890
- // we need to sort these to ensure that `'ref'` is the last attr
891
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
892
- ) : (
893
- // no need to sort, return the original array
894
- attrNames
895
- );
896
- }
897
-
898
- // src/runtime/vdom/vdom-render.ts
899
- var scopeId;
900
- var contentRef;
901
- var hostTagName;
902
- var useNativeShadowDom = false;
903
- var checkSlotFallbackVisibility = false;
904
- var checkSlotRelocate = false;
905
- var isSvgMode = false;
906
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
907
- var _a;
908
- const newVNode2 = newParentVNode.$children$[childIndex];
909
- let i2 = 0;
910
- let elm;
911
- let childNode;
912
- let oldVNode;
913
- if (import_app_data5.BUILD.slotRelocation && !useNativeShadowDom) {
914
- checkSlotRelocate = true;
915
- if (newVNode2.$tag$ === "slot") {
916
- newVNode2.$flags$ |= newVNode2.$children$ ? (
917
- // slot element has fallback content
918
- // still create an element that "mocks" the slot element
919
- 2 /* isSlotFallback */
920
- ) : (
921
- // slot element does not have fallback content
922
- // create an html comment we'll use to always reference
923
- // where actual slot content should sit next to
924
- 1 /* isSlotReference */
925
- );
831
+ var patchChildSlotNodes = (elm) => {
832
+ class FakeNodeList extends Array {
833
+ item(n) {
834
+ return this[n];
926
835
  }
927
836
  }
928
- if (import_app_data5.BUILD.isDev && newVNode2.$elm$) {
929
- consoleDevError(
930
- `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://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`
931
- );
932
- }
933
- if (import_app_data5.BUILD.vdomText && newVNode2.$text$ !== null) {
934
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
935
- } else if (import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
936
- elm = newVNode2.$elm$ = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
937
- } else {
938
- if (import_app_data5.BUILD.svg && !isSvgMode) {
939
- isSvgMode = newVNode2.$tag$ === "svg";
940
- }
941
- elm = newVNode2.$elm$ = import_app_data5.BUILD.svg ? doc.createElementNS(
942
- isSvgMode ? SVG_NS : HTML_NS,
943
- !useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
944
- ) : doc.createElement(
945
- !useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
946
- );
947
- if (import_app_data5.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
948
- isSvgMode = false;
837
+ patchHostOriginalAccessor("children", elm);
838
+ Object.defineProperty(elm, "children", {
839
+ get() {
840
+ return this.childNodes.filter((n) => n.nodeType === 1);
949
841
  }
950
- if (import_app_data5.BUILD.vdomAttribute) {
951
- updateElement(null, newVNode2, isSvgMode);
842
+ });
843
+ Object.defineProperty(elm, "childElementCount", {
844
+ get() {
845
+ return this.children.length;
952
846
  }
953
- if (import_app_data5.BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
954
- elm.classList.add(elm["s-si"] = scopeId);
847
+ });
848
+ patchHostOriginalAccessor("firstChild", elm);
849
+ Object.defineProperty(elm, "firstChild", {
850
+ get() {
851
+ return this.childNodes[0];
955
852
  }
956
- if (newVNode2.$children$) {
957
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
958
- childNode = createElm(oldParentVNode, newVNode2, i2);
959
- if (childNode) {
960
- elm.appendChild(childNode);
961
- }
962
- }
853
+ });
854
+ patchHostOriginalAccessor("lastChild", elm);
855
+ Object.defineProperty(elm, "lastChild", {
856
+ get() {
857
+ return this.childNodes[this.childNodes.length - 1];
963
858
  }
964
- if (import_app_data5.BUILD.svg) {
965
- if (newVNode2.$tag$ === "svg") {
966
- isSvgMode = false;
967
- } else if (elm.tagName === "foreignObject") {
968
- isSvgMode = true;
969
- }
859
+ });
860
+ patchHostOriginalAccessor("childNodes", elm);
861
+ Object.defineProperty(elm, "childNodes", {
862
+ get() {
863
+ const result = new FakeNodeList();
864
+ result.push(...getSlottedChildNodes(this.__childNodes));
865
+ return result;
970
866
  }
867
+ });
868
+ };
869
+ var patchSlottedNode = (node) => {
870
+ if (!node || node.__nextSibling || !globalThis.Node) return;
871
+ patchNextSibling(node);
872
+ patchPreviousSibling(node);
873
+ patchParentNode(node);
874
+ if (node.nodeType === Node.ELEMENT_NODE) {
875
+ patchNextElementSibling(node);
876
+ patchPreviousElementSibling(node);
971
877
  }
972
- elm["s-hn"] = hostTagName;
973
- if (import_app_data5.BUILD.slotRelocation) {
974
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
975
- elm["s-sr"] = true;
976
- elm["s-cr"] = contentRef;
977
- elm["s-sn"] = newVNode2.$name$ || "";
978
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
979
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
980
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
981
- if (import_app_data5.BUILD.experimentalSlotFixes) {
982
- relocateToHostRoot(oldParentVNode.$elm$);
983
- } else {
984
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
985
- }
878
+ };
879
+ var patchNextSibling = (node) => {
880
+ if (!node || node.__nextSibling) return;
881
+ patchHostOriginalAccessor("nextSibling", node);
882
+ Object.defineProperty(node, "nextSibling", {
883
+ get: function() {
884
+ var _a;
885
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
886
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
887
+ if (parentNodes && index > -1) {
888
+ return parentNodes[index + 1];
986
889
  }
987
- if (import_app_data5.BUILD.scoped) {
988
- addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
890
+ return this.__nextSibling;
891
+ }
892
+ });
893
+ };
894
+ var patchNextElementSibling = (element) => {
895
+ if (!element || element.__nextElementSibling) return;
896
+ patchHostOriginalAccessor("nextElementSibling", element);
897
+ Object.defineProperty(element, "nextElementSibling", {
898
+ get: function() {
899
+ var _a;
900
+ const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
901
+ const index = parentEles == null ? void 0 : parentEles.indexOf(this);
902
+ if (parentEles && index > -1) {
903
+ return parentEles[index + 1];
989
904
  }
905
+ return this.__nextElementSibling;
990
906
  }
991
- }
992
- return elm;
907
+ });
993
908
  };
994
- var relocateToHostRoot = (parentElm) => {
995
- plt.$flags$ |= 1 /* isTmpDisconnected */;
996
- const host = parentElm.closest(hostTagName.toLowerCase());
997
- if (host != null) {
998
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
999
- (ref) => ref["s-cr"]
1000
- );
1001
- const childNodeArray = Array.from(
1002
- parentElm.__childNodes || parentElm.childNodes
1003
- );
1004
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1005
- if (childNode["s-sh"] != null) {
1006
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1007
- childNode["s-sh"] = void 0;
1008
- checkSlotRelocate = true;
909
+ var patchPreviousSibling = (node) => {
910
+ if (!node || node.__previousSibling) return;
911
+ patchHostOriginalAccessor("previousSibling", node);
912
+ Object.defineProperty(node, "previousSibling", {
913
+ get: function() {
914
+ var _a;
915
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
916
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
917
+ if (parentNodes && index > -1) {
918
+ return parentNodes[index - 1];
1009
919
  }
920
+ return this.__previousSibling;
1010
921
  }
1011
- }
1012
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
922
+ });
1013
923
  };
1014
- var putBackInOriginalLocation = (parentElm, recursive) => {
1015
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1016
- const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1017
- if (parentElm["s-sr"] && import_app_data5.BUILD.experimentalSlotFixes) {
1018
- let node = parentElm;
1019
- while (node = node.nextSibling) {
1020
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1021
- oldSlotChildNodes.push(node);
924
+ var patchPreviousElementSibling = (element) => {
925
+ if (!element || element.__previousElementSibling) return;
926
+ patchHostOriginalAccessor("previousElementSibling", element);
927
+ Object.defineProperty(element, "previousElementSibling", {
928
+ get: function() {
929
+ var _a;
930
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
931
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
932
+ if (parentNodes && index > -1) {
933
+ return parentNodes[index - 1];
1022
934
  }
935
+ return this.__previousElementSibling;
1023
936
  }
1024
- }
1025
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1026
- const childNode = oldSlotChildNodes[i2];
1027
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1028
- insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1029
- childNode["s-ol"].remove();
1030
- childNode["s-ol"] = void 0;
1031
- childNode["s-sh"] = void 0;
1032
- checkSlotRelocate = true;
937
+ });
938
+ };
939
+ var patchParentNode = (node) => {
940
+ if (!node || node.__parentNode) return;
941
+ patchHostOriginalAccessor("parentNode", node);
942
+ Object.defineProperty(node, "parentNode", {
943
+ get: function() {
944
+ var _a;
945
+ return ((_a = this["s-ol"]) == null ? void 0 : _a.parentNode) || this.__parentNode;
946
+ },
947
+ set: function(value) {
948
+ this.__parentNode = value;
1033
949
  }
1034
- if (recursive) {
1035
- putBackInOriginalLocation(childNode, recursive);
950
+ });
951
+ };
952
+ var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
953
+ var validNodesPatches = [
954
+ "childNodes",
955
+ "firstChild",
956
+ "lastChild",
957
+ "nextSibling",
958
+ "previousSibling",
959
+ "textContent",
960
+ "parentNode"
961
+ ];
962
+ function patchHostOriginalAccessor(accessorName, node) {
963
+ let accessor;
964
+ if (validElementPatches.includes(accessorName)) {
965
+ accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
966
+ } else if (validNodesPatches.includes(accessorName)) {
967
+ accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
968
+ }
969
+ if (!accessor) {
970
+ accessor = Object.getOwnPropertyDescriptor(node, accessorName);
971
+ }
972
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
973
+ }
974
+ function intrnlCall(node, method) {
975
+ if ("__" + method in node) {
976
+ return node["__" + method];
977
+ } else {
978
+ return node[method];
979
+ }
980
+ }
981
+
982
+ // src/runtime/profile.ts
983
+ var import_app_data3 = require("@rindo/core/internal/app-data");
984
+ var i = 0;
985
+ var createTime = (fnName, tagName = "") => {
986
+ if (import_app_data3.BUILD.profile && performance.mark) {
987
+ const key = `st:${fnName}:${tagName}:${i++}`;
988
+ performance.mark(key);
989
+ return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
990
+ } else {
991
+ return () => {
992
+ return;
993
+ };
994
+ }
995
+ };
996
+ var uniqueTime = (key, measureText) => {
997
+ if (import_app_data3.BUILD.profile && performance.mark) {
998
+ if (performance.getEntriesByName(key, "mark").length === 0) {
999
+ performance.mark(key);
1036
1000
  }
1001
+ return () => {
1002
+ if (performance.getEntriesByName(measureText, "measure").length === 0) {
1003
+ performance.measure(measureText, key);
1004
+ }
1005
+ };
1006
+ } else {
1007
+ return () => {
1008
+ return;
1009
+ };
1037
1010
  }
1038
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1039
1011
  };
1040
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1041
- let containerElm = import_app_data5.BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1042
- let childNode;
1043
- if (import_app_data5.BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1044
- containerElm = containerElm.shadowRoot;
1012
+ var inspect = (ref) => {
1013
+ const hostRef = getHostRef(ref);
1014
+ if (!hostRef) {
1015
+ return void 0;
1045
1016
  }
1046
- for (; startIdx <= endIdx; ++startIdx) {
1047
- if (vnodes[startIdx]) {
1048
- childNode = createElm(null, parentVNode, startIdx);
1049
- if (childNode) {
1050
- vnodes[startIdx].$elm$ = childNode;
1051
- insertBefore(containerElm, childNode, import_app_data5.BUILD.slotRelocation ? referenceNode(before) : before);
1017
+ const flags = hostRef.$flags$;
1018
+ const hostElement = hostRef.$hostElement$;
1019
+ return {
1020
+ renderCount: hostRef.$renderCount$,
1021
+ flags: {
1022
+ hasRendered: !!(flags & 2 /* hasRendered */),
1023
+ hasConnected: !!(flags & 1 /* hasConnected */),
1024
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1025
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1026
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1027
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1028
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1029
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
1030
+ isListenReady: !!(flags & 256 /* isListenReady */),
1031
+ needsRerender: !!(flags & 512 /* needsRerender */)
1032
+ },
1033
+ instanceValues: hostRef.$instanceValues$,
1034
+ ancestorComponent: hostRef.$ancestorComponent$,
1035
+ hostElement,
1036
+ lazyInstance: hostRef.$lazyInstance$,
1037
+ vnode: hostRef.$vnode$,
1038
+ modeName: hostRef.$modeName$,
1039
+ onReadyPromise: hostRef.$onReadyPromise$,
1040
+ onReadyResolve: hostRef.$onReadyResolve$,
1041
+ onInstancePromise: hostRef.$onInstancePromise$,
1042
+ onInstanceResolve: hostRef.$onInstanceResolve$,
1043
+ onRenderResolve: hostRef.$onRenderResolve$,
1044
+ queuedListeners: hostRef.$queuedListeners$,
1045
+ rmListeners: hostRef.$rmListeners$,
1046
+ ["s-id"]: hostElement["s-id"],
1047
+ ["s-cr"]: hostElement["s-cr"],
1048
+ ["s-lr"]: hostElement["s-lr"],
1049
+ ["s-p"]: hostElement["s-p"],
1050
+ ["s-rc"]: hostElement["s-rc"],
1051
+ ["s-sc"]: hostElement["s-sc"]
1052
+ };
1053
+ };
1054
+ var installDevTools = () => {
1055
+ if (import_app_data3.BUILD.devTools) {
1056
+ const rindo = win.rindo = win.rindo || {};
1057
+ const originalInspect = rindo.inspect;
1058
+ rindo.inspect = (ref) => {
1059
+ let result = inspect(ref);
1060
+ if (!result && typeof originalInspect === "function") {
1061
+ result = originalInspect(ref);
1052
1062
  }
1053
- }
1063
+ return result;
1064
+ };
1054
1065
  }
1055
1066
  };
1056
- var removeVnodes = (vnodes, startIdx, endIdx) => {
1057
- for (let index = startIdx; index <= endIdx; ++index) {
1058
- const vnode = vnodes[index];
1059
- if (vnode) {
1060
- const elm = vnode.$elm$;
1061
- nullifyVNodeRefs(vnode);
1062
- if (elm) {
1063
- if (import_app_data5.BUILD.slotRelocation) {
1064
- checkSlotFallbackVisibility = true;
1065
- if (elm["s-ol"]) {
1066
- elm["s-ol"].remove();
1067
- } else {
1068
- putBackInOriginalLocation(elm, true);
1069
- }
1067
+
1068
+ // src/runtime/vdom/h.ts
1069
+ var import_app_data4 = require("@rindo/core/internal/app-data");
1070
+ var h = (nodeName, vnodeData, ...children) => {
1071
+ let child = null;
1072
+ let key = null;
1073
+ let slotName = null;
1074
+ let simple = false;
1075
+ let lastSimple = false;
1076
+ const vNodeChildren = [];
1077
+ const walk = (c) => {
1078
+ for (let i2 = 0; i2 < c.length; i2++) {
1079
+ child = c[i2];
1080
+ if (Array.isArray(child)) {
1081
+ walk(child);
1082
+ } else if (child != null && typeof child !== "boolean") {
1083
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
1084
+ child = String(child);
1085
+ } else if (import_app_data4.BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
1086
+ consoleDevError(`vNode passed as children has unexpected type.
1087
+ Make sure it's using the correct h() function.
1088
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
1070
1089
  }
1071
- elm.remove();
1090
+ if (simple && lastSimple) {
1091
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
1092
+ } else {
1093
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
1094
+ }
1095
+ lastSimple = simple;
1072
1096
  }
1073
1097
  }
1074
- }
1075
- };
1076
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1077
- let oldStartIdx = 0;
1078
- let newStartIdx = 0;
1079
- let idxInOld = 0;
1080
- let i2 = 0;
1081
- let oldEndIdx = oldCh.length - 1;
1082
- let oldStartVnode = oldCh[0];
1083
- let oldEndVnode = oldCh[oldEndIdx];
1084
- let newEndIdx = newCh.length - 1;
1085
- let newStartVnode = newCh[0];
1086
- let newEndVnode = newCh[newEndIdx];
1087
- let node;
1088
- let elmToMove;
1089
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1090
- if (oldStartVnode == null) {
1091
- oldStartVnode = oldCh[++oldStartIdx];
1092
- } else if (oldEndVnode == null) {
1093
- oldEndVnode = oldCh[--oldEndIdx];
1094
- } else if (newStartVnode == null) {
1095
- newStartVnode = newCh[++newStartIdx];
1096
- } else if (newEndVnode == null) {
1097
- newEndVnode = newCh[--newEndIdx];
1098
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1099
- patch(oldStartVnode, newStartVnode, isInitialRender);
1100
- oldStartVnode = oldCh[++oldStartIdx];
1101
- newStartVnode = newCh[++newStartIdx];
1102
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1103
- patch(oldEndVnode, newEndVnode, isInitialRender);
1104
- oldEndVnode = oldCh[--oldEndIdx];
1105
- newEndVnode = newCh[--newEndIdx];
1106
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1107
- if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1108
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1109
- }
1110
- patch(oldStartVnode, newEndVnode, isInitialRender);
1111
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1112
- oldStartVnode = oldCh[++oldStartIdx];
1113
- newEndVnode = newCh[--newEndIdx];
1114
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1115
- if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1116
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1117
- }
1118
- patch(oldEndVnode, newStartVnode, isInitialRender);
1119
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1120
- oldEndVnode = oldCh[--oldEndIdx];
1121
- newStartVnode = newCh[++newStartIdx];
1122
- } else {
1123
- idxInOld = -1;
1124
- if (import_app_data5.BUILD.vdomKey) {
1125
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
1126
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
1127
- idxInOld = i2;
1128
- break;
1129
- }
1130
- }
1131
- }
1132
- if (import_app_data5.BUILD.vdomKey && idxInOld >= 0) {
1133
- elmToMove = oldCh[idxInOld];
1134
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1135
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
1136
- } else {
1137
- patch(elmToMove, newStartVnode, isInitialRender);
1138
- oldCh[idxInOld] = void 0;
1139
- node = elmToMove.$elm$;
1140
- }
1141
- newStartVnode = newCh[++newStartIdx];
1142
- } else {
1143
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1144
- newStartVnode = newCh[++newStartIdx];
1145
- }
1146
- if (node) {
1147
- if (import_app_data5.BUILD.slotRelocation) {
1148
- insertBefore(
1149
- referenceNode(oldStartVnode.$elm$).parentNode,
1150
- node,
1151
- referenceNode(oldStartVnode.$elm$)
1152
- );
1153
- } else {
1154
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1155
- }
1098
+ };
1099
+ walk(children);
1100
+ if (vnodeData) {
1101
+ if (import_app_data4.BUILD.isDev && nodeName === "input") {
1102
+ validateInputProperties(vnodeData);
1103
+ }
1104
+ if (import_app_data4.BUILD.vdomKey && vnodeData.key) {
1105
+ key = vnodeData.key;
1106
+ }
1107
+ if (import_app_data4.BUILD.slotRelocation && vnodeData.name) {
1108
+ slotName = vnodeData.name;
1109
+ }
1110
+ if (import_app_data4.BUILD.vdomClass) {
1111
+ const classData = vnodeData.className || vnodeData.class;
1112
+ if (classData) {
1113
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
1156
1114
  }
1157
1115
  }
1158
1116
  }
1159
- if (oldStartIdx > oldEndIdx) {
1160
- addVnodes(
1161
- parentElm,
1162
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1163
- newVNode2,
1164
- newCh,
1165
- newStartIdx,
1166
- newEndIdx
1117
+ if (import_app_data4.BUILD.isDev && vNodeChildren.some(isHost)) {
1118
+ consoleDevError(`The <Host> must be the single root component. Make sure:
1119
+ - You are NOT using hostData() and <Host> in the same component.
1120
+ - <Host> is used once, and it's the single root component of the render() function.`);
1121
+ }
1122
+ if (import_app_data4.BUILD.vdomFunctional && typeof nodeName === "function") {
1123
+ return nodeName(
1124
+ vnodeData === null ? {} : vnodeData,
1125
+ vNodeChildren,
1126
+ vdomFnUtils
1167
1127
  );
1168
- } else if (import_app_data5.BUILD.updatable && newStartIdx > newEndIdx) {
1169
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1170
1128
  }
1129
+ const vnode = newVNode(nodeName, null);
1130
+ vnode.$attrs$ = vnodeData;
1131
+ if (vNodeChildren.length > 0) {
1132
+ vnode.$children$ = vNodeChildren;
1133
+ }
1134
+ if (import_app_data4.BUILD.vdomKey) {
1135
+ vnode.$key$ = key;
1136
+ }
1137
+ if (import_app_data4.BUILD.slotRelocation) {
1138
+ vnode.$name$ = slotName;
1139
+ }
1140
+ return vnode;
1171
1141
  };
1172
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1173
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1174
- if (import_app_data5.BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
1175
- return leftVNode.$name$ === rightVNode.$name$;
1176
- }
1177
- if (import_app_data5.BUILD.vdomKey && !isInitialRender) {
1178
- return leftVNode.$key$ === rightVNode.$key$;
1142
+ var newVNode = (tag, text) => {
1143
+ const vnode = {
1144
+ $flags$: 0,
1145
+ $tag$: tag,
1146
+ $text$: text,
1147
+ $elm$: null,
1148
+ $children$: null
1149
+ };
1150
+ if (import_app_data4.BUILD.vdomAttribute) {
1151
+ vnode.$attrs$ = null;
1152
+ }
1153
+ if (import_app_data4.BUILD.vdomKey) {
1154
+ vnode.$key$ = null;
1155
+ }
1156
+ if (import_app_data4.BUILD.slotRelocation) {
1157
+ vnode.$name$ = null;
1158
+ }
1159
+ return vnode;
1160
+ };
1161
+ var Host = {};
1162
+ var isHost = (node) => node && node.$tag$ === Host;
1163
+ var vdomFnUtils = {
1164
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
1165
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
1166
+ };
1167
+ var convertToPublic = (node) => ({
1168
+ vattrs: node.$attrs$,
1169
+ vchildren: node.$children$,
1170
+ vkey: node.$key$,
1171
+ vname: node.$name$,
1172
+ vtag: node.$tag$,
1173
+ vtext: node.$text$
1174
+ });
1175
+ var convertToPrivate = (node) => {
1176
+ if (typeof node.vtag === "function") {
1177
+ const vnodeData = { ...node.vattrs };
1178
+ if (node.vkey) {
1179
+ vnodeData.key = node.vkey;
1179
1180
  }
1180
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1181
- leftVNode.$key$ = rightVNode.$key$;
1181
+ if (node.vname) {
1182
+ vnodeData.name = node.vname;
1182
1183
  }
1183
- return true;
1184
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
1184
1185
  }
1185
- return false;
1186
+ const vnode = newVNode(node.vtag, node.vtext);
1187
+ vnode.$attrs$ = node.vattrs;
1188
+ vnode.$children$ = node.vchildren;
1189
+ vnode.$key$ = node.vkey;
1190
+ vnode.$name$ = node.vname;
1191
+ return vnode;
1186
1192
  };
1187
- var referenceNode = (node) => node && node["s-ol"] || node;
1188
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1189
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
1190
- const oldChildren = oldVNode.$children$;
1191
- const newChildren = newVNode2.$children$;
1192
- const tag = newVNode2.$tag$;
1193
- const text = newVNode2.$text$;
1194
- let defaultHolder;
1195
- if (!import_app_data5.BUILD.vdomText || text === null) {
1196
- if (import_app_data5.BUILD.svg) {
1197
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1193
+ var validateInputProperties = (inputElm) => {
1194
+ const props = Object.keys(inputElm);
1195
+ const value = props.indexOf("value");
1196
+ if (value === -1) {
1197
+ return;
1198
+ }
1199
+ const typeIndex = props.indexOf("type");
1200
+ const minIndex = props.indexOf("min");
1201
+ const maxIndex = props.indexOf("max");
1202
+ const stepIndex = props.indexOf("step");
1203
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
1204
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
1205
+ }
1206
+ };
1207
+
1208
+ // src/runtime/client-hydrate.ts
1209
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1210
+ const endHydrate = createTime("hydrateClient", tagName);
1211
+ const shadowRoot = hostElm.shadowRoot;
1212
+ const childRenderNodes = [];
1213
+ const slotNodes = [];
1214
+ const slottedNodes = [];
1215
+ const shadowRootNodes = import_app_data5.BUILD.shadowDom && shadowRoot ? [] : null;
1216
+ const vnode = newVNode(tagName, null);
1217
+ vnode.$elm$ = hostElm;
1218
+ let scopeId2;
1219
+ if (import_app_data5.BUILD.scoped) {
1220
+ const cmpMeta = hostRef.$cmpMeta$;
1221
+ if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1222
+ scopeId2 = hostElm["s-sc"];
1223
+ hostElm.classList.add(scopeId2 + "-h");
1224
+ } else if (hostElm["s-sc"]) {
1225
+ delete hostElm["s-sc"];
1198
1226
  }
1199
- if (import_app_data5.BUILD.vdomAttribute || import_app_data5.BUILD.reflect) {
1200
- if (import_app_data5.BUILD.slot && tag === "slot" && !useNativeShadowDom) {
1201
- if (import_app_data5.BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1202
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1203
- relocateToHostRoot(newVNode2.$elm$.parentElement);
1227
+ }
1228
+ if (!plt.$orgLocNodes$) {
1229
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1230
+ }
1231
+ hostElm[HYDRATE_ID] = hostId;
1232
+ hostElm.removeAttribute(HYDRATE_ID);
1233
+ hostRef.$vnode$ = clientHydrate(
1234
+ vnode,
1235
+ childRenderNodes,
1236
+ slotNodes,
1237
+ shadowRootNodes,
1238
+ hostElm,
1239
+ hostElm,
1240
+ hostId,
1241
+ slottedNodes
1242
+ );
1243
+ let crIndex = 0;
1244
+ const crLength = childRenderNodes.length;
1245
+ let childRenderNode;
1246
+ for (crIndex; crIndex < crLength; crIndex++) {
1247
+ childRenderNode = childRenderNodes[crIndex];
1248
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1249
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1250
+ const node = childRenderNode.$elm$;
1251
+ if (!shadowRoot) {
1252
+ node["s-hn"] = tagName.toUpperCase();
1253
+ if (childRenderNode.$tag$ === "slot") {
1254
+ node["s-cr"] = hostElm["s-cr"];
1255
+ }
1256
+ }
1257
+ if (childRenderNode.$tag$ === "slot") {
1258
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
1259
+ if (childRenderNode.$children$) {
1260
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1261
+ if (!childRenderNode.$elm$.childNodes.length) {
1262
+ childRenderNode.$children$.forEach((c) => {
1263
+ childRenderNode.$elm$.appendChild(c.$elm$);
1264
+ });
1204
1265
  }
1205
1266
  } else {
1206
- updateElement(oldVNode, newVNode2, isSvgMode);
1267
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
1207
1268
  }
1208
1269
  }
1209
- if (import_app_data5.BUILD.updatable && oldChildren !== null && newChildren !== null) {
1210
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1211
- } else if (newChildren !== null) {
1212
- if (import_app_data5.BUILD.updatable && import_app_data5.BUILD.vdomText && oldVNode.$text$ !== null) {
1213
- elm.textContent = "";
1270
+ if (orgLocationNode && orgLocationNode.isConnected) {
1271
+ if (shadowRoot && orgLocationNode["s-en"] === "") {
1272
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1273
+ }
1274
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
1275
+ if (!shadowRoot) {
1276
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1214
1277
  }
1215
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1216
- } else if (
1217
- // don't do this on initial render as it can cause non-hydrated content to be removed
1218
- !isInitialRender && import_app_data5.BUILD.updatable && oldChildren !== null
1219
- ) {
1220
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1221
- }
1222
- if (import_app_data5.BUILD.svg && isSvgMode && tag === "svg") {
1223
- isSvgMode = false;
1224
1278
  }
1225
- } else if (import_app_data5.BUILD.vdomText && import_app_data5.BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
1226
- defaultHolder.parentNode.textContent = text;
1227
- } else if (import_app_data5.BUILD.vdomText && oldVNode.$text$ !== text) {
1228
- elm.data = text;
1279
+ plt.$orgLocNodes$.delete(orgLocationId);
1229
1280
  }
1230
- };
1231
- var relocateNodes = [];
1232
- var markSlotContentForRelocation = (elm) => {
1233
- let node;
1234
- let hostContentNodes;
1235
- let j;
1236
- const children = elm.__childNodes || elm.childNodes;
1237
- for (const childNode of children) {
1238
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1239
- hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1240
- const slotName = childNode["s-sn"];
1241
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1242
- node = hostContentNodes[j];
1243
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!import_app_data5.BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1244
- if (isNodeLocatedInSlot(node, slotName)) {
1245
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1246
- checkSlotFallbackVisibility = true;
1247
- node["s-sn"] = node["s-sn"] || slotName;
1248
- if (relocateNodeData) {
1249
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1250
- relocateNodeData.$slotRefNode$ = childNode;
1251
- } else {
1252
- node["s-sh"] = childNode["s-hn"];
1253
- relocateNodes.push({
1254
- $slotRefNode$: childNode,
1255
- $nodeToRelocate$: node
1256
- });
1257
- }
1258
- if (node["s-sr"]) {
1259
- relocateNodes.map((relocateNode) => {
1260
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1261
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1262
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1263
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1264
- }
1265
- }
1266
- });
1267
- }
1268
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1269
- relocateNodes.push({
1270
- $nodeToRelocate$: node
1271
- });
1272
- }
1281
+ const hosts = [];
1282
+ const snLen = slottedNodes.length;
1283
+ let snIndex = 0;
1284
+ let slotGroup;
1285
+ let snGroupIdx;
1286
+ let snGroupLen;
1287
+ let slottedItem;
1288
+ for (snIndex; snIndex < snLen; snIndex++) {
1289
+ slotGroup = slottedNodes[snIndex];
1290
+ if (!slotGroup || !slotGroup.length) continue;
1291
+ snGroupLen = slotGroup.length;
1292
+ snGroupIdx = 0;
1293
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1294
+ slottedItem = slotGroup[snGroupIdx];
1295
+ if (!hosts[slottedItem.hostId]) {
1296
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1297
+ }
1298
+ if (!hosts[slottedItem.hostId]) continue;
1299
+ const hostEle = hosts[slottedItem.hostId];
1300
+ if (!hostEle.shadowRoot || !shadowRoot) {
1301
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1302
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1303
+ slottedItem.slot["s-cr"] = hostEle;
1304
+ } else {
1305
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1306
+ }
1307
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1308
+ if (import_app_data5.BUILD.experimentalSlotFixes) {
1309
+ patchSlottedNode(slottedItem.node);
1273
1310
  }
1274
1311
  }
1275
- }
1276
- if (childNode.nodeType === 1 /* ElementNode */) {
1277
- markSlotContentForRelocation(childNode);
1312
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1313
+ hostEle.appendChild(slottedItem.node);
1314
+ }
1278
1315
  }
1279
1316
  }
1280
- };
1281
- var nullifyVNodeRefs = (vNode) => {
1282
- if (import_app_data5.BUILD.vdomRef) {
1283
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1284
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1317
+ if (import_app_data5.BUILD.scoped && scopeId2 && slotNodes.length) {
1318
+ slotNodes.forEach((slot) => {
1319
+ slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1320
+ });
1285
1321
  }
1286
- };
1287
- var insertBefore = (parent, newNode, reference) => {
1288
- if (import_app_data5.BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1289
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1322
+ if (import_app_data5.BUILD.shadowDom && shadowRoot) {
1323
+ let rnIdex = 0;
1324
+ const rnLen = shadowRootNodes.length;
1325
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
1326
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1327
+ }
1290
1328
  }
1291
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1292
- return inserted;
1329
+ hostRef.$hostElement$ = hostElm;
1330
+ endHydrate();
1293
1331
  };
1294
- function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1295
- var _a;
1296
- let scopeId2;
1297
- if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1298
- const scopeName = slotNode["s-sn"];
1299
- const hostName = slotNode["s-hn"];
1300
- (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1301
- if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
1302
- let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1303
- let found = false;
1304
- while (child) {
1305
- if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1306
- found = true;
1307
- break;
1332
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1333
+ let childNodeType;
1334
+ let childIdSplt;
1335
+ let childVNode;
1336
+ let i2;
1337
+ const scopeId2 = hostElm["s-sc"];
1338
+ if (node.nodeType === 1 /* ElementNode */) {
1339
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1340
+ if (childNodeType) {
1341
+ childIdSplt = childNodeType.split(".");
1342
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1343
+ childVNode = createSimpleVNode({
1344
+ $flags$: 0,
1345
+ $hostId$: childIdSplt[0],
1346
+ $nodeId$: childIdSplt[1],
1347
+ $depth$: childIdSplt[2],
1348
+ $index$: childIdSplt[3],
1349
+ $tag$: node.tagName.toLowerCase(),
1350
+ $elm$: node,
1351
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1352
+ // won't try to reconcile them. Classes set on the node will be blown away.
1353
+ $attrs$: { class: node.className || "" }
1354
+ });
1355
+ childRenderNodes.push(childVNode);
1356
+ node.removeAttribute(HYDRATE_CHILD_ID);
1357
+ if (!parentVNode.$children$) {
1358
+ parentVNode.$children$ = [];
1359
+ }
1360
+ if (import_app_data5.BUILD.scoped && scopeId2) {
1361
+ node["s-si"] = scopeId2;
1362
+ childVNode.$attrs$.class += " " + scopeId2;
1363
+ }
1364
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
1365
+ if (typeof slotName === "string") {
1366
+ if (childVNode.$tag$ === "slot-fb") {
1367
+ addSlot(
1368
+ slotName,
1369
+ childIdSplt[2],
1370
+ childVNode,
1371
+ node,
1372
+ parentVNode,
1373
+ childRenderNodes,
1374
+ slotNodes,
1375
+ shadowRootNodes,
1376
+ slottedNodes
1377
+ );
1378
+ if (import_app_data5.BUILD.scoped && scopeId2) {
1379
+ node.classList.add(scopeId2);
1380
+ }
1381
+ }
1382
+ childVNode.$elm$["s-sn"] = slotName;
1383
+ childVNode.$elm$.removeAttribute("s-sn");
1384
+ }
1385
+ if (childVNode.$index$ !== void 0) {
1386
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1387
+ }
1388
+ parentVNode = childVNode;
1389
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1390
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1308
1391
  }
1309
- child = child.nextSibling;
1310
1392
  }
1311
- if (!found) oldParent.classList.remove(scopeId2 + "-s");
1312
1393
  }
1313
- }
1314
- }
1315
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1316
- var _a, _b, _c, _d, _e;
1317
- const hostElm = hostRef.$hostElement$;
1318
- const cmpMeta = hostRef.$cmpMeta$;
1319
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1320
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1321
- hostTagName = hostElm.tagName;
1322
- if (import_app_data5.BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1323
- throw new Error(`The <Host> must be the single root component.
1324
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1325
-
1326
- The render() function should look like this instead:
1327
-
1328
- render() {
1329
- // Do not return an array
1330
- return (
1331
- <Host>{content}</Host>
1332
- );
1333
- }
1334
- `);
1335
- }
1336
- if (import_app_data5.BUILD.reflect && cmpMeta.$attrsToReflect$) {
1337
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1338
- cmpMeta.$attrsToReflect$.map(
1339
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
1340
- );
1341
- }
1342
- if (isInitialLoad && rootVnode.$attrs$) {
1343
- for (const key of Object.keys(rootVnode.$attrs$)) {
1344
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1345
- rootVnode.$attrs$[key] = hostElm[key];
1394
+ if (node.shadowRoot) {
1395
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1396
+ clientHydrate(
1397
+ parentVNode,
1398
+ childRenderNodes,
1399
+ slotNodes,
1400
+ shadowRootNodes,
1401
+ hostElm,
1402
+ node.shadowRoot.childNodes[i2],
1403
+ hostId,
1404
+ slottedNodes
1405
+ );
1346
1406
  }
1347
1407
  }
1348
- }
1349
- rootVnode.$tag$ = null;
1350
- rootVnode.$flags$ |= 4 /* isHost */;
1351
- hostRef.$vnode$ = rootVnode;
1352
- rootVnode.$elm$ = oldVNode.$elm$ = import_app_data5.BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1353
- if (import_app_data5.BUILD.scoped || import_app_data5.BUILD.shadowDom) {
1354
- scopeId = hostElm["s-sc"];
1355
- }
1356
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1357
- if (import_app_data5.BUILD.slotRelocation) {
1358
- contentRef = hostElm["s-cr"];
1359
- checkSlotFallbackVisibility = false;
1360
- }
1361
- patch(oldVNode, rootVnode, isInitialLoad);
1362
- if (import_app_data5.BUILD.slotRelocation) {
1363
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1364
- if (checkSlotRelocate) {
1365
- markSlotContentForRelocation(rootVnode.$elm$);
1366
- for (const relocateData of relocateNodes) {
1367
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1368
- if (!nodeToRelocate["s-ol"]) {
1369
- const orgLocationNode = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1370
- orgLocationNode["s-nr"] = nodeToRelocate;
1371
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1372
- }
1373
- }
1374
- for (const relocateData of relocateNodes) {
1375
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1376
- const slotRefNode = relocateData.$slotRefNode$;
1377
- if (slotRefNode) {
1378
- const parentNodeRef = slotRefNode.parentNode;
1379
- let insertBeforeNode = slotRefNode.nextSibling;
1380
- if (!import_app_data5.BUILD.hydrateServerSide && (!import_app_data5.BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
1381
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1382
- while (orgLocationNode) {
1383
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1384
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1385
- refNode = refNode.nextSibling;
1386
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1387
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1388
- }
1389
- if (!refNode || !refNode["s-nr"]) {
1390
- insertBeforeNode = refNode;
1391
- break;
1392
- }
1393
- }
1394
- orgLocationNode = orgLocationNode.previousSibling;
1395
- }
1396
- }
1397
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1398
- if (nodeToRelocate !== insertBeforeNode) {
1399
- if (!import_app_data5.BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1400
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1401
- }
1402
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1403
- if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1404
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1405
- }
1408
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1409
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1410
+ clientHydrate(
1411
+ parentVNode,
1412
+ childRenderNodes,
1413
+ slotNodes,
1414
+ shadowRootNodes,
1415
+ hostElm,
1416
+ nonShadowNodes[i2],
1417
+ hostId,
1418
+ slottedNodes
1419
+ );
1420
+ }
1421
+ } else if (node.nodeType === 8 /* CommentNode */) {
1422
+ childIdSplt = node.nodeValue.split(".");
1423
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1424
+ childNodeType = childIdSplt[0];
1425
+ childVNode = createSimpleVNode({
1426
+ $hostId$: childIdSplt[1],
1427
+ $nodeId$: childIdSplt[2],
1428
+ $depth$: childIdSplt[3],
1429
+ $index$: childIdSplt[4] || "0",
1430
+ $elm$: node,
1431
+ $attrs$: null,
1432
+ $children$: null,
1433
+ $key$: null,
1434
+ $name$: null,
1435
+ $tag$: null,
1436
+ $text$: null
1437
+ });
1438
+ if (childNodeType === TEXT_NODE_ID) {
1439
+ childVNode.$elm$ = node.nextSibling;
1440
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1441
+ childVNode.$text$ = childVNode.$elm$.textContent;
1442
+ childRenderNodes.push(childVNode);
1443
+ node.remove();
1444
+ if (hostId === childVNode.$hostId$) {
1445
+ if (!parentVNode.$children$) {
1446
+ parentVNode.$children$ = [];
1406
1447
  }
1448
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1407
1449
  }
1408
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1409
- } else {
1410
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1411
- if (isInitialLoad) {
1412
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1413
- }
1414
- nodeToRelocate.hidden = true;
1450
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1451
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1415
1452
  }
1416
1453
  }
1417
- }
1418
- }
1419
- if (checkSlotFallbackVisibility) {
1420
- updateFallbackSlotVisibility(rootVnode.$elm$);
1421
- }
1422
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1423
- relocateNodes.length = 0;
1424
- }
1425
- if (import_app_data5.BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1426
- const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1427
- for (const childNode of children) {
1428
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1429
- if (isInitialLoad && childNode["s-ih"] == null) {
1430
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1454
+ } else if (childNodeType === COMMENT_NODE_ID) {
1455
+ childVNode.$elm$ = node.nextSibling;
1456
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1457
+ childRenderNodes.push(childVNode);
1458
+ node.remove();
1431
1459
  }
1432
- childNode.hidden = true;
1433
- }
1434
- }
1435
- }
1436
- contentRef = void 0;
1437
- };
1438
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1439
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1440
- );
1441
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1442
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1443
- );
1444
-
1445
- // src/runtime/dom-extras.ts
1446
- var patchPseudoShadowDom = (hostElementPrototype) => {
1447
- patchCloneNode(hostElementPrototype);
1448
- patchSlotAppendChild(hostElementPrototype);
1449
- patchSlotAppend(hostElementPrototype);
1450
- patchSlotPrepend(hostElementPrototype);
1451
- patchSlotInsertAdjacentElement(hostElementPrototype);
1452
- patchSlotInsertAdjacentHTML(hostElementPrototype);
1453
- patchSlotInsertAdjacentText(hostElementPrototype);
1454
- patchTextContent(hostElementPrototype);
1455
- patchChildSlotNodes(hostElementPrototype);
1456
- patchSlotRemoveChild(hostElementPrototype);
1457
- };
1458
- var patchCloneNode = (HostElementPrototype) => {
1459
- const orgCloneNode = HostElementPrototype.cloneNode;
1460
- HostElementPrototype.cloneNode = function(deep) {
1461
- const srcNode = this;
1462
- const isShadowDom = import_app_data6.BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
1463
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1464
- if (import_app_data6.BUILD.slot && !isShadowDom && deep) {
1465
- let i2 = 0;
1466
- let slotted, nonRindoNode;
1467
- const rindoPrivates = [
1468
- "s-id",
1469
- "s-cr",
1470
- "s-lr",
1471
- "s-rc",
1472
- "s-sc",
1473
- "s-p",
1474
- "s-cn",
1475
- "s-sr",
1476
- "s-sn",
1477
- "s-hn",
1478
- "s-ol",
1479
- "s-nr",
1480
- "s-si",
1481
- "s-rf",
1482
- "s-scs"
1483
- ];
1484
- const childNodes = this.__childNodes || this.childNodes;
1485
- for (; i2 < childNodes.length; i2++) {
1486
- slotted = childNodes[i2]["s-nr"];
1487
- nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
1488
- if (slotted) {
1489
- if (import_app_data6.BUILD.appendChildSlotFix && clonedNode.__appendChild) {
1490
- clonedNode.__appendChild(slotted.cloneNode(true));
1491
- } else {
1492
- clonedNode.appendChild(slotted.cloneNode(true));
1460
+ } else if (childVNode.$hostId$ === hostId) {
1461
+ if (childNodeType === SLOT_NODE_ID) {
1462
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
1463
+ addSlot(
1464
+ slotName,
1465
+ childIdSplt[2],
1466
+ childVNode,
1467
+ node,
1468
+ parentVNode,
1469
+ childRenderNodes,
1470
+ slotNodes,
1471
+ shadowRootNodes,
1472
+ slottedNodes
1473
+ );
1474
+ } else if (childNodeType === CONTENT_REF_ID) {
1475
+ if (import_app_data5.BUILD.shadowDom && shadowRootNodes) {
1476
+ node.remove();
1477
+ } else if (import_app_data5.BUILD.slotRelocation) {
1478
+ hostElm["s-cr"] = node;
1479
+ node["s-cn"] = true;
1493
1480
  }
1494
1481
  }
1495
- if (nonRindoNode) {
1496
- clonedNode.appendChild(childNodes[i2].cloneNode(true));
1497
- }
1498
1482
  }
1499
1483
  }
1500
- return clonedNode;
1501
- };
1484
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1485
+ const vnode = newVNode(null, node.textContent);
1486
+ vnode.$elm$ = node;
1487
+ vnode.$index$ = "0";
1488
+ parentVNode.$children$ = [vnode];
1489
+ }
1490
+ return parentVNode;
1502
1491
  };
1503
- var patchSlotAppendChild = (HostElementPrototype) => {
1504
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1505
- HostElementPrototype.appendChild = function(newChild) {
1506
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1507
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
1508
- if (slotNode) {
1509
- addSlotRelocateNode(newChild, slotNode);
1510
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1511
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1512
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1513
- updateFallbackSlotVisibility(this);
1514
- return insertedNode;
1492
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
1493
+ if (node.nodeType === 1 /* ElementNode */) {
1494
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1495
+ if (componentId) {
1496
+ orgLocNodes.set(componentId, node);
1515
1497
  }
1516
- return this.__appendChild(newChild);
1517
- };
1518
- };
1519
- var patchSlotRemoveChild = (ElementPrototype) => {
1520
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
1521
- ElementPrototype.removeChild = function(toRemove) {
1522
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
1523
- const childNodes = this.__childNodes || this.childNodes;
1524
- const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
1525
- if (slotNode && toRemove.isConnected) {
1526
- toRemove.remove();
1527
- updateFallbackSlotVisibility(this);
1528
- return;
1498
+ let i2 = 0;
1499
+ if (node.shadowRoot) {
1500
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1501
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1529
1502
  }
1530
1503
  }
1531
- return this.__removeChild(toRemove);
1532
- };
1504
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1505
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1506
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1507
+ }
1508
+ } else if (node.nodeType === 8 /* CommentNode */) {
1509
+ const childIdSplt = node.nodeValue.split(".");
1510
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1511
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1512
+ node.nodeValue = "";
1513
+ node["s-en"] = childIdSplt[3];
1514
+ }
1515
+ }
1533
1516
  };
1534
- var patchSlotPrepend = (HostElementPrototype) => {
1535
- HostElementPrototype.__prepend = HostElementPrototype.prepend;
1536
- HostElementPrototype.prepend = function(...newChildren) {
1537
- newChildren.forEach((newChild) => {
1538
- if (typeof newChild === "string") {
1539
- newChild = this.ownerDocument.createTextNode(newChild);
1540
- }
1541
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1542
- const childNodes = this.__childNodes || this.childNodes;
1543
- const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
1544
- if (slotNode) {
1545
- addSlotRelocateNode(newChild, slotNode, true);
1546
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1547
- const appendAfter = slotChildNodes[0];
1548
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1549
- }
1550
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
1551
- newChild.hidden = true;
1552
- }
1553
- return HostElementPrototype.__prepend(newChild);
1554
- });
1517
+ var createSimpleVNode = (vnode) => {
1518
+ const defaultVNode = {
1519
+ $flags$: 0,
1520
+ $hostId$: null,
1521
+ $nodeId$: null,
1522
+ $depth$: null,
1523
+ $index$: "0",
1524
+ $elm$: null,
1525
+ $attrs$: null,
1526
+ $children$: null,
1527
+ $key$: null,
1528
+ $name$: null,
1529
+ $tag$: null,
1530
+ $text$: null
1555
1531
  };
1532
+ return { ...defaultVNode, ...vnode };
1556
1533
  };
1557
- var patchSlotAppend = (HostElementPrototype) => {
1558
- HostElementPrototype.__append = HostElementPrototype.append;
1559
- HostElementPrototype.append = function(...newChildren) {
1560
- newChildren.forEach((newChild) => {
1561
- if (typeof newChild === "string") {
1562
- newChild = this.ownerDocument.createTextNode(newChild);
1563
- }
1564
- this.appendChild(newChild);
1565
- });
1566
- };
1567
- };
1568
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
1569
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
1570
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
1571
- if (position !== "afterbegin" && position !== "beforeend") {
1572
- return originalInsertAdjacentHtml.call(this, position, text);
1573
- }
1574
- const container = this.ownerDocument.createElement("_");
1575
- let node;
1576
- container.innerHTML = text;
1577
- if (position === "afterbegin") {
1578
- while (node = container.firstChild) {
1579
- this.prepend(node);
1580
- }
1581
- } else if (position === "beforeend") {
1582
- while (node = container.firstChild) {
1583
- this.append(node);
1584
- }
1585
- }
1586
- };
1587
- };
1588
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
1589
- HostElementPrototype.insertAdjacentText = function(position, text) {
1590
- this.insertAdjacentHTML(position, text);
1591
- };
1592
- };
1593
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
1594
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
1595
- HostElementPrototype.insertAdjacentElement = function(position, element) {
1596
- if (position !== "afterbegin" && position !== "beforeend") {
1597
- return originalInsertAdjacentElement.call(this, position, element);
1534
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1535
+ node["s-sr"] = true;
1536
+ childVNode.$name$ = slotName || null;
1537
+ childVNode.$tag$ = "slot";
1538
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1539
+ if (import_app_data5.BUILD.shadowDom && shadowRootNodes) {
1540
+ const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1541
+ if (childVNode.$name$) {
1542
+ childVNode.$elm$.setAttribute("name", slotName);
1598
1543
  }
1599
- if (position === "afterbegin") {
1600
- this.prepend(element);
1601
- return element;
1602
- } else if (position === "beforeend") {
1603
- this.append(element);
1604
- return element;
1544
+ if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1545
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1546
+ } else {
1547
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1605
1548
  }
1606
- return element;
1607
- };
1608
- };
1609
- var patchTextContent = (hostElementPrototype) => {
1610
- patchHostOriginalAccessor("textContent", hostElementPrototype);
1611
- Object.defineProperty(hostElementPrototype, "textContent", {
1612
- get: function() {
1613
- let text = "";
1614
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1615
- childNodes.forEach((node) => text += node.textContent || "");
1616
- return text;
1617
- },
1618
- set: function(value) {
1619
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1620
- childNodes.forEach((node) => {
1621
- if (node["s-ol"]) node["s-ol"].remove();
1622
- node.remove();
1623
- });
1624
- this.insertAdjacentHTML("beforeend", value);
1549
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1550
+ node.remove();
1551
+ if (childVNode.$depth$ === "0") {
1552
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1625
1553
  }
1626
- });
1627
- };
1628
- var patchChildSlotNodes = (elm) => {
1629
- class FakeNodeList extends Array {
1630
- item(n) {
1631
- return this[n];
1554
+ } else {
1555
+ const slot = childVNode.$elm$;
1556
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1557
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1558
+ if (shouldMove) {
1559
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1632
1560
  }
1561
+ childRenderNodes.push(childVNode);
1633
1562
  }
1634
- patchHostOriginalAccessor("children", elm);
1635
- Object.defineProperty(elm, "children", {
1636
- get() {
1637
- return this.childNodes.filter((n) => n.nodeType === 1);
1638
- }
1639
- });
1640
- Object.defineProperty(elm, "childElementCount", {
1641
- get() {
1642
- return this.children.length;
1643
- }
1644
- });
1645
- patchHostOriginalAccessor("firstChild", elm);
1646
- Object.defineProperty(elm, "firstChild", {
1647
- get() {
1648
- return this.childNodes[0];
1563
+ slotNodes.push(childVNode);
1564
+ if (!parentVNode.$children$) {
1565
+ parentVNode.$children$ = [];
1566
+ }
1567
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1568
+ }
1569
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1570
+ let slottedNode = slotNode.nextSibling;
1571
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1572
+ 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 */))) {
1573
+ slottedNode["s-sn"] = slotName;
1574
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1575
+ slottedNode = slottedNode.nextSibling;
1576
+ }
1577
+ };
1578
+
1579
+ // src/runtime/initialize-component.ts
1580
+ var import_app_data16 = require("@rindo/core/internal/app-data");
1581
+
1582
+ // src/runtime/mode.ts
1583
+ var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1584
+ var setMode = (handler) => modeResolutionChain.push(handler);
1585
+ var getMode = (ref) => getHostRef(ref).$modeName$;
1586
+
1587
+ // src/runtime/proxy-component.ts
1588
+ var import_app_data15 = require("@rindo/core/internal/app-data");
1589
+
1590
+ // src/runtime/set-value.ts
1591
+ var import_app_data14 = require("@rindo/core/internal/app-data");
1592
+
1593
+ // src/runtime/parse-property-value.ts
1594
+ var import_app_data6 = require("@rindo/core/internal/app-data");
1595
+ var parsePropertyValue = (propValue, propType) => {
1596
+ if (propValue != null && !isComplexType(propValue)) {
1597
+ if (import_app_data6.BUILD.propBoolean && propType & 4 /* Boolean */) {
1598
+ return propValue === "false" ? false : propValue === "" || !!propValue;
1649
1599
  }
1650
- });
1651
- patchHostOriginalAccessor("lastChild", elm);
1652
- Object.defineProperty(elm, "lastChild", {
1653
- get() {
1654
- return this.childNodes[this.childNodes.length - 1];
1600
+ if (import_app_data6.BUILD.propNumber && propType & 2 /* Number */) {
1601
+ return parseFloat(propValue);
1655
1602
  }
1656
- });
1657
- patchHostOriginalAccessor("childNodes", elm);
1658
- Object.defineProperty(elm, "childNodes", {
1659
- get() {
1660
- var _a, _b;
1661
- 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 */) {
1662
- const result = new FakeNodeList();
1663
- const nodes = getSlottedChildNodes(this.__childNodes);
1664
- result.push(...nodes);
1665
- return result;
1666
- }
1667
- return FakeNodeList.from(this.__childNodes);
1603
+ if (import_app_data6.BUILD.propString && propType & 1 /* String */) {
1604
+ return String(propValue);
1668
1605
  }
1669
- });
1670
- };
1671
- var patchNextPrev = (node) => {
1672
- if (!node || node.__nextSibling || !globalThis.Node) return;
1673
- patchNextSibling(node);
1674
- patchPreviousSibling(node);
1675
- if (node.nodeType === Node.ELEMENT_NODE) {
1676
- patchNextElementSibling(node);
1677
- patchPreviousElementSibling(node);
1606
+ return propValue;
1678
1607
  }
1608
+ return propValue;
1679
1609
  };
1680
- var patchNextSibling = (node) => {
1681
- if (!node || node.__nextSibling) return;
1682
- patchHostOriginalAccessor("nextSibling", node);
1683
- Object.defineProperty(node, "nextSibling", {
1684
- get: function() {
1685
- var _a;
1686
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1687
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1688
- if (parentNodes && index > -1) {
1689
- return parentNodes[index + 1];
1610
+
1611
+ // src/runtime/update-component.ts
1612
+ var import_app_data13 = require("@rindo/core/internal/app-data");
1613
+
1614
+ // src/runtime/event-emitter.ts
1615
+ var import_app_data8 = require("@rindo/core/internal/app-data");
1616
+
1617
+ // src/runtime/element.ts
1618
+ var import_app_data7 = require("@rindo/core/internal/app-data");
1619
+ var getElement = (ref) => import_app_data7.BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1620
+
1621
+ // src/runtime/event-emitter.ts
1622
+ var createEvent = (ref, name, flags) => {
1623
+ const elm = getElement(ref);
1624
+ return {
1625
+ emit: (detail) => {
1626
+ if (import_app_data8.BUILD.isDev && !elm.isConnected) {
1627
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1690
1628
  }
1691
- return this.__nextSibling;
1629
+ return emitEvent(elm, name, {
1630
+ bubbles: !!(flags & 4 /* Bubbles */),
1631
+ composed: !!(flags & 2 /* Composed */),
1632
+ cancelable: !!(flags & 1 /* Cancellable */),
1633
+ detail
1634
+ });
1692
1635
  }
1693
- });
1636
+ };
1694
1637
  };
1695
- var patchNextElementSibling = (element) => {
1696
- if (!element || element.__nextElementSibling) return;
1697
- patchHostOriginalAccessor("nextElementSibling", element);
1698
- Object.defineProperty(element, "nextElementSibling", {
1699
- get: function() {
1700
- var _a;
1701
- const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1702
- const index = parentEles == null ? void 0 : parentEles.indexOf(this);
1703
- if (parentEles && index > -1) {
1704
- return parentEles[index + 1];
1705
- }
1706
- return this.__nextElementSibling;
1707
- }
1708
- });
1638
+ var emitEvent = (elm, name, opts) => {
1639
+ const ev = plt.ce(name, opts);
1640
+ elm.dispatchEvent(ev);
1641
+ return ev;
1709
1642
  };
1710
- var patchPreviousSibling = (node) => {
1711
- if (!node || node.__previousSibling) return;
1712
- patchHostOriginalAccessor("previousSibling", node);
1713
- Object.defineProperty(node, "previousSibling", {
1714
- get: function() {
1715
- var _a;
1716
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1717
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1718
- if (parentNodes && index > -1) {
1719
- return parentNodes[index - 1];
1720
- }
1721
- return this.__previousSibling;
1643
+
1644
+ // src/runtime/styles.ts
1645
+ var import_app_data9 = require("@rindo/core/internal/app-data");
1646
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1647
+ var registerStyle = (scopeId2, cssText, allowCS) => {
1648
+ let style = styles.get(scopeId2);
1649
+ if (supportsConstructableStylesheets && allowCS) {
1650
+ style = style || new CSSStyleSheet();
1651
+ if (typeof style === "string") {
1652
+ style = cssText;
1653
+ } else {
1654
+ style.replaceSync(cssText);
1722
1655
  }
1723
- });
1656
+ } else {
1657
+ style = cssText;
1658
+ }
1659
+ styles.set(scopeId2, style);
1724
1660
  };
1725
- var patchPreviousElementSibling = (element) => {
1726
- if (!element || element.__previousElementSibling) return;
1727
- patchHostOriginalAccessor("previousElementSibling", element);
1728
- Object.defineProperty(element, "previousElementSibling", {
1729
- get: function() {
1730
- var _a;
1731
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1732
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1733
- if (parentNodes && index > -1) {
1734
- return parentNodes[index - 1];
1661
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1662
+ var _a;
1663
+ const scopeId2 = getScopeId(cmpMeta, mode);
1664
+ const style = styles.get(scopeId2);
1665
+ if (!import_app_data9.BUILD.attachStyles) {
1666
+ return scopeId2;
1667
+ }
1668
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1669
+ if (style) {
1670
+ if (typeof style === "string") {
1671
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
1672
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1673
+ let styleElm;
1674
+ if (!appliedStyles) {
1675
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1735
1676
  }
1736
- return this.__previousElementSibling;
1677
+ if (!appliedStyles.has(scopeId2)) {
1678
+ if (import_app_data9.BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1679
+ styleElm.innerHTML = style;
1680
+ } else {
1681
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1682
+ styleElm.innerHTML = style;
1683
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1684
+ if (nonce != null) {
1685
+ styleElm.setAttribute("nonce", nonce);
1686
+ }
1687
+ if ((import_app_data9.BUILD.hydrateServerSide || import_app_data9.BUILD.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1688
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1689
+ }
1690
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
1691
+ if (styleContainerNode.nodeName === "HEAD") {
1692
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1693
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1694
+ styleContainerNode.insertBefore(
1695
+ styleElm,
1696
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
1697
+ );
1698
+ } else if ("host" in styleContainerNode) {
1699
+ if (supportsConstructableStylesheets) {
1700
+ const stylesheet = new CSSStyleSheet();
1701
+ stylesheet.replaceSync(style);
1702
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1703
+ } else {
1704
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1705
+ if (existingStyleContainer) {
1706
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
1707
+ } else {
1708
+ styleContainerNode.prepend(styleElm);
1709
+ }
1710
+ }
1711
+ } else {
1712
+ styleContainerNode.append(styleElm);
1713
+ }
1714
+ }
1715
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
1716
+ styleContainerNode.insertBefore(styleElm, null);
1717
+ }
1718
+ }
1719
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1720
+ styleElm.innerHTML += SLOT_FB_CSS;
1721
+ }
1722
+ if (appliedStyles) {
1723
+ appliedStyles.add(scopeId2);
1724
+ }
1725
+ }
1726
+ } else if (import_app_data9.BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1727
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1737
1728
  }
1738
- });
1739
- };
1740
- var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
1741
- var validNodesPatches = [
1742
- "childNodes",
1743
- "firstChild",
1744
- "lastChild",
1745
- "nextSibling",
1746
- "previousSibling",
1747
- "textContent"
1748
- ];
1749
- function patchHostOriginalAccessor(accessorName, node) {
1750
- let accessor;
1751
- if (validElementPatches.includes(accessorName)) {
1752
- accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1753
- } else if (validNodesPatches.includes(accessorName)) {
1754
- accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1755
1729
  }
1756
- if (!accessor) {
1757
- accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1758
- }
1759
- if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1760
- }
1761
-
1762
- // src/runtime/profile.ts
1763
- var import_app_data7 = require("@rindo/core/internal/app-data");
1764
- var i = 0;
1765
- var createTime = (fnName, tagName = "") => {
1766
- if (import_app_data7.BUILD.profile && performance.mark) {
1767
- const key = `st:${fnName}:${tagName}:${i++}`;
1768
- performance.mark(key);
1769
- return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
1770
- } else {
1771
- return () => {
1772
- return;
1773
- };
1730
+ return scopeId2;
1731
+ };
1732
+ var attachStyles = (hostRef) => {
1733
+ const cmpMeta = hostRef.$cmpMeta$;
1734
+ const elm = hostRef.$hostElement$;
1735
+ const flags = cmpMeta.$flags$;
1736
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1737
+ const scopeId2 = addStyle(
1738
+ import_app_data9.BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
1739
+ cmpMeta,
1740
+ hostRef.$modeName$
1741
+ );
1742
+ if ((import_app_data9.BUILD.shadowDom || import_app_data9.BUILD.scoped) && import_app_data9.BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
1743
+ elm["s-sc"] = scopeId2;
1744
+ elm.classList.add(scopeId2 + "-h");
1774
1745
  }
1746
+ endAttachStyles();
1775
1747
  };
1776
- var uniqueTime = (key, measureText) => {
1777
- if (import_app_data7.BUILD.profile && performance.mark) {
1778
- if (performance.getEntriesByName(key, "mark").length === 0) {
1779
- performance.mark(key);
1780
- }
1781
- return () => {
1782
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
1783
- performance.measure(measureText, key);
1748
+ var getScopeId = (cmp, mode) => "sc-" + (import_app_data9.BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1749
+
1750
+ // src/runtime/vdom/vdom-render.ts
1751
+ var import_app_data12 = require("@rindo/core/internal/app-data");
1752
+
1753
+ // src/runtime/vdom/update-element.ts
1754
+ var import_app_data11 = require("@rindo/core/internal/app-data");
1755
+
1756
+ // src/runtime/vdom/set-accessor.ts
1757
+ var import_app_data10 = require("@rindo/core/internal/app-data");
1758
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
1759
+ if (oldValue !== newValue) {
1760
+ let isProp = isMemberInElement(elm, memberName);
1761
+ let ln = memberName.toLowerCase();
1762
+ if (import_app_data10.BUILD.vdomClass && memberName === "class") {
1763
+ const classList = elm.classList;
1764
+ const oldClasses = parseClassList(oldValue);
1765
+ let newClasses = parseClassList(newValue);
1766
+ if (import_app_data10.BUILD.hydrateClientSide && elm["s-si"] && initialRender) {
1767
+ newClasses.push(elm["s-si"]);
1768
+ oldClasses.forEach((c) => {
1769
+ if (c.startsWith(elm["s-si"])) newClasses.push(c);
1770
+ });
1771
+ newClasses = [...new Set(newClasses)];
1772
+ classList.add(...newClasses);
1773
+ } else {
1774
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1775
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1776
+ }
1777
+ } else if (import_app_data10.BUILD.vdomStyle && memberName === "style") {
1778
+ if (import_app_data10.BUILD.updatable) {
1779
+ for (const prop in oldValue) {
1780
+ if (!newValue || newValue[prop] == null) {
1781
+ if (!import_app_data10.BUILD.hydrateServerSide && prop.includes("-")) {
1782
+ elm.style.removeProperty(prop);
1783
+ } else {
1784
+ elm.style[prop] = "";
1785
+ }
1786
+ }
1787
+ }
1788
+ }
1789
+ for (const prop in newValue) {
1790
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1791
+ if (!import_app_data10.BUILD.hydrateServerSide && prop.includes("-")) {
1792
+ elm.style.setProperty(prop, newValue[prop]);
1793
+ } else {
1794
+ elm.style[prop] = newValue[prop];
1795
+ }
1796
+ }
1797
+ }
1798
+ } else if (import_app_data10.BUILD.vdomKey && memberName === "key") {
1799
+ } else if (import_app_data10.BUILD.vdomRef && memberName === "ref") {
1800
+ if (newValue) {
1801
+ newValue(elm);
1802
+ }
1803
+ } else if (import_app_data10.BUILD.vdomListener && (import_app_data10.BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1804
+ if (memberName[2] === "-") {
1805
+ memberName = memberName.slice(3);
1806
+ } else if (isMemberInElement(win, ln)) {
1807
+ memberName = ln.slice(2);
1808
+ } else {
1809
+ memberName = ln[2] + memberName.slice(3);
1810
+ }
1811
+ if (oldValue || newValue) {
1812
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1813
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1814
+ if (oldValue) {
1815
+ plt.rel(elm, memberName, oldValue, capture);
1816
+ }
1817
+ if (newValue) {
1818
+ plt.ael(elm, memberName, newValue, capture);
1819
+ }
1820
+ }
1821
+ } else if (import_app_data10.BUILD.vdomPropOrAttr) {
1822
+ const isComplex = isComplexType(newValue);
1823
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1824
+ try {
1825
+ if (!elm.tagName.includes("-")) {
1826
+ const n = newValue == null ? "" : newValue;
1827
+ if (memberName === "list") {
1828
+ isProp = false;
1829
+ } else if (oldValue == null || elm[memberName] != n) {
1830
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1831
+ elm[memberName] = n;
1832
+ } else {
1833
+ elm.setAttribute(memberName, n);
1834
+ }
1835
+ }
1836
+ } else if (elm[memberName] !== newValue) {
1837
+ elm[memberName] = newValue;
1838
+ }
1839
+ } catch (e) {
1840
+ }
1784
1841
  }
1785
- };
1786
- } else {
1787
- return () => {
1788
- return;
1789
- };
1842
+ let xlink = false;
1843
+ if (import_app_data10.BUILD.vdomXlink) {
1844
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
1845
+ memberName = ln;
1846
+ xlink = true;
1847
+ }
1848
+ }
1849
+ if (newValue == null || newValue === false) {
1850
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1851
+ if (import_app_data10.BUILD.vdomXlink && xlink) {
1852
+ elm.removeAttributeNS(XLINK_NS, memberName);
1853
+ } else {
1854
+ elm.removeAttribute(memberName);
1855
+ }
1856
+ }
1857
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
1858
+ newValue = newValue === true ? "" : newValue;
1859
+ if (import_app_data10.BUILD.vdomXlink && xlink) {
1860
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
1861
+ } else {
1862
+ elm.setAttribute(memberName, newValue);
1863
+ }
1864
+ }
1865
+ }
1790
1866
  }
1791
1867
  };
1792
- var inspect = (ref) => {
1793
- const hostRef = getHostRef(ref);
1794
- if (!hostRef) {
1795
- return void 0;
1868
+ var parseClassListRegex = /\s/;
1869
+ var parseClassList = (value) => {
1870
+ if (typeof value === "object" && value && "baseVal" in value) {
1871
+ value = value.baseVal;
1796
1872
  }
1797
- const flags = hostRef.$flags$;
1798
- const hostElement = hostRef.$hostElement$;
1799
- return {
1800
- renderCount: hostRef.$renderCount$,
1801
- flags: {
1802
- hasRendered: !!(flags & 2 /* hasRendered */),
1803
- hasConnected: !!(flags & 1 /* hasConnected */),
1804
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1805
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1806
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1807
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1808
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1809
- isWatchReady: !!(flags & 128 /* isWatchReady */),
1810
- isListenReady: !!(flags & 256 /* isListenReady */),
1811
- needsRerender: !!(flags & 512 /* needsRerender */)
1812
- },
1813
- instanceValues: hostRef.$instanceValues$,
1814
- ancestorComponent: hostRef.$ancestorComponent$,
1815
- hostElement,
1816
- lazyInstance: hostRef.$lazyInstance$,
1817
- vnode: hostRef.$vnode$,
1818
- modeName: hostRef.$modeName$,
1819
- onReadyPromise: hostRef.$onReadyPromise$,
1820
- onReadyResolve: hostRef.$onReadyResolve$,
1821
- onInstancePromise: hostRef.$onInstancePromise$,
1822
- onInstanceResolve: hostRef.$onInstanceResolve$,
1823
- onRenderResolve: hostRef.$onRenderResolve$,
1824
- queuedListeners: hostRef.$queuedListeners$,
1825
- rmListeners: hostRef.$rmListeners$,
1826
- ["s-id"]: hostElement["s-id"],
1827
- ["s-cr"]: hostElement["s-cr"],
1828
- ["s-lr"]: hostElement["s-lr"],
1829
- ["s-p"]: hostElement["s-p"],
1830
- ["s-rc"]: hostElement["s-rc"],
1831
- ["s-sc"]: hostElement["s-sc"]
1832
- };
1873
+ if (!value || typeof value !== "string") {
1874
+ return [];
1875
+ }
1876
+ return value.split(parseClassListRegex);
1833
1877
  };
1834
- var installDevTools = () => {
1835
- if (import_app_data7.BUILD.devTools) {
1836
- const rindo = win.rindo = win.rindo || {};
1837
- const originalInspect = rindo.inspect;
1838
- rindo.inspect = (ref) => {
1839
- let result = inspect(ref);
1840
- if (!result && typeof originalInspect === "function") {
1841
- result = originalInspect(ref);
1878
+ var CAPTURE_EVENT_SUFFIX = "Capture";
1879
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
1880
+
1881
+ // src/runtime/vdom/update-element.ts
1882
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
1883
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
1884
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
1885
+ const newVnodeAttrs = newVnode.$attrs$ || {};
1886
+ if (import_app_data11.BUILD.updatable) {
1887
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
1888
+ if (!(memberName in newVnodeAttrs)) {
1889
+ setAccessor(
1890
+ elm,
1891
+ memberName,
1892
+ oldVnodeAttrs[memberName],
1893
+ void 0,
1894
+ isSvgMode2,
1895
+ newVnode.$flags$,
1896
+ isInitialRender
1897
+ );
1842
1898
  }
1843
- return result;
1844
- };
1899
+ }
1900
+ }
1901
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
1902
+ setAccessor(
1903
+ elm,
1904
+ memberName,
1905
+ oldVnodeAttrs[memberName],
1906
+ newVnodeAttrs[memberName],
1907
+ isSvgMode2,
1908
+ newVnode.$flags$,
1909
+ isInitialRender
1910
+ );
1845
1911
  }
1846
1912
  };
1913
+ function sortedAttrNames(attrNames) {
1914
+ return attrNames.includes("ref") ? (
1915
+ // we need to sort these to ensure that `'ref'` is the last attr
1916
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
1917
+ ) : (
1918
+ // no need to sort, return the original array
1919
+ attrNames
1920
+ );
1921
+ }
1847
1922
 
1848
- // src/runtime/client-hydrate.ts
1849
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1850
- const endHydrate = createTime("hydrateClient", tagName);
1851
- const shadowRoot = hostElm.shadowRoot;
1852
- const childRenderNodes = [];
1853
- const slotNodes = [];
1854
- const slottedNodes = [];
1855
- const shadowRootNodes = import_app_data8.BUILD.shadowDom && shadowRoot ? [] : null;
1856
- const vnode = newVNode(tagName, null);
1857
- vnode.$elm$ = hostElm;
1858
- let scopeId2;
1859
- if (import_app_data8.BUILD.scoped) {
1860
- const cmpMeta = hostRef.$cmpMeta$;
1861
- if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1862
- scopeId2 = hostElm["s-sc"];
1863
- hostElm.classList.add(scopeId2 + "-h");
1864
- } else if (hostElm["s-sc"]) {
1865
- delete hostElm["s-sc"];
1923
+ // src/runtime/vdom/vdom-render.ts
1924
+ var scopeId;
1925
+ var contentRef;
1926
+ var hostTagName;
1927
+ var useNativeShadowDom = false;
1928
+ var checkSlotFallbackVisibility = false;
1929
+ var checkSlotRelocate = false;
1930
+ var isSvgMode = false;
1931
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1932
+ var _a;
1933
+ const newVNode2 = newParentVNode.$children$[childIndex];
1934
+ let i2 = 0;
1935
+ let elm;
1936
+ let childNode;
1937
+ let oldVNode;
1938
+ if (import_app_data12.BUILD.slotRelocation && !useNativeShadowDom) {
1939
+ checkSlotRelocate = true;
1940
+ if (newVNode2.$tag$ === "slot") {
1941
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
1942
+ // slot element has fallback content
1943
+ // still create an element that "mocks" the slot element
1944
+ 2 /* isSlotFallback */
1945
+ ) : (
1946
+ // slot element does not have fallback content
1947
+ // create an html comment we'll use to always reference
1948
+ // where actual slot content should sit next to
1949
+ 1 /* isSlotReference */
1950
+ );
1866
1951
  }
1867
1952
  }
1868
- if (!plt.$orgLocNodes$) {
1869
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1953
+ if (import_app_data12.BUILD.isDev && newVNode2.$elm$) {
1954
+ consoleDevError(
1955
+ `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://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`
1956
+ );
1870
1957
  }
1871
- hostElm[HYDRATE_ID] = hostId;
1872
- hostElm.removeAttribute(HYDRATE_ID);
1873
- hostRef.$vnode$ = clientHydrate(
1874
- vnode,
1875
- childRenderNodes,
1876
- slotNodes,
1877
- shadowRootNodes,
1878
- hostElm,
1879
- hostElm,
1880
- hostId,
1881
- slottedNodes
1882
- );
1883
- let crIndex = 0;
1884
- const crLength = childRenderNodes.length;
1885
- let childRenderNode;
1886
- for (crIndex; crIndex < crLength; crIndex++) {
1887
- childRenderNode = childRenderNodes[crIndex];
1888
- const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1889
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1890
- const node = childRenderNode.$elm$;
1891
- if (!shadowRoot) {
1892
- node["s-hn"] = tagName.toUpperCase();
1893
- if (childRenderNode.$tag$ === "slot") {
1894
- node["s-cr"] = hostElm["s-cr"];
1895
- }
1958
+ if (import_app_data12.BUILD.vdomText && newVNode2.$text$ !== null) {
1959
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1960
+ } else if (import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
1961
+ elm = newVNode2.$elm$ = import_app_data12.BUILD.isDebug || import_app_data12.BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
1962
+ } else {
1963
+ if (import_app_data12.BUILD.svg && !isSvgMode) {
1964
+ isSvgMode = newVNode2.$tag$ === "svg";
1896
1965
  }
1897
- if (childRenderNode.$tag$ === "slot") {
1898
- if (childRenderNode.$children$) {
1899
- childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1900
- if (!childRenderNode.$elm$.childNodes.length) {
1901
- childRenderNode.$children$.forEach((c) => {
1902
- childRenderNode.$elm$.appendChild(c.$elm$);
1903
- });
1966
+ elm = newVNode2.$elm$ = import_app_data12.BUILD.svg ? doc.createElementNS(
1967
+ isSvgMode ? SVG_NS : HTML_NS,
1968
+ !useNativeShadowDom && import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1969
+ ) : doc.createElement(
1970
+ !useNativeShadowDom && import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1971
+ );
1972
+ if (import_app_data12.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
1973
+ isSvgMode = false;
1974
+ }
1975
+ if (import_app_data12.BUILD.vdomAttribute) {
1976
+ updateElement(null, newVNode2, isSvgMode);
1977
+ }
1978
+ if (import_app_data12.BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
1979
+ elm.classList.add(elm["s-si"] = scopeId);
1980
+ }
1981
+ if (newVNode2.$children$) {
1982
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
1983
+ childNode = createElm(oldParentVNode, newVNode2, i2);
1984
+ if (childNode) {
1985
+ elm.appendChild(childNode);
1904
1986
  }
1905
- } else {
1906
- childRenderNode.$flags$ |= 1 /* isSlotReference */;
1907
1987
  }
1908
1988
  }
1909
- if (orgLocationNode && orgLocationNode.isConnected) {
1910
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1911
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1912
- }
1913
- orgLocationNode.parentNode.removeChild(orgLocationNode);
1914
- if (!shadowRoot) {
1915
- node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1989
+ if (import_app_data12.BUILD.svg) {
1990
+ if (newVNode2.$tag$ === "svg") {
1991
+ isSvgMode = false;
1992
+ } else if (elm.tagName === "foreignObject") {
1993
+ isSvgMode = true;
1916
1994
  }
1917
1995
  }
1918
- plt.$orgLocNodes$.delete(orgLocationId);
1919
1996
  }
1920
- const hosts = [];
1921
- const snLen = slottedNodes.length;
1922
- let snIndex = 0;
1923
- let slotGroup;
1924
- let snGroupIdx;
1925
- let snGroupLen;
1926
- let slottedItem;
1927
- for (snIndex; snIndex < snLen; snIndex++) {
1928
- slotGroup = slottedNodes[snIndex];
1929
- if (!slotGroup || !slotGroup.length) continue;
1930
- snGroupLen = slotGroup.length;
1931
- snGroupIdx = 0;
1932
- for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1933
- slottedItem = slotGroup[snGroupIdx];
1934
- if (!hosts[slottedItem.hostId]) {
1935
- hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1936
- }
1937
- if (!hosts[slottedItem.hostId]) continue;
1938
- const hostEle = hosts[slottedItem.hostId];
1939
- if (!hostEle.shadowRoot || !shadowRoot) {
1940
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1941
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1942
- slottedItem.slot["s-cr"] = hostEle;
1997
+ elm["s-hn"] = hostTagName;
1998
+ if (import_app_data12.BUILD.slotRelocation) {
1999
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
2000
+ elm["s-sr"] = true;
2001
+ elm["s-cr"] = contentRef;
2002
+ elm["s-sn"] = newVNode2.$name$ || "";
2003
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
2004
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2005
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
2006
+ if (import_app_data12.BUILD.experimentalSlotFixes) {
2007
+ relocateToHostRoot(oldParentVNode.$elm$);
1943
2008
  } else {
1944
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1945
- }
1946
- addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1947
- if (import_app_data8.BUILD.experimentalSlotFixes) {
1948
- patchNextPrev(slottedItem.node);
2009
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1949
2010
  }
1950
2011
  }
1951
- if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1952
- hostEle.appendChild(slottedItem.node);
2012
+ if (import_app_data12.BUILD.scoped) {
2013
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
1953
2014
  }
1954
2015
  }
1955
2016
  }
1956
- if (import_app_data8.BUILD.scoped && scopeId2 && slotNodes.length) {
1957
- slotNodes.forEach((slot) => {
1958
- slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1959
- });
2017
+ return elm;
2018
+ };
2019
+ var relocateToHostRoot = (parentElm) => {
2020
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2021
+ const host = parentElm.closest(hostTagName.toLowerCase());
2022
+ if (host != null) {
2023
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
2024
+ (ref) => ref["s-cr"]
2025
+ );
2026
+ const childNodeArray = Array.from(
2027
+ parentElm.__childNodes || parentElm.childNodes
2028
+ );
2029
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
2030
+ if (childNode["s-sh"] != null) {
2031
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
2032
+ childNode["s-sh"] = void 0;
2033
+ checkSlotRelocate = true;
2034
+ }
2035
+ }
1960
2036
  }
1961
- if (import_app_data8.BUILD.shadowDom && shadowRoot) {
1962
- let rnIdex = 0;
1963
- const rnLen = shadowRootNodes.length;
1964
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1965
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
2037
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2038
+ };
2039
+ var putBackInOriginalLocation = (parentElm, recursive) => {
2040
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2041
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
2042
+ if (parentElm["s-sr"] && import_app_data12.BUILD.experimentalSlotFixes) {
2043
+ let node = parentElm;
2044
+ while (node = node.nextSibling) {
2045
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
2046
+ oldSlotChildNodes.push(node);
2047
+ }
2048
+ }
2049
+ }
2050
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
2051
+ const childNode = oldSlotChildNodes[i2];
2052
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
2053
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
2054
+ childNode["s-ol"].remove();
2055
+ childNode["s-ol"] = void 0;
2056
+ childNode["s-sh"] = void 0;
2057
+ checkSlotRelocate = true;
2058
+ }
2059
+ if (recursive) {
2060
+ putBackInOriginalLocation(childNode, recursive);
1966
2061
  }
1967
- Array.from(hostElm.childNodes).forEach((node) => {
1968
- if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1969
- node.parentNode.removeChild(node);
2062
+ }
2063
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2064
+ };
2065
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
2066
+ let containerElm = import_app_data12.BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
2067
+ let childNode;
2068
+ if (import_app_data12.BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
2069
+ containerElm = containerElm.shadowRoot;
2070
+ }
2071
+ for (; startIdx <= endIdx; ++startIdx) {
2072
+ if (vnodes[startIdx]) {
2073
+ childNode = createElm(null, parentVNode, startIdx);
2074
+ if (childNode) {
2075
+ vnodes[startIdx].$elm$ = childNode;
2076
+ insertBefore(containerElm, childNode, import_app_data12.BUILD.slotRelocation ? referenceNode(before) : before);
1970
2077
  }
1971
- });
2078
+ }
1972
2079
  }
1973
- hostRef.$hostElement$ = hostElm;
1974
- endHydrate();
1975
2080
  };
1976
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1977
- let childNodeType;
1978
- let childIdSplt;
1979
- let childVNode;
1980
- let i2;
1981
- const scopeId2 = hostElm["s-sc"];
1982
- if (node.nodeType === 1 /* ElementNode */) {
1983
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1984
- if (childNodeType) {
1985
- childIdSplt = childNodeType.split(".");
1986
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1987
- childVNode = createSimpleVNode({
1988
- $flags$: 0,
1989
- $hostId$: childIdSplt[0],
1990
- $nodeId$: childIdSplt[1],
1991
- $depth$: childIdSplt[2],
1992
- $index$: childIdSplt[3],
1993
- $tag$: node.tagName.toLowerCase(),
1994
- $elm$: node,
1995
- // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1996
- // won't try to reconcile them. Classes set on the node will be blown away.
1997
- $attrs$: { class: node.className || "" }
1998
- });
1999
- childRenderNodes.push(childVNode);
2000
- node.removeAttribute(HYDRATE_CHILD_ID);
2001
- if (!parentVNode.$children$) {
2002
- parentVNode.$children$ = [];
2003
- }
2004
- if (import_app_data8.BUILD.scoped && scopeId2) {
2005
- node["s-si"] = scopeId2;
2006
- childVNode.$attrs$.class += " " + scopeId2;
2007
- }
2008
- const slotName = childVNode.$elm$.getAttribute("s-sn");
2009
- if (typeof slotName === "string") {
2010
- if (childVNode.$tag$ === "slot-fb") {
2011
- addSlot(
2012
- slotName,
2013
- childIdSplt[2],
2014
- childVNode,
2015
- node,
2016
- parentVNode,
2017
- childRenderNodes,
2018
- slotNodes,
2019
- shadowRootNodes,
2020
- slottedNodes
2021
- );
2022
- if (import_app_data8.BUILD.scoped && scopeId2) {
2023
- node.classList.add(scopeId2);
2024
- }
2081
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
2082
+ for (let index = startIdx; index <= endIdx; ++index) {
2083
+ const vnode = vnodes[index];
2084
+ if (vnode) {
2085
+ const elm = vnode.$elm$;
2086
+ nullifyVNodeRefs(vnode);
2087
+ if (elm) {
2088
+ if (import_app_data12.BUILD.slotRelocation) {
2089
+ checkSlotFallbackVisibility = true;
2090
+ if (elm["s-ol"]) {
2091
+ elm["s-ol"].remove();
2092
+ } else {
2093
+ putBackInOriginalLocation(elm, true);
2025
2094
  }
2026
- childVNode.$elm$["s-sn"] = slotName;
2027
- childVNode.$elm$.removeAttribute("s-sn");
2028
- }
2029
- if (childVNode.$index$ !== void 0) {
2030
- parentVNode.$children$[childVNode.$index$] = childVNode;
2031
- }
2032
- parentVNode = childVNode;
2033
- if (shadowRootNodes && childVNode.$depth$ === "0") {
2034
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2035
2095
  }
2096
+ elm.remove();
2036
2097
  }
2037
2098
  }
2038
- if (node.shadowRoot) {
2039
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
2040
- clientHydrate(
2041
- parentVNode,
2042
- childRenderNodes,
2043
- slotNodes,
2044
- shadowRootNodes,
2045
- hostElm,
2046
- node.shadowRoot.childNodes[i2],
2047
- hostId,
2048
- slottedNodes
2049
- );
2099
+ }
2100
+ };
2101
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
2102
+ let oldStartIdx = 0;
2103
+ let newStartIdx = 0;
2104
+ let idxInOld = 0;
2105
+ let i2 = 0;
2106
+ let oldEndIdx = oldCh.length - 1;
2107
+ let oldStartVnode = oldCh[0];
2108
+ let oldEndVnode = oldCh[oldEndIdx];
2109
+ let newEndIdx = newCh.length - 1;
2110
+ let newStartVnode = newCh[0];
2111
+ let newEndVnode = newCh[newEndIdx];
2112
+ let node;
2113
+ let elmToMove;
2114
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
2115
+ if (oldStartVnode == null) {
2116
+ oldStartVnode = oldCh[++oldStartIdx];
2117
+ } else if (oldEndVnode == null) {
2118
+ oldEndVnode = oldCh[--oldEndIdx];
2119
+ } else if (newStartVnode == null) {
2120
+ newStartVnode = newCh[++newStartIdx];
2121
+ } else if (newEndVnode == null) {
2122
+ newEndVnode = newCh[--newEndIdx];
2123
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
2124
+ patch(oldStartVnode, newStartVnode, isInitialRender);
2125
+ oldStartVnode = oldCh[++oldStartIdx];
2126
+ newStartVnode = newCh[++newStartIdx];
2127
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
2128
+ patch(oldEndVnode, newEndVnode, isInitialRender);
2129
+ oldEndVnode = oldCh[--oldEndIdx];
2130
+ newEndVnode = newCh[--newEndIdx];
2131
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
2132
+ if (import_app_data12.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2133
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
2050
2134
  }
2051
- }
2052
- const nonShadowNodes = node.__childNodes || node.childNodes;
2053
- for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
2054
- clientHydrate(
2055
- parentVNode,
2056
- childRenderNodes,
2057
- slotNodes,
2058
- shadowRootNodes,
2059
- hostElm,
2060
- nonShadowNodes[i2],
2061
- hostId,
2062
- slottedNodes
2063
- );
2064
- }
2065
- } else if (node.nodeType === 8 /* CommentNode */) {
2066
- childIdSplt = node.nodeValue.split(".");
2067
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
2068
- childNodeType = childIdSplt[0];
2069
- childVNode = createSimpleVNode({
2070
- $hostId$: childIdSplt[1],
2071
- $nodeId$: childIdSplt[2],
2072
- $depth$: childIdSplt[3],
2073
- $index$: childIdSplt[4] || "0",
2074
- $elm$: node,
2075
- $attrs$: null,
2076
- $children$: null,
2077
- $key$: null,
2078
- $name$: null,
2079
- $tag$: null,
2080
- $text$: null
2081
- });
2082
- if (childNodeType === TEXT_NODE_ID) {
2083
- childVNode.$elm$ = node.nextSibling;
2084
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
2085
- childVNode.$text$ = childVNode.$elm$.textContent;
2086
- childRenderNodes.push(childVNode);
2087
- node.remove();
2088
- if (hostId === childVNode.$hostId$) {
2089
- if (!parentVNode.$children$) {
2090
- parentVNode.$children$ = [];
2091
- }
2092
- parentVNode.$children$[childVNode.$index$] = childVNode;
2093
- }
2094
- if (shadowRootNodes && childVNode.$depth$ === "0") {
2095
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2135
+ patch(oldStartVnode, newEndVnode, isInitialRender);
2136
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
2137
+ oldStartVnode = oldCh[++oldStartIdx];
2138
+ newEndVnode = newCh[--newEndIdx];
2139
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
2140
+ if (import_app_data12.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2141
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
2142
+ }
2143
+ patch(oldEndVnode, newStartVnode, isInitialRender);
2144
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
2145
+ oldEndVnode = oldCh[--oldEndIdx];
2146
+ newStartVnode = newCh[++newStartIdx];
2147
+ } else {
2148
+ idxInOld = -1;
2149
+ if (import_app_data12.BUILD.vdomKey) {
2150
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
2151
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
2152
+ idxInOld = i2;
2153
+ break;
2096
2154
  }
2097
2155
  }
2098
- } else if (childNodeType === COMMENT_NODE_ID) {
2099
- childVNode.$elm$ = node.nextSibling;
2100
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
2101
- childRenderNodes.push(childVNode);
2102
- node.remove();
2156
+ }
2157
+ if (import_app_data12.BUILD.vdomKey && idxInOld >= 0) {
2158
+ elmToMove = oldCh[idxInOld];
2159
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
2160
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
2161
+ } else {
2162
+ patch(elmToMove, newStartVnode, isInitialRender);
2163
+ oldCh[idxInOld] = void 0;
2164
+ node = elmToMove.$elm$;
2103
2165
  }
2104
- } else if (childVNode.$hostId$ === hostId) {
2105
- if (childNodeType === SLOT_NODE_ID) {
2106
- const slotName = node["s-sn"] = childIdSplt[5] || "";
2107
- addSlot(
2108
- slotName,
2109
- childIdSplt[2],
2110
- childVNode,
2166
+ newStartVnode = newCh[++newStartIdx];
2167
+ } else {
2168
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
2169
+ newStartVnode = newCh[++newStartIdx];
2170
+ }
2171
+ if (node) {
2172
+ if (import_app_data12.BUILD.slotRelocation) {
2173
+ insertBefore(
2174
+ referenceNode(oldStartVnode.$elm$).parentNode,
2111
2175
  node,
2112
- parentVNode,
2113
- childRenderNodes,
2114
- slotNodes,
2115
- shadowRootNodes,
2116
- slottedNodes
2176
+ referenceNode(oldStartVnode.$elm$)
2117
2177
  );
2118
- } else if (childNodeType === CONTENT_REF_ID) {
2119
- if (import_app_data8.BUILD.shadowDom && shadowRootNodes) {
2120
- node.remove();
2121
- } else if (import_app_data8.BUILD.slotRelocation) {
2122
- hostElm["s-cr"] = node;
2123
- node["s-cn"] = true;
2124
- }
2178
+ } else {
2179
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2125
2180
  }
2126
2181
  }
2127
2182
  }
2128
- } else if (parentVNode && parentVNode.$tag$ === "style") {
2129
- const vnode = newVNode(null, node.textContent);
2130
- vnode.$elm$ = node;
2131
- vnode.$index$ = "0";
2132
- parentVNode.$children$ = [vnode];
2133
2183
  }
2134
- return parentVNode;
2184
+ if (oldStartIdx > oldEndIdx) {
2185
+ addVnodes(
2186
+ parentElm,
2187
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
2188
+ newVNode2,
2189
+ newCh,
2190
+ newStartIdx,
2191
+ newEndIdx
2192
+ );
2193
+ } else if (import_app_data12.BUILD.updatable && newStartIdx > newEndIdx) {
2194
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
2195
+ }
2135
2196
  };
2136
- var initializeDocumentHydrate = (node, orgLocNodes) => {
2137
- if (node.nodeType === 1 /* ElementNode */) {
2138
- const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
2139
- if (componentId) {
2140
- orgLocNodes.set(componentId, node);
2141
- }
2142
- let i2 = 0;
2143
- if (node.shadowRoot) {
2144
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
2145
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
2146
- }
2197
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
2198
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
2199
+ if (import_app_data12.BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
2200
+ return leftVNode.$name$ === rightVNode.$name$;
2147
2201
  }
2148
- const nonShadowNodes = node.__childNodes || node.childNodes;
2149
- for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
2150
- initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
2202
+ if (import_app_data12.BUILD.vdomKey && !isInitialRender) {
2203
+ return leftVNode.$key$ === rightVNode.$key$;
2151
2204
  }
2152
- } else if (node.nodeType === 8 /* CommentNode */) {
2153
- const childIdSplt = node.nodeValue.split(".");
2154
- if (childIdSplt[0] === ORG_LOCATION_ID) {
2155
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
2156
- node.nodeValue = "";
2157
- node["s-en"] = childIdSplt[3];
2205
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
2206
+ leftVNode.$key$ = rightVNode.$key$;
2158
2207
  }
2208
+ return true;
2159
2209
  }
2210
+ return false;
2160
2211
  };
2161
- var createSimpleVNode = (vnode) => {
2162
- const defaultVNode = {
2163
- $flags$: 0,
2164
- $hostId$: null,
2165
- $nodeId$: null,
2166
- $depth$: null,
2167
- $index$: "0",
2168
- $elm$: null,
2169
- $attrs$: null,
2170
- $children$: null,
2171
- $key$: null,
2172
- $name$: null,
2173
- $tag$: null,
2174
- $text$: null
2175
- };
2176
- return { ...defaultVNode, ...vnode };
2177
- };
2178
- function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
2179
- node["s-sr"] = true;
2180
- childVNode.$name$ = slotName || null;
2181
- childVNode.$tag$ = "slot";
2182
- const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
2183
- if (import_app_data8.BUILD.shadowDom && shadowRootNodes) {
2184
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
2185
- if (childVNode.$name$) {
2186
- childVNode.$elm$.setAttribute("name", slotName);
2212
+ var referenceNode = (node) => node && node["s-ol"] || node;
2213
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2214
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
2215
+ const oldChildren = oldVNode.$children$;
2216
+ const newChildren = newVNode2.$children$;
2217
+ const tag = newVNode2.$tag$;
2218
+ const text = newVNode2.$text$;
2219
+ let defaultHolder;
2220
+ if (!import_app_data12.BUILD.vdomText || text === null) {
2221
+ if (import_app_data12.BUILD.svg) {
2222
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2187
2223
  }
2188
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
2189
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2190
- } else {
2191
- node.parentNode.insertBefore(childVNode.$elm$, node);
2224
+ if (import_app_data12.BUILD.vdomAttribute || import_app_data12.BUILD.reflect) {
2225
+ if (import_app_data12.BUILD.slot && tag === "slot" && !useNativeShadowDom) {
2226
+ if (import_app_data12.BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
2227
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
2228
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
2229
+ }
2230
+ } else {
2231
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
2232
+ }
2192
2233
  }
2193
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
2194
- node.remove();
2195
- if (childVNode.$depth$ === "0") {
2196
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2234
+ if (import_app_data12.BUILD.updatable && oldChildren !== null && newChildren !== null) {
2235
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
2236
+ } else if (newChildren !== null) {
2237
+ if (import_app_data12.BUILD.updatable && import_app_data12.BUILD.vdomText && oldVNode.$text$ !== null) {
2238
+ elm.textContent = "";
2239
+ }
2240
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
2241
+ } else if (
2242
+ // don't do this on initial render as it can cause non-hydrated content to be removed
2243
+ !isInitialRender && import_app_data12.BUILD.updatable && oldChildren !== null
2244
+ ) {
2245
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
2197
2246
  }
2198
- } else {
2199
- const slot = childVNode.$elm$;
2200
- const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
2201
- addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
2202
- if (shouldMove) {
2203
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2247
+ if (import_app_data12.BUILD.svg && isSvgMode && tag === "svg") {
2248
+ isSvgMode = false;
2204
2249
  }
2205
- childRenderNodes.push(childVNode);
2250
+ } else if (import_app_data12.BUILD.vdomText && import_app_data12.BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
2251
+ defaultHolder.parentNode.textContent = text;
2252
+ } else if (import_app_data12.BUILD.vdomText && oldVNode.$text$ !== text) {
2253
+ elm.data = text;
2206
2254
  }
2207
- slotNodes.push(childVNode);
2208
- if (!parentVNode.$children$) {
2209
- parentVNode.$children$ = [];
2255
+ };
2256
+ var relocateNodes = [];
2257
+ var markSlotContentForRelocation = (elm) => {
2258
+ let node;
2259
+ let hostContentNodes;
2260
+ let j;
2261
+ const children = elm.__childNodes || elm.childNodes;
2262
+ for (const childNode of children) {
2263
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
2264
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
2265
+ const slotName = childNode["s-sn"];
2266
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
2267
+ node = hostContentNodes[j];
2268
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!import_app_data12.BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2269
+ if (isNodeLocatedInSlot(node, slotName)) {
2270
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2271
+ checkSlotFallbackVisibility = true;
2272
+ node["s-sn"] = node["s-sn"] || slotName;
2273
+ if (relocateNodeData) {
2274
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
2275
+ relocateNodeData.$slotRefNode$ = childNode;
2276
+ } else {
2277
+ node["s-sh"] = childNode["s-hn"];
2278
+ relocateNodes.push({
2279
+ $slotRefNode$: childNode,
2280
+ $nodeToRelocate$: node
2281
+ });
2282
+ }
2283
+ if (node["s-sr"]) {
2284
+ relocateNodes.map((relocateNode) => {
2285
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
2286
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2287
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
2288
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
2289
+ }
2290
+ }
2291
+ });
2292
+ }
2293
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
2294
+ relocateNodes.push({
2295
+ $nodeToRelocate$: node
2296
+ });
2297
+ }
2298
+ }
2299
+ }
2300
+ }
2301
+ if (childNode.nodeType === 1 /* ElementNode */) {
2302
+ markSlotContentForRelocation(childNode);
2303
+ }
2210
2304
  }
2211
- parentVNode.$children$[childVNode.$index$] = childVNode;
2212
- }
2213
- var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
2214
- let slottedNode = slotNode.nextSibling;
2215
- slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
2216
- 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 */))) {
2217
- slottedNode["s-sn"] = slotName;
2218
- slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
2219
- slottedNode = slottedNode.nextSibling;
2305
+ };
2306
+ var nullifyVNodeRefs = (vNode) => {
2307
+ if (import_app_data12.BUILD.vdomRef) {
2308
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
2309
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2220
2310
  }
2221
2311
  };
2222
-
2223
- // src/runtime/initialize-component.ts
2224
- var import_app_data16 = require("@rindo/core/internal/app-data");
2225
-
2226
- // src/runtime/mode.ts
2227
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
2228
- var setMode = (handler) => modeResolutionChain.push(handler);
2229
- var getMode = (ref) => getHostRef(ref).$modeName$;
2230
-
2231
- // src/runtime/proxy-component.ts
2232
- var import_app_data15 = require("@rindo/core/internal/app-data");
2233
-
2234
- // src/runtime/set-value.ts
2235
- var import_app_data14 = require("@rindo/core/internal/app-data");
2236
-
2237
- // src/runtime/parse-property-value.ts
2238
- var import_app_data9 = require("@rindo/core/internal/app-data");
2239
- var parsePropertyValue = (propValue, propType) => {
2240
- if (propValue != null && !isComplexType(propValue)) {
2241
- if (import_app_data9.BUILD.propBoolean && propType & 4 /* Boolean */) {
2242
- return propValue === "false" ? false : propValue === "" || !!propValue;
2243
- }
2244
- if (import_app_data9.BUILD.propNumber && propType & 2 /* Number */) {
2245
- return parseFloat(propValue);
2312
+ var insertBefore = (parent, newNode, reference) => {
2313
+ if (import_app_data12.BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2314
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2315
+ } else if (import_app_data12.BUILD.experimentalSlotFixes && typeof newNode["s-sn"] === "string") {
2316
+ if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
2317
+ patchParentNode(newNode);
2246
2318
  }
2247
- if (import_app_data9.BUILD.propString && propType & 1 /* String */) {
2248
- return String(propValue);
2319
+ return parent.insertBefore(newNode, reference);
2320
+ }
2321
+ if (import_app_data12.BUILD.experimentalSlotFixes && parent.__insertBefore) {
2322
+ return parent.__insertBefore(newNode, reference);
2323
+ } else {
2324
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2325
+ }
2326
+ };
2327
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
2328
+ var _a, _b;
2329
+ let scopeId2;
2330
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
2331
+ const scopeName = slotNode["s-sn"];
2332
+ const hostName = slotNode["s-hn"];
2333
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
2334
+ if (oldParent && ((_b = oldParent.classList) == null ? void 0 : _b.contains(scopeId2 + "-s"))) {
2335
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
2336
+ let found = false;
2337
+ while (child) {
2338
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
2339
+ found = true;
2340
+ break;
2341
+ }
2342
+ child = child.nextSibling;
2343
+ }
2344
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
2249
2345
  }
2250
- return propValue;
2251
2346
  }
2252
- return propValue;
2253
- };
2254
-
2255
- // src/runtime/update-component.ts
2256
- var import_app_data13 = require("@rindo/core/internal/app-data");
2257
-
2258
- // src/runtime/event-emitter.ts
2259
- var import_app_data11 = require("@rindo/core/internal/app-data");
2347
+ }
2348
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2349
+ var _a, _b, _c, _d, _e;
2350
+ const hostElm = hostRef.$hostElement$;
2351
+ const cmpMeta = hostRef.$cmpMeta$;
2352
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2353
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2354
+ hostTagName = hostElm.tagName;
2355
+ if (import_app_data12.BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
2356
+ throw new Error(`The <Host> must be the single root component.
2357
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2260
2358
 
2261
- // src/runtime/element.ts
2262
- var import_app_data10 = require("@rindo/core/internal/app-data");
2263
- var getElement = (ref) => import_app_data10.BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2359
+ The render() function should look like this instead:
2264
2360
 
2265
- // src/runtime/event-emitter.ts
2266
- var createEvent = (ref, name, flags) => {
2267
- const elm = getElement(ref);
2268
- return {
2269
- emit: (detail) => {
2270
- if (import_app_data11.BUILD.isDev && !elm.isConnected) {
2271
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2361
+ render() {
2362
+ // Do not return an array
2363
+ return (
2364
+ <Host>{content}</Host>
2365
+ );
2366
+ }
2367
+ `);
2368
+ }
2369
+ if (import_app_data12.BUILD.reflect && cmpMeta.$attrsToReflect$) {
2370
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
2371
+ cmpMeta.$attrsToReflect$.map(
2372
+ ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
2373
+ );
2374
+ }
2375
+ if (isInitialLoad && rootVnode.$attrs$) {
2376
+ for (const key of Object.keys(rootVnode.$attrs$)) {
2377
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
2378
+ rootVnode.$attrs$[key] = hostElm[key];
2272
2379
  }
2273
- return emitEvent(elm, name, {
2274
- bubbles: !!(flags & 4 /* Bubbles */),
2275
- composed: !!(flags & 2 /* Composed */),
2276
- cancelable: !!(flags & 1 /* Cancellable */),
2277
- detail
2278
- });
2279
- }
2280
- };
2281
- };
2282
- var emitEvent = (elm, name, opts) => {
2283
- const ev = plt.ce(name, opts);
2284
- elm.dispatchEvent(ev);
2285
- return ev;
2286
- };
2287
-
2288
- // src/runtime/styles.ts
2289
- var import_app_data12 = require("@rindo/core/internal/app-data");
2290
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
2291
- var registerStyle = (scopeId2, cssText, allowCS) => {
2292
- let style = styles.get(scopeId2);
2293
- if (supportsConstructableStylesheets && allowCS) {
2294
- style = style || new CSSStyleSheet();
2295
- if (typeof style === "string") {
2296
- style = cssText;
2297
- } else {
2298
- style.replaceSync(cssText);
2299
2380
  }
2300
- } else {
2301
- style = cssText;
2302
2381
  }
2303
- styles.set(scopeId2, style);
2304
- };
2305
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
2306
- var _a;
2307
- const scopeId2 = getScopeId(cmpMeta, mode);
2308
- const style = styles.get(scopeId2);
2309
- if (!import_app_data12.BUILD.attachStyles) {
2310
- return scopeId2;
2382
+ rootVnode.$tag$ = null;
2383
+ rootVnode.$flags$ |= 4 /* isHost */;
2384
+ hostRef.$vnode$ = rootVnode;
2385
+ rootVnode.$elm$ = oldVNode.$elm$ = import_app_data12.BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
2386
+ if (import_app_data12.BUILD.scoped || import_app_data12.BUILD.shadowDom) {
2387
+ scopeId = hostElm["s-sc"];
2311
2388
  }
2312
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
2313
- if (style) {
2314
- if (typeof style === "string") {
2315
- styleContainerNode = styleContainerNode.head || styleContainerNode;
2316
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
2317
- let styleElm;
2318
- if (!appliedStyles) {
2319
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
2389
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
2390
+ if (import_app_data12.BUILD.slotRelocation) {
2391
+ contentRef = hostElm["s-cr"];
2392
+ checkSlotFallbackVisibility = false;
2393
+ }
2394
+ patch(oldVNode, rootVnode, isInitialLoad);
2395
+ if (import_app_data12.BUILD.slotRelocation) {
2396
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2397
+ if (checkSlotRelocate) {
2398
+ markSlotContentForRelocation(rootVnode.$elm$);
2399
+ for (const relocateData of relocateNodes) {
2400
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2401
+ if (!nodeToRelocate["s-ol"]) {
2402
+ const orgLocationNode = import_app_data12.BUILD.isDebug || import_app_data12.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2403
+ orgLocationNode["s-nr"] = nodeToRelocate;
2404
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2405
+ }
2320
2406
  }
2321
- if (!appliedStyles.has(scopeId2)) {
2322
- if (import_app_data12.BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
2323
- styleElm.innerHTML = style;
2324
- } else {
2325
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
2326
- styleElm.innerHTML = style;
2327
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2328
- if (nonce != null) {
2329
- styleElm.setAttribute("nonce", nonce);
2330
- }
2331
- if ((import_app_data12.BUILD.hydrateServerSide || import_app_data12.BUILD.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2332
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
2333
- }
2334
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2335
- if (styleContainerNode.nodeName === "HEAD") {
2336
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2337
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2338
- styleContainerNode.insertBefore(styleElm, referenceNode2);
2339
- } else if ("host" in styleContainerNode) {
2340
- if (supportsConstructableStylesheets) {
2341
- const stylesheet = new CSSStyleSheet();
2342
- stylesheet.replaceSync(style);
2343
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2344
- } else {
2345
- const existingStyleContainer = styleContainerNode.querySelector("style");
2346
- if (existingStyleContainer) {
2347
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2348
- } else {
2349
- styleContainerNode.prepend(styleElm);
2407
+ for (const relocateData of relocateNodes) {
2408
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2409
+ const slotRefNode = relocateData.$slotRefNode$;
2410
+ if (slotRefNode) {
2411
+ const parentNodeRef = slotRefNode.parentNode;
2412
+ let insertBeforeNode = slotRefNode.nextSibling;
2413
+ if (!import_app_data12.BUILD.hydrateServerSide && (!import_app_data12.BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
2414
+ let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
2415
+ while (orgLocationNode) {
2416
+ let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
2417
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
2418
+ refNode = refNode.nextSibling;
2419
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
2420
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
2421
+ }
2422
+ if (!refNode || !refNode["s-nr"]) {
2423
+ insertBeforeNode = refNode;
2424
+ break;
2350
2425
  }
2351
2426
  }
2352
- } else {
2353
- styleContainerNode.append(styleElm);
2427
+ orgLocationNode = orgLocationNode.previousSibling;
2354
2428
  }
2355
2429
  }
2356
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
2357
- styleContainerNode.insertBefore(styleElm, null);
2430
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
2431
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2432
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2433
+ if (nodeToRelocate !== insertBeforeNode) {
2434
+ if (!import_app_data12.BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2435
+ nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
2436
+ }
2437
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2438
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2439
+ nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
2440
+ }
2441
+ }
2442
+ }
2443
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2444
+ } else {
2445
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2446
+ if (isInitialLoad) {
2447
+ nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
2448
+ }
2449
+ nodeToRelocate.hidden = true;
2358
2450
  }
2359
- }
2360
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2361
- styleElm.innerHTML += SLOT_FB_CSS;
2362
- }
2363
- if (appliedStyles) {
2364
- appliedStyles.add(scopeId2);
2365
2451
  }
2366
2452
  }
2367
- } else if (import_app_data12.BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2368
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
2369
2453
  }
2454
+ if (checkSlotFallbackVisibility) {
2455
+ updateFallbackSlotVisibility(rootVnode.$elm$);
2456
+ }
2457
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2458
+ relocateNodes.length = 0;
2370
2459
  }
2371
- return scopeId2;
2372
- };
2373
- var attachStyles = (hostRef) => {
2374
- const cmpMeta = hostRef.$cmpMeta$;
2375
- const elm = hostRef.$hostElement$;
2376
- const flags = cmpMeta.$flags$;
2377
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2378
- const scopeId2 = addStyle(
2379
- import_app_data12.BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2380
- cmpMeta,
2381
- hostRef.$modeName$
2382
- );
2383
- if ((import_app_data12.BUILD.shadowDom || import_app_data12.BUILD.scoped) && import_app_data12.BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2384
- elm["s-sc"] = scopeId2;
2385
- elm.classList.add(scopeId2 + "-h");
2460
+ if (import_app_data12.BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2461
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2462
+ for (const childNode of children) {
2463
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2464
+ if (isInitialLoad && childNode["s-ih"] == null) {
2465
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2466
+ }
2467
+ childNode.hidden = true;
2468
+ }
2469
+ }
2386
2470
  }
2387
- endAttachStyles();
2471
+ contentRef = void 0;
2388
2472
  };
2389
- var getScopeId = (cmp, mode) => "sc-" + (import_app_data12.BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2473
+ var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2474
+ `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2475
+ );
2476
+ var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2477
+ `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2478
+ );
2390
2479
 
2391
2480
  // src/runtime/update-component.ts
2392
2481
  var attachToAncestor = (hostRef, ancestorComponent) => {
2393
2482
  if (import_app_data13.BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2394
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
2483
+ const index = ancestorComponent["s-p"].push(
2484
+ new Promise(
2485
+ (r) => hostRef.$onRenderResolve$ = () => {
2486
+ ancestorComponent["s-p"].splice(index - 1, 1);
2487
+ r();
2488
+ }
2489
+ )
2490
+ );
2395
2491
  }
2396
2492
  };
2397
2493
  var scheduleUpdate = (hostRef, isInitialLoad) => {
@@ -2420,23 +2516,23 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
2420
2516
  if (import_app_data13.BUILD.lazyLoad && import_app_data13.BUILD.hostListener) {
2421
2517
  hostRef.$flags$ |= 256 /* isListenReady */;
2422
2518
  if (hostRef.$queuedListeners$) {
2423
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
2519
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
2424
2520
  hostRef.$queuedListeners$ = void 0;
2425
2521
  }
2426
2522
  }
2427
2523
  emitLifecycleEvent(elm, "componentWillLoad");
2428
2524
  if (import_app_data13.BUILD.cmpWillLoad) {
2429
- maybePromise = safeCall(instance, "componentWillLoad");
2525
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2430
2526
  }
2431
2527
  } else {
2432
2528
  emitLifecycleEvent(elm, "componentWillUpdate");
2433
2529
  if (import_app_data13.BUILD.cmpWillUpdate) {
2434
- maybePromise = safeCall(instance, "componentWillUpdate");
2530
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2435
2531
  }
2436
2532
  }
2437
2533
  emitLifecycleEvent(elm, "componentWillRender");
2438
2534
  if (import_app_data13.BUILD.cmpWillRender) {
2439
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
2535
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
2440
2536
  }
2441
2537
  endSchedule();
2442
2538
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
@@ -2549,7 +2645,7 @@ var postUpdateComponent = (hostRef) => {
2549
2645
  if (import_app_data13.BUILD.isDev) {
2550
2646
  hostRef.$flags$ |= 1024 /* devOnRender */;
2551
2647
  }
2552
- safeCall(instance, "componentDidRender");
2648
+ safeCall(instance, "componentDidRender", void 0, elm);
2553
2649
  if (import_app_data13.BUILD.isDev) {
2554
2650
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2555
2651
  }
@@ -2564,7 +2660,7 @@ var postUpdateComponent = (hostRef) => {
2564
2660
  if (import_app_data13.BUILD.isDev) {
2565
2661
  hostRef.$flags$ |= 2048 /* devOnDidLoad */;
2566
2662
  }
2567
- safeCall(instance, "componentDidLoad");
2663
+ safeCall(instance, "componentDidLoad", void 0, elm);
2568
2664
  if (import_app_data13.BUILD.isDev) {
2569
2665
  hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
2570
2666
  }
@@ -2582,7 +2678,7 @@ var postUpdateComponent = (hostRef) => {
2582
2678
  if (import_app_data13.BUILD.isDev) {
2583
2679
  hostRef.$flags$ |= 1024 /* devOnRender */;
2584
2680
  }
2585
- safeCall(instance, "componentDidUpdate");
2681
+ safeCall(instance, "componentDidUpdate", void 0, elm);
2586
2682
  if (import_app_data13.BUILD.isDev) {
2587
2683
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2588
2684
  }
@@ -2616,9 +2712,6 @@ var forceUpdate = (ref) => {
2616
2712
  return false;
2617
2713
  };
2618
2714
  var appDidLoad = (who) => {
2619
- if (import_app_data13.BUILD.cssAnnotations) {
2620
- addHydratedFlag(doc.documentElement);
2621
- }
2622
2715
  if (import_app_data13.BUILD.asyncQueue) {
2623
2716
  plt.$flags$ |= 2 /* appLoaded */;
2624
2717
  }
@@ -2627,12 +2720,12 @@ var appDidLoad = (who) => {
2627
2720
  performance.measure(`[Rindo] ${import_app_data13.NAMESPACE} initial load (by ${who})`, "st:app:start");
2628
2721
  }
2629
2722
  };
2630
- var safeCall = (instance, method, arg) => {
2723
+ var safeCall = (instance, method, arg, elm) => {
2631
2724
  if (instance && instance[method]) {
2632
2725
  try {
2633
2726
  return instance[method](arg);
2634
2727
  } catch (e) {
2635
- consoleError(e);
2728
+ consoleError(e, elm);
2636
2729
  }
2637
2730
  }
2638
2731
  return void 0;
@@ -2735,6 +2828,12 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
2735
2828
  var proxyComponent = (Cstr, cmpMeta, flags) => {
2736
2829
  var _a, _b;
2737
2830
  const prototype = Cstr.prototype;
2831
+ if (import_app_data15.BUILD.isTesting) {
2832
+ if (prototype.__rindoAugmented) {
2833
+ return;
2834
+ }
2835
+ prototype.__rindoAugmented = true;
2836
+ }
2738
2837
  if (import_app_data15.BUILD.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
2739
2838
  FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => {
2740
2839
  const originalFormAssociatedCallback = prototype[cbName];
@@ -2762,77 +2861,91 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
2762
2861
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
2763
2862
  members.map(([memberName, [memberFlags]]) => {
2764
2863
  if ((import_app_data15.BUILD.prop || import_app_data15.BUILD.state) && (memberFlags & 31 /* Prop */ || (!import_app_data15.BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2765
- if ((memberFlags & 2048 /* Getter */) === 0) {
2864
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
2865
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
2866
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
2867
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
2766
2868
  Object.defineProperty(prototype, memberName, {
2767
2869
  get() {
2768
- return getValue(this, memberName);
2769
- },
2770
- set(newValue) {
2771
- if (import_app_data15.BUILD.isDev) {
2772
- const ref = getHostRef(this);
2773
- if (
2774
- // we are proxying the instance (not element)
2775
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
2776
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2777
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2778
- (memberFlags & 1024 /* Mutable */) === 0
2779
- ) {
2780
- consoleDevWarn(
2781
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2782
- More information: https://rindojs.web.app/docs/properties#prop-mutability`
2783
- );
2870
+ if (import_app_data15.BUILD.lazyLoad) {
2871
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
2872
+ return getValue(this, memberName);
2784
2873
  }
2874
+ const ref = getHostRef(this);
2875
+ const instance = ref ? ref.$lazyInstance$ : prototype;
2876
+ if (!instance) return;
2877
+ return instance[memberName];
2878
+ }
2879
+ if (!import_app_data15.BUILD.lazyLoad) {
2880
+ return origGetter ? origGetter.apply(this) : getValue(this, memberName);
2785
2881
  }
2786
- setValue(this, memberName, newValue, cmpMeta);
2787
2882
  },
2788
2883
  configurable: true,
2789
2884
  enumerable: true
2790
2885
  });
2791
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 2048 /* Getter */) {
2792
- if (import_app_data15.BUILD.lazyLoad) {
2793
- Object.defineProperty(prototype, memberName, {
2794
- get() {
2795
- const ref = getHostRef(this);
2796
- const instance = import_app_data15.BUILD.lazyLoad && ref ? ref.$lazyInstance$ : prototype;
2797
- if (!instance) return;
2798
- return instance[memberName];
2799
- },
2800
- configurable: true,
2801
- enumerable: true
2802
- });
2803
- }
2804
- if (memberFlags & 4096 /* Setter */) {
2805
- const origSetter = Object.getOwnPropertyDescriptor(prototype, memberName).set;
2806
- Object.defineProperty(prototype, memberName, {
2807
- set(newValue) {
2808
- const ref = getHostRef(this);
2809
- if (origSetter) {
2810
- const currentValue = ref.$hostElement$[memberName];
2811
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2812
- ref.$instanceValues$.set(memberName, currentValue);
2813
- }
2814
- origSetter.apply(this, [parsePropertyValue(newValue, cmpMeta.$members$[memberName][0])]);
2815
- setValue(this, memberName, ref.$hostElement$[memberName], cmpMeta);
2816
- return;
2886
+ }
2887
+ Object.defineProperty(prototype, memberName, {
2888
+ set(newValue) {
2889
+ const ref = getHostRef(this);
2890
+ if (import_app_data15.BUILD.isDev) {
2891
+ if (
2892
+ // we are proxying the instance (not element)
2893
+ (flags & 1 /* isElementConstructor */) === 0 && // if the class has a setter, then the Element can update instance values, so ignore
2894
+ (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0 && // the element is not constructing
2895
+ (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2896
+ (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2897
+ (memberFlags & 1024 /* Mutable */) === 0
2898
+ ) {
2899
+ consoleDevWarn(
2900
+ `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2901
+ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2902
+ );
2903
+ }
2904
+ }
2905
+ if (origSetter) {
2906
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2907
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
2908
+ newValue = ref.$instanceValues$.get(memberName);
2909
+ } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
2910
+ ref.$instanceValues$.set(memberName, currentValue);
2911
+ }
2912
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
2913
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2914
+ setValue(this, memberName, newValue, cmpMeta);
2915
+ return;
2916
+ }
2917
+ if (!import_app_data15.BUILD.lazyLoad) {
2918
+ setValue(this, memberName, newValue, cmpMeta);
2919
+ return;
2920
+ }
2921
+ if (import_app_data15.BUILD.lazyLoad) {
2922
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
2923
+ setValue(this, memberName, newValue, cmpMeta);
2924
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
2925
+ ref.$onReadyPromise$.then(() => {
2926
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
2927
+ ref.$lazyInstance$[memberName] = newValue;
2928
+ }
2929
+ });
2817
2930
  }
2818
- if (!ref) return;
2819
- const setterSetVal = () => {
2820
- const currentValue = ref.$lazyInstance$[memberName];
2821
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2822
- ref.$instanceValues$.set(memberName, currentValue);
2823
- }
2824
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, cmpMeta.$members$[memberName][0]);
2825
- setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2826
- };
2827
- if (ref.$lazyInstance$) {
2828
- setterSetVal();
2829
- } else {
2830
- ref.$onReadyPromise$.then(() => setterSetVal());
2931
+ return;
2932
+ }
2933
+ const setterSetVal = () => {
2934
+ const currentValue = ref.$lazyInstance$[memberName];
2935
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
2936
+ ref.$instanceValues$.set(memberName, currentValue);
2831
2937
  }
2938
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags);
2939
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2940
+ };
2941
+ if (ref.$lazyInstance$) {
2942
+ setterSetVal();
2943
+ } else {
2944
+ ref.$onReadyPromise$.then(() => setterSetVal());
2832
2945
  }
2833
- });
2946
+ }
2834
2947
  }
2835
- }
2948
+ });
2836
2949
  } else if (import_app_data15.BUILD.lazyLoad && import_app_data15.BUILD.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2837
2950
  Object.defineProperty(prototype, memberName, {
2838
2951
  value(...args) {
@@ -2874,8 +2987,9 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2874
2987
  return;
2875
2988
  }
2876
2989
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
2877
- if (!propDesc.get || !!propDesc.set) {
2878
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2990
+ newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2991
+ if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
2992
+ this[propName] = newValue;
2879
2993
  }
2880
2994
  });
2881
2995
  };
@@ -2904,7 +3018,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2904
3018
  if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2905
3019
  hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2906
3020
  const bundleId = cmpMeta.$lazyBundleId$;
2907
- if ((import_app_data16.BUILD.lazyLoad || import_app_data16.BUILD.hydrateClientSide) && bundleId) {
3021
+ if (import_app_data16.BUILD.lazyLoad && bundleId) {
2908
3022
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
2909
3023
  if (CstrImport && "then" in CstrImport) {
2910
3024
  const endLoad = uniqueTime(
@@ -2933,7 +3047,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2933
3047
  try {
2934
3048
  new Cstr(hostRef);
2935
3049
  } catch (e) {
2936
- consoleError(e);
3050
+ consoleError(e, elm);
2937
3051
  }
2938
3052
  if (import_app_data16.BUILD.member) {
2939
3053
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
@@ -2942,7 +3056,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2942
3056
  hostRef.$flags$ |= 128 /* isWatchReady */;
2943
3057
  }
2944
3058
  endNewInstance();
2945
- fireConnectedCallback(hostRef.$lazyInstance$);
3059
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
2946
3060
  } else {
2947
3061
  Cstr = elm.constructor;
2948
3062
  const cmpTag = elm.localName;
@@ -2981,9 +3095,9 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2981
3095
  schedule();
2982
3096
  }
2983
3097
  };
2984
- var fireConnectedCallback = (instance) => {
3098
+ var fireConnectedCallback = (instance, elm) => {
2985
3099
  if (import_app_data16.BUILD.lazyLoad && import_app_data16.BUILD.connectedCallback) {
2986
- safeCall(instance, "connectedCallback");
3100
+ safeCall(instance, "connectedCallback", void 0, elm);
2987
3101
  }
2988
3102
  };
2989
3103
 
@@ -3044,9 +3158,9 @@ var connectedCallback = (elm) => {
3044
3158
  } else {
3045
3159
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3046
3160
  if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
3047
- fireConnectedCallback(hostRef.$lazyInstance$);
3161
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
3048
3162
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
3049
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
3163
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
3050
3164
  }
3051
3165
  }
3052
3166
  endConnected();
@@ -3062,12 +3176,12 @@ var setContentReference = (elm) => {
3062
3176
 
3063
3177
  // src/runtime/disconnected-callback.ts
3064
3178
  var import_app_data18 = require("@rindo/core/internal/app-data");
3065
- var disconnectInstance = (instance) => {
3179
+ var disconnectInstance = (instance, elm) => {
3066
3180
  if (import_app_data18.BUILD.lazyLoad && import_app_data18.BUILD.disconnectedCallback) {
3067
- safeCall(instance, "disconnectedCallback");
3181
+ safeCall(instance, "disconnectedCallback", void 0, elm || instance);
3068
3182
  }
3069
3183
  if (import_app_data18.BUILD.cmpDidUnload) {
3070
- safeCall(instance, "componentDidUnload");
3184
+ safeCall(instance, "componentDidUnload", void 0, elm || instance);
3071
3185
  }
3072
3186
  };
3073
3187
  var disconnectedCallback = async (elm) => {
@@ -3082,9 +3196,9 @@ var disconnectedCallback = async (elm) => {
3082
3196
  if (!import_app_data18.BUILD.lazyLoad) {
3083
3197
  disconnectInstance(elm);
3084
3198
  } else if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
3085
- disconnectInstance(hostRef.$lazyInstance$);
3199
+ disconnectInstance(hostRef.$lazyInstance$, elm);
3086
3200
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
3087
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
3201
+ hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
3088
3202
  }
3089
3203
  }
3090
3204
  if (rootAppliedStyles.has(elm)) {
@@ -3337,6 +3451,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3337
3451
  plt.raf(() => {
3338
3452
  var _a3;
3339
3453
  const hostRef = getHostRef(this);
3454
+ const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
3455
+ if (i2 > -1) {
3456
+ deferredConnectedCallbacks.splice(i2, 1);
3457
+ }
3340
3458
  if (((_a3 = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a3.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
3341
3459
  delete hostRef.$vnode$.$elm$;
3342
3460
  }
@@ -3447,7 +3565,7 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
3447
3565
  hostRef.$hostElement$[methodName](ev);
3448
3566
  }
3449
3567
  } catch (e) {
3450
- consoleError(e);
3568
+ consoleError(e, hostRef.$hostElement$);
3451
3569
  }
3452
3570
  };
3453
3571
  var getHostListenerTarget = (elm, flags) => {