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

2 lines
7.0 KiB
JavaScript
Raw Normal View History

2025-07-24 21:23:30 +03:30
import{d as W,u as X,G as Z,r as w,d1 as ee,a1 as A,o as le,aj as te,y as c,z as v,C as k,A as s,D as b,H as t,ai as B,B as p,S as O,a7 as L,bY as ae,a2 as $,a3 as se,E as U,Q as oe}from"./B565zvD7.js";import{_ as ie}from"./CscEAC8U.js";import{C as V,a as I}from"./CFgyaiyP.js";import{m as a,d as g,o as i,l as ne,c as re}from"./BdYSuaW6.js";import{u as m}from"./50ego_Xv.js";import{i as x}from"./DGz2YCiv.js";import{B as ue}from"./B8tjfeLk.js";import{S as de}from"./DouGH0TO.js";import{a as ce,_ as ve}from"./DGoOYFa5.js";const pe={class:"w-full h-screen bg-black text-white"},me={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"},ke={key:0,class:"relative w-full"},xe=["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"},Ce={class:"media-grid"},Pe={class:"media-preview"},Se={class:"text-sm"},Fe=["onClick"],Le=["src"],Ue=["src"],Ie=["onClick"],Re={class:"text-sm"},Ee={class:"absolute bottom-5 right-5 addStyle"},C=10,ze=W({__name:"index",setup(je){const f=X(),r=Z(),y=w(""),P=w(null),_=w(null),o=w(-2),R=ee();function T(){a.value=[],i.value={},f.push({name:"home"})}A(a,l=>{var e,n,u;((e=a.value)==null?void 0:e.length)===0?g.value="":((n=a.value)==null?void 0:n.length)===1?g.value=a.value[0].url:l&&(g.value=(u=l[(l==null?void 0:l.length)-1])==null?void 0:u.url)},{deep:!0}),A(i,l=>{g.value=l.url,o.value=-1},{deep:!0});function z(){i.value.url?R.name=="edit-product-id-inputProduct"?f.push({name:"edit-product-id-infProduct"}):f.push({name:"add-product-infProduct"}):(console.log(m().originalFile),oe.warn(r.useString("addAtLeastOneMedia")))}function E(l){o.value=l,l===-1?g.value=i.value.url:g.value=a.value[l].url}const q=l=>l.includes(".mp4")||l.includes(".mov")||l.includes("video"),G=async()=>{o.value==-1?await M():await j()},j=async()=>{console.log(o.value,"Media");try{if(V.isNativePlatform())if(o.value==-2)(await I.pickImages({limit:C-a.value.length})).photos.forEach(e=>{m().mediaFiles.push({file:e,index:a.value.length}),a.value.push({url:e.webPath,index:a.value.length})}),o.value=a.value.length-1;else{const l=await I.pickImages({limit:1});l.photos.length>0&&(a.value[o.value].url=l.photos[0].webPath,m().mediaFiles[o.value].file=l.photos[0])}else console.log(o.value,"MediaA"),o.value==-2?P.value.click():_.value.click()}catch(l){console.error("Error selecting media:",l)}},M=async()=>{try{if(V.isNativePlatform()){const l=await I.pickImages({limit:1});l.photos.length>0&&(i.value.url=l.photos[0].webPath,m().originalFile={file:l.photos[0],index:0})}else console.log(o.value,"main"),await _.value.click(),console.log(o.value,"mainA"),_.value.onchange=l=>{const e=l.target.files;console.log(e,8888),e.length>0&&(i.value.url=URL.createObjectURL(e[0]),console.log(e,9999)),setTimeout(()=>{_.value.value=null},10)};console.log("dsacbnkjsdkmc,loskock,sdds",i.value)}catch(l){console.error("Error selecting main media:",l)}},D=l=>{console.log(o.value,4555);const e=l.target.files;e.length!=0&&(console.log(l,45),!i.value.url&&e.length>0||o.value==-1&&e.length>0?(i.value.url=URL.createObjectURL(e[0]),m().originalFile={file:e[0],index:0},console.log(i.value)):o.value==-2?Array.from(e).forEach(n=>{let u=a.value.length;a.value.length<C&&(a.value.push({url:URL.createObjectURL(n),index:u+1}),m().mediaFiles.push({file:n,index:u+1}),o.value=a.value.length-1)}):(a.value[o.value].url=URL.createObjectURL(e[0]),m().mediaFiles.push({file:e[0],index:a.value[o.value].index}),o.value=a.value.length-1),P.value.value="",_.value.value="")},H=l=>{l.preventDefault();const e=l.dataTransfer.files;Array.from(e).forEach(n=>{a.value.length<C&&(m().mediaFiles.push({file:n,index:a.value.length}),a.value.push({url:URL.createObjectURL(n),index:a.value.length}))})},Q=(l,e)=>{const n=m().mediaFiles.findIndex(u=>u.index==e);a.value.splice(l,1),n>=0&&m().mediaFiles.splice(n,1)},Y=()=>{i.value.url=void 0,re.value=void 0};return le(()=>{switch(f.currentRo