PageSourceSearch

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

js lidomatrip.com collected 2026-09-25 07:11:10 UTC 171,019 bytes, 1 lines download raw bytes

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