1import{r as l,j as e}from"./vendor-react-DqpSzHn6.js";import{u as M,t as z,H as Z,X as $}from"./index-DGEWvrlJ.js";import{S as A}from"./search-B2kDFC7o.js";import{C as B}from"./chevron-up-COnytpLy.js";import{C as U}from"./chevron-down-CiPRyB6_.js";import"./vendor-clerk-CqKdBWxc.js";import"./vendor-query-BN-D8v14.js";import"./vendor-router-D3JZmwjY.js";const W=({isOpen:o,onClose:m,filtersAll:d,setFiltersAll:v,recalcFilters:N})=>{const[n,p]=l.useState(""),[f,u]=l.useState(!1),[w,g]=l.useState([]),[r,x]=l.useState([]);M();const b=l.useRef(!0),{searchService:C}=z();l.useEffect(()=>{o&&j()},[o]),l.useEffect(()=>{var s;o&&x((s=d==null?void 0:d.topics)!=null&&s.filter?[...d.topics.filter]:[])},[o]),l.useEffect(()=>{let s;return o&&!b.current&&(s=setTimeout(()=>{j(n)},600)),b.current=!1,()=>clearTimeout(s)},[n]);const j=async(s="")=>{u(!0);try{const i=await C.getTopics("b2b",s);let t=i.categoryList||i||[];s&&Array.isArray(t)&&t.length>0&&t[0].name&&!t[0].subCategoryList&&(t=[{name:"Search Results",topicsCount:t.length,subCategoryList:[{name:"Results",topicsCount:t.length,topics:t}]}]),g(t.map(a=>({...a,isOpen:s.trim()})))}catch(i){console.error("Failed to load data stream topics",i)}finally{u(!1)}},y=s=>{p(s)},k=s=>{g(i=>i.map((t,a)=>a===s?{...t,isOpen:!t.isOpen}:t))},S=s=>{r.includes(s)?x(t=>t.filter(a=>a!==s)):r.length<100&&x(a=>[...a,s])},E=s=>{x(i=>i.filter(t=>t!==s))},T=()=>{x([]),p("")},L=()=>{v(s=>{const i=s.topics;if(!i)return s;let t={...s,topics:{...i,filter:[...r],filterNormal:[...r]}};return t=N(t),t}),m()},F=s=>{const i=[];return s.forEach(t=>{t.subCategoryList.forEach(a=>{a.topics.forEach(c=>{i.push(c)})})}),i},h=w,R=F(h).filter(s=>s.name.toLowerCase().includes(n.toLowerCase()));return o?e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/20 backdrop-blur-sm",onClick:m}),e.jsxs("div",{className:"relative z-[101] w-full max-w-[900px] max-h-[90vh] min-h-[600px] bg-white border-[3px] border-hairline rounded-2xl flex flex-col shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-0 right-0 bottom-0 h-px bg-hairline-soft z-0"}),e.jsx("div",{className:"flex flex-col items-start gap-2 sm:flex-row sm:gap-6 sm:items-center px-4 py-2 relative z-10 bg-white",children:e.jsx("span",{className:"text-base font-semibold text-ink",children:"Data Stream"})}),e.jsx("div",{className:"h-px bg-hairline-soft w-full"}),!n.trim()&&e.jsxs("div",{className:"absolute top-3.5 right-4 text-xs text-gray-500 tracking-[-0.4px] z-20",children:[R.length," topics available"]})]}),e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row flex-1 bg-white overflow-auto",children:[e.jsxs("div",{className:"max-w-[100%] sm:max-w-[50%] lg:max-w-[400px] w-full border-r border-hairline-soft flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-hairline-soft flex-shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[rgba(13,42,76,0.4)] w-4 h-4"}),e.jsx("input",{type:"text",placeholder:"Search topics...",value:n,onChange:s=>y(s.target.value),className:"w-full pl-10 pr-4 py-2 border placeholder:font-medium border-hairline rounded-lg text-sm placeholder:text-[rgba(13,42,76,0.4)] focus:outline-none focus:border-brand bg-white"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:f?e.jsxs("div",{className:"flex items-center justify-center p-8",children:[e.jsx(Z,{className:"w-6 h-6 animate-spin text-brand"}),e.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Loading topics..."})]}):e.jsxs("div",{className:"divide-y divide-hairline-soft",children:[h.map((s,i)=>e.jsxs("div",{className:"border-b border-hairline-soft",children:[e.jsxs("button",{onClick:()=>k(i),className:"w-full flex items-center justify-between p-4 hover:bg-gray-50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-ink",children:s.name}),!n.trim()&&e.jsxs("span",{className:"text-xs text-gray-500",children:["(",s.topicsCount,")"]})]}),s.isOpen?e.jsx(B,{className:"w-4 h-4 text-gray-500"}):e.jsx(U,{className:"w-4 h-4 text-gray-500"})]}),s.isOpen&&e.jsx("div",{className:"pl-4",children:s.subCategoryList.map((t,a)=>e.jsxs("div",{className:"border-l border-hairline-soft ml-2",children:[e.jsx("div",{className:"px-4 py-2",children:e.jsxs("div",{className:"text-xs font-medium text-gray-600",children:[t.name," (",!n.trim()&&e.jsx("span",{children:t.topicsCount}),")"]})}),t.topics.map((c,D)=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer hover:bg-gray-50 p-4 pl-[16px] transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-ink tracking-[-0.4px] truncate",children:c.name}),c.description&&e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:c.description})]}),e.jsx("input",{type:"checkbox",checked:r.includes(c.name),onChange:()=>S(c.name),className:"w-4 h-4 text-brand border-hairline focus:ring-brand focus:ring-offset-0"})]},`${i}-${a}
1-${D}`))]},a))})]},i)),h.length===0&&!f&&e.jsx("div",{className:"text-xs text-[rgba(13,42,76,0.4)] p-4 text-center",children:"No topics found"})]})})]}),e.jsx("div",{className:"flex-1 p-4 pb-0 sm:pb-4",children:r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:"48",height:"48",fill:"white"}),e.jsx("path",{d:"M22.3389 13.5056C25.5849 11.8993 28.0658 9.07677 29.2425 5.6515C29.3178 5.44444 30.5413 12.3997 34.6636 13.7409C34.6636 13.7409 29.6754 16.1315 28.4942 20.8656C28.4989 20.9315 28.2119 17.1056 22.3389 13.5056Z",fill:"#0D2A4C"}),e.jsx("path",{d:"M29.534 36.0327C32.2066 34.7083 34.2468 32.3806 35.2093 29.5574C35.2705 29.388 36.2728 35.1103 39.6799 36.2115C39.6799 36.2115 35.5811 38.1786 34.6069 42.0703C34.5928 42.1221 34.3575 38.9786 29.534 36.0327Z",fill:"#0D2A4C"}),e.jsx("path",{d:"M8 27.3362C10.5797 26.0557 12.551 23.8105 13.4871 21.0868C13.5435 20.9174 14.5176 26.4421 17.8071 27.5056C17.8071 27.5056 13.8447 29.388 12.9082 33.1527C12.8847 33.2139 12.6588 30.1786 8 27.3362Z",fill:"#0D2A4C"})]}),e.jsx("h3",{className:"text-lg font-medium text-ink mt-4 mb-2",children:"Nothing here... yet!"}),e.jsx("p",{className:"text-sm text-ink opacity-70 text-center px-16",children:"Start selecting topics, we will save your selection right here"})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-sm font-medium text-ink tracking-[-0.4px] mb-3",children:["Selected Topics (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(s=>e.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 text-ink px-3 py-1.5 rounded-lg text-sm",children:[e.jsx("span",{className:"max-w-[200px] truncate",children:s}),e.jsx("button",{onClick:()=>E(s),className:"hover:bg-[#E0ECFF] rounded-full p-0.5",children:e.jsx($,{className:"w-3 h-3"})})]},s))}),(r==null?void 0:r.length)>=100&&e.jsx("div",{className:"mt-3 font-bold text-red-500 text-[12px]",children:"Maximum search limit is 100 topics."})]})})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-hairline-soft bg-surface flex-shrink-0",children:[e.jsx("button",{onClick:T,className:"px-2 py-1 text-sm border border-brand bg-white font-medium text-brand hover:bg-[#F0F4FF] rounded-lg transition-colors tracking-[-0.4px]",children:"Reset"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:m,className:"px-2 py-1 text-sm font-medium text-ink bg-white border border-hairline hover:bg-gray-50 rounded-lg transition-colors tracking-[-0.4px]",children:"Cancel"}),e.jsx("button",{onClick:L,className:"px-2 py-1 text-sm font-medium border border-[#0073F5] text-white bg-brand hover:bg-[#1E73E6] rounded-lg transition-colors tracking-[-0.4px] min-w-[60px]",children:"Save"})]})]})]})]}):null};export{W as DataStreamModalManual};
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.