PageSourceSearch

https://www.numerama.com/wp-content/mu-plugins/optimus/build/js/chunks/AccountPage-oN2FWS34.js

js numerama.com collected 2026-09-24 08:38:50 UTC 50,594 bytes, 2 lines download raw bytes

1import{j as e,r as n}from"./react-Bs4hDxVO.js";import{aK as qe,aL as Ve,P as G,p as ee,G as Qe,r as Ee,o as et,q as Ge,T as q,b as O,aM as tt,aN as xe,D,C as st,I as nt,e as ae,i as re,j as oe,k as ie,aO as he,n as fe,x as at,av as rt,a as ot,aw as it,ax as lt,ay as ct,A as dt,E as ut,F as je,aP as Fe,S as mt,l as ue,aQ as pt}from"./hydrateServerComponents-Du9FxQ3x.js";import{a as ht,b as ft,T as He,g as xt,h as gt,i as bt}from"./feedRestoreBridge-Bz0WrI2L.js";import{F as le,N as jt,P as Pe}from"../optimus-react-COAbUwbl.js";import{A as J,a as K,b as Ae}from"./Alert-BQSYrQnx.js";import{N as yt,p as Le,a as wt}from"./notificationPreferences-BPRgisd1.js";import{b as vt,a as _t,s as Tt}from"./platform-CFLjzmHX.js";import{N as St}from"./NewsletterCard-DY0MMvKI.js";import"./site-B6KXgbd2.js";import"./relativeTime-C033wpEl.js";import"./TextInput-BcLTOYoG.js";import"./Divider-BawD-cUZ.js";import"./SearchField-CxASte-y.js";import"./Skeleton-CGcmIjgX.js";const Ct="scrollList___MF4fF",Et={scrollList:Ct},Nt=[],kt=({activeRoute:s,logoutUrl:a,routes:t=Nt,onRouteChange:i,hasExternalTabsProvider:d=!1})=>{const h=qe(),g=e.jsxs(ht,{className:h?Et.scrollList:"",children:[t.map(l=>e.jsx(ft,{value:l.slug,href:l.url,children:l.label},l.slug)),!h&&a&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"w-full border-0 border-t border-solid border-transparency-neutral-20 my-150"}),e.jsxs("a",{href:a,onClick:Ve,className:"flex items-center gap-200 w-full p-300 font-fontFamilySecondary text-2xs font-semibold leading-none text-font-body no-underline rounded-medium cursor-pointer hover:text-primary",children:[e.jsx(G,{name:"sign-out",size:20,color:"inherit"}),"Se déconnecter"]})]})]});return e.jsx("nav",{"aria-label":"Account navigation",className:`min-w-0 ${h?"w-full":"w-[15.75rem]"}`,children:d?g:e.jsx(He,{value:s,onValueChange:i,orientation:h?"horizontal":"vertical",corners:"medium",animation:"liquid",className:h?"":"grid-cols-1",children:g})})},ye=2;function ge(s){const a=s.querySelectorAll(':scope > [role="tabpanel"]');if(a.length>=2){const d=a[1].getBoundingClientRect().left-a[0].getBoundingClientRect().left;if(d!==0)return{stride:Math.abs(d),sign:Math.sign(d)}}const t=getComputedStyle(s),i=parseFloat(t.columnGap);return{stride:s.clientWidth+(Number.isNaN(i)?0:i),sign:t.direction==="rtl"?-1:1}}function Q(s,a,t=ge(s)){return a*t.stride*t.sign}function ce(s,a,t=ge(s)){if(t.stride<=0)return 0;const i=Math.round(Math.abs(s.scrollLeft)/t.stride);return Math.min(Math.max(i,0),Math.max(a-1,0))}function We(s,a=[]){return n.Children.forEach(s,t=>{if(!n.isValidElement(t))return;if(t.type===n.Fragment){We(t.props.children,a);return}const{value:i}=t.props;typeof i=="string"&&a.push(i)}),a}const Me=1,Ft=260,Pt="cubic-bezier(0.22, 1, 0.36, 1)",At=100;function Lt(s,a,t){const i=new Map;for(const g of Array.from(s.children)){const l=g;l.getAttribute("role")==="tabpanel"&&l.dataset.value&&i.set(l.dataset.value,l)}const d=[];if(t){const{stride:g}=ge(s);if(g>0){const l=Math.abs(s.scrollLeft)/g;for(const f of new Set([Math.floor(l),Math.ceil(l)])){const r=i.get(a[f]);r&&d.push(r)}}}if(d.length===0){const g=[...i.values()].find(l=>l.dataset.state==="active");g&&d.push(g)}const h=Math.max(0,...d.map(g=>g.getBoundingClientRect().height));return h>0?Math.round(h):null}function Mt({railRef:s,inputsRef:a,isGestureRef:t}){const i=n.useRef({animation:null,timer:0});return n.useEffect(()=>()=>{var d;(d=i.current.animation)==null||d.cancel(),clearTimeout(i.current.timer)},[]),n.useCallback((d,h=Ft,g=Pt)=>{var p;const l=s.current;if(!l)return;const f=Lt(l,a.current.values,t.current);if(f===null||l.style.height===`${f}px`||!l.style.height&&Math.abs(l.offsetHeight-f)<=Me)return;const r=l.offsetHeight;(p=i.current.animation)==null||p.cancel(),clearTimeout(i.current.timer),i.current={animation:null,timer:0},l.style.height=`${f}px`;const o=l.offsetHeight,b=Math.abs(o-r)>Me;if(d&&b&&!ee()&&!document.hidden&&typeof l.animate=="function"){const x=l.animate([{height:`${r}px`},{height:`${o}px`}],{duration:h,easing:g});i.current={animation:x,timer:window.setTimeout(()=>x.cancel(),h+At)}}},[s,a,t])}const Rt=180,we=280,ve=60,me="ease-in-out",It=100;function Ot(s,a){const t=n.useRef({animation:null,timers:[]}),i=n.useCallback(()=>{var l;return((l=t.current.animation)==null?void 0:l.playState)==="running"},[]),d=n.useCallback(()=>t.current.animation!==null||t.current.timers.length>0,[]),h=n.useCallback(()=>{var l;(l=t.current.animation)==null||l.cancel(),t.current.animation=null;for(const f of t.current.timers)clearTimeout(f);t.current.timers=[]},[]);return n.useEffect(()=>()=>h(),[h]),{crossFade:n.useCallback(l=>{const f=s.current;if(!f)return;const r=parseFloat(getComputedStyle(f).opacity)||1;if(h(),f.style.opacity="1",!(!ee()&&!document.hidden&&typeof f.animate=="function")){l!==null&&(f.scrollTo({left:l,behavior:"auto"}),a(!1));return}const b=Math.max(1,Math.round(Rt*r)),p=l===null?we:b+ve+we,x=f.animate(l===null?[{opacity:r,easing:me},{opacity:1}]:[{opacity:r,offset:0,easing:me},{opacity:0,offset:b/p,easing:"linear"},{opacity:0,offset:(b+ve)/p,easing:me},{opacity:1,offset:1}],{duration:p,easing:"linear"});t.current.animation=x,l!==null&&t.current.timers.push(window.setTimeout(()=>{f.scrollTo({left:l,behavior:"auto"}),a(!0,we,me)},b+ve/2)),t.current.timers.push(window.setTimeout(()=>{x.cancel(),t.current.animation===x&&(t.current.animation=null,t.current.timers=[]),l!==null&&a(!1)},p+It))},[s,h,a]),clearFade:h,isFadeRunning:i,hasPendingFade:d}}const Dt=3;function $t({railRef:s,inputsRef:a,values:t,pendingIndexRef:i,isGestureRef:d,indicatorProgressRef:h,syncRailHeight:g,isFadeRunning:l}){n.useEffect(()=>{const r=s.current;if(!r)return;const o="onscrollend"in window;let b=0,p=r.scrollLeft,x=0,_=null;const v=()=>(_??(_=ge(r)),_),u=()=>{const{values:T,activeValue:N,onValueChange:E}=a.current,F=T[ce(r,T.length,v())];return F===void 0||F===N?!1:(E(F),!0)},y=()=>{b&&cancelAnimationFrame(b),b=0},c=()=>{const T=h.current;if(!T||ee())return;const{values:N}=a.current,{stride:E}=v();if(E<=0||N.length===0)return;const F=N.length-1,M=Math.min(Math.max(Math.abs(r.scrollLeft)/E,0),F),R=Math.floor(M),S=Math.min(R+1,F);T.set(N[R],N[S],M-R)},m=()=>{var M;y(),_=null;
1const T=i.current,N=T===null?0:Q(r,T,v());if(T!==null&&Math.abs(r.scrollLeft-N)>ye){r.scrollTo({left:N,behavior:!a.current.isSwipeEnabled||ee()?"auto":"smooth"});return}i.current=null,d.current=!1;const E=ce(r,a.current.values.length,v());if((M=h.current)==null||M.clear(a.current.values[E]),a.current.isSwipeEnabled){const R=Q(r,E,v());Math.abs(r.scrollLeft-R)>ye&&(i.current=E,r.scrollTo({left:R,behavior:ee()?"auto":"smooth"}))}!(a.current.isSwipeEnabled?u():!1)&&a.current.isSwipeEnabled&&g(!0)},w=()=>{if(r.scrollLeft===p){if(x+=1,x>=Dt){m();return}}else x=0,p=r.scrollLeft;b=requestAnimationFrame(w)},j=()=>{x=0,p=r.scrollLeft,b||(b=requestAnimationFrame(w))},C=()=>{const T=i.current;T!==null?Math.abs(r.scrollLeft-Q(r,T,v()))<=ye&&(i.current=null):a.current.isSwipeEnabled&&(d.current=!0,c(),u()),o||j()},k=()=>{_=null,a.current.isSwipeEnabled&&(i.current=null)};return r.addEventListener("scroll",C,{passive:!0}),r.addEventListener("scrollend",m),r.addEventListener("pointerdown",k,{passive:!0}),()=>{y(),r.removeEventListener("scroll",C),r.removeEventListener("scrollend",m),r.removeEventListener("pointerdown",k)}},[s,a,i,d,h,g]);const f=t.join(`
2`);n.useEffect(()=>{const r=s.current;if(!r)return;let o=0;const b=()=>{o||(o=requestAnimationFrame(()=>{o=0,!l()&&g(!1)}))};let p=r.clientWidth;const x=new ResizeObserver(_=>{const v=r.clientWidth;if(v!==p&&v!==0){p=v;const{selectedIndex:y,values:c}=a.current;y>=0&&ce(r,c.length)!==y&&(i.current=y,r.scrollTo({left:Q(r,y),behavior:"auto"}))}const u=y=>{const c=y.target;return c===r?!1:c.dataset.state==="active"||d.current&&c.dataset.nearby==="true"};_.some(u)&&b()});x.observe(r);for(const _ of Array.from(r.children))x.observe(_);return()=>{o&&cancelAnimationFrame(o),x.disconnect()}},[s,a,i,d,g,l,f])}const Bt="rail___ottvN",zt="panel___WUFeV",Re={rail:Bt,panel:zt},_e=1;function Ut({values:s,isSwipeEnabled:a=!0,"aria-label":t,className:i,children:d}){const{value:h,onValueChange:g,indicatorProgressRef:l}=Qe(),f=n.useRef(null),r=n.useMemo(()=>s??We(d),[s,d]),o=r.indexOf(h),b=n.useRef(new Set);if(o>=0)for(let E=o-_e;E<=o+_e;E+=1)r[E]!==void 0&&b.current.add(r[E]);const p=n.useCallback(E=>!r.includes(E)||b.current.has(E),[r]),x=n.useCallback(E=>{const F=r.indexOf(E);return F<0||o<0?!0:Math.abs(F-o)<=_e},[r,o]),_=n.useMemo(()=>({panelClassName:Re.panel,shouldMountPanel:p,isPanelNearby:x}),[p,x]),v=n.useRef({values:r,activeValue:h,onValueChange:g,selectedIndex:o,isSwipeEnabled:a});n.useEffect(()=>{v.current={values:r,activeValue:h,onValueChange:g,selectedIndex:o,isSwipeEnabled:a}});const u=n.useRef(null),y=n.useRef(!1),c=n.useRef(!1),m=n.useRef(!1),w=Mt({railRef:f,inputsRef:v,isGestureRef:y}),{crossFade:j,clearFade:C,isFadeRunning:k,hasPendingFade:T}=Ot(f,w);n.useLayoutEffect(()=>{const E=f.current,F=!c.current;c.current=!0,!(E!==null&&!a&&o>=0&&m.current&&ce(E,r.length)!==o||k())&&w(!F&&!y.current&&a)}),n.useEffect(()=>{const E=f.current;if(!E||o<0)return;if(ce(E,r.length)===o){m.current=!0,T()&&j(null);return}const F=!m.current;m.current=!0,u.current=o;const M=Q(E,o);if(!a&&!F){j(M);return}E.scrollTo({left:M,behavior:F||ee()?"auto":"smooth"})},[o,r.length,a,j,T]);const N=n.useRef(a);return n.useEffect(()=>{var F;if(N.current===a)return;N.current=a;const E=f.current;!E||o<0||(y.current=!1,(F=l.current)==null||F.clear(),C(),E.style.opacity="1",u.current=o,E.scrollTo({left:Q(E,o),behavior:"auto"}))},[a,o,l,C]),$t({railRef:f,inputsRef:v,values:r,pendingIndexRef:u,isGestureRef:y,indicatorProgressRef:l,syncRailHeight:w,isFadeRunning:k}),e.jsx(xt.Provider,{value:_,children:e.jsx("div",{ref:f,"data-tabs-rail":"","data-swipe-disabled":a?void 0:"",role:t?"group":void 0,"aria-label":t,className:`${Re.rail} ${i??""}`.trim(),children:d})})}const V=({title:s,children:a,className:t})=>{const i=["flex flex-col items-stretch w-full",t].filter(Boolean).join(" ");return e.jsxs("div",{className:i,children:[s&&e.jsx("h2",{className:"font-fontFamilyPrimary text-xs font-bold leading-[1.5rem] text-font-body mb-300",children:s}),a]})};function Ie({iconName:s,size:a,color:t}){return Object.prototype.hasOwnProperty.call(et,s)?e.jsx(G,{name:s,size:a,c
2olor:t,weight:"fill"}):e.jsx(Ge,{name:s,size:a,color:t})}function qt({value:s,onAction:a,actionLabel:t,href:i,icon:d}){return s&&a?e.jsxs("button",{type:"button",className:"inline-flex items-center justify-start gap-200 min-w-0 font-fontFamilyTertiary text-3xs font-semibold leading-[1.25rem] tracking-[0.05rem] text-primary bg-transparent border-none p-0 cursor-pointer hover:underline",onClick:a,children:[e.jsx(G,{name:"pencil",size:16,color:"primary",weight:"fill"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:s})]}):s?e.jsx("span",{className:"font-fontFamilyTertiary text-3xs font-semibold leading-[1.25rem] tracking-[0.05rem] text-font-body text-left overflow-hidden text-ellipsis whitespace-nowrap",children:s}):t&&i?e.jsxs("a",{href:i,className:"inline-flex items-center self-center justify-start gap-200 min-w-0 font-fontFamilyTertiary text-3xs font-semibold leading-[1.25rem] tracking-[0.05rem] text-primary bg-transparent border-none p-0 cursor-pointer no-underline hover:underline",onClick:a,children:[d&&e.jsx(Ie,{iconName:d,size:16,color:"primary"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:t})]}):t&&a?e.jsxs("button",{type:"button",className:"inline-flex items-center self-center justify-start gap-200 min-w-0 font-fontFamilyTertiary text-3xs font-semibold leading-[1.25rem] tracking-[0.05rem] text-primary bg-transparent border-none p-0 cursor-pointer hover:underline",onClick:a,children:[d&&e.jsx(Ie,{iconName:d,size:16,color:"primary"}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:t})]}):null}const A=({label:s,labelIcon:a,description:t,value:i,actionLabel:d,icon:h,onAction:g,href:l,control:f,glass:r,className:o})=>{const b=!!(a&&t&&d),p=["grid gap-x-800 gap-y-[0.4375rem] py-500 self-stretch border-b border-transparency-primary-30",f?"grid-cols-[1fr_auto]":"grid-cols-2",b&&"items-start md:items-center",Ee(r),o].filter(Boolean).join(" "),x=e.jsx(qt,{value:i,onAction:g,actionLabel:d,href:l,icon:h});return b?e.jsxs("div",{className:p,children:[e.jsxs("div",{className:"flex flex-col items-start gap-200 md:flex-row md:items-center md:gap-500",children:[e.jsxs("span",{className:"inline-flex items-center gap-300 md:min-w-32 md:shrink-0",children:[a,e.jsx("span",{className:"font-fontFamilySecondary text-3xs font-semibold leading-[1.25rem] text-font-body",children:s})]}),e.jsx("span",{className:"font-fontFamilyTertiary text-5xs font-normal leading-[0.875rem] text-font-body",children:t})]}),x]}):e.jsxs("div",{className:p,children:[e.jsxs("div",{className:"flex flex-col gap-200 items-start justify-center",children:[a?e.jsxs("span",{className:"inline-flex items-center gap-300",children:[a,e.jsx("span",{className:"font-fontFamilySecondary text-3xs font-semibold leading-[1.25rem] text-font-body",children:s})]}):e.jsx("span",{className:"font-fontFamilySecondary text-3xs font-semibold leading-[1.25rem] text-font-body",children:s}),t&&e.jsx("span",{className:"font-fontFamilyTertiary text-5xs font-normal leading-[0.875rem] text-font-body",children:t})]}),f?e.jsx("div",{className:"flex items-center justify-end min-w-0",children:f}):x]})},Vt=({hasDefaultPassword:s,restNonce:a,onSuccess:t})=>{const[i,d]=n.useState(""),[h,g]=n.useState(""),[l,f]=n.useState(!1),[r,o]=n.useState(null),b=n.useCallback((x,_={})=>fetch(x,{..._,headers:{"Content-Type":"application/json",...a?{"X-WP-Nonce":a}:{},..._.headers}}),[a]),p=async x=>{if(x.preventDefault(),o(null),i.length===0||h.length===0){o("Veuillez remplir tous les champs.");return}if(i!==h){o("Les mots de passe ne correspondent pas.");return}f(!0);const v=new FormData(x.currentTarget).get("old_pass_confirm");try{const u=await b("/wp-json/humanoid/v1/account/password",{method:"PUT",body:JSON.stringify({oldPassword:s?void 0:v,newPassword:i,confirmPassword:h})}),y=await u.json();if(!u.ok||!y.success){o(y.error||"Une erreur est survenue.");return}O.success("Mot de passe mis à jour."),t==null||t()}catch{o("Une erreur est survenue.")}finally{f(!1)}};return e.jsxs("form",{name:"passwordform",id:"passwordform",onSubmit:p,className:"flex flex-col gap-600",children:[r&&e.jsx(J,{type:"error",closable:!0,onClose:()=>o(null),children:e.jsx(K,{children:r})}),e.jsxs("div",{className:"flex flex-col gap-400",children:[!s&&e.jsx(le,{id:"old-password",name:"old_pass_confirm",label:"Ancien mot de passe",type:"password",autoComplete:"current-password",placeholder:"••••••••"}),e.jsxs("fieldset",{className:"border-0 border-t border-solid border-t-primary mt-200 pt-600 flex flex-col gap-400",children:[e.jsx("legend",{className:"mx-auto px-[0.375rem] font-fontFamilySecondary text-3xs font-semibold leading-label text-font-body whitespace-nowrap",children:"Nouveau mot de passe"}),e.jsx(jt,{password:i,confirmPassword:h,onPasswordChange:d,onConfirmPasswordChange:g,passwordName:"user_pass",confirmPasswordName:"user_pass_confirm",idPrefix:"new-password",restNonce:a})]})]}),e.jsx(q,{type:"submit",name:"wp-submit",color:"primary",variant:"contained",disabled:l,children:"Sauvegarder"})]})},Gt="header___1x9rd",Ht="sectionTitle___-0WN7",Wt="cardList___cyFUt",Xt="empty
2Description___D6XFe",Jt="emptyText___TgiQ7",Kt="errorText___FSmGB",Yt="cardItem___NVL3O",Zt="removing___2RPEa",Qt="removeButton___-aKWV",z={header:Gt,sectionTitle:Ht,cardList:Wt,emptyDescription:Xt,emptyText:Jt,errorText:Kt,cardItem:Yt,removing:Zt,removeButton:Qt},es=400,ts=({restNonce:s,getGrouped:a})=>{const[t,i]=n.useState([]),[d,h]=n.useState(!0),[g,l]=n.useState(null),[f,r]=n.useState(!1),[o,b]=n.useState(new Set),p=n.useRef(!1),x=n.useRef(!1),_=n.useCallback(async()=>{h(!0),l(null);try{const w=await(a??tt.getGrouped)({restNonce:s});i(w.groups)}catch(m){l(m instanceof Error?m:new Error(String(m)))}finally{h(!1),x.current=!0}},[s,a]);n.useEffect(()=>{_()},[_]),n.useEffect(()=>{const m=()=>{!p.current&&x.current&&_()};return window.addEventListener("bookmarks-updated",m),()=>window.removeEventListener("bookmarks-updated",m)},[_]);const v=n.useCallback(async(m,w={})=>{const j=await fetch(m,{...w,headers:{"Content-Type":"application/json",...s?{"X-WP-Nonce":s}:{},...w.headers}});if(!j.ok)throw new Error(`API responded with ${j.status}`);return j},[s]),u=n.useCallback(async m=>{if(!o.has(m)){b(w=>new Set(w).add(m)),await new Promise(w=>setTimeout(w,es)),i(w=>w.map(j=>({...j,items:j.items.filter(C=>C.postId!==m)})).filter(j=>j.items.length>0)),b(w=>{const j=new Set(w);return j.delete(m),j});try{await v(`/wp-json/humanoid/v1/premium/bookmarks?post_id=${m}`,{method:"DELETE"}),xe.removeFromLocalCache(String(m)),p.current=!0,window.dispatchEvent(new CustomEvent("bookmarks-updated")),p.current=!1}catch{O.error("Erreur lors de la suppression du signet."),await _()}}},[v,_,o]),y=n.useCallback(async()=>{r(!1),i([]);try{await v("/wp-json/humanoid/v1/premium/bookmarks?all=true",{method:"DELETE"}),xe.clearLocalCache(),p.current=!0,window.dispatchEvent(new CustomEvent("bookmarks-updated")),p.current=!1}catch{O.error("Erreur lors de la suppression."),await _()}},[v,_]),c=!d&&!g&&t.length>0;return e.jsxs("div",{className:"flex flex-col gap-800 w-full",children:[e.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-600 w-full ${z.header}`,children:[e.jsx(D,{fullWidth:!1,children:"Signets"}),c&&e.jsx(st,{variant:"outlined",color:"primary",icon:"trash",iconIsFilled:!1,onClick:()=>r(!0),children:"Supprimer tous les signets"})]}),d&&e.jsx("div",{className:"flex justify-center py-1000 w-full",children:e.jsx("p",{className:z.emptyText,children:"Chargement…"})}),g&&e.jsx("p",{className:`${z.errorText} text-center w-full`,children:"Une erreur est survenue lors du chargement de vos signets."}),!d&&!g&&t.length===0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:z.emptyDescription,children:"Retrouvez l'intégralité des articles que vous avez enregistrés et consultez-les à tout moment."}),e.jsx("p",{className:z.emptyText,children:"Aucun article enregistré."})]}),c&&e.jsxs(e.Fragment,{children:[t.map(m=>e.jsxs("section",{className:"flex flex-col gap-400 w-full",children:[e.jsx("h2",{className:z.sectionTitle,children:m.label}),e.jsx("ul",{className:`${z.cardList} flex flex-col gap-800`,children:m.items.map(w=>e.jsxs("li",{className:`${z.cardItem}${o.has(w.postId)?` ${z.removing}`:""}`,children:[e.jsx(gt,{item:w.post,hideBookmarkButton:!0}),e.jsx(nt,{className:z.removeButton,name:"bookmark-simple",isFilled:!0,size:26,ariaLabel:"Retirer des signets",onClick:()=>u(w.postId)})]},w.postId))})]},m.key)),e.jsx(ae,{isOpen:f,onClose:()=>r(!1),children:e.jsxs(re,{size:"small",children:[e.jsxs(oe,{children:[e.jsx(ie,{children:"Supprimer tous les signets"}),e.jsx(he,{children:"Cette action est irréversible. Tous vos articles enregistrés seront retirés."})]}),e.jsxs(fe,{children:[e.jsx(q,{variant:"ghost",color:"primary",onClick:()=>r(!1),children:"Annuler"}),e.jsx(q,{variant:"contained",color:"primary",onClick:y,children:"Supprimer"})]})]})})]})]})},ss="toggle___rGwCG",ns="toggle__thumb___BkFvt",pe={toggle:ss,"toggle--checked":"toggle--checked___dfxdM","toggle--disabled":"toggle--disabled___WHUC3",toggle__thumb:ns},de=({checked:s,onChange:a,disabled:t=!1,name:i,glass:d,className:h,ariaLabel:g})=>{const l=["relative inline-flex items-center border-none rounded-full cursor-pointer shrink-0",pe.toggle,s&&pe["toggle--checked"],t&&pe["toggle--disabled"],Ee(d),h].filter(
2Boolean).join(" ");return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":g,className:l,onClick:()=>!t&&a(!s),disabled:t,children:e.jsx("span",{className:pe.toggle__thumb})}),i&&e.jsx("input",{type:"hidden",name:i,value:s?"1":"0"})]})},as=({state:s,permission:a,status:t,pending:i,onTogglePush:d,onToggleType:h})=>{const g=t!=="ready",l=a==="denied",f=a!=="unsupported",r=a==="granted"&&s.pushEnabled,o=g||l||i==="push",b=r,p=g;return e.jsxs("div",{className:"flex flex-col gap-800 w-full",children:[e.jsx(D,{fullWidth:!1,children:"Notifications"}),t==="error"&&e.jsxs(J,{type:"error",closable:!1,children:[e.jsx(Ae,{children:"Impossible de charger vos préférences."}),e.jsx(K,{children:"Réessayez plus tard."})]}),l&&e.jsxs(J,{type:"warning",closable:!1,children:[e.jsx(Ae,{children:"Notifications bloquées par le navigateur."}),e.jsx(K,{children:"Autorisez les notifications dans les réglages de votre navigateur pour pouvoir les activer ici."})]}),f&&e.jsx(V,{children:e.jsx(A,{label:"Autoriser les notifications push",description:"Recevez une alerte sur cet appareil pour les nouveautés qui vous concernent.",control:e.jsx(de,{checked:r,onChange:d,disabled:o,name:"push-enabled",ariaLabel:"Autoriser les notifications push"})})}),b&&e.jsx(V,{title:"Types de notifications push",className:"bg-background-accent rounded-default p-600",children:s.types.map(x=>e.jsx(A,{label:x.label,description:x.description,control:e.jsx(de,{checked:x.enabled,onChange:_=>h(x.id,_),disabled:p||i===x.id,name:`type-${x.id}`,ariaLabel:x.label})},x.id))})]})},rs={id:"community",kind:"workflows",label:"Communauté",description:"Réponses et réactions à vos commentaires.",workflowIds:["comment-reply","comment-interactions","comment-highlighted"]};function os(s){return[{id:"edito",kind:"topic",topic:"edito",label:s?"Articles essentiels":"Articles importants",description:"Une sélection d’articles majeurs par la rédaction."},{id:"lives",kind:"topic",topic:"lives",label:"Lives et événements",description:"Directs et événements à suivre en temps réel."},{id:"newsletters",kind:"topic",topic:"newsletters",label:"Newsletters",description:"Une nouvelle édition de vos newsletters est disponible."},rs]}function Oe(s,a,t={}){var r;const i=Array.isArray(s)||s===null||typeof s!="object"?{}:s,d=(r=i.global)==null?void 0:r.channels,h=(d==null?void 0:d.push)??!0,g=(d==null?void 0:d.email)??!1,l=new Map((i.workflows??[]).filter(o=>{var b;return!!((b=o.workflow)!=null&&b.identifier)}).map(o=>[o.workflow.identifier,o])),f=o=>{var p;const b=l.get(o);return b===void 0||b.enabled!==!1&&((p=b.channels)==null?void 0:p.in_app)!==!1};return{pushEnabled:h,emailRelay:g,types:a.map(o=>({...o,enabled:o.kind==="topic"?t[o.topic]??!0:o.workflowIds.every(f)}))}}const De="Impossible de mettre à jour vos préférences de notifications.",is="Impossible d'activer les notifications sur cet appareil.",ls=()=>{const{isNumerama:s}=at(),a=n.useMemo(()=>os(s),[s]),[t,i]=n.useState(()=>Oe(null,a)),d=rt(),[h,g]=n.useState("loading"),[l,f]=n.useState(null);n.useEffect(()=>{let b=!1;return ot(yt).then(p=>{b||(i(Oe(p.preferences,a,p.topics)),g("ready"))}).catch(()=>{b||g("error")}),()=>{b=!0}},[a]);const r=n.useCallback(async b=>{if(f("push"),b&&await it()!=="granted"){f(null);return}if(b&&lt()&&!await ct()){f(null),O.error(is);return}const p=t;i({...t,pushEnabled:b});try{await Le({channel:"push",enabled:b})}catch{i(p),O.error(De)}finally{f(null)}},[t]),o=n.useCallback(async(b,p)=>{const x=t.types.find(v=>v.id===b);if(!x)return;f(b);const _=t;i({...t,types:t.types.map(v=>v.id===b?{...v,enabled:p}:v)});try{await(x.kind==="topic"?wt(x.topic,p):Promise.all(x.workflowIds.map(v
2=>Le({workflowId:v,channels:["in_app","push"],enabled:p}))))}catch{i(_),O.error(De)}finally{f(null)}},[t]);return e.jsx(as,{state:t,permission:d,status:h,pending:l,onTogglePush:r,onToggleType:o})},Te="user-color-scheme",$e="data-scheme",cs=[],ds=({isPremiumUser:s=!1,initialSettings:a=cs,restNonce:t})=>{const[i,d]=n.useState(()=>localStorage.getItem(Te)||"system"),[h,g]=n.useState(()=>a.map(u=>u.name==="premiumThemeEnabled"?{...u,checked:!document.body.classList.contains("has-premium-theme")}:u)),[l,f]=n.useState(null),[r]=n.useState(vt),[o,b]=n.useState(_t),p=n.useCallback((u,y={})=>fetch(u,{...y,headers:{"Content-Type":"application/json",...t?{"X-WP-Nonce":t}:{},...y.headers}}),[t]),x=u=>{d(u),u==="system"?(document.documentElement.removeAttribute($e),localStorage.removeItem(Te)):(document.documentElement.setAttribute($e,u),localStorage.setItem(Te,u))},_=u=>{b(u),Tt(u)},v=(u,y)=>{g(c=>c.map(m=>m.name===u?{...m,checked:y}:m)),f(u),u==="premiumThemeEnabled"&&document.body.classList.toggle("has-premium-theme",!y),p("/wp-json/humanoid/v1/account/preferences",{method:"PUT",body:JSON.stringify({[u]:y})}).then(c=>{if(!c.ok)throw new Error("Failed to save");return c.json()}).then(c=>g(c.settings||[])).catch(()=>{g(c=>c.map(m=>m.name===u?{...m,checked:!y}:m)),u==="premiumThemeEnabled"&&document.body.classList.toggle("has-premium-theme",y)}).finally(()=>f(null))};return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Personnalisation"}),e.jsxs(V,{children:[e.jsx(A,{label:"Thème",description:"Choisissez l'apparence de l'interface.",className:"lt-md:grid-cols-1",control:e.jsx(dt,{value:i,onValueChange:x,background:"pill",animation:"bounce",children:e.jsxs(ut,{children:[e.jsx(je,{value:"dark",icon:e.jsx(G,{name:"moon",size:16,weight:"fill",color:"inherit"}),children:"Sombre"}),e.jsx(je,{value:"light",icon:e.jsx(G,{name:"sun",size:16,weight:"fill",color:"inherit"}),children:"Clair"}),e.jsx(je,{value:"system",icon:e.jsx(G,{name:"circle-half",size:16,weight:"fill",color:"inherit"}),children:"Système"})]})})}),r&&e.jsx(A,{label:"Retour haptique",description:"Une vibration courte à chaque réaction.",control:e.jsx(de,{checked:o,onChange:_,name:"haptics",ariaLabel:"Retour haptique"})}),s&&h.map(u=>e.jsx(A,{label:u.label,description:u.description,control:e.jsx(de,{checked:u.checked,onChange:y=>v(u.name,y),name:u.name,disabled:l===u.name,ariaLabel:u.label})},u.name))]})]})},us="logo___Oimpr",ms="codeRow___kq56s",ps="code___EFWYV",hs="generateButton___b2VuT",fs="copyButton___FHX0X",se={logo:us,codeRow:ms,code:ps,generateButton:hs,copyButton:fs},xs=({offer:s,onGenerate:a,generating:t=!1,error:i=null})=>{const[d,h]=n.useState(!1),g=n.useCallback(()=>{s.code&&navigator.clipboard.writeText(s.code).then(()=>{h(!0),setTimeout(()=>h(!1),1500)}).catch(()=>{})},[s.code]);return e.jsxs("div",{className:"flex flex-col gap-400 p-600 bg-background-accent rounded-default w-full",children:[e.jsxs("div",{className:"flex gap-400 items-center",children:[s.image&&e.jsx("img",{src:s.image,alt:s.providerName,width:64,height:64,className:se.logo}),e.jsx("h3",{className:"font-fontFamilyPrimary text-xs font-dynamicWeight leading-body text-font-body",children:s.title})]}),e.jsx("p",{className:"font-fontFamilySecondary text-2xs font-normal leading-body text-font-body",children:s.description}),i&&e.jsx(J,{type:"error",children:e.jsx(K,{children:i})}),e.jsxs("div",{className:"flex flex-col gap-300 sm:flex-row sm:items-stretch",children:[s.state==="claimed"&&s.code?e.jsxs("div",{className:se.codeRow,children:[e.jsx("span",{className:se.code,children:s.code}),e.jsx("button",{type:"button",className:se.copyButton,onClick:g,"aria-label":d?"Copié":"Copier",children:e.jsx(G,{name:d?"check":"copy",size:24,color:"inherit"})})]}):e.jsx(q,{type:"button",color:"primary",variant:"contained",className:se.generateButton,disabled:t,onClick:()=>a(s.provider),children:t?"Génération…":s.buttonLabel}),e.jsx(q,{as:"a",href:s.link,color:"primary",variant:"outlined",target:"_blank",rel:"noopener noreferrer",children:s.linkText})]})]})},gs="loadingText___SK8aj",bs="errorText___L9Upm",js="emptyText___jlEKO",Se={loadingText:gs,errorText:bs,emptyText:js},Be="Impossible de charger les promotions.",ne="La génération du code a échoué.",ys=({restNonce:s,fetchOffers:a,generateCode:t})=>{const[i,d]=n.useState([]),[h,g]=n.useState(!0),[l,f]=n.useState(null),[r,o]=n.useState(new Set),[b,p]=n.useState({}),x=n.useCallback((u,y={})=>fetch(u,{...y,headers:{"Content-Type":"application/json",...s?{"X-WP-Nonce":s}:{},...y.headers}}),[s]);n.useEffect(()=>{let u=!1;const y=a??(async()=>{var w;const c=await x("/api/account/promotional-offers");if(!c.ok)throw new Error(Be);const m=await c.json();return((w=m==null?void 0:m.data)==null?void 0:w.offers)??[]});return g(!0),f(null),y().then(c=>{u||d(c)}).catch(()=>{u||f(Be)}).finally(()=>{u||g(!1)}),()=>{u=!0}},[a,x]);const _=n.useCallback(async u=>{o(c=>new Set(c).add(u)),p(c=>({...c,[u]:void 0}));const y=t??(async c=>{var j;let m;try{m=await x(`/api/account/promotional-offers/${encodeURIComponent(c)}/code`,{method:"POST"})}catch{throw new Error(ne)}let w;try{w=await m.json()}catch{throw new Error(ne)}if(!m.ok)throw new Error(typeof((j=w==null?void 0:w.error)==null?void 0:j.message)=="str
2ing"?w.error.message:ne);if(!(w!=null&&w.data))throw new Error(ne);return w.data});try{const{code:c}=await y(u);d(m=>m.map(w=>w.provider===u?{...w,state:"claimed",code:c}:w))}catch(c){const m=c instanceof Error&&c.message?c.message:ne;p(w=>({...w,[u]:m}))}finally{o(c=>{const m=new Set(c);return m.delete(u),m})}},[t,x]);let v;return h?v=e.jsx("p",{className:`${Se.loadingText} w-full text-center`,children:"Chargement…"}):l?v=e.jsx("p",{className:`${Se.errorText} w-full text-center`,children:l}):i.length===0?v=e.jsx("p",{className:`${Se.emptyText} w-full`,children:"Aucune promotion en ce moment."}):v=e.jsx("div",{className:"flex flex-col gap-600 w-full",children:i.map(u=>e.jsx(xs,{offer:u,onGenerate:_,generating:r.has(u.provider),error:b[u.provider]??null},u.provider))}),e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Promotions"}),v]})},ws="textarea__wrapper___Wy5IZ",vs="textarea___pbgpP",_s="textarea__outer___sGMu5",Ts="textarea__copy___Suaxi",W={textarea__wrapper:ws,textarea:vs,"textarea--resize-none":"textarea--resize-none___QZGuU","textarea--resize-vertical":"textarea--resize-vertical___dC3LU","textarea--resize-horizontal":"textarea--resize-horizontal___QseXQ","textarea--resize-both":"textarea--resize-both___lr0x3","textarea__wrapper--error":"textarea__wrapper--error___eqfq8","textarea__wrapper--success":"textarea__wrapper--success___41Vw0","textarea__wrapper--disabled":"textarea__wrapper--disabled___q84Vy",textarea__outer:_s,textarea__copy:Ts},Ss=({id:s,name:a,value:t,placeholder:i,disabled:d=!1,variant:h="default",rows:g=4,resize:l="vertical",copyable:f=!1,onCopy:r,glass:o,className:b,...p})=>{const x=n.useRef(null),[_,v]=n.useState(!1),u=n.useCallback(()=>{var j;const w=((j=x.current)==null?void 0:j.value)??"";navigator.clipboard.writeText(w).then(()=>{v(!0),setTimeout(()=>v(!1),2e3),r==null||r()})},[r]),y=[W.textarea__wrapper,h!=="default"?W[`textarea__wrapper--${h}`]:"",d?W["textarea__wrapper--disabled"]:"",Ee(o),!f&&b].filter(Boolean).join(" "),c=[W.textarea,W[`textarea--resize-${l}`]].filter(Boolean).join(" "),m=e.jsx("div",{className:y,children:e.jsx("textarea",{ref:x,id:s,name:a,value:t,placeholder:i,disabled:d,rows:g,className:c,...p})});return f?e.jsxs("div",{className:`${W.textarea__outer} ${b??""}`.trim(),children:[m,e.jsx("button",{type:"button",className:W.textarea__copy,onClick:u,"aria-label":_?"Copié":"Copier",children:e.jsx(G,{name:_?"check":"copy",size:40,color:"inherit"})})]}):m},Cs="description___mNTBE",Es="rssUrlLabel___O20K2",ze={description:Cs,rssUrlLabel:Es},Ns=[],ks=[],Fs=({description:s,initialCategories:a=Ns,initialSettings:t=ks,rssUrl:i="",restNonce:
2d})=>{const[h,g]=n.useState(a),[l,f]=n.useState(t),[r,o]=n.useState(i),[b,p]=n.useState(null),x=n.useCallback((j,C={})=>fetch(j,{...C,headers:{"Content-Type":"application/json",...d?{"X-WP-Nonce":d}:{},...C.headers}}),[d]),_=n.useMemo(()=>h.length>0&&h.every(j=>j.checked),[h]),u=n.useMemo(()=>h.some(j=>j.checked),[h])&&!_,y=n.useCallback(async(j,C)=>{const k=await x("/wp-json/humanoid/v1/account/rss-preferences",{method:"PUT",body:JSON.stringify({categories:j.filter(N=>N.checked).map(N=>N.slug),settings:Object.fromEntries(C.map(N=>[N.name,N.checked]))})}),T=await k.json();if(!k.ok)throw new Error("Failed to save");return T.rssUrl!==void 0&&o(T.rssUrl),T},[x]),c=()=>{const j=!_,C=h.map(k=>({...k,checked:j}));g(C),p("all"),y(C,l).catch(()=>g(k=>k.map(T=>({...T,checked:!j})))).finally(()=>p(null))},m=(j,C)=>{const k=h.map(T=>T.slug===j?{...T,checked:C}:T);g(k),p(j),y(k,l).catch(()=>g(T=>T.map(N=>N.slug===j?{...N,checked:!C}:N))).finally(()=>p(null))},w=(j,C)=>{const k=l.map(T=>T.name===j?{...T,checked:C}:T);f(k),p(j),y(h,k).catch(()=>f(T=>T.map(N=>N.name===j?{...N,checked:!C}:N))).finally(()=>p(null))};return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Flux RSS"}),s&&e.jsx("p",{className:`${ze.description} w-full`,children:s}),h.length>0&&e.jsxs("div",{className:"flex flex-col gap-700 w-full px-300",children:[e.jsx(Fe,{checked:_,indeterminate:u,onChange:c,label:"Tous les univers"}),e.jsx("div",{className:"flex flex-col gap-600 pl-600",children:h.map(j=>e.jsx(Fe,{checked:j.checked,onChange:C=>m(j.slug,C),label:j.label},j.slug))})]}),l.length>0&&e.jsx(V,{children:l.map(j=>e.jsx(A,{label:j.label,description:j.description,control:e.jsx(de,{checked:j.checked,onChange:C=>w(j.name,C),name:j.name,disabled:b===j.name,ariaLabel:j.label})},j.name))}),r&&e.jsxs("div",{className:"flex flex-col gap-300 w-full",children:[e.jsx("p",{className:ze.rssUrlLabel,children:"Votre flux RSS personnalisé"}),e.jsx(Ss,{value:r,readOnly:!0,copyable:!0,onCopy:()=>O.success("Lien copié dans le presse-papiers."),rows:4,resize:"none"})]})]})},Ps="cancelButton___qJ3MA",As="cancelNotice___je019",Ls="reactivateButton___DCp0w",Ms="loadingText___yGvnA",Rs="errorText___t4XfO",Is="subscribeButton___Yi849",Os="historyTitle___P-AAV",U={cancelButton:Ps,cancelNotice:As,reactivateButton:Ls,loadingText:Ms,errorText:Rs,subscribeButton:Is,historyTitle:Os},Ds=({isPremiumUser:s,restNonce:a})=>{const[t,i]=n.useState(null),[d,h]=n.useState([]),[g,l]=n.useState(!0),[f,r]=n.useState(null),[o,b]=n.useState(!1),[p,x]=n.useState(!1),_=n.useCallback((c,m={})=>fetch(c,{...m,headers:{"Content-Type":"application/json",...a?{"X-WP-Nonce":a}:{},...m.headers}}),[a]);n.useEffect(()=>{(async()=>{try{const[m,w]=await Promise.all([_("/wp-json/humanoid/v1/account/subscription"),_("/wp-json/humanoid/v1/account/subscriptions/history")]);if(m.ok){const j=await m.json();i(j.subscription)}if(w.ok){const j=await w.json();h(j.subscriptions||[])}}catch{r("Impossible de charger les informations d'abonnement.")}finally{l(!1)}})()},[_]);const v=async()=>{b(!0);try{const c=await _("/wp-json/humanoid/v1/account/subscription/billing-portal",{method:"POST"}),m=await c.json();if(c.ok&&m.url){window.location.href=m.url;return}r(m.error||"Impossible d'ouvrir le portail de gestion.")}catch{r("Impossible d'ouvrir le portail de gestion.")}finally{b(!1)}},u=async()=>{x(!0),r(null);try{const c=await _("/wp-json/humanoid/v1/account/subscription/checkout",{method:"POST"}),m=await c.json();if(c.ok&&m.url){window.location.href=m.url;return}r(m.error||"Impossible de créer la session de paiement.")}catch{r("Impossible de créer la session de paiement.")}finally{x(!1)}};if(g)return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),e.jsx("p",{className:`${U.loadingText} text-center w-full`,children:"Chargement..."})]});if(f&&!t)return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),e.jsx("p",{className:`${U.errorText} text-center w-full`,children:f})]});if(!t)return s?e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),e.jsx("p",{className:"font-fontFamilySecondary text-2xs font-normal leading-body text-font-body w-full",children:"En tant qu'utilisateur à privilèges, vous disposez déjà de toutes les fonctionnalités premium sans adhésion liée."})]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),e.jsx(Pe,{className:"items-start gap-800",variant:"page"}),f&&e.jsx("p",{className:`${U.errorText} text-center w-full`,children:f}),e.jsx("button",{type:"button",className:U.subscribeButton,onClick:u,disabled:p,children:p?"Redirection...":"S'abonner"})]});if(t.status==="canceled")return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),e.jsxs(V,{children:[e.jsx(A,{label:"Statut",value:"Abonnement résilié"}),t.dateEnd&&e.jsx(A,{label:"Fin d'adhésion",value:t.dateEnd})]}),e.jsx(Pe,{className:"items-start gap-800",variant:"page"}),f&&e.jsx("p",{className:`${U.errorText} text-center w-full`,children:f}),e.jsx("button",{type:"button",className:U.subscribeButton,onClick:u,disabled:p,children:p?"Redirection...":"S'abonner à nouveau"})]});const y=t.cancelAtPeriodEnd;return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Abonnement"}),y&&e.jsxs("p",{className:U.cancelNotice,children:["Votre abonnement a été résilié. Vous conservez votre accès jusqu'au ",t.dateCancel,"."]}),e.jsxs(V,{children:[t.title&&e.jsx(A,{label:"Type d'abonnement",value:t.title}),t.dateStart&&e.jsx(A,{label:"Date d'adhésion",value:t.dateStart}),t.dateEnd&&e.jsx(A,{label:t.dateEndLabel,value:t.dateEnd}),t.paymentMethod&&e.jsx(A,{label:"Méthode de paiement",value:`${t.paymentMethod.brand} ${t.paymentMethod.last4}...`,onAction:v}),e.jsx(A,{label:"Historique de paiement et factures",actionLabel:"Voir",icon:"eye",onAction:v}),t.hasRecurringPayment&&!y&&e.jsx(A,{label:"Renouvellement automatique",actionLabel:"Désactiver",icon:"close",onAction:v})]}),e.jsx("button",{type:"button",className:y?U.reactivateButton:U.cancelButton,onClick:v,disabled:o,children:o?"Redirection...":y?"Réactiver l'abonnement":"Résilier l'abonnement"}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:U.historyTitle,children:"Historique des abonnements"}),e.jsx(V,{children:d.map((c,m)=>e.jsx(A,{label:c.title||"Abonnement",description:[c.dateStart&&`Du ${c.dateStart}`,c.dateEnd&&`au ${c.dateEnd}
2`].filter(Boolean).join(" "),value:c.status==="canceled"?"Résilié":c.status==="expired"?"Expiré":c.status},m))})]})]})},$s="grid___K3NAU",Bs={grid:$s},zs=({newsletters:s,nonce:a,ajaxUrl:t="/wp-admin/admin-ajax.php",userToken:i,isPremiumUser:d=!1})=>{const[h,g]=n.useState(s),[l,f]=n.useState(null);n.useEffect(()=>{document.dispatchEvent(new Event("updateLazyload"))},[]);const r=n.useCallback(async o=>{const b=o.subscribed?"unsubscribeFromNewsletter":"subscribeToNewsletter";f(o.id),g(p=>p.map(x=>x.id===o.id?{...x,subscribed:!x.subscribed}:x));try{const p=new FormData;p.append("action",b),p.append("nonce",a??""),p.append("userToken",i??""),p.append("uniqueListKey",o.uniqueListKey);const _=await(await fetch(new URL(t,window.location.origin),{method:"POST",body:p})).json();if(!_.success)throw new Error(_.message||"Request failed");O.success(o.subscribed?`Désabonné de ${o.title}`:`Abonné à ${o.title}`)}catch{g(p=>p.map(x=>x.id===o.id?{...x,subscribed:o.subscribed}:x)),O.error("Une erreur est survenue. Veuillez réessayer.")}finally{f(null)}},[t,a,i]);return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Newsletters"}),e.jsx("div",{className:Bs.grid,children:h.map(o=>e.jsx(St,{newsletter:o,onToggle:r,loading:l===o.id,isPremiumUser:d},o.id))})]})},Us="sectionsCell___B2dq3",qs="dialogText___tfDJ3",Vs="consequences___h8DZd",Gs="dangerZone___drjjf",Hs="dangerRow___DsSdQ",X={sectionsCell:Us,dialogText:qs,consequences:Vs,dangerZone:Gs,dangerRow:Hs},Ws={google:{icon:"google",color:"none"},apple:{icon:"apple",color:"inherit"},twitter:{icon:"x-twitter",color:"inherit"},facebook:{icon:"facebook",color:"inherit"}},Xs=[],Ce={"modifier-email":"email","mot-de-passe":"password","supprimer-mon-compte":"delete"},Ue=s=>s in Ce?"informations-generales":s,un=({activeRoute:s,ajaxUrl:a,bookmarksGetGrouped:t,promotionsFetchOffers:i,promotionsGenerateCode:d,funnelUrl:h,help:g,isNumerama:l,isProtectedAccount:f,isPremiumUser:r,sectionTransition:o="auto",logoutUrl:b,newsletters:p,newsletterNonce:x,newsletterUserToken:_,premiumBrandName:v,premiumSettings:u,restNonce:y,rssCategories:c,rssDescription:m,rssSettings:w,rssUrl:j,routes:C,socialProviders:k,user:T,form:N,flash:E=Xs})=>{const[F,M]=n.useState(()=>Ue(s)),[R,S]=n.useState(()=>Ce[s]??null),P=qe(),[I,$]=n.useState(T),[H,Y]=n.useState(T.displayName),[Xe,Ne]=n.useState(T.email),Je=()=>{S(null),Y(I.displayName),Ne(I.email)};n.useEffect(()=>{E.forEach(L=>{(O[L.type]??O.info)(L.message)})},[]);const Ke=n.useCallback(L=>{const B=C.find(Z=>Z.slug===L);if(B!=null&&B.external){window.location.href=B.url;return}M(L),S(null),B&&window.history.pushState({tab:L},"",B.url)},[C]);n.useEffect(()=>{const L=()=>{const Z=window.location.pathname.split("/").filter(Boolean),te=Z.indexOf("mon-compte");return te>=0&&Z[te+1]||"informations-generales"},B=Z=>{var ke;const te=((ke=Z.state)==null?void 0:ke.tab)??L();M(Ue(te)),S(Ce[te]??null)};return window.addEventListener("popstate",B),()=>window.removeEventListener("popstate",B)},[]),n.useEffect(()=>{var L;r&&((L=window.__optimusFeatures)!=null&&L.bookmarks)&&xe.init().then(()=>xe.preloadCards()).catch(()=>{})},[r]);const be=n.useMemo(()=>C.filter(L=>!L.external),[C]),Ye=n.useMemo(()=>be.map(L=>L.slug),[be]),Ze={"informations-generales":e.jsx(Js,{user:I,form:N,isProtectedAccount:f,logoutUrl:b,premiumBrandName:v,restNonce:y,socialProviders:k,displayName:H,email:Xe,openDialog:R,setDisplayName:Y,setEmail:Ne,setOpenDialog:S,setUser:$,closeDialog:Je}),personnalisation:e.jsx(ds,{isPremiumUser:r,initialSettings:u,restNonce:y}),newsletters:p?e.jsx(zs,{newsletters:p,nonce:x,ajaxUrl:a,userToken:_,isPremiumUser:r}):null,signets:e.jsx(ts,{restNonce:y,getGrouped:t}),notifications:e.jsx(ls,{}),"flux-rss":e.jsx(Fs,{description:m,initialCategories:c,initialSettings:w,rssUrl:j,restNonce:y}),adhesion:e.jsx(Ds,{isPremiumUser:r,restNonce:y,funnelUrl:h}),promotions:e.jsx(ys,{restNonce:y,fetchOffers:i,generateCode:d}),aide:g?e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Aide"}),e.jsx("p",{className:"font-fontFamilySecondary text-2xs font-normal leading-body text-font-body w-full",dangerouslySetInnerHTML:{__html:g.text}}),e.jsx(q,{as:"a",href:g.buttonUrl,color:"primary",variant:"contained",children:g.buttonLabel})]}):null};return e.jsx(mt,{isNumerama:l,children:e.jsxs(He,{value:F,onValueChange:Ke,orientation:P?"horizontal":"vertical",corners:"medium",animation:"liquid",className:"gap-2400 py-1000 lt-md:gap-600 lt-md:py-600",children:[e.jsx(kt,{logoutUrl:b,routes:C,hasExternalTabsProvi
2der:!0}),e.jsx("main",{className:`w-full min-w-0 ${X.sectionsCell}`,children:e.jsx(Ut,{"aria-label":"Sections du compte",values:Ye,isSwipeEnabled:o==="auto"?P:o==="swipe",children:be.map(L=>e.jsx(bt,{value:L.slug,className:"flex flex-col gap-800 items-start",children:Ze[L.slug]??null},L.slug))})})]})})},Js=({user:s,form:a,isProtectedAccount:t,logoutUrl:i,premiumBrandName:d,restNonce:h,socialProviders:g,displayName:l,email:f,openDialog:r,setDisplayName:o,setEmail:b,setOpenDialog:p,setUser:x,closeDialog:_})=>{const[v,u]=n.useState(!1),[y,c]=n.useState(null),[m,w]=n.useState(g??[]),[j,C]=n.useState(""),[k,T]=n.useState(a.hasDefaultPassword),[N,E]=n.useState(a.mustRedefinePassword),F=n.useCallback((S,P={})=>fetch(S,{...P,headers:{"Content-Type":"application/json",...h?{"X-WP-Nonce":h}:{},...P.headers}}),[h]),M=S=>{c(null),p(S)},R=()=>{c(null),_()};return e.jsxs(e.Fragment,{children:[e.jsx(D,{children:"Compte"}),e.jsxs(V,{children:[e.jsx(A,{label:"Nom d'affichage",value:s.displayName,onAction:()=>M("display-name")}),!t&&e.jsx(A,{label:"Adresse email",value:s.email,onAction:()=>M("email")}),!t&&e.jsx(A,{label:"Mot de passe",value:k?"Définir":"••••••••",onAction:()=>M("password")}),e.jsx(A,{label:"Cookies publicitaires",actionLabel:"Gérer mes préférences",href:"#preferences-publicitaires",onAction:()=>{var S,P;(P=(S=window.Didomi)==null?void 0:S.preferences)==null||P.show()}})]}),m.length>0&&e.jsxs("div",{className:"flex flex-col gap-300 w-full",children:[e.jsx("h2",{className:"font-fontFamilyPrimary text-xs font-dynamicWeight leading-body text-font-body w-full",children:"Connexion par réseaux sociaux"}),e.jsx(V,{children:m.map(S=>{const P=Ws[S.name];return e.jsx(A,{label:S.label,labelIcon:P&&e.jsx(Ge,{name:P.icon,size:28,color:P.color}),description:S.connected?"Connecté":"Non connecté",actionLabel:S.connected?"Se déconnecter":"Connexion",icon:S.connected?"sign-out":"sign-in",...S.connected?{onAction:async()=>{try{const I=await F("/wp-json/humanoid/v1/account/social-provider",{method:"DELETE",body:JSON.stringify({provider:S.name})}),$=await I.json();I.ok&&$.success&&w(H=>H.map(Y=>Y.name===S.name?{...Y,connected:!1}:Y))}catch{O.error("Erreur lors de la déconnexion.")}}}:{href:S.authUrl}},S.name)})})]}),e.jsx(q,{as:"a",href:i,onClick:Ve,color:"primary",variant:"contained",className:"flex justify-center w-full md:hidden",children:"Se déconnecter"}),!t&&e.jsxs("div",{className:`flex flex-col gap-150 p-600 bg-background-accent rounded-default w-full ${X.dangerZone}`,children:[e.jsxs("h2",{className:"flex items-center gap-150 font-fontFamilyPrimary text-xs font-dynamicWeight leading-body text-font-body",children:["Paramètres sensibles",e.jsx(G,{name:"warning-circle",size:20,color:"inherit",weight:"fill"})]}),e.jsx("p",{className:"font-fontFamilyTertiary text-5xs font-normal leading-[0.875rem] text-font-body",children:"Les actions de cette section sont définitives et ne peuvent être annulées."}),e.jsx(V,{children:e.jsx(A,{label:"Suppression du compte",description:"Les données effacées ne pourront être récupérées.",actionLabel:"Supprimer",icon:"trash",onAction:()=>M("delete"),className:X.dangerRow})})]}),e.jsx(ae,{isOpen:r==="display-name",onClose:R,children:e.jsxs(re,{size:"medium",autoHeight:!0,children:[e.jsx(oe,{children:e.jsx(ie,{children:"Modifier le nom d'affichage"})}),e.jsxs("form",{className:"flex flex-col gap-600",onSubmit:async S=>{if(S.preventDefault(),!l.trim()){O.error("Le nom d'affichage ne peut pas être vide.");return}u(!0),c(null);try{const P=await F("/wp-json/humanoid/v1/account/profile",{method:"PUT",body:JSON.stringify({display_name:l.trim()})}),I=await P.json();if(!P.ok||!I.success){c(I.error||"Une erreur est survenue.");return}x($=>({...$,displayName:I.user.displayName})),pt(),O.success("Nom d'affichage mis à jour."),R()}catch{c("Une erreur est survenue.")}finally{u(!1)}},children:[e.jsxs(ue,{className:"flex flex-col gap-600",scrollable:!1,children:[y&&e.jsx(J,{type:"error",closable:!0,onClose:()=>c(null),children:e.jsx(K,{children:y})}),e.jsx(le,{id:"display-name",name:"display_name",label:"Nom d'affichage",type:"text",value:l,placeholder:"e.g. John Doe",maxLength:30,onChange:S=>o(S.target.value),helperText:`${l.length}/30 caractères`})]}),e.jsx(fe,{children:e.jsx(q,{type:"submit",color:"primary",variant:"contained",disabled:v,children:"Sauvegarder"})})]})]})}),e.jsx(ae,{isOpen:r==="email",onClose:()=>{C(""),R()},children:e.jsxs(re,{size:"medium",autoHeight:!0,children:[e.jsx(oe,{children:e.jsx(ie,{children:"Modifier l'adresse email"})}),e.jsxs("form",{className:"flex flex-col gap-600",noValidate:!0,onSubmit:async S=>{if(S.preventDefault(),!f||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)){c("Veuillez entrer une adresse email valide.");return}u(!0),c(null);try{const P={user_email:f};k||(P.password=j);
2const I=await F("/wp-json/humanoid/v1/account/profile",{method:"PUT",body:JSON.stringify(P)}),$=await I.json();if(!I.ok||!$.success){c($.error||"Une erreur est survenue.");return}x(H=>({...H,email:$.user.email})),C(""),O.success("Adresse email mise à jour."),R()}catch{c("Une erreur est survenue.")}finally{u(!1)}},children:[e.jsxs(ue,{className:"flex flex-col gap-800",scrollable:!1,children:[y&&e.jsx(J,{type:"error",closable:!0,onClose:()=>c(null),children:e.jsx(K,{children:y})}),e.jsx(le,{id:"user-email",name:"user_email",label:"Adresse email",type:"email",value:f,placeholder:"e.g. [email protected]",onChange:S=>b(S.target.value)}),!k&&e.jsx(le,{id:"email-password",name:"password",label:"Mot de passe actuel",type:"password",autoComplete:"current-password",placeholder:"••••••••",value:j,onChange:S=>C(S.target.value)})]}),e.jsx(fe,{children:e.jsx(q,{type:"submit",color:"primary",variant:"contained",disabled:v,children:"Sauvegarder"})})]})]})}),e.jsx(ae,{isOpen:r==="password",onClose:R,children:e.jsxs(re,{size:"medium",autoHeight:!0,children:[e.jsxs(oe,{children:[e.jsx(ie,{children:k?"Définir un mot de passe":"Modifier le mot de passe"}),k&&e.jsx(he,{children:"Définissez un mot de passe pour vous connecter avec votre adresse email."}),N&&!k&&e.jsx(he,{children:"Votre mot de passe actuel a été identifié comme n'étant pas suffisamment sécurisé. Veuillez définir un nouveau mot de passe ci-dessous."})]}),e.jsx(ue,{className:"flex flex-col gap-400",scrollable:!1,children:e.jsx(Vt,{hasDefaultPassword:k,restNonce:h,onSuccess:()=>{T(!1),E(!1),R()}})})]})}),e.jsx(ae,{isOpen:r==="delete",onClose:R,children:e.jsxs(re,{size:"medium",autoHeight:!0,children:[e.jsxs(oe,{children:[e.jsx(ie,{children:"Supprimer mon compte"}),e.jsx(he,{children:"Attention, toute suppression de compte est définitive ! Les données effacées ne pourront être récupérées."})]}),e.jsxs("form",{className:"flex flex-col gap-600",name:"deleteform",id:"deleteform",onSubmit:async S=>{var P;S.preventDefault(),u(!0),c(null);try{const I=k||(P=S.currentTarget.elements.namedItem("old_pass_confirm"))==null?void 0:P.value,$=await F("/wp-json/humanoid/v1/account/delete",{method:"DELETE",body:JSON.stringify({password:I})}),H=await $.json();if(!$.ok||!H.success){c(H.error||"Une erreur est survenue.");return}window.location.href="/connexion"}catch{c("Une erreur est survenue.")}finally{u(!1)}},children:[e.jsxs(ue,{className:"flex flex-col gap-400",scrollable:!1,children:[y&&e.jsx(J,{type:"error",closable:!0,onClose:()=>c(null),children:e.jsx(K,{children:y})}),e.jsxs("div",{className:`${X.consequences} ${X.dialogText}`,children:[e.jsx("p",{className:X.dialogText,children:"En cliquant sur le bouton ci-dessous, voici ce qu'il va se passer :"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Toutes vos données personnelles (identifiant, compte, réseaux sociaux) seront effacées."}),e.jsxs("li",{children:["Si vous êtes adhérent·e ",d||"Numerama+",", vous perdrez votre adhésion définitivement sans possibilité de remboursement."]})]})]}),!k&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:X.dialogText,children:"Merci de rentrer le mot de passe associé à votre compte pour confirmer sa suppression"}),e.jsx(le,{id:"password",name:"old_pass_confirm",label:"Mot de passe",type:"password",autoComplete:"current-password",placeholder:"••••••••"})]})]}),e.jsx(fe,{children:e.jsx(q,{type:"submit",name:"wp-submit",color:"primary",variant:"contained",disabled:v,children:"Supprimer définitivement mon compte"})})]})]})})]})};export{un 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.