1import{j as e,b as We,u as Nt,V as Ct,a as St,B as j,c as T,Y as It,X as wt}from"./index-C9VyRByS.js";import{r as o,J as Be,aY as qe,al as Qt,ao as Pt,ap as F,as as Y,cc as Lt,o as zt,a6 as Et,b as Ve,B as Tt,p as Dt,aG as _t}from"./icons-Dk9ia89R.js";import{u as Mt}from"./useQuery-DwXbu02t.js";import{k as Ke,w as ie,u as Ge,s as ce,q as Ot}from"./workspace-queries-BwGSHjQO.js";import{c as At,a as Ft,u as Rt,m as Ut}from"./catalog-cache-Cgm62ltw.js";import{u as $t}from"./record-changed-DLg-4FAt.js";import{I as He}from"./input-CPdsLOuT.js";import{E as Bt}from"./error-note-DUDm2XNO.js";import{L as J}from"./label-xeDYeu0z.js";import{S as Z}from"./switch-frdVQ2Np.js";import{S as de,a as ue,b as me,c as pe,d as R}from"./select-DRVFTakE.js";import{P as Ye,a as Je,E as qt}from"./page-header-BapO8lcs.js";import{D as Vt,a as Kt,b as Gt,c as xe,d as Ht}from"./dropdown-menu-Br7A3ifT.js";import{f as fe}from"./list-view-Bo1lHrNw.js";import{Q as Yt}from"./quantity-input-DgzKSRaY.js";import{u as Jt}from"./sandbox-BB7rpX9h.js";import{w as Xt}from"./workspace-routing-DTKneyEE.js";import{i as Zt}from"./reserved-slugs-CorB3H1i.js";import{s as Wt,p as es}from"./stock-BiKmsNqB.js";import{u as ts,a as ss}from"./prefill-BGherzcJ.js";import{A as as,G as ns}from"./payment-method-marks-GeFsWA-j.js";import{C as ls}from"./CheckoutPreviewPane-D5TJ0CQG.js";const rs=o.memo(ls),os=[];function is(m){return m.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Xe(m,u){return new Intl.NumberFormat("en-US",{style:"currency",currency:u}).format(m/100)}function C(){return Math.random().toString(36).slice(2,10)}const Ze="h-10 rounded-xl border-0 bg-secondary shadow-none focus-visible:bg-muted focus-visible:ring-0",he="h-10 rounded-xl border-0 bg-secondary px-3 shadow-none",cs={text:"Text",textarea:"Text area",number:"Number",select:"Dropdown",checkbox:"Checkbox"};function X({icon:m,label:u,checked:i,onCheckedChange:p,first:b,last:v,children:S}){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{type:"button",onClick:()=>p(!i),className:T("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]",b?"rounded-t-[10px]":"rounded-t-md",v?"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:m}),e.jsx("span",{className:"flex-1 text-[13px] font-medium",children:u}),e.jsx("span",{onClick:I=>I.stopPropagation(),className:"flex items-center",children:e.jsx(Z,{checked:i,onCheckedChange:p})})]}),i&&S&&e.jsx("div",{className:"space-y-3 px-3.5 pb-4 pt-1",children:S})]})}function et({linkId:m}){const u=!!m,{activeWorkspace:i,authFetch:p}=Nt(),b=Ct(),{workspaceSlug:v}=We({strict:!1}),S=St(),{isSandboxMode:I}=Jt(),w=(i==null?void 0:i.id)??"",ge=Mt(Ot(p,w)),W=ge.data??os,x=o.useMemo(()=>W.filter(t=>!t.archived),[W]),ee=ge.isPending,[te,tt]=o.useState(u),[st,at]=o.useState(!1),[U,ye]=o.useState(""),[g,$]=o.useState(""),[je,nt]=o.useState(""),[B,be]=o.useState(!1),[ke,se]=o.useState(null),[lt,ve]=o.useState(!1),[rt,Ne]=o.useState("active"),[y,D]=o.useState(u?[]:[{localId:C(),productId:"",variantId:null,selectedOptions:null,defaultQuantity:1,adjustableQuantity:!1,minQuantity:1,maxQuantity:99}]),[q,Ce]=o.useState({}),[V,_]=o.useState([]),[K,Se]=o.useState(!1),[M,O]=o.useState([]),[ot,Ie]=o.useState(!1),[it,we]=o.useState(!1),[Q,Qe]=o.useState(!1),[k,ae]=o.useState(["card","bank","apple_pay","google_pay"]),[Pe,Le]=o.useState(!1),[ze,P]=o.useState(""),[G,Ee]=o.useState(!1),[A,ne]=o.useState(!1);o.useEffect(()=>{if(!u)return;let t=!1;async function a(){try{const s=await Ke(b,p,ie.detail((i==null?void 0:i.id)??"","payment-link",m),`/api/payment-links/${m}`);if(t)return;const n=s.paymentLink;ye(n.name),$(n.slug),nt(n.slug),be(!0),Ne(n.status),Se(n.collectShippingAddress);const r=(n.customFields||[]).map(c=>({...c,id:c.id||C()}));_(r),Ie(r.length>0),D((n.products||[]).map(c=>({localId:C(),productId:c.productId,variantId:c.variantId||null,selectedOptions:c.selectedOptions||null,defaultQuantity:c.defaultQuantity,adjustableQuantity:c.adjustableQuantity,minQuantity:c.minQuantity??1,maxQuantity:c.maxQuantity??99})));const l=(n.upsells||[]).map(c=>({localId:C(),productId:c.productId,variantId:null,selectedOptions:null,defaultQuantity:c.defaultQuantity,adjustableQuantity:c.adjustableQuantity,minQuantity:c.minQuantity??1,maxQuantity:c.maxQuantity??99}));O(l),we(l.length>0);const d=Array.isArray(n.paymentMethods)?n.paymentMethods:null;Qe(!!d),d&&ae(d)}catch(s){if(t)return;s instanceof Ge&&s.status===404?at(!0):P("Failed to load payment link")}finally{t||tt(!1)}}return a(),()=>{t=!0}},[m,u]),$t("payment-links",m,()=>{Ke(b,p,ie.detail((i==null?void 0:i.id)??"","payment-link",m),`/api/payment-links/${m}`).then(t=>{var a;(a=t.paymentLink)!=null&&a.status&&Ne(t.paymentLink.status)},()=>{})});const N=ts(!u),Te=o.useRef(!1);o.useEffect(()=>{if(Te.current||!N.name&&!N.productId||ee)return;Te.current=!0;const t=N.productId?x.find(l=>l.id===N.productId.toLowerCase()):void 0,a=(N.name??"").trim().toLowerCase(),s=ss(N.amount),n=x.filter(l=>{var d;return l.name.trim().toLowerCase()===a&&!(((d=l.options)==null?void 0:d.length)>0)}),r=t??(s!==null?n.find(l=>l.price===s):void 0)??n[0];r&&D(l=>l.length===1&&!l[0].productId?[{...l[0],productId:r.id}]:l)},[N,x,ee]);const f=x.find(t=>{var a;return t.id===((a=y.find(s=>s.productId))==null?void 0:a.productId)});o.useEffect(()=>{u||ye((f==null?void 0:f.name)??"")},[f==null?void 0:f.name,u]),o.useEffect(()=>{u||B||$(f?is(f.name):"")},[f==null?void 0:f.name,B,u,f]);const De=o.useCallback(async t=>{if(!t.trim()){se(null);return}if(u&&t===je){se(!0);return}ve(!0);try{const a=await p(`/api/payment-links/check-slug?slug=${encodeURIComponent(t)}`);if(a.ok){const s=await a.json();if(!s.available&&s.suggestion&&!B){$(s.suggestion);return}se(s.available)}}catch{}ve(!1)},[p,je,u,B]);o.useEffect(()=>{const t=setTimeout(()=>void De(g),400);return()=>clearTimeout(t)},[g,De]);const le=o.useCallback(async t=>{Ce(a=>(a[t]||(async()=>{try{const s=await b.fetchQuery({queryKey:ie.detail(w,"product",t),queryFn:async()=>{const n=await p(`/api/products/${t}`);if(!n.ok)throw new Ge(n.status,`/api/products/${t}`);return n.json()},staleTime:3e4,retry:!1});Ce(n=>({...n,[t]:s.variants||[]}))}catch{}})(),a))},[p,b,w]),_e=o.useRef(!1);o.useEffect(()=>{_e.current||x.length===0||y.length===0||(_e.current=!0,y.forEac
1h(t=>{var s;if(!t.productId)return;const a=x.find(n=>n.id===t.productId);a&&((s=a.options)==null?void 0:s.length)>0&&le(t.productId)}))},[x,y,le]);function ct(){D(t=>[...t,{localId:C(),productId:"",variantId:null,selectedOptions:null,defaultQuantity:1,adjustableQuantity:!1,minQuantity:1,maxQuantity:99}])}function L(t,a){D(s=>s.map(n=>n.localId===t?a:n))}function dt(t){D(a=>a.filter(s=>s.localId!==t))}function ut(){O(t=>[...t,{localId:C(),productId:"",variantId:null,selectedOptions:null,defaultQuantity:1,adjustableQuantity:!1,minQuantity:1,maxQuantity:99}])}function mt(t,a){O(s=>s.map(n=>n.localId===t?a:n))}function pt(t){O(a=>a.filter(s=>s.localId!==t))}function xt(){_(t=>[...t,{id:C(),label:"",type:"text",required:!1,options:[]}])}function z(t,a){_(s=>s.map(n=>n.id===t?a:n))}function ft(t){_(a=>a.filter(s=>s.id!==t))}const re=y.filter(t=>t.productId),Me=Xt(i,I),H=!!Me.card,Oe=!!(i!=null&&i.achEnabled)&&!!Me.bank,Ae=H&&!!(i!=null&&i.applePayEnabled),Fe=H&&!!(i!=null&&i.googlePayEnabled),Re=(t,a)=>{ae(s=>a?s.includes(t)?s:[...s,t]:s.filter(n=>n!==t))},Ue=!Q||k.includes("card")||k.includes("bank"),ht=re.length>0&&!!g.trim()&&!Pe&&Ue;function gt(t,a){const s=ce(p,w,t.sandbox??I).queryKey,n=new Map(W.map(d=>[d.id,d])),r=a.items.flatMap((d,c)=>{const h=n.get(d.productId);return h?[{id:`pending-${c}`,productId:h.id,defaultQuantity:d.defaultQuantity,productName:h.name,productPrice:h.price,productCurrency:h.currency,productImages:h.images??null,productPricingType:h.pricingType}]:[]}),l=a.upsells.flatMap((d,c)=>{const h=n.get(d.productId);return h?[{id:`pending-upsell-${c}`,productName:h.name}]:[]});Rt(b,s,{...t,products:r,upsells:l}),Ut(b,s)}async function yt(){if(P(""),re.length===0){P("Add at least one product.");return}if(!g.trim()){P("A URL slug is required.");return}Le(!0);try{const t={...u?{}:{workspaceId:i.id,sandbox:I},name:U.trim(),slug:g.trim(),collectShippingAddress:K,customFields:V.filter(s=>s.label.trim()).map(s=>({...s,options:s.options.map(n=>n.trim()).filter(Boolean)})),items:re.map(s=>({productId:s.productId,variantId:s.variantId||null,selectedOptions:s.selectedOptions||null,defaultQuantity:s.defaultQuantity,adjustableQuantity:s.adjustableQuantity,minQuantity:s.minQuantity,maxQuantity:s.maxQuantity})),upsells:M.filter(s=>s.productId).map(s=>({productId:s.productId,defaultQuantity:s.defaultQuantity,adjustableQuantity:s.adjustableQuantity,minQuantity:s.minQuantity,maxQuantity:s.maxQuantity})),paymentMethods:Q?k:null},a=await p(u?`/api/payment-links/${m}`:"/api/payment-links",{method:u?"PATCH":"POST",body:JSON.stringify(t)});if(a.ok){const s=await a.json().catch(()=>null);s!=null&&s.paymentLink&>(s.paymentLink,t),S({to:fe("payment-links",`/${v}/payment-links`)})}else{const s=await a.json();P(s.error||(u?"Failed to update payment link.":"Failed to create payment link."))}}catch{P("Something went wrong.")}Le(!1)}async function jt(){if(m)try{const t=await p(`/api/payment-links/${m}`,{method:"DELETE"});if(t.ok){for(const a of[!0,!1])Ft(b,ce(p,w,a).queryKey,m);S({to:`/${v}/payment-links`})}else await It(t,"Couldn't delete the payment link. Please try again.")}catch{wt.error("Couldn't delete the payment link. Please try again.")}}const E=o.useMemo(()=>{const t=i==null?void 0:i.customDomain,a=(i==null?void 0:i.customDomainStatus)==="active";return`${t&&a?`https://${t}`:window.location.origin}/pay/${g||"your-link"}`},[i,g]),oe=o.useMemo(()=>E.replace(/^https?:\/\//,""),[E]);o.useEffect(()=>{if(!G)return;const t=setTimeout(()=>Ee(!1),1600);return()=>clearTimeout(t)},[G]),o.useEffect(()=>{if(!A)return;const t=setTimeout(()=>ne(!1),4e3);return()=>clearTimeout(t)},[A]);const bt=o.useMemo(()=>{const t=(a,s)=>{var l,d;const n=x.find(c=>c.id===a.productId);if(!n)return null;const r=a.variantId?(l=q[a.productId])==null?void 0:l.find(c=>c.id===a.variantId):void 0;return{id:a.localId||s,productId:n.id,defaultQuantity:a.defaultQuantity,adjustableQuantity:a.adjustableQuantity,minQuantity:a.minQuantity,maxQuantity:a.maxQuantity,productName:n.name,productDescription:n.description??null,productPrice:(r==null?void 0:r.priceOverride)??n.price,productCurrency:n.currency,productPricingType:n.pricingType,productBillingPeriod:n.billingPeriod,productFirstPaymentPrice:n.firstPaymentPrice??null,productDefaultPrice
1:null,productMinPrice:null,productMaxPrice:null,productImages:(d=n.images)!=null&&d.length?n.images:null,productTrackInventory:!1,productStockQuantity:null,productCollectTax:!1,productTaxType:null,productTaxValue:null,productCollectShippingFee:!1,productShippingFeeType:null,productShippingFeeValue:null,variantId:a.variantId,selectedOptions:a.selectedOptions}};return{paymentLink:{id:m||"preview",name:U||"Payment link",slug:"__preview__",collectShippingAddress:K,customFields:V.filter(a=>a.label.trim()).map(a=>({...a,options:a.options.map(s=>s.trim()).filter(Boolean)})),sandbox:!1,appliedDiscountCode:null},workspace:i?{id:i.id,name:i.name,avatarUrl:i.avatarUrl,applePayEnabled:!1,googlePayEnabled:!1,achEnabled:Q&&k.includes("bank"),bankProcessor:null,cardSurchargePercent:0,allowDiscounts:!1,requireCheckoutPhone:!1,stackShippingFees:!1,checkoutPrimaryColor:i.checkoutPrimaryColor,checkoutBackgroundColor:i.checkoutBackgroundColor,checkoutBackground:i.checkoutBackground,checkoutBackgroundColorAccent:i.checkoutBackgroundColorAccent}:null,nmiPublicKey:null,processorConfig:{processorType:"nmi"},cardEnabled:!Q||k.includes("card"),paayEnabled:!1,threeDsEnabled:!1,products:y.map((a,s)=>t(a,`line-${s}`)).filter(Boolean),upsells:M.map((a,s)=>t(a,`upsell-${s}`)).filter(Boolean),hasActiveDiscounts:!1}},[y,M,x,q,U,K,V,i,m,Q,k]),kt=o.useDeferredValue(bt),vt=o.useDeferredValue(oe);if(st)return e.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[e.jsx(Ye,{title:e.jsx(Je,{items:[{label:"Payment links",to:fe("payment-links",`/${v}/payment-links`),icon:e.jsx(Be,{})},{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:"Payment link not found"}),e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"This link doesn't exist, or you don't have access to it."})]})]});const $e=(t,a)=>{const s=(a?[...y.map(l=>l.productId),...M.filter(l=>l.localId!==t.localId).map(l=>l.productId)]:y.filter(l=>l.localId!==t.localId).map(l=>l.productId)).filter(Boolean),n=x.filter(l=>!s.includes(l.id)||l.id===t.productId),r=a?mt:L;return e.jsxs(de,{value:t.productId,onValueChange:l=>{var c;const d=x.find(h=>h.id===l);d&&((c=d.options)==null?void 0:c.length)>0&&le(l),r(t.localId,{...t,productId:l,variantId:null,selectedOptions:null})},children:[e.jsx(ue,{className:he,children:e.jsx(me,{placeholder:"Choose a product"})}),e.jsxs(pe,{children:[n.map(l=>{var c;const d=Wt(es(l,q[l.id]));return e.jsx(R,{value:l.id,children:e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[(c=l.images)!=null&&c[0]?e.jsx("img",{src:l.images[0],alt:"",loading:"lazy",decoding:"async",className:"size-5 shrink-0 rounded object-cover"}):e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded bg-foreground
1/[0.06]",children:e.jsx(_t,{className:"size-3 text-muted-foreground/70"})}),e.jsx("span",{className:"truncate",children:l.name}),d&&e.jsx("span",{className:T("shrink-0 text-[11px]",d.soldOut?"text-destructive":"text-muted-foreground/70"),children:d.text}),l.price!=null&&e.jsx("span",{className:"ml-auto shrink-0 text-muted-foreground",children:Xe(l.price,l.currency)})]})},l.id)}),n.length===0&&e.jsx(R,{value:"_none",disabled:!0,children:"No products left"})]})]})};return e.jsxs("section",{className:"relative flex h-full min-h-0",children:[e.jsxs(Ye,{title:e.jsx(Je,{items:[{label:"Payment links",to:fe("payment-links",`/${v}/payment-links`),icon:e.jsx(Be,{})},{label:u?U||(te?At(b,ce(p,w,I).queryKey,m,"name"):null)||"Link":"New link"}]}),actions:e.jsx(j,{size:"sm",disabled:!ht||te,onClick:()=>void yt(),className:"h-7 px-3 text-[12px] font-medium tracking-normal",children:Pe?u?"Savingâ¦":"Creatingâ¦":u?"Save changes":"Create link"}),children:[u&&g&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 hidden justify-center sm:flex",children:e.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",title:E,className:"pointer-events-auto flex h-7 min-w-0 max-w-sm items-center gap-1.5 rounded-md bg-secondary px-2 text-[12px] text-muted-foreground transition-colors hover:bg-tertiary hover:text-foreground",children:[e.jsx("span",{className:"truncate",children:oe}),e.jsx(qe,{className:"size-3.5 shrink-0"})]})}),e.jsxs("div",{className:"-ml-2 flex min-w-0 items-center gap-1.5",children:[u&&rt!=="active"&&e.jsx("span",{className:"shrink-0 rounded-md bg-secondary px-2 py-0.5 text-[11px] font-medium text-muted-foreground",children:"Inactive"}),u&&e.jsxs(Vt,{onOpenChange:t=>{t||ne(!1)},children:[e.jsx(Kt,{asChild:!0,children:e.jsx(j,{variant:"ghost",size:"icon","aria-label":"Link actions",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground",children:e.jsx(qt,{className:"size-4"})})}),e.jsxs(Gt,{align:"end",className:"w-52",children:[e.jsxs(xe,{onSelect:()=>window.open(E,"_blank","noopener,noreferrer"),children:[e.jsx(qe,{}),"Open checkout"]}),e.jsxs(xe,{onSelect:t=>{t.preventDefault(),navigator.clipboard.writeText(E),Ee(!0)},children:[G?e.jsx(Qt,{className:"!opacity-100 text-green-500"}):e.jsx(Pt,{}),G?"Copied":"Copy link"]}),e.jsx(Ht,{}),e.jsxs(xe,{onSelect:t=>{if(!A){t.preventDefault(),ne(!0);return}jt()},className:A?"text-destructive":"",children:[e.jsx(F,{}),A?"Click again to delete":"Delete link"]})]})]})]})]}),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:[te&&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:[ze&&e.jsx(Bt,{children:ze}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{className:"text-[13px] font-medium",children:"Products"}),ee?e.jsx("div",{className:"h-10 skeleton rounded-xl bg-muted"}):x.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-2 rounded-[14px] border border-border p-4",children:[e.jsx("p",{className:"text-[13px] font-medium",children:"No products yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"A link sells a product, so you'll need one first."}),e.jsxs(j,{size:"sm",onClick:()=>S({to:`/${v}/products/new`}),className:"mt-1 h-7 gap-1.5 px-2.5 text-[12px] font-medium tracking-normal [&_svg]:size-3.5",children:[e.jsx(Y,{})," New product"]})]}):e.jsxs("div",{className:"space-y-3",children:[y.map(t=>{var n;const a=x.find(r=>r.id===t.productId),s=q[t.productId];return e.jsxs("div",{className:"space-y-2 rounded-[14px] border border-border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:$e(t,!1)}),y.length>1&&e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>dt(t.localId),"aria-label":"Remove product",className:"size-8 shrink-0 text-muted-foreground hover:text-destructive",children:e.jsx(F,{className:"size-4"})})]}),a&&((n=a.options)==null?void 0:n.length)>0&&e.jsxs(de,{value:t.variantId||"_any",onValueChange:r=>{if(r==="_any")L(t.localId,{...t,variantId:null,selectedOptions:null});else{const l=s==null?void 0:s.find(d=>d.id===r);l&&L(t.localId,{...t,variantId:l.id,selectedOptions:l.options})}},children:[e.jsx(ue,{className:he,children:e.jsx(me,{})}),e.jsxs(pe,{children:[e.jsx(R,{value:"_any",children:"Customer chooses"}),(s||[]).map(r=>{const l=a.trackInventory&&r.stockQuantity<=0;
1return e.jsx(R,{value:r.id,disabled:l,children:e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate",children:Object.values(r.options).join(" / ")}),e.jsx("span",{className:T("ml-auto shrink-0",l?"text-destructive":"text-muted-foreground"),children:l?"Sold out":Xe(r.priceOverride??a.price??0,a.currency)})]})},r.id)})]})]}),e.jsxs("button",{type:"button",onClick:()=>L(t.localId,{...t,adjustableQuantity:!t.adjustableQuantity}),className:"flex h-10 w-full items-center gap-2.5 rounded-xl px-2 text-left transition-[background-color,transform] duration-100 hover:bg-row-hover active:scale-[0.99]",children:[e.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-foreground/[0.05] text-muted-foreground [&>svg]:size-3.5",children:e.jsx(Lt,{})}),e.jsx("span",{className:"flex-1 text-[13px] font-medium",children:"Let customers change quantity"}),e.jsx("span",{onClick:r=>r.stopPropagation(),className:"flex items-center",children:e.jsx(Z,{checked:t.adjustableQuantity,onCheckedChange:r=>L(t.localId,{...t,adjustableQuantity:r})})})]}),t.adjustableQuantity&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Min",value:t.minQuantity,min:1,set:r=>({...t,minQuantity:r})},{label:"Default",value:t.defaultQuantity,min:1,set:r=>({...t,defaultQuantity:r})},{label:"Max",value:t.maxQuantity,min:t.minQuantity,set:r=>({...t,maxQuantity:r})}].map(r=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(J,{className:"text-[11px] text-muted-foreground",children:r.label}),e.jsx(Yt,{value:r.value,min:r.min,"aria-label":`${r.label} quantity`,onChange:l=>L(t.localId,r.set(l)),className:"px-1"})]},r.label))})]},t.localId)}),e.jsxs(j,{variant:"outline",size:"sm",onClick:ct,className:"h-8 w-full gap-1.5 rounded-xl text-[12px] font-medium tracking-normal [&_svg]:size-3.5",children:[e.jsx(Y,{})," Add product"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{className:"text-[13px] font-medium",children:"Link URL"}),e.jsxs("div",{className:"flex h-10 items-center rounded-xl bg-secondary pl-3.5 focus-within:bg-muted",children:[e.jsx("span",{className:"shrink-0 text-sm text-muted-foreground",children:"/pay/"}),e.jsx("input",{value:g,onChange:t=>{$(t.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),be(!0)},placeholder:"your-link",className:"h-full min-w-0 flex-1 bg-transparent pr-3.5 text-sm outline-none placeholder:text-muted-foreground/90"})]}),e.jsx("p",{className:"min-h-4 text-[11px]",children:g.trim()?lt?e.jsx("span",{className:"text-muted-foreground",children:"Checkingâ¦"}):ke===!1?e.jsx("span",{className:"text-destructive",children:Zt(g)?"That URL is reserved.":"That URL is already taken."}):ke?e.jsxs("span",{className:"text-muted-foreground",children:[oe," is available."]}):null:e.jsx("span",{className:"text-muted-foreground",children:"Auto-filled from the first product. Edit it any time."})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(J,{className:"text-[13px] font-medium",children:"Checkout options"}),e.jsxs("div",{className:"flex flex-col rounded-[14px] border border-border",children:[e.jsx(X,{first:!0,icon:e.jsx(zt,{}),label:"Collect shipping address",checked:K,onCheckedChange:Se}),e.jsxs(X,{icon:e.jsx(Et,{}),label:"Custom fields",checked:ot,onCheckedChange:t=>{Ie(t),t||_([])},children:[V.map(t=>e.jsxs("div",{className:"space-y-2 rounded-[10px] border border-border p-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{value:t.label,onChange:a=>z(t.id,{...t,label:a.target.value}),placeholder:"Field label",className:T(Ze,"h-8 flex-1 text-[13px]")}),e.jsxs(de,{value:t.type,onValueChange:a=>z(t.id,{...t,type:a}),children:[e.jsx(ue,{className:T(he,"h-8 w-[112px] text-[13px]"),children:e.jsx(me,{})}),e.jsx(pe,{children:Object.entries(cs).map(([a,s])=>e.jsx(R,{value:a,children:s},a))})]}),e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>ft(t.id),"aria-label":"Remove field",className:"size-8 shrink-0 text-muted-foreground hover:text-destructive",children:e.jsx(F,{className:"size-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[12px] text-muted-foreground",children:"Required"}),e.jsx(Z,{checked:t.required,onCheckedChange:a=>z(t.id,{...t,required:a})})]}),t.type==="select"&&e.jsxs("div",{className:"space-y-1.5",children:[t.options.map((a,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{value:a,onChange:n=>{const r=[...t.options];r[s]=n.target.value,z(t.id,{...t,options:r})},placeholder:`Option ${s+1}`,className:T(Ze,"h-8 flex-1 text-[13px]")}),e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>z(t.id,{...t,options:t.options.filter((n,r)=>r!==s)}),"aria-label":`Remove option ${s+1}`,className:"size-8 shrink-0 text-muted-foreground hover:text-destructive",children:e.jsx(F,{className:"size-4"})})]},s)),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>z(t.id,{...t,options:[...t.options,""]}
1),className:"h-7 w-full rounded-lg text-[12px] font-medium tracking-normal",children:"Add option"})]})]},t.id)),e.jsxs(j,{variant:"outline",size:"sm",onClick:xt,className:"h-8 w-full gap-1.5 rounded-xl text-[12px] font-medium tracking-normal [&_svg]:size-3.5",children:[e.jsx(Y,{})," Add field"]})]}),e.jsxs(X,{icon:e.jsx(Ve,{}),label:"Payment methods",checked:Q,onCheckedChange:t=>{if(Qe(t),!t)return;const a=[...H?["card"]:[],...Oe?["bank"]:[],...Ae?["apple_pay"]:[],...Fe?["google_pay"]:[]];ae(a.length?a:["card"])},children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Only the selected methods are offered on this link's checkout, instead of your workspace defaults."}),e.jsx("div",{className:"flex flex-col gap-0.5",children:[{key:"card",label:"Card",available:H,mark:e.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-foreground/[0.05] text-muted-foreground [&>svg]:size-3.5",children:e.jsx(Ve,{})})},{key:"bank",label:"Bank account",available:Oe,mark: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:e.jsx(Tt,{})})},{key:"apple_pay",label:"Apple Pay",available:Ae,mark:e.jsx(as,{})},{key:"google_pay",label:"Google Pay",available:Fe,mark:e.jsx(ns,{})}].map(({key:t,label:a,available:s,mark:n})=>e.jsxs("button",{type:"button",onClick:()=>Re(t,!k.includes(t)),className:"flex h-10 items-center gap-2.5 rounded-lg px-2 text-left transition-[background-color,transform] duration-100 hover:bg-row-hover active:scale-[0.985]",children:[n,e.jsxs("span",{className:"flex-1 text-[13px] font-medium",children:[a,!s&&e.jsx("span",{className:"font-normal text-muted-foreground",children:" â not set up in your workspace yet"})]}),e.jsx("span",{onClick:r=>r.stopPropagation(),className:"flex items-center",children:e.jsx(Z,{checked:k.includes(t),onCheckedChange:r=>Re(t,r)})})]},t))}),!Ue&&e.jsx("p",{className:"text-[12px] text-destructive",children:"Select at least Card or Bank account. Wallets can't be the only method."})]}),e.jsxs(X,{last:!0,icon:e.jsx(Dt,{}),label:"Upsells",checked:it,onCheckedChange:t=>{we(t),t||O([])},children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Offered alongside the main products at checkout."}),M.map(t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:$e(t,!0)}),e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>pt(t.localId),"aria-label":"Remove upsell",className:"size-8 shrink-0 text-muted-foreground hover:text-destructive",children:e.jsx(F,{className:"size-4"})})]},t.localId)),e.jsxs(j,{variant:"outline",size:"sm",onClick:ut,className:"h-8 w-full gap-1.5 rounded-xl text-[12px] font-medium tracking-normal [&_svg]:size-3.5",children:[e.jsx(Y,{})," Add upsell"]})]})]})]})]})]}),e.jsx(rs,{data:kt,previewUrl:vt})]})}function ds(){return e.jsx(et,{})}function us(){const{linkId:m}=We({strict:!1});return e.jsx(et,{linkId:m})}const Ds=Object.freeze(Object.defineProperty({__proto__:null,EditPaymentLinkPage:us},Symbol.toStringTag,{value:"Module"})),_s=Object.freeze(Object.defineProperty({__proto__:null,NewPaymentLinkPage:ds},Symbol.toStringTag,{value:"Module"}));export{us as E,ds as N,_s as a,Ds as p};
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.