marko 6.1.1 → 6.1.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.
package/dist/html.js CHANGED
@@ -610,11 +610,12 @@ function writeRegistered(state, val, parent, accessor, registered) {
610
610
  return !0;
611
611
  }
612
612
  function writeString(state, val, parent, accessor) {
613
- if (val.length > 30) {
613
+ if (val.length > 12) {
614
614
  let ref = state.strs.get(val);
615
- ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(val, new Reference(parent, accessor, state.flush, state.buf.length)), state.buf.push(quote(val, 0)));
616
- } else state.buf.push(quote(val, 0));
617
- return !0;
615
+ if (ref) return state.buf.push(ensureId(state, ref)), !0;
616
+ state.strs.set(val, new Reference(parent, accessor, state.flush, state.buf.length));
617
+ }
618
+ return state.buf.push(quote(val, 0)), !0;
618
619
  }
619
620
  function writeNumber(state, val) {
620
621
  return state.buf.push(val + ""), !0;
@@ -703,7 +704,7 @@ function writeArray(state, val, ref) {
703
704
  return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
704
705
  }
705
706
  function writeDate(state, val) {
706
- return state.buf.push("new Date(\"" + val.toISOString() + "\")"), !0;
707
+ return state.buf.push("new Date(" + +val + ")"), !0;
707
708
  }
708
709
  function writeRegExp(state, val) {
709
710
  return state.buf.push(val + ""), !0;
@@ -716,22 +717,37 @@ function writePromise(state, val, ref) {
716
717
  }
717
718
  function writeMap(state, val, ref) {
718
719
  if (!val.size) return state.buf.push("new Map"), !0;
719
- let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state)), items = [], assigns, i = 0;
720
+ let items = [], assigns, needsId, i = 0;
720
721
  if (val.size < 25) {
721
- for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
722
- assigns ? state.buf.push("((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "=") : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
722
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
723
+ writeArrayArg(state, ref, items, assigns && "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
723
724
  } else {
724
- for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
725
- assigns ? state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "=") : state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
725
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemKey, itemValue);
726
+ writeArrayArg(state, ref, items, assigns && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
726
727
  }
727
728
  return !0;
728
729
  }
729
730
  function writeSet(state, val, ref) {
730
731
  if (!val.size) return state.buf.push("new Set"), !0;
731
- let items = [], assigns, i = 0;
732
- for (let item of val) item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
733
- let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
734
- return state.buf.push((assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
732
+ let items = [], assigns, needsId, i = 0;
733
+ for (let item of val) item === val ? (item = 0, (assigns ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
734
+ return writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
735
+ }
736
+ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
737
+ if (assignsPrefix || needsId) {
738
+ let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
739
+ state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "="), writeArray(state, items, arrayRef);
740
+ } else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.flush, state.buf.length));
741
+ state.buf.push(")");
742
+ }
743
+ function isDedupedMember(val) {
744
+ switch (typeof val) {
745
+ case "object": return val !== null;
746
+ case "function":
747
+ case "symbol": return !0;
748
+ case "string": return val.length > 12;
749
+ default: return !1;
750
+ }
735
751
  }
736
752
  function writeArrayBuffer(state, val) {
737
753
  let result;
@@ -831,20 +847,12 @@ function writeObjectProps(state, val, ref) {
831
847
  state.buf.push(sep + escapedKey + ":"), writeProp(state, val[key], ref, escapedKey) ? sep = "," : state.buf.pop();
832
848
  }
833
849
  if (hasSymbolIterator(val)) {
834
- let iterArr = [...val];
835
- switch (iterArr.length) {
836
- case 0:
837
- state.buf.push(sep + "*[Symbol.iterator](){}");
838
- break;
839
- case 1:
840
- state.buf.push(sep + "*[Symbol.iterator](){yield " + (iterArr[0] === val ? "this" : ensureId(state, ref)) + "}");
841
- break;
842
- default: {
843
- let iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
844
- state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){yield*" + iterRef.id + "}");
845
- break;
846
- }
847
- }
850
+ let yieldSelf = "", iterArr = [];
851
+ for (let item of val) item === val && !(yieldSelf || iterArr.length) ? yieldSelf = "yield this;" : iterArr.push(item);
852
+ if (iterArr.length) {
853
+ let iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
854
+ state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
855
+ } else state.buf.push(sep + "*[Symbol.iterator](){" + yieldSelf.slice(0, -1) + "}");
848
856
  sep = ",";
849
857
  }
850
858
  return sep;
@@ -1062,7 +1070,7 @@ function _serialize_if(condition, key) {
1062
1070
  return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1063
1071
  }
1064
1072
  function _serialize_guard(condition, key) {
1065
- return condition && (condition === 1 || condition[key]) ? 1 : 0;
1073
+ return _serialize_if(condition, key) || 0;
1066
1074
  }
1067
1075
  function _el_resume(scopeId, accessor, shouldResume) {
1068
1076
  if (shouldResume === 0) return "";
@@ -1093,64 +1101,42 @@ function withIsAsync(cb, value) {
1093
1101
  return withContext(kIsAsync, !0, cb, value);
1094
1102
  }
1095
1103
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1096
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1097
- if (serializeBranch !== 0) {
1098
- let loopScopes;
1099
- forOf(list, (item, index) => {
1100
- let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1101
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1102
- cb(item, index);
1103
- let branchScope = writeScope(branchId, {});
1104
- resumeKeys && itemKey !== index && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1105
- });
1106
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1107
- } else forOf(list, cb);
1108
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1104
+ forBranches(by, (each) => each ? forOf(list, (item, index) => {
1105
+ let itemKey = forOfBy(by, item, index);
1106
+ each(itemKey, itemKey === index, () => cb(item, index));
1107
+ }) : forOf(list, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1109
1108
  }
1110
1109
  function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1111
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1112
- if (serializeBranch !== 0) {
1113
- let loopScopes;
1114
- forIn(obj, (key, value) => {
1115
- let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1116
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1117
- cb(key, value);
1118
- let branchScope = writeScope(branchId, {});
1119
- resumeKeys && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1120
- });
1121
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1122
- } else forIn(obj, cb);
1123
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1110
+ forBranches(by, (each) => each ? forIn(obj, (key, value) => {
1111
+ each(forInBy(by, key, value), !1, () => cb(key, value));
1112
+ }) : forIn(obj, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1124
1113
  }
1125
1114
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1126
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1127
- if (serializeBranch !== 0) {
1128
- let loopScopes;
1129
- forTo(to, from, step, (i) => {
1130
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1131
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1132
- cb(i);
1133
- let branchScope = writeScope(branchId, {});
1134
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1135
- });
1136
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1137
- } else forTo(to, from, step, cb);
1138
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1115
+ forBranches(by, (each) => each ? forTo(to, from, step, (i) => {
1116
+ let itemKey = forStepBy(by, i);
1117
+ each(itemKey, itemKey === i, () => cb(i));
1118
+ }) : forTo(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1139
1119
  }
1140
1120
  function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1141
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1142
- if (serializeBranch !== 0) {
1143
- let loopScopes;
1144
- forUntil(to, from, step, (i) => {
1145
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1146
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1147
- cb(i);
1148
- let branchScope = writeScope(branchId, {});
1149
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1150
- });
1151
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1152
- } else forUntil(to, from, step, cb);
1153
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1121
+ forBranches(by, (each) => each ? forUntil(to, from, step, (i) => {
1122
+ let itemKey = forStepBy(by, i);
1123
+ each(itemKey, itemKey === i, () => cb(i));
1124
+ }) : forUntil(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1125
+ }
1126
+ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1127
+ if (serializeBranch === 0) {
1128
+ iterate(0), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, "");
1129
+ return;
1130
+ }
1131
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "", loopScopes;
1132
+ iterate((itemKey, sameAsIndex, render) => {
1133
+ let branchId = _peek_scope_id();
1134
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1135
+ render();
1136
+ let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
1137
+ resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1138
+ });
1139
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1154
1140
  }
1155
1141
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1156
1142
  let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id();
@@ -1385,7 +1371,7 @@ var State = class {
1385
1371
  }
1386
1372
  flushScript() {
1387
1373
  let { boundary, effects } = this, { state } = boundary, { $global, runtimePrefix, nonceAttr } = state, { html, scripts } = this, needsWalk = state.walkOnNextFlush;
1388
- if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}}),self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), state.ensureReady && state.hasMainRuntime) {
1374
+ if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), state.ensureReady && state.hasMainRuntime) {
1389
1375
  let first = !0;
1390
1376
  for (let id in state.ensureReady) state.ensureReady[id] && (state.ensureReady[id] = 0, scripts = first ? concatScripts(scripts, "(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1") : concatScripts(scripts, runtimePrefix + ".b" + toAccess(toObjectKey(id)) + "=1")), first = !1;
1391
1377
  }
