PageSourceSearch

https://sunsetapartment.ee/assets/BookingSection-C3pXFB01.js

js sunsetapartment.ee collected 2026-09-30 06:36:30 UTC 14,827 bytes, 1 lines download raw bytes

1import{a as se,j as e,e as Oe,u as Ae,r as n,b as Be,s as A,a2 as Ee,au as $,av as $e,B as Z,aw as Ve}from"./index-DwmCyvIn.js";import{S as Fe,a as Le,b as Ue,c as ze,d as Je}from"./select-4GVnKBQv.js";import{u as Ge,A as Xe}from"./useAvailability-BsASYTAe.js";import{u as He,g as Ye,S as Ze,P as Ke}from"./StayExtensionPopup-DOjvL7Es.js";import{P as qe}from"./PromoCodeInput-DAH84oAB.js";import{a as Qe,P as We,b as et}from"./promoLink-CQl5Jlg8.js";import{a as _}from"./addDays-KM2RQqIm.js";import{S as tt}from"./star-FTLuhlWE.js";import{F as st}from"./facebook-BuPXFOUO.js";import{C as ot}from"./calendar-C_CFFMfJ.js";import{U as it}from"./users-BEB29zXW.js";import{d as K}from"./differenceInDays-Oo8GD58e.js";import{a as nt,i as q,b as at,c as Q}from"./popover-Dh3pQdP5.js";import{f as c,s as rt}from"./format-D--iGIR9.js";import"./index-BdQq_4o_.js";import"./index-C-D7eFvJ.js";import"./calendarEvents-Dd1sb3-Q.js";import"./startOfMonth-CqRI3ATb.js";import"./loader-circle-XjoJAR5T.js";import"./et-DIQHajBV.js";import"./isWithinInterval-CfEcPx4A.js";import"./trending-up-B_aOJnvT.js";import"./input-CmUnNnnD.js";const lt="/assets/sunset-view-CD9rXj_H.webp",ct=({rating:o,reviewCount:a,ratingLabel:y,featuredReviews:h,bookingUrl:i})=>{const{language:k}=se();return!o||!a?null:e.jsxs("div",{className:"p-4 sm:p-6 rounded-2xl bg-white/10 backdrop-blur-sm border border-white/20 mt-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3 sm:gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 order-1 
1sm:order-2 flex-1",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-semibold text-base sm:text-lg truncate",children:y||"Excellent"}),e.jsxs("p",{className:"text-white/60 text-xs sm:text-sm truncate",children:[a," ",k==="et"?"arvustust Booking.com":"reviews on Booking.com"]})]}),e.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-[#003580] flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-white font-bold text-lg sm:text-xl",children:o})})]}),e.jsx("a",{href:i||"https://www.booking.com/hotel/ee/sunset.html#tab-reviews",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center h-10 sm:h-12 px-4 sm:px-6 rounded-full bg-white text-ocean-deep font-medium text-sm sm:text-base hover:bg-white/90 transition-colors order-2 sm:order-1 w-full sm:w-auto flex-shrink-0",children:k==="et"?"Vaata Booking.com":"View on Booking.com"})]}),h&&h.length>0&&e.jsxs("div",{className:"border-t border-white/20 pt-4",children:[e.jsxs("p",{className:"text-white/80 italic text-sm leading-relaxed mb-2",children:['"',h[0].text,'"']}),e.jsxs("p",{className:"text-white/60 text-xs",children:["— ",h[0].author,", ",h[0].country]})]})]})},oe=(o,a)=>a==="et"?o.et:a==="fi"?o.fi:o.en,W=(o,a,y)=>o==="percent"?`−${a}%`:`−${a} ${oe({en:"€/night",et:"€/öö",fi:"€/yö"},y)}`,ee={"Code expired":{en:"This promo code has expired",et:"See sooduskood on aegunud",fi:"Tämä alennuskoodi on vanhentunut"},"Code usage limit reached":{en:"This promo code has already been used",et:"See sooduskood on juba ära kasutatud",fi:"Tämä alennuskoodi on jo käytetty"},"Code not yet valid":{en:"This promo code is not valid yet",et:"See sooduskood ei ole veel kehtiv",fi:"Tämä alennuskoodi ei ole vielä voimassa"}},te=(o,a)=>o&&ee[o]?oe(ee[o],a):void 0,Rt=()=>{var Y;const{t:o,language:a}=se(),y=Oe(),[h]=Ae(),[i,k]=n.useState(),[l,S]=n.useState(),[M,ie]=n.useState("2"),[v,ne]=n.useState(null),[D,ae]=n.useState(80),[C,re]=n.useState(2),[V,le]=n.useState(!1),[F,ce]=n.useState("16:00"),[de,me]=n.useState("11:00"),[ue,he]=n.useState(null),[pe,ge]=n.useState(null),[xe,be]=n.useState(null),[fe,ye]=n.useState(null),[ke,w]=n.useState(!1),[N,B]=n.useState(null),[I,ve]=n.useState("live"),[L,we]=n.useState("percent"),[P,Ne]=n.useState(10),[E,je]=n.useState(0),[U,_e]=n.useState(20),{toast:j}=Be();n.useEffect(()=>{(async()=>{var r,d;const{data:s}=await A.from("properties").select("id, base_price_per_night, min_stay, allow_same_day_booking, check_in_time, check_out_time, booking_rating, booking_review_count, booking_rating_label, booking_featured_reviews, payment_mode, direct_booking_discount_type, direct_booking_discount_value, returning_client_discount_type, returning_client_discount_value, one_night_upscale_percent").limit(1).single();if(s){ne(s.id),ae(Number(s.base_price_per_night)),re(s.min_stay||2),le(!!s.allow_same_day_booking),ce(((r=s.check_in_time)==null?void 0:r.slice(0,5))||"16:00"),me(((d=s.check_out_time)==null?void 0:d.slice(0,5))||"11:00"),he(s.booking_rating?Number(s.booking_rating):null),ge(s.booking_review_count),be(s.booking_rating_label),ye(s.booking_featured_reviews),ve(s.payment_mode||"live"),we(s.direct_booking_discount_type||"percent"),Ne(Number(s.direct_booking_discount_value??10)),_e(Number(s.one_night_upscale_percent??20));const{data:m}=await A.from("discount_rules").select("discount_percent, min_value, max_value, rule_type, is_active").eq("rule_type","occupancy").eq("is_active",!0).lte("min_value",1).limit(1).single();m&&je(Number(m.discount_percent??0))}})()},[]);const z=n.useRef(!1);n.useEffect(()=>{if(z.current)return;const t=h.get("promoCode");if(!t)return;const s=t.replace(/[^A-Za-z0-9+-]/g,"").toUpperCase().slice(0,8);s&&(z.current=!0,(async()=>{var m;let r=null,d=!1;try{const f=await A.functions.invoke("validate-promo-code",{body:{code:s}});r=f.data,d=!!f.error}catch{d=!0}if(d||!(r!=null&&r.valid)){j({title:o("promo.invalid"),description:te(r==null?void 0:r.error,a),variant:"destructive"});return}if(B(s),j({title:o("promo.applied"),description:W(r.discountType||"percent",Number(r.discountValue),a)}),!Qe(sessionStorage,s)){const f=h.get("pt")||"",O=et.test(f)?`&pt=${f}`:"",Re=`https://lljobjyomtsrarnjrxnh.supabase.co/functions/v1/lookup-promo-client?code=${encodeURIComponent(s)}${O}`;fetch(Re,{headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imxsam9ianlvbXRzcmFybmpyeG5oIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njk2MjQzMzksImV4cCI6MjA4NTIwMDMzOX0.AOcHtkFyBGGI9phHWx3EfcgbIx-GglhAj9cVuHboA_w"}}).then(g=>g.json()).then(g=>{g!=null&&g.found&&sessionStorage.setItem(We,JSON.stringify({code:s,name:g.name||"",email:g.email||"",phone:g.phone||"",language:g.language||"et"}))}).catch(()=>{})}(m=document.getElementById("booking"))==null||m.scrollIntoView({behavior:"smooth",block:"start"})})())},[h,j,o,a]);const{availability:T,loading:Se,isDateAvailable:x,findFirstAvailableDate:J}=Ge(v),Me=n.useMemo(()=>J(),[J]),{priceBreakdown:u,loading:Ce}=He(v,i,l,parseInt(M),N),G=Ee.useMemo(()=>{let t=D;return P>0&&(L==="percent"?t=Math.round(t*(1-P/100)):t=Math.max(0,t-P)),E>0&&(t=Math.round(t*(1-E/100))),t},[D,L,P,E]),b=i&&l?Math.max(0,K(l,i)):0,X=n.useCallback(t=>{let s=_(t,1);const r=nt(t,12);for(;s<=r;){if(!x(s))return s;s=_(s,1)}return null},[x]),p=n.useMemo(()=>
1i?X(i):null,[i,X]),R=n.useCallback(t=>{const s=c(t,"yyyy-MM-dd"),r=T[s];if(!r||r.available)return!1;const d=c(_(t,1),"yyyy-MM-dd"),m=T[d];return(m==null?void 0:m.available)===!0},[T]),De=n.useCallback(t=>{const s=rt(new Date),r=V?s:_(s,1);if(q(t,r))return;const m=i&&!l&&p&&at(t,p),f=R(t);if(!(!x(t)&&!m&&!f)){if(!i||i&&l){if(!x(t)&&!R(t))return;k(t),S(void 0),w(!1),$(c(t,"yyyy-MM-dd"))}else if(i&&!l){if(!x(t)&&R(t)){k(t),S(void 0),w(!1),$(c(t,"yyyy-MM-dd"));return}if(q(t,i))k(t),S(void 0),w(!1),$(c(t,"yyyy-MM-dd"));else{const O=K(t,i);if(O<C||p&&Q(t,p))return;S(t),w(!1),$e(c(i,"yyyy-MM-dd"),c(t,"yyyy-MM-dd"),O)}}}},[i,l,x,R,p,C]),Ie=n.useCallback(t=>{if(!i)return;const s=_(i,t);for(let r=1;r<t;r++){const d=_(i,r);if(!x(d))return}p&&Q(s,p)||(S(s),w(!1))},[i,x,p]),H=n.useMemo(()=>!i||!l?null:Ye(b,U),[i,l,b,U]),Pe=()=>i?l?`${c(i,"d MMM")} ${F} → ${c(l,"d MMM")} ${de}`:`${c(i,"d MMM")} ${F} → ?`:o("booking.selectDates"),Te=[o("booking.feature.instant"),o("booking.feature.cancellation"),o("booking.feature.bestPrice"),o("booking.feature.directComm")];return e.jsxs("section",{id:"booking",className:"py-12 md:py-20 relative overflow-hidden scroll-mt-nav",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:lt,alt:"Sunset view background",className:"w-full h-full object-cover",loading:"lazy",decoding:"async",width:1920,height:1080}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-ocean-deep/95 via-ocean-deep/90 to-ocean-deep/80"})]}),e.jsx("div",{className:"container mx-auto px-4 relative z-10",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-start",children:[e.jsxs("div",{className:"text-white",children:[e.jsx("h2",{className:"font-display text-3xl md:text-4xl lg:text-5xl font-semibold mb-6",children:o("booking.title")}),e.jsx("p",{className:"text-lg text-white/80 mb-8 leading-relaxed",children:o("booking.directDescription")}),e.jsx("div",{className:"space-y-4 mb-8",children:Te.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-gradient-sunset flex items-center justify-center",children:e.jsx(tt,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:"text-white/90",children:t})]},s))}),e.jsxs("div",{className:"p-6 rounded-2xl bg-white/10 backdrop-blur-sm border border-white/20",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx("span",{className:"text-white/70",children:o("booking.starting")}),e.jsxs("span",{className:"font-display text-4xl font-semibold",children:["€",G]}),e.jsx("span",{className:"text-white/70",children:o("booking.perNight")})]}),G<D&&e.jsxs("p",{className:"text-xs text-white/50 mb-2 line-through",children:["€",D," / ",o("booking.perNight")]}),e.jsx("p",{className:"text-sm text-white/60",children:o("booking.minStay")}),e.jsx("div",{className:"mt-4 pt-4 border-t border-white/20 text-sm",children:e.jsx("p",{className:"text-white/70",children:o("booking.discountInfo")})})]}),e.jsx(ct,{rating:ue,reviewCount:pe,ratingLabel:xe,featuredReviews:fe,bookingUrl:"https://www.booking.com/hotel/ee/sunset.html#tab-reviews"}),e.jsxs("a",{href:"https://www.facebook.com/SunsetDreamApartment",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 mt-4 p-4 rounded-xl bg-white/5 hover:bg-white/10 border border-white/10 transition-colors",children:[e.jsx(st,{className:"h-5 w-5 text-[#1877F2]"}),e.jsx("span",{className:"text-white/80 text-sm",children:o("booking.followFb")})]})]}),e.jsxs("div",{className:"bg-card rounded-3xl p-6 md:p-8 shadow-luxury relative",children:[I==="demo"&&e.jsx("div",{className:"absolute inset-0 z-20 bg-card/90 backdrop-blur-sm rounded-3xl flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"text-5xl mb-4",children:"🚧"}),e.jsx("h3",{className:"font-display text-2xl font-bold text-foreground mb-2",children:a==="et"?"Demo leht":a==="fi"?"Demosivu":"Demo page"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:a==="et"?"Avame peagi!":a==="fi"?"Avaamme pian!":"Opening soon!"})]})}),I==="test"&&e.jsx("div",{className:"mb-4 p-3 rounded-xl bg-yellow-100 border border-yellow-300 text-center",children:e.jsxs("p",{className:"text-sm font-semibold text-yellow-800",children:["🧪 ",a==="et"?"Testi broneerimist!":a==="fi"?"Testaa varausta!":"Test the booking!"]})}),e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(ot,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"font-display text-2xl font-semibold text-foreground",children:o("booking.checkAvailability")})]}),e.jsxs("div",{className:"mb-4 p-3 rounded-xl bg-muted text-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o("booking.selectedPeriod")}),e.jsx("p",{className:"font-medium text-foreground",children:Pe()})]}),e.jsx("div",{className:"mb-6",children:e.jsx(Xe,{availability:T,checkIn:i,checkOut:l,onDateSelect:De,isLoading:Se,maxCheckoutDate:p,firstAvailableDate:Me,minStay:C,allowSameDayBooking:V})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:o("booking.guests")}),e.jsxs(Fe,{value:M,onValueChange:ie,children:[e.jsx(Le,{className:"w-full h-12 booking-input","aria-label":o("booking.guests"),children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(it,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx(Ue,{})]})}),e.jsx(ze,{children:[1,2,3,4].map(t=>e.jsxs(Je,{value:t.toString(),children:[t," ",o(t===1?"booking.guest":"booking.guestPlural")]},t))})]})]}),e.jsx(Ze,{selectedNights:b,suggestion:H,onExtend:Ie,onDismiss:()=>w(!0),visible:!ke&&!!H}),e.jsx(qe,{appliedCode:N,onApply:async t=>{try{const{data:s,error:r}=await A.functions.invoke("validate-promo-code",{body:{code:t}});
1if(r||!(s!=null&&s.valid)){j({title:o("promo.invalid"),description:te(s==null?void 0:s.error,a),variant:"destructive"});return}B(t),j({title:o("promo.applied"),description:W(s.discountType||"percent",Number(s.discountValue),a)})}catch{j({title:a==="et"?"Viga":"Error",description:a==="et"?"Koodi kontrollimine ebaõnnestus":"Failed to validate code",variant:"destructive"})}},onRemove:()=>B(null)}),b>0&&e.jsx(Ke,{breakdown:u,loading:Ce}),e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx(Z,{onClick:()=>{if(i&&l&&v){const t=new URLSearchParams({checkIn:c(i,"yyyy-MM-dd"),checkOut:c(l,"yyyy-MM-dd"),guests:M,propertyId:v});N&&t.set("promoCode",N),Ve({checkIn:c(i,"yyyy-MM-dd"),checkOut:c(l,"yyyy-MM-dd"),nights:b,guests:parseInt(M),totalPrice:(u==null?void 0:u.finalPrice)??0}),y(`/checkout?${t.toString()}`)}},disabled:!i||!l||b<C,className:"w-full h-14 text-lg font-medium btn-sunset text-white",children:I==="demo"?a==="et"?"Demo broneering":a==="fi"?"Demo-varaus":"Demo booking":I==="test"?a==="et"?"Testbroneering - testi makseid!":a==="fi"?"Testivaraus - testaa maksuja!":"Test booking - test payments!":b>0&&u?`${o("booking.bookNow")} - €${Math.round(u.finalPrice)}`:o("booking.bookNow")}),((Y=u==null?void 0:u.deposit)==null?void 0:Y.enabled)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Z,{onClick:()=>{if(i&&l&&v){const t=new URLSearchParams({checkIn:c(i,"yyyy-MM-dd"),checkOut:c(l,"yyyy-MM-dd"),guests:M,propertyId:v,deposit:"true"});N&&t.set("promoCode",N),y(`/checkout?${t.toString()}`)}},disabled:!i||!l||b<C,variant:"outline",className:"w-full h-12 text-base font-medium border-primary/50 text-primary hover:bg-primary/10 hover:text-primary",children:[o("booking.orDeposit")," - €",Math.round(u.deposit.depositAmount)]}),e.jsx("p",{className:"text-sm text-center text-muted-foreground/80",children:o("booking.depositNonRefundable")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground mt-3",children:o("booking.notChargedYet")})]})]})})]})};export{Rt as BookingSection};

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.