"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("main").dataset.urlPrefix,l=document.querySelector("#container--lotTypes");let o=exports.lotTypes;delete exports.lotTypes;const s=new Set,a=e=>{const t=e.currentTarget,l=t.closest(".container--lotType"),o=Number.parseInt(l.dataset.lotTypeId,10);s.has(o)?s.delete(o):s.add(o),t.innerHTML=s.has(o)?'':'';const a=l.querySelectorAll(".panel-block");for(const e of a)e.classList.toggle("is-hidden")},i=e=>{e.success?(o=e.lotTypes,b()):bulmaJS.alert({title:"Error Updating "+exports.aliases.lot+" Type",message:e.errorMessage,contextualColorName:"danger"})},d=e=>{const l=Number.parseInt(e.currentTarget.closest(".container--lotType").dataset.lotTypeId,10);bulmaJS.confirm({title:"Delete "+exports.aliases.lot+" Type",message:"Are you sure you want to delete this "+exports.aliases.lot.toLowerCase()+" type?",contextualColorName:"warning",okButton:{text:"Yes, Delete "+exports.aliases.lot+" Type",callbackFunction:()=>{cityssm.postJSON(t+"/admin/doDeleteLotType",{lotTypeId:l},i)}}})},n=l=>{const s=Number.parseInt(l.currentTarget.closest(".container--lotType").dataset.lotTypeId,10),a=o.find(e=>s===e.lotTypeId);let d;const n=e=>{e.preventDefault(),cityssm.postJSON(t+"/admin/doUpdateLotType",e.currentTarget,e=>{i(e),e.success&&d()})};cityssm.openHtmlModal("adminLotTypes-editLotType",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotTypeEdit--lotTypeId").value=s.toString(),t.querySelector("#lotTypeEdit--lotType").value=a.lotType},onshown:(e,t)=>{d=t,e.querySelector("#lotTypeEdit--lotType").focus(),e.querySelector("form").addEventListener("submit",n),bulmaJS.toggleHtmlClipped()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},r=l=>{const o=Number.parseInt(l.currentTarget.closest(".container--lotType").dataset.lotTypeId,10);let a;const d=e=>{e.preventDefault(),cityssm.postJSON(t+"/admin/doAddLotTypeField",e.currentTarget,e=>{s.add(o),i(e),e.success&&(a(),u(o,e.lotTypeFieldId))})};cityssm.openHtmlModal("adminLotTypes-addLotTypeField",{onshow:t=>{e.populateAliases(t),o&&(t.querySelector("#lotTypeFieldAdd--lotTypeId").value=o.toString())},onshown:(e,t)=>{a=t,e.querySelector("#lotTypeFieldAdd--lotTypeField").focus(),e.querySelector("form").addEventListener("submit",d),bulmaJS.toggleHtmlClipped()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},p=e=>{e.preventDefault();const l=e.currentTarget.closest(".container--lotType").dataset.lotTypeId;cityssm.postJSON(t+"/admin/doMoveLotTypeUp",{lotTypeId:l,moveToTop:e.shiftKey?"1":"0"},i)},c=e=>{e.preventDefault();const l=e.currentTarget.closest(".container--lotType").dataset.lotTypeId;cityssm.postJSON(t+"/admin/doMoveLotTypeDown",{lotTypeId:l,moveToBottom:e.shiftKey?"1":"0"},i)},u=(l,s)=>{const a=o.find(e=>e.lotTypeId===l).lotTypeFields.find(e=>e.lotTypeFieldId===s);let d,n,r,p,c;const u=()=>{n.min=d.value},y=()=>{""===p.value?(d.disabled=!1,n.disabled=!1,r.disabled=!1):(d.disabled=!0,n.disabled=!0,r.disabled=!0)},m=e=>{e.preventDefault(),cityssm.postJSON(t+"/admin/doUpdateLotTypeField",e.currentTarget,e=>{i(e),e.success&&c()})},T=()=>{bulmaJS.confirm({title:"Delete Field",message:"Are you sure you want to delete this field? Note that historical records that make use of this field will not be affected.",contextualColorName:"warning",okButton:{text:"Yes, Delete Field",callbackFunction:()=>{cityssm.postJSON(t+"/admin/doDeleteLotTypeField",{lotTypeFieldId:s},e=>{i(e),e.success&&c()})}}})};cityssm.openHtmlModal("adminLotTypes-editLotTypeField",{onshow:t=>{e.populateAliases(t),t.querySelector("#lotTypeFieldEdit--lotTypeFieldId").value=a.lotTypeFieldId.toString(),t.querySelector("#lotTypeFieldEdit--lotTypeField").value=a.lotTypeField,t.querySelector("#lotTypeFieldEdit--isRequired").value=a.isRequired?"1":"0",(d=t.querySelector("#lotTypeFieldEdit--minimumLength")).value=a.minimumLength.toString(),(n=t.querySelector("#lotTypeFieldEdit--maximumLength")).value=a.maximumLength.toString(),(r=t.querySelector("#lotTypeFieldEdit--pattern")).value=a.pattern,(p=t.querySelector("#lotTypeFieldEdit--lotTypeFieldValues")).value=a.lotTypeFieldValues,y()},onshown:(e,t)=>{c=t,bulmaJS.init(e),bulmaJS.toggleHtmlClipped(),cityssm.enableNavBlocker(),e.querySelector("form").addEventListener("submit",m),d.addEventListener("keyup",u),u(),p.addEventListener("keyup",y),e.querySelector("#button--deleteLotTypeField").addEventListener("click",T)},onremoved:()=>{bulmaJS.toggleHtmlClipped(),cityssm.disableNavBlocker()}})},y=e=>{e.preventDefault();const t=Number.parseInt(e.currentTarget.closest(".container--lotTypeField").dataset.lotTypeFieldId,10),l=Number.parseInt(e.currentTarget.closest(".container--lotType").dataset.lotTypeId,10);u(l,t)},m=e=>{e.preventDefault();const l=e.currentTarget.closest(".container--lotTypeField").dataset.lotTypeFieldId;cityssm.postJSON(t+"/admin/doMoveLotTypeFieldUp",{lotTypeFieldId:l,moveToTop:e.shiftKey?"1":"0"},i)},T=e=>{e.preventDefault();const l=e.currentTarget.closest(".container--lotTypeField").dataset.lotTypeFieldId;cityssm.postJSON(t+"/admin/doMoveLotTypeFieldDown",{lotTypeFieldId:l,moveToBottom:e.shiftKey?"1":"0"},i)},v=(e,t,l)=>{if(0===l.length)e.insertAdjacentHTML("beforeend",'