!function(e){if(window.mapster_params&&window.mapster_params.public)(a=".mapster-wp-maps",new Promise((e=>{if(document.querySelector(a))return e(document.querySelector(a));const t=new MutationObserver((s=>{if(document.querySelector(a)){e(document.querySelector(a));t.disconnect()}}));t.observe(document.body,{childList:!0,subtree:!0})}))).then((t=>{let a=!1,s=e(document).scrollTop();e(".mapster-wp-maps").length>15&&(a=!0);e(".mapster-wp-maps").each((function(){const t=e(this).attr("id").replace("mapster-wp-maps-",""),i=""!==e(this).data("single_feature_id")&&e(this).data("single_feature_id"),p=""!==e(this).data("feature_ids")&&e(this).data("feature_ids");if(a){let o=!1;const n=e(window).height(),c=e(this).offset().top;r();e(document).scroll((()=>{s=e(document).scrollTop();r()}));function r(){if(s-1.5*n<c&&s+1.5*n>c&&!o){o=new MapsterMap(t,window.mapster_params.public,i,p);o.init()}else if((s-1.5*n>c||s+1.5*n<c)&&o){o.destroy();o=!1}}}else{new MapsterMap(t,window.mapster_params.public,i,p).init()}}))}));else if(window.mapster_params){let s="Publish this post to generate an embed code.";const i=new URLSearchParams(window.location.search);if(i.has("post")){let m=window.mapster_params.directory.replace("/admin/","/admin/includes/mapster-embed-map.php");m=m+window.mapster_params.qd+"map_id="+i.get("post");s=`<iframe src="${m}" />`}let p="Publish this post to generate a listing code.";i.has("post")&&(p=`[mapster_listing_posts id="${i.get("post")}"]`);if(document.body.classList.contains("block-editor-page")){e("#mapster-wp-maps-preview").prependTo("#normal-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(p);e("#mapster-wp-map-external-search-filter-shortcode").text(r)}else{e("#mapster-wp-maps-preview").prependTo("#acf_after_title-sortables");e(".acf-field-625df5ebf4ecc .acf-input").text(s);e(".acf-field-6507ba6e3053a .acf-input").text(p)}if(i.has("post")){let f=`\n        [mapster_wp_map_submit map_id="${i.get("post")}" type="create_point"]<br />\n        [mapster_wp_map_submit map_id="${i.get("post")}" type="edit_point" button_text="Edit Point" header_text="Edit Point"]\n      `;e(".acf-field-62bf86b094491 .acf-input").append(f)}let r="Publish this post to generate a custom search code.";i.has("post")&&(r=`[mapster_custom_search id="${i.get("post")}" to_url="${jQuery("#sample-permalink").text()}"]`);e("#mapster-wp-map-external-search-filter-shortcode").text(r);let o=acf.getFields().length,n=acf.getFields().filter((e=>"accordion"===e.data.type)).length;o-=n;let c=6,d=0,l=0;function t(e){"select"!==e&&(d+=1);if(d===o&&c===l){new MapsterMap("map",window.mapster_params.public,!1).init()}}acf.add_action("ready_field",t);acf.addAction("select2_init",(function(e,a,s,i){l+=1;t("select")}))}var a}(jQuery);