1import{r as n,j as e,A as C,w as P,a as p}from"./main-C2BHBFqc.js";function L(){const[h,w]=n.useState([]),[_,y]=n.useState(!0),[b,c]=n.useState(""),[f,i]=n.useState(""),[R,o]=n.useState(!1),[m,j]=n.useState(!1),[u,x]=n.useState(null),[a,d]=n.useState({pattern_type:"prefix",pattern:"",reason:"",status:!0}),[N,v]=n.useState(new Set),[E,S]=n.useState(null),g=async()=>{var t,l;y(!0);try{const{data:r}=await p.get("/admin/gsc/blocklist");w(r.data||[])}catch(r){c(((l=(t=r==null?void 0:r.response)==null?void 0:t.data)==null?void 0:l.message)||"Failed to load")}finally{y(!1)}};n.useEffect(()=>{g()},[]);const A=async t=>{var l,r;if(t.preventDefault(),!m){j(!0);try{u?(await p.put(`/admin/gsc/blocklist/${u.id}`,a),i("Pattern updated")):(await p.post("/admin/gsc/blocklist",a),i("Pattern added")),d({pattern_type:"prefix",pattern:"",reason:"",status:!0}),o(!1),x(null),g()}catch(s){c(((r=(l=s==null?void 0:s.response)==null?void 0:l.data)==null?void 0:r.message)||"Failed")}finally{j(!1)}}},D=t=>{x(t),d({pattern_type:t.pattern_type,pattern:t.pattern,reason:t.reason||"",status:!!t.status}),o(!0)},F=t=>{S({title:"Delete pattern?",message:"GSC sync will resume auto-creating tasks for URLs matching this pattern.",confirmText:"Delete",variant:"danger",onConfirm:async()=>{var l,r;v(s=>new Set(s).add(t));try{await p.delete(`/admin/gsc/blocklist/${t}`),i("Removed"),g()}catch(s){throw c(((r=(l=s==null?void 0:s.response)==null?void 0:l.data)==null?void 0:r.message)||"Failed"),s}finally{v(s=>{const k=new Set(s);return k.delete(t),k})}}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Task Blocklist"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"URL patterns where GSC sync should NOT auto-create tasks."})]}),e.jsx("button",{onClick:()=>{x(null),d({pattern_type:"prefix",pattern:"",reason:"",status:!0}),o(!0)},className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium",children:"+ Add Pattern"})]}),b&&e.jsx(C,{type:"error",message:b,onClose:()=>c("")}),f&&e.jsx(C,{type:"success",message:f,onClose:()=>i("")}),R&&e.jsxs("form",{onSubmit:A,className:"bg-white rounded-lg border border-gray-200 p-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),e.jsxs("select",{value:a.pattern_type,onChange:t=>d({...a,pattern_type:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"prefix",children:"Prefix (starts with)"}),e.jsx("option",{value:"exact",children:"Exact match"}),e.jsx("option",{value:"regex",children:"Regex"})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Pattern"}),e.jsx("input",{type:"text",required:!0,value:a.pattern,onChange:t=>d({...a,pattern:t.target.value}),placeholder:a.pattern_type==="regex"?"/^\\/admin\\//":"/admin/",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm font-mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Reason (optional)"}),e.jsx("input",{type:"text",value:a.reason,onChange:t=>d({...a,reason:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.status,onChange:t=>d({...a,status:t.target.checked})}),"Active"]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{o(!1),x(null)},className:"px-4 py-2 border border-gray-300 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:m,className:"px-4 py-2 bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white rounded-lg text-sm",children:m?"Savingâ¦":u?"Update":"Add"})]})]}),e.jsx("div",{className:"bg-white rounded-lg border border-gray-200",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-700",children:"Type"}),e.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-700",children:"Pattern"}),e.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-700",children:"Reason"}),e.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-700",children:"Hits"}),e.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-700",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-700",children:"Actions"})]})}),e.jsx("tbody",{children:_?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-gray-500",children:"Loadingâ¦"})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-gray-500",children:"No patterns yet"})}):h.map(t=>e.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-xs font-medium px-2 py-0.5 bg-gray-100 rounded",children:t.pattern_type})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs",children:t.pattern}),e.jsx("td",{className:"px-4 py-3 text-gray-600",children:t.reason||"â"}),e.jsx("td",{className:"px-4 py-3",children:t.hit_count}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${t.status?"bg-emerald-100 text-emerald-700":"bg-gray-100 text-gray-600"}`,children:t.status?"Active":"Disabled"})}),e.jsxs("td",{className:"px-4 py-3 text-right",children:[e.jsx("button",{onClick:()=>D(t),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded mr-1",children:"Edit"}),e.jsx("button",{onClick:()=>F(t.id),disabled:N.has(t.id),className:"px-2 py-1 text-xs text-red-600 hover:bg-red-50 disabled:opacity-50 rounded",children:N.has(t.id)?"Deletingâ¦":"Delete"})]})]},t.id))})]})})}),e.jsx(P,{state:E,onClose:()=>S(null)})]})}export{L 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.