import{d as e}from"./vendor-CB_mu4eO.js";import{R as a,m as t,f as n,P as l,S as u,E as o,U as i}from"./souav-BTAG2baT.js";import{v as s}from"./vendor-BAqn-6d_.js";import{r as v,c}from"./vendor-BXdGExd0.js";const r=e("myDrama",()=>{const e=v(0),r=v([[],[]]),f=v([a.loading,a.loading]),d=v([!0,!0]),m=v([0,0]),p=v(0),g=v(!0),h=v(t.ok),T=v(!1),y=v(5);let w=null,S=null,k=3;const L=v(!1),I=v(!1),b=n(),j=c(()=>r.value[e.value]||[]),C=c(()=>{if(j.value&&0!==j.value.length)return j.value[p.value]});async function D(e=!1){const a={pageNo:m.value[0],pageSize:10};await N(0,s.getShortLikes,a,e)}async function E(e=!1){const a={pageNo:m.value[1],pageSize:10};await N(1,s.getShortCollects,a,e)}async function N(e,t,n,l){try{const u=await t(n),{code:i,data:s}=u;if(i===o.Success){const t=(null==s?void 0:s.likeList)??(null==s?void 0:s.collectList)??[],n=t.length>=10;l?r.value[e].push(...t):(r.value[e]=t,f.value[e]=0===t.length?a.EmptyData:a.success),d.value[e]=n}else l||(f.value[e]=a.NetError)}catch(u){l||(f.value[e]=a.NetError)}finally{L.value=!1,I.value=!1,f.value[e]=a.success}}async function P(){const a=e.value;L.value=!0,d.value[a]=!0,m.value[a]=0,0===a?await D():await E()}async function R(){const a=e.value;d.value[a]&&(I.value=!0,m.value[a]++,0===a?await D(!0):await E(!0))}function x(a){p.value=a;const n=C.value;if(!n)return;n.contentType===u.ad?(g.value=!1,function(e){var a;w&&clearTimeout(w);y.value=(null==(a=C.value)?void 0:a.duration)??5;const t=()=>{y.value>0?(y.value--,w=setTimeout(t,1e3)):e()};w=setTimeout(t,1e3)}(()=>{g.value=!0})):g.value=!0,async function(e){h.value=t.ok,T.value=!1,S&&clearTimeout(S);const a=j.value[e];if(!a||a.contentType===u.ad)return;async function n(){var l;if(k<=0)return;const u=await s.reportShortView({contentId:a.contentId});if(e!==p.value)return;const{code:v,data:c}=u;if(v==o.Success){h.value=(null==(l=u.data)?void 0:l.limitReason)??t.ok;a.unlockType===i.vip&&b.isVip&&function(){if(T.value)return;T.value=!0,S&&clearTimeout(S);S=setTimeout(()=>{T.value=!1},5e3)}()}else await new Promise(e=>setTimeout(e,500)),k--,n()}k=3,await n()}(a);const l=e.value;a>=j.value.length-2&&d.value[l]&&!I.value&&R()}return{activeTab:e,tabs:["喜欢的","收藏的"],dataTabList:r,refreshStatusList:f,hasMoreList:d,refreshing:L,loading:I,pageIndex:p,isAllowScroll:g,playReason:h,isShowVipTip:T,currentList:j,currentSource:C,initData:function(){0===r.value[0].length&&P()},cleanup:function(){w&&clearTimeout(w),S&&clearTimeout(S)},onTabChange:function(t){e.value=t,0===r.value[t].length&&f.value[t]===a.loading&&P()},onRefresh:P,onLoadMore:R,onClickItem:function(e){const a=j.value.findIndex(a=>a.contentId===e.contentId);-1!==a&&x(a),l.open("MyDramaPop",{props:e,transition:"slide-fade"})},onPageChange:x,reset:function(){w&&(clearTimeout(w),w=null),S&&(clearTimeout(S),S=null),e.value=0,r.value=[[],[]],f.value=[a.loading,a.loading],d.value=[!0,!0],m.value=[0,0],p.value=0,g.value=!0,h.value=t.ok,T.value=!1,L.value=!1,I.value=!1,y.value=5,k=3}}});export{r as u};
