define("controllers/Property/PropertySidebar",["require","ControllerObjects","Application","Objects","Utilities"],function(e){return function(t){function n(e){switch(e.type){case"trackUserEvent":e.data&&(e.data.viewSourceID=3);break;case"leadgenForm.show":d();break;case"sellspeed.show":return j.exists("showSellSpeed")&&j.call("showSellSpeed"),!1;case"sellspeed.open":return j.exists("openSellSpeed")&&j.call("openSellSpeed"),!1;case"getAvailability.success":return D&&B.get("myListingAdminPanel").event("getAvailability.data",e.data.getAvailabilityData),!1;case"getAvailability.failure":return D&&B.get("myListingAdminPanel").event("getAvailability.failure"),!1;case"userItem.phoneNumberClicked":return"function"==typeof gtag&>ag("event","listing_lead_gen_phone_click"),!1}return j.call("bubble",e),!1}function o(e){W.update(e),i()}function i(){try{W.requireDom(),W.require("details"),W.require("propertyAddressItem"),W.optional("mlsFeedbackParams"),W.optional("qs")}catch(e){throw e}q.getCurrentUser(function(e){var t,n,o,i;A=e.user,S=null===(t=A)||void 0===t?void 0:null===(n=t.currentDetails)||void 0===n?void 0:null===(o=n.products)||void 0===o?void 0:null===(i=o.pro)||void 0===i?void 0:i.availableForUse,H.template.get({$dom:W.$dom,data:{details:W.get("details"),pro:S,permissions:A.permissions,coStarBrand:_},pass:{$mobileActionsContainer:W.get("mobileActionsContainer"),$mobileConversationsContainer:W.get("mobileConversationsContainer"),$mobileAgentsContainer:W.get("mobileAgentsContainer")}})})}function r(e){var t,o,r,u,v,m;h=e.$dom,w=e.data.details,null!==(t=w)&&void 0!==t&&null!==(o=t.status)&&void 0!==o&&o.enableCoExclusiveListing&&(B.add("listingRelatedListings",new x.ChildController({type:"controllers/Property/ListingRelatedListings",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("listingRelatedListings",{$dom:h.divRelatedListings,data:{listingID:w.listingID}}));var C=W.get("propertyAddressItem"),b=W.get("mlsFeedbackParams");if(D=!1,A&&A.permissions&&A.permissions.mlsAgent){var M,L=w&&w.agentOnly&&w.agentOnly.agents.filter(function(e){return e.agent.entityID===A.entityID&&e});if(D=L&&L.length>=1,D&&(I=L.role),L&&A.permissions.homeSnapAdminTools&&null!==(M=Homesnap)&&void 0!==M&&M.environmentType&&1!=(1&Homesnap.environmentType)){var k=$("").addClass("font-12").text("to toggle the My Listing Admin Panel"),R=$("").addClass("bs4--border-0 bs4--bg-transparent bs4--text-hs-blue").text("Click Here");k.prepend(R),h.divFloatingContainer.append(k),R.on("click",function(e){return W.set("currentUserRelatedToListing",!D),i(),!1}),D=W.get("currentUserRelatedToListing")}a(e.pass.$mobileActionsContainer)}if(w&&w.conversations&&l(e.pass.$mobileConversationsContainer),(null!==(r=A)&&void 0!==r&&null!==(u=r.permissions)&&void 0!==u&&u.mlsAgent||S)&&p(),w.status&&w.status.canGenerateRapidCMA&&!D&&(B.add("requestCMA",new x.ChildController({type:"controllers/ListingRequestCMA",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("requestCMA",{$dom:h.divRequestCMA,data:{listing:w,pro:S}}),h.divAgentActions.removeClass("hidden")),w.agentOnly&&(w.agentOnly.status&&w.agentOnly.status.checkForShowingUrl&&(D?g(C):(B.add("scheduleShowing",new x.ChildController({type:"controllers/ListingScheduleShowing",namespace:N.get(),register:{bubble:n,showingUrlSuccess:function(){h.divAgentActions.removeClass("hidden")},showingUrlHomesnapSuccess:function(){g(C)}}}),!0),W.updateController("scheduleShowing",{$dom:h.divScheduleShowing,data:{propertyAddressItem:W.get("propertyAddressItem")}}))),w.agentOnly.agents&&!D)){h.divRelatedAgentsPanel.length>0&&h.divRelatedAgentsPanel.removeClass("bs4--d-none"),c(e.pass.$mobileAgentsContainer);var F=w.agentOnly.agents.length>1;B.add("relatedAgents",new x.ChildControllerArray({type:"controllers/ListingRelatedAgent",namespace:N.get(),register:{bubble:n,listingRelatedAgentCheck:function(e){B.get("relatedAgents").event("check",e.data),B.get("conversationInlineSend").event("relatedAgentsRecipient",e.data)},listingRelatedAgentUnCheck:function(e){B.get("relatedAgents").event("uncheck",e.data)}}}),!0),W.updateController("relatedAgents",{$dom:h.divRelatedAgents,data:w.agentOnly.agents.map(function(e,t){return{relatedAgent:e,showCheckBox:F&&e.status.showWithMessageTextBox,checked:0===t}})}),B.add("conversationInlineSend",new x.ChildController({type:"controllers/ConversationInlineSend",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("conversationInlineSend",{$dom:h.divInlineConversation,data:{relatedAgent:w.agentOnly.agents[0],listing:w}})}if(w&&!w.listingID&&S&&C&&C.propertyID&&H.getOwner.get({$dom:W.$dom,data:{propertyID:C.propertyID},success:s,failure:function(){throw W&&console.info(W),new Error("Property Sidebar controller: Unhandled Error in GetOwnershipSnapshot web service")}}),null!==(v=A)&&void 0!==v&&null!==(m=v.permissions)&&void 0!==m&&m.agent){var P;null!==C&&void 0!==C&&null!==(P=C.transactionType)&&void 0!==P&&P.forSale&&!w.listingID&&h.btnNetSheet.on("click",function(){return B.add("netSheetCalculator",new x.ChildController({type:"controllers/NetSheetCalculator",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("netSheetCalculator",{data:{propertyAddressItem:C,propertyDetails:w}}),!1}).removeClass("hidden"),B.add("advertiseUnits",new x.ChildController({type:"controllers/AdvertiseUnits",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("advertiseUnits",{$dom:h.divAdvertiseUnits,data:{placementType:C&&C.listing?3:4,currentUser:A}})}var U=b&&"object"==typeof b&&Object.keys(b).length>0;C&&h.divLeadGenForm&&!U&&d(e.pass.$mobileAgentsContainer),w.conversations&&w.conversations.length>0&&h.divRelatedConversations&&(B.add("conversationItem",new x.ChildControllerArray({type:"controllers/ConversationItem",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("conversationItem",{$dom:h.divRelatedConversations,data:w.conversations.map(function(e){return{conversationItem:e,relatedConversation:!0}})}),h.btnSendInAMessage.on("click",function(){return B.add("sendInAMessageMaster",new x.ChildController({type:"controllers/SendInAMessageMaster",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("sendInAMessageMaster",{data:{paItem:w}}),!1})),A&&A.currentDetails&&(A.currentDetails.clientAppType&&!A.currentDetails.clientAppType.isAppUser? (2===G.placardVersion),V.get("showAgo",!1)&&B.listing&&B.listing.ago)G.statusText=B.listing.ago;else if(e&&e.latitude&&e.longitude&&B.latitude&&B.longitude){var t=U.map.getDistance(e.latitude,e.longitude,B.latitude,B.longitude);t>0&&(G.statusText="".concat(U.string.getNumber(t).decimal1," Miles Away"))}else V.get("showUnit",!1)&&B.address&&B.address.unitNumber&&(G.statusText=B.address.unitNumber.string);V.get("statusCssClass",null)&&B.customStatus&&""!==B.customStatus&&(G.statusText=B.customStatus),G.paging=V.get("paging",!0),(V.get("link",!0)||V.get("detailsButton"))&&(G.detailsButton=!0),(G.corner||G.address)&&(G.paging=!1),G.priceAddressGroup=V.get("showPriceAddressGroup",!1),(G.units.total||G.units.listings)&&(G.price=!1,G.address=!1,G.statusBar=!1,G.statusText=!1),V.get("showBuildingUnit",!1)&&B.address&&B.address.unitNumber&&(G.buildingUnit="Unit ".concat(B.address.unitNumber.string),G.gradient=!0),V.set("paging",G.paging)}function a(e){"propertyFavoriteStatus.updated"===(null===e||void 0===e?void 0:e.type)&&h(e.data),O.call("bubble",e)}function s(e){V.update(e),r(),P=V.get("$container"),!1===V.get("lazy")?o():setTimeout(g,100)}function o(){try{if(V.requireDom(),!V.get("propertyAddressItem")&&!V.get("ids"))throw new Error("Requires state.data.propertyAddressItem OR state.data.ids")}catch(e){throw e}if(V.get("propertyAddressItem"))n();else{var e=V.get("ids");X.itemByIds.get({data:{propertyAddressID:e.propertyAddressID||0,propertyID:e.propertyID||0,listingID:e.listingID||0}})}}function n(e){if(e&&e.data&&V.set("propertyAddressItem",e.data),B=V.get("propertyAddressItem")){if(Array.isArray(B)&&B[0]){var t=B.filter(function(e){return e.listing&&(e.listing.isOpenHouse||e.listing.isAgentOpen)});G.openHouses=t.length===B.length,B.length>1&&(G.units.listings=U.string.getNumber(B.length).commas,G.units.total=M.get(B[0],"building.propertyCount.commas"),G.buildingSummary=!0,V.set("paging",!1)),V.set("propertyAddressItem",B[0]),B=B[0]}i(),G.statusBar&&!B.listing?H.getCurrentUser(function(e){var t,r,i;if(null===(t=(e.user||{}).currentDetails)||void 0===t?void 0:null===(r=t.products)||void 0===r?void 0:null===(i=r.pro)||void 0===i?void 0:i.availableForUse)if(B.attributes&&B.attributes.likelihoodToList&&!B.attributes.likelihoodToList.none)if(B.attributes.likelihoodToList.leastLikely)d();else{var a="",s="likely-status";B.attributes.likelihoodToList.mostLikely&&(a="Most ",s="most-likely-status"),a+="Likely To List",d({title:a,customClass:s})}else d();else d()}):d()}}function l(){(B=V.get("propertyAddressItem"))&&V&&V.$dom&&V.$dom.html("").concat(B.address.fullStreetAddress,"").concat(B.address.cityStateZip,""))}function d(e){if(D++,(I=Math.floor(V.$dom.width()))>0){var t=2===G.placardVersion?{}:c(I);X.template.get({$dom:V.$dom,data:{item:B,paging:G.paging,link:V.get("link",!0),corner:G.corner,statusBar:G.statusBar,price:G.price,units:G.units,openHouses:G.openHouses,address:G.address,gradient:G.gradient,statusText:G.statusText,statusCssClass:G.statusCssClass,fonts:t,detailsButton:G.detailsButton,priceAddressGroup:G.priceAddressGroup,openInNewTab:V.get("openInNewTab",!1),puppeteer:!(!Homesnap||!Homesnap.puppeteer),singleFamilyResidence:!(! !W.get("qs",{}).bookshowing,o=!1;D&&(o=!0),B.add("scheduleTour",new x.ChildController({type:"controllers/Property/ScheduleTour",namespace:N.get(),register:{bubble:n}}),!0),W.updateController("scheduleTour",{$dom:h.divScheduleTour,data:{propertyAddressItem:e,inSideBar:!0,inListingAdminPanel:o,showingData:{bookingType:"listing",listingId:e.listing.id,listingAddress:"".concat(e.address.fullStreetAddress,", ").concat(e.address.cityStateZip),itineraryName:e.address.streetNameWithoutNumber},triggerOpenModal:t,promo:u()}})}function u(){var e=W.get("promo",{}),t=e.promoMedium,n=e.promoContent,o=e.promoTerm,i=e.promoDate,r=e.promoSource;return"mls"!==r&&(r=W.get("qs",{}).bookshowing? Homesnap.templates["controllers/DownloadMobileAppForm.html"] = '{{#with data}}