1import{a as l,u as h,b as d,j as r}from"./vendor-query-CniT1WJL.js";import{r as E}from"./vendor-react-69GsFwrV.js";import{a5 as i,aI as P,aN as A,S as q,b as U,c as R,f as v,d as $,e as K,F as B,G as z,at as Q}from"./index-KjAD5lCC.js";import{bL as D,ao as T,ax as M,g as J}from"./vendor-ui-Ad3ANzF6.js";function N(e){return e instanceof P&&e.data&&typeof e.data=="object"?e.data:null}function fe(e){return e instanceof P?e.status:null}function he(e){return N(e)?.error??null}function G(e,t){const n=N(e);return n?.message?n.message:n?.error?n.error.replace(/_/g," "):e instanceof Error&&e.message?e.message:t}const H=5,X=5*1024*1024,F=["csv","tsv","txt","xlsx","xls","pdf"],W=".csv,.tsv,.txt,.xlsx,.xls,.pdf",g={price_list:"Price list",coa:"COA",certificate:"Certificate",company_doc:"Company document",other:"Other"};function k(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} kB`:`${(e/(1024*1024)).toFixed(1)} MB`}function V(e){const t=e.name.split(".").pop()?.toLowerCase()??"";return F.includes(t)?e.size>X?`${e.name}: ${k(e.size)} exceeds the 5 MB limit.`:null:`${e.name}: unsupported type. Accepted: ${F.join(", ")}.`}function Y(e){return new Promise((t,n)=>{const s=new FileReader;s.onerror=()=>n(new Error(`Could not read ${e.name}.`)),s.onload=()=>{const u=typeof s.result=="string"?s.result:"",m=u.indexOf(",");t(m>=0?u.slice(m+1):u)},s.readAsDataURL(e)})}async function be(e){return Promise.all(e.map(async t=>({filename:t.file.name,kind:t.kind,contentBase64:await Y(t.file)})))}const x=["supplier-portal"],w=e=>[...x,"application",e],Z=e=>[...x,"invite",e],b=[...x,"me"],ee=[...x,"files"],te=e=>[...x,"submissions","all"],p={"content-type":"application/json"};function Se(){return l({mutationFn:e=>i("/api/supplier-portal/apply",{method:"POST",body:JSON.stringify(e),headers:p})})}function ye(e){const t=N(e);return{publicToken:t?.error==="file_rejected"?t.publicToken??null:null,message:G(e,"We could not submit your application. Please try again.")}}function ge(e){return h({queryKey:w(e??""),enabled:!!e,retry:!1,queryFn:()=>i(`/api/supplier-portal/application/${encodeURIComponent(e??"")}`)})}function ve(e){const t=d();return l({mutationFn:n=>i(`/api/supplier-portal/application/${encodeURIComponent(e)}/respond`,{method:"POST",body:JSON.stringify(n),headers:p}),onSuccess:()=>{t.invalidateQueries({queryKey:w(e)})}})}function Ne(e){const t=d();return l({mutationFn:()=>i(`/api/supplier-portal/application/${encodeURIComponent(e)}/withdraw`,{method:"POST",headers:p}),onSuccess:()=>{t.invalidateQueries({queryKey:w(e)})}})}function ke(e){return h({queryKey:Z(e??""),enabled:!!e,retry:!1,queryFn:()=>i(`/api/supplier-portal/invite/${encodeURIComponent(e??"")}`)})}function we(e){const t=d();return l({mutationFn:()=>i(`/api/supplier-portal/invite/${encodeURIComponent(e)}/accept`,{method:"POST",headers:p}),onSuccess:()=>{t.invalidateQueries({queryKey:x})}})}function je(e){return h({queryKey:b,enabled:e,retry:!1,queryFn:()=>i("/api/supplier-portal/me")})}function Ce(){const e=d();return l({mutationFn:t=>i("/api/supplier-portal/profile",{method:"PATCH",body:JSON.stringify(t),headers:p}),onSuccess:()=>{e.invalidateQueries({queryKey:b})}})}function Ee(){const e=d();return l({mutationFn:t=>i("/api/supplier-portal/contacts",{method:"POST",body:JSON.stringify(t),headers:p}),onSuccess:()=>{e.invalidateQueries({queryKey:b})}})}function Fe(){const e=d();return l({mutationFn:({id:t,...n})=>i(`/api/supplier-portal/contacts/${t}`,{method:"PUT",body:JSON.stringify(n),headers:p}),onSuccess:()=>{e.invalidateQueries({queryKey:b})}})}function Pe(){const e=d();return l({mutationFn:t=>i(`/api/supplier-portal/contacts/${t}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:b})}})}function Te(e){return h({queryKey:ee,enabled:e,retry:!1,queryFn:()=>i("/api/supplier-portal/files")})}function Ie(){const e=d();return l({mutationFn:t=>i("/api/supplier-portal/files",{method:"POST",body:JSON.stringify({files:t}),headers:p}),onSuccess:()=>{e.invalidateQueries({queryKey:x})}})}function _e(e,t){return h({queryKey:te(),enabled:e,retry:!1,queryFn:()=>i("/api/supplier-portal/submissions")})}function Le(){const e=d();return l({mutationFn:t=>i("/api/supplier-portal/submissions",{method:"POST",body:JSON.stringify(t),headers:p}),onSuccess:()=>
1{e.invalidateQueries({queryKey:x})}})}function Oe(){const e=d();return l({mutationFn:({id:t,action:n,...s})=>i(`/api/supplier-portal/submissions/${t}`,{method:"PATCH",body:JSON.stringify(n?{action:n,...s}:s),headers:p}),onSuccess:()=>{e.invalidateQueries({queryKey:x})}})}const re={submitted:"Submitted",under_review:"Under review",needs_info:"Needs information",approved:"Approved",accepted:"Accepted",rejected:"Not accepted",withdrawn:"Withdrawn"};function ne(e){return re[e]??e.replace(/_/g," ")}const ae={submitted:"bg-muted text-muted-foreground border-card-border",under_review:"bg-amber-tint text-amber border-amber/25",needs_info:"bg-amber-tint text-amber border-amber/25",approved:"bg-vida-mint-soft text-vida-green-800 border-vida-green-800/15",accepted:"bg-vida-mint-soft text-vida-green-800 border-vida-green-800/15",rejected:"bg-danger/10 text-danger border-danger/25",withdrawn:"bg-muted text-muted-foreground border-card-border"};function ie(e){return ae[e]??"bg-muted text-muted-foreground border-card-border"}function Ae(e){return e==null?"":`$${(e/100).toFixed(2)}`}function qe(e){return A(e)}function Ue(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}const Re="w-full rounded-lg border border-ink/15 bg-white px-3 py-2 text-base sm:text-sm text-ink placeholder:text-ink-3 outline-none focus:border-vida-green-600 dark:border-white/15 dark:bg-white/5 dark:text-white dark:placeholder:text-white/40",se="w-full rounded-lg border border-ink/15 bg-white px-3 text-base sm:text-sm text-ink dark:border-white/15 dark:bg-white/5 dark:text-white",$e=[{value:"CN",label:"China"},{value:"US",label:"United States"},{value:"EU",label:"Europe"},{value:"OTHER",label:"Other"}],Ke=[{value:"compound",label:"Compounds"},{value:"packaging",label:"Packaging"},{value:"equipment",label:"Equipment"},{value:"general",label:"General goods"},{value:"other",label:"Other"}],Be=[{value:"whatsapp",label:"WhatsApp"},{value:"telegram",label:"Telegram"},{value:"email",label:"Email"},{value:"wechat",label:"WeChat"}];function oe({children:e}){return r.jsx(B,{className:"py-12",children:r.jsx(z,{className:"mx-auto max-w-lg text-center",children:e})})}function ze({label:e}){return r.jsx(oe,{children:r.jsxs("div",{className:"flex items-center justify-center gap-3 text-ink-2 dark:text-white/70",children:[r.jsx(J,{className:"size-5 animate-spin"}),r.jsx("span",{className:"text-body",children:e})]})})}function Qe({message:e}){return e?r.jsx("div",{className:"rounded-lg border border-danger/25 bg-danger/10 px-4 py-3 text-sm text-danger",children:e}):null}function le({status:e,className:t}){return r.jsx("span",{className:v("inline-flex items-center rounded-pill border px-2.5 py-0.5 text-xs font-semibold",ie(e),t),children:ne(e)})}function De({label:e,htmlFor:t,hint:n,required:s,children:u,className:m}){const f=t?"label":"span";return r.jsxs("div",{className:m,children:[r.jsxs(f,{...t?{htmlFor:t}:{},className:"mb-1.5 block text-sm font-medium text-ink dark:text-white",children:[e,s?" *":""]}),u,n?r.jsx("p",{className:"mt-1 text-caption text-ink-3 dark:text-white/55",children:n}):null]})}function ue({value:e,onChange:t,options:n,placeholder:s,triggerClassName:u,ariaLabel:m}){return r.jsxs(q,{value:e,onValueChange:t,children:[r.jsx(U,{"aria-label":m,className:v(se,"h-10",u),children:r.jsx(R,{placeholder:s??"Select"})}),r.jsx($,{children:n.map(f=>r.jsx(K,{value:f.value,children:f.label},f.value))})]})}const ce=Object.keys(g).map(e=>({value:e,label:g[e]}));function Me({staged:e,onChange:t,fixedKind:n,maxFiles:s=H,onError:u,disabled:m,label:f="Attach files",hint:I}){const y=E.useRef(null),j=E.useId(),_=a=>{if(!a||a.length===0)return;const c=[],o=[];for(const S of Array.from(a)){if(e.length+c.length>=s){o.push(`You can attach up to ${s} files.`);break}const C=V(S);if(C){o.push(C);continue}c.push({file:S,kind:n??"price_list"})}u(o.length>0?o.join(" "):null),c.length>0&&t([...e,...c]),y.current&&(y.current.value="")},L=a=>{t(e.filter((c,o)=>o!==a)),u(null)},O=(a,c)=>{t(e.map((o,S)=>S===a?{...o,kind:c}:o))};return r.jsxs("div",{children:[r.jsx("span",{className:"mb-1.5 block text-sm font-medium text-ink dark:text-white",children:f}),r.jsx("p",{className:"mb-2 text-caption text-ink-3 dark:text-white/55",children:I??"CSV, TSV, TXT, XLSX, XLS, or PDF. Up to 5 files, 5 MB each. A structured price list parses fastest."}),r.jsx("input",{ref:y,id:j,type:"file",multiple:!0,accept:W,disabled:m,onChange:a=>_(a.target.files),className:"sr-only"}),r.jsxs("label",{htmlFor:j,className:v("inline-flex cursor-pointer items-center gap-2 rounded-pill border border-ink/15 bg-white px-4 py-2 text-sm font-semibold text-ink","hover:border-vida-green-600 dark:border-white/15 dark:bg-white/5 dark:text-white",m&&"pointer-events-none opacity-50"),children:[r.jsx(D,{className:"size-4"}),"Choose files"]}),e.length>0&&r.jsx("ul",{className:"mt-3 space-y-2",children:e.map((a,c)=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-card-border bg-card/70 px-3 py-2",children:[r.jsx(T,{className:"size-4 shrink-0 text-ink-3 dark:text-white/55"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-ink dark:text-white",children:a.file.name}),r.jsx("span",{className:"text-caption text-ink-3 dark:text-white/55",children:k(a.file.size)}),!n&&r.jsx(ue,{value:a.kind,onChange:o=>O(c,o),options:ce,ariaLabel:`File type for ${a.file.name}`,triggerClassName:"h-9 w-40 shrink-0"}),r.jsx("button",{type:"button",onClick:()=>L(c),"aria-label":`Remove ${a.file.name}`,className:"shrink-0 rounded-lg border border-ink/15 px-2 py-1.5 text-ink-3 hover:text-danger dark:border-white/15 dark:text-white/50",children:r.jsx(M,{className:"size-4"})})]},`${a.file.name}-${a.file.lastModified}-${a.file.size}`))})]})}function Je({files:e}){return e.length===0?r.jsx("p",{className:"text-body text-ink-2 dark:text-white/70",children:"No files uploaded yet."}):r.jsx("ul",{className:"space-y-2",children:e.map(t=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-card-border bg-card/70 px-3 py-2",children:[r.jsx(T,{className:"size-4 shrink-0 text-ink-3 dark:text-white/55"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-ink dark:text-white",children:t.originalFilename}),r.jsxs("span",{className:"text-caption text-ink-3 dark:text-white/55",children:[g[t.kind]??t.kind," · ",k(t.sizeBytes),t.parsedRowCount!=null?` · ${t.parsedRowCount} rows`:""]}),r.jsx(le,{status:t.parseStatus})]},t.id))})}function Ge({title:e,body:t}){return r.jsxs(r.Fragment,{children:[r.jsx(Q,{as:"h1",center:!0,title:e}),t?r.jsx("p",{className:"mt-3 text-body text-ink-2 dark:text-white/70",children:t}):null]})}export{Oe as A,Ae as B,ue as C,qe as D,Qe as E,De as F,Re as I,ze as L,Ge as N,$e as O,le as S,Je as U,Ke as a,Be as b,Me as c,ge as d,Ne as e,oe as f,G as g,Ue as h,ne as i,ve as j,ke as k,we as l,je as m,he as n,fe as o,ye as p,Ce as q,_e as r,be as s,Le as t,Se as u,Te as v,Ie as w,Ee as x,Fe as y,Pe as z};
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.