2025-08-25 15:52:41 +03:30
|
|
|
import{d as W,u as X,H as Z,r as w,d4 as ee,a2 as A,o as le,al as te,y as v,z as m,C as _,T as L,D as b,A as s,I as t,ak as B,B as p,a8 as R,bY as ie,a3 as O,a4 as se,E as U,R as ae}from"./CYzE2ijA.js";import{_ as oe}from"./CscEAC8U.js";import{C as $,a as E}from"./7leyeuG9.js";import{m as i,e as g,o as u,b as T,l as ne,r as V,i as re,d as ue}from"./DtjP-fro.js";import{u as o}from"./cnyNrgym.js";import{i as x}from"./4y87cp-D.js";import{B as de}from"./DD5Ys7CO.js";import{S as ce}from"./5Tcs8R9X.js";import{a as ve,_ as me}from"./BVqkG0IS.js";const pe={class:"w-full h-screen bg-black text-white"},ge={class:"flex w-full p-4 gap-8 justify-between items-center"},fe={class:"flex gap-8 items-center"},he=["alt"],_e={class:"font-semibold text-lg"},xe={class:"aspect-square flex items-center justify-center"},ke={key:0,class:"relative w-full"},ye=["alt"],be={class:"flex absolute shadow-black shadow-sm rounded-full bottom-2 mx-3"},we={key:1,class:"empty-state"},Fe={class:"media-picker"},Ce={class:"media-grid"},Pe={class:"media-preview"},Se={class:"text-sm"},Ie=["onClick"],Le=["src"],Re=["src"],Ue=["onClick"],Ee={class:"text-sm"},Me={key:0,class:"absolute bottom-5 right-5 addStyle"},F=10,qe=W({__name:"index",setup(je){const f=X(),d=Z(),k=w(""),C=w(null),h=w(null),a=w(-2),P=ee();function z(){f.push({name:"home"}),V(),o().mediaFiles=[],re.value=[]}A(i,l=>{i.value?.length===0?g.value="":i.value?.length===1?g.value=i.value[0].url:l&&(g.value=l[l?.length-1]?.url)},{deep:!0}),A(u,l=>{g.value=l.url,a.value=-1},{deep:!0});function q(){u.value.url?P.name=="edit-product-id-inputProduct"?f.push({name:"edit-product-id-infProduct"}):f.push({name:"add-product-infProduct"}):(console.log(o().originalFile,o().mediaFiles),ae.warn(d.useString("addAtLeastOneMedia"))),console.log(o().originalFile,o().mediaFiles)}function M(l){a.value=l,l===-1?g.value=u.value.url:g.value=i.value[l].url}const H=l=>l.includes(".mp4")||l.includes(".mov")||l.includes("video"),Y=async()=>{a.value==-1?await D():await j()},j=async()=>{console.log(a.value,"Media");try{if($.isNativePlatform())if(a.value==-2)(await E.pickImages({limit:F-i.value.length})).photos.forEach(e=>{o().mediaFiles.push({file:e,index:i.value.length}),i.value.push({url:e.webPath,index:i.value.length})}),a.value=i.value.length-1;else{const l=await E.pickImages({limit:1});l.photos.length>0&&(i.value[a.value].url=l.photos[0].webPath,o().mediaFiles[a.value].file=l.photos[0])}else console.log(a.value,"MediaA"),a.value==-2?C.value.click():h.value.click()}catch(l){console.error("Error selecting media:",l)}},D=async()=>{try{if($.isNativePlatform()){const l=await E.pickImages({limit:1});l.photos.length>0&&(u.value.url=l.photos[0].webPath,o().originalFile={file:l.photos[0],index:0})}else console.log(a.value,"main"),await h.value.click(),console.log(a.value,"mainA"),h.value.onchange=l=>{const e=l.target.files;console.log(e,8888),e.length>0&&(u.value.url=URL.createObjectURL(e[0]),console.log(e,9999)),setTimeout(()=>{h.value.value=null},10)};console.log("dsacbnkjsdkmc,loskock,sdds",u.value)}catch(l){console.error("Error selecting main media:",l)}},N=l=>{console.log(a.value,4555);const e=l.target.files;e.length!=0&&(console.log(l,45),!u.value.url&&e.length>0||a.value==-1&&e.length>0?(u.value.url=URL.createObjectURL(e[0]),o().originalFile={file:e[0],index:0},console.log(u.value)):a.value==-2?Array.from(e).forEach(r=>{let c=i.value.at(-1)?.index??0;i.value.length<F&&(i.value.push({url:URL.createObjectURL(r),index:c+1}),o().mediaFiles.push({file:r,index:c+1}),o().mediaFiles.sort((S,y)=>S.index-y.index),a.value=i.value.length-1)}):(i.value[a.value].url=URL.createObjectURL(e[0]),o().mediaFiles.length>0?o().mediaFiles.some((r,c)=>{if(r.index==i.value[a.value].index)return r.file=e[0],!0})||(o().mediaFiles.push({file:e[0],index:i.value[a.value].index}),console.log(o().mediaFiles)):o().mediaFiles.push({file:e[0],index:i.value[a.value].index}),o().mediaFiles.sort((r,c)=>r.index-c.index),a.value=i.value.length-1),C.value.value="",h.value.value="",console.log(o().mediaFiles))},G=l=>{l.preventDefault();const e=l.dataTransfer.files;Array.
|