PageSourceSearch

https://trendresell.com/assets/VenteStockPage-D7-Jco5O.js

js trendresell.com collected 2026-10-02 01:48:04 UTC 78,956 bytes, 3 lines download raw bytes

1import{j as e}from"./framer-C6n3ICkC.js";import{r as a}from"./sentry-DnK0TUx-.js";import{p as et,F as $,u as St,a2 as Yt,l as Oe,w as Ce,y as Ct,d as Qt,a9 as Xt,a8 as es,G as mt,b as xt,H as ts,r as pt}from"./index-BGWpaLpH.js";import{i as ss}from"./ArrowCounterClockwise.es-BzSjM8Y0.js";import{p as ht}from"./ArrowsDownUp.es-pGsLDlzW.js";import{s as as}from"./CaretLeft.es-BfPnQ7vO.js";import{s as rs}from"./CaretRight.es-Me-lhmzd.js";import{s as gt}from"./Download.es-DmO7tDU8.js";import{s as Ne}from"./FileText.es-DCER1LsZ.js";import{c as He,H as ls}from"./HowItWorksButton-RvEX0a7i.js";import{a as ft}from"./PencilSimple.es-D50XoNS0.js";import{n as bt}from"./Plus.es-4uypyryg.js";import{m as ns}from"./ShoppingBag.es-BAd8t_-b.js";import{n as yt}from"./Trash.es-CKoelzJA.js";import{c as cs}from"./TrendUp.es-BFX0QsjT.js";import{s as vt}from"./Upload.es-aHM_-BCe.js";import{S as is}from"./SEO-CEGXMWYc.js";import{D as V}from"./Dropdown-BLx_feCq.js";import"./recharts-wAJvnJnG.js";const os=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M222.14,69.17,186.83,33.86A19.86,19.86,0,0,0,172.69,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V83.31A19.86,19.86,0,0,0,222.14,69.17ZM164,204H92V160h72Zm40,0H188V156a20,20,0,0,0-20-20H88a20,20,0,0,0-20,20v48H52V52H171l33,33ZM164,84a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h56A12,12,0,0,1,164,84Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,83.31V208a8,8,0,0,1-8,8H176V152a8,8,0,0,0-8-8H88a8,8,0,0,0-8,8v64H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H172.69a8,8,0,0,1,5.65,2.34l35.32,35.32A8,8,0,0,1,216,83.31Z",opacity:"0.2"}),a.createElement("path",{d:"M219.31,72,184,36.69A15.86,15.86,0,0,0,172.69,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V83.31A15.86,15.86,0,0,0,219.31,72ZM168,208H88V152h80Zm40,0H184V152a16,16,0,0,0-16-16H88a16,16,0,0,0-16,16v56H48V48H172.69L208,83.31ZM160,72a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h56A8,8,0,0,1,160,72Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M219.31,72,184,36.69A15.86,15.86,0,0,0,172.69,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V83.31A15.86,15.86,0,0,0,219.31,72ZM208,208H184V152a16,16,0,0,0-16-16H88a16,16,0,0,0-16,16v56H48V48H172.69L208,83.31ZM160,72a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h56A8,8,0,0,1,160,72Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M217.9,73.42,182.58,38.1a13.9,13.9,0,0,0-9.89-4.1H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V83.31A13.9,13.9,0,0,0,217.9,73.42ZM170,210H86V152a2,2,0,0,1,2-2h80a2,2,0,0,1,2,2Zm40-2a2,2,0,0,1-2,2H182V152a14,14,0,0,0-14-14H88a14,14,0,0,0-14,14v58H48a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H172.69a2,2,0,0,1,1.41.58L209.42,81.9a2,2,0,0,1,.58,1.41ZM158,72a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h56A6,6,0,0,1,158,72Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M219.31,72,184,36.69A15.86,15.86,0,0,0,172.69,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V83.31A15.86,15.86,0,0,0,219.31,72ZM168,208H88V152h80Zm40,0H184V152a16,16,0,0,0-16-16H88a16,16,0,0,0-16,16v56H48V48H172.69L208,83.31ZM160,72a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h56A8,8,0,0,1,160,72Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,74.83,181.17,39.51A11.93,11.93,0,0,0,172.69,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V83.31A11.93,11.93,0,0,0,216.49,74.83ZM172,212H84V152a4,4,0,0,1,4-4h80a4,4,0,0,1,4,4Zm40-4a4,4,0,0,1-4,4H180V152a12,12,0,0,0-12-12H88a12,12,0,0,0-12,12v60H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H172.69a4,4,0,0,1,2.82,1.17l35.32,35.32A4,4,0,0,1,212,83.31ZM156,72a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h56A4,4,0,0,1,156,72Z"}))]]),ds=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,84H180.2l7.61-41.85a12,12,0,0,0-23.62-4.3L155.8,84H116.2l7.61-41.85a12,12,0,1,0-23.62-4.3L91.8,84H48a12,12,0,0,0,0,24H87.44l-7.27,40H32a12,12,0,0,0,0,24H75.8l-7.61,41.85a12,12,0,0,0,9.66,14A11.43,11.43,0,0,0,80,228a12,12,0,0,0,11.8-9.86L100.2,172h39.6l-7.61,41.85a12,12,0,0,0,9.66,14,11.43,11.43,0,0,0,2.16.2,12,12,0,0,0,11.8-9.86L164.2,172H208a12,12,0,0,0,0-24H168.56l7.27-40H224a12,12,0,0,0,0-24Zm-79.83,64H104.56l7.27-40h39.61Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M165.82,96l-11.64,64h-64l11.64-64Z",opacity:"0.2"}),a.createElement("path",{d:"M224,88H175.4l8.47-46.57a8,8,0,0,0-15.74-2.86l-9,49.43H111.4l8.47-46.57a8,8,0,0,0-15.74-2.86L95.14,88H48a8,8,0,0,0,0,16H92.23L83.5,152H32a8,8,0,0,0,0,16H80.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,80,224a8,8,0,0,0,7.86-6.57l9-49.43H144.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,144,224a8,8,0,0,0,7.86-6.57l9-49.43H208a8,8,0,0,0,0-16H163.77l8.73-48H224a8,8,0,0,0,0-16Zm-76.5,64H99.77l8.73-48h47.73Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M116.25,112h31.5l-8,32h-31.5ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Zm-16,56a8,8,0,0,0-8-8H168.25l7.51-30.06a8,8,0,0,0-15.52-3.88L151.75,96h-31.5l7.51-30.06a8,8,0,0,0-15.52-3.88L103.75,96H64a8,8,0,0,0,0,16H99.75l-8,32H56a8,8,0,0,0,0,16H87.75l-7.51,30.06a8,8,0,0,0,5.82,9.7,8.13,8.13,0,0,0,2,.24,8,8,0,0,0,7.75-6.06L104.25,160h31.5l-7.51,30.06a8,8,0,0,0,5.82,9.7A8.13,8.13,0,0,0,136,200a8,8,0,0,0,7.75-6.06L152.25,160H192a8,8,0,0,0,0-16H156.25l8-32H200A8,8,0,0,0,208,104Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,90H173l8.89-48.93a6,6,0,1,0-11.8-2.14L160.81,90H109l8.89-48.93a6,6,0,0,0-11.8-2.14L96.81,90H48a6,6,0,0,0,0,12H94.63l-9.46,52H32a6,6,0,0,0,0,12H83L74.1,214.93a6,6,0,0,0,4.83,7A5.64,5.64,0,0,0,80,222a6,6,0,0,0,5.89-4.93L95.19,166H147l-8.89,48.93a6,6,0,0,0,4.83,7,5.64,5.64,0,0,0,1.08.1,6,6,0,0,0,5.89-4.93L159.19,166H208a6,6,0,0,0,0-12H161.37l9.46-52H224a6,6,0,0,0,0-12Zm-74.83,64H97.37l9.46-52h51.8Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,88H175.4l8.47-46.57a8,8,0,0,0-15.74-2.86l-9,49.43H111.4l8.47-46.57a8,8,0,0,0-15.74-2.86L95.14,88H48a8,8,0,0,0,0,16H92.23L83.5,152H32a8,8,0,0,0,0,16H80.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,80,224a8,8,0,0,0,7.86-6.57l9-49.43H144.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,144,224a8,8,0,0,0,7.86-6.57l9-49.43H208a8,8,0,0,0,0-16H163.77l8.73-48H224a8,8,0,0,0,0-16Zm-76.5,64H99.77l8.73-48h47.73Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,92H170.61l9.33-51.28a4,4,0,1,0-7.88-1.44L162.48,92H106.61l9.33-51.28a4,4,0,1,0-7.88-1.44L98.48,92H48a4,4,0,0,0,0,8H97L86.84,156H32a4,4,0,0,0,0,8H85.39l-9.33,51.28a4,4,0,0,0,3.22,4.65A3.65,3.65,0,0,0,80,220a4,4,0,0,0,3.94-3.29L93.52,164h55.87l-9.33,51.28a4,4,0,0,0,3.22,4.65,3.65,3.65,0,0,0,.72.07,4,4,0,0,0,3.94-3.29L157.52,164H208a4,4,0,0,0,0-8H159l10.19-56H224a4,4,0,0,0,0-8Zm-73.16,64H95l10.19-56H161Z"}))]]),us=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M228,40V80a12,12,0,0,1-24,0V52H176a12,12,0,0,1,0-24h40A12,12,0,0,1,228,40ZM80,204H52V176a12,12,0,0,0-24,0v40a12,12,0,0,0,12,12H80a12,12,0,0,0,0-24Zm136-40a12,12,0,0,0-12,12v28H176a12,12,0,0,0,0,24h40a12,12,0,0,0,12-12V176A12,12,0,0,0,216,164ZM40,92A12,12,0,0,0,52,80V52H80a12,12,0,0,0,0-24H40A12,12,0,0,0,28,40V80A12,12,0,0,0,40,92ZM84,72h88a12,12,0,0,1,12,12v88a12,12,0,0,1-12,12H84a12,12,0,0,1-12-12V84A12,12,0,0,1,84,72Zm12,88h64V96H96Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M176,80v96H80V80Z",opacity:"0.2"}),a.createElement("path",{d:"M224,40V80a8,8,0,0,1-16,0V48H176a8,8,0,0,1,0-16h40A8,8,0,0,1,224,40ZM80,208H48V176a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H80a8,8,0,0,0,0-16Zm136-40a8,8,0,0,0-8,8v32H176a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V176A8,8,0,0,0,216,168ZM40,88a8,8,0,0,0,8-8V48H80a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8V80A8,8,0,0,0,40,88ZM80,72h96a8,8,0,0,1,8,8v96a8,8,0,0,1-8,8H80a8,8,0,0,1-8-8V80A8,8,0,0,1,80,72Zm8,96h80V88H88Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,40V80a8,8,0,0,1-16,0V48H176a8,8,0,0,1,0-16h40A8,8,0,0,1,224,40ZM80,208H48V176a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H80a8,8,0,0,0,0-16Zm136-40a8,8,0,0,0-8,8v32H176a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V176A8,8,0,0,0,216,168ZM40,88a8,8,0,0,0,8-8V48H80a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8V80A8,8,0,0,0,40,88Zm32-8v96a8,8,0,0,0,8,8h96a8,8,0,0,0,8-8V80a8,8,0,0,0-8-8H80A8,8,0,0,0,72,80Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M222,40V80a6,6,0,0,1-12,0V46H176a6,6,0,0,1,0-12h40A6,6,0,0,1,222,40ZM80,210H46V176a6,6,0,0,0-12,0v40a6,6,0,0,0,6,6H80a6,6,0,0,0,0-12Zm136-40a6,6,0,0,0-6,6v34H176a6,6,0,0,0,0,12h40a6,6,0,0,0,6-6V176A6,6,0,0,0,216,170ZM40,86a6,6,0,0,0,6-6V46H80a6,6,0,0,0,0-12H40a6,6,0,0,0-6,6V80A6,6,0,0,0,40,86ZM80,74h96a6,6,0,0,1,6,6v96a6,6,0,0,1-6,6H80a6,6,0,0,1-6-6V80A6,6,0,0,1,80,74Zm6,96h84V86H86Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,40V80a8,8,0,0,1-16,0V48H176a8,8,0,0,1,0-16h40A8,8,0,0,1,224,40ZM80,208H48V176a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H80a8,8,0,0,0,0-16Zm136-40a8,8,0,0,0-8,8v32H176a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V176A8,8,0,0,0,216,168ZM40,88a8,8,0,0,0,8-8V48H80a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8V80A8,8,0,0,0,40,88ZM80,72h96a8,8,0,0,1,8,8v96a8,8,0,0,1-8,8H80a8,8,0,0,1-8-8V80A8,8,0,0,1,80,72Zm8,96h80V88H88Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M220,40V80a4,4,0,0,1-8,0V44H176a4,4,0,0,1,0-8h40A4,4,0,0,1,220,40ZM80,212H44V176a4,4,0,0,0-8,0v40a4,4,0,0,0,4,4H80a4,4,0,0,0,0-8Zm136-40a4,4,0,0,0-4,4v36H176a4,4,0,0,0,0,8h40a4,4,0,0,0,4-4V176A4,4,0,0,0,216,172ZM40,84a4,4,0,0,0,4-4V44H80a4,4,0,0,0,0-8H40a4,4,0,0,0-4,4V80A4,4,0,0,0,40,84Zm40-8h96a4,4,0,0,1,4,4v96a4,4,0,0,1-4,4H80a4,4,0,0,1-4-4V80A4,4,0,0,1,80,76Zm4,96h88V84H84Z"}))]]),Ht=a.forwardRef((s,o)=>a.createElement(et,{ref:o,...s,weights:os}));Ht.displayName="FloppyDiskIcon";const ms=Ht,Pt=a.forwardRef((s,o)=>a.createElement(et,{ref:o,...s,weights:ds}));Pt.displayName="HashIcon";const xs=Pt,Mt=a.forwardRef((s,o)=>a.createElement(et,{ref:o,...s,weights:us}));Mt.displayName="ScanIcon";const jt=Mt,ps=/#([A-Za-z0-9_-]+)/g;
1function Nt(s){if(!s||typeof s!="string")return[];const o=[];for(const l of s.matchAll(ps))l[1]&&o.push(l[1]);return o}function Le(s,o){return s.length?o==="last"?s[s.length-1]:s[0]:null}function hs(s,o){const l=(o==null?void 0:o.detection_source)||"title",g=(o==null?void 0:o.hashtag_order)||"first",w=(s==null?void 0:s.title)||"",k=(s==null?void 0:s.description)||"",p=Nt(w),u=Nt(k);let v=null,f=null;l==="title"?(v=Le(p,g),v&&(f="title")):l==="description"?(v=Le(u,g),v&&(f="description")):(v=Le(p,g),v?f="title":(v=Le(u,g),v&&(f="description")));const h=new Set,x=[];for(const d of[...p,...u])h.has(d)||(h.add(d),x.push(d));return{sku:v,sku_source:f,hashtags:x}}const we="https://api.trendresell.com",gs="trendresell_stock",Ke="trendresell_stock_migrated",ke=s=>s===""||s==null||Number.isNaN(Number(s))?0:Number(s);function fs(s){return{id:String(s.id),title:s.name||"",sku:s.sku||"",purchasePrice:s.unit_cost!=null?String(s.unit_cost):"",estimatedSellPrice:s.estimated_price!=null?String(s.estimated_price):"",quantity:s.quantity??0,source:s.source||"Manual",status:s.status||"en_stock",notes:s.notes||"",photoUrl:s.image_url||"",supplier:s.supplier||"",tvaRegime:s.vat_regime||"marge",purchaseDate:s.purchase_date||"",createdAt:s.created_at||new Date().toISOString(),sharedSku:s.is_shared_sku!==!1}}function Ye(s){const o=ke(s.quantity),l=ke(s.purchasePrice);return{sku:s.sku||"",name:s.title||"",quantity:o,unit_cost:l,total_cost:s.totalCost!=null?ke(s.totalCost):l*o,estimated_price:s.estimatedSellPrice===""||s.estimatedSellPrice==null?null:ke(s.estimatedSellPrice),is_shared_sku:s.sharedSku!==!1,quantity_sold_external:ke(s.alreadySoldElsewhere),vat_regime:s.tvaRegime||"marge",status:s.status||"en_stock",source:s.source||"Manual",supplier:s.supplier||null,notes:s.notes||null,image_url:s.photoUrl||null,purchase_date:s.purchaseDate||null}}function bs(){const[s,o]=a.useState([]),[l,g]=a.useState(!0),[w,k]=a.useState(null),p=a.useCallback(async()=>{const d=await(await $(`${we}/api/vente/stock`,{signal:AbortSignal.timeout(15e3)})).json();if(d!=null&&d.success)o((d.data||[]).map(fs));else throw new Error((d==null?void 0:d.error)||"Chargement du stock impossible");return d},[]),u=a.useRef(!1);a.useEffect(()=>{u.current||(u.current=!0,(async()=>{g(!0);try{if(localStorage.getItem(Ke)!=="1"){let x=[];try{x=JSON.parse(localStorage.getItem(gs)||"[]")}catch{x=[]}if(Array.isArray(x)&&x.length){const d=x.map(q=>({...Ye(q),legacy_id:String(q.id)}));(await $(`${we}/api/vente/stock/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:d})})).ok&&localStorage.setItem(Ke,"1")}else localStorage.setItem(Ke,"1")}await p()}catch(x){k(x.message||String(x))}finally{g(!1)}})())},[p]);const v=a.useCallback(async x=>{var q;const d=Array.isArray(x)?x:[x];if(!d.length)return[];o(T=>[...T,...d]);const N=[];try{const T=await Promise.all(d.map(H=>$(`${we}/api/vente/stock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye(H))}).then(ce=>ce.json().catch(()=>null))));for(const H of T)H!=null&&H.success&&((q=H.data)==null?void 0:q.id)!=null&&N.push(String(H.data.id))}finally{await p().catch(()=>{})}return N},[p]),f=a.useCallback(async x=>{o(d=>d.map(N=>N.id===x.id?{...x}:N));try{await $(`${we}/api/vente/stock/${x.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye(x))})}finally{await p().catch(()=>{})}},[p]),h=a.useCallback(async x=>{o(d=>d.filter(N=>N.id!==x));try{await $(`${we}/api/vente/stock/${x}`,{method:"DELETE"})}finally{await p().catch(()=>{})}},[p]);return{items:s,setItems:o,loading:l,error:w,createItems:v,updateItem:f,deleteItem:h,reload:p}}const Qe="https://api.trendresell.com";function ys(){const[s,o]=a.useState([]),[l,g]=a.useState(!0),[w,k]=a.useState(null),p=a.useCallback(async()=>{try{const h=await(await $(`${Qe}/api/vente/suppliers`,{signal:AbortSignal.timeout(1e4)})).json();if(h!=null&&h.success)o(h.data||[]);else throw new Error((h==null?void 0:h.error)||"Chargement fournisseurs impossible")}catch(f){k(f.message||String(f))}},[]);a.useEffect(()=>{g(!0),p().finally(()=>g(!1))},[p]);const u=a.useCallback(async(f,h={})=>{const x=(f||"").trim();if(!x)return null;const N=await(await $(`${Qe}/api/vente/suppliers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:x,...h})})).json();return N!=null&&N.success?(await p(),N.data):null},[p]),v=a.useCallback(async f=>{await $(`${Qe}/api/vente/suppliers/${f}`,{method:"DELETE"}),await p()},[p]);return{suppliers:s,loading:l,error:w,upsertSupplier:u,deleteSupplier:v,reload:p}}const vs="https://api.trendresell.com",js=["title","description","title_and_description"],Ns=["first","last"],ws=["all","with","without"];async function Se(s,o,l,g){const w={"Content-Type":"application/json"};return g&&(w["x-account-id"]=g),(await $(`${vs}/api/vente/sku${o}`,{method:s,headers:w,body:l?JSON.stringify(l):void 0})).json()}function ks({open:s,onClose:o}){var ye,ae;const{t:l}=St("venteStockSkuSettings"),g=a.useMemo(()=>js.map(n=>({value:n,label:l(`source.${n}`)})),[l]),w=a.useMemo(()=>Ns.map(n=>({value:n,label:l(`order.${n}`)})),[l]),k=a.useMemo(()=>ws.map(n=>({value:n,label:l(`viewFilter.${n}`)})),[l]),{accounts:p,primaryAccountId:u,linked:v,isAccountActive:f}
1=Yt(),[h,x]=a.useState(u||null);a.useEffect(()=>{!h&&u&&x(u)},[u,h]);const[d,N]=a.useState(null),[q,T]=a.useState(!1),[H,ce]=a.useState(!1),[J,Re]=a.useState([]),L=a.useMemo(()=>J.filter(f),[J,f]),[tt,K]=a.useState(!1),[ie,se]=a.useState("all"),[ge,oe]=a.useState(""),[Pe,E]=a.useState(!1),[Z,z]=a.useState(null),[de,Me]=a.useState(()=>l("preview.exampleTitle")),[P,I]=a.useState(()=>l("preview.exampleDesc")),[B,b]=a.useState(null),M=a.useCallback(async()=>{if(!h||!s)return;const n=await Se("GET","/preferences",null,h);n.success&&(N(n.data),T(!1))},[h,s]),ue=a.useCallback(async()=>{if(!h||!s)return;K(!0);const C=await Se("GET",ie==="without"?"/listings?missing=1&limit=500":"/listings?limit=500",null,h);if(C.success){let W=C.data||[];ie==="with"&&(W=W.filter(F=>F.sku)),Re(W)}K(!1)},[h,ie,s]),Y=a.useCallback(async()=>{if(!d||!s)return;const n=await Se("POST","/preview",{title:de,description:P,detection_source:d.detection_source,hashtag_order:d.hashtag_order});n.success&&b(n.data)},[d,de,P,s]);a.useEffect(()=>{M()},[M]),a.useEffect(()=>{ue()},[ue]),a.useEffect(()=>{Y()},[Y]);const fe=n=>{N(C=>({...C||{},...n})),T(!0)},be=async()=>{if(!h||!d)return;ce(!0);const n=await Se("PUT","/preferences",{detection_source:d.detection_source,hashtag_order:d.hashtag_order,enabled:d.enabled},h);n.success&&(N(n.data),T(!1)),ce(!1)},Ue=async()=>{if(!h)return;E(!0),z(null);const n=await Se("POST","/refresh",{maxPages:3},h);z(n),E(!1),n.success&&ue()},O=a.useMemo(()=>{const n=ge.trim().toLowerCase();return n?L.filter(C=>(C.vinted_title||"").toLowerCase().includes(n)||(C.sku||"").toLowerCase().includes(n)||(C.hashtags||[]).some(W=>W.toLowerCase().includes(n))):L},[L,ge]),S=a.useMemo(()=>{const n=L.length,C=L.filter(W=>W.sku).length;return{total:n,withSku:C,without:n-C}},[L]);return s?e.jsx("div",{className:"fixed inset-0 md:left-64 z-50 flex items-start justify-center p-4 pt-[3vh] bg-black/40",onClick:o,children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-3xl max-h-[94vh] overflow-y-auto shadow-xl",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 sticky top-0 bg-white z-10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:l("title")}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:l("subtitle")})]}),e.jsx("button",{onClick:o,className:"p-1.5 rounded hover:bg-gray-100",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-400"})})]}),!v||!p.length?e.jsx("div",{className:"px-6 py-10 text-center text-sm text-gray-600",children:l("notLinked")}):e.jsxs("div",{className:"px-6 py-5 space-y-6",children:[p.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:l("account")}),e.jsx(V,{value:h,onChange:x,options:p.map(n=>({value:n.accountId,label:`@${n.username}`}))})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-2",children:l("detection.title")}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:l("detection.desc")}),d?e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:l("detection.hashtagSource")}),e.jsx(V,{value:d.detection_source,onChange:n=>fe({detection_source:n}),options:g})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[l("detection.whichHashtag"),e.jsx("span",{className:"text-xs font-normal text-gray-500 ml-1",children:l("detection.ifMultiple")})]}),e.jsx(V,{value:d.hashtag_order,onChange:n=>fe({hashtag_order:n}),options:w})]}),e.jsx("div",{className:"md:col-span-2 flex items-center gap-3",children:e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!d.enabled,onChange:n=>fe({enabled:n.target.checked}),className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent"}),e.jsx("span",{className:"text-sm",children:l("detection.enabledForAccount")}
1)]})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx(Ce,{className:"w-4 h-4 animate-spin"})," ",l("loading")]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs("button",{onClick:be,disabled:!q||H,className:"inline-flex items-center gap-2 px-4 py-2 bg-accent text-white rounded-lg text-sm font-medium hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed",children:[H?e.jsx(Ce,{className:"w-4 h-4 animate-spin"}):e.jsx(ms,{className:"w-4 h-4"}),l("save")]})})]}),e.jsxs("section",{children:[e.jsxs("h3",{className:"font-semibold text-gray-900 mb-2 flex items-center gap-2",children:[e.jsx(He,{className:"w-4 h-4 text-gray-500"})," ",l("preview.title")]}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:l("preview.desc")}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:l("preview.titleField")}),e.jsx("input",{type:"text",value:de,onChange:n=>Me(n.target.value),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:l("preview.descField")}),e.jsx("textarea",{value:P,onChange:n=>I(n.target.value),rows:3,className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]})]}),B&&e.jsxs("div",{className:"mt-3 p-3 bg-gray-50 border border-gray-200 rounded-lg text-sm space-y-1",children:[e.jsxs("div",{children:[l("preview.detectedSku")," ",B.sku?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-accent/10 text-accent rounded font-mono font-semibold",children:["#",B.sku]}):e.jsx("span",{className:"text-gray-500 italic",children:l("preview.none")}),B.sku_source&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:l("preview.fromSource",{source:B.sku_source==="title"?l("preview.theTitle"):l("preview.theDescription")})})]}),e.jsxs("div",{className:"text-xs text-gray-600",children:[l("preview.allHashtags")," ",B.hashtags.length?B.hashtags.map(n=>e.jsxs("span",{className:"font-mono mr-1",children:["#",n]},n)):e.jsx("span",{className:"italic",children:l("preview.none")})]})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(Ct,{className:"w-4 h-4 text-gray-500"})," ",l("listings.title")]}),e.jsxs("button",{onClick:Ue,disabled:Pe,className:"inline-flex items-center gap-2 px-3 py-1.5 bg-accent text-white rounded-lg text-xs font-medium hover:bg-accent/90 disabled:opacity-50",children:[Pe?e.jsx(Ce,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Qt,{className:"w-3.5 h-3.5"}),l("listings.refresh")]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mb-3",children:[e.jsx("span",{className:"font-medium text-gray-900",children:S.total})," ",l("listings.scannedLabel")," ·"," ",e.jsx("span",{className:"text-accent font-medium",children:S.withSku})," ",l("listings.withSkuLabel")," ·"," ",e.jsx("span",{className:"text-gray-400",children:S.without})," ",l("listings.withoutLabel")]}),Z&&e.jsx("div",{className:`p-2.5 mb-3 rounded-lg text-xs ${Z.success?"bg-green-50 text-green-800 border border-green-200":"bg-red-50 text-red-800 border border-red-200"}`,children:Z.success?e.jsxs(e.Fragment,{children:["✓ ",l("listings.refreshSuccess",{scanned:(ye
1=Z.data)==null?void 0:ye.scanned,withSku:(ae=Z.data)==null?void 0:ae.with_sku})]}):e.jsxs(e.Fragment,{children:["✗ ",Z.error||l("listings.refreshError")]})}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("input",{type:"text",placeholder:l("listings.searchPlaceholder"),value:ge,onChange:n=>oe(n.target.value),className:"flex-1 px-3 py-1.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"}),e.jsx(V,{value:ie,onChange:se,options:k,size:"sm",className:"w-48"})]}),tt?e.jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500 text-sm",children:[e.jsx(Ce,{className:"w-4 h-4 animate-spin mr-2"})," ",l("loading")]}):O.length?e.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:e.jsxs("tr",{className:"text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2",children:l("listings.colItem")}),e.jsx("th",{className:"px-3 py-2",children:l("listings.colSku")}),e.jsx("th",{className:"px-3 py-2",children:l("listings.colSource")}),e.jsx("th",{className:"px-3 py-2",children:l("listings.colState")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:O.slice(0,200).map(n=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-3 py-2 max-w-xs",children:e.jsx("div",{className:"text-gray-900 truncate",title:n.vinted_title,children:n.vinted_title||`#${n.vinted_item_id}`})}),e.jsx("td",{className:"px-3 py-2",children:n.sku?e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 bg-accent/10 text-accent rounded font-mono font-semibold text-xs",children:["#",n.sku]}):e.jsx("span",{className:"text-gray-400 italic text-xs",children:"-"})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600",children:n.sku_source==="title"?l("preview.titleField"):n.sku_source==="description"?l("preview.descField"):"-"}),e.jsx("td",{className:"px-3 py-2",children:n.is_closed?e.jsx("span",{className:"text-xs px-2 py-0.5 bg-gray-100 text-gray-600 rounded",children:l("listings.sold")}):e.jsx("span",{className:"text-xs px-2 py-0.5 bg-green-50 text-green-700 rounded",children:l("listings.active")})})]},n.vinted_item_id))})]})}),O.length>200&&e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 bg-gray-50 border-t border-gray-200",children:l("listings.moreResults",{count:O.length-200})})]}):e.jsx("div",{className:"text-center text-gray-500 text-sm py-8",children:S.total===0?l("listings.emptyNoScan"):l("listings.emptyNoMatch")})]})]})]})}):null}const Xe="https://api.trendresell.com",Ze=30,Ss=[{value:"en_stock",color:"bg-green-100 text-green-700"},{value:"vendu",color:"bg-blue-100 text-blue-700"},{value:"reserve",color:"bg-yellow-100 text-yellow-700"}],Cs=["Manual","Vinted"],Hs=["sku","date_desc","date_asc","price_desc","price_asc"],Ps=["marge_country_default","marge","marge_2_1","marge_5_5","marge_6","marge_10","marge_12","marge_20_fr","marge_21_be","normal","exonere"],Ms=["","7d","30d","90d","ytd"];function _s(s){if(!s)return{from:null,to:null};const o=new Date,l=o.toISOString().slice(0,10),g=new Date(o);if(s==="7d")g.setDate(g.getDate()-7);else if(s==="30d")g.setDate(g.getDate()-30);else if(s==="90d")g.setDate(g.getDate()-90);else if(s==="ytd")return{from:`${o.getUTCFullYear()}-01-01`,to:l};return{from:g.toISOString().slice(0,10),to:l}}const Fe=(s="ART")=>{const o=String(Math.floor(Math.random()*999)+1).padStart(3,"0");return`${s}-${o}`},_t=()=>{const s="ABCDEFGHIJKLMNOPQRSTUVWXYZ",o=Array.from({length:3},()=>s[Math.floor(Math.random()*s.length)]).join(""),l=String(Math.floor(Math.random()*999)+1).padStart(3,"0");return`LOT-${o}-${l}`},wt=()=>({sharedSku:!0,sku:_t(),title:"",quantity:"",alreadySoldElsewhere:0,totalCost:"",estimatedSellPrice:"",supplier:"",tvaRegime:"marge",purchaseDate:"",notes:""}),kt=()=>({sku:Fe(),title:"",purchasePrice:"",estimatedSellPrice:"",supplier:"",tvaRegime:"marge",purchaseDate:"",notes:""}),As=s=>{const o=s.split(`
2`)[0]||"";return o.includes("	")?"	":o.includes(";")?";":","},Vs=s=>
2{const o=As(s),l=s.split(`
3`).filter(k=>k.trim());if(l.length<2)return{headers:[],rows:[]};const g=l[0].split(o).map(k=>k.trim().replace(/^["']|["']$/g,"")),w=l.slice(1).map(k=>{const p=k.split(o).map(v=>v.trim().replace(/^["']|["']$/g,"")),u={};return g.forEach((v,f)=>{u[v]=p[f]||""}),u});return{headers:g,rows:w}},At={sku:["sku","SKU","ref","reference","référence","code"],title:["title","nom","name","produit","product","nom du produit","article"],purchasePrice:["prix_achat","cogs","cost","prix achat","coût","cout","purchase_price","prix d'achat"],estimatedSellPrice:["prix_vente","price","sell_price","prix vente","prix de vente","estimated_price"],quantity:["quantite","quantity","qty","qte","quantité"],notes:["notes","note","commentaire","description"]},Es=s=>{const o={};for(const[l,g]of Object.entries(At)){const w=s.find(k=>g.some(p=>k.toLowerCase()===p.toLowerCase()));w&&(o[l]=w)}return o},ta=()=>{const{t:s,i18n:o}=St("venteStock"),l=a.useMemo(()=>Ss.map(t=>({...t,label:s(`status.${t.value}`)})),[s]),g=a.useMemo(()=>Hs.map(t=>({value:t,label:s(`sort.${t}`)})),[s]),w=a.useMemo(()=>Ps.map(t=>({value:t,label:s(`tva.${t}`)})),[s]),k=a.useMemo(()=>Ms.map(t=>({value:t,label:s(`period.${t||"all"}`)})),[s]),p=a.useCallback(t=>{const r=l.find(c=>c.value===t)||l[0];return e.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${r.color}`,children:r.label})},[l]),{items:u,error:v,createItems:f,updateItem:h,deleteItem:x,reload:d}=bs(),{suppliers:N,upsertSupplier:q}=ys(),T=a.useMemo(()=>N.map(t=>t.name),[N]),[H,ce]=a.useState(""),[J,Re]=a.useState(""),[L,tt]=a.useState(""),[K,ie]=a.useState(""),[se,ge]=a.useState(""),[oe,Pe]=a.useState("sku"),[E,Z]=a.useState(1),[z,de]=a.useState("direct"),[Me,P]=a.useState(!1),[I,B]=a.useState("bulk"),[b,M]=a.useState(null),[ue,Y]=a.useState(null),[fe,be]=a.useState(!1),[Ue,O]=a.useState(!1),[S,ye]=a.useState([]),[ae,n]=a.useState(!1),[C,W]=a.useState(""),[F,qe]=a.useState(new Set),[st,Vt]=a.useState({detection_source:"title",hashtag_order:"first"});a.useEffect(()=>{$(`${Xe}/api/vente/sku/preferences`,{signal:AbortSignal.timeout(5e3)}).then(t=>t.json()).then(t=>{t!=null&&t.success&&t.data&&Vt(t.data)}).catch(()=>{})},[]);const[i,_]=a.useState(wt()),[m,R]=a.useState(kt()),[ze,at]=a.useState(""),[rt,Q]=a.useState(!1),[D,ve]=a.useState(null),[Is,Ds]=a.useState(!1),_e=a.useCallback(async(t,r)=>{if(!t||!r)return;const c=new FormData;c.append("file",r);try{await $(`${Xe}/api/vente/stock/${t}/invoice`,{method:"POST",body:c}),await d()}catch{}},[d]),[X,me]=a.useState(0),[A,Ae]=a.useState(null),[y,Be]=a.useState({}),[Et,We]=a.useState(!1),lt=a.useRef(null),Ve=a.useRef(null),Ee=a.useCallback(t=>{t&&t.type==="application/pdf"&&(t.size>10*1024*1024||ve(t))},[]),xe=a.useCallback(t=>t.trim()?!u.some(r=>r.sku===t):null,[u]),ee=a.useMemo(()=>{let t=[...u];if(z==="direct"?t=t.filter(r=>r.status!=="vendu"):t=t.filter(r=>r.status==="vendu"),H.trim()){const r=H.toLowerCase();t=t.filter(c=>(c.title||"").toLowerCase().includes(r)||(c.sku||"").toLowerCase().includes(r)||(c.notes||"").toLowerCase().includes(r)||(c.supplier||"").toLowerCase().includes(r))}if(J&&(t=t.filter(r=>r.source===J)),L&&(t=t.filter(r=>r.status===L)),K&&(t=t.filter(r=>(r.tvaRegime||"marge")===K)),se){const{from:r,to:c}=_s(se);r&&c&&(t=t.filter(j=>j.purchaseDate?j.purchaseDate>=r&&j.purchaseDate<=c:!1))}return t.sort((r,c)=>{switch(oe){case"sku":return(r.sku||"").localeCompare(c.sku||"");case"date_desc":return new Date(c.createdAt)-new Date(r.createdAt);case"date_asc":return new Date(r.createdAt)-new Date(c.createdAt);case"price_desc":return(Number(c.estimatedSellPrice)||0)-(Number(r.estimatedSellPrice)||0);case"price_asc":return(Number(r.estimatedSellPrice)||0)-(Number(c.estimatedSellPrice)||0);default:return 0}}),t},[u,H,J,L,K,se,oe,z]);Math.max(1,Math.ceil(ee.length/Ze));const je=ee.slice((E-1)*Ze,E*Ze),pe=a.useMemo(()=>{const t=u.filter(G=>G.status==="en_stock"),r=u.filter(G=>G.status==="vendu"),c=t.reduce((G,ne)=>G+(Number(ne.quantity)||0),0),j=t.reduce((G,ne)=>G+(Number(ne.purchasePrice)||0)*(Number(ne.quantity)||0),0),te=c>0?j/c:0,re=t.reduce((G,ne)=>G+(Number(ne.estimatedSellPrice)||0)*(Number(ne.quantity)||0),0),U=u.length,le=U>0?Math.round(r.length/U*100):0;return{stockCount:c,totalCogs:j,avgCogs:te,estimatedRevenue:re,rotationRate:le}},[u]),It=a.useCallback(()=>{_(wt()),R(kt()),me(0),Ae(null),Be({}),B("bulk"),M(null),P(!0)},[]),nt=a.useCallback(t=>{M({...t}),P(!0)},[]),Ie=a.useCallback(t=>{t!=null&&t.trim()&&q(t).catch(()=>{})},[q]),Dt=a.useCallback(async()=>
3{if(!i.title.trim()||!i.quantity)return;const t=Number(i.quantity)||0,r=Number(i.totalCost)||0,c=t>0?r/t:0,j=Number(i.alreadySoldElsewhere)||0;i.supplier&&Ie(i.supplier);let te=[];if(i.sharedSku){const re={id:crypto.randomUUID(),title:i.title,sku:i.sku,purchasePrice:c.toFixed(2),estimatedSellPrice:i.estimatedSellPrice||"",quantity:t-j,source:"Manual",status:"en_stock",notes:i.notes,photoUrl:"",supplier:i.supplier,tvaRegime:i.tvaRegime,purchaseDate:i.purchaseDate,isLot:!0,lotQuantityOriginal:t,sharedSku:!0,createdAt:new Date().toISOString()};te=await f(re)}else{const re=Array.from({length:t-j},(U,le)=>({id:crypto.randomUUID(),title:`${i.title} #${le+1}`,sku:`${i.sku}-${String(le+1).padStart(3,"0")}`,purchasePrice:c.toFixed(2),estimatedSellPrice:i.estimatedSellPrice||"",quantity:1,source:"Manual",status:"en_stock",notes:i.notes,photoUrl:"",supplier:i.supplier,tvaRegime:i.tvaRegime,purchaseDate:i.purchaseDate,createdAt:new Date().toISOString()}));te=await f(re)}D&&te[0]&&await _e(te[0],D),ve(null),P(!1)},[i,Ie,f,D,_e]),$t=a.useCallback(async()=>{if(!m.title.trim())return;m.supplier&&Ie(m.supplier);const t={id:crypto.randomUUID(),title:m.title,sku:m.sku,purchasePrice:m.purchasePrice||"",estimatedSellPrice:m.estimatedSellPrice||"",quantity:1,source:"Manual",status:"en_stock",notes:m.notes,photoUrl:"",supplier:m.supplier,tvaRegime:m.tvaRegime,purchaseDate:m.purchaseDate,createdAt:new Date().toISOString()},r=await f(t);D&&r[0]&&await _e(r[0],D),ve(null),P(!1)},[m,Ie,f,D,_e]),ct=a.useCallback(t=>{if(!t)return;const r=new FileReader;r.onload=c=>{const j=Vs(c.target.result);j.headers.length>0&&(Ae(j),Be(Es(j.headers)),me(1))},r.readAsText(t)},[]),Tt=a.useCallback(()=>{if(!A)return;const t=A.rows.map(r=>({id:crypto.randomUUID(),title:r[y.title]||s("fallback.noName"),sku:r[y.sku]||Fe(),purchasePrice:r[y.purchasePrice]||"",estimatedSellPrice:r[y.estimatedSellPrice]||"",quantity:Number(r[y.quantity])||1,source:"CSV",status:"en_stock",notes:r[y.notes]||"",photoUrl:"",supplier:"",tvaRegime:"marge",purchaseDate:"",createdAt:new Date().toISOString()}));f(t),P(!1)},[A,y,f,s]),Lt=a.useCallback(()=>{!b||!b.title.trim()||(h(b),P(!1),M(null))},[b,h]),Zt=a.useCallback(t=>{x(t),Y(null)},[x]),Ot=a.useCallback(async()=>{O(!0),n(!0),W(""),ye([]),qe(new Set);try{const t=await $(`${Xe}/api/vente/items`,{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new Error(s("error.httpStatus",{status:t.status}));const r=await t.json(),j=(Array.isArray(r)?r:r.items||[]).map(U=>{const le=hs({title:U.title,description:U.description},st);return{...U,_detectedSku:le.sku,_hashtags:le.hashtags}}),te=new Set(u.map(U=>(U.title||"").toLowerCase())),re=j.filter(U=>!te.has((U.title||"").toLowerCase()));ye(re)}catch(t){W(t.name==="TimeoutError"?s("vintedImport.timeout"):s("vintedImport.loadError",{message:t.message}))}finally{n(!1)}},[u,st,s]),Ft=a.useCallback(t=>{qe(r=>{const c=new Set(r);return c.has(t)?c.delete(t):c.add(t),c})},[]),Rt=a.useCallback(()=>{qe(t=>t.size===S.length?new Set:new Set(S.map((r,c)=>c)))},[S]),Ut=a.useCallback(()=>{const t=S.filter((r,c)=>F.has(c)).map(r=>{var c,j;return{id:crypto.randomUUID(),title:r.title||s("fallback.noTitle"),sku:r._detectedSku||Fe("VTD"),purchasePrice:0,estimatedSellPrice:r.price?String(r.price):"",quantity:1,source:"Vinted",status:r.is_closed?"vendu":"en_stock",notes:"",photoUrl:((j=(c=r.photos)==null?void 0:c[0])==null?void 0:j.url)||"",supplier:"",tvaRegime:"marge",purchaseDate:"",createdAt:new Date().toISOString()}});f(t),O(!1)},[S,F,f,s]);a.useEffect(()=>{Z(1)},[H,J,L,K,se,oe,z]);const De=a.useMemo(()=>ze.trim()?T.filter(t=>t.toLowerCase().includes(ze.toLowerCase())):T,[T,ze]),qt=a.useMemo(()=>u.filter(t=>t.source==="Manual"&&t.status!=="vendu").length,[u]),zt=a.useMemo(()=>u.filter(t=>t.source==="Vinted"&&t.status!=="vendu").length,[u]),Bt=a.useMemo(()=>{const t=u.filter(c=>c.status!=="vendu");if(t.length===0)return 0;const r=t.filter(c=>Number(c.estimatedSellPrice)>0).length;return Math.round(r/t.length*100)},[u]),Wt=a.useMemo(()=>u.filter(t=>t.status==="vendu").length,[u]),Gt=a.useMemo(()=>u.filter(t=>t.status!=="vendu").length,[u]),[it,Jt]=a.useState(Ze),Kt=[10,20,30,50,100],[$e,ot]=a.useState(new Set),Te=je.length>0&&je.every(t=>$e.has(t.id)),dt=a.useCallback(()=>{ot(t=>{const r=new Set(t);return Te?je.forEach(c=>r.delete(c.id)):je.forEach(c=>r.add(c.id)),r})},[Te,je]),ut=a.useCallback(t=>{ot(r=>{const c=new Set(r);return c.has(t)?c.delete(t):c.add(t),c})},[]),he=it,Ge=Math.max(1,Math.ceil(ee.length/he)),Je=ee.slice((E-1)*he,E*he);return e.jsxs("div",{className:"w-full",children:[e.jsx(is,{title:s("seoTitle"),description:s("subtitle")}),v&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-50 border border-red-200 text-sm text-red-700",children:s("error.stockUnavailable",{error:v})}),e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl md:text-2xl font-bold text-gray-900",children:s("title")}),e.jsxs(ls,{title:s("title"),children:[e.jsxs("p",{children:[s("howItWorks.p1.before"),e.jsx("strong",{children:s("howItWorks.p1.strong")}),s("howItWorks.p1.after")]}),e.jsx("p",{children:s("howItWorks.p2")}),e.jsxs("p",{children:[s("howItWorks.p3.before"),e.jsx("strong",{children:s("howItWorks.p3.strong")}),s("howItWorks.p3.after")]})]})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:s("subtitle")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:()=>be(!0),className:"p-2 rounded-lg hover:bg-gray-100 transition-colors",title:s("skuSettingsTooltip"),children:e.jsx(Xt,{className:"w-5 h-5 text-gray-500"})})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs md:text-sm font-medium text-gray-500",children:s("stats.available")}),e.jsx(ns,{className:"w-3.5 h-3.5 text-accent"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:pe.stockCount}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("stats.availableBreakdown",{manual:qt,vinted:zt})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs md:text-sm font-medium text-gray-500",children:s("stats.value")}),e.jsx(es,{className:"w-3.5 h-3.5 text-accent"})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:[pe.totalCogs.toFixed(2).replace(".",",")," €"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("stats.avgCogs",{value:pe.avgCogs.toFixed(2).replace(".",",")})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs md:text-sm font-medium text-gray-500",children:s("stats.estimatedRevenue")}),e.jsx(cs,{className:"w-3.5 h-3.5 text-accent"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:pe.estimatedRevenue>0?`${pe.estimatedRevenue.toFixed(0)} €`:"-"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("stats.withEstimatedPrice",{percent:Bt})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs md:text-sm font-medium text-gray-500",children:s("stats.rotationRate")}),e.jsx(ss,{className:"w-3.5 h-3.5 text-accent"})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:[pe.rotationRate,"%"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s("stats.rotationBreakdown",{sold:Wt,inStock:Gt})})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(mt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:s("searchPlaceholder"),value:H,onChange:t=>ce(t.target.value),className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-accent/20 focu
3s:border-accent"})]}),e.jsx(V,{value:se,onChange:t=>ge(t),options:k,placeholder:s("filters.period"),size:"sm"}),e.jsx(V,{value:J,onChange:t=>Re(t),options:[{value:"",label:s("filters.allSources")},...Cs.map(t=>({value:t,label:t}))],placeholder:s("filters.allSources"),size:"sm"}),e.jsx(V,{value:K,onChange:t=>ie(t),options:[{value:"",label:s("filters.allVat")},...w],placeholder:s("filters.allVat"),size:"sm"}),e.jsx(V,{value:it,onChange:t=>{Jt(Number(t)),Z(1)},options:Kt.map(t=>({value:t,label:s("filters.perPage",{count:t})})),size:"sm"}),e.jsx(V,{value:oe,onChange:t=>Pe(t),options:g,placeholder:s("filters.sortBy"),icon:ht,size:"sm"}),e.jsxs("button",{onClick:Ot,className:"flex items-center gap-1.5 px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 transition-colors whitespace-nowrap",children:[e.jsx(gt,{className:"w-4 h-4"}),s("importFromVinted")]}),e.jsxs("button",{onClick:It,className:"flex items-center gap-1.5 px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 transition-colors whitespace-nowrap",children:[e.jsx(bt,{className:"w-4 h-4"}),s("addStock")]})]}),e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3 mb-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm text-gray-600",children:[e.jsx("input",{type:"checkbox",checked:Te,onChange:dt,className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent"}),s("selectAll",{count:ee.length})]}),e.jsxs("div",{className:"flex gap-1 bg-gray-100 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>de("direct"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors ${z==="direct"?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:s("tabs.live")}),e.jsx("button",{onClick:()=>de("historique"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors ${z==="historique"?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:s("tabs.history")})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden",children:[Je.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[e.jsx(xt,{className:"w-12 h-12 text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:s(z==="direct"?"empty.noStock":"empty.noSold")}),z==="direct"&&e.jsx("p",{className:"text-gray-500 mt-1 text-center max-w-sm",children:s("empty.hint")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-10 px-4 py-3",children:e.jsx("input",{type:"checkbox",checked:Te,onChange:dt,className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent"})}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.item")}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.sku")}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.cogs")}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.estimatedPrice")}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-gray-500",children:s("table.qty")}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.source")}),e.jsx("th",{className:"text-left px-4 py-3 font-medium text-gray-500",children:s("table.status")}),e.jsx("th",{className:"text-right px-4 py-3 font-medium text-gray-500",children:s("table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:Je.map(t=>e.jsxs("tr",{className:`hover:bg-gray-50 transition-colors ${$e.has(t.id)?"bg-accent/5":""}`,children:[e.jsx("td",{className:"w-10 px-4 py-3",children:e.jsx("input",{type:"checkbox",checked:$e.has(t.id),onChange:()=>ut(t.id),className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[t.photoUrl?e.jsx("img",{src:t.photoUrl,alt:"",className:"w-8 h-8 rounded object-cover"}):e.jsx("div",{className:"w-8 h-8 rounded bg-gray-100"}),e.jsx("span",{className:"font-medium text-gray-900 truncate max-w-[200px]",children:t.title})]})}),e.jsx("td",{className:"px-4 py-3 text-gray-600 font-mono text-xs",children:t.sku||"-"}),e.jsx("td",{className:"px-4 py-3 text-gray-600",children:t.purchasePrice?`${t.purchasePrice} €`:"-"}),e.jsx("td",{className:"px-4 py-3 text-gray-600",children:t.estimatedSellPrice?`${t.estimatedSellPrice} €`:"-"}),e.jsx("td",{className:"px-4 py-3 text-center text-gray-600",children:t.quantity}),e.jsx("td",{className:"px-4 py-3 text-gray-600",children:t.source}),e.jsx("td",{className:"px-4 py-3",children:p(t.status)}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>nt(t),className:"p-1.5 rounded hover:bg-gray-100 transition-colors",title:s("actions.edit"),children:e.jsx(ft,{className:"w-4 h-4 text-gray-400"})}),e.jsx("button",{onClick:()=>Y(t.id),className:"p-1.5 rounded hover:bg-red-50 transition-colors",title:s("actions.delete"),children:e.jsx(yt,{className:"w-4 h-4 text-gray-400 hover:text-red-500"})})]})})]},t.id))})]})}),e.jsx("div",{className:"md:hidden divide-y divide-gray-100",children:Je.map(t=>e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("input",{type:"checkbox",checked:$e.has(t.id),onChange:()=>ut(t.id),className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent mt-1 flex-shrink-0"}),t.photoUrl?e.jsx("img",{src:t.photoUrl,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-gray-100 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm truncate",children:t.title}),t.sku&&e.jsx("p",{className:"text-xs text-gray-400 font-mono truncate",children:t.sku})]})]}),e.jsx("div",{className:"flex-shrink-0",children:p(t.status)})]}),e.jsxs("div",{className:"flex items-center justify-between mt-3 text-xs text-gray-500 pl-7",children:[e.jsxs("span",{children:[s("table.cogs"),": ",t.purchasePrice?`${t.purchasePrice} €`:"-"]}),e.jsxs("span",{children:[s("mobile.estimated"),": ",t.estimatedSellPrice?`${t.estimatedSellPrice} €`:"-"]}),e.jsxs("span",{children:[s("table.qty"),": ",t.quantity]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1 mt-2",children:[e.jsx("button",{onClick:()=>nt(t),className:"p-1.5 rounded hover:bg-gray-100",children:e.jsx(ft,{className:"w-4 h-4 text-gray-400"})}),e.jsx("button",{onClick:()=>Y(t.id),className:"p-1.5 rounded hover:bg-red-50",children:e.jsx(yt,{className:"w-4 h-4 text-gray-400"})})]})]},t.id))})]}),ee.length>he&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[e.jsx("p",{className:"text-xs text-gray-500",children:s("pagination.range",{from:(E-1)*he+1,to:Math.min(E*he,ee.length),total:ee.length})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>Z(t=>Math.max(1,t-1)),disabled:E===1,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(as,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-xs text-gray-600 px-2",children:[E," / ",Ge]}),e.jsx("button",{onClick:()=>Z(t=>Math.min(Ge,t+1)),disabled:E===Ge,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(rs,{className:"w-4 h-4"})})]})]})]}),Me&&!b&&e.jsx("div",{className:"fixed inset-0 md:left-64 z-50 flex items-start justify-center p-4 pt-[5vh] bg-black/40",onClick:()=>P(!1),children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-lg max-h-[90vh] overflow-y-auto shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"px-6 pt-5 pb-2 text-center relative",children:[e.jsx("button",{onClick:()=>P(!1),className:"absolute right-4 top-4 p-1.5 rounded hover:bg-gray-100",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:s("addModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s("addModal.subtitle")})]}),e.jsx("div",{className:"flex items-center gap-1 mx-6 mt-3 mb-4 bg-gray-100 rounded-lg p-1",children:[{key:"bulk",label:s("addModal.modeBulk"),Icon:ts},{key:"single",label:s("addModal.modeSingle"),Icon:Ct},{key:"csv",label:s("addModal.modeCsv"),Icon:Ne}].map(t=>e.jsxs("button",{onClick:()=>{B(t.key),t.key==="csv"&&(me(0),Ae(null))},className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-sm font-medium rounded-md transition-colors ${I===t.key?"bg-accent text-white shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx(t.Icon,{className:"w-3.5 h-3.5"}),t.label]},t.key))}),I==="bulk"&&e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:s("bulk.sharedSkuLabel")}),e.jsxs("div",{className:"group relative",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-gray-400 cursor-help"}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none",children:s("bulk.sharedSkuTooltip")})]})]}),e.jsx("button",{onClick:()=>_({...i,sharedSku:!i.sharedSku}),className:`relative w-10 h-5 rounded-full transition-colors ${i.sharedSku?"bg-accent":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform ${i.sharedSku?"translate-x-5":""}`})})]}),i.sharedSku&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1.5 flex items-center gap-1",children:[e.jsx(pt,{className:"w-3 h-3 text-green-500"}),s("bulk.sharedSkuRecommended")]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("bulk.lotSku")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:i.sku,onChange:t=>_({...i,sku:t.target.value}),placeholder:"LOT-ABC-001",className:"w-full px-3 py-2 pr-9 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focu
3s:border-accent"}),e.jsx("button",{onClick:()=>_({...i,sku:_t()}),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-gray-100",title:s("generateSku"),children:e.jsx(jt,{className:"w-4 h-4 text-gray-400"})})]}),i.sku.trim()&&e.jsxs("p",{className:`text-xs mt-1 flex items-center gap-1 ${xe(i.sku)?"text-green-600":"text-red-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${xe(i.sku)?"bg-green-500":"bg-red-500"}`}),xe(i.sku)?s("skuAvailable"):s("skuTaken")]}),i.sharedSku&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-2.5 mt-2 text-xs text-blue-700",children:[e.jsx("span",{className:"font-medium",children:s("bulk.sharedModeStrong")})," ",s("bulk.sharedModeText")]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("bulk.orderName")}),e.jsx("input",{type:"text",value:i.title,onChange:t=>_({...i,title:t.target.value}),placeholder:s("bulk.orderNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("bulk.orderNameHint")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("bulk.quantity")}),e.jsx("input",{type:"number",min:"1",value:i.quantity,onChange:t=>_({...i,quantity:t.target.value}),placeholder:"50",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("bulk.alreadySold")}),e.jsxs("div",{className:"group relative",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-gray-400 cursor-help"}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none",children:s("bulk.alreadySoldTooltip")})]})]}),e.jsx("input",{type:"number",min:"0",value:i.alreadySoldElsewhere,onChange:t=>_({...i,alreadySoldElsewhere:Math.max(0,Number(t.target.value)||0)}),placeholder:"0",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("bulk.totalCost")}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:i.totalCost,onChange:t=>_({...i,totalCost:t.target.value}),placeholder:"625.00",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("bulk.estimatedUnitPrice")}),e.jsxs("div",{className:"group relative",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-gray-400 cursor-help"}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none",children:s("bulk.estimatedUnitPriceTooltip")})]})]}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:i.estimatedSellPrice,onChange:t=>_({...i,estimatedSellPrice:t.target.value}),placeholder:"25.00",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("supplier.label")}),e.jsx("input",{type:"text",value:I==="bulk"&&i.supplier||"",onChange:t=>{_({...i,supplier:t.target.value}),at(t.target.value),Q(!0)},onFocus:()=>Q(!0),onBlur:()=>setTimeout(()=>Q(!1),200),placeholder:s("supplier.placeholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focu
3s:border-accent"}),rt&&De.length>0&&I==="bulk"&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg max-h-32 overflow-y-auto",children:De.map(t=>e.jsx("button",{onMouseDown:()=>{_({...i,supplier:t}),Q(!1)},className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-50",children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("vatRegime.label")}),e.jsx(V,{value:i.tvaRegime,onChange:t=>_({...i,tvaRegime:t}),options:w}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("vatRegime.hintBulk")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("purchaseDate")}),e.jsx("input",{type:"date",value:i.purchaseDate,onChange:t=>_({...i,purchaseDate:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("notes")}),e.jsx("textarea",{rows:2,value:i.notes,onChange:t=>_({...i,notes:t.target.value}),placeholder:s("bulk.notesPlaceholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("invoice.label")}),e.jsx("div",{onClick:()=>{var t;return(t=Ve.current)==null?void 0:t.click()},onDragOver:t=>{t.preventDefault()},onDrop:t=>{var r;t.preventDefault(),Ee((r=t.dataTransfer.files)==null?void 0:r[0])},className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-accent transition-colors cursor-pointer",children:D?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-6 h-6 text-accent mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:D.name}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[(D.size/1024/1024).toFixed(2)," MB"]}),e.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),ve(null)},className:"text-xs text-gray-500 hover:text-red-500 mt-2 underline",children:s("invoice.remove")})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:s("invoice.dropHint")}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("invoice.constraint")})]})}),e.jsx("input",{ref:Ve,type:"file",accept:"application/pdf",className:"hidden",onChange:t=>{var r;return Ee((r=t.target.files)==null?void 0:r[0])}})]})]}),I==="single"&&e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("single.sku")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:m.sku,onChange:t=>R({...m,sku:t.target.value}),placeholder:"RL-001",className:"w-full px-3 py-2 pr-9 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"}),e.jsx("button",{onClick:()=>R({...m,sku:Fe()}),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-gray-100",title:s("generateSku"),children:e.jsx(jt,{className:"w-4 h-4 text-gray-400"})})]}),m.sku.trim()&&e.jsxs("p",{className:`text-xs mt-1 flex items-center gap-1 ${xe(m.sku)?"text-green-600":"text-red-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${xe(m.sku)?"bg-green-500":"bg-red-500"}`}),xe(m.sku)?s("skuAvailable"):s("skuTaken")]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("single.productName")}
3),e.jsx("input",{type:"text",value:m.title,onChange:t=>R({...m,title:t.target.value}),placeholder:s("single.productNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("single.unitCogs")}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:m.purchasePrice,onChange:t=>R({...m,purchasePrice:t.target.value}),placeholder:"12.50",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("single.estimatedSellPrice")}),e.jsxs("div",{className:"group relative",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-gray-400 cursor-help"}),e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-gray-900 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none",children:s("single.estimatedSellPriceTooltip")})]})]}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:m.estimatedSellPrice,onChange:t=>R({...m,estimatedSellPrice:t.target.value}),placeholder:"25.00",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("supplier.label")}),e.jsx("input",{type:"text",value:m.supplier||"",onChange:t=>{R({...m,supplier:t.target.value}),at(t.target.value),Q(!0)},onFocus:()=>Q(!0),onBlur:()=>setTimeout(()=>Q(!1),200),placeholder:s("supplier.placeholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"}),rt&&De.length>0&&I==="single"&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg max-h-32 overflow-y-auto",children:De.map(t=>e.jsx("button",{onMouseDown:()=>{R({...m,supplier:t}),Q(!1)},className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-50",children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("vatRegime.label")}),e.jsx(V,{value:m.tvaRegime,onChange:t=>R({...m,tvaRegime:t}),options:w}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("vatRegime.hintSingle")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("purchaseDate")}),e.jsx("input",{type:"date",value:m.purchaseDate,onChange:t=>R({...m,purchaseDate:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("notes")}),e.jsx("textarea",{rows:2,value:m.notes,onChange:t=>R({...m,notes:t.target.value}),placeholder:s("single.notesPlaceholder"),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("invoice.label")}),e.jsx("div",{onClick:()=>{var t;return(t=Ve.current)==null?void 0:t.click()},onDragOver:t=>{t.preventDefault()},onDrop:t=>{var r;t.preventDefault(),Ee((r=t.dataTransfer.files)==null?void 0:r[0])},className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-accent transition-colors cursor-pointer",children:D?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-6 h-6 text-accent mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:D.name}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[(D.size/1024/1024).toFixed(2)," MB"]}),e.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),ve(null)},className:"text-xs text-gray-500 hover:text-red-500 mt-2 underline",children:s("invoice.remove")})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:s("invoice.dropHint")}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("invoice.constraint")})]})}),e.jsx("input",{ref:Ve,type:"file",accept:"application/pdf",className:"hidden",onChange:t=>{var r;return Ee((r=t.target.files)==null?void 0:r[0])}})]})]}),I==="csv"&&e.jsxs("div",{className:"px-6 py-4",children:[e.jsx("div",{className:"flex items-center justify-center gap-4 sm:gap-8 mb-6",children:[{step:0,label:s("csv.stepFile"),icon:Ne},{step:1,label:s("csv.stepMapping"),icon:ht},{step:2,label:s("csv.stepPreview"),icon:mt}].map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[r>0&&e.jsx("div",{className:`w-8 h-px ${X>=t.step?"bg-accent":"bg-gray-300"}`}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center border-2 transition-colors ${X===t.step?"border-accent bg-accent/10 text-accent":X>t.step?"border-green-500 bg-green-50 text-green-600":"border-gray-300 text-gray-400"}`,children:X>t.step?e.jsx(pt,{className:"w-4 h-4"}):e.jsx(t.icon,{className:"w-4 h-4"})}),e.jsx("span",{className:`text-xs font-medium ${X>=t.step?"text-gray-900":"text-gray-400"}`,children:t.label})]})]},t.step))}),X===0&&e.jsxs("div",{onDragOver:t=>{t.preventDefault(),We(!0)},onDragLeave:()=>We(!1),onDrop:t=>{t.preventDefault(),We(!1);const r=t.dataTransfer.files[0];r&&(r.name.endsWith(".csv")||r.name.endsWith(".tsv")||r.name.endsWith(".txt"))&&ct(r)},onClick:()=>{var t;return(t=lt.current)==null?void 0:t.click()},className:`border-2 border-dashed rounded-xl p-12 text-center cursor-pointer transition-colors ${Et?"border-accent bg-accent/5":"border-gray-300 hover:border-gray-400"}`,children:[e.jsx(Ne,{className:"w-10 h-10 text-gray-400 mx-auto mb-3"}),e.jsx("p",{className:"text-base font-medium text-gray-700",children:s("csv.dropHint")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s("csv.browseHint")}),e.jsx("p",{className:"text-xs text-gray-400 mt-4",children:s("csv.formats")}),e.jsx("input",{ref:lt,type:"file",accept:".csv,.tsv,.txt",className:"hidden",onChange:t=>ct(t.target.files[0])})]}),X===1&&A&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-3",children:s("csv.mappingIntro",{count:A.rows.length})}),Object.entries(At).map(([t,r])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 w-36 capitalize",children:s(`csv.field.${t}`)}),e.jsx("div",{className:"flex-1",children:e.jsx(V,{value:y[t]||"",onChange:c=>Be({...y,[t]:c}),options:[{value:"",label:s("csv.ignore")},...A.headers.map(c=>({value:c,label:c}))],placeholder:s("csv.ignore"),size:"sm"})})]},t)),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx("button",{onClick:()=>{me(0),Ae(null)},className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",children:s("csv.back")}),e.jsx("button",{onClick:()=>me(2),disabled:!y.title,className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 disabled:opacity-40 disabled:cursor-not-allowed",children:s("csv.next")})]})]}),X===2&&A&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-3",children:s("csv.previewIntro",{shown:Math.min(5,A.rows.length),total:A.rows.length})}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[y.sku&&e.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-500",children:s("table.sku")}),e.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-500",children:s("csv.colName")}),y.purchasePrice&&e.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-500",children:s("table.cogs")}),y.estimatedSellPrice&&e.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-500",children:s("csv.colPrice")}),y.quantity&&e.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-500",children:s("table.qty")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:A.rows.slice(0,5).map((t,r)=>e.jsxs("tr",{children:[y.sku&&e.jsx("td",{className:"px-3 py-2 font-mono",children:t[y.sku]}),e.jsx("td",{className:"px-3 py-2",children:t[y.title]||"-"}),y.purchasePrice&&e.jsxs("td",{className:"px-3 py-2",children:[t[y.purchasePrice]," €"]}),y.estimatedSellPrice&&e.jsxs("td",{className:"px-3 py-2",children:[t[y.estimatedSellPrice]," €"]}),y.quantity&&e.jsx("td",{className:"px-3 py-2 text-center",children:t[y.quantity]})]},r))})]})}),A.rows.length>5&&e.jsx("p",{className:"text-xs text-gray-400 text-center",children:s("csv.moreItems",{count:A.rows.length-5})}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx("button",{onClick:()=>me(1),className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",children:s("csv.back")}),e.jsx("button",{onClick:Tt,className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90",children:s("csv.importCount",{count:A.rows.length})})]})]})]}),I!=="csv"&&e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200",children:[e.jsx("button",{onClick:()=>P(!1),className:"px-4 py-2 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:s("cancel")}),e.jsxs("button",{onClick:I==="bulk"?Dt:$t,disabled:I==="bulk"?!i.title.trim()||!i.quantity:!m.title.trim(),className:"flex items-center gap-1.5 px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(bt,{className:"w-4 h-4"}),s("addToStock")]})]})]})}),Me&&b&&e.jsx("div",{className:"fixed inset-0 md:left-64 z-50 flex items-center justify-center p-4 bg-black/40",onClick:()=>{P(!1),M(null)},children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-lg max-h-[90vh] overflow-y-auto shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:s("editModal.title")}),e.jsx("button",{onClick:()=>{P(!1),M(null)},className:"p-1.5 rounded hover:bg-gray-100",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-400"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("editModal.titleField")}),e.jsx("input",{type:"text",value:b.title,onChange:t=>M({...b,title:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focu
3s:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("table.sku")}),e.jsx("input",{type:"text",value:b.sku,onChange:t=>M({...b,sku:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("editModal.purchasePrice")}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:b.purchasePrice,onChange:t=>M({...b,purchasePrice:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("single.estimatedSellPrice")}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:b.estimatedSellPrice,onChange:t=>M({...b,estimatedSellPrice:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("editModal.quantity")}),e.jsx("input",{type:"number",min:"1",value:b.quantity,onChange:t=>M({...b,quantity:Math.max(1,parseInt(t.target.value)||1)}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("table.status")}),e.jsx(V,{value:b.status,onChange:t=>M({...b,status:t}),options:l})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("notes")}),e.jsx("textarea",{rows:2,value:b.notes,onChange:t=>M({...b,notes:t.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent resize-none"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200",children:[e.jsx("button",{onClick:()=>{P(!1),M(null)},className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",children:s("cancel")}),e.jsx("button",{onClick:Lt,disabled:!b.title.trim(),className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 disabled:opacity-40 disabled:cursor-not-allowed",children:s("save")})]})]})}),Ue&&e.jsx("div",{className:"fixed inset-0 md:left-64 z-50 flex items-start justify-center p-4 pt-[5vh] bg-black/40",onClick:()=>O(!1),children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-lg max-h-[90vh] overflow-y-auto shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"px-6 pt-5 pb-2 text-center relative",children:[e.jsx("button",{onClick:()=>O(!1),className:"absolute right-4 top-4 p-1.5 rounded hover:bg-gray-100",children:e.jsx(Oe,{className:"w-5 h-5 text-gray-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:s("importFromVinted")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s("vintedImport.subtitle")}),e.jsxs("p",{className:"text-xs text-gray-400 mt-2 inline-flex items-center gap-1.5",children:[e.jsx(xs,{className:"w-3 h-3"}),s("vintedImport.skuHashtagBefore"),e.jsx("code",{className:"font-mono",children:"#hashtags"}),s("vintedImport.skuHashtagAfter")," ",e.jsx("button",{type:"button",onClick:()=>{O(!1),be(!0)},className:"text-accent hover:underline",children:s("vintedImport.detectionSettings")})]})]}),e.jsxs("div",{className:"px-6 py-4",children:[ae&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Ce,{className:"w-8 h-8 text-accent animate-spin mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:s("vintedImport.loading")})]}),C&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-sm text-red-700",children:C}),!ae&&!C&&S.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xt,{className:"w-10 h-10 text-gray-300 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:s("vintedImport.emptyTitle")}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s("vintedImport.emptyHint")})]}
3),!ae&&!C&&S.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm text-gray-600",children:[e.jsx("input",{type:"checkbox",checked:F.size===S.length&&S.length>0,onChange:Rt,className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent"}),s("selectAll",{count:S.length})]}),e.jsx("span",{className:"text-xs text-gray-400",children:s("vintedImport.selectedCount",{count:F.size})})]}),e.jsx("div",{className:"space-y-2 max-h-[50vh] overflow-y-auto",children:S.map((t,r)=>{var c,j;return e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${F.has(r)?"border-accent bg-accent/5":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("input",{type:"checkbox",checked:F.has(r),onChange:()=>Ft(r),className:"w-4 h-4 rounded border-gray-300 text-accent focus:ring-accent flex-shrink-0"}),(j=(c=t.photos)==null?void 0:c[0])!=null&&j.url?e.jsx("img",{src:t.photos[0].url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-gray-100 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.price!=null&&e.jsxs("span",{className:"text-xs text-gray-500",children:[t.price," €"]}),t.is_closed&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-blue-100 text-blue-700",children:s("status.vendu")}),t._detectedSku?e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold bg-accent/10 text-accent",title:s("vintedImport.skuDetectedTooltip"),children:["#",t._detectedSku]}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] text-gray-400 bg-gray-50",title:s("vintedImport.skuAutoTooltip"),children:s("vintedImport.skuAuto")})]})]})]},r)})})]})]}),!ae&&!C&&S.length>0&&e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:s("cancel")}),e.jsxs("button",{onClick:Ut,disabled:F.size===0,className:"flex items-center gap-1.5 px-4 py-2 bg-accent text-white text-sm font-medium rounded-lg hover:bg-accent/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(gt,{className:"w-4 h-4"}),F.size>0?s("vintedImport.importCount",{count:F.size}):s("vintedImport.import")]})]})]})}),e.jsx(ks,{open:fe,onClose:()=>be(!1)}),ue&&e.jsx("div",{className:"fixed inset-0 md:left-64 z-50 flex items-center justify-center p-4 bg-black/40",onClick:()=>Y(null),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-sm shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:s("deleteConfirm.title")}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s("deleteConfirm.irreversible")}),e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>Y(null),className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800 transition-colors",children:s("cancel")}),e.jsx("button",{onClick:()=>Zt(ue),className:"px-4 py-2 bg-red-600 text-white text-sm font-medium rounded-lg hover:bg-red-700 transition-colors",children:s("actions.delete")})]})]})})]})};export{ta as default};

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.