(()=>{const e=/^geo:([-+]?\d+(?:\.\d+)?),([-+]?\d+(?:\.\d+)?)(?:\?z=(\d{1,2}))?$/,t=".error-message";function n(e){return e===Number(e).toString()}function r(e,t){return e+t}document.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("id_center_latitude"),d=document.getElementById("id_center_longitude"),o=document.getElementById("map-center-calculate"),u=o.parentElement.querySelector(t);o.addEventListener("click",(()=>{const t=[],o=[];u.setAttribute("hidden",""),document.querySelectorAll("#id_points-FORMS > li:not(.deleted)").forEach((e=>{const r=e.querySelector("[name$=-latitude]").value,d=e.querySelector("[name$=-longitude]").value;n(r)&&n(d)&&(t.push(Number(r)),o.push(Number(d)))})),t.length?(e.value=t.reduce(r)/t.length,d.value=o.reduce(r)/o.length):u.removeAttribute("hidden")}))})),document.addEventListener("DOMContentLoaded",(()=>{const n=document.getElementById("point-from-geo-modal"),r=n.querySelector("form"),d=r.querySelector('input[name="prefix"]'),o=r.querySelector('input[name="geo-uri"]'),u=r.querySelector(t);window.jQuery(n).on("show.bs.modal",(e=>{o.value="",u.setAttribute("hidden",""),d.value=e.relatedTarget.getAttribute("data-point-prefix")})),r.addEventListener("submit",(t=>{t.preventDefault(),t.stopPropagation(),u.setAttribute("hidden","");const d=new FormData(r),o=d.get("geo-uri").match(e);if(!o)return void u.removeAttribute("hidden");const i=d.get("prefix"),l=document.querySelector(`[name="${i}-latitude"]`),a=document.querySelector(`[name="${i}-longitude"]`);l.value=Number(o[1]),a.value=Number(o[2]),window.jQuery(n).modal("hide")}))}))})();
//# sourceMappingURL=admin-form.js.map