import{j as w,ak as B,n as C,v as E,d as L,i as g,az as R,w as m,aA as N,o as y,ag as _,g as r,y as j,Y as b,aB as z,$ as A,al as D,D as F}from"./index-8911ca98.js";import{u as H}from"./use-tab-status-5da328dc.js";const[I,o,M]=w("list"),U={error:Boolean,offset:B(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:E};var V=L({name:I,props:U,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=g(e.loading),u=g(),h=g(),s=H(),v=R(u),n=()=>{j(()=>{if(d.value||e.finished||e.disabled||e.error||(s==null?void 0:s.value)===!1)return;const{direction:t}=e,l=+e.offset,i=b(v);if(!i.height||z(u))return;let f=!1;const x=b(h);t==="up"?f=i.top-x.top<=l:f=x.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},T=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},k=()=>{c("update:error",!1),n()},P=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return r("div",{role:"button",class:o("error-text"),tabindex:0,onClick:k},[t])}},S=()=>{if(d.value&&!e.finished&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(A,{class:o("loading-icon")},{default:()=>[e.loadingText||M("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),y(()=>{e.immediateCheck&&n()}),D({check:n}),_("scroll",n,{target:v,passive:!0}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:h,class:o("placeholder")},null);return r("div",{ref:u,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,S(),T(),P(),e.direction==="up"?l:i])}}});const q=F(V);export{q as L};
