1import{d as J,y as Q,r as a,E as A,z as X,j as e,H as z,D as Y,J as Z,K as I,a4 as ee,t as te,w as R,I as E,B as b,a5 as ae,G as se,a6 as ne,a7 as re}from"./index-C5ThO-dY.js";import{T as ce}from"./textarea-CVhfIIme.js";import{u as oe,C as S}from"./index-ChMotFah.js";import{L as ie}from"./lock-CDGCRKvU.js";import{T as le}from"./trash-2-BNYSMPKT.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const de=J("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var P="Switch",[ue,ye]=Q(P),[he,pe]=ue(P),L=a.forwardRef((n,c)=>{const{__scopeSwitch:s,name:m,checked:i,defaultChecked:k,required:u,disabled:h,value:x="on",onCheckedChange:j,form:p,...N}=n,[g,y]=a.useState(null),l=A(c,o=>y(o)),v=a.useRef(!1),C=g?p||!!g.closest("form"):!0,[w,r]=X({prop:i,defaultProp:k??!1,onChange:j,caller:P});return e.jsxs(he,{scope:s,checked:w,disabled:h,children:[e.jsx(z.button,{type:"button",role:"switch","aria-checked":w,"aria-required":u,"data-state":F(w),"data-disabled":h?"":void 0,disabled:h,value:x,...N,ref:l,onClick:Y(n.onClick,o=>{r(f=>!f),C&&(v.current=o.isPropagationStopped(),v.current||o.stopPropagation())})}),C&&e.jsx(q,{control:g,bubbles:!v.current,name:m,value:x,checked:w,required:u,disabled:h,form:p,style:{transform:"translateX(-100%)"}})]})});L.displayName=P;var U="SwitchThumb",V=a.forwardRef((n,c)=>{const{__scopeSwitch:s,...m}=n,i=pe(U,s);return e.jsx(z.span,{"data-state":F(i.checked),"data-disabled":i.disabled?"":void 0,...m,ref:c})});V.displayName=U;var fe="SwitchBubbleInput",q=a.forwardRef(({__scopeSwitch:n,control:c,checked:s,bubbles:m=!0,...i},k)=>{const u=a.useRef(null),h=A(u,k),x=oe(s),j=Z(c);return a.useEffect(()=>{const p=u.current;if(!p)return;const N=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(N,"checked").set;if(x!==s&&y){const l=new Event("click",{bubbles:m});y.call(p,s),p.dispatchEvent(l)}},[x,s,m]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...i,tabIndex:-1,ref:h,style:{...i.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});q.displayName=fe;function F(n){return n?"checked":"unchecked"}var K=L,me=V;const W=a.forwardRef(({className:n,...c},s)=>e.jsx(K,{className:I("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",n),...c,ref:s,children:e.jsx(me,{className:I("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));W.displayName=K.displayName;const xe=ee("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",glow:"border-primary/30 bg-primary/10 text-primary"}},defaultVariants:{variant:"default"}});function B({className:n,variant:c,...s}){return e.jsx("div",{className:I(xe({variant:c}),n),...s})}const ke=()=>{const[n,c]=a.useState(""),[s,m]=a.useState(!1),[i,k]=a.useState([]),[u,h]=a.useState(!1),[x,j]=a.useState(!1),[p,N]=a.useState("https://supportsquad-ai.lovable.app"),[g,y]=a.useState(null),[l,v]=a.useState({title:"",content:"",category:"faq"}),[C,w]=a.useState(!1),{toast:r}=te(),o=a.useCallback(async(t,d)=>{const G=t==="list"?"GET":"POST",{data:$,error:_}=await R.functions.invoke("admin-knowledge?action="+t,{method:G,body:d||void 0,headers:{"x-admin-password":n}});if(_)throw _;return $},[n]),f=a.useCallback(async()=>{h(!0);try{const t=await o("list");k(t)}catch{r({title:"Fout",description:"Kon artikelen niet laden",variant:"destructive"})}finally{h(!1)}},[o,r]),T=async()=>{try{await o("list"),m(!0)}catch{r({title:"Verkeerd wachtwoord",variant:"destructive"})}};a.useEffect(()=>{s&&f()},[s,f]);const D=async()=>
6{if(!(!l.title||!l.content))try{await o("create",l),v({title:"",content:"",category:"faq"}),w(!1),f(),r({title:"Artikel aangemaakt"})}catch{r({title:"Fout bij aanmaken",variant:"destructive"})}},H=async t=>{try{await o("update",{id:t.id,active:!t.active,title:t.title,content:t.content,category:t.category}),f()}catch{r({title:"Fout bij updaten",variant:"destructive"})}},M=async t=>{if(confirm("Weet je het zeker?"))try{await o("delete",{id:t}),f(),r({title:"Verwijderd"})}catch{r({title:"Fout bij verwijderen",variant:"destructive"})}},O=async()=>{j(!0);try{const{data:t,error:d}=await R.functions.invoke("scrape-website",{body:{url:p,maxPages:30},headers:{"x-admin-password":n}});if(d)throw d;r({title:"Website gescand",description:`${t.pagesScraped} pagina's opgeslagen`}),f()}catch{r({title:"Scan mislukt",variant:"destructive"})}finally{j(!1)}};return s?e.jsx("div",{className:"min-h-screen bg-background p-4 md:p-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Kennisbank"}),e.jsxs(b,{variant:"outline",size:"sm",onClick:f,disabled:u,children:[e.jsx(ae,{className:`w-4 h-4 mr-1 ${u?"animate-spin":""}`})," Vernieuwen"]})]}),e.jsxs(S,{className:"p-4 space-y-3",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4"})," Website Scannen"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{value:p,onChange:t=>N(t.target.value),placeholder:"https://jouwwebsite.nl",className:"flex-1"}),e.jsx(b,{onClick:O,disabled:x,children:x?"Bezig met scannen...":"Scan Website"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Scant tot 30 pagina's en slaat de content op als kennisartikelen. Vervangt eerdere website-scans."})]}),e.jsx(S,{className:"p-4",children:C?e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{placeholder:"Titel",value:l.title,onChange:t=>v(d=>({...d,title:t.target.value}))}),e.jsx(ce,{placeholder:"Content",rows:4,value:l.content,onChange:t=>v(d=>({...d,content:t.target.value}))}),e.jsxs("select",{className:"w-full p-2 rounded border bg-background",value:l.category,onChange:t=>v(d=>({...d,category:t.target.value})),children:[e.jsx("option",{value:"faq",children:"FAQ"}),e.jsx("option",{value:"product",children:"Product"}),e.jsx("option",{value:"procedure",children:"Procedure"}),e.jsx("option",{value:"general",children:"Algemeen"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{onClick:D,children:"Opslaan"}),e.jsx(b,{variant:"outline",onClick:()=>w(!1),children:"Annuleren"})]})]}):e.jsxs(b,{variant:"outline",onClick:()=>w(!0),className:"w-full",children:[e.jsx(ne,{className:"w-4 h-4 mr-1"})," Nieuw artikel toevoegen"]})}),e.jsxs("div",{className:"space-y-2",children:[i.map(t=>e.jsxs(S,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:()=>y(g===t.id?null:t.id),children:[g===t.id?e.jsx(de,{className:"w-4 h-4 shrink-0"}):e.jsx(re,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:t.title}),e.jsx(B,{variant:"secondary",className:"shrink-0",children:t.category}),e.jsx(B,{variant:"outline",className:"shrink-0",children:t.source})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[e.jsx(W,{checked:t.active,onCheckedChange:()=>H(t)}),e.jsx(b,{variant:"ghost",size:"icon",onClick:()=>M(t.id),children:e.jsx(le,{className:"w-4 h-4 text-destructive"})})]})]}),g===t.id&&e.jsxs("div",{className:"mt-3 text-sm text-muted-foreground whitespace-pre-wrap max-h-60 overflow-auto",children:[t.content,t.source_url&&e.jsxs("p",{className:"mt-2 text-xs",children:["Bron: ",e.jsx("a",{href:t.source_url,target:"_blank",rel:"noopener",className:"underline",children:t.source_url})]})]})]},t.id)),i.length===0&&!u&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"Nog geen kennisartikelen. Voeg er een toe of scan je website."})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs(S,{className:"p-8 w-full max-w-sm space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"w-5 h-5"}),e.jsx("h1",{className:"text-xl font-bold",children:"Kennisbank Admin"})]}),e.jsx(E,{type:"password",placeholder:"Wachtwoord",value:n,onChange:t=>c(t.target.value),onKeyDown:t=>t.key==="Enter"&&T()}),e.jsx(b,{onClick:T,className:"w-full",children:"Inloggen"})]})})};export{ke 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.