PageSourceSearch

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

js numerama.com collected 2026-10-01 09:05:13 UTC 51,113 bytes, 2 lines download raw bytes

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