import{i as x}from"./DGECmbjy.js";import{e as z,J as L,j as D,k as S,B as j,c as a,a as t,f as r,F as h,b as v,t as d,h as B,r as E,i as _,E as N,o as n,_ as O}from"./DpdQcRr7.js";import"./BcpEzrWT.js";const C={class:"org-page"},R={class:"org-container"},V={key:0,class:"state-box"},F={class:"stat-grid"},J={class:"stat-card"},M={class:"stat-icon",style:{color:"#3273dc"}},T={class:"stat-value"},A={class:"stat-card"},I={class:"stat-icon",style:{color:"#48c774"}},P={class:"stat-value"},U={class:"card"},W={key:0,class:"empty-text"},$={class:"card"},q={key:0,class:"empty-text"},G={key:1,class:"data-table"},H={class:"mono"},K=z({__name:"index",setup(Q){const{$api:f}=L(),u=_(!0),i=_({total_users:0,active_users:0,membership_distribution:{},recent_users:[]}),p=_(null);let o=null;const b={trial:"体験",regular:"通常",short_term:"短期",special:"特別"},g=s=>s?new Date(s).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"}):"",y=()=>{if(!p.value)return;o=x(p.value);const s=i.value.membership_distribution,e=Object.entries(s).map(([l,w])=>({name:b[l]||l,value:w})),c={tooltip:{trigger:"item",formatter:"{b}: {c}人 ({d}%)"},legend:{bottom:0,textStyle:{color:"#718096",fontSize:12}},color:["#ff8906","#e53170","#3b82f6","#10b981"],series:[{type:"pie",radius:["40%","70%"],center:["50%","45%"],avoidLabelOverlap:!1,label:{show:!1},emphasis:{label:{show:!0,fontSize:14,fontWeight:"bold"}},data:e}]};o.setOption(c)},m=()=>{o==null||o.resize()},k=async()=>{u.value=!0;try{const s=await f("/api/organization/dashboard/stats");i.value=s}catch(s){console.error("ダッシュボード情報の取得に失敗しました:",s)}finally{u.value=!1}};return D(async()=>{await k(),S(()=>{y(),window.addEventListener("resize",m)})}),j(()=>{window.removeEventListener("resize",m),o==null||o.dispose()}),(s,e)=>{const c=N("Icon");return n(),a("div",C,[t("div",R,[e[6]||(e[6]=t("div",{class:"page-header"},[t("h1",{class:"page-title"},"ダッシュボード")],-1)),r(u)?(n(),a("div",V,[...e[0]||(e[0]=[t("div",{class:"loader"},null,-1),t("p",null,"読み込み中...",-1)])])):(n(),a(h,{key:1},[t("div",F,[t("div",J,[t("span",M,[v(c,{icon:"mdi:account-multiple",width:28,height:28})]),t("div",null,[e[1]||(e[1]=t("p",{class:"stat-label"},"総ユーザー数",-1)),t("p",T,d(r(i).total_users),1)])]),t("div",A,[t("span",I,[v(c,{icon:"mdi:account-check",width:28,height:28})]),t("div",null,[e[2]||(e[2]=t("p",{class:"stat-label"},"アクティブユーザー",-1)),t("p",P,d(r(i).active_users),1)])])]),t("div",U,[e[3]||(e[3]=t("h3",{class:"card-title"},"所属種別分布",-1)),t("div",{ref_key:"membershipChartRef",ref:p,style:{width:"100%",height:"280px"}},null,512),Object.keys(r(i).membership_distribution).length===0?(n(),a("p",W," データがありません ")):B("",!0)]),t("div",$,[e[5]||(e[5]=t("h3",{class:"card-title"},"最近登録されたユーザー",-1)),r(i).recent_users.length===0?(n(),a("div",q," ユーザーデータがありません ")):(n(),a("table",G,[e[4]||(e[4]=t("thead",null,[t("tr",null,[t("th",null,"ユーザーID"),t("th",null,"名前"),t("th",null,"登録日")])],-1)),t("tbody",null,[(n(!0),a(h,null,E(r(i).recent_users,l=>(n(),a("tr",{key:l.id},[t("td",null,[t("span",H,d(l.user_id),1)]),t("td",null,d(l.name||"-"),1),t("td",null,d(g(l.created_at)),1)]))),128))])]))])],64))])])}}}),tt=O(K,[["__scopeId","data-v-d5288856"]]);export{tt as default};
