PIMS/public/build/assets/Show-D_R328ht.js

2 lines
6.4 KiB
JavaScript
Raw Permalink Normal View History

import{d as A,n as B,c as I,r,e as E,p as z,a as o,f as w,u as D,h as O,w as M,b as e,i as u,o as l,t as i,q as N,v as X,s as Y,F as g,g as j,l as k,T as Z}from"./app-BXYcVHqk.js";import{_ as H}from"./AppLayout.vue_vue_type_script_setup_true_lang-86gE95Fg.js";import{_ as W}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./AppLogoIcon.vue_vue_type_script_setup_true_lang-BzXwPo6R.js";import"./useForwardExpose-Djbxsgaa.js";import"./VisuallyHidden-BvthYHr5.js";import"./RovingFocusGroup-dmigQ6Dy.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./index-C4J_hXM0.js";import"./createLucideIcon-BlA39rtn.js";const G={class:"flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4"},J={key:0,class:"flex items-center gap-3"},K={class:"flex items-center gap-3"},Q={class:"min-w-0 flex-1"},ee={class:"truncate text-lg font-semibold"},te={class:"flex items-center gap-2"},se={key:1,class:"rounded-md border border-red-300 bg-red-50 p-3 text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-200"},ae=["aria-busy"],oe=["href"],le={class:"h-20 w-14 shrink-0 overflow-hidden rounded bg-muted"},re=["src","alt"],ne={class:"flex min-w-0 flex-1 flex-col"},ue={class:"flex items-center justify-between gap-2"},ie={class:"truncate font-medium"},de={class:"text-xs text-muted-foreground"},ce={class:"mt-1 text-xs text-muted-foreground"},ve={key:0,class:"mr-2 rounded border px-1 py-0.5"},fe={key:1},pe={class:"mt-2 text-sm text-foreground/90"},me={key:0,class:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2 rounded bg-foreground px-3 py-2 text-sm text-background shadow-lg"},ge=A({__name:"Show",setup(he){const C=B(),S=I(()=>C.props.entityId),d=r(""),c=r("title_asc"),v=r([]),L=r(0),T=r(1),h=r(1),n=r(!1),_=r(null),b=r(!1),P=r(""),p=r(null);let $=null;const q=I(()=>h.value<T.value&&!n.value);function U(a,t=50){if(!a)return"";const s=a.split(/\s+/);return s.length<=t?a:s.slice(0,t).join(" ")+"…"}async function x(a=!1){if(!n.value){n.value=!0,_.value=null;try{const t=new URLSearchParams;d.value&&t.set("q",d.value),c.value&&t.set("sort",c.value),t.set("per_page","20"),t.set("page",String(h.value));const s=await fetch(`/api/studios/${S.value}?${t.toString()}`,{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"});if(!s.ok)throw new Error(`Fetch failed: ${s.status}`);const f=await s.json();p.value=f.entity,L.value=f.movies.total,T.value=f.movies.last_page,a?v.value=f.movies.data:v.value=v.value.concat(f.movies.data)}catch(t){_.value=t?.message??"Unexpected error",P.value=_.value,b.value=!0,setTimeout(()=>b.value=!1,2500)}finally{n.value=!1}}}function V(){clearTimeout($),$=setTimeout(()=>{h.value=1,x(!0)},300)}function F(){const a=new URL(window.location.href);d.value?a.searchParams.set("q",d.value):a.searchParams.delete("q"),c.value?a.searchParams.set("sort",c.value):a.searchParams.delete("sort"),window.history.replaceState({},"",a.toString()),h.value=1,x(!0)}async function R(){q.value&&(h.value+=1,await x(!1))}const y=r(null);let m=null;return E(()=>{const a=new URL(window.location.href);d.value=a.searchParams.get("q")??"",c.value=a.searchParams.get("sort")??"title_asc",x(!0),m=new IntersectionObserver(t=>{for(const s of t)s.isIntersecting&&R()},{root:null,rootMargin:"200px",threshold:0}),y.value&&m.observe(y.value)}),z(y,(a,t)=>{t&&m&&m.unobserve(t),a&&m&&m.observe(a)}),(a,t)=>(l(),o(g,null,[w(D(O),{title:p.value?.name?`${p.value.name} · Studio`:"Studio"},null,8,["title"]),w(H,{breadcrumbs:[{title:"Studios",href:"/studios"},{title:p.value?.name??"…",href:`/studios/${S.value}`}]},{default:M(()=>[e("div",G,[!p.value&&n.value?(l(),o("div",J,[...t[2]||(t[2]=[e("div",{class:"h-12 w-12 shrink-0 rounded bg-muted animate-pulse"},null,-1),e("div",{class:"h-4 w-40 rounded bg-muted animate-pulse"},null,-1)])])):u("",!0),e("div",K,[t[3]||(t[3]=e("div",{class:"h-12 w-12 shrink-0 rounded bg-muted"},null,-1)),e("div",Q,[e("h1",ee,i(p.value?.name??"…"),1)])]),e("div",te,[N(e("input",{class:"w-full rounded-md border border-gray-300 bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary"