(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function i(t){if(this.formData={},this.tree={},!(t instanceof FormData))return this;this.formData=t;const e=()=>{const t=new Map;return t.largestIndex=0,t.set=function(e,i){""===e?e=t.largestIndex++:/^[0-9]+$/.test(e)&&(e=parseInt(e),t.largestIndex<=e&&(t.largestIndex=e+1)),Map.prototype.set.call(t,e,i)},t};this.tree=e();const i=/^(?<name>[a-z][-a-z0-9_:]*)(?<array>(?:\[(?:[a-z][-a-z0-9_:]*|[0-9]*)\])*)/i;for(const[t,s]of this.formData){const o=t.match(i);if(o)if(""===o.groups.array)this.tree.set(o.groups.name,s);else{const t=[...o.groups.array.matchAll(/\[([a-z][-a-z0-9_:]*|[0-9]*)\]/gi)].map((([t,e])=>e));t.unshift(o.groups.name);const i=t.pop();t.reduce(((t,i)=>{if(/^[0-9]+$/.test(i)&&(i=parseInt(i)),t.get(i)instanceof Map)return t.get(i);const s=e();return t.set(i,s),s}),this.tree).set(i,s)}}}t.r(e),t.d(e,{all:()=>D,any:()=>M,date:()=>m,dayofweek:()=>u,email:()=>r,enum:()=>h,file:()=>d,maxdate:()=>z,maxfilesize:()=>j,maxitems:()=>v,maxlength:()=>x,maxnumber:()=>y,mindate:()=>A,minfilesize:()=>$,minitems:()=>w,minlength:()=>g,minnumber:()=>b,number:()=>c,required:()=>n,requiredfile:()=>a,stepnumber:()=>I,tel:()=>l,time:()=>f,url:()=>p}),i.prototype.entries=function(){return this.tree.entries()},i.prototype.get=function(t){return this.tree.get(t)},i.prototype.getAll=function(t){if(!this.has(t))return[];const e=t=>{const i=[];if(t instanceof Map)for(const[s,o]of t)i.push(...e(o));else""!==t&&i.push(t);return i};return e(this.get(t))},i.prototype.has=function(t){return this.tree.has(t)},i.prototype.keys=function(){return this.tree.keys()},i.prototype.values=function(){return this.tree.values()};const s=i;function o({rule:t,field:e,error:i,...s}){this.rule=t,this.field=e,this.error=i,this.properties=s}const n=function(t){if(0===t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).length)throw new o(this)},a=function(t){if(0===t.getAll(this.field).length)throw new o(this)},r=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>{if(t.length<6)return!1;if(-1===t.indexOf("@",1))return!1;if(t.indexOf("@")!==t.lastIndexOf("@"))return!1;const[e,i]=t.split("@",2);if(!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/.test(e))return!1;if(/\.{2,}/.test(i))return!1;if(/(?:^[ \t\n\r\0\x0B.]|[ \t\n\r\0\x0B.]$)/.test(i))return!1;const s=i.split(".");if(s.length<2)return!1;for(const t of s){if(/(?:^[ \t\n\r\0\x0B-]|[ \t\n\r\0\x0B-]$)/.test(t))return!1;if(!/^[a-z0-9-]+$/i.test(t))return!1}return!0})))throw new o(this)},p=function(t){const e=t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t));if(!e.every((t=>{try{return(t=>-1!==["http","https","ftp","ftps","mailto","news","irc","irc6","ircs","gopher","nntp","feed","telnet","mms","rtsp","sms","svn","tel","fax","xmpp","webcal","urn"].indexOf(t))(new URL(t).protocol.replace(/:$/,""))}catch{return!1}})))throw new o(this)},l=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>(((t=(t=t.replace(/[#*].*$/,"")).replaceAll(/[()/.*#\s-]+/g,"")).startsWith("+")||t.startsWith("00"))&&(t=`+${t.replace(/^[+0]+/,"")}`),!!/^[+]?[0-9]+$/.test(t)&&5<t.length&&t.length<16))))throw new o(this)},c=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>!!/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t)||!!/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t))))throw new o(this)},m=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>{if(!/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t))return!1;const e=new Date(t);return!Number.isNaN(e.valueOf())})))throw new o(this)},f=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>{const e=t.match(/^([0-9]{2})\:([0-9]{2})(?:\:([0-9]{2}))?$/);if(!e)return!1;const i=parseInt(e[1]),s=parseInt(e[2]),o=e[3]?parseInt(e[3]):0;return 0<=i&&i<=23&&0<=s&&s<=59&&0<=o&&o<=59})))throw new o(this)},d=function(t){if(!t.getAll(this.field).every((t=>t instanceof File&&this.accept?.some((e=>/^\.[a-z0-9]+$/i.test(e)?t.name.toLowerCase().endsWith(e.toLowerCase()):(t=>{const e=[],i=t.match(/^(?<toplevel>[a-z]+)\/(?<sub>[*]|[a-z0-9.+-]+)$/i);if(i){const t=i.groups.toplevel.toLowerCase(),s=i.groups.sub.toLowerCase();for(const[o,n]of(()=>{const t=new Map;return t.set("jpg|jpeg|jpe","image/jpeg"),t.set("gif","image/gif"),t.set("png","image/png"),t.set("bmp","image/bmp"),t.set("tiff|tif","image/tiff"),t.set("webp","image/webp"),t.set("ico","image/x-icon"),t.set("heic","image/heic"),t.set("asf|asx","video/x-ms-asf"),t.set("wmv","video/x-ms-wmv"),t.set("wmx","video/x-ms-wmx"),t.set("wm","video/x-ms-wm"),t.set("avi","video/avi"),t.set("divx","video/divx"),t.set("flv","video/x-flv"),t.set("mov|qt","video/quicktime"),t.set("mpeg|mpg|mpe","video/mpeg"),t.set("mp4|m4v","video/mp4"),t.set("ogv","video/ogg"),t.set("webm","video/webm"),t.set("mkv","video/x-matroska"),t.set("3gp|3gpp","video/3gpp"),t.set("3g2|3gp2","video/3gpp2"),t.set("txt|asc|c|cc|h|srt","text/plain"),t.set("csv","text/csv"),t.set("tsv","text/tab-separated-values"),t.set("ics","text/calendar"),t.set("rtx","text/richtext"),t.set("css","text/css"),t.set("htm|html","text/html"),t.set("vtt","text/vtt"),t.set("dfxp","application/ttaf+xml"),t.set("mp3|m4a|m4b","audio/mpeg"),t.set("aac","audio/aac"),t.set("ra|ram","audio/x-realaudio"),t.set("wav","audio/wav"),t.set("ogg|oga","audio/ogg"),t.set("flac","audio/flac"),t.set("mid|midi","audio/midi"),t.set("wma","audio/x-ms-wma"),t.set("wax","audio/x-ms-wax"),t.set("mka","audio/x-matroska"),t.set("rtf","application/rtf"),t.set("js","application/javascript"),t.set("pdf","application/pdf"),t.set("swf","application/x-shockwave-flash"),t.set("class","application/java"),t.set("tar","application/x-tar"),t.set("zip","application/zip"),t.set("gz|gzip","application/x-gzip"),t.set("rar","application/rar"),t.set("7z","application/x-7z-compressed"),t.set("exe","application/x-msdownload"),t.set("psd","application/octet-stream"),t.set("xcf","application/octet-stream"),t.set("doc","application/msword"),t.set("pot|pps|ppt","application/vnd.ms-powerpoint"),t.set("wri","application/vnd.ms-write"),t.set("xla|xls|xlt|xlw","application/vnd.ms-excel"),t.set("mdb","application/vnd.ms-access"),t.set("mpp","application/vnd.ms-project"),t.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),t.set("docm","application/vnd.ms-word.document.macroEnabled.12"),t.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),t.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),t.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),t.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),t.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),t.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),t.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),t.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),t.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),t.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),t.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),t.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),t.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),t.set("potm","application/vnd.ms-powerpoint.template.macroEnabled.12"),t.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),t.set("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"),t.set("sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"),t.set("onetoc|onetoc2|onetmp|onepkg","application/onenote"),t.set("oxps","application/oxps"),t.set("xps","application/vnd.ms-xpsdocument"),t.set("odt","application/vnd.oasis.opendocument.text"),t.set("odp","application/vnd.oasis.opendocument.presentation"),t.set("ods","application/vnd.oasis.opendocument.spreadsheet"),t.set("odg","application/vnd.oasis.opendocument.graphics"),t.set("odc","application/vnd.oasis.opendocument.chart"),t.set("odb","application/vnd.oasis.opendocument.database"),t.set("odf","application/vnd.oasis.opendocument.formula"),t.set("wp|wpd","application/wordperfect"),t.set("key","application/vnd.apple.keynote"),t.set("numbers","application/vnd.apple.numbers"),t.set("pages","application/vnd.apple.pages"),t})())("*"===s&&n.startsWith(t+"/")||n===i[0])&&e.push(...o.split("|"))}return e})(e).some((e=>(e="."+e.trim(),t.name.toLowerCase().endsWith(e.toLowerCase())))))))))throw new o(this)},h=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>this.accept?.some((e=>t===String(e))))))throw new o(this)},u=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>{const e=0===(i=new Date(t).getDay())?7:i;var i;return this.accept?.some((t=>e===parseInt(t)))})))throw new o(this)},w=function(t){if(t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).length<parseInt(this.threshold))throw new o(this)},v=function(t){const e=t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t));if(parseInt(this.threshold)<e.length)throw new o(this)},g=function(t){const e=t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t));let i=0;if(e.forEach((t=>{"string"==typeof t&&(i+=t.length)})),0!==i&&i<parseInt(this.threshold))throw new o(this)},x=function(t){const e=t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t));let i=0;if(e.forEach((t=>{"string"==typeof t&&(i+=t.length)})),parseInt(this.threshold)<i)throw new o(this)},b=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>!(parseFloat(t)<parseFloat(this.threshold)))))throw new o(this)},y=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>!(parseFloat(this.threshold)<parseFloat(t)))))throw new o(this)},A=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&t<this.threshold))))throw new o(this)},z=function(t){if(!t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)).every((t=>!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&this.threshold<t))))throw new o(this)},$=function(t){const e=t.getAll(this.field);let i=0;if(e.forEach((t=>{t instanceof File&&(i+=t.size)})),i<parseInt(this.threshold))throw new o(this)},j=function(t){const e=t.getAll(this.field);let i=0;if(e.forEach((t=>{t instanceof File&&(i+=t.size)})),parseInt(this.threshold)<i)throw new o(this)},I=function(t){const e=t.getAll(this.field).map((t=>t.trim())).filter((t=>""!==t)),i=parseFloat(this.base),s=parseFloat(this.interval);if(!(0<s))return!0;if(!e.every((t=>{const e=(parseFloat(t)-i)%s;return"0.000000"===Math.abs(e).toFixed(6)||"0.000000"===Math.abs(e-s).toFixed(6)})))throw new o(this)},O=({ruleObj:t,options:i})=>{const{rule:s,...o}=t;return"function"==typeof e[s]&&("function"!=typeof e[s].matches||e[s].matches(o,i))},E=({ruleObj:t,formDataTree:i,options:s})=>{const{rule:o}=t;e[o].call(t,i,s)},k=[],F=t=>[...k].reduce(((t,e)=>i=>e(i,t)),t),D=function(t,e={}){const i=(this.rules??[]).filter((t=>O({ruleObj:t,options:e}))),s=F(E);if(!i.every((i=>{try{s({ruleObj:i,formDataTree:t,options:e})}catch(t){if(!(t instanceof o))throw t;if(void 0!==t.error)throw t;return!1}return!0})))throw new o(this)},M=function(t,e={}){const i=(this.rules??[]).filter((t=>O({ruleObj:t,options:e}))),s=F(E);if(!i.some((i=>{try{s({ruleObj:i,formDataTree:t,options:e})}catch(t){if(!(t instanceof o))throw t;return!1}return!0})))throw new o(this)};var L;window.swv={validators:e,validate:(t,e,i={})=>{const n=(t.rules??[]).filter((t=>O({ruleObj:t,options:i})));if(!n.length)return new Map;const a=F(E),r=new s(e),p=n.reduce(((t,e)=>{try{a({ruleObj:e,formDataTree:r,options:i})}catch(e){if(!(e instanceof o))throw e;if(void 0!==e.field&&!t.has(e.field)&&void 0!==e.error)return t.set(e.field,e)}return t}),new Map);for(const t of r.keys())p.has(t)||p.set(t,{validInputs:r.getAll(t)});return p},use:t=>{k.push(t)},...null!==(L=window.swv)&&void 0!==L?L:{}}})();
(()=>{"use strict";const e=window.wp.i18n,t=e=>Math.abs(parseInt(e,10)),a=(e,t,a)=>{const n=new CustomEvent(`wpcf7${t}`,{bubbles:!0,detail:a});"string"==typeof e&&(e=document.querySelector(e)),e.dispatchEvent(n)},n=(e,t)=>{const n=new Map([["init","init"],["validation_failed","invalid"],["acceptance_missing","unaccepted"],["spam","spam"],["aborted","aborted"],["mail_sent","sent"],["mail_failed","failed"],["submitting","submitting"],["resetting","resetting"],["validating","validating"],["payment_required","payment-required"]]);n.has(t)&&(t=n.get(t)),Array.from(n.values()).includes(t)||(t=`custom-${t=(t=t.replace(/[^0-9a-z]+/i," ").trim()).replace(/\s+/,"-")}`);const r=e.getAttribute("data-status");if(e.wpcf7.status=t,e.setAttribute("data-status",t),e.classList.add(t),r&&r!==t){e.classList.remove(r);const t={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,prevStatus:r};a(e,"statuschanged",t)}return t},r=e=>{const{root:t,namespace:a="contact-form-7/v1"}=wpcf7.api;return c.reduceRight(((e,t)=>a=>t(a,e)),(e=>{let n,r,{url:c,path:o,endpoint:s,headers:i,body:l,data:p,...d}=e;"string"==typeof s&&(n=a.replace(/^\/|\/$/g,""),r=s.replace(/^\//,""),o=r?n+"/"+r:n),"string"==typeof o&&(-1!==t.indexOf("?")&&(o=o.replace("?","&")),o=o.replace(/^\//,""),c=t+o),i={Accept:"application/json, */*;q=0.1",...i},delete i["X-WP-Nonce"],p&&(l=JSON.stringify(p),i["Content-Type"]="application/json");const f={code:"fetch_error",message:"You are probably offline."},u={code:"invalid_json",message:"The response is not a valid JSON response."};return window.fetch(c||o||window.location.href,{...d,headers:i,body:l}).then((e=>Promise.resolve(e).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>{if(204===e.status)return null;if(e&&e.json)return e.json().catch((()=>{throw u}));throw u}))),(()=>{throw f}))}))(e)},c=[];function o(e,t={}){const{target:a,scope:r=e,...c}=t;if(void 0===e.wpcf7?.schema)return;const o={...e.wpcf7.schema};if(void 0!==a){if(!e.contains(a))return;if(!a.closest(".wpcf7-form-control-wrap[data-name]"))return;if(a.closest(".novalidate"))return}const p=r.querySelectorAll(".wpcf7-form-control-wrap"),d=Array.from(p).reduce(((e,t)=>(t.closest(".novalidate")||t.querySelectorAll(":where(input, textarea, select):enabled").forEach((t=>{if(t.name)switch(t.type){case"button":case"image":case"reset":case"submit":break;case"checkbox":case"radio":t.checked&&e.append(t.name,t.value);break;case"select-multiple":for(const a of t.selectedOptions)e.append(t.name,a.value);break;case"file":for(const a of t.files)e.append(t.name,a);break;default:e.append(t.name,t.value)}})),e)),new FormData),f=e.getAttribute("data-status");Promise.resolve(n(e,"validating")).then((n=>{if(void 0!==swv){const n=swv.validate(o,d,t);for(const t of p){if(void 0===t.dataset.name)continue;const c=t.dataset.name;if(n.has(c)){const{error:t,validInputs:a}=n.get(c);i(e,c),void 0!==t&&s(e,c,t,{scope:r}),l(e,c,null!=a?a:[])}if(t.contains(a))break}}})).finally((()=>{n(e,f)}))}r.use=e=>{c.unshift(e)};const s=(e,t,a,n)=>{const{scope:r=e,...c}=null!=n?n:{},o=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,""),s=e.querySelector(`.wpcf7-form-control-wrap[data-name="${t}"] .wpcf7-form-control`);(()=>{const t=document.createElement("li");t.setAttribute("id",o),s&&s.id?t.insertAdjacentHTML("beforeend",`<a href="#${s.id}">${a}</a>`):t.insertAdjacentText("beforeend",a),e.wpcf7.parent.querySelector(".screen-reader-response ul").appendChild(t)})(),r.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{const t=document.createElement("span");t.classList.add("wpcf7-not-valid-tip"),t.setAttribute("aria-hidden","true"),t.insertAdjacentText("beforeend",a),e.appendChild(t),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.classList.add("wpcf7-not-valid"),e.setAttribute("aria-describedby",o),"function"==typeof e.setCustomValidity&&e.setCustomValidity(a),e.closest(".use-floating-validation-tip")&&(e.addEventListener("focus",(e=>{t.setAttribute("style","display: none")})),t.addEventListener("click",(e=>{t.setAttribute("style","display: none")})))}))}))},i=(e,t)=>{const a=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,"");e.wpcf7.parent.querySelector(`.screen-reader-response ul li#${a}`)?.remove(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{e.querySelector(".wpcf7-not-valid-tip")?.remove(),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid"),"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}))}))},l=(e,t,a)=>{e.querySelectorAll(`[data-reflection-of="${t}"]`).forEach((e=>{if("output"===e.tagName.toLowerCase()){const t=e;0===a.length&&a.push(t.dataset.default),a.slice(0,1).forEach((e=>{e instanceof File&&(e=e.name),t.textContent=e}))}else e.querySelectorAll("output").forEach((e=>{e.hasAttribute("data-default")?0===a.length?e.removeAttribute("hidden"):e.setAttribute("hidden","hidden"):e.remove()})),a.forEach((a=>{a instanceof File&&(a=a.name);const n=document.createElement("output");n.setAttribute("name",t),n.textContent=a,e.appendChild(n)}))}))};function p(e,t={}){if(wpcf7.blocked)return d(e),void n(e,"submitting");const c=new FormData(e);t.submitter&&t.submitter.name&&c.append(t.submitter.name,t.submitter.value);const o={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(c,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:c};r({endpoint:`contact-forms/${e.wpcf7.id}/feedback`,method:"POST",body:c,wpcf7:{endpoint:"feedback",form:e,detail:o}}).then((t=>{const r=n(e,t.status);return o.status=t.status,o.apiResponse=t,["invalid","unaccepted","spam","aborted"].includes(r)?a(e,r,o):["sent","failed"].includes(r)&&a(e,`mail${r}`,o),a(e,"submit",o),t})).then((t=>{t.posted_data_hash&&(e.querySelector('input[name="_wpcf7_posted_data_hash"]').value=t.posted_data_hash),"mail_sent"===t.status&&(e.reset(),e.wpcf7.resetOnMailSent=!0),t.invalid_fields&&t.invalid_fields.forEach((t=>{s(e,t.field,t.message)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').insertAdjacentText("beforeend",t.message),e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=t.message}))})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"feedback"===e.wpcf7.endpoint){const{form:t,detail:r}=e.wpcf7;d(t),a(t,"beforesubmit",r),n(t,"submitting")}return t(e)}));const d=e=>{e.querySelectorAll(".wpcf7-form-control-wrap").forEach((t=>{t.dataset.name&&i(e,t.dataset.name)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').innerText="",e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=""}))};function f(e){const t=new FormData(e),c={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(t,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:t};r({endpoint:`contact-forms/${e.wpcf7.id}/refill`,method:"GET",wpcf7:{endpoint:"refill",form:e,detail:c}}).then((t=>{e.wpcf7.resetOnMailSent?(delete e.wpcf7.resetOnMailSent,n(e,"mail_sent")):n(e,"init"),c.apiResponse=t,a(e,"reset",c)})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"refill"===e.wpcf7.endpoint){const{form:t,detail:a}=e.wpcf7;d(t),n(t,"resetting")}return t(e)}));const u=(e,t)=>{for(const a in t){const n=t[a];e.querySelectorAll(`input[name="${a}"]`).forEach((e=>{e.value=""})),e.querySelectorAll(`img.wpcf7-captcha-${a.replaceAll(":","")}`).forEach((e=>{e.setAttribute("src",n)}));const r=/([0-9]+)\.(png|gif|jpeg)$/.exec(n);r&&e.querySelectorAll(`input[name="_wpcf7_captcha_challenge_${a}"]`).forEach((e=>{e.value=r[1]}))}},m=(e,t)=>{for(const a in t){const n=t[a][0],r=t[a][1];e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${a}"]`).forEach((e=>{e.querySelector(`input[name="${a}"]`).value="",e.querySelector(".wpcf7-quiz-label").textContent=n,e.querySelector(`input[name="_wpcf7_quiz_answer_${a}"]`).value=r}))}};function w(e){const a=new FormData(e);e.wpcf7={id:t(a.get("_wpcf7")),status:e.getAttribute("data-status"),pluginVersion:a.get("_wpcf7_version"),locale:a.get("_wpcf7_locale"),unitTag:a.get("_wpcf7_unit_tag"),containerPost:t(a.get("_wpcf7_container_post")),parent:e.closest(".wpcf7"),get schema(){return wpcf7.schemas.get(this.id)}},wpcf7.schemas.set(e.wpcf7.id,void 0),e.querySelectorAll(".has-spinner").forEach((e=>{e.insertAdjacentHTML("afterend",'<span class="wpcf7-spinner"></span>')})),(e=>{e.querySelectorAll(".wpcf7-exclusive-checkbox").forEach((t=>{t.addEventListener("change",(t=>{const a=t.target.getAttribute("name");e.querySelectorAll(`input[type="checkbox"][name="${a}"]`).forEach((e=>{e!==t.target&&(e.checked=!1)}))}))}))})(e),(e=>{e.querySelectorAll(".has-free-text").forEach((t=>{const a=t.querySelector("input.wpcf7-free-text"),n=t.querySelector('input[type="checkbox"], input[type="radio"]');a.disabled=!n.checked,e.addEventListener("change",(e=>{a.disabled=!n.checked,e.target===n&&n.checked&&a.focus()}))}))})(e),(e=>{e.querySelectorAll(".wpcf7-validates-as-url").forEach((e=>{e.addEventListener("change",(t=>{let a=e.value.trim();a&&!a.match(/^[a-z][a-z0-9.+-]*:/i)&&-1!==a.indexOf(".")&&(a=a.replace(/^\/+/,""),a="http://"+a),e.value=a}))}))})(e),(e=>{if(!e.querySelector(".wpcf7-acceptance")||e.classList.contains("wpcf7-acceptance-as-validation"))return;const t=()=>{let t=!0;e.querySelectorAll(".wpcf7-acceptance").forEach((e=>{if(!t||e.classList.contains("optional"))return;const a=e.querySelector('input[type="checkbox"]');(e.classList.contains("invert")&&a.checked||!e.classList.contains("invert")&&!a.checked)&&(t=!1)})),e.querySelectorAll(".wpcf7-submit").forEach((e=>{e.disabled=!t}))};t(),e.addEventListener("change",(e=>{t()})),e.addEventListener("wpcf7reset",(e=>{t()}))})(e),(e=>{const a=(e,a)=>{const n=t(e.getAttribute("data-starting-value")),r=t(e.getAttribute("data-maximum-value")),c=t(e.getAttribute("data-minimum-value")),o=e.classList.contains("down")?n-a.value.trim().length:a.value.trim().length;e.setAttribute("data-current-value",o),e.innerText=o,r&&r<a.value.length?e.classList.add("too-long"):e.classList.remove("too-long"),c&&a.value.length<c?e.classList.add("too-short"):e.classList.remove("too-short")},n=t=>{t={init:!1,...t},e.querySelectorAll(".wpcf7-character-count").forEach((n=>{const r=n.getAttribute("data-target-name"),c=e.querySelector(`[name="${r}"]`);c&&(c.value=c.defaultValue,a(n,c),t.init&&c.addEventListener("keyup",(e=>{a(n,c)})))}))};n({init:!0}),e.addEventListener("wpcf7reset",(e=>{n()}))})(e),window.addEventListener("load",(t=>{wpcf7.cached&&e.reset()})),e.addEventListener("reset",(t=>{wpcf7.reset(e)})),e.addEventListener("submit",(t=>{wpcf7.submit(e,{submitter:t.submitter}),t.preventDefault()})),e.addEventListener("wpcf7submit",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("wpcf7reset",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("change",(t=>{t.target.closest(".wpcf7-form-control")&&wpcf7.validate(e,{target:t.target})})),e.addEventListener("wpcf7statuschanged",(t=>{const a=t.detail.status;e.querySelectorAll(".active-on-any").forEach((e=>{e.removeAttribute("inert"),e.classList.remove("active-on-any")})),e.querySelectorAll(`.inert-on-${a}`).forEach((e=>{e.setAttribute("inert","inert"),e.classList.add("active-on-any")}))}))}document.addEventListener("DOMContentLoaded",(t=>{var a;if("undefined"!=typeof wpcf7)if(void 0!==wpcf7.api)if("function"==typeof window.fetch)if("function"==typeof window.FormData)if("function"==typeof NodeList.prototype.forEach)if("function"==typeof String.prototype.replaceAll){wpcf7={init:w,submit:p,reset:f,validate:o,schemas:new Map,...null!==(a=wpcf7)&&void 0!==a?a:{}},document.querySelectorAll("form .wpcf7[data-wpcf7-id]").forEach((t=>{const a=document.createElement("p");a.setAttribute("class","wpcf7-form-in-wrong-place");const n=document.createElement("strong");n.append((0,e.__)("Error:","contact-form-7"));const r=(0,e.__)("This contact form is placed in the wrong place.","contact-form-7");a.append(n," ",r),t.replaceWith(a)})),document.querySelectorAll(".wpcf7 > form").forEach((e=>{wpcf7.init(e),e.closest(".wpcf7").classList.replace("no-js","js")}));for(const e of wpcf7.schemas.keys())r({endpoint:`contact-forms/${e}/feedback/schema`,method:"GET"}).then((t=>{wpcf7.schemas.set(e,t)}))}else console.error("Your browser does not support String.replaceAll().");else console.error("Your browser does not support NodeList.forEach().");else console.error("Your browser does not support window.FormData().");else console.error("Your browser does not support window.fetch().");else console.error("wpcf7.api is not defined.");else console.error("wpcf7 is not defined.")}))})();
(function ($){
"use strict";
window.wgm_front={
instances: {},
init: function (data){
var self=this;
var id=data.count;
this.instances[id]=data;
window["wgm_config_" + id]=data.config;
$(document).ready(function (){
self.initMap(id);
self.initLightbox(id);
self.initSelect2();
});
},
escapeHTML: function (str){
if(!str) return "";
return String(str)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
},
sanitizeClasses: function (selector, allowed){
$(selector).each(function (){
var $el=$(this);
var classes=($el.attr("class")||"").split(/\s+/);
var filtered=classes.filter(function (c){
return (
allowed.indexOf(c)!==-1 ||
(c&&c.indexOf("wgm-")===0) ||
(c&&c.indexOf("wpgmap_")===0)
);
});
$el.attr("class", filtered.join(" "));
});
},
initSelect2: function (){
if($.fn.select2){
$(".wgm-select2").each(function (){
var $this=$(this);
if(!$this.hasClass("select2-hidden-accessible")){
$this.select2({
allowClear: true,
width: "100%",
});
}});
}},
initMap: function (id){
var data=this.instances[id];
var self=this;
var initFn=function (){
console.log("WGM: Initializing map " + id);
if(typeof google!=="object"||typeof google.maps!=="object"){
console.warn("WGM: Google Maps API not ready yet inside initFn.");
return;
}
var mapDiv=document.getElementById("srm_gmp_embed_" + id);
if(!mapDiv){
console.error("WGM: Map container not found: srm_gmp_embed_" + id);
return;
}
console.log("WGM: Found map container, proceeding with initialization."
);
try {
var mapOptions={
center: new google.maps.LatLng(data.map_center.lat,
data.map_center.lng
),
zoom: parseInt(data.map_zoom),
mapTypeId: google.maps.MapTypeId[data.map_type],
scrollwheel: data.options.disable_mouse_wheel_zoom!=="Y",
zoomControl: data.options.zoom_control,
zoomControlOptions: {
position:
google.maps.ControlPosition[data.options.zoom_control_pos],
},
mapTypeControl: data.options.map_type_control,
mapTypeControlOptions: {
position:
google.maps.ControlPosition[data.options.map_type_control_pos],
},
streetViewControl: data.options.street_view_control,
streetViewControlOptions: {
position:
google.maps.ControlPosition[
data.options.street_view_control_pos
],
},
fullscreenControl: data.options.fullscreen_control,
fullscreenControlOptions: {
position:
google.maps.ControlPosition[
data.options.fullscreen_control_pos
],
},
rotateControl: data.options.rotate_control,
rotateControlOptions: {
position:
google.maps.ControlPosition[data.options.rotate_control_pos],
},
scaleControl: data.options.scale_control,
scaleControlOptions: {
position:
google.maps.ControlPosition[data.options.scale_control_pos],
},
draggable: data.options.disable_mouse_dragging!=="Y",
disableDoubleClickZoom:
data.options.disable_mouse_double_click_zooming==="Y",
};
var map=new google.maps.Map(mapDiv, mapOptions);
data.map=map;
window["wgm_map_" + id]=map;
if(data.theme_json){
try {
map.setOptions({ styles: JSON.parse(data.theme_json) });
} catch (e){
console.error("WGM: Invalid map theme JSON:", e);
}}
self.loadMarkers(id);
self.initSearch(id);
self.initDirections(id);
$(window).trigger("wgm_map_init_" + id, { map: map, data: data });
} catch (e){
console.error("WGM: Error during map initialization:", e);
}};
if(typeof google==="object"&&typeof google.maps==="object"){
console.log("WGM: Google Maps API ready, initializing immediately.");
initFn();
}else{
console.log("WGM: Google Maps API not ready, queuing initialization.");
window.wgm_map_queue=window.wgm_map_queue||[];
window.wgm_map_queue.push(initFn);
}},
loadMarkers: function (id){
var data=this.instances[id];
var self=this;
var ajaxData={
action: "wpgmapembed_p_get_markers_by_map_id",
_wgm_p_nonce: data.nonces.marker_render,
data: {
map_id: data.map_id,
},
};
$.post(data.ajax_url, ajaxData, function (response){
try {
response =
typeof response==="string" ? JSON.parse(response):response;
} catch (e){
console.error("WGM: Failed to parse markers response", e);
return;
}
if(response.markers&&response.markers.length > 0){
if(!window.custom_markers) window.custom_markers={};
if(!window.custom_marker_infowindows)
window.custom_marker_infowindows={};
window.custom_markers[id]=[];
window.custom_marker_infowindows[id]=[];
window["wgm_config_" + id]=data.config;
response.markers.forEach(function (markerData, i){
markerData.marker_idx=i;
self.addMarker(id, markerData, i);
});
$(window).trigger("wgm_markers_loaded_" + id, {
markers: response.markers,
});
if(response.markers.length===1 &&
data.config.enable_modern_direction
){
var singleAddr=response.markers[0].marker_name||"";
$("#srm_gmap_to_" + id).val(self.escapeHTML(singleAddr.replace(/(<([^>]+)>)/gi, ""))
);
}}
}).fail(function (xhr, status, error){
console.error("WGM: Failed to load markers: " + error);
});
},
addMarker: function (id, markerData, index){
var data=this.instances[id];
var self=this;
var latlng=(markerData.lat_lng||"0,0").split(",");
if(latlng.length < 2){
console.warn("WGM: Invalid coordinates for marker", markerData);
return;
}
var anim=null;
if(markerData.animation==="BOUNCE")
anim=google.maps.Animation.BOUNCE;
if(markerData.animation==="DROP") anim=google.maps.Animation.DROP;
var marker=new google.maps.Marker({
position: new google.maps.LatLng(parseFloat(latlng[0]),
parseFloat(latlng[1])
),
title: self.escapeHTML(markerData.marker_name),
animation: anim,
icon: markerData.icon==="" ? data.default_icon:markerData.icon,
visible: !data.config.hide_markers,
map: data.map,
});
marker.wgm_data=markerData;
window.custom_markers[id][index]=marker;
var infowindow=new google.maps.InfoWindow({
content: self.getInfoWindowContent(id, markerData),
maxWidth: 320,
});
window.custom_marker_infowindows[id][index]=infowindow;
if(markerData.show_desc_by_default==="1"){
self.closeAllInfoWindows(id);
infowindow.open({ anchor: marker, shouldFocus: false });
}
if(markerData.have_marker_link==="1"){
marker.addListener("click", function (){
var target =
markerData.marker_link_new_tab==="1" ? "_blank":"_self";
window.open(markerData.marker_link, target);
});
}else{
marker.addListener("click", function (){
self.closeAllInfoWindows(id);
infowindow.open({ anchor: marker, shouldFocus: false });
});
}},
getInfoWindowContent: function (id, markerData){
var data=this.instances[id];
var self=this;
var hasImg=markerData.marker_image&&markerData.marker_image!=="";
if(data.marker_listing_type==="basic_list") hasImg=false;
var imgHtml=hasImg
? '<div class="wgm-iw-img-wrap"><img src="' +
markerData.marker_image +
'" class="wgm-infowindow-img wgm-lightbox-trigger" /></div>'
: "";
var titleHtml=markerData.marker_name
? '<p class="info_content_title wgm-infowindow-title">' +
self.escapeHTML(markerData.marker_name) +
"</p>"
: "";
var dirLink="";
if(data.config.enable_direction_link){
var dirAddr=(markerData.address||markerData.lat_lng).replace(/'/g,
"&#39;"
);
dirLink =
'<br><a href="#" class="wgm-get-dir-link wgm-dir-link-' +
id +
'" data-addr="' +
dirAddr +
'" style="display:inline-block;margin-top:5px;font-size:13px;">' +
data.i18n.get_directions +
"</a>";
}
var wrapperClass =
"wgm-infowindow-wrapper" + (hasImg ? " wgm-has-img":" wgm-no-img");
return (
'<div class="' +
wrapperClass +
'">' +
imgHtml +
'<div class="wgm-infowindow-content">' +
titleHtml +
'<div class="wgm-iw-desc">' +
markerData.marker_desc +
"</div>" +
dirLink +
"</div>" +
"</div>"
);
},
closeAllInfoWindows: function (id){
if(window.custom_marker_infowindows &&
window.custom_marker_infowindows[id]
){
window.custom_marker_infowindows[id].forEach(function (iw){
if(iw) iw.close();
});
}},
initSearch: function (id){
var data=this.instances[id];
var self=this;
var controlDiv=document.getElementById("wpgmap_search_control_" + id);
var mapWrapper=document.getElementById("srm_gmp_embed_" + id);
if(!controlDiv||!mapWrapper) return;
self.sanitizeClasses(controlDiv, ["wgm-search-control-container"]);
var $cd=$(controlDiv);
self.sanitizeClasses($cd.find(".wpgmap_search_box"), [
"wpgmap_search_box",
]);
self.sanitizeClasses($cd.find(".wpgmap_search_input"), [
"wpgmap_search_input",
]);
self.sanitizeClasses($cd.find(".wpgmap_search_select"), [
"wpgmap_search_select",
]);
self.sanitizeClasses($cd.find(".wpgmap_search_btn"), [
"wpgmap_search_btn",
]);
self.sanitizeClasses($cd.find(".wpgmap_search_clear"), [
"wpgmap_search_clear",
]);
if(data.config.placement==="above_map"){
$(mapWrapper).before(controlDiv);
$(controlDiv).show();
}else if(data.config.placement==="below_map"){
$(mapWrapper).after(controlDiv);
$(controlDiv).show();
}else{
data.map.controls[google.maps.ControlPosition.TOP_CENTER].push(controlDiv
);
$(controlDiv).show();
}
var btn=$("#wpgmap_search_btn_" + id);
var locInput=$("#wpgmap_search_loc_" + id);
var keyInput=$("#wpgmap_search_key_" + id);
var radSelect=$("#wpgmap_search_radius_" + id);
var catInput=$("#wpgmap_search_cat_" + id);
var catPanel=$("#wpgmap_filter_panel_" + id);
var catToggle=$("#wpgmap_filter_toggle_" + id);
var spinner=$("#wpgmap_search_spinner_" + id);
var notFoundMsg=$("#wpgmap_not_found_msg_" + id);
notFoundMsg.find(".wgm-not-found-close").on("click", function (e){
e.preventDefault();
notFoundMsg.stop(true, false).animate({ opacity: 0 }, 500, function (){
$(this).removeClass("wgm-show").css("opacity", "");
});
if(window["wgm_not_found_timer_" + id]){
clearTimeout(window["wgm_not_found_timer_" + id]);
}});
var searchCircle=null;
var adjustWidth=function (){
var container=$(mapWrapper).closest(".wgm-map-listing-container");
var containerWidth=container.width();
var mapWidth=mapWrapper.offsetWidth;
var container=$(mapWrapper).closest(".wgm-map-listing-container");
var containerWidth=container.width();
var mapWidth=mapWrapper.offsetWidth;
if(containerWidth < 600){
container.addClass("wgm-force-stack");
}else{
container.removeClass("wgm-force-stack");
}
if(mapWidth < 480){
if(keyInput.length) keyInput.hide();
}else{
if(keyInput.length) keyInput.show();
}
if(mapWidth < 380){
if(radSelect.length) radSelect.hide();
if(catToggle.length) catToggle.hide();
}else{
if(radSelect.length) radSelect.show();
if(catToggle.length) catToggle.show();
}};
adjustWidth();
if(typeof ResizeObserver!=="undefined"){
var ro=new ResizeObserver(function (){
adjustWidth();
});
ro.observe(mapWrapper);
}else{
$(window).on("resize", adjustWidth);
}
google.maps.event.addListenerOnce(data.map, "idle", adjustWidth);
if(locInput.length&&typeof google.maps.places!=="undefined"){
var autocomplete=new google.maps.places.Autocomplete(locInput[0]);
autocomplete.bindTo("bounds", data.map);
}
var getDistance=function (lat1, lon1, lat2, lon2){
var R=6371;
var dLat=((lat2 - lat1) * Math.PI) / 180;
var dLon=((lon2 - lon1) * Math.PI) / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos((lat1 * Math.PI) / 180) *
Math.cos((lat2 * Math.PI) / 180) *
Math.sin(dLon / 2) *
Math.sin(dLon / 2);
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
};
var updateMapAndList=function (
centerLat,
centerLng,
radius,
keyword,
catId
){
var markers=window.custom_markers[id]||[];
var filteredData=[];
var bounds=new google.maps.LatLngBounds();
var hasVisible=false;
var hasLocation=centerLat!==null&&centerLng!==null;
if(searchCircle) searchCircle.setMap(null);
if(window["wgm_center_marker_" + id])
window["wgm_center_marker_" + id].setMap(null);
if(hasLocation){
if(radius){
searchCircle=new google.maps.Circle({
strokeColor: data.circle.stroke_color,
strokeOpacity: data.circle.stroke_opacity,
strokeWeight: data.circle.stroke_weight,
fillColor: data.circle.fill_color,
fillOpacity: data.circle.fill_opacity,
map: data.map,
center: { lat: centerLat, lng: centerLng },
radius: radius * 1000,
});
}
if(data.config.show_center_icon){
window["wgm_center_marker_" + id]=new google.maps.Marker({
position: { lat: centerLat, lng: centerLng },
map: data.map,
title: "Search Center",
icon: "https://maps.google.com/mapfiles/ms/icons/blue-dot.png",
});
}}
markers.forEach(function (m, i){
var d=Object.assign({}, m.wgm_data);
d.marker_idx=i;
var isVisible=true;
var distVal=0;
if(hasLocation){
var mLatLng=m.getPosition();
var distKm=getDistance(
centerLat,
centerLng,
mLatLng.lat(),
mLatLng.lng()
);
if(radius&&distKm > radius) isVisible=false;
if(isVisible&&data.config.show_distance){
distVal =
data.config.distance_unit==="miles"
? distKm * 0.621371
: distKm;
var unit=data.config.distance_unit==="miles" ? "miles":"km";
d.distance=distVal.toFixed(2) + " " + unit;
d.distance_html =
'<span class="wgm-distance-badge">' + d.distance + "</span>";
}}
if(isVisible&&keyword){
var hay=(
(d.marker_name||"") +
" " +
(d.marker_desc||"") +
" " +
(d.address||"")
).toLowerCase();
if(hay.indexOf(keyword)===-1) isVisible=false;
}
if(isVisible&&catId&&catId.length > 0){
var markerCats=d.category_id
? d.category_id.toString().split(",")
: [];
var selectedCats=Array.isArray(catId)
? catId
: [catId.toString()];
var logic=data.config.category_selection_logic||"OR";
if(logic==="AND"){
for (var j=0; j < selectedCats.length; j++){
if(markerCats.indexOf(selectedCats[j].toString())===-1){
isVisible=false;
break;
}}
}else{
var found=false;
for (var k=0; k < selectedCats.length; k++){
if(markerCats.indexOf(selectedCats[k].toString())!==-1){
found=true;
break;
}}
if(!found) isVisible=false;
}}
m.setVisible(isVisible);
if(isVisible){
filteredData.push(d);
bounds.extend(m.getPosition());
hasVisible=true;
}});
if(hasLocation&&data.config.sort_by_distance){
filteredData.sort(function (a, b){
return (
(parseFloat(a.distance)||0) - (parseFloat(b.distance)||0)
);
});
}
$(window).trigger("wgm_search_update_" + id, { markers: filteredData });
if(hasVisible){
notFoundMsg.removeClass("wgm-show");
if(hasLocation&&radius){
data.map.fitBounds(searchCircle.getBounds());
}else{
data.map.fitBounds(bounds);
if(data.map.getZoom() > 15) data.map.setZoom(15);
}}else{
notFoundMsg.addClass("wgm-show");
if(window["wgm_not_found_timer_" + id]){
clearTimeout(window["wgm_not_found_timer_" + id]);
}
window["wgm_not_found_timer_" + id]=setTimeout(function (){
notFoundMsg
.stop(true, false)
.animate({ opacity: 0 }, 500, function (){
$(this).removeClass("wgm-show").css("opacity", "");
});
}, 8000);
if(hasLocation){
data.map.setCenter({ lat: centerLat, lng: centerLng });
data.map.setZoom(10);
}}
};
var executeSearch=function (){
var loc=locInput.length ? locInput.val().trim():"";
var key=keyInput.length ? keyInput.val().trim().toLowerCase():"";
var rad =
radSelect.length&&radSelect.val()
? parseFloat(radSelect.val())
: null;
var cat =
catInput.length&&catInput.val()
? catInput.val().split(",")
: null;
if(loc){
spinner.show();
var geocoder=new google.maps.Geocoder();
geocoder.geocode({ address: loc }, function (results, status){
spinner.hide();
if(status==="OK"){
var pos=results[0].geometry.location;
updateMapAndList(pos.lat(), pos.lng(), rad, key, cat);
}else{
alert("Geocode was not successful: " + status);
}});
}else{
updateMapAndList(null, null, null, key, cat);
}};
btn.on("click", executeSearch);
var clearBtn=$("#wpgmap_search_clear_" + id);
var toggleClearBtn=function (){
var hasLocation=locInput.length&&locInput.val().trim()!=="";
var hasKeyword=keyInput.length&&keyInput.val().trim()!=="";
var hasRadius=radSelect.length&&radSelect.val()!=="";
var hasCategory=catInput.length&&catInput.val()!=="";
if(hasLocation||hasKeyword||hasRadius||hasCategory){
clearBtn.show();
}else{
clearBtn.hide();
}};
if(locInput.length) locInput.on("input", toggleClearBtn);
if(keyInput.length) keyInput.on("input", toggleClearBtn);
if(radSelect.length) radSelect.on("change", toggleClearBtn);
if(catInput.length) catInput.on("change", toggleClearBtn);
toggleClearBtn();
clearBtn.on("click", function (){
if(locInput.length) locInput.val("");
if(keyInput.length) keyInput.val("");
if(radSelect.length) radSelect.val("");
if(catInput.length) catInput.val("");
if(catPanel.length)
catPanel.find(".wgm-front-cat-checkbox").prop("checked", false);
clearBtn.hide();
if(searchCircle) searchCircle.setMap(null);
if(window["wgm_center_marker_" + id])
window["wgm_center_marker_" + id].setMap(null);
var markers=window.custom_markers[id]||[];
markers.forEach(function (m){
m.setVisible(true);
});
notFoundMsg.removeClass("wgm-show");
var allMarkers=markers.map(function (m, i){
var d=Object.assign({}, m.wgm_data);
d.marker_idx=i;
return d;
});
$(window).trigger("wgm_search_update_" + id, { markers: allMarkers });
if(markers.length > 0){
var bounds=new google.maps.LatLngBounds();
markers.forEach(function (m){
bounds.extend(m.getPosition());
});
data.map.fitBounds(bounds);
}});
var triggerSearch=function (e){
if(e.key==="Enter") executeSearch();
};
locInput.on("keydown", triggerSearch);
if(keyInput.length) keyInput.on("keydown", triggerSearch);
if(data.categories&&catPanel.length){
var buildCategoryTree=function (parentId){
var html="";
var children=data.categories.filter(function (cat){
return cat.parent_id==parentId;
});
if(children.length > 0){
if(parentId!=0){
html +='<ul class="wgm-filter-sublist">';
}
children.forEach(function (cat){
html +='<li class="wgm-filter-item">';
html +="<label>";
html +=
'<input type="checkbox" class="wgm-front-cat-checkbox" value="' +
self.escapeHTML(cat.id) +
'"> ';
html +=
'<span class="wgm-cat-name">' +
self.escapeHTML(cat.name) +
"</span>";
html +="</label>";
html +=buildCategoryTree(cat.id);
html +="</li>";
});
if(parentId!=0){
html +="</ul>";
}}
return html;
};
var listHtml =
'<div class="wgm-filter-header">' +
'<span class="wgm-filter-close" title="Close">&times;</span>' +
"</div>" +
'<ul class="wgm-filter-list">' +
buildCategoryTree(0) +
"</ul>";
if(data.categories.length===0)
listHtml='<p class="wgm-no-cats">No categories</p>';
catPanel.html(listHtml);
catToggle.on("click", function (e){
e.preventDefault();
e.stopPropagation();
catPanel.toggleClass("hidden");
});
catPanel.on("click", function (e){
e.stopPropagation();
});
catPanel.on("click", ".wgm-filter-close", function (e){
e.preventDefault();
e.stopPropagation();
catPanel.addClass("hidden");
});
catPanel.on("click", "label, input", function (e){
e.stopPropagation();
});
$(document).on("click", function (e){
if($(e.target).closest("#wpgmap_filter_panel_" + id).length===0 &&
$(e.target).closest("#wpgmap_filter_toggle_" + id).length===0
){
catPanel.addClass("hidden");
}});
catPanel.on("change", ".wgm-front-cat-checkbox", function (){
var $this=$(this);
var isChecked=$this.prop("checked");
var val=$this.val();
var $parentLi=$this.closest("li");
var $childrenList=$parentLi.find("ul");
if($childrenList.length){
$childrenList
.find(".wgm-front-cat-checkbox")
.prop("checked", isChecked);
}
var selectedIds=[];
catPanel.find(".wgm-front-cat-checkbox:checked").each(function (){
selectedIds.push($(this).val());
});
catInput.val(selectedIds.join(","));
executeSearch();
});
}
if(catInput.length&&catInput.val()){
var preselected=catInput.val().split(",");
preselected.forEach(function (pid){
catPanel
.find('.wgm-front-cat-checkbox[value="' + pid + '"]')
.prop("checked", true);
});
executeSearch();
}},
initDirections: function (id){
var data=this.instances[id];
var self=this;
var drawer=$("#wgm_direction_drawer_" + id);
var legacyFromInput=$("#srm_gmap_from_" + id);
var legacyToInput=$("#srm_gmap_to_" + id);
window["wgm_open_directions_" + id]=function (destination){
if(drawer.length){
var toInput=$("#wgm_dir_to_" + id);
var fromInput=$("#wgm_dir_from_" + id);
var toggleBtn=$("#wgm_drawer_toggle_" + id);
toInput.val(destination);
drawer.addClass("active");
toggleBtn.fadeOut(200);
fromInput.focus();
}else if(legacyToInput.length){
legacyToInput.val(destination);
legacyFromInput.focus();
$("html, body").animate({
scrollTop:
legacyToInput.closest(".wgm-legacy-direction-box").offset()
.top - 20,
},
500
);
}};
$(document).on("click", ".wgm-dir-link-" + id, function (e){
e.preventDefault();
self.closeAllInfoWindows(id);
window["wgm_open_directions_" + id]($(this).data("addr"));
});
$(document).on("click",
"#wgm_listing_area_" + id + " .wgm-get-direction-btn",
function (e){
e.preventDefault();
var idx=$(this).data("idx");
var m=window.custom_markers[id][idx];
if(m)
window["wgm_open_directions_" + id](
m.wgm_data.address||m.wgm_data.lat_lng
);
}
);
if(!drawer.length){
this.initLegacyDirections(id);
return;
}
var toggleBtn=$("#wgm_drawer_toggle_" + id);
var fromInput=$("#wgm_dir_from_" + id);
var toInput=$("#wgm_dir_to_" + id);
var goBtn=drawer.find(".wgm-dir-go-btn");
var travelMode="DRIVING";
var resultsPanel=$("#wgm_dir_results_" + id);
var directionsService=new google.maps.DirectionsService();
var directionsRenderer=new google.maps.DirectionsRenderer({
map: data.map,
suppressMarkers: false,
panel: resultsPanel[0],
});
toggleBtn.on("click", function (){
drawer.addClass("active");
toggleBtn.fadeOut(200);
});
drawer.find(".wgm-drawer-close").on("click", function (){
drawer.removeClass("active");
toggleBtn.fadeIn(200);
directionsRenderer.setDirections({ routes: [] });
resultsPanel.empty().removeClass("active");
});
if(typeof google.maps.places!=="undefined"){
new google.maps.places.Autocomplete(fromInput[0]).bindTo("bounds",
data.map
);
new google.maps.places.Autocomplete(toInput[0]).bindTo("bounds",
data.map
);
}
drawer.find(".wgm-travel-btn").on("click", function (){
drawer.find(".wgm-travel-btn").removeClass("active");
$(this).addClass("active");
travelMode=$(this).data("mode");
});
drawer.find(".wgm-dir-adv-toggle").on("click", function (){
drawer.find(".wgm-dir-adv-options").toggleClass("active");
});
var waypointsContainer=$("#wgm_waypoints_container_" + id);
$("#wgm_add_waypoint_" + id).on("click", function (){
var wpId="wgm_wp_" + Date.now();
var html =
'<div class="wgm-dir-input-group wgm-waypoint-item" id="' +
wpId +
'">' +
'<div class="wgm-dir-field-wrap">' +
'<input type="text" class="wgm-dir-input wgm-waypoint-input" placeholder="' +
data.i18n.via +
'">' +
'<button type="button" class="wgm-remove-waypoint-btn" title="' +
data.i18n.remove_waypoint +
'">' +
'<svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg>' +
"</button>" +
"</div>" +
"</div>";
waypointsContainer.append(html);
if(typeof google.maps.places!=="undefined"){
new google.maps.places.Autocomplete(waypointsContainer.find("#" + wpId + " input")[0]
).bindTo("bounds", data.map);
}
$("#" + wpId + " .wgm-remove-waypoint-btn").on("click", function (){
$("#" + wpId).remove();
});
});
drawer.find(".wgm-current-loc-btn").on("click", function (){
var btn=$(this);
var targetInput=btn.siblings("input");
if(navigator.geolocation){
btn.css("opacity", "0.5");
navigator.geolocation.getCurrentPosition(function (position){
btn.css("opacity", "1");
var geocoder=new google.maps.Geocoder();
geocoder.geocode({
location: {
lat: position.coords.latitude,
lng: position.coords.longitude,
},
},
function (results, status){
if(status==="OK"&&results[0])
targetInput.val(results[0].formatted_address);
else
targetInput.val(position.coords.latitude + "," + position.coords.longitude
);
}
);
},
function (error){
btn.css("opacity", "1");
console.error("Geolocation error:", error);
alert(
(data.i18n.geo_fail||"Unable to get your location") +
": " +
error.message
);
}
);
}else{
alert(data.i18n.geo_not_supported);
}});
goBtn.on("click", function (){
var origin=fromInput.val().trim();
var destination=toInput.val().trim();
var waypoints=[];
drawer.find(".wgm-waypoint-input").each(function (){
var val=$(this).val().trim();
if(val) waypoints.push({ location: val, stopover: true });
});
if(!origin||!destination){
alert(data.i18n.origin_dest_required);
return;
}
var request={
origin: origin,
destination: destination,
waypoints: waypoints,
optimizeWaypoints: true,
travelMode: google.maps.TravelMode[travelMode],
avoidTolls: drawer.find(".wgm-avoid-tolls").is(":checked"),
avoidHighways: drawer.find(".wgm-avoid-highways").is(":checked"),
avoidFerries: drawer.find(".wgm-avoid-ferries").is(":checked"),
};
directionsService.route(request, function (result, status){
if(status=="OK"){
directionsRenderer.setDirections(result);
resultsPanel.addClass("active");
}else{
alert("Directions request failed: " + status);
}});
});
this.initLegacyDirections(id);
},
initLegacyDirections: function (id){
var data=this.instances[id];
var legacySubmit=$("#wp_gmap_submit_" + id);
var directionsService=new google.maps.DirectionsService();
if(legacySubmit.length){
var legacyRenderer=new google.maps.DirectionsRenderer({
map: data.map,
panel: document.getElementById("wp_gmap_directions_" + id),
});
var fromInput=document.getElementById("srm_gmap_from_" + id);
var toInput=document.getElementById("srm_gmap_to_" + id);
if(typeof google.maps.places!=="undefined" &&
data.options.enable_direction_form_auto_complete
){
if(fromInput){
var fromAutocomplete=new google.maps.places.Autocomplete(fromInput,
{
fields: ["formatted_address", "geometry", "name"],
}
);
fromAutocomplete.bindTo("bounds", data.map);
}
if(toInput){
var toAutocomplete=new google.maps.places.Autocomplete(toInput, {
fields: ["formatted_address", "geometry", "name"],
});
toAutocomplete.bindTo("bounds", data.map);
}}
$(".wgm-legacy-travel-btn").on("click", function (){
$(".wgm-legacy-travel-btn").removeClass("active");
$(this).addClass("active");
var mode=$(this).data("mode");
$("#srm_gmap_mode_" + id).val(mode);
});
$(".wgm-legacy-loc-btn").on("click", function (){
var btn=$(this);
var targetInput=btn.siblings("input");
if(navigator.geolocation){
btn.css("opacity", "0.5");
navigator.geolocation.getCurrentPosition(function (position){
btn.css("opacity", "1");
var geocoder=new google.maps.Geocoder();
geocoder.geocode({
location: {
lat: position.coords.latitude,
lng: position.coords.longitude,
},
},
function (results, status){
if(status==="OK"&&results[0])
targetInput.val(results[0].formatted_address);
else
targetInput.val(position.coords.latitude +
"," +
position.coords.longitude
);
}
);
},
function (error){
btn.css("opacity", "1");
console.error("Geolocation error:", error);
alert(
(data.i18n.geo_fail||"Unable to get your location") +
": " +
error.message
);
}
);
}else{
alert(
data.i18n.geo_not_supported||"Geolocation is not supported"
);
}});
legacySubmit.on("click", function (){
var mode=$("#srm_gmap_mode_" + id).val(),
from=$("#srm_gmap_from_" + id).val(),
to=$("#srm_gmap_to_" + id).val();
if(!from||!to){
$("#wp_gmap_results_" + id).hide();
return;
}
$("#wp_gmap_loading_" + id).addClass("wgm-show");
directionsService.route({
origin: from,
destination: to,
travelMode: google.maps.DirectionsTravelMode[mode],
unitSystem:
data.distance_unit_system==="METRIC"
? google.maps.UnitSystem.METRIC
: google.maps.UnitSystem.IMPERIAL,
},
function (response, status){
$("#wp_gmap_loading_" + id).removeClass("wgm-show");
if(status==="OK"){
legacyRenderer.setDirections(response);
$("#wp_gmap_results_" + id).show();
}else{
$("#wp_gmap_results_" + id).hide();
alert("Directions request failed: " + status);
}}
);
});
}},
initLightbox: function (id){
var data=this.instances[id];
var overlay=$("#wgm-lightbox-overlay_" + id);
var img=$("#wgm-lightbox-img_" + id);
if(!overlay.length) return;
var container=$(".wgm-map-id-" + data.map_id).eq($(".wgm-map-id-" + data.map_id).index($("#srm_gmp_embed_" + id).closest(".wgm-map-id-" + data.map_id)
)
);
container.on("click", ".wgm-lightbox-trigger", function (e){
e.stopPropagation();
img.attr("src", $(this).attr("src"));
overlay.addClass("show");
});
overlay.on("click", function (e){
if(e.target!==img[0]) overlay.removeClass("show");
});
overlay.find(".wgm-lightbox-close").on("click", function (){
overlay.removeClass("show");
});
$(document).on("keydown", function (e){
if(e.key==="Escape") overlay.removeClass("show");
});
},
};})(jQuery);