import{V as i}from"./vue-ROl3rvO--v4.6.0.js";import{P as s}from"./ProductMixin-C7jc-7_E-v4.6.0.js";import{E as a}from"./Errors-CLl7ZKxD-v4.6.0.js";import{g as o}from"./functions-CqgSXQpZ-v4.6.0.js";import"./blueimp-md5-DrCnc-_a-v4.6.0.js";import"./@popperjs-DMMwm23M-v4.6.0.js";import"./wysiwyg-CMELiC-r-v4.6.0.js";import"./tinymce-O4mhUEqw-v4.6.0.js";import"./vuedraggable-wexgooZQ-v4.6.0.js";import"./vue2-selectize-BzvTQgAy-v4.6.0.js";import"./jquery-DsDSGtnt-v4.6.0.js";import"./vue-flatpickr-component-CGjPFiav-v4.6.0.js";import"./flatpickr-uj7nod85-v4.6.0.js";import"./@melloware-BTYRaMki-v4.6.0.js";import"./NProgress-Day8y6xD-v4.6.0.js";import"./nprogress-u2jSs69r-v4.6.0.js";import"./Toaster-kJWPoJWx-v4.6.0.js";import"./vue-toast-notification-mZWJjkD3-v4.6.0.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)})}}});
