1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8673],{2373:(e,t,s)=>{"use strict";s.d(t,{p:()=>r,u:()=>n});var a=s(79207);let r="https://backend.nuha.care",n=a.A.create({baseURL:r,headers:{"Content-Type":"application/json"},withCredentials:!1})},4006:(e,t,s)=>{"use strict";s.d(t,{d:()=>i});var a=s(74863);s(99335);var r=s(78673),n=s(9573);function i(e){let{className:t,...s}=e;return(0,a.jsx)(r.bL,{"data-slot":"switch",className:(0,n.cn)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:(0,a.jsx)(r.zi,{"data-slot":"switch-thumb",className:(0,n.cn)("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}},9573:(e,t,s)=>{"use strict";s.d(t,{Cb:()=>i,Jc:()=>d,Sn:()=>l,cn:()=>n,gl:()=>o,il:()=>u,n4:()=>c,vv:()=>m});var a=s(84127),r=s(16933);function n(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.QP)((0,a.$)(t))}let i=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(""):"",l=e=>{let t=String(null!=e?e:"").trim();return t?t.split(/\s+/).map(e=>e.length<=3?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):""};function o(e){return"/api/file-proxy?fileUrl=".concat(encodeURIComponent(e))}function d(e){if(e.includes("storage.nuha.care")){let t=e.indexOf("?");return -1!==t?e.substring(0,t):e}return o(e)}let c=e=>{if(!e)return e;let t=e.replace(/[^\d]/g,""),s=t.length;return s<=4?t:s<=8?"".concat(t.slice(0,4),"-").concat(t.slice(4)):"".concat(t.slice(0,4),"-").concat(t.slice(4,8),"-").concat(t.slice(8,13))},u=e=>e?e.replace(/\D/g,""):e,m=e=>e?new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR"}).format(e):e},12034:(e,t,s)=>{"use strict";s.d(t,{default:()=>S});var a=s(74863),r=s(39622),n=s(22783),i=s(14877),l=s(42301),o=s(13431),d=s(73887),c=s(99335),u=s(8571),m=s(43535),g=s.n(m),x=s(4006),p=s(34782),h=s(50800),f=s(72902),v=s(26023),b=s(87784);let j=b.Ik({email:b.Yj().email("Please enter a valid email"),password:b.Yj().min(1,"Password is required")});var y=s(92640),w=s(80034),N=s(18550),k=s(22674);let C=e=>{let{isOpen:t,onClose:s}=e,{preLoginData:r,setUser:n}=(0,k.n)(),[i,l]=(0,c.useState)(""),[o,d]=(0,c.useState)(!1),m=(0,h.useRouter)(),g=async()=>{if(r&&i){d(!0);try{let e=await (0,v.signIn)("credentials",{email:r.email,password:r.password,role:i,redirect:!1});(null==e?void 0:e.error)?y.o.error("Failed to set role. Please try again. "+(null==e?void 0:e.error)):(n({uuid:r.uuid,token:r.token,role:i,user_id:r.user_id}),y.o.success("Login successful!"),m.push("/crm-support/".concat(i.toLowerCase(),"/dashboard")))}catch(e){l(""),console.error("Login error:",e),y.o.error("An error occurred. Please try again.")}finally{l(""),d(!1),s()}}},x=async()=>{l(""),n(null),await (0,v.signOut)({redirect:!1}),s()};return(0,a.jsx)(w.lG,{open:t,onOpenChange:()=>{l("")},children:(0,a.jsxs)(w.Cf,{className:"sm:max-w-md",children:[(0,a.jsx)(w.c7,{children:(0,a.jsx)(w.L3,{children:"Select Your Role"})}),(0,a.jsx)("div",{className:"flex flex-col space-y-4 py-4",children:null==r?void 0:r.role.map(e=>(0,a.jsx)(N.$,{variant:i===e?"default":"outline",className:"w-full justify-start",onClick:()=>{l(e)},children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,a.jsxs)(w.Es,{className:"flex justify-end space-x-2",children:[(0,a.jsx)(N.$,{variant:"outline",onClick:x,children:"Cancel"}),(0,a.jsx)(N.$,{onClick:g,disabled:!i||o,children:o?(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)("div",{className:"w-5 h-5 relative",children:(0,a.jsx)(u.default,{src:"/images/png/logo-only.png",alt:"Loading",fill:!0,className:"animate-spin"})})}):"Confirm"})]})]})})};var L=s(59143);let S=function(){let[e,t]=(0,c.useState)(!1),[s,m]=(0,c.useState)(!1),[b,w]=(0,c.useState)(!1),N=(0,h.useRouter)(),S=(0,h.useSearchParams)().get("callbackUrl")||"/crm-support",{setPreLoginData:_,setUser:A}=(0,k.n)(),{mutate:P,isPending:z}=(0,L.CR)(),{register:D,handleSubmit:E,formState:{errors:R},setError:U}=(0,r.mN)({resolver:(0,n.u)(j)}),O=async e=>{try{P(e,{onSuccess:async t=>{let s={uuid:t.uuid,token:t.token,role:t.role,email:e.email,password:e.password,user_id:t.user_id};if(_(s),s.role.length>1)w(!0);else{A({uuid:s.uuid,token:s.token,role:s.role[0],user_id:s.user_id});let e=await (0,v.signIn)("credentials",{email:s.email,password:s.password,role:s.role[0],redirect:!1});(null==e?void 0:e.error)?y.o.error("Failed to set role. Please try again. "+(null==e?void 0:e.error)):(y.o.success("Login successful!"),N.push(S))}},onError:e=>{let t="object"==typeof e&&null!==e&&"message"in e?String(e.message):"An error occurred during login";U("root",{type:"manual",message:t}),y.o.error(t)}})}catch(e){U("root",{type:"manual",message:"An error occurred. Please try again. "+e}),y.o.error("An error occurred. Please try again.")}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 grid-rows-[6fr_1fr] h-screen overflow-hidden",children:[z&&(0,a.jsx)("div",{className:"fixed inset-0 bg-white/80 backdrop-blur-sm z-50 flex items-center justify-center",children:(0,a.jsx)(f.W,{})}),(0,a.jsx)("div",{className:"flex justify-center items-center h-full px-4 lg:px-0",children:(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)(u.default,{src:"/images/svg/logo.svg",alt:"Nuha Care Logo",width:134,height:36,className:"mx-auto mb-6 lg:hidden"}),(0,a.jsx)("h1",{className:"text-4xl font-semibold mb-2 text-[#0B6463]",children:"Selamat Datang Kembali"}),(0,a.jsx)("p",{className:"text-gray-400 font-semibold text-sm",children:"Enter your email and password to sign in"})]}),(0,a.jsxs)("form",{onSubmit:E(O),className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium ",children:"Email"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,a.jsx)(i.A,{className:"h-5 w-5 text-gray-400"})}),(0,a.jsx)(p.p,{...D("email"),type:"text",className:"pl-10",placeholder:"Enter your email",disabled:z})]}),R.email&&(0,a.jsx)("p",{className:"text-sm text-red-600",children:R.email.message})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium ",children:"Password"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,a.jsx)(l.A,{className:"h-5 w-5 text-gray-400"})}),(0,a.jsx)(p.p,{...D("password"),type:e?"text":"password",className:"pl-10 pr-10",placeholder:"Enter your password",disabled:z}),(0,a.jsx)("button",{type:"button",onClick:()=>t(!e),className:"absolute inset-y-0 right-0 pr-3 flex items-center",disabled:z,children:e?(0,a.jsx)(o.A,{className:"h-5 w-5 text-gray-400"}):(0,a.jsx)(d.A,{className:"h-5 w-5 text-gray-400"})})]}),R.password&&(0,a.jsx)("p",{className:"text-sm text-red-600",children:R.password.message})]}),R.root&&(0,a.jsx)("p",{className:"text-sm text-red-600 text-center",children:R.root.message}),(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(x.d,{id:"remember-me",checked:s,onCheckedChange:m,disabled:z}),(0,a.jsx)("label",{htmlFor:"remember-me",className:"text-sm text-gray-700 cursor-pointer",children:"Remember me"})]})}),(0,a.jsx)("button",{type:"submit",className:"w-full flex justify-center py-2 px-4 border border-transparent roun
1ded-lg shadow-sm text-sm font-medium text-white bg-[#0B6463] hover:bg-[#0a5251] transition-all duration-300 ease-in-out transform hover:scale-[1.02] disabled:opacity-50 disabled:cursor-not-allowed",disabled:z,children:z?(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)("div",{className:"w-5 h-5 relative",children:(0,a.jsx)(u.default,{src:"/images/png/logo-only.png",alt:"Loading",fill:!0,className:"animate-spin"})})}):"Sign in"})]}),(0,a.jsx)("div",{className:"flex justify-center items-center mt-4",children:(0,a.jsxs)("p",{className:"text-gray-400 text-sm text-center",children:["Don't have an account? ",(0,a.jsx)(g(),{href:"#",className:"text-[#0B6463]",children:" Sign up"})]})})]})}),(0,a.jsx)("div",{className:"hidden lg:flex justify-end items-center row-span-2 w-full h-full",children:(0,a.jsx)(u.default,{src:"/images/svg/crm-support/login-image.svg",alt:"Login Pattern",width:100,height:100,className:"w-full"})}),(0,a.jsx)("div",{className:"p-4 h-full flex items-end justify-center",children:(0,a.jsx)("p",{className:"text-xs text-gray-500",children:"\xa9 2025, Made with Nuha Care Company"})})]}),(0,a.jsx)(C,{isOpen:b,onClose:()=>{w(!1),_(null)}})]})}},18550:(e,t,s)=>{"use strict";s.d(t,{$:()=>o,r:()=>l});var a=s(74863);s(99335);var r=s(19071),n=s(23879),i=s(9573);let l=(0,n.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:s,size:n,asChild:o=!1,...d}=e,c=o?r.DX:"button";return(0,a.jsx)(c,{"data-slot":"button",className:(0,i.cn)(l({variant:s,size:n,className:t})),...d})}},22674:(e,t,s)=>{"use strict";s.d(t,{n:()=>n});var a=s(62276),r=s(91837);let n=(0,a.v)()((0,r.Zr)(e=>({user:null,preLoginData:null,loginData:null,isAuthenticated:!1,isLoading:!0,setUser:t=>e({user:t,isAuthenticated:!!t}),setPreLoginData:t=>e({preLoginData:t}),setLoginData:t=>e({loginData:t}),setLoading:t=>e({isLoading:t}),logout:()=>e({user:null,isAuthenticated:!1})}),{name:"auth-storage",partialize:e=>({user:e.user,preLoginData:e.preLoginData})}))},34782:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var a=s(74863);s(99335);var r=s(9573);function n(e){let{className:t,type:s,...n}=e;return(0,a.jsx)("input",{type:s,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n})}},59143:(e,t,s)=>{"use strict";s.d(t,{As:()=>d,CR:()=>c});var a=s(50800),r=s(99335),n=s(22311),i=s(26023),l=s(2373);s(22674);let o=async e=>{let t=await fetch("".concat(l.p,"/management-access/auth/pre-login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw await t.json();return(await t.json()).data};function d(){var e;let{role:t,redirectTo:s="/crm-support/login"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,a.useRouter)(),{data:l,status:o}=(0,i.useSession)(),d="authenticated"===o,c=null==l||null==(e=l.user)?void 0:e.role,u=!t||c===t;return(0,r.useEffect)(()=>
1{if("unauthenticated"===o)n.push(s);else if(t&&!u){let e=(null==c?void 0:c.toLowerCase())==="admin"?"/crm-support/admin/dashboard":"/crm-support/client/dashboard";console.log("redirectPath",e),n.push(e)}},[o,u,t,s,n,c]),{isAuthenticated:d,userRole:c,hasRequiredRole:u,user:null==l?void 0:l.user,status:o}}function c(){return(0,n.n)({mutationFn:o})}},72902:(e,t,s)=>{"use strict";s.d(t,{W:()=>n});var a=s(74863),r=s(8571);function n(e){let{className:t}=e;return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center ".concat(t||"min-h-screen"),children:[(0,a.jsx)("div",{className:"animate-bounce-slow transition-transform",children:(0,a.jsx)(r.default,{src:"/images/png/logo-only.png",alt:"Nuha Care Logo",width:100,height:100,priority:!0,className:"animate-bounce"})}),(0,a.jsx)("p",{className:"mt-4 text-gray-600 animate-pulse",children:"Loading..."})]})}},80034:(e,t,s)=>{"use strict";s.d(t,{Cf:()=>m,Es:()=>x,HM:()=>c,L3:()=>p,c7:()=>g,lG:()=>l,rr:()=>h,zM:()=>o});var a=s(74863);s(99335);var r=s(21117),n=s(53278),i=s(9573);function l(e){let{...t}=e;return(0,a.jsx)(r.bL,{"data-slot":"dialog",...t})}function o(e){let{...t}=e;return(0,a.jsx)(r.l9,{"data-slot":"dialog-trigger",...t})}function d(e){let{...t}=e;return(0,a.jsx)(r.ZL,{"data-slot":"dialog-portal",...t})}function c(e){let{...t}=e;return(0,a.jsx)(r.bm,{"data-slot":"dialog-close",...t})}function u(e){let{className:t,...s}=e;return(0,a.jsx)(r.hJ,{"data-slot":"dialog-overlay",className:(0,i.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s})}function m(e){let{className:t,children:s,withCloseButton:l=!0,...o}=e;return(0,a.jsxs)(d,{"data-slot":"dialog-portal",children:[(0,a.jsx)(u,{}),(0,a.jsxs)(r.UC,{"data-slot":"dialog-content",className:(0,i.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...o,children:[s,l&&(0,a.jsxs)(r.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,a.jsx)(n.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function g(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,i.cn)("flex flex-col gap-2 text-center sm:text-left",t),...s})}function x(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"dialog-footer",className:(0,i.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function p(e){let{className:t,...s}=e;return(0,a.jsx)(r.hE,{"data-slot":"dialog-title",className:(0,i.cn)("text-lg leading-none font-semibold",t),...s})}function h(e){let{className:t,...s}=e;return(0,a.jsx)(r.VY,{"data-slot":"dialog-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...s})}},86980:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,43848,23)),Promise.resolve().then(s.bind(s,12034))}},e=>{e.O(0,[1235,2311,7681,4420,952,8473,2640,3088,9622,7784,3535,7528,6218,3541,7358],()=>e(e.s=86980)),_N_E=e.O()}]);
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.