package/dist/html.mjs CHANGED
@@ -609,11 +609,12 @@ function writeRegistered(state, val, parent, accessor, registered) {
609
609
  return !0;
610
610
  }
611
611
  function writeString(state, val, parent, accessor) {
612
- if (val.length > 30) {
612
+ if (val.length > 12) {
613
613
  let ref = state.strs.get(val);
614
- ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(val, new Reference(parent, accessor, state.flush, state.buf.length)), state.buf.push(quote(val, 0)));
615
- } else state.buf.push(quote(val, 0));
616
- return !0;
614
+ if (ref) return state.buf.push(ensureId(state, ref)), !0;
615
+ state.strs.set(val, new Reference(parent, accessor, state.flush, state.buf.length));
616
+ }
617
+ return state.buf.push(quote(val, 0)), !0;
617
618
  }
618
619
  function writeNumber(state, val) {
619
620
  return state.buf.push(val + ""), !0;
@@ -702,7 +703,7 @@ function writeArray(state, val, ref) {
702
703
  return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
703
704
  }
704
705
  function writeDate(state, val) {
705
- return state.buf.push("new Date(\"" + val.toISOString() + "\")"), !0;
706
+ return state.buf.push("new Date(" + +val + ")"), !0;
706
707
  }
707
708
  function writeRegExp(state, val) {
708
709
  return state.buf.push(val + ""), !0;
@@ -715,22 +716,37 @@ function writePromise(state, val, ref) {
715
716
  }
716
717
  function writeMap(state, val, ref) {
717
718
  if (!val.size) return state.buf.push("new Map"), !0;
718
- let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state)), items = [], assigns, i = 0;
719
+ let items = [], assigns, needsId, i = 0;
719
720
  if (val.size < 25) {
720
- for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
721
- assigns ? state.buf.push("((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "=") : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
721
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
722
+ writeArrayArg(state, ref, items, assigns && "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
722
723
  } else {
723
- for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
724
- assigns ? state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "=") : state.buf.push("(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
724
+ for (let [itemKey, itemValue] of val) itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemKey, itemValue);
725
+ writeArrayArg(state, ref, items, assigns && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
725
726
  }
726
727
  return !0;
727
728
  }
728
729
  function writeSet(state, val, ref) {
729
730
  if (!val.size) return state.buf.push("new Set"), !0;
730
- let items = [], assigns, i = 0;
731
- for (let item of val) item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
732
- let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
733
- return state.buf.push((assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
731
+ let items = [], assigns, needsId, i = 0;
732
+ for (let item of val) item === val ? (item = 0, (assigns ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
733
+ return writeArrayArg(state, ref, items, assigns && "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
734
+ }
735
+ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
736
+ if (assignsPrefix || needsId) {
737
+ let arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
738
+ state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "="), writeArray(state, items, arrayRef);
739
+ } else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.flush, state.buf.length));
740
+ state.buf.push(")");
741
+ }
742
+ function isDedupedMember(val) {
743
+ switch (typeof val) {
744
+ case "object": return val !== null;
745
+ case "function":
746
+ case "symbol": return !0;
747
+ case "string": return val.length > 12;
748
+ default: return !1;
749
+ }
734
750
  }
735
751
  function writeArrayBuffer(state, val) {
736
752
  let result;
@@ -830,20 +846,12 @@ function writeObjectProps(state, val, ref) {
830
846
  state.buf.push(sep + escapedKey + ":"), writeProp(state, val[key], ref, escapedKey) ? sep = "," : state.buf.pop();
831
847
  }
832
848
  if (hasSymbolIterator(val)) {
833
- let iterArr = [...val];
834
- switch (iterArr.length) {
835
- case 0:
836
- state.buf.push(sep + "*[Symbol.iterator](){}");
837
- break;
838
- case 1:
839
- state.buf.push(sep + "*[Symbol.iterator](){yield " + (iterArr[0] === val ? "this" : ensureId(state, ref)) + "}");
840
- break;
841
- default: {
842
- let iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
843
- state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){yield*" + iterRef.id + "}");
844
- break;
845
- }
846
- }
849
+ let yieldSelf = "", iterArr = [];
850
+ for (let item of val) item === val && !(yieldSelf || iterArr.length) ? yieldSelf = "yield this;" : iterArr.push(item);
851
+ if (iterArr.length) {
852
+ let iterRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
853
+ state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
854
+ } else state.buf.push(sep + "*[Symbol.iterator](){" + yieldSelf.slice(0, -1) + "}");
847
855
  sep = ",";
848
856
  }
849
857
  return sep;
@@ -1061,7 +1069,7 @@ function _serialize_if(condition, key) {
1061
1069
  return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1062
1070
  }
1063
1071
  function _serialize_guard(condition, key) {
1064
- return condition && (condition === 1 || condition[key]) ? 1 : 0;
1072
+ return _serialize_if(condition, key) || 0;
1065
1073
  }
1066
1074
  function _el_resume(scopeId, accessor, shouldResume) {
1067
1075
  if (shouldResume === 0) return "";
@@ -1092,64 +1100,42 @@ function withIsAsync(cb, value) {
1092
1100
  return withContext(kIsAsync, !0, cb, value);
1093
1101
  }
1094
1102
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1095
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1096
- if (serializeBranch !== 0) {
1097
- let loopScopes;
1098
- forOf(list, (item, index) => {
1099
- let branchId = _peek_scope_id(), itemKey = forOfBy(by, item, index);
1100
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1101
- cb(item, index);
1102
- let branchScope = writeScope(branchId, {});
1103
- resumeKeys && itemKey !== index && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1104
- });
1105
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1106
- } else forOf(list, cb);
1107
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1103
+ forBranches(by, (each) => each ? forOf(list, (item, index) => {
1104
+ let itemKey = forOfBy(by, item, index);
1105
+ each(itemKey, itemKey === index, () => cb(item, index));
1106
+ }) : forOf(list, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1108
1107
  }
1109
1108
  function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1110
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1111
- if (serializeBranch !== 0) {
1112
- let loopScopes;
1113
- forIn(obj, (key, value) => {
1114
- let branchId = _peek_scope_id(), itemKey = forInBy(by, key, value);
1115
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1116
- cb(key, value);
1117
- let branchScope = writeScope(branchId, {});
1118
- resumeKeys && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1119
- });
1120
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1121
- } else forIn(obj, cb);
1122
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1109
+ forBranches(by, (each) => each ? forIn(obj, (key, value) => {
1110
+ each(forInBy(by, key, value), !1, () => cb(key, value));
1111
+ }) : forIn(obj, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1123
1112
  }
1124
1113
  function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1125
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1126
- if (serializeBranch !== 0) {
1127
- let loopScopes;
1128
- forTo(to, from, step, (i) => {
1129
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1130
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1131
- cb(i);
1132
- let branchScope = writeScope(branchId, {});
1133
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1134
- });
1135
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1136
- } else forTo(to, from, step, cb);
1137
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1114
+ forBranches(by, (each) => each ? forTo(to, from, step, (i) => {
1115
+ let itemKey = forStepBy(by, i);
1116
+ each(itemKey, itemKey === i, () => cb(i));
1117
+ }) : forTo(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1138
1118
  }
1139
1119
  function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1140
- let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "";
1141
- if (serializeBranch !== 0) {
1142
- let loopScopes;
1143
- forUntil(to, from, step, (i) => {
1144
- let branchId = _peek_scope_id(), itemKey = forStepBy(by, i);
1145
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1146
- cb(i);
1147
- let branchScope = writeScope(branchId, {});
1148
- resumeKeys && itemKey !== i && (branchScope.M = itemKey), resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1149
- });
1150
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes });
1151
- } else forUntil(to, from, step, cb);
1152
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1120
+ forBranches(by, (each) => each ? forUntil(to, from, step, (i) => {
1121
+ let itemKey = forStepBy(by, i);
1122
+ each(itemKey, itemKey === i, () => cb(i));
1123
+ }) : forUntil(to, from, step, cb), scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode);
1124
+ }
1125
+ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1126
+ if (serializeBranch === 0) {
1127
+ iterate(0), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, "");
1128
+ return;
1129
+ }
1130
+ let { state } = $chunk.boundary, resumeKeys = serializeMarker !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), flushBranchIds = "", loopScopes;
1131
+ iterate((itemKey, sameAsIndex, render) => {
1132
+ let branchId = _peek_scope_id();
1133
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1134
+ render();
1135
+ let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
1136
+ resumeMarker || (loopScopes = push(loopScopes, referenceScope(branchScope)));
1137
+ });
1138
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1153
1139
  }
1154
1140
  function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1155
1141
  let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id();
@@ -1384,7 +1370,7 @@ var State = class {
1384
1370
  }
1385
1371
  flushScript() {
1386
1372
  let { boundary, effects } = this, { state } = boundary, { $global, runtimePrefix, nonceAttr } = state, { html, scripts } = this, needsWalk = state.walkOnNextFlush;
1387
- if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}}),self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), state.ensureReady && state.hasMainRuntime) {
1373
+ if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), state.ensureReady && state.hasMainRuntime) {
1388
1374
  let first = !0;
1389
1375
  for (let id in state.ensureReady) state.ensureReady[id] && (state.ensureReady[id] = 0, scripts = first ? concatScripts(scripts, "(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1") : concatScripts(scripts, runtimePrefix + ".b" + toAccess(toObjectKey(id)) + "=1")), first = !1;
1390
1376
  }