Files
appco_dist/.output/public/_nuxt/D1nsTRfe.js
T

2 lines
7.5 KiB
JavaScript
Raw Normal View History

2025-08-18 18:29:28 +03:30
import{d as Z,u as ee,G as le,r as C,d3 as te,a1 as O,o as ie,al as ae,y as c,z as v,C as x,S as E,D as w,A as a,H as t,ak as $,B as g,a7 as I,b_ as se,a2 as V,a3 as oe,E as R,Q as ne}from"./B3Hm6diO.js";import{_ as re}from"./CscEAC8U.js";import{C as T,a as M}from"./ppZ4gnC7.js";import{m as i,e as f,o as u,b as z,l as ue,r as q,i as de,d as ce}from"./D94lvKi3.js";import{u as o}from"./4q1sGPs7.js";import{i as k}from"./DS96Ojhv.js";import{B as ve}from"./BJmKrNtx.js";import{S as me}from"./CFKSihEF.js";import{a as pe,_ as ge}from"./BrW_ACFg.js";const fe={class:"w-full h-screen bg-black text-white"},he={class:"flex w-full p-4 gap-8 justify-between items-center"},_e={class:"flex gap-8 items-center"},xe=["alt"],ke={class:"font-semibold text-lg"},ye={class:"aspect-square flex items-center justify-center"},be={key:0,class:"relative w-full"},we=["alt"],Fe={class:"flex absolute shadow-black shadow-sm rounded-full bottom-2 mx-3"},Ce={key:1,class:"empty-state"},Se={class:"media-picker"},Pe={class:"media-grid"},Le={class:"media-preview"},Ue={class:"text-sm"},Ee=["onClick"],Ie=["src"],Re=["src"],Me=["onClick"],je={class:"text-sm"},De={key:0,class:"absolute bottom-5 right-5 addStyle"},S=10,He=Z({__name:"index",setup(Ne){const h=ee(),d=le(),y=C(""),P=C(null),_=C(null),s=C(-2),L=te();function G(){h.push({name:"home"}),q(),o().mediaFiles=[],de.value=[]}O(i,l=>{var e,n,r;((e=i.value)==null?void 0:e.length)===0?f.value="":((n=i.value)==null?void 0:n.length)===1?f.value=i.value[0].url:l&&(f.value=(r=l[(l==null?void 0:l.length)-1])==null?void 0:r.url)},{deep:!0}),O(u,l=>{f.value=l.url,s.value=-1},{deep:!0});function H(){u.value.url?L.name=="edit-product-id-inputProduct"?h.push({name:"edit-product-id-infProduct"}):h.push({name:"add-product-infProduct"}):(console.log(o().originalFile,o().mediaFiles),ne.warn(d.useString("addAtLeastOneMedia"))),console.log(o().originalFile,o().mediaFiles)}function j(l){s.value=l,l===-1?f.value=u.value.url:f.value=i.value[l].url}const Q=l=>l.includes(".mp4")||l.includes(".mov")||l.includes("video"),J=async()=>{s.value==-1?await N():await D()},D=async()=>{console.log(s.value,"Media");try{if(T.isNativePlatform())if(s.value==-2)(await M.pickImages({limit:S-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?P.value.click():_.value.click()}catch(l){console.error("Error selecting media:",l)}},N=async()=>{try{if(T.isNativePlatform()){const l=await M.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(s.value,"main"),await _.value.click(),console.log(s.value,"mainA"),_.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(()=>{_.value.value=null},10)};console.log("dsacbnkjsdkmc,loskock,sdds",u.value)}catch(l){console.error("Error selecting main media:",l)}},A=l=>{console.log(s.value,4555);const e=l.target.files;e.length!=0&&(console.log(l,45),!u.value.url&&e.length>0||s.value==-1&&e.length>0?(u.value.url=URL.createObjectURL(e[0]),o().originalFile={file:e[0],index:0},console.log(u.value)):s.value==-2?Array.from(e).forEach(n=>{var F;let r=((F=i.value.at(-1))==null?void 0:F.index)??0;i.value.length<S&&(i.value.push({url:URL.createObjectURL(n),index:r+1}),o().mediaFiles.push({file:n,index:r+1}),o().mediaFiles.sort((b,m)=>b.index-m.index),s.value=i.value.length-1)}):(i.value[s.value].url=URL.createObjectURL(e[0]),o().mediaFiles.length>0?o().mediaFiles.some((n,r)=>{if(n.index==i.value[s.value].index)return n.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((n,r)=>n.index-r.index),s.value=i.value.length-1),P.value.va