@funhub/platform 0.1.156 → 0.1.158

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.
@@ -1,2 +1,2 @@
1
1
 
2
- "use client";import{cn as e}from"../../../../../utils/cn.mjs";import{useFollowIdsState as t}from"../../../../../store/modules/follow-ids-store.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{followUser as r,unfollowUser as i}from"../../../../../utils/follow-service.mjs";import a from"../../../../../assets/icons/common/follow_sel.mjs";import o from"../../../../../assets/icons/common/follow_user.mjs";import{UnfollowConfirmDialog as s}from"../../../../common/follow-button/unfollow-confirm-dialog.mjs";import{useEffect as c,useState as l}from"react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";import{useTranslations as p}from"next-intl";function m({information:e,onUpdate:a}){let{userId:o,userInfo:p}=n(),m=o||p?.userId||``,g=e.author,_=e.up_user||g?.user_id||``,v=!!(m&&_&&m===_),[y,b]=l(!!e.is_followed),[x,S]=l(!1),[C,w]=l(!1);c(()=>{b(!!e.is_followed)},[e.id,e.is_followed]);async function T(){if(!_){console.warn(`用户信息不完整,无法执行关注操作`);return}w(!0);let e=!y;try{let n;if(n=e?await r({app_id:0,follower_id:m,followee_id:_}):await i({app_id:0,follower_id:m,followee_id:_}),n.success){b(e),a({is_followed:e});let{followIds:n,setFollowIds:r}=t.getState(),i=new Set(n);e?i.add(_):i.delete(_),r(Array.from(i))}else console.error(`关注操作失败:`,n.message)}catch(e){console.error(`关注操作异常:`,e)}finally{w(!1)}}function E(){if(!C){if(y){S(!0);return}T()}}function D(){S(!1),T()}function O(){S(!1)}return f(u,{children:[e.up_user&&_&&!v?d(h,{followed:y,loading:C,onToggle:E}):null,d(s,{open:x,onOpenChange:S,onCancel:O,onConfirm:D})]})}function h({followed:t,loading:n=!1,onToggle:r}){let i=p(`components.biz.business.detail`);return d(`button`,{type:`button`,disabled:n,className:e(`flex h-7 items-center rounded-full border border-solid px-3 text-xs font-medium transition-colors`,n&&`opacity-50 cursor-not-allowed`,t?`border-text3 text-text3`:`border-theme5 text-theme5`),onClick:r,children:t?f(u,{children:[d(a,{className:`w-[12px] h-[12px] text-text3 shrink-0`}),d(`span`,{className:`text-text3 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.following`)})]}):f(u,{children:[d(o,{className:`block w-[12px] h-[12px] text-theme5 shrink-0`}),d(`span`,{className:`block text-theme5 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.follow`)})]})})}export{m as DetailFollowAction};
2
+ "use client";import{cn as e}from"../../../../../utils/cn.mjs";import{useFollowIdsState as t}from"../../../../../store/modules/follow-ids-store.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{followUser as r,unfollowUser as i}from"../../../../../utils/follow-service.mjs";import{useLoginModalStore as a}from"../../../../../store/modules/login-modal-store.mjs";import o from"../../../../../assets/icons/common/follow_sel.mjs";import s from"../../../../../assets/icons/common/follow_user.mjs";import{UnfollowConfirmDialog as c}from"../../../../common/follow-button/unfollow-confirm-dialog.mjs";import{useEffect as l,useState as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";function h({information:e,onUpdate:o}){let{isLogin:s,userId:m,userInfo:h}=n(),_=m||h?.userId||``,v=e.author,y=e.up_user||v?.user_id||``,b=!!(_&&y&&_===y),[x,S]=u(!!e.is_followed),[C,w]=u(!1),[T,E]=u(!1);l(()=>{S(!!e.is_followed)},[e.id,e.is_followed]);async function D(){if(!s||!_){a.getState().open();return}if(!y){console.warn(`用户信息不完整,无法执行关注操作`);return}E(!0);let e=!x;try{let n;if(n=e?await r({app_id:0,follower_id:_,followee_id:y}):await i({app_id:0,follower_id:_,followee_id:y}),n.success){S(e),o({is_followed:e});let{followIds:n,setFollowIds:r}=t.getState(),i=new Set(n);e?i.add(y):i.delete(y),r(Array.from(i))}else console.error(`关注操作失败:`,n.message)}catch(e){console.error(`关注操作异常:`,e)}finally{E(!1)}}function O(){if(!T){if(!s||!_){a.getState().open();return}if(x){w(!0);return}D()}}function k(){w(!1),D()}function A(){w(!1)}return p(d,{children:[e.up_user&&y&&!b?f(g,{followed:x,loading:T,onToggle:O}):null,f(c,{open:C,onOpenChange:w,onCancel:A,onConfirm:k})]})}function g({followed:t,loading:n=!1,onToggle:r}){let i=m(`components.biz.business.detail`);return f(`button`,{type:`button`,disabled:n,className:e(`flex h-7 items-center rounded-full border border-solid px-3 text-xs font-medium transition-colors`,n&&`opacity-50 cursor-not-allowed`,t?`border-text3 text-text3`:`border-theme5 text-theme5`),onClick:r,children:t?p(d,{children:[f(o,{className:`w-[12px] h-[12px] text-text3 shrink-0`}),f(`span`,{className:`text-text3 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.following`)})]}):p(d,{children:[f(s,{className:`block w-[12px] h-[12px] text-theme5 shrink-0`}),f(`span`,{className:`block text-theme5 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.follow`)})]})})}export{h as DetailFollowAction};
@@ -1,2 +1,2 @@
1
1
 
