import{R as a,j as e,E as k,at as P,ee as E,as as R,a9 as i,g as V,i as w}from"./app-BgLa5dit.js";import{p as D}from"./_VQbNI_n.chunk.js";import{u as H}from"./DVk23zZ1.chunk.js";function F(c){const[u,x]=a.useState([]),[f,C]=a.useState([]),[g,j]=a.useState(""),[l,d]=a.useState([]),[n,p]=a.useState(""),{setCrmIds:S}=H({reset:!0}),o=a.useRef(null);function b(t){var r;const s=(r=t.target.files)==null?void 0:r[0];s&&D.parse(s,{header:!0,skipEmptyLines:!0,complete:h=>{const N=h.meta.fields||[];x(N),C(h.data)}})}function v(t){j(t.target.value);const s=f.map(r=>r[t.target.value]);d(m(s))}function m(t){return t.filter(s=>!!s&&!isNaN(Number(s)))}function I(){if(n.length){p(""),d(m(n.split(/[\s,]+/)));return}S(l),V.trigger({application:w.SYSTEM,action:c.searchAction},{replace:!0}),c.closePopup()}return e.jsxs(k,{title:"Search list of CVC IDs",closePopup:c.closePopup,children:[!l.length&&e.jsxs("div",{className:"mb-3",children:[u.length?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"form-label",children:"Select a column"}),e.jsxs("select",{className:"form-select",value:g,onChange:v,children:[e.jsx("option",{value:"",disabled:!0,children:"Select a column"}),u.map(t=>e.jsx("option",{value:t,children:t},t))]})]}):e.jsx(P,{className:"btn btn-outline-dark",svg:E,onClick:()=>{o.current.value=null,o.current.click()},children:"Upload CSV"}),e.jsx("input",{type:"file",className:"file-select d-none",accept:"text/csv",ref:o,onChange:b}),e.jsx("hr",{}),e.jsxs("div",{children:[e.jsx("label",{className:"form-label",children:"OR Paste CVC IDs"}),e.jsx("textarea",{className:"form-control",rows:3,placeholder:"Paste CVC IDs here",value:n,onChange:t=>p(t.target.value)})]})]}),!!l.length&&e.jsxs("div",{children:[e.jsxs("label",{className:"form-label",children:["Extracted ",l.length," CVC IDs:"]}),e.jsx(R.Scrollbars,{autoHeight:!0,autoHeightMax:300,children:e.jsx("ul",{children:l.map((t,s)=>e.jsx("li",{children:t},s))})})]}),e.jsxs(i,{children:[e.jsx(i.Cancel,{onClick:c.closePopup}),e.jsx(i.Submit,{text:n.length?"Next":"Search",variant:"dark",disabled:!l.length&&!n.length,onClick:I})]})]})}export{F as CrmIdSelectView};
//# sourceMappingURL=BSExgNUt.chunk.js.map
