import{i as L}from"./DGECmbjy.js";import{e as D,J as S,j,k as B,B as C,c as a,a as t,f as r,F as h,b as p,t as i,h as E,r as g,i as m,E as N,o,m as O,_ as R}from"./DpdQcRr7.js";import"./BcpEzrWT.js";const M={class:"org-page"},V={class:"org-container"},A={key:0,class:"state-box"},F={class:"stat-grid"},J={class:"stat-card"},T={class:"stat-icon",style:{color:"#3273dc"}},I={class:"stat-value"},P={class:"stat-card"},U={class:"stat-icon",style:{color:"#48c774"}},W={class:"stat-value"},$={class:"stat-card"},q={class:"stat-icon",style:{color:"#ff8906"}},G={class:"stat-value"},H={class:"card"},K={key:0,class:"empty-text"},Q={class:"card"},X={key:0,class:"empty-text"},Y={key:1,class:"data-table"},Z={class:"right"},tt={class:"right"},st={class:"right"},et={class:"card"},at={key:0,class:"empty-text"},ot={key:1,class:"data-table"},nt={class:"mono"},it=D({__name:"index",setup(lt){const{$api:y}=S(),u=m(!0),l=m({total_users:0,active_users:0,total_organizations:0,membership_distribution:{},organizations_summary:[],recent_users:[]}),_=m(null);let c=null;const f={trial:"体験",regular:"通常",short_term:"短期",special:"特別"},b=n=>n?new Date(n).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"}):"",k=(n,s)=>s===0?"0%":Math.round(n/s*100)+"%",w=()=>{if(!_.value)return;c=L(_.value);const n=l.value.membership_distribution,s=Object.entries(n).map(([e,z])=>({name:f[e]||e,value:z})),d={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:s}]};c.setOption(d)},v=()=>{c==null||c.resize()},x=async()=>{u.value=!0;try{const n=await y("/api/company/dashboard/stats");l.value=n}catch(n){console.error("ダッシュボード情報の取得に失敗しました:",n)}finally{u.value=!1}};return j(async()=>{await x(),B(()=>{w(),window.addEventListener("resize",v)})}),C(()=>{window.removeEventListener("resize",v),c==null||c.dispose()}),(n,s)=>{const d=N("Icon");return o(),a("div",M,[t("div",V,[s[9]||(s[9]=t("div",{class:"page-header"},[t("h1",{class:"page-title"},"ダッシュボード")],-1)),r(u)?(o(),a("div",A,[...s[0]||(s[0]=[t("div",{class:"loader"},null,-1),t("p",null,"読み込み中...",-1)])])):(o(),a(h,{key:1},[t("div",F,[t("div",J,[t("span",T,[p(d,{icon:"mdi:account-multiple",width:28,height:28})]),t("div",null,[s[1]||(s[1]=t("p",{class:"stat-label"},"総ユーザー数",-1)),t("p",I,i(r(l).total_users),1)])]),t("div",P,[t("span",U,[p(d,{icon:"mdi:account-check",width:28,height:28})]),t("div",null,[s[2]||(s[2]=t("p",{class:"stat-label"},"アクティブユーザー",-1)),t("p",W,i(r(l).active_users),1)])]),t("div",$,[t("span",q,[p(d,{icon:"mdi:school",width:28,height:28})]),t("div",null,[s[3]||(s[3]=t("p",{class:"stat-label"},"教室数",-1)),t("p",G,i(r(l).total_organizations),1)])])]),t("div",H,[s[4]||(s[4]=t("h3",{class:"card-title"},"所属種別分布",-1)),t("div",{ref_key:"membershipChartRef",ref:_,style:{width:"100%",height:"280px"}},null,512),Object.keys(r(l).membership_distribution).length===0?(o(),a("p",K," データがありません ")):E("",!0)]),t("div",Q,[s[6]||(s[6]=t("h3",{class:"card-title"},"教室別ユーザー数",-1)),r(l).organizations_summary.length===0?(o(),a("div",X," 教室データがありません ")):(o(),a("table",Y,[s[5]||(s[5]=t("thead",null,[t("tr",null,[t("th",null,"教室名"),t("th",{class:"right"},"ユーザー数"),t("th",{class:"right"},"アクティブ数"),t("th",{class:"right"},"アクティブ率")])],-1)),t("tbody",null,[(o(!0),a(h,null,g(r(l).organizations_summary,e=>(o(),a("tr",{key:e.id},[t("td",null,i(e.name),1),t("td",Z,i(e.user_count),1),t("td",tt,i(e.active_user_count),1),t("td",st,[t("span",{class:O(["tag",e.active_user_count===e.user_count?"tag-success":"tag-info"])},i(k(e.active_user_count,e.user_count)),3)])]))),128))])]))]),t("div",et,[s[8]||(s[8]=t("h3",{class:"card-title"},"最近登録されたユーザー",-1)),r(l).recent_users.length===0?(o(),a("div",at," ユーザーデータがありません ")):(o(),a("table",ot,[s[7]||(s[7]=t("thead",null,[t("tr",null,[t("th",null,"ユーザーID"),t("th",null,"名前"),t("th",null,"所属教室"),t("th",null,"登録日")])],-1)),t("tbody",null,[(o(!0),a(h,null,g(r(l).recent_users,e=>(o(),a("tr",{key:e.id},[t("td",null,[t("span",nt,i(e.user_id),1)]),t("td",null,i(e.name||"-"),1),t("td",null,i(e.organization_name||"-"),1),t("td",null,i(b(e.created_at)),1)]))),128))])]))])],64))])])}}}),ut=R(it,[["__scopeId","data-v-1e6eaaec"]]);export{ut as default};
