Files
appco_dist/.output/public/_nuxt/D94lvKi3.js
T
2025-08-18 18:29:28 +03:30

2 lines
4.6 KiB
JavaScript

import{g as F,a as T}from"./qfLEUnwX.js";import{r as s,k,K as j,aI as h}from"./B3Hm6diO.js";const O=s(),I=s(!1),p=s(1);let c=[];const _=s(),g=s([]),b=s([]),w=s([]),A=s({url:void 0,index:0}),H=s(),L=s(),K=s([]),d=s([]),R=s([]),z=s([]),f=j({title_fa:"",title:"",price:0,body:"",is_show:!0,is_active:!0,box_size:0,sell_type:"numeric",original_image:void 0,product_attributes:[],files:[],price_type:"manual",auto_calculate:!1,sku:null,created_at:void 0,updated_at:void 0,deleted_at:null,count_order:void 0,count_fav:void 0,count_view:void 0,min_price:void 0,max_price:void 0,type:"simple",owner_id:void 0,users:void 0,saved:[],variants:[],code:void 0,brand_id:void 0,collection_id:void 0,discount:void 0,discount_type:void 0,id:void 0,count:void 0,display_price:void 0,meta:void 0,seo_title:void 0,description:void 0,product_type:void 0,weight:void 0,rial_fee:void 0,percent_fee:void 0}),D=h(f);function S(){Object.assign(f,D),b.value=[],g.value=[],d.value=[],p.value=1,A.value={url:void 0,index:0},w.value=[],_.value=void 0,O.value=void 0}const U=k(()=>{let e=h(w.value);return e==null||e.splice(0,0,A.value),e=e==null?void 0:e.map((t,a)=>t),console.log(e),e});function q(){var a,n;let e=[],t=[];(a=g.value)==null||a.forEach(i=>{i.valueId,e.push(i.valueId),t.push(i.valueName)}),console.log(e,g.value),(n=f.variants)==null||n.push({id:void 0,attribute_values:[],attribute_values_name:[],price:0,weight:0,stock:0,auto_calculate:!1,discount_type:void 0,discount:void 0,is_default:!1,sku:""}),console.log(d,f.variants)}function J(e,t){var v;let a=e;p.value=1,b.value=[],g.value=[],console.log(e),console.log("why");let n=0,i=[];e==null||e.forEach((l,o)=>{var r,m,y;console.log(l,o),l.show_in_variable?(p.value=2,f.variants.length===0&&q(),b.value.push({attributeId:l.id,name:l.name,values:l.new_feature,show:l.show_in_variable,valueKey:o}),(r=l.new_feature)==null||r.forEach((u,N)=>{g.value.push({attributeName:l.name,attributeId:l.id,valueId:u.id,valueName:u.value,valueKey:n})})):(i.push(o),(m=d.value)==null||m.forEach(u=>{console.log("val.attribute_values>",o),console.log(u.attribute_values),console.log("myAttributes.value.length "+a.length),console.log("val.attribute_values.length "+u.attribute_values.length),a.length>u.attribute_values.length&&u.attribute_values[o]!=null&&(u.attribute_values.length!=o?(u.attribute_values.splice(o,0,null),u.attribute_values_name.splice(o,0,null)):(u.attribute_values=[...u.attribute_values,null],u.attribute_values_name=[...u.attribute_values_name,null])),console.log("val.attribute_values After slice>"+o),console.log(u.attribute_values)})),n++,(y=d.value)==null||y.forEach((u,N)=>{a.length>u.attribute_values.length&&u.attribute_values[o]!=null&&(u.attribute_values=[...u.attribute_values,null],u.attribute_values_name=[...u.attribute_values_name,null])}),console.log("variants+++")}),console.log("tempIndexArray"),console.log(i),B(d.value),i.length!=0&&((v=d.value)==null||v.forEach(l=>{i.forEach(o=>{l.attribute_values[o]=null,l.attribute_values_name[o]=null})}))}function B(e){console.log("444444",e),e==null||e.forEach((t,a)=>{c=h(t.attribute_values),b.value.length<=c.length&&(c==null||c.forEach((n,i)=>{var v;(v=g.value)==null||v.forEach((l,o)=>{c.find(r=>r==(l==null?void 0:l.valueId))&&t.attribute_values[l.valueKey]!=c.find(r=>r==l.valueId)&&(t.attribute_values[l.valueKey]=c.find(r=>r==l.valueId),t.attribute_values_name[l.valueKey]=l.valueName),console.log((t==null?void 0:t.attribute_values)+"AFTER CHANGE ITEM"+a)})})),a==0&&(_.value=E(t.attribute_values_name)),t.is_default&&(console.log("val.attribute_values",t.attribute_values_name),_.value=E(t.attribute_values_name),console.log("defaultVariant",_.value))})}function E(e){console.log(e,_.value);let t="";return e.forEach((a,n)=>{if(a)return t+=(n!==0?" - ":"")+a}),t}async function P(){try{I.value=!0,z.value=await T()}catch(e){console.log(e)}finally{I.value=!1}}async function Q(e){let t;e[e.length-1]!=null&&(t=await F(e[e.length-1]));let a;a=t[0],Object.assign(a,{new_feature:[],show_in_product:!1,show_in_variable:!1}),console.log("gggggggggggggggggggggggggggggggg",a),K.value.push(a)}async function W(e){var n,i;const t=await F(e),a=K.value.find(v=>v.id===e);a&&(console.log(a.attribute_values,t[0].attribute_values),a.attribute_values=[],a.attribute_values=(n=t[0])!=null&&n.attribute_values?h((i=t[0])==null?void 0:i.attribute_values):[],console.log(a.attribute_values))}const X=e=>(console.log("fsdfuygiuhguighuisdf",e),e.split("-")[0]==="edit"),Y=s([]),Z=s([]);export{U as a,X as b,Z as c,H as d,O as e,Y as f,z as g,P as h,K as i,W as j,Q as k,I as l,w as m,f as n,A as o,L as p,b as q,S as r,R as s,p as t,J as u,d as v,q as w,_ as x,E as y,g as z};