1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3779],{13779:(e,t,s)=>{s.r(t),s.d(t,{GiftDialogContent:()=>B,PayGift:()=>M});var a=s(37876),r=s(92035),n=s(33560),i=s(48325),l=s(96367),o=s(14232),c=s(45195);let d=o.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("textarea",{className:(0,c.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:t,...r})});d.displayName="Textarea";var u=s(28249),p=s(35739),m=s(45966),x=s(48230),h=s.n(x),f=s(15707),g=s(74485),j=s(89099),v=s(65364);let b="true"===v.env.NEXT_PUBLIC_ENABLE_SPECIAL_OPERATION,y="true"===v.env.NEXT_PUBLIC_ENABLE_NOEL_OPERATION,N={passionne:{amount:34700},passionne12:{amount:43440},pro:{amount:69700},pro12:{amount:87120}},w={passionne:{amount:23700},passionne12:{amount:29700},pro:{amount:48700},pro12:{amount:59700}},C=e=>{let t=e/100;return e%100==0?t.toFixed(0):t.toFixed(2).replace(".",",")},E=e=>{var t,s,a,r;return b&&(null==(t=w[e])?void 0:t.amount)?{original:(null==(r=N[e])?void 0:r.amount)||0,discounted:w[e].amount,hasDiscount:!0}:{original:(null==(s=N[e])?void 0:s.amount)||0,discounted:(null==(a=N[e])?void 0:a.amount)||0,hasDiscount:!1}},T=e=>{let{onClick:t,className:s=""}=e;return(0,a.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),t()},className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors ".concat(s),type:"button",style:{pointerEvents:"auto"},children:(0,a.jsx)(u.A,{className:"h-5 w-5 cursor-pointer"})})},k=e=>{let{children:t,className:s=""}=e;return(0,a.jsx)("h2",{className:"text-8xl font-rama text-center uppercase ".concat(s),children:t})},_=e=>{let{children:t,className:s=""}=e;return(0,a.jsx)("p",{className:"text-2xl text-gray-700 mb-5 text-center font-cursive ".concat(s),children:t})},S=e=>{let{className:t=""}=e;return(0,a.jsxs)("div",{className:"p-3 sm:p-4 border border-gray-300 ".concat(t),children:[(0,a.jsx)("h3",{className:"font-semibold mb-2 text-sm text-gray-900",children:"Comment \xe7a marche"}),(0,a.jsxs)("ul",{className:"space-y-1 text-xs sm:text-sm text-gray-700",children:[(0,a.jsx)("li",{children:"⢠Choisis le cadeau que tu veux offrir"}),(0,a.jsx)("li",{children:"⢠Personnalise ton message"}),(0,a.jsx)("li",{children:"⢠Effectue le paiement en toute s\xe9curit\xe9"}),(0,a.jsx)("li",{children:"⢠Le destinataire aura 6 mois pour activer sa carte cadeau depuis son propre compte"})]})]})},A=e=>{let{className:t=""}=e,s=E("passionne"),r=E("pro");return(0,a.jsxs)("div",{className:"p-3 sm:p-4 border border-gray-300 ".concat(t),children:[(0,a.jsx)("h3",{className:"font-semibold mb-2 text-sm text-gray-900",children:"⨠Ce que tu peux offrir"}),(0,a.jsxs)("ul",{className:"space-y-1 text-xs sm:text-sm text-gray-700",children:[(0,a.jsxs)("li",{children:["⢠",(0,a.jsx)("strong",{children:"Un abonnement Passionn\xe9"})," ",s.hasDiscount?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"line-through text-gray-500",children:[C(s.original),"â¬"]})," ",(0,a.jsxs)("span",{className:"text-red font-semibold",children:[C(s.discounted),"â¬"]})]}):(0,a.jsxs)("span",{children:[C(s.original),"â¬"]})," ","- Acc\xe8s aux cours ",(0,a.jsx)(h(),{href:"/cours?filter=Passionn%C3%A9",className:"text-red hover:underline",children:"Passionn\xe9"}),", bonus et Club Passionn\xe9"]}),(0,a.jsxs)("li",{children:["⢠",(0,a.jsx)("strong",{children:"Un abonnement Pro"})," ",r.hasDiscount?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"line-through text-gray-500",children:[C(r.original),"â¬"]})," ",(0,a.jsxs)("span",{className:"text-red font-semibold",children:[C(r.discounted),"â¬"]})]}):(0,a.jsxs)("span",{children:[C(r.original),"â¬"]})," ","- Acc\xe8s a TOUS nos cours, bonus et Club Pro"]}),(0,a.jsxs)("li",{children:["⢠",(0,a.jsx)("strong",{children:"Un cours sp\xe9cifique"})," - Choisis librement parmi tous les cours"]})]})]})},F=e=>{let{children:t,className:s=""}=e;return(0,a.jsx)("div",{className:"bg-yellow-50 p-3 sm:p-4 border border-yellow-200 ".concat(s),children:(0,a.jsxs)("p",{className:"text-yellow-800 text-xs sm:text-sm text-left",children:[(0,a.jsx)("strong",{children:"\uD83D\uDCA1 Bon \xe0 savoir :"})," ",t]})})},L=e=>{let{error:t,isSubmitted:s,children:r,errorMessage:n}=e;return(0,a.jsxs)("div",{children:[r,t&&s&&(0,a.jsx)("p",{className:"text-red-500 text-sm mt-1 text-left",children:n})]})},D=e=>{let{error:t,isSubmitted:s,...r}=e;return(0,a.jsx)(l.p,{...r,className:"".concat(t&&s?"border-red-500 ring-red-500":""," bg-white text-black placeholder-gray-500 rounded-none border-gray-300 py-6 px-3 border")})},P=e=>{let{value:t,onChange:s,error:r,isSubmitted:n,placeholder:i="S\xe9lectionner le cadeau",children:l}=e,[c,d]=(0,o.useState)(!1),[u,p]=(0,o.useState)(!1),m=(0,o.useRef)(null),x=(0,o.useRef)(null);return(0,o.useEffect)(()=>{function e(e){!(!c||m.current&&m.current.contains(e.target))&&(x.current&&x.current.contains(e.target)||d(!1))}let t=setTimeout(()=>{document.addEventListener("mousedown",e)},0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[c]),(0,o.useEffect)(()=>
1{if(c&&x.current){let e=x.current;p(e.scrollHeight>e.clientHeight)}},[c,l]),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{ref:m,type:"button",className:"".concat(r&&n?"border-red-500 ring-red-500":""," bg-white text-black w-full rounded-none border-gray-300 p-3 border flex items-center justify-between gap-2"),onClick:()=>d(e=>!e),"aria-haspopup":"listbox","aria-expanded":c,children:[(0,a.jsx)("span",{className:"truncate text-left flex-1",children:(()=>{let e=i;return o.Children.forEach(l,s=>{s&&"div"===s.type&&s.props&&s.props["data-select-item"]&&s.props.value===t&&(e=s.props.children)}),e})()}),(0,a.jsx)("span",{className:"opacity-50",children:"â¼"})]}),c&&(0,a.jsxs)("div",{ref:x,role:"listbox",className:"absolute z-60 mt-1 p-4 max-h-72 w-full overflow-auto bg-gray-50 text-black border border-gray-300 rounded-none shadow-xl",children:[u&&(0,a.jsx)("div",{className:"text-center text-gray-400 text-xs mb-2 flex items-center justify-center gap-1",children:(0,a.jsx)("span",{children:"â D\xe9filer pour voir plus"})}),l&&o.Children.map(l,e=>{if(!e)return null;if("div"===e.type&&e.props["data-select-label"]){let t=e.props.className?" ".concat(e.props.className):"";return(0,a.jsx)("div",{className:"px-2 py-1.5 text-xs tracking-widest font-semibold text-black border-b border-gray-300 uppercase".concat(t),children:e.props.children})}if("div"===e.type&&e.props["data-select-item"]){let r=e.props.value,
1n=t===r;return(0,a.jsx)("div",{role:"option","aria-selected":n,className:"whitespace-normal cursor-pointer text-black hover:bg-gray-100 px-2 py-2 ".concat(n?"bg-gray-50":""," ").concat(e.props.className||""),onClick:()=>{null==s||s(r),d(!1)},children:e.props.children})}return null})]})]})},O=e=>{let{isSubmitted:t,className:s=""}=e;return(0,a.jsx)(r.A,{type:"submit",disabled:t,className:"bg-red text-white cursor-pointer ".concat(s),children:t?(0,a.jsx)(p.A,{className:"h-5 w-5 animate-spin animate-fade-in"}):"OFFRIR UNE CARTE CADEAU"})},I=e=>{let{onClick:t,children:s,className:n="",variant:i="secondary"}=e;return(0,a.jsx)(r.A,{variant:i,className:"".concat(n," cursor-pointer"),onClick:t,children:s})},R=()=>(0,a.jsx)(n._,{as:o.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/50 transition-opacity"})}),U=e=>{let{children:t,maxWidth:s="max-w-[1200px]",className:r=""}=e;return(0,a.jsx)("div",{className:"fixed inset-0 z-150 overflow-y-auto",style:{scrollBehavior:"auto"},children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,a.jsx)(n._,{as:o.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsx)(i.Lj,{className:"w-full ".concat(s," transform overflow-visible bg-white shadow-xl transition-all relative ").concat(r),children:t})})})})},G=e=>{let{isOpen:t,onClose:s,children:r,maxWidth:l="max-w-[1200px]",className:c=""}=e;return(0,a.jsx)(n.e,{appear:!0,show:t,as:o.Fragment,children:(0,a.jsxs)(i.lG,{as:"div",className:"relative",onClose:s,children:[(0,a.jsx)(R,{}),(0,a.jsxs)(U,{maxWidth:l,className:c,children:[(0,a.jsx)(T,{onClick:s}),r]})]})})},z=e=>{let{isOpen:t,onClose:s,openSignup:l,openLogin:c,router:d}=e;return(0,a.jsx)(n.e,{appear:!0,show:t,as:o.Fragment,children:(0,a.jsxs)(i.lG,{as:"div",className:"relative",onClose:s,children:[(0,a.jsx)(R,{}),(0,a.jsx)("div",{className:"fixed inset-0 z-150 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,a.jsx)(n._,{as:o.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(i.Lj,{className:"sm:max-w-[600px] max-h-[90vh] h-[90vh] sm:h-auto overflow-y-auto p-4 sm:p-6 bg-white border border-gray-300 transform overflow-hidden shadow-xl transition-all relative",children:[(0,a.jsx)(T,{onClick:s}),(0,a.jsx)(k,{children:"La carte cadeau Empara"}),(0,a.jsx)(_,{children:"Fais plaisir \xe0 un proche en lui offrant l'acc\xe8s \xe0 nos formations"}),(0,a.jsxs)("div",{className:"space-y-3 sm:space-y-4 flex-1",children:[(0,a.jsx)(A,{}),(0,a.jsx)(S,{}),(0,a.jsx)(F,{children:"La carte cadeau est valable 6 mois \xe0 compter de la date d'achat"})]}),(0,a.jsx)("div",{className:"flex justify-center mt-4 sm:mt-6",children:(0,a.jsx)(r.A,{className:"bg-red text-white cursor-pointer text-sm px-4 sm:px-6 py-2 sm:py-3",onClick:()=>{(0,f.trackCTAClick)({ctaType:"button",ctaText:"Cr\xe9er mon compte pour continuer",ctaLocation:"gift_popup",ctaDestination:"auth_popup",ctaVariant:"gift_signup"}),s(),l("",d.asPath,null,null,"gift_card")},children:"Cr\xe9er mon compte pour continuer"})}),(0,a.jsx)("p",{className:"text-center text-xs sm:text-sm text-gray-500 mt-3 sm:mt-4",children:(0,a.jsxs)("button",{onClick:()=>{(0,f.trackCTAClick)({ctaType:"link",ctaText:"Connecte-toi",ctaLocation:"gift_popup",ctaDestination:"auth_popup",ctaVariant:"gift_login"}),s(),c("",d.asPath)},className:"text-red hover:underline bg-transparent border-none cursor-pointer",children:["D\xe9j\xe0 un compte ?"," ","Connecte-toi"]})})]})})})})]})})},B=e=>{let{selectedGift:t,setSelectedGift:s,recipientName:r,setRecipientName:n,message:i,handleChangeAera:l,errors:o,isSubmitted:c,handleSubmit:u,giftList:p,CHAR_LIMIT:m}=e,x=E("passionne"),h=E("pro");return(0,a.jsxs)("form",{onSubmit:u,children:[(0,a.jsx)(k,{children:"La carte cadeau Empara"}),(0,a.jsx)(_,{children:"Fais plaisir \xe0 un proche avec la carte cadeau Empara."}),(0,a.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,a.jsx)(L,{error:o.gift,isSubmitted:c,errorMessage:o.gift,children:(0,a.jsxs)(P,{value:t,onChange:e=>s(e),error:o.gift,isSubmitted:c,children:[(0,a.jsx)("div",{"data-select-label":!0,className:"mt-5",children:"Offrir l'abonnement"}),(0,a.jsx)("div",{"data-select-item":!0,value:"passionne",children:(0,a.jsxs)("div",{className:"flex justify-between items-center max-w-[80vw]",children:[(0,a.jsx)("span",{children:"L'offre Passionn\xe9"}),(0,a.jsx)("span",{children:x.hasDiscount?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"line-through text-gray-500 mr-1",children:[C(x.original)," â¬"]}),(0,a.jsxs)("span",{className:"text-red font-semibold",children:[C(x.discounted)," â¬"]})]}):(0,a.jsxs)("span",{children:[C(x.original)," â¬"]})})]})}),(0,a.jsx)("div",{"data-select-item":!0,value:"pro",children:(0,a.jsxs)("div",{className:"flex justify-between items-center max-w-[80vw]",children:[(0,a.jsx)("span",{children:"L'offre Pro"}),(0,a.jsx)("span",{children:h.hasDiscount?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"line-through text-gray-500 mr-1",children:[C(h.original)," â¬"]}),(0,a.jsxs)("span",{className:"text-red font-semibold",children:[C(h.discounted)," â¬"]})]}):(0,a.jsxs)("span",{children:[C(h.original)," â¬"]})})]})}),(0,a.jsx)("div",{"data-select-label":!0,className:"mt-5",children:"Offrir un cours"}),p.map(e=>(0,a.jsx)("div",{"data-select-item":!0,value:e._id,children:(0,a.jsxs)("div",{className:"flex justify-between items-center max-w-[80vw]",children:[(0,a.jsx)("span",{className:"flex-1 min-w-0 overflow-hidden group",children:(0,a.jsx)("span",{className:"inline-block hover:cursor-pointer whitespace-nowrap animate-none group-hover:animate-scroll-left",children:e.title})}),(0,a.jsxs)("div",{className:"shrink-0 ml-2 flex flex-col items-end",children:[y&&(0,a.jsxs)("span",{className:"line-through text-gray-500 text-xs",children:[e.priceAfterLive," â¬"]}),(0,a.jsxs)("span",{className:y?"text-[#aa484d] font-bold":"",children:[y?Math.round(.5*e.priceAfterLive):e.priceAfterLive," â¬"]})]})]})},e._id))]})}),(0,a.jsx)(L,{error:o.name,isSubmitted:c,errorMessage:o.name,children:(0,a.jsx)(D,{id:"name",placeholder:"Pr\xe9nom du receveur",value:r,onChange:e=>n(e.target.value),error:o.name,isSubmitted:c})}),(0,a.jsx)("div",{children:(0,a.jsxs)("div",{className:"relative flex flex-col gap-2",children:[(0,a.jsx)(d,{id:"message",placeholder:"Message (facultatif)",className:"resize-none bg-white text-black placeholder-gray-500 rounded-none border-gray-300 border",value:i,onChange:l}),(0,a.jsxs)("div",{className:"absolute bottom-2 right-2 text-sm text-gray-500",children:[i.length,"/",m]})]})})]}),(0,a.jsx)(S,{className:"my-5"}),(0,a.jsx)("div",{className:"mt-5 flex justify-center",children:(0,a.jsx)(O,{isSubmitted:c})}),(0,a.jsx)(F,{className:"mt-5",children:"La carte cadeau est valable 6 mois \xe0 compter de la date d'achat"})]})};function M(e){let{user:t,setIsPopupOpen:s,btn:r,btnOnly:n=!1,course:i=null}=e,l=(0,j.useRouter)(),{openSignup:c,openLogin:d}=(0,g.Y)(),[u,p]=(0,o.useState)(!1),[x,h]=(0,o.useState)(!1),[v,b]=(0,o.useState)([]),[y,N]=(0,o.useState)(""),[w,C]=(0,o.useState)(""),[T,k]=(0,o.useState)(""),[_,S]=(0,o.useState)({}),[A,F]=(0,o.useState)(!1),L=async()=>{try{let e=await fetch("/api/course/gift-list",{method:"POST",headers:{"Content-Type":"application/json"}}),t=await e.json();i?b([i]):b(t)}catch(e){console.error("Error fetching gift list:",e)}};(0,o.useEffect)(()=>{u&&0===v.length&&L()},[u,v.length]),(0,o.useEffect)(()=>{var e;1===v.length&&!y&&(null==(e=v[0])?void 0:e._id)&&N(v[0]._id)},[v,y]),(0,o.useEffect)(()=>
1{if(!(u||x))return;let e=window.scrollY,t={position:document.body.style.position,top:document.body.style.top,width:document.body.style.width,overflow:document.body.style.overflow};return()=>{document.body.style.position=t.position,document.body.style.top=t.top,document.body.style.width=t.width,document.body.style.overflow=t.overflow,window.scrollTo(0,e)}},[u,x]);let D=e=>{if(!t)return void h(!0);p(e),e||(N(""),C(""),k(""),S({}),F(!1),b([]))},P=(0,a.jsx)("div",{className:"sm:max-w-[1200px] bg-white border border-gray-600 p-6",children:(0,a.jsx)(B,{selectedGift:y,setSelectedGift:N,recipientName:w,setRecipientName:C,message:T,handleChangeAera:e=>{let t=e.target.value;t.length<=500&&k(t)},errors:_,isSubmitted:A,handleSubmit:e=>{let s;if(e.preventDefault(),F(!0),setTimeout(()=>{F(!1)},3e3),!(()=>{let e={};return y||(e.gift="Veuillez s\xe9lectionner un cadeau"),w.trim()||(e.name="Veuillez entrer le pr\xe9nom du destinataire"),S(e),0===Object.keys(e).length})())return;if(!t)return void h(!0);(0,f.trackCTAClick)({ctaType:"button",ctaText:"J'OFFRE UNE CARTE CADEAU",ctaLocation:"course_page",ctaDestination:"gift_checkout",ctaVariant:"gift_purchase"});let a=E("passionne"),r=E("pro"),n={passionne:{type:"subscription",duration:12,price:a.hasDiscount?a.discounted/100:a.original/100},pro:{type:"subscription",duration:12,price:r.hasDiscount?r.discounted/100:r.original/100}};s=n[y]?n[y]:v.find(e=>e._id===y);let i={giftType:n[y]?"subscription":"course",giftDetails:s,recipientName:w,message:T,selectedGiftId:y,...s&&s.url&&!n[y]?{courseUrl:s.url}:{}};console.log("Form Data:",i),(0,m.D)({formData:i})},giftList:v,CHAR_LIMIT:500})});return n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{onClick:()=>D(!0),className:r.classes,variant:r.variant,children:r.title}),(0,a.jsx)(G,{isOpen:u,onClose:()=>D(!1),children:P}),(0,a.jsx)(z,{isOpen:x,onClose:()=>h(!1),openSignup:c,openLogin:d,router:l})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col w-6/12 m-auto items-center justify-center gap-6",children:[(0,a.jsx)("h2",{className:"",children:"Fais plaisir \xe0 un proche avec la carte cadeau Empara"}),(0,a.jsx)(I,{onClick:()=>D(!0),className:r.classes,variant:r.variant,children:r.title})]}),(0,a.jsx)(G,{isOpen:u,onClose:()=>D(!1),children:P}),(0,a.jsx)(z,{isOpen:x,onClose:()=>h(!1),openSignup:c,openLogin:d,router:l})]})}},45966:(e,t,s)=>{function a(e){let{item:t,rec:s,payment:a,course:r={},returnUrl:n,eventId:i,fbp:l,fbc:o}=e;return fetch("/api/pay/create-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({item:t,rec:s,payment:a,course:r,returnUrl:n,eventId:i,fbp:l,fbc:o})}).then(e=>{if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return e.json()}).then(e=>{var t,s;return null==e||e.needsPaymentMethod,(null==e?void 0:e.paymentIntent)&&console.log("if (data?.paymentIntent)",null==e?void 0:e.paymentIntent),(null==e||null==(t=e.session)?void 0:t.url)&&(window.location.href=null==e?void 0:e.session.url),(null==e||null==(s=e.session)?void 0:s.pay)&&console.log("data?.session.pay",e),e}).catch(e=>{throw console.error("Erreur dans createNewSession:",e),e})}function r(e){let{formData:t}=e;fetch("/api/pay/create-gift-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({formData:t})}).then(e=>e.json()).then(e=>{var t;(null==e||null==(t=e.session)?void 0:t.sessionUrl)&&(location.href=e.session.sessionUrl)}).catch(e=>{console.error("Error creating gift intent:",e)})}s.d(t,{D:()=>r,l:()=>a})}}]);
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.