import{V as i}from"./vue-DkJ1Kgzj-v4.3.1.js";import{P as s}from"./ProductMixin-frwGkPwF-v4.3.1.js";import{E as a}from"./Errors-Dscm1BJ0-v4.3.1.js";import{g as o}from"./functions-CqgSXQpZ-v4.3.1.js";import"./blueimp-md5-ClWCTRan-v4.3.1.js";import"./wysiwyg-BAYziHDN-v4.3.1.js";import"./tinymce-D75crZP1-v4.3.1.js";import"./vuedraggable-BDfjX5jl-v4.3.1.js";import"./vue2-selectize-BDtudStj-v4.3.1.js";import"./jquery-J9L-zf0Y-v4.3.1.js";import"./vue-flatpickr-component-Bwau1EAQ-v4.3.1.js";import"./flatpickr-Dta993Ce-v4.3.1.js";import"./@melloware-BTYRaMki-v4.3.1.js";import"./NProgress-BQVJao7--v4.3.1.js";import"./nprogress-DKCYbahp-v4.3.1.js";import"./Toaster-euwuEYDO-v4.3.1.js";import"./vue-toast-notification-KMO5b-nv-v4.3.1.js";i.prototype.defaultCurrencySymbol=FleetCart.defaultCurrencySymbol;i.prototype.route=route;new i({el:"#app",mixins:[s],data:{formSubmissionType:null,form:{brand_id:"",tax_class_id:"",is_active:!0,media:[],is_virtual:!1,manage_stock:0,in_stock:1,special_price_type:"fixed",meta:{},attributes:[],downloads:[],variations:[],variants:[],options:[],slug:null},errors:new a,selectizeConfig:{plugins:["remove_button"]},searchableSelectizeConfig:{},categoriesSelectizeConfig:{},flatPickrConfig:{mode:"single",enableTime:!0,altInput:!0}},created(){this.setSearchableSelectizeConfig(),this.setCategoriesSelectizeConfig()},methods:{setProductSlug(t){this.form.slug=o(t)},setFormDefaultData(){this.form={brand_id:"",tax_class_id:"",is_active:!0,media:[],is_virtual:!1,manage_stock:0,in_stock:1,special_price_type:"fixed",meta:{},attributes:[],downloads:[],variations:[],variants:[],options:[],slug:null}},resetForm(){this.setFormDefaultData(),this.textEditor.get("description").setContent(""),this.textEditor.get("description").execCommand("mceCancel"),this.resetBulkEditVariantFields(),this.focusField({selector:"#name"})},submit({submissionType:t}){this.formSubmissionType=t,$.ajax({type:"POST",url:route("admin.products.store",{...(t==="save_and_edit"||t==="save_and_exit")&&{exit_flash:!0}}),data:this.transformData(this.form),dataType:"json",success:({message:e,product_id:r})=>{if(t==="save_and_edit"){location.href=route("admin.products.edit",r);return}if(t==="save_and_exit"){location.href=route("admin.products.index");return}toaster(e,{type:"success"}),this.resetForm()}}).catch(e=>{if(this.formSubmissionType=null,toaster(e.responseJSON.message,{type:"default"}),e.status===422){this.errors.reset(),this.errors.record(e.responseJSON.errors),this.focusFirstErrorField(this.$refs.form.elements);return}this.hasAnyVariant&&this.regenerateVariationsAndVariantsUid()}).always(()=>{t==="save"&&(this.formSubmissionType=null)})}}});
