"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6645],{13406:(e,t,s)=>{s.d(t,{Xi:()=>o,av:()=>c,j7:()=>i,tU:()=>l});var a=s(95155);s(12115);var r=s(60574),n=s(64269);function l(e){let{className:t,...s}=e;return(0,a.jsx)(r.bL,{"data-slot":"tabs",className:(0,n.cn)("flex flex-col gap-2",t),...s})}function i(e){let{className:t,...s}=e;return(0,a.jsx)(r.B8,{"data-slot":"tabs-list",className:(0,n.cn)("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...s})}function o(e){let{className:t,...s}=e;return(0,a.jsx)(r.l9,{"data-slot":"tabs-trigger",className:(0,n.cn)("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function c(e){let{className:t,...s}=e;return(0,a.jsx)(r.UC,{"data-slot":"tabs-content",className:(0,n.cn)("flex-1 outline-none",t),...s})}},14734:(e,t,s)=>{s.d(t,{F:()=>i});var a=s(12115),r=s(9829),n=s(36489),l=s(95704);function i(){var e;let{data:t}=(0,n.useSession)(),[s,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(!1),[d,x]=(0,a.useState)(null),u=(0,a.useRef)(null);return(0,a.useEffect)(()=>{(async()=>{try{var e;let t=await fetch("/api/settings/socket-status"),s=await t.json();x(null==(e=s.socketEnabled)||e),console.log("\uD83D\uDD0C Socket enabled status:",s.socketEnabled)}catch(e){console.error("Error checking socket status:",e),x(!0)}})()},[]),(0,a.useEffect)(()=>{if(!(null==t?void 0:t.user)||null===d)return;if(!1===d)return void console.log("\uD83D\uDD0C Socket.IO disabled by admin - SSE will be used instead");let e=window.location.hostname.includes("app.github.dev")||window.location.hostname.includes("github.dev"),a=window.location.origin;console.log("\uD83D\uDD0C Socket URL Detection:"),console.log("  - isCodespace:",e),console.log("  - NODE_ENV:","production"),console.log("  - NEXT_PUBLIC_SITE_URL:",l.env.NEXT_PUBLIC_SITE_URL),console.log("  - window.location.origin:",window.location.origin),console.log("  - window.location.hostname:",window.location.hostname),console.log("  - Final socketUrl:",a);let n=(0,r.io)(a,{path:"/api/socket/io",addTrailingSlash:!1,transports:["polling","websocket"],timeout:1e4,reconnection:!0,reconnectionAttempts:3,reconnectionDelay:5e3,reconnectionDelayMax:1e4,randomizationFactor:0,forceNew:!0});return n.on("connect",()=>{console.log("✅ Socket connected:",n.id),c(!0),t.user.id&&n.emit("joinUserRoom",t.user.id)}),n.on("disconnect",e=>{console.log("❌ Socket disconnected:",e),c(!1),"io server disconnect"===e&&(u.current=setTimeout(()=>{n.connect()},5e3))}),n.on("connect_error",e=>{console.error("\uD83D\uDD25 Socket connection error:",e.message),c(!1)}),n.io.on("reconnect_failed",()=>{console.log("❌ Socket reconnection failed after all attempts. Stopping socket."),c(!1)}),i(n),()=>{u.current&&clearTimeout(u.current),null==s||s.disconnect()}},[null==t||null==(e=t.user)?void 0:e.id,d]),{socket:s,isConnected:o,joinUserRoom:()=>{s&&(null==t?void 0:t.user.id)&&s.emit("joinUserRoom",t.user.id)},leaveUserRoom:()=>{s&&(null==t?void 0:t.user.id)&&s.emit("leaveUserRoom",t.user.id)},joinCafeRoom:e=>{s&&s.emit("joinCafeRoom",e)},leaveCafeRoom:e=>{s&&s.emit("leaveCafeRoom",e)},joinEventRoom:e=>{s&&s.emit("joinEventRoom",e)},leaveEventRoom:e=>{s&&s.emit("leaveEventRoom",e)}}}},25112:(e,t,s)=>{s.d(t,{h:()=>n});var a=s(12115),r=s(36489);function n(){var e;let{data:t}=(0,r.useSession)(),[s,n]=(0,a.useState)(!1),[l,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(null),d=(0,a.useRef)(null);return(0,a.useEffect)(()=>{var e;if(!(null==t||null==(e=t.user)?void 0:e.id))return;console.log("\uD83D\uDCE1 Setting up SSE connection for user:",t.user.id);let s=new EventSource("/api/notifications/sse");return d.current=s,s.onopen=()=>{console.log("✅ SSE connection established"),n(!0),c(null)},s.onmessage=e=>{try{let t=JSON.parse(e.data);console.log("\uD83D\uDD14 SSE notification received:",t),i(t),"notification"===t.type&&window.dispatchEvent(new CustomEvent("newNotification",{detail:t})),"points"===t.type&&window.dispatchEvent(new CustomEvent("newPoints",{detail:t}))}catch(e){console.error("❌ Error parsing SSE message:",e)}},s.onerror=e=>{console.error("❌ SSE connection error:",e),n(!1),c("اتصال real-time قطع شد")},()=>{console.log("\uD83E\uDDF9 Cleaning up SSE connection"),s.close(),n(!1)}},[null==t||null==(e=t.user)?void 0:e.id]),{isConnected:s,lastNotification:l,connectionError:o}}},41444:(e,t,s)=>{s.d(t,{v:()=>r});class a{formatMessage(e,t,s){let a=new Date().toISOString();return s&&JSON.stringify(s),JSON.stringify({timestamp:a,level:e,message:t,...s})}info(e,t){console.log(this.formatMessage("info",e,t))}warn(e,t){console.warn(this.formatMessage("warn",e,t))}error(e,t){console.error(this.formatMessage("error",e,t))}debug(e,t){}}let r=new a},56645:(e,t,s)=>{s.d(t,{NotificationPanel:()=>L});var a=s(95155),r=s(12115),n=s(86948),l=s(3998),i=s(11647),o=s(13406),c=s(78519),d=s(16485),x=s(91169),u=s(6132),m=s(16645),h=s(95740),p=s(85998),f=s(13492),g=s(61362),b=s(65229),v=s(5917),j=s(20017),w=s(71360),N=s(56210),y=s(14734),k=s(25112),E=s(18720),S=s(20063),C=s(64269);let A=r.createContext(null),I=e=>{let{children:t}=e,[s,n]=r.useState(!1),l=r.useMemo(()=>({open:s,setOpen:n}),[s]);return r.useEffect(()=>{let e=e=>{s&&e.target instanceof Element&&(e.target.closest("[data-dropdown]")||n(!1))};if(s)return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[s]),(0,a.jsx)(A.Provider,{value:l,children:(0,a.jsx)("div",{className:"relative inline-block","data-dropdown":!0,children:t})})},D=()=>{let e=r.useContext(A);if(!e)throw Error("useDropdownMenu must be used within DropdownMenu");return e},T=r.forwardRef((e,t)=>{let{className:s,children:r,onClick:n,...l}=e,{open:i,setOpen:o}=D();return(0,a.jsx)("button",{ref:t,className:(0,C.cn)("inline-flex items-center justify-center",s),onClick:e=>{e.preventDefault(),e.stopPropagation(),o(!i),null==n||n(e)},"aria-expanded":i,...l,children:r})});T.displayName="DropdownMenuTrigger";let R=r.forwardRef((e,t)=>{let{className:s,align:r="center",...n}=e,{open:l}=D();return l?(0,a.jsx)("div",{ref:t,className:(0,C.cn)("absolute top-full mt-1 w-56 rounded-md border bg-popover p-1 text-popover-foreground shadow-lg z-50","end"===r&&"right-0","start"===r&&"left-0","center"===r&&"left-1/2 -translate-x-1/2",s),...n}):null});R.displayName="DropdownMenuContent";let M=r.forwardRef((e,t)=>{let{className:s,onClick:r,...n}=e,{setOpen:l}=D();return(0,a.jsx)("div",{ref:t,className:(0,C.cn)("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",s),onClick:e=>{null==r||r(e),l(!1)},...n})});M.displayName="DropdownMenuItem";var O=s(20508),P=s(95767);function U(e){let{nudgeId:t,notificationId:s,isRead:n,onNotificationRead:i}=e,[o,c]=(0,r.useState)(!1),[d,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),h=async()=>{if(!o){if(d){m(!0),n||p();return}c(!0);try{let e=await fetch("/api/nudges/".concat(t,"/sender-profile")),s=await e.json();e.ok&&s.success&&s.data?(x(s.data),m(!0),n||p()):E.o.error(s.error||"پروفایل یا تلنگر مورد نظر یافت نشد")}catch(e){console.error("Error fetching nudge sender profile:",e),E.o.error("خطای ارتباط با سرور در دریافت پروفایل کاربر")}finally{c(!1)}}},p=async()=>{try{(await fetch("/api/notifications/".concat(s),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"mark-read"})})).ok&&(null==i||i())}catch(e){console.error("Error auto-marking nudge notification as read:",e)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$,{size:"sm",onClick:h,disabled:o,className:"w-full text-xs h-8 rounded-lg bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white font-medium shadow-xs hover:shadow-sm transition-all duration-200 flex items-center justify-center gap-1.5",children:o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.LoadingSpinner,{size:"xs"}),(0,a.jsx)("span",{children:"در حال دریافت پروفایل..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(O.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:"مشاهده پروفایل"})]})}),d&&(0,a.jsx)(P.A,{user:d,isOpen:u,onClose:()=>m(!1)})]})}function L(e){let{userId:t,className:s,onNotificationRead:A,onClose:D,showCloseButton:O=!1}=e,[P,L]=(0,r.useState)([]),[F,G]=(0,r.useState)(0),[z,Y]=(0,r.useState)(!1),[_,B]=(0,r.useState)("new"),[J,V]=(0,r.useState)(null),$=(0,S.useRouter)(),{socket:W,isConnected:q}=(0,y.F)(),{isConnected:H}=(0,k.h)(),X=(0,r.useRef)(null),K=q||H,Q=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Y(!0);try{let t=new URLSearchParams;e&&t.append("unread","true");let s=await fetch("/api/notifications?".concat(t)),a=await s.json();a.success&&(e?G(a.data.unreadCount):L(a.data.notifications))}catch(e){console.error("Error loading notifications:",e),E.o.error("خطا در بارگذاری اعلان‌ها")}finally{Y(!1)}},Z=async e=>{try{(await fetch("/api/notifications/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"mark-read"})})).ok&&(L(t=>t.map(t=>t.id===e?{...t,isRead:!0}:t)),G(e=>Math.max(0,e-1)),null==A||A())}catch(e){console.error("Error marking as read:",e),E.o.error("خطا در علامت‌گذاری اعلان")}},ee=async(e,t,s)=>{V(e);try{let o=await fetch("/api/invite/respond",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({invitationId:e,action:t})}),c=await o.json();if(c.success)if(await Z(s),window.dispatchEvent(new CustomEvent("playmo:refresh-globe")),"ACCEPT"===t){var a,r,n,l,i;(null==(a=c.data)?void 0:a.isFree)?(E.o.success("دعوتنامه پذیرفته شد! شما به میز بازی اضافه شدید \uD83C\uDF89"),D&&D(),$.push("/checkout/invite-success?tableId=".concat((null==(n=c.data)?void 0:n.bookingId)||""))):(null==(r=c.data)?void 0:r.requiresPayment)&&(E.o.info(c.message||"دعوتنامه پذیرفته شد. لطفاً هزینه ورودی را پرداخت نمایید."),(null==(l=c.data)?void 0:l.payer)==="GUEST"&&(D&&D(),$.push("/checkout/event/".concat((null==(i=c.data)?void 0:i.bookingId)||""))))}else E.o.info("دعوتنامه رد شد.");else E.o.error(c.error||c.message||"خطا در پردازش پاسخ دعوتنامه")}catch(e){console.error("Error responding to invitation:",e),E.o.error("خطای ارتباط با سرور در پاسخ به دعوتنامه")}finally{V(null)}},et=async e=>{try{(await fetch("/api/notifications/".concat(e),{method:"DELETE"})).ok&&(L(t=>t.filter(t=>t.id!==e)),E.o.success("اعلان حذف شد"))}catch(e){console.error("Error deleting notification:",e),E.o.error("خطا در حذف اعلان")}},es=async()=>{try{(await fetch("/api/notifications/mark-all-read",{method:"PUT"})).ok&&(L(e=>e.map(e=>({...e,isRead:!0}))),G(0),null==A||A(),E.o.success("تمام اعلان‌ها به عنوان خوانده شده علامت‌گذاری شدند"))}catch(e){console.error("Error marking all as read:",e),E.o.error("خطا در علامت‌گذاری همه اعلان‌ها")}};(0,r.useEffect)(()=>{if(!W||!q)return;W.emit("joinUserRoom",t);let e=e=>{let t={id:e.id,userId:e.userId,type:e.type,title:e.title,message:e.message,data:e.data,isRead:!1,createdAt:e.createdAt,updatedAt:e.createdAt};L(e=>[t,...e]),G(e=>e+1)};return W.on("notification",e),()=>{W.off("notification",e)}},[W,q,t]),(0,r.useEffect)(()=>{let e=e=>{let s=e.detail;if(s&&"notification"===s.type){let e={id:s.id||"sse-".concat(Date.now()),userId:s.userId||t,type:s.notificationType||"SYSTEM",title:s.title,message:s.message,data:s.data,isRead:!1,createdAt:s.timestamp||new Date().toISOString(),updatedAt:s.timestamp||new Date().toISOString()};L(t=>[e,...t]),G(e=>e+1),console.log("\uD83D\uDCE1 SSE notification added to panel")}};return window.addEventListener("newNotification",e),()=>{window.removeEventListener("newNotification",e)}},[t]),(0,r.useEffect)(()=>{let e=X.current;if(!e)return;let t=t=>{t.stopPropagation(),t.preventDefault();let s=e.querySelector(".scrollable-content");s&&(s.scrollTop+=.5*t.deltaY)};return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}},[]),(0,r.useEffect)(()=>{Q(),Q(!0)},[]);let ea=e=>"new"===_?e.filter(e=>!e.isRead).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()):e.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,a.jsxs)(n.Zp,{ref:X,className:(0,C.cn)("flex flex-col overflow-hidden max-h-[32rem]",s),style:{overscrollBehavior:"contain",height:"auto"},children:[(0,a.jsx)(n.aR,{className:"pb-3 flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)(n.ZB,{className:"flex items-center gap-2 text-right",children:[F>0?(0,a.jsx)(f.A,{className:"h-5 w-5 text-blue-600"}):(0,a.jsx)(p.A,{className:"h-5 w-5"}),"اعلان‌ها",F>0&&(0,a.jsx)(i.E,{variant:"destructive",className:"text-xs",children:F})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(K?"bg-green-500":"bg-red-500")}),K?"آنلاین":"آفلاین",!q&&H&&(0,a.jsx)(i.E,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4 bg-blue-100 text-blue-700",children:"SSE"})]}),F>0&&(0,a.jsxs)(l.$,{variant:"outline",size:"sm",onClick:es,className:"text-xs",children:[(0,a.jsx)(g.A,{className:"h-3 w-3 mr-1"}),"همه خوانده شد"]}),O&&D&&(0,a.jsx)(l.$,{variant:"ghost",size:"sm",onClick:D,className:"text-xs p-1 h-6 w-6",children:(0,a.jsx)(b.A,{className:"h-3 w-3"})})]})]})}),(0,a.jsx)(n.Wu,{className:"flex-1 flex flex-col min-h-0",children:(0,a.jsxs)(o.tU,{value:_,onValueChange:B,className:"w-full h-full flex flex-col",children:[(0,a.jsxs)(o.j7,{className:"grid w-full grid-cols-2 flex-shrink-0",dir:"rtl",children:[(0,a.jsxs)(o.Xi,{value:"new",children:["جدید (",F,")"]}),(0,a.jsxs)(o.Xi,{value:"all",children:["همه اعلان‌ها (",P.length,")"]})]}),(0,a.jsx)(o.av,{value:_,className:"mt-4 flex-1 flex flex-col min-h-0",children:(0,a.jsx)("div",{className:"flex-1 overflow-y-auto scrollable-content max-h-[60vh] sm:max-h-[22rem]",style:{overscrollBehavior:"contain"},children:z?(0,a.jsxs)("div",{className:"flex justify-center items-center py-8",children:[(0,a.jsx)(N.LoadingSpinner,{size:"md",className:"ml-2"}),(0,a.jsx)("span",{className:"mr-2",children:"در حال بارگذاری..."})]}):(0,a.jsxs)("div",{className:"space-y-3",children:[ea(P).map(e=>(0,a.jsx)("div",{className:"p-3 rounded-lg border ".concat(e.isRead?"bg-muted/30 border-muted":"bg-card border-border shadow-sm"," transition-all hover:shadow-md"),children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsx)("div",{className:"p-2 rounded-full ".concat((e=>{switch(e){case"BOOKING":return"text-green-600 bg-green-50";case"EVENT":return"text-blue-600 bg-blue-50";case"FRIEND_REQUEST":return"text-purple-600 bg-purple-50";case"PAYMENT":return"text-orange-600 bg-orange-50";case"REVIEW":return"text-yellow-600 bg-yellow-50";case"TABLE_INVITATION":return"text-purple-600 bg-purple-100";case"NUDGE":return"text-pink-600 bg-pink-50";default:return"text-gray-600 bg-gray-50"}})(e.type)),children:(e=>{switch(e){case"BOOKING":case"PAYMENT":return(0,a.jsx)(c.A,{className:"h-4 w-4"});case"EVENT":return(0,a.jsx)(d.A,{className:"h-4 w-4"});case"FRIEND_REQUEST":return(0,a.jsx)(x.A,{className:"h-4 w-4"});case"REVIEW":return(0,a.jsx)(u.A,{className:"h-4 w-4"});case"TABLE_INVITATION":return(0,a.jsx)(m.A,{className:"h-4 w-4"});case"NUDGE":return(0,a.jsx)(h.A,{className:"h-4 w-4"});default:return(0,a.jsx)(p.A,{className:"h-4 w-4"})}})(e.type)}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)("h4",{className:"font-medium text-sm truncate",children:e.title}),!e.isRead&&(0,a.jsx)("div",{className:"w-2 h-2 bg-blue-600 rounded-full flex-shrink-0"})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.message}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,a.jsx)(i.E,{variant:"secondary",className:"text-xs",children:"TABLE_INVITATION"===e.type?"دعوت به میز":"NUDGE"===e.type?"تلنگر":e.type}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleString("fa-IR",{timeZone:"Asia/Tehran"})})]}),"TABLE_INVITATION"===e.type&&e.relatedId&&!e.isRead&&(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-3 pt-2 border-t border-purple-100/70",children:[(0,a.jsx)(l.$,{size:"sm",onClick:()=>ee(e.relatedId,"ACCEPT",e.id),disabled:J===e.relatedId,className:"text-xs h-7 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white flex-1 shadow-xs",children:J===e.relatedId?(0,a.jsx)(N.LoadingSpinner,{size:"xs"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.A,{className:"h-3.5 w-3.5 ml-1"}),"قبول دعوت"]})}),(0,a.jsxs)(l.$,{size:"sm",variant:"outline",onClick:()=>ee(e.relatedId,"REJECT",e.id),disabled:J===e.relatedId,className:"text-xs h-7 rounded-lg text-gray-700 hover:bg-red-50 hover:text-red-600 hover:border-red-200 flex-1",children:[(0,a.jsx)(b.A,{className:"h-3.5 w-3.5 ml-1"}),"رد کردن"]})]}),"NUDGE"===e.type&&e.relatedId&&(0,a.jsx)("div",{className:"mt-3 pt-2 border-t border-orange-100/70 dark:border-orange-950/30",children:(0,a.jsx)(U,{nudgeId:e.relatedId,notificationId:e.id,isRead:e.isRead,onNotificationRead:A})})]}),(0,a.jsxs)(I,{children:[(0,a.jsx)(T,{asChild:!0,children:(0,a.jsx)(l.$,{variant:"ghost",size:"sm",children:(0,a.jsx)(j.A,{className:"h-4 w-4"})})}),(0,a.jsxs)(R,{align:"end",dir:"rtl",children:[!e.isRead&&(0,a.jsxs)(M,{onClick:()=>Z(e.id),children:[(0,a.jsx)(v.A,{className:"h-4 w-4 mr-2"}),"علامت‌گذاری به عنوان خوانده شده"]}),(0,a.jsxs)(M,{onClick:()=>et(e.id),className:"text-red-600 hover:text-red-700",children:[(0,a.jsx)(w.A,{className:"h-4 w-4 mr-2"}),"حذف اعلان"]})]})]})]})},e.id)),0===ea(P).length&&(0,a.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,a.jsx)(p.A,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,a.jsx)("p",{children:"اعلانی وجود ندارد"})]})]})})})]})})]})}},58779:(e,t,s)=>{s.d(t,{Fi:()=>x,Mk:()=>o,NP:()=>d,Or:()=>n,WV:()=>i,aR:()=>c,oC:()=>u,pJ:()=>l});var a=s(4368),r=s.n(a);function n(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"jYYYY/jMM/jDD";try{let s=r().utc(e).add(3.5,"hours");if(!s.isValid())return"تاریخ نامشخص";return s.format(t)}catch(e){return"تاریخ نامشخص"}}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{dateFormat:s="jYYYY/jMM/jDD",timeFormat:a="HH:mm",separator:n=" - "}=t;try{let t=r().utc(e).add(3.5,"hours");if(!t.isValid())return"تاریخ نامشخص";let l=t.format(s),i=t.format(a);return"".concat(l).concat(n).concat(i)}catch(e){return"تاریخ نامشخص"}}function i(e){let t=r()(e);return{year:t.jYear(),month:t.jMonth()+1,day:t.jDate()}}function o(e,t,s){return r()("".concat(e,"/").concat(t,"/").concat(s),"jYYYY/jM/jD").toDate()}function c(e){return["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"][e-1]||""}function d(){return["ش","ی","د","س","چ","پ","ج"]}function x(e,t){return r().jDaysInMonth(e,t-1)}function u(e,t){return(r()("".concat(e,"/").concat(t,"/1"),"jYYYY/jM/jD").day()+1)%7}},87388:(e,t,s)=>{s.d(t,{y:()=>o});var a=s(12115),r=s(36489),n=s(18720),l=s(14734),i=s(41444);function o(e){var t,s;let{tableId:o,isCreator:c=!1,isPlayerTable:d=!0,onStatusChange:x,onArchetypeRequired:u}=e,{data:m,status:h}=(0,r.useSession)(),{socket:p,isConnected:f,joinEventRoom:g,leaveEventRoom:b,joinUserRoom:v}=(0,l.F)(),[j,w]=(0,a.useState)(null),[N,y]=(0,a.useState)(null),[k,E]=(0,a.useState)(!0),[S,C]=(0,a.useState)(!1),[A,I]=(0,a.useState)(null),D=(0,a.useRef)(x);D.current=x;let T=(0,a.useCallback)(async()=>{var e,t,s;if(!(null==m||null==(e=m.user)?void 0:e.id)||c||!d)return void E(!1);try{let e=await fetch("/api/tables/".concat(o,"/my-request"),{cache:"no-store"}),a=await e.json();if(a.success&&a.data){let e=a.data.status||null;w(e),y(a.data.booking||null),null==(t=D.current)||t.call(D,e)}else w(null),y(null),null==(s=D.current)||s.call(D,null)}catch(e){i.v.error("Error fetching table join status:",{error:e,tableId:o})}finally{E(!1)}},[o,null==m||null==(t=m.user)?void 0:t.id,c,d]);(0,a.useEffect)(()=>{"loading"!==h&&T()},[h,T]),(0,a.useEffect)(()=>{var e;if(!p||!f||!o)return;g(o),(null==m||null==(e=m.user)?void 0:e.id)&&v();let t=e=>{if(e.tableId===o){var t,s;e.userId!==(null==m||null==(t=m.user)?void 0:t.id)&&e.userId||(w(e.status),y(t=>t?{...t,status:e.status}:{id:e.bookingId,status:e.status}),null==(s=D.current)||s.call(D,e.status),"PENDING_PAYMENT"===e.status?n.o.success("\uD83C\uDF89 درخواست همبازی شدن شما تایید شد! لطفاً پرداخت را انجام دهید."):"CONFIRMED"===e.status?n.o.success("✅ عضویت شما در میز قطعی شد!"):"CANCELLED"===e.status&&n.o.info("وضعیت درخواست شما تغییر کرد (لغو شد)."))}},s=e=>{var t,s;if(e.eventId===o&&e.userId===(null==m||null==(t=m.user)?void 0:t.id)){let t=e.status;w(t),y(s=>s?{...s,status:t}:{id:e.bookingId,status:t}),null==(s=D.current)||s.call(D,t)}};return p.on("tableJoinRequestUpdate",t),p.on("bookingStatusChanged",s),()=>{p.off("tableJoinRequestUpdate",t),p.off("bookingStatusChanged",s),b(o)}},[p,f,o,null==m||null==(s=m.user)?void 0:s.id,g,b,v]),(0,a.useEffect)(()=>{if(!N)return void I(null);let e=0,t=null;if("PENDING"===j&&N.createdAt?(e=900,t=new Date(N.createdAt)):"PENDING_PAYMENT"===j&&N.updatedAt&&(e=600,t=new Date(N.updatedAt)),!t||0===e)return void I(null);let s=()=>{let s=Math.floor((Date.now()-t.getTime())/1e3),a=Math.max(0,e-s);I(a),0===a&&T()};s();let a=setInterval(s,1e3);return()=>clearInterval(a)},[N,j,T]);let R=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!(null==m?void 0:m.user))return!1;C(!0);try{var t;let s=await fetch("/api/tables/".concat(o,"/join"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({isAnonymous:e})}),a=await s.json();if(!a.success||!a.data)return"ARCHETYPE_REQUIRED"===a.code?null==u||u():n.o.error(a.error||"خطا در ثبت درخواست همبازی شدن"),!1;return w("PENDING"),y({id:a.data.bookingId,status:"PENDING",createdAt:new Date().toISOString()}),null==(t=D.current)||t.call(D,"PENDING"),n.o.success("درخواست همبازی شدن با موفقیت برای پلی‌مستر ارسال شد!"),!0}catch(e){return i.v.error("Error submitting join request:",{error:e,tableId:o}),n.o.error("خطای شبکه در ارسال درخواست"),!1}finally{C(!1)}},M=async()=>{if(!(null==N?void 0:N.id))return!1;C(!0);try{var e;let t=await fetch("/api/tables/".concat(o,"/join-requests/").concat(N.id,"/cancel"),{method:"POST"}),s=await t.json();if(!s.success)return n.o.error(s.error||"خطا در انصراف از درخواست"),!1;return w(null),y(null),I(null),null==(e=D.current)||e.call(D,null),n.o.success("درخواست شما با موفقیت لغو شد"),!0}catch(e){return i.v.error("Error cancelling join request:",{error:e,tableId:o,bookingId:N.id}),n.o.error("خطای شبکه در لغو درخواست"),!1}finally{C(!1)}},O=null!==A?"".concat(Math.floor(A/60),":").concat((A%60).toString().padStart(2,"0")):null;return{status:j,booking:N,loading:k,submitting:S,remainingSeconds:A,formattedCountdown:O,sendJoinRequest:R,cancelRequest:M,refetchStatus:T}}},95767:(e,t,s)=>{s.d(t,{A:()=>_});var a=s(95155),r=s(12115),n=s(52619),l=s.n(n),i=s(15239),o=s(36489),c=s(6490),d=s(65229),x=s(59384),u=s(95740),m=s(68854),h=s(21873),p=s(5789),f=s(16645),g=s(55136),b=s(16485),v=s(35626),j=s(96093),w=s(3998),N=s(87388),y=s(35299),k=s(26983),E=s(91761),S=s(78519),C=s(61362);function A(e){let{tableId:t,isCreator:s=!1,onCloseModal:n,className:i=""}=e,{data:c,status:x}=(0,o.useSession)(),[u,m]=(0,r.useState)(!1),{status:h,booking:p,loading:f,remainingSeconds:g,cancelRequest:b}=(0,N.y)({tableId:t,isCreator:s,isPlayerTable:!0,onStatusChange:()=>{window.dispatchEvent(new CustomEvent("playmo:refresh-globe"))}}),j=async()=>{m(!0);try{await b()&&window.dispatchEvent(new CustomEvent("playmo:refresh-globe"))}finally{m(!1)}};if(s)return(0,a.jsx)("div",{className:"space-y-2 ".concat(i),children:(0,a.jsxs)(l(),{href:"/events/".concat(t),onClick:n,className:"inline-flex items-center justify-center gap-2 w-full py-2.5 px-4 rounded-xl text-xs font-black bg-amber-400 hover:bg-amber-300 text-amber-950 border border-amber-300/80 transition-all shadow-xs",children:[(0,a.jsx)("span",{children:"\uD83D\uDC51 مدیریت میز بازی شما"}),(0,a.jsx)(v.A,{className:"w-3.5 h-3.5"})]})});if("loading"===x||(null==c?void 0:c.user)&&f)return(0,a.jsxs)("div",{className:"flex items-center justify-center h-11 bg-white/20 border border-white/20 rounded-xl backdrop-blur-xs animate-pulse ".concat(i),children:[(0,a.jsx)(y.A,{className:"h-4 w-4 animate-spin text-white ml-2"}),(0,a.jsx)("span",{className:"text-[11px] font-semibold text-white/90",children:"در حال بررسی وضعیت همبازی..."})]});if("PENDING"===h){let e=Math.min(100,Math.max(0,(null!==g?g:900)/900*100)),t=2*Math.PI*16.5;return(0,a.jsx)("div",{className:"bg-white/95 border border-white/90 rounded-2xl p-3 shadow-xs backdrop-blur-xs space-y-2.5 ".concat(i),children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsxs)("div",{className:"relative w-9 h-9 shrink-0 flex items-center justify-center",children:[(0,a.jsxs)("svg",{className:"w-full h-full -rotate-90",viewBox:"0 0 ".concat(36," ").concat(36),children:[(0,a.jsx)("circle",{cx:18,cy:18,r:16.5,className:"stroke-amber-200",strokeWidth:3,fill:"transparent"}),(0,a.jsx)("circle",{cx:18,cy:18,r:16.5,className:"stroke-amber-600 transition-all duration-1000 ease-linear",strokeWidth:3,strokeDasharray:t,strokeDashoffset:t*(1-e/100),strokeLinecap:"round",fill:"transparent"})]}),(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:(0,a.jsx)(k.A,{className:"w-3.5 h-3.5 text-amber-700 animate-pulse"})})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h5",{className:"text-xs font-black text-amber-900 truncate",children:"درخواست برای پلی‌مستر ارسال شد"}),(0,a.jsx)("p",{className:"text-[11px] text-amber-700 leading-tight",children:"منتظر تایید پلی‌مستر میز بازی باشید"})]})]}),(0,a.jsx)(w.$,{type:"button",variant:"outline",size:"sm",onClick:j,disabled:u,className:"h-8 px-2.5 border-red-200/80 bg-white hover:bg-red-50 text-red-600 hover:text-red-700 font-bold text-[11px] rounded-xl shrink-0 transition-all shadow-2xs",children:u?(0,a.jsx)(y.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 ml-1"}),(0,a.jsx)("span",{children:"انصراف"})]})})]})})}if("PENDING_PAYMENT"===h&&(null==p?void 0:p.id)){let e=Math.min(100,Math.max(0,(null!==g?g:600)/600*100)),t=2*Math.PI*16.5;return(0,a.jsx)("div",{className:"bg-white/95 border border-white/90 rounded-2xl p-3 shadow-xs backdrop-blur-xs space-y-2.5 ".concat(i),children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsxs)("div",{className:"relative w-9 h-9 shrink-0 flex items-center justify-center",children:[(0,a.jsxs)("svg",{className:"w-full h-full -rotate-90",viewBox:"0 0 ".concat(36," ").concat(36),children:[(0,a.jsx)("circle",{cx:18,cy:18,r:16.5,className:"stroke-emerald-200",strokeWidth:3,fill:"transparent"}),(0,a.jsx)("circle",{cx:18,cy:18,r:16.5,className:"stroke-emerald-600 transition-all duration-1000 ease-linear",strokeWidth:3,strokeDasharray:t,strokeDashoffset:t*(1-e/100),strokeLinecap:"round",fill:"transparent"})]}),(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:(0,a.jsx)(E.A,{className:"w-3.5 h-3.5 text-emerald-600 animate-bounce"})})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h5",{className:"text-xs font-black text-emerald-900 truncate",children:"\uD83C\uDF89 درخواست همبازی تایید شد!"}),(0,a.jsx)("p",{className:"text-[11px] text-emerald-700 leading-tight",children:"جهت نهایی‌سازی صندلی، پرداخت را انجام دهید"})]})]}),(0,a.jsx)(l(),{href:"/checkout/booking/".concat(p.id),onClick:n,className:"shrink-0",children:(0,a.jsxs)(w.$,{type:"button",size:"sm",className:"h-8 px-3 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-700 hover:to-teal-700 text-white font-bold text-[11px] rounded-xl shadow-xs transition-all flex items-center gap-1",children:[(0,a.jsx)(S.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:"پرداخت"})]})})]})})}return"CONFIRMED"===h?(0,a.jsx)("div",{className:"bg-white/95 border border-white/90 rounded-2xl p-3 shadow-xs space-y-2 ".concat(i),children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-xl bg-emerald-500/20 text-emerald-600 flex items-center justify-center shrink-0",children:(0,a.jsx)(C.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h5",{className:"text-xs font-bold text-emerald-900 truncate",children:"✅ شما همبازی رسمی این میز هستید"}),(0,a.jsx)("p",{className:"text-[11px] text-emerald-700 leading-tight",children:"صندلی شما رزرو شده است"})]})]}),(0,a.jsx)(l(),{href:"/events/".concat(t),onClick:n,className:"shrink-0",children:(0,a.jsx)(w.$,{variant:"outline",size:"sm",className:"h-8 px-2.5 border-emerald-300 text-emerald-700 hover:bg-emerald-100 font-bold text-[11px] rounded-xl",children:"مشاهده میز"})})]})}):(0,a.jsxs)(l(),{href:"/events/".concat(t),onClick:n,className:"inline-flex items-center justify-center gap-2 w-full py-2.5 px-4 rounded-xl text-xs font-black bg-white hover:bg-emerald-50 text-emerald-900 hover:text-emerald-950 transition-all shadow-xs border border-white/80",children:[(0,a.jsx)("span",{children:"مشاهده و پیوستن به این میز"}),(0,a.jsx)(v.A,{className:"w-3.5 h-3.5"})]})}var I=s(51834),D=s(11647),T=s(56210),R=s(6132),M=s(91169),O=s(18720),P=s(58779),U=s(58036);function L(e){let{isOpen:t,onClose:s,targetUser:n}=e,[l,i]=(0,r.useState)([]),[o,c]=(0,r.useState)(!1),[d,x]=(0,r.useState)(null),[u,m]=(0,r.useState)("GUEST"),[h,p]=(0,r.useState)(""),[v,j]=(0,r.useState)(!1),[N,k]=(0,r.useState)(null),[E,C]=(0,r.useState)(!1),A=n.name||n.username||"همبازی",L=(n.name||n.username||"این بازیکن").trim().split(/\s+/)[0]||"این بازیکن",F=(0,r.useCallback)(()=>{n.id&&(c(!0),k(null),fetch("/api/invite/eligible-tables?targetUserId=".concat(encodeURIComponent(n.id))).then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.data)?(i(e.data),e.data.length>0&&x(e.data[0].id)):k(e.error||"خطا در دریافت لیست میزها")}).catch(()=>{k("خطا در برقراری ارتباط با سرور")}).finally(()=>{c(!1)}))},[n.id]);(0,r.useEffect)(()=>{t&&n.id&&(x(null),p(""),m("GUEST"),F())},[t,n.id,F]);let G=l.find(e=>e.id===d),z=async()=>{if(!d)return void O.o.error("لطفاً ابتدا یک میز را انتخاب کنید.");j(!0);try{let e=await fetch("/api/invite/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({receiverId:n.id,eventId:d,payer:u,customMessage:h.trim()||void 0})}),t=await e.json();t.success?(O.o.success("دعوتنامه برای ".concat(A," با موفقیت ارسال شد! \uD83C\uDFB2")),s(),window.dispatchEvent(new CustomEvent("playmo:refresh-globe"))):O.o.error(t.error||"خطا در ارسال دعوتنامه")}catch(e){O.o.error("خطای ارتباط با سرور در ارسال دعوت")}finally{j(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.lG,{open:t,onOpenChange:e=>!e&&s(),children:(0,a.jsxs)(I.Cf,{className:"w-[calc(100%-2rem)] sm:w-full sm:max-w-lg p-0 overflow-hidden bg-white/95 backdrop-blur-2xl border-purple-100 shadow-2xl rounded-3xl dir-rtl",children:[(0,a.jsxs)(I.c7,{className:"p-6 pb-4 bg-gradient-to-r from-purple-900 via-indigo-900 to-purple-950 text-white",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)("span",{className:"p-2 rounded-xl bg-white/10 backdrop-blur-md",children:(0,a.jsx)(f.A,{className:"w-5 h-5 text-purple-300"})}),(0,a.jsxs)(I.L3,{className:"text-lg font-bold text-white",children:["دعوت ",A," به میز بازی"]})]}),(0,a.jsxs)(I.rr,{className:"text-purple-200 text-xs",children:["یکی از میزهای فعال خود را انتخاب کنید تا برای ",A," دعوتنامه ۱۵ دقیقه‌ای ارسال شود."]})]}),(0,a.jsx)("div",{className:"p-6 space-y-4 max-h-[65vh] overflow-y-auto",children:o?(0,a.jsxs)("div",{className:"py-12 flex flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,a.jsx)(T.LoadingSpinner,{size:"md"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:"در حال بررسی میزهای فعال شما..."})]}):N?(0,a.jsxs)("div",{className:"p-4 rounded-2xl bg-red-50 border border-red-200 text-red-700 flex items-center gap-3",children:[(0,a.jsx)(R.A,{className:"w-5 h-5 shrink-0 text-red-500"}),(0,a.jsx)("p",{className:"text-xs font-medium",children:N})]}):0===l.length?(0,a.jsxs)("div",{className:"text-center py-7 px-4 rounded-2xl bg-purple-50/60 border border-purple-100/80 space-y-3.5",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-full bg-purple-100 text-purple-600 flex items-center justify-center mx-auto shadow-xs",children:(0,a.jsx)(f.A,{className:"w-6 h-6"})}),(0,a.jsx)("h4",{className:"text-sm font-bold text-gray-800",children:"میز فعالی با صندلی خالی یافت نشد!"}),(0,a.jsx)("div",{className:"pt-1",children:(0,a.jsxs)("button",{type:"button",onClick:()=>C(!0),className:"w-full max-w-xs mx-auto py-3 px-5 rounded-2xl font-black text-xs sm:text-sm bg-emerald-600 hover:bg-emerald-700 active:scale-[0.98] text-white shadow-md shadow-emerald-950/10 transition-all flex items-center justify-center gap-2 cursor-pointer border border-emerald-500/80",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-emerald-100"}),(0,a.jsx)("span",{children:"ایجاد میز بازی"})]})}),(0,a.jsxs)("p",{className:"text-[11px] sm:text-xs text-gray-500 font-medium leading-relaxed max-w-xs mx-auto text-center",children:["برای افزایش شانس پذیرش دعوت، به علایق و آرکیتایپ ",L," توجه کن\uD83D\uDE09"]})]}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:"انتخاب میز بازی مقصد:"}),(0,a.jsx)("div",{className:"space-y-2",children:l.map(e=>{var t;let s=d===e.id,r=Math.max(0,e.maxPlayers-e.currentPlayers),n=(0,P.pJ)(e.startTime,{dateFormat:"jYYYY/jMM/jDD",timeFormat:"HH:mm",separator:" - ساعت "});return(0,a.jsxs)("div",{onClick:()=>x(e.id),className:"p-3.5 rounded-2xl border transition-all cursor-pointer flex flex-col gap-2 ".concat(s?"bg-purple-50/90 border-purple-500 ring-2 ring-purple-400/30 shadow-sm":"bg-white hover:bg-gray-50/80 border-gray-200"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-4 h-4 rounded-full border flex items-center justify-center ".concat(s?"border-purple-600 bg-purple-600":"border-gray-300"),children:s&&(0,a.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-white"})}),(0,a.jsx)("span",{className:"font-bold text-sm text-gray-900 truncate",children:e.gameTitle||e.title}),e.genre&&(0,a.jsx)(D.E,{variant:"secondary",className:"text-[10px] px-2 py-0 bg-purple-100 text-purple-800",children:e.genre})]}),(0,a.jsx)("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full ".concat(0===e.entryFee?"bg-emerald-100 text-emerald-800":"bg-amber-100 text-amber-800"),children:0===e.entryFee?"رایگان":"".concat(e.entryFee.toLocaleString("fa-IR")," تومان")})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500 pr-6",children:[(null==(t=e.cafe)?void 0:t.name)&&(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(g.A,{className:"w-3.5 h-3.5 text-gray-400"}),"کافه ",e.cafe.name]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(b.A,{className:"w-3.5 h-3.5 text-gray-400"}),n]}),(0,a.jsxs)("span",{className:"flex items-center gap-1 text-purple-700 font-medium",children:[(0,a.jsx)(M.A,{className:"w-3.5 h-3.5 text-purple-500"}),r," جای خالی"]})]})]},e.id)})})]}),G&&G.entryFee>0&&(0,a.jsxs)("div",{className:"p-3.5 rounded-2xl bg-amber-50/70 border border-amber-200/80 space-y-2",children:[(0,a.jsxs)("label",{className:"text-xs font-bold text-amber-900 flex items-center gap-1.5",children:[(0,a.jsx)(S.A,{className:"w-3.5 h-3.5 text-amber-700"}),"پرداخت هزینه ورودی میز (",G.entryFee.toLocaleString("fa-IR")," تومان):"]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>m("GUEST"),className:"py-2 px-3 rounded-xl text-xs font-medium border transition-all ".concat("GUEST"===u?"bg-amber-600 text-white border-amber-600 shadow-xs":"bg-white text-gray-700 border-gray-200 hover:bg-gray-50"),children:"بر عهده مهمان"}),(0,a.jsx)("button",{type:"button",onClick:()=>m("HOST"),className:"py-2 px-3 rounded-xl text-xs font-medium border transition-all ".concat("HOST"===u?"bg-amber-600 text-white border-amber-600 shadow-xs":"bg-white text-gray-700 border-gray-200 hover:bg-gray-50"),children:"مهمان من است (پرداخت توسط من)"})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("label",{className:"text-xs font-bold text-gray-700",children:["پیام کوتاه به ",A," (اختیاری):"]}),(0,a.jsxs)("span",{className:"text-[10px] text-gray-400",children:[h.length,"/۸۰"]})]}),(0,a.jsx)("input",{type:"text",maxLength:80,value:h,onChange:e=>p(e.target.value),placeholder:"مثال: سلام! خوشحال میشم در این بازی همراه ما باشی \uD83C\uDFB2",className:"w-full text-xs px-3.5 py-2.5 rounded-xl border border-gray-200 bg-white focus:outline-hidden focus:ring-2 focus:ring-purple-400 focus:border-purple-400 transition-all text-gray-800 placeholder:text-gray-400"})]})]})}),(0,a.jsxs)(I.Es,{className:"p-4 bg-gray-50 border-t border-gray-100 flex items-center justify-between sm:justify-between gap-2",children:[(0,a.jsx)(w.$,{type:"button",variant:"outline",size:"sm",onClick:s,disabled:v,className:"text-xs rounded-xl",children:"انصراف"}),(0,a.jsx)(w.$,{type:"button",size:"sm",onClick:z,disabled:v||o||0===l.length||!d,className:"text-xs rounded-xl bg-purple-600 hover:bg-purple-700 text-white shadow-md shadow-purple-600/20 px-5",children:v?(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(y.A,{className:"w-3.5 h-3.5 animate-spin"}),"در حال ارسال..."]}):(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(f.A,{className:"w-3.5 h-3.5"}),"ارسال دعوتنامه \uD83C\uDFB2"]})})]})]})}),(0,a.jsx)(U.k,{open:E,onOpenChange:e=>{C(e),e||F()}})]})}var F=s(81703),G=s(17188);let z=["\uD83C\uDFB2","\uD83C\uDFAF","\uD83E\uDDE9","\uD83C\uDCCF","⚔️","\uD83D\uDC51","\uD83C\uDFC6","⏳","☕️","\uD83C\uDF55","\uD83C\uDF7B","\uD83C\uDF54","\uD83C\uDF5F","\uD83C\uDF6B","\uD83C\uDF69","\uD83C\uDF66","\uD83D\uDC4B\uD83C\uDFFB","\uD83E\uDD1D","\uD83D\uDC4D\uD83C\uDFFB","✌\uD83C\uDFFB","\uD83E\uDEF0\uD83C\uDFFB","\uD83E\uDEF5\uD83C\uDFFB","❤️","\uD83D\uDC8C","\uD83D\uDE0E","\uD83D\uDE03","\uD83D\uDE02","\uD83E\uDD79","\uD83D\uDE09","\uD83E\uDD2D","\uD83E\uDD21","\uD83E\uDD16","\uD83D\uDD25","⚡️","\uD83D\uDCA3","\uD83D\uDCAF","\uD83D\uDC8E","✨","\uD83D\uDC7B","\uD83C\uDF89","\uD83C\uDF39","\uD83C\uDF82","\uD83D\uDC9A","\uD83D\uDC94","\uD83D\uDC99","\uD83C\uDFA8","✅","❌","⏰","\uD83C\uDF1B"];function Y(e){let{targetUserId:t,targetUserName:s,isCurrentUser:n=!1,hasArchetype:l,onDiscoverArchetype:i,onOpenAuthModal:c,onOpenInviteModal:d}=e,{data:x}=(0,o.useSession)(),m=void 0!==l?l:!!((null==x?void 0:x.user)&&x.user.archetype),[h,p]=(0,r.useState)(null),[g,b]=(0,r.useState)(!1),[v,j]=(0,r.useState)(!1),[w,N]=(0,r.useState)(!1),[E,S]=(0,r.useState)(!1),[C,A]=(0,r.useState)(!0),[I,D]=(0,r.useState)(null),T=(0,r.useRef)(null);if((0,r.useEffect)(()=>{function e(e){T.current&&!T.current.contains(e.target)&&(v&&h?j(!1):v&&!h&&(b(!1),j(!1)))}return g&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[g,v,h]),(0,r.useEffect)(()=>{if(n||!t)return void A(!1);let e=!0;return async function(){try{let s=await fetch("/api/users/".concat(t,"/nudge"));if(s.ok){let t=await s.json();e&&t.success&&t.data&&D(t.data)}}catch(e){console.error("Error checking nudge status:",e)}finally{e&&A(!1)}}(),()=>{e=!1}},[t,n]),n||!t)return null;let M=async e=>{if(E||w)return;N(!0),S(!0);let s=new Promise(e=>setTimeout(e,1e3));try{let a=fetch("/api/users/".concat(t,"/nudge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({emoji:e})}),[r]=await Promise.all([a,s]),n=await r.json();if(!r.ok||!n.success){let e=n.error||"ارسال تلنگر با خطا مواجه شد.";O.o.error(e),(429===n.code||429===r.status)&&D(e=>e?{...e,canNudge:!1,remainingDailyNudges:0}:null),N(!1);return}b(!1),j(!1),N(!1),p(null),O.o.success(n.message||"تلنگر بازی با موفقیت ارسال شد! \uD83C\uDFB2")}catch(e){console.error("Error sending nudge:",e),O.o.error("خطای ارتباط با سرور. لطفاً دوباره تلاش کنید."),N(!1)}finally{S(!1)}};return(0,a.jsxs)("div",{className:"space-y-2.5",children:[m?I&&!I.canNudge?(0,a.jsxs)("div",{className:"space-y-2.5",children:[(0,a.jsxs)("div",{className:"p-3 rounded-2xl bg-amber-50/90 border border-amber-200/80 text-amber-900 space-y-1 text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 font-bold text-amber-800",children:["COOLDOWN"===I.reason?(0,a.jsx)(k.A,{className:"w-4 h-4 text-amber-600 shrink-0"}):(0,a.jsx)(R.A,{className:"w-4 h-4 text-amber-600 shrink-0"}),(0,a.jsx)("span",{children:"COOLDOWN"===I.reason?"در دوره خنک‌سازی (تا ".concat(I.remainingCooldownDays||7," روز دیگر)"):"سقف روزانه تکمیل است"})]}),(0,a.jsx)("p",{className:"text-[11px] text-amber-700 leading-relaxed",children:I.message||"در حال حاضر امکان ارسال مجدد تلنگر به این کاربر وجود ندارد."})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2.5",children:[d&&(0,a.jsxs)("button",{type:"button",onClick:d,className:"w-full py-2.5 px-3 rounded-xl text-xs font-black text-white bg-emerald-600 hover:bg-emerald-700 active:bg-emerald-800 active:scale-[0.98] shadow-md shadow-emerald-600/20 transition-all flex items-center justify-center gap-1.5 hover:scale-[1.01]",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-emerald-100 shrink-0"}),(0,a.jsx)("span",{children:"دعوت به میز"})]}),(0,a.jsxs)("button",{type:"button",disabled:!0,className:"w-full py-2.5 px-3 rounded-xl text-xs font-black text-white/90 bg-gradient-to-r from-amber-500/50 to-orange-500/50 opacity-60 cursor-not-allowed shadow-none flex items-center justify-center gap-1.5 ".concat(d?"":"col-span-2"),children:[(0,a.jsx)(k.A,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{children:"ارسال تلنگر"})]})]})]}):(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2.5 relative",ref:T,children:[d&&(0,a.jsxs)("button",{type:"button",onClick:d,className:"w-full py-2.5 px-3 rounded-xl text-xs font-black text-white bg-emerald-600 hover:bg-emerald-700 active:bg-emerald-800 active:scale-[0.98] shadow-md shadow-emerald-600/20 transition-all flex items-center justify-center gap-1.5 hover:scale-[1.01]",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-emerald-100 shrink-0"}),(0,a.jsx)("span",{children:"دعوت به میز"})]}),(0,a.jsxs)("div",{className:"relative w-full",children:[g&&(0,a.jsx)(a.Fragment,{children:v?(0,a.jsxs)("div",{className:"absolute bottom-full mb-3 left-0 right-auto z-40 w-[240px] sm:w-[255px] bg-slate-900/95 backdrop-blur-xl border border-orange-500/50 shadow-2xl shadow-slate-950/70 rounded-2xl p-2 animate-in fade-in zoom-in-95 slide-in-from-bottom-2 duration-200",children:[(0,a.jsx)("div",{className:"grid grid-cols-5 gap-1.5 max-h-[195px] overflow-y-auto select-none overscroll-contain [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:z.map(e=>{let t=h===e;return(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),p(e),j(!1),b(!0)},className:"w-10 h-10 rounded-xl flex items-center justify-center text-2xl sm:text-[26px] transition-all duration-150 hover:scale-125 hover:bg-slate-800/90 active:scale-90 ".concat(t?"bg-slate-800 ring-2 ring-amber-400 scale-110 shadow-md shadow-amber-500/20":"bg-slate-800/40 hover:bg-slate-800/70"),children:(0,a.jsx)("span",{className:"drop-shadow-xs",children:e})},e)})}),(0,a.jsx)("div",{className:"absolute -bottom-1.5 left-8 w-3 h-3 bg-slate-900/95 rotate-45 border-r border-b border-orange-500/50"})]}):h?(0,a.jsxs)("div",{onClick:w?void 0:e=>{e.stopPropagation(),j(!0)},title:w?void 0:"کلیک برای تغییر ایموجی",className:"absolute bottom-full mb-3 left-1/2 -translate-x-1/2 z-40 ".concat(w?"nudge-flying-bubble pointer-events-none":"group cursor-pointer animate-bounce hover:scale-110 active:scale-95 transition-transform"),children:[(0,a.jsx)("div",{className:"bg-slate-900/95 backdrop-blur-md border border-orange-500/60 shadow-xl shadow-slate-950/60 rounded-2xl w-10 h-10 flex items-center justify-center text-2xl ring-2 transition-all ".concat(w?"ring-amber-300 shadow-orange-500/60 scale-110":"ring-amber-400/50 group-hover:scale-110"),children:(0,a.jsx)("span",{className:"drop-shadow-sm",children:h})}),!w&&(0,a.jsx)("div",{className:"absolute -bottom-1.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-slate-900/95 rotate-45 border-r border-b border-orange-500/60"})]}):null}),(0,a.jsx)("button",{type:"button",onClick:()=>{if(!I||I.canNudge){if(h&&g&&!v)return void M(h);b(!0),j(!0)}},disabled:E,className:"w-full py-2.5 px-3 rounded-xl text-xs font-black text-white bg-gradient-to-r from-amber-500 via-orange-500 to-amber-600 hover:from-amber-600 hover:to-orange-600 active:scale-[0.98] shadow-md shadow-amber-500/25 transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.01] ".concat(h&&g&&!v?"ring-2 ring-amber-300 ring-offset-1 shadow-amber-500/40":""),children:E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.A,{className:"w-4 h-4 animate-spin text-white shrink-0"}),(0,a.jsx)("span",{children:"در حال ارسال..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(G.A,{className:"w-4 h-4 text-amber-100 shrink-0"}),(0,a.jsx)("span",{children:"ارسال تلنگر"})]})})]})]}):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2.5",children:[(0,a.jsxs)("button",{type:"button",disabled:!0,className:"w-full py-2.5 px-3 rounded-xl text-xs font-bold text-white/80 bg-emerald-600/50 opacity-50 cursor-not-allowed shadow-none flex items-center justify-center gap-1.5",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-emerald-100/70 shrink-0"}),(0,a.jsx)("span",{children:"دعوت به میز"})]}),(0,a.jsxs)("button",{type:"button",disabled:!0,className:"w-full py-2.5 px-3 rounded-xl text-xs font-bold text-white/80 bg-gradient-to-r from-amber-500/50 to-orange-500/50 opacity-50 cursor-not-allowed shadow-none flex items-center justify-center gap-1.5",children:[(0,a.jsx)(G.A,{className:"w-4 h-4 text-amber-100/70 shrink-0"}),(0,a.jsx)("span",{children:"ارسال تلنگر"})]})]}),(0,a.jsxs)("div",{onClick:()=>{if(!(null==x?void 0:x.user))return void(c?c():i&&i());i&&i()},role:"button",tabIndex:0,className:"text-center py-2 px-3 rounded-xl bg-purple-50/90 border border-purple-200/70 text-purple-900 text-[11px] sm:text-xs font-bold flex items-center justify-center gap-1.5 transition-all select-none cursor-pointer hover:bg-purple-100 active:scale-[0.99]",children:[(0,a.jsx)(u.A,{className:"w-3.5 h-3.5 text-purple-600 shrink-0 animate-pulse"}),(0,a.jsx)("span",{children:"برای فعالسازی اکشن ها باید آرکی تایپ خودتو کشف کنی"})]})]}),(0,a.jsx)("style",{children:"\n        @keyframes nudgeLaunch {\n          0% {\n            transform: translate3d(-50%, 0, 0) scale3d(1, 1, 1);\n            opacity: 1;\n          }\n          20% {\n            /* خیز گرفتن، فشرده‌شدن به سمت دکمه و ذخیره انرژی */\n            transform: translate3d(-50%, 9px, 0) scale3d(1.3, 0.72, 1) rotate(6deg);\n            opacity: 1;\n          }\n          45% {\n            /* جهش کشسان و شتاب اولیه موشکی */\n            transform: translate3d(-50%, -28px, 0) scale3d(0.8, 1.35, 1) rotate(-10deg);\n            opacity: 1;\n          }\n          75% {\n            /* اوج پرواز در فضا با چرخش ملایم */\n            transform: translate3d(-50%, -115px, 0) scale3d(1.15, 1.15, 1) rotate(14deg);\n            opacity: 0.9;\n          }\n          100% {\n            /* پرتاب به سمت مخاطب و محو شدن در عمق */\n            transform: translate3d(-50%, -190px, 0) scale3d(0.25, 0.25, 1) rotate(25deg);\n            opacity: 0;\n          }\n        }\n\n        .nudge-flying-bubble {\n          animation: nudgeLaunch 1000ms cubic-bezier(0.25, 1, 0.35, 1) forwards;\n          will-change: transform, opacity;\n          backface-visibility: hidden;\n          -webkit-backface-visibility: hidden;\n          transform-style: preserve-3d;\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n          .nudge-flying-bubble {\n            animation: none !important;\n            opacity: 0;\n          }\n        }\n      "})]})}function _(e){var t,s,n,w;let{user:N,isOpen:y,onClose:k,isCurrentUser:E=!1,onEditArchetype:S,onOpenAuthModal:C}=e,{data:D}=(0,o.useSession)(),[T,R]=r.useState(!1),[M,O]=r.useState(!1);if(!y||!N)return null;let P=null==D||null==(t=D.user)?void 0:t.archetype,U=!!((null==D?void 0:D.user)&&P),G=()=>{k(),(null==D?void 0:D.user)?S&&S():C?C():O(!0)},z=N.archetype?c.aK[N.archetype]:null,_=z?c.R6.find(e=>e.id===z.category):null,B=(null==(s=N.activeEvent)?void 0:s.startTime)?new Date(N.activeEvent.startTime).toLocaleString("fa-IR",{weekday:"long",hour:"2-digit",minute:"2-digit"}):null;return(0,a.jsx)(I.lG,{open:y,onOpenChange:e=>!e&&k(),children:(0,a.jsxs)(I.Cf,{className:"w-[calc(100%-2rem)] sm:w-full sm:max-w-lg p-0 border-0 bg-transparent shadow-none focus:outline-none overflow-visible",showCloseButton:!1,children:[(0,a.jsxs)(I.L3,{className:"sr-only",children:["پروفایل کاربری ",N.name||"کاربر پلیمو"]}),(0,a.jsxs)(I.rr,{className:"sr-only",children:["مشاهده اطلاعات آرکی‌تایپ، رویدادها و تعامل با ",N.name||"کاربر"]}),(0,a.jsxs)("div",{className:"relative w-full overflow-hidden rounded-3xl bg-white/95 backdrop-blur-2xl border border-purple-100/80 shadow-2xl shadow-purple-950/10 text-gray-900 transition-all duration-300 transform scale-100 dir-rtl",style:{boxShadow:z?"0 10px 40px -10px ".concat(z.accentColor,"30, 0 0 20px 0 rgba(0,0,0,0.05)"):"0 10px 40px -10px rgba(124, 58, 237, 0.15), 0 0 20px 0 rgba(0,0,0,0.05)"},children:[(0,a.jsx)("div",{className:"absolute -top-24 -right-24 w-64 h-64 rounded-full blur-3xl opacity-25 pointer-events-none",style:{background:(null==z?void 0:z.accentColor)||"#8b5cf6"}}),(0,a.jsx)("button",{onClick:k,className:"absolute top-4 left-4 z-20 p-2 text-gray-400 hover:text-gray-700 rounded-full bg-gray-100/80 hover:bg-gray-200/80 transition-colors border border-gray-200/60 shadow-xs",children:(0,a.jsx)(d.A,{className:"w-5 h-5"})}),(0,a.jsxs)("div",{className:"p-5 sm:p-6 space-y-5 max-h-[85vh] overflow-y-auto no-scrollbar [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-5 sm:gap-7 pt-2 animate-in fade-in zoom-in-95 duration-500",children:[(0,a.jsx)("div",{className:"relative group",children:E?(0,a.jsxs)(l(),{href:"/dashboard",onClick:k,title:"رفتن به داشبورد و مدیریت حساب",className:"block cursor-pointer",children:[(0,a.jsx)("div",{className:"w-24 h-24 sm:w-28 sm:h-28 rounded-full p-1 bg-gradient-to-tr from-purple-500 via-pink-400 to-amber-400 shadow-xl transition-transform duration-300 group-hover:scale-105",children:(0,a.jsx)("div",{className:"w-full h-full rounded-full overflow-hidden bg-white flex items-center justify-center relative shadow-inner",children:N.avatar?(0,a.jsx)(i.default,{src:(0,j.cG)(N.avatar)||"",alt:N.name||"کاربر",fill:!0,className:"object-cover group-hover:scale-105 transition-transform"}):(0,a.jsx)("div",{className:"w-full h-full bg-gradient-to-br from-purple-100 to-indigo-100 flex items-center justify-center text-purple-600 font-bold text-2xl sm:text-3xl",children:N.name?N.name.charAt(0):"\uD83D\uDC64"})})}),(0,a.jsx)("div",{className:"absolute -bottom-1 -right-2 w-8 h-8 rounded-full bg-purple-600 text-white flex items-center justify-center border-2 border-white shadow-lg group-hover:scale-110 group-hover:bg-purple-700 active:scale-95 transition-all z-10",children:(0,a.jsx)(x.A,{className:"w-4 h-4"})})]}):(0,a.jsx)("div",{className:"w-24 h-24 sm:w-28 sm:h-28 rounded-full p-1 bg-gradient-to-tr from-purple-500 via-pink-400 to-amber-400 shadow-xl",children:(0,a.jsx)("div",{className:"w-full h-full rounded-full overflow-hidden bg-white flex items-center justify-center relative shadow-inner",children:N.avatar?(0,a.jsx)(i.default,{src:(0,j.cG)(N.avatar)||"",alt:N.name||"کاربر",fill:!0,className:"object-cover"}):(0,a.jsx)("div",{className:"w-full h-full bg-gradient-to-br from-purple-100 to-indigo-100 flex items-center justify-center text-purple-600 font-bold text-2xl sm:text-3xl",children:N.name?N.name.charAt(0):"\uD83D\uDC64"})})})}),(0,a.jsxs)("div",{className:"relative group",children:[(0,a.jsx)("div",{onClick:()=>{E&&S&&(k(),S())},role:E&&S?"button":void 0,tabIndex:E&&S?0:void 0,title:E&&S?"انتخاب یا تغییر آرکی‌تایپ":(null==z?void 0:z.title)||"آرکی‌تایپ",className:"w-24 h-24 sm:w-28 sm:h-28 rounded-full p-1 shadow-xl transition-transform duration-300 group-hover:scale-105 ".concat(E&&S?"cursor-pointer":""," ").concat(z?"bg-gradient-to-tr from-sky-400 via-indigo-500 to-blue-600":"bg-gradient-to-tr from-gray-200 via-gray-300 to-slate-300"),children:(0,a.jsx)("div",{className:"w-full h-full rounded-full overflow-hidden bg-white/95 backdrop-blur-sm flex flex-col items-center justify-center text-center shadow-inner relative",children:z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.default,{src:z.imageUrl,alt:z.title,fill:!0,className:"object-cover absolute inset-0 z-0 opacity-95 group-hover:scale-105 transition-transform"}),(0,a.jsx)("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/85 via-black/50 to-transparent pt-3 pb-1.5 z-10",children:(0,a.jsx)("span",{className:"text-[10px] sm:text-xs font-bold text-white truncate max-w-[90%] mx-auto block drop-shadow-sm",children:z.title})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-2xl sm:text-3xl opacity-75",children:"❓"}),(0,a.jsx)("span",{className:"text-[10px] font-medium text-gray-500 mt-1 leading-tight",children:"هنوز کشف نشده!"})]})})}),E&&S&&(0,a.jsx)("button",{type:"button",onClick:()=>{k(),S()},className:"absolute -bottom-1 -left-2 w-8 h-8 rounded-full bg-gradient-to-r from-amber-500 to-orange-500 text-white flex items-center justify-center border-2 border-white shadow-lg hover:from-amber-600 hover:to-orange-600 hover:scale-110 active:scale-95 transition-all z-10",title:"انتخاب یا تغییر آرکی‌تایپ",children:(0,a.jsx)(u.A,{className:"w-4 h-4"})})]})]}),(0,a.jsxs)("div",{className:"text-center space-y-1.5 px-2",children:[N.isPlayMaster&&(0,a.jsx)("div",{children:(0,a.jsxs)("div",{className:"inline-flex items-center gap-1.5 px-3.5 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-800 border border-amber-200 shadow-xs",children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5 text-amber-500"}),(0,a.jsx)("span",{children:"پلی‌مستر کافه (Play Master)"})]})}),(0,a.jsxs)("h3",{className:"text-2xl sm:text-3xl font-black text-gray-900 tracking-tight flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{children:N.name||"کاربر پلیمو"}),E&&(0,a.jsx)("span",{className:"text-xs px-2.5 py-0.5 rounded-full bg-purple-50 text-purple-700 border border-purple-200 font-bold",children:"شما"})]}),N.city&&(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-500 flex items-center justify-center gap-1",children:[(0,a.jsx)(h.A,{className:"w-4 h-4 text-rose-500"}),(0,a.jsx)("span",{children:N.city})]}),N.bio&&(0,a.jsx)("div",{className:"pt-1 flex justify-center",children:(0,a.jsxs)("div",{className:"relative inline-flex items-center justify-center gap-2 bg-gradient-to-r from-emerald-50/60 via-white to-teal-50/40 border border-emerald-100/80 rounded-2xl px-4 py-2.5 max-w-md mx-auto shadow-2xs",children:[(0,a.jsx)(p.A,{className:"w-4 h-4 sm:w-5 sm:h-5 text-emerald-600 fill-emerald-500/25 shrink-0 rotate-180"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-gray-700 font-medium leading-relaxed text-center px-1",children:N.bio.trim()}),(0,a.jsx)(p.A,{className:"w-4 h-4 sm:w-5 sm:h-5 text-emerald-600 fill-emerald-500/25 shrink-0"})]})})]}),(0,a.jsx)("div",{className:"relative rounded-2xl p-4 bg-gradient-to-br from-purple-50/60 via-white to-sky-50/50 border border-purple-100/90 shadow-xs space-y-3",children:z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("span",{className:"text-2xl",children:(null==_?void 0:_.icon)||"\uD83C\uDFAE"}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("h4",{className:"font-black text-gray-900 text-base flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:z.title}),(0,a.jsxs)("span",{className:"text-xs font-normal text-gray-400",children:["(",z.englishTitle,")"]})]}),(0,a.jsx)("p",{className:"text-xs text-purple-700 font-medium",children:null==_?void 0:_.title})]})]}),(0,a.jsx)("div",{className:"w-3.5 h-3.5 rounded-full shadow-xs shrink-0 border border-white",style:{backgroundColor:z.accentColor}})]}),z.traits&&z.traits.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:z.traits.map((e,t)=>(0,a.jsxs)("span",{className:"text-[11px] sm:text-xs px-3 py-1 rounded-full font-medium bg-white text-gray-700 border border-purple-100/90 shadow-2xs",children:["• ",e]},t))})]}):(0,a.jsxs)("div",{className:"text-center py-4 space-y-2",children:[(0,a.jsx)(u.A,{className:"w-8 h-8 text-purple-400 mx-auto animate-pulse"}),(0,a.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"هنوز آرکی‌تایپ بردگیمی خود را کشف و انتخاب نکرده است."})]})}),N.activeEvent&&(0,a.jsxs)(a.Fragment,{children:[(E||!1!==N.activeEvent.isCreator)&&(0,a.jsxs)("div",{className:"rounded-2xl p-4 bg-emerald-600 border border-emerald-500/80 shadow-md shadow-emerald-950/10 space-y-3 text-white",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-emerald-200"}),!1!==N.activeEvent.isCreator?"میز / رویداد فعال پلی‌مستر":"میز بازی شما (همبازی)"]}),(0,a.jsx)("span",{className:"text-[10px] px-2.5 py-0.5 rounded-full bg-white/20 text-white border border-white/30 backdrop-blur-xs font-semibold shadow-2xs",children:!1!==N.activeEvent.isCreator?"در حال برگزاری / به زودی":"همبازی تایید شده"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("h5",{className:"font-black text-white text-base",children:N.activeEvent.gameTitle||N.activeEvent.title}),!1===N.activeEvent.isCreator&&N.activeEvent.playMasterName&&(0,a.jsxs)("p",{className:"text-xs text-amber-200 flex items-center gap-1.5 font-medium",children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5 text-amber-300"}),(0,a.jsxs)("span",{children:["پلی‌مستر میز: ",N.activeEvent.playMasterName]})]}),N.activeEvent.cafeName&&(0,a.jsxs)("p",{className:"text-xs text-emerald-100 flex items-center gap-1.5",children:[(0,a.jsx)(g.A,{className:"w-3.5 h-3.5 text-emerald-200"}),(0,a.jsxs)("span",{children:["کافه ",N.activeEvent.cafeName]})]}),B&&(0,a.jsxs)("p",{className:"text-xs text-emerald-100 flex items-center gap-1.5",children:[(0,a.jsx)(b.A,{className:"w-3.5 h-3.5 text-emerald-200"}),(0,a.jsx)("span",{children:B})]})]}),(0,a.jsx)(A,{tableId:N.activeEvent.id,isCreator:!!(E&&!1!==N.activeEvent.isCreator),onCloseModal:k})]}),!E&&!1===N.activeEvent.isCreator&&!N.activeEvent.isAnonymous&&(0,a.jsxs)("div",{className:"rounded-2xl p-4 bg-gradient-to-br from-purple-900/90 via-indigo-900/90 to-purple-950/90 border border-purple-400/30 text-white shadow-md space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[(0,a.jsx)(f.A,{className:"w-4 h-4 text-purple-200"}),"همبازی در میز فعال"]}),(0,a.jsx)("span",{className:"text-[10px] px-2.5 py-0.5 rounded-full bg-white/20 text-white border border-white/30 backdrop-blur-xs font-semibold shadow-2xs",children:"همبازی تایید شده"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("h5",{className:"font-black text-white text-base",children:N.activeEvent.gameTitle||N.activeEvent.title}),N.activeEvent.playMasterName&&(0,a.jsxs)("p",{className:"text-xs text-amber-200 flex items-center gap-1.5 font-medium",children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5 text-amber-300"}),(0,a.jsxs)("span",{children:["پلی‌مستر میز: ",N.activeEvent.playMasterName]})]}),N.activeEvent.cafeName&&(0,a.jsxs)("p",{className:"text-xs text-purple-100 flex items-center gap-1.5",children:[(0,a.jsx)(g.A,{className:"w-3.5 h-3.5 text-purple-200"}),(0,a.jsxs)("span",{children:["کافه ",N.activeEvent.cafeName]})]}),B&&(0,a.jsxs)("p",{className:"text-xs text-purple-100 flex items-center gap-1.5",children:[(0,a.jsx)(b.A,{className:"w-3.5 h-3.5 text-purple-200"}),(0,a.jsx)("span",{children:B})]})]}),(0,a.jsxs)(l(),{href:"/events/".concat(N.activeEvent.id),onClick:k,className:"inline-flex items-center justify-center gap-2 w-full py-2.5 px-4 rounded-xl text-xs font-black bg-white hover:bg-purple-50 text-purple-950 hover:text-purple-900 transition-all shadow-xs border border-white/80",children:[(0,a.jsx)("span",{children:"مشاهده میز و همبازی شدن"}),(0,a.jsx)(v.A,{className:"w-3.5 h-3.5"})]})]}),!E&&!1===N.activeEvent.isCreator&&N.activeEvent.isAnonymous&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-3.5 py-2.5 rounded-2xl bg-gradient-to-r from-slate-100 via-purple-50/50 to-slate-100 border border-purple-100/80 text-gray-700 shadow-2xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-base",children:"\uD83C\uDFB2"}),(0,a.jsxs)("span",{className:"text-xs font-bold text-gray-800",children:["همبازی در ",N.coPlayerTablesCount||1," میز فعال"]})]}),(0,a.jsx)("span",{className:"text-[10px] font-semibold text-purple-700 bg-purple-100/80 px-2 py-0.5 rounded-full",children:"به زودی"})]})]}),(N.favoriteGames&&N.favoriteGames.length>0||N.favoriteGenres&&N.favoriteGenres.length>0)&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h5",{className:"text-xs font-bold text-gray-700 flex items-center gap-1.5",children:[(0,a.jsx)(f.A,{className:"w-3.5 h-3.5 text-purple-600"}),(0,a.jsx)("span",{children:"بازی‌ها و علاقه‌مندی‌ها"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[null==(n=N.favoriteGames)?void 0:n.map((e,t)=>{let s=RegExp("^\\p{Extended_Pictographic}","u").test(e.trim());return(0,a.jsx)("span",{className:"text-xs px-3 py-1.5 rounded-xl bg-purple-50 hover:bg-purple-100/80 text-purple-800 border border-purple-100/90 font-medium transition-colors shadow-2xs",children:s?e:"\uD83C\uDFB2 ".concat(e)},"game-".concat(t))}),null==(w=N.favoriteGenres)?void 0:w.map((e,t)=>(0,a.jsx)("span",{className:"text-xs px-3 py-1.5 rounded-xl bg-sky-50 hover:bg-sky-100/80 text-sky-800 border border-sky-100/90 font-medium transition-colors shadow-2xs",children:e},"genre-".concat(t)))]})]}),!E&&N.id&&(0,a.jsx)("div",{className:"pt-1",children:(0,a.jsx)(Y,{targetUserId:N.id,targetUserName:N.name,isCurrentUser:E,hasArchetype:U,onDiscoverArchetype:G,onOpenAuthModal:G,onOpenInviteModal:()=>R(!0)})}),(0,a.jsx)("div",{className:"pt-3 flex items-center justify-end border-t border-gray-100",children:(0,a.jsx)("button",{onClick:k,className:"py-2.5 px-6 rounded-xl text-xs font-bold bg-gray-100 hover:bg-gray-200 text-gray-700 transition-colors border border-gray-200",children:"بستن"})})]})]}),!E&&N.id&&(0,a.jsx)(L,{isOpen:T,onClose:()=>R(!1),targetUser:{id:N.id,name:N.name,username:N.username,avatar:N.avatar}}),(0,a.jsx)(F.G,{isOpen:M,onClose:()=>O(!1),description:"برای کشف آرکی‌تایپ خود و حضور در کلاب پلیمو، لطفاً ابتدا وارد حساب کاربری خود شوید یا ثبت‌نام کنید."})]})})}}}]);