!function(t){"function"==typeof define&&define.amd?define("singleListing",t):t()}(function(){"use strict";var e,c,i,n,a,o,s,l,r,d,t,u,g,p,m,f;MyListing.Helpers.css_escape=function(t){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var e,i=String(t),n=i.length,a=-1,o="",s=i.charCodeAt(0);++a<n;)0==(e=i.charCodeAt(a))?o+="�":o+=1<=e&&e<=31||127==e||0==a&&48<=e&&e<=57||1==a&&48<=e&&e<=57&&45==s?"\\"+e.toString(16)+" ":(0!=a||1!=n||45!=e)&&(128<=e||45==e||95==e||48<=e&&e<=57||65<=e&&e<=90||97<=e&&e<=122)?i.charAt(a):"\\"+i.charAt(a);return o},jQuery(function(n){var i={postid:n("#case27-post-id").val(),authid:n("#case27-author-id").val()};function a(e){var t;(t=e).contents.hide(),t.pagination.hide(),t.loader.show(),n.ajax({url:CASE27.mylisting_ajax_url+"&action=get_related_listings",type:"GET",dataType:"json",data:{listing_id:i.postid,page:e.page,field_key:e.field_key},success:function(t){e.contents.html(t.html),e.pagination.html(t.pagination),e.menu_spinner.hide(),e.counter.html(t.formatted_count).removeClass("hide"),(t=e).loader.hide(),t.contents.fadeIn(150),t.pagination.fadeIn(150),setTimeout(function(){MyListing.BackgroundCarousel()},10)}})}n(".toggle-tab-type-related_listings").each(function(t,e){var i={};i.menu=n(this),i.id=i.menu.data("section-id"),i.section=n("#listing_tab_"+i.id),i.field_key=i.menu.data("options").field_key,i.loader=i.section.find(".tab-loader"),i.contents=i.section.find(".tab-contents"),i.pagination=i.section.find(".tab-pagination"),i.counter=i.menu.find(".items-counter"),i.menu_spinner=i.menu.find(".tab-spinner"),i.page=0,a(i),i.pagination.on("click","a",function(t){t.preventDefault(),i.page=parseInt(n(this).data("page"),10)-1,a(i)})})}),jQuery(function(n){var i={postid:n("#case27-post-id").val(),authid:n("#case27-author-id").val()};function a(e){var t;(t=e).contents.hide(),t.pagination.hide(),t.loader.show(),n.ajax({url:CASE27.ajax_url+"?action=mylisting_get_products&security="+CASE27.ajax_nonce,type:"POST",dataType:"json",data:{products:e.products,page:e.page,author_id:i.authid},success:function(t){e.contents.html(t.html),e.pagination.html(t.pagination),e.counter.html(t.formatted_count),(t=e).loader.hide(),t.contents.fadeIn(150),t.pagination.fadeIn(150)}})}n(".toggle-tab-type-store").each(function(t,e){var i={};i.menu=n(this),i.id=i.menu.data("section-id"),i.section=n("#listing_tab_"+i.id),i.loader=i.section.find(".store-loader"),i.contents=i.section.find(".store-contents"),i.pagination=i.section.find(".store-pagination"),i.counter=i.menu.find(".items-counter"),i.products=i.menu.data("options").products,i.page=0,a(i),i.pagination.on("click","a",function(t){t.preventDefault(),i.page=parseInt(n(this).data("page"),10)-1,a(i)})})}),(e=jQuery)(".c27-add-listing-review, .show-review-form, .pa-below-title .listing-rating").click(function(t){t.preventDefault(),e(".toggle-tab-type-comments").first().click(),setTimeout(function(){e('#commentform textarea[name="comment"]').focus()},250)}),(t=document.getElementById("commentform"))&&t.removeAttribute("novalidate"),(c=jQuery)("body.single-listing .tab-template-two-columns").each(function(t,e){function i(t){var e=window.matchMedia("(max-width: 991.5px)").matches?"mobile":"desktop";e===l&&!t||("mobile"==e?o.forEach(function(t,e){c(t).appendTo(n),s[e]&&c(s[e]).appendTo(n)}):s.forEach(function(t,e){c(t).appendTo(a)}),l=e)}var n=c(this).find(".cts-column-wrapper.cts-main-column"),a=c(this).find(".cts-column-wrapper.cts-side-column"),o=n.find("> div").toArray(),s=a.find("> div").toArray(),l=window.matchMedia("(max-width: 991.5px)").matches?"mobile":"desktop";i("mobile"===l),c(window).on("resize",MyListing.Helpers.debounce(function(){i()},300))}),jQuery(document).ready(function(o){if(!o("#commentform").length)return!1;o("#commentform")[0].encoding="multipart/form-data",o("body").on("click",".review-gallery-image-remove",function(t){t.preventDefault(),o(this).parents(".review-gallery-image").remove()});o("#review-gallery-add-input").on("change",function(){o("#review-gallery-preview").html("");var t=this,e="#review-gallery-preview";if(t.files)for(var i=t.files.length,n=0;n<i;n++){var a=new FileReader;a.onload=function(t){t=o('<div class="review-gallery-image">\n                            <span class="review-gallery-preview-icon">\n                                <i class="material-icons file_upload"></i>\n                            </span>\n                        </div>').css("background-image","url('"+t.target.result+"')");o(t).appendTo(e)},a.readAsDataURL(t.files[n])}})}),i=jQuery,t=i(".ml-track-btn"),n=i("#case27-post-id").val(),t.each(function(){i(this).on("click",function(){var t={listing_id:n,btn_id:i(this).attr("id")};i.post(CASE27.mylisting_ajax_url+"&action=track_listing_button&security="+CASE27.ajax_nonce,t,function(t){t.tracked||console.log("Could not log button click.")})})}),a=jQuery,t=a(".add-to-i-cal"),o=a("#case27-post-id").val(),t.on("click",function(t){t.preventDefault();var t=a(this),e=t.data("event-id"),t=t.parents(".event-dates-timeline"),i=t.data("field"),n=t.data("count"),t=t.data("past-count");a.post(CASE27.mylisting_ajax_url+"&action=download_ical_calendar&security="+CASE27.ajax_nonce,{listing_id:o,eventindex:e,eventField:i,eventCount:n,eventPastCount:t},function(t){var e,i;t.data?(e=new Blob([t.data],{type:"text/Calendar"}),t=t.name+".ics",!!document.documentMode?window.navigator.msSaveBlob(e,t):(e=(window.URL||window.webkitURL).createObjectURL(e),(i=a("<a />")).attr("download",t),i.attr("href",e),a("body").append(i),i[0].click(),a("body").remove(i))):alert("Please try again.")})}),s=jQuery,l=s(".listing-tab-toggle").first().data("section-id"),s(".listing-tab-toggle").on("click",function(t){t.preventDefault(),s(".profile-menu li.active").removeClass("active"),s(this).parent().addClass("active");s(".listing-tab.tab-active");var t=s(this).data("section-id"),e=(document.body.dataset.activeTab=t,!0!==MyListing.isListingPreview&&history.replaceState(null,null,l===t?" ":"#"+t),s(".listing-tab#listing_tab_"+MyListing.Helpers.css_escape(t)));setTimeout(function(){e.trigger("mylisting:single:tab-switched"),jQuery(document).trigger("mylisting/single:tab-switched")},25)}),(r=jQuery)(".qa-internal-link a").on("click",function(t){var e=r(this).attr("href"),e=r('.listing-tab-toggle[data-section-id="'+MyListing.Helpers.css_escape(e.substring(1))+'"]');e.length&&e.click()}),(d=jQuery)(".listing-tab-toggle.toggle-tab-type-main").each(function(){var t=d(this).data("section-id");0<d(".listing-tab#listing_tab_"+MyListing.Helpers.css_escape(t)).find(".row").children().not("link, script, style").length||d(this).remove()}),t=jQuery,f=window.location.hash.substr(1),u=t(".listing-tab-toggle#listing_tab_"+MyListing.Helpers.css_escape(f)+"_toggle"),(f.length&&u.length?u:t(".listing-tab-toggle")).first().click(),jQuery(function(e){var i,n,a;e("#report-listing-modal").length&&(i=e("#report-listing-modal"),n=i.find(".validation-message"),a=e("#case27-post-id").val(),i.find(".report-submit").on("click",function(t){t.preventDefault(),n.hide(),i.find(".sign-in-box").addClass("cts-processing-login"),e.ajax({url:CASE27.ajax_url+"?action=report_listing&security="+CASE27.ajax_nonce,type:"POST",dataType:"json",data:{listing_id:a,content:i.find(".report-content").val()},success:function(t){i.find(".sign-in-box").removeClass("cts-processing-login"),"error"===t.status&&n.html("<em>"+t.message+"</em>").show(),"success"===t.status&&i.find(".report-wrapper").html('<div class="submit-message"><em>'+t.message+"</em></div>")}})})),e(".comments-list .comment .review-galleries .gallery-item img").on("click",function(t){t.preventDefault();var i=[],n=this,a=0;e(this).parents(".review-galleries").find(".gallery-item img").each(function(t,e){if(!e.dataset.fullSizeSrc||!e.dataset.fullSizeWidth||!e.dataset.fullSizeHeight)return!1;e.dataset.fullWidth=e.dataset.fullSizeWidth,e.dataset.fullHeight=e.dataset.fullSizeHeight,i.push({src:e.dataset.fullSizeSrc,w:e.dataset.fullWidth||0,h:e.dataset.fullHeight||0,el:e}),e==n&&(a=t)}),new MyListing.PhotoSwipe(i,a)})}),g=document.querySelector(".listing-main-info"),p=document.querySelector(".main-info-desktop"),m=document.querySelector(".main-info-mobile"),f=window.matchMedia("(max-width: 1200px)"),g&&p&&m&&(f.matches&&m.appendChild(g),u=function(t){(t.matches?m:p).appendChild(g)},"function"==typeof f.addEventListener?f.addEventListener("change",u):f.addListener(u)),jQuery(function(o){var s=o("#case27-post-id").val();o(".comments-list-wrapper").each(function(t,e){var i=(e=o(e)).data("current-page"),n=e.data("page-count"),a=1<i?"lower":"upper";e.on("click",".nav-links .load-more",function(t){t.preventDefault(),"upper"==a?i++:i--,e.addClass("loading-comments"),o.get(CASE27.mylisting_ajax_url,{action:"list_comments",page:i,post_id:s,page_count:n,direction:a},function(t){"string"==typeof t&&('<ul class="comments-list no-list-style"></ul>'===t||t.length<10?e.find(".nav-links .load-more").hide():e.find("ul.comments-list").append(o(t).children())),e.removeClass("loading-comments"),("lower"==a&&i<=1||"upper"==a&&n<=i)&&e.find(".nav-links .load-more").hide()})})})}),jQuery(function(e){e(".hide-notification").click(function(t){t.preventDefault(),e(t.target).parents(".listing-notifications").hide()})}),jQuery(".listing-tab").one("mylisting:single:tab-switched",function(){jQuery(this).find("ins").each(function(t,e){"done"!==e.dataset.adsbygoogleStatus&&(adsbygoogle=window.adsbygoogle||[]).push({})})})});
