PageSourceSearch

https://globihome.com/assets/use-listing-interactions-Bjyk3liF.js

js globihome.com collected 2026-10-04 07:38:37 UTC 25,059 bytes, 1 lines download raw bytes

1import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t}from"./sentry-C5mSwRLu.js";import{r as n,t as r}from"./locale-messages-Cyk8Fozq.js";import{C as i}from"./shared-runtime-BrPBoBo3.js";import{n as a,p as o}from"./queryOptions-D5n76UJu.js";import{t as s}from"./useMutation-DzpM5oWU.js";import{A as c,On as l,Y as u,an as d,dn as f,dt as ee}from"./api-client-DlxYM9mr.js";import{$ as p,X as m,ct as h,dt as g,ft as _,lt as v,ut as y}from"./dist-BawyjGbQ.js";import{n as te}from"./AuthContext-3hFlvovY.js";import{t as b}from"./message-circle-BaltZA5D.js";import{r as x}from"./runtime-DtptkwDy.js";import{i as ne,o as re,r as ie,s as S,t as C}from"./dialog-DHGrOcz1.js";import{n as ae}from"./dist-Q5Zbqw46.js";import{a as w}from"./zaraz-C_fCGrmd.js";import{f as oe,r as T}from"./product-analytics-DQw1bobS.js";var se=(e,t={})=>(r(t.locale??x()).listingdetail_selfchat_description3??n(`listingdetail_selfchat_description3`))(e),ce=(e,t={})=>(r(t.locale??x()).listingdetail_selfchat_descriptionownlisting5??n(`listingdetail_selfchat_descriptionownlisting5`))(e),le=(e,t={})=>(r(t.locale??x()).listingdetail_selfchat_dismiss3??n(`listingdetail_selfchat_dismiss3`))(e),ue=(e,t={})=>(r(t.locale??x()).listingdetail_selfchat_technical3??n(`listingdetail_selfchat_technical3`))(e),de=(e,t={})=>(r(t.locale??x()).listingdetail_selfchat_title3??n(`listingdetail_selfchat_title3`))(e),fe=(e,t={})=>(r(t.locale??x()).listinginteractions_errors_actionfailed3??n(`listinginteractions_errors_actionfailed3`))(e),pe=(e,t={})=>(r(t.locale??x()).listinginteractions_errors_contactfailed3??n(`listinginteractions_errors_contactfailed3`))(e),me=(e,t={})=>(r(t.locale??x()).listinginteractions_errors_undofailed3??n(`listinginteractions_errors_undofailed3`))(e),E=e(t(),1),D=i(),he=e(l(),1);function O(e,t){return e===t||e.endsWith(`.${t}`)}function ge(){if(typeof window>`u`)return`production`;let e=window.location.hostname;return O(e,`globihome.local`)||O(e,`localhost`)?`local`:O(e,`globihome.dev`)?`dev`:O(e,`globihome.com`)?`production`:`local`}var _e=`globihome_ad_lead_claims_v1`;function ve(e){let t=new Set;return{claim(n,r){let i=`${n}:${r}`;if(t.has(i))return!1;t.add(i);try{let t=e();if(!t)return!0;let n=ye(t.getItem(_e));if(n.includes(i))return!1;n.push(i),t.setItem(_e,JSON.stringify(n.slice(-300)))}catch{}return!0}}}function ye(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function be(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}var xe=ve(be),k={listingViewed:`gh_listing_viewed`,searchResults:`gh_search_results`,listingSaved:`gh_listing_saved`,messageLead:`gh_lead_message`,callLead:`gh_lead_call`,whatsappLead:`gh_lead_whatsapp`,phoneRevealed:`gh_phone_revealed`},A={message:{eventIdPrefix:`lead_msg_`,guardGroup:`message`,event:k.messageLead,leadChannel:`message`},conversation:{eventIdPrefix:`lead_conv_`,guardGroup:`message`,event:k.messageLead,leadChannel:`message`},call:{eventIdPrefix:`lead_ph_`,guardGroup:`call_or_whatsapp`,event:k.callLead,leadChannel:`phone`},whatsapp:{eventIdPrefix:`lead_wa_`,guardGroup:`call_or_whatsapp`,event:k.whatsappLead,leadChannel:`whatsapp`},phone_reveal:{eventIdPrefix:`lead_rv_`,guardGroup:`phone_reveal`,event:k.phoneRevealed}},j=`home_listing`,Se=`EUR`,Ce=10;function we(e,t){return`${A[e].eventIdPrefix}${t}`}function M(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null&&e!==``&&!(Array.isArray(e)&&e.length===0)))}function N(e,t=e.length){return e.filter(e=>y(e.id)&&_(e.propertyType)).slice(0,t).map(e=>v(e.id))}function Te(e,t){if(y(e.id))try{return h(e.id,t)}catch{return}}function Ee(e){if(e===`sale`)return`for_sale`;if(e===`rent`)return`for_rent`}function P(e,t){return{event_id:e,dl:p(t.href)}}function De(e,t,n){let r=e.offerType===`sale`||e.offerType===`rent`;return{name:k.listingViewed,props:M({...P(n,t),content_type:j,content_ids:N([e]),city:e.city,country:e.countryCode?.toUpperCase(),property_type:_(e.propertyType),listing_type:r?g(e):void 0,availability:Ee(e.offerType),currency:e.currency,google_item_id:Te(e,t.locale)})}}function Oe(e){return JSON.stringify([e.countries??null,e.city??null,e.district??null,e.lat??null,e.lng??null,e.radiusKm??null,e.propertyType??null,e.offerType??null,e.priceMin??null,e.priceMax??null,e.currency??null])}function ke(e,t,n,r){let i=e.priceMin!=null||e.priceMax!=null;return{name:k.searchResults,props:M({...P(r,n),content_type:j,content_ids:N(t,Ce),country:e.countries?.length===1?e.countries[0]?.toUpperCase():void 0,property_type:_(e.propertyType),listing_type:e.marketType===`new`&&e.offerType===`sale`?`new_construction`:void 0,availability:Ee(e.offerType),preferred_price_range:i?[e.priceMin??null,e.priceMax??null]:void 0,currency:i?e.currency??`EUR`:void 0})}}function Ae(e,t,n){return{name:k.listingSaved,props:M({...P(n,t),content_type:j,content_ids:N([e]),google_item_id:Te(e,t.locale)})}}function je(e,t){let n=A[e.kind],r=we(e.kind,e.sourceId);return{name:n.event,props:M({...P(r,t),transaction_id:r,value:e.value,currency:Se,lead_channel:n.leadChannel,lead_state:e.leadState,content_type:j,content_ids:N([e.listing])})}}var F={sessionEligible:!1,routeSuppressed:!1,impersonating:!1};function Me(){return typeof window<`u`&&ge()===`production`}function Ne(e){F.sessionEligible=e}function Pe(e){F.routeSuppressed=e}function Fe(e){F.impersonating=e}function Ie(){return F.sessionEligible&&!F.routeSuppressed&&!F.impersonating&&Me()}function Le(){return{locale:x(),href:window.location.href}}function Re(e){if(Ie())try{w(e(Le()))}catch{}}
1function I(e){if(Ie())try{if(!xe.claim(A[e.kind].guardGroup,e.listing.id))return;w(je(e,Le()))}catch{}}function ze(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function Be(e){Re(t=>De(e,t,ze()))}function Ve(e,t){Re(n=>ke(e,t,n,ze()))}function He(e,t){Re(n=>Ae(e,n,t))}function Ue(e){I({kind:`message`,listing:e.listing,sourceId:e.clientRequestId,value:e.state===`queued`?m.messageLeadConfirmed:m.messageLeadUnverified,leadState:e.state})}function We(e){I({kind:`conversation`,listing:e.listing,sourceId:e.conversationId,value:m.messageLeadConfirmed,leadState:`queued`})}function Ge(e){I({kind:`call`,listing:e.listing,sourceId:e.clientActionId,value:m.callLead})}function Ke(e){I({kind:`whatsapp`,listing:e.listing,sourceId:e.clientActionId,value:m.whatsappLead})}function qe(e){I({kind:`phone_reveal`,listing:e.listing,sourceId:e.clientActionId,value:m.phoneRevealed})}function Je(e){return{id:e.id,propertyType:e.propertyType,offerType:e.offerType,marketType:e.marketType,sellerType:e.sellerType,city:e.address?.city,countryCode:e.address?.countryCode,currency:e.price?.currency}}var L=null,R=null;function Ye(e,t,n=`unknown`){T({channel:`globichat`,stage:`blocked_self`,surface:t,countryRelation:n,result:`blocked_self`});let r={source:e,surface:t};R=r,L&&(L(r),R=null)}function z(e){return(0,he.isAxiosError)(e)?e.response?.data?.code===`chat_self_conversation_not_allowed`:!1}function Xe(){let[e,t]=(0,E.useState)(!1),[n,r]=(0,E.useState)(null),i=(0,E.useRef)(!1);return(0,E.useEffect)(()=>{let e=e=>{r(e.source),t(!0)};if(L=e,R){let t=R;R=null,e(t)}return()=>{L===e&&(L=null)}},[]),(0,E.useEffect)(()=>{e&&!i.current&&n&&oe({source:n}),i.current=e},[e,n]),(0,D.jsx)(C,{open:e,onOpenChange:t,children:(0,D.jsxs)(ie,{className:`gap-0 rounded-[24px] p-0 sm:max-w-[420px]`,children:[(0,D.jsxs)(re,{className:`items-center px-6 pb-0 pt-8 text-center`,children:[(0,D.jsx)(`span`,{className:`mb-3 flex size-12 items-center justify-center rounded-full bg-accent-blue-soft text-[var(--icon-accent-primary)]`,children:(0,D.jsx)(b,{className:`size-6`,"aria-hidden":`true`})}),(0,D.jsx)(S,{className:`text-[20px] font-semibold leading-[1.5] tracking-[-1px] text-heading-globi`,children:de()}),(0,D.jsx)(ne,{className:`text-[14px] font-medium leading-[1.6] tracking-[-0.56px] text-[var(--text-caption)]`,children:se()}),(0,D.jsx)(`p`,{className:`text-[14px] font-medium leading-[1.6] tracking-[-0.56px] text-[var(--text-caption)]`,children:ce()}),(0,D.jsx)(`p`,{className:`pt-1 text-[12px] font-medium leading-[1.5] tracking-[-0.36px] text-[var(--text-placeholder)]`,children:ue()})]}),(0,D.jsx)(`div`,{className:`flex justify-center px-6 pb-8 pt-5`,children:(0,D.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`rounded-[50px] bg-[var(--button-primary-default)] px-6 py-2.5 text-[14px] font-medium tracking-[-0.56px] text-[var(--text-button-on-dark)] transition-colors hover:bg-[var(--button-primary-hover)]`,children:le()})})]})})}var Ze=3e4,Qe=1800*1e3,$e=new WeakMap;function et(e){return e.isAuthConfirmed?e.isAuthenticated?e.userId?`user:${e.userId}`:null:`anonymous`:null}function B(e){return[`listing-interaction-cache`,e]}function tt(e,t){return[...e,{listingInteractionActorScope:t}]}function nt(){return{states:{},knownIds:{},resolvedIds:{},inFlightIds:{},statusRetryAtById:{},pendingMutationIds:{},rehydrateAfterMutationIds:{},mutationSequenceByListingId:{},nextMutationSequence:0,nextStatusRequestSequence:0,importState:`idle`,importRetryAt:null}}function V(e){let t=$e.get(e);if(t)return t;let n={actorScope:null,generation:0,importBarrier:Promise.resolve(),persistenceByListing:new Map,pendingHydrationIds:new Map,scheduledHydrationActors:new Set};return $e.set(e,n),n}function rt(e){return e.queryKey.some(e=>typeof e==`object`&&!!e&&`listingInteractionActorScope`in e)}function it(e){let[t]=e.queryKey;return typeof t==`object`&&t&&`_id`in t?t._id:void 0}function at(e,t){let n=V(e);if(n.actorScope===t)return n.generation;let r=n.actorScope;if(n.actorScope=t,n.generation+=1,n.persistenceByListing.clear(),r){let t={predicate:e=>e.queryKey.some(e=>typeof e==`object`&&!!e&&`listingInteractionActorScope`in e&&e.listingInteractionActorScope===r)};e.cancelQueries(t).finally(()=>{e.removeQueries(t)}),e.removeQueries({queryKey:B(r)}
1),n.pendingHydrationIds.delete(r),n.scheduledHydrationActors.delete(r)}return e.removeQueries({predicate:e=>it(e)===`getSavedListingsControllerGetSavedListings`&&!rt(e)}),n.generation}function H(e){return V(e).generation}function U(e,t,n){let r=V(e);return r.actorScope===t&&r.generation===n}function W(e,t,n){let r=nt();return e.setQueryData(B(t),e=>(r=n(e??nt()),r)),r}function G(e,t,n,r){let i=V(e),a=i.generation,o=`${t}:${n}`,s=(i.persistenceByListing.get(o)??Promise.resolve()).catch(()=>void 0).then(()=>{if(!U(e,t,a))throw Error(`Listing interaction actor changed before persistence started`);return r()});i.persistenceByListing.set(o,s);let c=()=>{i.persistenceByListing.get(o)===s&&i.persistenceByListing.delete(o)};return s.then(c,c),s}function ot(e,t,n){let r=V(e),i=r.generation,a=r.importBarrier.then(()=>{if(!U(e,t,i))throw Error(`Listing interaction actor changed before import started`);return n()});return r.importBarrier=a.then(()=>void 0,()=>void 0),a}function st(e,t,n,r){let i=V(e),a=i.pendingHydrationIds.get(t)??new Set;n.forEach(e=>a.add(e)),i.pendingHydrationIds.set(t,a),!i.scheduledHydrationActors.has(t)&&(i.scheduledHydrationActors.add(t),queueMicrotask(()=>{i.scheduledHydrationActors.delete(t);let n=i.generation,a=[...i.pendingHydrationIds.get(t)??[]];if(i.pendingHydrationIds.delete(t),a.length===0||!U(e,t,n))return;let o=[],s=null;W(e,t,e=>{let t=dt(e,a);return o=t.batches,s=t.requestToken,t.cache}),o.length>0&&s!==null&&r(o,n,s)}))}function ct(e,t){return{listingId:e,isSaved:t.isSaved,isRejected:t.isRejected,hasContactIntent:t.hasContactIntent,isContacted:t.isContacted,conversationId:t.conversationId??null,lastEventId:null,lastAction:null}}function lt(e,t){let n={...e.knownIds},r={...e.resolvedIds},i={...e.inFlightIds},a={...e.statusRetryAtById},o={...e.states};for(let s of t)n[s.id]=!0,s.authority===`authoritative`&&(e.pendingMutationIds[s.id]||(o[s.id]=ct(s.id,s.interaction),r[s.id]=!0,delete i[s.id],delete a[s.id]));return{...e,knownIds:n,resolvedIds:r,inFlightIds:i,statusRetryAtById:a,states:o}}function ut(e){return[...new Set(e.filter(Boolean))].sort((e,t)=>e.localeCompare(t))}function dt(e,t=Object.keys(e.knownIds)){let n=ut(t).filter(t=>e.knownIds[t]&&!e.resolvedIds[t]&&!e.inFlightIds[t]&&!e.pendingMutationIds[t]&&(e.statusRetryAtById[t]??0)<=Date.now());if(n.length===0)return{cache:e,batches:[],requestToken:null};let r=e.nextStatusRequestSequence+1,i={...e.inFlightIds};for(let e of n)i[e]=r;let a=[];for(let e=0;e<n.length;e+=40)a.push(n.slice(e,e+40));return{cache:{...e,inFlightIds:i,nextStatusRequestSequence:r},batches:a,requestToken:r}}function ft(e,t,n,r=Date.now()+Ze){let i={...e.inFlightIds},a={...e.statusRetryAtById};for(let e of t)i[e]===n&&(delete i[e],a[e]=r);return{...e,inFlightIds:i,statusRetryAtById:a}}function pt(e,t,n=Date.now()){let r={...e.statusRetryAtById};return t.forEach(e=>{(r[e]??1/0)<=n&&delete r[e]}),{...e,statusRetryAtById:r}}function mt(e,t){let n={...e.knownIds},r={...e.resolvedIds},i={...e.inFlightIds},a={...e.statusRetryAtById};for(let e of t)n[e]=!0,delete r[e],delete i[e],delete a[e];return{...e,knownIds:n,resolvedIds:r,inFlightIds:i,statusRetryAtById:a}}function ht(e,t,n,r){let i=new Set(t),a=new Set(t.filter(t=>e.inFlightIds[t]===r)),o={...e.inFlightIds},s={...e.resolvedIds},c={...e.states},l={...e.statusRetryAtById};for(let e of i)o[e]===r&&delete o[e];for(let e of n)a.has(e.listingId)&&(c[e.listingId]=e,s[e.listingId]=!0,delete l[e.listingId]);return{...e,states:c,resolvedIds:s,inFlightIds:o,statusRetryAtById:l}}function K(e,t){let n=e.nextMutationSequence+1,r=e.states[t.listingId],i={...e.inFlightIds},a={...e.statusRetryAtById},o={...e.pendingMutationIds,[t.listingId]:!0};return delete i[t.listingId],delete a[t.listingId],{cache:{...e,states:{...e.states,[t.listingId]:t},knownIds:{...e.knownIds,[t.listingId]:!0},resolvedIds:{...e.resolvedIds,[t.listingId]:!0},inFlightIds:i,statusRetryAtById:a,pendingMutationIds:o,mutationSequenceByListingId:{...e.mutationSequenceByListingId,[t.listingId]:n},nextMutationSequence:n},token:{listingId:t.listingId,sequence:n,previousState:r}}}function q(e,t,n){if(e.mutationSequenceByListingId[n.listingId]!==t)return e;let r={...e.pendingMutationIds},i={...e.rehydrateAfterMutationIds},a={...e.resolvedIds},o={...e.inFlightIds};return delete r[n.listingId],delete o[n.listingId],i[n.listingId]?(delete i[n.listingId],delete a[n.listingId]):a[n.listingId]=!0,{...e,states:{...e.states,[n.listingId]:n},resolvedIds:a,inFlightIds:o,pendingMutationIds:r,rehydrateAfterMutationIds:i}}function gt(e,t){if(e.mutationSequenceByListingId[t.listingId]!==t.sequence)return e;let n={...e.states},r={...e.resolvedIds},i={...e.inFlightIds},a={...e.pendingMutationIds},o={...e.rehydrateAfterMutationIds};return t.previousState?n[t.listingId]=t.previousState:delete n[t.listingId],delete r[t.listingId],delete i[t.listingId],delete a[t.listingId],delete o[t.listingId],{...e,states:n,resolvedIds:r,inFlightIds:i,pendingMutationIds:a,rehydrateAfterMutationIds:o}}function _t(e){return e.importState===`pending`||e.importState===`complete`||e.importState===`failed`&&(e.importRetryAt??0)>Date.now()?{cache:e,claimed:!1}
1:{cache:{...e,importState:`pending`,importRetryAt:null},claimed:!0}}function vt(e){let t={...e.rehydrateAfterMutationIds};return Object.keys(e.pendingMutationIds).forEach(e=>{t[e]=!0}),{...e,resolvedIds:{},inFlightIds:{},importState:`complete`,importRetryAt:null,rehydrateAfterMutationIds:t}}function yt(e,t=Date.now()+Ze){return{...e,importState:`failed`,importRetryAt:t}}function bt(e){return e.importState===`failed`?{...e,importState:`idle`,importRetryAt:null}:e}var xt=`getSavedListingsControllerGetSavedListings`;function St(e,t){let[n]=e.queryKey;return typeof n==`object`&&!!n&&`_id`in n&&n._id===xt&&e.queryKey.some(e=>typeof e==`object`&&!!e&&`listingInteractionActorScope`in e&&e.listingInteractionActorScope===t)}var Ct=e=>({predicate:t=>St(t,e)});function wt(e,t){let n=e.items.filter(e=>e.id!==t);return n.length===e.items.length?e:{...e,items:n}}function Tt(e,t,n){let r=!1,i=e.items.map(e=>e.id===t?(r=!0,{...e,note:n}):e);return r?{...e,items:i}:e}function Et(e,t){if(`pages`in e){let n=!1,r=e.pages.map(e=>{let r=t(e);return r!==e&&(n=!0),r});return n?{...e,pages:r}:e}return t(e)}function Dt(e,t,n){e.setQueriesData(Ct(t),e=>e&&Et(e,e=>wt(e,n)))}function Ot(e,t,n,r){e.setQueriesData(Ct(t),e=>e&&Et(e,e=>Tt(e,n,r)))}function J(e,t){return e.invalidateQueries(Ct(t))}var Y=`globihome_listing_interactions_v1`,X=`globihome_pending_listing_contact_v1`,Z={isSaved:!1,isRejected:!1,hasContactIntent:!1,isContacted:!1,conversationId:null,lastEventId:null,lastAction:null};function Q(e=`web`){return`${e}:${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}function kt(){let e=$();if(!e)return null;try{let t=e.getItem(X);if(!t)return null;let n=JSON.parse(t);if(typeof n==`object`&&n&&`listingId`in n&&`clientActionId`in n&&`createdAt`in n&&typeof n.listingId==`string`&&typeof n.clientActionId==`string`&&typeof n.createdAt==`string`)return{listingId:n.listingId,clientActionId:n.clientActionId,createdAt:n.createdAt}}catch{e.removeItem(X)}return null}function At(e,t){let n=$();n&&n.setItem(X,JSON.stringify({listingId:e,clientActionId:t,createdAt:new Date().toISOString()}))}function jt(){$()?.removeItem(X)}function Mt(e){let t=JSON.parse(e.getItem(Y)??`[]`);return Array.isArray(t)?t.filter(Rt):[]}function Nt(){let e=$();if(!e)return[];try{return Mt(e).slice(-500)}catch{return e.removeItem(Y),[]}}function Pt(e){let t=$();if(!t)return[];try{let n=Mt(t),r=new Set(n.map((e,t)=>({event:e,index:t})).filter(({event:t})=>!t.claimedByUserId||t.claimedByUserId===e).slice(-500).map(({index:e})=>e)),i=n.map((t,n)=>r.has(n)&&!t.claimedByUserId?{...t,claimedByUserId:e}:t);return t.setItem(Y,JSON.stringify(i)),i.filter((e,t)=>r.has(t))}catch{return t.removeItem(Y),[]}}function Ft(e,t){let n=$();if(n)try{let r=new Set(e),i=Mt(n).filter(e=>!r.has(e.clientActionId)||t!==void 0&&e.claimedByUserId!==t);n.setItem(Y,JSON.stringify(i))}catch{n.removeItem(Y)}}function It(e){let t=$();if(!t)return;let n=Nt().filter(t=>t.clientActionId!==e.clientActionId);n.push(e),t.setItem(Y,JSON.stringify(n.slice(-500)))}function Lt(e){let t=$();if(!t)return;let n=Nt().filter(t=>t.clientActionId!==e);t.setItem(Y,JSON.stringify(n))}function $(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Rt(e){return typeof e==`object`&&!!e&&`listingId`in e&&`action`in e&&`source`in e&&`clientActionId`in e&&`createdAt`in e&&typeof e.listingId==`string`&&zt(e.action)&&Bt(e.source)&&typeof e.clientActionId==`string`&&typeof e.createdAt==`string`&&(!(`claimedByUserId`in e)||e.claimedByUserId===void 0||typeof e.claimedByUserId==`string`)}function zt(e){return e===`SAVE`||e===`UNSAVE`||e===`REJECT`||e===`CONTACT_INTENT`}function Bt(e){return e===`get_matched_swipe`||e===`get_matched_button`||e===`listing_card_heart`||e===`listing_detail_heart`||e===`saved_page`||e===`migration`||e===`contact_resume`}function Vt(e,t){switch(t){case`SAVE`:return{...e,isSaved:!0,isRejected:!1,hasContactIntent:!1,lastAction:t};case`UNSAVE`:return{...e,isSaved:!1,isRejected:!1,hasContactIntent:!1,lastAction:t};case`REJECT`:return e.isContacted?e:{...e,isSaved:!1,isRejected:!0,hasContactIntent:!1,lastAction:t};case`CONTACT_INTENT`:return{...e,isSaved:!0,isRejected:!1,hasContactIntent:!0,lastAction:t}}}function Ht(e,t){let n={...e};for(let e of Nt()){if(e.claimedByUserId&&e.claimedByUserId!==t)continue;let r=n[e.listingId]??{...Z,listingId:e.listingId};n[e.listingId]=Vt(r,e.action)}return n}function Ut(e){let{isAuthenticated:t,isAuthConfirmed:n,user:r}=te(),i=o(),[l,p]=(0,E.useState)(0),[m,h]=(0,E.useState)(0),g=(0,E.useRef)(!0),_=(0,E.useRef)([]),v=(0,E.useRef)(null),y=et({isAuthConfirmed:n,isAuthenticated:t,userId:r?.id}),{data:b}=a({queryKey:y?B(y):[`listing-interaction-cache`,`unconfirmed`],queryFn:nt,enabled:!1,staleTime:1/0,gcTime:Qe});(0,E.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,E.useEffect)(()=>{v.current!==y&&(_.current=[],v.current=y),at(i,y),y&&W(i,y,t=>lt(t,e))},[y,i,e]);let x=s({...ee(),retry:3}).mutateAsync;(0,E.useEffect)(()=>
1{if(!y?.startsWith(`user:`))return;let e=H(i),t=!1;W(i,y,e=>{let n=_t(e);return t=n.claimed,n.cache}),t&&ot(i,y,async()=>{let e=Pt(y.slice(5));await x({body:{events:e.map(({claimedByUserId:e,...t})=>t)}});let t=e.map(e=>e.clientActionId);return Ft(t,y.slice(5)),t}).then(()=>{U(i,y,e)&&(W(i,y,e=>vt(e)),J(i,y))}).catch(()=>{U(i,y,e)&&(W(i,y,yt),g.current&&h(e=>e+1),window.setTimeout(()=>{U(i,y,e)&&(W(i,y,bt),g.current&&h(e=>e+1))},3e4))})},[b?.importRetryAt,b?.importState,y,x,m,i]),(0,E.useEffect)(()=>{if(!y)return;let e=i.getQueryData(B(y));e&&(y.startsWith(`user:`)&&(e.importState===`idle`||e.importState===`pending`)||st(i,y,Object.keys(e.knownIds),(e,t,n)=>{for(let r of e){let e=u({query:{listingIds:r}}),a=[...tt(e.queryKey,y),{listingInteractionStatusRequestToken:n}];i.fetchQuery({...e,queryKey:a,staleTime:0}).then(e=>{U(i,y,t)&&W(i,y,t=>ht(t,r,e.items,n))}).catch(()=>{U(i,y,t)&&(W(i,y,e=>ft(e,r,n)),window.setTimeout(()=>{U(i,y,t)&&W(i,y,e=>pt(e,r))},3e4))})}}))},[b,y,m,i]);let ne=s({...d(),retry:3,onError:()=>{ae.error(fe())}}),re=s({...f(),retry:3,onError:()=>{ae.error(me())}}),ie=s({...c(),retry:(e,t)=>e<2&&!z(t),onError:e=>{z(e)||ae.error(pe())}}),S=(0,E.useMemo)(()=>{let t={...b?.states};for(let n of e)n.authority!==`authoritative`||t[n.id]||(t[n.id]={...Z,...n.interaction,conversationId:n.interaction.conversationId??null,listingId:n.id});return Ht(t,y?.startsWith(`user:`)?y.slice(5):null)},[b?.states,y,l,e]),C=(0,E.useCallback)(e=>S[e]??{...Z,listingId:e},[S]),w=(0,E.useCallback)((e,n,r,a)=>{let o=Q(n.toLowerCase()),s=C(e),c=Vt(s,n),l=n===`SAVE`||n===`UNSAVE`||n===`REJECT`,u=y,d=H(i),f=null;u&&W(i,u,e=>{let t=K(e,c);return f=t.token,t.cache}),u&&s.isSaved&&!c.isSaved&&Dt(i,u,e),t||(It({listingId:e,action:n,source:r,clientActionId:o,createdAt:new Date().toISOString()}),p(e=>e+1));let ee=()=>ne.mutateAsync({path:{id:e},body:{action:n,source:r,clientActionId:o}}),m=(u?G(i,u,e,ee):ee()).then(t=>{let r=f;return u&&r&&U(i,u,d)&&W(i,u,e=>q(e,r.sequence,t.interaction)),l&&u&&J(i,u),n===`SAVE`&&He(a??{id:e},o),t}).catch(e=>{let t=f;throw u?.startsWith(`user:`)&&t&&U(i,u,d)&&(W(i,u,e=>gt(e,t)),g.current&&h(e=>e+1)),l&&u&&J(i,u),e}),v=m.catch(()=>void 0);return l&&(_.current=[{listingId:e,previousState:s,clientActionId:o,persist:v,actorScope:u}]),{clientActionId:o,nextState:c,persist:m}},[y,C,t,i,ne]),oe=(0,E.useCallback)(()=>{let[e]=_.current;if(!e||e.actorScope!==y)return _.current=[],null;_.current=[];let t=Q(`undo`),n=e.actorScope,r=H(i),a=null;return n&&(W(i,n,t=>{let n=K(t,e.previousState);return a=n.token,n.cache}),J(i,n)),e.actorScope===`anonymous`&&(Lt(e.clientActionId),p(e=>e+1)),e.persist.then(o=>{if(!o){let t=a;n&&t&&U(i,n,r)&&(W(i,n,n=>mt(q(n,t.sequence,e.previousState),[e.listingId])),g.current&&h(e=>e+1));return}let s=()=>re.mutateAsync({path:{id:e.listingId},body:{clientActionId:t,undoEventId:o.interaction.lastEventId??void 0}});(n?G(i,n,e.listingId,s):s()).then(e=>{let t=a;n&&t&&U(i,n,r)&&W(i,n,n=>q(n,t.sequence,e.interaction))}).catch(()=>{let e=a;n&&e&&U(i,n,r)&&(W(i,n,t=>gt(t,e)),g.current&&h(e=>e+1))}).finally(()=>{n&&J(i,n)})}),e},[y,i,re]);return{states:S,getInteraction:C,recordAction:w,contactListing:(0,E.useCallback)(async(e,n=`listing_detail_sidebar`,r)=>{let a=Q(`contact`);if(T({channel:`globichat`,stage:`cta_clicked`,surface:n,countryRelation:`unknown`}),!t)return At(e,a),w(e,`CONTACT_INTENT`,`get_matched_button`),T({channel:`globichat`,stage:`intent_created`,surface:n,countryRelation:`unknown`,result:`auth_required`}),{requiresAuth:!0,conversationId:null};let o=C(e),s=_.current,c=y,l=H(i),u={...o,isSaved:!0,isRejected:!1,isContacted:!0,hasContactIntent:!1,lastAction:`CONTACT`},d={current:null};c&&W(i,c,e=>{let t=K(e,u);return d.current=t.token,t.cache}),_.current=[];try{let t=()=>ie.mutateAsync({path:{id:e}}),a=await(c?G(i,c,e,t):t());a.conversationId?(T({channel:`globichat`,stage:`conversation_started`,surface:n,countryRelation:`unknown`,result:`success`}),We({listing:r??{id:e},conversationId:a.conversationId})):T({channel:`globichat`,stage:`failed`,surface:n,countryRelation:`unknown`,result:`failed`});let o=d.current;return c&&o&&U(i,c,l)&&W(i,c,e=>q(e,o.sequence,{...u,conversationId:a.conversationId})),{requiresAuth:!1,conversationId:a.conversationId}}
1catch(e){z(e)?Ye(`api_rejection`,n):T({channel:`globichat`,stage:`failed`,surface:n,countryRelation:`unknown`,result:`failed`}),_.current=s;let t=d.current;throw c&&t&&U(i,c,l)&&(W(i,c,e=>gt(e,t)),g.current&&h(e=>e+1)),e}finally{c&&U(i,c,l)&&J(i,c)}},[y,ie,C,t,i,w]),undoLast:oe,canUndo:_.current.length>0,isImporting:b?.importState===`pending`}}export{Be as A,Oe as C,Ne as D,Pe as E,ge as F,qe as M,Ve as N,Ge as O,Ke as P,Je as S,Fe as T,tt as _,kt as a,z as b,J as c,vt as d,ot as f,U as g,mt as h,Q as i,Ue as j,We as k,Ot as l,et as m,Ft as n,At as o,H as p,jt as r,Ut as s,Pt as t,at as u,W as v,Me as w,Ye as x,Xe as y};

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.