import{jsx as e,jsxs as l,Fragment as I}from"react/jsx-runtime";import{D as k,a as C,b as _,c as f,d as w,e as P}from"./dialog-BfGkTFdF.js";import{B as h}from"./button-BvFBRYHq.js";import{I as r}from"./input-qMvM9qch.js";import{L as d}from"./label-DMnntKPk.js";import{S as B,a as F,b as L,c as T,d as j,e as G,f as o}from"./select-DfhewM4T.js";import{Loader2 as u}from"lucide-react";import{TemplateSelect as V}from"./TemplateSelect-DfGd1_U3.js";import"@radix-ui/react-dialog";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-slot";import"class-variance-authority";import"@radix-ui/react-label";import"@radix-ui/react-select";import"react";function D({isOpen:g,onOpenChange:n,formData:i,onFormDataChange:a,masks:v,itemName:p,isLoadingItemName:x,errors:c,isLoading:s,onSubmit:N,onTemplateSelect:y,onItemNameLookup:S}){return e(k,{open:g,onOpenChange:n,children:l(C,{className:"sm:max-w-[500px]",children:[l(_,{children:[e(f,{children:"Create Shop Item"}),e(w,{children:"Add a new item to the shop for players to purchase with gold."})]}),l("div",{className:"space-y-4 py-4",children:[e("div",{className:"p-3 bg-muted/50 rounded-lg border border-dashed",children:e(V,{onSelect:y})}),l("div",{className:"grid gap-4",children:[l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"item_id",children:"Item ID"}),e("div",{className:"flex gap-2",children:e(r,{id:"item_id",type:"number",value:i.item_id,onChange:t=>a({...i,item_id:t.target.value}),onBlur:()=>S(i.item_id),placeholder:"Enter item ID"})}),x?l("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e(u,{className:"h-3 w-3 animate-spin"})," Loading..."]}):p?l("p",{className:"text-sm text-muted-foreground",children:["Item: ",e("span",{className:"font-medium",children:p})]}):null,c.item_id&&e("p",{className:"text-sm text-destructive",children:c.item_id})]}),l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"count",children:"Count"}),e(r,{id:"count",type:"number",min:"1",value:i.count,onChange:t=>a({...i,count:t.target.value}),placeholder:"Quantity"}),c.count&&e("p",{className:"text-sm text-destructive",children:c.count})]}),l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"octet",children:"Octet"}),e(r,{id:"octet",value:i.octet,onChange:t=>a({...i,octet:t.target.value}),placeholder:"Item octet data"}),c.octet&&e("p",{className:"text-sm text-destructive",children:c.octet})]}),l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"mask",children:"Mask"}),l(B,{value:i.mask,onValueChange:t=>a({...i,mask:t}),children:[e(F,{id:"mask",children:e(L,{placeholder:"Select mask"})}),e(T,{className:"max-h-[300px]",children:v.map((t,b)=>"options"in t&&t.options?l(j,{children:[e(G,{children:t.label}),t.options.map(m=>e(o,{value:String(m.value),children:m.label},m.value))]},b):e(o,{value:String(t.value),children:t.label},t.value))})]}),c.mask&&e("p",{className:"text-sm text-destructive",children:c.mask})]}),l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"proctype",children:"Proctype"}),e(r,{id:"proctype",type:"number",value:i.proctype,onChange:t=>a({...i,proctype:t.target.value}),placeholder:"Process type"}),c.proctype&&e("p",{className:"text-sm text-destructive",children:c.proctype})]}),l("div",{className:"grid gap-2",children:[e(d,{htmlFor:"price",children:"Price (Gold)"}),e(r,{id:"price",type:"number",min:"0",value:i.price,onChange:t=>a({...i,price:t.target.value}),placeholder:"Price in gold"}),c.price&&e("p",{className:"text-sm text-destructive",children:c.price})]})]})]}),l(P,{children:[e(h,{variant:"outline",onClick:()=>n(!1),disabled:s,children:"Cancel"}),e(h,{onClick:N,disabled:s,children:s?l(I,{children:[e(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Item"})]})]})})}export{D as CreateShopItemDialog};
