1import{j as r,bd as R,u as w,be as g,bf as I,bg as $}from"./main-CRoKG4v1.js";import{a as D}from"./newsletter-ClNvgBLy.js";import{P as T,S as G,L,T as P}from"./filter-constants-DcRvIGTv.js";import{r as p,F as V,y as W,h as M,b as k,s as B}from"./icons-XSZ3OYVz.js";import{A as U,G as Y,F as E,S as q,a as z,I as H,b as J,L as K,C as Q,c as X,D as Z}from"./StatsBar-CQEQh0uR.js";import"./IssueReplyInput-ebDFkZ0I.js";import"./IssueDetailPanel-BskUEef2.js";import"./useAddReply-Ciu5QFgX.js";import{P as ee}from"./manage-newsletter-B3jhJToW.js";import"./about-BLu64JyC.js";import"./my-events-quA-HjSD.js";import"./index-DHJRIBCR.js";import"./LineChart-DlULXcZt.js";import"./generateCategoricalChart-CBnUvSO0.js";import"./PieChart-Bubu9bp5.js";import"./logo-control-JRSREu4O.js";import"./mapbox-overlay-xAcGcC2r.js";import"./IssueReplies-Bt6N1EHz.js";function xe(){return r.jsx(ee,{requiredTier:R.MUNICIPALITY,children:r.jsx(se,{})})}function se(){const{t:n}=w(),{categories:f,problems:o,problemsCount:O}=g.useLoaderData(),{filters:t}=g.useSearch(),c=g.useNavigate(),b=e=>{c({search:s=>({...s,filters:{...s.filters,search:e}})})},y=e=>{c({search:s=>({...s,filters:{...s.filters,categories:e}})})},v=e=>{c({search:s=>({...s,filters:{...s.filters,priorities:e}})})},x=e=>{c({search:s=>({...s,filters:{...s.filters,statuses:e}})})},S=e=>{c({search:s=>({...s,filters:{...s.filters,levels:e}})})},C=e=>{c({search:s=>({...s,filters:{...s.filters,timeframe:e}})})},_=e=>{c({search:s=>({...s,filters:{...s.filters,ageGroups:e}})})},N=e=>{c({search:s=>({...s,filters:{...s.filters,genders:e}})})},A=e=>{if(e.startsWith("search-")){const s=Number.parseInt(e.replace("search-",""));b(t.search.filter((l,a)=>a!==s));return}if(e.startsWith("category-")){const s=Number.parseInt(e.replace("category-",""));y(t.categories.filter((l,a)=>a!==s));return}if(e.startsWith("priority-")){const s=Number.parseInt(e.replace("priority-",""));v(t.priorities.filter((l,a)=>a!==s));return}if(e.startsWith("status-")){const s=Number.parseInt(e.replace("status-",""));x(t.statuses.filter((l,a)=>a!==s));return}if(e.startsWith("level-")){const s=Number.parseInt(e.replace("level-",""));S(t.levels.filter((l,a)=>a!==s));return}if(e.startsWith("ageGroup-")){const s=Number.parseInt(e.replace("ageGroup-",""));_(t.ageGroups.filter((l,a)=>a!==s));return}if(e.startsWith("gender-")){const s=Number.parseInt(e.replace("gender-",""));N(t.genders.filter((l,a)=>a!==s));return}if(e==="timeframe"){C("all");return}},F=()=>{c({search:e=>({...e,filters:$.parse({})})})},h=p.useMemo(()=>f?.map(e=>({value:e.id,label:e.name,count:o.filter(s=>s.issue_categories?.some(l=>l.category?.id===e.id)).length}))||[],[f,o]),u=p.useMemo(()=>U.map(e=>({value:e.value,label:e.label})),[]),m=p.useMemo(()=>Object.entries(Y).map(([e,s])=>({value:e,label:s})),[]),d=p.useMemo(()=>{const e=[];if(t.search?.length&&t.search.forEach((s,l)=>{e.push({id:`search-${l}`,label:s,type:"search",value:s})}),t.categories?.length&&t.categories.forEach((s,l)=>{const a=h.find(i=>i.value===s);e.push({id:`category-${l}`,label:a?.label||s,type:"category",value:s})}),t.priorities?.length&&t.priorities.forEach((s,l)=>{const a=T.find(i=>i.value===s);e.push({id:`priority-${l}`,label:a?.label||s,type:"priority",value:s})}),t.statuses?.length&&t.statuses.forEach((s,l)=>{const a=G.find(i=>i.value===s);e.push({id:`status-${l}`,label:a?.label||s,type:"status",value:s})}),t.levels?.length&&t.levels.forEach((s,l)=>{const a=L.find(i=>i.value===s);e.push({id:`level-${l}`,label:a?.label||s,type:"level",value:s})}),t.timeframe&&t.timeframe!=="all"){const s=P.find(l=>l.value===t.timeframe);e.push({id:"timeframe",label:s?.label||t.timeframe,type:"timeframe",value:t.timeframe})}return t.ageGroups?.length&&t.ageGroups.forEach((s,l)=>{const a=u.find(i=>i.value===s);e.push({id:`ageGroup-${l}`,label:a?.label||s,type:"ageGroup",value:s})}),t.genders?.length&&t.genders.forEach((s,l)=>{const a=m.find(i=>i.value===s);e.push({id:`gender-${l}`,label:a?.label||s,type:"gender",value:s})}),e},[t,h,u,m]),j=p.useMemo(()=>({onAddSearchTerm:e=>{t.search.includes(e)||b([...t.search,e])},activeFilters:d,onRemoveFilter:A,onClearAllFilters:F,filterConfigs:[{id:"category",label:n("municipality.analytics.filterLabels.category"),icon:W,options:h,selectedValues:t.categories,onSelectionChange:y,multiSelect:!0,showCounts:!0},{id:"timeframe",label:n("municipality.analytics.filterLabels.timeframe"),icon:M,options:P,selectedValues:[t.timeframe],onSelectionChange:e=>C(e[0]||"all"),multiSelect:!1,showCounts:!1},{id:"priority",label:n("municipality.analytics.filterLabels.priority"),icon:k,options:T,selectedValues:t.priorities,onSelectionChange:e=>v(e),multiSelect:!0,showCounts:!1},{id:"demographics",label:n("municipality.analytics.filterLabels.demographics"),icon:B,options:[...u.map(e=>({...e,label:n("municipality.analytics.filterLabels.agePrefix",{label:e.label})})),...m.map(e=>({...e,label:n("municipality.analytics.filterLabels.genderPrefix",{label:e.label})}))],selectedValues:[...t.ageGroups,...t.genders],onSelectionChange:e=>{const s=e.filter(a=>u.some(i=>i.value===a)),l=e.filter(a=>m.some(i=>i.value===a));_(s),N(l)},multiSelect:!0,showCounts:!1}],advancedFilterConfig:{id:"advanced",label:n("municipality.analytics.filterLabels.advanced"),icon:V,options:[...G.map(e=>({...e,value:`status_${e.value}`})),...L.map(e=>({...e,value:`level_${e.value}`}))],selectedValues:[...t.statuses.map(e=>`status_${e}`),...t.levels.map(e=>`level_${e}`)],onSelectionChange:e=>{const s=e.filter(a=>a.startsWith("status_")).map(a=>a.replace("status_","")),l=e.filter(a=>a.startsWith("level_")).map(a=>a.replace("level_",""));x(s),S(l)},multiSelect:!0,showCounts:!1}}),[t,d,h,u,m,n]);return r.jsx(I,{children:r.jsx("div",{className:"min-h-screen",children:r.jsxs("div",{className:"max-w-6xl px-6 pb-6 pt-8",children:[r.jsxs("div",{className:"mb-8",children:[r.jsx("h1",{className:"mb-2 text-2xl font-bold",children:n("sidebar.nav.dashboard")}),r.jsx("p",{className:"text-muted-foreground text-lg",children:n("politicianInbox.analytics.description")})]}),r.jsx("div",{className:"bg-background/80 sticky top-0 z-20 -mx-4 mb-6 px-4 backdrop-blur-md",children:r.jsx(E,{...j})}),r.jsx(q,{isLoading:!1,stats:[{label:n("municipality.analytics.totalConcerns"),value:O||0,sparkline:[40,45,48,52,55,58,62]},{label:n("municipality.analytics.unanswered"),value:o.filter(e=>e.status==="unanswered").length},{label:n("municipality.analytics.highPriority"),value:o.filter(e=>e.priority==="high").length},{label:n("municipality.analytics.thisWeek"),value:o.filter(e=>{if(!e.created_at)return!1;const s=new Date(e.created_at),l=new Date;return l.setDate(l.getDate()-7),s>l}).length,sparkline:[8,12,10,15,18,14,20]}],className:"mb-6"}),r.jsxs(D,{className:"mb-6",children:[r.jsx(z,{problems:o,isProblemsLoading:!1,filters:t,className:"md:col-span-2"}),r.jsx(H,{problems:o}),r.jsx(J,{problems:o,hasActiveFilters:d.length>0,filterBar:r.jsx(E,{...j})}),r.jsx(K,{problems:o}),r.jsx(Q,{problems:o,categories:f}),r.jsx(X,{problems:o}),r.jsx(Z,{problems:o})]})]})})})}export{xe as component};
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.