1import{j as e,u as Qt,V as Bt,b as qt,a as Kt,B as le,c as g}from"./index-C9VyRByS.js";import{r as a,O as xt,I as ht,X as oe,aV as Ht,ae as Jt,as as Gt,p as Xt,o as Yt,P as Zt,T as Wt}from"./icons-Dk9ia89R.js";import{q as Ce,k as gt,w as ke,u as es}from"./workspace-queries-BwGSHjQO.js";import{c as ts,u as ft,m as ss}from"./catalog-cache-Cgm62ltw.js";import{u as as}from"./record-changed-DLg-4FAt.js";import{I as m}from"./input-CPdsLOuT.js";import{E as rs}from"./error-note-DUDm2XNO.js";import{L as x}from"./label-xeDYeu0z.js";import{T as ns}from"./textarea-DnR2M_4n.js";import{S as St}from"./switch-frdVQ2Np.js";import{S as ce,a as de,b as ue,c as pe,d as V}from"./select-DRVFTakE.js";import{P as yt,a as vt}from"./page-header-BapO8lcs.js";import{T as is,a as ls,b as os,c as cs}from"./tooltip-dthSM347.js";import{f as bt}from"./list-view-Bo1lHrNw.js";import{u as ds}from"./sandbox-BB7rpX9h.js";import{a as jt}from"./workspace-routing-DTKneyEE.js";import{u as us,p as ps}from"./prefill-BGherzcJ.js";import{b as ms,C as xs}from"./CheckoutPreviewPane-D5TJ0CQG.js";import"./queryOptions-C9woPjwX.js";import"./index-Bhv3eNQI.js";import"./index-SqWoeikz.js";import"./index-DuU_63WQ.js";import"./index-4ZCr8EaA.js";import"./index-BfqoL0OZ.js";import"./kbd-BLyrb5u9.js";import"./command-menu-host-DogwMDAn.js";import"./sidebar-nav-B9fLWvsz.js";import"./list-selection-gEcAN2ZM.js";import"./dropdown-menu-Br7A3ifT.js";import"./index-CNSOSpc_.js";import"./hover-intent-BVJL3ioV.js";const hs=a.memo(xs);function gs(o){const d=o.filter(u=>u.name.trim()&&u.values.length>0);if(d.length===0)return[];let i=[{}];for(const u of d){const f=[];for(const N of i)for(const w of u.values)f.push({...N,[u.name]:w});i=f}return i}function Nt(o){return Object.values(o).join(" / ")}const we=[{value:"every_2_minutes",label:"Every 2 minutes"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"monthly",label:"Monthly"},{value:"every_2_months",label:"Every 2 months"},{value:"every_3_months",label:"Every 3 months"},{value:"every_4_months",label:"Every 4 months"},{value:"every_6_months",label:"Every 6 months"},{value:"yearly",label:"Yearly"}];function fs(o){return o==="EUR"?"â¬":o==="GBP"?"£":"$"}function q(o){return o==null?"":(o/100).toFixed(2)}function ys(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const j="[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",h="h-10 rounded-xl border-0 bg-secondary shadow-none focus-visible:bg-muted focus-visible:ring-0",vs=["10","25","50","100"];function z({icon:o,label:d,checked:i,onCheckedChange:u,first:f,last:N,children:w}){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{type:"button",onClick:()=>u(!i),className:g("m-1 flex h-10 items-center gap-2.5 px-2.5 text-left transition-[background-color,transform] duration-100 hover:bg-row-hover active:scale-[0.985]",f?"rounded-t-[10px]":"rounded-t-md",N?"rounded-b-[10px]":"rounded-b-md"),children:[e.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-foreground
1/[0.05] text-muted-foreground [&>svg]:size-3.5",children:o}),e.jsx("span",{className:"flex-1 text-[13px] font-medium",children:d}),e.jsx("span",{onClick:K=>K.stopPropagation(),className:"flex items-center",children:e.jsx(St,{checked:i,onCheckedChange:u})})]}),i&&w&&e.jsx("div",{className:"space-y-3 px-3.5 pb-4 pt-1",children:w})]})}function bs({label:o,checked:d,onCheckedChange:i}){return e.jsxs("button",{type:"button",onClick:()=>i(!d),className:"-mx-2.5 flex h-9 w-[calc(100%+1.25rem)] items-center gap-2.5 rounded-[10px] px-2.5 text-left transition-[background-color,transform] duration-100 hover:bg-row-hover active:scale-[0.985]",children:[e.jsx("span",{className:"flex-1 text-[12px] font-medium",children:o}),e.jsx("span",{onClick:u=>u.stopPropagation(),className:"flex items-center",children:e.jsx(St,{checked:d,onCheckedChange:i})})]})}function js({productId:o}){var pt,mt;const d=!!o,{activeWorkspace:i,authFetch:u}=Qt(),f=Bt(),{workspaceSlug:N}=qt({strict:!1}),w=Kt(),K=a.useRef(null),[T,Ct]=a.useState(d),[kt,wt]=a.useState(!1),[H,me]=a.useState(!1),[Pt,Pe]=a.useState(!1),E=us(!d),[S,Fe]=a.useState(()=>(E.name??"").slice(0,200)),[L,Te]=a.useState(()=>(E.description??"").slice(0,1e3)),[$,xe]=a.useState([]),[De,_e]=a.useState(!1),[Ft,he]=a.useState(!1),Oe=(pt=we.find(t=>t.value===E.billingPeriod))==null?void 0:pt.value,[p,Ae]=a.useState(()=>E.pricingType==="recurring"&&Oe?"recurring":"one_time"),[v,J]=a.useState(()=>ps(E.price)),[P,Ue]=a.useState("USD"),[I,Ve]=a.useState(Oe??"monthly"),[D,ge]=a.useState(""),[G,ze]=a.useState(!1),{isSandboxMode:fe}=ds();a.useEffect(()=>{i&&Ue(jt(i,fe))},[i,fe]);const[X,Ee]=a.useState(""),[Y,Le]=a.useState(""),[Z,$e]=a.useState(""),[ye,Ie]=a.useState(!1),[Re,Me]=a.useState(""),[W,Qe]=a.useState(!1),[ve,Be]=a.useState(""),[qe,Ke]=a.useState("g"),[C,He]=a.useState(!1),[R,Je]=a.useState("percentage"),[ee,Ge]=a.useState(""),[b,Xe]=a.useState(!1),[M,Ye]=a.useState("fixed"),[te,Ze]=a.useState(""),[be,se]=a.useState([]),[We,ae]=a.useState(""),[et,je]=a.useState(""),[Tt,tt]=a.useState(!1),[Dt,st]=a.useState(!1),[re,k]=a.useState([]),[at,Ne]=a.useState({}),[ne,_]=a.useState([]),[rt,nt]=a.useState(!1),[it,O]=a.useState(null);a.useEffect(()=>{if(!d)return;let t=!1;async function n(){try{const r=await gt(f,u,ke.detail((i==null?void 0:i.id)??"","product",o),`/api/products/${o}`);if(t)return;const s=r.product;me(!!s.archived),Fe(s.name??""),Te(s.description??""),xe(s.images??[]),Ae(s.pricingType),J(q(s.price)),Ue(i?jt(i,fe):s.currency),s.billingPeriod&&Ve(s.billingPeriod),ge(q(s.firstPaymentPrice)),ze(s.firstPaymentPrice!=null),Ee(q(s.defaultPrice)),Le(q(s.minPrice)),$e(q(s.maxPrice)),Ie(!!s.trackInventory),Me(s.stockQuantity!=null?String(s.stockQuantity):""),Qe(!!s.requiresShipping),Be(s.weight!=null?String(s.weight):""),s.weightUnit&&Ke(s.weightUnit),He(!!s.collectTax),s.taxType&&Je(s.taxType),Ge(s.taxValue!=null?String(s.taxValue):""),Xe(!!s.collectShippingFee),s.shippingFeeType&&Ye(s.shippingFeeType),Ze(s.shippingFeeValue!=null?String(s.shippingFeeValue):""),se(s.tags??[]),je(s.category??""),k(s.options??[]),st((s.options??[]).length>0),tt((s.tags??[]).length>0||!!s.category),_((r.variants??[]).map(l=>({options:l.options,sku:l.sku||"",priceOverride:l.priceOverride!=null?(l.priceOverride/100).toFixed(2):"",stockQuantity:String(l.stockQuantity)})))}catch(r){if(t)return;r instanceof es&&r.status===404?wt(!0):O("Failed to load product")}finally{t||Ct(!1)}}return n(),()=>{t=!0}},[o,d]),as("products",o,()=>{gt(f,u,ke.detail((i==null?void 0:i.id)??"","product",o),`/api/products/${o}`).then(t=>{var n;return me(!!((n=t.product)!=null&&n.archived))},()=>{})});const A=a.useMemo(()=>re.filter(t=>t.name.trim()&&t.values.length>0),[re]),Se=a.useMemo(()=>gs(A),[A]);a.useEffect(()=>{T||(Se.length>0?_(t=>{const n=s=>JSON.stringify(Object.entries(s).sort(([l],[c])=>l.localeCompare(c))),r=new Map(t.map(s=>[n(s.options),s]));return Se.map(s=>{const l=n(s),c=r.get(l);return c?{...c,options:s}:{options:s,sku:"",priceOverride:"",stockQuantity:"0"}})}):_([]))},[Se,T]);async function lt(t){const n=t.filter(s=>s.type.startsWith("image/"));if(n.length===0)return;_e(!0);const r=[];for(const s of n)try{const l=new FormData;l.append("image",s);const c=await u("/api/products/upload-image",{method:"POST",headers:{},body:l});if(c.ok){const F=await c.json();
1r.push(F.url)}}catch{}xe(s=>[...s,...r]),_e(!1)}async function _t(t){const n=Array.from(t.target.files??[]);t.target.value="",await lt(n)}const Q=a.useRef(0);function ie(t){return Array.from(t.dataTransfer.types).includes("Files")}function Ot(t){ie(t)&&(t.preventDefault(),Q.current+=1,he(!0))}function At(t){ie(t)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy")}function Ut(t){ie(t)&&(Q.current=Math.max(0,Q.current-1),Q.current===0&&he(!1))}function Vt(t){ie(t)&&(t.preventDefault(),Q.current=0,he(!1),lt(Array.from(t.dataTransfer.files)))}function zt(t){xe(n=>n.filter((r,s)=>s!==t))}function y(t){const n=parseFloat(t);return isNaN(n)?null:Math.round(n*100)}function ot(){const t=We.trim();if(!t||be.includes(t)){ae("");return}se(n=>[...n,t]),ae("")}const ct=!!S.trim()&&!rt&&(p==="open_ended"?!0:y(v)!=null);async function Et(){var t,n;if(!(!i||!ct)){nt(!0),O(null);try{const r={...d?{}:{workspaceId:i.id},name:S.trim(),description:L.trim()||null,images:$,pricingType:p,currency:P,trackInventory:ye,stockQuantity:ye&&A.length===0?parseInt(Re)||0:null,requiresShipping:W,weight:W&&ve.trim()?parseFloat(ve):null,weightUnit:W?qe:null,collectTax:C,taxType:C?R:null,taxValue:C?parseFloat(ee)||0:null,collectShippingFee:b,shippingFeeType:b?M:null,shippingFeeValue:b?parseFloat(te)||0:null,tags:be,category:et.trim()||null,options:A};(p==="one_time"||p==="recurring")&&(r.price=y(v)),p==="recurring"&&(r.billingPeriod=I,r.firstPaymentPrice=G?y(D):null),p==="open_ended"&&(r.defaultPrice=y(X),r.minPrice=y(Y),r.maxPrice=y(Z));const s=await u(d?`/api/products/${o}`:"/api/products",{method:d?"PATCH":"POST",body:JSON.stringify(r)}),l=await s.json();if(!s.ok){O(l.error||(d?"Failed to save product":"Failed to create product"));return}const c=d?o:(t=l.product)==null?void 0:t.id;if(c&&(ne.length>0||d)){const F=A.length>0?ne.map(B=>({options:B.options,sku:B.sku||null,priceOverride:B.priceOverride?Math.round(parseFloat(B.priceOverride)*100):null,stockQuantity:parseInt(B.stockQuantity)||0})):[];await u(`/api/products/${c}/variants`,{method:"PUT",body:JSON.stringify({variants:F})})}(n=l.product)!=null&&n.id&&(ft(f,Ce(u,i.id).queryKey,l.product),ss(f,ke.detail(i.id,"product",l.product.id))),w({to:`/${N}/products`})}catch{O("Something went wrong")}finally{nt(!1)}}}async function Lt(){var t;if(o){Pe(!0);try{const n=await u(`/api/products/${o}/archive`,{method:"PATCH",body:JSON.stringify({archived:!H})});if(n.ok){me(!H);const r=await n.json().catch(()=>null);(t=r==null?void 0:r.product)!=null&&t.id&&i&&ft(f,Ce(u,i.id).queryKey,r.product)}else O("Failed to update product")}catch{O("Something went wrong")}finally{Pe(!1)}}}const U=fs(P),dt=a.useMemo(()=>({name:S,description:L.trim()||null,images:$,pricingType:p,priceCents:y(v),currency:P,billingPeriod:p==="recurring"?I:null,firstPaymentPriceCents:p==="recurring"&&G?y(D):null,defaultPriceCents:y(X),minPriceCents:y(Y),maxPriceCents:y(Z),collectTax:C,taxType:C?R:null,taxValue:C&&ee||null,collectShippingFee:b,shippingFeeType:b?M:null,shippingFeeValue:b&&te||null}),[S,L,$,p,v,P,I,G,D,X,Y,Z,C,R,ee,b,M,te]),ut=a.useMemo(()=>i?{name:i.name,avatarUrl:i.avatarUrl,checkoutPrimaryColor:i.checkoutPrimaryColor,checkoutBackgroundColor:i.checkoutBackgroundColor,checkoutBackground:i.checkoutBackground,checkoutBackgroundColorAccent:i.checkoutBackgroundColorAccent}:null,[i]),$t=a.useMemo(()=>ms(dt,ut),[dt,ut]),It=a.useMemo(()=>{const t=i==null?void 0:i.customDomain,n=(i==null?void 0:i.customDomainStatus)==="active";return`${t&&n?t:window.location.host}/pay/${ys(S)||"your-product"}`},[i,S]),Rt=a.useDeferredValue($t),Mt=a.useDeferredValue(It);return kt?e.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[e.jsx(yt,{title:e.jsx(vt,{items:[{label:"Products",to:bt("products",`/${N}/products`),icon:e.jsx(xt,{})},{label:"Not found"}]})}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Product not found"}),e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"This product doesn't exist, or you don't have access to it."})]})]}):e.jsxs("section",{className:"relative flex h-full min-h-0",onDragEnter:Ot,onDragOver:At,onDragLeave:Ut,onDrop:Vt,children:[Ft&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-[2px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-2xl border-2 border-dashed border-foreground
1/25 px-10 py-8",children:[e.jsx(ht,{className:"size-6 text-muted-foreground"}),e.jsx("p",{className:"text-[13px] font-medium",children:"Drop to add product images"})]})}),e.jsx(yt,{title:e.jsx(vt,{items:[{label:"Products",to:bt("products",`/${N}/products`),icon:e.jsx(xt,{})},{label:d?S||(T?ts(f,Ce(u,(i==null?void 0:i.id)??"").queryKey,o,"name"):null)||"Product":"New product"}]}),actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[d&&H&&e.jsx("span",{className:"rounded-md bg-secondary px-2 py-0.5 text-[11px] font-medium text-muted-foreground",children:"Archived"}),d&&e.jsx(le,{size:"sm",variant:"outline",disabled:Pt||T,onClick:()=>void Lt(),className:"h-7 px-3 text-[12px] font-medium tracking-normal",children:H?"Unarchive":"Archive"}),e.jsx(le,{size:"sm",disabled:!ct||T,onClick:()=>void Et(),className:"h-7 px-3 text-[12px] font-medium tracking-normal",children:rt?d?"Savingâ¦":"Creatingâ¦":d?"Save changes":"Create product"})]})}),e.jsxs("div",{className:"relative flex h-full w-full min-w-0 flex-col lg:max-w-[440px] lg:border-r lg:border-border-subtle",children:[T&&e.jsx("div",{className:"absolute inset-0 z-20 space-y-7 bg-card px-5 py-5",children:[0,1,2,3].map(t=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"skeleton h-3 w-24 rounded bg-muted"}),e.jsx("div",{className:"skeleton h-10 rounded-xl bg-muted"})]},t))}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-7 overflow-y-auto px-5 py-5 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:[it&&e.jsx(rs,{children:it}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"product-name",className:"text-[13px] font-medium",children:"Product"}),e.jsx(m,{id:"product-name",value:S,onChange:t=>Fe(t.target.value),placeholder:"What are you selling?",autoFocus:!0,className:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"product-description",className:"text-[13px] font-medium",children:"Description"}),e.jsx(ns,{id:"product-description",value:L,onChange:t=>Te(t.target.value),placeholder:"Shown to a customer who is about to payâ¦",maxLength:1e3,className:"min-h-[84px] resize-none rounded-xl border-0 bg-secondary text-sm shadow-none focus-visible:bg-muted focus-visible:ring-0"}),e.jsxs("p",{className:"text-right text-[11px] tabular-nums text-muted-foreground/60",children:[L.length," / 1000"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{id:"product-images-label",className:"text-[13px] font-medium",children:"Images"}),e.jsxs("div",{role:"group","aria-labelledby":"product-images-label",className:"flex flex-wrap gap-2",children:[$.map((t,n)=>e.jsxs("div",{className:"group relative",children:[e.jsx("img",{src:t,alt:"",className:"size-16 rounded-xl border border-border-subtle bg-muted object-cover"}),n===0&&$.length>1&&e.jsx("span",{className:"absolute bottom-1 left-1 rounded bg-black/60 px-1 text-[9px] font-medium text-white",children:"Cover"}),e.jsx("button",{type:"button",onClick:()=>zt(n),className:"absolute -right-1.5 -top-1.5 hidden size-5 items-center justify-center rounded-full bg-foreground text-background shadow group-hover:flex","aria-label":"Remove image",children:e.jsx(oe,{className:"size-3"})})]},t)),e.jsxs("button",{type:"button",onClick:()=>{var t;return(t=K.current)==null?void 0:t.click()},disabled:De,className:"flex size-16 flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-border text-muted-foreground transition-colors hover:border-foreground
1/25 hover:text-foreground disabled:opacity-50",children:[e.jsx(ht,{className:"size-4"}),e.jsx("span",{className:"text-[9px] font-medium",children:De?"Uploadingâ¦":"Add"})]})]}),e.jsx("input",{ref:K,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:_t}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Click to browse, or drop images anywhere on this page."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-3 rounded-lg bg-secondary p-0.5",children:[{id:"one_time",label:"One-time"},{id:"recurring",label:"Recurring"},{id:"open_ended",label:"Open-ended"}].map(t=>e.jsx("button",{type:"button",onClick:()=>Ae(t.id),className:g("h-8 rounded-[7px] text-[13px] font-medium transition-colors",p===t.id?"bg-card text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)]":"text-muted-foreground hover:text-foreground"),children:t.label},t.id))}),p!=="open_ended"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"pointer-events-none absolute left-3.5 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:U}),e.jsx(m,{type:"number",step:"0.01",min:"0",value:v,onChange:t=>J(t.target.value),placeholder:"0.00",className:g(h,j,"pl-8 tabular-nums")})]}),p==="recurring"?e.jsxs(ce,{value:I,onValueChange:t=>Ve(t),children:[e.jsx(de,{className:"h-10 w-[150px] rounded-xl border-0 bg-secondary shadow-none",children:e.jsx(ue,{})}),e.jsx(pe,{children:we.map(t=>e.jsx(V,{value:t.value,children:t.label},t.value))})]}):e.jsx(is,{delayDuration:200,children:e.jsxs(ls,{children:[e.jsx(os,{asChild:!0,children:e.jsx("span",{className:"flex h-10 cursor-help items-center rounded-xl bg-secondary px-3.5 text-sm font-medium text-muted-foreground",children:P})}),e.jsx(cs,{side:"top",align:"end",className:"max-w-[230px] p-3",children:e.jsxs("p",{className:"text-[12px] leading-relaxed",children:["Currency is set for the whole workspace, so every product shares it."," ",e.jsx("button",{type:"button",onClick:()=>w({to:`/${N}/settings/general`}),className:"font-medium underline underline-offset-2 opacity-80 transition-opacity hover:opacity-100",children:"Change in settings"})]})})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[vs.map(t=>e.jsxs("button",{type:"button",onClick:()=>{const n=parseFloat(v),r=(Number.isFinite(n)?n:0)+parseFloat(t);J(Number.isInteger(r)?String(r):r.toFixed(2))},className:"h-6 rounded-md bg-secondary px-2 text-[11px] font-medium tabular-nums text-muted-foreground transition-colors hover:bg-tertiary hover:text-foreground",children:["+",U,t]},t)),v&&e.jsx("button",{type:"button",onClick:()=>J(""),className:"h-6 rounded-md px-2 text-[11px] font-medium text-muted-foreground/70 transition-colors hover:text-foreground",children:"Clear"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"The customer chooses what to pay."}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Suggested",value:X,set:Ee},{label:"Minimum",value:Y,set:Le},{label:"Maximum",value:Z,set:$e}].map(t=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:`product-price-${t.label.toLowerCase()}`,className:"text-[11px] text-muted-foreground",children:t.label}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:U}),e.jsx(m,{id:`product-price-${t.label.toLowerCase()}`,type:"number",step:"0.01",min:"0",value:t.value,onChange:n=>t.set(n.target.value),placeholder:"â",className:g(h,j,"pl-7 tabular-nums")})]})]},t.label))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{id:"product-advanced-label",className:"text-[13px] font-medium",children:"Advanced options"}),e.jsxs("div",{role:"group","aria-labelledby":"product-advanced-label",className:"flex flex-col rounded-[14px] border border-border",children:[p==="recurring"&&e.jsxs(z,{first:!0,icon:e.jsx(Ht,{}),label:"Different first payment",checked:G,onCheckedChange:t=>{ze(t),t||ge("")},children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-first-payment",className:"text-[11px] text-muted-foreground",children:"First payment"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute left-3.5 to
1p-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:U}),e.jsx(m,{id:"product-first-payment",type:"number",step:"0.01",min:"0",value:D,onChange:t=>ge(t.target.value),placeholder:"0.00",className:g(h,j,"pl-8 tabular-nums")})]})]}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:D&&v?`Charged ${U}${D} today, then ${U}${v} ${((mt=we.find(t=>t.value===I))==null?void 0:mt.label.toLowerCase())??""}.`:"Charged once at signup instead of the recurring price. Every cycle after costs the recurring price."})]}),e.jsx(z,{first:p!=="recurring",icon:e.jsx(Jt,{}),label:"Track inventory",checked:ye,onCheckedChange:Ie,children:A.length===0?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-stock",className:"text-[11px] text-muted-foreground",children:"Stock quantity"}),e.jsx(m,{id:"product-stock",type:"number",min:"0",value:Re,onChange:t=>Me(t.target.value),placeholder:"0",className:g(h,j,"w-40 tabular-nums")})]}):e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Stock is tracked per variant below."})}),e.jsx(z,{icon:e.jsx(Xt,{}),label:"Options & variants",checked:Dt,onCheckedChange:t=>{st(t),t?re.length===0&&k([{name:"",values:[]}]):(k([]),Ne({}))},children:e.jsxs("div",{className:"space-y-3",children:[re.map((t,n)=>
1e.jsxs("div",{className:"space-y-2 rounded-xl bg-foreground/[0.03] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{value:t.name,onChange:r=>k(s=>s.map((l,c)=>c===n?{...l,name:r.target.value}:l)),placeholder:"Option name (e.g. Size)",className:g(h,"h-9 flex-1 bg-card")}),e.jsx(le,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(r=>r.filter((s,l)=>l!==n)),"aria-label":"Remove option",className:"size-8 rounded-md text-muted-foreground hover:text-destructive",children:e.jsx(oe,{className:"size-4"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.values.map(r=>e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-secondary py-1 pl-2.5 pr-1.5 text-[12px] font-medium",children:[r,e.jsx("button",{type:"button",onClick:()=>k(s=>s.map((l,c)=>c===n?{...l,values:l.values.filter(F=>F!==r)}:l)),className:"flex size-4 items-center justify-center rounded-full text-muted-foreground hover:text-foreground","aria-label":`Remove ${r}`,children:e.jsx(oe,{className:"size-3"})})]},r)),e.jsx(m,{value:at[n]||"",onChange:r=>Ne(s=>({...s,[n]:r.target.value})),onKeyDown:r=>{if(r.key==="Enter"||r.key===","){r.preventDefault();const s=(at[n]||"").trim();if(!s||t.values.includes(s))return;k(l=>l.map((c,F)=>F===n?{...c,values:[...c.values,s]}:c)),Ne(l=>({...l,[n]:""}))}},placeholder:"Add value âµ",className:g(h,"h-7 w-28 bg-card text-[12px]")})]})]},n)),e.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>k(t=>[...t,{name:"",values:[]}]),className:"h-7 gap-1 rounded-lg px-2.5 text-[12px] font-medium tracking-normal",children:[e.jsx(Gt,{className:"size-3.5"})," Add option"]}),ne.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_88px_88px_64px] gap-1.5 px-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:[e.jsx("span",{children:"Variant"}),e.jsx("span",{children:"SKU"}),e.jsx("span",{children:"Price"}),e.jsx("span",{children:"Stock"})]}),ne.map((t,n)=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_88px_88px_64px] items-center gap-1.5",children:[e.jsx("span",{className:"truncate px-1 text-[12px] font-medium",children:Nt(t.options)}),e.jsx(m,{value:t.sku,onChange:r=>_(s=>s.map((l,c)=>c===n?{...l,sku:r.target.value}:l)),placeholder:"SKU",className:g(h,"h-8 px-2 text-[12px]")}),e.jsx(m,{type:"number",step:"0.01",value:t.priceOverride,onChange:r=>_(s=>s.map((l,c)=>c===n?{...l,priceOverride:r.target.value}:l)),placeholder:"â",className:g(h,j,"h-8 px-2 text-[12px] tabular-nums")}),e.jsx(m,{type:"number",min:"0",value:t.stockQuantity,onChange:r=>_(s=>s.map((l,c)=>c===n?{...l,stockQuantity:r.target.value}:l)),className:g(h,j,"h-8 px-2 text-[12px] tabular-nums")})]},Nt(t.options)))]})]})}),e.jsxs(z,{icon:e.jsx(Yt,{}),label:"Requires shipping",checked:W,onCheckedChange:Qe,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-weight",className:"text-[11px] text-muted-foreground",children:"Weight"}),e.jsx(m,{id:"product-weight",type:"number",step:"0.01",min:"0",value:ve,onChange:t=>Be(t.target.value),placeholder:"0",className:g(h,j,"tabular-nums")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-weight-unit",className:"text-[11px] text-muted-foreground",children:"Unit"}),e.jsxs(ce,{value:qe,onValueChange:t=>Ke(t),children:[e.jsx(de,{id:"product-weight-unit",className:"h-10 rounded-xl border-0 bg-secondary shadow-none",children:e.jsx(ue,{})}),e.jsx(pe,{children:["g","kg","oz","lb"].map(t=>e.jsx(V,{value:t,children:t},t))})]})]})]}),e.jsx(bs,{label:"Charge a shipping fee",checked:b,onCheckedChange:Xe}),b&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-shipping-fee-type",className:"text-[11px] text-muted-foreground",children:"Type"}),e.jsxs(ce,{value:M,onValueChange:t=>Ye(t),children:[e.jsx(de,{id:"product-shipping-fee-type",className:"h-10 rounded-xl border-0 bg-secondary shadow-none",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(V,{value:"fixed",children:"Fixed amount"}),e.jsx(V,{value:"percentage",children:"Percentage"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-shipping-fee",className:"text-[11px] text-muted-foreground",children:M==="fixed"?`Amount (${P})`:"Percent"}),e.jsx(m,{id:"product-shipping-fee",type:"number",step:"0.01",min:"0",value:te,onChange:t=>Ze(t.target.value),placeholder:"0",className:g(h,j,"tabular-nums")})]})]})]}),e.jsx(z,{icon:e.jsx(Zt,{}),label:"Collect tax",checked:C,onCheckedChange:He,children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-tax-type",className:"text-[11px] text-muted-foreground",children:"Type"}),e.jsxs(ce,{value:R,onValueChange:t=>Je(t),children:[e.jsx(de,{id:"product-tax-type",className:"h-10 rounded-xl border-0 bg-secondary shadow-none",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(V,{value:"percentage",children:"Percentage"}),e.jsx(V,{value:"fixed",children:"Fixed amount"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-tax",className:"text-[11px] text-muted-foreground",children:R==="fixed"?`Amount (${P})`:"Percent"}),e.jsx(m,{id:"product-tax",type:"number",step:"0.01",min:"0",value:ee,onChange:t=>Ge(t.target.value),placeholder:"0",className:g(h,j,"tabular-nums")})]})]})}),e.jsxs(z,{last:!0,icon:e.jsx(Wt,{}),label:"Tags & category",checked:Tt,onCheckedChange:t=>{tt(t),t||(se([]),ae(""),je(""))},children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-category",className:"text-[11px] text-muted-foreground",children:"Category"}),e.jsx(m,{id:"product-category",value:et,onChange:t=>je(t.target.value),placeholder:"e.g. Apparel",className:h})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"product-tag-input",className:"text-[11px] text-muted-foreground",children:"Tags"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[be.map(t=>e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-secondary py-1 pl-2.5 pr-1.5 text-[12px] font-medium",children:[t,e.jsx("button",{type:"button",onClick:()=>se(n=>n.filter(r=>r!==t)),className:"flex size-4 items-center justify-center rounded-full text-muted-foreground hover:text-foreground","aria-label":`Remove ${t}`,children:e.jsx(oe,{className:"size-3"})})]},t)),e.jsx(m,{id:"product-tag-input",value:We,onChange:t=>ae(t.target.value),onKeyDown:t=>{(t.key==="Enter"||t.key===",")&&(t.preventDefault(),ot())},onBlur:ot,placeholder:"Add tag âµ",className:g(h,"h-7 w-28 text-[12px]")})]})]})]})]})]})]})]}),e.jsx(hs,{data:Rt,previewUrl:Mt})]})}function Ws(){return e.jsx(js,{})}export{Ws as NewProductPage,js as ProductForm};
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.