1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C7UdPtST.js","assets/vendor-ui-DsKmQING.js","assets/vendor-react-CVjhXiGk.js","assets/vendor-utils-ICtsnra3.js","assets/index-1JkZwIA3.css"])))=>i.map(i=>d[i]); 2var Fe=Object.defineProperty;var r=(n,l)=>Fe(n,"name",{value:l,configurable:!0});import{u as pe,v as je,L as We,g as ze,_ as Ke}from"./index-C7UdPtST.js";import{j as e,X as oe,bQ as Oe,bR as we,l as Ne,aC as Ce,a8 as Pe,M as Ve,bP as Ge,b8 as He,T as Ue,a1 as _e,a0 as Se,bn as Be,C as Ie,k as Re,V as Je,H as Qe,F as Me,bS as $e}from"./vendor-ui-DsKmQING.js";import{r as i,b as Ze,R as fe}from"./vendor-react-CVjhXiGk.js";import{l as Ee,m as qe}from"./vendor-utils-ICtsnra3.js";const ke=[{id:"mon",label:"M"},{id:"tue",label:"D"},{id:"wed",label:"W"},{id:"thu",label:"D"},{id:"fri",label:"V"},{id:"sat",label:"Z"},{id:"sun",label:"Z"}],Xe=["1e","2e","3e","4e","Laatste"];function Le({onClose:n,checklist:l,preselectedAdAccount:f,facebookAccounts:M=[]}){const{adAccounts:_,createChecklist:I,updateChecklist:te,user:S,companyUsers:k,companies:u,currentCompany:G}=pe(),[g,ie]=i.useState((l==null?void 0:l.title)||""),[x,E]=i.useState((l==null?void 0:l.platform)||"facebook"),[W,ye]=i.useState((l==null?void 0:l.ad_account)||f||""),[v,H]=i.useState(()=>l!=null&&l.ad_account?[l.ad_account]:f?[f]:[]),[U,B]=i.useState(""),[C,de]=i.useState(l!=null&&l.items&&Array.isArray(l.items)?l.items.map(t=>t.content):[""]),[b,j]=i.useState((l==null?void 0:l.refresh_interval)||"never"),[ae,L]=i.useState(new Set),[ce,q]=i.useState("1e"),[X,z]=i.useState(ke[0].id),[R,K]=i.useState(!1),[T,J]=i.useState(()=>{const t=localStorage.getItem(`user_selected_accounts_${S==null?void 0:S.id}`);return t?JSON.parse(t):[]}),[w,xe]=i.useState(()=>{if(l&&l.title){const t=l.title.toLowerCase();if(t.includes("kpi")||t.includes("metriek"))return"kpi";if(t.includes("campagne")||t.includes("controle")||t.includes("checkup"))return"campaign_control"}return"normal"}),[N,Y]=i.useState(()=>l&&l.title&&(l.title.toLowerCase().includes("kpi")||l.title.toLowerCase().includes("metriek"))?(l.items||[]).map(t=>({metric:t.content||""})):[{metric:""}]),[y,h]=i.useState([]),[re,ue]=i.useState((l==null?void 0:l.is_template)||!1),[D,ee]=i.useState(!1);i.useEffect(()=>{l!=null&&l.ad_account&&!v.includes(l.ad_account)&&H([l.ad_account])},[l==null?void 0:l.ad_account]),i.useEffect(()=>{},[]);const $=x==="facebook"&&M.length>0?M.map(t=>({id:t.id,account_id:t.account_id||t.id,name:t.name,platform:"facebook"})):Array.isArray(_)?_.filter(t=>t.platform===x):[],O=r(t=>{if(!T.includes(t)){const o=[...T,t];J(o),S&&localStorage.setItem(`user_selected_accounts_${S.id}`,JSON.stringify(o))}},"addAccountToUserList"),Z=r((t,o)=>{o.stopPropagation(),W===t&&ye("");const a=T.filter(s=>s!==t);J(a),S&&localStorage.setItem(`user_selected_accounts_${S.id}`,JSON.stringify(a))},"removeAccountFromUserList"),be=r(t=>t.user?t.user.name||t.user.email||"Onbekende gebruiker":t.name||t.email||"Onbekende gebruiker","getUserDisplayName"),ge=r(t=>{const o=t.user||t;return{id:o.id,name:typeof o.name=="string"?o.name:void 0,email:typeof o.email=="string"?o.email:void 0}},"formatUserForSelection"),P=r(()=>{const t=(Array.isArray(k)?k:[]).map(ge);h(t)},"handleSelectAllUsers"),se=r(t=>{const o=ge(t);y.some(a=>a.id===o.id)?h(y.filter(a=>a.id!==o.id)):h([...y,o])},"toggleUserSelection"),le=r(()=>{w==="kpi"?Y([...N,{metric:""}]):de([...C,""])},"handleAddItem"),V=r((t,o)=>{const a=[...C];a[t]=o,de(a)},"handleItemChange"),A=r((t,o)=>{const a=[...N];a[t]={metric:o},Y(a)},"handleKpiMetricChange"),ne=r(t=>{w==="kpi"?N.length>1&&Y(N.filter((o,a)=>a!==t)):C.length>1&&de(C.filter((o,a)=>a!==t))},"handleRemoveItem"),me=r(t=>{const o=new Set(ae);o.has(t)?o.delete(t):o.add(t),L(o)},"toggleWeekDay"),d=r(async()=>{var a;const t=l?[W]:v;if(!g||t.length===0||w!=="kpi"&&C.some(s=>!s.trim())||w==="kpi"&&N.some(s=>!s.metric.trim()))return;t.forEach(s=>{s&&O(s)});const o=(G==null?void 0:G.id)||(u&&u.length>0?(a=u[0])==null?void 0:a.id:null);if(!o){console.error("Geen bedrijf beschikbaar voor het aanmaken van de checklist");return}K(!0);try{let s=[];w==="kpi"?s=N.filter(m=>m.metric.trim()!=="").map(m=>m.metric):s=C.filter(m=>m.trim()!=="");let c=g;if(!l&&g){const m=g.toLowerCase();w==="campaign_control"&&!m.includes("campagne")&&!m.includes("controle")?c=`Campagne controle: ${g}`:w==="kpi"&&!m.includes("kpi")&&!m.includes("metriek")&&(c=`KPI Metrieken: ${g}`)}let p=null;if(b==="weekly"?p={days:Array.from(ae)}:b==="monthly"&&(p={week:ce,day:X}),l){const m={title:c,ad_account:W,platform:x,refresh_interval:b,refresh_settings:p,checklist_type:w,is_template:re,finalItems:s,selectedUsers:y},F=await te(l.id,m)}else{`${t.length}`;let m=0;for(const F of t)try{const he={title:t.length>1?`${c} - ${F}`:c,ad_account:F,platform:x,company_id:o,refresh_interval:b,refresh_settings:p,checklist_type:w,is_template:re,selectedUsers:y};await I(he,s)?(m++,`${m}${t.length}${F}`):console.error(`ChecklistModal: Fout bij aanmaken checklist voor account ${F}`)}catch(he){console.error(`ChecklistModal: Fout bij aanmaken checklist voor account ${F}:`,he)}`${m}${t.length}`}n()}catch(s){console.error("Fout bij het aanmaken van checklist:",s),K(!1)}},"handleSubmit");return i.useEffect(()=>{l!=null&&l.refresh_settings&&(l.refresh_interval==="weekly"&&l.refresh_settings.weekDays&&L(new Set(l.refresh_settings.weekDays)),l.refresh_interval==="monthly"&&(l.refresh_settings.monthWeek&&q(l.refresh_settings.monthWeek),l.refresh_settings.monthDay&&z(l.refresh_settings.monthDay)))},[l]),e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-2xl w-[600px] max-w-[90vw] max-h-[90vh] overflow-auto border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between sticky top-0 bg-white dark:bg-gray-800 z-10",children:[e.jsx("h2",{className:"text-sm font-medium text-gray-900 dark:text-white",children:l?"Checklist bewerken":"Nieuwe Checklist aanmaken"}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(oe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[!l&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Type Checklist"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:r(()=>xe("normal"),"onClick"),className:`flex flex-col items-center justify-center gap-2 p-3 rounded text-sm ${w==="normal"?"border border-black bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white":"border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(Oe,{className:"h-5 w-5"}),e.jsx("span",{children:"Standaard"})]}),e.jsxs("button",{onClick:r(()=>xe("campaign_control"),"onClick"),className:`flex flex-col items-center justify-center gap-2 p-3 rounded text-sm ${w==="campaign_control"?"border border-black bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white":"border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(we,{className:"h-5 w-5"}),e.jsx("span",{children:"Campagne Controle"})]}),e.jsxs("button",{onClick:r(()=>xe("kpi"),"onClick"),className:`flex flex-col items-center justify-center gap-2 p-3 rounded text-sm ${w==="kpi"?"border border-black bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white":"border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(Ne,{className:"h-5 w-5"}),e.jsx("span",{children:"KPI Checklist"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Titel"}),e.jsx("input",{type:"text",value:g,onChange:r(t=>ie(t.target.value),"onChange"),className:"w-full px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white",placeholder:"Titel van checklist"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Platform"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:r(()=>E("facebook"),"onClick"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded text-sm ${x==="facebook"?"border border-black bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white":"border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx("img",{src:"/images/facebookadsicon.svg",alt:"Facebook Ads",className:"w-4 h-4"}),e.jsx("span",{children:"Facebook"})]}),e.jsxs("button",{onClick:r(()=>E("google"),"onClick"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded text-sm ${x==="google"?"border border-black bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white":"border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx("img",{src:"/images/googleadsicon.svg",alt:"Google Ads",className:"w-4 h-4"}),e.jsx("span",{children:"Google"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Advertentie-accounts"}),e.jsxs("div",{className:"space-y-2",children:[$.length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:"select-all-accounts",checked:v.length===$.length&&$.length>0,onChange:r(t=>{t.target.checked?H(Array.isArray($)?$.map(o=>o.account_id):[]):H([])},"onChange"),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsxs("label",{htmlFor:"select-all-accounts",className:"ml-2 text-sm text-gray-700 dark:text-gray-300 font-medium",children:["Alles selecteren (",$.length," accounts)"]})]}),e.jsx("div",{className:"max-h-40 overflow-y-auto space-y-2 border border-gray-200 dark:border-gray-600 rounded p-2",children:$.length===0?e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Geen accounts gevonden voor ",x]}):$.map(t=>e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:`account-${t.account_id}`,checked:v.includes(t.account_id),onChange:r(o=>{o.target.checked?H(a=>[...a,t.account_id]):H(a=>a.filter(s=>s!==t.account_id))},"onChange"),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsx("label",{htmlFor:`account-${t.account_id}`,className:"ml-2 text-sm text-gray-700 dark:text-gray-300",children:t.name||t.account_id})]},t.id))}),T.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Je geselecteerde accounts:"}),e.jsx("div",{className:"flex flex-wrap gap-2 max-h-32 overflow-y-auto",children:(Array.isArray(_)?_:[]).filter(t=>t.platform===x&&T.includes(t.account_id)).map(t=>e.jsxs("div",{className:"inline-flex items-center px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded-md text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800",children:[e.jsx("span",{className:"mr-1",children:t.name||t.account_id}),e.jsx("button",{type:"button",onClick:r(o=>Z(t.account_id,o),"onClick"),className:"ml-1 text-gray-400 hover:text-red-500",children:e.jsx(oe,{className:"h-3 w-3"})})]},t.id))})]}),e.jsx("div",{className:"relative",children:e.jsx("input",{type:"text",value:U,onChange:r(t=>{B(t.target.value),ye("")}
2,"onChange"),placeholder:"Of voer handmatig een account ID in",className:"w-full px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Vernieuwingsinterval"}),e.jsxs("select",{value:b,onChange:r(t=>j(t.target.value),"onChange"),className:"w-full px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white",children:[e.jsx("option",{value:"never",children:"Nooit (Handmatig)"}),e.jsx("option",{value:"daily",children:"Dagelijks"}),e.jsx("option",{value:"weekly",children:"Wekelijks"}),e.jsx("option",{value:"monthly",children:"Maandelijks"})]}),b==="weekly"&&e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Herhalen op dagen"}),e.jsx("div",{className:"flex gap-1",children:ke.map(t=>e.jsx("button",{onClick:r(()=>me(t.id),"onClick"),className:`w-8 h-8 rounded-full text-xs font-medium transition-colors ${ae.has(t.id)?"bg-blue-500 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300"}`,children:t.label},t.id))})]}),b==="monthly"&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Herhalen op"}),e.jsx("select",{value:ce,onChange:r(t=>q(t.target.value),"onChange"),className:"w-full px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white",children:Xe.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx("div",{children:e.jsx("select",{value:X,onChange:r(t=>z(t.target.value),"onChange"),className:"w-full px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white",children:ke.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))})})]})]}),w==="kpi"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"KPI Metrics"}),e.jsxs("div",{className:"space-y-2",children:[N.map((t,o)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t.metric,onChange:r(a=>A(o,a.target.value),"onChange"),placeholder:"Metric naam (bijv. CPC, CTR, CPA)",className:"flex-1 px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-black dark:text-white"}),N.length>1&&e.jsx("button",{onClick:r(()=>ne(o),"onClick"),className:"px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:e.jsx(oe,{className:"h-4 w-4"})})]},o)),e.jsxs("button",{onClick:le,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Metric toevoegen"]})]})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Checklist Items"}),e.jsxs("div",{className:"space-y-2",children:[C.map((t,o)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:r(a=>V(o,a.target.value),"onChange"),className:"flex-1 px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-black dark:text-white",placeholder:"Checklist item"}),C.length>1&&e.jsx("button",{onClick:r(()=>ne(o),"onClick"),className:"px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:e.jsx(oe,{className:"h-4 w-4"})})]},o)),e.jsxs("button",{onClick:le,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Item toevoegen"]})]})]}
2),e.jsxs("div",{className:"space-y-2 pt-4 border-t mt-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Delen met medewerkers"}),e.jsxs("div",{className:"relative mt-2",children:[e.jsxs("button",{type:"button",onClick:r(()=>ee(!D),"onClick"),className:"w-full flex items-center justify-between px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-2 focus:ring-black dark:text-white",children:[e.jsx("span",{children:y.length===0?"Selecteer medewerkers":`${y.length} medewerker(s) geselecteerd`}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${D?"transform rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]}),D&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 dark:border-gray-600 rounded shadow-lg dark:bg-gray-800",children:[e.jsx("div",{className:"p-2 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:"select-all-users",checked:k.length>0&&y.length===k.length,onChange:P,className:"h-4 w-4 text-black rounded border-black focus:ring-black dark:border-gray-600 dark:bg-gray-700"}),e.jsx("label",{htmlFor:"select-all-users",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Selecteer allemaal"})]})}),e.jsx("div",{className:"max-h-60 overflow-y-auto",children:(Array.isArray(k)?k:[]).length===0?e.jsx("p",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Geen medewerkers beschikbaar"}):(Array.isArray(k)?k:[]).map(t=>e.jsx("div",{className:"px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:`user-${t.id}`,checked:y.some(o=>o.id===(t.user?t.user.id:t.id)),onChange:r(()=>se(t),"onChange"),className:"h-4 w-4 text-black rounded border-black focus:ring-black dark:border-gray-600 dark:bg-gray-700"}),e.jsx("label",{htmlFor:`user-${t.id}`,className:"ml-2 text-sm text-gray-700 dark:text-gray-300 cursor-pointer",children:be(t)})]})},t.id))})]})]}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:y.map(t=>e.jsxs("div",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:[e.jsx("span",{children:t.name||t.email||"Onbekende gebruiker"}),e.jsx("button",{type:"button",onClick:r(()=>se(t),"onClick"),className:"ml-1 text-blue-600 hover:text-blue-800 dark:text-blue-400",children:e.jsx(oe,{className:"h-3 w-3"})})]},t.id))}),e.jsxs("div",{className:"flex items-center mt-4",children:[e.jsx("input",{type:"checkbox",id:"is-template",checked:re,onChange:r(t=>ue(t.target.checked),"onChange"),className:"h-4 w-4 text-black rounded border-black focus:ring-black dark:border-gray-600 dark:bg-gray-700"}),e.jsx("label",{htmlFor:"is-template",className:"ml-2 text-sm text-gray-700 dark:text-gray-300",children:"Opslaan als template"})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-2",children:[e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",children:"Annuleren"}),e.jsx("button",{onClick:d,disabled:R||!g.trim()||(l?!W&&!U:v.length===0&&!U)||w!=="kpi"&&(C.length===0||C.every(t=>!t.trim()))||w==="kpi"&&(N.length===0||N.every(t=>!t.metric.trim())),className:"px-3 py-1.5 text-xs bg-black text-white rounded hover:bg-gray-800 disabled:opacity-50",children:R?"Bezig met opslaan...":l?"Bijwerken":v.length>1?`${v.length} Checklists aanmaken`:"Checklist aanmaken"})]})]})})}r(Le,"ChecklistModal");const ve=[{id:"mon",label:"M"},{id:"tue",label:"D"},{id:"wed",label:"W"},{id:"thu",label:"D"},{id:"fri",label:"V"},{id:"sat",label:"Z"},{id:"sun",label:"Z"}],Ye=["1e","2e","3e","4e","Laatste"];function et({onClose:n,onSave:l,defaultSettings:f}){const[M,_]=i.useState((f==null?void 0:f.refreshInterval)||"never"),[I,te]=i.useState(new Set((f==null?void 0:f.weekDays)||[])),[S,k]=i.useState((f==null?void 0:f.monthWeek)||"1e"),[u,G]=i.useState((f==null?void 0:f.monthDay)||ve[0].id),g=r(x=>{const E=new Set(I);E.has(x)?E.delete(x):E.add(x),te(E)},"toggleWeekDay"),ie=r(()=>{l({refreshInterval:M,weekDays:M==="weekly"?Array.from(I):void 0,monthWeek:M==="monthly"?S:void 0,monthDay:M==="monthly"?u:void 0})},"handleSave");return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Copy Settings"}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-500 dark:hover:text-gray-300",children:e.jsx(oe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Refresh Interval"}),e.jsxs("select",{value:M,onChange:r(x=>_(x.target.value),"onChange"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"never",children:"Never (Manual)"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]}),M==="weekly"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Repeat on days"}),e.jsx("div",{className:"flex gap-1",children:ve.map(x=>e.jsx("button",{onClick:r(()=>g(x.id),"onClick"),className:`w-8 h-8 rounded-full text-xs font-medium transition-colors ${I.has(x.id)?"bg-blue-500 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300"}`,children:x.label},x.id))})]}),M==="monthly"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Repeat on"}),e.jsx("select",{value:S,onChange:r(x=>k(x.target.value),"onChange"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:Ye.map(x=>e.jsx("option",{value:x,children:x},x))})]}),e.jsx("div",{children:e.jsx("select",{value:u,onChange:r(x=>G(x.target.value),"onChange"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:ve.map(x=>e.jsx("option",{value:x.id,children:x.label},x.id))})})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx("button",{onClick:n,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:"Cancel"}),e.jsx("button",{onClick:ie,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 dark:bg-gray-800 dark:hover:bg-gray-700",children:"Save Settings"})]})]})})}r(et,"CopySettingsModal");function De({checklist:n,isCompact:l}){var $,O,Z,be,ge,P,se,le,V,A,ne,me;const{updateChecklistItem:f,updateChecklist:M,createChecklistComment:_,adAccounts:I,deleteChecklist:te,copyChecklist:S}=pe(),[k,u]=i.useState(!1),[G,g]=i.useState(!1),[ie,x]=i.useState(!1),[E,W]=i.useState(!1),[ye,v]=i.useState(""),[H,U]=i.useState(!1),[B,C]=i.useState(new Set),[de,b]=i.useState(!1),[j,ae]=i.useState({refreshInterval:n.refresh_interval,weekDays:($=n.refresh_settings)==null?void 0:$.weekDays,monthWeek:(O=n.refresh_settings)==null?void 0:O.monthWeek,monthDay:(Z=n.refresh_settings)==null?void 0:Z.monthDay}),[L,ce]=i.useState(!1),q=Ze(),X=I.find(d=>d.account_id===n.ad_account);
2X!=null&&X.name||n.ad_account,n.checklist_type==="kpi"||n.title.toLowerCase().includes("kpi")||n.title.toLowerCase().includes("metriek"),n.checklist_type==="campaign_control"||n.title.toLowerCase().includes("campagne")||n.title.toLowerCase().includes("controle")||n.title.toLowerCase().includes("checkup");const z=r(()=>n.checklist_type==="kpi"||n.checklist_type==="campaign_control"?"border-l-4 border-l-purple-300 border-r border-t border-b border-gray-200 dark:border-r-gray-700 dark:border-t-gray-700 dark:border-b-gray-700":"border border-gray-200 dark:border-gray-700","getBorderColor"),R=(n.items||[]).filter(d=>d.is_completed).length,K=(n.items||[]).length,T=K>0?R/K*100:0,J=I.filter(d=>d.platform===n.platform),w=r(async(d,t)=>{await f(d,t)},"handleToggleItem"),xe=r(async(d,t)=>{U(!0);try{const o=(n.items||[]).find(a=>a.id===d);if(!o)return;await M(n.id,{items:[{id:d,checklist_id:n.id,content:o.content,order:o.order,is_completed:o.is_completed,actual_value:t}]})}catch(o){console.error("Error updating KPI value:",o)}finally{U(!1)}},"handleKpiValueChange"),N=r(async()=>{if(B.size!==0){U(!0);try{for(const d of B){const t={...n,ad_account:d,title:`${n.title} (Copy)`,refresh_interval:j.refreshInterval,refresh_settings:{weekDays:j.weekDays,monthWeek:j.monthWeek,monthDay:j.monthDay}};await S(n.id)}x(!1),C(new Set)}finally{U(!1)}}},"handleCopyToAccounts"),Y=r(async()=>{await te(n.id),g(!1)},"handleDelete"),y=((be=n.shares)==null?void 0:be.length)||0,h=n.platform==="facebook"?e.jsx("img",{src:"/images/facebookadsicon.svg",alt:"Facebook Ads",className:"h-3.5 w-3.5"}):n.platform==="google"?e.jsx("img",{src:"/images/googleadsicon.svg",alt:"Google Ads",className:"h-3.5 w-3.5"}):e.jsx(Pe,{className:"h-3.5 w-3.5 text-[#EA4335] dark:text-[#ff5f53]"}),re=!!n.created_by_admin_id,ue=!!n.is_template,D=3,ee=L?n.items||[]:(n.items||[]).slice(0,D),Q=(n.items||[]).length>D;return l?e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg ${z()} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:n.title}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ee(new Date(n.created_at),"MMM d")})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[h,e.jsxs("span",{className:"text-[#6d6e6f] dark:text-gray-400",children:[R,"/",K]})]}),e.jsx("button",{onClick:r(()=>W(!E),"onClick"),className:"text-[#6d6e6f] dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]})]}):e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg ${z()} w-full max-w-[350px] min-w-[280px] flex-none flex flex-col`,style:{flexShrink:0},children:[e.jsxs("div",{className:"p-4 flex-grow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[h,ue&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium text-purple-800 bg-purple-100 dark:bg-purple-900 dark:text-purple-200 rounded-full",children:"Template"}),n.checklist_type==="campaign_control"&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium text-purple-800 bg-purple-100 dark:bg-purple-900 dark:text-purple-200 rounded-full",children:"Campagne"}),n.checklist_type==="kpi"&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium text-purple-800 bg-purple-100 dark:bg-purple-900 dark:text-purple-200 rounded-full",children:"KPI"})]}),e.jsxs("div",{className:"flex space-x-1",children:[e.jsx("button",{onClick:r(d=>{d.preventDefault(),d.stopPropagation(),u(!0)},"onClick"),className:"p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700",title:"Bewerken",children:e.jsx(Ge,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"})}),e.jsx("button",{onClick:r(d=>{d.preventDefault(),d.stopPropagation(),x(!0)},"onClick"),className:"p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700",title:"Kopiëren",children:e.jsx(He,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"})}),e.jsx("button",{onClick:r(d=>{d.preventDefault(),d.stopPropagation(),g(!0)},"onClick"),className:"p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700",title:"Verwijderen",children:e.jsx(Ue,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"})})]})]}),e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-lg mb-1 break-words cursor-pointer",onClick:r(()=>q(`/checklist/${n.id}`),"onClick"),children:n.title}),e.jsxs("div",{className:"flex flex-wrap items-center mb-3 text-xs text-gray-500 dark:text-gray-400 space-x-2",children:[e.jsxs("div",{className:"flex items-center",title:`Gemaakt door: ${((ge=n.creator)==null?void 0:ge.name)||((P=n.creator)==null?void 0:P.email)||"Onbekend"}`,children:[e.jsx(_e,{className:"h-3 w-3 mr-1"}),e.jsx("span",{className:"truncate max-w-[150px]",children:((se=n.creator)==null?void 0:se.name)||((le=n.creator)==null?void 0:le.email)||"Onbekend"})]}),re&&n.admin&&e.jsxs("div",{className:"flex items-center",title:`Admin: ${((V=n.admin)==null?void 0:V.name)||((A=n.admin)==null?void 0:A.email)}`,children:[e.jsx("span",{className:"mx-1",children:"â¢"}
2),e.jsxs("span",{className:"font-medium text-blue-600 dark:text-blue-400 truncate max-w-[150px]",children:["Admin: ",((ne=n.admin)==null?void 0:ne.name)||((me=n.admin)==null?void 0:me.email)]})]}),y>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mx-1",children:"â¢"}),e.jsx(Se,{className:"h-3 w-3 mr-1 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["Gedeeld met ",y," ",y===1?"persoon":"personen"]})]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-600 space-y-1",children:[e.jsx("div",{className:je("space-y-1 transition-all duration-300 ease-in-out overflow-hidden"),children:ee&&ee.length>0?n.checklist_type==="kpi"?ee.map((d,t)=>e.jsx("div",{className:"py-1",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 min-w-[100px]",children:[d.content,":"]}),e.jsx("input",{type:"text",value:d.actual_value||"",onChange:r(o=>xe(d.id,o.target.value),"onChange"),placeholder:"Input waarde",className:"flex-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-700 border-0 rounded focus:outline-none focus:ring-0 dark:text-white"})]})},d.id||`item-${t}`)):ee.map((d,t)=>e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx("input",{type:"checkbox",checked:d.is_completed,onChange:r(()=>w(d.id,!d.is_completed),"onChange"),className:"form-checkbox h-4 w-4 text-black border-black rounded focus:ring-0 focus:ring-offset-0 dark:border-gray-500 dark:checked:bg-black dark:focus:ring-offset-gray-800"}),e.jsx("span",{className:`text-sm ${d.is_completed?"line-through text-gray-500 dark:text-gray-400":"text-gray-700 dark:text-gray-200"}`,children:d.content})]},d.id||`item-${t}`)):(n.items||[]).length===0&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:"Nog geen items."})}),Q&&e.jsxs("button",{onClick:r(()=>ce(!L),"onClick"),className:"mt-2 flex items-center text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 w-full justify-center py-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors",children:[L?e.jsx(Be,{className:"h-4 w-4 mr-1"}):e.jsx(Ie,{className:"h-4 w-4 mr-1"}),L?"Minder weergeven":`Toon ${(n.items||[]).length-D} meer items`]})]})]}),e.jsxs("div",{className:"p-3 border-t border-gray-200 dark:border-gray-600",children:[e.jsx("div",{className:"w-full h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden mb-1.5",children:e.jsx("div",{className:je("h-full",T>=80?"bg-emerald-200":T>=40?"bg-orange-200":"bg-rose-200"),style:{width:`${T}%`}})}),e.jsxs("div",{className:"flex justify-between text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:[e.jsxs("span",{children:[R," van ",K," items voltooid"]}),e.jsxs("span",{children:[Math.round(T),"%"]})]}),e.jsxs("div",{className:"flex items-center text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsx(Re,{className:"h-2.5 w-2.5 mr-1"}),e.jsx("span",{children:n.refresh_interval==="never"?"Geen auto. verversing":`Ververst ${n.refresh_interval==="daily"?"dagelijks":n.refresh_interval==="weekly"?"wekelijks":"maandelijks"}`})]}),e.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-0.5",children:["Laatst bijgewerkt: ",Ee(new Date(n.updated_at||n.created_at),"dd-MM-yy")]})]}),G&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-sm mx-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:"Delete Checklist?"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this checklist? This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:r(()=>g(!1),"onClick"),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:"Cancel"}),e.jsx("button",{onClick:Y,className:"px-4 py-2 text-sm bg-red-600 text-white rounded hover:bg-red-700",children:"Delete"})]})]})}),ie&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Copy Checklist"}),e.jsx("button",{onClick:r(()=>x(!1),"onClick"),className:"text-gray-400 hover:text-gray-500 dark:hover:text-gray-300",children:e.jsx(oe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"flex items-center gap-2 mb-2",children:[e.jsx("input",{type:"checkbox",onChange:r(d=>{d.target.checked?C(new Set(J.map(t=>t.account_id))):C(new Set)}
2,"onChange"),checked:B.size===J.length,className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Select All Accounts"})]}),e.jsx("div",{className:"space-y-2 max-h-60 overflow-auto",children:J.map(d=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:B.has(d.account_id),onChange:r(t=>{const o=new Set(B);t.target.checked?o.add(d.account_id):o.delete(d.account_id),C(o)},"onChange"),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:d.name||d.account_id})]},d.id))})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsxs("button",{onClick:r(()=>b(!0),"onClick"),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),"Settings"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:r(()=>x(!1),"onClick"),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:"Cancel"}),e.jsx("button",{onClick:N,disabled:B.size===0||H,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 dark:bg-gray-800 dark:hover:bg-gray-700 disabled:opacity-50",children:H?"Copying...":"Copy to Selected"})]})]})]})}),de&&e.jsx(et,{onClose:r(()=>b(!1),"onClose"),onSave:r(d=>{ae(d),b(!1)},"onSave"),defaultSettings:j}),k&&e.jsx(Le,{checklist:n,onClose:r(()=>u(!1),"onClose")})]})}r(De,"ChecklistCard");function nt(){const[n,l]=i.useState(!1),[f,M]=i.useState(""),[_,I]=i.useState(()=>{try{const a=localStorage.getItem("checklists_expanded_accounts");if(a){const s=JSON.parse(a);return new Set(s)}}catch(a){console.warn("Failed to load expanded accounts from localStorage:",a)}return new Set}),[te,S]=i.useState({}),{adAccounts:k,checklists:u,fetchChecklists:G,currentCompany:g,testChecklistsDirectQuery:ie,isSidebarCollapsed:x,resetFetchChecklistsErrors:E,error:W,fetchChecklistsErrorCount:ye,user:v,fetchApiAccounts:H,fetchDatabaseAccounts:U,syncApiAccountsToDatabase:B}=pe(),[C,de]=i.useState("grid"),[b,j]=i.useState("all"),[ae,L]=i.useState(void 0),[ce,q]=i.useState(void 0),[X,z]=i.useState(!0),[R,K]=i.useState(null),[T,J]=i.useState(null),[w,xe]=i.useState(!1),[N,Y]=i.useState(!1),[y,h]=i.useState(null),[re,ue]=i.useState({}),[D,ee]=i.useState({}),[Q,$]=i.useState({}),[O,Z]=i.useState([]),[be,ge]=i.useState([]),P=Array.isArray(k)&&k.length>0?k:Array.isArray(O)?O:[];i.useEffect(()=>{try{localStorage.setItem("checklists_expanded_accounts",JSON.stringify(Array.from(_)))}catch(a){console.warn("Failed to save expanded accounts to localStorage:",a)}},[_]),i.useEffect(()=>{const a=`checklists_initialized_${v==null?void 0:v.id}_${g==null?void 0:g.id}`;if(localStorage.getItem(a)){z(!1),Y(!0);return}return k!=null&&k.length,u!=null&&u.length,r(async()=>{if(!(g!=null&&g.id)||!(v!=null&&v.id)){z(!1);return}localStorage.setItem(a,Date.now().toString()),g.name,z(!0),K(null);try{if(await se(),(!u||u.length===0)&&(typeof E=="function"&&E(),await G(),W))throw console.error("â CHECKLISTS: Store error detected after fetch:",W),new Error(`Store error: ${W}`)}catch(c){console.error("â CHECKLISTS INIT: Error during initialization:",c),K(`Fout bij laden van data: ${c instanceof Error?c.message:"Onbekende fout"}`),localStorage.removeItem(a)}finally{z(!1),Y(!0)}},"initializeData")(),()=>{Object.keys(localStorage).forEach(p=>{p.startsWith("checklists_initialized_")&&!p.includes(`${v==null?void 0:v.id}_${g==null?void 0:g.id}`)&&localStorage.removeItem(p)})}},[v==null?void 0:v.id,g==null?void 0:g.id]);const se=r(async()=>{var a;try{try{const c=await ze("me/adaccounts",{fields:"name,account_id,account_status,currency"});if(c.data&&Array.isArray(c.data)){const p=c.data.map(m=>({id:m.id,account_id:m.account_id,name:m.name}));`${p.length}`,Z(p),localStorage.setItem("fb_accounts_data",JSON.stringify(p));return}else console.warn("â ï¸ CHECKLISTS: Facebook Graph API failed or returned no data:",(a=c.error)==null?void 0:a.message)}catch(c){console.error("â CHECKLISTS: Facebook Graph API error:",c)}const s=localStorage.getItem("fb_accounts_data");if(s){const c=JSON.parse(s);c.length,Z(c)}else Z([])}catch(s){console.error("ð¥ CHECKLISTS: Fout bij laden Facebook accounts:",s),Z([])}},"loadFacebookAccounts");i.useEffect(()=>{const a=r(()=>{document.visibilityState==="visible"&&N&&g&&le()},"handleVisibilityChange");return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[N,g==null?void 0:g.id]),i.useEffect(()=>{N&&u&&u.length>0&&(localStorage.setItem("checklists_data",JSON.stringify(u)),u.length)},[N,u]),i.useEffect(()=>{u.length},[u]);const le=r(async()=>
2{if(g)try{const{supabase:a}=await Ke(async()=>{const{supabase:p}=await import("./index-C7UdPtST.js").then(m=>m.ay);return{supabase:p}},__vite__mapDeps([0,1,2,3,4])),{data:s,error:c}=await a.from("checklists").select("*").eq("company_id",g.id).order("created_at",{ascending:!1});if(c){console.error("Directe fetch error:",c);return}if(s&&s.length>0){const p=s.map(m=>({...m,items:[],comments:[],shares:[]}));pe.getState().setChecklists(p),J("Checklists opgehaald via directe methode"),localStorage.setItem("checklists_data",JSON.stringify(p)),setTimeout(()=>J(null),3e3)}}catch(a){console.error("Fout bij directe fetch:",a)}},"directFetchChecklists"),V=u.filter(a=>f===""||a.title.toLowerCase().includes(f.toLowerCase())||a.ad_account&&a.ad_account.toLowerCase().includes(f.toLowerCase())?b==="all"?!0:b==="mine"?!a.created_by_admin_id&&!a.is_template&&(!a.shares||a.shares.length===0):b==="shared"?a.shares&&a.shares.length>0:b==="templates"?a.is_template:b==="kpi"?a.checklist_type==="kpi":b==="campaign_control"?a.checklist_type==="campaign_control":!0:!1),A=fe.useMemo(()=>!Array.isArray(P)||P.length===0?[]:P.map(a=>{var m,F,he;const s=(a==null?void 0:a.account_id)||(a==null?void 0:a.id),c=[s,(m=s==null?void 0:s.replace)==null?void 0:m.call(s,"act_",""),(F=s==null?void 0:s.replace)==null?void 0:F.call(s,/^act_/,""),`act_${s}`,(he=s==null?void 0:s.substring)==null?void 0:he.call(s,4)].filter(Boolean),p=V.filter(Ae=>c.some(Te=>Ae.ad_account===Te));return{account:{...a,account_id:s},checklists:p}}),[k,P,V]);fe.useEffect(()=>{A.length},[k,O,P,A.length]),fe.useEffect(()=>{if(A.length>0){const a=A.filter(s=>s.checklists.length>0).map(s=>s.account.account_id||s.account.id).filter(Boolean);a.length>0&&I(s=>{const c=new Set(s);return a.forEach(p=>c.add(p)),c})}},[A]);const ne=r((a,s)=>a.filter(c=>(()=>{switch(s){case"today":return qe(new Date(c.next_refresh||c.created_at));case"daily":return c.refresh_interval==="daily";case"weekly":return c.refresh_interval==="weekly";case"monthly":return c.refresh_interval==="monthly";case"completed":return c.is_completed;default:return!0}})()),"filterChecklists"),me=r(a=>{const s=new Set(_);s.has(a)?s.delete(a):(s.add(a),S(c=>({...c,[a]:c[a]||"today"}))),I(s)},"toggleAccount"),d=r((a,s)=>{ue(c=>({...c,[a]:s}))},"setAccountDate"),t=r((a,s)=>{ee(c=>({...c,[a]:s}))},"setAccountTimeFilter"),o=r((a,s)=>{$(c=>({...c,[a]:s}))},"setAccountFilterValue");return e.jsxs(e.Fragment,{children:[e.jsxs(Qe,{children:[e.jsx("title",{children:"adhocq - Checklists"}),e.jsx("meta",{name:"description",content:"Beheer je marketing checklists. Vergeet nooit meer een belangrijke stap met onze slimme templates en workflow automation."})]}),e.jsxs("div",{className:"flex min-h-screen bg-white dark:bg-gray-950",children:[e.jsx("main",{className:"flex-1 transition-all duration-300 ",style:{maxWidth:x?"100vw":"calc(100vw - 256px)"},children:e.jsxs("div",{className:"w-full h-full",style:{maxWidth:"100%"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 w-full max-w-full",children:[e.jsx("h1",{className:"text-base font-medium text-gray-900 dark:text-white flex-shrink-0",children:"Checklists"}),e.jsx("button",{onClick:r(()=>{L(void 0),q(void 0),l(!0)},"onClick"),className:"px-3 py-1.5 text-xs text-white bg-black hover:bg-gray-800 transition-colors rounded-md font-medium flex-shrink-0 whitespace-nowrap",children:"Nieuwe Checklist"})]}),X&&A.length===0?e.jsx("div",{className:"flex items-center justify-center h-full min-h-[400px]",children:e.jsx(We,{size:"lg"})}):R?e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-800",children:e.jsx("p",{children:R})}):e.jsxs("div",{className:"space-y-6 px-6 py-4 max-w-full",children:[A.filter(({account:a})=>a&&(a.account_id||a.id)).map(({account:a,checklists:s})=>{const c=te[a.account_id]||"today",p=ne(s,c);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:`px-3 py-2 flex items-center justify-between cursor-pointer ${_.has(a.account_id)?"border-b border-gray-200 dark:border-gray-700":""}`,onClick:r(()=>me(a.account_id),"onClick"),children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:a.name||a.account_id}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[s.length," checklist",s.length!==1?"s":""]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:r(m=>{m.stopPropagation(),L(void 0),q(a.account_id),l(!0)},"onClick"),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx(Ie,{className:`h-4 w-4 text-gray-400 transition-transform ${_.has(a.account_id)?"rotate-180":""}`})]})]}),e.jsxs("div",{className:je("transition-all duration-300 ease-in-out",_.has(a.account_id)?"max-h-[1000px] opacity-100 p-3":"max-h-0 opacity-0"),children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:r(()=>t(a.account_id,"today"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${(D[a.account_id]||"today")==="today"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Vandaag"}),e.jsx("button",{onClick:r(()=>t(a.account_id,"week"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${D[a.account_id]==="week"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Week"}),e.jsx("button",{onClick:r(()=>t(a.account_id,"month"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${D[a.account_id]==="month"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Maand"}),e.jsx("button",{onClick:r(()=>t(a.account_id,"all"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${D[a.account_id]==="all"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Alles"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"all"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-all`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${(Q[a.account_id]||"all")==="all"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Me,{className:"h-4 w-4"})}),y===`${a.account_id}-all`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Alle"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"mine"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-mine`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${Q[a.account_id]==="mine"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(_e,{className:"h-4 w-4"})}),y===`${a.account_id}-mine`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Mijn checklists"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"shared"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-shared`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${Q[a.account_id]==="shared"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Se,{className:"h-4 w-4"})}),y===`${a.account_id}-shared`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Gedeeld"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"templates"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-templates`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${Q[a.account_id]==="templates"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx($e,{className:"h-4 w-4"})}),y===`${a.account_id}-templates`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Templates"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"kpi"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-kpi`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${Q[a.account_id]==="kpi"?"bg-gray-100 dark:bg-gray-600 text-indigo-800 dark:text-indigo-200 shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Ne,{className:"h-4 w-4"})}),y===`${a.account_id}-kpi`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"KPI"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>o(a.account_id,"campaign_control"),"onClick"),onMouseEnter:r(()=>h(`${a.account_id}-campaign_control`),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${Q[a.account_id]==="campaign_control"?"bg-gray-100 dark:bg-gray-600 text-orange-800 dark:text-orange-200 shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(we,{className:"h-4 w-4"})}),y===`${a.account_id}-campaign_control`&&e.jsx("div",{className:"absolute top-8 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Campagne"})]})]}),e.jsx("input",{type:"date",value:re[a.account_id]||new Date().toISOString().split("T")[0],onChange:r(m=>d(a.account_id,m.target.value),"onChange"),className:"px-3 py-1.5 text-xs bg-gray-100 border-0 rounded focus:outline-none focus:ring-2 focus:ring-black"})]})]})}),p.length>0?e.jsx("div",{className:"max-w-full",children:e.jsx("div",{className:"overflow-x-auto overflow-y-hidden pb-2",style:{scrollbarWidth:"thin",WebkitOverflowScrolling:"touch",maxWidth:"100%"},children:e.jsx("div",{className:"flex gap-4",style:{width:"max-content"},children:p.map(m=>e.jsx("div",{className:"w-80 flex-shrink-0",children:e.jsx(De,{checklist:m})},m.id))})})}):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"Geen checklists gevonden voor deze selectie."})]})]},a.id)}),A.length===0&&u.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Checklists (niet gekoppeld aan ad accounts)"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:r(()=>j("all"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${b==="all"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Vandaag"}),e.jsx("button",{onClick:r(()=>j("mine"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${b==="mine"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Week"}),e.jsx("button",{onClick:r(()=>j("shared"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${b==="shared"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Maand"}),e.jsx("button",{onClick:r(()=>j("templates"),"onClick"),className:`px-3 py-1.5 text-xs font-medium rounded-full transition-colors ${b==="templates"?"bg-black text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:"Alles"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("all"),"onClick"),onMouseEnter:r(()=>h("fallback-all"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${b==="all"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Me,{className:"h-4 w-4"})}),y==="fallback-all"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Alle"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("mine"),"onClick"),onMouseEnter:r(()=>h("fallback-mine"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${b==="mine"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(_e,{className:"h-4 w-4"})}),y==="fallback-mine"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Mijn checklists"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("shared"),"onClick"),onMouseEnter:r(()=>h("fallback-shared"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${b==="shared"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Se,{className:"h-4 w-4"})}),y==="fallback-shared"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Gedeeld"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("templates"),"onClick"),onMouseEnter:r(()=>h("fallback-templates"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${b==="templates"?"bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx($e,{className:"h-4 w-4"})}),y==="fallback-templates"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Templates"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("kpi"),"onClick"),onMouseEnter:r(()=>h("fallback-kpi"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-
21 text-xs font-medium rounded-md transition-colors ${b==="kpi"?"bg-gray-100 dark:bg-gray-600 text-purple-800 dark:text-purple-200 shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(Ne,{className:"h-4 w-4"})}),y==="fallback-kpi"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"KPI"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:r(()=>j("campaign_control"),"onClick"),onMouseEnter:r(()=>h("fallback-campaign_control"),"onMouseEnter"),onMouseLeave:r(()=>h(null),"onMouseLeave"),className:`px-2 py-1 text-xs font-medium rounded-md transition-colors ${b==="campaign_control"?"bg-gray-100 dark:bg-gray-600 text-purple-800 dark:text-purple-200 shadow-sm":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:e.jsx(we,{className:"h-4 w-4"})}),y==="fallback-campaign_control"&&e.jsx("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 bg-black text-white text-xs px-2 py-1 rounded whitespace-nowrap z-[9999] shadow-lg pointer-events-none",children:"Campagne"})]})]}),e.jsx("input",{type:"date",value:new Date().toISOString().split("T")[0],className:"px-3 py-1.5 text-xs bg-gray-100 border-0 rounded focus:outline-none focus:ring-2 focus:ring-black"})]})]})}),e.jsx("div",{className:"max-w-full",children:V.length>0?e.jsx("div",{className:"overflow-x-auto overflow-y-hidden pb-2",style:{scrollbarWidth:"thin",WebkitOverflowScrolling:"touch",maxWidth:"100%"},children:e.jsx("div",{className:"flex gap-4",style:{width:"max-content"},children:V.map(a=>e.jsx("div",{className:"w-80 flex-shrink-0",children:e.jsx(De,{checklist:a})},a.id))})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Geen checklists gevonden voor de huidige filter"}),e.jsxs("p",{className:"text-xs text-gray-400 mt-2",children:["Totaal ",u.length," checklists beschikbaar"]})]})})]})]}),A.length===0&&V.length===0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:f?"Geen checklists gevonden die matchen met je zoekopdracht":u.length===0?"Nog geen checklists aangemaakt":"Geen checklists gevonden voor de huidige filter"}),u.length>0&&e.jsxs("div",{className:"text-xs text-gray-400 mt-2",children:["Totaal ",u.length," checklists in database, probeer een andere filter"]})]})]})]})}),n&&e.jsx(Le,{onClose:r(()=>{l(!1),L(void 0),q(void 0)},"onClose"),checklist:ae,preselectedAdAccount:ce,facebookAccounts:Array.isArray(O)?O:[]})]})]})}r(nt,"Checklists");export{nt 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.