1import{d as F,b as I,y as R,o as H,c as d,l as a,h as c,v as M,t as u,e as i,f as h,p as g,F as y,r as w,g as E,R as $,z as C,B as k,m as W,W as q,i as G,j as l}from"./CiKtckVa.js";import{_ as x}from"./B_iF5i9d.js";const J={class:"max-w-4xl mx-auto px-4 py-8"},K={class:"flex items-center justify-between mb-2"},Q={class:"flex items-center"},X={class:"text-2xl font-bold text-navy-500"},Y=["disabled"],Z={class:"text-sm text-gray-400 mb-6"},ee={key:0,class:"space-y-4"},se={key:1,class:"space-y-4"},te={class:"flex items-center px-4 text-xs font-medium text-gray-400"},oe={class:"w-14 flex flex-col items-center gap-0.5"},ae={class:"w-14 flex flex-col items-center gap-0.5"},ne={class:"flex items-center gap-3 p-4"},ie={class:"flex-1 font-semibold text-navy-500 text-sm"},le={class:"w-14 flex justify-center"},re={class:"w-14 flex justify-center"},de=["onClick","aria-expanded"],ce={key:0,class:"border-t border-gray-100 divide-y divide-gray-100 bg-gray-50/50"},me={class:"flex-1 pl-12 text-sm text-gray-500 leading-tight"},ue={class:"w-14 flex justify-center"},pe={class:"w-14 flex justify-center"},fe={key:2,class:"mt-6 md:hidden"},he=["disabled"],_e=F({__name:"settings",setup(ge){I({title:"Paramètres des notifications"});const{t:r,te:S}=R(),f=k(!0),p=k(!1),v=k([]),U={vpdive:{bg:"#f3e8ff",text:"#7c3aed"},club:{bg:"#dbeafe",text:"#1d4ed8"},event:{bg:"#dcfce7",text:"#16a34a"},user:{bg:"#fef3c7",text:"#d97706"},chat:{bg:"#fce7f3",text:"#db2777"},photo:{bg:"#e0e7ff",text:"#4f46e5"},cart:{bg:"#ffedd5",text:"#ea580c"},form:{bg:"#ccfbf1",text:"#0d9488"},support:{bg:"#fee2e2",text:"#dc2626"},news:{bg:"#f0fdf4",text:"#15803d"},printing:{bg:"#f5f5f4",text:"#57534e"},slot:{bg:"#ecfeff",text:"#0891b2"},travel:{bg:"#eff6ff",text:"#2563eb"}},B={vpdive:"heroicons:sparkles",club:"heroicons:building-office-2",event:"heroicons:calendar-days",user:"heroicons:users",chat:"heroicons:chat-bubble-left-right",photo:"heroicons:photo",cart:"heroicons:shopping-cart",form:"heroicons:document-text",support:"heroicons:lifebuoy",news:"heroicons:newspaper",printing:"material-symbols:apparel",slot:"heroicons:clock",travel:"material-symbols:flight"},N=e=>{const s=U[e]||{bg:"#f3f4f6",text:"#374151"};return{backgroundColor:s.bg,color:s.text}},O=e=>B[e]||"heroicons:bell",P=e=>{const s=`notif_details.${e.replace(/[. ]/g,"_")}`;return S(s)?r(s):e},z=e=>Object.entries(e.notifications_categories).reduce((s,[t,o])=>(o&&typeof o=="object"&&(s[t]=Object.entries(o).reduce((n,[m,j])=>(n[m]={email:j.email||!1,push:j.push||!1},n),{})),s),{}),L=async()=>{f.value=!0;try{const e=await $("/api/notifications/settings"),s=z(e);v.value=Object.entries(s).map(([t,o])=>({id:t,name:r(`settings.${t}`),expanded:!1,subcategories:Object.entries(o).map(([n,m])=>({id:n,name:P(n),email:m.email,push:m.push}))}))}catch(e){console.error("Erreur lors du chargement des paramètres:",e)}finally{f.value=!1}},_=e=>e.subcategories.every(s=>s.email),b=e=>e.subcategories.every(s=>s.push),T=e=>{const s=!_(e);e.subcategories.forEach(t=>{t.email=s})},A=e=>{const s=!b(e);e.subcategories.forEach(t=>{t.push=s})},D=e=>{e.expanded=!e.expanded},V=async()=>{p.value=!0;try{const e={};v.value.forEach(t=>{_(t)&&(e[`group_${t.id}_email`]="on"),b(t)&&(e[`group_${t.id}_push`]="on"),t.subcategories.forEach(o=>{o.email&&(e[`check_${t.id}.${o.id}_email`]="on"),o.push&&(e[`check_${t.id}.${o.id}_push`]="on")})}),await $("/api/notifications/settings",{method:"POST",data:e}),C().add({title:r("settings.saved_title"),description:r("settings.saved_desc"),icon:"heroicons:check-circle",color:"green"})}catch(e){console.error("Erreur lors de la sauvegarde des paramètres:",e),C().add({title:r("settings.error_title"),description:r("settings.error_desc"),icon:"heroicons:x-circle",color:"red"})}finally{p.value=!1}};return H(()=>{L()}),(e,s)=>{const t=M;return l(),d("div",J,[a("div",K,[a("div",Q,[c(t,{name:"heroicons:cog-6-tooth",class:"w-6 h-6 mr-2 text-navy-500"}),a("h1",X,u(i(r)("settings.title")),1)]),a("button",{onClick:V,disabled:i(p)||i(f),class:"hidden md:inline-flex items-center gap-2 px-4 py-2 bg-primary text-white rounded-md text-sm font-medium hover:bg-primary-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},[i(p)?(l(),h(t,{key:0,name:"heroicons:arrow-path",class:"w-5 h-5 animate-spin"})):(l(),h(t,{key:1,name:"heroicons:check",class:"w-5 h-5"}
1)),g(" "+u(i(r)("settings.validate")),1)],8,Y)]),a("p",Z,u(i(r)("settings.subtitle")),1),i(f)?(l(),d("div",ee,[(l(),d(y,null,w(6,o=>a("div",{key:o,class:"bg-white rounded-lg shadow-sm p-4"},[...s[0]||(s[0]=[W('<div class="flex items-center gap-3"><div class="w-9 h-9 rounded-lg bg-gray-100 animate-pulse"></div><div class="h-4 bg-gray-100 rounded w-1/3 animate-pulse"></div><div class="ml-auto flex gap-6"><div class="w-11 h-6 rounded-full bg-gray-100 animate-pulse"></div><div class="w-11 h-6 rounded-full bg-gray-100 animate-pulse"></div></div></div>',1)])])),64))])):(l(),d("div",se,[a("div",te,[s[1]||(s[1]=a("span",{class:"flex-1"},null,-1)),a("span",oe,[c(t,{name:"heroicons:envelope",class:"w-4 h-4"}),g(" "+u(i(r)("settings.email_short")),1)]),a("span",ae,[c(t,{name:"heroicons:device-phone-mobile",class:"w-4 h-4"}),g(" "+u(i(r)("settings.push_short")),1)]),s[2]||(s[2]=a("span",{class:"w-8"},null,-1))]),(l(!0),d(y,null,w(i(v),o=>(l(),d("div",{key:o.id,class:"bg-white rounded-lg shadow-sm overflow-hidden"},[a("div",ne,[a("div",{class:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0",style:q(N(o.id))},[c(t,{name:O(o.id),class:"w-5 h-5"},null,8,["name"])],4),a("span",ie,u(o.name),1),a("div",le,[c(x,{"model-value":_(o),"onUpdate:modelValue":n=>T(o)},null,8,["model-value","onUpdate:modelValue"])]),a("div",re,[c(x,{"model-value":b(o),"onUpdate:modelValue":n=>A(o)},null,8,["model-value","onUpdate:modelValue"])]),a("button",{onClick:n=>D(o),class:"w-8 h-8 flex items-center justify-center text-gray-400 hover:text-navy-500 transition-colors","aria-expanded":o.expanded},[c(t,{name:"heroicons:chevron-down",class:G(["w-5 h-5 transition-transform",{"rotate-180":o.expanded}])},null,8,["class"])],8,de)]),o.expanded?(l(),d("div",ce,[(l(!0),d(y,null,w(o.subcategories,n=>(l(),d("div",{key:n.id,class:"flex items-center gap-3 px-4 py-3"},[a("span",me,u(n.name),1),a("div",ue,[c(x,{modelValue:n.email,"onUpdate:modelValue":m=>n.email=m},null,8,["modelValue","onUpdate:modelValue"])]),a("div",pe,[c(x,{modelValue:n.push,"onUpdate:modelValue":m=>n.push=m},null,8,["modelValue","onUpdate:modelValue"])]),s[3]||(s[3]=a("span",{class:"w-8"},null,-1))]))),128))])):E("",!0)]))),128))])),i(f)?E("",!0):(l(),d("div",fe,[a("button",{onClick:V,disabled:i(p),class:"w-full flex items-center justify-center gap-2 py-3 bg-primary text-white rounded-md font-medium hover:bg-primary-600 transition-colors disabled:opacity-50"},[i(p)?(l(),h(t,{key:0,name:"heroicons:arrow-path",class:"w-5 h-5 animate-spin"})):(l(),h(t,{key:1,name:"heroicons:check",class:"w-5 h-5"})),g(" "+u(i(r)("settings.validate")),1)],8,he)]))])}}});export{_e 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.