PageSourceSearch

https://hellolumen.ai/assets/Settings-BlBUoBqE.js

js hellolumen.ai collected 2026-10-05 14:20:39 UTC 332,508 bytes, 28 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BbUi1KSl.js","assets/radix-7KI6mJPD.js","assets/highcharts-DAm76Z6K.js","assets/recharts-CAKF_bA0.js","assets/tanstack-B2cSsH6e.js","assets/react-vendor-BDlMpkbs.js","assets/tiptap-Sol8dTPd.js","assets/motion-DQzAdaMo.js","assets/index-D-XLB9lt.css"])))=>i.map(i=>d[i]);
2import{eY as Dl,u as ss,s as o,e as R,f as J,h as Q,dI as ps,i as Z,j as G,B as p,bA as At,L as b,I as q,a as he,d6 as Zr,c as Ms,bc as Ol,bl as Ne,g1 as Ml,aM as be,b5 as Vl,M as zl,R as it,V as lt,a0 as ot,dV as Ll,v as Kl,aJ as ct,S as Vs,br as Re,b0 as ia,dB as Pt,H as ae,_ as wt,bJ as Xe,d5 as ln,cH as $l,Y as ks,$ as Ss,ab as Se,bp as Is,aa as Ds,bB as Rl,c5 as ws,J as os,K as cs,N as ds,O as us,Q as U,aq as Nt,bO as Js,d3 as Gl,ca as Ts,a3 as ql,bj as on,bD as kt,ay as fn,az as vn,aA as Je,bo as Wa,bz as la,ct as Ul,aE as We,C as ei,P as si,T as Fs,D as Zt,k as ea,l as sa,m as ta,q as It,by as Ni,n as ki,cI as Hs,A as Bl,X as zs,b1 as oa,aV as Os,b as Ks,cD as Hl,g2 as ti,dL as Jl,aw as aa,Z as ns,ak as Wl,bk as Ql,aY as Si,p as Yl,es as Rs,af as Ws,aW as St,cg as Xl,cf as Zl,F as eo,cK as so,b6 as to,b7 as ge,aO as ao,aK as Ci,E as at,aT as Qa,aS as no,aQ as ca,d8 as ro,g3 as ai,bi as ra,db as ni,dF as io,eB as lo,w as oo,bV as co,bv as ri,d as ii,cC as uo,aZ as mo}from"./index-BbUi1KSl.js";import{j as e}from"./radix-7KI6mJPD.js";import{r as a}from"./highcharts-DAm76Z6K.js";import{P as ho}from"./PageTransition-DLn4QQ4W.js";import{A as xs,b as Ct,a as gs}from"./alert-CTkodxa6.js";import{Q as po}from"./index-CMVeBlTt.js";import{Q as xo,S as go,R as na,B as fo}from"./shield-off-CNcpsNou.js";import{P as vo}from"./PageBreadcrumb-DNvI_kLy.js";import{u as jo}from"./useRBACRouteProtection-BM2HAdv0.js";import{u as bo}from"./useLocalStorageBoolean-CSJAS6fJ.js";import{a as es,u as Es,b as ze}from"./tanstack-B2cSsH6e.js";import{Y as $s}from"./youtube-B4nUn7SS.js";import{F as Ai}from"./file-pen-CZzi30-v.js";import{m as Be,A as yo}from"./motion-DQzAdaMo.js";import{L as _o}from"./LogoMediaLibrary-DYzMHPAc.js";import{A as cn,a as dn,b as un,c as mn,d as hn,e as pn,f as xn,g as gn,h as wo}from"./alert-dialog-B2-XbRWq.js";import{R as No,a as ko}from"./radio-group-Ds0ay9xO.js";import{P as li}from"./panels-top-left-BCTlF9Bn.js";import{C as Qt}from"./calendar-DLv6ZC3s.js";import{L as dt}from"./languages-CAMPtTNX.js";import{P as So}from"./pause-DmwokjBG.js";import{P as Co}from"./pen-CgYfNDCy.js";import{R as Ao}from"./ResilientBoundary-DZD4vPUS.js";import{E as nt}from"./eye-off-BOgZaMGj.js";import{u as Pi,L as Po}from"./react-vendor-BDlMpkbs.js";import{S as Io}from"./SchemaDumpButton-AQFV3OR6.js";function To(t,n){return Dl(t,-1)}const Eo=({onComplete:t})=>{const[n,i]=a.useState(!1),[l,d]=a.useState(null),[m,g]=a.useState(null),[v,u]=a.useState(""),[w,N]=a.useState([]),[k,j]=a.useState(!1),{toast:I}=ss();a.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:B,error:L}=await o.functions.invoke("mfa-setup",{body:{action:"status"}});if(L)throw L;d(B)}catch(B){}},V=async()=>{i(!0);try{const{data:B,error:L}=await o.functions.invoke("mfa-setup",{body:{action:"setup"}});if(L)throw L;g({secret:B.secret,otpAuthUrl:B.otpAuthUrl}),I({title:"2FA Setup gestart",description:"Scan de QR-code met je Authy of authenticator app."})}catch(B){I({title:"Fout bij starten 2FA setup",description:B.message,variant:"destructive"})}finally{i(!1)}},me=async()=>{if(v.length!==6){I({title:"Ongeldige code",description:"Voer een 6-cijferige code in.",variant:"destructive"});return}i(!0);try{const{data:B,error:L}=await o.functions.invoke("mfa-setup",{body:{action:"verify",code:v}});if(L)throw L;if(B.success)N(B.backupCodes||[]),j(!0),g(null),await f(),I({title:"2FA Ingeschakeld!",description:"Bewaar je backup codes veilig!"});else throw new Error(B.error||"Verificatie mislukt")}catch(B){I({title:"Verificatie mislukt",description:B.message,variant:"destructive"})}finally{i(!1)}},ee=async()=>{const B=prompt("Voer je huidige 2FA code in om uit te schakelen:");if(B){i(!0);try{const{data:L,error:F}=await o.functions.invoke("mfa-setup",{body:{action:"disable",code:B}});if(F)throw F;if(L.success)await f(),I({title:"2FA Uitgeschakeld",description:"Twee-factor authenticatie is uitgeschakeld."});else throw new Error(L.error||"Kon 2FA niet uitschakelen")}catch(L){I({title:"Fout bij uitschakelen",description:L.message,variant:"destructive"})}finally{i(!1)}}},ue=()=>{navigator.clipboard.writeText(w.join(`
3`)),I({title:"Gekopieerd!",description:"Backup codes zijn naar je klembord gekopieerd."})},je=()=>{j(!1),t==null||t()};return k&&w.length>0?e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Backup Codes"]}
3),e.jsx(Z,{children:"Bewaar deze codes veilig! Je kunt ze gebruiken als je geen toegang hebt tot je authenticator app."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs(xs,{variant:"destructive",children:[e.jsx(Ct,{children:"Belangrijk!"}),e.jsx(gs,{children:"Elke code kan maar één keer gebruikt worden. Bewaar ze op een veilige plek."})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 p-4 bg-muted rounded-lg font-mono text-sm",children:w.map(B=>e.jsx("div",{className:"p-2 bg-background rounded border",children:B},`backup-${B}`))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{variant:"outline",onClick:ue,className:"flex-1",children:[e.jsx(At,{className:"h-4 w-4 mr-2"}),"Kopieer codes"]}),e.jsx(p,{onClick:je,className:"flex-1",children:"Ik heb ze opgeslagen"})]})]})]}):m?e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-primary"}),"2FA Instellen"]}),e.jsx(Z,{children:"Scan de QR-code met Authy, Google Authenticator of een andere TOTP app."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsx("div",{className:"flex justify-center p-4 bg-white rounded-lg",children:e.jsx(po,{value:m.otpAuthUrl,size:200,level:"M"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"Of voer deze code handmatig in:"}),e.jsx("div",{className:"p-3 bg-muted rounded-lg font-mono text-sm break-all select-all",children:m.secret})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"verification-code",children:"Verificatiecode"}),e.jsx(q,{id:"verification-code",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,placeholder:"000000",value:v,onChange:B=>u(B.target.value.replace(/\D/g,"").slice(0,6)),className:"text-center text-2xl tracking-widest font-mono"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Voer de 6-cijferige code van je authenticator app in"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",onClick:()=>g(null),disabled:n,className:"flex-1",children:"Annuleren"}),e.jsx(p,{onClick:me,disabled:n||v.length!==6,className:"flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Verifiëren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"Activeren"]})})]})]})]}):e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-5 w-5 text-primary"}),"Twee-Factor Authenticatie"]}),e.jsx(Z,{children:"Voeg een extra beveiligingslaag toe aan je account met 2FA via Authy of een andere authenticator app."})]}),e.jsx(G,{className:"space-y-4",children:l!=null&&l.enabled?e.jsxs(e.Fragment,{children:[e.jsxs(xs,{className:"border-green-500/20 bg-green-500/10",children:[e.jsx(Zr,{className:"h-4 w-4 text-green-500"}),e.jsx(Ct,{children:"2FA is ingeschakeld"}),e.jsxs(gs,{children:["Je account is beveiligd met twee-factor authenticatie.",l.backupCodesRemaining>0&&e.jsxs("span",{className:"block mt-1 text-xs",children:[l.backupCodesRemaining," backup codes beschikbaar"]})]})]}),e.jsx(p,{variant:"destructive",onClick:ee,disabled:n,className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Uitschakelen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(go,{className:"h-4 w-4 mr-2"}),"2FA Uitschakelen"]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(xs,{children:[e.jsx(Ms,{className:"h-4 w-4"}),e.jsx(Ct,{children:"Extra beveiliging aanbevolen"}),e.jsx(gs,{children:"Bescherm je account tegen ongeautoriseerde toegang door 2FA in te schakelen."})]}),e.jsx(p,{onClick:V,disabled:n,className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Opstarten..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-4 w-4 mr-2"}),"2FA Inschakelen"]})})]})})]})},Fo=()=>{const{user:t}=Ol(),[n,i]=a.useState(null),[l,d]=a.useState(!0),m=a.useCallback(async()=>{if(!(t!=null&&t.id)){i(null),d(!1);return}try{const{data:v,error:u}=await o.from("user_privacy_consent").select("*").eq("user_id",t.id).single();
3u&&u.code,i(v?{analyticsConsent:v.analytics_consent,marketingConsent:v.marketing_consent,trackingConsent:v.tracking_consent,consentGivenAt:v.consent_given_at}:null)}catch(v){}finally{d(!1)}},[t==null?void 0:t.id]);a.useEffect(()=>{m()},[m]);const g=a.useCallback(async v=>{var u,w,N,k,j,I;if(t!=null&&t.id)try{const f={user_id:t.id,analytics_consent:(w=(u=v.analyticsConsent)!=null?u:n==null?void 0:n.analyticsConsent)!=null?w:!1,marketing_consent:(k=(N=v.marketingConsent)!=null?N:n==null?void 0:n.marketingConsent)!=null?k:!1,tracking_consent:(I=(j=v.trackingConsent)!=null?j:n==null?void 0:n.trackingConsent)!=null?I:!1,consent_given_at:new Date().toISOString(),updated_at:new Date().toISOString()},{error:V}=await o.from("user_privacy_consent").upsert(f,{onConflict:"user_id"});if(V)throw V;i({analyticsConsent:f.analytics_consent,marketingConsent:f.marketing_consent,trackingConsent:f.tracking_consent,consentGivenAt:f.consent_given_at})}catch(f){throw f}},[t==null?void 0:t.id,n]);return{consent:n,isLoading:l,updateConsent:g,hasGivenConsent:!!(n!=null&&n.consentGivenAt)}},Do=()=>{const{consent:t,updateConsent:n,isLoading:i}=Fo(),{toast:l}=ss(),[d,m]=a.useState(!1),[g,v]=a.useState(!1),[u,w]=a.useState(!1),[N,k]=a.useState(!1),[j,I]=a.useState(!1);a.useEffect(()=>{t&&(m(t.analyticsConsent),v(t.marketingConsent),w(t.trackingConsent))},[t]),a.useEffect(()=>{t&&I(d!==t.analyticsConsent||g!==t.marketingConsent||u!==t.trackingConsent)},[d,g,u,t]);const f=async()=>{k(!0);try{await n({analyticsConsent:d,marketingConsent:g,trackingConsent:u}),l({title:"Voorkeuren opgeslagen",description:"Je privacyvoorkeuren zijn bijgewerkt."}),I(!1)}catch(V){l({title:"Fout",description:"Kon voorkeuren niet opslaan.",variant:"destructive"})}finally{k(!1)}};return i?e.jsx(R,{className:"border-primary/20",children:e.jsx(G,{className:"flex items-center justify-center p-8",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-5 w-5 text-primary"}),"Privacy Voorkeuren"]}),e.jsx(Z,{children:"Beheer welke gegevens je met ons deelt. Je kunt deze instellingen op elk moment wijzigen."})]}),e.jsxs(G,{className:"space-y-6",children:[(t==null?void 0:t.consentGivenAt)&&e.jsxs(xs,{className:"border-green-500/20 bg-green-500/10",children:[e.jsx(Ne,{className:"h-4 w-4 text-green-500"}),e.jsxs(gs,{children:["Laatst bijgewerkt: ",new Date(t.consentGivenAt).toLocaleDateString("nl-NL",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(Ml,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(b,{className:"font-medium",children:"Essentiële Cookies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Noodzakelijk voor de werking van de applicatie. Kan niet uitgeschakeld worden."})]})]}),e.jsx(be,{checked:!0,disabled:!0})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10",children:e.jsx(Vl,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"analytics-setting",className:"font-medium",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Helpt ons de applicatie te verbeteren door anonieme gebruiksstatistieken te verzamelen."})]})]}),e.jsx(be,{id:"analytics-setting",checked:d,onCheckedChange:m})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10",children:e.jsx(zl,{className:"h-5 w-5 text-purple-500"})}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"marketing-setting",className:"font-medium",children:"Marketing Communicatie"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ontvang updates, tips en gepersonaliseerde aanbevelingen via email."})]})]}),e.jsx(be,{id:"marketing-setting",checked:g,onCheckedChange:v})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10",children:e.jsx(Ms,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"tracking-setting",className:"font-medium",children:"Gedragstracking"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Volgt je navigatie en klikgedrag om de gebruikerservaring te personaliseren."})]})]}),e.jsx(be,{id:"tracking-setting",checked:u,onCheckedChange:w})]}),j&&e.jsx(p,{onClick:f,disabled:N,className:"w-full",children:N?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Opslaan..."]}):"Wijzigingen Opslaan"})]})]})},Oo=t=>{const[n,i,l]=t.split(" ").map(f=>parseFloat(f.replace("%",""))),d=n/360,m=i/100,g=l/100,v=(1-Math.abs(2*g-1))*m,u=v*(1-Math.abs(d*6%2-1)),w=g-v/2;let N=0,k=0,j=0;d<1/6?(N=v,k=u,j=0):d<2/6?(N=u,k=v,j=0):d<3/6?(N=0,k=v,j=u):d<4/6?(N=0,k=u,j=v):d<5/6?(N=u,k=0,j=v):(N=v,k=0,j=u);const I=f=>{const V=Math.round((f+w)*255).toString(16);return V.length===1?"0"+V:V};return`#${I(N)}${I(k)}${I(j)}`},Mo=t=>{const n=parseInt(t.slice(1,3),16)/255,i=parseInt(t.slice(3,5),16)/255,l=parseInt(t.slice(5,7),16)/255,d=Math.max(n,i,l),m=Math.min(n,i,l);let g=0,v=0,u=(d+m)/2;if(d!==m){const w=d-m;switch(v=u>.5?w/(2-d-m):w/(d+m),d){case n:g=((i-l)/w+(i<l?6:0))/6;break;case i:g=((l-n)/w+2)/6;break;case l:g=((n-i)/w+4)/6;break}}return`${Math.round(g*360)} ${Math.round(v*100)}% ${Math.round(u*100)}%`};function as({label:t,hslValue:n,onChange:i,description:l}){const d=Oo(n),m=u=>{const w=Mo(u);i(w)},g=u=>{i(u.target.value)},v=u=>{navigator.clipboard.writeText(u),Kl.success("Gekopieerd naar klembord")};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:t}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsx(p,{variant:"outline",className:"w-12 h-12 p-0 border-2",style:{backgroundColor:`hsl(${n})`},"aria-label":`Kies kleur voor ${t}`})}),e.jsxs(ot,{className:"w-auto p-3",align:"start",children:[e.jsx(Ll,{c
3olor:d,onChange:m}),e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{value:d,onChange:u=>m(u.target.value),className:"font-mono text-sm",placeholder:"#000000"}),e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>v(d),children:e.jsx(At,{className:"h-4 w-4"})})]})})]})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsx(q,{type:"text",value:n,onChange:g,placeholder:"360 100% 50%",className:"font-mono text-sm"}),e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>v(`hsl(${n})`),children:e.jsx(At,{className:"h-4 w-4"})})]})]})]})}var Vo=Object.defineProperty,oi=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable,ci=(t,n,i)=>n in t?Vo(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Ko=(t,n)=>{for(var i in n||(n={}))zo.call(n,i)&&ci(t,i,n[i]);if(oi)for(var i of oi(n))Lo.call(n,i)&&ci(t,i,n[i]);return t};const $o={cron_push_enabled:!0,cron_push_interval_minutes:30,cron_push_last_run:null,cron_health_enabled:!0,cron_health_interval_minutes:5,cron_ai_ranking_enabled:!0,cron_ai_ranking_interval_minutes:180,cron_ai_ranking_last_run:null,snapshot_enabled:!0,snapshot_interval_months:4,snapshot_day_range:7,snapshot_last_run:null},Ya={push_enabled:!1,push_trigger_type:"time",push_trigger_time_seconds:30,push_trigger_on_exit:!0,push_trigger_scroll_depth:50,push_prompt_title:"Wil je op de hoogte blijven?",push_prompt_message:"Ontvang meldingen over relevante updates en aanbiedingen."},Ro=()=>es({queryKey:["cronSettings"],queryFn:async()=>{var t,n,i,l,d,m,g,v,u,w,N,k;const{data:j,error:I}=await o.from("platform_settings").select("cron_push_enabled, cron_push_interval_minutes, cron_push_last_run, cron_health_enabled, cron_health_interval_minutes, cron_ai_ranking_enabled, cron_ai_ranking_interval_minutes, cron_ai_ranking_last_run, snapshot_enabled, snapshot_interval_months, snapshot_day_range, snapshot_last_run").eq("id",1).maybeSingle();return I?$o:{cron_push_enabled:(t=j==null?void 0:j.cron_push_enabled)!=null?t:!0,cron_push_interval_minutes:(n=j==null?void 0:j.cron_push_interval_minutes)!=null?n:30,cron_push_last_run:(i=j==null?void 0:j.cron_push_last_run)!=null?i:null,cron_health_enabled:(l=j==null?void 0:j.cron_health_enabled)!=null?l:!0,cron_health_interval_minutes:(d=j==null?void 0:j.cron_health_interval_minutes)!=null?d:5,cron_ai_ranking_enabled:(m=j==null?void 0:j.cron_ai_ranking_enabled)!=null?m:!0,cron_ai_ranking_interval_minutes:(g=j==null?void 0:j.cron_ai_ranking_interval_minutes)!=null?g:180,cron_ai_ranking_last_run:(v=j==null?void 0:j.cron_ai_ranking_last_run)!=null?v:null,snapshot_enabled:(u=j==null?void 0:j.snapshot_enabled)!=null?u:!0,snapshot_interval_months:(w=j==null?void 0:j.snapshot_interval_months)!=null?w:4,snapshot_day_range:(N=j==null?void 0:j.snapshot_day_range)!=null?N:7,snapshot_last_run:(k=j==null?void 0:j.snapshot_last_run)!=null?k:null}},staleTime:60*1e3}),Ii=()=>{const t=Es(),{toast:n}=ss();return ze({mutationFn:async i=>{const{error:l}=await o.from("platform_settings").update(i).eq("id",1);if(l)throw l;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["cronSettings"]}),n({title:"Opgeslagen",description:"Cronjob instellingen zijn bijgewerkt."})},onError:i=>{n({title:"Fout",description:i.message,variant:"destructive"})}})},Go=t=>es({queryKey:["pushTriggerSettings",t],queryFn:async()=>{var n,i,l,d,m,g,v;if(!t)return Ya;const{data:u,error:w}=await o.from("lumen_chat_settings").select("push_enabled, push_trigger_type, push_trigger_time_seconds, push_trigger_on_exit, push_trigger_scroll_depth, push_prompt_title, push_prompt_message").eq("user_id",t).maybeSingle();return w||!u?Ya:{push_enabled:(n=u==null?void 0:u.push_enabled)!=null?n:!1,push_trigger_type:(i=u==null?void 0:u.push_trigger_type)!=null?i:"time",push_trigger_time_seconds:(l=u==null?void 0:u.push_trigger_time_seconds)!=null?l:30,push_trigger_on_exit:(d=u==null?void 0:u.push_trigger_on_exit)!=null?d:!0,push_trigger_scroll_depth:(m=u==null?void 0:u.push_trigger_scroll_depth)!=null?m:50,push_prompt_title:(g=u==null?void 0:u.push_prompt_title)!=null?g:"Wil je op de hoogte blijven?",push_prompt_message:(v=u==null?void 0:u.push_prompt_message)!=null?v:"Ontvang meldingen over relevante updates en aanbiedingen."}},enabled:!!t,staleTime:60*1e3}),qo=()=>{const t=Es(),{toast:n}=ss();return ze({mutationFn:async({userId:i,updates:l})=>{const{data:d}=await o.from("lumen_chat_settings").select("id").eq("user_id",i).maybeSingle();if(d){const{error:m}=await o.from("lumen_chat_settings").update(l).eq("user_id",i);if(m)throw m}else{const{error:m}=await o.from("lumen_chat_settings").insert(Ko({user_id:i},l));if(m)throw m}return l},onSuccess:(i,l)=>{t.invalidateQueries({queryKey:["pushTriggerSettings",l.userId]}),n({title:"Opgeslagen",description:"Push notification instellingen zijn bijgewerkt."})},onError:i=>{n({title:"Fout",description:i.message,variant:"destructive"})}})},Ns={youtube_sync_enabled:!0,youtube_sync_base_schedule:"0 */6 * * *",youtube_sync_lookback_days:7,youtube_transcription_enabled:!0,youtube_transcription_delay_minutes:30,youtube_analysis_enabled:!0,youtube_analysis_delay_minutes:60,youtube_article_enabled:!0,youtube_article_delay_minutes:60},Uo=[{value:"0 */4 * * *",label:"Elke 4 uur",intervalHours:4},{value:"0 */6 * * *",label:"Elke 6 uur",intervalHours:6},{value:"0 */8 * * *",label:"Elke 8 uur",intervalHours:8},{value:"0 */12 * * *",label:"Elke 12 uur",intervalHours:12},{value:"0 0 * * *",label:"Eenmaal per dag (00:00)",intervalHours:24},{value:"0 6 * * *",label:"Eenmaal per dag (06:00)",intervalHours:24}],Bo=()=>
3es({queryKey:["youtubePipelineSettings"],queryFn:async()=>{var t,n,i,l,d,m,g,v,u;const{data:w,error:N}=await o.from("platform_settings").select(`
4          youtube_sync_enabled,
5          youtube_sync_base_schedule,
6          youtube_sync_lookback_days,
7          youtube_transcription_enabled,
8          youtube_transcription_delay_minutes,
9          youtube_analysis_enabled,
10          youtube_analysis_delay_minutes,
11          youtube_article_enabled,
12          youtube_article_delay_minutes
13        `).eq("id",1).maybeSingle();return N||!w?Ns:{youtube_sync_enabled:(t=w==null?void 0:w.youtube_sync_enabled)!=null?t:Ns.youtube_sync_enabled,youtube_sync_base_schedule:(n=w==null?void 0:w.youtube_sync_base_schedule)!=null?n:Ns.youtube_sync_base_schedule,youtube_sync_lookback_days:(i=w==null?void 0:w.youtube_sync_lookback_days)!=null?i:Ns.youtube_sync_lookback_days,youtube_transcription_enabled:(l=w==null?void 0:w.youtube_transcription_enabled)!=null?l:Ns.youtube_transcription_enabled,youtube_transcription_delay_minutes:(d=w==null?void 0:w.youtube_transcription_delay_minutes)!=null?d:Ns.youtube_transcription_delay_minutes,youtube_analysis_enabled:(m=w==null?void 0:w.youtube_analysis_enabled)!=null?m:Ns.youtube_analysis_enabled,youtube_analysis_delay_minutes:(g=w==null?void 0:w.youtube_analysis_delay_minutes)!=null?g:Ns.youtube_analysis_delay_minutes,youtube_article_enabled:(v=w==null?void 0:w.youtube_article_enabled)!=null?v:Ns.youtube_article_enabled,youtube_article_delay_minutes:(u=w==null?void 0:w.youtube_article_delay_minutes)!=null?u:Ns.youtube_article_delay_minutes}},staleTime:60*1e3}),Ho=()=>{const t=Es(),{toast:n}=ss();return ze({mutationFn:async i=>{const{error:l}=await o.from("platform_settings").update(i).eq("id",1);if(l)throw l;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["youtubePipelineSettings"]})},onError:i=>{n({title:"Fout",description:i.message,variant:"destructive"})}})},Xa=(t,n)=>{const i=t.split(" ");if(i.length!==5)return t;const l=parseInt(i[0])||0,d=i[1],m=l+n,g=m%60,v=Math.floor(m/60);if(d.startsWith("*/")){const u=parseInt(d.replace("*/",""))||6;if(v===0)return`${g} ${d} * * *`;{const w=[];for(let k=0;k<24;k+=u)w.push(k);const N=w.map(k=>(k+v)%24).sort((k,j)=>k-j);return`${g} ${N.join(",")} * * *`}}else if(d!=="*"){const w=((parseInt(d)||0)+v)%24;return`${g} ${w} * * *`}return`${g} ${d} * * *`},Jo=t=>{const n=t.youtube_sync_base_schedule,i=t.youtube_transcription_delay_minutes,l=i+t.youtube_analysis_delay_minutes,d=l+t.youtube_article_delay_minutes;return{sync:n,transcription:Xa(n,i),analysis:Xa(n,l),article:Xa(n,d)}},Wo=t=>{const n=new Date,i=t.split(" ");if(i.length!==5)return n;const l=i[0]==="*"?0:parseInt(i[0])||0,d=i[1];let m=n.getHours();if(d.startsWith("*/")){const v=parseInt(d.replace("*/",""))||6;m=Math.ceil((n.getHours()+1)/v)*v,m>=24&&(m=0)}else d!=="*"&&(m=parseInt(d)||0,m<=n.getHours()&&(m+=24));const g=new Date(n);return g.setHours(m%24,l,0,0),m>=24&&g.setDate(g.getDate()+1),g},Yt=t=>t.toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"}),Za=(t,n)=>new Date(t.getTime()+n*6e4),Qo=({baseSchedule:t,transcriptionDelay:n,analysisDelay:i,articleDelay:l,syncEnabled:d,transcriptionEnabled:m,analysisEnabled:g,articleEnabled:v})=>{const u=a.useMemo(()=>{const V=Wo(t),me=Za(V,n),ee=Za(me,i),ue=Za(ee,l);return[{label:"Video Sync",time:Yt(V),icon:e.jsx($s,{className:"h-4 w-4"}),color:"text-red-400",bgColor:"bg-red-500/10",borderColor:"border-red-500/30"},{label:"Transcriptie",time:Yt(me),icon:e.jsx(ct,{className:"h-4 w-4"}),color:"text-blue-400",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30"},{label:"AI Analyse",time:Yt(ee),icon:e.jsx(Vs,{className:"h-4 w-4"}),color:"text-purple-400",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30"},{label:"Artikelen",time:Yt(ue),icon:e.jsx(Ai,{className:"h-4 w-4"}),color:"text-emerald-400",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30"}]},[t,n,i,l]),w=[d,m,g,v],N=n+i+l,j=(f=>{var V;const me=f.split(" ");return(V=me[1])!=null&&V.startsWith("*/")?parseInt(me[1].replace("*/",""))*60:24*60})(t),I=N>=j;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-2",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{children:"Volgende run tijden (gebaseerd op huidige instellingen)"})]}),e.jsx("div",{className:"flex items-center justify-between gap-1 p-4 rounded-lg bg-muted/20 border",children:u.map((f,V)=>e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:`
14                flex flex-col items-center gap-1 p-3 rounded-lg border transition-opacity
15                ${f.bgColor} ${f.borderColor}
16                ${w[V]?"opacity-100":"opacity-40"}
17              `,children:[e.jsx("div",{className:`${f.color}`,children:f.icon}),e.jsx("span",{className:"text-xs font-medium",children:f.time}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:f.label})]}),V<u.length-1&&e.jsx(ia,{className:"h-4 w-4 mx-2 text-muted-foreground
17/50 flex-shrink-0"})]},f.label))}),e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{children:"Totale pipeline duur:"}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.floor(N/60),"u ",N%60,"m"]})]}),I&&e.jsx(xs,{className:"border-yellow-500/30 bg-yellow-500/10",children:e.jsxs(gs,{className:"text-sm text-yellow-200",children:[e.jsx("strong",{children:"⚠️ Let op:"})," De totale pipeline duur (",Math.floor(N/60),"u ",N%60,"m) is langer dan of gelijk aan het sync interval. Dit kan overlappende runs veroorzaken."]})})]})},Yo=["Jan","Feb","Mrt","Apr","Mei","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],Xo=["Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December"],Zo=({cronSettings:t})=>{const{toast:n}=ss(),i=Ii(),[l,d]=a.useState(!0),[m,g]=a.useState(4),[v,u]=a.useState(7),[w,N]=a.useState(null),[k,j]=a.useState(!1),[I,f]=a.useState(!1),[V,me]=a.useState(null);a.useEffect(()=>{t&&(d(t.snapshot_enabled),g(t.snapshot_interval_months),u(t.snapshot_day_range),t.snapshot_last_run&&N(t.snapshot_last_run))},[t]);const ee=a.useMemo(()=>{const L=[];for(let F=1;F<=12;F+=m)L.push(F);return L},[m]),ue=new Date().getMonth()+1,je=async()=>{try{f(!0),await i.mutateAsync({snapshot_enabled:l,snapshot_interval_months:m,snapshot_day_range:v}),n({title:"✨ Time Machine Geconfigureerd",description:`Snapshots ${l?"actief":"uitgeschakeld"}. Volgende: elke ${m} maand(en).`})}catch(L){}finally{f(!1)}},B=async()=>{try{j(!0);const{error:L}=await o.functions.invoke("sync-ai-models",{body:{force_snapshot:!0}});if(L)throw L;n({title:"🎉 Snapshot Gemaakt!",description:"Een nieuwe Time Machine snapshot is succesvol vastgelegd."}),N(new Date().toISOString())}catch(L){n({title:"Snapshot Mislukt",description:"Er is een fout opgetreden bij het maken van de snapshot.",variant:"destructive"})}finally{j(!1)}};return e.jsxs(R,{className:"relative overflow-hidden border-0 bg-gradient-to-br from-slate-900 via-purple-950/30 to-slate-900",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(Be.div,{className:"absolute -top-1/2 -left-1/2 w-full h-full bg-gradient-to-br from-cyan-500/20 via-transparent to-transparent rounded-full blur-3xl",animate:{x:[0,50,0],y:[0,30,0],scale:[1,1.1,1]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),e.jsx(Be.div,{className:"absolute -bottom-1/2 -right-1/2 w-full h-full bg-gradient-to-tl from-purple-500/20 via-transparent to-transparent rounded-full blur-3xl",animate:{x:[0,-30,0],y:[0,-50,0],scale:[1.1,1,1.1]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),[...Array(6)].map((L,F)=>e.jsx(Be.div,{className:"absolute w-1 h-1 bg-cyan-400/60 rounded-full",style:{left:`${20+F*15}%`,top:`${30+F%3*20}%`},animate:{y:[-10,10,-10],opacity:[.3,.8,.3],scale:[1,1.5,1]},transition:{duration:3+F*.5,repeat:1/0,ease:"easeInOut",delay:F*.3}},F))]}),e.jsxs(G,{className:"relative z-10 p-4 sm:p-6 lg:p-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4 mb-6 sm:mb-8",children:[e.jsxs(Be.div,{className:"relative",animate:{rotate:360},transition:{duration:20,repeat:1/0,ease:"linear"},children:[e.jsx("div",{className:"w-14 h-14 sm:w-16 sm:h-16 rounded-2xl bg-gradient-to-br from-cyan-500 via-purple-500 to-pink-500 p-[2px]",children:e.jsx("div",{className:"w-full h-full rounded-2xl bg-slate-900 flex items-center justify-center",children:e.jsx(Be.div,{animate:{rotate:-360},transition:{duration:20,repeat:1/0,ease:"linear"},children:e.jsx(Pt,{className:"w-7 h-7 sm:w-8 sm:h-8 text-cyan-400"})})})}),e.jsx(Be.div,{className:"absolute -top-1 -right-1 w-4 h-4 bg-green-500 rounded-full border-2 border-slate-900",animate:{scale:[1,1.2,1]},transition:{duration:2,repeat:1/0}})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"text-xl sm:text-2xl lg:text-3xl font-bold bg-gradient-to-r from-cyan-400 via-purple-400 to-pink-400 bg-clip-text text-transparent",children:"Time Machine"}),e.jsxs(ae,{className:"bg-gradient-to-r from-cyan-500/20 to-purple-500/20 text-cyan-300 border-cyan-500/30 text-xs",children:[e.jsx(Vs,{className:"w-3 h-3 mr-1"}),"Dynamisch"]})]}),e.jsx("p",{className:"text-sm sm:text-base text-slate-400 mt-1 sm:mt-2",children:"Reis door de tijd en ontdek hoe AI rankings evolueren"})]}),e.jsxs(Be.div,{className:"flex items-center gap-3 p-3 sm:p-4 roun
17ded-xl bg-slate-800/50 border border-slate-700/50",whileHover:{scale:1.02},children:[e.jsxs("div",{className:"text-right hidden sm:block",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Status"}),e.jsx("p",{className:`text-sm font-semibold ${l?"text-green-400":"text-slate-400"}`,children:l?"Actief":"Inactief"})]}),e.jsx(be,{checked:l,onCheckedChange:d,className:"data-[state=checked]:bg-gradient-to-r data-[state=checked]:from-cyan-500 data-[state=checked]:to-purple-500"})]})]}),e.jsx(Be.div,{className:"relative mb-6 sm:mb-8",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8 items-center",children:[e.jsxs("div",{className:"relative w-64 h-64 sm:w-72 sm:h-72 lg:w-80 lg:h-80 flex-shrink-0",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-slate-700/50"}),Yo.map((L,F)=>{const P=F+1,D=ee.includes(P),T=P===ue,W=(F*30-90)*(Math.PI/180),fe=45,re=50+fe*Math.cos(W),pe=50+fe*Math.sin(W);return e.jsxs(Be.div,{className:"absolute",style:{left:`${re}%`,top:`${pe}%`,transform:"translate(-50%, -50%)"},onHoverStart:()=>me(P),onHoverEnd:()=>me(null),whileHover:{scale:1.2},children:[e.jsxs(Be.div,{className:`
18                        relative w-10 h-10 sm:w-12 sm:h-12 rounded-full flex items-center justify-center cursor-pointer
19                        transition-all duration-300
20                        ${D?"bg-gradient-to-br from-cyan-500 to-purple-500 text-white shadow-lg shadow-cyan-500/30":"bg-slate-800 text-slate-500 border border-slate-700"}
21                        ${T?"ring-2 ring-yellow-400 ring-offset-2 ring-offset-slate-900":""}
22                      `,animate:D&&l?{boxShadow:["0 0 20px rgba(6, 182, 212, 0.3)","0 0 40px rgba(6, 182, 212, 0.5)","0 0 20px rgba(6, 182, 212, 0.3)"]}:{},transition:{duration:2,repeat:1/0},children:[e.jsx("span",{className:"text-xs sm:text-sm font-bold",children:L}),D&&e.jsx(Be.div,{className:"absolute -top-1 -right-1 w-3 h-3 bg-green-400 rounded-full border-2 border-slate-900",animate:{scale:[1,1.3,1]},transition:{duration:1.5,repeat:1/0}}),T&&e.jsx(Be.div,{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 text-[8px] font-bold text-yellow-400 whitespace-nowrap",animate:{opacity:[1,.5,1]},transition:{duration:1,repeat:1/0},children:"NU"})]}),e.jsx(yo,{children:V===P&&e.jsxs(Be.div,{className:"absolute z-20 top-full mt-2 left-1/2 -translate-x-1/2 bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 whitespace-nowrap",initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},children:[e.jsx("p",{className:"text-xs text-white font-medium",children:Xo[F]}),e.jsx("p",{className:`text-xs ${D?"text-cyan-400":"text-slate-500"}`,children:D?"📸 Snapshot maand":"Geen snapshot"})]})})]},P)}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs(Be.div,{className:"text-center",animate:{scale:[1,1.02,1]},transition:{duration:3,repeat:1/0},children:[e.jsx("p",{className:"text-3xl sm:text-4xl lg:text-5xl font-bold bg-gradient-to-r from-cyan-400 to-purple-400 bg-clip-text text-transparent",children:ee.length}),e.jsx("p",{className:"text-xs sm:text-sm text-slate-400",children:"snapshots/jaar"})]})}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",children:[ee.map((L,F)=>{const P=((L-1)*30-90)*(Math.PI/180),D=((ee[(F+1)%ee.length]-1)*30-90)*(Math.PI/180),T=45,W=50+T*Math.cos(P),fe=50+T*Math.sin(P),re=50+T*Math.cos(D),pe=50+T*Math.sin(D);return e.jsx(Be.line,{x1:`${W}%`,y1:`${fe}%`,x2:`${re}%`,y2:`${pe}%`,stroke:"url(#gradient)",strokeWidth:"2",strokeDasharray:"5,5",initial:{pathLength:0},animate:{pathLength:1},transition:{duration:1,delay:F*.1}},`line-${L}`)}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#06b6d4",stopOpacity:"0.5"}),e.jsx("stop",{offset:"100%",stopColor:"#a855f7",stopOpacity:"0.5"})]})})]})]}),e.jsxs("div",{className:"flex-1 w-full space-y-6",children:[e.jsxs(Be.div,{className:"p-4 sm:p-5 rounded-xl bg-slate-800/50 border border-slate-700/50",whileHover:{borderColor:"rgba(6, 182, 212, 0.3)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-cyan-500/20 to-purple-500/20 flex items-center justify-center",children:e.jsx(wt,{className:"w-5 h-5 text-cyan-400"})}),e.jsxs("div",{children:[e.jsx(b,{className:"text-sm font-semibold text-white",children:"Snapshot Interval"}),e.jsxs("p",{className:"text-xs text-slate-400",children:["Elke ",e.jsx("span",{className:"text-cyan-400 font-bold",children:m})," maand",m!==1&&"en"]})]})]}),e.jsx(Xe,{value:[m],onValueChange:L=>g(L[0]),min:1,max:12,step:1,className:"w-full",disabled:!l}),e.jsxs("div",{className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{children:"Maandelijks"}),e.jsx("span",{children:"Jaarlijks"})]})]}),e.jsxs(Be.div,{className:"p-4 sm:p-5 rounded-xl bg-slate-800/50 border border-slate-700/50",whileHover:{borderColor:"rgba(168, 85, 247, 0.3)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-purple-500/20 to-pink-500/20 flex items-center justify-center",children:e.jsx(ln,{className:"w-5 h-5 text-purple-400"})}),e.jsxs("div",{children:[e.jsx(b,{className:"text-sm font-semibold text-white",children:"Capture Window"}),e.jsxs("p",{className:"text-xs text-slate-400",children:["Eerste ",e.jsx("span",{className:"text-purple-400 font-bold",children:v})," dag",v!==1&&"en"," van de maand"]})]})]}),e.jsx(Xe,{value:[v],onValueChange:L=>u(L[0]),min:1,max:14,step:1,className:"w-full",disabled:!l}),e.jsxs("div",{className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{children:"1 dag"}),e.jsx("span",{children:"2 weken"})]})]})]})]})}),e.jsxs(Be.div,{className:"flex flex-col sm:flex-row gap-4 items-stretch sm:items-center justify-between p-4 sm:p-5 rounded-xl bg-gradient-to-r from-slate-800/80 to-slate-800/40 border border-slate-700/50",initial:{opacity:0}
22,animate:{opacity:1},transition:{delay:.4},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-green-500/20 to-emerald-500/20 flex items-center justify-center",children:e.jsx($l,{className:"w-6 h-6 text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider",children:"Laatste Snapshot"}),w?e.jsxs("p",{className:"text-base sm:text-lg font-semibold text-white",children:[ks(new Date(w),"d MMMM yyyy",{locale:Ss}),e.jsx("span",{className:"text-slate-400 text-sm ml-2",children:ks(new Date(w),"HH:mm",{locale:Ss})})]}):e.jsx("p",{className:"text-base font-semibold text-slate-400",children:"Nog geen snapshots"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(p,{onClick:je,disabled:I,className:"bg-gradient-to-r from-cyan-600 to-cyan-700 hover:from-cyan-500 hover:to-cyan-600 text-white border-0 h-11 px-5",children:I?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Opslaan"]})}),e.jsx(Be.div,{whileHover:{scale:1.02},whileTap:{scale:.98},children:e.jsx(p,{onClick:B,disabled:k,variant:"outline",className:"h-11 px-5 border-2 border-purple-500/50 bg-purple-500/10 text-purple-300 hover:bg-purple-500/20 hover:border-purple-400",children:k?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Capturing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ds,{className:"mr-2 h-4 w-4"}),"Nu Snapshot"]})})})]})]}),e.jsxs(Be.p,{className:"text-xs text-slate-500 text-center mt-4 sm:mt-6",initial:{opacity:0}
22,animate:{opacity:1},transition:{delay:.6},children:[e.jsx("span",{className:"text-cyan-400",children:"💡"})," Snapshots worden automatisch gemaakt tijdens sync in snapshot-maanden"]})]})]})},ec=()=>{const{data:t,isLoading:n}=Ro(),{data:i,isLoading:l}=Bo(),d=Ii(),m=Ho(),{toast:g}=ss(),[v,u]=a.useState(!0),[w,N]=a.useState(30),[k,j]=a.useState(!0),[I,f]=a.useState(5),[V,me]=a.useState(!0),[ee,ue]=a.useState(180),[je,B]=a.useState(null),[L,F]=a.useState(!1),[P,D]=bo("boxing-battle-enabled",!0),[T,W]=a.useState(!0),[fe,re]=a.useState("0 */6 * * *"),[pe,Ce]=a.useState(7),[ke,ie]=a.useState(!0),[_e,xe]=a.useState(30),[Ae,z]=a.useState(!0),[H,te]=a.useState(60),[le,we]=a.useState(!0),[Fe,M]=a.useState(60),[Te,Le]=a.useState(!1),[Qe,ms]=a.useState(!1),[Ge,Me]=a.useState(!1),[He,Ve]=a.useState(!1),[qe,Pe]=a.useState(null),[Ie,De]=a.useState(!1),[rs,ts]=a.useState(!1);a.useEffect(()=>{t&&(u(t.cron_push_enabled),N(t.cron_push_interval_minutes),j(t.cron_health_enabled),f(t.cron_health_interval_minutes),me(t.cron_ai_ranking_enabled),ue(t.cron_ai_ranking_interval_minutes),t.cron_ai_ranking_last_run&&B(t.cron_ai_ranking_last_run))},[t]),a.useEffect(()=>{i&&(W(i.youtube_sync_enabled),re(i.youtube_sync_base_schedule),Ce(i.youtube_sync_lookback_days),ie(i.youtube_transcription_enabled),xe(i.youtube_transcription_delay_minutes),z(i.youtube_analysis_enabled),te(i.youtube_analysis_delay_minutes),we(i.youtube_article_enabled),M(i.youtube_article_delay_minutes))},[i]);const is=x=>{const O=Math.floor(x/60);return O>=1?`0 */${O} * * *`:`*/${x} * * * *`},Ue=x=>{if(x<60)return`${x} min`;const O=Math.floor(x/60),oe=x%60;return oe===0?`${O} uur`:`${O}u ${oe}m`},fs=async()=>{try{await d.mutateAsync({cron_ai_ranking_enabled:V,cron_ai_ranking_interval_minutes:ee});const{error:x}=await o.functions.invoke("update-cron-schedule",{body:{jobName:"sync-ai-rankings-every-3-hours",schedule:is(ee),enabled:V}});g(x?{title:"Let op",description:"Instellingen opgeslagen, maar cron schedule kon niet worden bijgewerkt.",variant:"destructive"}:{title:"Opgeslagen",description:`AI Ranking sync is ${V?"actief":"uitgeschakeld"} met interval ${Ue(ee)}.`})}catch(x){}},hs=async()=>{try{F(!0);const{data:x,error:O}=await o.functions.invoke("sync-ai-models");if(O)throw O;g({title:"AI Ranking Sync gestart",description:`Sync voltooid: ${(x==null?void 0:x.rankings_synced)||0} rankings bijgewerkt`}),B(new Date().toISOString())}catch(x){g({title:"Sync mislukt",description:"Er is een fout opgetreden bij het synchroniseren van AI rankings.",variant:"destructive"})}finally{F(!1)}},vs=async()=>{try{Me(!0),await m.mutateAsync({youtube_sync_enabled:T,youtube_sync_base_schedule:fe,youtube_sync_lookback_days:pe,youtube_transcription_enabled:ke,youtube_transcription_delay_minutes:_e,youtube_analysis_enabled:Ae,y
22outube_analysis_delay_minutes:H,youtube_article_enabled:le,youtube_article_delay_minutes:Fe});const x=Jo({youtube_sync_enabled:T,youtube_sync_base_schedule:fe,youtube_sync_lookback_days:pe,youtube_transcription_enabled:ke,youtube_transcription_delay_minutes:_e,youtube_analysis_enabled:Ae,youtube_analysis_delay_minutes:H,youtube_article_enabled:le,youtube_article_delay_minutes:Fe}),O=[o.functions.invoke("update-cron-schedule",{body:{jobName:"sync-youtube-videos",schedule:x.sync,enabled:T}}),o.functions.invoke("update-cron-schedule",{body:{jobName:"fetch-transcripts",schedule:x.transcription,enabled:ke}}),o.functions.invoke("update-cron-schedule",{body:{jobName:"analyze-videos",schedule:x.analysis,enabled:Ae}}),o.functions.invoke("update-cron-schedule",{body:{jobName:"generate-articles",schedule:x.article,enabled:le}})],S=(await Promise.allSettled(O)).filter(Y=>Y.status==="rejected");S.length>0?g({title:"Gedeeltelijk opgeslagen",description:`${S.length} cron job(s) konden niet worden bijgewerkt.`,variant:"destructive"}):g({title:"Pipeline opgeslagen",description:"Alle YouTube pipeline cronjobs zijn bijgewerkt met de nieuwe cascade timing."})}catch(x){g({title:"Fout",description:"Er is een fout opgetreden bij het opslaan van de pipeline instellingen.",variant:"destructive"})}finally{Me(!1)}},h=async()=>{await d.mutateAsync({cron_push_enabled:v,cron_push_interval_minutes:w,cron_health_enabled:k,cron_health_interval_minutes:I})};return n||l?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Se,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(R,{className:"border-purple-500/30 bg-gradient-to-br from-purple-500/5 to-transparent",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Rl,{className:"h-5 w-5 text-purple-500"}),"AI Model Ranking Sync",e.jsx(ae,{className:"ml-2 bg-purple-500/20 text-purple-400 border-purple-500/30",children:"Actief"})]}),e.jsx(Z,{children:"Automatisch AI model rankings ophalen van LMArena.ai en andere bronnen. Houdt de AI Ranking pagina up-to-date."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Ranking Sync Actief"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Periodiek AI model rankings synchroniseren"})]}),e.jsx(be,{checked:V,onCheckedChange:me})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-gradient-to-r from-primary/10 to-accent/10 border-border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"text-base font-medium flex items-center gap-2",children:["🥊 3D Bokshandschoenen Animatie",e.jsx(ae,{variant:"outline",className:"text-xs",children:"Tijdelijk"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toon de 3D boksgevecht animatie op de AI Ranking pagina"})]}),e.jsx(be,{checked:P,onCheckedChange:x=>D(x)})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Interval: ",Ue(ee)]}),e.jsx(Xe,{value:[ee],onValueChange:x=>ue(x[0]),min:60,max:720,step:60,className:"w-full",disabled:!V}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Hoe vaak rankings worden gesynchroniseerd (1-12 uur)"})]})}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[je&&e.jsx("div",{className:"p-3 bg-muted/50 rounded-lg flex-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Laatst gesynchroniseerd:"})," ",ks(new Date(je),"d MMMM yyyy HH:mm",{locale:Ss})]})}),e.jsx(p,{onClick:fs,disabled:d.isPending,className:"bg-purple-600 hover:bg-purple-700",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Opslaan"]})}),e.jsx(p,{onClick:hs,disabled:L,variant:"outline",className:"border-purple-500/30 hover:bg-purple-500/20 hover:text-purple-300",children:L?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Synchroniseren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Synchroniseren"]})})]})]})]}),e.jsx(Zo,{cronSettings:t}),e.jsxs(R,{className:"border-gradient-to-r from-red-500/30 via-purple-500/30 to-emerald-500/30 border-2",children:[e.jsxs(J,{className:"bg-gradient-to-r from-red-500/5 via-purple-500/5 to-emerald-500/5",children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-5 w-5 text-red-500"}),"YouTube Pipeline Configuratie",e.jsx(ae,{className:"ml-2 bg-gradient-to-r from-red-500/20 to-emerald-500/20 text-white border-0",children:"Cascading"})]}),e.jsx(Z,{children:"Configureer de complete YouTube video-naar-artikel pipeline. Elke stap start automatisch na de vorige stap met de ingestelde vertraging."})]}),e.jsxs(G,{className:"space-y-8 pt-6",children:[e.jsx(Qo,{baseSchedule:fe,transcriptionDelay:_e,analysisDelay:H,articleDelay:Fe,syncEnabled:T,transcriptionEnabled:ke,analysisEnabled:Ae,articleEnabled:le}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-red-500/20 bg-red-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-red-500/20 text-red-400 font-bold text-sm",children:"1"}),e.jsx($s,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-semibold",children:"YouTube Video Sync"}),e.jsx(ae,{variant:"outline",className:"ml-auto border-red-500/30 text-red-400",children:"Startpunt"})]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-10",children:"Dit is het startpunt van de pipeline. Nieuwe video's worden opgehaald van alle actieve kanalen."}),e.jsxs("div",{className:"flex items-center justify-between pl-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Sync Actief"}),e.jsx(be,{checked:T,onCheckedChange:W})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{children:"Basis Schema:"}),e.jsxs(os,{value:fe,onValueChange:re,disabled:!T,children:[e.jsx(cs,{className:"w-[200px]",children:e.jsx(ds,{})}),e.jsx(us,{children:Uo.map(x=>e.jsx(U,{value:x.value,children:x.label},x.value))})]})]})]}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Video's ophalen van laatste: ",pe," ",pe===1?"dag":"dagen"]}),e.jsx(Xe,{value:[pe],onValueChange:x=>Ce(x[0]),min:1,max:30,step:1,className:"w-full max-w-md",disabled:!T}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gebruikt de YouTube API om video's van de afgelopen X dagen op te halen. Dit zorgt ervoor dat altijd de nieuwste video's worden gesynchroniseerd."})]}),e.jsx("div",{className:"pl-10 pt-2",children:e.jsx(p,{onClick:async()=>
22{try{Le(!0);const x=new Date,O=new Date(x);O.setDate(O.getDate()-pe);const{data:oe,error:S}=await o.functions.invoke("sync-youtube-videos",{body:{historical:!0,publishedAfter:O.toISOString(),publishedBefore:x.toISOString()}});if(S)throw S;g({title:"Video sync voltooid",description:`${(oe==null?void 0:oe.videosAdded)||0} nieuwe video's toegevoegd. API units: ${(oe==null?void 0:oe.apiUnitsUsed)||0}`})}catch(x){g({title:"Sync mislukt",description:x instanceof Error?x.message:"Er is een fout opgetreden.",variant:"destructive"})}finally{Le(!1)}},disabled:Te,variant:"outline",size:"sm",className:"border-red-500/30 hover:bg-red-500/20 hover:text-red-300",children:Te?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Synchroniseren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Sync (laatste ",pe," dagen)"]})})})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Nt,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-blue-500/20 bg-blue-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-500/20 text-blue-400 font-bold text-sm",children:"2"}),e.jsx(ct,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"font-semibold",children:"Transcriptie"}),e.jsx(p,{onClick:async()=>{try{De(!0);const{data:x,error:O}=await o.functions.invoke("fetch-youtube-transcript?processPending=true&maxVideos=10&parallel=2");if(O)throw O;g({title:"Transcripties opgehaald",description:`${(x==null?void 0:x.successful)||0} succesvol, ${(x==null?void 0:x.failed)||0} mislukt, ${(x==null?void 0:x.remaining)||0} resterend.`})}catch(x){g({title:"Fout bij transcripties",description:x instanceof Error?x.message:"Onbekende fout",variant:"destructive"})}finally{De(!1)}},variant:"outline",size:"sm",disabled:Ie,className:"ml-auto border-blue-500/30 hover:bg-blue-500/20",children:Ie?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-1 h-3 w-3 animate-spin"})," Bezig..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-1 h-3 w-3"})," Nu Uitvoeren"]})}),e.jsxs(ae,{variant:"outline",className:"border-blue-500/30 text-blue-400",children:["+",_e," min na stap 1"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground pl-10",children:["Loopt ",e.jsxs("strong",{children:[_e," minuten"]})," na de Video Sync. Transcripties/ondertiteling worden opgehaald voor nieuwe video's."]}),e.jsx("div",{className:"flex items-center justify-between pl-10",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Transcriptie Actief"}),e.jsx(be,{checked:ke,onCheckedChange:ie})]})}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Vertraging na Video Sync: ",Ue(_e)]}),e.jsx(Xe,{value:[_e],onValueChange:x=>xe(x[0]),min:15,max:120,step:15,className:"w-full max-w-md",disabled:!ke}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Aanbevolen: 30-60 minuten. Dit geeft tijd om nieuwe video's te registreren."})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Nt,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-purple-500/20 bg-purple-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-purple-500/20 text-purple-400 font-bold text-sm",children:"3"}),e.jsx(Vs,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-semibold",children:"AI Analyse"}),e.jsx(p,{onClick:async()=>{try{ts(!0);const{data:x,error:O}=await o.functions.invoke("analyze-youtube-video?processPending=true&articleType=snackable&maxVideos=10");if(O)throw O;g({title:"AI Analyse voltooid",description:`${(x==null?void 0:x.processed)||0} video's geanalyseerd.`})}catch(x){g({title:"Fout bij AI analyse",description:x instanceof Error?x.message:"Onbekende fout",variant:"destructive"})}finally{ts(!1)}},variant:"outline",size:"sm",disabled:rs,className:"ml-auto border-purple-500/30 hover:bg-purple-500/20",children:rs?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-1 h-3 w-3 animate-spin"})," Bezig..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-1 h-3 w-3"})," Nu Uitvoeren"]})}),e.jsxs(ae,{variant:"outline",className:"border-purple-500/30 text-purple-400",children:["+",H," min na stap 2"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground pl-10",children:["Loopt ",e.jsxs("strong",{children:[H," minuten"]})," na de Transcriptie. Video's worden geanalyseerd met AI voor highlights en key takeaways."]}),e.jsx("div",{className:"flex items-center justify-between pl-10",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"AI Analyse Actief"}),e.jsx(be,{checked:Ae,onCheckedChange:z})]})}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Vertraging na Transcriptie: ",Ue(H)]}),e.jsx(Xe,{value:[H],onValueChange:x=>te(x[0]),min:30,max:180,step:15,className:"w-full max-w-md",disabled:!Ae}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Aanbevolen: 60-90 minuten. Dit zorgt dat transcripties compleet zijn. Let op: gebruikt Gemini API credits."})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Nt,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-emerald-500/20 bg-emerald-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-emerald-500/20 text-emerald-400 font-bold text-sm",children:"4"}),e.jsx(Ai,{className:"h-5 w-5 text-emerald-500"}),e.jsx("span",{className:"font-semibold",children:"Artikel Generatie"}),e.jsxs(ae,{variant:"outline",className:"ml-auto border-emerald-500/30 text-emerald-400",children:["+",Fe," min na stap 3"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground pl-10",children:["Loopt ",e.jsxs("strong",{children:[Fe," minuten"]})," na de AI Analyse. Volledige blogartikelen worden gegenereerd."]}),e.jsx("div",{className:"flex items-center justify-between pl-10",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Artikel Generatie Actief"}),e.jsx(be,{checked:le,onCheckedChange:we})]})}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Vertraging na AI Analyse: ",Ue(Fe)]}),e.jsx(Xe,{value:[Fe],onValueChange:x=>M(x[0]),min:30,max:180,step:15,className:"w-full max-w-md",disabled:!le}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Aanbevolen: 60-120 minuten. Dit is de meest intensieve stap qua API credits."})]}),e.jsx("div",{className:"pl-10 pt-2",children:e.jsx(p,{onClick:async()=>{try{ms(!0);const{data:x,error:O}=await o.functions.invoke("generate-full-articles",{body:{processPending:!0,maxVideos:10}
22});if(O)throw O;g({title:"Artikel generatie gestart",description:`${(x==null?void 0:x.processed)||0} video's verwerkt, ${(x==null?void 0:x.generated)||0} artikelen gegenereerd.`})}catch(x){g({title:"Generatie mislukt",description:"Er is een fout opgetreden bij het genereren van artikelen.",variant:"destructive"})}finally{ms(!1)}},disabled:Qe,variant:"outline",size:"sm",className:"border-emerald-500/30 hover:bg-emerald-500/20 hover:text-emerald-300",children:Qe?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Genereren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Genereren (max 10)"]})})})]}),e.jsxs("div",{className:"p-4 rounded-lg border-2 border-dashed border-amber-500/30 bg-amber-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"h-5 w-5 text-amber-500"}),e.jsx("span",{className:"font-semibold text-amber-400",children:"Test Volledige Pipeline"}),e.jsx(ae,{variant:"outline",className:"ml-auto border-amber-500/30 text-amber-400",children:"Handmatig"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Start alle 4 stappen achter elkaar om de pipeline te testen. Elke stap wacht op de vorige voordat deze start."}),qe&&e.jsxs(xs,{className:"mb-4 border-amber-500/30 bg-amber-500/10",children:[e.jsx(Js,{className:"h-4 w-4 text-amber-500"}),e.jsxs(gs,{className:"text-amber-300",children:[e.jsx("strong",{children:"Status:"})," ",qe]})]}),e.jsx(p,{onClick:async()=>{try{Ve(!0),Pe("Stap 1/4: YouTube video's synchroniseren...");const x=new Date,O=new Date(x);O.setDate(O.getDate()-pe);const{error:oe}=await o.functions.invoke("sync-youtube-videos",{body:{historical:!0,publishedAfter:O.toISOString(),publishedBefore:x.toISOString()}});if(oe)throw new Error(`Sync failed: ${oe.message}`);Pe("Stap 2/4: Transcripties ophalen...");const{data:S,error:Y}=await o.functions.invoke("fetch-youtube-transcript?processPending=true&maxVideos=10&parallel=2");Pe("Stap 3/4: AI analyse uitvoeren...");const{data:_,error:E}=await o.functions.invoke("analyze-youtube-video?processPending=true&articleType=snackable&maxVideos=10");Pe("Stap 4/4: Artikelen genereren...");const{data:ve,error:ye}=await o.functions.invoke("cron-generate-articles");Pe(null),g({title:"Pipeline test voltooid",description:`Alle 4 stappen zijn uitgevoerd. ${(ve==null?void 0:ve.generated)||0} artikelen gegenereerd.`})}catch(x){Pe(null),g({title:"Pipeline test mislukt",description:x instanceof Error?x.message:"Er is een fout opgetreden.",variant:"destructive"})}finally{Ve(!1)}},disabled:He,className:"w-full bg-amber-600 hover:bg-amber-700 text-white",children:He?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Pipeline wordt uitgevoerd..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Start Volledige Pipeline Test"]})})]}),e.jsx(p,{onClick:vs,disabled:Ge,className:"w-full bg-gradient-to-r from-red-600 via-purple-600 to-emerald-600 hover:from-red-700 hover:via-purple-700 hover:to-emerald-700",children:Ge?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Pipeline Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"YouTube Pipeline Opslaan"]})}),e.jsxs(xs,{className:"border-blue-500/30 bg-blue-500/10",children:[e.jsx(Gl,{className:"h-4 w-4 text-blue-500"}),e.jsxs(gs,{className:"text-sm text-blue-200",children:[e.jsx("strong",{children:"Hoe werkt het?"})," Wanneer je de pipeline opslaat, worden alle 4 cronjobs automatisch ingesteld met de juiste tijden. Stap 2 draait altijd X minuten na stap 1, stap 3 draait Y minuten na stap 2, enzovoort."]})]})]})]}),e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"h-5 w-5 text-primary"}),"Push Notificaties Cronjob"]}),e.jsx(Z,{children:"Beheer de automatische push notificatie verwerking. Deze job controleert of bezoekers in aanmerking komen voor een push notificatie."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Push Cronjob Actief"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatisch pu
22sh notificaties versturen naar gekwalificeerde bezoekers"})]}),e.jsx(be,{checked:v,onCheckedChange:u})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Interval (minuten): ",w]}),e.jsx(Xe,{value:[w],onValueChange:x=>N(x[0]),min:5,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Hoe vaak de push notificatie job moet draaien (5-120 minuten)"})]})}),(t==null?void 0:t.cron_push_last_run)&&e.jsx("div",{className:"p-3 bg-muted/50 rounded-lg",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Laatst uitgevoerd:"})," ",ks(new Date(t.cron_push_last_run),"d MMMM yyyy HH:mm",{locale:Ss})]})})]})]}),e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Js,{className:"h-5 w-5 text-primary"}),"API Health Check Cronjob"]}),e.jsx(Z,{children:"Beheer de automatische API health checks. Deze job controleert de status van alle externe API verbindingen."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Health Check A
22ctief"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatisch API endpoints controleren en status bijhouden"})]}),e.jsx(be,{checked:k,onCheckedChange:j})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Interval (minuten): ",I]}),e.jsx(Xe,{value:[I],onValueChange:x=>f(x[0]),min:1,max:60,step:1,className:"w-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Hoe vaak de health check job moet draaien (1-60 minuten)"})]})})]})]}),e.jsx(p,{onClick:h,disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Overige Cronjob Instellingen Opslaan"]})})]})};var sc=Object.defineProperty,tc=Object.defineProperties,ac=Object.getOwnPropertyDescriptors,di=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,ui=(t,n,i)=>n in t?sc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,ys=(t,n)=>{for(var i in n||(n={}))nc.call(n,i)&&ui(t,i,n[i]);if(di)for(var i of di(n))rc.call(n,i)&&ui(t,i,n[i]);return t},Us=(t,n)=>tc(t,ac(n));const ic={name:"",title:"Nieuwe notificatie",body:"",icon_url:null,image_url:null,badge_url:null,cta_enabled:!0,cta_text:"Bekijken",cta_url:"",background_color:"#ffffff",text_color:"#000000",cta_background_color:"#3b82f6",cta_text_color:"#ffffff",border_radius:12,shadow_enabled:!0,close_button_enabled:!0,close_button_position:"top-right",template_format:"standard",screen_position:"bottom-right",custom_width:300,custom_height:180,is_system_template:!0,category_id:null},lc={name:"",description:"",color:"#6366f1",icon:"folder",sort_order:0},_t=[{id:"basis",label:"Basis",icon:ql},{id:"afbeeldingen",label:"Afbeeldingen",icon:on},{id:"formaat",label:"Formaat",icon:kt},{id:"vormgeving",label:"Vormgeving",icon:kt},{id:"cta",label:"Call-to-Action",icon:Ts}];function mi({template:t,compact:n=!1}){var i;const l={"top-right":"top-2 right-2","top-left":"top-2 left-2","bottom-right":"bottom-2 right-2","bottom-left":"bottom-2 left-2"};if(n)return e.jsxs("div",{className:"relative overflow-hidden cursor-pointer group",style:{backgroundColor:t.background_color||"#1a1a2e",borderRadius:`${t.border_radius||12}px`,boxShadow:t.shadow_enabled?"0 10px 40px rgba(0,0,0,0.3)":"none"},children:[t.close_button_enabled&&e.jsx("div",{className:`absolute ${l[t.close_button_position||"top-right"]} p-1 rounded-full z-10`,style:{color:t.text_color||"#ffffff"},children:e.jsx(zs,{className:"h-3 w-3 opacity-60"})}),t.image_url&&e.jsx("div",{className:"w-full aspect-[16/9] overflow-hidden",children:e.jsx("img",{src:t.image_url,alt:"Banner",className:"w-full h-full object-cover"})}),t.cta_enabled&&e.jsx("div",{className:"p-3 pt-2 flex justify-center",children:e.jsx("div",{className:"py-2 px-6 rounded text-xs font-semibold text-center transition-opacity group-hover:opacity-90",style:{backgroundColor:t.cta_background_color||"#7c3aed",color:t.cta_text_color||"#ffffff"},children:t.cta_text||"Bekijken"})})]});const d=(i=t.custom_width)!=null?i:300;return e.jsx("div",{className:"relative w-full min-h-[300px] bg-gradient-to-br from-muted/50 to-muted rounded-lg border border-border overflow-hidden flex items-center justify-center p-4",children:e.jsx("div",{style:{width:`${Math.min(d,280)}px`,maxWidth:"100%"},children:e.jsxs("div",{className:"relative overflow-hidden",style:{backgroundColor:t.background_color||"#1a1a2e",borderRadius:`${t.border_radius||12}px`,boxShadow:t.shadow_enabled?"0 10px 40px rgba(0,0,0,0.15)":"none"},children:[t.close_button_enabled&&e.jsx("button",{className:`absolute ${l[t.close_button_position||"top-right"]} p-1 rounded-full hover:bg-black/10 transition-colors z-10`,style:{color:t.text_color||"#ffffff"},children:e.jsx(zs,{className:"h-3 w-3"})}),e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.icon_url?e.jsx("img",{src:t.icon_url,alt:"Icon",className:"w-8 h-8 rounded-lg flex-shrink-0 object-cover"}):e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Ts,{className:"h-4 w-4 text-primary"})}),e.jsx("h4",{className:"font-bold text-sm leading-tight",style:{color:t.text_color||"#ffffff"},children:t.title||"Notificatie titel"})]}),e.jsx("p",{className:"text-[10px] leading-relaxed opacity-80 line-clamp-2 ml-10",style:{color:t.text_color||"#ffffff"},children:t.body||"Notificatie tekst komt hier..."})]}),t.image_url&&e.jsx("div",{className:"w-full aspect-video overflow-hidden",children:e.jsx("img",{src:t.image_url,alt:"Banner",className:"w-full h-full object-cover"})}),t.cta_enabled&&e.jsx("div",{className:"p-3 pt-2 flex justify-center",children:e.jsx("button",{className:"py-1.5 px-6 rounded text-xs font-medium transition-opacity hover:opacity-90",style:{backgroundColor:t.cta_background_color||"#7c3aed",color:t.cta_text_color||"#ffffff"},children:t.cta_text||"Bekijken"})})]})})})}function oc(){var t,n,i,l,d,m,g,v,u,w;const{toast:N}
22=ss(),k=Es(),[j,I]=a.useState(!1),[f,V]=a.useState(null),[me,ee]=a.useState(null),[ue,je]=a.useState("templates"),[B,L]=a.useState("basis"),[F,P]=a.useState(!1),[D,T]=a.useState(null),[W,fe]=a.useState(null),[re,pe]=a.useState("all"),[Ce,ke]=a.useState(!1),[ie,_e]=a.useState(1),[xe,Ae]=a.useState(""),[z,H]=a.useState(3),[te,le]=a.useState(""),[we,Fe]=a.useState(!1),[M,Te]=a.useState([]),[Le,Qe]=a.useState(0),[ms,Ge]=a.useState(""),{data:Me=[],isLoading:He}=es({queryKey:["push-template-categories"],queryFn:async()=>{const{data:r,error:$}=await o.from("push_template_categories").select("*").order("sort_order",{ascending:!0});if($)throw $;return r}}),{data:Ve=[],isLoading:qe}=es({queryKey:["system-templates"],queryFn:async()=>{const{data:r,error:$}=await o.from("push_notification_templates").select("*").eq("is_system_template",!0).order("created_at",{ascending:!1});if($)throw $;return r}}),{data:Pe=[]}=es({queryKey:["master-prompts-for-ai"],queryFn:async()=>{const{data:r,error:$}=await o.from("lumen_master_prompts").select("id, name, description").eq("is_active",!0).order("name");if($)throw $;return r}}),Ie=re==="all"?Ve:re==="uncategorized"?Ve.filter(r=>!r.category_id):Ve.filter(r=>r.category_id===re),De=ze({mutationFn:async r=>{if(r.id){const{error:$}=await o.from("push_template_categories").update({name:r.name,description:r.description,color:r.color,icon:r.icon,sort_order:r.sort_order}).eq("id",r.id);if($)throw $}else{const{error:$}=await o.from("push_template_categories").insert({name:r.name,description:r.description,color:r.color,icon:r.icon,sort_order:r.sort_order});if($)throw $}},onSuccess:()=>{k.invalidateQueries({queryKey:["push-template-categories"]}),P(!1),T(null),N({title:"Opgeslagen",description:"Categorie is opgeslagen."})},onError:()=>{N({title:"Fout",description:"Kon categorie niet opslaan.",variant:"destructive"})}}),rs=ze({mutationFn:async r=>{const{error:$}=await o.from("push_template_categories").delete().eq("id",r);if($)throw $},onSuccess:()=>{k.invalidateQueries({queryKey:["push-template-categories"]}),fe(null),N({title:"Verwijderd",description:"Categorie is verwijderd."})},onError:()=>{N({title:"Fout",description:"Kon categorie niet verwijderen.",variant:"destructive"})}}),ts=ze({mutationFn:async r=>{const{data:{user:$}}=await o.auth.getUser();if(!$)throw new Error("Niet ingelogd");const ce={name:r.name,title:r.title,body:r.body,icon_url:r.icon_url,image_url:r.image_url,badge_url:r.badge_url,cta_enabled:r.cta_enabled,cta_text:r.cta_text,cta_url:r.cta_url,background_color:r.background_color,text_color:r.text_color,cta_background_color:r.cta_background_color,cta_text_color:r.cta_text_color,border_radius:r.border_radius,shadow_enabled:r.shadow_enabled,close_button_enabled:r.close_button_enabled,close_button_position:r.close_button_position,template_format:r.template_format,screen_position:r.screen_position,custom_width:r.custom_width,custom_height:r.custom_height,category_id:r.category_id};if(r.id){const{error:Ke}=await o.from("push_notification_templates").update(ce).eq("id",r.id);if(Ke)throw Ke}else{const{error:Ke}=await o.from("push_notification_templates").insert(Us(ys({},ce),{owner_id:$.id,template_type:"push_notification",is_system_template:!0}));if(Ke)throw Ke}},onSuccess:()=>{k.invalidateQueries({queryKey:["system-templates"]}),k.invalidateQueries({queryKey:["push-templates"]}),I(!1),V(null),L("basis"),N({title:"Opgeslagen",description:"Template is opgeslagen."})},onError:()=>{N({title:"Fout",description:"Kon template niet opslaan.",variant:"destructive"})}}),is=ze({mutationFn:async r=>{const{error:$}=await o.from("push_notification_templates").delete().eq("id",r);if($)throw $},onSuccess:()=>{k.invalidateQueries({queryKey:["system-templates"]}),k.invalidateQueries({queryKey:["push-templates"]}),ee(null),N({title:"Verwijderd",description:"Template is verwijderd."})},onError:()=>{N({title:"Fout",description:"Kon template niet verwijderen.",variant:"destructive"})}}),Ue=ze({mutationFn:async({id:r,categoryId:$})=>{$&&await o.from("push_notification_templates").update({is_default:!1}).eq("category_id",$);const{error:ce}=await o.from("push_notification_templates").update({is_default:!0}).eq("id",r);
22if(ce)throw ce},onSuccess:()=>{k.invalidateQueries({queryKey:["system-templates"]}),k.invalidateQueries({queryKey:["push-templates"]}),N({title:"Opgeslagen",description:"Standaard template ingesteld."})},onError:()=>{N({title:"Fout",description:"Kon standaard niet instellen.",variant:"destructive"})}}),fs=()=>{V(ys({},ic)),L("basis"),I(!0)},hs=r=>{V(ys({},r)),L("basis"),I(!0)},vs=()=>{if(!(f!=null&&f.name)){N({title:"Fout",description:"Vul een naam in voor de template.",variant:"destructive"});return}ts.mutate(f)},h=()=>{T(Us(ys({},lc),{sort_order:Me.length})),P(!0)},x=r=>{T(ys({},r)),P(!0)},O=()=>{if(!(D!=null&&D.name)){N({title:"Fout",description:"Vul een naam in voor de categorie.",variant:"destructive"});return}De.mutate(D)},oe=r=>r?Me.find($=>$.id===r):null,S=r=>{V($=>$?ys(ys({},$),r):null)},Y=_t.findIndex(r=>r.id===B),_=Y===0,E=Y===_t.length-1,ve=()=>{E||L(_t[Y+1].id)},ye=()=>{_||L(_t[Y-1].id)},Ee=qe||He;return e.jsxs(R,{className:"group relative overflow-hidden border-primary/10 shadow-xl shadow-primary/5",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-purple-500/5 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx(J,{className:"relative",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-purple-500 to-purple-600 shadow-lg shadow-purple-500/25",children:e.jsx(li,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx(Q,{className:"text-xl",children:"Template Library"}),e.jsx(Z,{children:"Systeemtemplates die beschikbaar zijn voor alle gebruikers"})]})]})}),e.jsx(G,{className:"relative",children:e.jsxs(fn,{value:ue,onValueChange:je,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(vn,{children:[e.jsxs(Je,{value:"templates",className:"gap-2",children:[e.jsx(Ts,{className:"h-4 w-4"}),"Templates"]}),e.jsxs(Je,{value:"categories",className:"gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Categorieën"]})]}),ue==="templates"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{onClick:()=>{ke(!0),_e(1),Ae(""),H(3),le(""),Te([])},size:"sm",variant:"outline",className:"border-purple-500/50 text-purple-400 hover:bg-purple-500/10",children:[e.jsx(Vs,{className:"mr-2 h-4 w-4"}),"AI Genereren"]}),e.jsxs(p,{onClick:fs,size:"sm",children:[e.jsx(la,{className:"mr-2 h-4 w-4"}),"Nieuwe Template"]})]}),ue==="categories"&&e.jsxs(p,{onClick:h,size:"sm",children:[e.jsx(Ul,{className:"mr-2 h-4 w-4"}),"Nieuwe Categorie"]})]}),e.jsxs(We,{value:"templates",className:"mt-0",children:[Me.length>0&&e.jsxs("div",{className:"flex gap-2 mb-4 flex-wrap",children:[e.jsxs(ae,{variant:re==="all"?"default":"outline",className:"cursor-pointer",onClick:()=>pe("all"),children:["Alle (",Ve.length,")"]}),Me.map(r=>{const $=Ve.filter(ce=>ce.category_id===r.id).length;return e.jsxs(ae,{variant:re===r.id?"default":"outline",className:"cursor-pointer",style:re===r.id?{backgroundColor:r.color}:{borderColor:r.color,color:r.color},onClick:()=>pe(r.id),children:[r.name," (",$,")"]},r.id)}),e.jsxs(ae,{variant:re==="uncategorized"?"default":"outline",className:"cursor-pointer",onClick:()=>pe("uncategorized"),children:["Zonder categorie (",Ve.filter(r=>!r.category_id).length,")"]})]}),Ee?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3].map(r=>e.jsx("div",{className:"h-80 rounded-xl bg-muted animate-pulse"},r))}):Ie.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(li,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Geen templates gevonden"}),e.jsx("p",{className:"text-sm",children:"Maak templates aan die voor alle gebruikers beschikbaar zijn."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Ie.map(r=>{const $=oe(r.category_id);return e.jsxs("div",{onClick:()=>hs(r),className:`cursor-pointer rounded-xl border-2 transition-all overflow-hidden hover:scale-[1.02] hover:shadow-lg ${r.is_default?"border-green-500 ring-2 ring-green-500/20":"border-border hover:border-primary/50"}`,children:[e.jsx("div",{className:"p-3 bg-gradient-to-br from-background to-muted/30",children:e.jsx(mi,{template:r,compact:!0})}),e.jsxs("div",{className:"px-4 py-3 bg-card border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[$&&e.jsx(ae,{variant:"outline",className:"text-xs",style:{borderColor:$.color,color:$.color},children:$.name}),r.is_default?e.jsx(ae,{className:"bg-green-500 text-white text-xs",children:"Standaard"}):e.jsxs(p,{variant:"outline",size:"sm",onClick:ce=>{ce.stopPropagation(),Ue.mutate({id:r.id,categoryId:r.category_id})},disabled:Ue.isPending,className:"text-xs h-7",children:[e.jsx(ei,{className:"h-3.5 w-3.5 mr-1"}),"Standaard"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-bold text-lg truncate",children:r.name}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:ce=>{ce.stopPropagation(),hs(r)},children:[e.jsx(si,{className:"h-3.5 w-3.5 mr-1"}),"Bewerken"]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:ce=>{ce.stopPropagation(),ee(r.id)},children:e.jsx(Fs,{className:"h-4 w-4"})})]})]})]})]},r.id)})})]}),e.jsx(We,{value:"categories",className:"mt-0",children:He?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):Me.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Wa,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Nog geen categorieën aangemaakt"}),e.jsx("p",{className:"text-sm",children:"Maak categorieën aan om templates te ordenen."})]}):e.jsx("div",{className:"space-y-2",children:Me.map(r=>{const $=Ve.filter(ce=>ce.category_id===r.id).length;return e.jsxs("div",{className:"flex items-center justify-between border rounded-lg p-4 bg-card hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:r.color},children:e.jsx(Wa,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:r.name}),r.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$," template(s)"]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(r),children:e.jsx(si,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>fe(r.id),children:e.jsx(Fs,{className:"h-4 w-4"})})]})]},r.id)})})})]})}),e.jsx(Zt,{open:j,onOpenChange:r=>{r||(I(!1),V(null),L("basis"))},children:e.jsxs(ea,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(sa,{children:e.jsx(ta,{children:f!=null&&f.id?"Template bewerken":"Nieuwe template"})}),f&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between border-b border-border pb-4",children:_t.map((r,$)=>{const ce=r.icon,Ke=r.id===B,js=$<Y;return e.jsxs("button",{onClick:()=>L(r.id),className:`flex flex-col items-center gap-1 px-2 py-1 rounded-lg transition-all ${Ke?"bg-primary/10 text-primary":js?"text-primary/70 hover:bg-muted":"text-muted-foreground hover:bg-muted"}`,children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${Ke?"bg-primary text-primary-foreground":js?"bg-primary/20":"bg-muted"}`,children:js?e.jsx(ei,{className:"h-3.5 w-3.5"}):e.jsx(ce,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-[10px] font-medium",children:r.label})]},r.id)})}),e.jsxs("div",{className:"min-h-[300px]",children:[B==="basis"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Template naam *"}),e.jsx(q,{value:f.name||"",onChange:r=>S({name:r.target.value}),placeholder:"Bijv. Welkomstbericht"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Categorie"}),e.jsxs(os,{value:f.category_id||"none",onValueChange:r=>S({category_id:r==="none"?null:r}),children:[e.jsx(cs,{children:e.jsx(ds,{placeholder:"Selecteer categorie"})}),e.jsxs(us,{children:[e.jsx(U,{value:"none",children:"Geen categorie"}),Me.map(r=>
22e.jsx(U,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:r.color}}),r.name]})},r.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Titel *"}),e.jsx(q,{value:f.title||"",onChange:r=>S({title:r.target.value}),placeholder:"Notificatie titel"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Body"}),e.jsx(It,{value:f.body||"",onChange:r=>S({body:r.target.value}),placeholder:"Notificatie tekst...",rows:4})]})]}),B==="afbeeldingen"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(_o,{label:"Logo / Icoon",value:f.icon_url||null,onChange:r=>S({icon_url:r})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Banner afbeelding URL"}),e.jsx(q,{value:f.image_url||"",onChange:r=>S({image_url:r.target.value||null}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Badge URL (optioneel)"}),e.jsx(q,{value:f.badge_url||"",onChange:r=>S({badge_url:r.target.value||null}),placeholder:"https://..."})]})]}),B==="formaat"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Breedte"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(t=f.custom_width)!=null?t:300,"px"]})]}),e.jsx(Xe,{value:[(n=f.custom_width)!=null?n:300],onValueChange:([r])=>S({custom_width:r}),min:200,max:500,step:10})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Hoogte"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(i=f.custom_height)!=null?i:180,"px"]})]}),e.jsx(Xe,{value:[(l=f.custom_height)!=null?l:180],onValueChange:([r])=>S({custom_height:r}),min:100,max:400,step:10})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{children:"Scherm positie"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{id:"top-left",label:"↖"},{id:"top-center",label:"↑"},{id:"top-right",label:"↗"},{id:"center-left",label:"←"},{id:"center",label:"●"},{id:"center-right",label:"→"},{id:"bottom-left",label:"↙"},{id:"bottom-center",label:"↓"},{id:"bottom-right",label:"↘"}].map(r=>e.jsx("button",{onClick:()=>S({screen_position:r.id}),className:`p-2 rounded-lg border-2 text-lg transition-all ${f.screen_position===r.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:r.label},r.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Sluit knop (X)"}),e.jsx(be,{checked:(d=f.close_button_enabled)!=null?d:!0,onCheckedChange:r=>S({close_button_enabled:r})})]}),f.close_button_enabled&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Positie sluit knop"}),e.jsxs(os,{value:f.close_button_position||"top-right",onValueChange:r=>S({close_button_position:r}),children:[e.jsx(cs,{children:e.jsx(ds,{})}),e.jsxs(us,{children:[e.jsx(U,{value:"top-right",children:"Rechtsboven"}),e.jsx(U,{value:"top-left",children:"Linksboven"}),e.jsx(U,{value:"bottom-right",children:"Rechtsonder"}),e.jsx(U,{value:"bottom-left",children:"Linksonder"})]})]})]})]})]}),B==="vormgeving"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Achtergrond"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"color",value:f.background_color||"#ffffff",onChange:r=>S({background_color:r.target.value}),className:"w-10 h-10 rounded cursor-pointer border border-border"}),e.jsx(q,{value:f.background_color||"#ffffff",onChange:r=>S({background_color:r.target.value}),className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Tekst kleur"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"color",value:f.text_color||"#000000",onChange:r=>S({text_color:r.target.value}),className:"w-10 h-10 rounded cursor-pointer border border-border"}),e.jsx(q,{value:f.text_color||"#000000",onChange:r=>S({text_color:r.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Hoekafronding"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(m=f.border_radius)!=null?m:12,"px"]})]}),e.jsx(Xe,{value:[(g=f.border_radius)!=null?g:12],onValueChange:([r])=>S({border_radius:r}),min:0,max:32,step:2})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Schaduw"}),e.jsx(be,{checked:(v=f.shadow_enabled)!=null?v:!0,onCheckedChange:r=>S({shadow_enabled:r})})]})]}),B==="cta"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Call-to-Action knop"}),e.jsx(be,{checked:(u=f.cta_enabled)!=null?u:!0,onCheckedChange:r=>S({cta_enabled:r})})]}),f.cta_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Button tekst"}),e.jsx(q,{value:f.cta_text||"",onChange:r=>S({cta_text:r.target.value}),placeholder:"Bekijken"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Button URL"}),e.jsx(q,{value:f.cta_url||"",onChange:r=>S({cta_url:r.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"CTA achtergrond"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"color",value:f.cta_background_color||"#3b82f6",onChange:r=>S({cta_background_color:r.target.value}),className:"w-10 h-10 rounded cursor-pointer border border-border"}),e.jsx(q,{value:f.cta_background_color||"#3b82f6",onChange:r=>S({cta_background_color:r.target.value}),className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"CTA tekstkleur"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"color",value:f.cta_text_color||"#ffffff",onChange:r=>S({cta_text_color:r.target.value}),className:"w-10 h-10 rounded cursor-pointer border border-border"}),e.jsx(q,{value:f.cta_text_color||"#ffffff",onChange:r=>S({cta_text_color:r.target.value}),className:"flex-1"})]})]})]})]})]})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsx(p,{variant:"outline",onClick:ye,disabled:_,children:"Vorige"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",onClick:()=>{I(!1),V(null),L("basis")},children:"Annuleren"}),E?e.jsxs(p,{onClick:vs,disabled:ts.isPending,children:[ts.isPending?e.jsx(he,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Opslaan"]}):e.jsx(p,{onClick:ve,children:"Volgende"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{children:"Live Preview"}),e.jsx(mi,{template:f})]})]})]})}),e.jsx(Zt,{open:F,onOpenChange:r=>{r||(P(!1),T(null))},children:e.jsxs(ea,{className:"max-w-md",children:[e.jsx(sa,{children:e.jsx(ta,{children:D!=null&&D.id?"Categorie bewerken":"Nieuwe categorie"})}),D&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Naam *"}),e.jsx(q,{value:D.name||"",onChange:r=>T(Us(ys({},D),{name:r.target.value})),placeholder:"Bijv. Promoties"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Beschrijving"}),e.jsx(It,{value:D.description||"",onChange:r=>T(Us(ys({},D),{description:r.target.value})),placeholder:"Optionele beschrijving...",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Kleur"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"color",value:D.color,onChange:r=>T(Us(ys({},D),{color:r.target.value}
22)),className:"h-10 w-14 rounded cursor-pointer"}),e.jsx(q,{value:D.color,onChange:r=>T(Us(ys({},D),{color:r.target.value})),className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Sorteervolgorde"}),e.jsx(q,{type:"number",value:D.sort_order||0,onChange:r=>T(Us(ys({},D),{sort_order:parseInt(r.target.value)||0})),min:0})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(p,{variant:"outline",onClick:()=>{P(!1),T(null)},className:"flex-1",children:"Annuleren"}),e.jsxs(p,{onClick:O,disabled:De.isPending,className:"flex-1",children:[De.isPending?e.jsx(he,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Opslaan"]})]})]})]})}),e.jsx(cn,{open:!!me,onOpenChange:r=>!r&&ee(null),children:e.jsxs(dn,{children:[e.jsxs(un,{children:[e.jsx(mn,{children:"Template verwijderen?"}),e.jsx(hn,{children:"Deze actie kan niet ongedaan worden gemaakt. De template wordt permanent verwijderd."})]}),e.jsxs(pn,{children:[e.jsx(xn,{children:"Annuleren"}),e.jsx(gn,{onClick:()=>me&&is.mutate(me),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:is.isPending?e.jsx(he,{className:"h-4 w-4 animate-spin"}):"Verwijderen"})]})]})}),e.jsx(cn,{open:!!W,onOpenChange:r=>!r&&fe(null),children:e.jsxs(dn,{children:[e.jsxs(un,{children:[e.jsx(mn,{children:"Categorie verwijderen?"}),e.jsx(hn,{children:"Deze actie kan niet ongedaan worden gemaakt. Templates in deze categorie worden niet verwijderd, maar krijgen geen categorie meer."})]}),e.jsxs(pn,{children:[e.jsx(xn,{children:"Annuleren"}),e.jsx(gn,{onClick:()=>W&&rs.mutate(W),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:rs.isPending?e.jsx(he,{className:"h-4 w-4 animate-spin"}):"Verwijderen"})]})]})}),e.jsx(Zt,{open:Ce,onOpenChange:r=>{we||(ke(r),r||(_e(1),Ae(""),H(3),le(""),Te([])))},children:e.jsxs(ea,{className:"max-w-lg",children:[e.jsxs(sa,{children:[e.jsxs(ta,{className:"flex items-center gap-2",children:[e.jsx(Ni,{className:"h-5 w-5 text-purple-500"}),"AI Template Generator"]}),e.jsx(ki,{children:"Genereer mooie templates met AI in 3 eenvoudige stappen"})]}),e.jsx("div",{className:"flex items-center justify-center gap-2 py-4",children:[1,2,3].map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-all ${ie===r?"bg-purple-500 text-white":ie>r?"bg-green-500 text-white":"bg-muted text-muted-foreground"}`,children:ie>r?e.jsx(Ne,{className:"h-4 w-4"}):r}),r<3&&e.jsx("div",{className:`w-12 h-0.5 ${ie>r?"bg-green-500":"bg-muted"}`})]},r))}),ie===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Categorie *"}),e.jsxs(os,{value:xe,onValueChange:Ae,children:[e.jsx(cs,{children:e.jsx(ds,{placeholder:"Selecteer een categorie"})}),e.jsx(us,{children:Me.map(r=>e.jsx(U,{value:r.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:r.color}}),r.name]})},r.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Aantal templates"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Xe,{value:[z],onValueChange:([r])=>H(r),min:1,max:5,step:1,className:"flex-1"}),e.jsx("span",{className:"text-lg font-semibold w-8 text-center",children:z})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Genereer 1-5 templates tegelijk"})]})]}),ie===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{children:"Kies een prompt uit de Master Prompt Library *"}),e.jsx(No,{value:te,onValueChange:le,className:"space-y-2",children:Pe.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Geen actieve prompts gevonden. Maak eerst een master prompt aan."}):Pe.map(r=>e.jsxs("div",{className:`flex items-start space-x-3 p-3 rounded-lg border cursor-pointer transition-all ${te===r.id?"border-purple-500 bg-purple-500/10":"border-border hover:border-purple-500/50"}`,onClick:()=>
22le(r.id),children:[e.jsx(ko,{value:r.id,id:r.id,className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:r.id,className:"font-medium cursor-pointer",children:r.name}),r.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:r.description})]})]},r.id))})]}),ie===3&&e.jsxs("div",{className:"space-y-4",children:[!we&&M.length===0&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-purple-500/20 flex items-center justify-center mx-auto mb-4",children:e.jsx(Vs,{className:"h-8 w-8 text-purple-500"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Klaar om te genereren"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[z," template",z>1?"s":""," worden gegenereerd voor"," ",e.jsx("span",{className:"font-medium text-foreground",children:((w=Me.find(r=>r.id===xe))==null?void 0:w.name)||"onbekende categorie"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates worden één voor één gegenereerd om timeouts te voorkomen"})]}),we&&e.jsxs("div",{className:"py-6 space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-purple-500/20 flex items-center justify-center mx-auto mb-4 animate-pulse",children:e.jsx(he,{className:"h-8 w-8 text-purple-500 animate-spin"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Templates worden gegenereerd..."}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:ms||"Bezig met genereren..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsx("span",{children:"Voortgang"}),e.jsxs("span",{children:[Le," / ",z]})]}),e.jsx(Hs,{value:Le/z*100,className:"h-3"})]}),M.length>0&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gegenereerde templates:"}),M.map((r,$)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ne,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{children:r.name||`Template ${$+1}`})]},r.id))]})]}),!we&&M.length>0&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center mx-auto mb-4",children:e.jsx(Ne,{className:"h-8 w-8 text-green-500"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Gereed!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M.length," template",M.length>1?"s":""," succesvol gegenereerd"]})]})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsxs(p,{variant:"outline",onClick:()=>{ie===1?ke(!1):_e(r=>r-1)},disabled:we,children:[e.jsx(Bl,{className:"mr-2 h-4 w-4"}),ie===1?"Annuleren":"Vorige"]}),ie<3?e.jsxs(p,{onClick:()=>_e(r=>r+1),disabled:ie===1&&!xe||ie===2&&!te,children:["Volgende",e.jsx(ia,{className:"ml-2 h-4 w-4"})]}):M.length>0&&!we?e.jsx(p,{onClick:()=>ke(!1),children:"Sluiten"}):e.jsx(p,{onClick:async()=>{Fe(!0),Qe(0),Te([]);const r=Me.find(ce=>ce.id===xe),$=[];try{for(let ce=0;ce<z;ce++){Ge(`Template ${ce+1} van ${z} wordt gegenereerd...`),ce>0&&(Ge(`Wachten op Higgsfield API... (${ce+1}/${z})`),await new Promise(Gs=>setTimeout(Gs,8e3)),Ge(`Template ${ce+1} van ${z} wordt gegenereerd...`));const{data:Ke,error:js}=await o.functions.invoke("generate-ai-templates",{body:{categoryId:xe,promptId:te,categoryName:(r==null?void 0:r.name)||"Algemeen",templateIndex:ce}});if(js){N({title:`Fout bij template ${ce+1}`,description:js.message||"Er is iets misgegaan.",variant:"destructive"});continue}if(!Ke.success){N({title:`Fout bij template ${ce+1}`,description:Ke.error||"Er is iets misgegaan.",variant:"destructive"});continue}Ke.template&&($.push(Ke.template),Te([...$])),Qe(ce+1)}k.invalidateQueries({queryKey:["system-templates"]}),$.length>0&&N({title:"Templates gegenereerd!",description:`${$.length} nieuwe templates zijn aangemaakt.`})}catch(ce){N({title:"Fout bij genereren",description:ce.message||"Er is iets misgegaan.",variant:"destructive"})}finally{Fe(!1),Ge("")}},disabled:we,className:"bg-purple-600 hover:bg-purple-700",children:we?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"mr-2 h-4 w-4 animate-spin"}),"Genereren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Vs,{className:"mr-2 h-4 w-4"}),"Genereer Templates"]})})]})]})})]})}const cc=({userId:t})=>{const{data:n,isLoading:i}=Go(t),l=qo(),{toast:d}=ss(),[m,g]=a.useState(""),[v,u]=a.useState(""),[w,N]=a.useState(!1),[k,j]=a.useState(!0),[I,f]=a.useState(!1),[V,me]=a.useState(!1),[ee,ue]=a.useState(!1),[je,B]=a.use
22State("time"),[L,F]=a.useState(30),[P,D]=a.useState(!0),[T,W]=a.useState(50),[fe,re]=a.useState("Wil je op de hoogte blijven?"),[pe,Ce]=a.useState("Ontvang meldingen over relevante updates en aanbiedingen.");a.useEffect(()=>{(async()=>{if(t)try{const{data:H,error:te}=await o.from("profiles").select("vapid_public_key").eq("id",t).single();!te&&H&&(N(!!H.vapid_public_key),H.vapid_public_key&&g(H.vapid_public_key))}catch(H){}finally{j(!1)}})()},[t]),a.useEffect(()=>{n&&(ue(n.push_enabled),B(n.push_trigger_type),F(n.push_trigger_time_seconds),D(n.push_trigger_on_exit),W(n.push_trigger_scroll_depth),re(n.push_prompt_title),Ce(n.push_prompt_message))},[n]);const ke=async()=>{if(!t||!m||!v){d({title:"Fout",description:"Genereer eerst VAPID keys voordat je opslaat.",variant:"destructive"});return}try{const{error:z}=await o.from("profiles").update({vapid_public_key:m,vapid_private_key:v}).eq("id",t);if(z)throw z;N(!0),d({title:"VAPID Keys Opgeslagen",description:"Je push notificatie configuratie is nu actief."})}catch(z){d({title:"Fout",description:"Kon VAPID keys niet opslaan.",variant:"destructive"})}},ie=async()=>{if(t){f(!0);try{const{data:z,error:H}=await o.functions.invoke("register-push-subscription",{body:{action:"check",owner_id:t}});if(H)throw H;if(z!=null&&z.success&&(z!=null&&z.configured))d({title:"VAPID Keys Geldig",description:"Public key gevonden en correct geconfigureerd."});else throw new Error((z==null?void 0:z.error)||"VAPID configuratie niet gevonden")}catch(z){d({title:"VAPID Test Mislukt",description:z.message||"Kon VAPID keys niet valideren.",variant:"destructive"})}finally{f(!1)}}},_e=()=>{navigator.clipboard.writeText(m),d({title:"Gekopieerd",description:"Public key gekopieerd naar clipboard."})},xe=async()=>{if(!t){d({title:"Fout",description:"Gebruiker niet gevonden",variant:"destructive"});return}await l.mutateAsync({userId:t,updates:{push_enabled:ee,push_trigger_type:je,push_trigger_time_seconds:L,push_trigger_on_exit:P,push_trigger_scroll_depth:T,push_prompt_title:fe,push_prompt_message:pe}})};if(i||k)return e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Se,{className:"h-6 w-6 animate-spin text-muted-foreground"})});const Ae=async()=>{if(t){me(!0);try{const{data:z,error:H}=await o.functions.invoke("send-push-notification",{body:{owner_id:t,title:"🧪 Test Push Notificatie",body:"Dit is een test push van het beheerpaneel. Als je dit ziet, werkt alles!",url:"/",generate_with_ai:!1}});if(H)throw H;if(z!=null&&z.success)z.sent>0?d({title:"Test Push Verstuurd",description:`${z.sent} van ${z.total} subscriber(s) bereikt.`}):d({title:"Geen Subscribers",description:"Er zijn nog geen actieve push subscribers.",variant:"destructive"});else throw new Error((z==null?void 0:z.error)||"Kon push niet versturen")}catch(z){d({title:"Push Versturen Mislukt",description:z.message||"Kon test push niet versturen.",variant:"destructive"})}finally{me(!1)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(oc,{}),e.jsxs(R,{className:"group relative overflow-hidden border-primary/10 shadow-xl shadow-primary/5",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-500/5 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx(J,{className:"relative",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-orange-500 to-orange-600 shadow-lg shadow-orange-500/25",children:e.jsx(Ts,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx(Q,{className:"text-xl",children:"Push Notificaties"}),e.jsx(Z,{children:"VAPID keys voor Web Push notificaties"})]})]})}),e.jsxs(G,{className:"relative space-y-6",children:[e.jsx("div",{className:"p-4 rounded-xl bg-muted/30 border border-muted-foreground/10 space-y-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ps,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"VAPID Keys Configuratie"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Genereer keys via"," ",e.jsxs("a",{href:"https://vapidkeys.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["vapidkeys.com",e.jsx(oa,{className:"h-3 w-3"})]})]})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"text-sm font-medium flex items-center gap-2",children:["Public Key",w&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-500/10 text-green-500 border border-green-500/20",children:"Geconfigureerd"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{placeholder:"Plak hier de VAPID public key...",value:m,onChange:z=>g(z.target.value),className:"h-11 bg-muted/50 border-muted-foreground
22/20 focus:border-primary focus:bg-background transition-all pr-10 font-mono text-xs"}),m&&e.jsx(p,{type:"button",variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8",onClick:_e,children:e.jsx(At,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"text-sm font-medium flex items-center gap-2",children:["Private Key",w&&v&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-500/10 text-green-500 border border-green-500/20",children:"Geconfigureerd"})]}),e.jsx("div",{className:"relative",children:e.jsx(q,{type:"password",placeholder:"Plak hier de VAPID private key...",value:v,onChange:z=>u(z.target.value),className:"h-11 bg-muted/50 border-muted-foreground/20 focus:border-primary focus:bg-background transition-all font-mono text-xs"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deze key wordt versleuteld opgeslagen en is alleen zichtbaar voor beheerders"})]})]}),w&&e.jsxs("div",{className:"p-3 rounded-lg bg-green-500/10 border border-green-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-500",children:[e.jsx(Os,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Push notificaties zijn geconfigureerd"})]}),e.jsx("p",{className:"text-xs text-green-500/80 mt-1",children:"Deze gebruiker kan nu push notificaties versturen via de Target Suite"})]}),!w&&!m&&!v&&e.jsxs(xs,{variant:"destructive",children:[e.jsx(Ks,{className:"h-4 w-4"}),e.jsx(Ct,{children:"VAPID Keys Niet Geconfigureerd"}),e.jsx(gs,{children:"Push notificaties werken niet zonder VAPID keys. Configureer deze om push te activeren."})]}),m&&v&&!w&&e.jsxs(p,{onClick:ke,className:"w-full",children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"VAPID Keys Opslaan"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{type:"button",variant:"outline",onClick:ie,disabled:I,className:"flex-1",children:I?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"mr-2 h-4 w-4 animate-spin"}),"Testen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Hl,{className:"mr-2 h-4 w-4"}),"Test VAPID Keys"]})}),e.jsx(p,{type:"button",variant:"secondary",onClick:Ae,disabled:V||!w,className:"flex-1 bg-orange-500 hover:bg-orange-600 text-white",children:V?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"mr-2 h-4 w-4 animate-spin"}),"Versturen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"mr-2 h-4 w-4"}),"Test Push Versturen"]})})]})]})]}),e.jsxs(R,{className:w?"border-primary/20":"opacity-50 pointer-events-none",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"h-5 w-5 text-primary"}),"Push Notificaties"]}),e.jsx(Z,{children:"Configureer wanneer en hoe de push notificatie prompt aan bezoekers wordt getoond."})]}),e.jsx(G,{className:"space-y-6",children:e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Push Notificaties Inschakelen"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Vraag bezoekers om zich aan te melden voor push notificaties"})]}),e.jsx(be,{checked:ee,onCheckedChange:ue,disabled:!w})]})})]}),e.jsxs(R,{className:!ee||!w?"opacity-50 pointer-events-none":"",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-5 w-5 text-primary"}),"Trigger Instellingen"]}),e.jsx(Z,{children:"Bepaal wanneer de push notificatie prompt wordt getoond aan bezoekers."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 border rounded-lg bg-muted/30",children:[e.jsx(b,{className:"text-base font-medium mb-3 block",children:"Trigger Type"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{type:"button",variant:je==="time"?"default":"outline",onClick:()=>B("time"),className:"flex-1",children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Tijd op pagina"]}),e.jsxs(p,{type:"button",variant:je==="scroll"?"default":"outline",onClick:()=>B("scroll"),className:"flex-1",children:[e.jsx(ti,{className:"h-4 w-4 mr-2"}),"Scroll diepte"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Kies of de prompt wordt getoond na een bepaalde tijd óf na een bepaalde scroll diepte (niet beide)"})]}),je==="time"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Tijd op pagina (seconden): ",L]}),e.jsx(Xe,{value:[L],onValueChange:z=>F(z[0]),min:5,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toon de prompt nadat een bezoeker X seconden op de pagina is geweest"})]})}),je==="scroll"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(ti,{className:"h-4 w-4"}),"Scroll diepte (%): ",T,"%"]}),e.jsx(Xe,{value:[T],onValueChange:z=>W(z[0]),min:10,max:100,step:10,className:"w-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toon de prompt nadat een bezoeker X% van de pagina heeft gescrolld"})]})}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(b,{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Jl,{className:"h-4 w-4"}),"Exit Intent Detectie (altijd actief als fallback)"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toon de prompt wanneer een bezoeker probeert weg te navigeren"})]}),e.jsx(be,{checked:P,onCheckedChange:D})]})]})]}),e.jsx(p,{onClick:xe,disabled:l.isPending,className:"w-full",children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Push Instellingen Opslaan"]})})]})},dc=[1,10,25,50,100,250];function uc(){var t,n;const[i,l]=a.useState(""),[d,m]=a.useState(!1),[g,v]=a.useState(!1),[u,w]=a.useState(!1),[N,k]=a.useState(null),[j,I]=a.use
22State(!1),[f,V]=a.useState(!1),[me,ee]=a.useState(!1),[ue,je]=a.useState(!1),[B,L]=a.useState(!1),[F,P]=a.useState(!1),[D,T]=a.useState(To(new Date)),[W,fe]=a.useState([]),[re,pe]=a.useState(new Date),[Ce,ke]=a.useState(25),[ie,_e]=a.useState(void 0),[xe,Ae]=a.useState(void 0),[z,H]=a.useState([]),{toast:te}=ss(),le=Es(),{data:we=[],isLoading:Fe}=es({queryKey:["youtube-channels"],queryFn:async()=>{const{data:h,error:x}=await o.from("lumen_youtube_channels").select("*").order("created_at",{ascending:!1});if(x)throw x;return h}}),{data:M}=es({queryKey:["pipeline-stats"],queryFn:async()=>{const[h,x,O,oe,S,Y,_]=await Promise.all([o.from("lumen_youtube_videos").select("id",{count:"planned",head:!0}),o.from("lumen_youtube_videos").select("id",{count:"planned",head:!0}).eq("transcript_status","pending"),o.from("lumen_youtube_videos").select("id",{count:"planned",head:!0}).eq("transcript_status","completed"),o.from("lumen_youtube_videos").select("id",{count:"planned",head:!0}).eq("transcript_status","unavailable"),o.from("lumen_youtube_videos").select("id",{count:"planned",head:!0}).not("ai_summary","is",null),o.from("lumen_video_articles").select("id",{count:"planned",head:!0}),o.from("lumen_video_articles").select("id",{count:"planned",head:!0}).eq("article_type","full")]),E=Math.max(0,(O.count||0)-(_.count||0));return{total:h.count||0,pending:x.count||0,transcribed:O.count||0,unavailable:oe.count||0,analyzed:S.count||0,articles:Y.count||0,readyForFullArticles:E}},staleTime:2*60*1e3,refetchInterval:!1}),{data:Te}=es({queryKey:["smart-transcript-date"],queryFn:async()=>{const[{data:h,error:x},{data:O,error:oe}]=await Promise.all([o.from("lumen_youtube_videos").select("published_at").eq("transcript_status","completed").order("published_at",{ascending:!1}).limit(1).maybeSingle(),o.from("lumen_youtube_videos").select("published_at").eq("transcript_status","pending").order("published_at",{ascending:!0}).limit(1).maybeSingle()]);if(x)throw x;if(oe)throw oe;const S=h!=null&&h.published_at?new Date(h.published_at):null,Y=O!=null&&O.published_at?new Date(O.published_at):null;return Y&&(!S||Y<S)?{date:Y,type:"oldest_pending"}:S?{date:S,type:"last_completed"}:null}});a.useEffect(()=>{Te!=null&&Te.date&&!ie&&_e(Te.date)},[Te]);const{data:Le,isFetching:Qe}=es({queryKey:["filtered-pending-count",z,ie==null?void 0:ie.toISOString(),xe==null?void 0:xe.toISOString()],queryFn:async()=>{let h=o.from("lumen_youtube_videos").select("*",{count:"exact",head:!0}).eq("transcript_status","pending");z.length>0&&(h=h.in("channel_id",z)),ie&&(h=h.gte("published_at",ie.toISOString())),xe&&(h=h.lte("published_at",xe.toISOString()));const{count:x,error:O}=await h;if(O)throw O;return x!=null?x:0}}),ms=ze({mutationFn:async h=>{const{data:x,error:O}=await o.functions.invoke("add-youtube-channel",{body:{channelUrl:h}});if(O)throw O;if(x!=null&&x.error)throw new Error(x.error);return x},onSuccess:h=>{var x;le.invalidateQueries({queryKey:["youtube-channels"]}),l(""),te({title:"Kanaal toegevoegd",description:`${((x=h.channel)==null?void 0:x.channel_name)||"Kanaal"} is succesvol toegevoegd.`})},onError:h=>{te({title:"Fout bij toevoegen",description:h.message,variant:"destructive"})}}),Ge=ze({mutationFn:async({id:h,isActive:x})=>{const{error:O}=await o.from("lumen_youtube_channels").update({is_active:x}).eq("id",h);if(O)throw O},onSuccess:()=>{le.invalidateQueries({queryKey:["youtube-channels"]})}}),Me=ze({mutationFn:async h=>{const{error:x}=await o.from("lumen_youtube_channels").delete().eq("id",h);if(x)throw x},onSuccess:()=>{le.invalidateQueries({queryKey:["youtube-channels"]}),te({title:"Kanaal verwijderd",description:"Het YouTube kanaal is verwijderd."})},onError:h=>{te({title:"Fout bij verwijderen",description:h.message,variant:"destructive"})}}),He=ze({mutationFn:async()=>{const{data:h,error:x}=await o.functions.invoke("sync-youtube-videos");if(x)throw x;if(h!=null&&h.error)throw new Error(h.error);return h},onSuccess:h=>{le.invalidateQueries({queryKey:["pipeline-stats"]}),te({title:"Video's gesynchroniseerd",description:`${h.videosAdded||0} nieuwe video's gevonden.`})},onError:h=>{te({title:"Sync mislukt",description:h.message,variant:"destructive"})}}),Ve=ze({mutationFn:async({publishedAfter:h,publishedBefore:x,channelIds:O})=>{const oe=new URLSearchParams;oe.set("historical","true"),h&&oe.set("publishedAfter",h),x&&oe.set("publishedBefore",x),O&&O.length>0&&oe.set("channelIds",O.join(",")),oe.set("maxResults","200");const{data:S,error:Y}=await o.functions.invoke(`sync-youtube-videos?${oe.toString()}`);if(Y)throw Y;if(S!=null&&S.error)throw new Error(S.error);return S},onSuccess:h=>{var x;
22le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["youtube-videos"]});const O=((x=h.results)==null?void 0:x.reduce((oe,S)=>oe+(S.videosSkipped||0),0))||0;k({videosAdded:h.videosAdded||0,videosSkipped:O}),te({title:"Historische video's gesynchroniseerd",description:`${h.videosAdded||0} nieuwe video's toegevoegd${O>0?`, ${O} duplicaten overgeslagen`:""}.`})},onError:h=>{te({title:"Historische sync mislukt",description:h.message,variant:"destructive"})}}),qe=ze({mutationFn:async({batchSize:h,startDate:x,endDate:O,channelIds:oe})=>{const S=Math.min(h,10),Y=Math.ceil(h/S);let _=0,E=0,ve=null,ye=0;for(let Ee=0;Ee<Y;Ee++){const r=new URLSearchParams;r.set("processPending","true"),r.set("maxVideos",String(S)),r.set("parallel","2"),x&&r.set("publishedAfter",x.toISOString()),O&&r.set("publishedBefore",O.toISOString()),oe&&oe.length>0&&r.set("channelIds",oe.join(","));const{data:$,error:ce}=await o.functions.invoke(`fetch-youtube-transcript?${r.toString()}`);if(ce)throw ce;if($!=null&&$.error)throw new Error($.error);if(_+=$.successful||0,E+=$.failed||0,ve=$.remainingPending,ye++,ve===0||$.successful===0&&$.failed===0)break;Ee<Y-1&&ve>0&&await new Promise(Ke=>setTimeout(Ke,500))}return{successful:_,failed:E,remainingPending:ve,roundsCompleted:ye}},onSuccess:h=>{le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["youtube-videos"]}),le.invalidateQueries({queryKey:["smart-transcript-date"]}),te({title:"Transcripties opgehaald",description:`${h.successful||0} succesvol, ${h.failed||0} niet beschikbaar (${h.roundsCompleted} rondes).${typeof h.remainingPending=="number"&&h.remainingPending>0?` Nog ${h.remainingPending} in wachtrij.`:""}`})},onError:h=>{te({title:"Fout bij transcripties",description:h.message,variant:"destructive"})}}),Pe=ze({mutationFn:async()=>{const h=((M==null?void 0:M.transcribed)||0)-((M==null?void 0:M.analyzed)||0),{data:x,error:O}=await o.functions.invoke("analyze-youtube-video?processPending=true&articleType=snackable&maxVideos="+Math.max(h,100));if(O)throw O;if(x!=null&&x.error)throw new Error(x.error);return x},onSuccess:h=>{var x;le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["youtube-videos"]}),le.invalidateQueries({queryKey:["video-articles"]}),le.invalidateQueries({queryKey:["top-articles"]}),le.invalidateQueries({queryKey:["categories-with-content"]}),le.invalidateQueries({queryKey:["ai-news-articles"]}),te({title:"AI Analyse voltooid (Snackable)",description:`${h.processed||0} video's geanalyseerd. ${((x=h.totalTokens)==null?void 0:x.toLocaleString())||0} tokens gebruikt (~${h.avgTokensPerVideo||0}/video).`})},onError:h=>{te({title:"Fout bij analyse",description:h.message,variant:"destructive"})}}),Ie=ze({mutationFn:async()=>{const{data:h,error:x}=await o.functions.invoke("generate-full-articles?processPending=true&maxVideos=50&chunkSize=5");if(x)throw x;if(h!=null&&h.error)throw new Error(h.error);return h},onSuccess:h=>{var x;if(le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["video-articles"]}),h.mode==="background"){je(!0),te({title:"🚀 Artikel Generatie Gestart!",description:`${h.totalToProcess} artikelen worden op de achtergrond gegenereerd. Ververs straks de pagina.`});const O=Math.max(6e4,h.totalToProcess*3e4);setTimeout(()=>{je(!1),le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["video-articles"]})},O)}else te({title:"✨ Artikelen Gegenereerd!",description:`${h.processed||0} volwaardige artikelen gecreëerd met ${((x=h.totalTokens)==null?void 0:x.toLocaleString())||0} tokens.`})},onError:h=>{te({title:"Fout bij artikel generatie",description:h.message,variant:"destructive"})}}),De=async()=>{if(i.trim()){m(!0);try{await ms.mutateAsync(i)}finally{m(!1)}}},rs=async()=>{v(!0);try{await He.mutateAsync()}finally{v(!1)}},ts=async()=>{if(!D||!re){te({title:"Selecteer datums",description:"Kies een start- en einddatum voor de historische sync.",variant:"destructive"});return}w(!0);try{await Ve.mutateAsync({publishedAfter:D.toISOString(),publishedBefore:re.toISOString(),channelIds:W.length>0?W:void 0})}finally{w(!1)}},is=async()=>{I(!0);try{await qe.mutateAsync({batchSize:Ce,startDate:ie,endDate:xe,channelIds:z.length>0?z:void 0})}finally{I(!1)}},Ue=async()=>{V(!0);try{await Pe.mutateAsync()}finally{V(!1)}},fs=async()=>
22{if(ue){te({title:"⏳ Generatie al actief",description:"Er worden al artikelen op de achtergrond gegenereerd. Wacht tot dit is voltooid."});return}ee(!0);try{await Ie.mutateAsync()}finally{ee(!1)}},hs=async()=>{L(!0);try{te({title:"Pipeline gestart",description:"Stap 1/3: Video's synchroniseren..."}),await He.mutateAsync(),te({title:"Pipeline",description:"Stap 2/3: Transcripties ophalen..."}),await qe.mutateAsync({batchSize:Ce}),te({title:"Pipeline",description:"Stap 3/3: AI Analyse uitvoeren..."}),await Pe.mutateAsync(),te({title:"Pipeline voltooid!",description:"Alle stappen zijn succesvol uitgevoerd."})}catch(h){te({title:"Pipeline gestopt",description:h.message,variant:"destructive"})}finally{L(!1)}},vs=async()=>{P(!0);try{const{error:h}=await o.from("lumen_youtube_videos").update({transcript_status:"pending",transcript_text:null,transcript_language:null,transcript_tokens:null,ai_summary:null}).neq("transcript_status","pending");if(h)throw h;le.invalidateQueries({queryKey:["pipeline-stats"]}),le.invalidateQueries({queryKey:["youtube-videos"]}),le.invalidateQueries({queryKey:["smart-transcript-date"]}),_e(void 0),te({title:"Pipeline gereset",description:"Alle video statussen zijn teruggezet naar 'wacht op transcript'."})}catch(h){te({title:"Reset mislukt",description:h.message,variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-5 w-5 text-red-500"}),"YouTube Kanaal Toevoegen"]}),e.jsx(Z,{children:"Voeg een YouTube kanaal toe om automatisch video's te analyseren voor AI model nieuws en insights."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"channel-url",className:"sr-only",children:"YouTube Kanaal URL"}),e.jsx(q,{id:"channel-url",placeholder:"https://youtube.com/@AIExplained of kanaal URL...",value:i,onChange:h=>l(h.target.value),onKeyDown:h=>h.key==="Enter"&&De()})]}),e.jsxs(p,{onClick:De,disabled:d||!i.trim(),children:[d?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(la,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 hidden sm:inline",children:"Toevoegen"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:"Ondersteunde formaten:"}),e.jsx("code",{className:"bg-muted px-1 rounded",children:"youtube.com/@handle"}),e.jsx("code",{className:"bg-muted px-1 rounded",children:"youtube.com/channel/ID"})]})]})]}),e.jsxs(R,{className:"border-primary/20 bg-gradient-to-r from-primary/5 via-transparent to-accent/5",children:[e.jsxs(J,{className:"flex flex-row items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ds,{className:"h-5 w-5 text-primary"}),"Video Analyse Pipeline"]}),e.jsx(Z,{children:"Automatische transcriptie en AI analyse van YouTube video's"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:vs,disabled:F,className:"text-orange-600 border-orange-500/30 hover:bg-orange-500/10",children:[F?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Reset Pipeline"]})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[e.jsxs("div",{className:"text-center p-3 rounded-lg bg-background/50 border",children:[e.jsx("div",{className:"text-2xl font-bold text-foreground",children:(M==null?void 0:M.total)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Totaal Video's"})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20",children:[e.jsx("div",{className:"text-2xl font-bold text-yellow-600",children:(M==null?void 0:M.pending)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Wacht op Transcript"})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:(M==null?void 0:M.transcribed)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Getranscribeerd"})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:(M==null?void 0:M.unavailable)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Geen Transcript"})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-green-500/10 border border-green-500/20",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:(M==null?void 0:M.analyzed)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"AI Geanalyseerd"})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-purple-500/10 border border-purple-500/20",children:[e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:(M==null?void 0:M.articles)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Artikelen"})]})]}),M&&M.total>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-2",children:[e.jsx(ct,{className:"h-3.5 w-3.5 text-blue-500"}),"Transcriptie voortgang"]}),e.jsxs("span",{className:"font-medium",children:[M.transcribed+M.unavailable," / ",M.total," verwerkt",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Math.round((M.transcribed+M.unavailable)/M.total*100),"%)"]})]})]}),e.jsx("div",{className:"relative",children:e.jsx(Hs,{value:(M.transcribed+M.unavailable)/M.total*100,className:"h-2"})}),e.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"}),M.transcribed," succesvol"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-500"}),M.unavailable," niet beschikbaar"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-500"}),M.pending," wachtend"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-2",children:[e.jsx(Vs,{className:"h-3.5 w-3.5 text-green-500"}),"AI Analyse voortgang"]}),e.jsxs("span",{className:"font-medium",children:[M.analyzed," / ",M.total," geanalyseerd",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Math.round(M.analyzed/M.total*100),"%)"]})]})]}),e.jsx(Hs,{value:M.analyzed/M.total*100,className:"h-2"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ct,{className:"h-4 w-4 text-primary"}),"Transcripties Ophalen Instellingen"]}
22),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"Kanalen filter"}),e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsx(p,{variant:"outline",className:"w-full justify-start text-left font-normal h-10",children:z.length===0?e.jsx("span",{className:"text-muted-foreground",children:"Alle kanalen"}):z.length===1?e.jsx("span",{children:(t=we.find(h=>h.id===z[0]))==null?void 0:t.channel_name}):e.jsxs("span",{children:[z.length," kanalen"]})})}),e.jsx(ot,{className:"w-64 p-2 bg-popover",align:"start",children:e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.jsxs(p,{variant:"ghost",size:"sm",className:"w-full justify-start text-xs",onClick:()=>H([]),children:[e.jsx(Ne,{className:ns("h-3 w-3 mr-2",z.length===0?"opacity-100":"opacity-0")}),"Alle kanalen"]}),we.filter(h=>h.is_active).map(h=>{const x=z.includes(h.id);return e.jsxs(p,{variant:"ghost",size:"sm",className:"w-full justify-start text-xs",onClick:()=>{H(x?O=>O.filter(oe=>oe!==h.id):O=>[...O,h.id])},children:[e.jsx(Ne,{className:ns("h-3 w-3 mr-2",x?"opacity-100":"opacity-0")}),h.channel_name]},h.id)})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"Aantal per batch"}),e.jsx("select",{value:Ce,onChange:h=>ke(Number(h.target.value)),className:"w-full h-10 rounded-md border border-input bg-background px-3 py-2 text-sm r
22ing-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:dc.map(h=>e.jsxs("option",{value:h,children:[h," video's"]},h))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"text-xs text-muted-foreground",children:["Van datum",Te&&e.jsxs("span",{className:"ml-1 text-primary",children:["(",Te.type==="last_completed"?"laatste transcriptie":"oudste video",")"]})]}),e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:ns("w-full justify-start text-left font-normal",!ie&&"text-muted-foreground"),children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),ie?ks(ie,"d MMM yyyy",{locale:Ss}):"Geen filter"]})}),e.jsxs(ot,{className:"w-auto p-0 bg-popover",align:"start",children:[e.jsx(Qt,{mode:"single",selected:ie,onSelect:_e,initialFocus:!0}),ie&&e.jsx("div",{className:"p-2 border-t",children:e.jsxs(p,{variant:"ghost",size:"sm",className:"w-full",onClick:()=>_e(void 0),children:[e.jsx(zs,{className:"h-3 w-3 mr-1"})," Wis datum"]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:"Tot datum (optioneel)"}),e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:ns("w-full justify-start text-left font-normal",!xe&&"text-muted-foreground"),children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),xe?ks(xe,"d MMM yyyy",{locale:Ss}):"Geen filter"]})}),e.jsxs(ot,{className:"w-auto p-0 bg-popover",align:"start",children:[e.jsx(Qt,{mode:"single",selected:xe,onSelect:Ae,initialFocus:!0}),xe&&e.jsx("div",{className:"p-2 border-t",children:e.jsxs(p,{variant:"ghost",size:"sm",className:"w-full",onClick:()=>Ae(void 0),children:[e.jsx(zs,{className:"h-3 w-3 mr-1"})," Wis datum"]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-xs text-muted-foreground",children:" "}),e.jsxs(p,{onClick:is,disabled:j||B||Qe||(Le!=null?Le:0)===0,className:"w-full",children:[j?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ct,{className:"h-4 w-4 mr-2"}),"Ophalen",(Le!=null?Le:0)>0&&e.jsx(ae,{variant:"secondary",className:"ml-2",children:Le})]}),!j&&!B&&(Le!=null?Le:0)===0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Geen video’s met status ",e.jsx("span",{className:"font-medium",children:"wacht op transcript"})," binnen deze selectie. Kies een eerdere ",e.jsx("span",{className:"font-medium",children:"van datum"})," of selecteer ",e.jsx("span",{className:"font-medium",children:"Alle kanalen"}),"."]})]})]}),(z.length>0||ie||xe)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[z.length>0&&`Alleen videos van ${z.length===1?((n=we.find(h=>h.id===z[0]))==null?void 0:n.channel_name)||"geselecteerd kanaal":`${z.length} kanalen`}`,z.length>0&&(ie||xe)&&", ",(ie||xe)&&"gepubliceerd",ie&&` vanaf ${ks(ie,"d MMM yyyy",{locale:Ss})}`,ie&&xe&&" tot",xe&&` ${ks(xe,"d MMM yyyy",{locale:Ss})}`," ","worden verwerkt."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(p,{variant:"outline",onClick:Ue,disabled:f||B||me||((M==null?void 0:M.transcribed)||0)-((M==null?void 0:M.analyzed)||0)<=0,children:[f?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Vs,{className:"h-4 w-4 mr-2"}),"AI Analyse Starten",((M==null?void 0:M.transcribed)||0)-((M==null?void 0:M.analyzed)||0)>0&&e.jsx(ae,{variant:"secondary",className:"ml-2",children:((M==null?void 0:M.transcribed)||0)-((M==null?void 0:M.analyzed)||0)})]}),e.jsxs(p,{onClick:fs,disabled:me||ue||B||f||((M==null?void 0:M.readyForFullArticles)||0)<=0,className:"relative overflow-hidden bg-gradient-to-r from-violet-600 via-purple-600 to-fuchsia-600 hover:from-violet-500 hover:via-purple-500 hover:to-fuchsia-500 text-white shadow-lg shadow-purple-500/25 transition-all hover:shadow-xl hover:shadow-purple-500/30 hover:scale-[1.02]",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full animate-[shimmer_2s_infinite]",style:{animation:"shimmer 2s infinite"}}),me||ue?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ni,{className:"h-4 w-4 mr-2"}),e.jsx("span",{className:"font-semibold",children:ue?"Bezig met genereren...":"Artikelen Genereren"}),!ue&&((M==null?void 0:M.readyForFullArticles)||0)>0&&e.jsx(ae,{className:"ml-2 bg-white/20 text-white border-white/30 hover:bg-white/30",children:M==null?void 0:M.readyForFullArticles})]}),e.jsxs(p,{onClick:hs,disabled:B||me,className:"bg-gradient-to-r from-primary to-accent hover:opacity-90",children:[B?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ws,{className:"h-4 w-4 mr-2"}),"Volledige Pipeline Starten"]})]}),B&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-primary/5 p-3 rounded-lg",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Pipeline wordt uitgevoerd... Dit kan enkele minuten duren."})]})]})]}),e.jsxs(R,{className:"border-dashed border-primary/30",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-5 w-5 text-primary"}),"Historische Video Sync"]}),e.jsx(Z,{children:"Haal oudere video's op van je kanalen met de YouTube Data API. Selecteer een datum bereik om video's uit het verleden te importeren."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Kanalen (optioneel)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:we.map(h=>{const x=W.includes(h.channel_id);return e.jsxs(ae,{variant:x?"default":"outline",className:"cursor-pointer hover:bg-primary/20 transition-colors",onClick:()=>{fe(O=>x?O.filter(oe=>oe!==h.channel_id):[...O,h.channel_id])},children:[h.channel_name,x&&e.jsx(Ne,{className:"h-3 w-3 ml-1"})]}
22,h.id)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:W.length===0?"Alle kanalen worden gesynchroniseerd":`${W.length} kanaal${W.length>1?"en":""} geselecteerd`})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Startdatum"}),e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:ns("w-[200px] justify-start text-left font-normal",!D&&"text-muted-foreground"),children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),D?ks(D,"d MMM yyyy",{locale:Ss}):"Kies datum"]})}),e.jsx(ot,{className:"w-auto p-0",align:"start",children:e.jsx(Qt,{mode:"single",selected:D,onSelect:T,initialFocus:!0,disabled:h=>h>new Date,className:ns("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Einddatum"}),e.jsxs(it,{children:[e.jsx(lt,{asChild:!0,children:e.jsxs(p,{variant:"outline",className:ns("w-[200px] justify-start text-left font-normal",!re&&"text-muted-foreground"),children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),re?ks(re,"d MMM yyyy",{locale:Ss}):"Kies datum"]})}),e.jsx(ot,{className:"w-auto p-0",align:"start",children:e.jsx(Qt,{mode:"single",selected:re,onSelect:pe,initialFocus:!0,disabled:h=>h>new Date,className:ns("p-3 pointer-events-auto")})})]})]}),e.jsxs(p,{onClick:ts,disabled:u||!D||!re||we.length===0,children:[u?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Pt,{className:"h-4 w-4 mr-2"}),"Historische Video's Ophalen"]})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-primary/5 p-3 rounded-lg",children:[e.jsx(he,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Historische video's worden opgehaald via de YouTube API. Dit kan even duren..."})]}),N&&N.videosAdded>0&&!u&&e.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 p-4 rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-700 dark:text-green-400",children:[e.jsx(Ne,{className:"h-5 w-5"}),e.jsxs("span",{className:"font-medium",children:[N.videosAdded," video's toegevoegd",N.videosSkipped?`, ${N.videosSkipped} duplicaten overgeslagen`:""]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start de pipeline om transcripties op te halen en AI-analyses uit te voeren op de nieuwe video's."}),e.jsxs(p,{onClick:()=>{k(null),hs()},disabled:B,className:"w-full",children:[B?e.jsx(he,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ws,{className:"h-4 w-4 mr-2"}),"Start Pipeline (Transcripties + Analyse)"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"Let op:"})," Deze functie gebruikt de YouTube Data API en vereist een geldige API key (ingesteld via API Keys). Er geldt een quotum limiet van ~10.000 verzoeken per dag."]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Gevolgde Kanalen"}),e.jsxs(Z,{children:[we.length," kanalen • ",we.filter(h=>h.is_active).length," actief"]})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:rs,disabled:g,children:[g?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(Se,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:"Sync Video's"})]})]}),e.jsx(G,{children:Fe?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):we.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx($s,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"Nog geen kanalen toegevoegd"}),e.jsx("p",{className:"text-sm",children:"Voeg hierboven een YouTube kanaal toe om te starten"})]}):e.jsx("div",{className:"space-y-3",children:we.map(h=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[h.thumbnail_url?e.jsx("img",{src:h.thumbnail_url,alt:h.channel_name,className:"w-12 h-12 rounded-full object-cover"}):e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/20 flex items-center justify-center",children:e.jsx($s,{className:"h-6 w-6 text-red-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:h.channel_name}),h.category&&e.jsx(ae,{variant:"secondary",className:"text-xs",children:h.category})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Toegevoegd op ",ks(new Date(h.created_at),"d MMM yyyy",{locale:Ss})]})]}),e.jsx(ae,{variant:h.is_active?"default":"secondary",children:h.is_active?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"})," Actief"]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"h-3 w-3 mr-1"})," Gepauzeerd"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{checked:h.is_active,onCheckedChange:x=>Ge.mutate({id:h.id,isActive:x})}),e.jsx(p,{variant:"ghost",size:"icon",asChild:!0,children:e.jsx("a",{href:h.channel_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(oa,{className:"h-4 w-4"})})}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>Me.mutate(h.id),className:"text-destructive hover:text-destructive",children:e.jsx(Fs,{className:"h-4 w-4"})})]})]}
22,h.id))})})]}),e.jsxs(R,{className:"border-dashed",children:[e.jsxs(J,{children:[e.jsx(Q,{className:"text-base",children:"Aanbevolen Kanalen"}),e.jsx(Z,{children:"Populaire AI-gerelateerde YouTube kanalen om te volgen"})]}),e.jsx(G,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:[{name:"AI Explained",url:"https://youtube.com/@AIExplained"},{name:"Matt Wolfe",url:"https://youtube.com/@maboroshi"},{name:"Fireship",url:"https://youtube.com/@Fireship"},{name:"Two Minute Papers",url:"https://youtube.com/@TwoMinutePapers"},{name:"The AI Advantage",url:"https://youtube.com/@aiadvantage"}].map(h=>e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>l(h.url),className:"gap-2",children:[e.jsx($s,{className:"h-3 w-3 text-red-500"}),h.name]},h.name))})})]})]})}var mc=Object.defineProperty,hc=Object.defineProperties,pc=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,xc=Object.prototype.hasOwnProperty,gc=Object.prototype.propertyIsEnumerable,pi=(t,n,i)=>n in t?mc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,en=(t,n)=>{for(var i in n||(n={}))xc.call(n,i)&&pi(t,i,n[i]);if(hi)for(var i of hi(n))gc.call(n,i)&&pi(t,i,n[i]);return t},sn=(t,n)=>hc(t,pc(n));const fc=({existingUrls:t})=>{const[n,i]=a.useState(!1),[l,d]=a.useState(""),[m,g]=a.useState(!1),[v,u]=a.useState([]),[w,N]=a.useState("input"),{toast:k}=ss(),j=Es(),I=(P,D)=>{const T=P.toLowerCase(),W=D.toLowerCase(),fe={OpenAI:["openai","chatgpt","gpt-4","gpt-5","dall-e","sora"],Anthropic:["anthropic","claude"],Google:["google","gemini","deepmind","bard"],Meta:["meta","llama","facebook ai"],Microsoft:["microsoft","copilot","bing ai","azure ai"],xAI:["xai","grok","elon musk ai"],Amazon:["amazon","aws ai","bedrock","alexa ai"],Apple:["apple","apple intelligence","siri ai"],Nvidia:["nvidia","cuda","tensorrt"],Mistral:["mistral"],Cohere:["cohere"],"Stability AI":["stability","stable diffusion"],"Hugging Face":["hugging face","huggingface"],Perplexity:["perplexity"],"AI Algemeen":["artificial intelligence","ai news","machine learning","deep learning"]};for(const[re,pe]of Object.entries(fe))for(const Ce of pe)if(T.includes(Ce)||W.includes(Ce))return re;try{const re=new URL(P).hostname.replace("www.","").split(".")[0];return re.charAt(0).toUpperCase()+re.slice(1)}catch(re){return"Overig"}},f=async()=>{const P=l.split(`
23`).map(T=>T.trim()).filter(T=>T.length>0&&(T.startsWith("http://")||T.startsWith("https://")));if(P.length===0){k({title:"Geen geldige URLs",description:"Voer minimaal één geldige RSS feed URL in (begint met http:// of https://).",variant:"destructive"});return}g(!0);const D=[];for(const T of P){if(t.includes(T)){D.push({url:T,title:"Bestaande feed",description:null,suggestedProvider:"",articleCount:0,isValid:!1,error:"Deze feed bestaat al",selected:!1});continue}try{const{data:W,error:fe}=await o.functions.invoke("parse-rss-feed",{body:{url:T}});if(fe)throw fe;W.success?D.push({url:T,title:W.title||T,description:W.description,suggestedProvider:I(T,W.title||""),articleCount:W.articleCount||0,isValid:!0,selected:!0}):D.push({url:T,title:T,description:null,suggestedProvider:"",articleCount:0,isValid:!1,error:W.error||"Kon feed niet parsen",selected:!1})}catch(W){D.push({url:T,title:T,description:null,suggestedProvider:I(T,""),articleCount:0,isValid:!1,error:W instanceof Error?W.message:"Onbekende fout",selected:!1})}}u(D),N("review"),g(!1)},V=P=>{u(D=>D.map((T,W)=>W===P?sn(en({},T),{selected:!T.selected}):T))},me=(P,D)=>{u(T=>T.map((W,fe)=>fe===P?sn(en({},W),{suggestedProvider:D}):W))},ee=(P,D)=>{u(T=>T.map((W,fe)=>fe===P?sn(en({},W),{title:D}):W))},ue=ze({mutationFn:async P=>{const D=P.filter(W=>W.selected&&W.isValid);if(D.length===0)throw new Error("Geen feeds geselecteerd");const{error:T}=await o.from("ai_news_rss_feeds").insert(D.map(W=>({name:W.title,url:W.url,provider:W.suggestedProvider||null,description:W.description,is_active:!0})));if(T)throw T;return D.length},onSuccess:P=>{j.invalidateQueries({queryKey:["ai-news-rss-feeds"]}),k({title:"Feeds geïmporteerd",description:`${P} RSS feed(s) succesvol toegevoegd.`}),B()},onError:P=>{k({title:"Import mislukt",description:P instanceof Error?P.message:"Onbekende fout",variant:"destructive"})}}),je=()=>{ue.mutate(v)},B=()=>{i(!1),d(""),u([]),N("input")},L=v.filter(P=>P.isValid).length,F=v.filter(P=>P.selected&&P.isValid).length;return e.jsxs(Zt,{open:n,onOpenChange:i,children:[e.jsx(Wl,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm",className:"border-purple-500/30 hover:bg-purple-500/10",children:[e.jsx(Ql,{className:"h-4 w-4 mr-2"}),"Bulk Import"]})}),e.jsxs(ea,{className:"max-w-2xl max-h-[80vh]",children:[e.jsxs(sa,{children:[e.jsxs(ta,{className:"flex items-center gap-2",children:[e.jsx(ct,{className:"h-5 w-5 text-purple-500"}),"RSS Feeds Importeren"]}),e.jsx(ki,{children:w==="input"?"Plak RSS feed URLs (één per regel). De feeds worden automatisch uitgelezen en voorzien van labels.":`${L} van ${v.length} feeds geldig. Selecteer welke je wilt importeren.`})]}),w==="input"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"RSS Feed URLs (één per regel)"}
23),e.jsx(It,{value:l,onChange:P=>d(P.target.value),placeholder:`https://news.google.com/rss/search?q=OpenAI
24https://news.google.com/rss/search?q=Anthropic+Claude
25https://news.google.com/rss/search?q=Google+Gemini`,className:"min-h-[200px] font-mono text-sm"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["💡 Tip: Google News RSS feeds werken goed. Gebruik het formaat:",e.jsx("code",{className:"bg-muted px-1 rounded",children:"https://news.google.com/rss/search?q=ZOEKTERM"})]})]}):e.jsx(Si,{className:"max-h-[400px] pr-4",children:e.jsx("div",{className:"space-y-3",children:v.map((P,D)=>e.jsx("div",{className:`p-3 rounded-lg border ${P.isValid?P.selected?"border-purple-500/30 bg-purple-500/5":"border-muted bg-muted/20":"border-destructive/30 bg-destructive/5"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[P.isValid?e.jsx(be,{checked:P.selected,onCheckedChange:()=>V(D),className:"mt-1"}):e.jsx(Ks,{className:"h-5 w-5 text-destructive mt-1"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[P.isValid?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(q,{value:P.title,onChange:T=>ee(D,T.target.value),className:"h-7 text-sm font-medium flex-1 min-w-[150px]"}),e.jsx(q,{value:P.suggestedProvider,onChange:T=>me(D,T.target.value),placeholder:"Provider",className:"h-7 text-sm w-28"}),e.jsxs(ae,{variant:"outline",className:"text-xs",children:[e.jsx(na,{className:"h-3 w-3 mr-1"}),P.articleCount," artikelen"]})]}),P.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:P.description})]}):e.jsx("div",{children:e.jsx("p",{className:"text-sm font-medium text-destructive",children:P.error})}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:P.url})]})]})},D))})}),e.jsx(Yl,{className:"flex-col sm:flex-row gap-2",children:w==="input"?e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"outline",onClick:B,children:"Annuleren"}),e.jsx(p,{onClick:f,disabled:m||!l.trim(),className:"bg-purple-500 hover:bg-purple-600",children:m?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-4 w-4 mr-2 animate-spin"}),"Feeds uitlezen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Feeds Uitlezen & Labels Toewijzen"]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"outline",onClick:()=>N("input"),children:"Terug"}),e.jsx(p,{onClick:je,disabled:F===0||ue.isPending,className:"bg-purple-500 hover:bg-purple-600",children:ue.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-4 w-4 mr-2 animate-spin"}),"Importeren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),F," Feed(s) Importeren"]})})]})})]})]})},_s={ainews_sync_enabled:!0,ainews_sync_base_schedule:"0 */6 * * *",ainews_sync_lookback_days:30,ainews_sync_max_articles:50,ainews_scraping_enabled:!0,ainews_scraping_delay_minutes:30,ainews_translation_enabled:!0,ainews_translation_delay_minutes:30,ainews_sync_batch_size:10,ainews_scrape_batch_size:5,ainews_translate_batch_size:3},vc=[{value:"2",label:"Elke 2 uur",interval:2},{value:"3",label:"Elke 3 uur",interval:3},{value:"4",label:"Elke 4 uur",interval:4},{value:"6",label:"Elke 6 uur",interval:6},{value:"8",label:"Elke 8 uur",interval:8},{value:"12",label:"Elke 12 uur",interval:12},{value:"24",label:"Eenmaal per dag",interval:24}];function jc(t){const n=t.split(" ");if(n.length!==5)return{frequency:6,hour:0,minute:0};const i=parseInt(n[0],10)||0,l=n[1];if(l.startsWith("*/"))return{frequency:parseInt(l.substring(2),10),hour:0,minute:i};const d=parseInt(l,10)||0,m=-new Date().getTimezoneOffset()/60;let g=d+m;return g<0&&(g+=24),g>=24&&(g-=24),{frequency:24,hour:Math.floor(g),minute:i}}function xi(t,n,i){if(t<24)return`${i} */${t} * * *`;const l=-new Date().getTimezoneOffset()/60;let d=n-l;return d<0&&(d+=24),d>=24&&(d-=24),`${i} ${Math.floor(d)} * * *`}const Ti=()=>es({queryKey:["aiNewsPipelineSettings"],queryFn:async()=>{var t,n,i,l,d,m,g,v,u,w,N;const{data:k,error:j}=await o.from("platform_settings").select("ainews_sync_enabled, ainews_sync_base_schedule, ainews_sync_lookback_days, ainews_sync_max_articles, ainews_scraping_enabled, ainews_scraping_delay_minutes, ainews_translation_enabled, ainews_translation_delay_minutes, ainews_sync_batch_size, ainews_scrape_batch_size, ainews_translate_batch_size").eq("id",1).maybeSingle();if(j)throw j;return k?{ainews_sync_enabled:(t=k.ainews_sync_enabled)!=null?t:_s.ainews_sync_enabled,ainews_sync_base_schedule:(n=k.ainews_sync_base_schedule)!=null?n:_s.ainews_sync_base_schedule,ainews_sync_lookback_days:(i=k.ainews_sync_lookback_days)!=null?i:_s.ainews_sync_lookback_days,ainews_sync_max_articles:(l=k.ainews_sync_max_articles)!=null?l:_s.ainews_sync_max_articles,ainews_scraping_enabled:(d=k.ainews_scraping_enabled)!=null?d:_s.ainews_scraping_enabled,ainews_scraping_delay_minutes:(m=k.ainews_scraping_delay_minutes)!=null?m:_s.ainews_scraping_delay_minutes,ainews_translation_enabled:(g=k.ainews_translation_enabled)!=null?g:_s.ainews_translation_enabled,ainews_translation_delay_minutes:(v=k.ainews_translation_delay_minutes)!=null?v:_s.ainews_translation_delay_minutes,ainews_sync_batch_size:(u=k.ainews_sync_batch_size)!=null?u:_s.ainews_sync_batch_size,ainews_scrape_batch_size:(w=k.ainews_scrape_batch_size)!=null?w:_s.ainews_scrape_batch_size,ainews_translate_batch_size:(N=k.ainews_translate_batch_size)!=null?N:_s.ainews_translate_batch_size}:_s}}),bc=()=>{const t=Es(),{toast:n}=ss();return ze({mutationFn:async i=>{const{error:l}=await o.from("platform_settings").update(i).eq("id",1);if(l)throw l;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["aiNewsPipelineSettings"]})},onError:i=>{n({title:"Fout",description:"Kon AI News pipeline instellingen niet opslaan.",variant:"destructive"})}})};function gi(t,n){const i=t.split(" ");if(i.length!==5)return t;const[l,d,m,g,v]=i;let u=parseInt(l,10)||0,w=d,N=u+n,k=Math.floor(N/60);if(N=N%60,k>0&&!d.includes("*")&&!d.includes("/")){const j=parseInt(d,10);isNaN(j)||(w=String((j+k)%24))}return`${N} ${w} ${m} ${g} ${v}`}function yc(t){const n=t.ainews_sync_base_schedule,i=gi(n,t.ainews_scraping_delay_minutes),l=gi(n,t.ainews_scraping_delay_minutes+t.ainews_translation_delay_minutes);return{sync:n,scraping:i,translation:l}}function _c(){return-new Date().getTimezoneOffset()/60}function wc(t){const n=_c();let i=t+n;return i<0&&(i+=24),i>=24&&(i-=24),Math.floor(i)}function Nc(t){const n=t.split(" ");if(n.length!==5)return new Date;const[i,l]=n,d=new Date,m=i.includes("*/")||i==="*"?0:parseInt(i,10);if(l.includes("*/")){const v=parseInt(l.replace("*/",""),10),u=d.getHours(),w=d.getMinutes();let N=Math.floor(u/v)*v;(u>N||u===N&&w>=m)&&(N+=v);const k=new Date(d);return N>=24&&(k.setDate(k.getDate()+1),N=N%24),k.setHours(N),k.setMinutes(m),k.setSeconds(0),k.setMilliseconds(0),k}const g=new Date(d);if(l!=="*"&&!l.includes("/")){const v=parseInt(l,10),u=wc(v);g.setHours(u)}return g.setMinutes(m),g.setSeconds(0),g.setMilliseconds(0),g<=d&&g.setDate(g.getDate()+1),g}function tn(t){return t.toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"})}const kc=({baseSchedule:t,syncEnabled:n,scrapingEnabled:i,translationEnabled:l,cascadeEnabled:d=!0})=>{const{pipelineSteps:m,syncTime:g}=a.useMemo(()=>{const u=Nc(t);return{pipelineSteps:[{label:"News Sync",description:tn(u),icon:e.jsx(Rs,{className:"h-4 w-4"}),bgColor:"bg-blue-500/20",borderColor:"border-blue-500/30",textColor:"text-blue-400",enabled:n},{label:"Scraping",description:d?"Direct na sync":"Handmatig gepland",icon:e.jsx(Ws,{className:"h-4 w-4"}),bgColor:"bg-orange-500/20",borderColor:"border-orange-500/30",textColor:"text-orange-400",enabled:i},{label:"Vertaling",description:d?"Direct na scraping":"Handmatig gepland",icon:e.jsx(dt,{className:"h-4 w-4"}),bgColor:"bg-green-500/20",borderColor:"border-green-500/30",textColor:"text-green-400",enabled:l}],syncTime:u}},[t,n,i,l,d]),v=m.filter(u=>u.enabled);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsxs(ae,{variant:"outline",className:"border-green-500/50 text-green-400 bg-green-500/10",children:[e.jsx(Ds,{className:"h-3 w-3 mr-1"}),"Cascade Mode Actief"]}):e.jsxs(ae,{variant:"outline",className:"border-amber-500/50 text-amber-400 bg-amber-500/10",children:[e.jsx(Re,{className:"h-3 w-3 mr-1"}),"Losse Cron Jobs"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d?"Stappen worden automatisch na elkaar uitgevoerd":"Elke stap heeft een eigen geplande tijd"})]}),e.jsx("div",{className:"flex items-center justify-between gap-2 p-4 rounded-lg bg-gradient-to-r from-blue-500/5 via-orange-500/5 to-green-500/5 border border-blue-500/20",children:m.map((u,w)=>e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:`flex flex-col items-center gap-1 p-3 rounded-lg border ${u.bgColor} ${u.borderColor} transition-opacity ${u.enabled?"opacity-100":"opacity-40"} min-w-[100px]`,children:[e.jsxs("div",{className:`flex items-center gap-2 ${u.textColor}`,children:[u.icon,e.jsx("span",{className:"font-medium text-sm",children:u.label})]}),e.jsx("span",{className:"text-xs text-muted-foreground text-center",children:u.description})]}),w<m.length-1&&e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx(ia,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),d&&e.jsx("span",{className:"text-[10px] text-green-400/70",children:"~2s"})]})]},u.label))}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Volgende sync: ",e.jsx("span",{className:"font-medium text-foreground",children:tn(g)})]}),e.jsxs("span",{className:"text-muted-foreground",children:["Actieve stappen: ",e.jsxs("span",{className:"font-medium text-foreground",children:[v.length,"/",m.length]})]}),d&&e.jsxs("span",{className:"text-muted-foreground",children:["Geschatte totale duur: ",e.jsx("span",{className:"font-medium text-green-400",children:"~5-10 min"})]})]})]})},Sc={sync:{icon:Rs,label:"AI News Sync",color:"blue",bgClass:"bg-blue-500/10",borderClass:"border-blue-500/30",textClass:"text-blue-400"},scrape:{icon:Ws,label:"Content Scraping",color:"orange",bgClass:"bg-orange-500/10",borderClass:"border-orange-500/30",textClass:"text-orange-400"},translate:{icon:dt,label:"Vertaling",color:"green",bgClass:"bg-green-500/10",borderClass:"border-green-500/30",textClass:"text-green-400"}};function an({type:t,currentRun:n,isEnabled:i}){const l=Sc[t],d=l.icon,m=()=>{if(!i)return e.jsxs(ae,{variant:"outline",className:"border-muted-foreground
25/30 text-muted-foreground",children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),"Uitgeschakeld"]});if(!n)return e.jsxs(ae,{variant:"outline",className:"border-muted-foreground/30 text-muted-foreground",children:[e.jsx(Re,{className:"h-3 w-3 mr-1"}),"Idle"]});switch(n.status){case"started":case"running":return e.jsxs(ae,{className:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",children:[e.jsx(he,{className:"h-3 w-3 mr-1 animate-spin"}),"Bezig..."]});case"completed":return e.jsxs(ae,{className:"bg-green-500/20 text-green-400 border-green-500/30",children:[e.jsx(Os,{className:"h-3 w-3 mr-1"}),"Voltooid"]});case"failed":return e.jsxs(ae,{className:"bg-red-500/20 text-red-400 border-red-500/30",children:[e.jsx(St,{className:"h-3 w-3 mr-1"}),"Mislukt"]});default:return null}},g=(n==null?void 0:n.status)==="started"||(n==null?void 0:n.status)==="running",v=n!=null&&n.items_total?Math.round(n.items_processed/n.items_total*100):0,u=N=>{const k=Math.floor(N/1e3);if(k<60)return`${k}s`;const j=Math.floor(k/60),I=k%60;return`${j}m ${I}s`},w=N=>new Date(N).toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"});return e.jsxs(R,{className:ns("relative overflow-hidden transition-all",l.borderClass,g&&"ring-2 ring-yellow-500/50",!i&&"opacity-50"),children:[e.jsx("div",{className:ns("absolute inset-0",l.bgClass)}),e.jsxs(G,{className:"relative p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{className:ns("h-5 w-5",l.textClass)}),e.jsx("span",{className:"font-medium",children:l.label})]}),m()]}),g&&(n==null?void 0:n.items_total)>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Hs,{value:v,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[n.items_processed," / ",n.items_total," items"]}),e.jsxs("span",{children:[v,"%"]})]})]}),n&&!g&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs text-muted-foreground mt-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground font-medium",children:n.items_processed})," verwerkt"]}),n.items_failed>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-red-400 font-medium",children:n.items_failed})," mislukt"]}),n.duration_ms&&e.jsxs("div",{children:["Duur: ",e.jsx("span",{className:"text-foreground",children:u(n.duration_ms)})]}),n.completed_at&&e.jsxs("div",{children:["Klaar: ",e.jsx("span",{className:"text-foreground",children:w(n.completed_at)})]})]}),!n&&i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wacht op volgende geplande run"})]})]})}function Cc(t=50){return es({queryKey:["pipeline-run-logs",t],queryFn:async()=>{const{data:n,error:i}=await o.from("pipeline_run_logs").select("*").order("started_at",{ascending:!1}).limit(t);if(i)throw i;return n},staleTime:30*1e3,refetchInterval:!1})}function Ac(){return es({queryKey:["latest-cascade"],queryFn:async()=>{var t,n;const{data:i,error:l}=await o.from("pipeline_run_logs").select("cascade_id").not("cascade_id","is",null).order("started_at",{ascending:!1}).limit(1);let d=[],m=null;if(!l&&i&&i.length>0&&((t=i[0])!=null&&t.cascade_id)){m=i[0].cascade_id;const{data:F,error:P}=await o.from("pipeline_run_logs").select("*").eq("cascade_id",m).order("started_at",{ascending:!0});!P&&F&&(d=F)}const g=["ai_news_sync","ai_news_scrape","ai_news_translate"],v={ai_news_sync:null,ai_news_scrape:null,ai_news_translate:null};for(const F of g){const{data:P}=await o.from("pipeline_run_logs").select("*").eq("pipeline_type",F).order("started_at",{ascending:!1}).limit(1);P&&P.length>0&&(v[F]=P[0])}const u=d.find(F=>F.pipeline_type==="ai_news_sync")||null,w=d.find(F=>F.pipeline_type==="ai_news_scrape")||null,N=d.find(F=>F.pipeline_type==="ai_news_translate")||null,k=(F,P)=>{if(!F&&!P)return null;if(!F)return P;if(!P)return F;const D=new Date(F.started_at).getTime();return new Date(P.started_at).getTime()>D?P:F},j=k(u,v.ai_news_sync),I=k(w,v.ai_news_scrape),f=k(N,v.ai_news_translate);if(!j&&!I&&!f)return null;
25const V=[j,I,f].filter(Boolean),ue=V.every(F=>F.status==="completed"||F.status==="failed")&&f!==null,je=j!=null&&j.started_at?new Date(j.started_at).getTime():null,B=f!=null&&f.completed_at?new Date(f.completed_at).getTime():null,L=je&&B?B-je:null;return{cascade_id:m||"standalone",started_at:(j==null?void 0:j.started_at)||((n=V[0])==null?void 0:n.started_at)||"",completed_at:(f==null?void 0:f.completed_at)||null,total_duration_ms:L,is_complete:ue,steps:{sync:j,scrape:I,translate:f}}},staleTime:30*1e3,refetchInterval:!1})}function Pc(t=24){return es({queryKey:["pipeline-metrics",t],queryFn:async()=>{const n=new Date(Date.now()-t*60*60*1e3).toISOString(),{data:i,error:l}=await o.from("pipeline_run_logs").select("*").gte("started_at",n).order("started_at",{ascending:!1});if(l)throw l;const d=i,m=d.filter(f=>f.pipeline_type==="ai_news_sync"),g=d.filter(f=>f.pipeline_type==="ai_news_scrape"),v=d.filter(f=>f.pipeline_type==="ai_news_translate"),u=d.filter(f=>f.status==="completed"),w=d.filter(f=>f.status==="failed"),N=d.length>0?u.length/d.length*100:100,k=u.length>0?u.reduce((f,V)=>f+(V.duration_ms||0),0)/u.length:0,j=u.reduce((f,V)=>f+V.items_processed,0),I=d.reduce((f,V)=>f+V.items_failed,0);return{total_runs:d.length,completed_runs:u.length,failed_runs:w.length,success_rate:N,avg_duration_ms:k,total_items_processed:j,total_items_failed:I,by_type:{sync:{total:m.length,completed:m.filter(f=>f.status==="completed").length,failed:m.filter(f=>f.status==="failed").length},scrape:{total:g.length,completed:g.filter(f=>f.status==="completed").length,failed:g.filter(f=>f.status==="failed").length},translate:{total:v.length,completed:v.filter(f=>f.status==="completed").length,failed:v.filter(f=>f.status==="failed").length}}}},refetchInterval:6e4})}function Ic(t){const n=Es();a.useEffect(()=>{const i=o.channel("pipeline-run-logs-changes").on("postgres_changes",{event:"*",schema:"public",table:"pipeline_run_logs"},l=>{n.invalidateQueries({queryKey:["pipeline-run-logs"]}),n.invalidateQueries({queryKey:["latest-cascade"]}),n.invalidateQueries({queryKey:["pipeline-metrics"]}),l.new&&t(l.new)}).subscribe();return()=>{o.removeChannel(i)}},[n,t])}function Tc(){return es({queryKey:["running-pipelines"],queryFn:async()=>{const{data:t,error:n}=await o.from("pipeline_run_logs").select("*").in("status",["started","running"]).order("started_at",{ascending:!1});if(n)throw n;return t},staleTime:15*1e3,refetchInterval:!1})}const Ec={ai_news_sync:Rs,ai_news_scrape:Ws,ai_news_translate:dt},Fc={ai_news_sync:"Sync",ai_news_scrape:"Scrape",ai_news_translate:"Translate"},Dc={ai_news_sync:"text-blue-400",ai_news_scrape:"text-orange-400",ai_news_translate:"text-green-400"};function Oc(){const{data:t,isLoading:n,refetch:i}=Cc(100),[l,d]=a.useState("all"),[m,g]=a.useState(null),v=(t==null?void 0:t.filter(j=>l==="all"?!0:j.pipeline_type===l))||[],u=j=>{const I=Math.floor(j/1e3);if(I<60)return`${I}s`;const f=Math.floor(I/60),V=I%60;return`${f}m ${V}s`},w=j=>{const I=new Date(j);return{date:I.toLocaleDateString("nl-NL",{day:"2-digit",month:"short"}),time:I.toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"})}},N=j=>{switch(j){case"started":case"running":return e.jsx(he,{className:"h-4 w-4 animate-spin text-yellow-400"});case"completed":return e.jsx(Os,{className:"h-4 w-4 text-green-400"});case"failed":return e.jsx(St,{className:"h-4 w-4 text-red-400"});default:return e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"})}},k=j=>{const I=Ec[j.pipeline_type],f=Fc[j.pipeline_type],V=Dc[j.pipeline_type],{date:me,time:ee}=w(j.started_at),ue=m===j.id;return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("button",{onClick:()=>g(ue?null:j.id),className:"w-full p-3 flex items-center gap-3 hover:bg-muted/50 transition-colors text-left",children:[N(j.status),e.jsxs("div",{className:"flex items-center gap-2 min-w-[100px]",children:[e.jsx(I,{className:ns("h-4 w-4",V)}),e.jsx("span",{className:"text-sm font-medium",children:f})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{children:[me," ",ee]}),e.jsxs("span",{children:[j.items_processed," items"]}),j.items_failed>0&&e.jsxs(ae,{variant:"outline",className:"text-red-400 border-red-400/30",children:[j.items_failed," failed"]}),j.duration_ms&&e.jsx("span",{children:u(j.duration_ms)})]}),ue?e.jsx(Xl,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zl,{className:"h-4 w-4 text-muted-foreground"})]}),ue&&e.jsxs("div",{className:"px-4 pb-3 pt-1 bg-muted/30",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Status:"}),e.jsx(ae,{variant:"outline",className:ns("ml-2",j.status==="completed"&&"border-green-500/30 text-green-400",j.status==="failed"&&"border-red-500/30 text-red-400",(j.status==="started"||j.status==="running")&&"border-yellow-500/30 text-yellow-400"),children:j.status})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Totaal:"}),e.jsxs("span",{className:"ml-2",children:[j.items_total," items"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Verwerkt:"}),e.jsx("span",{className:"ml-2 text-green-400",children:j.items_processed})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Mislukt:"}),e.jsx("span",{className:"ml-2 text-red-400",children:j.items_failed})]})]}),j.cascade_id&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:["Cascade ID: ",e.jsxs("code",{className:"bg-muted px-1 rounded",children:[j.cascade_id.substring(0,8),"..."]})]}),j.error_details&&Object.keys(j.error_details).length>0&&e.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 rounded border border-red-500/20",children:[e.jsx("span",{className:"text-xs text-red-400",children:"Error:"}),e.jsx("pre",{className:"text-xs text-red-300 mt-1 overflow-x-auto",children:JSON.stringify(j.error_details,null,2)})]}),j.metadata&&Object.keys(j.metadata).length>0&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Metadata bekijken"}),e.jsx("pre",{className:"text-xs text-muted-foreground mt-1 p-2 bg-muted/50 rounded overflow-x-auto",children:JSON.stringify(j.metadata,null,2)})]})]})]},j.id)};return e.jsxs(R,{children:[e.jsx(J,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Q,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Pt,{className:"h-5 w-5"}),"Pipeline Run History"]}),e.jsx(Z,{children:"Overzicht van alle pipeline uitvoeringen"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(os,{value:l,onValueChange:d,children:[e.jsx(cs,{className:"w-[140px]",children:e.jsx(ds,{})}),e.jsxs(us,{children:[e.jsx(U,{value:"all",children:"Alle types"}),e.jsx(U,{value:"ai_news_sync",children:"Sync"}),e.jsx(U,{value:"ai_news_scrape",children:"Scrape"}),e.jsx(U,{value:"ai_news_translate",children:"Translate"})]})]}),e.jsx(p,{variant:"outline",size:"icon",onClick:()=>i(),disabled:n,children:e.jsx(Se,{className:ns("h-4 w-4",n&&"animate-spin")})})]})]})}),e.jsx(G,{className:"p-0",children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):v.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nog geen pipeline runs gevonden"}):e.jsx(Si,{className:"h-[400px]",children:v.map(k)})})]})}function Xt({title:t,value:n,subtitle:i,icon:l,color:d="default"}){const m={default:"text-foreground",success:"text-green-400",warning:"text-yellow-400",danger:"text-red-400"};return e.jsx(R,{className:"relative overflow-hidden",children:e.jsx(G,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t}
25),e.jsx("p",{className:ns("text-2xl font-bold mt-1",m[d]),children:n}),i&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i})]}),e.jsx("div",{className:"text-muted-foreground",children:l})]})})})}function Mc(){const{data:t,isLoading:n}=Pc(24);if(n)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[...Array(4)].map((d,m)=>e.jsx(R,{children:e.jsx(G,{className:"p-4 flex items-center justify-center h-[100px]",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})})},m))});if(!t)return null;const i=d=>{const m=Math.floor(d/1e3);return m<60?`${m}s`:`${Math.floor(m/60)}m`},l=d=>d>=95?"success":d>=80?"warning":"danger";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Xt,{title:"Totale Runs",value:t.total_runs,subtitle:"Laatste 24 uur",icon:e.jsx(Js,{className:"h-5 w-5"})}),e.jsx(Xt,{title:"Succes Rate",value:`${t.success_rate.toFixed(1)}%`,subtitle:`${t.completed_runs} voltooid`,icon:e.jsx(eo,{className:"h-5 w-5"}),color:l(t.success_rate)}),e.jsx(Xt,{title:"Items Verwerkt",value:t.total_items_processed,subtitle:t.total_items_failed>0?`${t.total_items_failed} mislukt`:void 0,icon:e.jsx(Os,{className:"h-5 w-5"}),color:"success"}),e.jsx(Xt,{title:"Gem. Duur",value:i(t.avg_duration_ms),subtitle:"Per run",icon:e.jsx(Re,{className:"h-5 w-5"})})]}),e.jsxs(R,{children:[e.jsx(J,{className:"pb-2",children:e.jsxs(Q,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Js,{className:"h-4 w-4"}),"Per Pipeline Type (24u)"]})}),e.jsxs(G,{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4 text-blue-400"}),e.jsx("span",{className:"text-sm font-medium",children:"Sync"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ae,{variant:"outline",className:"border-green-500/30 text-green-400",children:[e.jsx(Os,{className:"h-3 w-3 mr-1"}),t.by_type.sync.completed]}),t.by_type.sync.failed>0&&e.jsxs(ae,{variant:"outline",className:"border-red-500/30 text-red-400",children:[e.jsx(St,{className:"h-3 w-3 mr-1"}),t.by_type.sync.failed]})]}),t.by_type.sync.total>0&&e.jsx(Hs,{value:t.by_type.sync.completed/t.by_type.sync.total*100,className:"h-1.5"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ws,{className:"h-4 w-4 text-orange-400"}),e.jsx("span",{className:"text-sm font-medium",children:"Scrape"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ae,{variant:"outline",className:"border-green-500/30 text-green-400",children:[e.jsx(Os,{className:"h-3 w-3 mr-1"}),t.by_type.scrape.completed]}),t.by_type.scrape.failed>0&&e.jsxs(ae,{variant:"outline",className:"border-red-500/30 text-red-400",children:[e.jsx(St,{className:"h-3 w-3 mr-1"}),t.by_type.scrape.failed]})]}),t.by_type.scrape.total>0&&e.jsx(Hs,{value:t.by_type.scrape.completed/t.by_type.scrape.total*100,className:"h-1.5"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dt,{className:"h-4 w-4 text-green-400"}),e.jsx("span",{className:"text-sm font-medium",children:"Translate"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ae,{variant:"outline",className:"border-green-500/30 text-green-400",children:[e.jsx(Os,{className:"h-3 w-3 mr-1"}),t.by_type.translate.completed]}),t.by_type.translate.failed>0&&e.jsxs(ae,{variant:"outline",className:"border-red-500/30 text-red-400",children:[e.jsx(St,{className:"h-3 w-3 mr-1"}),t.by_type.translate.failed]})]}),t.by_type.translate.total>0&&e.jsx(Hs,{value:t.by_type.translate.completed/t.by_type.translate.total*100,className:"h-1.5"})]})]})]})]})}function Vc(){var t,n,i,l,d,m;const{toast:g}=ss(),{data:v}=Ti(),{data:u,isLoading:w}=Ac(),{data:N}=Tc(),[k,j]=a.useState(!1),[I,f]=a.useState(!1);a.useEffect(()=>{"Notification"in window&&(f(Notification.permission==="granted"),Notification.permission==="granted"&&j(localStorage.getItem("pipeline-notifications")==="true"))},[]);const V=async()=>
25{if("Notification"in window){const F=await Notification.requestPermission();f(F==="granted"),F==="granted"&&(j(!0),localStorage.setItem("pipeline-notifications","true"),g({title:"Notificaties ingeschakeld",description:"Je ontvangt nu meldingen wanneer de pipeline is voltooid."}))}},me=F=>{j(F),localStorage.setItem("pipeline-notifications",String(F)),g({title:F?"Notificaties ingeschakeld":"Notificaties uitgeschakeld",description:F?"Je ontvangt nu meldingen wanneer de pipeline is voltooid.":"Je ontvangt geen meldingen meer."})},ee=a.useCallback(F=>{k&&F.pipeline_type==="ai_news_translate"&&F.status==="completed"&&"Notification"in window&&Notification.permission==="granted"&&new Notification("AI News Pipeline Voltooid ✓",{body:`${F.items_processed} artikelen succesvol verwerkt`,icon:"/favicon.ico"}),F.status==="failed"&&g({title:`Pipeline ${F.pipeline_type.replace("ai_news_","")} mislukt`,description:"Bekijk de run history voor details.",variant:"destructive"})},[k,g]);Ic(ee);const ue=F=>{const P=Math.floor(F/1e3);if(P<60)return`${P} seconden`;const D=Math.floor(P/60),T=P%60;if(D<60)return`${D}m ${T}s`;const W=Math.floor(D/60),fe=D%60;return`${W}u ${fe}m`},je=F=>new Date(F).toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"}),B=F=>{const P=new Date(F),D=new Date;return P.toDateString()===D.toDateString()?`Vandaag ${je(F)}`:P.toLocaleDateString("nl-NL",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})},L=N&&N.length>0;return e.jsxs(R,{className:"border-2 border-gradient-to-r from-blue-500/30 via-orange-500/30 to-green-500/30",children:[e.jsx(J,{className:"bg-gradient-to-r from-blue-500/5 via-orange-500/5 to-green-500/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5"}),"Pipeline Control Center",L&&e.jsxs(ae,{className:"ml-2 bg-yellow-500/20 text-yellow-400 border-yellow-500/30 animate-pulse",children:[e.jsx(he,{className:"h-3 w-3 mr-1 animate-spin"}),"Running"]})]}),e.jsx(Z,{children:"Real-time monitoring en beheer van de AI News pipeline"})]}),e.jsx("div",{className:"flex items-center gap-2",children:I?e.jsxs(e.Fragment,{children:[e.jsx(be,{id:"notifications",checked:k,onCheckedChange:me}),e.jsxs(b,{htmlFor:"notifications",className:"flex items-center gap-1 cursor-pointer",children:[k?e.jsx(Ts,{className:"h-4 w-4 text-green-400"}):e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:"Meldingen"})]})]}):e.jsxs(p,{variant:"outline",size:"sm",onClick:V,className:"gap-2",children:[e.jsx(Ts,{className:"h-4 w-4"}),"Meldingen aanzetten"]})})]})}),e.jsx(G,{className:"pt-6",children:e.jsxs(fn,{defaultValue:"status",className:"space-y-4",children:[e.jsxs(vn,{className:"grid w-full grid-cols-3",children:[e.jsxs(Je,{value:"status",className:"flex items-center gap-2",children:[e.jsx(Js,{className:"h-4 w-4"}),"Live Status"]}),e.jsxs(Je,{value:"metrics",className:"flex items-center gap-2",children:[e.jsx(Ds,{className:"h-4 w-4"}),"Metrics"]}),e.jsxs(Je,{value:"history",className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"h-4 w-4"}),"History"]})]}),e.jsxs(We,{value:"status",className:"space-y-4",children:[w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u?e.jsx(xs,{className:ns("border-2",u.is_complete?"border-green-500/30 bg-green-500/5":"border-yellow-500/30 bg-yellow-500/5"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[u.is_complete?e.jsx(Os,{className:"h-5 w-5 text-green-400 mt-0.5"}):e.jsx(he,{className:"h-5 w-5 text-yellow-400 animate-spin mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsxs(gs,{className:"text-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:u.is_complete?"Laatste cascade voltooid":"Cascade bezig..."}),e.jsx("span",{className:"text-sm text-muted-foreground",children:B(u.started_at)})]}),u.is_complete&&u.total_duration_ms&&e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Re,{className:"h-4 w-4"}),"Totale duur: ",ue(u.total_duration_ms)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Rs,{className:"h-4 w-4"}),((t=u.steps.sync)==null?void 0:t.items_processed)||0," synced"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ws,{className:"h-4 w-4"}),((n=u.steps.scrape)==null?void 0:n.items_processed)||0," scraped"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(dt,{className:"h-4 w-4"}),((i=u.steps.translate)==null?void 0:i.items_processed)||0," translated"]})]})]})})]})}):e.jsx(xs,{children:e.jsx(gs,{children:"Nog geen pipeline runs gevonden. Start de pipeline handmatig of wacht op de volgende geplande run."})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(an,{type:"sync",currentRun:(u==null?void 0:u.steps.sync)||null,isEnabled:(l=v==null?void 0:v.ainews_sync_enabled)!=null?l:!0}),e.jsx(an,{type:"scrape",currentRun:(u==null?void 0:u.steps.scrape)||null,isEnabled:(d=v==null?void 0:v.ainews_scraping_enabled)!=null?d:!0}),e.jsx(an,{type:"translate",currentRun:(u==null?void 0:u.steps.translate)||null,isEnabled:(m=v==null?void 0:v.ainews_translation_enabled)!=null?m:!0})]})]}),e.jsx(We,{value:"metrics",children:e.jsx(Mc,{})}),e.jsx(We,{value:"history",children:e.jsx(Oc,{})})]})})]})}var zc=Object.defineProperty,Lc=Object.defineProperties,Kc=Object.getOwnPropertyDescriptors,fi=Object.getOwnPropertySymbols,$c=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable,vi=(t,n,i)=>n in t?zc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,nn=(t,n)=>{for(var i in n||(n={}))$c.call(n,i)&&vi(t,i,n[i]);if(fi)for(var i of fi(n))Rc.call(n,i)&&vi(t,i,n[i]);return t},rn=(t,n)=>Lc(t,Kc(n));const Gc=()=>{const{data:t,isLoading:n}=Ti(),i=bc(),{toast:l}=ss(),d=Es(),[m,g]=a.useState(!0),[v,u]=a.useState("0 */6 * * *"),[w,N]=a.useState(30),[k,j]=a.useState(50),[I,f]=a.useState(!0),[V,me]=a.useState(30),[ee,ue]=a.useState(!0),[je,B]=a.use
25State(30),[L,F]=a.useState(6),[P,D]=a.useState(8),[T,W]=a.useState(0),[fe,re]=a.useState(null),[pe,Ce]=a.useState({}),[ke,ie]=a.useState(""),[_e,xe]=a.useState(""),[Ae,z]=a.useState(""),[H,te]=a.useState(!1),[le,we]=a.useState(!1),[Fe,M]=a.useState(!1),[Te,Le]=a.useState(!1),[Qe,ms]=a.useState(!1),[Ge,Me]=a.useState(!1),[He,Ve]=a.useState(null),{data:qe,isLoading:Pe}=es({queryKey:["ai-news-rss-feeds"],queryFn:async()=>{const{data:_,error:E}=await o.from("ai_news_rss_feeds").select("*").order("provider",{ascending:!0});if(E)throw E;return _}}),Ie=ze({mutationFn:async _=>{const{error:E}=await o.from("ai_news_rss_feeds").insert({name:_.name,url:_.url,provider:_.provider||null});if(E)throw E},onSuccess:()=>{d.invalidateQueries({queryKey:["ai-news-rss-feeds"]}),ie(""),xe(""),z(""),te(!1),l({title:"RSS feed toegevoegd"})},onError:_=>{l({title:"Fout",description:_.message,variant:"destructive"})}}),De=ze({mutationFn:async({id:_,updates:E})=>{const{error:ve}=await o.from("ai_news_rss_feeds").update(E).eq("id",_);if(ve)throw ve},onSuccess:()=>{d.invalidateQueries({queryKey:["ai-news-rss-feeds"]}),re(null),Ce({}),l({title:"RSS feed bijgewerkt"})},onError:_=>{l({title:"Fout",description:_.message,variant:"destructive"})}}),rs=ze({mutationFn:async _=>{const{error:E}=await o.from("ai_news_rss_feeds").delete().eq("id",_);if(E)throw E},onSuccess:()=>{d.invalidateQueries({queryKey:["ai-news-rss-feeds"]}),l({title:"RSS feed verwijderd"})},onError:_=>{l({title:"Fout",description:_.message,variant:"destructive"})}}),ts=_=>{De.mutate({id:_.id,updates:{is_active:!_.is_active}})},is=_=>{re(_.id),Ce({name:_.name,url:_.url,provider:_.provider})},Ue=()=>{fe&&pe.name&&pe.url&&De.mutate({id:fe,updates:pe})},fs=()=>{re(null),Ce({})},hs=()=>{ke&&_e&&Ie.mutate({name:ke,url:_e,provider:Ae})};a.useEffect(()=>{if(t){g(t.ainews_sync_enabled),u(t.ainews_sync_base_schedule),N(t.ainews_sync_lookback_days),j(t.ainews_sync_max_articles),f(t.ainews_scraping_enabled),me(t.ainews_scraping_delay_minutes),ue(t.ainews_translation_enabled),B(t.ainews_translation_delay_minutes);const _=jc(t.ainews_sync_base_schedule);F(_.frequency),D(_.hour),W(_.minute)}},[t]);const vs=_=>{const E=parseInt(_);F(E);const ve=xi(E,P,T);u(ve)},h=(_,E)=>{D(_),W(E);const ve=xi(L,_,E);u(ve)},x=async()=>{var _,E,ve;try{ms(!0),await i.mutateAsync({ainews_sync_enabled:m,ainews_sync_base_schedule:v,ainews_sync_lookback_days:w,ainews_sync_max_articles:k,ainews_scraping_enabled:I,ainews_scraping_delay_minutes:V,ainews_translation_enabled:ee,ainews_translation_delay_minutes:je});const ye=yc({ainews_sync_enabled:m,ainews_sync_base_schedule:v,ainews_sync_lookback_days:w,ainews_sync_max_articles:k,ainews_scraping_enabled:I,ainews_scraping_delay_minutes:V,ainews_translation_enabled:ee,ainews_translation_delay_minutes:je,ainews_sync_batch_size:(_=t==null?void 0:t.ainews_sync_batch_size)!=null?_:10,ainews_scrape_batch_size:(E=t==null?void 0:t.ainews_scrape_batch_size)!=null?E:5,ainews_translate_batch_size:(ve=t==null?void 0:t.ainews_translate_batch_size)!=null?ve:3}),Ee=[o.functions.invoke("update-cron-schedule",{body:{jobName:"sync-ai-news",schedule:ye.sync,enabled:m}}),o.functions.invoke("update-cron-schedule",{body:{jobName:"scrape-ai-news",schedule:ye.scraping,enabled:I}}),o.functions.invoke("update-cron-schedule",{body:{jobName:"translate-ai-news",schedule:ye.translation,enabled:ee}})],$=(await Promise.allSettled(Ee)).filter(ce=>ce.status==="rejected");$.length>0?l({title:"Gedeeltelijk opgeslagen",description:`${$.length} cron job(s) konden niet worden bijgewerkt.`,variant:"destructive"}):l({title:"Pipeline opgeslagen",description:"Alle AI News pipeline cronjobs zijn bijgewerkt."})}catch(ye){l({title:"Fout",description:"Er is een fout opgetreden bij het opslaan.",variant:"destructive"})}finally{ms(!1)}},O=async()=>{try{we(!0);const{data:_,error:E}=await o.functions.invoke("sync-ai-models",{body:{max_articles:k,lookback_days:w}});if(E)throw E;l({title:"AI News Sync voltooid",description:`${(_==null?void 0:_.news_synced)||0} nieuwsartikelen gesynchroniseerd.`})}catch(_){l({title:"Sync mislukt",description:"Er is een fout opgetreden.",variant:"destructive"})}finally{we(!1)}},oe=async()=>{try{M(!0);const{data:_,error:E}=await o.functions.invoke("process-ai-news-articles",{body:{phase:"scrape",maxArticles:10}});if(E)throw E;l({title:"Scraping voltooid",description:`${(_==null?void 0:_.processed)||0} artikelen gescraped met Readability, ${(_==null?void 0:_.failed)||0} mislukt.`})}catch(_){l({title:"Scraping mislukt",description:"Er is een fout opgetreden.",variant:"destructive"})}finally{M(!1)}},S=async()=>
25{try{Le(!0);const{data:_,error:E}=await o.functions.invoke("process-ai-news-articles",{body:{phase:"translate",maxArticles:10}});if(E)throw E;l({title:"Vertaling voltooid",description:`${(_==null?void 0:_.processed)||0} artikelen vertaald, ${(_==null?void 0:_.failed)||0} mislukt.`})}catch(_){l({title:"Vertaling mislukt",description:"Er is een fout opgetreden.",variant:"destructive"})}finally{Le(!1)}},Y=async()=>{try{Me(!0),Ve("Stap 1/3: AI nieuws synchroniseren via RSS...");const{error:_}=await o.functions.invoke("sync-ai-models",{body:{max_articles:k,lookback_days:w}});if(_)throw new Error(`Sync failed: ${_.message}`);Ve("Stap 2/3: Content scrapen met Readability...");const{data:E,error:ve}=await o.functions.invoke("process-ai-news-articles",{body:{phase:"scrape",maxArticles:k}});Ve("Stap 3/3: Vertalen naar Nederlands...");const{data:ye,error:Ee}=await o.functions.invoke("process-ai-news-articles",{body:{phase:"translate",maxArticles:k}});Ve(null),l({title:"Pipeline voltooid",description:`Alle stappen uitgevoerd. ${(E==null?void 0:E.processed)||0} gescraped, ${(ye==null?void 0:ye.processed)||0} vertaald.`})}catch(_){Ve(null),l({title:"Pipeline mislukt",description:_ instanceof Error?_.message:"Er is een fout opgetreden.",variant:"destructive"})}finally{Me(!1)}};return n?e.jsx(R,{className:"border-blue-500/30 bg-gradient-to-br from-blue-500/5 to-transparent",children:e.jsx(G,{className:"flex items-center justify-center py-8",children:e.jsx(Se,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(xs,{className:"border-blue-500/30 bg-blue-500/5",children:[e.jsx(na,{className:"h-4 w-4 text-blue-500"}),e.jsxs(gs,{children:[e.jsx("strong",{children:"Readability Scraping Actief"})," - Deze pipeline gebruikt Mozilla Readability (dezelfde technologie als Firefox/Safari Reader Mode) om artikelen te scrapen. Dit is betrouwbaarder en goedkoper dan Jina Reader."]})]}),e.jsxs(R,{className:"border-purple-500/30",children:[e.jsxs(J,{className:"bg-purple-500/5",children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(na,{className:"h-5 w-5 text-purple-500"}),"RSS Feed Bronnen",e.jsxs(ae,{className:"ml-2 bg-purple-500/20 text-purple-300 border-0",children:[(qe==null?void 0:qe.filter(_=>_.is_active).length)||0," actief"]})]}),e.jsx(Z,{children:"Beheer de RSS feeds waarvan AI nieuws wordt opgehaald. De URLs worden gebruikt door de sync functie."})]}),e.jsxs(G,{className:"space-y-4 pt-4",children:[Pe?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Se,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"space-y-2",children:qe==null?void 0:qe.map(_=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${_.is_active?"border-purple-500/20 bg-purple-500/5":"border-muted bg-muted/20 opacity-60"}`,children:[e.jsx(be,{checked:_.is_active,onCheckedChange:()=>ts(_)}),fe===_.id?e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsx(q,{value:pe.name||"",onChange:E=>Ce(rn(nn({},pe),{name:E.target.value})),placeholder:"Naam",className:"w-32"}),e.jsx(q,{value:pe.url||"",onChange:E=>Ce(rn(nn({},pe),{url:E.target.value})),placeholder:"URL",className:"flex-1"}),e.jsx(q,{value:pe.provider||"",onChange:E=>Ce(rn(nn({},pe),{provider:E.target.value})),placeholder:"Provider",className:"w-24"}),e.jsx(p,{size:"icon",variant:"ghost",onClick:Ue,className:"text-green-500 hover:text-green-400",children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx(p,{size:"icon",variant:"ghost",onClick:fs,className:"text-muted-foreground",children:e.jsx(zs,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:_.name}),_.provider&&e.jsx(ae,{variant:"outline",className:"text-xs",children:_.provider})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-lg",children:_.url})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>window.open(_.url,"_blank","noopener,noreferrer"),className:"text-muted-foreground hover:text-foreground",children:e.jsx(oa,{className:"h-4 w-4"})}),e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>is(_),className:"text-muted-foreground hover:text-foreground",children:e.jsx(Co,{className:"h-4 w-4"})}),e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>rs.mutate(_.id),className:"text-destructive/60 hover:text-destructive",children:e.jsx(Fs,{className:"h-4 w-4"})})]})]})]},_.id))}),H?e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-dashed border-purple-500/30 bg-purple-500/5",children:[e.jsx(q,{value:ke,onChange:_=>ie(_.target.value),placeholder:"Naam (bijv. OpenAI News)",className:"w-40"}),e.jsx(q,{value:_e,onChange:_=>xe(_.target.value),placeholder:"RSS Feed URL",className:"flex-1"}),e.jsx(q,{value:Ae,onChange:_=>z(_.target.value),placeholder:"Provider",className:"w-24"}),e.jsx(p,{size:"sm",onClick:hs,disabled:!ke||!_e||Ie.isPending,className:"bg-purple-500 hover:bg-purple-600",children:Ie.isPending?e.jsx(Se,{className:"h-4 w-4 animate-spin"}):e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>te(!1),children:e.jsx(zs,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>te(!0),className:"border-purple-500/30 hover:bg-purple-500/10",children:[e.jsx(la,{className:"h-4 w-4 mr-2"}),"RSS Feed Toevoegen"]}),e.jsx(fc,{existingUrls:(qe==null?void 0:qe.map(_=>_.url))||[]})]})]})]}),e.jsxs(R,{className:"border-gradient-to-r from-blue-500/30 via-orange-500/30 to-green-500/30 border-2",children:[e.jsxs(J,{className:"bg-gradient-to-r from-blue-500/5 via-orange-500/5 to-green-500/5",children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-5 w-5 text-blue-500"}),"AI News Pipeline Configuratie",e.jsx(ae,{className:"ml-2 bg-gradient-to-r from-blue-500/20 to-green-500/20 text-white border-0",children:"Readability"})]}),e.jsx(Z,{children:"Configureer de complete AI nieuws verwerking pipeline. RSS feeds → Readability Scraping → Gemini Vertaling."})]}),e.jsxs(G,{className:"space-y-8 pt-6",children:[e.jsx(kc,{baseSchedule:v,syncEnabled:m,scrapingEnabled:I,translationEnabled:ee,cascadeEnabled:!0}),e.jsx(Vc,{}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-blue-500/20 bg-blue-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-blue-500/20 text-blue-400 font-bold text-sm",children:"1"}),e.jsx(na,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"font-semibold",children:"RSS Feed Sync"}),e.jsx(ae,{variant:"outline",className:"ml-auto border-blue-500/30 text-blue-400",children:"Startpunt"})]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-10",children:"Haalt nieuwsartikelen op van Google News RSS feeds voor alle AI providers (OpenAI, Anthropic, Google, Meta, etc.)."}),e.jsxs("div",{className:"flex items-center justify-between pl-10 flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Sync Actief"}),e.jsx(be,{checked:m,onCheckedChange:g})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(b,{children:"Frequentie:"}),e.jsxs(os,{value:String(L),onValueChange:vs,disabled:!m,children:[e.jsx(cs,{className:"w-[160px]",children:e.jsx(ds,{})}),e.jsx(us,{children:vc.map(_=>e.jsx(U,{value:_.value,children:_.label},_.value))})]})]})]}),e.jsxs("div",{className:"pl-10 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[e.jsxs(b,{className:"flex items-center gap-2 mb-3",children:[e.jsx(Re,{className:"h-4 w-4 text-blue-400"}),"Starttijd (lokale tijd)"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(os,{value:String(P),onValueChange:_=>h(parseInt(_),T),disabled:!m,children:[e.jsx(cs,{className:"w-[80px]",children:e.jsx(ds,{})}),e.jsx(us,{children:Array.from({length:24},(_,E)=>e.jsx(U,{value:String(E),children:String(E).padStart(2,"0")}
25,E))})]}),e.jsx("span",{className:"text-lg font-bold",children:":"}),e.jsxs(os,{value:String(T),onValueChange:_=>h(P,parseInt(_)),disabled:!m,children:[e.jsx(cs,{className:"w-[80px]",children:e.jsx(ds,{})}),e.jsx(us,{children:[0,5,10,15,20,25,30,35,40,45,50,55].map(_=>e.jsx(U,{value:String(_),children:String(_).padStart(2,"0")},_))})]}),e.jsx("span",{className:"text-sm text-muted-foreground ml-2",children:L<24?`= elke ${L} uur vanaf ${String(P).padStart(2,"0")}:${String(T).padStart(2,"0")}`:`= dagelijks om ${String(P).padStart(2,"0")}:${String(T).padStart(2,"0")}`})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["💡 Dit is je lokale tijd. ",L<24?`De sync draait elke ${L} uur.`:"De sync draait eenmaal per dag."]})]}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Nieuws ophalen van laatste: ",w," ",w===1?"dag":"dagen"]}),e.jsx(Xe,{value:[w],onValueChange:_=>N(_[0]),min:1,max:90,step:1,className:"w-full max-w-md",disabled:!m})]}),e.jsxs("div",{className:"pl-10 space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4"}),"Maximum artikelen per sync: ",k]}),e.jsx(Xe,{value:[k],onValueChange:_=>j(_[0]),min:10,max:200,step:10,className:"w-full max-w-md",disabled:!m})]}),e.jsx("div",{className:"pl-10 pt-2",children:e.jsx(p,{onClick:O,disabled:le,variant:"outline",size:"sm",className:"border-blue-500/30 hover:bg-blue-500/20 hover:text-blue-300",children:le?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Synchroniseren..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Synchroniseren"]})})})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Nt,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-orange-500/20 bg-orange-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-orange-500/20 text-orange-400 font-bold text-sm",children:"2"}),e.jsx(to,{className:"h-5 w-5 text-orange-500"}),e.jsx("span",{className:"font-semibold",children:"Readability Scraping"}),e.jsxs(ae,{variant:"outline",className:"ml-auto border-green-500/30 text-green-400 bg-green-500/10",children:[e.jsx(Ds,{className:"h-3 w-3 mr-1"}),"Automatisch na sync"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-10",children:"Scrapt volledige artikelcontent met Mozilla Readability. Geen externe API kosten, directe HTML parsing zoals Firefox/Safari Reader Mode."}),e.jsx("div",{className:"flex items-center justify-between pl-10",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Scraping Actief"}),e.jsx(be,{checked:I,onCheckedChange:f})]})}),e.jsx("div",{className:"pl-10 p-3 rounded-lg bg-green-500/5 border border-green-500/20",children:e.jsxs("p",{className:"text-sm text-green-400 flex items-center gap-2",children:[e.jsx(Ds,{className:"h-4 w-4"}),e.jsx("span",{children:"Start automatisch ~2 seconden na voltooiing van News Sync"})]})}),e.jsx("div",{className:"pl-10 pt-2",children:e.jsx(p,{onClick:oe,disabled:Fe,variant:"outline",size:"sm",className:"border-orange-500/30 hover:bg-orange-500/20 hover:text-orange-300",children:Fe?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Scrapen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Scrapen"]})})})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Nt,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border border-green-500/20 bg-green-500/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-green-500/20 text-green-400 font-bold text-sm",children:"3"}),e.jsx(dt,{className:"h-5 w-5 text-green-500"}),e.jsx("span",{className:"font-semibold",children:"Vertaling (Gemini)"}),e.jsxs(ae,{variant:"outline",className:"ml-auto border-green-500/30 text-green-400 bg-green-500/10",children:[e.jsx(Ds,{className:"h-3 w-3 mr-1"}),"Automatisch na scraping"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-10",children:"Vertaalt Engelse artikelen naar vloeiend Nederlands met Gemini AI. Inclusief kwaliteitscontrole (min. score 85)."}),e.jsx("div",{className:"flex items-center justify-between pl-10",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(b,{children:"Vertaling Actief"}),e.jsx(be,{checked:ee,onCheckedChange:ue})]})}),e.jsx("div",{className:"pl-10 p-3 rounded-lg bg-green-500/5 border border-green-500/20",children:e.jsxs("p",{className:"text-sm text-green-400 flex items-center gap-2",children:[e.jsx(Ds,{className:"h-4 w-4"}),e.jsx("span",{children:"Start automatisch ~2 seconden na voltooiing van Scraping"})]})}),e.jsx("div",{className:"pl-10 pt-2",children:e.jsx(p,{onClick:S,disabled:Te,variant:"outline",size:"sm",className:"border-green-500/30 hover:bg-green-500/20 hover:text-green-300",children:Te?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Vertalen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Nu Vertalen"]})})})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 pt-4 border-t",children:[e.jsx(p,{onClick:x,disabled:Qe,className:"bg-gradient-to-r from-blue-500 to-green-500 hover:from-blue-600 hover:to-green-600",children:Qe?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Pipeline Instellingen Opslaan"]})}),e.jsx(p,{onClick:Y,disabled:Ge,variant:"outline",className:"border-primary/30",children:Ge?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"mr-2 h-4 w-4 animate-spin"}),He||"Pipeline draait..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Js,{className:"mr-2 h-4 w-4"}),"Volledige Pipeline Testen"]})})]}),He&&e.jsxs(xs,{className:"border-primary/30 bg-primary/5",children:[e.jsx(Js,{className:"h-4 w-4 animate-pulse"}),e.jsx(gs,{children:He})]})]})]})]})};function qc(){return e.jsxs("div",{className:"space-y-6 animate-in fade-in duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-8 w-48"}),e.jsx(ge,{className:"h-4 w-72"})]}),e.jsx(ge,{className:"h-6 w-24 rounded-full"})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5"}),e.jsx(ge,{className:"h-6 w-40"})]}),e.jsx(ge,{className:"h-4 w-64 mt-1"})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-5 w-16"}),e.jsx(ge,{className:"h-4 w-56"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ge,{className:"h-4 w-8"}),e.jsx(ge,{className:"h-5 w-9 rounded-full"}),e.jsx(ge,{className:"h-4 w-8"})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsx(ge,{className:"h-10 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsx(ge,{className:"h-10 w-full"})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx(ge,{className:"h-5 w-40"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ge,{className:"h-10 flex-1"}),e.jsx(ge,{className:"h-10 w-10"})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsx(ge,{className:"h-10 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsx(ge,{className:"h-10 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-4 w-28"}),e.jsx(ge,{className:"h-10 w-full"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ge,{className:"h-4 w-32"}),e.jsx(ge,{className:"h-3 w-48"})]}),e.jsx(ge,{className:"h-5 w-9 rounded-full"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-primary/5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ge,{className:"h-5 w-24"}),e.jsx(ge,{className:"h-4 w-56"})]}),e.jsx(ge,{className:"h-5 w-9 rounded-full"})]})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ge,{className:"h-10 w-36"}),e.jsx(ge,{className:"h-10 w-40"})]}),e.jsx(ge,{className:"h-10 w-40"})]})]})]}),e.jsxs(R,{className:"border-blue-500/20 bg-blue-500/5",children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx(ge,{className:"h-5 w-56"})]})}),e.jsx(G,{className:"space-y-2",children:[1,2,3,4,5,6].map(t=>e.jsx(ge,{className:"h-4 w-full max-w-md"},t))})]})]})}var Uc=Object.defineProperty,Bc=Object.defineProperties,Hc=Object.getOwnPropertyDescriptors,ji=Object.getOwnPropertySymbols,Jc=Object.prototype.hasOwnProperty,Wc=Object.prototype.propertyIsEnumerable,bi=(t,n,i)=>n in t?Uc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Bs=(t,n)=>{for(var i in n||(n={}))Jc.call(n,i)&&bi(t,i,n[i]);
25if(ji)for(var i of ji(n))Wc.call(n,i)&&bi(t,i,n[i]);return t},rt=(t,n)=>Bc(t,Hc(n));const yi=ca().max(256,"API key is te lang").refine(t=>t===""||/^sk_(test|live)_[a-zA-Z0-9]{24,}$/.test(t),{message:"Ongeldige Stripe API key formaat (verwacht: sk_test_... of sk_live_...)"}),_i=ca().max(256,"Publishable key is te lang").refine(t=>t===""||/^pk_(test|live)_[a-zA-Z0-9]{24,}$/.test(t),{message:"Ongeldige Stripe publishable key formaat (verwacht: pk_test_... of pk_live_...)"}),wi=ca().max(256,"Webhook secret is te lang").refine(t=>t===""||/^whsec_[a-zA-Z0-9]{24,}$/.test(t),{message:"Ongeldige webhook secret formaat (verwacht: whsec_...)"}),Qc=no(["EUR","USD","GBP"],{errorMap:()=>({message:"Selecteer een geldige valuta"})}),Yc=ao({owner_id:ca().uuid("Ongeldige profiel ID"),gateway_type:ro("stripe"),is_test_mode:Qa(),test_api_key:yi.nullable(),live_api_key:yi.nullable(),test_publishable_key:_i.nullable(),live_publishable_key:_i.nullable(),test_webhook_secret:wi.nullable(),live_webhook_secret:wi.nullable(),default_currency:Qc,auto_sync_enabled:Qa(),is_active:Qa()});async function Xc(){var t;const{data:n,error:i}=await o.functions.invoke("test-stripe-connection",{body:{}});if(!i&&n)return n;const l="https://wvqjywcbmxbtifvdlyby.supabase.co",d="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Ind2cWp5d2NibXhidGlmdmRseWJ5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzM3NTQzMDEsImV4cCI6MjA4OTMzMDMwMX0.h5LhJTLB4UgYz5wtVMVLa259pF8SIZnVyZGNcWDgRY8",{data:m}=await o.auth.getSession(),g=(t=m.session)==null?void 0:t.access_token,v=await fetch(`${l}/functions/v1/test-stripe-connection`,{method:"POST",headers:{"Content-Type":"application/json",apikey:d,Authorization:`Bearer ${g||d}`},body:JSON.stringify({})}),u=await v.text(),w=u?JSON.parse(u):null;if(!v.ok)throw new Error((w==null?void 0:w.error)||(i==null?void 0:i.message)||`Backend functie fout (${v.status})`);return w!=null?w:{success:!1,error:(i==null?void 0:i.message)||"Geen response ontvangen van backend functie"}}function Zc(t,n){const[i,l]=a.useState(!1),d=a.useRef(null),m=a.useRef(!1),g=a.useCallback(async(...v)=>{if(!m.current){m.current=!0,l(!0);try{await t(...v)}finally{d.current=setTimeout(()=>{m.current=!1,l(!1)},n)}}},[t,n]);return a.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),[g,i]}function ed(){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ks,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium",children:"Er is iets misgegaan"}),e.jsx("p",{className:"text-muted-foreground",children:"De betalingsinstellingen konden niet worden geladen. Probeer de pagina te vernieuwen."})]})}function sd({brandProfileId:t}){const{toast:n}=ss(),i=a.useRef(null),l=a.useRef(!0),d=a.useRef(null),m=a.useRef(0),g=a.useRef(null),v=a.useRef(!1),u=15e3,[w,N]=a.useState(!0),[k,j]=a.useState(!1),[I,f]=a.useState(!1),[V,me]=a.useState(null),[ee,ue]=a.useState(!0),[je,B]=a.useState(""),[L,F]=a.use
25State(""),[P,D]=a.useState(""),[T,W]=a.useState(""),[fe,re]=a.useState(""),[pe,Ce]=a.useState(""),[ke,ie]=a.useState("EUR"),[_e,xe]=a.useState(!0),[Ae,z]=a.useState(!1),[H,te]=a.useState({}),[le,we]=a.useState(!1),[Fe,M]=a.useState(!1),[Te,Le]=a.useState(!1),[Qe,ms]=a.useState(!1),[Ge,Me]=a.useState(!1),[He,Ve]=a.useState(!1),[qe,Pe]=a.useState("disconnected"),[Ie,De]=a.useState("unknown"),[rs,ts]=a.useState(!1),is=a.useMemo(()=>"https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/stripe-webhook",[]);a.useMemo(()=>"https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/stripe-webhook",[]),a.useEffect(()=>(l.current=!0,()=>{l.current=!1,i.current&&i.current.abort(),d.current&&d.current.abort(),g.current&&g.current.abort()}),[]),a.useEffect(()=>{if(!t){N(!1);return}if(v.current)return;g.current&&g.current.abort();const S=new AbortController;g.current=S,v.current=!0;const Y=setTimeout(()=>{S.abort()},u);return(async()=>{var E,ve,ye,Ee,r,$,ce,Ke,js,Gs;try{N(!0);const{data:Cs,error:qs}=await o.from("payment_gateway_settings").select("*").eq("owner_id",t).eq("gateway_type","stripe").maybeSingle();if(clearTimeout(Y),S.signal.aborted||!l.current)return;if(qs){n({title:"Fout bij laden",description:"Kon instellingen niet ophalen",variant:"destructive"});return}if(Cs){const ls=Cs;me(ls),ue((E=ls.is_test_mode)!=null?E:!0),B((ve=ls.test_api_key)!=null?ve:""),F((ye=ls.live_api_key)!=null?ye:""),D((Ee=ls.test_publishable_key)!=null?Ee:""),W((r=ls.live_publishable_key)!=null?r:""),re(($=ls.test_webhook_secret)!=null?$:""),Ce((ce=ls.live_webhook_secret)!=null?ce:""),ie((Ke=ls.default_currency)!=null?Ke:"EUR"),xe((js=ls.auto_sync_enabled)!=null?js:!0),z((Gs=ls.is_active)!=null?Gs:!1),ls.is_active?Pe("connected"):Pe("disconnected")}else me(null),Pe("disconnected")}catch(Cs){if(clearTimeout(Y),!l.current)return;if(Cs instanceof Error&&Cs.name==="AbortError"){n({title:"Timeout",description:"Het laden duurde te lang. Controleer je internetverbinding.",variant:"destructive"});return}n({title:"Fout",description:"Er is een onverwachte fout opgetreden",variant:"destructive"})}finally{l.current&&N(!1),v.current=!1}})(),()=>{clearTimeout(Y),S.abort(),v.current=!1}},[t,n]),a.useEffect(()=>{const S=async()=>{var _,E;if(l.current){ts(!0);try{const ve=await fetch("https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/check-health-status?store=false",{method:"GET",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Ind2cWp5d2NibXhidGlmdmRseWJ5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzM3NTQzMDEsImV4cCI6MjA4OTMzMDMwMX0.h5LhJTLB4UgYz5wtVMVLa259pF8SIZnVyZGNcWDgRY8"}});if(!l.current)return;if(ve.ok){const ye=await ve.json(),Ee=ye.stripe_webhook||((E=(_=ye.detailed)==null?void 0:_.find(r=>r.apiName==="stripe_webhook"))==null?void 0:E.status);De(Ee||"unknown")}else De("unknown")}catch(ve){l.current&&De("unknown")}finally{l.current&&ts(!1)}}};S();const Y=setInterval(S,6e4);return()=>clearInterval(Y)},[]);const Ue=a.useCallback(async()=>{if(!(!t||!l.current))try{const{data:S,error:Y}=await o.from("payment_gateway_settings").select("*").eq("owner_id",t).eq("gateway_type","stripe").maybeSingle();if(!l.current)return;if(!Y&&S){const _=S;me(_),_.is_active?Pe("connected"):Pe("disconnected")}}catch(S){}},[t]),fs=a.useCallback(async()=>{if(!t){n({title:"Fout",description:"Geen profiel ID gevonden",variant:"destructive"});return}te({});const S=++m.current;try{j(!0);const Y={owner_id:t,gateway_type:"stripe",is_test_mode:ee,test_api_key:je||null,live_api_key:L||null,test_publishable_key:P||null,live_publishable_key:T||null,test_webhook_secret:fe||null,live_webhook_secret:pe||null,default_currency:ke,auto_sync_enabled:_e,is_active:Ae},_=Yc.safeParse(Y);if(!_.success){const ye={};_.error.errors.forEach(Ee=>{const r=Ee.path[0];r&&["test_api_key","live_api_key","test_publishable_key","live_publishable_key","test_webhook_secret","live_webhook_secret"].includes(r)?ye[r]=Ee.message:ye.general=Ee.message}),te(ye),n({title:"Validatiefout",description:"Controleer de ingevoerde gegevens",variant:"destructive"}),j(!1);return}const E=_.data;let ve=null;if(V!=null&&V.id){const{error:ye}=await o.from("payment_gateway_settings").update({gateway_type:E.gateway_type,is_test_mode:E.is_test_mode,test_api_key:E.test_api_key,live_api_key:E.live_api_key,test_publishable_key:E.test_publishable_key,live_publishable_key:E.live_publishable_key,test_webhook_secret:E.test_webhook_secret,live_webhook_secret:E.live_webhook_secret,default_currency:E.default_currency,auto_sync_enabled:E.auto_sync_enabled,is_active:E.is_active}).eq("id",V.id);ye&&(ve=ye)}else{const{error:ye}=await o.from("payment_gateway_settings").insert({owner_id:E.owner_id,gateway_type:E.gateway_type,is_test_mode:E.is_test_mode,test_api_key:E.test_api_key,live_api_key:E.live_api_key,test_publishable_key:E.test_publishable_key,live_publishable_key:E.live_publishable_key,test_webhook_secret:E.test_webhook_secret,live_webhook_secret:E.live_webhook_secret,default_currency:E.default_currency,auto_sync_enabled:E.auto_sync_enabled,is_active:E.is_active});
25ye&&(ve=ye)}if(!l.current||S!==m.current)return;if(ve)throw ve;n({title:"Instellingen opgeslagen",description:"Je Stripe configuratie is succesvol opgeslagen."}),S===m.current&&await Ue()}catch(Y){if(!l.current||S!==m.current)return;const _=Y instanceof Error?Y.message:"Onbekende fout opgetreden";n({title:"Opslaan mislukt",description:_,variant:"destructive"})}finally{l.current&&S===m.current&&j(!1)}},[t,ee,je,L,P,T,fe,pe,ke,_e,Ae,V==null?void 0:V.id,n,Ue]),[hs,vs]=Zc(fs,300),h=a.useCallback(async()=>{i.current&&i.current.abort(),i.current=new AbortController;try{f(!0);const S=await Xc();if(!l.current)return;if(!(S!=null&&S.success)){Pe("error"),n({title:"Verbinding mislukt",description:(S==null?void 0:S.error)||"Kon geen verbinding maken met Stripe",variant:"destructive"});return}Pe("connected");const Y=S.account_name||S.account_email||"Account gevonden",_=S.is_test_mode?"(Test)":"(Live)";n({title:"Verbinding succesvol!",description:`Verbonden met Stripe account: ${Y} ${_}`})}catch(S){if(!l.current||S instanceof Error&&S.name==="AbortError")return;Pe("error"),n({title:"Verbinding mislukt",description:S instanceof Error?S.message:"Er is een netwerkfout opgetreden",variant:"destructive"})}finally{l.current&&f(!1)}},[n]),x=a.useCallback(async(S,Y)=>{if(!S){n({title:"Niets te kopiëren",description:"De waarde is leeg",variant:"destructive"});return}d.current&&d.current.abort(),d.current=new AbortController;try{if(!l.current||(await navigator.clipboard.writeText(S),!l.current))return;n({title:"Gekopieerd",description:`${Y} is gekopieerd naar je klembord`})}catch(_){if(!l.current||_ instanceof Error&&_.name==="AbortError")return;n({title:"Kopiëren mislukt",description:"Kon niet kopiëren naar klembord",variant:"destructive"})}},[n]),O=a.useMemo(()=>{switch(qe){case"connected":return{variant:"default",icon:e.jsx(Ne,{className:"h-3 w-3"}),text:"Verbonden"};case"error":return{variant:"destructive",icon:e.jsx(Ks,{className:"h-3 w-3"}),text:"Fout"};default:return{variant:"secondary",icon:e.jsx(Ks,{className:"h-3 w-3"}),text:"Niet verbonden"}}},[qe]),oe=a.useMemo(()=>!I,[I]);return w?e.jsx(qc,{}):t?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(Ci,{className:"h-6 w-6 text-primary"}),"Payment Gateways"]}),e.jsx("p",{className:"text-muted-foreground",children:"Configureer je betalingsproviders voor abonnementen en facturen"})]}),e.jsxs(ae,{variant:O.variant,className:"flex items-center gap-1",children:[O.icon,O.text]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fill:"#6772E5",d:"M111.328 15.602c0-4.82-2.342-8.62-6.822-8.62-4.5 0-7.22 3.8-7.22 8.58 0 5.66 3.22 8.52 7.82 8.52 2.24 0 3.94-.5 5.22-1.22v-3.78c-1.28.64-2.74 1.04-4.6 1.04-1.82 0-3.44-.64-3.64-2.86h9.18c0-.24.04-1.2.04-1.66zm-9.28-1.78c0-2.14 1.3-3.02 2.5-3.02 1.16 0 2.38.88 2.38 3.02z",transform:"translate(-83.5 0) scale(.72727)"})}),"Stripe Configuratie"]}),e.jsx(Z,{children:"Verbind je Stripe account voor betalingen en abonnementenbeheer"})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Modus"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ee?"Test modus - Geen echte betalingen worden verwerkt":"Live modus - Echte betalingen worden verwerkt"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-sm ${ee?"text-primary font-medium":"text-muted-foreground"}`,children:"Test"}),e.jsx(be,{checked:!ee,onCheckedChange:S=>ue(!S)}),e.jsx("span",{className:`text-sm ${ee?"text-muted-foreground":"text-primary font-medium"}`,children:"Live"})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ms,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm text-foreground",children:"Secret Keys"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Vul hier je Str
25ipe secret keys in wanneer Cloud Secrets niet beschikbaar zijn op live. Alleen superadmins kunnen deze instellingen beheren."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"test-api-key",className:"flex items-center gap-2",children:["Test Secret Key",e.jsx(ae,{variant:"outline",className:"text-xs",children:"sk_test_..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"test-api-key",type:le?"text":"password",value:je,onChange:S=>{B(S.target.value),H.test_api_key&&te(Y=>rt(Bs({},Y),{test_api_key:void 0}))},placeholder:"sk_test_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-10 ${H.test_api_key?"border-destructive":""}`,"aria-invalid":!!H.test_api_key}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0",onClick:()=>we(!le),children:le?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})]}),H.test_api_key&&e.jsx("p",{className:"text-sm text-destructive",children:H.test_api_key})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"live-api-key",className:"flex items-center gap-2",children:["Live Secret Key",e.jsx(ae,{variant:"outline",className:"text-xs",children:"sk_live_..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"live-api-key",type:Fe?"text":"password",value:L,onChange:S=>{F(S.target.value),H.live_api_key&&te(Y=>rt(Bs({},Y),{live_api_key:void 0}))},placeholder:"sk_live_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-10 ${H.live_api_key?"border-destructive":""}`,"aria-invalid":!!H.live_api_key}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0",onClick:()=>M(!Fe),children:Fe?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})]}),H.live_api_key&&e.jsx("p",{className:"text-sm text-destructive",children:H.live_api_key})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx("h4",{className:"font-medium mb-3 text-sm text-muted-foreground",children:"Publishable Keys (voor frontend checkout)"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"test-publishable-key",className:"flex items-center gap-2",children:["Test Publishable Key",e.jsx(ae,{variant:"outline",className:"text-xs",children:"pk_test_..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"test-publishable-key",type:Te?"text":"password",value:P,onChange:S=>{D(S.target.value),H.test_publishable_key&&te(Y=>rt(Bs({},Y),{test_publishable_key:void 0}))},placeholder:"pk_test_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-20 ${H.test_publishable_key?"border-destructive":""}`,"aria-invalid":!!H.test_publishable_key}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Le(!Te),children:Te?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})})]}),H.test_publishable_key&&e.jsx("p",{className:"text-sm text-destructive",children:H.test_publishable_key})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"live-publishable-key",className:"flex items-center gap-2",children:["Live Publishable Key",e.jsx(ae,{variant:"outline",className:"text-xs",children:"pk_live_..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"live-publishable-key",type:Qe?"text":"password",value:T,onChange:S=>{W(S.target.value),H.live_publishable_key&&te(Y=>rt(Bs({},Y),{live_publishable_key:void 0}))},placeholder:"pk_live_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-20 ${H.live_publishable_key?"border-destructive":""}`,"aria-invalid":!!H.live_publishable_key}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>ms(!Qe),children:Qe?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})})]}),H.live_publishable_key&&e.jsx("p",{className:"text-sm text-destructive",children:H.live_publishable_key})]})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4"}),"Webhook Configuratie"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Configureer webhooks in je Stripe Dashboard om real-time updates te ontvangen"})]}),e.jsxs(ae,{variant:Ie==="online"?"default":Ie==="degraded"?"secondary":Ie==="offline"?"destructive":"outline",className:"flex items-center gap-1",children:[rs?e.jsx(he,{className:"h-3 w-3 animate-spin"}):Ie==="online"?e.jsx(Ne,{className:"h-3 w-3"}):Ie==="offline"?e.jsx(Ks,{className:"h-3 w-3"}):null,"Webhook ",Ie==="online"?"Online":Ie==="degraded"?"Traag":Ie==="offline"?"Offline!":"Onbekend"]})]}),Ie==="offline"&&e.jsxs("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/30 text-destructive text-sm",children:[e.jsx("strong",{children:"⚠️ Kritiek:"})," De webhook endpoint is niet bereikbaar! Betalingen worden niet verwerkt. Neem contact op met support of wacht tot de functie opnieuw is gedeployed."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:["Webhook Endpoint URL",e.jsx(ae,{variant:"outline",className:"text-xs",children:"Stabiel"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{value:is,readOnly:!0,className:"font-mono text-sm bg-muted"}),e.jsx(p,{variant:"outline",size:"icon",onClick:()=>x(is,"Webhook URL"),title:"Kopieer URL",children:e.jsx(At,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"Belangrijk:"})," Gebruik deze URL in je Stripe Dashboard → Developers → Webhooks. Deze URL is stabiel en wordt niet beïnvloed door preview deployments."]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"test-webhook-secret",children:"Test Webhook Secret"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"test-webhook-secret",type:Ge?"text":"password",value:fe,onChange:S=>{re(S.target.value),H.test_webhook_secret&&te(Y=>rt(Bs({},Y),{test_webhook_secret:void 0}))},placeholder:"whsec_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-10 ${H.test_webhook_secret?"border-destructive":""}`,"aria-invalid":!!H.test_webhook_secret}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0",onClick:()=>Me(!Ge),children:Ge?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})]}),H.test_webhook_secret&&e.jsx("p",{className:"text-sm text-destructive",children:H.test_webhook_secret})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"live-webhook-secret",children:"Live Webhook Secret"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"live-webhook-secret",type:He?"text":"password",value:pe,onCh
25ange:S=>{Ce(S.target.value),H.live_webhook_secret&&te(Y=>rt(Bs({},Y),{live_webhook_secret:void 0}))},placeholder:"whsec_xxxxxxxxxxxxxxxxxxxxxxxx",className:`pr-10 ${H.live_webhook_secret?"border-destructive":""}`,"aria-invalid":!!H.live_webhook_secret}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0",onClick:()=>Ve(!He),children:He?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(at,{className:"h-4 w-4"})})]}),H.live_webhook_secret&&e.jsx("p",{className:"text-sm text-destructive",children:H.live_webhook_secret})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"currency",children:"Standaard Valuta"}),e.jsxs(os,{value:ke,onValueChange:ie,children:[e.jsx(cs,{id:"currency",children:e.jsx(ds,{placeholder:"Selecteer valuta"})}),e.jsxs(us,{children:[e.jsx(U,{value:"EUR",children:"EUR - Euro"}),e.jsx(U,{value:"USD",children:"USD - US Dollar"}),e.jsx(U,{value:"GBP",children:"GBP - British Pound"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Auto-sync producten"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatisch prijsplannen synchroniseren"})]}),e.jsx(be,{checked:_e,onCheckedChange:xe})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-primary/5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Stripe Actief"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schakel Stripe in/uit voor betalingsverwerking"})]}),e.jsx(be,{checked:Ae,onCheckedChange:z})]})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",onClick:h,disabled:!oe,children:I?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Testen..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Test Verbinding"]})}),e.jsx(p,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:"https://dashboard.stripe.com/apikeys",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Stripe Dashboard"]})})]}),e.jsx(p,{onClick:hs,disabled:k||vs,"aria-busy":k,children:k?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 mr-2 animate-spin"}),"Opslaan..."]}):"Instellingen Opslaan"})]})]})]}),e.jsxs(R,{className:"border-blue-500/20 bg-blue-500/5",children:[e.jsx(J,{children:e.jsxs(Q,{className:"text-base flex items-center gap-2",children:[e.jsx(Ks,{className:"h-4 w-4 text-blue-500"}),"Hoe werkt de Stripe integratie?"]})}),e.jsx(G,{className:"text-sm text-muted-foreground space-y-2",children:e.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[e.jsxs("li",{children:["Maak een Stripe account aan op ",e.jsx("a",{href:"https://stripe.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"stripe.com"})]}),e.jsx("li",{children:"Ga naar Developers → API Keys en kopieer je Secret Key"}),e.jsx("li",{children:"Voer de API key hierboven in (test of live)"}),e.jsx("li",{children:"Configureer de webhook URL in Stripe Dashboard"}),e.jsx("li",{children:"Kopieer de Webhook Signing Secret naar de instellingen"}),e.jsx("li",{children:"Schakel Stripe actief en synchroniseer je prijsplannen"})]})})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ks,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium",children:"Configuratie niet beschikbaar"}),e.jsx("p",{className:"text-muted-foreground",children:"Er is geen profiel gevonden om de betalingsinstellingen aan te koppelen."})]})}function td(t){return e.jsx(Ao,{name:"PaymentGatewaysSettings",fallback:e.jsx(ed,{}),autoRetryAfter:3e3,maxAutoRetries:2,children:e.jsx(sd,Bs({},t))})}function ad({className:t}){const n=Pi();return e.jsxs(R,{className:`border-amber-500/50 bg-gradient-to-br from-amber-500/10 to-orange-500/5 ${t}`,children:[e.jsxs(J,{className:"pb-4",children:[e.jsxs(Q,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-amber-500/20 rounded-lg",children:e.jsx(ai,{className:"h-5 w-5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg",children:"AI API Keys Verplaatst"}),e.jsx("span",{className:"ml-2 text-xs font-normal text-amber-600 dar
25k:text-amber-400 bg-amber-500/20 px-2 py-0.5 rounded-full",children:"Nieuw systeem"})]})]}),e.jsxs(Z,{className:"text-sm",children:["AI provider keys (Gemini, OpenAI, Claude, Grok, Perplexity) worden nu beheerd via het nieuwe",e.jsx("strong",{className:"text-foreground",children:" API Key Management"})," dashboard met geavanceerde features."]})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-card/50 rounded-lg border border-border/50",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full mt-1.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Automatische Load Balancing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Verdeel requests over meerdere keys"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-card/50 rounded-lg border border-border/50",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full mt-1.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Rate Limit Monitoring"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Real-time RPM/TPM tracking"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-card/50 rounded-lg border border-border/50",children:[e.jsx("div",{className:"w-2 h-2 bg-purple-500 rounded-full mt-1.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Automatische Fallback"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Failover bij rate limit errors"})]})]})]}),e.jsxs(xs,{variant:"default",className:"border-amber-500/30 bg-amber-500/5",children:[e.jsx(ra,{className:"h-4 w-4 text-amber-500"}),e.jsx(Ct,{className:"text-sm font-medium",children:"Migratie voltooid"}),e.jsx(gs,{className:"text-xs",children:"Je bestaande AI keys zijn automatisch gemigreerd naar het nieuwe systeem. Alle edge functions gebruiken nu de key pool voor verbeterde betrouwbaarheid."})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:e.jsxs(p,{onClick:()=>n("/dashboard/admin/api-keys"),className:"flex-1 gap-2",children:[e.jsx(ai,{className:"h-4 w-4"}),"Ga naar API Key Management",e.jsx(ia,{className:"h-4 w-4"})]})})]})]})}const nd=()=>{var t,n,i,l,d,m;const g=Es(),{toast:v}=ss(),u=es({queryKey:["migrationMode"],queryFn:async()=>{var N,k,j;const{data:I,error:f}=await o.from("platform_settings").select("migration_mode, migration_started_at, migration_started_by").eq("id",1).maybeSingle();return f?{migration_mode:!1,migration_started_at:null,migration_started_by:null}:{migration_mode:(N=I==null?void 0:I.migration_mode)!=null?N:!1,migration_started_at:(k=I==null?void 0:I.migration_started_at)!=null?k:null,migration_started_by:(j=I==null?void 0:I.migration_started_by)!=null?j:null}},staleTime:1e4,refetchInterval:15e3}),w=ze({mutationFn:async N=>{const{data:{user:k}}=await o.auth.getUser();if(!k)throw new Error("Not authenticated");const j={migration_mode:N,migration_started_at:N?new Date().toISOString():null,migration_started_by:N?k.id:null},{error:I}=await o.from("platform_settings").update(j).eq("id",1);if(I)throw I;const{data:f}=await o.from("profiles").select("id").limit(1).single();f&&(await o.from("profiles").update({maintenance_mode:N}).eq("id",f.id),localStorage.removeItem("app_settings_cache_v3"));try{const{data:{session:V}}=await o.auth.getSession(),ue=await(await fetch("https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/toggle-migration-crons",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Ind2cWp5d2NibXhidGlmdmRseWJ5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzM3NTQzMDEsImV4cCI6MjA4OTMzMDMwMX0.h5LhJTLB4UgYz5wtVMVLa259pF8SIZnVyZGNcWDgRY8"},body:JSON.stringify({action:N?"pause":"resume"})})).json()}catch(V){}return N},onSuccess:N=>{g.invalidateQueries({queryKey:["migrationMode"]}),g.invalidateQueries({queryKey:["platformSettings"]}),v({title:N?"🔴 Migratiemodus geactiveerd":"🟢 Migratiemodus gedeactiveerd",description:N?"Database is bevroren. Alle writes zijn geblokkeerd, cron jobs gepauzeerd.":"Database is weer actief. Alle systemen hervat."})},onError:N=>{v({title:"Fout",description:`Kon migratiemodus niet wijzigen: ${N.message}`,variant:"destructive"})}});return{isMigrationMode:(n=(t=u.data)==null?void 0:t.migration_mode)!=null?n:!1,migrationStartedAt:(l=(i=u.data)==null?void 0:i.migration_started_at)!=null?l:null,migrationStartedBy:(m=(d=u.data)==null?void 0:d.migration_started_by)!=null?m:null,isLoading:u.isLoading,toggleMigration:w.mutate,isToggling:w.isPending}},rd=()=>{const{isMigrationMode:t,migrationStartedAt:n,isLoading:i,toggleMigration:l,isToggling:d}=nd(),[m,g]=a.useState("");
25if(a.useEffect(()=>{if(!t||!n){g("");return}const u=()=>{const N=Date.now()-new Date(n).getTime(),k=Math.floor(N/36e5),j=Math.floor(N%36e5/6e4),I=Math.floor(N%6e4/1e3);g(`${k}u ${j}m ${I}s`)};u();const w=setInterval(u,1e3);return()=>clearInterval(w)},[t,n]),i)return e.jsx(R,{children:e.jsx(G,{className:"flex items-center justify-center py-12",children:e.jsx(he,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});const v=[{label:"Database triggers (alle tabellen)",description:"BEFORE INSERT/UPDATE/DELETE op alle tabellen geblokkeerd",icon:ni,active:t},{label:"pg_cron jobs (16 stuks)",description:"Alle achtergrondtaken gepauzeerd via cron.unschedule()",icon:Re,active:t},{label:"Onderhoudsmodus",description:"Website geblokkeerd voor gebruikers, auth routes beschikbaar",icon:Ms,active:t},{label:"Edge Function writes",description:"114 edge functions geblokkeerd door DB triggers",icon:io,active:t},{label:"Client-side writes",description:"200+ frontend writes geblokkeerd door DB triggers",icon:Ds,active:t},{label:"Realtime subscriptions",description:"Traffic wordt nog ontvangen maar writes falen",icon:lo,active:t}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(R,{className:`border-2 ${t?"border-destructive bg-destructive/5":"border-border"}`,children:[e.jsx(J,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{className:"flex items-center gap-2 text-xl",children:[e.jsx(ra,{className:`h-5 w-5 ${t?"text-destructive":"text-muted-foreground"}`}),"Migratiemodus — Database Kill Switch"]}),e.jsx(Z,{children:"Bevriest de volledige database. Alle INSERT, UPDATE en DELETE operaties worden geblokkeerd op database-niveau via triggers. Cron jobs worden gepauzeerd. Onderhoudsmodus wordt automatisch geactiveerd."})]})})}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border bg-card",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-semibold",children:t?"🔴 Database is BEVROREN":"🟢 Database is actief"}),t&&m&&e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Re,{className:"h-3 w-3"}),"Actief sinds: ",m]})]}),e.jsxs(cn,{children:[e.jsx(wo,{asChild:!0,children:e.jsxs("div",{children:[e.jsx(be,{checked:t,disabled:d,onCheckedChange:()=>{},className:"pointer-events-none"}),e.jsxs(p,{variant:t?"default":"destructive",size:"sm",className:"ml-3",disabled:d,children:[d?e.jsx(he,{className:"h-4 w-4 animate-spin mr-1"}):null,t?"Hervatten":"Activeren"]})]})}),e.jsxs(dn,{children:[e.jsxs(un,{children:[e.jsxs(mn,{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"h-5 w-5 text-destructive"}),t?"Database hervatten?":"Database bevriezen?"]}),e.jsx(hn,{className:"space-y-2",children:t?e.jsx("span",{children:"Alle systemen worden weer geactiveerd. Database writes worden toegestaan, cron jobs worden hervat en de onderhoudsmodus wordt uitgeschakeld."}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block font-semibold text-destructive",children:"⚠️ Dit blokkeert ALLE database writes!"}),e.jsx("span",{className:"block",children:"• Alle INSERT/UPDATE/DELETE operaties worden geblokkeerd op alle tabellen"}),e.jsx("span",{className:"block",children:"• Alle 16 cron jobs worden gepauzeerd"}),e.jsx("span",{className:"block",children:"• De website wordt automatisch op onderhoud gezet"}),e.jsx("span",{className:"block",children:"• Externe webhooks (Stripe, Mailgun) krijgen een database error"}),e.jsx("span",{className:"block mt-2 text-xs",children:"Alleen de platform_settings tabel blijft schrijfbaar zodat je de modus weer kunt uitschakelen."})]})})]}),e.jsxs(pn,{children:[e.jsx(xn,{children:"Annuleren"}),e.jsx(gn,{onClick:()=>l(!t),className:t?"":"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:t?"Ja, hervatten":"Ja, bevriezen"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider",children:"Systeemstatus"}),e.jsx("div",{className:"space-y-1",children:v.map(u=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md border bg-card",children:[e.jsx(u.icon,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:u.label}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:u.description})]}),u.active?e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-destructive",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-destructive animate-pulse"}),"Geblokkeerd"]}):e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-green-600",children:[e.jsx(Os,{className:"h-3 w-3"}),"Actief"]})]},u.label))})]}),e.jsx("div",{className:"flex gap-3 pt-2",children:e.jsx(Po,{to:"/schema-dump",children:e.jsxs(p,{variant:"outline",size:"sm",children:[e.jsx(ni,{className:"h-4 w-4 mr-1"}),"Schema Dump"]})})})]})]}),e.jsxs(R,{children:[e.jsx(J,{children:e.jsx(Q,{className:"text-base",children:"Hoe werkt de migratiemodus?"})}),e.jsxs(G,{className:"text-sm text-muted-foreground space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Laag 1 — Database triggers:"})," Een ",e.jsx("code",{children:"BEFORE INSERT/UPDATE/DELETE"})," trigger op elke tabel checkt de ",e.jsx("code",{children:"migration_mode"})," flag. Bij ",e.jsx("code",{children:"true"})," wordt een exception gegooid en de write geblokkeerd. Dit vangt 100% van alle writes, ongeacht de bron."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Laag 2 — pg_cron:"})," Alle 16 cron jobs worden via ",e.jsx("code",{children:"cron.unschedule()"}),"gepauzeerd. Bij deactivatie worden ze hervat met hun originele schedule."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Laag 3 — Onderhoudsmodus:"})," Wordt automatisch geactiveerd zodat gebruikers de website niet kunnen bereiken. Auth routes blijven beschikbaar voor beheerders."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Uitzondering:"})," De ",e.jsx("code",{children:"platform_settings"})," tabel is uitgezonderd van de blokkade, zodat je de migratiemodus altijd kunt uitschakelen."]})]})]})]})},Md=()=>{const t=Pi(),{hasAccess:n,isLoading:i}=jo("settings:manage"),{isSuperAdmin:l}=oo(),[d,m]=a.useState(!1),[g,v]=a.useState(null),[u,w]=a.useState(null),[N,k]=a.useState(null),[j,I]=a.use
25State(""),[f,V]=a.useState(""),[me,ee]=a.useState(!1),[ue,je]=a.useState(!1),[B,L]=a.useState(!1),[F,P]=a.useState(!1),[D,T]=a.useState(null),[W,fe]=a.useState(!1),[re,pe]=a.useState(null),[Ce,ke]=a.useState(!1),[ie,_e]=a.useState(!1),[xe,Ae]=a.useState(""),[z,H]=a.useState(!1),[te,le]=a.useState(!1),[we,Fe]=a.useState(!1),[M,Te]=a.useState(""),[Le,Qe]=a.useState("gemini-3.1-flash-image-preview"),[ms,Ge]=a.useState("gemini-3-flash-preview"),[Me,He]=a.useState(!1),[Ve,qe]=a.useState(!1),[Pe,Ie]=a.useState(!1),[De,rs]=a.useState(""),[ts,is]=a.useState("gpt-5-2025-08-07"),[Ue,fs]=a.useState(!1),[hs,vs]=a.useState(!1),[h,x]=a.useState(!1),[O,oe]=a.useState(""),[S,Y]=a.useState(!1),[_,E]=a.useState(""),[ve,ye]=a.useState(!1),[Ee,r]=a.useState(""),[$,ce]=a.useState(!1),[Ke,js]=a.useState(!1),[Gs,Cs]=a.useState(!1),[qs,ls]=a.useState(""),[jn,bn]=a.useState(!1),[yn,_n]=a.useState(!1),[wn,Tt]=a.useState(!1),[Et,da]=a.useState(""),[Nn,kn]=a.useState(!1),[Sn,Cn]=a.useState(!1),[An,Ft]=a.useState(!1),[ut,ua]=a.useState(""),[mt,ma]=a.useState(""),[Pn,In]=a.useState(!1),[Tn,En]=a.useState(!1),[Fn,ht]=a.useState(!1),[As,pt]=a.useState(""),[Ps,xt]=a.useState(""),[Dn,ha]=a.useState("higgsfield-ai/soul/standard"),[On,pa]=a.useState("higgsfield-ai/soul/standard"),[Mn,Vn]=a.useState(!1),[zn,Ln]=a.useState(!1),[Kn,Qs]=a.useState(!1),[Dt,Ei]=a.useState([]),[Ot,$n]=a.useState(!1),[de,Rn]=a.useState(null),[Ys,Gn]=a.useState(""),[Xs,qn]=a.useState(""),[Un,Bn]=a.useState(!1),[Hn,Jn]=a.useState(!1),[Wn,Zs]=a.useState(!1),[et,xa]=a.useState(""),[Qn,Yn]=a.useState(!1),[Xn,Zn]=a.useState(!1),[er,gt]=a.useState(!1),[st,sr]=a.useState(""),[tr,ar]=a.useState(!1),[nr,rr]=a.useState(!1),[ir,ft]=a.useState(!1),[Mt,lr]=a.useState(""),[or,cr]=a.useState(!1),[dr,ur]=a.useState(!1),[mr,Vt]=a.useState(!1),[zt,hr]=a.useState(""),[pr,xr]=a.useState(!1),[gr,fr]=a.useState(!1),[vr,ga]=a.useState(!1),[tt,fa]=a.useState(""),[jr,br]=a.useState(!1),[yr,Lt]=a.useState(!1),[va,Kt]=a.useState("25 95% 55%"),[ja,$t]=a.useState("30 90% 60%"),[ba,Rt]=a.useState("25 95% 55%"),[ya,Gt]=a.useState("240 10% 6%"),[_a,qt]=a.useState("210 40% 98%"),[wa,Ut]=a.useState("240 8% 10%"),[Na,vt]=a.useState("217 91% 60%"),[ka,jt]=a.useState("48 96% 53%"),[Sa,bt]=a.useState("25 95% 53%"),[Ca,yt]=a.useState("0 84% 60%"),[Aa,_r]=a.useState(!1),[wr,id]=a.useState([]),[Nr,kr]=a.useState(""),[Fi,Sr]=a.useState(!1),[Cr,ld]=a.useState(!1),[Pa,Bt]=a.useState("240 5% 18%"),[Ia,Ht]=a.useState("240 5% 25%"),[Ta,Jt]=a.useState("0 84% 60%"),[Ea,Ar]=a.useState(!1),[Pr,Fa]=a.useState(!1),[Ir,Da]=a.useState(""),[Oa,Ma]=a.useState(""),[Tr,Va]=a.useState("Dagen"),[Er,za]=a.useState("Uren"),[Fr,La]=a.useState("Minuten"),[Dr,Ka]=a.useState("Seconden"),[Or,$a]=a.useState("modern"),[Mr,Ra]=a.useState("240 8% 10%"),[Vr,Ga]=a.useState("210 40% 98%"),[zr,qa]=a.useState("180 100% 50%"),[Ua,Ba]=a.useState(100),[Lr,Kr]=a.useState(!1),[$r,Ha]=a.useState(!0),[od,cd]=a.useState(!1),[Di,Rr]=a.useState(!0),[Oi,Gr]=a.useState(!1),[Mi,qr]=a.useState(!0),[Vi,Ur]=a.useState(!1),[Br,Hr]=a.useState(!1),[zi,Jr]=a.useState(!1),[Wr,Qr]=a.useState(""),{toast:C}=ss(),Ls=s=>s.replace(/\s+/g,"").trim(),Yr=async()=>{try{$n(!0);const{data:s,error:c}=await o.functions.invoke("list-higgsfield-models");if(c)return;s!=null&&s.models&&Array.isArray(s.models)&&Ei(s.models)}catch(s){}finally{$n(!1)}},Li=async()=>{const{data:{session:s}}=await o.auth.getSession();s||t("/login")},Ja=s=>{const c=document.documentElement;s.color_primary&&c.style.setProperty("--primary",s.color_primary),s.color_secondary&&c.style.setProperty("--secondary",s.color_secondary),s.color_accent&&c.style.setProperty("--accent",s.color_accent),s.color_background&&c.style.setProperty("--background",s.color_background),s.color_foreground&&c.style.setProperty("--foreground",s.color_foreground),s.color_card&&c.style.setProperty("--card",s.color_card),s.color_muted&&c.style.setProperty("--muted",s.color_muted),s.color_border&&c.style.setProperty("--border",s.color_border),s.color_destructive&&c.style.setProperty("--destructive",s.color_destructive)},Ki=async()=>{try{const{data:{user:s}}=await o.auth.getUser();if(!s)return;const{data:c,error:K}=await o.from("user_roles").select("role").eq("user_id",s.id),se=c==null?void 0:c.some(y=>y.role==="superadmin");let ne=s.id;if(se){const{data:y,error:bs}=await o.from("profiles").select("id, logo_url, login_logo_url, favicon_url, founder_photo_url, lumen_brain_image_url, homepage_title, version_number, openai_model, openai_assistant_id, website_scan_prompt, lumen_chatwidget_prompt, color_primary, color_secondary, color_accent, color_background, color_foreground, color_card, color_muted, color_border, color_destructive, countdown_enabled, countdown_title, countdown_end_date, countdown_label_days, countdown_label_hours, countdown_label_minutes, countdown_label_seconds, countdown_style, countdown_color_bg, countdown_color_text, countdown_color_accent, countdown_size, background_enabled, phase_color_orientation, phase_color_problem_recognition, phase_color_evaluation, phase_color_purchase, signup_enabled, maintenance_mode, maintenance_message").order("created_at",{ascending:!0}).limit(1).single();if(!bs){if(y){ne=y.id,Rn(y.id),y.logo_url&&v(y.logo_url),y.login_logo_url&&w(y.login_logo_url),y.favicon_url&&k(y.favicon_url),y.founder_photo_url&&T(y.founder_photo_url),y.lumen_brain_image_url&&pe(y.lumen_brain_image_url),y.homepage_title&&I(y.homepage_title),y.version_number&&V(y.version_number);const{data:Oe}=await o.from("user_secrets").select("secret_name, encrypted_value").eq("user_id",y.id);Oe&&Oe.forEach(X=>{if(X.secret_name==="ipinfo_api_key"&&Ae(X.encrypted_value),X.secret_name==="gemini_api_key"&&Te(X.encrypted_value),X.secret_name==="gemini_model"){const Ze=X.encrypted_value;Qe(Ze!=null&&Ze.startsWith("imagen-")?"gemini-3.1-flash-image-preview":Ze)}X.secret_name==="gemini_text_model"&&Ge(X.encrypted_value||"gemini-3-flash-preview"),
25X.secret_name==="openai_api_key"&&rs(X.encrypted_value),X.secret_name==="openai_admin_api_key"&&ls(X.encrypted_value),X.secret_name==="claude_api_key"&&da(X.encrypted_value),X.secret_name==="mailgun_api_key"&&ua(X.encrypted_value),X.secret_name==="mailgun_domain"&&ma(X.encrypted_value),X.secret_name==="higgsfield_api_key"&&pt(Ls(X.encrypted_value||"")),X.secret_name==="higgsfield_api_secret"&&xt(Ls(X.encrypted_value||"")),X.secret_name==="higgsfield_image_model"&&ha(X.encrypted_value||"higgsfield-ai/soul/standard"),X.secret_name==="higgsfield_video_model"&&pa(X.encrypted_value||"higgsfield-ai/soul/standard"),X.secret_name==="browseract_api_key"&&Gn(X.encrypted_value||""),X.secret_name==="browseract_workflow_id"&&qn(X.encrypted_value||""),X.secret_name==="jina_api_key"&&xa(X.encrypted_value||""),X.secret_name==="apify_api_key"&&sr(X.encrypted_value||""),X.secret_name==="grok_api_key"&&lr(X.encrypted_value||""),X.secret_name==="perplexity_api_key"&&hr(X.encrypted_value||""),X.secret_name==="syncfusion_license_key"&&(fa(X.encrypted_value||""),X.encrypted_value&&(Lt(!0),localStorage.setItem("syncfusion_license_key",X.encrypted_value)))}),y.openai_model&&is(y.openai_model),y.website_scan_prompt&&oe(y.website_scan_prompt),y.lumen_chatwidget_prompt&&E(y.lumen_chatwidget_prompt),y.openai_assistant_id&&r(y.openai_assistant_id),y.color_primary&&Kt(y.color_primary),y.color_secondary&&$t(y.color_secondary),y.color_accent&&Rt(y.color_accent),y.color_background&&Gt(y.color_background),y.color_foreground&&qt(y.color_foreground),y.color_card&&Ut(y.color_card),y.color_muted&&Bt(y.color_muted),y.color_border&&Ht(y.color_border),y.color_destructive&&Jt(y.color_destructive),Fa(y.countdown_enabled||!1),y.countdown_title&&Da(y.countdown_title),y.countdown_end_date&&Ma(y.countdown_end_date.slice(0,16)),y.countdown_label_days&&Va(y.countdown_label_days),y.countdown_label_hours&&za(y.countdown_label_hours),y.countdown_label_minutes&&La(y.countdown_label_minutes),y.countdown_label_seconds&&Ka(y.countdown_label_seconds),y.countdown_style&&$a(y.countdown_style),y.countdown_color_bg&&Ra(y.countdown_color_bg),y.countdown_color_text&&Ga(y.countdown_color_text),y.countdown_color_accent&&qa(y.countdown_color_accent),Ba(y.countdown_size||100),Ha(y.background_enabled!==!1),Rr(y.signup_enabled!==!1),qr(y.show_logo_on_login!==!1),Hr(y.maintenance_mode===!0),Qr(y.maintenance_message||""),y.phase_color_orientation&&vt(y.phase_color_orientation),y.phase_color_problem_recognition&&jt(y.phase_color_problem_recognition),y.phase_color_evaluation&&bt(y.phase_color_evaluation),y.phase_color_purchase&&yt(y.phase_color_purchase),Ja(y);return}}}const{data:A,error:$e}=await o.from("profiles").select("logo_url, favicon_url, homepage_title, version_number, openai_model, website_scan_prompt, color_primary, color_secondary, color_accent, color_background, color_foreground, color_card, color_muted, color_border, color_destructive, countdown_enabled, countdown_title, countdown_end_date, countdown_label_days, countdown_label_hours, countdown_label_minutes, countdown_label_seconds, countdown_style, countdown_color_bg, countdown_color_text, countdown_color_accent, background_enabled").eq("id",ne).single();if($e)throw $e;Rn(ne),A!=null&&A.logo_url&&v(A.logo_url),A!=null&&A.favicon_url&&k(A.favicon_url),A!=null&&A.homepage_title&&I(A.homepage_title),A!=null&&A.version_number&&V(A.version_number);const{data:Ye}=await o.from("user_secrets").select("secret_name, encrypted_value").eq("user_id",ne);Ye&&Ye.forEach(y=>{if(y.secret_name==="ipinfo_api_key"&&Ae(y.encrypted_value),y.secret_name==="gemini_api_key"&&Te(y.encrypted_value),y.secret_name==="gemini_model"){const bs=y.encrypted_value;Qe(bs!=null&&bs.startsWith("imagen-")?"gemini-3.1-flash-image-preview":bs)}y.secret_name==="gemini_text_model"&&Ge(y.encrypted_value||"gemini-3-flash-preview"),y.secret_name==="openai_api_key"&&rs(y.encrypted_value),y.secret_name==="claude_api_key"&&da(y.encrypted_value),y.secret_name==="mailgun_api_key"&&ua(y.encrypted_value),y.secret_name==="mailgun_domain"&&ma(y.encrypted_value),y.secret_name==="higgsfield_api_key"&&pt(Ls(y.encrypted_value||"")),y.secret_name==="higgsfield_api_secret"&&xt(Ls(y.encrypted_value||"")),y.secret_name==="higgsfield_image_model"&&ha(y.encrypted_value||"higgsfield-ai/soul/standard"),y.secret_name==="higgsfield_video_model"&&pa(y.encrypted_value||"higgsfield-ai/soul/standard"),y.secret_name==="jina_api_key"&&xa(y.encrypted_value||""),y.secret_name==="syncfusion_license_key"&&(fa(y.encrypted_value||""),y.encrypted_value&&(Lt(!0),localStorage.setItem("syncfusion_license_key",y.encrypted_value)))}),A!=null&&A.openai_model&&is(A.openai_model),A!=null&&A.website_scan_prompt&&oe(A.website_scan_prompt),A!=null&&A.color_primary&&Kt(A.color_primary),A!=null&&A.color_secondary&&$t(A.color_secondary),A!=null&&A.color_accent&&Rt(A.color_accent),A!=null&&A.color_background&&Gt(A.color_background),A!=null&&A.color_foreground&&qt(A.color_foreground),A!=null&&A.color_card&&Ut(A.color_card),A!=null&&A.color_muted&&Bt(A.color_muted),A!=null&&A.color_border&&Ht(A.color_border),A!=null&&A.color_destructive&&Jt(A.color_destructive),Fa((A==null?void 0:A.countdown_enabled)||!1),A!=null&&A.countdown_title&&Da(A.countdown_title),A!=null&&A.countdown_end_date&&Ma(A.countdown_end_date.slice(0,16)),A!=null&&A.countdown_label_days&&Va(A.countdown_label_days),A!=null&&A.countdown_label_hours&&za(A.countdown_label_hours),A!=null&&A.countdown_label_minutes&&La(A.countdown_label_minutes),A!=null&&A.countdown_label_seconds&&Ka(A.countdown_label_seconds),A!=null&&A.countdown_style&&$a(A.countdown_style),A!=null&&A.countdown_color_bg&&Ra(A.countdown_color_bg),A!=null&&A.countdown_color_text&&Ga(A.countdown_color_text),A!=null&&A.countdown_color_accent&&qa(A.countdown_color_accent),Ba((A==null?void 0:A.countdown_size)||100),Ha((A==null?void 0:A.background_enabled)!==!1),A&&Ja(A)}catch(s){}};if(a.useEffect(()=>{Li(),Ki()},[]),a.useEffect(()=>{As&&Ps&&Yr()},[As,Ps]),i)return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(he,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!n)return null;const $i=async()=>{C({title:"Functie niet beschikbaar",description:"Presets opslaan is momenteel niet beschikbaar.",variant:"destructive"})},Ri=async(s,c)=>{C({title:"Functie niet beschikbaar",description:"Presets verwijderen is momenteel niet beschikbaar.",variant:"destructive"})},Gi=s=>{vt(s.orientation_color),jt(s.problem_recognition_color),bt(s.evaluation_color),yt(s.purchase_color)},Wt=s=>{const c=s.split(" ");if(c.length!==3)return"#3b82f6";const K=parseFloat(c[0])/360,se=parseFloat(c[1].replace("%",""))/100,ne=parseFloat(c[2].replace("%",""))/100,A=(Oe,X,Ze)=>(Ze<0&&(Ze+=1),Ze>1&&(Ze-=1),Ze<1/6?Oe+(X-Oe)*6*Ze:Ze<1/2?X:Ze<2/3?Oe+(X-Oe)*(2/3-Ze)*6:Oe);let $e,Ye,y;if(se===0)$e=Ye=y=ne;else{const Oe=ne<.5?ne*(1+se):ne+se-ne*se,X=2*ne-Oe;$e=A(X,Oe,K+1/3),Ye=A(X,Oe,K),y=A(X,Oe,K-1/3)}const bs=Oe=>{const X=Math.round(Oe*255).toString(16);return X.length===1?"0"+X:X};return`#${bs($e)}${bs(Ye)}${bs(y)}`},qi=async s=>{try{if(ee(!0),!s.target.files||s.target.files.length===0)return;const c=s.target.files[0],K=c.name.split(".").pop(),se=c.type||"image/png",{data:{session:ne}}=await o.auth.getSession();if(!(ne!=null&&ne.user))throw new Error("Niet ingelogd");const A=`logo_${Date.now()}.${K}`,$e=await fetch("https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/get-r2-upload-url",{method:"POST",headers:{Authorization:`Bearer ${ne.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({fileName:A,contentType:se,folder:`logos/${ne.user.id}`,fileSize:c.size})});if(!$e.ok)throw new Error("Kon upload URL niet ophalen");const{uploadUrl:Ye,publicUrl:y}=await $e.json();if(!(await fetch(Ye,{method:"PUT",headers:{"Content-Type":se},body:c})).ok)throw new Error("Upload naar opslag mislukt");const{error:Oe}=await o.from("profiles").update({logo_url:y}).eq("id",de||ne.user.id);if(Oe)throw Oe;v(y),C({title:"Logo geüpload",description:"Je logo is succesvol geüpload!"})}catch(c){C({title:"Upload mislukt",description:c.message,variant:"destructive"})}finally{ee(!1)}},Ui=async s=>{try{if(je(!0),!s.target.files||s.target.files.length===0)return;const c=s.target.files[0],K=c.name.split(".").pop(),se=c.type||"image/png",{data:{session:ne}}=await o.auth.getSession();if(!(ne!=null&&ne.user))throw new Error("Niet ingelogd");const A=`login-logo_${Date.now()}.${K}`,$e=await fetch("https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/get-r2-upload-url",{method:"POST",headers:{Authorization:`Bearer ${ne.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({fileName:A,contentType:se,folder:`logos/${ne.user.id}`,fileSize:c.size})});if(!$e.ok)throw new Error("Kon upload URL niet ophalen");const{uploadUrl:Ye,publicUrl:y}=await $e.json();if(!(await fetch(Ye,{method:"PUT",headers:{"Content-Type":se},body:c})).ok)throw new Error("Upload naar opslag mislukt");const{error:Oe}=await o.from("profiles").update({login_logo_url:y}).eq("id",de||ne.user.id);if(Oe)throw Oe;w(y),localStorage.removeItem("app_settings_cache_v3"),C({title:"Login logo geüpload",description:"Het login pagina logo is succesvol geüpload!"})}catch(c){C({title:"Upload mislukt",description:c.message,variant:"destructive"})}finally{je(!1)}},Bi=async()=>{try{m(!0);const{data:{session:s}}=await o.auth.getSession();if(!(s!=null&&s.user))throw new Error("Niet ingelogd");const{error:c}=await o.from("profiles").update({login_logo_url:null}).eq("id",de||s.user.id);if(c)throw c;w(null),localStorage.removeItem("app_settings_cache_v3"),C({title:"Login logo verwijderd",de
25scription:"Het login pagina logo is succesvol verwijderd. Het standaard logo wordt nu gebruikt."})}catch(s){C({title:"Verwijderen mislukt",description:s.message,variant:"destructive"})}finally{m(!1)}},Hi=async s=>{try{if(L(!0),!s.target.files||s.target.files.length===0)return;const c=s.target.files[0],K=c.name.split(".").pop(),se=c.type||"image/png",{data:{session:ne}}=await o.auth.getSession();if(!(ne!=null&&ne.user))throw new Error("Niet ingelogd");const A=`favicon_${Date.now()}.${K}`,$e=await fetch("https://wvqjywcbmxbtifvdlyby.supabase.co/functions/v1/get-r2-upload-url",{method:"POST",headers:{Authorization:`Bearer ${ne.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({fileName:A,contentType:se,folder:`logos/${ne.user.id}`,fileSize:c.size})});if(!$e.ok)throw new Error("Kon upload URL niet ophalen");const{uploadUrl:Ye,publicUrl:y}=await $e.json();if(!(await fetch(Ye,{method:"PUT",headers:{"Content-Type":se},body:c})).ok)throw new Error("Upload naar opslag mislukt");const{error:Oe}=await o.from("profiles").update({favicon_url:y}).eq("id",de||ne.user.id);if(Oe)throw Oe;k(y),document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(Fl=>Fl.remove());const Ze=document.createElement("link");Ze.rel="icon",Ze.href=y+"?t="+Date.now(),document.head.appendChild(Ze),C({title:"Favicon geüpload",description:"Je favicon is succesvol geüpload!"})}catch(c){C({title:"Upload mislukt",description:c.message,variant:"destructive"})}finally{L(!1)}},Ji=async()=>{try{m(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");if(g){const K=g.split("/").slice(-2).join("/");await o.storage.from("app-logos").remove([K])}const{error:c}=await o.from("profiles").update({logo_url:null}).eq("id",de||s.id);if(c)throw c;v(null),C({title:"Logo verwijderd",description:"Je logo is succesvol verwijderd."})}catch(s){C({title:"Verwijderen mislukt",description:s.message,variant:"destructive"})}finally{m(!1)}},Wi=async()=>{try{m(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");if(N){const se=N.split("/").slice(-2).join("/");await o.storage.from("app-logos").remove([se])}const{error:c}=await o.from("profiles").update({favicon_url:null}).eq("id",de||s.id);if(c)throw c;k(null),document.querySelectorAll("link[rel='icon'], link[rel='shortcut icon']").forEach(se=>se.remove()),C({title:"Favicon verwijderd",description:"Je favicon is succesvol verwijderd."})}catch(s){C({title:"Verwijderen mislukt",description:s.message,variant:"destructive"})}finally{m(!1)}},Qi=async()=>{try{ke(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({homepage_title:j}).eq("id",de||s.id);if(c)throw c;document.title=j||"Lumen",C({title:"Titel opgeslagen",description:"De homepage titel is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{ke(!1)}},Yi=async()=>{try{_e(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({version_number:f}).eq("id",de||s.id);if(c)throw c;C({title:"Versie opgeslagen",description:"Het versienummer is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{_e(!1)}},Xi=async()=>{try{H(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"ipinfo_api_key",p_secret_value:xe});if(c)throw c;C({title:"API Key opgeslagen",description:"Je IPinfo.io API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{H(!1)}},Zi=async()=>{try{le(!0);const s=await fetch(`https://ipinfo.io/json?token=${xe}`);if(s.ok){const c=await s.json();Fe(!0),C({title:"Verbinding succesvol!",description:`API key werkt. Huidige locatie: ${c.city}, ${c.country}`})}else throw Fe(!1),new Error("Ongeldige API key")}catch(s){Fe(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met IPinfo.io",variant:"destructive"})}finally{le(!1)}},el=async()=>{try{He(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"gemini_api_key",p_secret_value:M});if(c)throw c;const{error:K}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"gemini_model",p_secret_value:Le});if(K)throw K;const{error:se}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"gemini_text_model",p_secret_value:ms});if(se)throw se;C({title:"Instellingen opgeslagen",description:"Je Google Gemini API key en modellen zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{He(!1)}},sl=async()=>{var s;try{qe(!0);const c=await fetch("https://generativelanguage.googleapis.com/v1beta/models?key="+M);if(c.ok)Ie(!0),C({title:"Verbinding succesvol!",description:"Google Gemini API key is geldig en werkt."});else{Ie(!1);const K=await c.json();throw new Error(((s=K.error)==null?void 0:s.message)||"Ongeldige API key")}}catch(c){Ie(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met Google Gemini",variant:"destructive"})}finally{qe(!1)}},tl=async()=>{try{kn(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"claude_api_key",p_secret_value:Et});if(c)throw c;C({title:"API Key opgeslagen",description:"Je Claude API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{kn(!1)}},al=async()=>{try{Cn(!0);const{data:s,error:c}=await o.functions.invoke("test-claude-api",{body:{apiKey:Et}});if(c)throw new Error(c.message||"Verbinding mislukt");if(s!=null&&s.success)Ft(!0),C({title:"Verbinding succesvol!",description:"Claude API key is geldig en werkt."});else throw Ft(!1),new Error((s==null?void 0:s.error)||"Ongeldige API key")}catch(s){Ft(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met Claude",variant:"destructive"})}finally{Cn(!1)}},nl=async()=>{try{cr(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"grok_api_key",p_secret_value:Mt});if(c)throw c;C({title:"API Key opgeslagen",description:"Je Grok API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{cr(!1)}},rl=async()=>{var s;try{ur(!0);const c=await fetch("https://api.x.ai/v1/models",{method:"GET",headers:{Authorization:`Bearer ${Mt}`,"Content-Type":"application/json"}});if(c.ok)Vt(!0),C({title:"Verbinding succesvol!",description:"Grok API key is geldig en werkt."});else{const K=await c.json().catch(()=>({}));throw Vt(!1),new Error(((s=K.error)==null?void 0:s.message)||"Ongeldige API key")}}catch(c){Vt(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met Grok",variant:"destructive"})}finally{ur(!1)}},il=async()=>{try{xr(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"perplexity_api_key",p_secret_value:zt});if(c)throw c;C({title:"API Key opgeslagen",description:"Je Perplexity API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{xr(!1)}},ll=async()=>{try{fr(!0);const s=await fetch("https://api.perplexity.ai/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${zt}`,"Content-Type":"application/json"},body:JSON.stringify({model:"sonar",messages:[{role:"user",content:"Hello"}],max_tokens:5})});if(!s.ok){const c=await s.text();throw new Error(`API fout: ${s.status} - ${c}`)}ga(!0),C({title:"Verbinding succesvol",description:"Je Perplexity API key werkt correct!"})}catch(s){ga(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met Perplexity",variant:"destructive"})}finally{fr(!1)}},ol=async()=>{try{In(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"mailgun_api_key",p_secret_value:ut});if(c)throw c;const{error:K}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"mailgun_domain",p_secret_value:mt});if(K)throw K;C({title:"Mailgun instellingen opgeslagen",description:"Je Mailgun API key en domain zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{In(!1)}},cl=async()=>{try{En(!0);const{data:s,error:c}=await o.functions.invoke("test-mailgun-api",{body:{apiKey:ut,domain:mt}});if(c)throw new Error(c.message||"Verbinding mislukt");if(s!=null&&s.success)ht(!0),C({title:"Verbinding succesvol!",description:"Mailgun API is geldig en werkt."});else throw ht(!1),new Error((s==null?void 0:s.error)||"Ongeldige API key of domain")}catch(s){ht(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met Mailgun",variant:"destructive"})}finally{En(!1)}},Xr=async()=>{try{fs(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"openai_api_key",p_secret_value:De});if(c)throw c;const{error:K}=await o.from("profiles").update({openai_model:ts}).eq("id",de||s.id);if(K)throw K;C({title:"Instellingen opgeslagen",description:"Je OpenAI instellingen zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{fs(!1)}},dl=async()=>{var s;try{vs(!0);const c=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${De}`}});if(c.ok)x(!0),C({title:"Verbinding succesvol!",description:"OpenAI API key is geldig en werkt."});else{x(!1);const K=await c.json();throw new Error(((s=K.error)==null?void 0:s.message)||"Ongeldige API key")}}catch(c){x(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met OpenAI",variant:"destructive"})}finally{vs(!1)}},ul=async()=>{try{Vn(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const c=Ls(As),K=Ls(Ps),se=c!==As||K!==Ps;if(!c||!K)throw new Error("Voer zowel de API Key als API Secret in");se&&(pt(c),xt(K));const ne=de||s.id,{error:A}=await o.rpc("store_user_secret",{p_user_id:ne,p_secret_name:"higgsfield_api_key",p_secret_value:c});if(A)throw A;const{error:$e}=await o.rpc("store_user_secret",{p_user_id:ne,p_secret_name:"higgsfield_api_secret",p_secret_value:K});if($e)throw $e;const{error:Ye}=await o.rpc("store_user_secret",{p_user_id:ne,p_secret_name:"higgsfield_image_model",p_secret_value:Dn}
25);if(Ye)throw Ye;const{error:y}=await o.rpc("store_user_secret",{p_user_id:ne,p_secret_name:"higgsfield_video_model",p_secret_value:On});if(y)throw y;C({title:"Instellingen opgeslagen",description:se?"Credentials opgeschoond (spaties/nieuwe regels verwijderd) en opgeslagen.":"Je Higgsfield AI API instellingen zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Vn(!1)}},ml=async()=>{try{Ln(!0);const s=Ls(As),c=Ls(Ps),K=s!==As||c!==Ps;if(!s||!c)throw new Error("Voer zowel de API Key als API Secret in");K&&(pt(s),xt(c));const{data:se,error:ne}=await o.functions.invoke("test-higgsfield-api",{body:{apiKey:s,apiSecret:c}});if(ne)throw Qs(!1),new Error(ne.message||"API verbinding mislukt");if(se!=null&&se.success)Qs(!0),C({title:se!=null&&se.warning?"API key geldig (let op)":"Verbinding succesvol!",description:(K?"Credentials opgeschoond. ":"")+((se==null?void 0:se.warning)||"Higgsfield AI API is geldig en werkt.")});else throw Qs(!1),new Error((se==null?void 0:se.error)||"API verbinding mislukt")}catch(s){Qs(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met Higgsfield AI",variant:"destructive"})}finally{Ln(!1)}},hl=async()=>{try{Bn(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const c=de||s.id,{error:K}=await o.rpc("store_user_secret",{p_user_id:c,p_secret_name:"browseract_api_key",p_secret_value:Ys});if(K)throw K;const{error:se}=await o.rpc("store_user_secret",{p_user_id:c,p_secret_name:"browseract_workflow_id",p_secret_value:Xs});if(se)throw se;C({title:"Instellingen opgeslagen",description:"Je BrowserAct API instellingen zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Bn(!1)}},pl=async()=>{try{if(Jn(!0),!Ys||!Xs)throw new Error("Voer zowel de API Key als Workflow ID in");const{data:s,error:c}=await o.functions.invoke("test-browseract-api",{body:{apiKey:Ys,workflowId:Xs}});if(c)throw Zs(!1),new Error(c.message||"API verbinding mislukt");if(s!=null&&s.success)Zs(!0),C({title:"Verbinding succesvol!",description:(s==null?void 0:s.message)||"BrowserAct API is geldig en werkt."});else throw Zs(!1),new Error((s==null?void 0:s.error)||"BrowserAct verbinding mislukt")}catch(s){Zs(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met BrowserAct",variant:"destructive"})}finally{Jn(!1)}},xl=async()=>{try{Yn(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const c=de||s.id,{error:K}=await o.rpc("store_user_secret",{p_user_id:c,p_secret_name:"jina_api_key",p_secret_value:et});if(K)throw K;C({title:"API Key opgeslagen",description:"Je Jina Reader API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Yn(!1)}},gl=async()=>{try{if(Zn(!0),!et)throw new Error("Voer eerst een API key in");const s=await fetch("https://r.jina.ai/https://example.com",{headers:{Authorization:`Bearer ${et}`,"X-Return-Format":"json"}});if(s.ok)gt(!0),C({title:"Verbinding succesvol!",description:"Jina Reader API key is geldig en werkt."});else{if(s.status===401)throw gt(!1),new Error("Ongeldige API key");gt(!0),C({title:"Verbinding succesvol!",description:"Jina Reader API key werkt (of gratis tier actief)."})}}catch(s){gt(!1),C({title:"Verbinding mislukt",description:s.message||"Kon geen verbinding maken met Jina Reader",variant:"destructive"})}finally{Zn(!1)}},fl=async()=>{try{ar(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const c=de||s.id,{error:K}=await o.rpc("store_user_secret",{p_user_id:c,p_secret_name:"apify_api_key",p_secret_value:st});if(K)throw K;C({title:"API Key opgeslagen",description:"Je Apify API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{ar(!1)}},vl=async()=>{var s;try{if(rr(!0),!st)throw new Error("Voer eerst een API key in");const c=await fetch("https://api.apify.com/v2/users/me",{headers:{Authorization:`Bearer ${st}`}});if(c.ok){const K=await c.json();ft(!0),C({title:"Verbinding succesvol!",description:`Apify account: ${((s=K.data)==null?void 0:s.username)||"Verbonden"}`})}else throw c.status===401?(ft(!1),new Error("Ongeldige API key")):(ft(!1),new Error("Kon geen verbinding maken met Apify"))}catch(c){ft(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met Apify",variant:"destructive"})}finally{rr(!1)}},jl=async()=>{try{br(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const c=de||s.id,{error:K}=await o.rpc("store_user_secret",{p_user_id:c,p_secret_name:"syncfusion_license_key",p_secret_value:tt});if(K)throw K;if(tt){localStorage.setItem("syncfusion_license_key",tt);try{const{registerNewLicenseKey:se}=await mo(async()=>{const{registerNewLicenseKey:ne}=await import("./index-BbUi1KSl.js").then(A=>A.iT);return{registerNewLicenseKey:ne}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await se(tt),Lt(!0)}catch(se){}}else localStorage.removeItem("syncfusion_license_key");C({title:"License Key opgeslagen",description:"Je Syncfusion license key is succesvol opgeslagen. Herlaad de pagina om de wijziging toe te passen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{br(!1)}},bl=async()=>{try{Y(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({website_scan_prompt:O}).eq("id",de||s.id);if(c)throw c;C({title:"Prompt opgeslagen",description:"De website scan prompt is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Y(!1)}},yl=async()=>{try{ye(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({lumen_chatwidget_prompt:_}).eq("id",de||s.id);if(c)throw c;C({title:"Prompt opgeslagen",description:"De Lumen chatwidget prompt is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{ye(!1)}},_l=async()=>{try{ce(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({openai_assistant_id:Ee}).eq("id",de||s.id);if(c)throw c;C({title:"Assistant ID opgeslagen",description:"De OpenAI Assistant ID voor de kennisbank is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{ce(!1)}},wl=async()=>{var s;try{if(js(!0),!De)throw new Error("Voer eerst een OpenAI API key in onder het API Keys tabblad");if(!Ee)throw new Error("Voer eerst een Assistant ID in");const c=await fetch(`https://api.openai.com/v1/assistants/${Ee}`,{headers:{Authorization:`Bearer ${De}`,"OpenAI-Beta":"assistants=v2"}});if(c.ok){const K=await c.json();Cs(!0),C({title:"Verbinding succesvol!",description:`Assistant "${K.name||"Unnamed"}" is gekoppeld en werkt.`})}else{Cs(!1);const K=await c.json();throw new Error(((s=K.error)==null?void 0:s.message)||"Ongeldige Assistant ID")}}catch(c){Cs(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met de Assistant",variant:"destructive"})}finally{js(!1)}},Nl=async()=>{try{bn(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.rpc("store_user_secret",{p_user_id:de||s.id,p_secret_name:"openai_admin_api_key",p_secret_value:qs});if(c)throw c;C({title:"Admin API Key opgeslagen",description:"Je OpenAI Admin API key is succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{bn(!1)}},kl=async()=>{var s;try{if(_n(!0),!qs)throw new Error("Voer eerst een Admin API key in");const c=await fetch("https://api.openai.com/v1/organization/usage/completions?start_time="+Math.floor(Date.now()/1e3-86400),{headers:{Authorization:`Bearer ${qs}`}});if(c.ok)Tt(!0),C({title:"Verbinding succesvol!",description:"OpenAI Admin API key is geldig en werkt."});else{Tt(!1);const K=await c.json();throw new Error(((s=K.error)==null?void 0:s.message)||"Ongeldige Admin API key")}}catch(c){Tt(!1),C({title:"Verbinding mislukt",description:c.message||"Kon geen verbinding maken met de OpenAI Admin API",variant:"destructive"})}finally{_n(!1)}},Sl=async s=>{try{if(P(!0),!s.target.files||s.target.files.length===0)return;const c=s.target.files[0],K=c.name.split(".").pop(),{data:{user:se}}=await o.auth.getUser();if(!se)throw new Error("No user found");const ne=`${se.id}/founder-photo.${K}`;if(D){const y=D.split("/").slice(-2).join("/");await o.storage.from("app-logos").remove([y])}const{error:A}=await o.storage.from("app-logos").upload(ne,c,{upsert:!0});if(A)throw A;const{data:{publicUrl:$e}}=o.storage.from("app-logos").getPublicUrl(ne),{error:Ye}=await o.rpc("update_founder_photo",{p_photo_url:$e});if(Ye)throw Ye;T($e),C({title:"Foto geüpload",description:"De founder foto is succesvol geüpload!"})}catch(c){C({title:"Upload mislukt",description:c.message,variant:"destructive"})}finally{P(!1)}},Cl=async()=>{try{m(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");if(D){const K=D.split("/").slice(-2).join("/");await o.storage.from("app-logos").remove([K])}const{error:c}=await o.rpc("update_founder_photo",{p_photo_url:null});if(c)throw c;
25T(null),C({title:"Foto verwijderd",description:"De founder foto is succesvol verwijderd."})}catch(s){C({title:"Verwijderen mislukt",description:s.message,variant:"destructive"})}finally{m(!1)}},Al=async()=>{try{Ar(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({color_primary:va,color_secondary:ja,color_accent:ba,color_background:ya,color_foreground:_a,color_card:wa,color_muted:Pa,color_border:Ia,color_destructive:Ta}).eq("id",de||s.id);if(c)throw c;Ja({color_primary:va,color_secondary:ja,color_accent:ba,color_background:ya,color_foreground:_a,color_card:wa,color_muted:Pa,color_border:Ia,color_destructive:Ta}),C({title:"Kleuren opgeslagen",description:"De platform kleuren zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Ar(!1)}},Pl=()=>{Kt("25 95% 55%"),$t("30 90% 60%"),Rt("25 95% 55%"),Gt("240 10% 6%"),qt("210 40% 98%"),Ut("240 8% 10%"),Bt("240 5% 18%"),Ht("240 5% 25%"),Jt("0 84% 60%"),C({title:"Kleuren gereset",description:"Klik op 'Kleuren Opslaan' om de standaard kleuren op te slaan."})},Il=async()=>{try{_r(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({phase_color_orientation:Na,phase_color_problem_recognition:ka,phase_color_evaluation:Sa,phase_color_purchase:Ca}).eq("id",de||s.id);if(c)throw c;localStorage.setItem("phase-colors-cache",JSON.stringify({orientation:Na,problem_recognition:ka,evaluation:Sa,purchase:Ca})),C({title:"Fase kleuren opgeslagen",description:"De klantreis fase kleuren zijn bijgewerkt en worden overal toegepast."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{_r(!1)}},Tl=()=>{vt("217 91% 60%"),jt("48 96% 53%"),bt("25 95% 53%"),yt("0 84% 60%"),C({title:"Fase kleuren gereset",description:"Klik op 'Fase Kleuren Opslaan' om de standaard kleuren op te slaan."})},El=async()=>{try{Kr(!0);const{data:{user:s}}=await o.auth.getUser();if(!s)throw new Error("No user found");const{error:c}=await o.from("profiles").update({countdown_enabled:Pr,countdown_title:Ir,countdown_end_date:Oa?new Date(Oa).toISOString():null,countdown_label_days:Tr,countdown_label_hours:Er,countdown_label_minutes:Fr,countdown_label_seconds:Dr,countdown_style:Or,countdown_color_bg:Mr,countdown_color_text:Vr,countdown_color_accent:zr,countdown_size:Ua,background_enabled:$r}).eq("id",de||s.id);if(c)throw c;C({title:"Countdown timer opgeslagen",description:"De countdown timer instellingen zijn succesvol opgeslagen."})}catch(s){C({title:"Opslaan mislukt",description:s.message,variant:"destructive"})}finally{Kr(!1)}};return e.jsx(ho,{children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(vo,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[e.jsx("div",{className:"p-3 rounded-xl bg-gradient-to-br from-slate-500/20 to-zinc-500/20",children:e.jsx(co,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h1",{className:"text-4xl md:text-6xl font-bold tracking-tight",children:"Instellingen"})]}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Beheer je applicatie instellingen"})]}),e.jsxs(fn,{defaultValue:"branding",className:"w-full",children:[e.jsxs(vn,{className:"flex flex-wrap w-full mb-6 h-auto gap-1",children:[e.jsxs(Je,{value:"branding",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Branding"})]}),e.jsxs(Je,{value:"security",className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Beveiliging"})]}),e.jsxs(Je,{value:"api-keys",className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"API Keys"})]}),e.jsxs(Je,{value:"ai",className:"flex items-center gap-2",children:[e.jsx(ri,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"AI"})]}),e.jsxs(Je,{value:"push",className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Push"})]}),l&&e.jsxs(Je,{value:"youtube",className:"flex items-center gap-2",children:[e.jsx($s,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"hidden sm:inline",children:"YouTube"})]}),l&&e.jsxs(Je,{value:"nieuws",className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"hidden sm:inline",children:"Nieuws"})]}),l&&e.jsxs(Je,{value:"colors",className:"flex items-center gap-2",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Kleuren"})]}),l&&e.jsxs(Je,{value:"countdown",className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Countdown"})]}),l&&e.jsxs(Je,{value:"login",className:"flex items-center gap-2",children:[e.jsx(ii,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Login"})]}),l&&e.jsxs(Je,{value:"cronjobs",className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Cronjobs"})]}),l&&e.jsxs(Je,{value:"payments",className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"hidden sm:inline",children:"Betalingen"})]}),l&&e.jsxs(Je,{value:"database",className:"flex items-center gap-2",children:[e.jsx(Ws,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"hidden sm:inline",children:"Database"})]}),l&&e.jsxs(Je,{value:"migration",className:"flex items-center gap-2",children:[e.jsx(ra,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"hidden sm:inline",children:"Migratie"})]})]}),e.jsxs(We,{value:"security",className:"space-y-6",children:[e.jsx(Eo,{}),e.jsx(Do,{})]}),e.jsxs(We,{value:"branding",className:"space-y-6",children:[e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(kt,{className:"h-5 w-5 text-primary"}),"Klantreis Fase Kleuren"]}),e.jsx(Z,{children:"Pas de kleuren aan voor elke fase van de klantreis. Deze kleuren worden overal in analytics en grafieken toegepast."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{className:"text-sm font-medium",children:"Snel Kiezen - Kleurschema's"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{name:"Standaard",colors:{orientation:"217 91% 60%",problem_recognition:"48 96% 53%",evaluation:"25 95% 53%",purchase:"0 84% 60%"},preview:["#3b82f6","#eab308","#f97316","#ef4444"]},{name:"Ocean",colors:{orientation:"199 89% 48%",problem_recognition:"172 66% 50%",evaluation:"145 63% 42%",purchase:"158 64% 52%"},preview:["#0ea5e9","#14b8a6","#22c55e","#10b981"]},{name:"Sunset",colors:{orientation:"38 92% 50%",problem_recognition:"24 95% 53%",evaluation:"12 91% 55%",purchase:"0 72% 51%"},preview:["#f59e0b","#f97316","#ef4444","#dc2626"]},{name:"Royal",colors:{orientation:"262 83% 58%",problem_recognition:"291 64% 42%",evaluation:"330 81% 60%",purchase:"346 77% 50%"}
25,preview:["#8b5cf6","#a855f7","#ec4899","#e11d48"]},{name:"Forest",colors:{orientation:"142 71% 45%",problem_recognition:"158 64% 52%",evaluation:"168 76% 36%",purchase:"173 80% 40%"},preview:["#22c55e","#10b981","#0d9488","#14b8a6"]},{name:"Neon",colors:{orientation:"180 100% 50%",problem_recognition:"280 100% 70%",evaluation:"330 100% 71%",purchase:"45 100% 51%"},preview:["#00ffff","#bf7fff","#ff69b4","#ffc107"]},{name:"Monochrome",colors:{orientation:"220 9% 46%",problem_recognition:"220 9% 36%",evaluation:"220 9% 26%",purchase:"220 9% 16%"},preview:["#6b7280","#4b5563","#374151","#1f2937"]},{name:"Warm",colors:{orientation:"32 95% 44%",problem_recognition:"21 90% 48%",evaluation:"0 74% 42%",purchase:"350 89% 38%"},preview:["#d97706","#ea580c","#b91c1c","#be123c"]}].map(s=>e.jsxs("button",{onClick:()=>{vt(s.colors.orientation),jt(s.colors.problem_recognition),bt(s.colors.evaluation),yt(s.colors.purchase)},className:"p-3 rounded-lg border border-border hover:border-primary/50 transition-all hover:scale-105 bg-card/50 hover:bg-card",children:[e.jsx("div",{className:"flex gap-1 mb-2 justify-center",children:s.preview.map((c,K)=>e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/10",style:{backgroundColor:c}},K))}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name})]},s.name))})]}),wr.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{className:"text-sm font-medium",children:"Mijn Opgeslagen Presets"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:wr.map(s=>e.jsxs("div",{className:"relative group p-3 rounded-lg border border-border hover:border-primary/50 transition-all bg-card/50 hover:bg-card",children:[e.jsxs("button",{onClick:()=>Gi(s),className:"w-full",children:[e.jsxs("div",{className:"flex gap-1 mb-2 justify-center",children:[e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/10",style:{backgroundColor:Wt(s.orientation_color)}}),e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/10",style:{backgroundColor:Wt(s.problem_recognition_color)}}),e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/10",style:{backgroundColor:Wt(s.evaluation_color)}}),e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/10",style:{backgroundColor:Wt(s.purchase_color)}})]}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name})]}),e.jsx("button",{onClick:c=>{c.stopPropagation(),Ri(s.id,s.name)},className:"absolute -top-2 -right-2 w-5 h-5 bg-destructive text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx(zs,{className:"w-3 h-3"})})]},s.id))})]}),e.jsx("div",{className:"space-y-3",children:Fi?e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(b,{className:"text-sm",children:"Preset Naam"}),e.jsx(q,{value:Nr,onChange:s=>kr(s.target.value),placeholder:"Bijv. Mijn Kleurschema",className:"h-9"})]}),e.jsxs(p,{size:"sm",onClick:$i,disabled:Cr||!Nr.trim(),children:[e.jsx(Is,{className:"w-4 h-4 mr-1"}),Cr?"Opslaan...":"Opslaan"]}),e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>{Sr(!1),kr("")},children:e.jsx(zs,{className:"w-4 h-4"})})]}):e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>Sr(!0),className:"w-full md:w-auto",children:[e.jsx(la,{className:"w-4 h-4 mr-2"}),"Huidige kleuren opslaan als preset"]})}),e.jsx("div",{className:"border-t pt-4"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(as,{label:"Oriëntatie",hslValue:Na,onChange:vt,description:"Eerste fase: bezoeker oriënteert zich"}),e.jsx(as,{label:"Probleem Herkenning",hslValue:ka,onChange:jt,description:"Tweede fase: bezoeker herkent probleem"}),e.jsx(as,{label:"Evaluatie",hslValue:Sa,onChange:bt,description:"Derde fase: bezoeker vergelijkt opties"}),e.jsx(as,{label:"Aankoop",hslValue:Ca,onChange:yt,description:"Laatste fase: klaar om te kopen"})]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsx(p,{onClick:Il,disabled:Aa,children:Aa?"Opslaan...":"Fase Kleuren Opslaan"}),e.jsxs(p,{onClick:Tl,variant:"outline",disabled:Aa,children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Reset naar Standaard"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deze kleuren worden gebruikt in: Klantreis grafieken, Intent Analytics, Persona Charts, Journey Funnel en Bezoeker Analytics."})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Homepage Titel"}),e.jsx(Z,{children:"Pas de titel aan die wordt weergegeven in het browser tabblad en op de homepage"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"homepage-title",children:"Pagina Titel"}),e.jsx(q,{id:"homepage-title",type:"text",value:j,onChange:s=>I(s.target.value),placeholder:"Bijv. Lumen"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deze titel wordt weergegeven in het browser tabblad en als hoofdtitel op de homepage"})]}),e.jsx(p,{onClick:Qi,disabled:Ce,children:Ce?"Opslaan...":"Titel Opslaan"})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Favicon"}),e.jsx(Z,{children:"Upload een favicon dat wordt weergegeven in het browser tabblad"})]}),e.jsxs(G,{className:"space-y-4",children:[N&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 border-2 border-border overflow-hidden bg-card rounded",children:e.jsx("img",{src:N,alt:"Current favicon",className:"w-full h-full object-cover"})}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:Wi,disabled:d,children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Verwijder Favicon"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"favicon",children:"Upload Nieuw Favicon"}),e.jsx(q,{id:"favicon",type:"file",accept:"image/*",onChange:Hi,disabled:B}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"PNG, JPG, ICO of SVG (optimaal 32x32 of 64x64 pixels)"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Homepage Logo"}),e.jsx(Z,{children:"Upload een logo dat wordt weergegeven op de homepage"})]}),e.jsxs(G,{className:"space-y-4",children:[g&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-full border-2 border-border overflow-hidden bg-card",children:e.jsx("img",{src:g,alt:"Current logo",className:"w-full h-full object-cover"})}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:Ji,disabled:d,children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Verwijder Logo"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"logo",children:"Upload Nieuw Logo"}),e.jsx(q,{id:"logo",type:"file",accept:"image/*",onChange:qi,disabled:me}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"PNG, JPG, WEBP of SVG (max 2MB)"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Login Pagina Logo"}),e.jsx(Z,{children:"Upload een apart logo specifiek voor de login pagina. Als geen logo is ingesteld, wordt het homepage logo gebruikt."})]}),e.jsxs(G,{className:"space-y-4",children:[u?e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-border overflow-hidden bg-card",children:e.jsx("img",{src:u,alt:"Login logo",className:"w-full h-full object-contain"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Specifiek login logo actief"}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:Bi,disabled:d,children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Verwijder Login Logo"]})]})]}):g?e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/50 border border-border",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg border border-border overflow-hidden bg-card",children:e.jsx("img",{src:g,alt:"Fallback logo",className:"w-full h-full object-contain opacity-60"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Gebruikt homepage logo als fallback"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload een apart logo om dit te overschrijven"})]})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"login-logo",children:"Upload Login Logo"}),e.jsx(q,{id:"login-logo",type:"file",accept:"image/*",onChange:Ui,disabled:ue}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"PNG, JPG, WEBP of SVG (max 2MB)"})]})]})]}),l&&e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Founder Foto (John Wallbrink)"}),e.jsxs(Z,{children:['Upload een foto voor de "Achter de schermen" sectie op de homepage.',e.jsx("br",{}),e.jsx("span",{className:"text-primary font-medium",children:"Aanbevolen formaat: 3:4 verhouding (bijv. 600x800 pixels)"})]})]}),e.jsxs(G,{className:"space-y-4",children:[D&&e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-32 h-40 rounded-lg border-2 border-border overflow-hidden bg-card",children:e.jsx("img",{src:`${D}?t=${Date.now()}`,alt:"Founder foto",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Huidige foto geladen"}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:Cl,disabled:d,children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Verwijder Foto"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"founder-photo",children:"Upload Nieuwe Foto"}),e.jsx(q,{id:"founder-photo",type:"file",accept:"image/*",onChange:Sl,disabled:F}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"PNG, JPG of WEBP. Crop de foto zelf naar 3:4 verhouding voordat je uploadt."})]})]})]}),l&&e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Lumen Brain Video"}),e.jsxs(Z,{children:['Voer een Vimeo video URL in voor de "Lumen Brain" sectie op de homepage.',e.jsx("br",{}),e.jsx("span",{className:"text-primary font-medium",children:"De video zal automatisch loopen zonder geluid."})]})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"lumen-brain-url",children:"Vimeo Video URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{id:"lumen-brain-url",type:"url",placeholder:"https://vimeo.com/123456789",value:re||"",onChange:s=>pe(s.target.value),className:"flex-1"}),e.jsxs(p,{onClick:async()=>{try{const{data:{user:s}}=await o.auth.getUser();if(!s)return;await o.from("profiles").update({lumen_brain_image_url:re}).eq("id",de||s.id),C({title:"Vimeo URL opgeslagen",description:"De video URL is succesvol opgeslagen!"})}catch(s){C({title:"Fout bij opslaan",description:"Er ging iets mis bij het opslaan.",variant:"destructive"})}},disabled:!re,children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Opslaan"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plak de volledige Vimeo URL (bijv. https://vimeo.com/123456789)"})]}),re&&re.includes("vimeo")&&(()=>{const s=re.replace("https://vimeo.com/","").split("/"),c=s[0],K=s[1]||"",se=K?`https://player.vimeo.com/video/${c}?h=${K}
25&background=1&autoplay=1&loop=1&muted=1`:`https://player.vimeo.com/video/${c}?background=1&autoplay=1&loop=1&muted=1`;return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Video preview:"}),e.jsx("div",{className:"aspect-video rounded-lg border-2 border-border overflow-hidden bg-card",children:e.jsx("iframe",{src:se,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:async()=>{try{const{data:{user:ne}}=await o.auth.getUser();if(!ne)return;await o.from("profiles").update({lumen_brain_image_url:null}).eq("id",de||ne.id),pe(null),C({title:"Video URL verwijderd",description:"De video URL is succesvol verwijderd."})}catch(ne){C({title:"Fout bij verwijderen",description:"Er ging iets mis bij het verwijderen.",variant:"destructive"})}},children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Verwijder Video URL"]})]})})()]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Lumen Versie"}),e.jsx(Z,{children:"Stel het versienummer in dat rechtsonder in het scherm wordt weergegeven"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"version-number",children:"Versienummer"}),e.jsx(q,{id:"version-number",type:"text",value:f,onChange:s=>V(s.target.value),placeholder:"v1.0.0"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Dit versienummer wordt rechtsonder in het scherm weergegeven"})]}),e.jsx(p,{onClick:Yi,disabled:ie,children:ie?"Opslaan...":"Versie Opslaan"})]})]})]}),e.jsxs(We,{value:"api-keys",className:"space-y-6",children:[e.jsx(ad,{}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"IPinfo.io API Key"}),e.jsx(Z,{children:"Configureer je IPinfo.io API key voor nauwkeurige geolocatie op basis van IP-adressen"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"ipinfo-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"ipinfo-api-key",type:"password",value:xe,onChange:s=>{Ae(s.target.value),Fe(!1)},placeholder:"Voer je IPinfo.io API key in",className:we?"pr-12":""}),we&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor het ophalen van nauwkeurige locatiegegevens (stad, land) op basis van IP-adressen."," ",e.jsx("a",{href:"https://ipinfo.io/signup",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Krijg een gratis API key"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:Zi,disabled:te||!xe,variant:"outline",children:te?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:Xi,disabled:z,children:z?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Google Gemini API Key"}),e.jsx(Z,{children:"Configureer je Google Gemini API key voor AI-functionaliteit"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"gemini-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"gemini-api-key",type:"password",value:M,onChange:s=>{Te(s.target.value),Ie(!1)},placeholder:"Voer je Gemini API key in",className:Pe?"pr-12":""}),Pe&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor AI-functionaliteit met Google Gemini."," ",e.jsx("a",{href:"https://ai.google.dev/gemini-api/docs/api-key",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Krijg een API key"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"gemini-text-model",children:"Tekst Model (Website Scans)"}),e.jsxs(os,{value:ms,onValueChange:Ge,children:[e.jsx(cs,{id:"gemini-text-model",children:e.jsx(ds,{placeholder:"Selecteer een tekst model"})}),e.jsxs(us,{className:"bg-card border-border z-50",children:[e.jsx(U,{value:"gemini-3-pro-preview",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsx("span",{children:"Gemini 3 Pro Preview"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~3.99s ~$0.00
2572/min"})]})}),e.jsx(U,{value:"gemini-3-flash-preview",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Gemini 3 Flash Preview"}),e.jsx("span",{className:"text-xs bg-primary/20 text-primary px-1.5 py-0.5 rounded",children:"New"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~1.22s ~$0.0018/min"})]})}),e.jsx(U,{value:"gemini-2.5-flash",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsx("span",{children:"Gemini 2.5 Flash"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~702ms ~$0.0005/min"})]})}),e.jsx(U,{value:"gemini-2.5-flash-lite",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsx("span",{children:"Gemini 2.5 Flash Lite"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~473ms ~$0.0003/min"})]})}),e.jsx(U,{value:"gemini-2.5-flash",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsx("span",{children:"Gemini 2.0 Flash"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~552ms ~$0.0003/min"})]})}),e.jsx(U,{value:"gemini-2.5-flash-lite",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-4",children:[e.jsx("span",{children:"Gemini 2.0 Flash Lite"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"~465ms ~$0.0003/min"})]})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Dit model wordt gebruikt voor website scans en tekst-analyse."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"gemini-model",children:"Afbeelding Model"}),e.jsxs(os,{value:Le,onValueChange:Qe,children:[e.jsx(cs,{id:"gemini-model",children:e.jsx(ds,{placeholder:"Selecteer een model"})}),e.jsxs(us,{className:"bg-card border-border z-50",children:[e.jsx(U,{value:"gemini-3.1-flash-image-preview",children:"Nano Banana 2 (aanbevolen)"}),e.jsx(U,{value:"gemini-3-pro-image-preview",children:"Nano Banana Pro"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Dit model wordt gebruikt voor het genereren van afbeeldingen bij AI templates."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:sl,disabled:Ve||!M,variant:"outline",children:Ve?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:el,disabled:Me,children:Me?"Opslaan...":"Instellingen Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"OpenAI API Key"}),e.jsx(Z,{children:"Configureer je OpenAI API key voor AI-functionaliteit"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"openai-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"openai-api-key",type:"password",value:De,onChange:s=>{rs(s.target.value),x(!1)},placeholder:"Voer je OpenAI API key in",className:h?"pr-12":""}),h&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor AI-functionaliteit met OpenAI modellen."," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Krijg een API key"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:dl,disabled:hs||!De,variant:"outline",children:hs?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:Xr,disabled:Ue,children:Ue?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"OpenAI Admin API Key"]}),e.jsx(Z,{children:"Configureer je OpenAI Admin API key om kosten en gebruik op te halen vanuit het OpenAI dashboard"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"openai-admin-api-key",children:"Admin API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"openai-admin-api-key",type:"password",value:qs,onChange:s=>{ls(s.target.value),Tt(!1)},placeholder:"sk-admin-...",className:wn?"pr-12":""}),wn&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt om kostenoverzichten op te halen uit het OpenAI dashboard."," ",e.jsx("a",{href:"https://platform.openai.com/settings/organization/admin-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Maak een Admin API key aan"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:kl,disabled:yn||!qs,variant:"outline",children:yn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:Nl,disabled:jn,children:jn?"Opslaan...":"Admin Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Claude API Key (Anthropic)"]}),e.jsx(Z,{children:"Configureer je Claude API key voor AI-functionaliteit met Anthropic modellen"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"claude-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"claude-api-key",type:"password",value:Et,onChange:s=>{da(s.target.value),Ft(!1)},placeholder:"sk-ant-...",className:An?"pr-12":""}),An&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor AI-functionaliteit met Claude modellen."," ",e.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Maak een API key aan"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:al,disabled:Sn||!Et,variant:"outline",children:Sn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:tl,disabled:Nn,children:Nn?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Grok API Key (xAI)"]}),e.jsx(Z,{children:"Configureer je Grok API key voor AI-functionaliteit met xAI modellen in de Lumen AI Hub"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"grok-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"grok-api-key",type:"password",value:Mt,onChange:s=>{lr(s.target.value),Vt(!1)},placeholder:"xai-...",className:mr?"pr-12":""}),mr&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor AI-functionaliteit met Grok modellen in de Lumen AI Hub."," ",e.jsx("a",{href:"https://console.x.ai/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Maak een API key aan bij xAI"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:rl,disabled:dr||!Mt,variant:"outline",children:dr?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:nl,disabled:or,children:or?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(Ws,{className:"h-5 w-5 text-primary"}),"Perplexity API"]}),e.jsx(Z,{children:"Configureer je Perplexity API voor AI-powered zoekfunctionaliteit"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"perplexity-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"perplexity-api-key",type:"password",value:zt,onCh
25ange:s=>{hr(s.target.value),ga(!1)},placeholder:"pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:vr?"pr-12":""}),vr&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Verkrijg je API key via"," ",e.jsx("a",{href:"https://www.perplexity.ai/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"perplexity.ai/settings/api"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:ll,disabled:gr||!zt,variant:"outline",children:gr?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:il,disabled:pr,children:pr?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Mailgun API"]}),e.jsx(Z,{children:"Configureer je Mailgun API voor het versturen van e-mails"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"mailgun-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"mailgun-api-key",type:"password",value:ut,onChange:s=>{ua(s.target.value),ht(!1)},placeholder:"key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:Fn?"pr-12":""}),Fn&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"mailgun-domain",children:"Domain"}),e.jsx(q,{id:"mailgun-domain",type:"text",value:mt,onChange:s=>{ma(s.target.value),ht(!1)},placeholder:"mg.yourdomain.com"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Je Mailgun domain (bijv. mg.yourdomain.com of sandbox domain)."," ",e.jsx("a",{href:"https://app.mailgun.com/settings/api_security",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Bekijk je API keys in Mailgun"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:cl,disabled:Tn||!ut||!mt,variant:"outline",children:Tn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:ol,disabled:Pn||!ut||!mt,children:Pn?"Opslaan...":"Instellingen Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Higgsfield AI API"]}),e.jsx(Z,{children:"Configureer je Higgsfield AI API voor video- en beeldgeneratie"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"higgsfield-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"higgsfield-api-key",type:"password",value:As,onChange:s=>{pt(s.target.value),Qs(!1)},placeholder:"Voer je Higgsfield API key in",className:Kn?"pr-12":""}),Kn&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"higgsfield-api-secret",children:"API Secret"}),e.jsx(q,{id:"higgsfield-api-secret",type:"password",value:Ps,onChange:s=>{xt(s.target.value),Qs(!1)},placeholder:"Voer je Higgsfield API secret in"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"higgsfield-image-model",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Afbeelding Model (Text-to-Image)",Ot&&e.jsx(he,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsxs(os,{value:Dn,onValueChange:ha,children:[e.jsx(cs,{id:"higgsfield-image-model",children:e.jsx(ds,{placeholder:Ot?"Modellen laden...":"Selecteer een image model"})}),e.jsx(us,{className:"bg-card border-border z-50 max-h-[400px]",children:Dt.length>0?e.jsx(e.Fragment,{children:["higgsfield","bytedance","flux","ideogram","stability","google","reve"].map(s=>{const c=Dt.filter(se=>se.category===s);if(c.length===0)return null;const K={higgsfield:"⭐ Higgsfield",bytedance:"ByteDance Seedream",flux:"FLUX",ideogram:"Ideogram",stability:"Stability AI",google:"Google Imagen",reve:"Reve"};return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border",children:K[s]||s}),c.map(se=>e.jsx(U,{value:se.id,children:se.name},se.id))]},s)})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{value:"higgsfield-ai/soul/standard",children:"⭐ Soul Standard (Higgsfield Flagship)"}),e.jsx(U,{value:"bytedance/seedream/v4/text-to-image",children:"Seedream V4 Text-to-Image"}),e.jsx(U,{value:"reve/text-to-image",children:"Reve Text-to-Image"}),e.jsx(U,{value:"flux/1.1-pro",children:"FLUX 1.1 Pro"})]})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:Dt.length>0?`${Dt.length} modellen geladen via Higgsfield API`:"Voer API credentials in om modellen te laden"}),As&&Ps&&e.jsxs(p,{variant:"ghost",size:"sm",onClick:Yr,disabled:Ot,className:"text-xs h-6 px-2",children:[Ot?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(aa,{className:"h-3 w-3"}),e.jsx("span",{className:"ml-1",children:"Vernieuwen"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"higgsfield-video-model",className:"flex items-center gap-2",children:[e.jsx(uo,{className:"h-4 w-4"}),"Video Model"]}),e.jsxs(os,{value:On,onValueChange:pa,children:[e.jsx(cs,{id:"higgsfield-video-model",children:e.jsx(ds,{placeholder:"Selecteer een video model"})}),e.jsxs(us,{className:"bg-card border-border z-50 max-h-[400px]",children:[e.jsx(U,{value:"higgsfield-ai/soul/standard",children:"Soul Standard - Flagship"}),e.jsx(U,{value:"higgsfield-ai/soul/pro",children:"Soul Pro - Premium kwaliteit"}),e.jsx(U,{value:"kling/v1.6/standard",children:"Kling 1.6 Standard"}),e.jsx(U,{value:"kling/v1.6/pro",children:"Kling 1.6 Pro"}),e.jsx(U,{value:"kling/v1.5/pro",children:"Kling 1.5 Pro"}),e.jsx(U,{value:"kling/v1/standard",children:"Kling 1.0 Standard"}),e.jsx(U,{value:"kling/v1/pro",children:"Kling 1.0 Pro"}),e.jsx(U,{value:"runway/gen3a-turbo",children:"Runway Gen3a Turbo"}),e.jsx(U,{value:"runway/gen3a",children:"Runway Gen3a"}),e.jsx(U,{value:"luma/ray2",children:"Luma Ray 2 - Nieuwste"}),e.jsx(U,{value:"luma/ray2-flash",children:"Luma Ray 2 Flash - Snel"}),e.jsx(U,{value:"luma/dream-machine",children:"Luma Dream Machine 1.5"}),e.jsx(U,{value:"minimax/video-01",children:"Minimax Video-01"}),e.jsx(U,{value:"minimax/video-01-live",children:"Minimax Video-01 Live"}),e.jsx(U,{value:"pika/v2.2",children:"Pika 2.2 - Nieuwste"}),e.jsx(U,{value:"pika/v2.1",children:"Pika 2.1"}),e.jsx(U,{value:"pika/v2",children:"Pika 2.0"}),e.jsx(U,{value:"pika/v1",children:"Pika 1.0"}),e.jsx(U,{value:"veo/veo2",children:"Veo 2 (Google)"}),e.jsx(U,{value:"wan/v2.1",children:"Wan 2.1"}),e.jsx(U,{value:"stability/stable-video",children:"Stable Video Diffusion"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wordt gebruikt voor het genereren van video's in AI templates."})]}),e.jsx("p",{className:"text-sm text-muted-foreground pt-2",children:e.jsx("a",{href:"https://cloud.higgsfield.ai/ex
25plore",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Bekijk alle beschikbare modellen op Higgsfield"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:ml,disabled:zn||!As||!Ps,variant:"outline",children:zn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:ul,disabled:Mn||!As||!Ps,children:Mn?"Opslaan...":"Instellingen Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"BrowserAct API"]}),e.jsx(Z,{children:"Configureer je BrowserAct API voor geavanceerde website scraping (Cloudflare, JavaScript-heavy sites)"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"browseract-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"browseract-api-key",type:"password",value:Ys,onChange:s=>{Gn(s.target.value),Zs(!1)},placeholder:"ba_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:Wn?"pr-12":""}),Wn&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"browseract-workflow-id",children:"Workflow ID"}),e.jsx(q,{id:"browseract-workflow-id",type:"text",value:Xs,onChange:s=>{qn(s.target.value),Zs(!1)},placeholder:"wf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"font-mono"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Maak een "Generic Website Scraper" workflow aan in'," ",e.jsx("a",{href:"https://browseract.com/dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"BrowserAct Dashboard"})," ","met een URL input parameter."]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:pl,disabled:Hn||!Ys||!Xs,variant:"outline",children:Hn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:hl,disabled:Un||!Ys||!Xs,children:Un?"Opslaan...":"Instellingen Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Jina Reader API"]}),e.jsx(Z,{children:"Configureer je Jina Reader API key voor het scrapen van websites (website scans, DeepScan)"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"jina-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"jina-api-key",type:"password",value:et,onChange:s=>{xa(s.target.value),gt(!1)},placeholder:"jina_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:er?"pr-12":""}),er&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor het scrapen van websites tijdens scans en DeepScan analyses."," ",e.jsx("a",{href:"https://jina.ai/reader",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Krijg een API key bij Jina AI"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:gl,disabled:Xn||!et,variant:"outline",children:Xn?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:xl,disabled:Qn||!et,children:Qn?"Opslaan...":"API Key Opslaan"})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-5 w-5 text-primary"}),"Apify API"]}),e.jsx(Z,{children:"Configureer je Apify API key voor web scraping en automatisering"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"apify-api-key",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"apify-api-key",type:"password",value:st,onChange:s=>{sr(s.target.value),ft(!1)},placeholder:"apify_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:ir?"pr-12":""}),ir&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deze key wordt gebruikt voor geavanceerde web scraping en automatisering taken."," ",e.jsx("a",{href:"https://console.apify.com/account/integrations",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Krijg een API key bij Apify"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:vl,disabled:nr||!st,variant:"outline",children:nr?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:fl,disabled:tr||!st,children:tr?"Opslaan...":"API Key Opslaan"})]})]})]})]}),e.jsxs(We,{value:"ai",className:"space-y-6",children:[e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"OpenAI Model"}),e.jsx(Z,{children:"Selecteer welk AI model gebruikt wordt voor analyses"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"openai-model",children:"Model"}),e.jsxs(os,{value:ts,onValueChange:is,children:[e.jsx(cs,{id:"openai-model",children:e.jsx(ds,{placeholder:"Selecteer een model"})}
25),e.jsxs(us,{children:[e.jsx(U,{value:"gpt-5-2025-08-07",children:"GPT-5 (Flagship - Krachtigste)"}),e.jsx(U,{value:"gpt-5-mini-2025-08-07",children:"GPT-5 Mini (Sneller & goedkoper)"}),e.jsx(U,{value:"gpt-5-nano-2025-08-07",children:"GPT-5 Nano (Snelst & goedkoopst)"}),e.jsx(U,{value:"gpt-4.1-2025-04-14",children:"GPT-4.1 (Betrouwbaar)"}),e.jsx(U,{value:"gpt-4.1-mini-2025-04-14",children:"GPT-4.1 Mini (Vision support)"}),e.jsx(U,{value:"o3-2025-04-16",children:"O3 (Krachtige reasoning)"}),e.jsx(U,{value:"o4-mini-2025-04-16",children:"O4 Mini (Snelle reasoning)"}),e.jsx(U,{value:"gpt-4o",children:"GPT-4o (Legacy - Vision)"}),e.jsx(U,{value:"gpt-4o-mini",children:"GPT-4o Mini (Legacy - Snel)"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Kies het AI model dat gebruikt wordt voor analyses"})]}),e.jsx(p,{onClick:Xr,disabled:Ue,children:Ue?"Opslaan...":"Model Opslaan"})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Website Scan Prompt"}),e.jsx(Z,{children:"Configureer de AI prompt die wordt gebruikt voor de website scan functionaliteit"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"website-scan-prompt",children:"Analyse Prompt"}),e.jsx(It,{id:"website-scan-prompt",value:O,onChange:s=>oe(s.target.value),placeholder:"Voer de AI prompt in voor website analyse...",rows:8,className:"font-mono text-sm"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deze prompt bepaalt hoe de AI websites analyseert. Specificeer welke frameworks, aspecten en details je wilt zien in de scan resultaten."})]}),e.jsx(p,{onClick:bl,disabled:S||!O,children:S?"Opslaan...":"Prompt Opslaan"})]})]}),e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ri,{className:"w-5 h-5 text-primary"}),e.jsx(Q,{children:"Lumen Assistent Prompt"})]}),e.jsx(Z,{children:"Configureer de systeem prompt die de Lumen Assistent aanstuurt"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"lumen-chatwidget-prompt",children:"Systeem Prompt"}),e.jsx(It,{id:"lumen-chatwidget-prompt",value:_,onChange:s=>E(s.target.value),placeholder:`Voer de systeem prompt in die de Lumen Assistent aanstuurt...
26
27Bijvoorbeeld:
28Je bent Lumen, een vriendelijke AI assistent die bezoekers helpt met vragen over ons platform. Je geeft duidelijke en behulpzame antwoorden op basis van de beschikbare kennisbank.`,rows:10,className:"font-mono text-sm"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deze prompt bepaalt de persoonlijkheid en het gedrag van de Lumen Assistent. Beschrijf hoe de AI moet reageren en welke informatie hij moet gebruiken."})]}),e.jsx(p,{onClick:yl,disabled:ve,children:ve?"Opslaan...":"Prompt Opslaan"})]})]}),e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"w-5 h-5 text-primary"}),e.jsx(Q,{children:"OpenAI Kennisbank (Assistant)"})]}),e.jsx(Z,{children:"Koppel een OpenAI Assistant voor de kennisbank functionaliteit"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"openai-assistant-id",children:"OpenAI Assistant ID"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"openai-assistant-id",type:"text",value:Ee,onChange:s=>{r(s.target.value),Cs(!1)},placeholder:"asst_xxxxxxxxxxxxxxxxxxxxxxxx",className:`font-mono ${Gs?"pr-12":""}`}),Gs&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Maak een Assistant aan in de"," ",e.jsx("a",{href:"https://platform.openai.com/assistants",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Playground"})," ","en upload daar je kennisbank documenten (PDF's, Word bestanden, etc.). Kopieer vervolgens de Assistant ID hieronder."]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Zo werkt de kennisbank:"}),e.jsxs("ol",{className:"text-sm text-muted-foreground space-y-1 list-decimal list-inside",children:[e.jsxs("li",{children:["Ga naar ",e.jsx("a",{href:"https://platform.openai.com/assistants",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"platform.openai.com/assistants"})]}),e.jsx("li",{children:"Maak een nieuwe Assistant aan"}),e.jsx("li",{children:"Upload je documenten naar de Assistant (kennisbank)"}),e.jsx("li",{children:"Kopieer de Assistant ID en plak deze hierboven"}),e.jsx("li",{children:"De Lumen Assistent kan nu vragen beantwoorden op basis van je documenten"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{onClick:wl,disabled:Ke||!Ee||!De,variant:"outline",children:Ke?"Testen...":"Test Verbinding"}),e.jsx(p,{onClick:_l,disabled:$||!Ee,children:$?"Opslaan...":"Assistant ID Opslaan"})]})]})]}),e.jsxs(R,{className:"border-blue-500/20",children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"w-5 h-5 text-blue-500"}),e.jsx(Q,{children:"Word Editor Pro - License Key"})]}),e.jsx(Z,{children:"Configureer je Syncfusion Community License voor de Word Editor Pro"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"syncfusion-license-key",children:"License Key"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"syncfusion-license-key",type:"password",value:tt,onCh
28ange:s=>{fa(s.target.value),Lt(!1)},placeholder:"Voer je Syncfusion license key in",className:`font-mono ${yr?"pr-12":""}`}),yr&&e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx(Ne,{className:"w-4 h-4 text-green-500"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:e.jsx("a",{href:"https://www.syncfusion.com/products/communitylicense",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Vraag een gratis Community License aan"})})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 space-y-2",children:[e.jsxs("h4",{className:"font-medium text-sm flex items-center gap-2",children:[e.jsx("span",{className:"h-6 w-6 rounded bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center text-white text-xs",children:"W"}),"Word Editor Pro Features:"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Native DOCX import en export"}),e.jsx("li",{children:"Track Changes voor samenwerking"}),e.jsx("li",{children:"Comments en annotaties"}),e.jsx("li",{children:"Headers, footers en paginanummering"}),e.jsx("li",{children:"Tabellen, afbeeldingen en hyperlinks"}),e.jsx("li",{children:"95% Microsoft Word compatibiliteit"})]})]}),e.jsx(p,{onClick:jl,disabled:jr||!tt,children:jr?"Opslaan...":"License Key Opslaan"})]})]})]}),l&&e.jsxs(We,{value:"colors",className:"space-y-6",children:[e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{className:"w-5 h-5 text-primary"}),e.jsx(Q,{children:"Platform Kleuren"})]}),e.jsx(Z,{children:"Beheer de kleuren van het hele platform. Gebruik de color picker of voer HSL waarden direct in."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(as,{label:"Primary Color",hslValue:va,onChange:Kt,description:"Hoofdkleur voor belangrijke elementen"}),e.jsx(as,{label:"Secondary Color",hslValue:ja,onChange:$t,description:"Secundaire accentkleur"}),e.jsx(as,{label:"Accent Color",hslValue:ba,onChange:Rt,description:"Extra accentkleur voor highlights"}),e.jsx(as,{label:"Background Color",hslValue:ya,onChange:Gt,description:"Hoofdachtergrondkleur"}),e.jsx(as,{label:"Foreground Color",hslValue:_a,onChange:qt,description:"Primaire tekstkleur"}),e.jsx(as,{label:"Card Color",hslValue:wa,onChange:Ut,description:"Achtergrondkleur voor kaarten"}),e.jsx(as,{label:"Muted Color",hslValue:Pa,onChange:Bt,description:"Gedempte achtergrondkleur"}),e.jsx(as,{label:"Border Color",hslValue:Ia,onChange:Ht,description:"Kleur voor randen en dividers"}),e.jsx(as,{label:"Destructive Color",hslValue:Ta,onChange:Jt,description:"Kleur voor waarschuwingen en verwijderen"})]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsx(p,{onClick:Al,disabled:Ea,children:Ea?"Opslaan...":"Kleuren Opslaan"}),e.jsxs(p,{onClick:Pl,variant:"outline",disabled:Ea,children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Reset naar standaard"]})]})]})]}),e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Achtergrond Effecten"}),e.jsx(Z,{children:"Schakel de geanimeerde glow effecten op de homepage in of uit"})]}),e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"background-enabled",children:"Achtergrond Effecten"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toon de geanimeerde glow effecten op de homepage"})]}),e.jsx(be,{id:"background-enabled",checked:$r,onCheckedChange:Ha})]})})]})]}),l&&e.jsx(We,{value:"countdown",className:"space-y-6",children:e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"w-5 h-5 text-primary"}),e.jsx(Q,{children:"Countdown Timer"})]}),e.jsx(Z,{children:"Configureer een countdown timer die bovenaan de homepage wordt weergegeven"})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Timer Actief"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schakel de countdown timer in of uit"})]}),e.jsx(be,{checked:Pr,onCheckedChange:Fa})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-title",children:"Titel"}),e.jsx(q,{id:"countdown-title",value:Ir,onChange:s=>Da(s.target.value),placeholder:"Bijv. Nog maar beperkte tijd!"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-end-date",children:"Einddatum en tijd"}),e.jsx(q,{id:"countdown-end-date",type:"datetime-local",value:Oa,onChange:s=>Ma(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-style",children:"Stijl"}),e.jsxs(os,{value:Or,onValueChange:s=>$a(s),children:[e.jsx(cs,{id:"countdown-style",children:e.jsx(ds,{placeholder:"Selecteer stijl"})}),e.jsxs(us,{children:[e.jsx(U,{value:"modern",children:"Modern (met kaarten)"}),e.jsx(U,{value:"classic",children:"Klassiek"}),e.jsx(U,{value:"minimal",children:"Minimaal (één regel)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"countdown-size",children:["Grootte: ",Ua,"%"]}),e.jsx(Xe,{id:"countdown-size",value:[Ua],onValueChange:s=>Ba(s[0]),min:50,max:150,step:10,className:"w-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pas de grootte van de countdown timer aan (50% - 150%)"})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsx("h4",{className:"font-medium",children:"Labels"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-label-days",children:"Dagen"}
28),e.jsx(q,{id:"countdown-label-days",value:Tr,onChange:s=>Va(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-label-hours",children:"Uren"}),e.jsx(q,{id:"countdown-label-hours",value:Er,onChange:s=>za(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-label-minutes",children:"Minuten"}),e.jsx(q,{id:"countdown-label-minutes",value:Fr,onChange:s=>La(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"countdown-label-seconds",children:"Seconden"}),e.jsx(q,{id:"countdown-label-seconds",value:Dr,onChange:s=>Ka(s.target.value)})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsx("h4",{className:"font-medium",children:"Kleuren (HSL formaat)"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(as,{label:"Achtergrond",hslValue:Mr,onChange:Ra,description:"Timer achtergrond"}),e.jsx(as,{label:"Tekst",hslValue:Vr,onChange:Ga,description:"Tekstkleur"}),e.jsx(as,{label:"Accent",hslValue:zr,onChange:qa,description:"Cijfers kleur"})]})]}),e.jsx(p,{onClick:El,disabled:Lr,className:"w-full",children:Lr?"Opslaan...":"Countdown Timer Opslaan"})]})]})}),l&&e.jsx(We,{value:"login",className:"space-y-6",children:e.jsxs(R,{className:"border-primary/20",children:[e.jsxs(J,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(ii,{className:"h-5 w-5 text-primary"}),"Authenticatie Instellingen"]}),e.jsx(Z,{children:"Beheer de login en registratie instellingen voor je applicatie."})]}),e.jsxs(G,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Aanmelden toestaan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Wanneer uitgeschakeld kunnen nieuwe gebruikers zich niet registreren."})]}),e.jsx(be,{checked:Di,onCheckedChange:async s=>{Gr(!0);try{if(!de){C({title:"Fout",description:"Profiel niet gevonden",variant:"destructive"});return}const{error:c}=await o.from("profiles").update({signup_enabled:s}).eq("id",de);if(c)throw c;Rr(s),localStorage.removeItem("app_settings_cache_v3"),C({title:"Opgeslagen",description:s?"Nieuwe gebruikers kunnen zich nu registreren":"Registratie is uitgeschakeld"})}catch(c){C({title:"Fout",description:"Kon instelling niet opslaan",variant:"destructive"})}finally{Gr(!1)}},disabled:Oi})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Logo tonen op login pagina"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Wanneer ingeschakeld wordt het logo getoond in de hero sectie van de login pagina."})]}),e.jsx(be,{checked:Mi,onCheckedChange:async s=>{Ur(!0);try{if(!de){C({title:"Fout",description:"Profiel niet gevonden",variant:"destructive"});return}const{error:c}=await o.from("profiles").update({show_logo_on_login:s}).eq("id",de);if(c)throw c;qr(s),localStorage.removeItem("app_settings_cache_v3"),C({title:"Opgeslagen",description:s?"Logo wordt nu getoond op de login pagina":"Logo wordt nu verborgen op de login pagina"})}catch(c){C({title:"Fout",description:"Kon instelling niet opslaan",variant:"destructive"})}finally{Ur(!1)}},disabled:Vi})]}),e.jsxs("div",{className:"p-4 border rounded-lg space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(b,{className:"text-base font-medium",children:"Onderhoudsmodus"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Wanneer ingeschakeld is de website niet bereikbaar voor gebruikers. Alleen super admins kunnen inloggen."})]}),e.jsx(be,{checked:Br,onCheckedChange:async s=>{Jr(!0);try{if(!de){C({title:"Fout",description:"Profiel niet gevonden",variant:"destructive"});return}const{error:c}=await o.from("profiles").update({maintenance_mode:s}).eq("id",de);if(c)throw c;Hr(s),localStorage.removeItem("app_settings_cache_v3"),C({title:"Opgeslagen",description:s?"Onderhoudsmodus is ingeschakeld — de website is nu geblokkeerd voor gebruikers":"Onderhoudsmodus is uitgeschakeld — de website is weer bereikbaar"})}catch(c){C({title:"Fout",description:"Kon instelling niet opslaan",variant:"destructive"})}finally{Jr(!1)}},disabled:zi})]}),Br&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"text-sm font-medium",children:"Onderhoudsbericht (optioneel)"}),e.jsx("textarea",{className:"w-full p-3 border rounded-lg bg-background text-foreground text-sm resize-none",rows:2,placeholder:"We zijn bezig met onderhoudswerkzaamheden. Probeer het later opnieuw.",value:Wr,onChange:s=>Qr(s.target.value),onBlur:async()=>
28{if(de)try{await o.from("profiles").update({maintenance_message:Wr||null}).eq("id",de),localStorage.removeItem("app_settings_cache_v3")}catch(s){}}})]})]})]})]})}),e.jsx(We,{value:"push",className:"space-y-6",children:e.jsx(cc,{userId:de})}),l&&e.jsx(We,{value:"cronjobs",className:"space-y-6",children:e.jsx(ec,{})}),l&&e.jsx(We,{value:"youtube",className:"space-y-6",children:e.jsx(uc,{})}),l&&e.jsx(We,{value:"nieuws",className:"space-y-6",children:e.jsx(Gc,{})}),l&&e.jsx(We,{value:"payments",className:"space-y-6",children:e.jsx(td,{brandProfileId:de})}),l&&e.jsx(We,{value:"database",className:"space-y-6",children:e.jsxs(R,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Database Schema Dump"}),e.jsx(Z,{children:"Download een complete SQL dump van alle tabellen, RLS policies, functions, triggers en indexes."})]}),e.jsx(G,{children:e.jsx(Io,{})})]})}),l&&e.jsx(We,{value:"migration",className:"space-y-6",children:e.jsx(rd,{})})]})]})})};export{Md 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.