(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[676],{1664:function(e,t,n){Promise.resolve().then(n.bind(n,1056))},1056:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return l}});var a=n(7437),r=n(2265),s=n(5995);function l(){let[e,t]=(0,r.useState)(null),[n,l]=(0,r.useState)(""),[i,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),[u,p]=(0,r.useState)(null),h=async()=>{if(e){o(!0),p(null),d(null);try{let t=new FormData;t.append("pdf",e),n&&t.append("name",n);let a=await fetch("/api/upload",{method:"POST",body:t}),r=await a.json();if(!a.ok)throw Error(r.error||"Erreur");d(r)}catch(e){p(e.message)}finally{o(!1)}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("header",{className:"app-header",children:[(0,a.jsx)(s.default,{size:38}),(0,a.jsx)("a",{className:"btn ghost",href:"/",children:"← Retour au s\xe9lecteur"})]}),(0,a.jsxs)("main",{className:"main",style:{maxWidth:620,margin:"0 auto"},children:[(0,a.jsx)("h1",{style:{marginTop:10},children:"Charger un catalogue PDF"}),(0,a.jsx)("p",{className:"hint",style:{fontSize:".9rem"},children:"Importez un nouveau catalogue. L'application en extrait automatiquement les produits (r\xe9f\xe9rence, nom, description, prix, cat\xe9gorie), d\xe9coupe une image par article et rend les pages pour le feuilletage."}),(0,a.jsxs)("div",{className:"panel",style:{marginTop:16},children:[(0,a.jsxs)("div",{className:"field",children:[(0,a.jsx)("label",{children:"Fichier PDF"}),(0,a.jsx)("input",{type:"file",accept:"application/pdf,.pdf",onChange:e=>{var n,a;return t(null!==(a=null===(n=e.target.files)||void 0===n?void 0:n[0])&&void 0!==a?a:null)}}),e&&(0,a.jsxs)("p",{className:"hint",children:[e.name," \xb7 ",(e.size/1024/1024).toFixed(1)," Mo"]})]}),(0,a.jsxs)("div",{className:"field",children:[(0,a.jsx)("label",{children:"Nom du catalogue (optionnel)"}),(0,a.jsx)("input",{type:"text",placeholder:"ex. More than Gifts 2026",value:n,onChange:e=>l(e.target.value)})]}),(0,a.jsx)("button",{className:"btn primary block",onClick:h,disabled:!e||i,children:i?"Extraction en cours… (peut prendre 1–2 min)":"Importer et extraire"}),i&&(0,a.jsx)("p",{className:"hint",style:{textAlign:"center"},children:"Traitement du PDF : rendu des pages et d\xe9coupe des produits…"})]}),u&&(0,a.jsxs)("div",{className:"panel",style:{marginTop:16,borderColor:"var(--danger)"},children:[(0,a.jsx)("strong",{style:{color:"var(--danger)"},children:"\xc9chec"}),(0,a.jsx)("p",{style:{whiteSpace:"pre-wrap",fontSize:".85rem"},children:u}),(0,a.jsxs)("p",{className:"hint",children:["L'extraction n\xe9cessite Python + PyMuPDF sur le serveur. V\xe9rifiez que",(0,a.jsx)("code",{children:" python "})," est disponible (variable ",(0,a.jsx)("code",{children:"PYTHON_BIN"}),")."]})]}),c&&(0,a.jsxs)("div",{className:"panel",style:{marginTop:16},children:[(0,a.jsxs)("strong",{children:["✅ Catalogue import\xe9 : ",c.catalog]}),(0,a.jsxs)("p",{style:{margin:"8px 0"},children:[c.total," produits extraits."]}),(0,a.jsx)("pre",{style:{background:"#f3f4f6",padding:12,borderRadius:8,fontSize:".78rem",overflow:"auto"},children:c.log}),(0,a.jsx)("a",{className:"btn primary",href:"/",children:"Ouvrir le s\xe9lecteur →"})]})]})]})}},5995:function(e,t,n){"use strict";n.d(t,{default:function(){return s}});var a=n(7437),r=n(2265);function s(e){let{size:t=40,wordmark:n=!0}=e,[s,l]=(0,r.useState)("/logo.svg");return(0,r.useEffect)(()=>{let e=!0;return fetch("/logo.png",{method:"HEAD"}).then(t=>{e&&t.ok&&(t.headers.get("content-type")||"").includes("image")&&l("/logo.png")}).catch(()=>{}),()=>{e=!1}},[]),(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,a.jsx)("img",{src:s,alt:"Tickey",style:{height:t,width:"auto",display:"block"}}),n&&(0,a.jsx)("span",{style:{fontWeight:800,letterSpacing:"0.14em",fontSize:.42*t,color:"var(--ink)"},children:"TICKEY"})]})}}},function(e){e.O(0,[971,117,744],function(){return e(e.s=1664)}),_N_E=e.O()}]);