PageSourceSearch

https://app.ventiapp.mx/assets/editor-ia-DNURlS6-.js

js ventiapp.mx collected 2026-09-28 05:55:01 UTC 32,122 bytes, 116 lines download raw bytes

1import{bB as P,bx as te,aX as y,bD as we,by as ke,bF as Ne,bj as n,bn as Ce,bb as e,ah as Se}from"./index-CNZVeRkL.js";import{u as Ie}from"./usePageTitle-BjMLwBTV.js";function Fe(r,i){return P({queryKey:["ai-image-editor-init",r,i],queryFn:()=>{const s=new URLSearchParams({productId:String(r)});return i&&s.set("pictureId",String(i)),y.get(`/ai/image-editor?${s}`)},enabled:!!r,staleTime:1/0})}function Ee(r){return P({queryKey:["ai-product-images",r],queryFn:()=>y.get(`/productos/GetPicturesForEditor/${r}`),enabled:!!r,staleTime:3e4,select:i=>i.items})}function ze(){return te({mutationFn:({productId:r,url:i})=>y.get(`/ai/image-editor/product/${r}/resolve-image?url=${encodeURIComponent(i)}`)})}function Pe(){return te({mutationFn:r=>y.post("/ai/image-editor/send",r)})}function Ae(r,i){return P({queryKey:["ai-product-search",r,i],queryFn:()=>{const s=new URLSearchParams({page:String(i),pageSize:"20"});return r&&s.set("q",r),y.get(`/ai/image-editor/products?${s}`)},staleTime:3e4,placeholderData:s=>s})}function Be(r,i){return P({queryKey:["ai-image-logs",r,i],queryFn:()=>{const s=i?`?filterInfo=${encodeURIComponent(i)}`:"";return y.get(`/ai/image-editor/logs/${r}${s}`)},enabled:!!r,staleTime:0})}const ae=[{nombre:"Celeste",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--9f7edd49-1ebc-4023-8639-78d62e9663f7_29_9_2025_12_58_10_178.jpg"},{nombre:"Ale",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--c5c6f651-1cb8-4b98-930c-2252da8c5f01_29_9_2025_12_58_10_197.jpg"},{nombre:"Sony",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--c9eddb8f-3469-44ad-a92e-47838ec24f7c_29_9_2025_12_58_12_25.jpg"},{nombre:"Ari",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--a6d8581d-b46b-4320-b71d-4d8c4d53861e_29_9_2025_12_58_10_470.jpg"},{nombre:"Dai",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--eabaa4eb-3cdc-4a85-af53-01563e041248_29_9_2025_12_58_12_494.jpg"},{nombre:"Erick",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--28049789-2d0d-4362-8c0e-73db35cf061c_29_9_2025_12_58_10_236.jpg"},{nombre:"Kevin",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--8dc1a9ed-d60b-473d-aecc-450114f7d9a1_29_9_2025_12_58_10_413.jpg"},{nombre:"Moi",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--5737bcab-df53-4896-bc69-9964e6d5d0b6_29_9_2025_12_58_10_431.jpg"},{nombre:"Isaac",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--1a81cced-3610-4e96-97eb-892bc71d3b43_29_9_2025_12_58_12_9.jpg"},{nombre:"Juan",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--ba79e46a-0bc6-4516-afcb-058f02135e00_29_9_2025_12_58_10_908.jpg"},{nombre:"Ro",url:"https://ventiapp.blob.core.windows.net/images/D65FC12/ventiapp-image--0b31ceb7-2958-4900-a036-8bd16bdcbdd4_29_9_2025_12_58_12_541.jpg"}],De=`
2.ed-shell{display:flex;flex-direction:column;gap:16px;min-height:calc(100vh - 160px)}
3.ed-shell a{color:var(--va-brand-blue);text-decoration:none}
4.ed-shell a:hover{color:var(--va-brand-blue-600);text-decoration:underline}
5.icn{width:16px;height:16px;stroke:currentColor;stroke-width:1.8;fill:none;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
6.icn-sm{width:14px;height:14px}.icn-lg{width:20px;height:20px}.icn-xl{width:24px;height:24px}
7.ed-titlebar{display:flex;align-items:center;gap:14px;background:white;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);padding:14px 20px}
8.ed-titlebar__back{width:34px;height:34px;border-radius:var(--va-radius-sm);border:1px solid var(--va-neutral-300);background:white;display:inline-flex;align-items:center;justify-content:center;color:var(--va-neutral-600);flex:0 0 auto;cursor:pointer;transition:background var(--va-dur-1),border-color var(--va-dur-1);text-decoration:none}
9.ed-titlebar__back:hover{background:var(--va-neutral-50);border-color:var(--va-neutral-400);color:var(--va-neutral-800)}
10.ed-titlebar__text{min-width:0;flex:1}
11.ed-titlebar__title{margin:0;font-size:17px;font-weight:500;color:var(--va-neutral-700);letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
12.ed-titlebar__sub{font-size:11px;color:var(--va-brand-blue);cursor:pointer;background:none;border:none;padding:0;font-family:inherit}
13.ed-titlebar__sub:hover{text-decoration:underline}
14.ed-work{flex:1;display:flex;min-height:0;align-items:stretch;background:white;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);overflow:hidden}
15.ed-side{width:394px;flex:0 0 394px;background:#F4F9FF;border-right:1px solid var(--va-neutral-200);padding:20px 22px 32px;display:flex;flex-direction:column;gap:16px;overflow-y:auto}
16.ed-side__title{margin:0;font-size:16px;font-weight:700;color:var(--va-neutral-800)}
17.ed-side__sub{margin:2px 0 4px;font-size:13px;color:var(--va-neutral-600)}
18.ed-tool{background:white;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);box-shadow:var(--va-shadow-xs);padding:16px 18px;display:flex;align-items:center;gap:14px;width:100%;text-align:left;font-family:inherit;cursor:pointer;transition:border-color var(--va-dur-1),box-shadow var(--va-dur-1)}
19.ed-tool:hover{border-color:var(--va-brand-blue-100);box-shadow:var(--va-shadow-sm)}
20.ed-tool.is-active{border-color:var(--va-brand-blue);box-shadow:0 0 0 1px var(--va-brand-blue)}
21.ed-tool__icon{width:44px;height:44px;flex:0 0 44px;border:1px solid var(--va-brand-blue);border-radius:var(--va-radius-sm);display:flex;align-items:center;justify-content:center;color:var(--va-brand-blue)}
22.ed-tool__icon svg{width:24px;height:24px;stroke:currentColor;stroke-width:1.6;fill:none;stroke-linecap:round;stroke-linejoin:round}
23.ed-tool__name{display:block;font-size:14px;font-weight:600;color:var(--va-neutral-800)}
24.ed-tool__desc{display:block;font-size:13px;color:var(--va-neutral-600);margin-top:1px}
25.ed-tool__spacer{flex:1}
26.ed-panel{background:white;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);box-shadow:var(--va-shadow-xs);padding:16px 18px}
27.ed-panel__title{font-size:14px;font-weight:600;color:var(--va-neutral-800)}
28.ed-panel__sub{font-size:13px;color:var(--va-neutral-600);margin:1px 0 12px}
29.ed-models{display:grid;grid-template-columns:repeat(auto-fill,minmax(78px,1fr));gap:12px 10px;max-height:280px;overflow-y:auto;padding-right:8px}
30.ed-models::-webkit-scrollbar{width:8px}
31.ed-models::-webkit-scrollbar-thumb{background:var(--va-neutral-300);border-radius:999px}
32.ed-model{border:none;background:none;padding:0;font-family:inherit;cursor:pointer;text-align:left}
33.ed-model__thumb{aspect-ratio:3/4;border-radius:var(--va-radius-sm);border:1px solid var(--va-neutral-200);background:var(--va-neutral-100);display:flex;align-items:center;justify-content:center;overflow:hidden;transition:border-color var(--va-dur-1)}
34.ed-model__thumb img{width:100%;height:100%;object-fit:cover}
35.ed-model__name{display:block;font-size:12px;color:var(--va-neutral-600);margin-top:5px}
36.ed-model:hover .ed-model__thumb{border-color:var(--va-brand-blue-100)}
37.ed-model.is-selected .ed-model__thumb{border-color:var(--va-brand-blue);box-shadow:0 0 0 1px var(--va-brand-blue)}
38.ed-model.is-selected .ed-model__name{color:var(--va-brand-blue);font-weight:600}
39.ed-actions{background:white;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);box-shadow:var(--va-shadow-xs);padding:16px 18px;display:flex;flex-direction:column;gap:12px}
40.ed-actions .va-btn{height:44px;width:100%}
41.ed-apply{height:48px;width:100%;font-size:15px}
42.ed-apply:disabled{background:#A8CFFB;border-color:#A8CFFB;color:white;opacity:1}
43.ed-canvas{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;padding:40px;background-image:linear-gradient(45deg,#E9EDF2 25%,transparent 25%,transparent 75%,#E9EDF2 75%),linear-gradient(45deg,#E9EDF2 25%,transparent 25%,transparent 75%,#E9EDF2 75%);background-size:24px 24px;background-position:0 0,12px 12px}
44.ed-canvas__frame{width:min(530px,100%);aspect-ratio:1/1;background:white;border:1px solid var(--va-neutral-200);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:var(--va-neutral-400);position:relative;overflow:hidden}
45.ed-canvas__frame img{width:100%;height:100%;object-fit:contain}
46.ed-canvas__frame svg{width:64px;
46height:64px;stroke:currentColor;stroke-width:1.2;fill:none;stroke-linecap:round;stroke-linejoin:round}
47.ed-canvas__label{font-size:12px;letter-spacing:.04em;text-transform:uppercase;color:var(--va-neutral-500)}
48.ed-canvas__busy{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.86);font-size:14px;font-weight:600;color:var(--va-brand-blue);flex-direction:column;gap:12px}
49.ed-canvas__spinner{width:36px;height:36px;border:3px solid var(--va-brand-blue-100);border-top-color:var(--va-brand-blue);border-radius:50%;animation:edSpin .8s linear infinite}
50@keyframes edSpin{to{transform:rotate(360deg)}}
51.ed-hist{position:fixed;inset:0;z-index:80;display:none}
52.ed-hist[aria-hidden="false"]{display:block}
53.ed-hist__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.45)}
54.ed-hist__panel{position:absolute;top:0;bottom:0;right:0;width:min(420px,calc(100vw - 56px));background:white;box-shadow:var(--va-shadow-xl);display:flex;flex-direction:column;animation:edSlideR .22s var(--va-ease-emphasized)}
55@keyframes edSlideR{from{transform:translateX(100%)}to{transform:translateX(0)}}
56.ed-hist__head{display:flex;align-items:center;gap:14px;padding:18px 22px 16px;border-bottom:1px solid var(--va-neutral-200);flex-shrink:0}
57.ed-hist__close{width:32px;height:32px;border:none;background:transparent;color:var(--va-brand-blue);border-radius:var(--va-radius-sm);display:flex;align-items:center;justify-content:center;cursor:pointer}
58.ed-hist__close:hover{background:var(--va-brand-blue-50)}
59.ed-hist__close svg{width:20px;height:20px;stroke:currentColor;stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round}
60.ed-hist__title{margin:0;font-size:18px;font-weight:600;color:var(--va-brand-blue)}
61.ed-hist__search{display:flex;gap:10px;padding:16px 22px;flex-shrink:0}
62.ed-hist__search .va-input{height:40px}
63.ed-hist__search .va-btn{height:40px;padding:0 22px}
64.ed-hist__body{flex:1;overflow-y:auto;padding:0 22px 24px}
65.ed-hist__empty{padding:8px 0 24px;text-align:center;font-size:13px;color:var(--va-brand-blue)}
66.ed-hist__item{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--va-neutral-100)}
67.ed-hist__thumb{width:56px;height:56px;flex:0 0 56px;border-radius:var(--va-radius-sm);border:1px solid var(--va-neutral-200);object-fit:cover;cursor:pointer}
68.ed-hist__meta{flex:1;min-width:0}
69.ed-hist__user{font-size:13px;font-weight:500;color:var(--va-neutral-800);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
70.ed-hist__date{font-size:12px;color:var(--va-neutral-500)}
71.ed-modal{position:fixed;inset:0;z-index:90;display:none}
72.ed-modal[aria-hidden="false"]{display:flex;align-items:center;justify-content:center;padding:32px}
73.ed-modal__backdrop{position:absolute;inset:0;background:rgba(15,23,42,.45)}
74.ed-modal__dialog{position:relative;background:white;border-radius:var(--va-radius-lg);box-shadow:var(--va-shadow-xl);width:min(720px,100%);max-height:min(640px,100%);display:flex;flex-direction:column;animation:edPop .18s var(--va-ease-emphasized)}
75@keyframes edPop{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
76.ed-modal__head{display:flex;align-items:center;gap:12px;padding:20px 24px 14px;border-bottom:1px solid var(--va-neutral-200)}
77.ed-modal__title{margin:0;font-size:16px;font-weight:600;color:var(--va-brand-blue);flex:1}
78.ed-modal__x{width:32px;height:32px;border:none;background:transparent;color:var(--va-neutral-700);border-radius:var(--va-radius-sm);display:flex;align-items:center;justify-content:center;cursor:pointer}
79.ed-modal__x:hover{background:var(--va-neutral-100)}
80.ed-modal__x svg{width:20px;height:20px;stroke:currentColor;stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round}
81.ed-modal__bar{display:flex;align-items:center;gap:12px;padding:16px 24px 6px;font-size:14px;color:var(--va-neutral-700)}
82.ed-modal__back{width:32px;height:32px;border:1px solid var(--va-neutral-300);border-radius:var(--va-radius-sm);background:white;display:flex;align-items:center;justify-content:center;color:var(--va-neutral-600);cursor:pointer}
83.ed-modal__back:hover{background:var(--va-neutral-50)}
84.ed-modal__body{padding:14px 24px 20px;overflow-y:auto;flex:1;min-height:0}
85.ed-modal__foot{display:flex;justify-content:center;gap:12px;padding:14px 24px 22px;border-top:1px solid var(--va-neutral-200)}
86.ed-modal__foot .va-btn{min-width:150px;height:40px}
87.ed-picks{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
88.ed-pick{border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);background:white;padding:10px;cursor:pointer;font-family:inherit;transition:border-color var(--va-dur-1),box-shadow var(--va-dur-1)}
89.ed-pick:hover{border-color:var(--va-brand-blue-100)}
90.ed-pick.is-selected{border-color:var(--va-brand-blue);box-shadow:0 0 0 1px var(--va-brand-blue)}
91.ed-pick__thumb{aspect-ratio:1/1;border-radius:var(--va-radius-sm);background:var(--va-neutral-100);display:flex;align-items:center;justify-content:center;overflow:hidden}
92.ed-pick__thumb img{width:100%;height:100%;object-fit:cover}
93.ed-pick__tag{font-size:11px;letter-spacing:.03em;text-transform:uppercase;color:var(--va-neutral-500)}
94.ed-pick__name{display:block;margin-top:8px;font-size:12px;color:var(--va-neutral-700);text-align:left;line-height:1.4}
95.ed-prodsearch{display:flex;gap:0;padding:6px 24px 4px}
96.ed-prodsearch .va-input{height:42px;border-top-right-radius:0;border-bottom-right-radius:0;flex:1}
97.ed-prodsearch .va-btn{height:42px;padding:0 28px;border-top-left-radius:0;border-bottom-left-radius:0}
98.ed-pager{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0 24px;padding:10px 16px;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);font-size:13px;color:var(--va-neutral-600)}
99.ed-pager__nav{display:flex;gap:6px}
100.ed-pager__btn{min-width:28px;height:28px;padding:0 6px;border:none;background:none;border-radius:var(--va-radius-sm);font-family:inherit;font-size:13px;color:var(--va-brand-blue);cursor:pointer}
101.ed-pager__btn:hover{background:var(--va-brand-blue-50)}
102.ed-pager__btn.is-current{background:var(--va-brand-blue-50);color:var(--va-neutral-700);font-weight:600}
103.ed-pager__btn:disabled{opacity:.4;cursor:default}
104.ed-prods{display:flex;flex-direction:column;gap:10px}
105.ed-prod{display:flex;align-items:center;gap:14px;border:1px solid var(--va-neutral-200);border-radius:var(--va-radius-md);background:white;padding:10px 14px;cursor:pointer;font-family:inherit;text-align:left;transition:border-color var(--va-dur-1),background var(--va-dur-1)}
106.ed-prod:hover{border-color:var(--va-brand-blue-100);background:var(--va-brand-blue-50)}
107.ed-prod.is-selected{border-color:var(--va-brand-blue);box-shadow:0 0 0 1px var(--va-brand-blue)}
108.ed-prod__thumb{width:52px;height:52px;flex:0 0 52px;border-radius:var(--va-radius-sm);background:var(--va-neutral-100);display:flex;align-items:center;justify-content:center;overflow:hidden}
109.ed-prod__thumb img{width:100%;height:100%;object-fit:cover}
110.ed-prod__name{display:block;font-size:13px;font-weight:500;color:var(--va-neutral-800)}
111.ed-prod__sku{display:block;font-size:12px;color:var(--va-neutral-500);margin-top:2px}
112.ed-drop{border:1.5px dashed var(--va-brand-blue-100);border-radius:var(--va-radius-md);background:var(--va-brand-blue-50);padding:38px 24px;display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;color:var(--va-neutral-600);cursor:pointer}
113.ed-drop svg{width:38px;height:38px;stroke:var(--va-brand-blue);stroke-width:1.4;fill:none;stroke-linecap:round;stroke-linejoin:round}
114.ed-drop__hint{font-size:12px;color:var(--va-neutral-500)}
115@media (max-width:1100px){.ed-work{flex-direction:column}.ed-side{width:100%;flex:none;border-right:none;border-bottom:1px solid var(--va-neutral-200)}}
116`;function re(){return e.jsxs("svg",{viewBox:"0 0 24 24",style:{width:22,height:22,stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}function z(){return e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}function Le(r,i){if(i<=3)return Array.from({length:i},(A,B)=>B+1);const s=[1];return r>2&&s.push("…"),r!==1&&r!==i&&s.push(r),r<i-1&&s.push("…"),s.push(i),s}
116function Me({urlParams:r}){Ie("Editor IA"),we("/editor-ia");const i=ke(),s=Ne(),A=r==null?void 0:r.productId,B=r==null?void 0:r.pictureId,[p,d]=n.useState(null),[m,D]=n.useState(!1),[S,L]=n.useState(!1),[I,F]=n.useState(null),[M,h]=n.useState(!1),[o,ne]=n.useState(A),[b,E]=n.useState(B),[ie,K]=n.useState(""),[w,v]=n.useState(null),[U,O]=n.useState(""),[se,R]=n.useState(""),[k,g]=n.useState(1),[N,G]=n.useState(null),[oe,de]=n.useState(""),[C,Q]=n.useState(null),[$,V]=n.useState(null),[le,J]=n.useState("JPG o PNG · máximo 5 MB · mínimo 800 × 800 px"),[q,ce]=n.useState(""),[pe,X]=n.useState(""),{data:_}=Fe(o,b);n.useEffect(()=>{_&&(_.productTitle&&K(_.productTitle),_.imageUrl&&v(_.imageUrl))},[_]),n.useEffect(()=>{i({search:{productId:o,pictureId:b},replace:!0})},[o,b]),n.useEffect(()=>{A||d("prod")},[]),n.useEffect(()=>{if(!p)return;const a=t=>{t.key==="Escape"&&d(null)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[p]);const{data:u,isFetching:ue}=Ae(se,k),[xe,H]=n.useState(o),{data:x,isFetching:Y}=Ee(p==="img"?xe:void 0),me=Pe(),W=ze(),{data:f,isFetching:T,refetch:Z}=Be(p==="hist"?o:void 0,pe);function he(){window.history.back()}const be=M||!o||!b||!(m||S&&I!==null);async function ve(){if(!o||!b)return;const a=m?"removeBackground":"generateImage",t=!m&&I!==null?ae[I].url:void 0;h(!0);const l=await me.mutateAsync({type:a,productId:o,pictureId:b,modelUrl:t});l.status==="success"?s.success(l.message):(s.error(l.message),h(!1))}const ee=n.useRef(W);ee.current=W,n.useEffect(()=>Ce(async a=>{if(a.topic!=="generacion-imagenes")return;const t=a.productoId??a.product_id;if(o&&t!==void 0&&t!==o)return;const l=a.value??null;if(v(l),h(!1),o&&l)try{const j=await ee.current.mutateAsync({productId:o,url:l});j.id&&E(j.id)}catch{}}),[o]);function ge(a,t){G(a),de(t)}function _e(){N&&(ne(N),K(oe),H(N),E(void 0),v(null),h(!1),D(!1),L(!1),F(null),d("img"))}function fe(){if(!C)return;const a=x==null?void 0:x.find(t=>t.imagenId===C);a&&v(a.url??a.thumbnailUrl??null),E(C),h(!1),d(null)}function je(a){var l;const t=(l=a.target.files)==null?void 0:l[0];t&&(V(t),J(t.name))}async function ye(){if(!w){s.error("No hay imagen para descargar");return}try{const t=await fetch(`/api/ai/image-editor/download?imageUrl=${encodeURIComponent(w)}`,{credentials:"include"});if(!t.ok)throw new Error(t.statusText);const l=await t.blob(),j=URL.createObjectURL(l),c=document.createElement("a");c.href=j,c.download=`imagen_IA_${Date.now()}.jpg`,c.click(),URL.revokeObjectURL(j)}catch{s.error("Error al descargar la imagen.")}}return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:De}),e.jsxs("div",{className:"ed-shell",children:[e.jsxs("div",{className:"ed-titlebar",children:[e.jsx("button",{type:"button",className:"ed-titlebar__back",onClick:he,"aria-label":"Volver",children:e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]})}),e.jsxs("div",{className:"ed-titlebar__text",children:[e.jsx("h1",{className:"ed-titlebar__title",children:ie||"Editar con IA"}),o&&e.jsx("button",{type:"button",className:"ed-titlebar__sub",onClick:()=>d("hist"),children:"Últimas Actualizaciones"})]}),e.jsxs("button",{className:"va-btn va-btn--secondary",type:"button",onClick:ye,disabled:!w,children:[e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),"Descargar"]})]}),e.jsxs("div",{className:"ed-work",children:[e.jsxs("aside",{className:"ed-side",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"ed-side__title",children:"Herramientas IA"}),e.jsx("p",{className:"ed-side__sub",children:"Edita tu imagen con inteligencia artificial"})]}),e.jsxs("button",{type:"button",className:`ed-tool${m?" is-active":""}`,"aria-pressed":m,onClick:()=>{D(a=>!a),m||(L(!1),F(null))},children:[e.jsx("span",{className:"ed-tool__icon",children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"}),e.jsx("path",{d:"M22 21H7"}),e.jsx("path",{d:"m5 11 9 9"})]})}),e.jsxs("span",{children:[e.jsx("span",{className:"ed-tool__name",children:"Remover fondo"}),e.jsx("span",{className:"ed-tool__desc",children:"Elimina el fondo de tu imagen"})]})]}),e.jsxs("div",{className:`ed-tool${S?" is-active":""}`,children:[e.jsx("span",{className:"ed-tool__icon",children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z"})})}),e.jsx("span",{className:"ed-tool__name",children:"Esta imagen es una prenda"}),e.jsx("span",{className:"ed-tool__spacer"}),e.jsx("input",{type:"checkbox",className:"va-toggle va-toggle--lg",checked:S,onChange:a=>{L(a.target.checked),a.target.checked||F(null),D(!1)},"aria-label":"Esta imagen es una prenda"})]}),S&&e.jsxs("div",{className:"ed-panel",children:[e.jsx("div",{className:"ed-panel__title",children:"Selecciona el modelo"}),e.jsx("p",{className:"ed-panel__sub",children:"Elige un modelo para vestirlo con tu prenda"}),e.jsx("div",{className:"ed-models",children:ae.map((a,t)=>e.jsxs("button",{type:"button",className:`ed-model${I===t?" is-selected":""}`,onClick:()=>
116F(t),children:[e.jsx("span",{className:"ed-model__thumb",children:e.jsx("img",{src:a.url,alt:a.nombre,loading:"lazy"})}),e.jsx("span",{className:"ed-model__name",children:a.nombre})]},t))})]}),e.jsxs("div",{className:"ed-actions",children:[e.jsxs("button",{className:"va-btn va-btn--secondary",type:"button",onClick:()=>{O(""),R(""),g(1),G(null),d("prod")},children:[e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),"Seleccionar producto"]}),e.jsxs("button",{className:"va-btn va-btn--secondary",type:"button",onClick:()=>d("upload"),children:[e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),"Subir imagen"]}),o&&e.jsx("button",{className:"va-btn va-btn--secondary",type:"button",onClick:()=>{H(o),Q(null),d("img")},children:"Cambiar imagen"})]}),e.jsxs("button",{className:"va-btn va-btn--primary ed-apply",type:"button",disabled:be,onClick:ve,children:[e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}),e.jsx("path",{d:"M20 3v4"}),e.jsx("path",{d:"M22 5h-4"}),e.jsx("path",{d:"M4 17v2"}),e.jsx("path",{d:"M5 18H3"})]}),M?"Procesando…":"Aplicar cambios"]})]}),e.jsx("section",{className:"ed-canvas",children:e.jsxs("div",{className:"ed-canvas__frame",children:[w?e.jsx("img",{src:w,alt:"Imagen seleccionada"}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),e.jsx("span",{className:"ed-canvas__label",children:"Selecciona un producto e imagen"})]}),M&&e.jsxs("div",{className:"ed-canvas__busy",children:[e.jsx("div",{className:"ed-canvas__spinner"}),"Procesando con IA…"]})]})})]})]}),e.jsxs("div",{className:"ed-hist","aria-hidden":p==="hist"?"false":"true",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"ed-hist__backdrop",onClick:()=>d(null)}),e.jsxs("aside",{className:"ed-hist__panel",children:[e.jsxs("header",{className:"ed-hist__head",children:[e.jsx("button",{type:"button",className:"ed-hist__close",onClick:()=>d(null),"aria-label":"Cerrar",children:e.jsx(z,{})}),e.jsx("h2",{className:"ed-hist__title",children:"Historial de Imágenes"})]}),e.jsxs("div",{className:"ed-hist__search",children:[e.jsx("input",{className:"va-input",type:"search",placeholder:"Buscar por usuario…",value:q,onChange:a=>ce(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(X(q),Z())}}),e.jsx("button",{className:"va-btn va-btn--primary",type:"button",onClick:()=>{X(q),Z()},children:"Buscar"})]}),e.jsxs("div",{className:"ed-hist__body",children:[T&&e.jsx("p",{className:"ed-hist__empty",children:"Cargando…"}),!T&&(f==null?void 0:f.isEmpty)&&e.jsx("p",{className:"ed-hist__empty",children:"No hay actualizaciones."}),!T&&(f==null?void 0:f.items.map((a,t)=>e.jsxs("div",{className:"ed-hist__item",children:[e.jsx("img",{className:"ed-hist__thumb",src:a.imageUrl,alt:"",onClick:()=>{v(a.imageUrl),d(null)}}),e.jsxs("div",{className:"ed-hist__meta",children:[e.jsx("div",{className:"ed-hist__user",children:a.user}),e.jsx("div",{className:"ed-hist__date",children:a.date})]})]},t)))]})]})]}),e.jsxs("div",{className:"ed-modal","aria-hidden":p==="prod"?"false":"true",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"ed-modal__backdrop",onClick:()=>{o&&d(null)}}),e.jsxs("div",{className:"ed-modal__dialog",children:[e.jsxs("header",{className:"ed-modal__head",children:[e.jsx("h2",{className:"ed-modal__title",children:"Seleccionar Producto"}),o&&e.jsx("button",{type:"button",className:"ed-modal__x",onClick:()=>d(null),"aria-label":"Cerrar",children:e.jsx(z,{})})]}),e.jsx("div",{className:"ed-modal__bar",children:"Busca el producto con el que deseas trabajar"}),e.jsxs("div",{className:"ed-prodsearch",children:[e.jsx("input",{className:"va-input",type:"search",placeholder:"Nombre o SKU…",value:U,onChange:a=>O(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(R(U),g(1))}}),e.jsx("button",{className:"va-btn va-btn--primary",type:"button",onClick:()=>{R(U),g(1)},children:"Buscar"})]}),e.jsxs("div",{className:"ed-modal__body",children:[ue&&e.jsx("p",{style:{textAlign:"center",color:"var(--va-neutral-500)",fontSize:13},children:"Cargando…"}),e.jsx("div",{className:"ed-prods",children:u==null?void 0:u.items.map(a=>e.jsxs("button",{type:"button",className:`ed-prod${N===a.productoId?" is-selected":""}`,onClick:()=>ge(a.productoId,a.title??""),children:[e.jsx("span",{className:"ed-prod__thumb",children:a.urlThumb?e.jsx("img",{src:a.urlThumb,alt:""}):e.jsx(re,{})}),e.jsxs("span",{children:[e.jsx("span",{className:"ed-prod__name",children:a.title}),e.jsx("span",{className:"ed-prod__sku",children:a.sku})]})]},a.productoId))})]}),u&&u.pages>1&&e.jsxs("div",{className:"ed-pager",children:[e.jsxs("span",{children:[u.total," productos"]}),e.jsxs("div",{className:"ed-pager__nav",children:[e.jsx("button",{type:"button",className:"ed-pager__btn",disabled:k<=1,onClick:()=>g(a=>a-1),children:"‹"}),Le(k,u.pages).map((a,t)=>a==="…"?e.jsx("span",{style:{padding:"0 2px",color:"var(--va-neutral-400)",fontSize:13},children:"…"},`e${t}`):e.jsx("button",{type:"button",className:`ed-pager__btn${a===k?" is-current":""}`,onClick:()=>g(a),children:a},a)),e.jsx("button",{type:"button",className:"ed-pager__btn",disabled:k>=u.pages,onClick:()=>g(a=>a+1),children:"›"})]})]}),e.jsx("div",{className:"ed-modal__foot",children:e.jsx("button",{className:"va-btn va-btn--primary",type:"button",disabled:!N,onClick:_e,children:"Seleccionar"})})]})]}),e.jsxs("div",{className:"ed-modal","aria-hidden":p==="img"?"false":"true",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"ed-modal__backdrop",onClick:()=>d(null)}),e.jsxs("div",{className:"ed-modal__dialog",children:[e.jsxs("header",{className:"ed-modal__head",children:[e.jsx("h2",{className:"ed-modal__title",children:"Seleccione una imagen"}),e.jsx("button",{type:"button",className:"ed-modal__x",onClick:()=>d(null),"aria-label":"Cerrar",children:e.jsx(z,{})})]}),e.jsxs("div",{className:"ed-modal__bar",children:[e.jsx("button",{type:"button",className:"ed-modal__back",onClick:()=>d("prod"),"aria-label":"Volver a productos",children:e.jsxs("svg",{className:"icn",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m12 19-7-7 7-7"}),e.jsx("path",{d:"M19 12H5"})]})}),"Selecciona la imagen con la que deseas trabajar"]}),e.jsxs("div",{className:"ed-modal__body",children:[Y&&e.jsx("p",{style:{textAlign:"center",color:"var(--va-neutral-500)",fontSize:13},children:"Cargando imágenes…"}),e.jsxs("div",{className:"ed-picks",children:[(x??[]).map((a,t)=>e.jsxs("button",{type:"button",className:`ed-pick${C===a.imagenId?" is-selected":""}`,onClick:()=>Q(a.imagenId),children:[e.jsx("span",{className:"ed-pick__thumb",children:a.thumbnailUrl||a.url?e.jsx("img",{src:a.thumbnailUrl??a.url??"",alt:""}):e.jsx(re,{})}),e.jsxs("span",{className:"ed-pick__name",children:["Imagen ",t+1]})]},a.imagenId)),!Y&&(x==null?void 0:x.length)===0&&e.jsx("p",{style:{gridColumn:"1/-1",textAlign:"center",fontSize:13,color:"var(--va-neutral-500)"},children:"Este producto no tiene imágenes. Sube una."})]})]}),e.jsxs("div",{className:"ed-modal__foot",children:[e.jsx("button",{className:"va-btn va-btn--secondary",type:"button",onClick:()=>d("upload"),children:"Subir Imagen"}),e.jsx("button",{className:"va-btn va-btn--primary",type:"button",disabled:!C,onClick:fe,children:"Seleccionar"})]})]})]}),e.jsxs("div",{className:"ed-modal","aria-hidden":p==="upload"?"false":"true",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"ed-modal__backdrop",onClick:()=>d(null)}),e.jsxs("div",{className:"ed-modal__dialog",style:{width:"min(520px,100%)"},children:[e.jsxs("header",{className:"ed-modal__head",children:[e.jsx("h2",{className:"ed-modal__title",children:"Subir imagen"}),e.jsx("button",{type:"button",className:"ed-modal__x",onClick:()=>d(null),"aria-label":"Cerrar",children:e.jsx(z,{})})]}),e.jsx("div",{className:"ed-modal__body",children:e.jsxs("label",{className:"ed-drop",children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",x2:"12",y1:"3",y2:"15"})]}),e.jsxs("div",{children:["Arrastra tu imagen aquí o ",e.jsx("span",{style:{color:"var(--va-brand-blue)"},children:"búscala en tu equipo"})]}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg",hidden:!0,onChange:je}),e.jsx("div",{className:"ed-drop__hint",children:le})]})}),e.jsxs("div",{className:"ed-modal__foot",children:[e.jsx("button",{className:"va-btn va-btn--tertiary",type:"button",onClick:()=>d(null),children:"Cancelar"}),e.jsx("button",{className:"va-btn va-btn--primary",type:"button",disabled:!$||!o,onClick:async()=>
116{if(!(!$||!o))try{const a="/api",t=new FormData;t.append("file",$);const l=await fetch(`${a}/productos/${o}/imagen`,{method:"POST",body:t,credentials:"include"});if(!l.ok)throw new Error(l.statusText);const c=(await l.json()).imagen;c!=null&&c.url&&(v(c.url),E(c.imagenId),H(o),h(!1)),V(null),J("JPG o PNG · máximo 5 MB · mínimo 800 × 800 px"),d(null),s.success("Imagen subida correctamente")}catch{s.error("Error al subir la imagen")}},children:"Subir"})]})]})]})]})}const $e=function(){const i=Se.useSearch();return e.jsx(Me,{urlParams:i})};export{$e as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.