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