import{_ as D}from"./Ba76BwjT.js";import{e as T,J as B,K as M,j as S,c as i,a as s,f as a,t as r,h as v,b as m,y as V,z as L,D as P,F as A,r as F,i as u,E as I,o as n,n as E,m as w,H as x,d as J,w as R,A as U,_ as H}from"./DpdQcRr7.js";import"./BcpEzrWT.js";const K={class:"org-page"},Q={class:"org-container"},q={class:"page-header"},G={key:0,class:"total-badge"},O={class:"filter-bar"},W={class:"search-input-wrapper"},X={key:0,class:"state-box"},Y={key:1,class:"empty-state"},Z={key:2,class:"proj-grid"},ss=["onClick"],ts=["src"],es={class:"proj-body"},os={class:"proj-name"},as={key:0,class:"proj-desc"},ns={class:"proj-tags"},is={class:"tag"},ls={class:"tag"},rs={class:"proj-foot"},cs={key:1,class:"proj-author is-unknown"},ds={class:"proj-date"},us={key:3,class:"pagination"},hs=["disabled"],ps={class:"page-info"},_s=["disabled"],ms=T({__name:"index",setup(gs){const{$api:C}=B(),g=u([]),f=u(0),c=u(1),h=u(1),p=u(!1),d=u(""),k=o=>o.project_name||o.name,y=async()=>{p.value=!0;try{const o=new URLSearchParams;o.append("page",String(c.value)),d.value&&o.append("search",d.value);const t=await C(`/api/organization/projects?${o.toString()}`);g.value=t.projects||[],f.value=t.total||0,h.value=t.pages||1}catch(o){console.error("プロジェクト一覧の取得に失敗しました:",o),g.value=[]}finally{p.value=!1}},j=o=>{o<1||o>h.value||(c.value=o,y())},$=()=>{d.value=""},N=o=>{const t=o||"project";let l=0;for(let _=0;_<t.length;_++)l=l*31+t.charCodeAt(_)>>>0;return`linear-gradient(135deg, hsl(${l%360} 62% 60%), hsl(${(l+45)%360} 60% 48%))`},z=o=>o?new Date(o).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"}):"—";let b=null;return M(d,()=>{b&&clearTimeout(b),b=setTimeout(()=>{c.value=1,y()},300)}),S(y),(o,t)=>{const l=I("Icon"),_=D;return n(),i("div",K,[s("div",Q,[s("div",q,[t[4]||(t[4]=s("div",null,[s("h1",{class:"page-title"},"プロジェクト一覧"),s("p",{class:"page-sub"},"教室に所属するユーザーが作成したModプロジェクトの一覧です。")],-1)),a(p)?v("",!0):(n(),i("span",G,r(a(f))+"件",1))]),s("div",O,[s("div",W,[m(l,{icon:"mdi:magnify",width:18,height:18,class:"search-icon"}),V(s("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>P(d)?d.value=e:null),type:"text",class:"search-input",placeholder:"Mod名・説明で検索"},null,512),[[L,a(d)]])]),a(d)?(n(),i("button",{key:0,class:"btn btn-secondary",onClick:$},"クリア")):v("",!0)]),a(p)?(n(),i("div",X,[...t[5]||(t[5]=[s("div",{class:"loader"},null,-1),s("p",null,"読み込み中...",-1)])])):a(g).length===0?(n(),i("div",Y,[m(l,{icon:"mdi:cube-outline",width:48,height:48,class:"empty-icon"}),t[6]||(t[6]=s("p",{class:"empty-title"},"プロジェクトが見つかりません",-1)),t[7]||(t[7]=s("p",{class:"empty-sub"},"条件に一致するプロジェクトがありません。",-1))])):(n(),i("div",Z,[(n(!0),i(A,null,F(a(g),e=>(n(),i("div",{key:e.id,class:"proj-card",role:"link",onClick:vs=>o.$router.push(`/organization/projects/${e.id}`)},[s("div",{class:w(["proj-thumb",{"is-gen":!e.thumbnail_url}]),style:E(e.thumbnail_url?void 0:{background:N(k(e))})},[e.thumbnail_url?(n(),i("img",{key:0,src:e.thumbnail_url,alt:""},null,8,ts)):(n(),x(l,{key:1,icon:"mdi:cube-outline",width:30,height:30})),s("span",{class:w(["proj-badge",e.is_shared?"is-public":"is-private"])},[m(l,{icon:e.is_shared?"mdi:earth":"mdi:lock-outline",width:12,height:12},null,8,["icon"]),J(" "+r(e.is_shared?"公開中":"非公開"),1)],2)],6),s("div",es,[s("h3",os,r(k(e)),1),e.description?(n(),i("p",as,r(e.description),1)):v("",!0),s("div",ns,[s("span",is,r(e.mod_loader),1),s("span",ls,r(e.minecraft_version),1)])]),s("div",rs,[e.author?(n(),x(_,{key:0,to:`/organization/users/${e.author.id}`,class:"proj-author",onClick:t[1]||(t[1]=U(()=>{},["stop"]))},{default:R(()=>[m(l,{icon:"mdi:account-circle",width:18,height:18}),s("span",null,r(e.author.name||e.author.user_id),1)]),_:2},1032,["to"])):(n(),i("span",cs,[m(l,{icon:"mdi:account-circle",width:18,height:18}),t[8]||(t[8]=s("span",null,"不明",-1))])),s("span",ds,r(z(e.updated_at)),1)])],8,ss))),128))])),!a(p)&&a(h)>1?(n(),i("nav",us,[s("button",{class:"page-btn",disabled:a(c)<=1,onClick:t[2]||(t[2]=e=>j(a(c)-1))},"前へ",8,hs),s("span",ps,r(a(c))+" / "+r(a(h)),1),s("button",{class:"page-btn",disabled:a(c)>=a(h),onClick:t[3]||(t[3]=e=>j(a(c)+1))},"次へ",8,_s)])):v("",!0)])])}}}),ks=H(ms,[["__scopeId","data-v-2eb9df1a"]]);export{ks as default};
