1import{c as E,r as g,d as S,f as C,Y as f,j as e,w as j,c5 as w,L as u,b as y,bM as M,c6 as A,h as P}from"./index-DUpygkxg.js";import{h as U,j as I,H as $}from"./firebase-eOymXQZD.js";import{getEvents as D,getConfirmedAttendees as L,getAttendeeHeadcount as H}from"./events-DPZrMu27.js";import{E as T}from"./eye-DRZhOUPy.js";import{M as R}from"./mouse-pointer-click-Bmcq-bPN.js";import{A as k}from"./arrow-right-CNBzfzh2.js";const _=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],O=E("repeat",_),Y="542118708";function N(o){return(o??0).toLocaleString("ja-JP")}const F=[{to:"/website-analytics",label:"ã¢ã¯ã»ã¹è§£æ",desc:"mie-fuk.jp ã®è©³ç´°ï¼GA4ï¼",icon:w},{to:"/donations",label:"å¯ä»ç®¡ç",desc:"å¯ä»ã®éè¨ã»é 忏",icon:M},{to:"/members",label:"ä¼å¡ç®¡ç",desc:"ä¼å¡ã»ã ã©ããã®ç¶æ³",icon:A},{to:"/events",label:"ã¤ãã³ã",desc:"éå¬ã»åå ã®è¨é²",icon:y},{to:"/cashflow-forecast",label:"è³éç¹°ãäºæ¸¬",desc:"è³éã®è¦éã",icon:P}];function G(o){const i=new Date(Date.now()+324e5),p=i.toISOString().slice(0,10),x=[];for(let t=11;t>=0;t--){const s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-t,1)),r=s.toISOString().slice(0,7);x.push({key:r,label:`${s.getUTCMonth()+1}æ`,people:0,count:0})}const l=new Map(x.map(t=>[t.key,t])),d=new Map;let n=0,c=0;for(const t of o){if(!t.date||t.date>p)continue;const s=t.date.slice(0,7),r=l.get(s);if(!r)continue;const h=L(t);if(h.length===0)continue;const v=h.reduce((b,m)=>b+H(m),0);r.people+=v,r.count+=1,n+=v,c+=1;for(const b of h){const m=(b.email||"").trim().toLowerCase();m&&(d.has(m)||d.set(m,new Set),d.get(m).add(t.id))}}const a=[...d.values()].filter(t=>t.size>=2).length;return{months:x,totalPeople:n,totalEvents:c,repeaters:a,avgPerEvent:c>0?Math.round(n/c*10)/10:0}}function V(){const[o,i]=g.useState(null),[p,x]=g.useState(!0),[l,d]=g.useState(null);g.useEffect(()=>{(async()=>{try{const a=await D();d(G(a))}catch(a){console.error("[AnalyticsHomePage] event stats failed:",a)}})()},[]),g.useEffect(()=>{(async()=>{try{let a=Y;try{const r=await U(I(S,"settings","websiteAnalytics"));r.exists()&&r.data().propertyId&&(a=String(r.data().propertyId))}catch{}const s=await $(C,"getWebsiteAnalytics")({propertyId:a,days:28});i(s.data)}catch(a){console.error("[AnalyticsHomePage] web analytics fetch failed:",a),i(null)}finally{x(!1)}})()},[]);const n=o?.kpis,c=n?[{label:"訪åè
æ°",icon:f,value:n.activeUsers?.value??0},{label:"ãã¼ã¸ãã¥ã¼",icon:T,value:n.pageViews?.value??0},{label:"ã»ãã·ã§ã³",icon:R,value:n.sessions?.value??0}]:[];return e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"p-2 rounded-lg bg-indigo-50 dark:bg-indigo-900/30",children:e.jsx(j,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-gray-100",children:"åæ"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"å£ä½ã»ãµã¤ãã®ææ¨ãã¾ã¨ãã¦ç¢ºèª"})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 flex items-center gap-2",children:[e.jsx(w,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"}),"ã¦ã§ããµã¤ãï¼mie-fuk.jpï¼ã»ç´è¿28æ¥"]}),e.jsxs(u,{to:"/website-analytics",className:"text-xs text-indigo-600 dark:text-indigo-400 hover:underline inline-flex items-center gap-1",children:["詳細 ",e.jsx(k,{className:"w-3 h-3"})]})]}),p?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[0,1,2].map(a=>e.jsx("div",{className:"h-24 rounded-xl bg-gray-100 dark:bg-gray-800 animate-pulse"},a))}):o&&o.configured&&n?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:c.map(({label:a,icon:t,value:s})=>
1e.jsxs("div",{className:"p-3 sm:p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-gray-500 dark:text-gray-400 mb-1.5 sm:mb-2",children:[e.jsx(t,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 flex-shrink-0"}),e.jsx("span",{className:"text-[10px] sm:text-xs truncate",children:a})]}),e.jsx("div",{className:"text-lg sm:text-2xl font-bold text-gray-900 dark:text-gray-100",children:N(s)})]},a))}):e.jsx(u,{to:"/website-analytics",className:"block p-4 rounded-xl border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 text-sm text-amber-800 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-900/30",children:"ã¢ã¯ã»ã¹è§£æã®ãã¼ã¿ãã¾ã 表示ã§ãã¾ãããã¯ãªãã¯ãã¦è¨å®ã»ç¢ºèªãã â"})]}),l&&l.totalEvents>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 flex items-center gap-2 mb-3",children:[e.jsx(y,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"}),"ã¤ãã³ãåå ã»ç´è¿12ãæ"]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[{label:"ã®ã¹åå è
",icon:f,value:`${N(l.totalPeople)}å`},{label:"éå¬åæ°",icon:y,value:`${l.totalEvents}å`},{label:"å¹³å/å",icon:j,value:`${l.avgPerEvent}å`},{label:"ãªãã¼ã¿ã¼",icon:O,value:`${l.repeaters}çµ`}].map(({label:a,icon:t,value:s})=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-500 dark:text-gray-400 mb-1.5",children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-[11px]",children:a})]}),e.jsx("div",{className:"text-lg sm:text-2xl font-bold text-gray-900 dark:text-gray-100",children:s})]},a))}),e.jsxs("div",{className:"p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"flex items-end gap-1 h-28",children:l.months.map(a=>{const t=Math.max(...l.months.map(r=>r.people),1),s=Math.round(a.people/t*100);return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1 min-w-0",children:[e.jsx("span",{className:"text-[9px] text-gray-500 dark:text-gray-400 tabular-nums",children:a.people>0?a.people:""}),e.jsx("div",{className:"w-full rounded-t bg-emerald-500/80 dark:bg-emerald-500/70 transition-all",style:{height:`${Math.max(s,a.people>0?4:0)}%`},title:`${a.label}: ã®ã¹${a.people}åã»${a.count}å`}),e.jsx("span",{className:"text-[9px] text-gray-400",children:a.label})]},a.key)})}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-2",children:"æå¥ã®ã¹åå è
æ°ï¼ãã£ã³ã»ã«å¾
ã¡ãé¤ãç»é²ãã¼ã¹ï¼"})]})]}),e.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200 mb-3",children:"å種ãã¼ã¿"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(({to:a,label:t,desc:s,icon:r})=>e.jsxs(u,{to:a,className:"group p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm hover:shadow-md hover:border-indigo-300 dark:hover:border-indigo-700 transition-all flex items-start gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gray-50 dark:bg-gray-700/50 group-hover:bg-indigo-50 dark:group-hover:bg-indigo-900/30",children:e.jsx(r,{className:"w-5 h-5 text-gray-600 dark:text-gray-300 group-hover:text-indigo-600 dark:group-hover:text-indigo-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-medium text-gray-900 dark:text-gray-100 flex items-center gap-1",children:[t,e.jsx(k,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 -translate-x-1 group-hover:translate-x-0 transition-all"})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:s})]})]},a))})]})}export{V as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.