1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1847,4228,6929],{6929:(e,t,a)=>{a.r(t),a.d(t,{default:()=>x});var s=a(95155),l=a(12115),r=a(39867),n=a(89559),c=a(3998),i=a(80344),o=a(64269),d=a(88832);let u={available:"bg-emerald-100 text-emerald-800",unverified:"bg-sky-100 text-sky-800",partial:"bg-amber-100 text-amber-800",stale:"bg-amber-100 text-amber-800",missing:"bg-slate-100 text-slate-600",processing_failed:"bg-rose-100 text-rose-800",unavailable_at_source:"bg-slate-200 text-slate-700"};function m(e){return"".concat(Math.round(100*e),"%")}function x(){var e;let t=(0,d.v)(),[a,x]=(0,l.useState)(null),[v,b]=(0,l.useState)(!1),[g,j]=(0,l.useState)(null),[y,f]=(0,l.useState)("score"),[_,N]=(0,l.useState)("asc"),[w,k]=(0,l.useState)(new Set),C=(0,l.useCallback)(async()=>{b(!0),j(null);try{let e=await i.uE.get("/admin/terra/coverage-score");x(e)}catch(e){j(e instanceof Error?e.message:"Failed to load coverage scores")}finally{b(!1)}},[]);(0,l.useEffect)(()=>{t&&C()},[t,C]);let M=(0,l.useCallback)(e=>{y===e?N(e=>"asc"===e?"desc":"asc"):(f(e),N("asc"))},[y]),S=(0,l.useCallback)(e=>{k(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},[]),A=(0,l.useMemo)(()=>{var e;let t=null!=(e=null==a?void 0:a.municipalities)?e:[],s="asc"===_?1:-1;return[...t].sort((e,t)=>{switch(y){case"score":return(e.coverage_score-t.coverage_score)*s;case"name":return(e.municipality_name||"").localeCompare(t.municipality_name||"")*s;case"status":return(e.overall_status||"").localeCompare(t.overall_status||"")*s;default:return 0}})},[a,y,_]),L=(0,l.useCallback)(()=>{var e;if(!a)return;let t=new Blob(["municipality_id,municipality_name,coverage_score,overall_status,documents\n"+(null!=(e=a.municipalities)?e:[]).map(e=>{var t,a;let s=e.documents.map(e=>"".concat(e.label_en,": ").concat(e.status)).join("; ");return"".concat(e.municipality_id,',"').concat((e.municipality_name||"").replace(/"/g,'""'),'",').concat(e.coverage_score,",").concat(e.overall_status,",").concat(null!=(t=e.release_tier)?t:"none",",").concat(null!=(a=e.valid_until)?a:"",',"').concat(s,'"')}).join("\n")],{type:"text/csv;charset=utf-8"}),s=URL.createObjectURL(t),l=document.createElement("a");l.href=s,l.download="coverage-scores-".concat(a.snapshot_date||"latest",".csv"),document.body.appendChild(l),l.click(),l.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)},[a]),E=null==a?void 0:a.aggregate;return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-slate-800",children:"Document Coverage Score"}),(0,s.jsxs)("p",{className:"max-w-3xl text-sm text-slate-500",children:["Weighted share of required documents (PDM regulation, zoning layers, national statutes, establishing act) that are available per municipality.",(null==a?void 0:a.snapshot_date)&&(0,s.jsxs)(s.Fragment,{children:[" ","Snapshot: ",a.snapshot_date,null!=a.snapshot_age_h&&(0,s.jsxs)(s.Fragment,{children:[" (",a.snapshot_age_h,"h ago)"]}),"."]})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(c.$,{variant:"outline",size:"sm",onClick:L,disabled:!(null==a||null==(e=a.municipalities)?void 0:e.length),children:[(0,s.jsx)(r.A,{className:"mr-1 h-3.5 w-3.5"}),"CSV"]}),(0,s.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>void C(),disabled:v,children:[(0,s.jsx)(n.A,{className:(0,o.cn)("mr-1 h-3.5 w-3.5",v&&"animate-spin")}),"Refresh"]})]})]}),g?(0,s.jsx)("div",{className:"rounded border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-700",children:g}):null,(null==a?void 0:a.message)&&!g?(0,s.jsx)("div",{className:"rounded border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-700",children:a.message}):null,E?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-7",children:[(0,s.jsx)(h,{label:"Municipalities",value:E.municipalities_scored}),(0,s.jsx)(h,{label:"Mean",value:m(E.mean)}),(0,s.jsx)(h,{label:"Median",value:m(E.median)}),(0,s.jsx)(h,{label:"Min",value:m(E.min)}),(0,s.jsx)(h,{label:"Max",value:m(E.max)}),(0,s.jsx)(h,{label:"Fully covered",value:"".concat(E.fully_covered," / ").concat(E.municipalities_scored)}),(0,s.jsx)(h,{label:"Silent detectors",value:E.silent_detectors_total,warn:E.silent_detectors_total>0})]}):null,(null==E?void 0:E.status_counts)?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.entries(E.status_counts).sort((e,t)=>
1{let[,a]=e,[,s]=t;return s-a}).map(e=>{let[t,a]=e;return(0,s.jsxs)("span",{className:(0,o.cn)("rounded px-2 py-0.5 text-xs font-medium",u[t]||"bg-slate-100 text-slate-600"),children:[t,": ",a]},t)})}):null,A.length>0?(0,s.jsx)("div",{className:"overflow-x-auto rounded border border-slate-200",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"border-b bg-slate-50 text-left text-xs font-medium uppercase tracking-wide text-slate-500",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)(p,{label:"Municipality",sortKey:"name",current:y,dir:_,onClick:M}),(0,s.jsx)(p,{label:"Score",sortKey:"score",current:y,dir:_,onClick:M}),(0,s.jsx)(p,{label:"Status",sortKey:"status",current:y,dir:_,onClick:M}),(0,s.jsx)("th",{className:"px-3 py-2",children:"Documents"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-slate-100",children:A.map(e=>{var t;let a=w.has(e.municipality_id);return(0,s.jsxs)("tr",{className:"hover:bg-slate-50/50",children:[(0,s.jsx)("td",{className:"px-3 py-2 font-medium text-slate-800",children:e.municipality_name||"#".concat(e.municipality_id)}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"h-2 w-24 overflow-hidden rounded-full bg-slate-100",children:(0,s.jsx)("div",{className:(0,o.cn)("h-full rounded-full transition-all",(t=e.coverage_score)>=.8?"bg-emerald-500":t>=.5?"bg-amber-400":"bg-rose-500"),style:{width:"".concat(Math.round(100*e.coverage_score),"%")}})}),(0,s.jsx)("span",{className:"min-w-[3ch] text-right tabular-nums text-slate-700",children:m(e.coverage_score)})]})}),(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:(0,o.cn)("rounded px-1.5 py-0.5 text-xs font-medium",u[e.overall_status]||"bg-slate-100 text-slate-600"),children:e.overall_status})}),(0,s.jsxs)("td",{className:"px-3 py-2",children:[(0,s.jsx)("button",{type:"button",className:"text-xs text-blue-600 hover:underline",onClick:()=>S(e.municipality_id),children:a?"Hide":"".concat(e.documents.length," docs")}),a&&e.documents.length>0?(0,s.jsx)("div",{className:"mt-1 space-y-1",children:e.documents.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsx)("span",{className:(0,o.cn)("inline-block w-2 h-2 rounded-full flex-shrink-0","available"===e.status?"bg-emerald-500":"missing"===e.status?"bg-rose-400":"bg-amber-400")}),(0,s.jsx)("span",{className:"text-slate-600",children:e.label_en}),(0,s.jsx)("span",{className:(0,o.cn)("rounded px-1 py-0.5 text-[10px] font-medium",u[e.status]||"bg-slate-100 text-slate-600"),children:e.status}),(0,s.jsxs)("span",{className:"text-slate-400",children:["w=",e.weight]})]},t))}):null]})]},e.municipality_id)})})]})}):v||g||!a?null:(0,s.jsx)("p",{className:"text-sm text-slate-400",children:"No coverage data available."}),v&&!a?(0,s.jsx)("p",{className:"text-sm text-slate-400",children:"Loading..."}):null]})}function h(e){let{label:t,value:a,warn:l}=e;return(0,s.jsxs)("div",{className:(0,o.cn)("rounded border px-3 py-2",l?"border-amber-200 bg-amber-50":"border-slate-200 bg-white"),children:[(0,s.jsx)("div",{className:"text-xs text-slate-500",children:t}),(0,s.jsx)("div",{className:(0,o.cn)("text-lg font-semibold",l?"text-amber-700":"text-slate-800"),children:a})]})}function p(e){let{label:t,sortKey:a,current:l,dir:r,onClick:n}=e,c=l===a;return(0,s.jsx)("th",{className:"px-3 py-2",children:(0,s.jsxs)("button",{type:"button",className:"flex items-center gap-1 hover:text-slate-800",onClick:()=>n(a),children:[t,c?(0,s.jsx)("span",{className:"text-[10px]",children:"asc"===r?"^":"v"}):null]})})}},39867:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(71847).A)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},71847:(e,t,a)=>{a.d(t,{A:()=>c});var s=a(12115);let l=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim()};var r={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let n=(0,s.forwardRef)((e,t)=>{let{color:a="currentColor",size:n=24,strokeWidth:c=2,absoluteStrokeWidth:i,className:o="",children:d,iconNode:u,...m}=e;return(0,s.createElement)("svg",{ref:t,...r,width:n,height:n,stroke:a,strokeWidth:i?24*Number(c)/Number(n):c,className:l("lucide",o),...m},[...u.map(e=>
1{let[t,a]=e;return(0,s.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let a=(0,s.forwardRef)((a,r)=>{let{className:c,...i}=a;return(0,s.createElement)(n,{ref:r,iconNode:t,className:l("lucide-".concat(e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),c),...i})});return a.displayName="".concat(e),a}},89559:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(71847).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])}}]);
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.