PageSourceSearch

https://jhasolutions.com/assets/Rentals-D9-ibi_3.js

js jhasolutions.com collected 2026-10-02 01:33:08 UTC 86,247 bytes, 3 lines download raw bytes

1import{r as g,j as e,b as gs,u as js,d as Ge}from"./query-vendor-CqOtiPNe.js";import{u as Z,B as C,h as x,i as T,k as M,l as B,m as h,S as ce,j as Y,x as Ze,y as fs,c as F,L as U,s as he,C as Se,z as Ns,H as vs}from"./index-CgiuONvO.js";import{d as ys}from"./react-vendor-Oyj1q24G.js";import{A as Pe,n as We,W as bs,o as ws,p as ks,q as Cs,U as Ss,r as Rs,L as Re,B as Ds,E as es,D as As,s as Ps}from"./DashboardLayout-bhpyg6kK.js";import{P as Ts}from"./PageHeader-CZkE0AwI.js";import{T as ss,a as ts,b as ye,c as G}from"./tabs-DhAXdYsK.js";import{u as Ms}from"./use-mobile-Bs-uMLmp.js";import{u as le}from"./useListings-DtVnQ-LU.js";import{u as fe}from"./useBookings-CAiDnDJ3.js";import{u as as}from"./AvailabilityBlockDialog-BJMqiNTB.js";import{O as Bs,c as Ls,d as _s}from"./OperationsWorkspace-CMZPPGWo.js";import{B as H}from"./badge-CSzvBtO5.js";import{u as Ue}from"./useShortTermAnalytics-DGh9OyP4.js";import{u as De}from"./useCurrency-BwCXcmAr.js";import{S as Te}from"./skeleton-B97PTBMn.js";import{B as Is,L as Os}from"./BookingsCalendar-BIKQw5jb.js";import{E as Fs}from"./EmptyState-B8Ncwn5F.js";import{A as Es,a as Us,b as Gs,c as Ws,d as Vs,e as qs,f as $s,g as zs}from"./alert-dialog-3FMVIuPP.js";import{i as Ve}from"./isToday-C3mvRkZe.js";import{p as D}from"./parseISO-k3Q1d3Py.js";import{t as me}from"./en-US-5rFTtd83.js";import{a as rs}from"./addDays-DdzlNAKv.js";import{U as se}from"./users-BKG6ZMTq.js";import{C as xe}from"./clock-DZbyb8Zh.js";import{C as ge}from"./circle-check-DJQ0aRpE.js";import{P as _e}from"./plus-DhJDBkeB.js";import{B as is,a as Ks}from"./bed--FRu_ZOR.js";import{D as q}from"./dollar-sign-BoJmMuTa.js";import{C as K}from"./calendar-njTWr43i.js";import{S as Qs}from"./square-pen-Cd8FE6iD.js";import{T as ns}from"./trash-2-XdlKjO4t.js";import{S as pe}from"./star-DgTF5ai2.js";import{B as Hs}from"./bell-CJIBHycy.js";import{M as je}from"./message-square-BqIfb2eA.js";import{I as V}from"./input-oPoHA7Fw.js";import{T as ls}from"./textarea-CxLaKExY.js";import{P as cs}from"./progress-CGtqSgOL.js";import{u as Ys}from"./useProperties-DAUpZ_Uw.js";import{S as te,a as ae,b as re,c as ie,d as _}from"./select-DLa9MRfA.js";import{H as ne}from"./house-C9sHcoTX.js";import{I as Js}from"./image-DrO_YHf9.js";import{C as be}from"./check-EsNBkSFR.js";import{C as os}from"./chevron-left-ChhJq7GD.js";import{C as ds}from"./chevron-right-Cl4Mx2Wq.js";import{C as Xs}from"./car-BBeSSily.js";import{U as qe}from"./upload-B2TjyuSq.js";import{S as Zs,T as et}from"./TeamManagement-4wIVkPnL.js";import{C as ms}from"./calendar-DaWx4mTj.js";import{s as st}from"./startOfMonth-CR-gPZr_.js";import{e as tt,f as at}from"./formatDistanceToNow-DExfhm_y.js";import{f as X,s as rt}from"./format-Ch7dQtBq.js";import{i as oe}from"./isSameDay-DKb4pGQS.js";import{s as it}from"./subMonths-DSv0VBrP.js";import{a as nt}from"./addMonths-YCl4V_qS.js";import{D as lt,a as ct,b as ot,c as Ne,d as dt}from"./dropdown-menu-D-1fS2hr.js";import{T as mt,a as xt,b as Me,c as J,d as ht,e as Q}from"./table-CUs_AvL6.js";import{B as ut}from"./BookingDialog-CuZU8T1h.js";import{i as Be,a as pt}from"./isBefore-CgCj7brn.js";import{S as xs}from"./search-CT8fLn3_.js";import{F as hs}from"./filter-DOTkE5Cb.js";import{C as us}from"./circle-x-BuyswQ-Z.js";import{d as Ie}from"./differenceInDays-DGg7-ojw.js";import{U as ps}from"./user-C4n8hF8r.js";import{T as de}from"./trending-up-BVHf_RoK.js";import{P as gt}from"./ruler-PMZpHEX4.js";import{R as we,A as jt,C as Oe,X as Fe,Y as ke,T as Ce,a as ft,L as Nt,b as $e,d as ze,P as vt,e as yt,f as bt,B as wt,g as Ke}from"./chart-vendor-De-uRwFm.js";import{A as kt}from"./activity-DmUxG0fV.js";import{C as Ct}from"./chart-pie-BH1JXQN4.js";import{A as Qe,a as St,b as He}from"./avatar-B9y0eyOh.js";import{S as Ye}from"./scroll-area-Cf6pvS46.js";import{F as Rt}from"./file-text-BqBFGr3S.js";import{S as Dt}from"./send-Dev9pED3.js";import{C as At}from"./CleanerProofWorkspace-BlAZU2b-.js";import{B as Je}from"./book-open-CkJItcBu.js";import{C as Pt}from"./wifi-off--tLv87Xm.js";import{C as Tt}from"./clipboard-check-BqHgjlQp.js";import"./ui-vendor-C92kXd7i.js";
1import"./separator-BBHmpRWz.js";import"./sheet-Dt5T48FQ.js";import"./tooltip-DukMi9Yb.js";import"./Logo-BMQirxBI.js";import"./calendar-days-BvC5INej.js";import"./building-2-Dhg-JMoH.js";import"./map-pin-C3B4zHzE.js";import"./wrench-BveqLzJ6.js";import"./credit-card-B4XMcBmh.js";import"./panel-top-C_rCNK16.js";import"./mail-dnbKMUvE.js";import"./log-out-BzS-CLno.js";import"./check-check-XSobeTl0.js";import"./LanguageSwitcher-k7A6VFzv.js";import"./languages-1QBd6nWm.js";import"./message-circle-C3Kdh8KU.js";import"./arrow-down-C4HxAdL9.js";import"./arrow-left-Cg5pwYzI.js";import"./arrow-right-left-tf9Dbt9n.js";import"./arrow-right-CcjvJnjH.js";import"./banknote-wg82AAG7.js";import"./list-ordered-CD-hc5AR.js";import"./book-open-check-DeGSCDpn.js";import"./brain-QP504LxU.js";import"./building-B1y8ifkf.js";import"./calculator-BuA7e-mZ.js";import"./landmark-DVOwzqRj.js";import"./chart-no-axes-column-increasing-DINm0A4J.js";import"./chevron-down-C04YKbFY.js";import"./chevron-up-YEko4sQ9.js";import"./circle-check-big-B-nqExcc.js";import"./message-square-text-CGi8Ghec.js";import"./circle-help-C7Zpw0pA.js";import"./circle-QNrbGPhh.js";import"./clipboard-list-Csw_7fPS.js";import"./clipboard-BrLc9XKt.js";import"./copy-B3hQhSgM.js";import"./database-BFqeg3FR.js";import"./download-CVkjVrJo.js";import"./zoom-out-CZzr-t9-.js";import"./external-link-DLbL3mEn.js";import"./twitter-DZP3beY2.js";import"./file-chart-column-increasing-B5g6evDe.js";import"./file-check-2P_f7S4-.js";import"./file-spreadsheet-BbKDqPhp.js";import"./folder-open-CQAcdSBr.js";import"./tree-pine-BPQJJftn.js";import"./globe-CnUNDEKq.js";import"./video-CEw6mOAP.js";import"./hammer-wk7AQWqX.js";import"./heart-BnQgcucT.js";import"./hotel-GOTEiWOT.js";import"./image-plus-DfX-_AyQ.js";import"./infinity-BeOXN0LM.js";import"./key-round-Cl3pyXjD.js";import"./pen-tool-ErvG_pvg.js";import"./keyboard-CzV9enBr.js";import"./layers-BFQ0OLI3.js";import"./lightbulb-IBP3Qpkq.js";import"./list-checks-CsRR_GQp.js";import"./list-Cj3mFARp.js";import"./lock-rMWs3zu_.js";import"./map-pinned-DBhEITMu.js";import"./map-Dml-fuwB.js";import"./maximize-2-BAo6X0VP.js";import"./maximize-DllRQL4I.js";import"./menu-B6QavzjZ.js";import"./minus-BWhsihkF.js";import"./mouse-pointer-click-BX0OFv2U.js";import"./mouse-z7gxK0yj.js";import"./navigation-CE5W2bfp.js";import"./pause-DMf9J0er.js";import"./pencil-s0UamddO.js";import"./phone-CCpZm87m.js";import"./play-jGttOVZX.js";import"./printer-DPItEGKX.js";import"./refresh-ccw-D8-NZbc0.js";import"./rocket-o5dk1x7z.js";import"./rotate-ccw-D5LvpNON.js";import"./rotate-cw-qBQXdDzU.js";import"./route-BHkgA-GC.js";import"./save-CD5NOpBU.js";import"./scale-ChbaOrX5.js";import"./share-2-CZ8fruyy.js";import"./square-plus-BYoTN96c.js";import"./skip-forward-B2g28Adz.js";import"./smartphone-BVaS8Ogf.js";import"./square-check-big-S7f3xHqK.js";import"./square-DpPlSXOl.js";import"./trending-down-BOTbmgUi.js";import"./user-check-DLa2T6BS.js";import"./volume-2-CyzFl9Wm.js";import"./volume-x-DwUdAb_B.js";import"./wallet-DFZjOwp1.js";import"./workflow-eRF_Iozj.js";import"./zap-CZwSyBya.js";import"./useIsRTL-CvXztNyx.js";import"./useOrganization-BfvJJCCq.js";import"./index.esm-D5lf4VrX.js";import"./types-BjVZakaZ.js";import"./form-CuAyl4xB.js";import"./PropertiesMapPreview-aQEIDu4l.js";import"./esm-BfjIKsKB.js";import"./googleMaps-CnGBkgZD.js";import"./mapMarkerStyles-BrAskDV3.js";import"./index-BdQq_4o_.js";import"./useICalImports-C8oHEZdA.js";import"./TeamMemberDetailsDialog-BM7w8suH.js";import"./useUsageLimits-CSZmE2LJ.js";import"./UsageLimitDialog-C7vwhRex.js";import"./useFreemiumStatus-B1UF2GYp.js";import"./alert-DEyuFcXq.js";import"./isSameMonth-9MImqN3e.js";import"./subDays-CTCG_ujS.js";import"./index-DBVc4pCm.js";import"./checkbox-DKjJLhPq.js";function Le(s,j){const w=me(s.start),f=me(s.end);let p=+w>+f;const v=p?+w:+f,i=p?f:w;i.setHours(0,0,0,0);let u=1;const N=[];for(;+i<=v;)N.push(me(i)),i.setDate(i.getDate()+u),i.setHours(0,0,0,0);return p?N.reverse():N}function Ee(s,j){const w=+me(s),[f,p]=[+me(j.start),+me(j.end)].sort((v,i)=>v-i);return w>=f&&w<=p}const Mt=()=>{const{t:s}=Z(),{formatCurrency:j}=De(),{listings:w,isLoading:f,deleteListing:p}=le(),{bookings:v}=fe(),{stats:i,isLoadingStats:u}=Ue(),[N,b]=g.useState(!1),[k,c]=g.useState(null),[m,R]=g.useState(!1),[n,l]=g.useState(null),[r,P]=g.useState(null),[A,y]=g.useState(!0),I=t=>{c(t),b(!0)},O=t=>{l(t),R(!0)},$=()=>{n&&(p(n),R(!1),l(null))},L=g.useMemo(()=>{const t=new Date,o=v.filter(z=>z.status==="confirmed"),S=o.filter(z=>Ve(D(z.check_in))),W=o.filter(z=>Ve(D(z.check_out))),E=o.filter(z=>Ee(t,{start:D(z.check_in),end:D(z.check_out)})),Ae=o.filter(z=>Ee(D(z.check_in),{start:t,end:rs(t,7)}));return{checkInsToday:S.length,checkOutsToday:W.length,currentGuests:E.length,upcomingCheckIns:Ae.length,checkInsList:S,checkOutsList:W}},[v]);if(r){const t=w.find(o=>o.id===r);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:t==null?void 0:t.t
1itle}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("rentals.bookings")})]}),e.jsx(C,{variant:"outline",onClick:()=>P(null),children:s("common.back")})]}),e.jsx(Is,{listingId:r})]})}const d=[{title:s("str.checkInsToday","Check-ins Today"),value:L.checkInsToday,icon:Pe,color:"text-green-500",bgColor:"bg-green-500/10"},{title:s("str.checkOutsToday","Check-outs Today"),value:L.checkOutsToday,icon:We,color:"text-orange-500",bgColor:"bg-orange-500/10"},{title:s("str.currentGuests","Current Guests"),value:L.currentGuests,icon:se,color:"text-blue-500",bgColor:"bg-blue-500/10"},{title:s("str.upcomingCheckIns","Upcoming (7 days)"),value:L.upcomingCheckIns,icon:xe,color:"text-purple-500",bgColor:"bg-purple-500/10"}],a=[{title:s("str.totalBookings","Total Bookings"),value:(i==null?void 0:i.totalBookings)||0,change:"+12%",positive:!0},{title:s("str.avgNightlyRate","Avg Nightly Rate"),value:j((i==null?void 0:i.avgNightlyRate)||0),change:"+5%",positive:!0},{title:s("str.occupancyRate","Occupancy Rate"),value:`${((i==null?void 0:i.occupancyRate)||0).toFixed(1)}%`,change:"+8%",positive:!0},{title:s("str.revPAN","RevPAN"),value:j((i==null?void 0:i.revPAN)||0),change:"+15%",positive:!0}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(x,{className:"shadow-card",children:[e.jsx(T,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xl",children:s("str.todaySummary","Today's Summary")}
1),e.jsx(B,{children:new Date().toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),e.jsxs(H,{variant:"outline",className:"gap-1",children:[e.jsx(ge,{className:"h-3 w-3 text-green-500"}),s("str.allSystemsGo","All Systems Go")]})]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:d.map(t=>e.jsxs("div",{className:`p-4 rounded-lg ${t.bgColor}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t.title}),e.jsx(t.icon,{className:`h-5 w-5 ${t.color}`})]}),e.jsx("p",{className:"mt-2 text-2xl font-bold",children:t.value})]},t.title))}),(L.checkInsToday>0||L.checkOutsToday>0)&&e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 pt-4 border-t",children:[L.checkInsList.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4 text-green-500"}),s("str.arrivingToday","Arriving Today")]}),e.jsx("div",{className:"space-y-2",children:L.checkInsList.slice(0,3).map(t=>{var o;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-green-500/5 border border-green-500/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm font-medium",children:t.guest_name})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:((o=w.find(S=>S.id===t.listing_id))==null?void 0:o.title)||"Property"})]},t.id)})})]}),L.checkOutsList.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(We,{className:"h-4 w-4 text-orange-500"}),s("str.departingToday","Departing Today")]}),e.jsx("div",{className:"space-y-2",children:L.checkOutsList.slice(0,3).map(t=>{var o;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-orange-500/5 border border-orange-500/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:t.guest_name})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:((o=w.find(S=>S.id===t.listing_id))==null?void 0:o.title)||"Property"})]},t.id)})})]})]})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:u?Array(4).fill(0).map((t,o)=>e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx(Te,{className:"h-4 w-24 mb-2"}),e.jsx(Te,{className:"h-8 w-32"})]})},o)):a.map(t=>e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t.title}),e.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[e.jsx("p",{className:"text-2xl font-bold",children:t.value}),e.jsx(H,{variant:t.positive?"default":"destructive",className:"text-xs",children:t.change})]})]})},t.title))}),e.jsxs(x,{className:"shadow-card",children:[e.jsx(T,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("str.yourListings","Your Listings")}),e.jsx(B,{children:s("str.manageProperties","Manage your short-term rental properties")})]}),e.jsxs(C,{onClick:()=>{c(null),b(!0)},children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),s("rentals.addListing","Add Listing")]})]})}),e.jsx(h,{children:f?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:Array(3).fill(0).map((t,o)=>e.jsx(Te,{className:"h-48"},o))}):w.length===0?e.jsx(Fs,{icon:is,title:s("rentals.noListings","No listings yet"),description:s("rentals.createFirstListing","Create your first listing to get started"),action:{label:s("rentals.addListing","Add Listing"),onClick:()=>b(!0)}}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:w.map(t=>e.jsxs(x,{className:"border shadow-sm hover:shadow-md transition-shadow",children:[e.jsx(T,{className:"pb-3",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(M,{className:"text-base flex items-center gap-2",children:[t.title,t.is_active?e.jsx(H,{variant:"default",className:"text-xs",children:s("common.active")}):e.jsx(H,{variant:"secondary",className:"text-xs",children:s("common.inactive")})]}),t.description&&e.jsx(B,{className:"line-clamp-2",children:t.description})]})})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(q,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-foreground",children:j(t.nightly_rate)}),e.jsx("span",{children:"/night"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsxs("span",{children:[t.max_guests," guests"]})]})]}),t.cleaning_fee>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+ ",j(t.cleaning_fee)," ",s("rentals.cleaningFee")
1]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>P(t.id),className:"flex-1",children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),s("rentals.viewBookings","Bookings")]}),e.jsx(C,{variant:"outline",size:"icon",onClick:()=>I(t),children:e.jsx(Qs,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",onClick:()=>O(t.id),children:e.jsx(ns,{className:"h-4 w-4"})})]})]})]},t.id))})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs(x,{className:"shadow-card lg:col-span-2",children:[e.jsx(T,{children:e.jsx(M,{children:s("str.quickActions","Quick Actions")})}),e.jsx(h,{children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(C,{variant:"outline",className:"h-auto py-4 flex flex-col gap-2",children:[e.jsx(_e,{className:"h-5 w-5"}),e.jsx("span",{children:s("str.addNewProperty","Add New Property")})]}),e.jsxs(C,{variant:"outline",className:"h-auto py-4 flex flex-col gap-2",children:[e.jsx(K,{className:"h-5 w-5"}),e.jsx("span",{children:s("str.blockDates","Block Dates")})]}),e.jsxs(C,{variant:"outline",className:"h-auto py-4 flex flex-col gap-2",children:[e.jsx(q,{className:"h-5 w-5"}),e.jsx("span",{children:s("str.adjustPricing","Adjust Pricing")})]}),e.jsxs(C,{variant:"outline",className:"h-auto py-4 flex flex-col gap-2",children:[e.jsx(pe,{className:"h-5 w-5"}),e.jsx("span",{children:s("str.viewReviews","View Reviews")})]})]})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"h-5 w-5"}),s("str.notifications","Notifications")]}),e.jsx(B,{children:s("str.stayUpdated","Stay updated on bookings and messages")})]}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:s("str.newMessages","New Messages")})]}),e.jsx(ce,{checked:A,onCheckedChange:y})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:s("str.newBookings","New Bookings")})]}),e.jsx(ce,{checked:A,onCheckedChange:y})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:s("str.checkInReminders","Check-in Reminders")})]}),e.jsx(ce,{checked:A,onCheckedChange:y})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:s("str.pricingAlerts","Pricing Alerts")})]}),e.jsx(ce,{checked:A,onCheckedChange:y})]})]})]})]}),e.jsx(Os,{open:N,onOpenChange:b,propertyId:(k==null?void 0:k.property_id)||"",listingId:k==null?void 0:k.id}),e.jsx(Es,{open:m,onOpenChange:R,children:e.jsxs(Us,{children:[e.jsxs(Gs,{children:[e.jsx(Ws,{children:s("rentals.deleteListing")}),e.jsx(Vs,{children:s("rentals.deleteListingConfirm")})]}),e.jsxs(qs,{children:[e.jsx($s,{children:s("common.cancel")}),e.jsx(zs,{onClick:$,children:s("common.delete")})]})]})})]})},ee=[{id:1,title:"Basic Info",icon:ne,description:"Property details"},{id:2,title:"Photos",icon:Js,description:"Upload images"},{id:3,title:"Amenities",icon:fs,description:"Features & amenities"},{id:4,title:"Pricing",icon:q,description:"Set your rates"},{id:5,title:"Publish",icon:Y,description:"Go live"}],Bt=[{id:"wifi",label:"WiFi",icon:bs},{id:"parking",label:"Free Parking",icon:Xs},{id:"ac",label:"Air Conditioning",icon:ws},{id:"kitchen",label:"Kitchen",icon:ks},{id:"tv",label:"TV",icon:Cs},{id:"washer",label:"Washer",icon:Ss},{id:"pool",label:"Pool",icon:Rs}],Lt=()=>{const{t:s}=Z(),{toast:j}=Ze(),{properties:w}=Ys(),{createListing:f}=le(),[p,v]=g.useState(1),[i,u]=g.useState({title:"",description:"",propertyId:"",location:"",bedrooms:1,bathrooms:1,maxGuests:2,photos:[],amenities:[],nightlyRate:100,cleaningFee:50,minNights:1,instantBook:!0}),N=p/ee.length*100,b=()=>{p<ee.length&&v(p+1)},k=()=>{p>1&&v(p-1)},c=async()=>
1{if(!i.propertyId||!i.title){j({title:s("str.missingInfo","Missing Information"),description:s("str.fillRequiredFields","Please fill in all required fields"),variant:"destructive"});return}f({property_id:i.propertyId,title:i.title,description:i.description,nightly_rate:i.nightlyRate,cleaning_fee:i.cleaningFee,max_guests:i.maxGuests,is_active:!0}),j({title:s("str.listingCreated","Listing Created!"),description:s("str.listingPublished","Your property is now live and ready for bookings")}),v(1),u({title:"",description:"",propertyId:"",location:"",bedrooms:1,bathrooms:1,maxGuests:2,photos:[],amenities:[],nightlyRate:100,cleaningFee:50,minNights:1,instantBook:!0})},m=n=>{u(l=>({...l,amenities:l.amenities.includes(n)?l.amenities.filter(r=>r!==n):[...l.amenities,n]}))},R=()=>{switch(p){case 1:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"property",children:[s("str.selectProperty","Select Property")," *"]}),e.jsxs(te,{value:i.propertyId,onValueChange:n=>u(l=>({...l,propertyId:n})),children:[e.jsx(ae,{children:e.jsx(re,{placeholder:s("str.chooseProperty","Choose a property")})}),e.jsx(ie,{children:w.map(n=>e.jsx(_,{value:n.id,children:n.name},n.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"title",children:[s("str.listingTitle","Listing Title")," *"]}),e.jsx(V,{id:"title",placeholder:s("str.titlePlaceholder","Cozy Downtown Apartment"),value:i.title,onChange:n=>u(l=>({...l,title:n.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"description",children:s("str.description","Description")}),e.jsx(ls,{id:"description",placeholder:s("str.descriptionPlaceholder","Describe your property..."),value:i.description,onChange:n=>u(l=>({...l,description:n.target.value})),rows:4})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(is,{className:"h-4 w-4"}),s("str.bedrooms","Bedrooms")]}),e.jsx(V,{type:"number",min:0,value:i.bedrooms,onChange:n=>u(l=>({...l,bedrooms:parseInt(n.target.value)||0}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"h-4 w-4"}),s("str.bathrooms","Bathrooms")]}),e.jsx(V,{type:"number",min:0,step:.5,value:i.bathrooms,onChange:n=>u(l=>({...l,bathrooms:parseFloat(n.target.value)||0}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-4 w-4"}),s("str.maxGuests","Max Guests")]}),e.jsx(V,{type:"number",min:1,value:i.maxGuests,onChange:n=>u(l=>({...l,maxGuests:parseInt(n.target.value)||1}))})]})]})]});case 2:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(qe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:s("str.uploadPhotos","Upload Photos")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:s("str.dragDropPhotos","Drag and drop your photos here, or click to browse")}),e.jsxs(C,{variant:"outline",children:[e.jsx(qe,{className:"h-4 w-4 mr-2"}),s("str.selectFiles","Select Files")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:s("str.importFromChannel","Import from Channel")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs(C,{variant:"outline",className:"justify-start",children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),s("str.importAirbnb","Import from Airbnb")]}),e.jsxs(C,{variant:"outline",className:"justify-start",children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),s("str.importVrbo","Import from Vrbo")]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:s("str.photoTips","Photo Tips")}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("li",{children:["• ",s("str.tipHighQuality","Use high-quality, well-lit photos")]}),e.jsxs("li",{children:["• ",s("str.tipShowRooms","Show all main rooms and amenities")]}),e.jsxs("li",{children:["• ",s("str.tipFirstPhoto","Your first photo is the cover image")]}),e.jsxs("li",{children:["• ",s("str.tipMinPhotos","Upload at least 5 photos for better visibility")]})]})]})]});case 3:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-4",children:s("str.selectAmenities","Select Amenities")}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:Bt.map(n=>e.jsxs("button",{type:"button",onClick:()=>m(n.id),className:F("flex items-center gap-3 p-4 rounded-lg border transition-colors text-left",i.amenities.includes(n.id
1)?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsx(n.icon,{className:F("h-5 w-5",i.amenities.includes(n.id)?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"font-medium",children:n.label}),i.amenities.includes(n.id)&&e.jsx(be,{className:"h-4 w-4 text-primary ml-auto"})]},n.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(Y,{className:"h-4 w-4 inline mr-1"}),s("str.amenitiesTip","Listings with more amenities get up to 30% more bookings!")]})})]});case 4:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"nightlyRate",children:[s("str.nightlyRate","Nightly Rate")," *"]}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{id:"nightlyRate",type:"number",min:0,className:"pl-9",value:i.nightlyRate,onChange:n=>u(l=>({...l,nightlyRate:parseFloat(n.target.value)||0}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"cleaningFee",children:s("str.cleaningFee","Cleaning Fee")}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{id:"cleaningFee",type:"number",min:0,className:"pl-9",value:i.cleaningFee,onChange:n=>u(l=>({...l,cleaningFee:parseFloat(n.target.value)||0}))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"minNights",children:s("str.minimumNights","Minimum Nights")}),e.jsx(V,{id:"minNights",type:"number",min:1,value:i.minNights,onChange:n=>u(l=>({...l,minNights:parseInt(n.target.value)||1}))})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s("str.instantBook","Instant Book")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.instantBookDesc","Allow guests to book without approval")})]}),e.jsx(ce,{checked:i.instantBook,onCheckedChange:n=>u(l=>({...l,instantBook:n}))})]}),e.jsx(x,{className:"bg-primary/5 border-primary/20",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("h4",{className:"font-semibold mb-2",children:s("str.estimatedEarnings","Estimated Monthly Earnings")}),e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",(i.nightlyRate*20+i.cleaningFee*4).toLocaleString()]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("str.basedOnOccupancy","Based on 65% occupancy rate")})]})})]});case 5:return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(x,{className:"border-2 border-primary/20",children:[e.jsxs(T,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-5 w-5 text-green-500"}),s("str.readyToPublish","Ready to Publish!")]}),e.jsx(B,{children:s("str.reviewListing","Review your listing details before going live")})]}),e.jsx(h,{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.title","Title")}),e.jsx("p",{className:"font-medium",children:i.title||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.nightlyRate","Nightly Rate")}),e.jsxs("p",{className:"font-medium",children:["$",i.nightlyRate]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.maxGuests","Max Guests")}),e.jsx("p",{className:"font-medium",children:i.maxGuests})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.amenities","Amenities")}),e.jsxs("p",{className:"font-medium",children:[i.amenities.length," selected"]})]})]})})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:s("str.nextSteps","Next Steps")}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("li",{children:["• ",s("str.syncChannels","Connect to booking channels (Airbnb, Vrbo, etc.)")]}),e.jsxs("li",{children:["• ",s("str.setupCalendar","Set up your availability calendar")]}),e.jsxs("li",{children:["• ",s("str.addPricing","Add seasonal pricing rules")]})]})]})]});default:return null}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.propertyOnboarding","Property Onboarding")}),e.jsx(B,{children:s("str.onboardingDescription","Add a new property to your short-term rental portfolio")})]}),e.jsx(h,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(cs,{value:N,className:"h-2"}
1),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:ee.map(n=>e.jsxs("div",{className:F("flex flex-col items-center text-center",p>=n.id?"text-primary":"text-muted-foreground"),children:[e.jsx("div",{className:F("w-10 h-10 rounded-full flex items-center justify-center mb-2",p>n.id?"bg-primary text-primary-foreground":p===n.id?"border-2 border-primary bg-background":"border-2 border-muted bg-background"),children:p>n.id?e.jsx(be,{className:"h-5 w-5"}):e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx("span",{className:"text-xs font-medium hidden md:block",children:n.title})]},n.id))})]})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[(()=>{const n=ee[p-1].icon;return e.jsx(n,{className:"h-5 w-5"})})(),ee[p-1].title]}),e.jsx(B,{children:ee[p-1].description})]}),e.jsx(h,{children:R()})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(C,{variant:"outline",onClick:k,disabled:p===1,children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),s("common.back","Back")]}),p===ee.length?e.jsxs(C,{onClick:c,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),s("str.publishListing","Publish Listing")]}):e.jsxs(C,{onClick:b,children:[s("common.next","Next"),e.jsx(ds,{className:"h-4 w-4 ml-2"})]})]})]})},_t=()=>{const{t:s}=Z(),{listings:j,isLoading:w}=le(),{bookings:f,isLoading:p}=fe(),{blocks:v,isLoading:i}=as(),[u,N]=g.useState(new Date),[b,k]=g.useState("multi"),[c,m]=g.useState("all"),R=g.useMemo(()=>{const d=st(u),a=tt(u);return Le({start:d,end:a})},[u]),n=g.useMemo(()=>j.map(d=>({id:d.id,name:d.title,segments:[...f.filter(a=>a.listing_id===d.id&&a.status!=="cancelled").map(a=>({id:a.id,start:D(a.check_in),end:D(a.check_out),label:a.guest_name,status:a.status,source:a.booking_source??"direct",type:"booking"})),...v.filter(a=>a.listing_id===d.id).map(a=>{const t=a.source&&a.source!=="manual"?a.source:"blocked";return{id:a.id,start:D(a.start_date),end:D(a.end_date),label:a.external_summary||a.reason||t,status:t,source:t,type:a.external_uid||a.source&&a.source!=="manual"?"ical":"block"}})]})),[j,f,v]),l=(d,a)=>{const t=n.find(o=>o.id===d);return t?t.segments.find(o=>Ee(a,{start:o.start,end:o.end})||oe(a,o.start)||oe(a,o.end)):null},r=(d,a)=>{const t=l(d,a);return t?t.type!=="booking"?"blocked":oe(a,t.start)?"checkin":oe(a,t.end)?"checkout":"booked":"available"},P=d=>{N(d==="prev"?it(u,1):nt(u,1))},A=[{status:"available",label:s("str.available","Available"),color:"bg-green-500"},{status:"booked",label:s("str.booked","Booked"),color:"bg-destructive"},{status:"blocked",label:s("str.blocked","Blocked / iCal"),color:"bg-violet-500"},{status:"checkin",label:s("str.checkIn","Check-in"),color:"bg-blue-500"},{status:"checkout",label:s("str.checkOut","Check-out"),color:"bg-orange-500"}],y=c==="all"?n:n.filter(d=>d.id===c),I=y.reduce((d,a)=>d+R.filter(t=>l(a.id,t)).length,0),O=R.length*y.length,$=Math.max(0,O-I);return w||p||i?e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"p-8 text-center text-sm text-muted-foreground",children:"Loading calendar..."})}):e.jsxs("div",{className:"space-y-6 max-w-full overflow-hidden",children:[e.jsxs(x,{className:"shadow-card overflow-hidden",children:[e.jsx(T,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("str.unifiedCalendar","Unified Calendar")}
1),e.jsx(B,{children:s("str.calendarDescription","View and manage availability across all properties")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(te,{value:c,onValueChange:m,children:[e.jsx(ae,{className:"w-full sm:w-[180px]",children:e.jsx(re,{placeholder:s("str.allProperties","All Properties")})}),e.jsxs(ie,{className:"bg-popover",children:[e.jsx(_,{value:"all",children:s("str.allProperties","All Properties")}),j.map(d=>e.jsx(_,{value:d.id,children:d.title},d.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg",children:[e.jsx(C,{variant:b==="single"?"secondary":"ghost",size:"sm",onClick:()=>k("single"),children:e.jsx(K,{className:"h-4 w-4"})}),e.jsx(C,{variant:b==="multi"?"secondary":"ghost",size:"sm",onClick:()=>k("multi"),children:e.jsx(ne,{className:"h-4 w-4"})})]})]})]})}),e.jsxs(h,{className:"p-0 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 px-4 md:px-0 pt-4 md:pt-0",children:[e.jsx(C,{variant:"outline",size:"icon",onClick:()=>P("prev"),children:e.jsx(os,{className:"h-4 w-4"})}),e.jsx("h3",{className:"text-lg font-semibold",children:X(u,"MMMM yyyy")}),e.jsx(C,{variant:"outline",size:"icon",onClick:()=>P("next"),children:e.jsx(ds,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-3 mb-6 px-4 md:px-0",children:A.map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:F("w-3 h-3 rounded",d.color)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d.label})]},d.status))}),b==="single"?e.jsx("div",{className:"flex justify-center pb-4",children:e.jsx(ms,{mode:"single",month:u,onMonthChange:N,className:"rounded-md border",modifiers:{booked:y.flatMap(d=>d.segments.filter(a=>a.type==="booking").flatMap(a=>Le({start:a.start,end:a.end}))),blocked:y.flatMap(d=>d.segments.filter(a=>a.type!=="booking").flatMap(a=>Le({start:a.start,end:a.end})))},modifiersStyles:{booked:{backgroundColor:"hsl(var(--destructive))",color:"white"},blocked:{backgroundColor:"rgb(139 92 246)",color:"white"}}})}):e.jsx("div",{className:"overflow-x-auto -mx-0 md:mx-0",children:e.jsxs("div",{className:"min-w-[600px] pb-4",children:[e.jsxs("div",{className:"flex border-b sticky top-0 bg-background z-10",children:[e.jsx("div",{className:"w-32 md:w-48 flex-shrink-0 p-2 font-medium bg-muted/50 text-sm",children:s("str.property","Property")}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:R.map(d=>e.jsxs("div",{className:F("flex-1 min-w-[24px] md:min-w-[28px] p-1 text-center text-[10px] md:text-xs border-l",d.getDay()===0||d.getDay()===6?"bg-muted/30":""),children:[e.jsx("div",{className:"font-medium",children:X(d,"d")}),e.jsx("div",{className:"text-muted-foreground hidden md:block",children:X(d,"EEE")})]},d.toISOString()))})]}),y.map(d=>e.jsxs("div",{className:"flex border-b hover:bg-muted/20",children:[e.jsxs("div",{className:"w-32 md:w-48 flex-shrink-0 p-2 flex items-center gap-2",children:[e.jsx(ne,{className:"h-3 w-3 md:h-4 md:w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium truncate text-xs md:text-sm",children:d.name})]}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:R.map(a=>{const t=r(d.id,a),o=l(d.id,a);return e.jsxs("div",{className:F("flex-1 min-w-[24px] md:min-w-[28px] h-8 md:h-10 border-l relative group cursor-pointer transition-colors",t==="available"&&"bg-green-500/20 hover:bg-green-500/30",t==="booked"&&"bg-destructive/80",t==="blocked"&&"bg-violet-500/80",t==="checkin"&&"bg-blue-500/80",t==="checkout"&&"bg-orange-500/80"),title:o?`${o.label} - ${o.status}`:s("str.available","Available"),children:[t==="checkin"&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-white text-[10px] md:text-xs font-medium",children:">"}),t==="checkout"&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-white text-[10px] md:text-xs font-medium",children:"<"})]},a.toISOString())})})]},d.id)),y.length===0&&e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:s("str.noProperties","No properties to display")})]})})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(be,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.availableNights","Available Nights")}),e.jsx("p",{className:"text-xl font-bold",children:$})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Ds,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.bookedNights","Booked Nights")}),e.jsx("p",{className:"text-xl font-bold",children:I})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-blue-500/10 flex items-center justify-center",children:e.jsx(se,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.upcomingCheckins","Upcoming Check-ins")}),e.jsx("p",{className:"text-xl font-bold",children:y.reduce((d,a)=>d+a.segments.filter(t=>t.type==="booking"&&t.start>=new Date).length,0)})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.occupancyRate","Occupancy Rate")}),e.jsxs("p",{className:"text-xl font-bold",children:[O>0?Math.round(I/O*100):0,"%"]})]})]})})})]})]})},It={confirmed:{label:"Confirmed",icon:ge,color:"text-green-500",bg:"bg-green-500/10"},pending:{label:"Pending",icon:xe,color:"text-yellow-500",bg:"bg-yellow-500/10"},cancelled:{label:"Cancelled",icon:us,color:"text-destructive",bg:"bg-destructive/10"},completed:{label:"Completed",icon:ge,color:"text-blue-500",bg:"bg-blue-500/10"}},Ot={direct:"📱"},Ft=()=>{const{t:s}=Z(),{formatCurrency:j}=De(),{listings:w}=le(),{bookings:f,isLoading:p,updateBooking:v}=fe(),[i,u]=g.useState(""),[N,b]=g.useState("all"),[k,c]=g.useState("all"),[m,R]=g.useState("upcoming"),[n,l]=g.useState(!1),[r,P]=g.useState(null),[A,y]=g.useState(""),I=g.useMemo(()=>{let t=[...f];const o=new Date;if(i){const S=i.toLowerCase();t=t.filter(W=>{var E;return W.guest_name.toLowerCase().includes(S)||((E=W.guest_email)==null?void 0:E.toLowerCase().includes(S))||W.id.toLowerCase().includes(S)})}return N!=="all"&&(t=t.filter(S=>S.status===N)),k!=="all"&&(t=t.filter(S=>S.listing_id===k)),m==="upcoming"?t=t.filter(S=>
1Be(D(S.check_in),o)||Be(D(S.check_out),o)):m==="past"&&(t=t.filter(S=>pt(D(S.check_out),o))),t.sort((S,W)=>D(S.check_in).getTime()-D(W.check_in).getTime()),t},[f,i,N,k,m]),O=t=>{const o=w.find(S=>S.id===t);return(o==null?void 0:o.title)||"Unknown Property"},$=t=>{var o;P(null),y(((o=w[0])==null?void 0:o.id)||""),l(!0)},L=t=>{P(t.id),y(t.listing_id),l(!0)},d=(t,o)=>{v({id:t,status:o})},a=g.useMemo(()=>{const t=new Date,o=f.filter(E=>E.status!=="cancelled"&&Be(D(E.check_in),t)),S=f.filter(E=>E.status==="confirmed"||E.status==="completed").reduce((E,Ae)=>E+Ae.total_price,0),W=f.filter(E=>E.status==="pending").length;return{total:f.length,upcoming:o.length,totalRevenue:S,pending:W}},[f]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.totalBookings","Total Bookings")}),e.jsx("p",{className:"text-2xl font-bold",children:a.total})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.upcomingBookings","Upcoming")}),e.jsx("p",{className:"text-2xl font-bold",children:a.upcoming})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.pendingApproval","Pending Approval")}),e.jsx("p",{className:"text-2xl font-bold text-yellow-500",children:a.pending})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.totalRevenue","Total Revenue")}),e.jsx("p",{className:"text-2xl font-bold",children:j(a.totalRevenue)})]})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsx(T,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:s("str.reservations","Reservations")}),e.jsx(B,{children:s("str.reservationsDescription","Manage all your bookings across channels")})]}),e.jsxs(C,{onClick:()=>$(),children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),s("str.addBooking","Add Booking")]})]})}),e.jsxs(h,{children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{placeholder:s("str.searchBookings","Search by guest name, email, or ID..."),className:"pl-9",value:i,onChange:t=>u(t.target.value)})]}),e.jsxs(te,{value:m,onValueChange:t=>R(t),children:[e.jsxs(ae,{className:"w-full sm:w-[150px]",children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),e.jsx(re,{})]}),e.jsxs(ie,{children:[e.jsx(_,{value:"upcoming",children:s("str.upcoming","Upcoming")}),e.jsx(_,{value:"past",children:s("str.past","Past")}),e.jsx(_,{value:"all",children:s("str.all","All")})]})]}),e.jsxs(te,{value:N,onValueChange:b,children:[e.jsxs(ae,{className:"w-full sm:w-[150px]",children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),e.jsx(re,{placeholder:s("str.status","Status")})]}),e.jsxs(ie,{children:[e.jsx(_,{value:"all",children:s("str.allStatuses","All Statuses")}),e.jsx(_,{value:"confirmed",children:s("str.confirmed","Confirmed")}),e.jsx(_,{value:"pending",children:s("str.pending","Pending")}),e.jsx(_,{value:"completed",children:s("str.completed","Completed")}),e.jsx(_,{value:"cancelled",children:s("str.cancelled","Cancelled")})]})]}),e.jsxs(te,{value:k,onValueChange:c,children:[e.jsxs(ae,{className:"w-full sm:w-[200px]",children:[e.jsx(ne,{className:"h-4 w-4 mr-2"}),e.jsx(re,{placeholder:s("str.property","Property")})]}),e.jsxs(ie,{children:[e.jsx(_,{value:"all",children:s("str.allProperties","All Properties")}),w.map(t=>e.jsx(_,{value:t.id,children:t.title},t.id))]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Me,{children:[e.jsx(J,{children:s("str.guest","Guest")}),e.jsx(J,{children:s("str.property","Property")}),e.jsx(J,{children:s("str.dates","Dates")}),e.jsx(J,{children:s("str.nights","Nights")}),e.jsx(J,{children:s("str.total","Total")}),e.jsx(J,{children:s("str.source","Source")}),e.jsx(J,{children:s("str.status","Status")}),e.jsx(J,{className:"w-[50px]"})]})}),e.jsx(ht,{children:I.length===0?e.jsx(Me,{children:e.jsx(Q,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:p?s("common.loading","Loading..."):s("str.noBookings","No bookings found")})}):I.map(t=>{const o=It[t.status],S=Ie(D(t.check_out),D(t.check_in));return e.jsxs(Me,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>L(t),children:[e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(ps,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.guest_name}),t.guest_email&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t.guest_email})]})]})}),e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:O(t.listing_id)})]})}),e.jsx(Q,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{children:X(D(t.check_in),"MMM d")}),e.jsxs("p",{className:"text-muted-foreground",children:["→ ",X(D(t.check_out),"MMM d, yyyy")]})]})}),e.jsx(Q,{children:e.jsxs(H,{variant:"outline",children:[S," ",S===1?"night":"nights"]})}),e.jsx(Q,{children:e.jsx("span",{className:"font-medium",children:j(t.total_price)})}),e.jsx(Q,{children:e.jsx("span",{className:"text-lg",title:"Direct",children:Ot.direct})}
1),e.jsx(Q,{children:e.jsxs(H,{className:F("gap-1",o.bg,o.color,"border-0"),children:[e.jsx(o.icon,{className:"h-3 w-3"}),o.label]})}),e.jsx(Q,{children:e.jsxs(lt,{children:[e.jsx(ct,{asChild:!0,onClick:W=>W.stopPropagation(),children:e.jsx(C,{variant:"ghost",size:"icon",children:e.jsx(es,{className:"h-4 w-4"})})}),e.jsxs(ot,{align:"end",children:[e.jsx(Ne,{onClick:()=>L(t),children:s("str.viewDetails","View Details")}),e.jsxs(Ne,{children:[e.jsx(je,{className:"h-4 w-4 mr-2"}),s("str.messageGuest","Message Guest")]}),e.jsx(dt,{}),t.status==="pending"&&e.jsxs(Ne,{onClick:()=>d(t.id,"confirmed"),children:[e.jsx(ge,{className:"h-4 w-4 mr-2 text-green-500"}),s("str.confirm","Confirm")]}),t.status!=="cancelled"&&t.status!=="completed"&&e.jsxs(Ne,{className:"text-destructive",onClick:()=>d(t.id,"cancelled"),children:[e.jsx(us,{className:"h-4 w-4 mr-2"}),s("str.cancel","Cancel")]})]})]})})]},t.id)})})]})}),I.length>0&&e.jsx("div",{className:"flex items-center justify-between mt-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.showingBookings","Showing {{count}} of {{total}} bookings",{count:I.length,total:f.length})})})]})]}),e.jsx(ut,{open:n,onOpenChange:l,listingId:A,bookingId:r||void 0})]})},Et=s=>{const{toast:j}=Ze(),w=gs();g.useEffect(()=>{const N=he.channel("rate-overrides-changes").on("postgres_changes",{event:"*",schema:"public",table:"rate_overrides"},()=>{w.invalidateQueries({queryKey:["rate-overrides"]})}).subscribe();return()=>{he.removeChannel(N)}},[w]);const{data:f,isLoading:p}=js({queryKey:["rate-overrides",s],queryFn:async()=>{let N=he.from("rate_overrides").select("*");s&&(N=N.eq("listing_id",s));const{data:b,error:k}=await N.order("date",{ascending:!0});if(k)throw k;return b||[]},enabled:!!s||s===void 0}),v=Ge({mutationFn:async N=>{const{error:b}=await he.from("rate_overrides").insert(N);if(b)throw b},onSuccess:()=>{w.invalidateQueries({queryKey:["rate-overrides"]}),j({title:"Custom rate added",description:"The custom pricing has been set."})},onError:()=>{j({title:"Error",description:"Failed to add custom rate.",variant:"destructive"})}}),i=Ge({mutationFn:async N=>{const{error:b}=await he.from("rate_overrides").delete().eq("id",N);if(b)throw b},onSuccess:()=>{w.invalidateQueries({queryKey:["rate-overrides"]}),j({title:"Custom rate removed",description:"The custom pricing has been deleted."})},onError:()=>{j({title:"Error",description:"Failed to remove custom rate.",variant:"destructive"})}}),u=(N,b)=>{const k=f==null?void 0:f.find(c=>c.date===b);return k?k.custom_rate:N};return{overrides:f||[],isLoading:p,createOverride:v.mutate,deleteOverride:i.mutate,getEffectiveRate:u}},Ut=()=>{var d;const{t:s}=Z(),{formatCurrency:j,currencyInfo:w}=De(),{listings:f,updateListing:p}=le(),{stats:v,trends:i}=Ue(),[u,N]=g.useState(((d=f[0])==null?void 0:d.id)||""),[b,k]=g.useState([]),[c,m]=g.useState(""),[R,n]=g.useState(!1),{overrides:l,createOverride:r,deleteOverride:P}=Et(u),A=f.find(a=>a.id===u),y=g.useMemo(()=>i?i.map(a=>({month:a.month,revenue:a.revenue,bookings:a.bookings})):[],[i]),I=g.useMemo(()=>l.map(a=>new Date(a.date)),[l]),O=()=>{!b.length||!c||!u||(b.forEach(a=>{r({listing_id:u,date:X(a,"yyyy-MM-dd"),custom_rate:parseFloat(c),min_nights:1})}),k([]),m(""))},$=a=>{P(a)},L=[{label:s("str.weekendBoost","Weekend +20%"),multiplier:1.2,days:"weekends"},{label:s("str.weekdayDiscount","Weekday -10%"),multiplier:.9,days:"weekdays"},{label:s("str.lastMinute","Last Minute -15%"),multiplier:.85,days:"next3days"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.monthlyRevenue","Monthly Revenue")}),e.jsx("p",{className:"text-2xl font-bold",children:j((v==null?void 0:v.totalRevenue)||0)})]}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(q,{className:"h-5 w-5 text-green-500"})})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-sm text-green-500",children:[e.jsx(de,{className:"h-4 w-4"}),e.jsx("span",{children:"+12% vs last month"})]})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.avgDailyRate","Avg Daily Rate")}),e.jsx("p",{className:"text-2xl font-bold",children:j((v==null?void 0:v.avgNightlyRate)||0)})]}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-blue-500/10 flex items-center justify-center",children:e.jsx(Se,{className:"h-5 w-5 text-blue-500"})})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-sm text-blue-500",children:[e.jsx(de,{className:"h-4 w-4"}),e.jsx("span",{children:"+5% vs market avg"})]})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.revPAN","RevPAN")}
1),e.jsx("p",{className:"text-2xl font-bold",children:j((v==null?void 0:v.revPAN)||0)})]}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(de,{className:"h-5 w-5 text-purple-500"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Revenue per available night"})]})}),e.jsx(x,{className:"shadow-card",children:e.jsxs(h,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.occupancy","Occupancy")}),e.jsxs("p",{className:"text-2xl font-bold",children:[((v==null?void 0:v.occupancyRate)||0).toFixed(1),"%"]})]}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(gt,{className:"h-5 w-5 text-orange-500"})})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-sm text-orange-500",children:[e.jsx(de,{className:"h-4 w-4"}),e.jsx("span",{children:"+8% vs last month"})]})]})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.revenueOverTime","Revenue Over Time")}),e.jsx(B,{children:s("str.last6Months","Last 6 months performance")})]}),e.jsx(h,{children:e.jsx("div",{className:"h-[300px]",children:y.length>0?e.jsx(we,{width:"100%",height:"100%",children:e.jsxs(jt,{data:y,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorRevenue",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(Oe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Fe,{dataKey:"month",className:"text-xs"}),e.jsx(ke,{className:"text-xs",tickFormatter:a=>`${w.symbol}${a}`}),e.jsx(Ce,{formatter:a=>[j(a),"Revenue"],contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(ft,{type:"monotone",dataKey:"revenue",stroke:"hsl(var(--primary))",fillOpacity:1,fill:"url(#colorRevenue)"})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:s("str.noRevenueData","No revenue data available yet")})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.baseRates","Base Rates")}),e.jsx(B,{children:s("str.setDefaultPricing","Set your default pricing for each property")})]}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:s("str.selectProperty","Select Property")}),e.jsxs(te,{value:u,onValueChange:N,children:[e.jsx(ae,{children:e.jsx(re,{placeholder:s("str.chooseProperty","Choose a property")})}),e.jsx(ie,{children:f.map(a=>e.jsx(_,{value:a.id,children:a.title},a.id))})]})]}),A&&e.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:s("str.nightlyRate","Nightly Rate")}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{type:"number",className:"pl-9",value:A.nightly_rate,onChange:a=>p({id:A.id,nightly_rate:parseFloat(a.target.value)||0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:s("str.cleaningFee","Cleaning Fee")}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{type:"number",className:"pl-9",value:A.cleaning_fee,onChange:a=>p({id:A.id,cleaning_fee:parseFloat(a.target.value)||0})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s("str.dynamicPricing","Dynamic Pricing")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.dynamicPricingDesc","Auto-adjust prices based on demand")})]}),e.jsx(ce,{checked:R,onCheckedChange:n})]}),R&&e.jsxs("div",{className:"p-4 rounded-lg bg-primary/5 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:s("str.smartPricing","Smart Pricing Active")}
1)]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.smartPricingDesc","Prices will automatically adjust based on seasonality, demand, and local events.")})]})]})]})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.dateSpecificPricing","Date-Specific Pricing")}),e.jsx(B,{children:s("str.customRatesForDates","Set custom rates for specific dates")})]}),e.jsxs(h,{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ms,{mode:"multiple",selected:b,onSelect:a=>k(a||[]),modifiers:{customRate:I},modifiersStyles:{customRate:{backgroundColor:"hsl(var(--primary) / 0.2)",fontWeight:"bold"}},className:"rounded-md border"})}),b.length>0&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsx("p",{className:"text-sm font-medium",children:s("str.selectedDates","{{count}} dates selected",{count:b.length})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{type:"number",className:"pl-9",placeholder:s("str.customRate","Custom rate"),value:c,onChange:a=>m(a.target.value)})]}),e.jsx(C,{onClick:O,children:s("str.apply","Apply")})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsx("p",{className:"text-sm font-medium",children:s("str.activeCustomRates","Active Custom Rates")}),e.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:l.slice(0,10).map(a=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:X(new Date(a.date),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:"secondary",children:j(a.custom_rate)}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(a.id),children:e.jsx(ns,{className:"h-3 w-3"})})]})]},a.id))})]})]})]})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5 text-primary"}),s("str.pricingSuggestions","Pricing Suggestions")]}),e.jsx(B,{children:s("str.pricingSuggestionsDesc","Quick pricing adjustments based on market insights")})]}),e.jsx(h,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:L.map((a,t)=>e.jsxs("div",{className:"p-4 rounded-lg border hover:border-primary/50 cursor-pointer transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium",children:a.label}),e.jsxs(H,{variant:a.multiplier>1?"default":"secondary",children:[a.multiplier>1?"+":"",((a.multiplier-1)*100).toFixed(0),"%"]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.days==="weekends"&&s("str.appliesToWeekends","Applies to Fri-Sun"),a.days==="weekdays"&&s("str.appliesToWeekdays","Applies to Mon-Thu"),a.days==="next3days"&&s("str.appliesToNext3Days","Applies to next 3 days")]}),e.jsx(C,{size:"sm",variant:"outline",className:"mt-3 w-full",children:s("str.applySuggestion","Apply")})]},t))})})]})]})},ve=["hsl(var(--primary))","#10B981","#F59E0B","#EF4444","#8B5CF6"],Gt=()=>{const{t:s}=Z(),{formatCurrency:j}=De(),{stats:w,trends:f}=Ue(),{bookings:p}=fe(),{listings:v}=le(),i=g.useMemo(()=>{const c=p.filter(l=>l.status==="confirmed"||l.status==="completed"),m=c.reduce((l,r)=>l+Ie(D(r.check_out),D(r.check_in)),0),R=c.reduce((l,r)=>l+r.total_price,0),n=c.length>0?m/c.length:0;return{totalBookings:c.length,totalNights:m,totalRevenue:R,avgStayLength:n,avgNightlyRate:m>0?R/m:0}},[p]),u=[{name:"Direct",value:45,color:ve[0]},{name:"Airbnb",value:30,color:ve[1]},{name:"Booking.com",value:15,color:ve[2]},{name:"Vrbo",value:10,color:ve[3]}],N=g.useMemo(()=>v.map(c=>{const m=p.filter(l=>l.listing_id===c.id&&(l.status==="confirmed"||l.status==="completed")),R=m.reduce((l,r)=>l+Ie(D(r.check_out),D(r.check_in)),0),n=m.reduce((l,r)=>l+r.total_price,0);return{name:c.title,bookings:m.length,nights:R,revenue:n,occupancy:Math.min(R/30*100,100)}}
1),[v,p]),b=f||[],k=[{type:"success",icon:de,title:s("str.occupancyUp","Occupancy is up!"),description:s("str.occupancyUpDesc","Your occupancy rate increased by 8% compared to last month.")},{type:"warning",icon:Ns,title:s("str.pricingOpportunity","Pricing Opportunity"),description:s("str.pricingOpportunityDesc","Weekend rates are 15% below market average. Consider increasing.")},{type:"info",icon:pe,title:s("str.reviewReminder","Review Collection"),description:s("str.reviewReminderDesc","You have 3 recent guests who haven't left reviews yet.")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-5",children:[e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(K,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.totalBookings","Total Bookings")}),e.jsx("p",{className:"text-xl font-bold",children:i.totalBookings})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(q,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.totalRevenue","Total Revenue")}),e.jsx("p",{className:"text-xl font-bold",children:j(i.totalRevenue)})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-blue-500/10 flex items-center justify-center",children:e.jsx(kt,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.occupancyRate","Occupancy Rate")}),e.jsxs("p",{className:"text-xl font-bold",children:[((w==null?void 0:w.occupancyRate)||0).toFixed(1),"%"]})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(Se,{className:"h-5 w-5 text-purple-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.avgNightlyRate","Avg Nightly Rate")}),e.jsx("p",{className:"text-xl font-bold",children:j(i.avgNightlyRate)})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.avgStayLength","Avg Stay Length")}),e.jsxs("p",{className:"text-xl font-bold",children:[i.avgStayLength.toFixed(1)," nights"]})]})]})})})]}),e.jsxs(ss,{defaultValue:"trends",className:"space-y-6",children:[e.jsxs(ts,{children:[e.jsxs(ye,{value:"trends",className:"gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),s("str.trends","Trends")]}),e.jsxs(ye,{value:"sources",className:"gap-2",children:[e.jsx(Ct,{className:"h-4 w-4"}),s("str.sources","Sources")]}),e.jsxs(ye,{value:"properties",className:"gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),s("str.byProperty","By Property")]})]}),e.jsx(G,{value:"trends",children:e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.bookingTrends","Booking & Revenue Trends")}),e.jsx(B,{children:s("str.last6Months","Performance over the last 6 months")})]}),e.jsx(h,{children:e.jsx("div",{className:"h-[350px]",children:b.length>0?e.jsx(we,{width:"100%",height:"100%",children:e.jsxs(Nt,{data:b,children:[e.jsx(Oe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Fe,{dataKey:"month",className:"text-xs"}),e.jsx(ke,{yAxisId:"left",className:"text-xs"}),e.jsx(ke,{yAxisId:"right",orientation:"right",className:"text-xs"}),e.jsx(Ce,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx($e,{}),e.jsx(ze,{yAxisId:"left",type:"monotone",dataKey:"bookings",name:"Bookings",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"}}),e.jsx(ze,{yAxisId:"right",type:"monotone",dataKey:"revenue",name:"Revenue",stroke:"#10B981",strokeWidth:2,dot:{fill:"#10B981"}})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:s("str.noTrendData","No trend data available yet")})})})]})}),e.jsx(G,{value:"sources",children:e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.bookingsBySource","Bookings by Source")}),e.jsx(B,{children:s("str.channelDistribution","Distribution across booking channels")})]}),e.jsx(h,{children:e.jsx("div",{className:"h-[350px] flex items-center justify-center",children:e.jsx(we,{width:"100%",height:"100%",children:e.jsxs(vt,{children:[e.jsx(yt,{data:u,cx:"50%",cy:"50%",innerRadius:80,outerRadius:120,paddingAngle:2,dataKey:"value",label:({name:c,percent:m})=>`${c} ${(m*100).toFixed(0)}%`,children:u.map((c,m)=>e.jsx(bt,{fill:c.color},`cell-${m}`))}),e.jsx(Ce,{})]})})})})]})}),e.jsx(G,{value:"properties",children:e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.propertyPerformance","Property Performance")}),e.jsx(B,{children:s("str.compareProperties","Compare performance across your properties")})]}),e.jsx(h,{children:e.jsx("div",{className:"h-[350px]",children:N.length>0?e.jsx(we,{width:"100%",height:"100%",children:e.jsxs(wt,{data:N,layout:"vertical",children:[e.jsx(Oe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Fe,{type:"number",className:"text-xs"}),e.jsx(ke,{dataKey:"name",type:"category",width:150,className:"text-xs"}),e.jsx(Ce,{formatter:(c,m)=>[m==="revenue"?j(c):c,m.charAt(0).toUpperCase()+m.slice(1)],contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx($e,{}),e.jsx(Ke,{dataKey:"bookings",name:"Bookings",fill:"hsl(var(--primary))"}),e.jsx(Ke,{dataKey:"nights",name:"Nights Booked",fill:"#10B981"})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:s("str.noPropertyData","No property performance data available")})})})]})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5 text-primary"}),s("str.insightsRecommendations","Insights & Recommendations")]}),e.jsx(B,{children:s("str.insightsDesc","AI-powered suggestions to improve your performance")})]}),e.jsx(h,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:k.map((c,m)=>e.jsxs("div",{className:`p-4 rounded-lg border ${c.type==="success"?"bg-green-500/5 border-green-500/20":c.type==="warning"?"bg-yellow-500/5 border-yellow-500/20":"bg-blue-500/5 border-blue-500/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(c.icon,{className:`h-5 w-5 ${c.type==="success"?"text-green-500":c.type==="warning"?"text-yellow-500":"text-blue-500"}`}),e.jsx("span",{className:"font-medium",children:c.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]},m))})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.guestSatisfaction","Guest Satisfaction")}),e.jsx(B,{children:s("str.reviewsRatings","Reviews and ratings overview")})]}),e.jsx(h,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:s("str.overallRating","Overall Rating")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(pe,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}),e.jsx("span",{className:"text-xl font-bold",children:"4.8"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"(47 reviews)"})]})]}),["Cleanliness","Communication","Check-in","Accuracy","Location","Value"].map((c,m)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:c}),e.jsx("span",{className:"font-medium",children:(4.5+Math.random()*.5).toFixed(1)})]}),e.jsx(cs,{value:90+Math.random()*10,className:"h-2"})]},c))]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:s("str.recentReviews","Recent Reviews")}),e.jsx("div",{className:"space-y-3",children:[{guest:"Sarah M.",rating:5,comment:"Amazing stay! The place was spotless and beautifully decorated."},{guest:"John D.",rating:5,comment:"Great location and very responsive host. Would definitely book again."},{guest:"Emma W.",rating:4,comment:"Nice apartment, could use better kitchen supplies."}].map((c,m)=>e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:c.guest}),e.jsx("div",{className:"flex items-center gap-0.5",children:Array(c.rating).fill(0).map((R,n)=>e.jsx(pe,{className:"h-3 w-3 fill-yellow-400 text-yellow-400"},n))})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.comment})]},m))})]})]})})]})]})},ue=[{id:"1",guestName:"Sarah Mitchell",guestAvatar:"",property:"Downtown Loft",source:"airbnb",lastMessage:"Thank y
1ou! Looking forward to our stay.",timestamp:new Date(Date.now()-1e3*60*15),unread:!0,status:"active"},{id:"2",guestName:"John Davis",guestAvatar:"",property:"Beach House",source:"booking",lastMessage:"What time is check-in?",timestamp:new Date(Date.now()-1e3*60*60*2),unread:!0,status:"pending"},{id:"3",guestName:"Emma Wilson",guestAvatar:"",property:"Mountain Cabin",source:"vrbo",lastMessage:"The wifi password worked, thanks!",timestamp:new Date(Date.now()-1e3*60*60*24),unread:!1,status:"active"},{id:"4",guestName:"Michael Brown",guestAvatar:"",property:"City Apartment",source:"direct",lastMessage:"Is early check-in possible?",timestamp:new Date(Date.now()-1e3*60*60*48),unread:!1,status:"completed"}],Wt=[{id:"1",sender:"guest",content:"Hi! I just booked your property for next weekend. Very excited!",timestamp:new Date(Date.now()-1e3*60*60*2)},{id:"2",sender:"host",content:"Welcome! We're thrilled to have you. Let me know if you have any questions about the area.",timestamp:new Date(Date.now()-1e3*60*60)},{id:"3",sender:"guest",content:"Thank y
1ou! What time is check-in?",timestamp:new Date(Date.now()-1e3*60*30)},{id:"4",sender:"host",content:"Check-in is at 3 PM. I'll send you the door code the morning of your arrival.",timestamp:new Date(Date.now()-1e3*60*20)},{id:"5",sender:"guest",content:"Thank you! Looking forward to our stay.",timestamp:new Date(Date.now()-1e3*60*15)}],Vt=[{id:"1",label:"Check-in Instructions",content:"Check-in is at 3 PM. The door code will be sent the morning of your arrival. Please find the lockbox on the right side of the front door."},{id:"2",label:"WiFi Info",content:`WiFi Network: GuestNetwork
2Password: Welcome2024
3Please let me know if you have any connection issues!`},{id:"3",label:"Check-out Reminder",content:"Just a friendly reminder that check-out is at 11 AM tomorrow. Please leave the keys on the kitchen counter. Safe travels!"},{id:"4",label:"Welcome Message",content:"Welcome to our home! We hope you have a wonderful stay. Please don't hesitate to reach out if you need anything."}],Xe={airbnb:"🏠",booking:"🅱️",vrbo:"🏡",direct:"📱"},qt=()=>{const{t:s}=Z(),[j,w]=g.useState(""),[f,p]=g.useState("all"),[v,i]=g.useState(ue[0].id),[u,N]=g.useState(""),[b,k]=g.useState(!1),c=g.useMemo(()=>{let r=[...ue];if(j){const P=j.toLowerCase();r=r.filter(A=>A.guestName.toLowerCase().includes(P)||A.property.toLowerCase().includes(P))}return f!=="all"&&(r=r.filter(P=>P.status===f)),r.sort((P,A)=>A.timestamp.getTime()-P.timestamp.getTime())},[j,f]),m=ue.find(r=>r.id===v),R=()=>{u.trim()&&(console.log("Sending message:",u),N(""))},n=r=>{N(r),k(!1)},l=ue.filter(r=>r.unread).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(je,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.unreadMessages","Unread")}),e.jsx("p",{className:"text-xl font-bold",children:l})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.avgResponseTime","Avg Response")}),e.jsx("p",{className:"text-xl font-bold",children:"15m"})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-blue-500/10 flex items-center justify-center",children:e.jsx(pe,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.responseRate","Response Rate")}),e.jsx("p",{className:"text-xl font-bold",children:"98%"})]})]})})}),e.jsx(x,{className:"shadow-card",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(ps,{className:"h-5 w-5 text-purple-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("str.activeChats","Active Chats")}),e.jsx("p",{className:"text-xl font-bold",children:ue.filter(r=>r.status==="active").length})]})]})})})]}),e.jsxs(x,{className:"shadow-card",children:[e.jsxs(T,{children:[e.jsx(M,{children:s("str.unifiedInbox","Unified Inbox")}),e.jsx(B,{children:s("str.inboxDescription","All guest messages from every channel in one place")})]}),e.jsx(h,{className:"p-0",children:e.jsxs("div",{className:"flex h-[600px] border-t",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{placeholder:s("str.searchConversations","Search conversations..."),className:"pl-9",value:j,onChange:r=>w(r.target.value)})]}),e.jsxs(te,{value:f,onValueChange:p,children:[e.jsxs(ae,{children:[e.jsx(hs,{className:"h-4 w-4 mr-2"}),e.jsx(re,{placeholder:s("str.allConversations","All Conversations")})]}),e.jsxs(ie,{children:[e.jsx(_,{value:"all",children:s("str.all","All")}),e.jsx(_,{value:"active",children:s("str.active","Active")}
3),e.jsx(_,{value:"pending",children:s("str.pending","Pending")}),e.jsx(_,{value:"completed",children:s("str.completed","Completed")})]})]})]}),e.jsx(Ye,{className:"flex-1",children:e.jsx("div",{className:"divide-y",children:c.map(r=>e.jsxs("div",{className:F("p-4 cursor-pointer hover:bg-muted/50 transition-colors",v===r.id&&"bg-muted"),onClick:()=>i(r.id),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs(Qe,{className:"h-10 w-10",children:[e.jsx(St,{src:r.guestAvatar}),e.jsx(He,{children:r.guestName.charAt(0)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:r.guestName}),e.jsx("span",{className:"text-lg",title:r.source,children:Xe[r.source]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r.property}),e.jsx("p",{className:F("text-sm truncate mt-1",r.unread?"font-medium":"text-muted-foreground"),children:r.lastMessage})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 pl-13",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:at(r.timestamp,{addSuffix:!0})}),r.unread&&e.jsx(H,{className:"h-2 w-2 p-0 rounded-full"})]})]},r.id))})})]}),e.jsx("div",{className:"flex-1 flex flex-col",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border-b flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qe,{children:e.jsx(He,{children:m.guestName.charAt(0)})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:m.guestName}),e.jsx("span",{className:"text-lg",children:Xe[m.source]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m.property})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",children:s("str.viewBooking","View Booking")}),e.jsx(C,{variant:"ghost",size:"icon",children:e.jsx(es,{className:"h-4 w-4"})})]})]}),e.jsx(Ye,{className:"flex-1 p-4",children:e.jsx("div",{className:"space-y-4",children:Wt.map(r=>e.jsx("div",{className:F("flex",r.sender==="host"?"justify-end":"justify-start"),children:e.jsxs("div",{className:F("max-w-[70%] rounded-lg p-3",r.sender==="host"?"bg-primary text-primary-foreground":"bg-muted"),children:[e.jsx("p",{className:"text-sm",children:r.content}),e.jsx("p",{className:F("text-xs mt-1",r.sender==="host"?"text-primary-foreground/70":"text-muted-foreground"),children:X(r.timestamp,"h:mm a")})]})},r.id))})}),b&&e.jsxs("div",{className:"p-4 border-t bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm font-medium",children:s("str.quickReplies","Quick Replies")}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>k(!1),children:"✕"})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:Vt.map(r=>e.jsxs(C,{variant:"outline",className:"justify-start h-auto py-2 px-3",onClick:()=>n(r.content),children:[e.jsx(Rt,{className:"h-4 w-4 mr-2 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r.label})]},r.id))})]}),e.jsx("div",{className:"p-4 border-t",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ls,{placeholder:s("str.typeMessage","Type your message..."),value:u,onChange:r=>N(r.target.value),className:"min-h-[80px] resize-none",onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),R())}}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>k(!b),children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),s("str.quickReplies","Quick Replies")]})})]}),e.jsx(C,{onClick:R,disabled:!u.trim(),children:e.jsx(Dt,{className:"h-4 w-4"})})]})})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(je,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:s("str.selectConversation","Select a conversation to view messages")})]})})})]})})]})]})},wn=()=>{const{t:s}=Z(),j=Ms(),[w,f]=ys(),{listings:p,isLoading:v}=le(),{bookings:i,isLoading:u}=fe(),{blocks:N,isLoading:b}=as(),k=[{id:"overview",label:s("str.overview","Overview"),icon:ne,hint:"Portfolio health"},{id:"calendar",label:s("str.calendar","Calendar"),icon:K,hint:"Turns and blocks"},{id:"bookings",label:s("str.bookings","Bookings"),icon:Je,hint:"Guest pipeline"},{id:"pricing",label:s("str.pricing","Pricing"),icon:q,hint:"Revenue controls"},{id:"channels",label:s("str.channels","Channels"),icon:Re,hint:"Airbnb, Vrbo, iCal"},{id:"messages",label:s("str.messages","Messages"),icon:je,hint:"Guest inbox"},{id:"analytics",label:s("str.analytics","Analytics"),icon:Se,hint:"Performance"},{id:"team",label:s("str.team","Team"),icon:se,hint:"Cleaner access"},{id:"proof",label:"Photo Proof",icon:Pt,hint:"Turnover evidence"},{id:"onboarding",label:s("str.onboarding","Setup"),icon:Y,hint:"Launch checklist"}],c=w.get("tab")||"overview",m=k.some(y=>y.id===c)?c:"overview",[R,n]=g.useState(m);g.useEffect(()=>{n(m)},[m]);const l=g.useMemo(()=>rt(new Date),[]),r=g.useMemo(()=>{const y=rs(l,30),I=p.filter(t=>t.is_active),O=i.filter(t=>
3t.status!=="cancelled"),$=O.filter(t=>{const o=D(t.check_in);return o>=l&&o<=y}),L=O.filter(t=>oe(D(t.check_in),l)).length,d=O.filter(t=>oe(D(t.check_out),l)).length,a=$.reduce((t,o)=>t+(Number(o.total_price)||0),0);return{activeListings:I.length,upcomingBookings:$.length,bookedRevenue:a,todaysCheckIns:L,todaysCheckOuts:d,blockedWindows:N.filter(t=>D(t.end_date)>=l).length}},[N,i,p,l]),P=y=>{n(y),f(I=>{const O=new URLSearchParams(I);return O.set("tab",y),O})},A=v||u||b;return e.jsxs(As,{children:[e.jsxs(vs,{children:[e.jsxs("title",{children:[s("rentals.shortTermRentals","Short-Term Rentals")," | JHA Solutions"]}),e.jsx("meta",{name:"description",content:s("str.dashboardDescription","Manage your short-term rental properties, bookings, and channels")})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ts,{title:s("rentals.shortTermRentals","Short-Term Rentals"),subtitle:s("str.dashboardSubtitle","Calendar, cleaner turns, guest messages, pricing, and channel sync in one workspace."),icon:e.jsx(ne,{className:"h-5 w-5"}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>P("channels"),children:[e.jsx(Re,{className:"mr-2 h-4 w-4"}),"Sync channels"]}),e.jsxs(C,{onClick:()=>P("bookings"),children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"New booking"]})]})}),e.jsx(Bs,{metrics:[{label:"Active listings",value:A?"...":r.activeListings,detail:`${p.length} total listings`,icon:Ps,tone:"info"},{label:"Next 30 days",value:A?"...":r.upcomingBookings,detail:"Upcoming reservations",icon:K,tone:"success"},{label:"Booked revenue",value:A?"...":`$${r.bookedRevenue.toLocaleString()}`,detail:"Expected from upcoming stays",icon:q,tone:"success"},{label:"Today",value:A?"...":`${r.todaysCheckIns} in / ${r.todaysCheckOuts} out`,detail:`${r.blockedWindows} active or future blocks`,icon:Tt,tone:r.todaysCheckIns||r.todaysCheckOuts?"warning":"default"}]}),e.jsx(Ls,{title:"Turnover Command",subtitle:"Use the calendar as the daily source of truth, then route cleaners and messages from the same flow.",action:e.jsx(_s,{tone:"info",children:"Smart STR workflow"}),children:e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:[{icon:K,title:"Check calendar gaps",detail:"Spot same-day turns, owner blocks, and open nights before they become missed revenue.",action:"Open Calendar",tab:"calendar"},{icon:ge,title:"Confirm cleaner readiness",detail:"Keep cleaner access, supply checks, and post-stay issues tied to the booking flow.",action:"Open Photo Proof",tab:"proof"},{icon:xe,title:"Review guest timing",detail:"Move check-ins, guest notes, and price changes out of scattered messages.",action:"Open Bookings",tab:"bookings"}].map(y=>e.jsxs("button",{type:"button",onClick:()=>P(y.tab),className:"rounded-lg border bg-background p-4 text-left transition-colors hover:bg-muted/60",children:[e.jsx(y.icon,{className:"h-5 w-5 text-primary"}),e.jsx("p",{className:"mt-3 font-medium",children:y.title}),e.jsx("p",{className:"mt-1 min-h-12 text-sm leading-6 text-muted-foreground",children:y.detail}),e.jsx("span",{className:"mt-3 inline-flex text-sm font-medium text-primary",children:y.action})]},y.title))})}),e.jsxs(ss,{value:R,onValueChange:P,className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-2",children:e.jsx(ts,{className:F("flex h-auto w-full justify-start gap-1 overflow-x-auto bg-transparent p-0",j&&"snap-x"),children:k.map(y=>e.jsxs(ye,{value:y.id,className:F("min-w-[132px] flex-none flex-col items-start gap-1 rounded-md px-3 py-2 text-left data-[state=active]:shadow-sm",j&&"snap-start"),children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(y.icon,{className:"h-4 w-4"}),y.label]}),e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:y.hint})]},y.id))})}),e.jsx(G,{value:"overview",className:"space-y-6",children:e.jsx(Mt,{})}),e.jsx(G,{value:"onboarding",className:"space-y-6",children:e.jsx(Lt,{})}),e.jsx(G,{value:"channels",className:"space-y-6",children:e.jsx(Zs,{})}),e.jsx(G,{value:"calendar",className:"space-y-6",children:e.jsx(_t,{})}),e.jsx(G,{value:"bookings",className:"space-y-6",children:e.jsx(Ft,{})}),e.jsx(G,{value:"pricing",className:"space-y-6",children:e.jsx(Ut,{})}),e.jsx(G,{value:"analytics",className:"space-y-6",children:e.jsx(Gt,{})}),e.jsx(G,{value:"messages",className:"space-y-6",children:e.jsx(qt,{})}),e.jsx(G,{value:"team",className:"space-y-6",children:e.jsx(et,{})}),e.jsx(G,{value:"proof",className:"space-y-6",children:e.jsx(At,{})})]})]})]})};export{wn as default};

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.