PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/residences/[id]-e60f838f2af02953.js

js lidomatrip.com collected 2026-10-02 20:26:08 UTC 148,740 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9157],{35105:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/residences/[id]",function(){return t(97868)}])},94267:function(e,a,t){"use strict";t.d(a,{Z:function(){return r}});var l=t(85893),s=t(67294),n=t(33496);function r(e){var a,t;let{residence:r}=e,i=r.rooms.filter(e=>"فضای مشترک"!==e.name),d="BOOMGARDI"===r.type||"HOTEL"===r.type,[c,o]=(0,s.useState)(d?null===(a=i[0])||void 0===a?void 0:a.id:void 0);if(d&&0===i.length)return(0,l.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D py-24 text-center",children:"این اقامتگاه هنوز اتاقی ندارد."});let x=d?{residenceId:r.id,roomId:c,label:(null===(t=i.find(e=>e.id===c))||void 0===t?void 0:t.name)??r.name}:{residenceId:r.id,label:r.name};return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[d&&i.length>1&&(0,l.jsx)("div",{className:"flex items-center gap-x-8 overflow-x-auto pb-4",children:i.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>o(e.id),className:`shrink-0 px-16 py-8 rounded-8 text-12 leading-21 font-m whitespace-nowrap transition ${c===e.id?"bg-primary-light text-primary-dark":"bg-gray-F5F5F7 text-black hover:bg-gray-F0F0F0"}`,children:e.name},e.id))}),(0,l.jsx)(n.Z,{targets:[x]})]})}},38436:function(e,a,t){"use strict";t.d(a,{Z:function(){return o}});var l=t(85893),s=t(67294),n=t(84858),r=t(32474);let i={DEACTIVATED:{tone:"bg-[#FEF2F2] border-[#FECACA]",lines:["از نتایج جستجو، صفحه‌های شهر و \xabاقامتگاه‌های مشابه\xbb حذف می‌شود.","صفحه‌ی اقامتگاه باز می‌ماند و همه‌ی اطلاعات، تصاویر و نظرات دیده می‌شوند.","باکس رزرو بسته می‌شود و روی صفحه نوشته می‌شود که فعلاً پذیرای مهمان نیست.","رزروهای ثبت‌شده‌ی قبلی دست نمی‌خورند."]},PUBLISHED:{tone:"bg-[#F0FDF4] border-[#BBF7D0]",lines:["اقامتگاه به نتایج جستجو برمی‌گردد.","باکس رزرو دوباره باز می‌شود.","توضیح غیرفعال‌سازی قبلی پاک می‌شود (در تاریخچه می‌ماند)."]},REJECTED:{tone:"bg-[#FEF2F2] border-[#FECACA]",lines:["به میزبان اطلاع داده می‌شود که آگهی رد شده است."]}},d={DRAFT:"پیش‌نویس",PENDING:"در انتظار بررسی",PUBLISHED:"منتشرشده",REJECTED:"رد شده",DEACTIVATED:"غیرفعال",DELETED:"حذف‌شده"},c={DEACTIVATED:["میزبان درخواست غیرفعال‌سازی موقت داد","اقامتگاه در دست تعمیر است","میزبان پاسخگو نیست","اطلاعات یا تصاویر آگهی با واقعیت نمی‌خواند","اختلاف مالی با میزبان"],PUBLISHED:["مشکل برطرف شد","میزبان درخواست فعال‌سازی داد","بررسی آگهی تایید شد"]};function o(e){let{open:a,onClose:t,ids:o,state:x,currentState:m,onSaved:u}
1=e,[h,p]=(0,s.useState)(""),[g,j]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null);(0,s.useEffect)(()=>{a&&(p(""),b(null),j(!1))},[a,x]);let f=o.length>1,N=i[x],v=c[x]??[];async function C(){let e=h.trim();if(!e){b("ثبت توضیحات برای تغییر وضعیت الزامی است");return}j(!0),b(null);try{f?await (0,n.SC)("/api/admin/residences/bulk/state",{method:"POST",body:JSON.stringify({ids:o,state:x,note:e})}):await (0,n.SC)(`/api/admin/residences/${o[0]}/state`,{method:"PATCH",body:JSON.stringify({state:x,note:e})}),u(),t()}catch(e){b((null==e?void 0:e.message)??"تغییر وضعیت انجام نشد")}finally{j(!1)}}return(0,l.jsxs)(r.u_,{open:a,onClose:t,title:f?`تغییر وضعیت ${(0,r.N)(o.length)} اقامتگاه`:"تغییر وضعیت اقامتگاه",width:"max-w-[520px]",children:[(0,l.jsxs)("div",{className:"mb-16 flex items-center gap-x-8 text-14 leading-24",children:[!f&&m&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"text-gray-6C6A7D",children:d[m]??m}),(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"←"})]}),(0,l.jsx)("span",{className:"font-b text-black",children:d[x]??x})]}),!!N&&(0,l.jsx)("ul",{className:`mb-16 rounded-8 border px-14 py-12 ${N.tone}`,children:N.lines.map(e=>(0,l.jsxs)("li",{className:"text-13 leading-22 text-black flex gap-x-8",children:[(0,l.jsx)("span",{className:"text-gray-9B9BAA shrink-0",children:"•"}),(0,l.jsx)("span",{children:e})]},e))}),(0,l.jsx)(r.gN,{label:"توضیحات (الزامی)",children:(0,l.jsx)("textarea",{value:h,onChange:e=>p(e.target.value),rows:3,placeholder:"چرا وضعیت این اقامتگاه عوض می‌شود؟",className:"w-full rounded-8 border border-gray-E3E3E8 px-12 py-10 text-14 leading-24 outline-none focus:border-primary resize-none"})}),!!v.length&&(0,l.jsx)("div",{className:"mt-8 flex flex-wrap gap-6",children:v.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>p(a=>a.trim()?`${a.trim()} ${e}`:e),className:"rounded-full border border-gray-E3E3E8 px-10 py-4 text-12 leading-20 text-gray-6C6A7D hover:border-primary hover:text-primary",children:e},e))}),(0,l.jsx)("p",{className:"mt-10 text-12 leading-20 text-gray-9B9BAA",children:"این توضیح در تاریخچه‌ی اقامتگاه ثبت می‌شود و برای مهمان نمایش داده نمی‌شود."}),!!y&&(0,l.jsx)("p",{className:"mt-12 text-13 leading-22 text-red-500",children:y}),(0,l.jsxs)("div",{className:"mt-20 flex items-center justify-end gap-x-10",children:[(0,l.jsx)(r.zx,{variant:"secondary",onClick:t,disabled:g,children:"انصراف"}),(0,l.jsx)(r.zx,{variant:"PUBLISHED"===x?"primary":"danger",onClick:C,disabled:g||!h.trim(),children:g?"در حال ثبت…":"ثبت تغییر وضعیت"})]})]})}},47693:function(e,a,t){"use strict";t.d(a,{Z:function(){return c}});var l=t(85893),s=t(67294),n=t(84858),r=t(32474);let i=[{key:"cleaning",label:"نظافت اقامتگاه"},{key:"location",label:"موقعیت مکانی"},{key:"quality",label:"کیفیت نسبت به نرخ"},{key:"integrity",label:"صحت اطلاعات"},{key:"greeting",label:"برخورد میزبان"},{key:"delivery",label:"نحوه تحویل"}];function d(e){let{value:a,onPick:t}=e;return(0,l.jsx)("span",{className:"inline-flex items-center gap-x-2",dir:"ltr",children:[1,2,3,4,5].map(e=>(0,l.jsx)("button",{type:"button",title:`${e} از ۵`,"aria-label":`${e} از ۵`,onClick:()=>t(e),className:"leading-none",children:(0,l.jsx)("i",{className:`icon-Star text-18 transition ${e<=a?"text-[#FFC120]":"text-gray-E5E5E6 hover:text-[#FFE2A0]"}`})},e))})}function c(e){let{open:a,onClose:t,onCreated:c,defaultResidenceId:o}=e,[x,m]=(0,s.useState)(null),[u,h]=(0,s.useState)(""),[p,g]=(0,s.useState)([]),[j,y]=(0,s.useState)(!1),[b,f]=(0,s.useState)(""),[N,v]=(0,s.useState)({cleaning:5,location:5,quality:5,integrity:5,greeting:5,delivery:5}),[C,k]=(0,s.useState)(""),[w,E]=(0,s.useState)(""),[A,S]=(0,s.useState)(!0),[D,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)("");function P(){m(null),h(""),g([]),f(""),v({cleaning:5,location:5,quality:5,integrity:5,greeting:5,delivery:5}),k(""),E(""),S(!0),I("")}let $=(0,s.useRef)(),O=(!!x||!!o)&&b.trim()&&C.trim();async function T(){B(!0),I("");try{await (0,n.SC)("/api/admin/reviews/manual",{method:"POST",body:JSON.stringify({residenceId:o??x.id,guestDisplayName:b.trim(),comment:C.trim(),hostAnswer:w.trim()||void 0,publish:A,...N})}),P(),c(),t()}catch(e){I(e instanceof Error?e.message:"ثبت نظر انجام نشد")}finally{B(!1)}}return(0,l.jsx)(r.u_,{open:a,onClose:()=>{P(),t()},title:"ثبت نظر دستی",width:"max-w-[560px]",children:(0,l.jsxs)("div",{className:"flex flex-col gap-y-14",children:[!
1o&&(0,l.jsx)(r.gN,{label:"اقامتگاه",children:x?(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-8 px-14 py-10 rounded-10 border border-gray-E5E5E6 bg-gray-F9F9FB",children:[(0,l.jsxs)("span",{className:"text-13 text-black",children:[x.name,!!x.reference&&(0,l.jsxs)("span",{className:"text-gray-9B9BAA",children:[" \xb7 ",x.reference]})]}),(0,l.jsx)("button",{type:"button",className:"text-12 text-primary-dark",onClick:()=>m(null),children:"تغییر"})]}):(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)(r.II,{value:u,onChange:e=>(function(e){if(h(e),clearTimeout($.current),e.trim().length<2){g([]);return}$.current=setTimeout(async()=>{y(!0);try{let a=await (0,n.Px)(`/api/admin/residences?q=${encodeURIComponent(e.trim())}&pageSize=8`);g(a.items)}catch{g([])}finally{y(!1)}},300)})(e.target.value),placeholder:"نام یا کد اقامتگاه…"}),(j||p.length>0)&&u.trim().length>=2&&(0,l.jsx)("div",{className:"absolute z-10 mt-4 w-full bg-white border border-gray-E5E5E6 rounded-10 shadow-lg max-h-[220px] overflow-y-auto",children:j?(0,l.jsx)("p",{className:"px-14 py-10 text-12 text-gray-9B9BAA",children:"در حال جست‌وجو…"}):0===p.length?(0,l.jsx)("p",{className:"px-14 py-10 text-12 text-gray-9B9BAA",children:"نتیجه‌ای پیدا نشد"}):p.map(e=>(0,l.jsxs)("button",{type:"button",className:"block w-full text-right px-14 py-10 text-13 hover:bg-gray-F9F9FB",onClick:()=>{m(e),g([]),h("")},children:[e.name,!!e.reference&&(0,l.jsxs)("span",{className:"text-gray-9B9BAA",children:[" \xb7 ",e.reference]})]},e.id))})]})}),(0,l.jsx)(r.gN,{label:"نام نمایشی مهمان",children:(0,l.jsx)(r.II,{value:b,onChange:e=>f(e.target.value),placeholder:"مثلاً: علی رضایی",maxLength:60})}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-20 gap-y-10",children:i.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-8",children:[(0,l.jsx)("span",{className:"text-12 text-gray-6C6A7D",children:e.label}),(0,l.jsx)(d,{value:N[e.key],onPick:a=>v(t=>({...t,[e.key]:a}))})]},e.key))}),(0,l.jsx)(r.gN,{label:"متن نظر",children:(0,l.jsx)("textarea",{value:C,onChange:e=>k(e.target.value),rows:4,className:"w-full rounded-10 border border-gray-E5E5E6 px-14 py-12 text-13 leading-24 outline-none focus:border-primary-main resize-y"})}),(0,l.jsx)(r.gN,{label:"پاسخ میزبان (اختیاری)",children:(0,l.jsx)("textarea",{value:w,onChange:e=>E(e.target.value),rows:3,placeholder:"اگر پر شود، همراه با خودِ نظر منتشر می‌شود.",className:"w-full rounded-10 border border-gray-E5E5E6 px-14 py-12 text-13 leading-24 outline-none focus:border-primary-main resize-y"})}),(0,l.jsx)(r.ZD,{checked:A,onChange:S,label:"بلافاصله منتشر شود"}),!!F&&(0,l.jsx)("p",{className:"text-12 text-[#C62828]",children:F}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-x-10 pt-4",children:[(0,l.jsx)(r.zx,{variant:"secondary",onClick:()=>{P(),t()},children:"انصراف"}),(0,l.jsx)(r.zx,{disabled:!O||D,onClick:T,children:"ثبت نظر"})]})]})})}},64616:function(e,a,t){"use strict";t.d(a,{Pd:function(){return l},oJ:function(){return s}});let l={none:"ندارد",dedicated:"اختصاصی",shared:"اشتراکی"},s={none:"ندارد",dedicated:"اختصاصی",shared:"اشتراکی"}},97868:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return eF}});var l=t(85893),s=t(67294),n=t(41664),r=t.n(n),i=t(11163),d=t(44389),c=t(49759),o=t(84858),x=t(32474);function m(e){let{open:a,onClose:t,residenceId:n,images:r,onChanged:i}=e,[d,c]=(0,s.useState)([]),[m,p]=(0,s.useState)(null),[g,j]=(0,s.useState)(null),[y,b]=(0,s.useState)(null),f=(0,s.useRef)(null),N=(0,s.useRef)(null);(0,s.useEffect)(()=>{a&&(c([...r].sort((e,a)=>e.sortOrder-a.sortOrder)),b(null),p(null))},[a,r]);let v=d.length===r.length&&d.some((e,a)=>{var t;return e.id!==(null===(t=[...r].sort((e,a)=>e.sortOrder-a.sortOrder)[a])||void 0===t?void 0:t.id)});function C(e,a){a<0||a>=d.length||c(t=>{let l=[...t],[s]=l.splice(e,1);return l.splice(a,0,s),l})}async function k(e,a){j(e),b(null);try{await a(),i()}catch(e){b(e instanceof Error?e.message:"انجام نشد")}finally{j(null)}}let w=e=>k(`main-${e.id}`,()=>(0,o.SC)(`/api/admin/residences/${n}/images/${e.id}`,{method:"PATCH",body:JSON.stringify({isMain:!0})})),E=e=>k(`del-${e.id}`,async()=>{await (0,o.SC)(`/api/admin/residences/${n}/images/${e.id}`,{method:"DELETE"}),c(a=>a.filter(a=>a.id!==e.id))}),A=()=>k("order",()=>(0,o.SC)(`/api/admin/residences/${n}/images/order`,{method:"POST",body:JSON.stringify({imageIds:d.map(e=>e.id)})}));async function S(e){if(null==e?void 0:e.length){j("upload"),b(null);try{for(let a of Array.from(e)){let e=new FormData;e.append("image",a);let t=await fetch(`/api/admin/residences/${n}/images`,{method:"POST",headers:{Authorization:`Bearer ${(0,o.LP)()??""}`},body:e});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error((null==e?void 0:e.message)??"بارگذاری نشد")}}i()}catch(e){b(e instanceof Error?e.message:"بارگذاری نشد")}finally{j(null),N.current&&(N.current.value="")}}}return(0,l.jsxs)(x.u_,{open:a,onClose:t,title:"تصاویر اقامتگاه",width:"max-w-[980px]",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-10 mb-14",children:[(0,l.jsxs)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:[(0,x.N)(d.length)," تصویر \xb7 برای جابه‌جایی بکشید و رها کنید، یا از فلش‌ها استفاده کنید."]}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("input",{ref:N,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>S(e.target.files)}),(0,l.jsxs)(x.zx,{variant:"secondary",disabled:"upload"===g,onClick:()=>{var e;return null===(e=N.current)||void 0===e?void 0:e.click()},children:[(0,l.jsx)("i",{className:"icon-Upload text-16"}),"upload"===g?"در حال بارگذاری...":"بارگذاری تصویر"]}),(0,l.jsx)(x.zx,{disabled:!v||"order"===g,onClick:A,children:"order"===g?"در حال ذخیره...":"ذخیره ترتیب"})]})]}),y&&(0,l.jsx)("p",{className:"mb-12 text-13 text-[#C62828]",children:y}),0===d.length?(0,l.jsx)("p",{className:"py-40 text-center text-14 text-gray-6C6A7D",children:"هنوز تصویری بارگذاری نشده."}):(0,l.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-12",children:d.map((e,a)=>(0,l.jsxs)("div",{draggable:!0,onDragStart:()=>f.current=a,onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==f.current&&C(f.current,a),f.current=null},className:`rounded-12 border overflow-hidden bg-white cursor-move transition ${e.isMain?"border-primary-main":"border-gray-E5E5E6 hover:border-gray-C4CAD3"}`,children:[(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)("img",{src:(0,x.vD)(e.url,384),alt:e.alt??"",className:"w-full h-[120px] object-cover"}),e.isMain&&(0,l.jsx)("span",{className:"absolute top-6 right-6",children:(0,l.jsx)(x.Ct,{tone:"green",children:"شاخص"})}),(0,l.jsx)("span",{className:"absolute top-6 left-6 px-6 py-2 rounded-6 bg-black/50 text-white text-10 leading-16",children:(0,x.N)(a+1)})]}),(0,l.jsxs)("div",{className:"p-8",children:[(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-6C6A7D truncate mb-2",children:e.title||(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"بدون عنوان"})}),(0,l.jsx)("p",{className:"text-10 leading-16 text-gray-9B9BAA truncate mb-8",children:e.alt?`alt: ${e.alt}`:"بدون متن جایگزین"}),(0,l.jsxs)("div",{className:"flex items-center gap-x-4",children:[(0,l.jsx)(u,{title:"جابه‌جایی به راست",onClick:()=>C(a,a-1),children:"›"}),(0,l.jsx)(u,{title:"جابه‌جایی به چپ",onClick:()=>C(a,a+1),children:"‹"}),(0,l.jsx)(u,{title:"ویرایش عنوان و متن جایگزین",onClick:()=>p(e),children:(0,l.jsx)("i",{className:"icon-Edit text-13"})}),!e.isMain&&(0,l.jsx)(u,{title:"انتخاب به‌عنوان تصویر شاخص",disabled:g===`main-${e.id}`,onClick:()=>w(e),children:(0,l.jsx)("i",{className:"icon-Star text-13"})}),(0,l.jsx)(u,{title:"حذف تصویر",danger:!0,disabled:g===`del-${e.id}`||e.isMain,onClick:()=>E(e),children:(0,l.jsx)("i",{className:"icon-Delete text-13"})})]})]})]},e.id))}),(0,l.jsx)("p",{className:"mt-12 text-11 leading-18 text-gray-9B9BAA",children:"برای حذف تصویر شاخص، اول تصویر دیگری را شاخص کنید."}),(0,l.jsx)("div",{className:"flex justify-end mt-16",children:(0,l.jsx)(x.zx,{variant:"secondary",onClick:t,children:"بستن"})}),(0,l.jsx)(h,{image:m,residenceId:n,onClose:()=>p(null),onSaved:i})]})}function u(e){let{children:a,title:t,onClick:s,disabled:n,danger:r}=e;return(0,l.jsx)("button",{type:"button",title:t,"aria-label":t,disabled:n,onClick:s,className:`w-26 h-26 rounded-8 border text-12 leading-none flex items-center justify-center transition disabled:opacity-35 ${r?"border-gray-E5E5E6 text-gray-9B9BAA hover:border-[#
1E53935] hover:text-[#E53935]":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3 hover:text-black"}`,children:a})}function h(e){let{image:a,residenceId:t,onClose:n,onSaved:r}=e,[i,d]=(0,s.useState)(""),[c,m]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null);async function j(){if(a){h(!0),g(null);try{await (0,o.SC)(`/api/admin/residences/${t}/images/${a.id}`,{method:"PATCH",body:JSON.stringify({title:i.trim()||null,alt:c.trim()||null})}),r(),n()}catch(e){g(e instanceof Error?e.message:"ذخیره نشد")}finally{h(!1)}}}return(0,s.useEffect)(()=>{a&&(d(a.title??""),m(a.alt??""),g(null))},[a]),(0,l.jsxs)(x.u_,{open:!!a,onClose:n,title:"عنوان و متن جایگزین",width:"max-w-[460px]",children:[a&&(0,l.jsx)("img",{src:(0,x.vD)(a.url,384),alt:"",className:"w-full h-[160px] object-cover rounded-12 mb-14"}),(0,l.jsxs)("label",{className:"block mb-12",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"عنوان تصویر"}),(0,l.jsx)("input",{value:i,onChange:e=>d(e.target.value),placeholder:"مثلاً: نمای حیاط",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"})]}),(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"متن جایگزین (alt)"}),(0,l.jsx)("input",{value:c,onChange:e=>m(e.target.value),placeholder:"توصیف تصویر برای موتور جستجو و صفحه‌خوان",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"}),(0,l.jsx)("span",{className:"block mt-4 text-11 leading-18 text-gray-9B9BAA",children:"چیزی که در تصویر دیده می‌شود را بنویسید، نه نام اقامتگاه."})]}),p&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:p}),(0,l.jsxs)("div",{className:"flex justify-end gap-x-8 mt-16",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:n,children:"انصراف"}),(0,l.jsx)(x.zx,{disabled:u,onClick:j,children:u?"در حال ذخیره...":"ذخیره"})]})]})}var p=t(38436),g=t(94267),j=t(5152),y=t.n(j);let b=y()(()=>Promise.all([t.e(9269),t.e(2926)]).then(t.bind(t,22926)),{loadableGenerated:{webpack:()=>[22926]},ssr:!1}),f={PROVINCE:"استان",CITY:"شهر",NEIGHBORHOOD:"محله",REGION:"منطقه",COUNTRY:"کشور",VILLAGE:"روستا"};function N(e){var a,t,n,r,i;let{residenceId:c,residence:m,onSaved:u,onEditAddress:h}=e,[p,g]=(0,s.useState)(m.latitude),[j,y]=(0,s.useState)(m.longitude),[N,C]=(0,s.useState)((null===(a=m.latitude)||void 0===a?void 0:a.toString())??""),[k,w]=(0,s.useState)((null===(t=m.longitude)||void 0===t?void 0:t.toString())??""),[E,A]=(0,s.useState)(30),[S,D]=(0,s.useState)(new Set),[B,F]=(0,s.use
1State)(null),[I,P]=(0,s.useState)(null),[$,O]=(0,s.useState)(null),[T,z]=(0,s.useState)(""),[M,R]=(0,s.useState)(""),[Z,U]=(0,s.useState)(""),[Y,H]=(0,s.useState)(m.extraLocations.map(e=>e.location)),[_,L]=(0,s.useState)(""),J=Y.length!==m.extraLocations.length||Y.some((e,a)=>{var t;return e.id!==(null===(t=m.extraLocations[a])||void 0===t?void 0:t.location.id)}),{data:G}=(0,d.u)(_.trim().length>=2?`/api/admin/locations?q=${encodeURIComponent(_.trim())}`:null,e=>(0,o.SC)(e)),q=(G??[]).filter(e=>"CITY"===e.type||"NEIGHBORHOOD"===e.type||"PROVINCE"===e.type).filter(e=>!Y.some(a=>a.id===e.id)).slice(0,12);async function V(){await et("extra",async()=>{let e=await (0,o.SC)(`/api/admin/residences/${c}/extra-cities`,{method:"PUT",body:JSON.stringify({cityIds:Y.map(e=>e.id)})});H(e.map(e=>e.location)),u()},"ذخیره شد")}let{data:X,mutate:K}=(0,d.u)(`/api/admin/residences/${c}/distances`,e=>(0,o.SC)(e)),{data:W,mutate:Q}=(0,d.u)(`/api/admin/residences/${c}/nearby-attractions?radiusKm=${E}&limit=30`,e=>(0,o.SC)(e)),ee=p!==m.latitude||j!==m.longitude,ea=(0,s.useMemo)(()=>((null==W?void 0:W.items)??[]).filter(e=>null!=e.latitude&&null!=e.longitude).map(e=>({id:e.id,name:e.name,latitude:e.latitude,longitude:e.longitude,note:e.distanceText})),[W]);async function et(e,a,t){F(e),O(null),P(null);try{await a(),P(t)}catch(e){O(e instanceof Error?e.message:"انجام نشد")}finally{F(null)}}let el=((null==W?void 0:W.items)??[]).filter(e=>null!=e.distanceKm),es=((null==W?void 0:W.items)??[]).filter(e=>null==e.distanceKm);return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8 mb-12",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"موقعیت روی نقشه"}),null!=p&&null!=j&&(0,l.jsx)("a",{href:`https://www.google.com/maps?q=${p},${j}`,target:"_blank",rel:"noreferrer",className:"text-13 text-primary-dark font-m",children:"باز کردن در گوگل مپ ↗"})]}),(0,l.jsx)(b,{lat:p,lng:j,onChange:function(e,a){g(e),y(a),C(e.toFixed(7)),w(a.toFixed(7)),P(null)},height:"h-[460px]",markers:ea}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_1fr_auto] gap-10 items-end mt-14",children:[(0,l.jsx)(x.gN,{label:"عرض جغرافیایی (Latitude)",children:(0,l.jsx)(x.II,{value:N,onChange:e=>{C(e.target.value);let a=(0,x.y1)(e.target.value);null!=a&&a>=-90&&a<=90&&g(a)},placeholder:"۳۵٫۶۸۹۲",inputMode:"decimal"})}),(0,l.jsx)(x.gN,{label:"طول جغرافیایی (Longitude)",children:(0,l.jsx)(x.II,{value:k,onChange:e=>{w(e.target.value);let a=(0,x.y1)(e.target.value);null!=a&&a>=-180&&a<=180&&y(a)},placeholder:"۵۱٫۳۸۹۰",inputMode:"decimal"})}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)(x.zx,{disabled:!ee||"coords"===B||null==p||null==j,onClick:()=>et("coords",async()=>{await (0,o.SC)(`/api/admin/residences/${c}`,{method:"PATCH",body:JSON.stringify({latitude:p,longitude:j})}),u(),Q()},"موقعیت ذخیره شد"),children:"coords"===B?"در حال ذخیره…":"ذخیره موقعیت"}),ee&&(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>{var e,a;g(m.latitude),y(m.longitude),C((null===(e=m.latitude)||void 0===e?void 0:e.toString())??""),w((null===(a=m.longitude)||void 0===a?void 0:a.toString())??"")},children:"بازگردانی"})]})]}),ee&&(0,l.jsx)("p",{className:"mt-8 text-12 leading-20 text-[#B26A00]",children:"موقعیت تغییر کرده و هنوز ذخیره نشده."}),!!I&&(0,l.jsx)("p",{className:"mt-8 text-13 leading-20 text-[#2E7D32]",children:I}),!!$&&(0,l.jsx)("p",{className:"mt-8 text-13 leading-20 text-[#C62828]",children:$}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-10 mt-16 pt-16 border-t border-gray-F0F0F0",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"استان"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black",children:(null===(n=m.location)||void 0===n?void 0:null===(r=n.parent)||void 0===r?void 0:r.name)||"—"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"شهر"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black",children:(null===(i=m.location)||void 0===i?void 0:i.name)||"—"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"محله"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black",children:m.neighborhood||"—"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"آدرس"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black break-words",children:m.address||"—"})]})]}),(0,l.jsx)("div",{className:"mt-12",children:(0,l.jsxs)(x.zx,{variant:"secondary",onClick:h,children:[(0,l.jsx)("i",{className:"icon-Edit text-16"})," ویرایش استان، شهر، محله و آدرس"]}
1)})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-4",children:"نمایش در سایر شهرها و محله‌ها"}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA mb-12",children:"علاوه بر شهر اصلی‌اش، این اقامتگاه در نتایج جست‌وجوی هر شهر یا محله‌ای که اینجا اضافه کنید هم نشان داده می‌شود — بدون اینکه موقعیت اصلی‌اش عوض شود."}),Y.length>0&&(0,l.jsx)("div",{className:"flex flex-wrap gap-8 mb-12",children:Y.map(e=>{var a;return(0,l.jsxs)("span",{className:"flex items-center gap-x-6 rounded-100 border border-gray-E5E5E6 bg-gray-F7F7F7 px-12 py-6 text-12 leading-18",children:[(0,l.jsx)(x.Ct,{tone:"NEIGHBORHOOD"===e.type?"blue":"gray",children:f[e.type]??e.type}),(0,l.jsxs)("span",{className:"text-black",children:[e.name,(null===(a=e.parent)||void 0===a?void 0:a.name)?` — ${e.parent.name}`:""]}),(0,l.jsx)("button",{type:"button",onClick:()=>{var a;return a=e.id,void H(e=>e.filter(e=>e.id!==a))},"aria-label":`حذف ${e.name}`,className:"text-gray-6C6A7D hover:text-error-light",children:"✕"})]},e.id)})}),(0,l.jsxs)("div",{className:"relative max-w-[420px]",children:[(0,l.jsx)(x.II,{value:_,onChange:e=>L(e.target.value),placeholder:"نام شهر یا محله را جست‌وجو کنید…"}),_.trim().length>=2&&q.length>0&&(0,l.jsx)("div",{className:"absolute z-10 mt-4 max-h-[220px] w-full overflow-y-auto rounded-10 border border-gray-E5E5E6 bg-white shadow-lg",children:q.map(e=>(0,l.jsxs)("button",{type:"button",onClick:()=>{H(a=>[...a,{id:e.id,name:e.name,type:e.type,parent:null}]),L("")},className:"flex w-full items-center gap-x-8 px-12 py-8 text-right text-13 hover:bg-gray-F5F5F7",children:[(0,l.jsx)(x.Ct,{tone:"NEIGHBORHOOD"===e.type?"blue":"gray",children:f[e.type]??e.type}),e.name]},e.id))})]}),(0,l.jsx)("div",{className:"mt-14",children:(0,l.jsx)(x.zx,{disabled:!J||"extra"===B,onClick:V,children:"extra"===B?"در حال ذخیره…":"ذخیره تغییرات"})})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8 mb-4",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"جاذبه‌های نزدیک"}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("span",{className:"text-12 text-gray-6C6A7D",children:"شعاع"}),[10,30,60].map(e=>(0,l.jsxs)("button",{type:"button",onClick:()=>A(e),className:`rounded-8 border px-10 py-4 text-12 leading-18 ${E===e?"border-primary-main text-primary-dark bg-primary-light":"border-gray-E5E5E6 text-gray-6C6A7D"}`,children:[(0,x.N)(e)," کیلومتر"]},e))]})]}),null==m.latitude&&(0,l.jsx)("div",{className:"rounded-10 bg-[#FFF8EC] border border-[#F5D9A8] px-12 py-10 mb-12",children:(0,l.jsx)("p",{className:"text-12 leading-20 text-black",children:"این اقامتگاه موقعیت روی نقشه ندارد، پس فاصله‌ی واقعی قابل محاسبه نیست. فعلاً فقط جاذبه‌های همان شهر پیشنهاد می‌شوند."})}),W?0===W.items.length?(0,l.jsx)(x.ub,{text:"جاذبه‌ای برای این اقامتگاه پیدا نشد"}):(0,l.jsxs)(l.Fragment,{children:[el.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"با فاصله‌ی محاسبه‌شده — هم اقامتگاه و هم جاذبه مختصات دارند"}),(0,l.jsx)("div",{className:"flex flex-col gap-y-6 mb-14",children:el.map(e=>(0,l.jsx)(v,{a:e,checked:S.has(e.id),onToggle:()=>D(a=>{let t=new Set(a);return t.has(e.id)?t.delete(e.id):t.add(e.id),t})},e.id))})]}),es.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"در همین شهر — این‌ها مختصات ندارند، پس فاصله‌شان محاسبه نشده و باید دستی نوشته شود"}),(0,l.jsx)("div",{className:"flex flex-col gap-y-6 mb-14",children:es.slice(0,12).map(e=>(0,l.jsx)(v,{a:e,checked:S.has(e.id),onToggle:()=>D(a=>
1{let t=new Set(a);return t.has(e.id)?t.delete(e.id):t.add(e.id),t})},e.id))})]}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,l.jsxs)(x.zx,{disabled:0===S.size||"bulk"===B,onClick:()=>et("bulk",async()=>{await (0,o.SC)(`/api/admin/residences/${c}/distances/bulk`,{method:"POST",body:JSON.stringify({attractionIds:[...S]})}),D(new Set),K(),Q()},"جاذبه‌های انتخاب‌شده اضافه شدند"),children:["افزودن ",S.size>0?(0,x.N)(S.size):""," مورد انتخاب‌شده"]}),el.filter(e=>!e.alreadyAdded).length>0&&(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>D(new Set(el.filter(e=>!e.alreadyAdded).slice(0,8).map(e=>e.id))),children:"انتخاب ۸ مورد نزدیک"})]})]}):(0,l.jsx)(x.Od,{className:"h-[160px]"})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("h3",{className:"text-16 leading-24 font-m text-black mb-4",children:["فاصله تا جاذبه‌های گردشگری",!!(null==X?void 0:X.length)&&(0,l.jsx)("span",{className:"mr-8",children:(0,l.jsx)(x.Ct,{tone:"gray",children:(0,x.N)(X.length)})})]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-12",children:"این فهرست در صفحه‌ی عمومی اقامتگاه نمایش داده می‌شود."}),X?0===X.length?(0,l.jsx)(x.ub,{text:"فاصله‌ای ثبت نشده"}):(0,l.jsx)("div",{className:"flex flex-col gap-y-8 mb-16",children:X.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-6 rounded-10 border border-gray-E5E5E6 px-12 py-10",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("p",{className:"text-14 leading-22 text-black",children:[e.placeName,!e.attraction&&(0,l.jsx)("span",{className:"mr-8 text-11 text-gray-9B9BAA",children:"(متن آزاد)"})]}),(0,l.jsxs)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:[e.distance||"بدون فاصله",e.eta?` \xb7 ${e.eta}`:""]})]}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:B===`del-${e.id}`,onClick:()=>et(`del-${e.id}`,async()=>{await (0,o.SC)(`/api/admin/distances/${e.id}`,{method:"DELETE"}),K(),Q()},"حذف شد"),children:"حذف"})]},e.id))}):(0,l.jsx)(x.Od,{className:"h-[120px]"}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14",children:[(0,l.jsx)("p",{className:"text-13 leading-22 font-m text-black mb-10",children:"افزودن دستی"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-10",children:[(0,l.jsx)(x.gN,{label:"نام مکان",children:(0,l.jsx)(x.II,{value:T,onChange:e=>z(e.target.value),placeholder:"مثلاً پل خواجو"})}),(0,l.jsx)(x.gN,{label:"فاصله",children:(0,l.jsx)(x.II,{value:M,onChange:e=>R(e.target.value),placeholder:"۳٫۵ کیلومتر"})}),(0,l.jsx)(x.gN,{label:"زمان رسیدن",children:(0,l.jsx)(x.II,{value:Z,onChange:e=>U(e.target.value),placeholder:"۱۲ دقیقه"})})]}),(0,l.jsx)("div",{className:"mt-10",children:(0,l.jsx)(x.zx,{disabled:!T.trim()||"add"===B,onClick:()=>et("add",async()=>{await (0,o.SC)(`/api/admin/residences/${c}/distances`,{method:"POST",body:JSON.stringify({placeName:T.trim(),distance:M.trim()||void 0,eta:Z.trim()||void 0})}),z(""),R(""),U(""),K()},"اضافه شد"),children:"افزودن"})})]})]})]})}function v(e){let{a,checked:t,onToggle:s}=e;return(0,l.jsxs)("label",{className:`flex items-center justify-between gap-x-12 rounded-10 border px-12 py-8 cursor-pointer ${a.alreadyAdded?"border-gray-E5E5E6 bg-gray-F7F7F7 opacity-70":t?"border-primary-main bg-primary-light":"border-gray-E5E5E6 hover:border-gray-C4CAD3"}`,children:[(0,l.jsxs)("span",{className:"flex items-center gap-x-10 min-w-0",children:[(0,l.jsx)("input",{type:"checkbox",checked:t,disabled:a.alreadyAdded,onChange:s,className:"w-16 h-16 shrink-0"}),(0,l.jsxs)("span",{className:"min-w-0",children:[(0,l.jsx)("span",{className:"block text-14 leading-22 text-black truncate",children:a.name}),!!a.locationName&&(0,l.jsx)("span",{className:"block text-11 leading-16 text-gray-9B9BAA",children:a.locationName})]})]}),(0,l.jsx)("span",{className:"text-12 leading-20 shrink-0",children:a.alreadyAdded?(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"قبلاً اضافه شده"}):a.distanceText?(0,l.jsx)("span",{className:"text-primary-dark font-m",children:a.distanceText}):(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"در همین شهر"})})]})}var C=t(68289),k=t.n(C),w=t(55290);function E(e){return e>=1e9?(0,x.N)(Math.round(e/1e8)/10)+" میلیارد":e>=1e6?(0,x.N)(Math.round(e/1e5)/10)+" م":e>=1e3?(0,x.N)(Math.round(e/1e3))+" هزار":(0,x.N)(e)}function A(e){let{label:a,value:t,hint:s,tone:n="text-black"}=e;return(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:a}),(0,l.jsx)("p",{className:`text-20 leading-30 font-b mt-2 ${n}`,children:t}),!!s&&(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-2",children:s})]})}function S(e){let{points:a,format:t,emptyText:s}=e,n=Math.max(...a.map(e=>e.value),0);return 0===n?(0,l.jsx)("div",{className:"h-[140px] flex items-center justify-center",children:(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA",children:s})}):(0,l.jsx)("div",{className:"flex items-end gap-x-4 h-[140px]",dir:"ltr",children:a.map(e=>(0,l.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-end h-full min-w-0",children:[(0,l.jsx)("span",{className:"text-9 leading-12 text-gray-9B9BAA mb-2 whitespace-nowrap",children:e.value>0?t(e.value):""}),(0,l.jsx)("div",{title:`${e.caption??e.label}: ${t(e.value)}`,style:{height:`${Math.max(2,e.value/n*100)}%`},className:`w-full rounded-t-4 ${e.value>0?"bg-primary-main":"bg-gray-E5E5E6"}`}),(0,l.jsx)("span",{className:"text-9 leading-12 text-gray-9B9BAA mt-4 truncate w-full text-center",children:e.label})]},e.key))})}function D(e){let{label:a,score:t}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,l.jsx)("span",{className:"text-12 leading-20 text-gray-6C6A7D w-[92px] shrink-0",children:a}),(0,l.jsx)("div",{className:"flex-1 h-6 rounded-full bg-gray-F0F0F0 overflow-hidden",children:(0,l.jsx)("div",{className:"h-full rounded-full bg-primary-main",style:{width:`${Math.min(100,t/5*100)}%`}})}),(0,l.jsx)("span",{className:"text-12 leading-20 text-black font-m w-[28px] text-left",children:(0,x.N)(t)})]})}function B(e){let{residenceId:a}=e,{data:t,isLoading:n,error:r}=(0,d.u)(`/api/admin/residences/${a}/stats`,e=>(0,o.SC)(e)),i=(0,s.useMemo)(()=>((null==t?void 0:t.monthly)??[]).map(e=>{var a;return{key:e.month,label:(a=e.month,w.Y3[k()(a+"-15","YYYY-MM-DD").jMonth()]),caption:function(e){let a=k()(e+"-15","YYYY-MM-DD");return`${w.Y3[a.jMonth()]} ${(0,w.YS)(a.jYear())}`}(e.month),nights:e.nights,income:e.income,views:e.views}}),[t]),c=(0,s.useMemo)(()=>((null==t?void 0:t.daily)??[]).map(e=>({key:e.date,label:(0,w.YS)(k()(e.date,"YYYY-MM-DD").format("jD")),caption:(0,w.YS)(k()(e.date,"YYYY-MM-DD").format("jYYYY/jMM/jDD")),nights:e.nights,views:e.views})),[t]);if(n)return(0,l.jsx)(x.Od,{className:"h-[420px]"});if(r||!t)return(0,l.jsx)(x.Zb,{children:(0,l.jsx)(x.ub,{text:"آمار این اقامتگاه خوانده نشد"})});let m=t.reservations,u=Math.max(...Object.values(t.reviews.spread),1);return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"آمار رزرو"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-10",children:[(0,l.jsx)(A,{label:"کل درخواست‌ها",value:(0,x.N)(m.total)}),(0,l.jsx)(A,{label:"تایید شده",value:(0,x.N)(m.confirmed),tone:"text-[#2E7D32]"}),(0,l.jsx)(A,{label:"قطعی شده",value:(0,x.N)(m.done),tone:"text-[#2E7D32]"}),(0,l.jsx)(A,{label:"در انتظار میزبان",value:(0,x.N)(m.pending),tone:"text-[#B26A00]"}),(0,l.jsx)(A,{label:"رد شده",value:(0,x.N)(m.rejected),tone:"text-[#C62828]"}),(0,l.jsx)(A,{label:"لغو شده",value:(0,x.N)(m.cancelled),tone:"text-[#C62828]"})]}),m.expired>0&&(0,l.jsxs)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-10",children:[(0,x.N)(m.expired)," درخواست هم منقضی شده — مهلت پرداختشان گذشت و خودکار بسته شدند."]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-8",children:"\xabرد شده\xbb یعنی میزبان نپذیرفته؛ \xabلغو شده\xbb یعنی رزرو بعد از ثبت لغو شده — معمولاً از سمت مهمان. این دو یکی نیستند."})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"شب اقامت"}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-10 mb-16",children:[(0,l.jsx)(A,{label:"کل",value:(0,x.N)(t.nights.total)}),(0,l.jsx)(A,{label:"۱۲ ماه اخیر",value:(0,x.N)(t.nights.last_year)}),(0,l.jsx)(A,{label:"۳۰ روز اخیر",value:(0,x.N)(t.nights.last_month)})]}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"شب اقامت ماهانه"}),(0,l.jsx)(S,{points:i.map(e=>({...e,value:e.nights})),format:e=>(0,x.N)(e),emptyText:"در ۱۲ ماه اخیر شب اقامتی ثبت نشده"})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"درآمد"}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-10 mb-16",children:[(0,l.jsx)(A,{label:"کل (سهم میزبان)",value:E(t.income.total),hint:"تومان"}),(0,l.jsx)(A,{label:"۱۲ ماه اخیر",value:E(t.income.last_year),hint:"تومان"}),(0,l.jsx)(A,{label:"میانگین ماهانه",value:E(t.income.monthly_average),hint:"فقط ماه‌هایی که درآمد داشته"})]}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"درآمد ماهانه"}),(0,l.jsx)(S,{points:i.map(e=>({...e,value:e.income})),format:E,emptyText:"در ۱۲ ماه اخیر درآمدی ثبت نشده"})]})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8 mb-14",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"بازدید صفحه"}),t.views.tracking_since?(0,l.jsxs)(x.Ct,{tone:"gray",children:["شمارش از ",(0,w.YS)(k()(t.views.tracking_since,"YYYY-MM-DD").format("jYYYY/jMM/jDD"))]}):(0,l.jsx)(x.Ct,{tone:"yellow",children:"هنوز شمارشی ثبت نشده"})]}),(0,l.jsx)("div",{className:"rounded-10 bg-[#FFF8EC] border border-[#F5D9A8] px-12 py-10 mb-14",children:(0,l.jsxs)("p",{className:"text-12 leading-20 text-black",children:["شمارش بازدید تازه راه افتاده. ماه‌های قبل از شروع شمارش ",(0,l.jsx)("b",{children:"اندازه‌گیری نشده‌اند"})," — نه اینکه بازدید نداشته‌اند. داده‌ی بازدید قدیمی هم در دسترس نیست: آخرین چیزی که سیستم قبلی ثبت کرده مربوط به خرداد ۱۴۰۰ است."]})}),(0,l.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-10 mb-16",children:[(0,l.jsx)(A,{label:"۳۰ روز اخیر",value:(0,x.N)(t.views.last_month)}),(0,l.jsx)(A,{label:"۱۲ ماه اخیر",value:(0,x.N)(t.views.last_year)}),(0,l.jsx)(A,{label:"افزودن به علاقه‌مندی‌ها",value:(0,x.N)(t.favourites)}),(0,l.jsx)(A,{label:"نظر ثبت‌شده",value:(0,x.N)(t.reviews.count),hint:t.reviews.count>0?`میانگین ${(0,x.N)(t.reviews.average)}`:void 0})]}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"بازدید روزانه — ۳۰ روز اخیر"}),(0,l.jsx)(S,{points:c.map(e=>({...e,value:e.views})),format:e=>(0,x.N)(e),emptyText:"هنوز بازدیدی شمرده نشده"}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8 mt-16",children:"بازدید ماهانه"}),(0,l.jsx)(S,{points:i.map(e=>({...e,value:e.views})),format:e=>(0,x.N)(e),emptyText:"هنوز بازدیدی شمرده نشده"})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"شب اقامت روزانه — ۳۰ روز اخیر"}),(0,l.jsx)(S,{points:c.map(e=>({...e,value:e.nights})),format:e=>(0,x.N)(e),emptyText:"در ۳۰ روز اخیر شب اقامتی ثبت نشده"})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"خلاصه نظرات"}),0===t.reviews.count?(0,l.jsx)(x.ub,{text:"هنوز نظری برای این اقامتگاه ثبت نشده"}):(0,l.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[220px_1fr_1fr] gap-16",children:[(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 text-center",children:[(0,l.jsx)("p",{className:"text-40 leading-56 font-b text-black",children:(0,x.N)(t.reviews.average)}),(0,l.jsx)("div",{className:"flex justify-center mb-6",children:(0,l.jsx)(x.tS,{value:t.reviews.average})}),(0,l.jsxs)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:["از ",(0,x.N)(t.reviews.count)," نظر"]})]}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 flex flex-col justify-center gap-y-8",children:[(0,l.jsx)(D,{label:"نظافت",score:t.reviews.cleaning}),(0,l.jsx)(D,{label:"موقعیت مکانی",score:t.reviews.location}),(0,l.jsx)(D,{label:"کیفیت نسبت به نرخ",score:t.reviews.quality}),(0,l.jsx)(D,{label:"صحت مطالب",score:t.reviews.integrity}),(0,l.jsx)(D,{label:"برخورد میزبان",score:t.reviews.greeting}),(0,l.jsx)(D,{label:"نحوه تحویل",score:t.reviews.delivery})]}),(0,l.jsx)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 flex flex-col justify-center gap-y-8",children:["5","4","3","2","1"].map(e=>{let a=t.reviews.spread[e]??0;return(0,l.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,l.jsxs)("span",{className:"text-12 leading-20 text-gray-6C6A7D w-[42px] shrink-0",children:[(0,x.N)(Number(e))," ستاره"]}),(0,l.jsx)("div",{className:"flex-1 h-6 rounded-full bg-gray-F0F0F0 overflow-hidden",children:(0,l.jsx)("div",{className:"h-full rounded-full bg-[#FFC120]",style:{width:`${a/u*100}%`}})}),(0,l.jsx)("span",{className:"text-12 leading-20 text-black font-m w-[36px] text-left",children:(0,x.N)(a)})]},e)})})]})]})]})}var F=t(47693);let I=e=>(0,w.YS)(k()(e).format("jYYYY/jMM/jDD")),P=[{key:"all",label:"همه"},{key:"visible",label:"نمایش داده می‌شود"},{key:"hidden",label:"پنهان"},{key:"unanswered",label:"بی‌پاسخ"}];function $(e){let{label:a,value:t}=e;return(0,l.jsxs)("span",{className:"inline-flex items-center gap-x-4 roun
1ded-6 bg-gray-F5F5F7 px-6 py-2 text-11 leading-16 text-gray-6C6A7D",children:[a,(0,l.jsx)("b",{className:"text-black",children:(0,x.N)(t)})]})}function O(e){let{residenceId:a}=e,{data:t,isLoading:n,mutate:i}=(0,d.u)(`/api/admin/residences/${a}/reviews`,e=>(0,o.SC)(e)),[c,m]=(0,s.useState)("all"),[u,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(""),[j,y]=(0,s.useState)(null),[b,f]=(0,s.useState)(""),[N,v]=(0,s.useState)(!1),[C,k]=(0,s.useState)(null),[w,E]=(0,s.useState)(!1);if(n)return(0,l.jsx)(x.Od,{className:"h-[360px]"});if(!t)return(0,l.jsx)(x.Zb,{children:(0,l.jsx)(x.ub,{text:"نظرات این اقامتگاه خوانده نشد"})});let A=t.reviews.filter(e=>"visible"===c?"PUBLISHED"===e.commentStatus:"hidden"===c?"PUBLISHED"!==e.commentStatus:"unanswered"!==c||"PUBLISHED"===e.commentStatus&&!e.hostAnswer);async function S(){if(u&&p.trim()){v(!0),k(null);try{await (0,o.SC)(`/api/admin/reviews/${u.id}/comment-status`,{method:"POST",body:JSON.stringify({status:"REJECTED",note:p.trim()})}),h(null),g(""),i()}catch(e){k(e instanceof Error?e.message:"انجام نشد")}finally{v(!1)}}}async function D(e){await (0,o.SC)(`/api/admin/reviews/${e.id}/comment-status`,{method:"POST",body:JSON.stringify({status:"PUBLISHED"})}),i()}async function B(){if(j&&b.trim()){v(!0),k(null);try{await (0,o.SC)(`/api/admin/reviews/${j.id}/answer`,{method:"PUT",body:JSON.stringify({answer:b.trim()})}),y(null),f(""),i()}catch(e){k(e instanceof Error?e.message:"ثبت نشد")}finally{v(!1)}}}return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-10 mb-14",children:[(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 text-center",children:[(0,l.jsx)("p",{className:"text-24 leading-34 font-b text-black",children:(0,x.N)(t.summary.average)}),(0,l.jsx)("div",{className:"flex justify-center",children:(0,l.jsx)(x.tS,{value:t.summary.average})}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-2",children:"میانگین"})]}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"نمایش داده می‌شود"}),(0,l.jsx)("p",{className:"text-20 leading-30 font-b text-black mt-2",children:(0,x.N)(t.summary.visible)})]}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"پنهان"}),(0,l.jsx)("p",{className:"text-20 leading-30 font-b text-[#C62828] mt-2",children:(0,x.N)(t.summary.hidden)})]}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:"بی‌پاسخ"}),(0,l.jsx)("p",{className:"text-20 leading-30 font-b text-[#B26A00] mt-2",children:(0,x.N)(t.summary.unanswered)})]}),(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 col-span-2",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-6",children:"میانگین دسته‌ها"}),(0,l.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,l.jsx)($,{label:"نظافت",value:t.summary.cleaning}),(0,l.jsx)($,{label:"موقعیت",value:t.summary.location}),(0,l.jsx)($,{label:"کیفیت",value:t.summary.quality}),(0,l.jsx)($,{label:"صحت",value:t.summary.integrity}),(0,l.jsx)($,{label:"برخورد",value:t.summary.greeting}),(0,l.jsx)($,{label:"تحویل",value:t.summary.delivery})]})]})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8",children:[(0,l.jsx)("div",{className:"flex items-center gap-x-6 flex-wrap gap-y-6",children:P.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>m(e.key),className:`rounded-full px-12 py-6 text-12 leading-20 border transition ${c===e.key?"border-primary-main bg-primary-light text-primary-dark font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:e.label},e.key))}),(0,l.jsx)(x.zx,{onClick:()=>E(!0),children:"ثبت نظر دستی"})]})]}),0===A.length?(0,l.jsx)(x.Zb,{children:(0,l.jsx)(x.ub,{text:0===t.summary.total?"هنوز نظری برای این اقامتگاه ثبت نشده":"نظری با این فیلتر پیدا نشد"})}):(0,l.jsx)("div",{className:"flex flex-col gap-y-12",children:A.map(e=>(0,l.jsxs)(x.Zb,{className:`p-16 ${"PUBLISHED"!==e.commentStatus?"bg-[#FCF6F6] border-r-4 border-r-[#E11D48]":""}`,children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-x-12 flex-wrap gap-y-8 mb-10",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-4",children:[e.guest?(0,l.jsx)(r(),{href:`/admin/users/${e.guest.id}`,className:"text-14 leading-22 font-m text-primary-dark",children:e.guest.name||e.guest.phone}):(0,l.jsx)("span",{className:"text-14 leading-22 font-m text-black",children:e.guestDisplayName??"مهمان"}),e.isManual&&(0,l.jsx)(x.Ct,{tone:"purple",children:"دستی"}),(0,l.jsx)(x.tS,{value:e.averageRating}),(0,l.jsx)("span",{className:"text-12 leading-20 text-gray-9B9BAA",children:I(e.createdAt)}),"REJECTED"===e.commentStatus&&(0,l.jsx)(x.Ct,{tone:"red",children:"رد شده"}),"PENDING"===e.commentStatus&&(0,l.jsx)(x.Ct,{tone:"yellow",children:"در انتظار تایید"}),"PENDING"===e.hostAnswerStatus&&(0,l.jsx)(x.Ct,{tone:"yellow",children:"پاسخ میزبان در انتظار تایید"}),"PUBLISHED"===e.commentStatus&&!e.hostAnswer&&(0,l.jsx)(x.Ct,{tone:"gray",children:"بی‌پاسخ"})]}
1),!!e.reservation&&(0,l.jsxs)(r(),{href:`/admin/reservations/${e.reservation.id}`,className:"text-12 leading-20 text-gray-6C6A7D hover:text-primary-dark",children:[e.reservation.reference," \xb7 ",I(e.reservation.startDate)," تا"," ",I(e.reservation.endDate)]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>{y(e),f(e.hostAnswer??"")},children:e.hostAnswer?"ویرایش پاسخ":"ثبت پاسخ میزبان"}),(0,l.jsx)(r(),{href:`/admin/comments/${e.id}`,children:(0,l.jsx)(x.zx,{variant:"secondary",children:"جزئیات نظر"})}),"PUBLISHED"!==e.commentStatus?(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>D(e),children:"تایید و انتشار"}):(0,l.jsx)(x.zx,{variant:"danger",onClick:()=>{h(e),g("")},children:"پنهان کردن"})]})]}),(0,l.jsx)("p",{className:"text-13 leading-24 text-black whitespace-pre-line",children:e.comment}),(0,l.jsxs)("div",{className:"flex flex-wrap gap-4 mt-10",children:[(0,l.jsx)($,{label:"نظافت",value:e.cleaning}),(0,l.jsx)($,{label:"موقعیت",value:e.location}),(0,l.jsx)($,{label:"کیفیت",value:e.quality}),(0,l.jsx)($,{label:"صحت",value:e.integrity}),(0,l.jsx)($,{label:"برخورد",value:e.greeting}),(0,l.jsx)($,{label:"تحویل",value:e.delivery})]}),!!e.hostAnswer&&(0,l.jsxs)("div",{className:"mt-12 rounded-10 bg-gray-F5F5F7 px-12 py-10",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-2",children:"پاسخ میزبان"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black whitespace-pre-line",children:e.hostAnswer})]}),"PUBLISHED"!==e.commentStatus&&(0,l.jsx)("div",{className:"mt-12 rounded-10 bg-[#FDECEC] px-12 py-10",children:(0,l.jsxs)("p",{className:"text-12 leading-20 text-[#C62828]",children:["REJECTED"===e.commentStatus?"رد شده":"در انتظار تایید",e.moderatedAt?` — ${I(e.moderatedAt)}`:"",e.moderationNote?` — ${e.moderationNote}`:""]})})]},e.id))}),(0,l.jsxs)(x.u_,{open:!!u,onClose:()=>h(null),title:"پنهان کردن نظر",width:"max-w-[480px]",children:[(0,l.jsx)("div",{className:"rounded-8 bg-[#F0F9FF] border border-[#BAE6FD] px-12 py-10 mb-14",children:(0,l.jsxs)("p",{className:"text-12 leading-20 text-black",children:["نظر ",(0,l.jsx)("b",{children:"حذف نمی‌شود"})," — فقط از صفحه‌ی اقامتگاه برداشته می‌شود و از میانگین امتیاز کنار گذاشته می‌شود. هر وقت بخواهید از همین‌جا برمی‌گردد."]})}),(0,l.jsx)(x.gN,{label:"دلیل (الزامی)",children:(0,l.jsx)("textarea",{value:p,onChange:e=>g(e.target.value),rows:3,placeholder:"چرا این نظر باید پنهان شود؟",className:"w-full rounded-8 border border-gray-E3E3E8 px-12 py-10 text-14 leading-24 outline-none focus:border-primary resize-none"})}),!!C&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:C}),(0,l.jsxs)("div",{className:"mt-16 flex items-center justify-end gap-x-10",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>h(null),disabled:N,children:"انصراف"}),(0,l.jsx)(x.zx,{variant:"danger",onClick:S,disabled:N||!p.trim(),children:N?"در حال ثبت…":"پنهان کن"})]})]}),(0,l.jsxs)(x.u_,{open:!!j,onClose:()=>y(null),title:"پاسخ میزبان",width:"max-w-[520px]",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA mb-12",children:"این متن در صفحه‌ی اقامتگاه به‌عنوان پاسخ میزبان دیده می‌شود. در تاریخچه ثبت می‌شود که شما آن را نوشته‌اید."}),(0,l.jsx)(x.gN,{label:"متن پاسخ",children:(0,l.jsx)("textarea",{value:b,onChange:e=>f(e.target.value),rows:4,className:"w-full rounded-8 border border-gray-E3E3E8 px-12 py-10 text-14 leading-24 outline-none focus:border-primary resize-none"})}),!!C&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:C}),(0,l.jsxs)("div",{className:"mt-16 flex items-center justify-end gap-x-10",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>y(null),disabled:N,children:"انصراف"}),(0,l.jsx)(x.zx,{onClick:B,disabled:N||!b.trim(),children:N?"در حال ثبت…":"ثبت پاسخ"})]})]}),(0,l.jsx)(F.Z,{open:w,onClose:()=>E(!1),onCreated:()=>i(),defaultResidenceId:a})]})}let T=e=>(0,w.YS)(k()(e).format("jYYYY/jMM/jDD"));function z(e){let{residenceId:a}=e,{data:t,isLoading:s}=(0,d.u)(`/api/admin/residences/${a}/phone-reviews`,e=>(0,o.SC)(e));return s?(0,l.jsx)(x.Od,{className:"h-[180px]"}):t?(0,l.jsxs)("div",{className:"flex flex-col gap-y-12 mt-8",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8",children:[(0,l.jsx)("h3",{className:"text-15 leading-24 font-m text-black",children:"نظرات رزرو تلفنی"}),(0,l.jsxs)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:[(0,x.N)(t.summary.visible)," منتشر \xb7 ",(0,x.N)(t.summary.pending)," در انتظار تایید"]})]}),0===t.reviews.length?(0,l.jsx)(x.Zb,{children:(0,l.jsx)(x.ub,{text:"هنوز نظر رزرو تلفنی برای این اقامتگاه ثبت نشده"})}):t.reviews.map(e=>(0,l.jsxs)(x.Zb,{className:`p-16 ${"PUBLISHED"!==e.commentStatus?"bg-[#FCF6F6] border-r-4 border-r-[#E11D48]":""}`,children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-x-12 flex-wrap gap-y-8 mb-8",children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-4",children:[e.guest?(0,l.jsx)(r(),{href:`/admin/users/${e.guest.id}`,className:"text-14 leading-22 font-m text-primary-dark",children:e.guest.name||e.guest.phone}):(0,l.jsx)("span",{className:"text-14 leading-22 font-m text-black",children:"مهمان"}),(0,l.jsx)(x.tS,{value:e.averageRating}),(0,l.jsx)("span",{className:"text-12 leading-20 text-gray-9B9BAA",children:T(e.createdAt)}),"REJECTED"===e.commentStatus&&(0,l.jsx)(x.Ct,{tone:"red",children:"رد شده"}),"PENDING"===e.commentStatus&&(0,l.jsx)(x.Ct,{tone:"yellow",children:"در انتظار تایید"}),"PENDING"===e.hostAnswerStatus&&(0,l.jsx)(x.Ct,{tone:"yellow",children:"پاسخ میزبان در انتظار تایید"})]}),(0,l.jsx)(r(),{href:`/admin/comments/phone/${e.id}`,className:"text-13 text-primary-dark font-m",children:"جزئیات و ویرایش"})]}),!!e.comment&&(0,l.jsx)("p",{className:"text-13 leading-24 text-black whitespace-pre-line",children:e.comment}),!!e.hostAnswer&&(0,l.jsxs)("div",{className:"mt-10 rounded-10 bg-gray-F5F5F7 px-12 py-10",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-2",children:"پاسخ میزبان"}),(0,l.jsx)("p",{className:"text-13 leading-22 text-black whitespace-pre-line",children:e.hostAnswer})]})]},e.id))]}):null}let M=[{kind:"document",field:"documentUrl",label:"سند / مدرک مالکیت",help:"سند تک‌برگ، قولنامه، Û
1ŒØ§ اجاره‌نامه‌ای که نشان می‌دهد میزبان حق واگذاری این ملک را دارد."},{kind:"hostCard",field:"hostNationalCardUrl",label:"کارت ملی میزبان",help:"کارت ملی همان شخصی که حساب میزبان به نامش است."},{kind:"ownerCard",field:"ownerNationalCardUrl",label:"کارت ملی مالک",help:"فقط وقتی لازم است که میزبان خودش مالک نباشد."}],R={CONFIRMED:{label:"احراز شده",tone:"green"},CHECKING:{label:"در حال بررسی",tone:"yellow"},NOT_CONFIRMED:{label:"احراز نشده",tone:"gray"}};function Z(e){var a;let{residenceId:t}=e,{data:n,isLoading:i,mutate:c}=(0,d.u)(`/api/admin/residences/${t}/documents`,e=>(0,o.SC)(e)),[m,u]=(0,s.useState)(null),[h,p]=(0,s.useState)(null),[g,j]=(0,s.useState)(null),y=(0,s.useRef)({});async function b(e,a){p(e),j(null);try{let l=new FormData;l.append("file",a);let s=await fetch(`/api/admin/residences/${t}/documents/${e}`,{method:"POST",headers:{Authorization:`Bearer ${(0,o.LP)()}`},body:l});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error((null==e?void 0:e.message)??"بارگذاری نشد")}c()}catch(e){j(e instanceof Error?e.message:"بارگذاری نشد")}finally{p(null)}}async function f(e){p(e),j(null);try{await (0,o.SC)(`/api/admin/residences/${t}/documents/${e}`,{method:"DELETE"}),c()}catch(e){j(e instanceof Error?e.message:"حذف نشد")}finally{p(null)}}if(i)return(0,l.jsx)(x.Od,{className:"h-[300px]"});if(!n)return(0,l.jsx)(x.Zb,{children:(0,l.jsx)(x.ub,{text:"مدارک این اقامتگاه خوانده نشد"})});let N=R[(null===(a=n.host)||void 0===a?void 0:a.verificationStatus)??"NOT_CONFIRMED"]??R.NOT_CONFIRMED;return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-16 flex items-center gap-x-14 flex-wrap gap-y-10",children:[(0,l.jsx)(x.Ct,{tone:"purple",children:"میزبان"}),n.host?(0,l.jsx)(r(),{href:`/admin/users/${n.host.id}`,className:"text-14 leading-22 font-m text-primary-dark",children:n.host.name||n.host.phone}):(0,l.jsx)("span",{className:"text-14 text-gray-9B9BAA",children:"—"}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsx)("span",{className:"text-13 leading-20 text-gray-6C6A7D",children:"وضعیت احراز هویت :"}),(0,l.jsx)(x.Ct,{tone:N.tone,children:N.label})]}),(0,l.jsx)(x.Zb,{className:"p-14 bg-[#FFF8EC] border-r-4 border-r-[#B26A00]",children:(0,l.jsxs)("p",{className:"text-13 leading-22 text-black",children:["این مدارک ",(0,l.jsx)("b",{children:"هویتی"})," هستند و فقط داخل پنل دیده می‌شوند — در هیچ صفحه‌ی عمومی نمایش داده نمی‌شوند. لطفاً از آن‌ها اسکرین‌شات نگیرید و لینکشان را جای دیگری نفرستید."]})}),!!g&&(0,l.jsx)(x.Zb,{className:"p-14",children:(0,l.jsx)("p",{className:"text-13 leading-22 text-[#C62828]",children:g})}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-16",children:M.map(e=>{let a=n[e.field];return(0,l.jsxs)(x.Zb,{className:"p-16 flex flex-col",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-8 mb-2",children:[(0,l.jsx)("h3",{className:"text-14 leading-22 font-m text-black",children:e.label}),a?(0,l.jsx)(x.Ct,{tone:"green",children:"ثبت شده"}):(0,l.jsx)(x.Ct,{tone:"gray",children:"ندارد"})]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-12",children:e.help}),(0,l.jsx)("div",{className:"rounded-10 border border-gray-E5E5E6 bg-gray-F7F7F7 h-[150px] flex items-center justify-center overflow-hidden mb-12",children:a&&function(e){let a=e.split("?")[0].toLowerCase();return!/.(heic|heif|pdf)$/.test(a)}(a)?(0,l.jsx)("button",{type:"button",onClick:()=>u({url:a,label:e.label}),className:"w-full h-full",title:"بزرگ کردن",children:(0,l.jsx)("img",{src:a,alt:e.label,className:"w-full h-full object-contain",loading:"lazy"})}):a?(0,l.jsxs)("a",{href:a,target:"_blank",rel:"noreferrer",className:"flex flex-col items-center justify-center gap-y-6 w-full h-full text-center px-10",children:[(0,l.jsx)("i",{className:"icon-Attach text-32 text-gray-9B9BAA"}),(0,l.jsxs)("span",{className:"text-12 leading-20 text-primary-dark font-m",children:[function(e){var a;let t=(null===(a=e.split("?")[0].split(".").pop())||void 0===a?void 0:a.toUpperCase())??"فایل";return"PDF"===t?"فایل PDF":`تصویر ${t}`}(a)," — باز کردن"]}),(0,l.jsx)("span",{className:"text-11 leading-16 text-gray-9B9BAA",children:"مرورگر این نوع فایل را پیش‌نمایش نمی‌دهد"})]}):(0,l.jsx)("span",{className:"text-12 leading-20 text-gray-9B9BAA",children:"فایلی بارگذاری نشده"})}),(0,l.jsx)("input",{ref:a=>{y.current[e.kind]=a},type:"file",accept:"image/*,application/pdf",className:"hidden",onChange:a=>{var t;let l=null===(t=a.target.files)||void 0===t?void 0:t[0];l&&b(e.kind,l),a.target.value=""}}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8 mt-auto",children:[(0,l.jsx)(x.zx,{variant:"secondary",className:"flex-1",disabled:h===e.kind,onClick:()=>{var a;return null===(a=y.current[e.kind])||void 0===a?void 0:a.click()},children:h===e.kind?"…":a?"جایگزینی":"بارگذاری"}),!!a&&(0,l.jsx)(x.zx,{variant:"danger",disabled:h===e.kind,onClick:()=>f(e.kind),children:"حذف"})]})]},e.kind)})}),(0,l.jsx)(x.u_,{open:!!m,onClose:()=>u(null),title:(null==m?void 0:m.label)??"",width:"max-w-[900px]",children:!!m&&(0,l.jsx)("div",{className:"max-h-[70vh] overflow-auto rounded-10 bg-gray-F7F7F7",children:(0,l.jsx)("img",{src:m.url,alt:m.label,className:"w-full h-auto"})})})]})}var U=t(35157),Y=t(64616);function H(e){let{label:a,value:t,onChange:s}=e,n=String((0,x.EU)(t)||"");return(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:a}),(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)("input",{value:n?Number(n).toLocaleStr
1ing("fa-IR"):"",onChange:e=>s(String((0,x.EU)(e.target.value)||"")),inputMode:"numeric",placeholder:"۰",className:"w-full px-14 py-10 pl-56 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),(0,l.jsx)("span",{className:"absolute left-14 top-1/2 -translate-y-1/2 text-12 text-gray-9B9BAA pointer-events-none",children:"تومان"})]})]})}function _(e){let{label:a,value:t,onChange:s}=e;return(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:a}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("input",{value:t,onChange:e=>s(String((0,x.EU)(e.target.value)||"")),inputMode:"numeric",placeholder:"۰",className:"flex-1 px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),(0,l.jsx)("span",{className:"px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 text-gray-6C6A7D bg-gray-F5F5F7",children:"درصد"})]})]})}let L=e=>null==e?"":String(Math.trunc(e)),J=e=>""===e?void 0:Number(e);function G(e){let{room:a,onClose:t,onSaved:n}=e,[r,i]=(0,s.useState)({weekPrice:"",weekendPrice:"",peakPrice:"",extraPrice:"",extraPeakPrice:"",weeklyDiscount:"",monthlyDiscount:"",coolingSystem:!1,heatingSystem:!1,refrigerator:"NONE",wc:"NONE",separateBathroom:!1,freeBreakfast:!1}),[d,c]=(0,s.useState)(null),[m,u]=(0,s.useState)(!1),[h,p]=(0,s.use
1State)(!1),[g,j]=(0,s.useState)(null),y=(0,s.useRef)(null);(0,s.useEffect)(()=>{a&&(i({weekPrice:L(a.weekPrice),weekendPrice:L(a.weekendPrice),peakPrice:L(a.peakPrice),extraPrice:L(a.extraPrice),extraPeakPrice:L(a.extraPeakPrice),weeklyDiscount:L(a.weeklyDiscount),monthlyDiscount:L(a.monthlyDiscount),coolingSystem:a.coolingSystem,heatingSystem:a.heatingSystem,refrigerator:a.refrigerator??"NONE",wc:a.wc??"NONE",separateBathroom:a.separateBathroom,freeBreakfast:a.freeBreakfast}),c(a.image),j(null))},[a]);let b=e=>a=>i(t=>({...t,[e]:a}));async function f(e){if(a&&(null==e?void 0:e.length)){u(!0),j(null);try{var t;let l=new FormData;l.append("image",e[0]);let s=await fetch(`/api/admin/rooms/${a.id}/image`,{method:"POST",headers:{Authorization:`Bearer ${(0,o.LP)()??""}`},body:l}),n=await s.json().catch(()=>({}));if(!s.ok)throw Error((null==n?void 0:n.message)??"بارگذاری نشد");c((null===(t=n.data)||void 0===t?void 0:t.image)??null)}catch(e){j(e instanceof Error?e.message:"بارگذاری نشد")}finally{u(!1),y.current&&(y.current.value="")}}}async function N(){if(a){p(!0),j(null);try{await (0,o.SC)(`/api/admin/rooms/${a.id}`,{method:"PATCH",body:JSON.stringify({weekPrice:J(r.weekPrice),weekendPrice:J(r.weekendPrice),peakPrice:J(r.peakPrice),extraPrice:J(r.extraPrice),extraPeakPrice:J(r.extraPeakPrice),weeklyDiscount:J(r.weeklyDiscount),monthlyDiscount:J(r.monthlyDiscount),coolingSystem:r.coolingSystem,heatingSystem:r.heatingSystem,refrigerator:r.refrigerator,wc:r.wc,separateBathroom:r.separateBathroom,freeBreakfast:r.freeBreakfast})}),n(),t()}catch(e){j(e instanceof Error?e.message:"ذخیره نشد")}finally{p(!1)}}}return(0,l.jsx)(x.u_,{open:!!a,onClose:t,title:a?`قیمت و امکانات — ${a.name}`:"",width:"max-w-[640px]",children:!!a&&(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"تصویر اتاق"}),(0,l.jsx)("input",{ref:y,type:"file",accept:"image/*",className:"hidden",onChange:e=>f(e.target.files)}),d?(0,l.jsxs)("div",{className:"relative w-full h-[160px] rounded-12 overflow-hidden",children:[(0,l.jsx)("img",{src:(0,x.vD)(d,640),alt:"",className:"w-full h-full object-cover"}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:m,onClick:()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.click()},className:"!absolute bottom-8 left-8 !w-auto",children:m?"در حال بارگذاری...":"تعویض عکس"})]}):(0,l.jsx)("button",{type:"button",disabled:m,onClick:()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.click()},className:"w-full h-[120px] rounded-12 border border-dashed border-gray-DBDFE5 text-13 text-gray-77828F hover:border-primary-main transition",children:m?"در حال بارگذاری...":"بارگذاری عکس اتاق"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-14",children:[(0,l.jsx)(H,{label:"قیمت پایه ( شنبه تا سه‌شنبه )",value:r.weekPrice,onChange:b("weekPrice")}),(0,l.jsx)(H,{label:"قیمت آخر هفته ( چهارشنبه، پنجشنبه، جمعه )",value:r.weekendPrice,onChange:b("weekendPrice")}),(0,l.jsx)(H,{label:"قیمت ایام پیک",value:r.peakPrice,onChange:b("peakPrice")}),(0,l.jsx)(H,{label:"نرخ هر نفر اضافه",value:r.extraPrice,onChange:b("extraPrice")}),(0,l.jsx)(H,{label:"نرخ هر نفر اضافه (ایام پیک)",value:r.extraPeakPrice,onChange:b("extraPeakPrice")}),(0,l.jsx)("div",{}),(0,l.jsx)(_,{label:"تخفیف رزرو هفتگی",value:r.weeklyDiscount,onChange:b("weeklyDiscount")}),(0,l.jsx)(_,{label:"تخفیف رزرو ماهانه",value:r.monthlyDiscount,onChange:b("monthlyDiscount")})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-14 pt-4 border-t border-gray-F0F0F0",children:[(0,l.jsx)(x.ZD,{label:"سیستم سرمایشی",checked:r.coolingSystem,onChange:b("coolingSystem")}),(0,l.jsx)(x.ZD,{label:"سیستم گرمایشی",checked:r.heatingSystem,onChange:b("heatingSystem")}),(0,l.jsx)(x.ZD,{label:"سرویس بهداشتی و حمام مجزا",checked:r.separateBathroom,onChange:b("separateBathroom")}),(0,l.jsx)(x.ZD,{label:"صبحانه رایگان",checked:r.freeBreakfast,onChange:b("freeBreakfast")}),(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"یخچال"}),(0,l.jsx)(x.Ph,{value:r.refrigerator,onChange:e=>b("refrigerator")(e.target.value),className:"w-full",children:Object.entries(Y.Pd).map(e=>{let[a,t]=e;return(0,l.jsx)("option",{value:a.toUpperCase(),children:t},a)})})]}),(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"سرویس فرنگی"}),(0,l.jsx)(x.Ph,{value:r.wc,onChange:e=>b("wc")(e.target.value),className:"w-full",children:Object.entries(Y.oJ).map(e=>{let[a,t]=e;return(0,l.jsx)("option",{value:a.toUpperCase(),children:t},a)})})]})]}),!!g&&(0,l.jsx)("p",{className:"text-12 text-[#C62828]",children:g}),(0,l.jsxs)("div",{className:"flex justify-end gap-x-8",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:t,children:"انصراف"}),(0,l.jsx)(x.zx,{disabled:h,onClick:N,children:h?"در حال ذخیره...":"ذخیره"})]})]})})}let q="فضای مشترک";function V(e){let{value:a,onChange:t,min:s=0,label:n}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,l.jsx)("span",{className:"text-13 leading-20 text-gray-6C6A7D whitespace-nowrap",children:n}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("button",{type:"button","aria-label":`کاهش ${n}`,onClick:()=>t(Math.max(s,a-1)),className:"w-24 h-24 rounded-full border border-gray-E5E5E6 text-gray-6C6A7D hover:bg-gray-F0F0F0 transition leading-none",children:"−"}),(0,l.jsx)("span",{className:"min-w-[28px] text-center text-14 font-m text-black",children:(0,x.N)(a)}),(0,l.jsx)("button",{type:"button","aria-label":`افزایش ${n}`,onClick:()=>t(a+1),className:"w-24 h-24 rounded-full border border-gray-E5E5E6 text-gray-6C6A7D hover:bg-gray-F0F0F0 transition leading-none",children:"+"})]})]})}function X(e){let{room:a,title:t,isRoomBookable:s,onChange:n,onRemove:r,onEditExtras:i}=e,d=e=>t=>n({...a,[e]:t});return(0,l.jsxs)("div",{className:"py-16 border-b border-gray-F0F0F0 last:border-0",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-12",children:[(0,l.jsx)("h4",{className:"text-14 leading-22 font-m text-black",children:t}),!!r&&(0,l.jsx)("button",{type:"button",onClick:r,"aria-label":`حذف ${t}`,className:"w-28 h-28 rounded-8 text-[#E53935] hover:bg-[#FFEBEB] transition",children:(0,l.jsx)("i",{className:"icon-Delete text-16"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-x-32 gap-y-12 flex-wrap",children:[(0,l.jsx)(V,{label:"تعداد تخت یک نفره",value:a.singleBed,onChange:d("singleBed")}),(0,l.jsx)(V,{label:"تعداد تخت دو نفره",value:a.doubleBed,onChange:d("doubleBed")}),(0,l.jsx)(V,{label:"تعداد رخت خواب",value:a.traditionalBed,onChange:d("traditionalBed")})]}),s&&(0,l.jsxs)("div",{className:"flex items-center gap-x-32 gap-y-12 flex-wrap mt-12",children:[(0,l.jsx)(V,{label:"ظرفیت این اتاق",value:a.capacity??1,onChange:e=>n({...a,capacity:e,maxCapacity:Math.max(a.maxCapacity??1,e)}),min:1}),(0,l.jsx)(V,{label:"حداکثر ظرفیت این اتاق",value:a.maxCapacity??a.capacity??1,onChange:e=>n({...a,maxCapacity:e}),min:a.capacity??1})]}),(0,l.jsx)("input",{value:a.description??"",onChange:e=>n({...a,description:e.target.value}),placeholder:"سایر موارد ( مثل مبل تاشو )",className:"w-full mt-12 px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),s&&!!i&&(0,l.jsxs)("button",{type:"button",onClick:i,className:"mt-12 w-full flex items-center justify-center gap-x-6 h-[38px] rounded-10 border border-dashed border-gray-DBDFE5 text-13 font-m text-primary-dark hover:border-primary-main transition",children:[(0,l.jsx)("i",{className:"icon-Edit text-14"}),"قیمت، عکس و امکانات این اتاق"]}),s&&!i&&void 0===a.id&&(0,l.jsx)("p",{className:"mt-10 text-11 text-gray-9B9BAA text-center",children:"برای تنظیم قیمت، عکس و امکانات، اول \xabذخیره\xbb کنید."})]})}function K(e){let{residenceId:a,residenceType:t,capacity:n,maxCapacity:r,rooms:i,onSaved:d}=e,c="BOOMGARDI"===t||"HOTEL"===t,m=i.find(e=>e.name===q)??{name:q,singleBed:0,doubleBed:0,traditionalBed:0,description:""},u=i.filter(e=>
1e.name!==q),[h,p]=(0,s.useState)(n??0),[g,j]=(0,s.useState)(r??0),[y,b]=(0,s.useState)(m),[f,N]=(0,s.useState)(u),[v,C]=(0,s.useState)(!1),[k,w]=(0,s.useState)(null),[E,A]=(0,s.useState)(null),[S,D]=(0,s.useState)(null),B=i.find(e=>e.id===S)??null;async function F(){C(!0),w(null);try{await (0,o.SC)(`/api/admin/residences/${a}/capacity`,{method:"PATCH",body:JSON.stringify({capacity:h,maxCapacity:g})}),await (0,o.SC)(`/api/admin/residences/${a}/rooms`,{method:"PUT",body:JSON.stringify({rooms:[y,...f].map(e=>({id:e.id,name:e.name,singleBed:Number(e.singleBed)||0,doubleBed:Number(e.doubleBed)||0,traditionalBed:Number(e.traditionalBed)||0,description:e.description||void 0,...c&&e!==y?{capacity:e.capacity||1,maxCapacity:e.maxCapacity||e.capacity||1}:{}}))})}),A(Date.now()),d()}catch(e){w(e instanceof Error?e.message:"خطا در ذخیره")}finally{C(!1)}}return(0,l.jsxs)("div",{className:"flex gap-x-16 items-start",children:[(0,l.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-16",children:"ظرفیت"}),(0,l.jsxs)("div",{className:"flex items-center gap-x-40 gap-y-12 flex-wrap",children:[(0,l.jsx)(V,{label:"ظرفیت پایه",value:h,onChange:p,min:1}),(0,l.jsx)(V,{label:"حداکثر ظرفیت",value:g,onChange:j,min:1})]}),g>0&&h>g&&(0,l.jsx)("p",{className:"mt-10 text-12 text-[#B26A00]",children:"ظرفیت پایه از حداکثر ظرفیت بیشتر است."})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"لیست اتاق ها"}),(0,l.jsxs)(x.zx,{variant:"secondary",onClick:function(){N(e=>[...e,{name:`اتاق ${e.length+1}`,singleBed:0,doubleBed:0,traditionalBed:0,description:"",capacity:1,maxCapacity:1}])},children:[(0,l.jsx)("i",{className:"icon-Plus text-16"})," افزودن اتاق"]})]}),(0,l.jsx)(X,{room:y,title:q,isRoomBookable:!1,onChange:b}),f.map((e,a)=>(0,l.jsx)(X,{room:e,title:e.name||`اتاق ${a+1}`,isRoomBookable:c,onChange:e=>N(t=>t.map((t,l)=>l===a?e:t)),onRemove:()=>N(e=>e.filter((e,t)=>t!==a)),onEditExtras:void 0!==e.id?()=>D(e.id):void 0},e.id??`new-${a}`)),0===f.length&&(0,l.jsx)("p",{className:"py-16 text-13 text-gray-9B9BAA",children:"اتاقی ثبت نشده — با \xabافزودن اتاق\xbb شروع کن."})]})]}),(0,l.jsxs)(x.Zb,{className:"p-12 w-[200px] shrink-0 flex flex-col gap-y-8 sticky top-[76px]",children:[(0,l.jsx)(x.zx,{onClick:F,disabled:v,children:v?"در حال ذخیره...":"ذخیره"}),(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>{p(n??0),j(r??0),b(m),N(u),w(null)},children:"انصراف"}),!!k&&(0,l.jsx)("p",{className:"text-12 text-[#C62828] mt-4",children:k}),!!E&&!k&&(0,l.jsx)("p",{className:"text-12 text-[#015046] mt-4",children:"ذخیره شد ✓"})]}),(0,l.jsx)(G,{room:B,onClose:()=>D(null),onSaved:d})]})}let W=["type","area","rent-type"];function Q(e){var a;let{residenceId:t,amenities:n,otherAmenities:r,onSaved:i}=e,{data:c,isLoading:m}=(0,d.u)("/api/admin/amenities",e=>(0,o.SC)(e)),u=(0,s.useMemo)(()=>{let e={};for(let l of n){var a,t;e[l.amenity.id]={checked:!0,extra:(null===(a=l.extraFeatures)||void 0===a?void 0:a.extra)??{},value:(null===(t=l.extraFeatures)||void 0===t?void 0:t.value)??"دارد"}}return e}
1,[n]),[h,p]=(0,s.useState)(u),[g,j]=(0,s.useState)(r??""),[y,b]=(0,s.useState)(null),[f,N]=(0,s.useState)(""),[v,C]=(0,s.useState)("all"),[k,w]=(0,s.useState)(!1),[E,A]=(0,s.useState)(null),[S,D]=(0,s.useState)(null);(0,s.useEffect)(()=>{p(u)},[u]),(0,s.useEffect)(()=>{j(r??"")},[r]);let B=(0,s.useMemo)(()=>(c??[]).filter(e=>!W.includes(e.key??"")),[c]),F=(0,s.useMemo)(()=>{let e=f.trim(),a=new Map;for(let l of B){var t;if(e&&!l.name.includes(e))continue;let s=!!(null===(t=h[l.id])||void 0===t?void 0:t.checked);if("on"===v&&!s||"off"===v&&s)continue;let n=l.category||"سایر";a.set(n,[...a.get(n)??[],l])}return[...a.entries()]},[B,f,v,h]),I=B.filter(e=>{var a;return null===(a=h[e.id])||void 0===a?void 0:a.checked}).length,P=F.reduce((e,a)=>{let[,t]=a;return e+t.length},0),$=B.filter(e=>{var a,t;return(null===(a=h[e.id])||void 0===a?void 0:a.checked)&&!(null===(t=u[e.id])||void 0===t?void 0:t.checked)}),O=B.filter(e=>{var a,t;return!(null===(a=h[e.id])||void 0===a?void 0:a.checked)&&(null===(t=u[e.id])||void 0===t?void 0:t.checked)}),T=g!==(r??""),z=$.length>0||O.length>0||T;async function M(){w(!0),D(null);try{await (0,o.SC)(`/api/admin/residences/${t}/amenities`,{method:"PATCH",body:JSON.stringify({amenities:B.filter(e=>{var a;return null===(a=h[e.id])||void 0===a?void 0:a.checked}).map(e=>{let a=h[e.id];return{amenityId:e.id,extraFeatures:{value:a.value??"دارد",...Object.keys(a.extra).length?{extra:a.extra}:{}}}}),other:g||void 0,scopeIds:B.map(e=>e.id)})}),A(Date.now()),i()}catch(e){D(e instanceof Error?e.message:"خطا در ذخیره")}finally{w(!1)}}return m?(0,l.jsx)("div",{className:"grid gap-12",children:Array.from({length:4}).map((e,a)=>(0,l.jsx)(x.Od,{className:"h-[90px]"},a))}):(0,l.jsxs)("div",{className:"flex gap-x-16 items-start",children:[(0,l.jsx)("div",{className:"flex-1 min-w-0 flex flex-col gap-y-16",children:(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-10 mb-14",children:[(0,l.jsxs)("h3",{className:"text-16 leading-24 font-m text-black",children:["امکانات",(0,l.jsxs)("span",{className:"text-13 font-r text-gray-6C6A7D",children:[" ","— ",(0,x.N)(I)," از ",(0,x.N)(B.length)," فعال"]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-8",children:[(0,l.jsx)("input",{value:f,onChange:e=>N(e.target.value),placeholder:"جستجوی امکانات...",className:"w-[190px] px-12 py-8 rounded-10 border border-gray-E5E5E6 text-13 leading-20 outline-none focus:border-primary-main"}),["all","on","off"].map(e=>(0,l.jsx)("button",{type:"button","aria-pressed":v===e,onClick:()=>C(e),className:`px-12 py-8 rounded-10 text-12 leading-20 border transition ${v===e?"border-primary-main bg-primary-light text-primary-dark font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:"all"===e?"همه":"on"===e?"دارد":"ندارد"},e))]})]}),0===P?(0,l.jsx)("p",{className:"py-32 text-center text-13 text-gray-9B9BAA",children:"امکاناتی با این جستجو پیدا نشد."}):F.map(e=>{let[a,t]=e,s=t.filter(e=>{var a;return null===(a=h[e.id])||void 0===a?void 0:a.checked}).length,n=s===t.length;return(0,l.jsxs)("section",{className:"mb-20 last:mb-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-10 mb-10",children:[(0,l.jsx)("h4",{className:"text-14 leading-22 font-m text-black",children:a}),(0,l.jsxs)("span",{className:"text-11 leading-18 text-gray-9B9BAA",children:[(0,x.N)(s)," از ",(0,x.N)(t.length)]}),(0,l.jsx)("button",{type:"button",onClick:()=>{p(e=>{let a={...e};return t.forEach(t=>{var l,s;a[t.id]={checked:!n,extra:(null===(l=e[t.id])||void 0===l?void 0:l.extra)??{},value:null===(s=e[t.id])||void 0===s?void 0:s.value}}),a}),A(null)},className:"mr-auto text-11 leading-18 text-gray-9B9BAA hover:text-primary-dark transition",children:n?"برداشتن همه":"انتخاب همه"})]}),(0,l.jsx)("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-10",children:t.map(e=>(0,l.jsx)(ee,{amenity:e,entry:h[e.id],onToggle:()=>{var a;return a=e.id,void(p(e=>{var t,l,s;return{...e,[a]:{checked:!(null===(t=e[a])||void 0===t?void 0:t.checked),extra:(null===(l=e[a])||void 0===l?void 0:l.extra)??{},value:null===(s=e[a])||void 0===s?void 0:s.value}}}),A(null))},onEditFeatures:()=>b(e)}
1,e.id))})]},a)}),(0,l.jsxs)("div",{className:"mt-16 pt-16 border-t border-gray-F0F0F0",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"سایر امکانات (متن آزاد)"}),(0,l.jsx)("textarea",{value:g,onChange:e=>{j(e.target.value),A(null)},rows:2,placeholder:"امکاناتی که در لیست بالا نیست...",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"})]})]})}),(0,l.jsxs)(x.Zb,{className:"p-14 w-[230px] shrink-0 flex flex-col gap-y-10 sticky top-[76px]",children:[z?(0,l.jsxs)("div",{className:"text-11 leading-18",children:[$.length>0&&(0,l.jsxs)("p",{className:"text-[#2E7D32] mb-4",children:["افزوده: ",$.map(e=>e.name).join("، ")]}),O.length>0&&(0,l.jsxs)("p",{className:"text-[#C62828] mb-4",children:["حذف: ",O.map(e=>e.name).join("، ")]}),T&&(0,l.jsx)("p",{className:"text-gray-6C6A7D mb-4",children:"متن \xabسایر امکانات\xbb تغییر کرده."})]}):(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA",children:"تغییری ثبت نشده."}),(0,l.jsx)(x.zx,{onClick:M,disabled:k||!z,children:k?"در حال ذخیره...":"ذخیره"}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:!z,onClick:()=>{p(u),j(r??""),D(null)},children:"بازگردانی"}),!!S&&(0,l.jsx)("p",{className:"text-12 text-[#C62828]",children:S}),!!E&&!S&&(0,l.jsx)("p",{className:"text-12 text-[#015046]",children:"ذخیره شد ✓"})]}),!!y&&(0,l.jsx)(ea,{amenity:y,value:(null===(a=h[y.id])||void 0===a?void 0:a.extra)??{},onClose:()=>b(null),onSave:e=>p(a=>{var t;return{...a,[y.id]:{checked:!0,extra:e,value:null===(t=a[y.id])||void 0===t?void 0:t.value}}})})]})}function ee(e){let{amenity:a,entry:t,onToggle:s,onEditFeatures:n}=e,r=!!(null==t?void 0:t.checked),i=Object.entries((null==t?void 0:t.extra)??{}).filter(e=>{let[,a]=e;return a}),d=a.features.length>0;return(0,l.jsxs)("div",{className:`rounded-12 border p-10 transition ${r?"border-primary-main bg-primary-light":"border-gray-E5E5E6 hover:border-gray-C4CAD3"}`,children:[(0,l.jsxs)("button",{type:"button",onClick:s,"aria-pressed":r,className:"w-full flex items-center gap-x-8 text-right",children:[(0,l.jsx)("span",{className:`w-18 h-18 rounded-6 border shrink-0 flex items-center justify-center text-11 leading-none ${r?"bg-primary-main border-primary-main text-white":"border-gray-C4CAD3"}`,children:r?"✓":""}),a.iconUrl?(0,l.jsx)("img",{src:a.iconUrl,alt:"",className:"w-18 h-18 shrink-0 opacity-70"}):(0,l.jsx)("i",{className:"icon-Possibilities text-16 text-gray-9B9BAA shrink-0"}),(0,l.jsx)("span",{className:`flex-1 min-w-0 truncate text-13 leading-20 ${r?"text-primary-dark font-m":"text-black"}`,children:a.name})]}),r&&d&&(0,l.jsxs)("div",{className:"mt-8 pr-26",children:[i.length>0?(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-6C6A7D break-words",children:i.map(e=>{let[a,t]=e;return`${a}: ${t}`}).join(" \xb7 ")}):(0,l.jsxs)("p",{className:"text-11 leading-18 text-gray-9B9BAA",children:[(0,x.N)(a.features.length)," جزئیات ثبت‌نشده"]}),(0,l.jsx)("button",{type:"button",onClick:n,className:"mt-4 text-11 leading-18 text-primary-dark hover:underline",children:i.length>0?"ویرایش جزئیات":"ثبت جزئیات"})]})]})}function ea(e){let{amenity:a,value:t,onClose:n,onSave:r}=e,[i,d]=(0,s.useState)(t),c=(e,a)=>d(t=>({...t,[e]:a}));return(0,l.jsx)(x.u_,{open:!0,onClose:n,title:`ویژگی های ${a.name}`,width:"max-w-[460px]",children:(0,l.jsxs)("div",{className:"flex flex-col gap-y-14",children:[a.features.map(e=>{let a=(e.values??"").split(",").map(e=>e.trim()).filter(Boolean);if("SWITCH"===e.fieldType||"CHECKBOX"===e.fieldType){let[t,s]=a.length>=2?a:["دارد","ندارد"],n=i[e.name]===t;return(0,l.jsxs)("label",{className:"flex items-center justify-between gap-x-12",children:[(0,l.jsx)("span",{className:"text-14 leading-22 text-black",children:e.name}),(0,l.jsxs)("span",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("span",{className:"text-12 text-gray-6C6A7D",children:n?t:s}
1),(0,l.jsx)(x.ZD,{checked:n,onChange:a=>c(e.name,a?t:s)})]})]},e.id)}return"DROPDOWN"===e.fieldType?(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:e.name}),(0,l.jsxs)("select",{value:i[e.name]??"",onChange:a=>c(e.name,a.target.value),className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 bg-white outline-none focus:border-primary-main transition",children:[(0,l.jsx)("option",{value:"",children:e.placeholder||"انتخاب کنید"}),a.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]})]},e.id):(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:e.name}),(0,l.jsx)("input",{value:i[e.name]??"",onChange:a=>c(e.name,a.target.value),placeholder:e.placeholder??"",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"})]},e.id)}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10 justify-between pt-4 flex-wrap gap-y-8",children:[(0,l.jsx)("span",{className:"text-11 leading-18 text-gray-9B9BAA",children:"برای ثبت نهایی، \xabذخیره\xbb کنار صفحه را بزنید."}),(0,l.jsxs)("span",{className:"flex items-center gap-x-8 shrink-0",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:n,children:"انصراف"}),(0,l.jsx)(x.zx,{onClick:()=>{r(Object.fromEntries(Object.entries(i).filter(e=>{let[,a]=e;return""!==a}))),n()},children:"تایید"})]})]})]})})}var et=t(11113);let el=[{key:"easy",label:"سهل گیرانه",tone:"text-[#15803D]",steps:["تا ۷ روز قبل از ورود مهمان: ۱۰۰٪ مبلغ کل رزرو به مهمان بازگردانده می‌شود","تا روز شروع اقامت: مبلغ ۱ شب اول رزرو + ۱۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود","از روز ورود به اقامتگاه: مبلغ شب‌های سپری شده + مبلغ ۱ شب بعد + ۱۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود"]},{key:"moderate",label:"متعادل",tone:"text-[#B26A00]",steps:["تا ۱۰ روز قبل از ورود مهمان: ۱۰۰٪ مبلغ کل رزرو به مهمان بازگردانده می‌شود","تا روز شروع اقامت: مبلغ ۲ شب اول رزرو + ۳۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود","از روز ورود به اقامتگاه: مبلغ شب‌های سپری شده + مبلغ ۲ شب بعد + ۳۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود"]},{key:"strict",label:"سخت گیرانه",tone:"text-[#C62828]",steps:["تا ۱۴ روز قبل از ورود مهمان: ۱۰۰٪ مبلغ کل رزرو به مهمان بازگردانده می‌شود","تا روز شروع اقامت: مبلغ ۳ شب اول رزرو + ۵۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود","از روز ورود به اقامتگاه: مبلغ شب‌های سپری شده + مبلغ ۳ شب بعد + ۵۰٪ مبلغ شب‌های باقی مانده به میزبان واریز می‌شود"]}],es=Array.from({length:24},(e,a)=>`${String(a).padStart(2,"0")}:00`);function en(e){let{value:a,onChange:t,label:s,unit:n,min:r=1}=e;return(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12",children:[(0,l.jsx)("span",{className:"text-13 leading-20 text-gray-6C6A7D",children:s}),(0,l.jsxs)("span",{className:"flex items-center gap-x-8",children:[(0,l.jsx)("button",{type:"button","aria-label":`کاهش ${s}`,onClick:()=>t(Math.max(r,a-1)),className:"w-24 h-24 rounded-full border border-gray-E5E5E6 text-gray-6C6A7D hover:bg-gray-F0F0F0 leading-none",children:"−"}),(0,l.jsxs)("span",{className:"min-w-[54px] text-center text-14 font-m text-black",children:[(0,x.N)(a)," ",n]}),(0,l.jsx)("button",{type:"button","aria-label":`افزایش ${s}`,onClick:()=>t(a+1),className:"w-24 h-24 rounded-full border border-gray-E5E5E6 text-gray-6C6A7D hover:bg-gray-F0F0F0 leading-none",children:"+"})]})]})}function er(e){var a;let{residenceId:t,rules:n,values:r,onSaved:i}=e,{data:c}=(0,d.u)("/api/admin/rules",e=>(0,o.SC)(e)),m=(0,s.useMemo)(()=>{let e={};for(let a of n)e[a.rule.id]="بله"===String(a.value??"");return e}
1,[n]),[u,h]=(0,s.useState)(m),[p,g]=(0,s.useState)(r.minReservableDays??1),[j,y]=(0,s.useState)(r.capacity??1),[b,f]=(0,s.useState)(r.checkinFrom??"14:00"),[N,v]=(0,s.useState)(r.checkout??"12:00"),[C,k]=(0,s.useState)(r.cancellationPolicy??"easy"),[w,E]=(0,s.useState)(r.hostRulesText??(null===(a=r.extraRules)||void 0===a?void 0:a.desc)??""),[A,S]=(0,s.useState)(!1),[D,B]=(0,s.useState)(null),[F,I]=(0,s.useState)(null),P=(c??[]).filter(e=>"cancellation"!==e.key);async function $(){S(!0),I(null);try{await (0,o.SC)(`/api/admin/residences/${t}/rules`,{method:"PATCH",body:JSON.stringify({rules:P.map(e=>({ruleId:e.id,value:u[e.id]?"بله":"خیر"})),checkinFrom:b,checkout:N,minReservableDays:p,rulesDesc:w||void 0,cancellationPolicy:C})}),B(Date.now()),i()}catch(e){I(e instanceof Error?e.message:"خطا در ذخیره")}finally{S(!1)}}return(0,l.jsxs)("div",{className:"flex gap-x-16 items-start",children:[(0,l.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"قوانین عمومی"}),(0,l.jsxs)("div",{className:"flex flex-col gap-y-12",children:[P.map(e=>(0,l.jsxs)("label",{className:"flex items-center justify-between gap-x-12",children:[(0,l.jsx)("span",{className:"text-13 leading-20 text-black",children:e.name}),(0,l.jsx)(x.ZD,{checked:!!u[e.id],onChange:a=>h(t=>({...t,[e.id]:a}))})]},e.id)),0===P.length&&(0,l.jsx)("p",{className:"text-13 text-gray-9B9BAA",children:"کاتالوگ قوانین خالی است — از تنظیمات ← قوانین اضافه کن."})]}),(0,l.jsxs)("div",{className:"mt-14",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"قوانین دلخواه میزبان"}),(0,l.jsx)("textarea",{value:w,onChange:e=>E(e.target.value),rows:3,placeholder:"توضیحات",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"})]})]}),(0,l.jsxs)(x.Zb,{className:"p-20 flex items-center gap-x-40 gap-y-12 flex-wrap",children:[(0,l.jsx)(en,{label:"حداقل تعداد شب رزرو",value:p,onChange:g,unit:"شب"}),(0,l.jsx)(en,{label:"حداقل تعداد نفرات برای رزرو",value:j,onChange:y,unit:"نفر"})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"ساعت ورود و خروج مهمان"}),(0,l.jsxs)("div",{className:"grid md:grid-cols-2 gap-12",children:[(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"ساعت ورود مهمان"}),(0,l.jsx)(x.Ph,{value:b,onChange:e=>f(e.target.value),className:"w-full",children:es.map(e=>(0,l.jsx)("option",{value:e,children:e},e))})]}),(0,l.jsxs)("label",{className:"block",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D",children:"ساعت خروج مهمان"}),(0,l.jsx)(x.Ph,{value:N,onChange:e=>v(e.target.value),className:"w-full",children:es.map(e=>(0,l.jsx)("option",{value:e,children:e},e))})]})]})]}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"قوانین لغو رزرو"}),(0,l.jsx)("div",{className:"grid md:grid-cols-3 gap-16",children:el.map(e=>(0,l.jsxs)("label",{className:`rounded-12 border p-14 cursor-pointer transition ${C===e.key?"border-primary-main bg-[#03D6BB0A]":"border-gray-E5E5E6 hover:border-gray-D2D2D7"}`,children:[(0,l.jsxs)("span",{className:"flex items-center gap-x-8 mb-10",children:[(0,l.jsx)("input",{type:"radio",name:"cancellation",checked:C===e.key,onChange:()=>k(e.key),className:"accent-primary-main"}),(0,l.jsx)("span",{className:`text-14 leading-22 font-m ${e.tone}`,children:e.label})]}),(0,l.jsx)("ol",{className:"flex flex-col gap-y-8",children:e.steps.map((e,a)=>(0,l.jsx)("li",{className:"text-11 leading-18 text-gray-6C6A7D",children:e},a))})]},e.key))})]})]}),(0,l.jsxs)(x.Zb,{className:"p-12 w-[200px] shrink-0 flex flex-col gap-y-8 sticky top-[76px]",children:[(0,l.jsx)(x.zx,{onClick:$,disabled:A,children:A?"در حال ذخیره...":"ویرایش قوانین"}),(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>{h(m),g(r.minReservableDays??1),f(r.checkinFrom??"14:00"),v(r.checkout??"12:00"),k(r.cancellationPolicy??"easy"),I(null)},children:"انصراف"}),!!F&&(0,l.jsx)("p",{className:"text-12 text-[#C62828] mt-4",children:F}),!!D&&!F&&(0,l.jsx)("p",{className:"text-12 text-[#015046] mt-4",children:"ذخیره شد ✓"})]})]})}let ei=[{key:"HOST_APPROVAL",label:"در انتظار تایید میزبان",tone:"yellow"},{key:"SECOND_PAYMENT",label:"در انتظار پرداخت نهایی",tone:"yellow"},{key:"DONE",label:"تکمیل شده",tone:"green"},{key:"CANCEL",label:"لغو شده",tone:"red"},{key:"EXPIRED",label:"منقضی شده",tone:"gray"}],ed=Object.fromEntries(ei.map(e=>[e.key,e])),ec=["ردیف","کد رزرو","ثبت رزرو","تاریخ شروع","مهمان","شب","مبلغ کل (تومان)","پرداختی (تومان)","سهم لیدوما (تومان)","وضعیت","رزرو قبلی مهمان"];function eo(e){let{residenceId:a}
1=e,[t,n]=(0,s.useState)(""),[i,c]=(0,s.useState)(1),m=new URLSearchParams({residenceId:String(a),page:String(i),pageSize:"20",...t?{state:t}:{}}),{data:u,isLoading:h}=(0,d.u)(`/api/admin/reservations?${m.toString()}`,e=>(0,o.Px)(e)),p=(null==u?void 0:u.items)??[],g=(null==u?void 0:u.meta.total)??0,j=Math.max((null==u?void 0:u.meta.pageCount)??1,1),y=e=>p.reduce((a,t)=>a+e(t),0);return(0,l.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,l.jsx)(x.Zb,{className:"p-16",children:(0,l.jsxs)("div",{className:"flex items-center gap-x-6 flex-wrap gap-y-6",children:[(0,l.jsx)(ex,{active:""===t,onClick:()=>{n(""),c(1)},children:"همه"}),ei.map(e=>(0,l.jsx)(ex,{active:t===e.key,onClick:()=>{n(e.key),c(1)},children:e.label},e.key)),(0,l.jsxs)("span",{className:"mr-auto text-12 leading-20 text-gray-9B9BAA",children:[(0,x.N)(g)," رزرو"]})]})}),p.length>0&&(0,l.jsxs)("section",{className:"grid grid-cols-2 md:grid-cols-4 gap-12",children:[(0,l.jsx)(em,{label:"مبلغ کل",value:(0,x.ND)(y(e=>e.totalAmount))}),(0,l.jsx)(em,{label:"پرداختی مهمان",value:(0,x.ND)(y(e=>e.paidAmount))}),(0,l.jsx)(em,{label:"سهم لیدوما",value:(0,x.ND)(y(e=>e.websiteShare??0))}),(0,l.jsx)(em,{label:"شب‌های فروخته‌شده",value:`${(0,x.N)(y(e=>e.daysCount))} شب`})]}),(0,l.jsx)(x.Zb,{className:"overflow-x-auto",children:h?(0,l.jsx)(x.Od,{className:"h-[240px]"}):0===p.length?(0,l.jsx)(x.ub,{text:t?"در این وضعیت رزروی نیست":"برای این اقامتگاه رزروی ثبت نشده"}):(0,l.jsxs)("table",{className:"w-full text-right border-collapse",children:[(0,l.jsx)("thead",{children:(0,l.jsx)("tr",{className:"bg-gray-F7F7F7",children:ec.map(e=>(0,l.jsx)("th",{className:"px-12 py-10 text-12 leading-18 font-m text-gray-6C6A7D whitespace-nowrap",children:e},e))})}),(0,l.jsx)("tbody",{children:p.map((e,a)=>{let t=ed[e.state],[s,n]=(0,x.A1)(e.createdAt);return(0,l.jsxs)("tr",{className:"border-t border-gray-F0F0F0 hover:bg-gray-F7F7F7 transition",children:[(0,l.jsx)("td",{className:"px-12 py-12 text-13 text-gray-6C6A7D",children:(0,x.N)((i-1)*20+a+1)}),(0,l.jsx)("td",{className:"px-12 py-12 whitespace-nowrap",children:(0,l.jsx)(r(),{href:`/admin/reservations/${e.id}`,className:"text-13 font-m text-primary-dark hover:text-primary-main",children:e.reference})}),(0,l.jsxs)("td",{className:"px-12 py-12 whitespace-nowrap",children:[(0,l.jsx)("div",{className:"text-13 leading-20 text-black",children:s}),(0,l.jsx)("div",{className:"text-12 leading-18 text-gray-6C6A7D",children:n})]}),(0,l.jsx)("td",{className:"px-12 py-12 text-13 whitespace-nowrap",children:(0,w.R3)(e.startDate)}),(0,l.jsxs)("td",{className:"px-12 py-12",children:[(0,l.jsx)("div",{className:"text-14 leading-20 text-black",children:e.guest.name||"بدون نام"}),(0,l.jsx)("div",{className:"text-12 leading-18 text-gray-6C6A7D",dir:"ltr",children:e.guest.phone})]}),(0,l.jsx)("td",{className:"px-12 py-12 text-14",children:(0,x.N)(e.daysCount)}),(0,l.jsx)("td",{className:"px-12 py-12 text-14 font-m whitespace-nowrap",children:(0,x.N)(e.totalAmount)}),(0,l.jsxs)("td",{className:"px-12 py-12 text-14 whitespace-nowrap",children:[(0,x.N)(e.paidAmount),e.paidAmount<e.totalAmount&&(0,l.jsxs)("div",{className:"text-11 leading-16 text-gray-6C6A7D",children:["مانده ",(0,x.N)(e.totalAmount-e.paidAmount)]})]}),(0,l.jsx)("td",{className:"px-12 py-12 text-14 whitespace-nowrap",children:null==e.websiteShare?(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"—"}):(0,x.N)(e.websiteShare)}),(0,l.jsx)("td",{className:"px-12 py-12 whitespace-nowrap",children:(0,l.jsx)(x.Ct,{tone:(null==t?void 0:t.tone)??"gray",children:(null==t?void 0:t.label)??e.state})}),(0,l.jsx)("td",{className:"px-12 py-12 text-14",children:e.guestPreviousCount>0?(0,x.N)(e.guestPreviousCount):(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"۰"})})]},e.id)})})]})}),p.length>0&&(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8",children:[(0,l.jsxs)("span",{className:"text-11 leading-18 text-gray-9B9BAA",children:["جمع‌های بالا مربوط به همین صفحه است، نه کل ",(0,x.N)(g)," رزرو."]}),j>1&&(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)(x.zx,{variant:"secondary",disabled:i<=1,onClick:()=>c(e=>e-1),children:"قبلی"}),(0,l.jsxs)("span",{className:"text-13 text-gray-6C6A7D",children:["صفحه ",(0,x.N)(i)," از ",(0,x.N)(j)]}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:i>=j,onClick:()=>c(e=>e+1),children:"بعدی"})]})]})]})}function ex(e){let{active:a,onClick:t,children:s}=e;return(0,l.jsx)("button",{type:"button","aria-pressed":a,onClick:t,className:`px-12 py-6 rounded-10 text-12 leading-20 border transition ${a?"border-primary-main bg-primary-light text-primary-dark font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:s})}function em(e){let{label:a,value:t}=e;return(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-12",children:[(0,l.jsx)("span",{className:"block text-11 leading-18 text-gray-9B9BAA mb-4",children:a}),(0,l.jsx)("strong",{className:"block text-14 leading-22 font-m text-black",children:t})]})}function eu(e){let{residenceId:a,onSaved:t}
1=e,[n,r]=(0,s.useState)(""),[i,c]=(0,s.useState)(!1),[m,u]=(0,s.useState)(null),{data:h,isLoading:p,mutate:g}=(0,d.u)(`/api/admin/residences/${a}/rank`,e=>(0,o.SC)(e)),j=null==h?void 0:h.importance;(0,s.useEffect)(()=>{void 0!==j&&r(String(j))},[j]);let y=(0,x.EU)(n),b=!!h&&y!==h.importance,{data:f}=(0,d.u)(b?`/api/admin/residences/${a}/rank?importance=${y}`:null,e=>(0,o.SC)(e));async function N(){c(!0),u(null);try{await (0,o.SC)(`/api/admin/residences/${a}`,{method:"PATCH",body:JSON.stringify({importance:y})}),g(),t()}catch(e){u(e instanceof Error?e.message:"ذخیره نشد")}finally{c(!1)}}return p||!h||"number"!=typeof h.importance?(0,l.jsx)(x.Od,{className:"h-[220px]"}):(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap gap-y-8 mb-14",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"اهمیت و رتبه در جستجو"}),h.city&&(0,l.jsx)(x.Ct,{tone:"gray",children:h.city.name})]}),h.city?h.published?(0,l.jsxs)("div",{className:"flex items-center gap-x-16 flex-wrap gap-y-10 mb-14",children:[(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 px-16 py-10",children:[(0,l.jsx)("span",{className:"block text-11 leading-18 text-gray-9B9BAA mb-2",children:"رتبه فعلی"}),(0,l.jsx)("strong",{className:"text-20 leading-28 font-m text-black",children:(0,x.N)(h.current_rank??0)}),(0,l.jsxs)("span",{className:"text-12 text-gray-6C6A7D",children:[" از ",(0,x.N)(h.total)]})]}),(null==f?void 0:f.simulated_rank)!=null&&f.simulated_rank!==h.current_rank&&(0,l.jsxs)("div",{className:"rounded-12 border border-[#B26A00] bg-[#FFF4E0] px-16 py-10",children:[(0,l.jsx)("span",{className:"block text-11 leading-18 text-[#B26A00] mb-2",children:"با مقدار جدید"}),(0,l.jsx)("strong",{className:"text-20 leading-28 font-m text-[#B26A00]",children:(0,x.N)(f.simulated_rank)}),(0,l.jsxs)("span",{className:"text-12 text-[#B26A00]",children:[" از ",(0,x.N)(f.total)]})]})]}):(0,l.jsx)("p",{className:"text-13 leading-22 text-[#B26A00]",children:"این اقامتگاه منتشر نشده و در نتایج جستجو دیده نمی‌شود. \xabاهمیت\xbb ذخیره می‌شود ولی تا زمان انتشار اثری ندارد."}):(0,l.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D",children:"این اقامتگاه به شهری وصل نیست، پس رتبه‌ای در نتایج شهر ندارد."}),(0,l.jsxs)("div",{className:"flex items-end gap-x-8 mb-4",children:[(0,l.jsxs)("label",{className:"flex-1 min-w-0",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"اهمیت اقامتگاه"}),(0,l.jsx)("input",{inputMode:"numeric",value:y?(0,x.XO)(y):"",onChange:e=>r(e.target.value),className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"})]}),(0,l.jsx)(x.zx,{disabled:i||!b,onClick:N,children:i?"در حال ذخیره...":"ذخیره"}),b&&(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>r(String(h.importance)),children:"بازگردانی"})]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-14",children:"عدد بزرگ‌تر یعنی بالاتر در \xabپیشنهاد لیدوما\xbb. در تساوی، امتیاز و بعد تازگی تعیین‌کننده است."}),(h.neighbours??[]).length>0&&(0,l.jsx)("div",{className:"rounded-12 border border-gray-E5E5E6 divide-y divide-gray-F0F0F0",children:(h.neighbours??[]).map(e=>(0,l.jsxs)("div",{className:`flex items-center gap-x-10 px-12 py-8 ${e.isSelf?"bg-primary-light":""}`,children:[(0,l.jsx)("span",{className:`w-28 text-center text-12 leading-20 ${e.isSelf?"text-primary-dark font-m":"text-gray-9B9BAA"}`,children:(0,x.N)(e.rank)}),(0,l.jsx)("span",{className:`flex-1 min-w-0 truncate text-13 leading-20 ${e.isSelf?"text-primary-dark font-m":"text-black"}`,children:e.name}),(0,l.jsx)("span",{className:"text-11 leading-18 text-gray-9B9BAA whitespace-nowrap",children:(0,x.XO)(e.importance)})]},e.id))}),m&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:m})]})}function eh(e){let{residenceId:a,onSaved:t}=e,{data:n,isLoading:r,mutate:i}=(0,d.u)(`/api/admin/residences/${a}/classification`,e=>
1(0,o.SC)(e)),[c,m]=(0,s.useState)(null),[u,h]=(0,s.useState)(null);async function p(e,l){let s=e.selected.includes(l)?e.selected.filter(e=>e!==l):[...e.selected,l];m(e.key),h(null);try{await (0,o.SC)(`/api/admin/residences/${a}/classification`,{method:"PATCH",body:JSON.stringify({key:e.key,values:s})}),i(),t()}catch(e){h(e instanceof Error?e.message:"ذخیره نشد")}finally{m(null)}}return r||!n?(0,l.jsx)(x.Od,{className:"h-[180px]"}):(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-2",children:"دسته‌بندی اقامتگاه"}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-14",children:"صفحه‌های تگ سئو از همین دو مورد ساخته می‌شوند — تغییرشان یعنی این اقامتگاه در فهرست‌های دیگری دیده می‌شود."}),(0,l.jsx)("div",{className:"flex flex-col gap-y-16",children:n.fields.map(e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-8 mb-8",children:[(0,l.jsx)("span",{className:"text-13 leading-20 font-m text-black",children:e.name}),0===e.selected.length&&(0,l.jsx)(x.Ct,{tone:"yellow",children:"ثبت نشده"}),c===e.key&&(0,l.jsx)("span",{className:"text-11 text-gray-9B9BAA",children:"در حال ذخیره..."})]}),0===e.options.length?(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA",children:"مقداری برای این دسته‌بندی در سامانه ثبت نشده است."}):(0,l.jsx)("div",{className:"flex flex-wrap gap-8",children:e.options.map(a=>{let t=e.selected.includes(a);return(0,l.jsx)("button",{type:"button","aria-pressed":t,disabled:c===e.key,onClick:()=>p(e,a),className:`px-12 py-6 rounded-10 text-12 leading-20 border transition disabled:opacity-50 ${t?"border-primary-main bg-primary-light text-primary-dark font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:a},a)})})]},e.key))}),u&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:u})]})}function ep(e){let{residenceId:a,suspendedAt:t,suspensionReason:n,onSaved:r}=e,[i,d]=(0,s.useState)(!1),[c,m]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null);async function p(){m(!0),h(null);try{await (0,o.SC)(`/api/admin/residences/${a}/unsuspend`,{method:"POST"}),r()}catch(e){h(e instanceof Error?e.message:"رفع تعلیق انجام نشد")}finally{m(!1)}}return(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"تعلیق"}),t?(0,l.jsx)(x.Ct,{tone:"red",children:"معلق"}):(0,l.jsx)(x.Ct,{tone:"gray",children:"معلق نیست"})]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-14",children:"مستقل از فعال/غیرفعال‌سازی خود میزبان — اقامتگاه معلق حتی اگر میزبان آن را فعال نگه داشته باشد، در سایت نمایش داده نمی‌شود."}),t?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{className:"text-13 leading-22 text-black mb-4",children:["از ",(0,x.IY)(t)," معلق است."]}),!!n&&(0,l.jsxs)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-14",children:["دلیل نمایش‌داده‌شده به میزبان: ",n]}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:c,onClick:p,children:c?"در حال ثبت...":"رفع تعلیق"})]}):(0,l.jsx)(x.zx,{variant:"danger",onClick:()=>d(!0),children:"تعلیق اقامتگاه"}),u&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:u}),(0,l.jsx)(eg,{open:i,residenceId:a,onClose:()=>d(!1),onDone:()=>{d(!1),r()}})]})}function eg(e){let{open:a,residenceId:t,onClose:n,onDone:r}=e,[i,d]=(0,s.useState)(""),[c,m]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null),j=i.trim().length>=3&&c.trim().length>=3;async function y(e){if(e.preventDefault(),j){h(!0),g(null);try{await (0,o.SC)(`/api/admin/residences/${t}/suspend`,{method:"POST",body:JSON.stringify({internalNote:i.trim(),reason:c.trim()})}),r()}catch(e){g(e instanceof Error?e.message:"ثبت نشد")}finally{h(!1)}}}return(0,l.jsx)(x.u_,{open:a,onClose:n,title:"تعلیق اقامتگاه",width:"max-w-[520px]",children:(0,l.jsxs)("form",{onSubmit:y,className:"flex flex-col gap-y-14",children:[(0,l.jsx)(x.gN,{label:"توضیحات داخلی (فقط برای تیم پشتیبانی)",hint:"روی سایت یا برای میزبان نمایش داده نمی‌شود.",children:(0,l.jsx)("textarea",{value:i,onChange:e=>d(e.target.value),rows:3,className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition",placeholder:"مثلاً: گزارش کلاهبرداری در حال بررسی توسط تیم حقوقی"})}),(0,l.jsx)(x.gN,{label:"دلیل نمایشی (به میزبان نشان داده می‌شود)",children:(0,l.jsx)("textarea",{value:c,onChange:e=>m(e.target.value),rows:3,className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition",placeholder:"مثلاً: در حال بررسی گزارش‌های ثبت‌شده در مورد این اقامتگاه هستیم"})}),!!p&&(0,l.jsx)("p",{className:"text-13 text-[#C62828]",children:p}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10 justify-end",children:[(0,l.jsx)(x.zx,{type:"button",variant:"secondary",onClick:n,children:"انصراف"}),(0,l.jsx)(x.zx,{type:"submit",variant:"danger",disabled:!j||u,children:u?"در حال ثبت...":"تعلیق Ú©Ù
1†"})]})]})})}let ej={DETAILS:"نوع و منطقه اقامتگاه",SPECS:"نام و توضیحات",LOCATION:"آدرس و محل دقیق",CAPACITY:"ظرفیت و اتاق‌ها",AMENITIES:"امکانات",PRICING:"نرخ‌گذاری",GALLERY:"گالری تصاویر",DOCUMENTS:"مدارک",RULES:"قوانین و شرایط",OTHER:"سایر"};function ey(e){let{residenceId:a,defects:t,onSaved:n}=e,[r,i]=(0,s.useState)(!1),[d,c]=(0,s.useState)(null),[m,u]=(0,s.useState)(null),h=t.filter(e=>!e.resolvedAt),p=t.filter(e=>!!e.resolvedAt);async function g(e){c(e),u(null);try{await (0,o.SC)(`/api/admin/defects/${e}/resolve`,{method:"POST"}),n()}catch(e){u(e instanceof Error?e.message:"ثبت نشد")}finally{c(null)}}return(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-12",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"نقص‌ها"}),(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>i(!0),children:"+ ثبت نقص"})]}),0===t.length?(0,l.jsx)(x.ub,{text:"نقصی برای این اقامتگاه ثبت نشده"}):(0,l.jsxs)("div",{className:"flex flex-col gap-y-10",children:[h.map(e=>(0,l.jsxs)("div",{className:"rounded-10 border border-gray-E5E5E6 p-12",children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-4 mb-6",children:[(0,l.jsx)(x.Ct,{tone:"MANDATORY"===e.severity?"red":"yellow",children:"MANDATORY"===e.severity?"اجباری":"پیشنهادی"}),(0,l.jsx)("span",{className:"text-13 font-m text-black",children:ej[e.section]}),e.reviewRequestedAt&&(0,l.jsx)(x.Ct,{tone:"blue",children:"میزبان درخواست بررسی مجدد داده"}),(0,l.jsx)("span",{className:"text-11 text-gray-9B9BAA mr-auto",children:(0,x.IY)(e.createdAt)})]}),(0,l.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D mb-10",children:e.description}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:d===e.id,onClick:()=>g(e.id),children:d===e.id?"در حال ثبت...":"برطرف‌شده ثبت کن"})]},e.id)),p.length>0&&(0,l.jsxs)("details",{className:"mt-4",children:[(0,l.jsxs)("summary",{className:"text-12 text-gray-6C6A7D cursor-pointer",children:[p.length," نقص برطرف‌شده"]}),(0,l.jsx)("div",{className:"flex flex-col gap-y-8 mt-8",children:p.map(e=>(0,l.jsxs)("div",{className:"rounded-10 bg-gray-F7F7F7 p-12",children:[(0,l.jsxs)("div",{className:"flex items-center gap-x-8 mb-4",children:[(0,l.jsx)(x.Ct,{tone:"green",children:"برطرف‌شده"}),(0,l.jsx)("span",{className:"text-12 font-m text-black",children:ej[e.section]})]}),(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D",children:e.description})]},e.id))})]})]}),m&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:m}),(0,l.jsx)(eb,{open:r,residenceId:a,onClose:()=>i(!1),onDone:()=>{i(!1),n()}})]})}function eb(e){let{open:a,residenceId:t,onClose:n,onDone:r}=e,[i,d]=(0,s.useState)("SPECS"),[c,m]=(0,s.useState)("SUGGESTED"),[u,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),b=u.trim().length>=3;async function f(e){if(e.preventDefault(),b){g(!0),y(null);try{await (0,o.SC)(`/api/admin/residences/${t}/defects`,{method:"POST",body:JSON.stringify({section:i,severity:c,description:u.trim()})}),h(""),r()}catch(e){y(e instanceof Error?e.message:"ثبت نشد")}finally{g(!1)}}}return(0,l.jsx)(x.u_,{open:a,onClose:n,title:"ثبت نقص",width:"max-w-[480px]",children:(0,l.jsxs)("form",{onSubmit:f,className:"flex flex-col gap-y-14",children:[(0,l.jsx)(x.gN,{label:"بخش دارای نقص",children:(0,l.jsx)(x.Ph,{value:i,onChange:e=>d(e.target.value),className:"w-full",children:Object.keys(ej).map(e=>(0,l.jsx)("option",{value:e,children:ej[e]},e))})}),(0,l.jsx)(x.gN,{label:"نوع نقص",children:(0,l.jsxs)("div",{className:"flex gap-x-16",children:[(0,l.jsxs)("label",{className:"flex items-center gap-x-6 text-13",children:[(0,l.jsx)("input",{type:"radio",checked:"SUGGESTED"===c,onChange:()=>m("SUGGESTED")}),"پیشنهادی — اقامتگاه فعال می‌ماند"]}),(0,l.jsxs)("label",{className:"flex items-center gap-x-6 text-13",children:[(0,l.jsx)("input",{type:"radio",checked:"MANDATORY"===c,onChange:()=>m("MANDATORY")}),"اجباری — اقامتگاه غیرفعال می‌شود"]})]})}),(0,l.jsx)(x.gN,{label:"توضیحات و راهنمای رفع ایراد",children:(0,l.jsx)("textarea",{value:u,onChange:e=>h(e.target.value),rows:4,className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition",placeholder:"مثلاً: عکس اصلی اقامتگاه واضح نیست، لطفاً یک عکس با نور بهتر جایگزین Ú©Ù
1†ÛŒØ¯"})}),!!j&&(0,l.jsx)("p",{className:"text-13 text-[#C62828]",children:j}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10 justify-end",children:[(0,l.jsx)(x.zx,{type:"button",variant:"secondary",onClick:n,children:"انصراف"}),(0,l.jsx)(x.zx,{type:"submit",disabled:!b||p,children:p?"در حال ثبت...":"ثبت نقص"})]})]})})}let ef={specs:"نام و توضیحات",amenities:"امکانات",rules:"قوانین و شرایط",pricing:"نرخ‌گذاری",capacity:"ظرفیت و اتاق‌ها",gallery:"تصاویر",documents:"مدارک"},eN={name:"نام",description:"توضیحات",floor:"طبقه",totalArea:"متراژ کل",foundationArea:"زیربنا",weekPrice:"نرخ روزهای عادی",weekendPrice:"نرخ آخر هفته",peakPrice:"نرخ ایام پیک",extraGuestsPrice:"نرخ نفر اضافه",weeklyDiscount:"تخفیف هفتگی",monthlyDiscount:"تخفیف ماهانه",capacity:"ظرفیت استاندارد",maxCapacity:"حداکثر ظرفیت",checkinFrom:"ورود از",checkinTo:"ورود تا",checkout:"خروج",minReservableDays:"حداقل شب رزرو",cancellationPolicy:"قانون لغو",other:"سایر امکانات (متن آزاد)",documentUrl:"سند اقامتگاه",hostNationalCardUrl:"کارت ملی میزبان",ownerNationalCardUrl:"کارت ملی مالک"};function ev(e){let{proposal:a,liveImages:t}=e,s=a.add??[],n=t.filter(e=>(a.removeIds??[]).includes(e.id));return(0,l.jsxs)("div",{className:"flex flex-col gap-y-12",children:[s.length>0&&(0,l.jsxs)("div",{children:[(0,l.jsxs)("p",{className:"text-12 text-gray-6C6A7D mb-6",children:["تصاویر پیشنهادی برای افزودن (",s.length,")"]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-8",children:s.map((e,a)=>(0,l.jsx)("img",{src:(0,x.vD)(e.url,240),alt:"",className:"w-[96px] h-[72px] object-cover rounded-8 border border-gray-E5E5E6"},`${e.url}-${a}`))})]}),n.length>0&&(0,l.jsxs)("div",{children:[(0,l.jsxs)("p",{className:"text-12 text-gray-6C6A7D mb-6",children:["تصاویری که حذف می‌شوند (",n.length,")"]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-8",children:n.map(e=>(0,l.jsx)("img",{src:(0,x.vD)(e.url,240),alt:"",className:"w-[96px] h-[72px] object-cover rounded-8 border-2 border-[#C62828] opacity-60"},e.id))})]}),void 0!==a.main&&null!==a.main&&(0,l.jsx)("p",{className:"text-12 text-gray-6C6A7D",children:"میزبان تصویر اصلی را عوض کرده است."}),0===s.length&&0===n.length&&null==a.main&&(0,l.jsx)("p",{className:"text-12 text-gray-9B9BAA",children:"فقط ترتیب تصاویر تغییر کرده است."})]})}function eC(e){let{residenceId:a,residence:t,pendingChanges:n,submittedAt:r,onSaved:i}=e,[d,c]=(0,s.useState)(!1),[m,u]=(0,s.useState)(!1),[h,p]=(0,s.use
1State)(null),g=Object.keys(n);if(0===g.length)return null;async function j(){u(!0),p(null);try{await (0,o.SC)(`/api/admin/residences/${a}/pending-changes/approve`,{method:"POST"}),i()}catch(e){p(e instanceof Error?e.message:"تأیید انجام نشد")}finally{u(!1)}}return(0,l.jsxs)(x.Zb,{className:"p-20 border-2 border-blue-main/30",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black",children:"ویرایش در انتظار بررسی"}),(0,l.jsx)(x.Ct,{tone:"blue",children:r?(0,x.IY)(r):""})]}),(0,l.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mb-14",children:"تا زمان تأیید یا رد، نسخه‌ی فعلی (ستون \xabالان روی سایت\xbb) همچنان برای مهمان‌ها نمایش داده می‌شود."}),(0,l.jsx)("div",{className:"flex flex-col gap-y-16 mb-16",children:g.map(e=>{let a=n[e]??{},s=Object.entries(a).filter(e=>{let[a]=e;return"step"!==a&&"scopeIds"!==a});return"gallery"===e?(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{className:"text-13 font-m text-black mb-8",children:ef[e]}),(0,l.jsx)(ev,{proposal:a,liveImages:t.images??[]})]},e):(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{className:"text-13 font-m text-black mb-8",children:ef[e]??e}),(0,l.jsx)("div",{className:"overflow-x-auto rounded-10 border border-gray-E5E5E6",children:(0,l.jsxs)("table",{className:"w-full min-w-[480px] text-right text-12",children:[(0,l.jsx)("thead",{className:"bg-gray-F7F7F7 text-gray-6C6A7D",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-8 font-r",children:"فیلد"}),(0,l.jsx)("th",{className:"p-8 font-r",children:"الان روی سایت"}),(0,l.jsx)("th",{className:"p-8 font-r",children:"پیشنهاد میزبان"})]})}),(0,l.jsx)("tbody",{children:s.map(e=>{let[a,s]=e,n="documentUrl"===a||"hostNationalCardUrl"===a||"ownerNationalCardUrl"===a,r=e=>n&&"string"==typeof e&&e?(0,l.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-[#0B6BCB] underline",children:"مشاهده"}):null==e||""===e?"—":Array.isArray(e)?`${e.length} مورد`:"object"==typeof e?JSON.stringify(e):String(e);return(0,l.jsxs)("tr",{className:"border-t border-gray-F0F0F0",children:[(0,l.jsx)("td",{className:"p-8 text-gray-6C6A7D",children:eN[a]??a}),(0,l.jsx)("td",{className:"p-8 text-gray-9B9BAA",children:r(t[a])}),(0,l.jsx)("td",{className:"p-8 font-m text-black",children:r(s)})]},a)})})]})})]},e)})}),!!h&&(0,l.jsx)("p",{className:"mb-10 text-13 text-[#C62828]",children:h}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,l.jsx)(x.zx,{disabled:m,onClick:j,children:m?"در حال ثبت...":"تأیید و اعمال روی سایت"}),(0,l.jsx)(x.zx,{variant:"secondary",disabled:m,onClick:()=>c(!0),children:"رد با ذکر دلیل"})]}),(0,l.jsx)(ek,{open:d,residenceId:a,onClose:()=>c(!1),onDone:()=>{c(!1),i()}})]})}function ek(e){let{open:a,residenceId:t,onClose:n,onDone:r}=e,[i,d]=(0,s.useState)(""),[c,m]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null);async function p(e){if(e.preventDefault(),!(i.trim().length<3)){m(!0),h(null);try{await (0,o.SC)(`/api/admin/residences/${t}/pending-changes/reject`,{method:"POST",body:JSON.stringify({reason:i.trim()})}),r()}catch(e){h(e instanceof Error?e.message:"ثبت نشد")}finally{m(!1)}}}return(0,l.jsx)(x.u_,{open:a,onClose:n,title:"رد تغییرات پیشنهادی",width:"max-w-[460px]",children:(0,l.jsxs)("form",{onSubmit:p,className:"flex flex-col gap-y-12",children:[(0,l.jsx)("textarea",{value:i,onChange:e=>d(e.target.value),rows:4,placeholder:"دلیل رد تغییرات را بنویسید...",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),!!u&&(0,l.jsx)("p",{className:"text-13 text-[#C62828]",children:u}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10 justify-end",children:[(0,l.jsx)(x.zx,{type:"button",variant:"secondary",onClick:n,children:"انصراف"}),(0,l.jsx)(x.zx,{type:"submit",variant:"danger",disabled:i.trim().length<3||c,children:c?"در حال ثبت...":"رد کن"})]})]})})}function ew(e){var a,t;let{open:n,onClose:r,residenceId:i,currentHostId:c,onSaved:m}
1=e,[u,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(null),[j,y]=(0,s.useState)(null),[b,f]=(0,s.useState)(""),[N,v]=(0,s.useState)(!1),[C,k]=(0,s.useState)(null);(0,s.useEffect)(()=>{n&&(h(""),g(null),y(null),f(""),k(null))},[n]);let{data:w,isLoading:E}=(0,d.u)(n&&u.trim().length>=3?`/api/admin/users?q=${encodeURIComponent(u.trim())}&pageSize=8`:null,e=>(0,o.Px)(e));async function A(e){g(e),v(!0),k(null);try{let a=await (0,o.SC)(`/api/admin/residences/${i}/host`,{method:"PATCH",body:JSON.stringify({hostId:e.id,dryRun:!0})});y(a)}catch(e){k(e instanceof Error?e.message:"بررسی نشد"),g(null)}finally{v(!1)}}async function S(){if(p){v(!0),k(null);try{await (0,o.SC)(`/api/admin/residences/${i}/host`,{method:"PATCH",body:JSON.stringify({hostId:p.id,note:b.trim()})}),m(),r()}catch(e){k(e instanceof Error?e.message:"ذخیره نشد")}finally{v(!1)}}}let D=((null==w?void 0:w.items)??[]).filter(e=>e.id!==c);return(0,l.jsxs)(x.u_,{open:n,onClose:r,title:"تغییر میزبان اقامتگاه",width:"max-w-[560px]",children:[j?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"rounded-12 border border-gray-E5E5E6 p-14 mb-14",children:[(0,l.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA mb-6",children:"اقامتگاه"}),(0,l.jsx)("p",{className:"text-14 leading-22 font-m text-black mb-10",children:j.residence.name}),(0,l.jsxs)("div",{className:"flex items-center gap-x-10 text-13 leading-22",children:[(0,l.jsx)("span",{className:"text-gray-6C6A7D",children:(null===(a=j.from)||void 0===a?void 0:a.name)||(null===(t=j.from)||void 0===t?void 0:t.phone)||"—"}),(0,l.jsx)("span",{className:"text-gray-9B9BAA",children:"←"}),(0,l.jsx)("b",{className:"font-m text-black",children:j.to.name||j.to.phone})]})]}),j.warnings.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-y-8 mb-14",children:j.warnings.map((e,a)=>(0,l.jsxs)("div",{className:"flex items-start gap-x-8",children:[(0,l.jsx)(x.Ct,{tone:"yellow",children:"توجه"}),(0,l.jsx)("span",{className:"text-12 leading-20 text-gray-6C6A7D",children:e})]},a))}),(0,l.jsx)("textarea",{value:b,onChange:e=>f(e.target.value),rows:2,placeholder:"توضیح — چرا میزبان عوض می‌شود؟",className:"w-full rounded-10 border border-gray-E5E5E6 p-12 text-13 leading-22 outline-none focus:border-primary-main"}),(0,l.jsx)("p",{className:"mt-4 text-11 leading-18 text-gray-9B9BAA",children:"با نام شما در تاریخچه‌ی اقامتگاه ثبت می‌شود."}),C&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:C})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("label",{className:"block mb-12",children:[(0,l.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"جستجوی کاربر"}),(0,l.jsx)("input",{value:u,onChange:e=>h(e.target.value),placeholder:"نام، شماره موبایل یا ایمیل — حداقل ۳ حرف",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"})]}),u.trim().length<3?(0,l.jsx)("p",{className:"py-24 text-center text-13 text-gray-9B9BAA",children:"برای پیدا کردن کاربر، حداقل سه حرف بنویسید."}):E?(0,l.jsx)(x.Od,{className:"h-[160px]"}):0===D.length?(0,l.jsx)("p",{className:"py-24 text-center text-13 text-gray-9B9BAA",children:"کاربری پیدا نشد."}):(0,l.jsx)("div",{className:"rounded-12 border border-gray-E5E5E6 divide-y divide-gray-F0F0F0 max-h-[280px] overflow-y-auto",children:D.map(e=>(0,l.jsxs)("button",{type:"button",disabled:N||!e.isActive,onClick:()=>A(e),className:"w-full flex items-center gap-x-10 px-12 py-10 text-right hover:bg-gray-F7F7F7 transition disabled:opacity-45",children:[(0,l.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,l.jsx)("span",{className:"block text-13 leading-20 text-black truncate",children:e.name||"بدون نام"}),(0,l.jsx)("span",{className:"block text-12 leading-18 text-gray-6C6A7D",dir:"ltr",children:e.phone})]}),e.isHost&&(0,l.jsx)(x.Ct,{tone:"green",children:"میزبان"}),!e.isActive&&(0,l.jsx)(x.Ct,{tone:"red",children:"غیرفعال"})]},e.id))}),C&&(0,l.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:C})]}),(0,l.jsxs)("div",{className:"flex justify-end gap-x-8 mt-16",children:[(0,l.jsx)(x.zx,{variant:"secondary",onClick:()=>j?(y(null),g(null)):r(),children:j?"بازگشت":"انصراف"}),j&&(0,l.jsx)(x.zx,{disabled:N||b.trim().length<3,onClick:S,children:N?"در حال ثبت...":"تغییر میزبان"})]})]})}let eE={SUIT:"ویلا و سوئیت",BOOMGARDI:"بوم‌گردی",HOTEL:"هتل"},eA={PUBLISHED:{label:"فعال",tone:"green"},PENDING:{label:"در انتظار تایید",tone:"yellow"},DRAFT:{label:"پیش‌نویس",tone:"gray"},REJECTED:{label:"رد شده",tone:"red"},DEACTIVATED:{label:"غیرفعال",tone:"red"},DELETED:{label:"حذف شده",tone:"gray"}},eS=[{key:"basic",label:"اطلاعات پایه"},{key:"location",label:"موقعیت مکانی"},{key:"capacity",label:"ظرفیت"},{key:"amenities",label:"امکانات"},{key:"rules",label:"قوانین و مقررات"},{key:"pricing",label:"نرخ اقامتگاه"},{key:"reservations",label:"رزروها"},{key:"calendar",label:"تقویم اقامتگاه"},{key:"stats",label:"آمار اقامتگاه"},{key:"reviews",label:"نظرات"},{key:"documents",label:"مدرک مالکیت"},{key:"edits",label:"بررسی ویرایش اقامتگاه"},{key:"defects",label:"نقص‌ها"}];async function eD(e){if("PUBLISHED"===e.state){window.open(`/rentals/${e.publicId}`,"_blank","noopener,noreferrer");return}let a=window.open("","_blank","noopener,noreferrer");try{let{token:t}=await (0,o.SC)(`/api/admin/residences/${e.id}/preview-token`);a&&(a.location.href=`/rentals/${e.publicId}?preview=${t}`)}catch{null==a||a.close()}}function eB(e){let{label:a,value:t}=e;return(0,l.jsxs)("div",{className:"flex items-start gap-x-8 py-10 border-b border-gray-F0F0F0 last:border-0",children:[(0,l.jsxs)("span",{className:"text-13 leading-20 text-gray-6C6A7D shrink-0",children:[a," :"]}),(0,l.jsx)("span",{className:"text-13 leading-20 text-black break-words whitespace-pre-line",children:t||"—"})]})}function eF(){var e,a,t,n,u,h,j;let y=(0,i.useRouter)(),{id:b}
1=y.query,[f,v]=(0,s.useState)(!1),[C,k]=(0,s.useState)(!1),[w,E]=(0,s.useState)(!1),[A,S]=(0,s.useState)(!1),[D,F]=(0,s.useState)(null),[I,P]=(0,s.useState)("basic"),{data:$,isLoading:T,mutate:M,error:R}=(0,d.u)(b?`/api/admin/residences/${b}`:null,e=>(0,o.SC)(e));(0,s.useEffect)(()=>{var e;let a=null==R?void 0:null===(e=R.details)||void 0===e?void 0:e.canonicalId;a&&y.replace(`/admin/residences/${a}`)},[R,y]),(null==$?void 0:$.images.find(e=>e.isMain))??(null==$||$.images[0]);let Y=(0,U.o)("residences","string"==typeof b?b:void 0);return(0,l.jsxs)(c.Z,{title:(null==$?void 0:$.name)??"جزئیات اقامتگاه",breadcrumb:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r(),{href:"/admin",children:"داشبورد"})," / ",(0,l.jsx)(r(),{href:"/admin/residences",children:"اقامتگاه‌ها"}),!!$&&(0,l.jsxs)(l.Fragment,{children:[" / کد اقامتگاه ",(0,x.XO)($.publicId)]})]}),backHref:(null==Y?void 0:Y.returnUrl)??"/admin/residences",prevNext:Y?{prevHref:Y.prevId?`/admin/residences/${Y.prevId}`:null,nextHref:Y.nextId?`/admin/residences/${Y.nextId}`:null,position:`${(0,x.N)(Y.index+1)} از ${(0,x.N)(Y.total)}`}:void 0,toolbar:(0,l.jsx)(x.Zb,{className:"px-8 py-6 flex items-center gap-x-4 overflow-x-auto",children:eS.map(e=>{var a;let t="edits"===e.key?(null==$?void 0:$.pendingChanges)&&Object.keys($.pendingChanges).length>0?1:0:"defects"===e.key?(null==$?void 0:null===(a=$.defects)||void 0===a?void 0:a.filter(e=>!e.resolvedAt).length)??0:0;return(0,l.jsxs)("button",{onClick:()=>P(e.key),"aria-pressed":I===e.key,className:`flex items-center gap-x-6 px-14 py-8 rounded-10 text-13 leading-20 font-m whitespace-nowrap transition ${I===e.key?"bg-primary-main text-white":"text-gray-6C6A7D hover:bg-gray-F0F0F0"}`,children:[e.label,t>0&&(0,l.jsx)("span",{className:`flex h-18 min-w-[18px] items-center justify-center rounded-full px-4 text-11 leading-16 ${I===e.key?"bg-white text-primary-dark":"bg-error-light text-white"}`,children:t})]},e.key)})}),children:[T&&(0,l.jsxs)("div",{className:"flex flex-col gap-16",children:[(0,l.jsx)(x.Od,{className:"h-[200px]"}),(0,l.jsx)(x.Od,{className:"h-[120px]"})]}),$&&"capacity"===I&&(0,l.jsx)(K,{residenceId:$.id,residenceType:$.type,capacity:$.capacity,maxCapacity:$.maxCapacity,rooms:$.rooms,onSaved:M}),$&&"amenities"===I&&(0,l.jsx)(Q,{residenceId:$.id,amenities:$.amenities,otherAmenities:$.otherAmenities,onSaved:M}),$&&"pricing"===I&&(0,l.jsx)(et.Z,{residenceId:$.id,pricing:{weekPrice:$.weekPrice,weekendPrice:$.weekendPrice,peakPrice:$.peakPrice,extraGuestsPrice:$.extraGuestsPrice,extraGuestsPeakPrice:$.extraGuestsPeakPrice,weeklyDiscount:$.weeklyDiscount,monthlyDiscount:$.monthlyDiscount},onSaved:M}),$&&"rules"===I&&(0,l.jsx)(er,{residenceId:$.id,rules:$.rules,values:{checkinFrom:$.checkinFrom,checkinTo:$.checkinTo,checkout:$.checkout,minReservableDays:$.minReservableDays,capacity:$.capacity,rulesDesc:$.rulesDesc,hostRulesText:$.hostRulesText,cancellationPolicy:$.cancellationPolicy,extraRules:$.extraRules},onSaved:M}),$&&"reservations"===I&&(0,l.jsx)(eo,{residenceId:$.id}),$&&"calendar"===I&&(0,l.jsx)(g.Z,{residence:{id:$.id,name:$.name,type:$.type,rooms:$.rooms}}),$&&"location"===I&&(0,l.jsx)(N,{residenceId:$.id,residence:$,onSaved:M,onEditAddress:()=>k(!0)}),$&&"stats"===I&&(0,l.jsx)(B,{residenceId:$.id}),$&&"reviews"===I&&(0,l.jsxs)("div",{className:"flex flex-col gap-y-24",children:[(0,l.jsx)(O,{residenceId:$.id}),(0,l.jsx)(z,{residenceId:$.id})]}),$&&"documents"===I&&(0,l.jsx)(Z,{residenceId:$.id}),$&&"edits"===I&&(0,l.jsx)(l.Fragment,{children:$.pendingChanges&&Object.keys($.pendingChanges).length>0?(0,l.jsx)(eC,{residenceId:$.id,residence:$,pendingChanges:$.pendingChanges,submittedAt:$.pendingChangesSubmittedAt,onSaved:()=>M()}):(0,l.jsx)(x.Zb,{className:"p-24 text-center text-13 text-gray-6C6A7D",children:"هیچ درخواست ویرایشی برای بررسی نیست"})}),$&&"defects"===I&&(0,l.jsx)(ey,{residenceId:$.id,defects:$.defects,onSaved:()=>M()}),$&&"basic"===I&&(0,l.jsxs)("div",{className:"flex gap-x-16 items-start",children:[(0,l.jsxs)(x.Zb,{className:"p-12 w-[200px] shrink-0 flex flex-col gap-y-8 sticky top-[76px]",children:[(0,l.jsxs)(x.zx,{variant:"secondary",className:"w-full",onClick:()=>eD($),children:[(0,l.jsx)("i",{className:"icon-See text-16"}),"PUBLISHED"===$.state?"مشاهده در فرانت":"پیش‌نمایش در فرانت"]}),(0,l.jsxs)(x.zx,{variant:"PUBLISHED"===$.state?"danger":"primary",onClick:()=>F("PUBLISHED"===$.state?"DEACTIVATED":"PUBLISHED"),children:[(0,l.jsx)("i",{className:"icon-Power text-16"}),"PUBLISHED"===$.state?"غیرفعال کردن":"فعال کردن"]}),(0,l.jsxs)(x.zx,{variant:"secondary",onClick:()=>F("DELETED"),children:[(0,l.jsx)("i",{className:"icon-Delete text-16"})," حذف اقامتگاه"]})]}),(0,l.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-y-16",children:[(0,l.jsxs)(x.Zb,{className:"p-16",children:[0===$.images.length?(0,l.jsx)(x.ub,{text:"تصویری بارگذاری نشده"}):(0,l.jsx)("div",{className:"flex gap-x-8 overflow-x-auto pb-8",children:$.images.map(e=>(0,l.jsxs)("div",{className:"relative shrink-0",children:[(0,l.jsx)("img",{src:(0,x.vD)(e.url,640),alt:e.title??$.name,className:"h-[130px] w-[200px] object-cover rounded-10",loading:"lazy"}
1),e.isMain&&(0,l.jsx)("span",{className:"absolute top-8 right-8 bg-white/95 rounded-8 px-8 py-2 text-11 font-m",children:"تصویر اصلی"})]},e.id))}),(0,l.jsxs)("div",{className:"flex items-center gap-x-8 mt-12",children:[(0,l.jsxs)(x.zx,{onClick:()=>E(!0),children:[(0,l.jsx)("i",{className:"icon-Edit text-16"})," مشاهده و ویرایش تصاویر"]}),(0,l.jsxs)(x.zx,{variant:"secondary",onClick:()=>E(!0),children:[(0,l.jsx)("i",{className:"icon-Upload text-16"})," بارگذاری تصویر جدید"]})]})]}),"DEACTIVATED"===$.state&&(0,l.jsx)(x.Zb,{className:"px-16 py-14 border-r-4 border-r-[#E11D48] bg-[#FEF2F2]",children:(0,l.jsxs)("div",{className:"flex items-start gap-x-10",children:[(0,l.jsx)("i",{className:"icon-WarningFill text-18 text-[#E11D48] mt-2 shrink-0"}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("p",{className:"text-14 leading-24 font-b text-black",children:["این اقامتگاه غیرفعال است",!!$.deactivatedAt&&(0,l.jsxs)("span",{className:"font-r text-gray-6C6A7D",children:[" — از ",(0,x.IY)($.deactivatedAt)]})]}),!!$.deactivationNote&&(0,l.jsx)("p",{className:"mt-4 text-13 leading-22 text-black",children:$.deactivationNote}),(0,l.jsx)("p",{className:"mt-6 text-12 leading-20 text-gray-6C6A7D",children:"صفحه‌ی اقامتگاه در سایت باز است و همه‌ی اطلاعاتش دیده می‌شود، ولی از نتایج جستجو حذف شده و باکس رزروش بسته است."})]})]})}),(0,l.jsxs)(x.Zb,{className:"px-16 py-12 flex items-center gap-x-16 flex-wrap gap-y-10 text-13",children:[(0,l.jsxs)("span",{className:"text-gray-6C6A7D",children:["کد اقامتگاه : ",(0,l.jsx)("span",{className:"text-black font-m",children:(0,x.XO)($.publicId)})]}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsx)(x.tS,{value:$.averageRating,count:$.reviewsCount}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsxs)("span",{className:"text-gray-6C6A7D",children:["اهمیت : ",(0,l.jsx)("span",{className:"text-black font-m",children:(0,x.XO)($.importance)})]}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsx)(x.Ct,{tone:(null===(e=eA[$.state])||void 0===e?void 0:e.tone)??"gray",children:(null===(a=eA[$.state])||void 0===a?void 0:a.label)??$.state}),(0,l.jsxs)("label",{className:"flex items-center gap-x-8 text-gray-6C6A7D",children:[(0,l.jsx)(x.ZD,{checked:$.published,onChange:e=>F(e?"PUBLISHED":"DEACTIVATED")}),"منتشر شده"]}),(0,l.jsx)(x.Ct,{tone:"purple",children:eE[$.type]}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsxs)("span",{className:"text-gray-6C6A7D",children:["تاریخ ایجاد : ",(0,x.IY)($.createdAt)]}),(0,l.jsxs)("span",{className:"text-gray-6C6A7D",children:["آخرین بروزرسانی : ",(0,x.IY)($.updatedAt)]})]}),!!$.host&&(0,l.jsxs)(x.Zb,{className:"px-16 py-12 flex items-center gap-x-16 flex-wrap gap-y-10 text-13",children:[(0,l.jsx)(x.Ct,{tone:"purple",children:"میزبان"}),(0,l.jsxs)(r(),{href:`/admin/users/${$.host.id}`,className:"flex items-center gap-x-8 text-primary-dark font-m",children:[(0,l.jsx)("span",{className:"w-28 h-28 rounded-full bg-gray-F0F0F0 flex items-center justify-center text-11 overflow-hidden",children:$.host.avatarUrl?(0,l.jsx)("img",{src:(0,x.vD)($.host.avatarUrl,96),alt:"",className:"w-full h-full object-cover"}):(null===(t=$.host.name)||void 0===t?void 0:t[0])??"؟"}),$.host.name??"بدون نام"]}),(0,l.jsx)("span",{className:"text-gray-6C6A7D",children:$.host.phone}),(0,l.jsx)("span",{className:"w-px h-16 bg-gray-E5E5E6"}),(0,l.jsxs)("span",{className:"text-gray-6C6A7D",children:["وضعیت همکاری :"," ",(0,l.jsx)(x.Ct,{tone:"CONFIRMED"===$.host.verificationStatus?"green":"yellow",children:"CONFIRMED"===$.host.verificationStatus?"تأیید همکاری":"در انتظار تایید"})]}),$.host.isSpecialHost&&(0,l.jsx)(x.Ct,{tone:"blue",children:"میزبان ویژه"}),(0,l.jsxs)(x.Ct,{tone:"gray",children:[(0,x.N)($.host.residencesCount)," اقامتگاه"]}),(0,l.jsxs)(x.zx,{variant:"secondary",className:"mr-auto",onClick:()=>S(!0),children:[(0,l.jsx)("i",{className:"icon-Refresh text-16"})," تغییر میزبان"]})]}),(0,l.jsx)(ep,{residenceId:$.id,suspendedAt:$.suspendedAt,suspensionReason:$.suspensionReason,onSaved:()=>M()}),(0,l.jsx)(eh,{residenceId:$.id,onSaved:M}),(0,l.jsx)(eu,{residenceId:$.id,onSaved:M}),(0,l.jsxs)(x.Zb,{className:"p-20",children:[(0,l.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-12",children:"مشخصات اقامتگاه"}),(0,l.jsxs)("div",{className:"grid md:grid-cols-2 gap-x-32",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(eB,{label:"نام در صفحه اقامتگاه",value:$.name}),(0,l.jsx)(eB,{label:"نام پیشنهادی میزبان",value:$.hostSuggestedName}),(0,l.jsx)(eB,{label:"نام در صفحات لیست",value:[null===(n=$.location)||void 0===n?void 0:null===(u=n.parent)||void 0===u?void 0:u.name,null===(h=$.location)||void 0===h?void 0:h.name].filter(
1Boolean).join(" / ")}),(0,l.jsx)(eB,{label:"نوع ملک",value:eE[$.type]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eB,{label:"دیگر شهرهای اقامتگاه",value:$.extraLocations.length?$.extraLocations.map(e=>e.location.name).join(" / "):"هیچ کدام"}),(0,l.jsx)(eB,{label:"مساحت کل زمین",value:$.totalArea?`${(0,x.N)($.totalArea)} متر`:null}),(0,l.jsx)(eB,{label:"مساحت زیربنای اقامتگاه",value:$.foundationArea?`${(0,x.N)($.foundationArea)} متر`:null}),(0,l.jsx)(eB,{label:"طبقه",value:$.floor}),(0,l.jsx)(eB,{label:"ظرفیت",value:$.capacity?`${(0,x.N)($.capacity)} نفر (حداکثر ${(0,x.N)($.maxCapacity)})`:null}),(0,l.jsx)(eB,{label:"قیمت هفته",value:(0,x.ND)($.weekPrice)})]})]}),(0,l.jsx)(eB,{label:"درباره اقامتگاه",value:$.description}),(0,l.jsx)("div",{className:"mt-12",children:(0,l.jsxs)(x.zx,{variant:"secondary",onClick:()=>v(!0),children:[(0,l.jsx)("i",{className:"icon-Edit text-16"})," ویرایش اطلاعات"]})})]})]})]}),$&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eI,{open:f,residence:$,onClose:()=>v(!1),onSaved:()=>{v(!1),M()}}),(0,l.jsx)(eP,{open:C,residence:$,onClose:()=>k(!1),onSaved:()=>{k(!1),M()}}),(0,l.jsx)(ew,{open:A,onClose:()=>S(!1),residenceId:$.id,currentHostId:(null===(j=$.host)||void 0===j?void 0:j.id)??null,onSaved:M}),(0,l.jsx)(m,{open:w,onClose:()=>E(!1),residenceId:$.id,images:$.images,onChanged:M}),(0,l.jsx)(p.Z,{open:null!==D,onClose:()=>F(null),ids:[$.id],state:D??"DEACTIVATED",currentState:$.state,onSaved:M})]})]})}function eI(e){let{open:a,residence:t,onClose:n,onSaved:r}=e,[i,d]=(0,s.useState)({name:t.name,hostSuggestedName:t.hostSuggestedName??"",description:t.description??"",type:t.type,region:t.region??"",rentType:t.rentType??"",floor:t.floor??"",totalArea:t.totalArea??"",foundationArea:t.foundationArea??"",importance:t.importance??0}),[c,m]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null),p=e=>a=>d(t=>({...t,[e]:a.target.value}));async function g(e){e.preventDefault(),m(!0),h(null);try{await (0,o.SC)(`/api/admin/residences/${t.id}`,{method:"PATCH",body:JSON.stringify({name:i.name,hostSuggestedName:i.hostSuggestedName||void 0,description:i.description||void 0,type:i.type,floor:i.floor||void 0,totalArea:""===i.totalArea?void 0:Number(i.totalArea),foundationArea:""===i.foundationArea?void 0:Number(i.foundationArea),importance:Number(i.importance)||0})}),r()}catch(e){h(e instanceof Error?e.message:"خطا در ذخیره")}finally{m(!1)}}return(0,l.jsx)(x.u_,{open:a,onClose:n,title:"ویرایش اطلاعات اقامتگاه",width:"max-w-[680px]",children:(0,l.jsxs)("form",{onSubmit:g,className:"grid md:grid-cols-2 gap-12",children:[(0,l.jsx)(x.gN,{label:"نام در صفحه اقامتگاه",children:(0,l.jsx)(x.II,{value:i.name,onChange:p("name"),required:!0})}),(0,l.jsx)(x.gN,{label:"نام پیشنهادی میزبان",children:(0,l.jsx)(x.II,{value:i.hostSuggestedName,onChange:p("hostSuggestedName")})}),(0,l.jsx)(x.gN,{label:"نوع ملک",children:(0,l.jsxs)(x.Ph,{value:i.type,onChange:p("type"),className:"w-full",children:[(0,l.jsx)("option",{value:"SUIT",children:"ویلا و سوئیت"}),(0,l.jsx)("option",{value:"BOOMGARDI",children:"بوم‌گردی"}),(0,l.jsx)("option",{value:"HOTEL",children:"هتل"})]})}),(0,l.jsx)(x.gN,{label:"اهمیت اقامتگاه (رتبه در جستجو)",children:(0,l.jsx)(x.II,{value:i.importance,onChange:p("importance"),inputMode:"numeric"})}),(0,l.jsx)(x.gN,{label:"مساحت کل زمین (متر)",children:(0,l.jsx)(x.II,{value:i.totalArea,onChange:p("totalArea"),inputMode:"numeric"})}),(0,l.jsx)(x.gN,{label:"مساحت زیربنا (متر)",children:(0,l.jsx)(x.II,{value:i.foundationArea,onChange:p("foundationArea"),inputMode:"numeric"})}),(0,l.jsx)(x.gN,{label:"طبقه",children:(0,l.jsx)(x.II,{value:i.floor,onChange:p("floor")})}),(0,l.jsx)(x.gN,{label:"درباره اقامتگاه",className:"md:col-span-2",children:(0,l.jsx)("textarea",{value:i.description,onChange:p("description"),rows:4,className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"})}),!!u&&(0,l.jsx)("p",{className:"md:col-span-2 text-13 text-[#C62828]",children:u}),(0,l.jsxs)("div",{className:"md:col-span-2 flex items-center gap-x-10 justify-end",children:[(0,l.jsx)(x.zx,{type:"button",variant:"secondary",onClick:n,children:"انصراف"}
1),(0,l.jsx)(x.zx,{type:"submit",disabled:c,children:c?"در حال ذخیره...":"ذخیره"})]})]})})}function eP(e){var a;let{open:t,residence:n,onClose:r,onSaved:i}=e,{data:c}=(0,d.u)(t?"/api/admin/locations":null,e=>(0,o.SC)(e)),m=(c??[]).filter(e=>"CITY"===e.type).map(e=>{var a;return{...e,parentName:(null===(a=(c??[]).find(a=>a.id===e.parentId))||void 0===a?void 0:a.name)??null}}).sort((e,a)=>e.name.localeCompare(a.name,"fa")),[u,h]=(0,s.useState)({cityId:(null===(a=n.location)||void 0===a?void 0:a.id)?String(n.location.id):"",neighborhood:n.neighborhood??"",address:n.address??"",invoiceAddress:n.invoiceAddress??"",latitude:n.latitude??"",longitude:n.longitude??""}),[p,g]=(0,s.useState)(n.distances.map(e=>({placeName:e.placeName,distance:e.distance??"",eta:e.eta??""}))),[j,y]=(0,s.useState)(!1),[b,f]=(0,s.useState)(null),N=e=>a=>h(t=>({...t,[e]:a.target.value})),v=(c??[]).filter(e=>"NEIGHBORHOOD"===e.type&&String(e.parentId)===u.cityId).sort((e,a)=>e.name.localeCompare(a.name,"fa"));async function C(e){e.preventDefault(),y(!0),f(null);try{await (0,o.SC)(`/api/admin/residences/${n.id}`,{method:"PATCH",body:JSON.stringify({cityId:u.cityId?Number(u.cityId):void 0,neighborhood:u.neighborhood||void 0,address:u.address||void 0,invoiceAddress:u.invoiceAddress||void 0,latitude:""===u.latitude?void 0:Number(u.latitude),longitude:""===u.longitude?void 0:Number(u.longitude)})}),await (0,o.SC)(`/api/admin/residences/${n.id}/distances`,{method:"PUT",body:JSON.stringify({distances:p.filter(e=>e.placeName.trim()).map(e=>({placeName:e.placeName,distance:e.distance||void 0,eta:e.eta||void 0}))})}),i()}catch(e){f(e instanceof Error?e.message:"خطا در ذخیره")}finally{y(!1)}}return(0,l.jsx)(x.u_,{open:t,onClose:r,title:"ویرایش آدرس",width:"max-w-[680px]",children:(0,l.jsxs)("form",{onSubmit:C,className:"grid md:grid-cols-2 gap-12",children:[(0,l.jsx)(x.gN,{label:"شهر",children:(0,l.jsxs)(x.Ph,{value:u.cityId,onChange:N("cityId"),className:"w-full",children:[(0,l.jsx)("option",{value:"",children:"— انتخاب شهر —"}),m.map(e=>(0,l.jsx)("option",{value:e.id,children:e.parentName?`${e.name} — ${e.parentName}`:e.name},e.id))]})}),(0,l.jsx)(x.gN,{label:"محله",hint:v.length?"از لیست انتخاب کنید یا اگر محله در لیست نبود، مستقیم تو همون فیلد بنویسید.":void 0,children:(0,l.jsxs)("div",{className:"flex flex-col gap-y-8",children:[!!v.length&&(0,l.jsxs)(x.Ph,{value:"",onChange:e=>{e.target.value&&h(a=>({...a,neighborhood:e.target.value}))},className:"w-full",children:[(0,l.jsx)("option",{value:"",children:"— انتخاب از محله‌های ثبت‌شده —"}),v.map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.id))]}),(0,l.jsx)(x.II,{value:u.neighborhood,onChange:N("neighborhood")})]})}),(0,l.jsx)(x.gN,{label:"آدرس در فرانت",children:(0,l.jsx)(x.II,{value:u.address,onChange:N("address")})}),(0,l.jsx)(x.gN,{label:"آدرس در فاکتور",className:"md:col-span-2",children:(0,l.jsx)(x.II,{value:u.invoiceAddress,onChange:N("invoiceAddress")})}),(0,l.jsx)(x.gN,{label:"عرض جغرافیایی",children:(0,l.jsx)(x.II,{value:u.latitude,onChange:N("latitude"),inputMode:"decimal"})}),(0,l.jsx)(x.gN,{label:"طول جغرافیایی",children:(0,l.jsx)(x.II,{value:u.longitude,onChange:N("longitude"),inputMode:"decimal"})}),(0,l.jsxs)("div",{className:"md:col-span-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,l.jsx)("span",{className:"text-12 leading-18 text-gray-6C6A7D font-m",children:"فاصله تا جاذبه‌های گردشگری"}),(0,l.jsx)("button",{type:"button",onClick:()=>g(e=>[...e,{placeName:"",distance:"",eta:""}]),className:"text-12 font-m text-primary-dark",children:"+ افزودن"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-y-8 max-h-[220px] overflow-y-auto",children:[p.map((e,a)=>(0,l.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,l.jsx)(x.II,{value:e.placeName,placeholder:"نام جاذبه",onChange:e=>g(t=>t.map((t,l)=>l===a?{...t,placeName:e.target.value}:t))}),(0,l.jsx)(x.II,{value:e.distance,placeholder:"فاصله",className:"max-w-[130px]",onChange:e=>g(t=>t.map((t,l)=>l===a?{...t,distance:e.target.value}:t))}),(0,l.jsx)(x.II,{value:e.eta,placeholder:"زمان",className:"max-w-[130px]",onChange:e=>g(t=>t.map((t,l)=>l===a?{...t,eta:e.target.value}:t))}),(0,l.jsx)("button",{type:"button",onClick:()=>g(e=>e.filter((e,t)=>
1t!==a)),className:"w-28 h-28 shrink-0 rounded-8 text-[#E53935] hover:bg-[#FFEBEB]","aria-label":"حذف",children:(0,l.jsx)("i",{className:"icon-Delete text-16"})})]},a)),0===p.length&&(0,l.jsx)("p",{className:"text-12 text-gray-9B9BAA",children:"موردی ثبت نشده"})]})]}),!!b&&(0,l.jsx)("p",{className:"md:col-span-2 text-13 text-[#C62828]",children:b}),(0,l.jsxs)("div",{className:"md:col-span-2 flex items-center gap-x-10 justify-end",children:[(0,l.jsx)(x.zx,{type:"button",variant:"secondary",onClick:r,children:"انصراف"}),(0,l.jsx)(x.zx,{type:"submit",disabled:j,children:j?"در حال ذخیره...":"ذخیره"})]})]})})}},35157:function(e,a,t){"use strict";t.d(a,{g:function(){return n},o:function(){return r}});var l=t(67294);let s="lidoma_admin_nav:";function n(e,a,t){try{let l={ids:a,returnUrl:t,savedAt:Date.now()};window.sessionStorage.setItem(s+e,JSON.stringify(l))}catch{}}function r(e,a){let[t,n]=(0,l.useState)(null);return(0,l.useEffect)(()=>{if(null==a){n(null);return}let t=function(e){try{let a=window.sessionStorage.getItem(s+e);if(!a)return null;let t=JSON.parse(a);if(Date.now()-t.savedAt>18e5)return null;return t}catch{return null}}(e);if(!t){n(null);return}let l=t.ids.findIndex(e=>String(e)===String(a));if(-1===l){n(null);return}n({index:l,total:t.ids.length,prevId:l>0?t.ids[l-1]:null,nextId:l<t.ids.length-1?t.ids[l+1]:null,returnUrl:t.returnUrl})},[e,a]),t}}},function(e){e.O(0,[4885,4389,8289,9759,3496,9774,2888,179],function(){return e(e.s=35105)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.