import{Q as e,S as s,T as t,V as r}from"./main-dc658e23.js";import{b as l,d as n,u as o,m as i,c as a}from"./c.74781bd9.js";const u=(e,s,t)=>{const r=new Map;for(let l=s;l<=t;l++)r.set(e[l],l);return r},f=e(class extends s{constructor(e){if(super(e),e.type!==t.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,s,t){let r;void 0===t?t=s:void 0!==s&&(r=s);const l=[],n=[];let o=0;for(const s of e)l[o]=r?r(s,o):o,n[o]=t(s,o),o++;return{values:n,keys:l}}render(e,s,t){return this.dt(e,s,t).values}update(e,[s,t,f]){var c;const d=l(e),{values:h,keys:p}=this.dt(s,t,f);if(!Array.isArray(d))return this.at=p,h;const v=null!==(c=this.at)&&void 0!==c?c:this.at=[],y=[];let m,x,b=0,g=d.length-1,j=0,k=h.length-1;for(;b<=g&&j<=k;)if(null===d[b])b++;else if(null===d[g])g--;else if(v[b]===p[j])y[j]=n(d[b],h[j]),b++,j++;else if(v[g]===p[k])y[k]=n(d[g],h[k]),g--,k--;else if(v[b]===p[k])y[k]=n(d[b],h[k]),o(e,y[k+1],d[b]),b++,k--;else if(v[g]===p[j])y[j]=n(d[g],h[j]),o(e,d[b],d[g]),g--,j++;else if(void 0===m&&(m=u(p,j,k),x=u(v,b,g)),m.has(v[b]))if(m.has(v[g])){const s=x.get(p[j]),t=void 0!==s?d[s]:null;if(null===t){const s=o(e,d[b]);n(s,h[j]),y[j]=s}else y[j]=n(t,h[j]),o(e,d[b],t),d[s]=null;j++}else i(d[g]),g--;else i(d[b]),b++;for(;j<=k;){const s=o(e,y[k+1]);n(s,h[j]),y[j++]=s}for(;b<=g;){const e=d[b++];null!==e&&i(e)}return this.at=p,a(e,y),r}});export{f as c};
