PageSourceSearch

https://ecomitram.org/_next/static/chunks/4996-8dd960bd7e441783.js

js ecomitram.org collected 2026-10-10 01:45:27 UTC 15,680 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4996],{1075:(e,t,n)=>{n.d(t,{y:()=>o});var r=n(59026);let i=null,o={signIn:async function(e){return i||(i=(async()=>{var e,t;let n=await (0,r.mintAnon)();return n?{user:{_id:n.user._id,email:null!=(e=n.user.email)?e:null,name:null!=(t=n.user.name)?t:null,profileComplete:!1},mergedFromGuest:!1}:null})().finally(()=>{i=null}))},cleanup:async()=>{}}},2659:(e,t,n)=>{n.d(t,{n:()=>o});var r=n(85785),i=n(54457);let o={signIn:async e=>{var t,n,o,a;let{email:l,code:u}=e,s=await (0,r.RY)(l,u);return(Promise.resolve((0,i.registerFcmToken)()).catch(()=>{}),null==s?void 0:s.user)?{user:{_id:s.user._id,email:null!=(t=s.user.email)?t:null,name:null!=(n=s.user.name)?n:null,profileComplete:null!=(o=s.user.profileComplete)&&o},mergedFromGuest:null!=(a=s.mergedFromGuest)&&a}:null},cleanup:async()=>{}}},4993:(e,t,n)=>{n.r(t),n.d(t,{handleRedirectResult:()=>h,prewarmGooglePopup:()=>c,signInWithGoogle:()=>f});var r=n(23259),i=n(78414),o=n(78079),a=n(54457);let l="em-auth-redirect-pending";function u(){try{sessionStorage.removeItem(l)}catch(e){}}let s=null;function c(){if(s)return;let e=function(){let e=r.hk;if("function"!=typeof e)return null;let t=e.prototype;if("object"!=typeof t||null===t||"function"!=typeof t._initialize)return null;try{return new e}catch(e){return null}}();e&&(s=e._initialize((0,i.Cy)()).then(()=>void 0).catch(()=>{s=null}))}async function d(e){let t=await (0,o.uE)("/auth/login",{method:"POST",body:{idToken:e}});return(0,a.registerFcmToken)().catch(()=>{}),t}async function f(){let e=(0,i.Cy)(),t=new r.HF;try{sessionStorage.setItem(l,"1")}catch(e){}if((window.matchMedia("(display-mode: standalone)").matches||!0===navigator.standalone)&&"undefined"!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent))return await (0,r.$2)(e,t,r.hk),null;let n=await (0,r.df)(e,t,r.hk);return u(),d(await n.user.getIdToken())}async function h(){if(!function(){try{return"1"===sessionStorage.getItem(l)}catch(e){return!1}}())return null;let e=(0,i.Cy)(),t=await (0,r.Q4)(e,r.hk);return(u(),t)?d(await t.user.getIdToken()):null}},21402:(e,t,n)=>{n.d(t,{h:()=>a});var r=n(4993),i=n(78414),o=n(54457);let a={signIn:async()=>{let e=await (0,r.signInWithGoogle)();return Promise.resolve((0,o.registerFcmToken)()).catch(()=>{}),e},cleanup:async()=>{let e=(0,i.Cy)();await e.signOut()}}},24404:(e,t,n)=>{n.d(t,{C:()=>u});var r=n(78079),i=n(54457),o=n(21402),a=n(2659),l=n(1075);async function u(){await Promise.resolve((0,i.deregisterFcmToken)()).catch(()=>{});let e=(await Promise.allSettled([o.h.cleanup(),a.n.cleanup(),l.y.cleanup(),(0,r.uE)("/auth/logout",{method:"POST"})]))[3];if("rejected"===e.status)throw e.reason}},30200:(e,t,n)=>{n.d(t,{H:()=>i,Z:()=>o});let r="is_twa";function i(){try{document.referrer.startsWith("android-app://")&&localStorage.setItem(r,"1")}catch(e){}}function o(){let e=navigator.userAgent,t=window.matchMedia("(display-mode: standalone)").matches||!0===navigator.standalone,n=document.referrer.startsWith("android-app://");try{n?localStorage.setItem(r,"1"):n=t&&"1"===localStorage.getItem(r)}catch(e){}if(n)return"android_twa";let i=/iPad|iPhone|iPod/.test(e)&&!("MSStream"in window),o=/Android/.test(e);return i&&t?"ios_pwa":o&&t?"android_pwa":"web"}},43431:(e,t,n)=>{n.d(t,{VL:()=>s,Y6:()=>c,lM:()=>u});var r=n(49719),i=n(85374);let o="ecomitram:pendingOp:v1",a=/^[A-Za-z0-9_-]{1,128}$/,l=/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;function u(e){if(!(0,r.ko)(e.kind))throw Error('setPendingOp: unknown kind "'.concat(String(e.kind),'"'));if(void 0!==e.refId){if("string"!=typeof e.refId)throw Error("setPendingOp: refId must be a string");if(l.test(e.refId))throw Error("setPendingOp: refId must not be JWT-shaped");if(!a.test(e.refId))throw Error("setPendingOp: refId failed format validation")}let t={kind:e.kind,ts:Date.now()};void 0!==e.refId&&(t.refId=e.refId),(0,i.YZ)(o,JSON.stringify(t))}function s(e){var t;let n,u=(0,i._A)(o);if(null===u)return null;(null==e?void 0:e.peekOnly)||(0,i.Un)(o);try{n=JSON.parse(u)}catch(t){return(null==e?void 0:e.peekOnly)&&(0,i.Un)(o),null}let s=!(!(t=n)||"object"!=typeof t||!(0,r.ko)(t.kind)||"number"!=typeof t.ts||!Number.isFinite(t.ts)||void 0!==t.refId&&("string"!=typeof t.refId||l.test(t.refId)||!a.test(t.refId)))?{kind:t.kind,refId:t.refId,ts:t.ts}:null;return!s||Date.now()-s.ts>
16e5?((null==e?void 0:e.peekOnly)&&(0,i.Un)(o),null):s}function c(){(0,i.Un)(o)}},44996:(e,t,n)=>{n.d(t,{AuthProvider:()=>b,useAuth:()=>k,useAuthActions:()=>E,useAuthModal:()=>I});var r=n(84157),i=n(41865),o=n(74062),a=n(78079),l=n(92213),u=n(4993),s=n(21402),c=n(2659),d=n(1075),f=n(24404),h=n(43431);let m=(0,i.createContext)(null),p=(0,i.createContext)(null),w=(0,i.createContext)(null);function g(e){return e?"anon"===e.type?"anonymous":"verified"===e.type||e._id?"verified":"none":"none"}let y={google:s.h,"email-otp":c.n,anon:d.y},v=new Set(["/login","/login/email","/login/guest","/login/complete-profile"]);function b(e){let{children:t}=e,[n,s]=(0,i.useState)(null),[c,d]=(0,i.useState)(!0),[b,k]=(0,i.useState)(!1),[E,I]=(0,i.useState)(null),S=(0,o.useRouter)(),C=(0,o.usePathname)(),A=(0,i.useRef)(null);A.current=n;let P=(0,i.useRef)({}),T=(0,i.useRef)(null),_=(0,i.useMemo)(()=>g(n),[n]),O=(0,i.useCallback)(e=>{if("verified"===g(A.current))return;let t=null;I(t=e?e:window.location.pathname+window.location.search),T.current=t?{path:t,ts:Date.now()}:null,k(!0)},[]),x=(0,i.useCallback)(()=>{k(!1),I(null)},[]),R=(0,i.useCallback)(async e=>{var t;try{let n=await (0,a.uE)("/auth/me",{method:"GET",signal:e});if(null==e?void 0:e.aborted)return;s(null!=(t=null==n?void 0:n.user)?t:null)}catch(t){if(null==e?void 0:e.aborted)return;s(null),!(t instanceof a.hD&&t.status)}finally{(null==e?void 0:e.aborted)||d(!1)}},[]),F=(0,i.useCallback)(async()=>{d(!0),await R()},[R]);(0,i.useEffect)(()=>{c||"none"===_&&((0,h.Y6)(),T.current=null)},[_,c]),(0,i.useEffect)(()=>{if("verified"!==_||!C||C.startsWith("/admin")||v.has(C))return;let e=T.current;T.current=null;let t=e&&Date.now()-e.ts<=6e5&&(0,l.sG)(e.path)===e.path?e.path:null,r=C+window.location.search;if((null==n?void 0:n.profileComplete)===!1)return void S.push("/login/complete-profile?redirect=".concat(encodeURIComponent(null!=t?t:r)));t&&t!==r&&S.push(t)},[_,null==n?void 0:n.profileComplete,C,S]);let N=(0,i.useRef)(C);(0,i.useEffect)(()=>{N.current!==C&&(b&&x(),N.current=C)},[C,b,x]);let j=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=new AbortController,t=()=>{e.signal.aborted||R(e.signal)};return(0,u.handleRedirectResult)().then(t,t),(0,a.iU)(()=>O()),(0,a.Wb)(async()=>{var e;await (null==(e=j.current)?void 0:e.call(j,"/login"))}),()=>{e.abort(),(0,a.iU)(null),(0,a.Wb)(null)}},[O,R]);let U=(0,i.useCallback)(async function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if("google"===e&&n.length>0)return null;let i=P.current[e];if(i)return i;let o=y[e].signIn,a=(async()=>{let e=await o(...n);return await F(),e})().finally(()=>{P.current[e]===a&&delete P.current[e]});return P.current[e]=a,a},[F]),D=(0,i.useCallback)(async e=>{await (0,f.C)(),s(null),d(!1),S.refresh(),e&&S.replace(e)},[S]);j.current=D;let W=(0,i.useMemo)(()=>({state:_,user:n,loading:c}),[_,n,c]),z=(0,i.useMemo)(()=>({signIn:U,signOut:D,refresh:F}),[U,D,F]),M=(0,i.useMemo)(()=>({isOpen:b,requireVerified:O,returnTo:E,closeModal:x}),[b,O,E,x]);return(0,r.jsx)(m.Provider,{value:W,children:(0,r.jsx)(p.Provider,{value:z,children:(0,r.jsx)(w.Provider,{value:M,children:t})})})}function k(){let e=(0,i.useContext)(m),t=(0,i.useContext)(w);if(!e||!t)throw Error("useAuth must be used within an <AuthProvider>");return{...e,requireVerified:t.requireVerified}}function E(){let e=(0,i.useContext)(p);if(!e)throw Error("useAuthActions must be used within an <AuthProvider>");return e}function I(){let e=(0,i.useContext)(w);if(!e)throw Error("useAuthModal must be used within an <AuthProvider>");return e}},48727:(e,t,n)=>{n.d(t,{D:()=>o});let r="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",i=null;async function o(){let e="0x4AAAAAADQh9z52fxOAAFyU";if(!e)throw Error("turnstile-loader: NEXT_PUBLIC_TURNSTILE_SITE_KEY is not set");await (window.turnstile?Promise.resolve():i||(i=new Promise((e,t)=>{if(document.querySelector('script[src="'.concat(r,'"]'))){let t=()=>{window.turnstile?e():setTimeout(t,50)};t();return}let n=document.createElement("script");n.src=r,n.async=!0,n.defer=!0,n.onload=()=>{window.turnstile?e():t(Error("turnstile-loader: script loaded but window.turnstile is undefined"))},n.onerror=()=>t(Error("turnstile-loader: script failed to load")),document.head.appendChild(n)})));let t=window.turnstile;if(!t)throw Error("turnstile-loader: window.turnstile not available after script load");return new Promise((n,r)=>{let i,o=document.createElement("div");o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",o.style.width="0",o.style.height="0",document.body.appendChild(o);let a=()=>{try{i&&t.remove(i)}catch(e){}o.remove()};try{(i=t.render(o,{sitekey:e,appearance:"execute",callback:e=>{a(),n(e)},"error-callback":()=>{a(),r(Error("turnstile-loader: widget error-callback"))},"expired-callback":()=>{a(),r(Error("turnstile-loader: widget expired before token issued"))},"timeout-callback":()=>{a(),r(Error("turnstile-loader: widget timed out"))}}))||(a(),r(Error("turnstile-loader: api.render returned no widget id")))}catch(e){a(),r(e instanceof Error?e:Error(String(e)))}})}},49719:(e,t,n)=>{n.d(t,{Wx:()=>i,ko:()=>o});let r=["post","like","comment","report","joinOrg","adoptSwitch"];Object.freeze(r);let i={post:{headline:"Sign in to share your post",reason:"Sign in to post, comment, and join campaigns."},like:{headline:"Sign in to like this post",reason:"Verified members can react to posts in the community."},comment:{headline:"Sign in to add a comment",reason:"Verified members can join the conversation."},report:{headline:"Sign in to report this post",reason:"Only verified members can flag content for moderators."},joinOrg:{headline:"Sign in to join this organization",reason:"Verified members can join organizations to collaborate on activities."},adoptSwitch:{headline:"Sign in to adopt this habit",reason:"Verified members can track the switches they have adopted."}};function o(e){return"string"==typeof e&&r.includes(e)}},54457:(e,t,n)=>{n.r(t),n.d(t,{deregisterFcmToken:()=>h,registerFcmToken:()=>d,usePushNotifications:()=>s});var r=n(41865),i=n(81041),o=n(78079),a=n(30200),l=n(78414);let u="fcm_token";function s(){let[e,t]=(0,r.useState)("unsupported");(0,r.useEffect)(()=>{"Notification"in window&&t(Notification.permission)},[]),(0,r.useEffect)(()=>
1{if(!("Notification"in window))return;let e=()=>t(Notification.permission);return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]);let n=(0,r.useCallback)(async()=>{await d()},[]),i=(0,r.useCallback)(async()=>{await h()},[]);return{permission:e,requestPermission:(0,r.useCallback)(async()=>{if(!("Notification"in window))return!1;let e=await Notification.requestPermission();return t(e),"granted"===e&&(await n(),!0)},[n]),registerToken:n,deregisterToken:i}}let c=null;function d(){if(c)return c;let e=f().finally(()=>{c===e&&(c=null),clearTimeout(t)}),t=setTimeout(()=>{c===e&&(c=null)},6e4);return c=e,e}async function f(){try{if(!("Notification"in window)||"granted"!==Notification.permission)return;let e=await (0,l.uT)();if(!e)return;let{getToken:t}=await n.e(9830).then(n.bind(n,89830)),r="BIBtQrY1Ym8w3mTIr6fYrSC3RhxnAi3m85IfnG11xu8av0juy5AjDDfdbx0QrsYps223kaZnwJrH2PAFILmn8hc";if(!r)return;let i=await navigator.serviceWorker.ready,s=await t(e,{vapidKey:r,serviceWorkerRegistration:i}),c=localStorage.getItem(u);s&&s!==c&&(await (0,o.uE)("/notifications/tokens",{method:"POST",body:{token:s,deviceType:(0,a.Z)()}}),localStorage.setItem(u,s))}catch(e){if(e instanceof Error&&"code"in e&&"messaging/permission-blocked"===e.code||e instanceof Error&&"code"in e&&"messaging/token-subscribe-failed"===e.code&&e.message.includes("Failed to fetch")||e instanceof DOMException&&("AbortError"===e.name||"NotAllowedError"===e.name)||e instanceof o.hD&&401===e.status)return;i.Cp(e,{tags:{area:"push-token-register"}})}}async function h(){try{let e=localStorage.getItem(u);if(!e)return;await (0,o.uE)("/notifications/tokens/".concat(encodeURIComponent(e)),{method:"DELETE"}),localStorage.removeItem(u)}catch(e){localStorage.removeItem(u)}}},59026:(e,t,n)=>{n.d(t,{mintAnon:()=>a});var r=n(78079),i=n(48727);let o=null;async function a(){return o||(o=(async()=>{let e=await (0,i.D)();if(!e)throw Error("auth-bootstrap: empty Turnstile token (refused to POST without one)");return(0,r.uE)("/auth/anon/start",{method:"POST",body:{turnstileToken:e}})})().catch(e=>{throw o=null,e}))}},78414:(e,t,n)=>{n.d(t,{Cy:()=>s,uT:()=>c});var r=n(55840),i=n(23259),o=n(86146);let a={apiKey:"AIzaSyCzQbtQAEqEriTs8bkNruZiFkUgSwwIwJE",authDomain:"ecomitram.org",projectId:"epsg-social",messagingSenderId:"444234092495",appId:"1:444234092495:web:c4bd0f9c3fd7279e4dccba"};function l(){return(0,r.Dk)().length>0?(0,r.Sx)():(0,r.Wp)(a)}let u=null;function s(){if(!u){u=(0,i.Nu)(l(),{persistence:[i.Gt,i.F0,i.iM]});let e=o.env.NEXT_PUBLIC_FIREBASE_AUTH_EMULATOR_HOST;e&&(0,i.Wq)(u,"http://".concat(e),{disableWarnings:!0})}return u}async function c(){let{getMessaging:e,isSupported:t}=await n.e(9830).then(n.bind(n,89830));return await t()?e(l()):null}},85374:(e,t,n)=>{function r(e){try{return"local"===e?window.localStorage:window.sessionStorage}catch(e){return null}}function i(e){let t=r("local");if(null===t)return null;try{return t.getItem(e)}catch(e){return null}}function o(e,t){let n=r("local");if(null===n)return!1;try{return n.setItem(e,t),!0}catch(e){return!1}}function a(e){let t=r("session");if(null===t)return null;try{return t.getItem(e)}catch(e){return null}}function l(e,t){let n=r("session");if(null===n)return!1;try{return n.setItem(e,t),!0}catch(e){return!1}}function u(e){let t=r("session");if(null===t)return!1;try{return t.removeItem(e),!0}catch(e){return!1}}n.d(t,{Un:()=>u,YZ:()=>l,_A:()=>a,bl:()=>o,zn:()=>i})},85785:(e,t,n)=>{n.d(t,{Ix:()=>a,RY:()=>l});var r=n(78079);class i extends Error{constructor(e,t="unknown"){super(e),this.name="EmailOtpError",this.code=t}}function o(e){return e.errorCode&&["turnstile-load-failed","network-failure","throttle-429","jwt-expired","invalid-code"].includes(e.errorCode)?e.errorCode:429===e.status?"throttle-429":401===e.status?"invalid-code":e.status>=500?"network-failure":"unknown"}async function a(e,t){try{return await (0,r.uE)("/auth/email/send-otp",{method:"POST",credentials:"include",body:{email:e,turnstileToken:t}})}catch(e){if(e instanceof r.hD)throw new i(e.message,o(e));throw new i(e instanceof Error?e.message:"Failed to send code","network-failure")}}async function l(e,t){try{return await (0,r.uE)("/auth/email/verify-otp",{method:"POST",credentials:"include",body:{email:e,code:t}})}catch(e){if(e instanceof r.hD)throw new i(e.message,o(e));throw new i(e instanceof Error?e.message:"Failed to verify code","network-failure")}}},92213:(e,t,n)=>{function r(e,t){return t?"".concat(e,"?redirect=").concat(encodeURIComponent(t)):e}n.d(t,{V:()=>r,jp:()=>l,sG:()=>a});
1let i=/[\\\t\n\r]|%5[cC]|%2[fF]/,o="https://placeholder.invalid";function a(e){if(!e||e.length<2||"/"!==e[0]||"/"===e[1]||"\\"===e[1]||i.test(e))return"/";try{let t=new URL(e,o);if(t.origin!==o||!t.pathname.startsWith("/"))return"/"}catch(e){return"/"}return e}function l(e,t,n,r){return e?a(e):t?a(t):!1===r?"/login/complete-profile":!0===r||(null==n?void 0:n.trim())?"/":"/profile/edit?onboarding=true"}}}]);

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.