1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2368],{1005:(e,t,r)=>{r.d(t,{I18nProvider:()=>s,s:()=>c});var n=r(95155),o=r(19749),u=r(12115);function i(e,t,r,n={}){let o=t[r];return o?("string"==typeof o?o:o[new Intl.PluralRules(e).select(Number(n.count??0))]??o.other).replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e):r}let a=(0,u.createContext)(null);function s(e){let t,r,s,c,l,f=(0,o.c)(11),{children:h,dictionary:d,locale:p}=e;return f[0]!==d||f[1]!==p?(r=(e,t,r)=>i(p,d[e]??{},t,r),s=(e,t,r,o)=>(function(e,t,r,o,a){let s=i(e,t,r,a),c=[],l=0;for(let e of s.matchAll(/<(\w+)>(.*?)<\/\1>/g)){let t=e.index??0;t>l&&c.push(s.slice(l,t));let[,r="",i=""]=e,a=`${r}-${t}`;c.push((0,n.jsx)(u.Fragment,{children:o[r]?.(i,a)??e[0]},a)),l=t+e[0].length}return l<s.length&&c.push(s.slice(l)),c})(p,d[e]??{},t,r,o),f[0]=d,f[1]=p,f[2]=r,f[3]=s):(r=f[2],s=f[3]),f[4]!==p||f[5]!==r||f[6]!==s?(c={locale:p,t:r,tRich:s},f[4]=p,f[5]=r,f[6]=s,f[7]=c):c=f[7],t=c,f[8]!==h||f[9]!==t?(l=(0,n.jsx)(a.Provider,{value:t,children:h}),f[8]=h,f[9]=t,f[10]=l):l=f[10],l}function c(){let e=(0,u.useContext)(a);if(!e)throw Error("useI18n must be used within I18nProvider");return e}},5955:(e,t,r)=>{r.d(t,{J5:()=>f,b2:()=>c,bV:()=>s,zf:()=>a});let n=["failed to fetch","fetch failed","load failed","networkerror","network error","network connection lost","loading chunk","chunkloaderror","dynamically imported module","connection closed","connection reset","socket hang up","terminated","econnreset","econnrefused","etimedout","gateway timeout","bad gateway","service unavailable"],o=new Set([408,425,429,500,502,503,504]),u=new Set(["GET","HEAD","OPTIONS"]);function i(e){return e instanceof Error?e.message:"string"==typeof e?e:""}function a(e){if("u">typeof DOMException&&e instanceof DOMException&&"AbortError"===e.name)return!0;if(e instanceof Error){if("AbortError"===e.name)return!0;if("cause"in e&&e.cause)return a(e.cause)}return!!e&&"object"==typeof e&&"cause"in e&&a(e.cause)}function s(e){if(a(e)||"u">typeof DOMException&&e instanceof DOMException&&"TimeoutError"===e.name)return!0;let t=i(e).toLowerCase();return n.some(e=>t.includes(e))}function c(e){return i(e).toLowerCase().includes("connection closed")}async function l(e){try{await e.body?.cancel()}catch{}}async function f(e,t,r={}){var n;let i,c=r.retries??2,h=r.baseDelayMs??150,d=r.timeoutMs,p=u.has(t?.method?t.method.toUpperCase():"u">typeof Request&&e instanceof Request?e.method.toUpperCase():"GET");for(let r=0;r<=c;r++){try{let u=d?AbortSignal.timeout(d):void 0,i=t?.signal&&u?AbortSignal.any([t.signal,u]):t?.signal??u,a=await fetch(e,i?{...t,signal:i}:t);if(!p||r===c||(n=a.status,!o.has(n)))return a;await l(a)}catch(e){if(i=e,!p||r===c||a(e)||!s(e))throw e}let u=Math.floor(75*Math.random());await function(e){return new Promise(t=>setTimeout(t,e))}(h*2**r+u)}throw i}},32039:(e,t,r)=>{let n;r.d(t,{OC:()=>E,ct:()=>A,dE:()=>p,zf:()=>w});var o,u=r(82402);function i(e){return!!e&&e.endsWith(".orb.local")}function a(e,t){if(!e)return t;try{let r=new URL(e);if(i(r.hostname))return t;return r.origin}catch{return t}}function s(e){let t=new URL(e);return{hostname:t.hostname,protocol:t.protocol.replace(":","")}}function c(e,t="/"){try{return new URL(t).toString()}catch{return new URL(function(e="/"){return e?e.startsWith("/")?e:`/${e}`:"/"}(t),`${e}/`).toString()}}let l=u.env.NEXT_PUBLIC_TYPESENSE_HOST,f=i(l),h=a(u.env.NEXT_PUBLIC_BASE_URL,"https://thaqalayn.com"),d=a(u.env.NEXT_PUBLIC_API_BASE_URL,"https://api.thaqalayn.com"),p=a(u.env.NEXT_PUBLIC_THAQALAYN_TRPC_SERVER_URL,"https://trpc.thaqalayn.com"),g=a(u.env.NEXT_PUBLIC_ANALYTICS_BASE_URL,"https://analytics.thaqalayn.net");s(h).hostname,s(d).hostname,s(h).protocol,s(d).protocol;let m={host:!l||i(l)?"api.thaqalayn.com":l,port:Number.isInteger(n=Number(u.env.NEXT_PUBLIC_TYPESENSE_PORT))&&n>0?n:8108,protocol:(o=u.env.NEXT_PUBLIC_TYPESENSE_PROTOCOL,f||!o?"https":o)},v=`${m.protocol}://${m.host}:${m.port}`;function E(e="/"){return c(h,e)}function w(e="/"){return c(d,e)}function A(e="/"){return c(v,e)}
1c(g,"/script.js"),c(h,"/images/brand/logo.png"),c(h,"/images/brand/scale-preview.png")},38095:(e,t,r)=>{r.d(t,{U_:()=>c,id:()=>a,qQ:()=>s});var n=r(9044),o=r(66849),u=r(5955),i=r(50412);let a=(0,o.pY)(),s=new n.E({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:(e,t)=>!(0,u.zf)(t)&&e<3}}}),c=a.createClient({links:[(0,o.fu)({url:(0,i.nX)(),fetch(e,t){let r=t?.headers?Object.fromEntries(new Headers(t.headers).entries()):{};return(0,u.J5)(e,{...t,...i.Wv,headers:{...r,...i.BD}})}})]})},42368:(e,t,r)=>{r.d(t,{A:()=>d,AuthProvider:()=>c});var n=r(95155),o=r(19749),u=r(87785),i=r(12115),a=r(38095);let s=(0,i.createContext)(void 0);function c(e){let t,r,c,d,p,g,m,v,E,w,A,y,C=(0,o.c)(36),{children:_}=e,S=(0,u.g)(),U=a.id.user.auth.refreshAccessToken.useMutation(),L=(0,i.useRef)(!1);C[0]===Symbol.for("react.memo_cache_sentinel")?(t={retry:h,staleTime:3e5,refetchOnWindowFocus:!0,refetchOnMount:!0},C[0]=t):t=C[0];let{data:R,isLoading:T,error:P,refetch:b}=a.id.user.profile.getCurrentUser.useQuery(void 0,t),x=(0,i.useRef)(!1),N=P?.data?.code??null,O=P?.message??null;C[1]!==N||C[2]!==O||C[3]!==b||C[4]!==U?(r=()=>{if("UNAUTHORIZED"!==N||"Invalid or expired auth token"!==O){x.current=!1;return}x.current||L.current||(x.current=!0,L.current=!0,U.mutateAsync().then(()=>{console.log("[AuthContext] Token refreshed, refetching user..."),b()}).catch(f).finally(()=>{L.current=!1}))},c=[N,O,U,b],C[1]=N,C[2]=O,C[3]=b,C[4]=U,C[5]=r,C[6]=c):(r=C[5],c=C[6]),(0,i.useEffect)(r,c),C[7]!==R?(d=R?.user?{...R.user,createdAt:R.user.createdAt?new Date(R.user.createdAt):void 0}:null,C[7]=R,C[8]=d):d=C[8];let I=d,k=P?.message||null;C[9]!==I?.privilege?(p=()=>I?.privilege==="SuperAdmin",C[9]=I?.privilege,C[10]=p):p=C[10];let $=p;C[11]!==I?.privilege?(g=()=>I?.privilege==="SuperAdmin"||I?.privilege==="Admin",C[11]=I?.privilege,C[12]=g):g=C[12];let q=g;C[13]!==I?.privilege?(m=()=>I?.privilege==="SuperAdmin"||I?.privilege==="Admin"||I?.privilege==="Moderator",C[13]=I?.privilege,C[14]=m):m=C[14];let B=m;C[15]!==b||C[16]!==S?(v=async(e,t)=>{console.log("[AuthContext] Login successful, refetching user..."),await b(),S.push(void 0===t?"/profile":t)},C[15]=b,C[16]=S,C[17]=v):v=C[17];let M=v,D=a.id.useUtils();C[18]!==S||C[19]!==D?(E={onSuccess:async()=>{console.log("[AuthContext] Logout successful"),await D.user.profile.getCurrentUser.cancel(),await D.user.profile.getCurrentUser.reset(),S.push("/"),S.refresh()},onError:l},C[18]=S,C[19]=D,C[20]=E):E=C[20];let X=a.id.user.auth.logout.useMutation(E);C[21]!==X?(w=async()=>{console.log("[AuthContext] Logging out..."),await X.mutateAsync()},C[21]=X,C[22]=w):w=C[22];let W=w;C[23]!==k||C[24]!==q||C[25]!==T||C[26]!==B||C[27]!==$||C[28]!==M||C[29]!==W||C[30]!==b||C[31]!==I?(A={user:I,isLoading:T,error:k,refetch:b,login:M,logout:W,isSuperAdmin:$,isAdmin:q,isModerator:B},C[23]=k,C[24]=q,C[25]=T,C[26]=B,C[27]=$,C[28]=M,C[29]=W,C[30]=b,C[31]=I,C[32]=A):A=C[32];let H=A;return C[33]!==_||C[34]!==H?(y=(0,n.jsx)(s.Provider,{value:H,children:_}),C[33]=_,C[34]=H,C[35]=y):y=C[35],y}function l(e){console.error("[AuthContext] Logout failed:",e.message)}function f(){console.log("[AuthContext] Refresh failed, user is logged out")}function h(e,t){return t?.data?.code!=="UNAUTHORIZED"&&e<3}function d(){let e=(0,i.useContext)(s);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},50412:(e,t,r)=>{r.d(t,{BD:()=>n,Wv:()=>o,nX:()=>u}),r(32039);let n={"x-thaqalayn-csrf":"1"},o={credentials:"include"};function u(){return"/api/trpc"}},67572:(e,t,r)=>{r.d(t,{Eq:()=>s,H$:()=>l,P1:()=>o,YZ:()=>n,aC:()=>i,dS:()=>c,l1:()=>a,rv:()=>f,u6:()=>u});let n=["en","ar"];function o(e){return"ar"===e?"ar":"en"}function u(e){return"ar"===e||"ur"===e?"rtl":"ltr"}function i(e){return"ar"===e?"ar-u-nu-latn":"ur"===e?"ur-u-nu-latn":"en-US-u-nu-latn"}function a(e){return e.replace(/^\/(?:ar|en|ur)(?=\/|$)/,"")||"/"}function s(e){let t=e.split("/")[1]??"";return"ur"===t||n.some(e=>e===t)?t:"en"}function c(e,t){if(!t.startsWith("/")||t.startsWith("//"))return t;let r=new URL(t,"https://thaqalayn.local"),n=a(r.pathname);return r.pathname="en"===e?n:`/${e}${"/"===n?"":n}`,`${r.pathname}${r.search}${r.hash}`}function l(e){return"ur"===e?["ar","en","ur"]:"ar"===e?["ar","en"]:["en"]}function f(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}},87785:(e,t,r)=>{r.d(t,{g:()=>a});var n=r(19749),o=r(82222),u=r(1005),i=r(67572);function a(){let e,t,r,a,s,c=(0,n.c)(12),l=(0,o.useRouter)(),{locale:f}=(0,u.s)();c[0]!==f?(e=e=>(0,i.dS)(f,e),c[0]=f,c[1]=e):e=c[1];let h=e;return c[2]!==h||c[3]!==l?(t=(e,t)=>
1l.push(h(e),t),r=(e,t)=>l.replace(h(e),t),a=(e,t)=>l.prefetch(h(e),t),c[2]=h,c[3]=l,c[4]=t,c[5]=r,c[6]=a):(t=c[4],r=c[5],a=c[6]),c[7]!==l||c[8]!==t||c[9]!==r||c[10]!==a?(s={...l,push:t,replace:r,prefetch:a},c[7]=l,c[8]=t,c[9]=r,c[10]=a,c[11]=s):s=c[11],s}}}]);
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.