Files
appco_dist/.output/public/_nuxt/7A7g6m02.js
T

2 lines
7.4 KiB
JavaScript
Raw Normal View History

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