PageSourceSearch

https://prajasakti.com/_next/static/chunks/426-e61944533092e782.js

js prajasakti.com collected 2026-10-02 07:22:06 UTC 9,896 bytes, 2 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[426],{80426:function(e,t,n){"use strict";n.d(t,{AuthProvider:function(){return v},E:function(){return m},V:function(){return h}});var r=n(57437),i=n(2265),o=n(99671),a=n(52552),l=n(75414),s=n(58143),c=n(25892),u=n(98104),d=n(65443),p=n(24062);let _="user";function f(){try{let e=(0,c.l)(_);if(e)return JSON.parse(e)}catch(e){}return null}let h=(0,i.createContext)(null),v=e=>{let{children:t}=e,[n,c]=(0,i.useState)(()=>f()),[v,m]=(0,i.useState)(!0),S=(0,i.useRef)(0),{showMessage:y}=(0,l.U)();async function A(){var e,t,n;c(null),(0,u.uB)(null);try{localStorage.removeItem(_)}catch(e){}let r=(null===(n=window.location)||void 0===n?void 0:null===(t=n.pathname)||void 0===t?void 0:null===(e=t.match(/^\/([\w]{2})-/))||void 0===e?void 0:e[1])||"en";y("success",(0,d.id)(r,"LOGOUT_SUCCESS"));try{await (0,s.Kv)()}catch(e){console.error("Logout API failed (session already cleared):",e)}}async function g(){let e=++S.current;try{var t;m(!0);let n={"Content-Type":"application/json"},r=(0,u.bW)();r&&(n.Authorization="Bearer ".concat(r));let i=await fetch("".concat(o.Z.publicServerUrl,"/api/auth/reader-me?t=").concat(Date.now()),{method:"GET",headers:n,credentials:"include",cache:"no-store"}),l=await i.json().catch(()=>({}));if(e!==S.current)return;let s=(0,a.P)(null!==(t=null==l?void 0:l.user)&&void 0!==t?t:null);if(s){c(s);try{localStorage.setItem(_,JSON.stringify(s)),(null==l?void 0:l.token)&&(0,u.uB)(l.token)}catch(e){}}else if(401===i.status||403===i.status){c(null),(0,u.uB)(null);try{localStorage.removeItem(_)}catch(e){}}}catch(t){e===S.current&&console.error("Failed to refresh authentication:",t)}finally{e===S.current&&m(!1)}}return(0,i.useEffect)(()=>{if(void 0===window.document)return;let e=new URLSearchParams(window.location.search),t=e.get("token"),n=e.get("socialAuth"),r=e.get("provider");if(t&&(0,u.uB)(t),t||n||e.get("reason"))try{window.history.replaceState({},document.title,window.location.pathname)}catch(e){}let i=f();i&&c(i),g().then(()=>{var t,i;if("success"===n){let e=(null===(t=window.location.pathname.match(/^\/([\w]{2})-/))||void 0===t?void 0:t[1])||"en";y("success",(0,d.id)(e,"LOGIN_SUCCESSFUL"))}else if("error"===n){let t=(null===(i=window.location.pathname.match(/^\/([\w]{2})-/))||void 0===i?void 0:i[1])||"en",n=e.get("reason");console.error("Social auth failed:",r,n),y("error",(0,p.v)(t,n))}})},[]),(0,r.jsx)(h.Provider,{value:{user:n,setUser:c,refreshAuthentication:g,logout:A,isUserLoading:v},children:t})},m=()=>{let e=(0,i.useContext)(h);if(!e)throw Error("useAuthContext must be used within a AuthProvider");return e}},75414:function(e,t,n){"use strict";n.d(t,{default:function(){return u},U:function(){return d}});var r=n(57437),i=n(2265),o=n(56877),a=n.n(o),l=n(63400);function s(e){let{message:t}=e;return(0,r.jsxs)("div",{className:"".concat(a().message),children:[(0,r.jsxs)("span",{className:"w-4 h-4 min-w-4 min-h-4 rounded-full flex items-center justify-center text-[10px] text-white  ".concat(a()[t.type]),children:["info"===t.type&&(0,r.jsx)(l.US6,{}),"error"===t.type&&(0,r.jsx)(l.oHP,{}),"success"===t.type&&(0,r.jsx)(l.bzc,{}),"warning"===t.type&&(0,r.jsx)(l.JZY,{})]}),(0,r.jsx)("span",{children:t.content})]})}let c=(0,i.createContext)(null);function u(e){let{children:t}=e,[n,o]=(0,i.useState)([]),a=(e,t)=>{let n=Date.now(),r={id:n,type:e,content:t};o(e=>[...e,r]),setTimeout(()=>{l(n)},3e3)};(0,i.useEffect)(()=>{try{let e=sessionStorage.getItem("flashMessage");if(!e)return;sessionStorage.removeItem("flashMessage");let t=JSON.parse(e);(null==t?void 0:t.type)&&(null==t?void 0:t.content)&&a(t.type,t.content)}catch(e){}},[]);let l=e=>{o(t=>null==t?void 0:t.filter(t=>t.id!==e))};return(0,r.jsxs)(c.Provider,{value:{showMessage:a},children:[t,(0,r.jsx)("div",{className:"fixed top-5 left-1/2 transform -translate-x-1/2 flex flex-col gap-[15px] z-50",children:null==n?void 0:n.map((e,t)=>(0,r.jsx)(s,{message:e},t))})]})}let d=()=>{let e=(0,i.useContext)(c);if(!e)throw Error("useMessage must be used within a MessageProvider");return e}},58143:function(e,t,n){"use strict";n.d(t,{CU:function(){return s},Kv:function(){return l},Nq:function(){return o},h8:function(){return a}});var r=n(99671),i=n(98104);let o=async e=>{let{fullName:t,email:n,phoneNumber:o,country:a,state:l,city:s,avatar:c}=e;try{"delete"===c&&await fetch("".concat(r.Z.publicServerUrl,"/api/v1/users/remove-profile-picture"),{method:"POST",headers:(0,i.g0)(),credentials:"include"});let e=new FormData;e.append("fullName",t),e.append("email",n),e.append("phoneNumber",o||""),e.append("country",a||""),e.append("state",l||""),e.append("city",s||""),c&&c instanceof File&&e.append("image",c);let f=await fetch("".concat(r.Z.publicServerUrl,"/api/v1/users/update-profile"),{method:"PATCH",headers:(0,i.g0)(),body:e,credentials:"include"});if(!f.ok){var u,d,p,_;let e=await f.json().catch(()=>({})),t=null!==(_=null!==(p=null==e?void 0:null===(d=e.errors)||void 0===d?void 0:null===(u=d[0])||void 0===u?void 0:u.message)&&void 0!==p?p:null==e?void 0:e.message)&&void 0!==_?_:"Failed to update user!",n=Error(t);throw n.code=null==e?void 0:e.code,n}return await f.json()}catch(e){throw e}},a=async()=>{try{let a=await fetch("".concat(r.Z.publicServerUrl,"/api/v1/users/deactivate"),{method:"DELETE",headers:{"Content-Type":"application/json",...(0,i.g0)()},credentials:"include"}),l=await a.json();if(!a.ok){var e,t,n,o;let r=null!==(o=null!==(n=null==l?void 0:null===(t=l.errors)||void 0===t?void 0:null===(e=t[0])||void 0===e?void 0:e.message)&&void 0!==n?n:null==l?void 0:l.message)&&void 0!==o?o:"Something went wrong!";throw Error(r)}return l}catch(e){throw e}},l=async()=>{try{let e=await fetch("".concat(r.Z.publicServerUrl,"/api/auth/reader-logout"),{method:"POST",headers:{"Content-Type":"application/json",...(0,i.g0)()},credentials:"include"});if(!e.ok)throw Error("Logout failed: ".concat(e.statusText));return await e.json()}catch(e){throw e}},s=async e=>{try{let t=await fetch("".concat(r.Z.publicServerUrl,"/api/subscribers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw Error("Failed to subscribe");return await t.json()}catch(e){throw console.error(e),e}}},25892:function(e,t,n){"use strict";n.d(t,{l:function(){return r}});let r=e=>{try{return localStorage.getItem(e)}catch(e){console.error("Failed to access localStorage:",e)}return null}},24062:function(e,t,n){"use strict";n.d(t,{f:function(){return l},v:function(){return s}});var r=n(65443);let i={account_inactive:"SOCIAL_AUTH_ACCOUNT_INACTIVE",account_suspended:"SOCIAL_AUTH_ACCOUNT_SUSPENDED",account_deleted:"SOCIAL_AUTH_ACCOUNT_DELETED",staff_login_blocked:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_super_admin:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_admin:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_editor:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_photographer:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_reporter:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED",role_not_allowed:"SOCIAL_AUTH_STAFF_LOGIN_BLOCKED"},o=[{includes:"email must be a valid email",key:"VALID_EMAIL"},{includes:"please enter a valid email",key:"VALID_EMAIL"},{includes:"please enter a valid 10-digit phone number",key:"VALID_PHONE_10"},{includes:"please enter a valid 10-digit indian mobile",key:"VALID_PHONE_10"},{includes:"a user already exists",key:"USER_ALREADY_EXISTS"},{includes:"a user  already exists",key:"USER_ALREADY_EXISTS"},{includes:"password must be at least 8 characters and include uppercase",key:"PASSWORD_COMPLEXITY"},{includes:"at least one lowercase letter",key:"PASSWORD_RULE_LOWERCASE"},{includes:"at least one uppercase letter",key:"PASSWORD_RULE_UPPERCASE"},{includes:"at least one special character",key:"PASSWORD_RULE_SPECIAL"},{includes:"at least one digit",key:"PASSWORD_RULE_DIGIT"},{includes:"at least 8 characters long",key:"PASSWORD_RULE_MIN_8"},{includes:"registration service is unavailable",key:"REGISTRATION_SERVICE_UNAVAILABLE"},{includes:"registration failed",key:"REGISTRATION_FAILED"},{includes:"cannot connect to server",key:"CANNOT_CONNECT_SERVER"},{includes:"please enter a valid 6-digit otp",key:"PHONE_OTP_INVALID"},{includes:"invalid credentials",key:"INVALID_CREDENTIALS"},{includes:"phone number already exists",key:"PHONE_NUMBER_EXISTS"}];function a(e,t){let n=e.trim(),a=i[n];if(a)return(0,r.id)(t,a);let l=n.toLowerCase();if(!l)return"";for(let{includes:e,key:n}of o)if(l.includes(e))return(0,r.id)(t,n);return l.includes("lowercase")&&l.includes("uppercase")&&l.includes("special")?(0,r.id)(t,"PASSWORD_COMPLEXITY"):e.trim()}function l(e,t){if(!(null==e?void 0:e.trim()))return"";let n=e.split(RegExp("(?<=\\.)\\s+")).map(e=>
1e.trim()).filter(Boolean);return n.length>1?n.map(e=>a(e,t)).join(" "):a(e,t)}function s(e,t){return t&&i[t]?(0,r.id)(e,i[t]):(0,r.id)(e,"TRY_AGAIN")}},52552:function(e,t,n){"use strict";function r(e){var t,n,r,i;if(!e||"object"!=typeof e)return null;let o="string"==typeof e.fullName?e.fullName:[e.firstName,e.lastName].filter(Boolean).join(" ")||"";return{id:String(null!==(t=e.id)&&void 0!==t?t:""),firstName:String(null!==(n=e.firstName)&&void 0!==n?n:""),lastName:String(null!==(r=e.lastName)&&void 0!==r?r:""),fullName:o,email:String(null!==(i=e.email)&&void 0!==i?i:""),phoneNumber:"string"==typeof e.phoneNumber?e.phoneNumber:void 0,country:"string"==typeof e.country?e.country:void 0,state:"string"==typeof e.state?e.state:void 0,city:"string"==typeof e.city?e.city:void 0,pictureURL:"string"==typeof e.pictureURL?e.pictureURL:void 0}}n.d(t,{P:function(){return r}})},56877:function(e){e.exports={message:"MessageComponent_message__n7BR6",slideDown:"MessageComponent_slideDown__J_6Aa",dark:"MessageComponent_dark__INI0F",success:"MessageComponent_success__c4b8r",error:"MessageComponent_error__CPnjS",warning:"MessageComponent_warning__U1RFq",info:"MessageComponent_info__dKOjr"}}}]);
2//# sourceMappingURL=426-e61944533092e782.js.map

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.