2
- "use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{gContentGetVideoDetail as t,pInteractionBrowse as n}from"../../../../../service/generated/client.mjs";import{uint8ArrayToBase64 as r}from"../../../../../utils/uint8.mjs";import{resolveM3u8Urls as i,resolveVideoPlayerSrc as a}from"../../../../common/video-player/process-m3u8-cache.mjs";import{batchQueryContentInteractions as o}from"../../../../../hooks/use-content-operate.mjs";import{useCallback as s,useEffect as c,useRef as l}from"react";import{usePathname as u}from"next/navigation";import{useQueryClient as d}from"@tanstack/react-query";const f=new Map,p=new Map;function m(e){let t=Math.floor(Number(e)||1);return t>0?t:1}function h(e){let t=typeof e==`string`?e:typeof window>`u`?``:window.location.pathname,n=String(t||``).split(`/`).filter(Boolean),r=n.findIndex(e=>e===`video`||e===`webview`);if(r<0)return{detailId:``,currentSeriesNum:1,episodeIndex:0};let i=n[r+1]||``;try{let e=decodeURIComponent(i),t=n.slice(r+1),a=t.findIndex(e=>e===`episode`),o=m(a>=0?t[a+1]:t[2]);return{detailId:e,currentSeriesNum:o,episodeIndex:Math.max(0,o-1)}}catch{let e=n.slice(r+1),t=e.findIndex(e=>e===`episode`),a=m(t>=0?e[t+1]:e[2]);return{detailId:i,currentSeriesNum:a,episodeIndex:Math.max(0,a-1)}}}function g(e){for(;e.size>5;){let t=e.keys().next().value;if(!t)break;e.delete(t)}}function _(e){let t=e,n=t?.data?.video||t?.video||t;if(!(!n||typeof n!=`object`))return{...n,content_type:1,episode_cnt:n.links?.length||0}}function v(e){let t=String(e||``).trim();return t?[[`video-detail`,t]]:[]}function y(m){let{enabled:y=!0}=m,b=d(),x=h(u()).detailId,S=l({detailId:``}),C=l(null),w=l(new Map),T=l(new Map);c(()=>{S.current={detailId:x},C.current=null},[x]);let E=s(async e=>{let n=Date.now(),r=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),i=r(),a=String(e||``).trim(),o=`empty-id`,s=!1,c=0,l=!1,u=0;if(!a){o=`empty-id`;return}if(S.current.detailId===a&&S.current.information){o=`cache`;let e=S.current.information;return l=!0,u=Array.isArray(e?.links)?e.links.length:0,e}let d=f.get(a);if(d)return o=`shared-cache`,S.current={detailId:a,information:d},l=!0,u=Array.isArray(d?.links)?d.links.length:0,d;let m=v(a).map(e=>b.getQueryData(e)).map(_).find(Boolean);if(m)return o=`query-cache`,S.current={detailId:a,information:m},f.set(a,m),l=!0,u=Array.isArray(m?.links)?m.links.length:0,m;if(C.current?.detailId===a){o=`inflight`;let e=r(),t=await C.current.promise;return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t}if(p.has(a)){o=`shared-inflight`;let e=r(),t=await p.get(a);return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t&&(S.current={detailId:a,information:t}),t}o=`network`;let h=r(),g=t({id:a}).then(e=>{let t=_(e);if(t)return S.current={detailId:a,information:t},f.set(a,t),t});C.current={detailId:a,promise:g},p.set(a,g);try{let e=await g;return c=Number((r()-h).toFixed(1)),l=!!e,u=Array.isArray(e?.links)?e.links.length:0,e||(o=`network-empty`),e}catch(e){throw s=!0,e}finally{let e=Number((r()-i).toFixed(1));console.warn(`[webview bridge] fetchVideoDetailInformation timing:`,JSON.stringify({status:s?`error`:`success`,detailId:a,source:o,hasInformation:l,episodeCnt:u,requestMs:c,totalMs:e,invocationWallStartMs:n,invocationWallStartTime:new Date(n).toISOString()})),C.current?.detailId===a&&(C.current=null),p.get(a)===g&&p.delete(a)}},[b]),D=s(async t=>{let n=String(t||``).trim();if(!n)return``;let i=w.current.get(n);if(i)return i;let a=T.current.get(n);if(a)return await a;let o=(async()=>{try{let t=await e(n);if(!t)return``;let i=r(t.bytes);return w.current.delete(n),w.current.set(n,i),g(w.current),i}catch(e){return console.warn(`[webview bridge] getVideoInfoAsync poster failed:`,e),``}finally{T.current.delete(n)}})();return T.current.set(n,o),await o},[]),O=s(async e=>{let t=String(e||``).trim();if(!t)return``;let n=D(t),r,i=new Promise(e=>{r=setTimeout(()=>{e(``)},150)}),a=await Promise.race([n,i]);return r!==void 0&&clearTimeout(r),a},[D]),k=s(async()=>{let e=Date.now(),t=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),n=[],r=e=>{n.push({stage:e,at:t(),wallAtMs:Date.now()})},o=e=>e<=0||e>=n.length?0:Number((n[e].at-n[e-1].at).toFixed(1));r(`start`);let s=``,c=1,l=``,u=0,d=`empty-url`,f=0,p=0,m=0,g=0,_=!1;try{let e;for(let t=0;t<2;t++){u+=1;let t=h();if(e=await E(t.detailId),h().detailId===t.detailId)break}r(`detail-ready`);let t=h(),n=i(Array.isArray(e?.links)?e.links:[],t.currentSeriesNum);r(`m3u8-ready`);let o=n[0]?await a(n[0]):``;r(`src-ready`);let _=e?.name||``,v=String(t.detailId||``).trim(),y=t.currentSeriesNum,b=String(e?.img_y||e?.img_x||e?.preview_images?.[0]||``).trim(),x=await O(b);return r(`poster-ready`),b&&(d=x?`resolved`:`timeout-or-empty`),f=b.length,p=x.length,g=o.length,s=v,c=y,l=_,m=0,{poster:``,src:o,title:_,contentId:v,episode:y}}catch(e){throw _=!0,e}finally{let r=t(),i=n[0]?.at??r,a=n.map((e,t)=>t===0?null:{stage:n[t].stage,costMs:o(t)}).filter(Boolean),h=n.map(e=>({stage:e.stage,offsetMs:Number((e.at-i).toFixed(1)),wallTime:new Date(e.wallAtMs).toISOString()})),v=Number((r-i).toFixed(1));console.warn(`[webview bridge] getVideoInfoAsync timing:`,JSON.stringify({status:_?`error`:`success`,invocationWallStartMs:e,invocationWallStartTime:new Date(e).toISOString(),detailId:s,seriesNum:c,title:l,detailFetchAttempts:u,posterStatus:d,posterUrlLength:f,resolvedPosterLength:p,returnedPosterLength:m,srcLength:g,phases:a,timeline:h,totalMs:v}))}},[E,O]),A=s(async()=>{let e=h();if(!e.detailId)return null;let t=await o([e.detailId],1);return t?.interaction_list?.[0]?t.interaction_list[0].browse_record:null},[]),j=s(async e=>{let t=h();if(!t.detailId)return;let r=e.browse_episode||t.currentSeriesNum,i=Date.now(),a=String(e.browse_key||i);try{await n({app_id:0,content_type:1,content_id:t.detailId,browse_duration:Number(e.browse_duration||0),browse_episode:String(r),browse_key:a,browse_page_ts:i})}catch(e){console.error(`上报播放进度失败:`,e)}},[]);c(()=>{if(!y||typeof window>`u`)return;let e=window;return e.getVideoInfoAsync=k,e.getVideoBrowseRecordAsync=A,e.reportVideoBrowse=j,()=>{e.getVideoInfoAsync===k&&delete e.getVideoInfoAsync,e.getVideoBrowseRecordAsync===A&&delete e.getVideoBrowseRecordAsync,e.reportVideoBrowse===j&&delete e.reportVideoBrowse}},[A,k,y,j])}export{y as useVideoDetailWebViewBridge};
2
+ "use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{useUserStore as t}from"../../../../../store/modules/user-store.mjs";import{gContentGetVideoDetail as n,pInteractionBrowse as r}from"../../../../../service/generated/client.mjs";import{uint8ArrayToBase64 as i}from"../../../../../utils/uint8.mjs";import{resolveM3u8Urls as a,resolveVideoPlayerSrc as o}from"../../../../common/video-player/process-m3u8-cache.mjs";import{useLoginModalStore as s}from"../../../../../store/modules/login-modal-store.mjs";import{batchQueryContentInteractions as c}from"../../../../../hooks/use-content-operate.mjs";import{useCallback as l,useEffect as u,useRef as d}from"react";import{usePathname as f}from"next/navigation";import{useQueryClient as p}from"@tanstack/react-query";const m=new Map,h=new Map;function g(){if(typeof window>`u`)return!1;let e={open:!1};return window.dispatchEvent(new CustomEvent(`funhub:detail-series-popup-query`,{detail:e})),!!e.open}function _(){typeof window>`u`||window.dispatchEvent(new Event(`funhub:detail-series-popup-close`))}function v(e){let t=Math.floor(Number(e)||1);return t>0?t:1}function y(e){let t=typeof e==`string`?e:typeof window>`u`?``:window.location.pathname,n=String(t||``).split(`/`).filter(Boolean),r=n.findIndex(e=>e===`video`||e===`webview`);if(r<0)return{detailId:``,currentSeriesNum:1,episodeIndex:0};let i=n[r+1]||``;try{let e=decodeURIComponent(i),t=n.slice(r+1),a=t.findIndex(e=>e===`episode`),o=v(a>=0?t[a+1]:t[2]);return{detailId:e,currentSeriesNum:o,episodeIndex:Math.max(0,o-1)}}catch{let e=n.slice(r+1),t=e.findIndex(e=>e===`episode`),a=v(t>=0?e[t+1]:e[2]);return{detailId:i,currentSeriesNum:a,episodeIndex:Math.max(0,a-1)}}}function b(e){for(;e.size>5;){let t=e.keys().next().value;if(!t)break;e.delete(t)}}function x(e){let t=e,n=t?.data?.video||t?.video||t;if(!(!n||typeof n!=`object`))return{...n,content_type:1,episode_cnt:n.links?.length||0}}function S(e){let t=String(e||``).trim();return t?[[`video-detail`,t]]:[]}function C(v){let{enabled:C=!0}=v,w=p(),T=y(f()).detailId,E=d({detailId:``}),D=d(null),O=d(new Map),k=d(new Map);u(()=>{E.current={detailId:T},D.current=null},[T]);let A=l(async e=>{let t=Date.now(),r=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),i=r(),a=String(e||``).trim(),o=`empty-id`,s=!1,c=0,l=!1,u=0;if(!a){o=`empty-id`;return}if(E.current.detailId===a&&E.current.information){o=`cache`;let e=E.current.information;return l=!0,u=Array.isArray(e?.links)?e.links.length:0,e}let d=m.get(a);if(d)return o=`shared-cache`,E.current={detailId:a,information:d},l=!0,u=Array.isArray(d?.links)?d.links.length:0,d;let f=S(a).map(e=>w.getQueryData(e)).map(x).find(Boolean);if(f)return o=`query-cache`,E.current={detailId:a,information:f},m.set(a,f),l=!0,u=Array.isArray(f?.links)?f.links.length:0,f;if(D.current?.detailId===a){o=`inflight`;let e=r(),t=await D.current.promise;return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t}if(h.has(a)){o=`shared-inflight`;let e=r(),t=await h.get(a);return c=Number((r()-e).toFixed(1)),l=!!t,u=Array.isArray(t?.links)?t.links.length:0,t&&(E.current={detailId:a,information:t}),t}o=`network`;let p=r(),g=n({id:a}).then(e=>{let t=x(e);if(t)return E.current={detailId:a,information:t},m.set(a,t),t});D.current={detailId:a,promise:g},h.set(a,g);try{let e=await g;return c=Number((r()-p).toFixed(1)),l=!!e,u=Array.isArray(e?.links)?e.links.length:0,e||(o=`network-empty`),e}catch(e){throw s=!0,e}finally{let e=Number((r()-i).toFixed(1));console.warn(`[webview bridge] fetchVideoDetailInformation timing:`,JSON.stringify({status:s?`error`:`success`,detailId:a,source:o,hasInformation:l,episodeCnt:u,requestMs:c,totalMs:e,invocationWallStartMs:t,invocationWallStartTime:new Date(t).toISOString()})),D.current?.detailId===a&&(D.current=null),h.get(a)===g&&h.delete(a)}},[w]),j=l(async t=>{let n=String(t||``).trim();if(!n)return``;let r=O.current.get(n);if(r)return r;let a=k.current.get(n);if(a)return await a;let o=(async()=>{try{let t=await e(n);if(!t)return``;let r=i(t.bytes);return O.current.delete(n),O.current.set(n,r),b(O.current),r}catch(e){return console.warn(`[webview bridge] getVideoInfoAsync poster failed:`,e),``}finally{k.current.delete(n)}})();return k.current.set(n,o),await o},[]),M=l(async e=>{let t=String(e||``).trim();if(!t)return``;let n=j(t),r,i=new Promise(e=>{r=setTimeout(()=>{e(``)},150)}),a=await Promise.race([n,i]);return r!==void 0&&clearTimeout(r),a},[j]),N=l(async()=>{let e=Date.now(),t=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),n=[],r=e=>{n.push({stage:e,at:t(),wallAtMs:Date.now()})},i=e=>e<=0||e>=n.length?0:Number((n[e].at-n[e-1].at).toFixed(1));r(`start`);let s=``,c=1,l=``,u=0,d=`empty-url`,f=0,p=0,m=0,h=0,g=!1;try{let e;for(let t=0;t<2;t++){u+=1;let t=y();if(e=await A(t.detailId),y().detailId===t.detailId)break}r(`detail-ready`);let t=y(),n=a(Array.isArray(e?.links)?e.links:[],t.currentSeriesNum);r(`m3u8-ready`);let i=n[0]?await o(n[0]):``;r(`src-ready`);let g=e?.name||``,_=String(t.detailId||``).trim(),v=t.currentSeriesNum,b=String(e?.img_y||e?.img_x||e?.preview_images?.[0]||``).trim(),x=await M(b);return r(`poster-ready`),b&&(d=x?`resolved`:`timeout-or-empty`),f=b.length,p=x.length,h=i.length,s=_,c=v,l=g,m=0,{poster:``,src:i,title:g,contentId:_,episode:v}}catch(e){throw g=!0,e}finally{let r=t(),a=n[0]?.at??r,o=n.map((e,t)=>t===0?null:{stage:n[t].stage,costMs:i(t)}).filter(Boolean),_=n.map(e=>({stage:e.stage,offsetMs:Number((e.at-a).toFixed(1)),wallTime:new Date(e.wallAtMs).toISOString()})),v=Number((r-a).toFixed(1));console.warn(`[webview bridge] getVideoInfoAsync timing:`,JSON.stringify({status:g?`error`:`success`,invocationWallStartMs:e,invocationWallStartTime:new Date(e).toISOString(),detailId:s,seriesNum:c,title:l,detailFetchAttempts:u,posterStatus:d,posterUrlLength:f,resolvedPosterLength:p,returnedPosterLength:m,srcLength:h,phases:o,timeline:_,totalMs:v}))}},[A,M]),P=l(async()=>{if(!t.getState().isLogin)return null;let e=y();if(!e.detailId)return null;let n=await c([e.detailId],1);return n?.interaction_list?.[0]?n.interaction_list[0].browse_record:null},[]),F=l(async e=>{if(!t.getState().isLogin)return;let n=y();if(!n.detailId)return;let i=e.browse_episode||n.currentSeriesNum,a=Date.now(),o=String(e.browse_key||a);try{await r({app_id:0,content_type:1,content_id:n.detailId,browse_duration:Number(e.browse_duration||0),browse_episode:String(i),browse_key:o,browse_page_ts:a})}catch(e){console.error(`上报播放进度失败:`,e)}},[]),I=l(()=>{let e=s.getState(),t=!!e.isOpen,n=g();return!t&&!n?!0:(t&&e.close(),n&&_(),!1)},[]);u(()=>{if(!C||typeof window>`u`)return;let e=window;return e.getVideoInfoAsync=N,e.getVideoBrowseRecordAsync=P,e.reportVideoProgress=F,e.guardWebViewNavigation=I,()=>{e.getVideoInfoAsync===N&&delete e.getVideoInfoAsync,e.getVideoBrowseRecordAsync===P&&delete e.getVideoBrowseRecordAsync,e.reportVideoProgress===F&&delete e.reportVideoProgress,e.guardWebViewNavigation===I&&delete e.guardWebViewNavigation}},[P,N,I,C,F])}export{C as useVideoDetailWebViewBridge};
@@ -1,2 +1,2 @@
1
1
 
