(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66027,54616,e=>{"use strict";let t;var s=e.i(75555),r=e.i(40143),i=e.i(86491),n=e.i(15823),o=e.i(93803),a=e.i(19273),l=e.i(80166),c=class extends n.Subscribable{constructor(e,t){super(),this.options=t,this.#e=e,this.#t=null,this.#s=(0,o.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#e;#r=void 0;#i=void 0;#n=void 0;#o;#a;#s;#t;#l;#c;#h;#u;#d;#p;#x=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#r.addObserver(this),h(this.#r,this.options)?this.#m():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return u(this.#r,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return u(this.#r,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#f(),this.#b(),this.#r.removeObserver(this)}setOptions(e){let t=this.options,s=this.#r;if(this.options=this.#e.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,a.resolveEnabled)(this.options.enabled,this.#r))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#y(),this.#r.setOptions(this.options),t._defaulted&&!(0,a.shallowEqualObjects)(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#r,observer:this});let r=this.hasListeners();r&&d(this.#r,s,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#r!==s||(0,a.resolveEnabled)(this.options.enabled,this.#r)!==(0,a.resolveEnabled)(t.enabled,this.#r)||(0,a.resolveStaleTime)(this.options.staleTime,this.#r)!==(0,a.resolveStaleTime)(t.staleTime,this.#r))&&this.#v();let i=this.#j();r&&(this.#r!==s||(0,a.resolveEnabled)(this.options.enabled,this.#r)!==(0,a.resolveEnabled)(t.enabled,this.#r)||i!==this.#p)&&this.#S(i)}getOptimisticResult(e){var t,s;let r=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(r,e);return t=this,s=i,(0,a.shallowEqualObjects)(t.getCurrentResult(),s)||(this.#n=i,this.#a=this.options,this.#o=this.#r.state),i}getCurrentResult(){return this.#n}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),t?.(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#s.status||this.#s.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,s))})}trackProp(e){this.#x.add(e)}getCurrentQuery(){return this.#r}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#m(e){this.#y();let t=this.#r.fetch(this.options,e);return e?.throwOnError||(t=t.catch(a.noop)),t}#v(){this.#f();let e=(0,a.resolveStaleTime)(this.options.staleTime,this.#r);if(a.isServer||this.#n.isStale||!(0,a.isValidTimeout)(e))return;let t=(0,a.timeUntilStale)(this.#n.dataUpdatedAt,e);this.#u=l.timeoutManager.setTimeout(()=>{this.#n.isStale||this.updateResult()},t+1)}#j(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#r):this.options.refetchInterval)??!1}#S(e){this.#b(),this.#p=e,!a.isServer&&!1!==(0,a.resolveEnabled)(this.options.enabled,this.#r)&&(0,a.isValidTimeout)(this.#p)&&0!==this.#p&&(this.#d=l.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||s.focusManager.isFocused())&&this.#m()},this.#p))}#g(){this.#v(),this.#S(this.#j())}#f(){this.#u&&(l.timeoutManager.clearTimeout(this.#u),this.#u=void 0)}#b(){this.#d&&(l.timeoutManager.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let s,r=this.#r,n=this.options,l=this.#n,c=this.#o,u=this.#a,x=e!==r?e.state:this.#i,{state:m}=e,g={...m},f=!1;if(t._optimisticResults){let s=this.hasListeners(),o=!s&&h(e,t),a=s&&d(e,r,t,n);(o||a)&&(g={...g,...(0,i.fetchState)(m.data,e.options)}),"isRestoring"===t._optimisticResults&&(g.fetchStatus="idle")}let{error:b,errorUpdatedAt:y,status:v}=g;s=g.data;let j=!1;if(void 0!==t.placeholderData&&void 0===s&&"pending"===v){let e;l?.isPlaceholderData&&t.placeholderData===u?.placeholderData?(e=l.data,j=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#h?.state.data,this.#h):t.placeholderData,void 0!==e&&(v="success",s=(0,a.replaceData)(l?.data,e,t),f=!0)}if(t.select&&void 0!==s&&!j)if(l&&s===c?.data&&t.select===this.#l)s=this.#c;else try{this.#l=t.select,s=t.select(s),s=(0,a.replaceData)(l?.data,s,t),this.#c=s,this.#t=null}catch(e){this.#t=e}this.#t&&(b=this.#t,s=this.#c,y=Date.now(),v="error");let S="fetching"===g.fetchStatus,R="pending"===v,N="error"===v,E=R&&S,w=void 0!==s,O={status:v,fetchStatus:g.fetchStatus,isPending:R,isSuccess:"success"===v,isError:N,isInitialLoading:E,isLoading:E,data:s,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:y,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>x.dataUpdateCount||g.errorUpdateCount>x.errorUpdateCount,isFetching:S,isRefetching:S&&!R,isLoadingError:N&&!w,isPaused:"paused"===g.fetchStatus,isPlaceholderData:f,isRefetchError:N&&w,isStale:p(e,t),refetch:this.refetch,promise:this.#s,isEnabled:!1!==(0,a.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==O.data,s="error"===O.status&&!t,i=e=>{s?e.reject(O.error):t&&e.resolve(O.data)},n=()=>{i(this.#s=O.promise=(0,o.pendingThenable)())},a=this.#s;switch(a.status){case"pending":e.queryHash===r.queryHash&&i(a);break;case"fulfilled":(s||O.data!==a.value)&&n();break;case"rejected":s&&O.error===a.reason||n()}}return O}updateResult(){let e=this.#n,t=this.createResult(this.#r,this.options);if(this.#o=this.#r.state,this.#a=this.options,void 0!==this.#o.data&&(this.#h=this.#r),(0,a.shallowEqualObjects)(t,e))return;this.#n=t;let s=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!this.#x.size)return!0;let r=new Set(s??this.#x);return this.options.throwOnError&&r.add("error"),Object.keys(this.#n).some(t=>this.#n[t]!==e[t]&&r.has(t))};this.#R({listeners:s()})}#y(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#r)return;let t=this.#r;this.#r=e,this.#i=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#R(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#r,type:"observerResultsUpdated"})})}};function h(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&u(e,t,t.refetchOnMount)}function u(e,t,s){if(!1!==(0,a.resolveEnabled)(t.enabled,e)&&"static"!==(0,a.resolveStaleTime)(t.staleTime,e)){let r="function"==typeof s?s(e):s;return"always"===r||!1!==r&&p(e,t)}return!1}function d(e,t,s,r){return(e!==t||!1===(0,a.resolveEnabled)(r.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&p(e,s)}function p(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,a.resolveStaleTime)(t.staleTime,e))}e.i(47167);var x=e.i(71645),m=e.i(12598);e.i(43476);var g=x.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),f=x.createContext(!1);f.Provider;var b=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function y(e,t){return function(e,t,s){let i,n=x.useContext(f),o=x.useContext(g),l=(0,m.useQueryClient)(s),c=l.defaultQueryOptions(e);l.getDefaultOptions().queries?._experimental_beforeQuery?.(c);let h=l.getQueryCache().get(c.queryHash);if(c._optimisticResults=n?"isRestoring":"optimistic",c.suspense){let e=e=>"static"===e?e:Math.max(e??1e3,1e3),t=c.staleTime;c.staleTime="function"==typeof t?(...s)=>e(t(...s)):e(t),"number"==typeof c.gcTime&&(c.gcTime=Math.max(c.gcTime,1e3))}i=h?.state.error&&"function"==typeof c.throwOnError?(0,a.shouldThrowError)(c.throwOnError,[h.state.error,h]):c.throwOnError,(c.suspense||c.experimental_prefetchInRender||i)&&!o.isReset()&&(c.retryOnMount=!1),x.useEffect(()=>{o.clearReset()},[o]);let u=!l.getQueryCache().get(c.queryHash),[d]=x.useState(()=>new t(l,c)),p=d.getOptimisticResult(c),y=!n&&!1!==e.subscribed;if(x.useSyncExternalStore(x.useCallback(e=>{let t=y?d.subscribe(r.notifyManager.batchCalls(e)):a.noop;return d.updateResult(),t},[d,y]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),x.useEffect(()=>{d.setOptions(c)},[c,d]),c?.suspense&&p.isPending)throw b(c,d,o);if((({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&void 0===e.data||(0,a.shouldThrowError)(s,[e.error,r])))({result:p,errorResetBoundary:o,throwOnError:c.throwOnError,query:h,suspense:c.suspense}))throw p.error;if(l.getDefaultOptions().queries?._experimental_afterQuery?.(c,p),c.experimental_prefetchInRender&&!a.isServer&&p.isLoading&&p.isFetching&&!n){let e=u?b(c,d,o):h?.promise;e?.catch(a.noop).finally(()=>{d.updateResult()})}return c.notifyOnChangeProps?p:d.trackResult(p)}(e,c,t)}e.s(["useQuery",()=>y],66027);var v=e.i(14272),j=n,S=class extends j.Subscribable{#e;#n=void 0;#N;#E;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#w()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,a.shallowEqualObjects)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#N,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,a.hashKey)(t.mutationKey)!==(0,a.hashKey)(this.options.mutationKey)?this.reset():this.#N?.state.status==="pending"&&this.#N.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#N?.removeObserver(this)}onMutationUpdate(e){this.#w(),this.#R(e)}getCurrentResult(){return this.#n}reset(){this.#N?.removeObserver(this),this.#N=void 0,this.#w(),this.#R()}mutate(e,t){return this.#E=t,this.#N?.removeObserver(this),this.#N=this.#e.getMutationCache().build(this.#e,this.options),this.#N.addObserver(this),this.#N.execute(e)}#w(){let e=this.#N?.state??(0,v.getDefaultState)();this.#n={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#R(e){r.notifyManager.batch(()=>{if(this.#E&&this.hasListeners()){let t=this.#n.variables,s=this.#n.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#E.onSuccess?.(e.data,t,s,r)}catch(e){Promise.reject(e)}try{this.#E.onSettled?.(e.data,null,t,s,r)}catch(e){Promise.reject(e)}}else if(e?.type==="error"){try{this.#E.onError?.(e.error,t,s,r)}catch(e){Promise.reject(e)}try{this.#E.onSettled?.(void 0,e.error,t,s,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#n)})})}};function R(e,t){let s=(0,m.useQueryClient)(t),[i]=x.useState(()=>new S(s,e));x.useEffect(()=>{i.setOptions(e)},[i,e]);let n=x.useSyncExternalStore(x.useCallback(e=>i.subscribe(r.notifyManager.batchCalls(e)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),o=x.useCallback((e,t)=>{i.mutate(e,t).catch(a.noop)},[i]);if(n.error&&(0,a.shouldThrowError)(i.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:o,mutateAsync:n.mutate}}e.s(["useMutation",()=>R],54616)},52749,e=>{"use strict";let t="http://localhost:8000",s=async()=>{let e=await fetch(`${t}/api/config`);if(!e.ok)throw Error("Failed to fetch config");return Object.fromEntries((await e.json()).map(e=>[e.key,e.value]))},r=async e=>{let s=Object.entries(e).map(([e,t])=>({key:e,value:t}));if(!(await fetch(`${t}/api/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok)throw Error("Failed to save config")};e.s(["fetchConfig",0,s,"saveConfig",0,r])},74880,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(77183),i=e.i(76590),n=e.i(7311),o=e.i(66027),a=e.i(54616),l=e.i(12598);let c="http://localhost:8000",h=async()=>{let e=await fetch(`${c}/api/keywords`);if(!e.ok)throw Error("Failed to fetch keywords");return e.json()},u=async(e,t=1)=>{let s=await fetch(`${c}/api/keywords`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({term:e,weight:t})});if(!s.ok)throw Error("Failed to add keyword");return s.json()},d=async(e,t)=>{if(!(await fetch(`${c}/api/keywords/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)throw Error("Failed to update keyword")},p=async e=>{if(!(await fetch(`${c}/api/keywords/${e}`,{method:"DELETE"})).ok)throw Error("Failed to delete keyword")},x=async e=>{if(!(await fetch(`${c}/api/keywords/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:e})})).ok)throw Error("Failed to reorder")},m=["keywords"];function g({keyword:e}){let r,o,{attributes:c,listeners:h,setNodeRef:u,transform:x,transition:g}=(0,i.useSortable)({id:e.id}),f=(r=(0,l.useQueryClient)(),(0,a.useMutation)({mutationFn:({id:e,data:t})=>d(e,t),onSuccess:()=>r.invalidateQueries({queryKey:m})})),b=(o=(0,l.useQueryClient)(),(0,a.useMutation)({mutationFn:p,onSuccess:()=>o.invalidateQueries({queryKey:m})})),[y,v]=(0,s.useState)(!1),[j,S]=(0,s.useState)(!1),[R,N]=(0,s.useState)(e.term),[E,w]=(0,s.useState)(String(e.weight)),O=()=>{f.mutate({id:e.id,data:{term:R}}),v(!1)},T=()=>{f.mutate({id:e.id,data:{weight:parseFloat(E)}}),S(!1)},C={transform:n.CSS.Transform.toString(x),transition:g};return(0,t.jsxs)("tr",{ref:u,style:C,className:"border-b border-ghost-border hover:bg-ghost-panel",children:[(0,t.jsx)("td",{className:"p-2 w-6 cursor-grab text-ghost-dim",...c,...h,children:"⋮⋮"}),(0,t.jsx)("td",{className:"p-2 font-mono text-xs",children:y?(0,t.jsx)("input",{autoFocus:!0,value:R,onChange:e=>N(e.target.value),onBlur:O,onKeyDown:e=>"Enter"===e.key&&O(),className:"bg-ghost-bg border border-ghost-accent text-ghost-text font-mono text-xs px-1 outline-none w-full"}):(0,t.jsx)("span",{onClick:()=>v(!0),className:"cursor-pointer hover:text-ghost-accent text-ghost-text",children:e.term})}),(0,t.jsx)("td",{className:"p-2 font-mono text-xs text-center",children:j?(0,t.jsx)("input",{autoFocus:!0,type:"number",step:"0.1",value:E,onChange:e=>w(e.target.value),onBlur:T,onKeyDown:e=>"Enter"===e.key&&T(),className:"bg-ghost-bg border border-ghost-accent text-ghost-gold font-mono text-xs px-1 outline-none w-16 text-center"}):(0,t.jsxs)("span",{onClick:()=>S(!0),className:"cursor-pointer text-ghost-gold hover:text-ghost-accent",children:[e.weight,"×"]})}),(0,t.jsx)("td",{className:"p-2 text-xs",children:e.ai_target&&(0,t.jsxs)("span",{className:"text-ghost-dim text-xs",children:["🤖 ",e.ai_target.slice(0,30),"…"]})}),(0,t.jsx)("td",{className:"p-2 text-xs text-ghost-dim",children:(e.min_price||e.max_price)&&(0,t.jsxs)("span",{children:[e.min_price?`≥$${e.min_price}`:""," ",e.max_price?`≤$${e.max_price}`:""]})}),(0,t.jsx)("td",{className:"p-2",children:(0,t.jsx)("button",{onClick:()=>{confirm(`Delete "${e.term}"?`)&&b.mutate(e.id)},className:"text-ghost-danger font-mono text-xs",children:"✕"})})]})}function f(){let e,n,{data:c,isLoading:d}=(0,o.useQuery)({queryKey:m,queryFn:h}),p=(e=(0,l.useQueryClient)(),(0,a.useMutation)({mutationFn:({term:e,weight:t})=>u(e,t),onSuccess:()=>e.invalidateQueries({queryKey:m})})),f=(n=(0,l.useQueryClient)(),(0,a.useMutation)({mutationFn:x,onSuccess:()=>n.invalidateQueries({queryKey:m})})),[b,y]=(0,s.useState)(""),[v,j]=(0,s.useState)("1"),[S,R]=(0,s.useState)("");return d?(0,t.jsx)("div",{className:"text-ghost-dim font-mono text-xs animate-pulse",children:"Loading keywords…"}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"font-mono text-ghost-dim text-xs",children:["Each target is a ",(0,t.jsx)("span",{className:"text-ghost-text",children:"search label"})," — the term is used to query auction sites. Set an ",(0,t.jsx)("span",{className:"text-ghost-accent",children:"AI Description"}),' on each target so the AI can accept or reject lots based on what you actually want (e.g. "actual Samsung Tab S10 device, not covers or accessories").']}),(0,t.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,t.jsx)("input",{value:b,onChange:e=>y(e.target.value),placeholder:"search term / label",className:"bg-ghost-bg border border-ghost-border text-ghost-text font-mono text-xs px-2 py-1 outline-none focus:border-ghost-accent flex-1"}),(0,t.jsx)("input",{value:v,onChange:e=>j(e.target.value),type:"number",step:"0.1",placeholder:"weight",className:"bg-ghost-bg border border-ghost-border text-ghost-gold font-mono text-xs px-2 py-1 outline-none focus:border-ghost-accent w-20"}),(0,t.jsx)("button",{onClick:()=>{b.trim()&&(p.mutate({term:b,weight:parseFloat(v)}),y(""),j("1"))},className:"btn-ghost",children:"+ ADD"})]})]}),(0,t.jsx)(r.DndContext,{collisionDetection:r.closestCenter,onDragEnd:({active:e,over:t})=>{if(!t||e.id===t.id||!c)return;let s=c.map(e=>e.id),r=s.indexOf(Number(e.id)),i=s.indexOf(Number(t.id)),n=[...s];n.splice(i,0,n.splice(r,1)[0]),f.mutate(n)},children:(0,t.jsx)(i.SortableContext,{items:(c??[]).map(e=>e.id),strategy:i.verticalListSortingStrategy,children:(0,t.jsxs)("table",{className:"w-full text-xs font-mono",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-ghost-border text-ghost-dim text-left",children:[(0,t.jsx)("th",{className:"p-2 w-6"}),(0,t.jsx)("th",{className:"p-2",children:"TARGET LABEL"}),(0,t.jsx)("th",{className:"p-2 text-center",children:"WEIGHT"}),(0,t.jsxs)("th",{className:"p-2",children:["AI DESCRIPTION ",(0,t.jsx)("span",{className:"text-ghost-accent",children:"★"})]}),(0,t.jsx)("th",{className:"p-2",children:"PRICE FILTER"}),(0,t.jsx)("th",{className:"p-2"})]})}),(0,t.jsx)("tbody",{children:(c??[]).map(e=>(0,t.jsx)(g,{keyword:e},e.id))})]})})}),(0,t.jsxs)("details",{className:"border border-ghost-border",children:[(0,t.jsx)("summary",{className:"px-3 py-2 text-ghost-dim font-mono text-xs cursor-pointer hover:text-ghost-text",children:"BATCH IMPORT"}),(0,t.jsxs)("div",{className:"p-3 space-y-2",children:[(0,t.jsx)("textarea",{value:S,onChange:e=>R(e.target.value),placeholder:"laptop:2\nRTX 4090:3\niPhone 15",rows:4,className:"w-full bg-ghost-bg border border-ghost-border text-ghost-text font-mono text-xs p-2 outline-none focus:border-ghost-accent resize-none"}),(0,t.jsx)("button",{onClick:()=>{S.split("\n").map(e=>e.trim()).filter(Boolean).forEach(e=>{let[t,s]=e.split(":");p.mutate({term:t.trim(),weight:parseFloat(s||"1")})}),R("")},className:"btn-ghost",children:"IMPORT"})]})]})]})}e.s(["default",()=>f],74880)},18397,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(66027),i=e.i(54616),n=e.i(12598);let o="http://localhost:8000/api";async function a(){let e=await fetch(`${o}/scoring-rules`);if(!e.ok)throw Error("Failed to fetch scoring rules");return e.json()}async function l(e,t,s){let r=await fetch(`${o}/scoring-rules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:e,delta:t,notes:s})});if(!r.ok)throw Error((await r.json().catch(()=>({}))).error||"Failed to create rule");return r.json()}async function c(e,t){let s=await fetch(`${o}/scoring-rules/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw Error("Failed to update rule");return s.json()}async function h(e){if(!(await fetch(`${o}/scoring-rules/${e}`,{method:"DELETE"})).ok)throw Error("Failed to delete rule")}var u=e.i(52749);function d(){let e=(0,n.useQueryClient)(),{data:o=[],isLoading:d}=(0,r.useQuery)({queryKey:["scoring-rules"],queryFn:a}),[x,m]=(0,s.useState)(!0),[g,f]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(0,u.fetchConfig)().then(e=>{m((e.scoring_enabled??"true")!=="false")})},[]);let b=async()=>{f(!0);let e=!x;await (0,u.saveConfig)({scoring_enabled:String(e)}),m(e),f(!1)},[y,v]=(0,s.useState)(""),[j,S]=(0,s.useState)(""),[R,N]=(0,s.useState)(""),[E,w]=(0,s.useState)(""),[O,T]=(0,s.useState)(null),[C,I]=(0,s.useState)(""),[Q,k]=(0,s.useState)(""),F=()=>e.invalidateQueries({queryKey:["scoring-rules"]}),D=(0,i.useMutation)({mutationFn:()=>l(y.trim(),parseInt(j),R.trim()||void 0),onSuccess:()=>{v(""),S(""),N(""),w(""),F()},onError:e=>w(e.message)}),M=(0,i.useMutation)({mutationFn:()=>c(O,{signal:C.trim(),delta:parseInt(Q)}),onSuccess:()=>{T(null),F()}}),P=(0,i.useMutation)({mutationFn:e=>h(e),onSuccess:F}),A=o.filter(e=>e.delta>0),L=o.filter(e=>e.delta<0);return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"font-mono text-ghost-accent text-xs tracking-widest",children:"SCORING RULES"}),(0,t.jsx)("p",{className:"font-mono text-ghost-dim text-xs mt-0.5",children:"Token signals that boost (+) or penalise (−) lot scores"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)("span",{className:"font-mono text-ghost-dim text-xs",children:"SCORING"}),(0,t.jsx)("button",{onClick:b,disabled:g,className:`font-mono text-xs px-3 py-1 border transition-colors ${x?"border-ghost-accent text-ghost-accent hover:bg-ghost-accent hover:text-ghost-bg":"border-ghost-border text-ghost-dim hover:border-ghost-text hover:text-ghost-text"} disabled:opacity-40`,children:x?"● ON":"○ OFF"})]})]}),!x&&(0,t.jsxs)("div",{className:"border border-ghost-accent/30 bg-ghost-accent/5 px-3 py-2 font-mono text-xs text-ghost-accent space-y-1",children:[(0,t.jsx)("div",{className:"font-bold",children:"⚡ AI-FIRST MODE ACTIVE"}),(0,t.jsxs)("div",{className:"text-ghost-dim leading-relaxed",children:["Score signals are disabled. The AI description on each target is the sole judge — set an ",(0,t.jsx)("span",{className:"text-ghost-text",children:"AI Description"})," on every target above and enable ",(0,t.jsx)("span",{className:"text-ghost-text",children:"AI Filter"})," in Settings → AI Filter. Without an AI description, ",(0,t.jsx)("span",{className:"text-ghost-text",children:"all lots pass through"}),"."]})]}),(0,t.jsxs)("div",{className:x?"":"opacity-40 pointer-events-none select-none",children:[(0,t.jsxs)("form",{className:"flex gap-2 flex-wrap items-end mb-4",onSubmit:e=>{e.preventDefault(),y&&j&&D.mutate()},children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"font-mono text-ghost-dim text-xs",children:"SIGNAL"}),(0,t.jsx)("input",{className:"bg-ghost-bg border border-ghost-border font-mono text-ghost-text text-xs px-2 py-1 w-32 focus:outline-none focus:border-ghost-accent",placeholder:"e.g. RTX",value:y,onChange:e=>v(e.target.value)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"font-mono text-ghost-dim text-xs",children:"DELTA"}),(0,t.jsx)("input",{type:"number",className:"bg-ghost-bg border border-ghost-border font-mono text-ghost-text text-xs px-2 py-1 w-20 focus:outline-none focus:border-ghost-accent",placeholder:"+10 / -8",value:j,onChange:e=>S(e.target.value)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"font-mono text-ghost-dim text-xs",children:"NOTES (optional)"}),(0,t.jsx)("input",{className:"bg-ghost-bg border border-ghost-border font-mono text-ghost-text text-xs px-2 py-1 w-48 focus:outline-none focus:border-ghost-accent",placeholder:"e.g. GPU keyword",value:R,onChange:e=>N(e.target.value)})]}),(0,t.jsx)("button",{type:"submit",disabled:!y||!j||D.isPending,className:"btn-ghost text-xs py-1 px-3 disabled:opacity-40",children:"+ ADD"}),E&&(0,t.jsx)("span",{className:"font-mono text-ghost-danger text-xs",children:E})]}),d&&(0,t.jsx)("p",{className:"font-mono text-ghost-dim text-xs",children:"Loading…"}),A.length>0&&(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsx)("div",{className:"font-mono text-xs text-ghost-accent mb-1",children:"▲ BOOSTS"}),(0,t.jsxs)("table",{className:"w-full border-collapse",children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{className:"border-b border-ghost-border",children:["SIGNAL","DELTA","NOTES",""].map(e=>(0,t.jsx)("th",{className:"font-mono text-ghost-dim text-xs text-left py-1 px-2",children:e},e))})}),(0,t.jsx)("tbody",{children:A.map(e=>(0,t.jsx)(p,{rule:e,editId:O,editSignal:C,editDelta:Q,setEditId:T,setEditSignal:I,setEditDelta:k,onSave:()=>M.mutate(),onDelete:()=>P.mutate(e.id)},e.id))})]})]}),L.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-mono text-xs text-ghost-danger mb-1",children:"▼ PENALTIES"}),(0,t.jsxs)("table",{className:"w-full border-collapse",children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{className:"border-b border-ghost-border",children:["SIGNAL","DELTA","NOTES",""].map(e=>(0,t.jsx)("th",{className:"font-mono text-ghost-dim text-xs text-left py-1 px-2",children:e},e))})}),(0,t.jsx)("tbody",{children:L.map(e=>(0,t.jsx)(p,{rule:e,editId:O,editSignal:C,editDelta:Q,setEditId:T,setEditSignal:I,setEditDelta:k,onSave:()=>M.mutate(),onDelete:()=>P.mutate(e.id)},e.id))})]})]})]})]})}function p({rule:e,editId:s,editSignal:r,editDelta:i,setEditId:n,setEditSignal:o,setEditDelta:a,onSave:l,onDelete:c}){let h=s===e.id,u=e.delta>0?"text-ghost-accent":"text-ghost-danger";return h?(0,t.jsxs)("tr",{className:"border-b border-ghost-border bg-ghost-panel",children:[(0,t.jsx)("td",{className:"py-1 px-2",children:(0,t.jsx)("input",{className:"bg-ghost-bg border border-ghost-border font-mono text-ghost-text text-xs px-1 py-0.5 w-28 focus:outline-none focus:border-ghost-accent",value:r,onChange:e=>o(e.target.value)})}),(0,t.jsx)("td",{className:"py-1 px-2",children:(0,t.jsx)("input",{type:"number",className:"bg-ghost-bg border border-ghost-border font-mono text-ghost-text text-xs px-1 py-0.5 w-16 focus:outline-none focus:border-ghost-accent",value:i,onChange:e=>a(e.target.value)})}),(0,t.jsx)("td",{className:"py-1 px-2 font-mono text-ghost-dim text-xs",children:e.notes||"—"}),(0,t.jsxs)("td",{className:"py-1 px-2 flex gap-2",children:[(0,t.jsx)("button",{onClick:l,className:"btn-ghost text-xs py-0.5 px-2",children:"SAVE"}),(0,t.jsx)("button",{onClick:()=>n(null),className:"font-mono text-ghost-dim text-xs hover:text-ghost-text",children:"×"})]})]}):(0,t.jsxs)("tr",{className:"border-b border-ghost-border hover:bg-ghost-panel/50 group",children:[(0,t.jsx)("td",{className:"py-1.5 px-2 font-mono text-ghost-text text-xs cursor-pointer hover:text-ghost-accent",onClick:()=>{n(e.id),o(e.signal),a(String(e.delta))},children:e.signal}),(0,t.jsxs)("td",{className:`py-1.5 px-2 font-mono text-xs font-bold ${u}`,children:[e.delta>0?"+":"",e.delta]}),(0,t.jsx)("td",{className:"py-1.5 px-2 font-mono text-ghost-dim text-xs",children:e.notes||"—"}),(0,t.jsx)("td",{className:"py-1.5 px-2",children:(0,t.jsx)("button",{onClick:c,className:"font-mono text-ghost-dim text-xs hover:text-ghost-danger opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})})]})}e.s(["default",()=>d],18397)}]);