PageSourceSearch

https://www.hitekmarketing.com/_next/static/chunks/45808-45a26b26bb6f4a22.js

js hitekmarketing.com collected 2026-10-09 22:05:34 UTC 16,241 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[45808],{39540:(e,t,a)=>{a.d(t,{T:()=>i});var s=a(95155);a(12115);var r=a(91337);function i({className:e,...t}){return(0,s.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}},45808:(e,t,a)=>{a.d(t,{KbManager:()=>C,W:()=>k});var s=a(95155),r=a(12115),i=a(73321),l=a(74350),n=a(4474),d=a(39658),o=a(39540),c=a(79792),u=a(90466),h=a(38291),x=a(79984),m=a(77833),p=a(61878),g=a(91958),f=a(51914),b=a(48368),j=a(22164),v=a(49387),w=a(68459);let y={id:null,title:"",body:"",source_url:"",is_published:!0,tagsInput:"",audience:"internal",category:"general"},N=["support","company-info","product-info","policies","glossary","promotions","operations","sales","general"];function k(e){return e.split(/[-_]/).map(e=>e?e[0].toUpperCase()+e.slice(1):e).join(" ")}function C({initialArticles:e,companyName:t}){let a=(0,i.useRouter)(),{toast:_}=(0,m.d)(),[$,E]=(0,r.useTransition)(),[S,A]=(0,r.useState)(!1),[L,z]=(0,r.useState)(y),[T,I]=(0,r.useState)(""),[D,R]=(0,r.useState)(null),[O,H]=(0,r.useState)(""),[P,F]=(0,r.useState)(""),B=[...new Set(e.map(e=>e.category??"general").concat(O?[O]:[]))].sort(),M=e.filter(e=>{if(O&&(e.category??"general")!==O||P&&(e.audience??"internal")!==P)return!1;if(!T)return!0;let t=T.toLowerCase();return e.title.toLowerCase().includes(t)||(e.tags??[]).some(e=>e.toLowerCase().includes(t))}),W=()=>{z(y),A(!0)},U=e=>{z({id:e.id,title:e.title,body:e.body,source_url:e.source_url??"",is_published:e.is_published,tagsInput:(e.tags??[]).join(", "),audience:e.audience??"internal",category:e.category??"general"}),A(!0)},Z=async e=>{E(async()=>{try{let t=await fetch(`/api/support/kb/${e}/reindex`,{method:"POST"});if(!t.ok)throw Error(await t.text());_.success("Reindexed"),a.refresh()}catch(e){_.error(e instanceof Error?e.message:"Reindex failed")}})},G=e.filter(e=>e.needs_reindex).length;return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h1",{className:"text-2xl font-bold",children:["Knowledge Base — ",t]}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:["The company's master knowledge base — staff read it in the drawer (Cmd+Shift+/). Customer-facing articles also power the support AI + Help tab. ",e.length," total."]})]}),(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(p.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,s.jsx)(d.p,{placeholder:"Search title or tag…",value:T,onChange:e=>I(e.target.value),className:"pl-9 w-64"})]}),G>0&&(0,s.jsxs)(n.$,{variant:"outline",onClick:()=>void E(async()=>{try{let e=await fetch("/api/support/kb/reindex-all",{method:"POST"});if(!e.ok)throw Error(await e.text());let t=await e.json();t.failed>0?_.error(`Reindexed ${t.reindexed}/${t.total} (${t.failed} failed — see console)`):_.success(`Reindexed ${t.reindexed} article${1===t.reindexed?"":"s"}`),a.refresh()}catch(e){_.error(e instanceof Error?e.message:"Reindex failed")}}),disabled:$,children:[(0,s.jsx)(g.A,{className:"w-4 h-4 mr-2"}),"Reindex ",G," pending"]}),(0,s.jsxs)(n.$,{onClick:W,className:"!bg-[image:linear-gradient(180deg,#ed0004,#4b0001)] !text-white",children:[(0,s.jsx)(f.A,{className:"w-4 h-4 mr-2"}),"New article"]})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(n.$,{size:"sm",variant:""===O?"default":"outline",onClick:()=>H(""),children:"All categories"}),B.map(e=>(0,s.jsx)(n.$,{size:"sm",variant:O===e?"default":"outline",onClick:()=>H(O===e?"":e),children:k(e)},e)),(0,s.jsx)("div",{className:"mx-1 h-5 w-px bg-border"}),(0,s.jsx)(n.$,{size:"sm",variant:"internal"===P?"default":"outline",onClick:()=>F("internal"===P?"":"internal"),children:"Internal"}),(0,s.jsx)(n.$,{size:"sm",variant:"customer"===P?"default":"outline",onClick:()=>F("customer"===P?"":"customer"),children:"Customer-facing"})]}),0===M.length?(0,s.jsx)(x.Zp,{children:(0,s.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,s.jsx)(b.A,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),(0,s.jsx)("p",{className:"text-muted-foreground mb-4",children:T||O||P?"No articles match your filters.":"No articles yet."}),!T&&!O&&!P&&(0,s.jsx)(n.$,{onClick:W,children:"Write the first one"})]})}):(0,s.jsx)("div",{className:"grid gap-3",children:M.map(e=>(0,s.jsxs)(x.Zp,{className:"hover:bg-muted/30 transition-colors",children:[(0,s.jsx)(x.aR,{className:"pb-3",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)(x.ZB,{className:"text-lg flex-1",children:(0,s.jsx)("button",{type:"button",onClick:()=>U(e),className:"text-left hover:underline",children:e.title})}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 shrink-0",children:[(0,s.jsx)(h.E,{variant:"outline",children:k(e.category??"general")}),(e.audience??"internal")==="customer"?(0,s.jsx)(h.E,{className:"!bg-emerald-500/15 !text-emerald-700 dark:!text-emerald-300 border-transparent",children:"Customer-facing"}):(0,s.jsx)(h.E,{className:"!bg-slate-500/15 !text-slate-700 dark:!text-slate-300 border-transparent",children:"Internal"}),e.is_published?(0,s.jsx)(h.E,{variant:"default",children:"Published"}):(0,s.jsx)(h.E,{variant:"secondary",children:"Draft"}),e.needs_reindex&&(0,s.jsxs)(h.E,{variant:"outline",children:[(0,s.jsx)(g.A,{className:"w-3 h-3 mr-1"}),"Needs reindex"]})]})]})}),(0,s.jsxs)(x.Wu,{className:"pt-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-3",children:[(0,s.jsxs)("span",{children:["Updated ",new Date(e.updated_at).toLocaleStr
1ing()]}),(e.tags??[]).length>0&&(0,s.jsx)("span",{children:(e.tags??[]).map(e=>`#${e}`).join(" ")}),e.source_url&&(0,s.jsxs)("a",{href:e.source_url,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center",children:["Source ",(0,s.jsx)(j.A,{className:"w-3 h-3 ml-1"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(n.$,{size:"sm",variant:"outline",onClick:()=>U(e),children:[(0,s.jsx)(v.A,{className:"w-3 h-3 mr-1"}),"Edit"]}),(0,s.jsxs)(n.$,{size:"sm",variant:"outline",onClick:()=>Z(e.id),disabled:$,children:[(0,s.jsx)(g.A,{className:"w-3 h-3 mr-1"}),"Reindex"]}),(0,s.jsxs)(n.$,{size:"sm",variant:"ghost",className:"text-red-600 hover:!text-red-700",onClick:()=>R(e.id),children:[(0,s.jsx)(w.A,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},e.id))}),(0,s.jsx)(l.lG,{open:S,onOpenChange:A,children:(0,s.jsxs)(l.Cf,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[(0,s.jsxs)(l.c7,{children:[(0,s.jsx)(l.L3,{children:L.id?"Edit article":"New article"}),(0,s.jsx)(l.rr,{children:"Saved articles are auto-chunked + re-embedded for AI retrieval."})]}),(0,s.jsxs)("div",{className:"space-y-4 py-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c.Label,{htmlFor:"title",children:"Title"}),(0,s.jsx)(d.p,{id:"title",value:L.title,onChange:e=>z(t=>({...t,title:e.target.value})),placeholder:"How to install ceramic tint",required:!0})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c.Label,{htmlFor:"body",children:"Body (Markdown supported)"}),(0,s.jsx)(o.T,{id:"body",value:L.body,onChange:e=>z(t=>({...t,body:e.target.value})),placeholder:"# Section heading\n\nSeparate paragraphs with blank lines.",rows:14,className:"font-mono text-sm",required:!0}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Approx. ",Math.ceil(L.body.length/4)," tokens"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c.Label,{htmlFor:"category",children:"Category"}),(0,s.jsx)(d.p,{id:"category",list:"kb-category-suggestions",value:L.category,onChange:e=>z(t=>({...t,category:e.target.value})),placeholder:"support, policies, product-info…"}),(0,s.jsx)("datalist",{id:"kb-category-suggestions",children:[...new Set([...N,...B])].map(e=>(0,s.jsx)("option",{value:e,children:k(e)},e))})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c.Label,{htmlFor:"tags",children:"Tags (comma-separated)"}),(0,s.jsx)(d.p,{id:"tags",value:L.tagsInput,onChange:e=>z(t=>({...t,tagsInput:e.target.value})),placeholder:"install, warranty, ceramic"})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c.Label,{htmlFor:"source_url",children:"Source URL (optional)"}),(0,s.jsx)(d.p,{id:"source_url",type:"url",value:L.source_url,onChange:e=>z(t=>({...t,source_url:e.target.value})),placeholder:"https://hitekfilms.com/install-guide"})]}),(0,s.jsxs)("div",{className:"rounded-lg border p-3 space-y-2",children:[(0,s.jsx)(c.Label,{className:"text-sm font-medium",children:"Who can see this?"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,s.jsx)(n.$,{type:"button",size:"sm",variant:"internal"===L.audience?"default":"outline",onClick:()=>z(e=>({...e,audience:"internal"})),children:"Internal — staff only"}),(0,s.jsx)(n.$,{type:"button",size:"sm",variant:"customer"===L.audience?"default":"outline",onClick:()=>z(e=>({...e,audience:"customer"})),children:"Customer-facing — feeds the AI chat + Help tab"})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"customer"===L.audience?"Dealers/customers can get this content from the support AI and the widget's Help tab. Don't include internal procedures.":"Only staff see this — in the Knowledge Base drawer and on this page. The customer AI never reads it."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(u.d,{id:"published",checked:L.is_published,onCheckedChange:e=>z(t=>({...t,is_published:e}))}),(0,s.jsxs)(c.Label,{htmlFor:"published",className:"cursor-pointer",children:["Published"," ",(0,s.jsx)("span",{className:"text-muted-foreground",children:"customer"===L.audience?"(visible to staff, the AI, and the Help tab)":"(visible to staff in the drawer)"})]})]})]}),(0,s.jsxs)(l.Es,{children:[(0,s.jsx)(n.$,{variant:"outline",onClick:()=>A(!1),disabled:$,children:"Cancel"}),(0,s.jsx)(n.$,{onClick:()=>{let e={title:L.title,body:L.body,source_url:L.source_url.trim()||null,is_published:L.is_published,tags:L.tagsInput.split(",").map(e=>
1e.trim()).filter(Boolean),audience:L.audience,category:L.category.trim().toLowerCase().replace(/\s+/g,"-")||"general"};E(async()=>{try{let t=L.id;if(L.id){let t=await fetch(`/api/support/kb/${L.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text())}else{let a=await fetch("/api/support/kb",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok)throw Error(await a.text());t=(await a.json()).id}if(t){let e=await fetch(`/api/support/kb/${t}/reindex`,{method:"POST"});if(e.ok)_.success(L.id?"Article updated + reindexed":"Article created + indexed");else{let t=await e.text();_.error(`Saved, but reindex failed: ${t.slice(0,120)}`)}}A(!1),a.refresh()}catch(e){_.error(e instanceof Error?e.message.slice(0,200):"Save failed")}})},disabled:$||!L.title||!L.body,className:"!bg-[image:linear-gradient(180deg,#ed0004,#4b0001)] !text-white",children:$?"Saving + indexing…":L.id?"Save changes":"Create article"})]})]})}),(0,s.jsx)(l.lG,{open:!!D,onOpenChange:e=>!e&&R(null),children:(0,s.jsxs)(l.Cf,{children:[(0,s.jsxs)(l.c7,{children:[(0,s.jsx)(l.L3,{children:"Delete this article?"}),(0,s.jsx)(l.rr,{children:"This will also remove its embedded chunks. Customers' chats won't see this article anymore."})]}),(0,s.jsxs)(l.Es,{children:[(0,s.jsx)(n.$,{variant:"outline",onClick:()=>R(null),disabled:$,children:"Cancel"}),(0,s.jsx)(n.$,{variant:"destructive",onClick:()=>D&&void E(async()=>{try{let e=await fetch(`/api/support/kb/${D}`,{method:"DELETE"});if(!e.ok)throw Error(await e.text());_.success("Article deleted"),R(null),a.refresh()}catch(e){_.error(e instanceof Error?e.message:"Delete failed")}}),disabled:$,children:$?"Deleting…":"Delete"})]})]})})]})}},74350:(e,t,a)=>{a.d(t,{Cf:()=>h,Es:()=>m,HM:()=>c,L3:()=>p,c7:()=>x,lG:()=>n,rr:()=>g,zM:()=>d});var s=a(95155);a(12115);var r=a(43146),i=a(33210),l=a(91337);function n({...e}){return(0,s.jsx)(r.bL,{"data-slot":"dialog",...e})}function d({...e}){return(0,s.jsx)(r.l9,{"data-slot":"dialog-trigger",...e})}function o({...e}){return(0,s.jsx)(r.ZL,{"data-slot":"dialog-portal",...e})}function c({...e}){return(0,s.jsx)(r.bm,{"data-slot":"dialog-close",...e})}function u({className:e,...t}){return(0,s.jsx)(r.hJ,{"data-slot":"dialog-overlay",className:(0,l.cn)("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function h({className:e,children:t,...a}){return(0,s.jsxs)(o,{"data-slot":"dialog-portal",children:[(0,s.jsx)(u,{}),(0,s.jsxs)(r.UC,{"data-slot":"dialog-content",className:(0,l.cn)("bg-card data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...a,children:[t,(0,s.jsxs)(r.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,s.jsx)(i.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function x({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,l.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function m({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-footer",className:(0,l.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function p({className:e,...t}){return(0,s.jsx)(r.hE,{"data-slot":"dialog-title",className:(0,l.cn)("text-lg leading-none font-semibold",e),...t})}function g({className:e,...t}){return(0,s.jsx)(r.VY,{"data-slot":"dialog-description",className:(0,l.cn)("text-muted-foreground text-sm",e),...t})}},79792:(e,t,a)=>{a.d(t,{Label:()=>l});var s=a(95155);a(12115);var r=a(29486),i=a(91337);function l({className:e,...t}){return(0,s.jsx)(r.b,{"data-slot":"label",className:(0,i.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},90466:(e,t,a)=>{a.d(t,{d:()=>l});var s=a(95155);a(12115);var r=a(8678),i=a(91337);function l({className:e,...t}){return(0,s.jsx)(r.bL,{"data-slot":"switch",className:(0,i.cn)("peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-gray-300","dark:data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-gray-600","focus-visible:border-ring focus-visible:ring-ring/50",e),...t,children:(0,s.jsx)(r.zi,{"data-slot":"switch-thumb",className:(0,i.cn)("pointer-events-none block size-4 rounded-full ring-0 transition-transform","bg-white shadow-sm","data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}}}]);

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.