"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5937],{6886:(e,t,s)=>{s.d(t,{ZM:()=>o,ac:()=>d,hH:()=>c});var a=s(95155),r=s(12115),l=s(59072),n=s(35299),i=s(51834);let o=[{value:l.Gender.MALE,label:"آقا هستم",icon:"\uD83D\uDE4B\uD83C\uDFFB‍♂️"},{value:l.Gender.FEMALE,label:"خانم هستم",icon:"\uD83D\uDE4B\uD83C\uDFFB‍♀️"}],c=[{value:l.AgeRange.UNDER_15,label:"زیر ۱۵ سال"},{value:l.AgeRange.RANGE_15_20,label:"۱۵ تا ۲۰"},{value:l.AgeRange.RANGE_21_25,label:"۲۱ تا ۲۵"},{value:l.AgeRange.RANGE_26_30,label:"۲۶ تا ۳۰"},{value:l.AgeRange.RANGE_31_40,label:"۳۱ تا ۴۰"},{value:l.AgeRange.ABOVE_40,label:"بالای ۴۰ سال"}];function d(e){let{isOpen:t,onClose:s,currentAgeRange:l,currentGender:d,onAgeSelected:x,onSave:m,isLoading:u=!1}=e,[p,h]=r.useState(l),[b,g]=r.useState(d);r.useEffect(()=>{t&&(h(l),g(d))},[t,l,d]);let f=async()=>{!u&&(m?await m({ageRange:p,gender:b}):x&&p&&await x(p))};return(0,a.jsx)(i.lG,{open:t,onOpenChange:e=>!e&&s(),children:(0,a.jsxs)(i.Cf,{className:"dir-rtl font-vazir rounded-3xl p-6 bg-white border border-purple-100 shadow-2xl max-w-sm mx-auto z-[9999]",showCloseButton:!0,children:[(0,a.jsxs)(i.L3,{className:"text-lg font-bold text-gray-900 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xl",children:"\uD83C\uDFAF"}),(0,a.jsx)("span",{children:"تعیین مشخصات همبازی"})]}),(0,a.jsx)(i.rr,{className:"text-xs text-gray-500 mt-1 leading-relaxed",children:"برای هماهنگی دقیق‌تر با همبازی‌ها در کافه‌بازی‌ها، رده سنی و جنسیت خود را مشخص کنید."}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("label",{className:"text-xs font-bold text-gray-700 block mb-1.5",children:"جنسیت"}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:o.map(e=>{let t=b===e.value;return(0,a.jsxs)("button",{type:"button",disabled:u,onClick:()=>g(t?null:e.value),className:"py-2 px-3 rounded-2xl text-xs font-bold border transition-all text-center flex items-center justify-center gap-1.5 cursor-pointer ".concat(t?"bg-purple-600 text-white border-purple-600 shadow-md shadow-purple-500/20 scale-[1.02]":"bg-gray-50 hover:bg-purple-50 text-gray-700 border-gray-200 hover:border-purple-300"),children:[(0,a.jsx)("span",{children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})})]}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsxs)("label",{className:"text-xs font-bold text-gray-700 block mb-1.5",children:["رده سنی ",(0,a.jsx)("span",{className:"text-purple-600",children:"*"})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:c.map(e=>{let t=p===e.value;return(0,a.jsx)("button",{type:"button",disabled:u,onClick:()=>h(e.value),className:"py-2.5 px-3 rounded-2xl text-xs font-bold border transition-all text-center flex items-center justify-center gap-1.5 cursor-pointer ".concat(t?"bg-purple-600 text-white border-purple-600 shadow-md shadow-purple-500/20 scale-[1.02]":"bg-gray-50 hover:bg-purple-50 text-gray-700 border-gray-200 hover:border-purple-300"),children:(0,a.jsx)("span",{children:e.label})},e.value)})})]}),(0,a.jsxs)("div",{className:"mt-5 flex items-center justify-between pt-3 border-t border-gray-100 gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:u,onClick:s,className:"text-xs text-gray-500 hover:text-gray-700 py-2 px-3.5 rounded-xl hover:bg-gray-100 transition-colors cursor-pointer",children:"انصراف"}),(0,a.jsx)("button",{type:"button",disabled:u||!p,onClick:f,className:"py-2 px-4 rounded-xl text-xs font-bold transition-all flex items-center justify-center gap-1.5 cursor-pointer ".concat(p&&!u?"bg-purple-600 hover:bg-purple-700 text-white shadow-md shadow-purple-500/25 active:scale-95":"bg-gray-100 text-gray-400 cursor-not-allowed border border-gray-200"),children:u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.A,{className:"w-3.5 h-3.5 animate-spin"}),(0,a.jsx)("span",{children:"در حال ذخیره..."})]}):(0,a.jsx)("span",{children:"ذخیره مشخصات"})})]})]})})}},41751:(e,t,s)=>{s.d(t,{x:()=>a});function a(e,t){let s;return"string"==typeof e?s=e:e&&"object"==typeof e&&("username"in e&&"string"==typeof e.username?s=e.username:"user"in e&&e.user&&"object"==typeof e.user&&"username"in e.user&&"string"==typeof e.user.username&&(s=e.user.username)),"string"==typeof s&&!!(s.trim().length>0)||"string"==typeof t&&!!(t.trim().length>0)}},44846:(e,t,s)=>{s.d(t,{d:()=>n});var a=s(95155);s(12115);var r=s(27599),l=s(64269);function n(e){let{className:t,...s}=e;return(0,a.jsx)(r.bL,{"data-slot":"switch",className:(0,l.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-gray-200 dark:data-[state=unchecked]:bg-gray-700",t),...s,children:(0,a.jsx)(r.zi,{"data-slot":"switch-thumb",className:(0,l.cn)("pointer-events-none block h-5 w-5 rounded-full bg-white shadow-md ring-0 transition-transform data-[state=unchecked]:translate-x-0 data-[state=checked]:translate-x-5 rtl:data-[state=checked]:-translate-x-5")})})}},65142:(e,t,s)=>{s.d(t,{p:()=>l});var a=s(95155);s(12115);var r=s(64269);function l(e){let{className:t,type:s,...l}=e;return(0,a.jsx)("input",{type:s,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...l})}},66091:(e,t,s)=>{function a(){return"/auth/customer/signin"}function r(e){let t="/auth/customer/signup/phone";return e?"".concat(t,"?ref=").concat(encodeURIComponent(e)):t}function l(){return"/auth/business/signin"}function n(){return"/auth/business/signup/phone"}function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"customer";return"business"===e?"/auth/business/forgot-password":"/auth/customer/forgot-password"}s.d(t,{Ku:()=>r,O$:()=>i,aC:()=>l,al:()=>n,kk:()=>a})},73618:(e,t,s)=>{s.d(t,{s:()=>f});var a=s(95155),r=s(12115),l=s(36489),n=s(51834),i=s(3998),o=s(65142),c=s(35299),d=s(18720),x=s(72377);let m=new Set(["playmo","playmaster","playmo_bot","playmo_support","playmo_admin","playmo_official","playmoclub","playmo_club","playmo_app","playmogame","playmogames","admin","administrator","moderator","mod","support","help","security","staff","team","system","root","owner","superuser","master","official","api","app","auth","login","signin","logout","signout","register","signup","dashboard","profile","settings","events","cafes","tables","games","wallet","payments","payment","checkout","webhook","callback","public","static","assets","docs","about","contact","terms","privacy","null","undefined","test","demo","bot"]),u=["playmo_","playmaster_","admin_","support_","system_","mod_"],p={MIN_LENGTH:3,MAX_LENGTH:20},h={REQUIRED:"نام کاربری الزامی است",MIN_LENGTH:"نام کاربری باید حداقل ".concat(p.MIN_LENGTH," کاراکتر باشد"),MAX_LENGTH:"نام کاربری نباید بیشتر از ".concat(p.MAX_LENGTH," کاراکتر باشد"),START_CHAR:"نام کاربری باید با یک حرف انگلیسی شروع شود",ALLOWED_CHARS:"نام کاربری فقط می‌تواند شامل حروف انگلیسی، اعداد و زیرخط (_) باشد",NO_TRAILING_UNDERSCORE:"نام کاربری نمی‌تواند با زیرخط (_) پایان یابد",NO_CONSECUTIVE_UNDERSCORES:"نام کاربری نمی‌تواند شامل دو یا چند زیرخط متوالی باشد",RESERVED:"این نام کاربری رزرو شده و غیرقابل استفاده است",DUPLICATE:"این نام کاربری قبلاً توسط شخص دیگری انتخاب شده است",CANNOT_UNSET:"نام کاربری پس از تعیین قابل حذف نیست و فقط می‌توانید آن را تغییر دهید"},b=x.Yj({message:h.REQUIRED}).min(p.MIN_LENGTH,h.MIN_LENGTH).max(p.MAX_LENGTH,h.MAX_LENGTH).regex(/^[a-zA-Z]/,h.START_CHAR).regex(/^[a-zA-Z0-9_]+$/,h.ALLOWED_CHARS).refine(e=>!e.endsWith("_"),{message:h.NO_TRAILING_UNDERSCORE}).refine(e=>!e.includes("__"),{message:h.NO_CONSECUTIVE_UNDERSCORES}).refine(e=>!function(e){if("string"!=typeof e)return!1;let t=e.trim().toLowerCase();return!!t&&(!!m.has(t)||u.some(e=>t.startsWith(e)))}(e),{message:h.RESERVED});var g=s(6886);function f(e){let{open:t,onOpenChange:s,onSuccess:x}=e,{data:m,update:u}=(0,l.useSession)(),[p,h]=(0,r.useState)(""),[f,j]=(0,r.useState)(null),[v,N]=(0,r.useState)(null),[y,w]=(0,r.useState)(!1),[T,k]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(t&&(null==m?void 0:m.user)){let e=m.user;e.username&&h(e.username),e.gender&&j(e.gender),e.ageRange&&N(e.ageRange)}},[t,null==m?void 0:m.user]);let D=async e=>{e.preventDefault();let t=p.trim().toLowerCase(),a=b.safeParse(t);if(!a.success){var r;k((null==(r=a.error.issues[0])?void 0:r.message)||"ساختار نام کاربری نامعتبر است");return}if(!f)return void k("لطفاً جنسیت خود را مشخص کنید");if(!v)return void k("لطفاً رده سنی خود را مشخص کنید");k(null),w(!0);try{let e=await fetch("/api/user/profile",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,gender:f,ageRange:v})}),a=await e.json();if(!e.ok||!a.success)throw Error(a.error||"خطا در ثبت مشخصات");if(d.o.success("پروفایل شما با موفقیت تکمیل شد!",{description:"\uD83C\uDFC5 نشان افتخار عملگرایی (Action Taker) به شما اعطا گردید."}),null==m?void 0:m.user){let e=m.user;e.username=t,e.gender=f,e.ageRange=v}try{await (null==u?void 0:u())}catch(e){}x(t),s(!1)}catch(e){k(e instanceof Error?e.message:"خطا در ارتباط با سرور")}finally{w(!1)}},C=!!(p.trim()&&f&&v);return(0,a.jsx)(n.lG,{open:t,onOpenChange:s,children:(0,a.jsxs)(n.Cf,{dir:"rtl",className:"w-[calc(100vw-2.5rem)] max-w-sm sm:max-w-md p-4 sm:p-5 rounded-3xl bg-white/95 dark:bg-gray-900/95 backdrop-blur-2xl border border-gray-100 dark:border-gray-800 shadow-2xl text-right font-vazir box-border overflow-hidden",children:[(0,a.jsxs)(n.c7,{className:"text-right sm:text-right space-y-1 pb-1 w-full min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between pb-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 bg-amber-50 dark:bg-amber-950/40 px-2 py-0.5 rounded-full border border-amber-200/80 dark:border-amber-700/60 shadow-2xs",children:[(0,a.jsx)("span",{className:"text-sm",children:"\uD83C\uDFC5"}),(0,a.jsx)("span",{className:"text-[10.5px] font-extrabold text-amber-800 dark:text-amber-300 font-vazir",children:"نشان افتخار عملگرایی"})]}),(0,a.jsx)("span",{className:"text-[10px] text-gray-400 font-medium font-vazir",children:"گام ۳ از ۴"})]}),(0,a.jsx)(n.L3,{className:"text-sm sm:text-base font-extrabold text-gray-900 dark:text-white tracking-tight font-vazir",children:"تکمیل مشخصات و آیدی همبازی"}),(0,a.jsx)(n.rr,{className:"text-[11px] text-gray-500 dark:text-gray-400 leading-tight font-vazir",children:"برای فعال‌سازی نشان و هماهنگی دقیق‌تر در میزهای بازی، مشخصات زیر را وارد کنید:"})]}),(0,a.jsxs)("form",{onSubmit:D,className:"space-y-2.5 mt-1 font-vazir",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-[11px] font-bold text-gray-800 dark:text-gray-200 block mb-1",children:["آیدی اختصاصی (انگلیسی) ",(0,a.jsx)("span",{className:"text-purple-600",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(o.p,{dir:"ltr",type:"text",placeholder:"e.g. ali_gamer",value:p,onChange:e=>{h(e.target.value),T&&k(null)},className:"h-8.5 rounded-xl border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-left font-vazir pl-3 pr-7 text-xs focus:ring-1 focus:ring-purple-500",disabled:y}),(0,a.jsx)("span",{className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs",children:"@"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-[11px] font-bold text-gray-800 dark:text-gray-200 block mb-1",children:["جنسیت ",(0,a.jsx)("span",{className:"text-purple-600",children:"*"})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:g.ZM.map(e=>{let t=f===e.value;return(0,a.jsxs)("button",{type:"button",disabled:y,onClick:()=>{j(e.value),T&&k(null)},className:"h-8 px-2 rounded-xl text-[11px] font-bold border transition-all flex items-center justify-center gap-1.5 cursor-pointer ".concat(t?"bg-purple-600 text-white border-purple-600 shadow-xs scale-[1.01]":"bg-gray-50 dark:bg-gray-800/80 hover:bg-purple-50 dark:hover:bg-purple-950/40 text-gray-700 dark:text-gray-300 border-gray-200 dark:border-gray-700"),children:[(0,a.jsx)("span",{children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-[11px] font-bold text-gray-800 dark:text-gray-200 block mb-1",children:["رده سنی ",(0,a.jsx)("span",{className:"text-purple-600",children:"*"})]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:g.hH.map(e=>{let t=v===e.value;return(0,a.jsx)("button",{type:"button",disabled:y,onClick:()=>{N(e.value),T&&k(null)},className:"h-7.5 px-1.5 rounded-xl text-[10.5px] font-bold border transition-all flex items-center justify-center cursor-pointer text-center ".concat(t?"bg-purple-600 text-white border-purple-600 shadow-xs scale-[1.01]":"bg-gray-50 dark:bg-gray-800/80 hover:bg-purple-50 dark:hover:bg-purple-950/40 text-gray-700 dark:text-gray-300 border-gray-200 dark:border-gray-700"),children:(0,a.jsx)("span",{children:e.label})},e.value)})})]}),T&&(0,a.jsx)("p",{className:"text-[10.5px] text-rose-500 font-medium pt-0.5 animate-in fade-in font-vazir",children:T}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pt-2 border-t border-gray-100 dark:border-gray-800",children:[(0,a.jsx)(i.$,{type:"submit",disabled:y||!C,className:"flex-1 h-9 rounded-xl font-bold text-xs transition-all flex items-center justify-center gap-1 cursor-pointer font-vazir ".concat(C&&!y?"bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white shadow-md shadow-purple-500/20 active:scale-95":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 cursor-not-allowed border border-gray-200 dark:border-gray-700"),children:y?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.A,{className:"w-3.5 h-3.5 animate-spin"}),(0,a.jsx)("span",{children:"در حال ثبت..."})]}):(0,a.jsx)("span",{children:"ثبت مشخصات و دریافت مدال \uD83C\uDFC5"})}),(0,a.jsx)(i.$,{type:"button",variant:"outline",onClick:()=>s(!1),disabled:y,className:"h-9 px-3 rounded-xl border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 text-xs font-semibold cursor-pointer font-vazir",children:"انصراف"})]})]})]})})}},98373:(e,t,s)=>{s.d(t,{AA:()=>l,D7:()=>i,L7:()=>m,gA:()=>x,gH:()=>p,nM:()=>c,sM:()=>u});var a=s(72377);let r=/^(([01]\d|2[0-3]):[0-5]\d|24:00)$/,l=["06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00","00:00","01:00","02:00","03:00","04:00","05:00"],n={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},i={saturday:"شنبه",sunday:"یکشنبه",monday:"دوشنبه",tuesday:"سه‌شنبه",wednesday:"چهارشنبه",thursday:"پنج‌شنبه",friday:"جمعه"},o=a.Ik({isOpen:a.zM().default(!0),openTime:a.Yj().regex(r,"فرمت زمان بازگشایی نامعتبر است (HH:mm)"),closeTime:a.Yj().regex(r,"فرمت زمان بسته‌شدن نامعتبر است (HH:mm)")}),c=a.Ik({id:a.Yj().min(1),title:a.Yj().max(50).optional(),daysOfWeek:a.YO(a.k5(["saturday","sunday","monday","tuesday","wednesday","thursday","friday"])).min(1,"حداقل انتخاب یک روز الزامی است"),startHour:a.Yj().regex(r,"فرمت ساعت شروع باید HH:mm باشد"),endHour:a.Yj().regex(r,"فرمت ساعت پایان باید HH:mm باشد"),discountPercent:a.ai().int().min(1,"حداقل تخفیف ۱٪ است").max(90,"حداکثر تخفیف ۹۰٪ است"),isActive:a.zM().default(!0),createdAt:a.Yj().optional()}),d=a.YO(c).max(20,"حداکثر ۲۰ قانون مجاز است"),x=a.Ik({operatingHours:a.g1(a.Yj(),o).optional(),hourlyDiscounts:d.optional(),pricing:a.g1(a.Yj(),a.bz()).optional()}).passthrough();function m(e){if(!e||"string"!=typeof e)return NaN;let t=e.trim();if(/^\d:[0-5]\d$/.test(t)&&(t="0"+t),!r.test(t))return NaN;let[s,a]=t.split(":");return 60*parseInt(s,10)+parseInt(a,10)}function u(e){if("string"==typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e.trim())){let[t,s,a]=e.trim().split("-").map(Number);return n[new Date(Date.UTC(t,s-1,a,12,0,0)).getUTCDay()]}return n[new Date(("string"==typeof e?new Date(e):e).getTime()+126e5).getUTCDay()]}function p(e){var t;let{openTime:s,closeTime:a,settings:r,targetTime:l,targetDate:n,durationHours:i=1}=e,o=null;if("string"==typeof r)try{let e=JSON.parse(r),t=x.safeParse(e);o=t.success?t.data:e}catch(e){o=null}else if("object"==typeof r&&null!==r){let e=x.safeParse(r);o=e.success?e.data:r}let c=u(n?(n instanceof Date,n):new Date),d=null==o||null==(t=o.operatingHours)?void 0:t[c],p=(null==d?void 0:d.openTime)||s||"10:00",h=(null==d?void 0:d.closeTime)||a||"23:00";if(d&&!1===d.isOpen)return{isOpen:!1,reason:"کافه در این روز تعطیل است",openTime:p,closeTime:h};let b=l;if(!b&&n instanceof Date){let e=new Date(n.getTime()+126e5),t=String(e.getUTCHours()).padStart(2,"0"),s=String(e.getUTCMinutes()).padStart(2,"0");b="".concat(t,":").concat(s)}if(!b)return{isOpen:!0,openTime:p,closeTime:h};let g=m(b);if(isNaN(g))return{isOpen:!1,reason:"فرمت زمان انتخابی نامعتبر است",openTime:p,closeTime:h};let f=m(p),j=m(h);isNaN(f)&&(f=600),isNaN(j)&&(j=1380),0===j&&f>0&&(j=1440);let v=g+Math.round(60*i);if(f<j)return g>=f&&v<=j?{isOpen:!0,openTime:p,closeTime:h}:{isOpen:!1,reason:"کافه در این ساعت باز نیست (ساعات کاری: ".concat(p," الی ").concat(h,")"),openTime:p,closeTime:h};if(!(f>j))return{isOpen:!0,openTime:p,closeTime:h};{let e=g>=f&&v<=j+1440,t=g<f&&v<=j;return e||t?{isOpen:!0,openTime:p,closeTime:h}:{isOpen:!1,reason:"کافه در این ساعت باز نیست (ساعات کاری: ".concat(p," الی ").concat(h,")"),openTime:p,closeTime:h}}}},99624:(e,t,s)=>{s.d(t,{k:()=>es});var a=s(95155),r=s(12115),l=s(20063),n=s(51834),i=s(3998),o=s(90368),c=s(27937),d=s(35299),x=s(95740),m=s(99708),u=s(98373);let p=u.AA;function h(e,t){if(!e||!t)return p;let s=(0,u.L7)(e),a=(0,u.L7)(t);if(isNaN(s)||isNaN(a))return p;0===a&&(a=1440);let r=60*Math.ceil(s/60),l=[];if(s<a)for(let e=r;e+60<=a;e+=60){let t=Math.floor(e/60);l.push("".concat(String(t).padStart(2,"0"),":00"))}else if(s>a){for(let e=r;e<1440;e+=60){let t=Math.floor(e/60);l.push("".concat(String(t).padStart(2,"0"),":00"))}for(let e=0;e+60<=a;e+=60){let t=Math.floor(e/60);l.push("".concat(String(t).padStart(2,"0"),":00"))}}return l}function b(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.AA;if(!e||0===Object.keys(e).length){let e=t.some(e=>{let t=parseInt(e.split(":")[0],10);return!isNaN(t)&&t<6});return{hours:t,activeHoursSet:new Set(t),hasOvernightHours:e}}let s=[],a=[];if(u.AA.forEach((t,r)=>{let l=e[t];l&&(void 0===l.openCafeCount||l.openCafeCount>0)&&(s.push(t),a.push(r))}),0===a.length){let e=t.some(e=>{let t=parseInt(e.split(":")[0],10);return!isNaN(t)&&t<6});return{hours:t,activeHoursSet:new Set,hasOvernightHours:e}}let r=Math.min(...a),l=Math.max(...a),n=u.AA.slice(r,l+1),i=new Set(s),o=n.some(e=>{let t=parseInt(e.split(":")[0],10);return!isNaN(t)&&t<6});return{hours:n,activeHoursSet:i,hasOvernightHours:o}}function g(e,t,s,a){let r=parseInt(e.split(":")[0],10);return!isNaN(r)&&!(t<6)&&!(r<6)&&r<=t}let f=["تهران","مشهد","اصفهان","شیراز","کرج","تبریز"],j=["یکشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه","شنبه"],v=[{num:1,label:"ژانر",emoji:"\uD83E\uDDE9"},{num:2,label:"بازی",emoji:"\uD83C\uDFB2"},{num:3,label:"زمان",emoji:"⏰"},{num:4,label:"هم‌بازی",emoji:"\uD83D\uDC65"},{num:5,label:"کافه",emoji:"☕"}];var N=s(36489),y=s(18720);class w{static extractDiscountRules(e){if(!e)return[];let t=null;if("string"==typeof e)try{let s=JSON.parse(e),a=u.gA.safeParse(s);t=a.success?a.data:s}catch(e){return[]}else if("object"==typeof e&&null!==e){let s=u.gA.safeParse(e);t=s.success?s.data:e}return Array.isArray(null==t?void 0:t.hourlyDiscounts)?t.hourlyDiscounts:[]}static calculateEffectiveCafeRate(e){let{baseHourlyRate:t,settings:s,targetDate:a,targetTime:r}=e,l=Number(t)||0,n={originalRate:l,effectiveRate:l,discountPercent:0,hasDiscount:!1};if(l<=0)return n;let i=this.extractDiscountRules(s);if(0===i.length)return n;let o=a?a instanceof Date?a:new Date(a):new Date,c=(0,u.sM)(o),d=r;if(!d&&a instanceof Date){let e=new Date(a.getTime()+126e5),t=String(e.getUTCHours()).padStart(2,"0"),s=String(e.getUTCMinutes()).padStart(2,"0");d="".concat(t,":").concat(s)}if(!d)return n;let x=(0,u.L7)(d);if(isNaN(x))return n;let m=i.filter(e=>!1!==e.isActive&&Array.isArray(e.daysOfWeek)&&e.daysOfWeek.includes(c));if(0===m.length)return n;let p=m.filter(e=>{let t=(0,u.L7)(e.startHour),s=(0,u.L7)(e.endHour);return!(isNaN(t)||isNaN(s))&&(t<s?x>=t&&x<s:!(t>s)||x>=t||x<s)});if(0===p.length)return n;let h=p.reduce((e,t)=>t.discountPercent>e.discountPercent?t:e),b=Math.min(Math.max(h.discountPercent,0),90),g=Math.round(l*(1-b/100));return{originalRate:l,effectiveRate:g,discountPercent:b,hasDiscount:b>0,ruleTitle:h.title,ruleId:h.id}}static getHourlyDiscountHeatmap(e){let{cafes:t,targetDate:s,availableHours:a}=e,r={},l=t.map(e=>{let t=null;if("string"==typeof e.settings)try{let s=JSON.parse(e.settings),a=u.gA.safeParse(s);t=a.success?a.data:s}catch(e){t=null}else if("object"==typeof e.settings&&null!==e.settings){let s=u.gA.safeParse(e.settings);t=s.success?s.data:e.settings}return{...e,parsedSettings:t}});for(let e of a){let t=0,a=0,n=0;for(let r of l){if(!(0,u.gH)({openTime:r.openTime,closeTime:r.closeTime,settings:r.parsedSettings,targetTime:e,targetDate:s,durationHours:1}).isOpen)continue;n++;let l=this.calculateEffectiveCafeRate({baseHourlyRate:r.hourlyRate||5e4,settings:r.parsedSettings,targetDate:s,targetTime:e});l.hasDiscount&&(a++,l.discountPercent>t&&(t=l.discountPercent))}r[e]={maxDiscountPercent:t,cafeCountWithDiscount:a,openCafeCount:n}}return r}static findAlternativeDiscountSlots(e){let{baseHourlyRate:t,settings:s,targetDate:a,currentHour:r,availableHours:l}=e,n=this.calculateEffectiveCafeRate({baseHourlyRate:t,settings:s,targetDate:a,targetTime:r}).discountPercent,i=[];for(let e of l){if(e===r)continue;let l=this.calculateEffectiveCafeRate({baseHourlyRate:t,settings:s,targetDate:a,targetTime:e});l.discountPercent>n&&i.push({hour:e,effectiveRate:l.effectiveRate,discountPercent:l.discountPercent,savingsPercent:l.discountPercent-n,ruleTitle:l.ruleTitle})}return i.sort((e,t)=>t.discountPercent-e.discountPercent)}static calculateEffectiveTableRate(e,t){let s=Number(e)||0;if(s<=0)return{originalRate:0,effectiveRate:0,discountPercent:0,hasDiscount:!1};let a=0;if(Array.isArray(t)){let e=t.find(e=>e&&"HOURLY_DISCOUNT"===e.code);e&&"number"==typeof e.percent&&e.percent>0&&(a=Math.min(Math.max(e.percent,0),90))}let r=a>0?Math.max(0,Math.round(s*(1-a/100))):s;return{originalRate:s,effectiveRate:r,discountPercent:a,hasDiscount:a>0}}}let T=(0,r.createContext)(null);function k(e){let{children:t,open:s,onOpenChange:n,userCity:i,initialCafeId:o}=e,c=function(e){var t;let{open:s,onOpenChange:a,userCity:n="همه",initialCafeId:i}=e,o=(0,l.useRouter)(),{data:c,status:d}=(0,N.useSession)(),x=(null==c||null==(t=c.user)?void 0:t.city)||("همه"!==n?n:"تهران"),[m,p]=(0,r.useState)(x),[f,v]=(0,r.useState)(1),[T,k]=(0,r.useState)([]),[D,C]=(0,r.useState)(new Set),[S,A]=(0,r.useState)("ALL"),[R,E]=(0,r.useState)(i?"همه بازی‌های این کافه":"آزاد"),[P,O]=(0,r.useState)(null),[H,L]=(0,r.useState)([]),[I,_]=(0,r.useState)(""),[M,U]=(0,r.useState)(null),[F,z]=(0,r.useState)(!1),[G,$]=(0,r.useState)(!1),[Y,V]=(0,r.useState)(null),J=(0,r.useMemo)(()=>(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=new Date(e.getTime()+126e5);return[{label:"امروز",offsetDays:0,emoji:"⚡"},{label:"فردا",offsetDays:1,emoji:"\uD83D\uDCC5"},{label:"پس‌فردا",offsetDays:2,emoji:"\uD83D\uDCC6"}].map(e=>{let s=new Date(t.getTime()+24*e.offsetDays*36e5),a=j[s.getUTCDay()],r=s.getUTCFullYear(),l=String(s.getUTCMonth()+1).padStart(2,"0"),n=String(s.getUTCDate()).padStart(2,"0"),i="".concat(r,"-").concat(l,"-").concat(n);return{...e,dateStr:i,weekdayName:a,displayLabel:"".concat(e.label," (").concat(a,")")}})})(),[]),W=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;try{let t=new Intl.DateTimeFormat("en-US",{timeZone:"Asia/Tehran",hour:"numeric",hourCycle:"h23"});return parseInt(t.format(e),10)}catch(t){return new Date(e.getTime()+126e5).getUTCHours()}}(),B=+(W>=22),[Z,X]=(0,r.useState)(B),[Q,q]=(0,r.useState)(new Set),K=(0,r.useMemo)(()=>{if(0===B){let e=Math.min(Math.max(10,W+1),23);return"".concat(String(e).padStart(2,"0"),":00")}return"17:00"},[W,B]),[ee,et]=(0,r.useState)(K),[es,ea]=(0,r.useState)({}),[er,el]=(0,r.useState)(3),[en,ei]=(0,r.useState)(!0),[eo,ec]=(0,r.useState)(!0),[ed,ex]=(0,r.useState)(""),[em,eu]=(0,r.useState)([]),[ep,eh]=(0,r.useState)(x),[eb,eg]=(0,r.useState)(null),[ef,ej]=(0,r.useState)(!1),[ev,eN]=(0,r.useState)(null),[ey,ew]=(0,r.useState)(!1),[eT,ek]=(0,r.useState)(null),eD=r.useRef(null);(0,r.useEffect)(()=>{s||ek(null)},[s]),(0,r.useEffect)(()=>{if(!s)return;let e=!0;return(async()=>{var t,s,a,r,l;let n=null==c||null==(t=c.user)?void 0:t.city;if(n&&""!==n.trim()){e&&(p(n),eh(e=>"همه"===e||"تهران"===e?n:e));return}if("authenticated"===d)try{let t=await fetch("/api/user/profile");if(t.ok){let n=await t.json(),i=(null==n||null==(a=n.data)||null==(s=a.user)?void 0:s.city)||(null==n||null==(l=n.profile)||null==(r=l.user)?void 0:r.city);i&&""!==i.trim()&&e&&(p(i),eh(e=>"همه"===e||"تهران"===e?i:e))}}catch(e){}})(),()=>{e=!1}},[s,c,d]);let eC=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/user/tables");if(e.ok){let t=await e.json();if(t.success&&t.data&&Array.isArray(t.data.hosted)){let e=new Set;t.data.hosted.forEach(t=>{if(t.startTime&&"UPCOMING"===t.status){let s=new Date(new Date(t.startTime).getTime()+126e5),a=s.getUTCFullYear(),r=String(s.getUTCMonth()+1).padStart(2,"0"),l=String(s.getUTCDate()).padStart(2,"0");e.add("".concat(a,"-").concat(r,"-").concat(l))}}),q(e),X(t=>{let s=J[t];if(s&&e.has(s.dateStr)){let s=J.findIndex(t=>!e.has(t.dateStr));return -1!==s?s:t}return t})}}}catch(e){}},[J]),eS=(0,r.useCallback)((e,t,s,a)=>{var r;let l=(null==(r=J[0])?void 0:r.dateStr)===t,{availableHours:n,openTime:i,closeTime:o}=function(e,t,s,a){let r=(0,u.gH)({openTime:e.openTime,closeTime:e.closeTime,settings:e.settings,targetDate:t,durationHours:1}),l=r.openTime||e.openTime,n=r.closeTime||e.closeTime;return r.isOpen?{availableHours:h(l,n).filter(r=>!(!(0,u.gH)({openTime:l,closeTime:n,settings:e.settings,targetTime:r,targetDate:t,durationHours:1}).isOpen||s&&g(r,a,l,n))),openTime:l,closeTime:n}:{availableHours:[],openTime:l,closeTime:n}}(e,t,l,W);if((null==a?void 0:a.updateHeatmap)!==!1){let s=w.getHourlyDiscountHeatmap({cafes:[e],targetDate:t,availableHours:n});eD.current=t,ea(e=>!function(e,t){if(e===t)return!0;if(!e||!t)return!1;let s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(let a of s){let s=e[a],r=t[a];if(!r||s.maxDiscountPercent!==r.maxDiscountPercent||s.cafeCountWithDiscount!==r.cafeCountWithDiscount)return!1}return!0}(e,s)?s:e)}let c=w.calculateEffectiveCafeRate({baseHourlyRate:e.hourlyRate||0,settings:e.settings,targetDate:t,targetTime:s}),d=w.findAlternativeDiscountSlots({baseHourlyRate:e.hourlyRate||0,settings:e.settings,targetDate:t,currentHour:s,availableHours:n}),x=d.length>0?d[0]:void 0;eg(t=>{var s,a;let r=t||e;return!r||t&&t.effectiveRate===c.effectiveRate&&t.discountPercent===c.discountPercent&&t.hasDiscount===c.hasDiscount&&t.discountTitle===c.ruleTitle&&t.openTime===i&&t.closeTime===o&&(null==(s=t.alternativeDiscountSlot)?void 0:s.hour)===(null==x?void 0:x.hour)&&(null==(a=t.alternativeDiscountSlot)?void 0:a.discountPercent)===(null==x?void 0:x.discountPercent)?t:{...r,openTime:i||r.openTime,closeTime:o||r.closeTime,effectiveRate:c.effectiveRate,discountPercent:c.discountPercent,hasDiscount:c.hasDiscount,discountTitle:c.ruleTitle,alternativeDiscountSlot:x}}),eu(t=>{var s,a;let r=t&&t.length>0?t[0]:e;return!r||t&&t.length>0&&r.effectiveRate===c.effectiveRate&&r.discountPercent===c.discountPercent&&r.hasDiscount===c.hasDiscount&&r.discountTitle===c.ruleTitle&&r.openTime===i&&r.closeTime===o&&(null==(s=r.alternativeDiscountSlot)?void 0:s.hour)===(null==x?void 0:x.hour)&&(null==(a=r.alternativeDiscountSlot)?void 0:a.discountPercent)===(null==x?void 0:x.discountPercent)?t:[{...r,openTime:i||r.openTime,closeTime:o||r.closeTime,effectiveRate:c.effectiveRate,discountPercent:c.discountPercent,hasDiscount:c.hasDiscount,discountTitle:c.ruleTitle,alternativeDiscountSlot:x}]})},[J,W]),eA=(0,r.useCallback)(async()=>{$(!0),V(null);try{if(i){let[t,s]=await Promise.all([fetch("/api/cafes/".concat(i,"/games")),fetch("/api/cafes/".concat(i))]),a=await t.json();if(a.success&&a.data){let e=a.data.cafeName||"این کافه";O(e);let t=(a.data.games||[]).map(e=>({id:e.id,title:e.nameFa||e.name,englishTitle:e.name!==e.nameFa?e.name:void 0,genre:e.genre||(e.genres&&e.genres.length>0?e.genres[0].name:void 0),genreId:e.genreId||(e.genres&&e.genres.length>0?e.genres[0].id:e.genreIds&&e.genreIds[0]),genreIds:e.genreIds||(e.genres?e.genres.map(e=>e.id):[]),minPlayers:e.minPlayers||2,maxPlayers:e.maxPlayers||6,isPopular:!!e.isPopular,imageUrl:e.imageUrl}));L(t);let s=(a.data.genres||[]).map(e=>({id:e.id,name:e.name,cleanName:e.cleanName||e.name}));k(s)}else V(a.error||"خطا در دریافت لیست بازی‌های کافه");if(s.ok){let t=await s.json();if(t.success&&t.data){var e;let s=t.data,a={id:s.id,name:s.name,address:s.address,city:s.city,district:s.district,hourlyRate:s.hourlyRate||0,isFree:0===s.hourlyRate||"FREE"===s.pricingType,pricingType:s.pricingType,logo:s.logo,images:s.images,openTime:s.openTime,closeTime:s.closeTime,settings:s.settings};eg(a),eu([a]),s.city&&eh(s.city),s.name&&O(s.name);let r=(null==(e=J[+(W>=22)])?void 0:e.dateStr)||"";eS(a,r,K,{updateHeatmap:!0})}}}else{let e=await fetch("/api/games"),t=await e.json();if(t.success&&t.data){let e=(t.data.games||[]).map(e=>({id:e.id,title:e.nameFa||e.name,englishTitle:e.name!==e.nameFa?e.name:void 0,genre:e.genre||(e.genres&&e.genres.length>0?e.genres[0].name:void 0),genreId:e.genreId||(e.genres&&e.genres.length>0?e.genres[0].id:e.genreIds&&e.genreIds[0]),genreIds:e.genreIds||(e.genres?e.genres.map(e=>e.id):[]),minPlayers:e.minPlayers||2,maxPlayers:e.maxPlayers||6,isPopular:!!e.isPopular,imageUrl:e.imageUrl}));L(e);let s=(t.data.genres||[]).map(e=>({id:e.id,name:e.name,cleanName:e.cleanName||e.name}));k(s)}else V(t.error||"خطا در بارگذاری لیست بازی‌ها")}}catch(e){V("خطا در برقراری ارتباط با سرور کاتالوگ بازی‌ها")}finally{$(!1)}},[i,W,J,K,eS]),eR=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/user/game-preferences");if(e.ok){let t=await e.json();if(t.success&&Array.isArray(t.data)){let e=new Set(t.data.map(e=>e.gameTitle));C(e)}}}catch(e){}},[]),eE=(0,r.useRef)(ee);eE.current=ee;let eP=(0,r.useCallback)(async(e,t,s,a,r)=>{var l,n;if(i){if(eb){let e=r||(null==(l=J[Z])?void 0:l.dateStr)||"",t=a||eE.current,s=!!r||!a&&e!==eD.current;eS(eb,e,t,{updateHeatmap:s})}return}ej(!0),eN(null);try{let l=new URLSearchParams;(null==e?void 0:e.id)?l.set("gameId",e.id):(null==e?void 0:e.title)&&l.set("game",e.title),S&&"ALL"!==S&&"FAVORITES"!==S&&"POPULAR"!==S?l.set("genreId",S):t&&"ALL"!==t&&"همه بازی‌ها"!==t&&"آزاد"!==t&&"FAVORITES"!==t&&"POPULAR"!==t&&l.set("genre",t),s&&"همه"!==s&&l.set("city",s);let i=a||(5===f?eE.current:void 0);i&&l.set("time",i);let o=r||(null==(n=J[Z])?void 0:n.dateStr);o&&l.set("date",o),l.set("includeHeatmap","true");let c=await fetch("/api/cafes/by-game?".concat(l.toString())),d=await c.json();d.success&&Array.isArray(d.data)?(eu(d.data),d.hourlyDiscountsMap&&ea(d.hourlyDiscountsMap),d.data.length>0?eg(e=>e&&d.data.some(t=>String(t.id)===String(e.id))?e:d.data[0]):eg(null)):eN(d.error||"خطا در دریافت لیست کافه‌ها")}catch(e){eN("خطا در برقراری ارتباط با سرور برای دریافت کافه‌ها")}finally{ej(!1)}},[i,eb,S,f,Z,J,eS]),eO=(0,r.useCallback)(e=>{et(e),eP(M,R,ep,e)},[M,R,ep,eP]);(0,r.useEffect)(()=>{s&&(v(1),A("ALL"),E(i?"همه بازی‌های این کافه":"آزاد"),_(""),U(null),z(!1),i||(eg(null),O(null)),X(+(W>=22)),et(K),el(3),ei(!0),ex(""),eD.current=null,eA(),eR(),eC())},[s,i,W,K,eA,eR,eC]),(0,r.useEffect)(()=>{(3===f||5===f)&&eP(M,R,ep)},[f,M,R,ep,Z,eP]),(0,r.useEffect)(()=>{var e;let t=null==(e=J[Z])?void 0:e.dateStr;if(t)if(i&&eb){let e=(0,u.gH)({openTime:eb.openTime,closeTime:eb.closeTime,settings:eb.settings,targetTime:ee,targetDate:t,durationHours:1}),s=0===Z&&g(ee,W,e.openTime||eb.openTime,e.closeTime||eb.closeTime),a=h(e.openTime||eb.openTime,e.closeTime||eb.closeTime);if(!a.includes(ee)||!e.isOpen||s){let s=a.find(s=>!(0===Z&&g(s,W,e.openTime||eb.openTime,e.closeTime||eb.closeTime))&&(0,u.gH)({openTime:eb.openTime,closeTime:eb.closeTime,settings:eb.settings,targetTime:s,targetDate:t,durationHours:1}).isOpen);s&&et(s)}}else{let{hours:e,activeHoursSet:t}=b(es);if(t.size>0){let s=0===Z&&g(ee,W),a=t.has(ee);if(s||!a){let s=e.find(e=>!(0===Z&&g(e,W))&&t.has(e));s&&s!==ee&&et(s)}}}},[i,eb,Z,J,W,ee,es]);let eH=(0,r.useMemo)(()=>H.filter(e=>{let t=!0;if("FAVORITES"===S)t=D.has(e.title);else if("POPULAR"===S)t=!!e.isPopular;else if("ALL"!==S){var s;t=e.genreId===S||e.genre===R||!!(null==(s=e.genreIds)?void 0:s.includes(S))}let a=I.trim().toLowerCase(),r=!a||e.title.toLowerCase().includes(a)||e.englishTitle&&e.englishTitle.toLowerCase().includes(a)||e.genre&&e.genre.toLowerCase().includes(a);return t&&r}),[H,S,R,D,I]),eL=async(e,t)=>{t.stopPropagation();let s=e.title,a=D.has(s);C(e=>{let t=new Set(e);return a?t.delete(s):t.add(s),t});try{if(a){if(!(await fetch("/api/user/game-preferences?gameTitle=".concat(encodeURIComponent(s)),{method:"DELETE"})).ok)throw Error("خطا در حذف از علاقه‌مندی‌ها");y.o.success("\xab".concat(s,"\xbb از لیست علاقه‌مندی‌های شما حذف شد"))}else{let t=await fetch("/api/user/game-preferences",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameTitle:s,category:function(e){if(!e)return"STRATEGY";let t=e.toLowerCase();return t.includes("استراتژیک")||t.includes("strategy")?"STRATEGY":t.includes("خانوادگی")||t.includes("family")?"FAMILY":t.includes("مخفی")||t.includes("استنتاجی")||t.includes("deduction")?"DEDUCTION":t.includes("مهمانی")||t.includes("پارتی")||t.includes("دورهمی")||t.includes("party")?"PARTY":t.includes("جنگی")||t.includes("war")?"WAR":t.includes("دو نفره")||t.includes("دونفره")||t.includes("duel")?"DUEL":t.includes("کارتی")||t.includes("card")?"CARD":t.includes("اقتصادی")||t.includes("مدیریتی")||t.includes("economic")?"ECONOMIC":t.includes("ماجراجویی")||t.includes("تعاونی")||t.includes("همکاری")||t.includes("adventure")?"ADVENTURE":t.includes("انتزاعی")||t.includes("فکری")||t.includes("abstract")?"ABSTRACT":"STRATEGY"}(e.genre),skillLevel:"ALL_LEVELS"})});if(!t.ok){if(401===t.status)throw Error("برای ذخیره بازی‌های موردعلاقه لطفاً ابتدا وارد حساب کاربری شوید");throw Error("خطا در افزودن به علاقه‌مندی‌ها")}y.o.success("\xab".concat(s,"\xbb به لیست علاقه‌مندی‌های شما افزوده شد ⭐️"))}}catch(e){C(e=>{let t=new Set(e);return a?t.add(s):t.delete(s),t}),y.o.error(e.message||"خطا در بروزرسانی علاقه‌مندی")}},eI=async()=>{if(!M&&!F&&(!R||"ALL"===S)){y.o.error("لطفاً یک بازی یا ژانر مشخص را انتخاب کنید"),v(1);return}if(!eb)return void y.o.error("لطفاً کافه‌گیم مورد نظر خود را انتخاب کنید");let e=J[Z];if(!e||!ee){y.o.error("لطفاً تاریخ و ساعت معتبر انتخاب کنید"),v(3);return}if(0===Z&&g(ee,W,null==eb?void 0:eb.openTime,null==eb?void 0:eb.closeTime)){y.o.error("ساعت انتخابی برای امروز سپری شده است. لطفاً ساعت آینده را انتخاب کنید."),v(3);return}ew(!0);try{let t=e.dateStr;if(6>parseInt(ee.split(":")[0],10)){let s=new Date(new Date("".concat(e.dateStr,"T12:00:00Z")).getTime()+864e5),a=s.getUTCFullYear(),r=String(s.getUTCMonth()+1).padStart(2,"0"),l=String(s.getUTCDate()).padStart(2,"0");t="".concat(a,"-").concat(r,"-").concat(l)}let s="".concat(t,"T").concat(ee,":00+03:30"),r=new Date(s),l={gameTitle:(null==M?void 0:M.title)||void 0,genre:(null==M?void 0:M.genre)||(R&&"همه بازی‌ها"!==R?R:"آزاد"),cafeId:eb.id,startTime:r.toISOString(),playersNeeded:er,isPublic:en,requiresApproval:!!en&&!eo},n=await fetch("/api/tables/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),i=await n.json();if(!n.ok||!i.success)throw Error(i.error||"خطا در ثبت میز بازی");let c=i.data;if("UPCOMING"===c.status){let e=window.location.origin,t="".concat(e,"/events/").concat(c.id),s=J[Z],a="".concat((null==s?void 0:s.label)||""," ساعت ").concat(ee);ek({id:c.id,isPublic:en,gameTitle:c.gameTitle||(null==M?void 0:M.title)||("همه بازی‌ها"!==R?R:"بازی رومیزی"),cafeName:c.cafeName||(null==eb?void 0:eb.name),shareUrl:t,timeLabel:a}),y.o.success(en?"\uD83C\uDF89 میز بازی شما با موفقیت ثبت و منتشر شد!":"\uD83C\uDF89 میز بازی خصوصی شما با موفقیت ایجاد شد!"),window.dispatchEvent(new CustomEvent("event-updated"))}else"PENDING_PAYMENT"===c.status?(a(!1),y.o.info("میز با موفقیت ایجاد شد. در حال انتقال به درگاه پرداخت..."),o.push("/checkout/table/".concat(c.id))):(a(!1),o.push("/events"))}catch(e){y.o.error(e.message||"خطا در برقراری ارتباط با سرور")}finally{ew(!1)}};return{step:f,setStep:v,open:s,onOpenChange:a,initialCafeId:i,genres:T,favoriteGames:D,selectedGenreId:S,selectedGenreName:R,cafeScopeName:P,isLoadingGames:G,gamesError:Y,handleSelectGenre:(e,t)=>{A(e),E(t),_(""),U(null),z(!1),v(2)},loadGames:eA,games:H,filteredGames:eH,gameSearch:I,setGameSearch:_,selectedGame:M,isContinuingWithGenre:F,handleSelectGame:e=>{U(e),z(!1),e.maxPlayers&&e.maxPlayers>1&&el(Math.max(1,Math.min(6,e.maxPlayers-1))),v(3)},handleContinueWithGenre:()=>{U(null),z(!0),v(3)},toggleFavorite:eL,dayOptions:J,selectedDayIndex:Z,setSelectedDayIndex:X,selectedTime:ee,setSelectedTime:et,currentIranHour:W,activeTableDates:Q,hourlyDiscountsMap:es,quickChangeHourAndReload:eO,neededPlayers:er,setNeededPlayers:el,isPublic:en,setIsPublic:ei,isInstantJoin:eo,setIsInstantJoin:ec,description:ed,setDescription:ex,cafes:em,selectedCafeCity:ep,setSelectedCafeCity:eh,profileCity:m,selectedCafe:eb,setSelectedCafe:eg,isLoadingCafes:ef,cafesError:ev,isSubmitting:ey,loadCafes:eP,handleSubmit:eI,createdTable:eT,setCreatedTable:ek}}({open:s,onOpenChange:n,userCity:i,initialCafeId:o});return(0,a.jsx)(T.Provider,{value:c,children:t})}function D(){let e=(0,r.useContext)(T);if(!e)throw Error("useCreateTableContext must be used within a CreateTableProvider");return e}function C(){let{step:e,setStep:t,selectedGenreId:s,selectedGame:r,isContinuingWithGenre:l}=D();return(0,a.jsx)("div",{className:"grid grid-cols-5 gap-1 pt-1 w-full box-border",children:v.map(n=>{let i=e===n.num,o=e>n.num,c=n.num<e||2===n.num&&!!s||3===n.num&&!!(r||l);return(0,a.jsxs)("button",{type:"button",disabled:!c&&!i,onClick:()=>{c&&t(n.num)},className:"flex flex-col items-center justify-center py-1.5 px-0.5 sm:px-1 rounded-xl text-[10px] sm:text-[11px] font-bold transition-all min-w-0 ".concat(i?"bg-emerald-600 text-white shadow-sm shadow-emerald-600/30":o?"bg-emerald-50 text-emerald-700 hover:bg-emerald-100 border border-emerald-200":"bg-slate-100 text-slate-400 opacity-60"),children:[(0,a.jsx)("span",{className:"text-xs leading-none mb-0.5",children:o?"✓":n.emoji}),(0,a.jsx)("span",{className:"truncate w-full text-center",children:n.label})]},n.num)})})}var S=s(11647),A=s(16645),R=s(39347),E=s(8198),P=s(89559);function O(){let{initialCafeId:e,cafeScopeName:t,favoriteGames:s,genres:r,isLoadingGames:l,gamesError:n,loadGames:c,handleSelectGenre:d}=D();return(0,a.jsxs)("div",{className:"space-y-4",children:[e&&(0,a.jsxs)("div",{className:"flex items-center gap-2 p-2.5 rounded-2xl bg-purple-50/80 border border-purple-200/80 text-purple-900 text-xs font-semibold",children:[(0,a.jsx)("span",{className:"text-base",children:"☕"}),(0,a.jsxs)("span",{className:"truncate",children:["نمایش بازی‌ها و ژانرهای موجود در کافه ",(0,a.jsx)("strong",{className:"font-black text-purple-950",children:t||"انتخابی"})]})]}),(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("span",{className:"text-xs font-bold text-slate-700 flex items-center gap-1.5",children:[(0,a.jsx)(A.A,{className:"w-4 h-4 text-purple-600"})," سبک یا ژانر بازی را مشخص کن:"]})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>d("FAVORITES","علاقه‌های من"),className:"flex items-center justify-center gap-2 p-3 rounded-2xl border border-amber-200 bg-amber-50/70 hover:bg-amber-100/80 text-amber-900 font-bold text-xs transition-all text-center shadow-sm",children:[(0,a.jsx)(R.A,{className:"w-4 h-4 text-amber-500 fill-amber-500 shrink-0"}),(0,a.jsx)("span",{children:"علاقه‌های من"}),(0,a.jsx)(S.E,{variant:"outline",className:"bg-white/80 border-amber-300 text-amber-800 text-[10px] px-1.5 py-0 font-mono",children:s.size})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>d("POPULAR","محبوب‌ترین‌ها"),className:"flex items-center justify-center gap-2 p-3 rounded-2xl border border-rose-200 bg-rose-50/70 hover:bg-rose-100/80 text-rose-900 font-bold text-xs transition-all text-center shadow-sm",children:[(0,a.jsx)(E.A,{className:"w-4 h-4 text-rose-500 fill-rose-500 shrink-0"}),(0,a.jsx)("span",{children:"محبوب‌ترین‌ها"})]})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-slate-100 space-y-2.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold text-slate-500 block",children:e?"ژانرهای موجود در این کافه:":"دسته‌بندی‌ها و ژانرهای بردگیم:"}),l?(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:Array.from({length:6}).map((e,t)=>(0,a.jsx)("div",{className:"h-11 bg-slate-100 rounded-xl animate-pulse"},t))}):n?(0,a.jsxs)("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-2xl text-center space-y-2",children:[(0,a.jsx)("p",{className:"text-xs text-rose-700",children:n}),(0,a.jsxs)(i.$,{size:"sm",variant:"outline",onClick:c,className:"text-xs border-rose-300 text-rose-700 hover:bg-rose-100",children:[(0,a.jsx)(P.A,{className:"w-3.5 h-3.5 ml-1.5"})," تلاش دوباره"]})]}):0===r.length?(0,a.jsxs)("div",{className:"p-4 bg-slate-50 border border-slate-200 rounded-2xl text-center space-y-1.5",children:[(0,a.jsx)("p",{className:"text-xs font-bold text-slate-700",children:"ژانری برای این کافه ثبت نشده است"}),(0,a.jsx)("p",{className:"text-[11px] text-slate-500",children:"می‌توانید کاتالوگ را به صورت مستقیم مشاهده کنید."})]}):(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2 max-h-[260px] overflow-y-auto px-1 py-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:r.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>d(e.id,e.name),className:"flex items-center justify-between p-3 rounded-2xl border border-slate-200 bg-white hover:bg-emerald-50 hover:border-emerald-300 text-slate-800 font-semibold text-xs transition-all text-right shadow-sm group",children:[(0,a.jsx)("span",{className:"truncate group-hover:text-emerald-700",children:e.name}),(0,a.jsx)(o.A,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-emerald-600 shrink-0"})]},e.id))})]})]})}var H=s(65142),L=s(86651),I=s(91169),_=s(5917);function M(){let{setStep:e,selectedGenreId:t,selectedGenreName:s,selectedGame:r,favoriteGames:l,filteredGames:n,gameSearch:o,setGameSearch:c,handleSelectGame:d,toggleFavorite:x}=D();return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between bg-emerald-50/80 border border-emerald-200 rounded-2xl p-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm",children:"\uD83E\uDDE9"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-emerald-600 font-semibold block",children:"ژانر انتخابی:"}),(0,a.jsx)("span",{className:"text-xs font-bold text-emerald-900",children:"ALL"===t||"همه بازی‌ها"===s?"آزاد":s})]})]}),(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>e(1),className:"h-8 text-xs text-emerald-700 hover:bg-emerald-100 rounded-xl px-2.5 font-bold",children:"تغییر ژانر"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(L.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-slate-400 h-4 w-4"}),(0,a.jsx)(H.p,{placeholder:"جستجوی نام بازی (مثلاً Catan, استوژیت)...",value:o,onChange:e=>c(e.target.value),className:"pr-9 bg-slate-50 border-slate-200 text-slate-900 text-xs h-10 rounded-xl focus:border-emerald-500 focus:bg-white"})]}),0===n.length?(0,a.jsxs)("div",{className:"p-8 text-center bg-slate-50 border border-slate-200 rounded-2xl space-y-2",children:[(0,a.jsx)("p",{className:"text-xs font-bold text-slate-600",children:"FAVORITES"===t?"هنوز بازی‌ای به لیست علاقه‌مندی‌های خود اضافه نکرده‌اید.":"بازی‌ای با این نام در این بخش یافت نشد."}),(0,a.jsx)("p",{className:"text-[11px] text-slate-400",children:"FAVORITES"===t?"می‌توانید با کلیک روی ستاره ⭐️ در کنار هر بازی، آن را به علایق خود اضافه کنید.":"می‌توانید عبارت جستجو را تغییر دهید یا به ژانر دیگری بروید."})]}):(0,a.jsx)("div",{className:"space-y-2 max-h-[320px] overflow-y-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:n.map(e=>{let t=(null==r?void 0:r.title)===e.title,s=l.has(e.title);return(0,a.jsxs)("div",{onClick:()=>d(e),className:"flex items-center justify-between p-3 rounded-2xl border transition-all cursor-pointer ".concat(t?"bg-emerald-50/80 border-emerald-500 ring-2 ring-emerald-500/20 text-emerald-950 shadow-sm":"bg-slate-50/70 hover:bg-emerald-50/30 border-slate-200 hover:border-emerald-200"),children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0 pr-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h4",{className:"font-bold text-xs text-slate-900 truncate",children:e.title}),e.englishTitle&&(0,a.jsxs)("span",{className:"text-[10px] text-slate-400 font-mono truncate dir-ltr text-right",children:["(",e.englishTitle,")"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[e.genre&&(0,a.jsx)("span",{className:"text-[10px] bg-slate-200/80 text-slate-700 px-1.5 py-0.2 rounded-md font-medium",children:e.genre}),(0,a.jsxs)("span",{className:"text-[10px] text-slate-500 flex items-center gap-0.5",children:[(0,a.jsx)(I.A,{className:"w-3 h-3 text-slate-400"}),e.minPlayers||2,"-",e.maxPlayers||6," نفر"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0 mr-2",children:[(0,a.jsx)("button",{type:"button",title:s?"حذف از علاقه‌مندی‌ها":"افزودن به علاقه‌مندی‌ها",onClick:t=>x(e,t),className:"p-1.5 rounded-lg hover:bg-slate-200/60 transition-colors",children:(0,a.jsx)(R.A,{className:"w-4 h-4 transition-colors ".concat(s?"text-amber-500 fill-amber-500":"text-slate-300 hover:text-amber-400")})}),(0,a.jsx)("div",{className:"w-5 h-5 rounded-full border flex items-center justify-center transition-all ".concat(t?"bg-emerald-600 border-emerald-600 text-white":"border-slate-300 text-transparent"),children:(0,a.jsx)(_.A,{className:"w-3 h-3"})})]})]},e.title)})})]})}var U=s(76444),F=s(10383),z=s(26983);function G(){var e,t,s;let{setStep:l,selectedGame:n,selectedGenreName:o,dayOptions:c,selectedDayIndex:d,setSelectedDayIndex:x,activeTableDates:m,currentIranHour:p,selectedTime:f,setSelectedTime:j,hourlyDiscountsMap:v,initialCafeId:N,selectedCafe:y,isLoadingCafes:w}=D(),T=null==(e=c[d])?void 0:e.dateStr,k=N&&y?(0,u.gH)({openTime:y.openTime,closeTime:y.closeTime,settings:y.settings,targetDate:T}):null,{hours:C,activeHoursSet:S,hasOvernightHours:A}=(0,r.useMemo)(()=>{if(N&&y){if(k&&!1===k.isOpen)return{hours:[],activeHoursSet:new Set,hasOvernightHours:!1};let e=h((null==k?void 0:k.openTime)||y.openTime,(null==k?void 0:k.closeTime)||y.closeTime),t=e.some(e=>{let t=parseInt(e.split(":")[0],10);return!isNaN(t)&&t<6});return{hours:e,activeHoursSet:new Set(e),hasOvernightHours:t}}return b(v)},[N,y,k,v]);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between bg-emerald-50/80 border border-emerald-200 rounded-2xl p-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm",children:"\uD83C\uDFB2"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-emerald-600 font-semibold block",children:"بازی تعیین‌شده:"}),(0,a.jsx)("span",{className:"text-xs font-bold text-emerald-900",children:n?n.title:"آزاد"===o?"بازی آزاد (بدون فیلتر ژانر)":"کل ژانر ".concat(o)})]})]}),(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>l(2),className:"h-8 text-xs text-emerald-700 hover:bg-emerald-100 rounded-xl px-2.5 font-bold",children:"تغییر بازی"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)(U.J,{className:"text-xs font-bold text-slate-700 mb-2 block flex items-center gap-1.5",children:[(0,a.jsx)(F.A,{className:"w-4 h-4 text-emerald-600"})," روز برگزاری میز:"]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:c.map((e,t)=>{let s=d===t,r=m.has(e.dateStr),l=!1;N&&y&&(l=!(0,u.gH)({openTime:y.openTime,closeTime:y.closeTime,settings:y.settings,targetDate:e.dateStr}).isOpen);let n=r||l;return(0,a.jsxs)("button",{type:"button",disabled:n,onClick:()=>x(t),className:"py-2 px-1.5 rounded-2xl text-xs font-bold transition-all text-center border flex flex-col items-center justify-center min-h-[56px] ".concat(n?"bg-slate-100/90 text-slate-400 border-slate-200 cursor-not-allowed opacity-60":s?"bg-emerald-600 border-emerald-600 text-white shadow-md shadow-emerald-600/20 ring-2 ring-emerald-500/20":"bg-slate-50 hover:bg-emerald-50/50 hover:border-emerald-200 border-slate-200 text-slate-700"),children:[(0,a.jsx)("span",{className:"text-xs font-bold ".concat(n?"line-through opacity-80":""),children:e.label}),(0,a.jsxs)("span",{className:"text-[11px] ".concat(s&&!n?"text-emerald-100 font-semibold":"text-slate-500 font-medium"," mt-0.5"),children:["(",e.weekdayName,")"]}),r?(0,a.jsx)("span",{className:"text-[9px] text-rose-500 font-bold mt-0.5 whitespace-nowrap",children:"میز فعال دارید"}):l?(0,a.jsx)("span",{className:"text-[9px] text-amber-600 font-bold mt-0.5 whitespace-nowrap",children:"کافه تعطیل است"}):null]},e.dateStr)})}),c.every(e=>m.has(e.dateStr))&&(0,a.jsxs)("div",{className:"mt-2.5 p-3 rounded-2xl bg-amber-50 border border-amber-200 text-amber-900 text-xs flex items-start gap-2",children:[(0,a.jsx)("span",{className:"text-base leading-none",children:"⚠️"}),(0,a.jsx)("span",{children:"شما در تمامی روزهای مجاز (امروز، فردا و پس‌فردا) میز فعال دارید. طبق قوانین، امکان ایجاد بیش از یک میز فعال در یک روز وجود ندارد."})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-1.5 mb-2",children:[(0,a.jsxs)(U.J,{className:"text-xs font-bold text-slate-700 flex items-center gap-1.5",children:[(0,a.jsx)(z.A,{className:"w-4 h-4 text-emerald-600"})," ساعت شروع بازی:"]}),k&&(0,a.jsxs)("span",{className:"text-[10px] sm:text-[11px] font-bold text-emerald-800 bg-emerald-50 border border-emerald-200 px-2 py-0.5 rounded-lg flex items-center gap-1",children:["\uD83D\uDD52 ساعت کاری کافه: ",k.openTime," الی ",k.closeTime]})]}),w?(0,a.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-1.5","data-testid":"cafe-hours-skeleton",children:Array.from({length:12}).map((e,t)=>(0,a.jsxs)("div",{className:"h-[48px] rounded-xl bg-slate-100 border border-slate-200 animate-pulse flex flex-col items-center justify-center p-2",children:[(0,a.jsx)("div",{className:"h-3 w-8 bg-slate-200 rounded mb-1"}),(0,a.jsx)("div",{className:"h-2 w-6 bg-slate-200/60 rounded"})]},t))}):(0,a.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-1.5",children:C.map(e=>{let t=0===d&&g(e,p,N?(null==k?void 0:k.openTime)||(null==y?void 0:y.openTime):null,N?(null==k?void 0:k.closeTime)||(null==y?void 0:y.closeTime):null),s=!1;s=N&&y?!(0,u.gH)({openTime:y.openTime,closeTime:y.closeTime,settings:y.settings,targetTime:e,targetDate:T,durationHours:1}).isOpen:!S.has(e);let r=t||s,l=f===e,n=null==v?void 0:v[e],i=n&&n.maxDiscountPercent>0;return(0,a.jsxs)("button",{type:"button",disabled:r,onClick:()=>j(e),className:"py-2 px-1 rounded-xl text-xs font-mono font-bold transition-all border flex flex-col items-center justify-center min-h-[48px] ".concat(r?"bg-slate-100 text-slate-300 border-slate-200 cursor-not-allowed opacity-50":l?"bg-emerald-600 border-emerald-600 text-white shadow-sm ring-2 ring-emerald-500/20":"bg-slate-50 hover:bg-emerald-50/50 hover:border-emerald-200 border-slate-200 text-slate-700"),children:[(0,a.jsx)("span",{children:e}),!r&&i&&(0,a.jsxs)("span",{className:"text-[9px] font-black px-1 rounded-md mt-0.5 whitespace-nowrap animate-pulse ".concat(l?"bg-emerald-800/90 text-emerald-100":"bg-emerald-100 text-emerald-800"),children:["\uD83D\uDD25 تا ",n.maxDiscountPercent,"٪"]})]},e)})}),N&&y?(0,a.jsx)("p",{className:"text-[10px] text-slate-400 mt-1.5",children:"* ساعت‌های گذشته غیرفعال هستند."}):0===d?(0,a.jsx)("p",{className:"text-[10px] text-slate-400 mt-1.5",children:"* ساعت‌های گذشته برای روز جاری غیرفعال هستند."}):null,A&&(0,a.jsxs)("p",{className:"text-[10px] text-slate-500 mt-1.5 flex items-center gap-1 font-medium",children:[(0,a.jsx)("span",{children:"\uD83C\uDF19"}),(0,a.jsx)("span",{children:"ساعت‌های بامداد (۰۰:۰۰ الی ۰۵:۰۰) مربوط به شیفت شبانه همین روز کاری هستند."})]}),N&&y&&((null==k?void 0:k.isOpen)===!1||0===C.length||C.every(e=>{let t=0===d&&g(e,p,(null==k?void 0:k.openTime)||(null==y?void 0:y.openTime),(null==k?void 0:k.closeTime)||(null==y?void 0:y.closeTime)),s=(0,u.gH)({openTime:y.openTime,closeTime:y.closeTime,settings:y.settings,targetTime:e,targetDate:T,durationHours:1});return t||!s.isOpen}))&&(0,a.jsxs)("div",{className:"mt-2.5 p-3 rounded-2xl bg-amber-50 border border-amber-200 text-amber-900 text-xs flex items-start gap-2",children:[(0,a.jsx)("span",{className:"text-base leading-none",children:"⚠️"}),(0,a.jsx)("span",{children:(null==k?void 0:k.isOpen)===!1?"کافه \xab".concat(y.name,"\xbb در روز ").concat(null==(t=c[d])?void 0:t.label," تعطیل است. لطفاً روز دیگری را انتخاب کنید."):"در روز ".concat(null==(s=c[d])?void 0:s.label," هیچ ساعت بازی فعالی برای کافه \xab").concat(y.name,"\xbb در دسترس نیست. لطفاً روز دیگری را انتخاب کنید.")})]})]})]})}var $=s(44846),Y=s(39068),V=s(56154);function J(){let{neededPlayers:e,setNeededPlayers:t,isPublic:s,setIsPublic:r,isInstantJoin:l,setIsInstantJoin:n,description:i,setDescription:o}=D();return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(U.J,{className:"text-xs font-bold text-slate-800 block",children:"\uD83D\uDC65 چند نفر هم‌بازی نیاز داری؟ (غیر از خودت)"}),(0,a.jsxs)("span",{className:"text-[11px] text-slate-500 mt-0.5 block",children:["ظرفیت کل میز:"," ",(0,a.jsxs)("span",{className:"font-bold text-emerald-700",children:[e+1," نفر"]})," (شما + ",e," هم‌بازی)"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 bg-white px-2 py-1 rounded-xl border border-slate-200 shadow-sm",children:[(0,a.jsx)("button",{type:"button",onClick:()=>t(e=>Math.min(10,e+1)),className:"w-8 h-8 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-700 font-black text-base flex items-center justify-center transition-colors disabled:opacity-40",disabled:e>=10,title:"افزایش هم‌بازی",children:"+"}),(0,a.jsx)("span",{className:"w-8 text-center font-bold text-base text-emerald-700 font-mono",children:e}),(0,a.jsx)("button",{type:"button",onClick:()=>t(e=>Math.max(1,e-1)),className:"w-8 h-8 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-700 font-black text-base flex items-center justify-center transition-colors disabled:opacity-40",disabled:e<=1,title:"کاهش هم‌بازی",children:"-"})]})]})}),(0,a.jsxs)("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-4 space-y-2",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 flex-1",children:[s?(0,a.jsx)(Y.A,{className:"w-5 h-5 text-emerald-600 shrink-0"}):(0,a.jsx)(m.A,{className:"w-5 h-5 text-amber-600 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)(U.J,{className:"text-xs font-bold text-slate-800 block",children:s?"میز عمومی (نمایش برای همه کاربران)":"میز خصوصی (فقط با لینک اختصاصی)"}),(0,a.jsx)("span",{className:"text-[10px] text-slate-500 block leading-tight",children:s?"تمام بازیکنان پلیمو می‌توانند میز شما را در لیست ببینند و ملحق شوند.":"فقط افرادی که لینک میز را دارند امکان مشاهده و عضویت دارند."})]})]}),(0,a.jsx)($.d,{checked:s,onCheckedChange:r,className:"data-[state=checked]:bg-emerald-600 shrink-0"})]}),!s&&(0,a.jsxs)("div",{className:"pt-2 border-t border-slate-200/80 text-[10px] text-amber-700 bg-amber-50/70 p-2 rounded-xl flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"\uD83D\uDD17"}),(0,a.jsx)("span",{children:"پس از ثبت میز، لینک اختصاصی دعوت جهت ارسال به دوستان در اختیارتان قرار می‌گیرد."})]})]}),s&&(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 bg-slate-50 border border-slate-200 rounded-2xl p-4 transition-all duration-200",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[(0,a.jsx)(V.A,{className:"w-5 h-5 shrink-0 ".concat(l?"text-amber-500 fill-amber-500":"text-slate-400")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)(U.J,{className:"text-xs font-bold text-slate-800 block",children:l?"⚡ پذیرش فوری هم‌بازی‌ها (پیشنهادی)":"پذیرش با تایید دستی پلی‌مستر"}),(0,a.jsx)("span",{className:"text-[10px] text-slate-500 block leading-tight mt-0.5",children:l?"هم‌بازی‌ها بدون معطلی و بدون نیاز به تایید شما به میز بازی ملحق می‌شوند.":"درخواست هر هم‌بازی ابتدا برای شما ارسال می‌شود و پس از تایید شما نهایی خواهد شد."})]})]}),(0,a.jsx)($.d,{checked:l,onCheckedChange:n,className:"data-[state=checked]:bg-amber-500 shrink-0","aria-label":"پذیرش فوری هم‌بازی‌ها"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(U.J,{className:"text-xs font-medium text-slate-600 mb-1.5 block",children:"یادداشت یا توضیحات برای هم‌بازی‌ها (اختیاری):"}),(0,a.jsx)(H.p,{placeholder:"مثال: بازی رو آموزش میدم، لطفاً سر وقت بیاید...",value:i,onChange:e=>o(e.target.value),maxLength:150,className:"bg-slate-50 border-slate-200 text-xs text-slate-900 rounded-xl focus:border-emerald-500 focus:bg-white"})]})]})}var W=s(15239),B=s(21873),Z=s(51950);function X(){var e;let{setStep:t,initialCafeId:s,cafeScopeName:r,selectedCafe:l,setSelectedCafe:n,cafes:o,selectedCafeCity:c,setSelectedCafeCity:d,profileCity:x,isLoadingCafes:m,cafesError:u,loadCafes:p,selectedGame:h,selectedGenreName:b,dayOptions:g,selectedDayIndex:j,selectedTime:v,neededPlayers:N,quickChangeHourAndReload:y,isPublic:w}=D();return(0,a.jsxs)("div",{className:"space-y-3.5 w-full box-border",children:[s?(0,a.jsxs)("div",{className:"flex items-center justify-between bg-emerald-50/80 border border-emerald-200 rounded-2xl p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-base",children:"\uD83D\uDD12"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-emerald-600 font-semibold block",children:"مکان برگزاری (قفل‌شده روی کافه انتخابی):"}),(0,a.jsx)("span",{className:"text-xs font-bold text-emerald-900",children:(null==l?void 0:l.name)||r})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(null==l?void 0:l.openTime)&&(null==l?void 0:l.closeTime)&&(0,a.jsxs)("span",{className:"text-[10px] bg-emerald-100/90 text-emerald-800 border border-emerald-300/50 px-2 py-0.5 rounded-lg font-bold",children:["\uD83D\uDD52 ",l.openTime," الی ",l.closeTime]}),(0,a.jsx)(S.E,{className:"bg-emerald-600 text-white border-0 text-[10px] px-2.5 py-1 rounded-xl font-bold",children:"کافه انتخاب‌شده"})]})]}):(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2 bg-emerald-50/60 border border-emerald-100 rounded-2xl p-2.5 w-full box-border",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-bold text-slate-800 min-w-0",children:[(0,a.jsx)(B.A,{className:"w-3.5 h-3.5 text-emerald-600 shrink-0"}),(0,a.jsxs)("span",{className:"truncate",children:["کافه‌های شهر ",(0,a.jsx)("span",{className:"text-emerald-700 font-black",children:c}),":"]})]}),(0,a.jsxs)("select",{value:c,onChange:e=>d(e.target.value),className:"text-[11px] font-semibold bg-white border border-emerald-200 text-emerald-900 rounded-xl px-2.5 py-1 focus:outline-none focus:ring-1 focus:ring-emerald-500 cursor-pointer shadow-sm shrink-0",children:[(0,a.jsxs)("option",{value:x,children:["شهر من (",x,")"]}),f.filter(e=>e!==x).map(e=>(0,a.jsx)("option",{value:e,children:e},e)),(0,a.jsx)("option",{value:"همه",children:"همه شهرها"})]})]}),m&&!l?(0,a.jsx)("div",{className:"space-y-2 py-2 w-full box-border",children:Array.from({length:3}).map((e,t)=>(0,a.jsx)("div",{className:"h-16 bg-slate-100 rounded-2xl animate-pulse w-full"},t))}):u&&!l?(0,a.jsxs)("div",{className:"p-4 bg-rose-50 border border-rose-200 rounded-2xl text-center space-y-2 w-full box-border",children:[(0,a.jsx)("p",{className:"text-xs text-rose-700",children:u}),(0,a.jsxs)(i.$,{size:"sm",variant:"outline",onClick:()=>p(h,b,c),className:"text-xs border-rose-300 text-rose-700 hover:bg-rose-100",children:[(0,a.jsx)(P.A,{className:"w-3.5 h-3.5 ml-1.5"})," تلاش مجدد"]})]}):0!==o.length||l?(0,a.jsx)("div",{className:"space-y-2.5 max-h-[260px] overflow-y-auto px-1 py-1 w-full box-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(s&&l?[l]:o).map(e=>{let t=(null==l?void 0:l.id)===e.id,r=0===e.hourlyRate||e.isFree;return(0,a.jsxs)("div",{onClick:()=>!s&&n(e),className:"rounded-2xl border p-2.5 sm:p-3 transition-all flex flex-col gap-2 w-full box-border ".concat(s?"bg-emerald-50/80 border-emerald-500 ring-2 ring-emerald-500/20 text-emerald-950 shadow-sm cursor-default":t?"bg-emerald-50/80 border-emerald-500 ring-2 ring-emerald-500/20 text-emerald-950 shadow-sm cursor-pointer":"bg-slate-50/70 hover:bg-emerald-50/30 border-slate-200 hover:border-emerald-200 cursor-pointer"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-white border border-slate-200 flex items-center justify-center text-lg shrink-0 overflow-hidden relative shadow-sm",children:e.logo?(0,a.jsx)(W.default,{src:e.logo,alt:e.name,fill:!0,className:"object-cover",sizes:"40px"}):"☕"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,a.jsx)("h4",{className:"font-bold text-xs text-slate-900 truncate",children:e.name}),e.city&&(0,a.jsx)("span",{className:"text-[9px] bg-slate-200 text-slate-700 px-1.5 py-0.2 rounded shrink-0",children:e.city}),e.openTime&&e.closeTime&&(0,a.jsxs)("span",{className:"text-[9px] bg-slate-100 text-slate-600 px-1.5 py-0.5 rounded-md shrink-0 flex items-center gap-0.5 border border-slate-200",children:["\uD83D\uDD52 ",e.openTime," الی ",e.closeTime]})]}),(0,a.jsx)("p",{className:"text-[10px] sm:text-[11px] text-slate-400 truncate mt-0.5",children:e.address||"آدرس ثبت نشده"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[r?(0,a.jsx)("span",{className:"bg-emerald-50 text-emerald-700 border border-emerald-200 text-[10px] font-bold px-2 py-0.5 rounded-lg whitespace-nowrap",children:"\uD83D\uDFE2 رایگان"}):e.hasDiscount?(0,a.jsxs)("div",{className:"flex flex-col items-end",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"line-through text-slate-400 text-[10px]",children:(0,Z.$g)(e.hourlyRate)}),(0,a.jsxs)("span",{className:"bg-emerald-50 text-emerald-800 border border-emerald-300 text-[10px] font-black px-1.5 py-0.5 rounded-lg whitespace-nowrap",children:["\uD83D\uDD25 ",(0,Z.$g)(e.effectiveRate||e.hourlyRate)," ت"]})]}),(0,a.jsxs)("span",{className:"text-[9px] text-emerald-600 font-bold mt-0.5",children:[e.discountPercent,"٪ تخفیف"]})]}):(0,a.jsxs)("span",{className:"bg-purple-50 text-purple-700 border border-purple-200 text-[10px] font-bold px-2 py-0.5 rounded-lg whitespace-nowrap",children:["\uD83D\uDCB0 ",(0,Z.$g)(e.hourlyRate)," ت/ساعت"]}),(0,a.jsx)("div",{className:"w-5 h-5 rounded-full border flex items-center justify-center shrink-0 transition-all ".concat(t||s?"bg-emerald-600 border-emerald-600 text-white":"border-slate-300 text-transparent"),children:(0,a.jsx)(_.A,{className:"w-3 h-3"})})]})]}),!r&&!e.hasDiscount&&e.alternativeDiscountSlot&&(0,a.jsxs)("div",{className:"p-2 rounded-xl bg-amber-50/90 border border-amber-200/90 text-[11px] flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{className:"text-amber-900 font-medium leading-relaxed",children:["\uD83D\uDCA1 این کافه در ساعت ",(0,a.jsx)("strong",{className:"font-bold",children:e.alternativeDiscountSlot.hour})," دارای"," ",(0,a.jsxs)("strong",{className:"text-emerald-700 font-bold",children:[e.alternativeDiscountSlot.discountPercent,"٪ تخفیف"]})," است!"]}),(0,a.jsxs)(i.$,{type:"button",size:"sm",onClick:t=>{t.stopPropagation(),y(e.alternativeDiscountSlot.hour)},className:"h-6 px-2.5 text-[10px] bg-amber-600 hover:bg-amber-700 text-white rounded-lg font-bold shrink-0 shadow-sm",children:["تغییر به ",e.alternativeDiscountSlot.hour]})]})]},e.id)})}):(0,a.jsxs)("div",{className:"p-5 bg-amber-50/70 border border-amber-200 rounded-2xl text-center space-y-3 w-full box-border",children:[(0,a.jsx)("div",{className:"w-10 h-10 mx-auto rounded-full bg-amber-100 flex items-center justify-center text-xl",children:"\uD83C\uDFB2"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-bold text-amber-900 leading-relaxed",children:h?"متأسفانه در ساعت ".concat(v," کافه بازی برای \xab").concat(h.title,"\xbb در شهر \xab").concat(c,"\xbb یافت نشد."):b&&"همه بازی‌ها"!==b&&"آزاد"!==b?"متأسفانه در ساعت ".concat(v," کافه بازی برای ژانر \xab").concat(b,"\xbb در شهر \xab").concat(c,"\xbb یافت نشد."):"کافه بازی در ساعت ".concat(v," در شهر \xab").concat(c,"\xbb یافت نشد.")}),(0,a.jsx)("p",{className:"text-[11px] text-amber-700 mt-1",children:"می‌توانید ساعت یا تاریخ بازی را تغییر دهید، یا شهر دیگری را انتخاب کنید."})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center flex-wrap gap-2 pt-1",children:[(0,a.jsx)(i.$,{type:"button",size:"sm",variant:"outline",onClick:()=>t(3),className:"text-xs border-amber-300 text-amber-900 hover:bg-amber-100 rounded-xl h-8 px-3 font-bold",children:"⏰ تغییر ساعت یا روز"}),(0,a.jsxs)(i.$,{type:"button",size:"sm",variant:"outline",onClick:()=>t(h?2:1),className:"text-xs border-amber-300 text-amber-900 hover:bg-amber-100 rounded-xl h-8 px-3 font-bold",children:["\uD83D\uDD04 تغییر ",h?"بازی":"ژانر"]}),(0,a.jsx)(i.$,{type:"button",size:"sm",variant:"outline",onClick:()=>d("همه"),className:"text-xs border-amber-300 text-amber-900 hover:bg-amber-100 rounded-xl h-8 px-3 font-bold",children:"\uD83C\uDF0D همه شهرها"})]})]}),l&&(0,a.jsxs)("div",{className:"bg-emerald-50/70 border border-emerald-200 rounded-2xl p-3 space-y-2 text-xs w-full box-border",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-slate-700",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"text-slate-400 text-[10px] block",children:"بازی:"}),(0,a.jsx)("span",{className:"font-bold text-slate-900 truncate block",children:h?h.title:"ژانر ".concat(b)})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"text-slate-400 text-[10px] block",children:"زمان:"}),(0,a.jsxs)("span",{className:"font-bold text-slate-900 truncate block",children:[null==(e=g[j])?void 0:e.label," - ساعت ",v]})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"text-slate-400 text-[10px] block",children:"کافه:"}),(0,a.jsx)("span",{className:"font-bold text-slate-900 truncate block",children:l.name})]}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"text-slate-400 text-[10px] block",children:"ظرفیت:"}),(0,a.jsxs)("span",{className:"font-bold text-slate-900 truncate block",children:[N+1," نفر (",N," هم‌بازی)"]})]}),(0,a.jsxs)("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[(0,a.jsx)("span",{className:"text-slate-400 text-[10px] block",children:"حریم خصوصی:"}),(0,a.jsx)("span",{className:"font-bold truncate block ".concat(w?"text-purple-700":"text-amber-700"),children:w?"\uD83C\uDF10 عمومی (نمایش برای همه)":"\uD83D\uDD12 خصوصی (فقط با لینک دعوت)"})]})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-emerald-200/60 flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-slate-600 font-medium",children:"هزینه رزرو کافه (ساعت اول):"}),(0,a.jsx)("span",{className:"font-black text-sm",children:0===l.hourlyRate||l.isFree?(0,a.jsx)("span",{className:"text-emerald-700",children:"رایگان"}):l.hasDiscount?(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"line-through text-slate-400 text-xs",children:(0,Z.$g)(l.hourlyRate)}),(0,a.jsxs)("span",{className:"text-emerald-700 font-bold",children:[(0,Z.$g)(l.effectiveRate||l.hourlyRate)," تومان"]}),(0,a.jsxs)("span",{className:"text-[10px] bg-emerald-100 text-emerald-800 font-bold px-1.5 py-0.5 rounded-md",children:["(",l.discountPercent,"٪ تخفیف)"]})]}):(0,a.jsxs)("span",{className:"text-emerald-700 font-bold",children:[(0,Z.$g)(l.hourlyRate)," تومان"]})})]})]})]})}var Q=s(75426),q=s(17181),K=s(18085);function ee(){let{createdTable:e,onOpenChange:t}=D(),[s,l]=(0,r.useState)(!1);if(!e)return null;let{id:n,isPublic:o,gameTitle:c,cafeName:d,shareUrl:x,timeLabel:u}=e,p=o?"\uD83C\uDFB2 دعوت به میز بازی ".concat(c||"بردگیم").concat(d?" در ".concat(d):"").concat(u?" (".concat(u,")"):"","\nبرای همبازی شدن و پیوستن به این میز، روی لینک زیر کلیک کنید:\n").concat(x):"\uD83D\uDD12 دعوت اختصاصی به میز خصوصی بازی ".concat(c||"بردگیم").concat(d?" در ".concat(d):"").concat(u?" (".concat(u,")"):"","\n(این میز خصوصی است و فقط با لینک زیر قابل دسترسی است):\n").concat(x),h=async()=>{try{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(x),l(!0),y.o.success(o?"لینک میز بازی کپی شد! \uD83D\uDCCB":"لینک اختصاصی میز با موفقیت کپی شد! \uD83D\uDCCB"),setTimeout(()=>l(!1),3e3))}catch(e){y.o.error("خطا در کپی لینک")}},b=async()=>{if("undefined"!=typeof navigator&&"function"==typeof navigator.share)try{await navigator.share({title:"میز بازی ".concat(c||"پلیمو"),text:p,url:x}),y.o.success("لینک میز با موفقیت به اشتراک گذاشته شد");return}catch(e){if((null==e?void 0:e.name)==="AbortError")return}await h()},g="https://t.me/share/url?url=".concat(encodeURIComponent(x),"&text=").concat(encodeURIComponent(p)),f="https://api.whatsapp.com/send?text=".concat(encodeURIComponent(p)),j="bale://send?text=".concat(encodeURIComponent(p));return(0,a.jsxs)("div",{className:"space-y-4 py-1 text-slate-800",dir:"rtl",children:[(0,a.jsxs)("div",{className:"p-4 rounded-2xl border text-center space-y-2 ".concat(o?"bg-gradient-to-b from-purple-50/80 to-indigo-50/50 border-purple-200":"bg-gradient-to-b from-amber-50/90 to-orange-50/40 border-amber-200"),children:[(0,a.jsx)("div",{className:"w-14 h-14 mx-auto rounded-2xl flex items-center justify-center text-2xl shadow-sm ".concat(o?"bg-purple-600 text-white shadow-purple-600/30":"bg-amber-500 text-white shadow-amber-500/30"),children:o?"\uD83C\uDF89":"\uD83D\uDD12"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-base font-black text-slate-900",children:o?"میز بازی با موفقیت منتشر شد!":"میز خصوصی شما با موفقیت ایجاد شد!"}),(0,a.jsx)("p",{className:"text-xs text-slate-600 mt-1 max-w-sm mx-auto leading-relaxed",children:o?"میز شما در لیست عمومی رویدادها قرار گرفت. همچنین می‌توانید لینک آن را مستقیماً برای دوستان بفرستید.":"این میز در لیست عمومی نمایش داده نمی‌شود. برای تکمیل ظرفیت، لینک اختصاصی زیر را برای دوستان خود بفرستید تا بتوانند مستقیماً وارد میز شوند:"})]})]}),(0,a.jsxs)("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-3 grid grid-cols-2 gap-2 text-xs",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-slate-400 block",children:"عنوان بازی:"}),(0,a.jsx)("span",{className:"font-bold text-slate-900 truncate block",children:c||"بازی رومیزی"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-slate-400 block",children:"کافه‌گیم:"}),(0,a.jsx)("span",{className:"font-bold text-slate-900 truncate block",children:d||"کافه بازی"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-slate-400 block",children:"وضعیت نمایش:"}),(0,a.jsxs)("span",{className:"font-bold inline-flex items-center gap-1 ".concat(o?"text-purple-700":"text-amber-700"),children:[o?(0,a.jsx)(Y.A,{className:"w-3.5 h-3.5"}):(0,a.jsx)(m.A,{className:"w-3.5 h-3.5"}),o?"عمومی (نمایش در لیست)":"خصوصی (فقط با لینک)"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-[10px] text-slate-400 block",children:"زمان برگزاری:"}),(0,a.jsx)("span",{className:"font-bold text-slate-900 truncate block",children:u||"تعیین‌شده"})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-xs font-bold text-slate-700 block",children:"\uD83D\uDD17 لینک اختصاصی میز بازی:"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)("input",{type:"text",readOnly:!0,value:x,onClick:e=>e.target.select(),className:"w-full bg-slate-50 border border-slate-300 text-slate-900 font-mono text-xs rounded-xl px-3 py-2.5 focus:outline-none focus:ring-2 focus:ring-purple-500 shadow-inner text-left",dir:"ltr"})}),(0,a.jsx)(i.$,{type:"button",onClick:h,className:"h-10 px-4 rounded-xl font-bold text-xs shrink-0 flex items-center gap-1.5 transition-all shadow-sm ".concat(s?"bg-emerald-600 hover:bg-emerald-700 text-white":"bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white"),children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(_.A,{className:"w-4 h-4 text-white"}),"کپی شد!"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Q.A,{className:"w-4 h-4"}),"کپی لینک"]})})]})]}),(0,a.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold text-slate-500 block",children:"اشتراک‌گذاری مستقیم در پیام‌رسان‌ها:"}),(0,a.jsxs)("div",{className:"grid grid-cols-4 gap-2",children:[(0,a.jsxs)(i.$,{type:"button",variant:"outline",size:"sm",onClick:b,className:"h-9 rounded-xl text-xs font-bold border-slate-200 hover:bg-slate-100 flex items-center justify-center gap-1 text-slate-800",children:[(0,a.jsx)(q.A,{className:"w-3.5 h-3.5 text-purple-600"}),"سیستم"]}),(0,a.jsxs)("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"h-9 rounded-xl text-xs font-bold border border-slate-200 hover:bg-blue-50 text-blue-700 bg-white flex items-center justify-center gap-1 shadow-xs transition-colors",children:[(0,a.jsx)(K.A,{className:"w-3.5 h-3.5"}),"تلگرام"]}),(0,a.jsxs)("a",{href:j,target:"_blank",rel:"noopener noreferrer",className:"h-9 rounded-xl text-xs font-bold border border-slate-200 hover:bg-emerald-50 text-emerald-700 bg-white flex items-center justify-center gap-1 shadow-xs transition-colors",children:[(0,a.jsx)("span",{children:"\uD83D\uDCAC"}),"بله"]}),(0,a.jsxs)("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"h-9 rounded-xl text-xs font-bold border border-slate-200 hover:bg-green-50 text-green-700 bg-white flex items-center justify-center gap-1 shadow-xs transition-colors",children:[(0,a.jsx)("span",{children:"\uD83D\uDCF1"}),"واتساپ"]})]})]})]})}function et(){var e;let t=(0,l.useRouter)(),{step:s,setStep:r,onOpenChange:u,selectedGame:p,isContinuingWithGenre:h,selectedTime:b,activeTableDates:g,dayOptions:f,selectedDayIndex:j,isSubmitting:v,selectedCafe:N,handleSubmit:y,selectedGenreId:w,handleSelectGenre:T,handleContinueWithGenre:k,initialCafeId:S,isPublic:A,createdTable:R}=D();return R?(0,a.jsxs)(n.Cf,{className:"w-[calc(100vw-2rem)] sm:w-full sm:max-w-lg max-h-[88vh] flex flex-col bg-white/95 backdrop-blur-xl border border-slate-100/90 text-slate-900 rounded-3xl shadow-2xl p-0 gap-0 overflow-hidden box-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",dir:"rtl",showCloseButton:!0,children:[(0,a.jsx)("div",{className:"p-4 sm:p-5 pb-3 border-b border-slate-100 bg-gradient-to-b from-purple-50/50 via-white to-white shrink-0 w-full box-border",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"w-9 h-9 sm:w-10 sm:h-10 rounded-2xl text-white flex items-center justify-center text-lg sm:text-xl shadow-md shrink-0 ".concat(R.isPublic?"bg-purple-600 shadow-purple-600/20":"bg-amber-500 shadow-amber-500/20"),children:R.isPublic?"\uD83D\uDC51":"\uD83D\uDD12"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)(n.L3,{className:"text-sm sm:text-base font-black text-slate-900 truncate",children:R.isPublic?"میز بازی با موفقیت منتشر شد":"میز خصوصی شما با موفقیت ایجاد شد"}),(0,a.jsx)(n.rr,{className:"text-[11px] sm:text-xs font-bold text-purple-600 mt-0.5 truncate",children:R.isPublic?"لینک میز بازی آماده ارسال به دوستان است":"لینک اختصاصی میز خصوصی جهت ارسال به دوستان آماده است"})]})]})}),(0,a.jsx)("div",{className:"p-4 sm:p-5 overflow-y-auto flex-1 w-full box-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,a.jsx)(ee,{})}),(0,a.jsxs)("div",{className:"p-4 border-t border-slate-100 bg-slate-50/90 backdrop-blur-sm flex items-center justify-between shrink-0",children:[(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>{u(!1),t.push("/events/".concat(R.id))},className:"text-xs text-slate-500 hover:text-slate-800 rounded-xl",children:"بستن"}),(0,a.jsxs)(i.$,{size:"sm",onClick:()=>{u(!1),t.push("/events/".concat(R.id))},className:"bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-bold text-xs px-5 py-2.5 rounded-xl shadow-md shadow-purple-600/20 flex items-center gap-1.5 active:scale-95 transition-transform",children:[(0,a.jsx)("span",{children:"مشاهده صفحه میز بازی"}),(0,a.jsx)(o.A,{className:"w-4 h-4"})]})]})]}):(0,a.jsxs)(n.Cf,{className:"w-[calc(100vw-2rem)] sm:w-full sm:max-w-lg max-h-[88vh] flex flex-col bg-white/95 backdrop-blur-xl border border-slate-100/90 text-slate-900 rounded-3xl shadow-2xl p-0 gap-0 overflow-hidden box-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",dir:"rtl",showCloseButton:!0,children:[(0,a.jsxs)("div",{className:"p-4 sm:p-5 pb-3 border-b border-slate-100 bg-gradient-to-b from-purple-50/50 via-white to-white shrink-0 w-full box-border",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-2.5",children:[(0,a.jsx)("div",{className:"w-9 h-9 sm:w-10 sm:h-10 rounded-2xl bg-purple-600 text-white flex items-center justify-center text-lg sm:text-xl shadow-md shadow-purple-600/20 shrink-0",children:"\uD83D\uDC51"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)(n.L3,{className:"text-sm sm:text-base font-black text-slate-900 truncate",children:"ایجاد میز بازی جدید"}),(0,a.jsxs)(n.rr,{className:"text-[11px] sm:text-xs font-bold text-purple-600 mt-0.5 truncate",children:[1===s&&"انتخاب ژانر یا سبک بازی",2===s&&"انتخاب عنوان بازی یا کل ژانر",3===s&&"تعیین روز و ساعت شروع بازی",4===s&&"تعداد هم‌بازی و حریم خصوصی میز",5===s&&"انتخاب کافه‌گیم و انتشار نهایی"]})]})]}),(0,a.jsx)(C,{})]}),(0,a.jsxs)("div",{className:"p-4 sm:p-5 overflow-y-auto flex-1 w-full box-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[1===s&&(0,a.jsx)(O,{}),2===s&&(0,a.jsx)(M,{}),3===s&&(0,a.jsx)(G,{}),4===s&&(0,a.jsx)(J,{}),5===s&&(0,a.jsx)(X,{})]}),(0,a.jsxs)("div",{className:"p-4 border-t border-slate-100 bg-slate-50/90 backdrop-blur-sm flex items-center justify-between shrink-0",children:[s>1?(0,a.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:()=>r(s-1),className:"text-xs text-slate-600 hover:text-slate-900 rounded-xl flex items-center gap-1",children:[(0,a.jsx)(c.A,{className:"w-4 h-4"}),"مرحله قبل"]}):(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"text-xs text-slate-500 hover:text-slate-800 rounded-xl",children:"انصراف"}),s<5?(0,a.jsxs)(i.$,{size:"sm",disabled:3===s&&(!b||g.has(null==(e=f[j])?void 0:e.dateStr)),onClick:()=>{1===s?T("ALL",S?"همه بازی‌های این کافه":"آزاد"):2===s?k():r(s+1)},className:"bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-bold text-xs px-5 py-2 rounded-xl shadow-md shadow-purple-600/20 flex items-center gap-1.5 disabled:opacity-50",children:[1===s?"ادامه بدون ژانر":2===s?"ادامه بدون بازی":"ادامه",(0,a.jsx)(o.A,{className:"w-4 h-4"})]}):(0,a.jsx)(i.$,{size:"sm",disabled:v||!N,onClick:y,className:"bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-black text-xs px-6 py-2.5 rounded-xl shadow-lg shadow-purple-600/30 flex items-center gap-2 disabled:opacity-50 active:scale-95 transition-transform",children:v?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.A,{className:"w-4 h-4 animate-spin"}),"در حال ثبت میز..."]}):(null==N?void 0:N.hourlyRate)===0||(null==N?void 0:N.isFree)?A?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"w-4 h-4"}),"\uD83D\uDE80 ثبت و انتشار عمومی میز"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{className:"w-4 h-4"}),"\uD83D\uDD12 ثبت میز بازی خصوصی"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{children:"\uD83D\uDCB3"}),"تایید و پرداخت رزرو کافه"]})})]})]})}function es(e){return(0,a.jsx)(n.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,a.jsx)(k,{...e,children:(0,a.jsx)(et,{})})})}}}]);