import{aF as q,k as A,d as F,r as g,aG as H,m as J,q as b,aH as K,o as L,K as O,J as Q,b as s,Y,B as z,A as E,y as I,Q as x,au as M,P as N,G as R,__tla as U}from"./index-WdVqRR-9.js";let _,D=Promise.all([(()=>{try{return U}catch(h){}})()]).then(async()=>{const h=Symbol(),T=()=>q(h,null),[k,e,y]=A("list"),B={error:Boolean,offset:Y(300),loading:Boolean,disabled:Boolean,finished:Boolean,scroller:Object,errorText:String,direction:z("down"),loadingText:String,finishedText:String,immediateCheck:E};var S=F({name:k,props:B,emits:["load","update:error","update:loading"],setup(a,{emit:u,slots:i}){const l=g(a.loading),c=g(),v=g(),n=T(),C=H(c),m=J(()=>a.scroller||C.value),t=()=>{I(()=>{if(l.value||a.finished||a.disabled||a.error||(n==null?void 0:n.value)===!1)return;const{direction:r}=a,d=+a.offset,o=x(m);if(!o.height||M(c))return;let f=!1;const p=x(v);r==="up"?f=o.top-p.top<=d:f=p.bottom-o.bottom<=d,f&&(l.value=!0,u("update:loading",!0),u("load"))})},w=()=>{if(a.finished){const r=i.finished?i.finished():a.finishedText;if(r)return s("div",{class:e("finished-text")},[r])}},G=()=>{u("update:error",!1),t()},P=()=>{if(a.error){const r=i.error?i.error():a.errorText;if(r)return s("div",{role:"button",class:e("error-text"),tabindex:0,onClick:G},[r])}},j=()=>{if(l.value&&!a.finished&&!a.disabled)return s("div",{class:e("loading")},[i.loading?i.loading():s(N,{class:e("loading-icon")},{default:()=>[a.loadingText||y("loading")]})])};return b(()=>[a.loading,a.finished,a.error],t),n&&b(n,r=>{r&&t()}),K(()=>{l.value=a.loading}),L(()=>{a.immediateCheck&&t()}),O({check:t}),Q("scroll",t,{target:m,passive:!0}),()=>{var r;const d=(r=i.default)==null?void 0:r.call(i),o=s("div",{ref:v,class:e("placeholder")},null);return s("div",{ref:c,role:"feed",class:e(),"aria-busy":l.value},[a.direction==="down"?d:o,j(),w(),P(),a.direction==="up"?d:o])}}});_=R(S)});export{_ as L,D as __tla};
