1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[76034],{76034:(e,t,s)=>{s.d(t,{IntelligentSearch:()=>u});var a=s(95155),r=s(12115),l=s(5565),n=s(48173),i=s.n(n),o=s(76046),c=s(76877);let d=["kitchen gadgets","wireless earbuds","home decor","fitness gear","skincare serum","pet supplies","men's shorts","kids toys"],m=[{label:"Electronics",icon:"devices",slug:"electronics"},{label:"Home & Kitchen",icon:"kitchen",slug:"home-kitchen"},{label:"Health & Beauty",icon:"spa",slug:"health-beauty"},{label:"Fashion",icon:"checkroom",slug:"fashion"},{label:"Sports",icon:"fitness_center",slug:"sports"},{label:"Pet Supplies",icon:"pets",slug:"pet-supplies"},{label:"Jewelry",icon:"diamond",slug:"jewelry"},{label:"Toys",icon:"toys",slug:"toys"}],x={"Men's":"man","Women's":"woman",Kids:"child_care",Wireless:"bluetooth",Waterproof:"water_drop","Natural / Organic":"eco","Fast Shipping":"local_shipping"};function u({placeholder:e="Search products by name, style, use case...",defaultCategory:t,categoryLabel:s,children:n}){let[u,p]=(0,r.useState)(""),[b,g]=(0,r.useState)(!1),[h,f]=(0,r.useState)(!1),[y,j]=(0,r.useState)([]),[k,N]=(0,r.useState)(null),[v,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[_,$]=(0,r.useState)(!0),[E,F]=(0,r.useState)([]),[I,L]=(0,r.useState)(!1),[R,A]=(0,r.useState)(!1),T=(0,r.useRef)(null),z=(0,r.useRef)(null),P=(0,r.useRef)(null),U=(0,r.useRef)(null);(0,o.useRouter)(),(0,r.useEffect)(()=>{function e(e){z.current&&!z.current.contains(e.target)&&(A(!1),g(!1))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.useEffect)(()=>{let e=u.trim();if(e.length<2){j([]),N(null),w(!1),S(!1);return}let s=setTimeout(async()=>{P.current&&P.current.abort(),P.current=new AbortController,f(!0);try{let s=t&&_?`&category=${encodeURIComponent(t)}`:"",a=await fetch(`/api/search/intelligent?q=${encodeURIComponent(e)}&limit=24${s}`,{signal:P.current.signal}),r=await a.json();j(r.products||[]),N(r.intent||null),S(r.expandedSearch??!1),w(!0)}catch(e){"AbortError"!==e.name&&(j([]),w(!0))}finally{f(!1)}},300);return()=>clearTimeout(s)},[u,t,_]),(0,r.useEffect)(()=>{let e=u.trim();if(e.length<2){F([]);return}let t=setTimeout(async()=>{U.current&&U.current.abort(),U.current=new AbortController,L(!0);try{let t=await fetch(`/api/search/suggest?q=${encodeURIComponent(e)}`,{signal:U.current.signal}),s=await t.json();F(s.suggestions||[])}catch{}finally{L(!1)}},150);return()=>clearTimeout(t)},[u]);let W=(0,r.useCallback)(()=>{p(""),j([]),N(null),w(!1),F([]),A(!1),S(!1),T.current?.focus()},[]),q=u.trim().length>=2,B=R&&q&&E.length>0;return(0,a.jsxs)("div",{ref:z,className:"w-full",children:[(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),u.trim()&&A(!1)},className:"relative",children:[(0,a.jsxs)("div",{className:`flex items-center gap-2 px-4 py-3 rounded-2xl border-2 transition-all duration-200 bg-white dark:bg-slate-800 shadow-sm ${b?"border-primary ring-4 ring-primary/10 shadow-lg":"border-slate-200 dark:border-slate-700"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-xl shrink-0 [font-variation-settings:'FILL'_1]",children:h?"hourglass_top":"search"}),(0,a.jsx)("input",{ref:T,type:"text",value:u,onChange:e=>{p(e.target.value),A(!0)},onFocus:()=>{g(!0),A(!0)},placeholder:e,className:"flex-1 bg-transparent text-slate-900 dark:text-slate-100 placeholder:text-slate-400 text-base focus:outline-none min-w-0",autoComplete:"off",spellCheck:!1}),h&&(0,a.jsx)("span",{className:"shrink-0 w-4 h-4 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),u&&!h&&(0,a.jsx)("button",{type:"button",onClick:W,"aria-label":"Clear",className:"shrink-0 text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),B&&(0,a.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white dark:bg-slate-800 rounded-2xl shadow-2xl border border-slate-200 dark:border-slate-700 overflow-hidden z-[200] animate-in fade-in slide-in-from-top-1 duration-150",children:[(0,a.jsx)("div",{className:"p-2 space-y-0.5",children:E.map(e=>(0,a.jsxs)(i(),{href:`/products/${e.slug}`,onClick:()=>{A(!1)},className:"flex items-center gap-3 px-3 py-2.5 hover:bg-slate-50 dark:hover:bg-slate-700/50 rounded-xl group transition-colors",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg overflow-hidden bg-slate-100 dar
1k:bg-slate-700 shrink-0 relative",children:e.image?(0,a.jsx)(l.default,{src:e.image,alt:e.name,fill:!0,sizes:"40px",className:"object-cover"}):(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-slate-300 text-sm",children:"image"})})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-slate-800 dark:text-slate-100 truncate group-hover:text-primary transition-colors",children:e.name}),(0,a.jsx)("p",{className:"text-xs text-slate-400 truncate",children:e.category})]}),(0,a.jsxs)("p",{className:"text-sm font-black text-primary shrink-0",children:["CA$",(e.price/100).toFixed(2)]})]},e.id))}),(0,a.jsxs)("button",{type:"submit",className:"w-full px-4 py-3 bg-slate-50 dark:bg-slate-700/40 border-t border-slate-100 dark:border-slate-700 text-xs font-bold text-primary hover:text-primary/80 flex items-center justify-center gap-1 transition-colors",children:["View all results for â",u,"â",(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"arrow_forward"})]})]})]}),b&&!q&&!q&&(0,a.jsxs)("div",{className:"mt-3 p-4 bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 shadow-lg animate-in fade-in slide-in-from-top-2 duration-150 z-[150] relative",children:[(0,a.jsx)("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400 mb-2",children:"Popular Searches"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mb-4",children:d.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{p(e),A(!1),T.current?.focus()},className:"flex items-center gap-1 px-3 py-1.5 bg-slate-100 dark:bg-slate-700 text-slate-700 dark:text-slate-300 rounded-full text-xs font-semibold hover:bg-primary/10 hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"trending_up"}),e]},e))}),(0,a.jsx)("p",{className:"text-[11px] font-black uppercase tracking-widest text-slate-400 mb-2",children:"Browse Categories"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:m.map(e=>(0,a.jsxs)(i(),{href:`/collections/${e.slug}`,onClick:()=>g(!1),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-slate-200 dark:border-slate-600 bg-white dark:bg-slate-700/50 text-xs font-semibold text-slate-600 dark:text-slate-300 hover:border-primary hover:text-primary hover:bg-primary/5 transition-all",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] [font-variation-settings:'FILL'_1]",children:e.icon}),e.label]},e.slug))})]}),q?(0,a.jsxs)("div",{className:"mt-5",children:[k&&(k.attributes.length>0||k.detectedCategory||k.scopeCategory)&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,a.jsx)("span",{className:"text-xs text-slate-500 font-medium",children:"Searching for:"}),t&&(0,a.jsxs)("button",{type:"button",onClick:()=>{$(e=>!e)},className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border transition-all ${_?"bg-primary text-white border-primary":"bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 border-slate-300 dark:border-slate-600 hover:border-primary hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"category"}),_?`In: ${s||t}`:"All Categories"]}),k.detectedCategory&&!k.scopeCategory&&(0,a.jsxs)("span",{className:"flex items-center gap-1 px-3 py-1 rounded-full bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 text-xs font-bold",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"category"}),k.detectedCategory]}),k.attributes.map(e=>(0,a.jsxs)("span",{className:"flex items-center gap-1 px-3 py-1 rounded-full bg-primary/10 text-primary text-xs font-bold",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px] [font-variation-settings:'FILL'_1]",children:x[e]||"label"}),e]},e)),C&&(0,a.jsxs)("span",{className:"flex items-center gap-1 px-3 py-1 rounded-full bg-amber-100 dar
1k:bg-amber-900/30 text-amber-700 dark:text-amber-300 text-xs font-medium",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"info"}),"Showing results across all categories"]})]}),!h&&v&&(0,a.jsx)("p",{className:"text-sm text-slate-500 mb-4",children:y.length>0?(0,a.jsxs)(a.Fragment,{children:[y.length," product",1!==y.length?"s":""," found"]}):(0,a.jsxs)(a.Fragment,{children:["No results for ",(0,a.jsxs)("span",{className:"font-semibold text-slate-700 dark:text-slate-300",children:["â",u,"â"]})]})}),h&&0===y.length&&(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:Array.from({length:12}).map((e,t)=>(0,a.jsx)("div",{className:"rounded-xl bg-slate-100 dark:bg-slate-800 animate-pulse aspect-[3/4]"},t))}),v&&!h&&0===y.length&&(0,a.jsxs)("div",{className:"text-center py-14 bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-5xl text-slate-300 mb-3 block",children:"search_off"}),(0,a.jsxs)("p",{className:"font-semibold text-slate-700 dark:text-slate-300 mb-1",children:["No products found for â",u,"â"]}),(0,a.jsx)("p",{className:"text-sm text-slate-400 mb-4",children:"Try different keywords or browse a category below"}),(0,a.jsx)("div",{className:"flex flex-wrap justify-center gap-2",children:m.slice(0,5).map(e=>(0,a.jsx)(i(),{href:`/collections/${e.slug}`,className:"px-4 py-1.5 rounded-full bg-slate-100 dark:bg-slate-700 text-xs font-semibold text-slate-600 dark:text-slate-300 hover:bg-primary/10 hover:text-primary transition-colors",children:e.label},e.slug))})]}),y.length>0&&(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:y.map(e=>(0,a.jsx)(c.ProductCard,{product:e},e.id))})]}):n]})}}}]);
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.