import{_ as B}from"./Ba76BwjT.js";import{e as F,J as I,K as R,j as U,c as o,a as e,b as h,y as z,z as j,f as l,D as N,N as E,F as g,r as S,h as y,i as m,E as J,o as i,t as p,m as D,d as T,w as O,G as V,_ as q}from"./DpdQcRr7.js";import"./BcpEzrWT.js";const A={class:"org-page"},G={class:"org-container"},K={class:"filter-bar"},Q={class:"search-input-wrapper"},H={key:0,class:"state-box"},W={key:1,class:"empty-state"},X={class:"user-list"},Y={class:"user-avatar",style:{color:"#7c3aed"}},Z={class:"user-main"},tt={class:"user-name-row"},et={class:"user-name"},st={key:0,class:"user-email"},at={class:"user-meta"},nt={key:0},ot={key:1},it={key:0,class:"pagination"},lt=["disabled"],ct={key:0,class:"page-ellipsis"},rt=["onClick"],ut=["disabled"],dt=F({__name:"index",setup(pt){const{$api:$}=I(),w=m([]),f=m(!1),u=m(""),d=m(""),c=m(1),v=m(1),_=async()=>{f.value=!0;try{const a=new URLSearchParams;a.append("page",String(c.value)),a.append("limit","20"),u.value&&a.append("search",u.value),d.value&&a.append("status",d.value);const t=a.toString(),n=await $(`/api/company/organizations?${t}`);w.value=n.organizations,v.value=n.pages||1}catch(a){console.error("組織一覧の取得に失敗しました:",a)}finally{f.value=!1}},C=V(()=>w.value),M=()=>{u.value="",d.value="",c.value=1,_()},b=a=>{a<1||a>v.value||(c.value=a,_())},P=V(()=>{const a=v.value,t=c.value,n=[];if(a<=7){for(let r=1;r<=a;r++)n.push(r);return n}n.push(1),t>3&&n.push("...");const x=Math.max(2,t-1),s=Math.min(a-1,t+1);for(let r=x;r<=s;r++)n.push(r);return t<a-2&&n.push("..."),n.push(a),n}),L=a=>new Date(a).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"});let k=null;return R([u,d],()=>{k&&clearTimeout(k),k=setTimeout(()=>{c.value=1,_()},300)}),U(()=>{_()}),(a,t)=>{const n=J("Icon"),x=B;return i(),o("div",A,[e("div",G,[t[9]||(t[9]=e("div",{class:"page-header"},[e("div",null,[e("h1",{class:"page-title"},"教室管理"),e("p",{class:"page-sub"},"教室の一覧を確認・管理します。")])],-1)),e("div",K,[e("div",Q,[h(n,{icon:"mdi:magnify",width:18,height:18,class:"search-icon"}),z(e("input",{"onUpdate:modelValue":t[0]||(t[0]=s=>N(u)?u.value=s:null),type:"text",class:"search-input",placeholder:"教室名"},null,512),[[j,l(u)]])]),z(e("select",{"onUpdate:modelValue":t[1]||(t[1]=s=>N(d)?d.value=s:null),class:"filter-select"},[...t[4]||(t[4]=[e("option",{value:""},"全てのステータス",-1),e("option",{value:"active"},"アクティブ",-1),e("option",{value:"inactive"},"非アクティブ",-1)])],512),[[E,l(d)]]),e("button",{class:"btn btn-secondary",onClick:M},"フィルタークリア")]),l(f)?(i(),o("div",H,[...t[5]||(t[5]=[e("div",{class:"loader"},null,-1),e("p",null,"読み込み中...",-1)])])):l(C).length===0?(i(),o("div",W,[h(n,{icon:"mdi:account-group-outline",width:48,height:48,class:"empty-icon"}),t[6]||(t[6]=e("p",{class:"empty-title"},"教室が見つかりません",-1)),t[7]||(t[7]=e("p",{class:"empty-sub"},"条件に一致する教室がありません。",-1))])):(i(),o(g,{key:2},[e("div",X,[(i(!0),o(g,null,S(l(C),s=>(i(),o("div",{key:s.id,class:"user-card"},[e("span",Y,[h(n,{icon:"mdi:account-group",width:44,height:44})]),e("div",Z,[e("div",tt,[e("span",et,p(s.name),1),e("span",{class:D(["tag",s.is_active?"tag-success":"tag-danger"])},p(s.is_active?"アクティブ":"非アクティブ"),3)]),s.description?(i(),o("p",st,p(s.description),1)):y("",!0),e("p",at,[T(" 作成日: "+p(L(s.created_at))+" ",1),s.user_count!==void 0?(i(),o("span",nt," | ユーザー数: "+p(s.user_count),1)):y("",!0),s.contact_email?(i(),o("span",ot," | "+p(s.contact_email),1)):y("",!0)])]),h(x,{to:`/company/organizations/${s.id}/edit`,class:"btn btn-secondary btn-sm"},{default:O(()=>[...t[8]||(t[8]=[T(" 編集 ",-1)])]),_:1},8,["to"])]))),128))]),l(v)>1?(i(),o("nav",it,[e("button",{class:"page-btn",disabled:l(c)<=1,onClick:t[2]||(t[2]=s=>b(l(c)-1))},"前へ",8,lt),(i(!0),o(g,null,S(l(P),(s,r)=>(i(),o(g,{key:r},[s==="..."?(i(),o("span",ct,"…")):(i(),o("button",{key:1,class:D(["page-btn",{"is-current":s===l(c)}]),onClick:mt=>b(s)},p(s),11,rt))],64))),128)),e("button",{class:"page-btn",disabled:l(c)>=l(v),onClick:t[3]||(t[3]=s=>b(l(c)+1))},"次へ",8,ut)])):y("",!0)],64))])])}}}),gt=q(dt,[["__scopeId","data-v-184bfb46"]]);export{gt as default};