2
- "use client";import{Box as e}from"../../ui/box.mjs";import{Text as t}from"../../ui/text.mjs";import{Sheet as n,SheetContent as r,SheetHeader as i,SheetTitle as a}from"../../ui/sheet.mjs";import{Switch as o}from"../../ui/switch.mjs";import{useKeepAliveState as s}from"../keep-scroll-position/index.mjs";import c from"../../../assets/icons/close.mjs";import l from"../../../assets/icons/common/right_arrow.mjs";import u from"../../ui/popup.mjs";import{useCallback as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{toast as y}from"sonner";import{useTranslations as b}from"next-intl";function x(e,t,n){return(e||[]).map((e,r)=>{let i=Number.parseInt(e?.id||``,10),a=Number.isNaN(i)?r+1:i,o=e?.id||``,s=Number.isNaN(i)&&o||n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:s}})}function S(e,t,n){return(e||[]).map((e,r)=>{let i=Number(e?.id),a=Number.isNaN(i)?r+1:i,o=n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:o}})}function C(e,t,n){return e<=0?n(`singleContent`):n(t===`1`?`completedSeriesTotal`:`ongoingSeriesTotal`,{total:e})}function w(e){return e.mode===`detail`?_(E,{information:e.information,series_num:e.series_num,onEpisodeChange:e.onEpisodeChange}):_(T,{open:e.open,variant:e.variant,title:e.title,updateStatus:e.updateStatus,summaryText:e.summaryText,seriesList:e.seriesList,activeEpisodeId:e.activeEpisodeId,showEpisodeTitle:e.showEpisodeTitle,onToggleTitle:e.onToggleTitle,onClose:e.onClose,onSelectEpisode:e.onSelectEpisode,popupBodyStyle:e.popupBodyStyle})}function T({open:s,variant:l,title:d,updateStatus:g,summaryText:y,seriesList:S,activeEpisodeId:w,showEpisodeTitle:T=!1,onToggleTitle:E,onClose:D,onSelectEpisode:O,popupBodyStyle:k}){let A=b(`components.common.seriesEpisodes`),j=!!E,M=j&&T,N=m(null),P=m(null),F=p(()=>x(S,`episode`,e=>A(`episodeLabel`,{episode:e})),[S,A]),I=p(()=>{if(F.length===0)return[];let e=[];return F.forEach((t,n)=>{let r=Math.floor(n/50);e[r]||(e[r]=[]),e[r].push(t)}),e},[F]),L=p(()=>{if(!w)return 0;let e=F.findIndex(e=>e.id===w);return e<0?0:Math.floor(e/50)},[w,F]),[R,z]=h(L);f(()=>{z(L)},[L]);let B=p(()=>typeof y==`string`&&y.trim()?y:C(F.length,g,A),[F.length,y,A,g]),V=d||A(`selectorTitle`);function H(){let e=N.current;if(e){P.current&&=(window.cancelAnimationFrame(P.current),null),e.scrollTop=0;try{e.scrollTo({top:0,left:0,behavior:`auto`})}catch{}P.current=window.requestAnimationFrame(()=>{P.current=null;let e=N.current;e&&(e.scrollTop=0)})}}f(()=>{s&&H()},[s,T,R]);function U(e){E&&(E(e),H())}function W(e){O?.(e.id,e.series_num),D()}let G=M?2:5,K=I.length>1?_(`div`,{className:`shrink-0 w-full flex gap-[8px] overflow-x-auto`,children:I.map((e,t)=>{if(e.length===0)return null;let n=t===R,r=t*50+1,i=Math.min((t+1)*50,F.length);return v(`div`,{className:`shrink-0 px-[16px] py-[6px] rounded-[16px] text-[14px] transition-colors cursor-pointer relative overflow-hidden ${n?`text-theme5 bg-bg2`:`text-text2 bg-bg2`}`,onClick:()=>{z(t),H()},children:[r,`-`,i,n&&_(`div`,{className:`absolute w-full h-full top-0 left-0 opacity-20 bg-theme5`})]},`series-group-${t}`)})}):null,q=v(`div`,{className:`pb-[8px] flex justify-between`,children:[_(`span`,{className:`text-[16px] text-text1`,children:B}),j&&v(`div`,{className:`flex items-center gap-[4px]`,children:[_(o,{size:`sm`,className:`data-checked:bg-theme5 h-[20px] w-[33px]`,checked:T,onCheckedChange:e=>{U(!!e)}}),_(`button`,{type:`button`,className:`text-[16px] text-text1`,onClick:()=>{U(!T)},children:A(`episodeTitle`)})]})]}),J=_(`div`,{className:`grid w-full gap-2 ${G===2?`grid-cols-2`:`grid-cols-5`}`,children:(I[R]||[]).map((e,t)=>{let n=!!(w&&e.id===w);return _(`button`,{type:`button`,"data-episode-id":e.id,onClick:()=>{W(e)},className:`flex items-center justify-center w-full h-[60px] rounded-[8px] border border-line1 border-solid text-[16px] cursor-pointer select-none transition-colors relative overflow-hidden ${n?`font-bold text-theme5 bg-line1`:`text-text1`} ${M?`h-[72px] px-[10px] text-[14px]`:``} ${t%G===0?``:`border-l-0`}`,children:M?_(`span`,{className:`leading-[22px] line-clamp-2`,children:e.title}):e.series_num},e.id)})});return l===`sheet`?_(n,{open:s,onOpenChange:e=>!e&&D(),children:v(r,{side:`bottom`,showCloseButton:!0,className:`min-h-[50vh] bg-bg1 text-text1 rounded-t-2xl border-t border-white/10`,children:[_(i,{className:`pt-3 pb-0`,children:_(a,{className:`flex items-center justify-between text-lg text-text1`,children:V})}),v(`div`,{className:`px-4 pb-2 flex flex-col gap-3`,children:[K,q]}),_(`div`,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto px-4`,children:J})]})}):_(u,{open:s,onOpenChange:e=>{e||D()},showCloseButton:!1,className:`border-0 bg-transparent p-0`,children:v(e,{className:`w-full flex flex-col bg-bg1 px-[12px] text-text1`,style:{height:`70vh`,...k},children:[v(e,{className:`shrink-0 flex justify-between items-center h-[48px]`,children:[_(t,{className:`text-[16px] font-bold text-text1`,children:V}),_(e,{className:`pl-[12px] h-full flex items-center`,onClick:D,children:_(c,{className:`w-[14px] h-[14px] text-text1 cursor-pointer`})})]}),v(e,{className:`flex-1 h-0 w-full pb-[12px] flex flex-col gap-3`,children:[K,q,_(e,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto`,children:J})]})]})})}function E({information:n,series_num:r,onEpisodeChange:i}){let a=b(`components.common`),[o,c]=s(`detail-series-popup-${n.id}`,!1),[u,x]=s(`detail-series-title-toggle-${n.id}`,!1),[C,w]=s(`detail-series-scroll-left-${n.id}`,null),[E,D]=h(r);f(()=>{D(r)},[n.id,r]);let O=p(()=>S((n.links||[]).map(e=>({id:e.id,name:e.name})),n.id||`episode`,e=>a(`seriesEpisodes.episodeLabel`,{episode:e})),[n.id,n.links,a]),k=n.update_status===`1`?a(`seriesEpisodes.completedSeriesTotal`,{total:n.links.length}):a(`seriesEpisodes.ongoingSeriesUpdatedTo`,{total:n.links.length}),A=p(()=>n.links[E-1]?.id||n.links[0]?.id||``,[n.links,E]),j=m(null),M=m(null),N=m(null),P=m(!1),F=m(null),I=m(null),L=m(null),[R,z]=h(!1),B=d((e,t=`smooth`)=>{let n=j.current?.querySelector(`[data-content-id="${e}"]`);if(n&&j.current){let e=j.current,r=Math.max(0,n.offsetLeft-10);e.scrollTo({left:r,behavior:t})}},[]),V=d(()=>{I.current!==null&&(window.clearTimeout(I.current),I.current=null)},[]),H=d(()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]),U=d(()=>{F.current!==null&&(y.dismiss(F.current),F.current=null),V(),H()},[H,V]),W=d(()=>{M.current=null,N.current=null,U(),z(!1)},[U]),G=d((e,t)=>{H(),L.current=window.setTimeout(()=>{L.current=null,M.current===e&&W()},Math.max(0,t))},[H,W]);f(()=>{P.current=!1},[n.id]),f(()=>{if(P.current||!A)return;let e=window.requestAnimationFrame(()=>{let e=j.current;e&&(typeof C==`number`?e.scrollTo({left:Math.max(0,C),behavior:`auto`}):(B(A,`auto`),w(Math.max(0,Math.round(e.scrollLeft)))),P.current=!0)});return()=>{window.cancelAnimationFrame(e)}},[A,C,B,w]),f(()=>{let e=M.current;!e||e!==r||G(e,1e3)},[G,r]),f(()=>()=>{W()},[W]);let K=d((e,t,n)=>{let r=j.current;if(!r||!e)return t;let i=r.querySelector(`[data-content-id="${e}"]`);if(!i)return t;let a=r.getBoundingClientRect();if(a.width<=0||typeof n!=`number`||(n-a.left)/a.width<.5)return t;let o=i.offsetLeft+i.offsetWidth/2,s=r.clientWidth/2,c=Math.max(0,r.scrollWidth-r.clientWidth),l=Math.min(c,Math.max(0,o-s));return r.scrollTo({left:l,behavior:`smooth`}),Math.round(l)},[]),q=d((e,t=`inline`,o,s)=>{if(e!==E){if(!n.links[e-1]){y.error(a(`seriesEpisodes.episodeNotFound`));return}if(typeof window<`u`&&window.isWebView===!0){try{D(e);let c=o||n.links[e-1]?.id||``,l=Math.max(0,Math.round(j.current?.scrollLeft||0));t===`popup`?(c&&B(c,`auto`),w(Math.max(0,Math.round(j.current?.scrollLeft||0)))):w(K(c,l,s)),z(!0),U(),F.current=y.loading(a(`seriesEpisodes.episodeSwitching`)),M.current=e,N.current=t,I.current=window.setTimeout(()=>{M.current===e&&(D(r),W(),y.error(a(`seriesEpisodes.episodeSwitchFailed`)))},3e3),i(e)}catch(e){D(r),W(),console.error(`切换剧集失败`,e),y.error(a(`seriesEpisodes.episodeSwitchFailed`))}return}try{D(e);let c=o||n.links[e-1]?.id||``,l=Math.max(0,Math.round(j.current?.scrollLeft||0));t===`popup`?(c&&B(c,`auto`),w(Math.max(0,Math.round(j.current?.scrollLeft||0)))):w(K(c,l,s)),z(!0),U(),F.current=y.loading(a(`seriesEpisodes.episodeSwitching`)),M.current=e,N.current=t,I.current=window.setTimeout(()=>{M.current===e&&(D(r),W(),y.error(a(`seriesEpisodes.episodeSwitchFailed`)))},8e3),i(e)}catch(e){D(r),W(),console.error(`切换剧集失败`,e),y.error(a(`seriesEpisodes.episodeSwitchFailed`))}}},[W,U,n.links,i,E,r,K,B,w,a]),[J,Y]=h(`70vh`),X=d(()=>{if(typeof window>`u`)return;if(window.isWebView===!0){Y(`100vh`);return}let e=document.getElementById(`selectPopupPosition`),t=window.visualViewport?.height||window.innerHeight;if(!e){Y(`70vh`);return}let n=Math.max(0,t-e.offsetTop);if(n<=0){Y(`70vh`);return}Y(`${n}px`)},[]);return f(()=>{if(!o)return;X();let e=()=>{X()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[X,o]),O.length<=1?null:v(g,{children:[v(e,{className:`w-full mt-[16px] flex flex-col items-end mb-[4px]`,children:[v(e,{className:`w-fit flex items-center px-[12px] h-[28px]`,onClick:()=>c(!0),children:[_(t,{className:`text-[14px] text-text2 leading-[20px]`,children:k}),_(l,{className:`w-[11px] h-[18px] ml-[4px] text-text2`})]}),_(`div`,{ref:j,className:`w-full mt-[12px] overflow-x-auto px-[12px] flex gap-x-[8px] ${u?`h-[76px]`:`h-[60px]`} ${R?`touch-none`:``}`,children:O.map((e,n)=>_(`div`,{"data-content-id":e.id,className:`shrink-0 h-[full] px-[18px] rounded-[6px] border border-line1 flex items-center ${u?`w-[162px]`:`w-[60px] !px-[0] justify-center`} ${e.id===A?`!border-theme5 bg-line1`:``}`,onClick:t=>{q(n+1,`inline`,e.id,t.clientX)},children:_(t,{className:`text-[16px] text-text1 leading-[22px] line-clamp-2 ${e.id===A?`font-bold !text-theme5`:``}`,children:u?e.title:e.series_num})},e.id))})]}),_(T,{title:a(`seriesEpisodes.selectorTitle`),variant:`popup`,open:o,updateStatus:n.update_status,summaryText:k,seriesList:(n.links||[]).map(e=>({id:e.id,name:e.name})),activeEpisodeId:A,showEpisodeTitle:u,onToggleTitle:e=>{x(e)},onClose:()=>c(!1),onSelectEpisode:(e,t)=>{c(!1),q(t,`popup`,e)},popupBodyStyle:{height:J}})]})}export{w as SeriesEpisodes};
2
+ "use client";import{Box as e}from"../../ui/box.mjs";import{Text as t}from"../../ui/text.mjs";import{Sheet as n,SheetContent as r,SheetHeader as i,SheetTitle as a}from"../../ui/sheet.mjs";import{Switch as o}from"../../ui/switch.mjs";import{useKeepAliveState as s}from"../keep-scroll-position/index.mjs";import c from"../../../assets/icons/close.mjs";import l from"../../../assets/icons/common/right_arrow.mjs";import u from"../../ui/popup.mjs";import{useCallback as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{toast as y}from"sonner";import{useTranslations as b}from"next-intl";const x=`funhub:detail-series-popup-query`,S=`funhub:detail-series-popup-close`;function C(e){return e.type===x&&e instanceof CustomEvent}function w(e,t,n){return(e||[]).map((e,r)=>{let i=Number.parseInt(e?.id||``,10),a=Number.isNaN(i)?r+1:i,o=e?.id||``,s=Number.isNaN(i)&&o||n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:s}})}function T(e,t,n){return(e||[]).map((e,r)=>{let i=Number(e?.id),a=Number.isNaN(i)?r+1:i,o=n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:o}})}function E(e,t,n){return e<=0?n(`singleContent`):n(t===`1`?`completedSeriesTotal`:`ongoingSeriesTotal`,{total:e})}function D(e){return e.mode===`detail`?_(k,{information:e.information,series_num:e.series_num,onEpisodeChange:e.onEpisodeChange}):_(O,{open:e.open,variant:e.variant,title:e.title,updateStatus:e.updateStatus,summaryText:e.summaryText,seriesList:e.seriesList,activeEpisodeId:e.activeEpisodeId,showEpisodeTitle:e.showEpisodeTitle,onToggleTitle:e.onToggleTitle,onClose:e.onClose,onSelectEpisode:e.onSelectEpisode,popupBodyStyle:e.popupBodyStyle})}function O({open:s,variant:l,title:d,updateStatus:g,summaryText:y,seriesList:x,activeEpisodeId:S,showEpisodeTitle:C=!1,onToggleTitle:T,onClose:D,onSelectEpisode:O,popupBodyStyle:k}){let A=b(`components.common.seriesEpisodes`),j=!!T,M=j&&C,N=m(null),P=m(null),F=p(()=>w(x,`episode`,e=>A(`episodeLabel`,{episode:e})),[x,A]),I=p(()=>{if(F.length===0)return[];let e=[];return F.forEach((t,n)=>{let r=Math.floor(n/50);e[r]||(e[r]=[]),e[r].push(t)}),e},[F]),L=p(()=>{if(!S)return 0;let e=F.findIndex(e=>e.id===S);return e<0?0:Math.floor(e/50)},[S,F]),[R,z]=h(L);f(()=>{z(L)},[L]);let B=p(()=>typeof y==`string`&&y.trim()?y:E(F.length,g,A),[F.length,y,A,g]),V=d||A(`selectorTitle`);function H(){let e=N.current;if(e){P.current&&=(window.cancelAnimationFrame(P.current),null),e.scrollTop=0;try{e.scrollTo({top:0,left:0,behavior:`auto`})}catch{}P.current=window.requestAnimationFrame(()=>{P.current=null;let e=N.current;e&&(e.scrollTop=0)})}}f(()=>{s&&H()},[s,C,R]);function U(e){T&&(T(e),H())}function W(e){O?.(e.id,e.series_num),D()}let G=M?2:5,K=I.length>1?_(`div`,{className:`shrink-0 w-full flex gap-[8px] overflow-x-auto`,children:I.map((e,t)=>{if(e.length===0)return null;let n=t===R,r=t*50+1,i=Math.min((t+1)*50,F.length);return v(`div`,{className:`shrink-0 px-[16px] py-[6px] rounded-[16px] text-[14px] transition-colors cursor-pointer relative overflow-hidden ${n?`text-theme5 bg-bg2`:`text-text2 bg-bg2`}`,onClick:()=>{z(t),H()},children:[r,`-`,i,n&&_(`div`,{className:`absolute w-full h-full top-0 left-0 opacity-20 bg-theme5`})]},`series-group-${t}`)})}):null,q=v(`div`,{className:`pb-[8px] flex justify-between`,children:[_(`span`,{className:`text-[16px] text-text1`,children:B}),j&&v(`div`,{className:`flex items-center gap-[4px]`,children:[_(o,{size:`sm`,className:`data-checked:bg-theme5 h-[20px] w-[33px]`,checked:C,onCheckedChange:e=>{U(!!e)}}),_(`button`,{type:`button`,className:`text-[16px] text-text1`,onClick:()=>{U(!C)},children:A(`episodeTitle`)})]})]}),J=_(`div`,{className:`grid w-full gap-2 ${G===2?`grid-cols-2`:`grid-cols-5`}`,children:(I[R]||[]).map((e,t)=>{let n=!!(S&&e.id===S);return _(`button`,{type:`button`,"data-episode-id":e.id,onClick:()=>{W(e)},className:`flex items-center justify-center w-full h-[60px] rounded-[8px] border border-line1 border-solid text-[16px] cursor-pointer select-none transition-colors relative overflow-hidden ${n?`font-bold text-theme5 bg-line1`:`text-text1`} ${M?`h-[72px] px-[10px] text-[14px]`:``} ${t%G===0?``:`border-l-0`}`,children:M?_(`span`,{className:`leading-[22px] line-clamp-2`,children:e.title}):e.series_num},e.id)})});return l===`sheet`?_(n,{open:s,onOpenChange:e=>!e&&D(),children:v(r,{side:`bottom`,showCloseButton:!0,className:`min-h-[50vh] bg-bg1 text-text1 rounded-t-2xl border-t border-white/10`,children:[_(i,{className:`pt-3 pb-0`,children:_(a,{className:`flex items-center justify-between text-lg text-text1`,children:V})}),v(`div`,{className:`px-4 pb-2 flex flex-col gap-3`,children:[K,q]}),_(`div`,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto px-4`,children:J})]})}):_(u,{open:s,onOpenChange:e=>{e||D()},showCloseButton:!1,className:`border-0 bg-transparent p-0`,children:v(e,{className:`w-full flex flex-col bg-bg1 px-[12px] text-text1`,style:{height:`70vh`,...k},children:[v(e,{className:`shrink-0 flex justify-between items-center h-[48px]`,children:[_(t,{className:`text-[16px] font-bold text-text1`,children:V}),_(e,{className:`pl-[12px] h-full flex items-center`,onClick:D,children:_(c,{className:`w-[14px] h-[14px] text-text1 cursor-pointer`})})]}),v(e,{className:`flex-1 h-0 w-full pb-[12px] flex flex-col gap-3`,children:[K,q,_(e,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto`,children:J})]})]})})}function k({information:n,series_num:r,onEpisodeChange:i}){let a=b(`components.common`),[o,c]=s(`detail-series-popup-${n.id}`,!1),[u,w]=s(`detail-series-title-toggle-${n.id}`,!1),[E,D]=s(`detail-series-scroll-left-${n.id}`,null),[k,A]=h(r);f(()=>{A(r)},[n.id,r]),f(()=>{if(typeof window>`u`)return;let e=()=>{c(!1)};return window.addEventListener(S,e),()=>{window.removeEventListener(S,e)}},[c]),f(()=>{if(typeof window>`u`)return;let e=e=>{if(!C(e))return;let t=e.detail||{};t.open=!!t.open||!!o};return window.addEventListener(x,e),()=>{window.removeEventListener(x,e)}},[o]);let j=p(()=>T((n.links||[]).map(e=>({id:e.id,name:e.name})),n.id||`episode`,e=>a(`seriesEpisodes.episodeLabel`,{episode:e})),[n.id,n.links,a]),M=n.update_status===`1`?a(`seriesEpisodes.completedSeriesTotal`,{total:n.links.length}):a(`seriesEpisodes.ongoingSeriesUpdatedTo`,{total:n.links.length}),N=p(()=>n.links[k-1]?.id||n.links[0]?.id||``,[n.links,k]),P=m(null),F=m(null),I=m(null),L=m(!1),R=m(null),z=m(null),B=m(null),[V,H]=h(!1),U=d((e,t=`smooth`)=>{let n=P.current?.querySelector(`[data-content-id="${e}"]`);if(n&&P.current){let e=P.current,r=Math.max(0,n.offsetLeft-10);e.scrollTo({left:r,behavior:t})}},[]),W=d(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),G=d(()=>{B.current!==null&&(window.clearTimeout(B.current),B.current=null)},[]),K=d(()=>{R.current!==null&&(y.dismiss(R.current),R.current=null),W(),G()},[G,W]),q=d(()=>{F.current=null,I.current=null,K(),H(!1)},[K]),J=d((e,t)=>{G(),B.current=window.setTimeout(()=>{B.current=null,F.current===e&&q()},Math.max(0,t))},[G,q]);f(()=>{L.current=!1},[n.id]),f(()=>{if(L.current||!N)return;let e=window.requestAnimationFrame(()=>{let e=P.current;e&&(typeof E==`number`?e.scrollTo({left:Math.max(0,E),behavior:`auto`}):(U(N,`auto`),D(Math.max(0,Math.round(e.scrollLeft)))),L.current=!0)});return()=>{window.cancelAnimationFrame(e)}},[N,E,U,D]),f(()=>{let e=F.current;!e||e!==r||J(e,1e3)},[J,r]),f(()=>()=>{q()},[q]);let Y=d((e,t,n)=>{let r=P.current;if(!r||!e)return t;let i=r.querySelector(`[data-content-id="${e}"]`);if(!i)return t;let a=r.getBoundingClientRect();if(a.width<=0||typeof n!=`number`||(n-a.left)/a.width<.5)return t;let o=i.offsetLeft+i.offsetWidth/2,s=r.clientWidth/2,c=Math.max(0,r.scrollWidth-r.clientWidth),l=Math.min(c,Math.max(0,o-s));return r.scrollTo({left:l,behavior:`smooth`}),Math.round(l)},[]),X=d((e,t=`inline`,o,s)=>{if(e!==k){if(!n.links[e-1]){y.error(a(`seriesEpisodes.episodeNotFound`));return}if(typeof window<`u`&&window.isWebView===!0){try{A(e);let c=o||n.links[e-1]?.id||``,l=Math.max(0,Math.round(P.current?.scrollLeft||0));t===`popup`?(c&&U(c,`auto`),D(Math.max(0,Math.round(P.current?.scrollLeft||0)))):D(Y(c,l,s)),H(!0),K(),R.current=y.loading(a(`seriesEpisodes.episodeSwitching`)),F.current=e,I.current=t,z.current=window.setTimeout(()=>{F.current===e&&(A(r),q(),y.error(a(`seriesEpisodes.episodeSwitchFailed`)))},3e3),i(e)}catch(e){A(r),q(),console.error(`切换剧集失败`,e),y.error(a(`seriesEpisodes.episodeSwitchFailed`))}return}try{A(e);let c=o||n.links[e-1]?.id||``,l=Math.max(0,Math.round(P.current?.scrollLeft||0));t===`popup`?(c&&U(c,`auto`),D(Math.max(0,Math.round(P.current?.scrollLeft||0)))):D(Y(c,l,s)),H(!0),K(),R.current=y.loading(a(`seriesEpisodes.episodeSwitching`)),F.current=e,I.current=t,z.current=window.setTimeout(()=>{F.current===e&&(A(r),q(),y.error(a(`seriesEpisodes.episodeSwitchFailed`)))},8e3),i(e)}catch(e){A(r),q(),console.error(`切换剧集失败`,e),y.error(a(`seriesEpisodes.episodeSwitchFailed`))}}},[q,K,n.links,i,k,r,Y,U,D,a]),[Z,Q]=h(`70vh`),$=d(()=>{if(typeof window>`u`)return;if(window.isWebView===!0){Q(`100vh`);return}let e=document.getElementById(`selectPopupPosition`),t=window.visualViewport?.height||window.innerHeight;if(!e){Q(`70vh`);return}let n=Math.max(0,t-e.offsetTop);if(n<=0){Q(`70vh`);return}Q(`${n}px`)},[]);return f(()=>{if(!o)return;$();let e=()=>{$()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[$,o]),j.length<=1?null:v(g,{children:[v(e,{className:`w-full mt-[16px] flex flex-col items-end mb-[4px]`,children:[v(e,{className:`w-fit flex items-center px-[12px] h-[28px]`,onClick:()=>c(!0),children:[_(t,{className:`text-[14px] text-text2 leading-[20px]`,children:M}),_(l,{className:`w-[11px] h-[18px] ml-[4px] text-text2`})]}),_(`div`,{ref:P,className:`w-full mt-[12px] overflow-x-auto px-[12px] flex gap-x-[8px] ${u?`h-[76px]`:`h-[60px]`} ${V?`touch-none`:``}`,children:j.map((e,n)=>_(`div`,{"data-content-id":e.id,className:`shrink-0 h-[full] px-[18px] rounded-[6px] border border-line1 flex items-center ${u?`w-[162px]`:`w-[60px] !px-[0] justify-center`} ${e.id===N?`!border-theme5 bg-line1`:``}`,onClick:t=>{X(n+1,`inline`,e.id,t.clientX)},children:_(t,{className:`text-[16px] text-text1 leading-[22px] line-clamp-2 ${e.id===N?`font-bold !text-theme5`:``}`,children:u?e.title:e.series_num})},e.id))})]}),_(O,{title:a(`seriesEpisodes.selectorTitle`),variant:`popup`,open:o,updateStatus:n.update_status,summaryText:M,seriesList:(n.links||[]).map(e=>({id:e.id,name:e.name})),activeEpisodeId:N,showEpisodeTitle:u,onToggleTitle:e=>{w(e)},onClose:()=>c(!1),onSelectEpisode:(e,t)=>{c(!1),X(t,`popup`,e)},popupBodyStyle:{height:Z}})]})}export{D as SeriesEpisodes};
@@ -8,7 +8,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
8
8
  /** buttonVariants 工具定义。 */
9
9
  declare const buttonVariants: (props?: ({
10
10
  variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
11
- size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
11
+ size?: "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
12
12
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
13
13
  /** Button 组件属性。 */
14
14
  type ButtonProps = Button.Props & VariantProps<typeof buttonVariants> & {
@@ -1,11 +1,11 @@
1
1
 
2
2
  import * as React from "react";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
- import NextImage from "next/image";
4
+ import Image from "next/image";
5
5
 
6
6
  //#region components/ui/image.d.ts
7
7
  /** BaseImageProps 属性定义。 */
8
- type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof NextImage>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
8
+ type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof Image>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
9
9
  type CommonImageProps = BaseImageProps & {
10
10
  /** 图片地址,支持普通 URL、默认资源路径和加密地址。 */src: string; /** 图片替代文本。 */
11
11
  alt?: string; /** 图片类名。 */
@@ -27,6 +27,6 @@ type ImagePropsWithSize = CommonImageProps & {
27
27
  /** ImageProps 属性定义。 */
28
28
  type ImageProps = ImagePropsWithFill | ImagePropsWithSize;
29
29
  /** 图片组件:支持 bnc 解密、默认资源域名拼接与错误占位。 */
30
- declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
30
+ declare function Image$1(props: ImageProps): react_jsx_runtime0.JSX.Element;
31
31
  //#endregion
32
- export { BaseImageProps, CommonImageProps, Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
32
+ export { BaseImageProps, CommonImageProps, Image$1 as Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.1.156",
4
+ "version": "0.1.158",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"