class d{constructor(e){this.slidePanelHtml=this.getSlidePanelHtml(e)}getSlidePanelHtml(e){e.slide.options=e.slide.options||this.getDefaultOptions();let t=_.template($("#slide-template").html());return $(t(e))}getDefaultOptions(){return{caption_1:{},caption_2:{},direction:"left",call_to_action:{}}}render(){return this.attachEventListeners(),this.showSelectedOptionBlock(),this.slidePanelHtml}attachEventListeners(){this.slidePanelHtml.find(".delete-slide").on("click",()=>{this.slidePanelHtml.remove()}),this.slidePanelHtml.find(".change-option-block").on("change",e=>{this.slidePanelHtml.find(".slide-options").hide(),this.slidePanelHtml.find(`.${e.currentTarget.value}`).show()})}showSelectedOptionBlock(){setTimeout(()=>{this.slidePanelHtml.find(".change-option-block").trigger("change")})}}class n{constructor(){this.slideCount=0,this.addSlides(FleetCart.data["slider.slides"]),this.slideCount===0&&this.addSlide(),this.attachEventListeners(),this.makeSlidesSortable()}addSlides(e){for(let t of e)this.addSlide(t)}addSlide(e={}){let t=new d({slideNumber:this.slideCount++,slide:e});$("#slides-wrapper").append(t.render())}attachEventListeners(){$(".add-slide").on("click",()=>{this.addSlide()}),this.attachImagePickerEventListener()}attachImagePickerEventListener(){$("#slides-wrapper").on("click",".slide-image",e=>{new MediaPicker({type:"image"}).on("select",l=>{let s=`
                    <img src="${l.path}">
                    <input type="hidden" name="slides[${e.currentTarget.dataset.slideNumber}][file_id]" value="${l.id}">
                `;$(e.currentTarget).html(s)})})}makeSlidesSortable(){Sortable.create(document.getElementById("slides-wrapper"),{handle:".slide-drag",animation:150})}}new n;$("#autoplay").on("change",i=>{$(".autoplay-speed-field").toggleClass("hide")});window.admin.removeSubmitButtonOffsetOn("#slides");
