1import{r as n,j as e}from"./react-vendor-CU6Sz31W.js";import{al as Ze,b as et,d9 as tt,da as q,db as z,dc as I,cW as st,t as p,R as at,ax as lt,c6 as rt,h as ze,i as R,dd as it,bS as nt,de as ot,df as dt,bR as ct,j as v,ce as de,ct as mt,cr as xt,I as ut,at as gt,a0 as $,dg as ft,dh as ht,S as bt,a2 as pt,au as yt,g as Nt}from"./index-DEXJEDAi.js";import{M as vt}from"./modal-option-cards-Dksohkou.js";import{u as jt}from"./usePatientTerminology-D5bkkKg2.js";import{i as kt}from"./patientInviteApi-BQHHKSjN.js";import{c as wt}from"./manageLabApi-BUlVz8vT.js";import{i as St}from"./catalogVisitMode-De-HDuz9.js";import{u as Pt}from"./useProductSubscriptionOffer-DL7oz6fV.js";import{r as Ct,P as ce,d as It}from"./subscriptionOffer--xmeipjh.js";import{M as $t,o as Lt}from"./modal-form-CqN5DZuv.js";import{B as Tt}from"./beaker-DG-PilI_.js";import"./firebase-w6DYUbFN.js";import"./payment-icons-Daq1K3F1.js";const Et=Nt("manageProduct"),_t=50,Mt=Object.freeze([]),Re={product:{itemLabel:"product",title:"Send Product to Patient",description:"Choose what the patient should do first, then send the offer to one or more patients.",successNoun:"Offer",sendLabel:"Send offer",testScope:"products"},package:{itemLabel:"package",title:"Send Package to Patient",description:"Choose what the patient should do first, then send the package offer to one or more patients.",successNoun:"Offer",sendLabel:"Send offer",testScope:"products"},lab:{itemLabel:"lab",title:"Send Lab to Patient",description:"Send a lab request to one or more patients. They will receive a checkout link to pay.",successNoun:"Lab request",sendLabel:"Send request",testScope:"labs"},visit:{itemLabel:"visit",title:"Send Visit to Patient",description:"Send a visit checkout link to one or more patients.",successNoun:"Visit offer",sendLabel:"Send visit",testScope:"visits"}};async function me(l,x={}){const s=yt.currentUser;if(!s)throw new Error("Not authenticated");const c=await s.getIdToken(),P=await fetch(Et,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:JSON.stringify({action:l,...x})}),f=await P.json().catch(()=>null);if(!P.ok||!(f!=null&&f.success))throw new Error((f==null?void 0:f.error)||"Request failed");return f}function qt(l,x=300){const[s,c]=n.useState(l);return n.useEffect(()=>{const P=window.setTimeout(()=>c(l),x);return()=>window.clearTimeout(P)},[l,x]),s}function B(l,x="Not set"){if(l==null||l==="")return x;const s=Number.parseFloat(l);return Number.isFinite(s)?`$${s.toFixed(2)}`:x}function Oe(l){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l)}const zt="staged-invite:";function Rt(l){return{id:`${zt}${l}`,email:l,isStagedInvite:!0}}function Fe(l){return(l==null?void 0:l.isStagedInvite)===!0}function L(l,x="Patient"){return[l==null?void 0:l.firstName,l==null?void 0:l.lastName].filter(Boolean).join(" ")||(l==null?void 0:l.email)||(l==null?void 0:l.id)||x}function Ot(l={}){return Array.isArray(l==null?void 0:l.includedProducts)?l.includedProducts:[]}function Ft(l={}){return l.displayName||l.name||l.productName||l.clientProductId||l.productId||"Included product"}function At(l={}){return l.displayThumbnailUrl||l.displayImageUrl||l.imageUrl||l.thumbnailUrl||""}function es({open:l,onClose:x,product:s,clientId:c,variant:P="product",initialPatients:f=Mt,lockPatientSelection:j=!1,initialCheckoutFlow:xe=null,onSent:O=null}){const{branding:H}=Ze(),G=(H==null?void 0:H.accentColor)||et,r=Re[P]?P:"product",{singular:u,plural:Ae}=jt(),m=u.toLowerCase(),y=Ae.toLowerCase(),h=n.useMemo(()=>{const t=Re[r],a={product:`Send Product to ${u}`,package:`Send Package to ${u}`,lab:`Send Lab to ${u}`,visit:`Send Visit to ${u}`},d={product:`Choose what the ${m} should do first, then send the offer to one or more ${y}.`,package:`Choose what the ${m} should do first, then send the package offer to one or more ${y}.`,lab:`Send a lab request to one or more ${y}. They will receive a checkout link to pay.`,visit:`Send a visit checkout link to one or more ${y}.`};return{...t,title:a[r]||t.title,description:d[r]||t.description}},[y,u,m,r]),ue=r!=="lab"&&r!=="visit",ge=r==="lab",Q=ue||ge,fe=r==="product"||r==="package",Ue=n.useMemo(()=>tt({sendToPatientDefaultFlow:s==null?void 0:s.sendToPatientDefaultFlow}),[s==null?void 0:s.sendToPatientDefaultFlow]),K=r==="visit"?St(s==null?void 0:s.visitMode)?q:z:[z,I,q].includes(xe)?xe:Ue.sendToPatientDefaultFlow===I?I:z,[he,W]=n.useState(""),[be,X]=n.useState([]),[F,J]=n.useState(!1),[Y,Z]=n.useState(!1),[pe,ee]=n.useState(!1),[g,A]=n.useState([]),[N,ye]=n.useState(K),{subscriptionOffer:k}=Pt({product:s,clientId:c,enabled:l&&r==="product"}),T=n.useMemo(()=>Ct(k),[k]),[Ne,ve]=n.useState(T.defaultMode);n.useEffect(()=>{ve(T.defaultMode)},[T.defaultMode,k==null?void 0:k.id]);const te=r==="product"&&k?Ne===ce.SUBSCRIBE?"subscription":"one_time":void 0,[je,E]=n.useState("action"),[ke,se]=n.useState("purchase_only"),[ae,le]=n.useState(!1),[we,re]=n.useState(!1),[Se,Pe]=n.useState([]),_=n.useRef(crypto.randomUUID()),M=qt(he,300),U=n.useRef(0),D=n.useRef(1);n.useEffect(()=>{l&&(W(""),X([]),J(!1),Z(!1),ee(!1),D.current=1,A(Array.isArray(f)?f.filter(t=>t==null?void 0:t.id):[]),ye(K),E(Q?"action":"patients"),se("purchase_only"),le(!1),re(!1),Pe([]),_.current=crypto.randomUUID())},[f,l,K,Q]);const V=n.useCallback(async({page:t,append:a})=>{if(!l||!c||j)return;const d=++U.current;a?Z(!0):J(!0);try{const i=await st({entity:"patients",query:M.trim()||"",tenantFilters:[c],tenantField:"clientId",perPage:_t,page:t,sortField:"sortDisplayName",sortDirection:"asc"});if(U.current!==d)return;const o=Array.isArray(i==null?void 0:i.patients)?i.patients:[];D.current=t,ee((i==null?void 0:i.hasMore)===!0),X(b=>{if(!a)return o;const qe=new Set(b.map(C=>C.id)),Ye=o.filter(C=>!(C!=null&&C.id)||qe.has(C.id)?!1:(qe.add(C.id),!0));return[...b,...Ye]})}catch{if(U.current!==d)return;a||(X([]),ee(!1))}finally{U.current===d&&(a?Z(!1):J(!1))}},[c,M,j,l]);n.useEffect(()=>{!l||!c||j||(D.current=1,V({page:1,append:!1}))},[l,M,c,V,j]);
1const w=(s==null?void 0:s.clientProductId)||(s==null?void 0:s.catalogEntryId)||(s==null?void 0:s.id)||null,De=(s==null?void 0:s.displayName)||(s==null?void 0:s.displayTitle)||(s==null?void 0:s.name)||(r==="lab"?"Lab":r==="package"?"Package":r==="visit"?"Visit":"Product"),Ce=(s==null?void 0:s.displayDescription)||(s==null?void 0:s.displaySummary)||(s==null?void 0:s.description)||"",Ie=At(s||{}),$e=Ot(s),Ve=r==="lab"?(s==null?void 0:s.customerPrice)??(s==null?void 0:s.defaultCustomerPrice)??null:s==null?void 0:s.customerPrice,Be=r==="visit"?"Send visit checkout":N===I?"Get approved first, then pay":N===q?"Complete intake first, then pay":r==="lab"?"Send lab request":`Pay for ${h.itemLabel} first`,He=n.useMemo(()=>new Set(g.map(t=>t.id)),[g]),ie=n.useMemo(()=>[...be].sort((t,a)=>L(t,u).localeCompare(L(a,u),void 0,{sensitivity:"base",numeric:!0})),[u,be]),Le=g.length===0||ae||!w,Te=n.useCallback(async t=>{let a=t;if(Fe(t)){if(r==="product"||r==="visit"){const o=await me("createPatientProductOfferByEmail",{requestId:_.current,clientId:c,email:t.email,clientProductId:w,checkoutFlow:N,purchaseMode:te});return{patient:t,result:o}}const i=await kt({email:t.email,clientId:c});a={...t,id:i.userId}}if(r==="lab"){const i=await wt("createProviderLabRequest",{clientId:c,patientId:a.id,clientProductId:w,productId:(s==null?void 0:s.productId)||null,providerNetworkId:(s==null?void 0:s.providerNetworkId)||null,requestFulfillmentMode:ke});return{patient:a,result:i}}if(r==="package"){const i=await me("createPatientPackageOffer",{requestId:_.current,clientId:c,patientId:a.id,clientProductId:w,checkoutFlow:N});return{patient:a,result:i}}const d=await me("createPatientProductOffer",{requestId:_.current,clientId:c,patientId:a.id,clientProductId:w,checkoutFlow:N,purchaseMode:te});return{patient:a,result:d}},[N,c,w,ke,r,te,s==null?void 0:s.productId,s==null?void 0:s.providerNetworkId]),Ge=n.useCallback(async()=>{if(!(g.length===0||!w)){le(!0);try{const t=await Promise.allSettled(g.map(i=>Te(i))),a=t.filter(i=>i.status==="fulfilled"),d=t.filter(i=>i.status==="rejected");if(Pe(a.map(({value:i})=>i)),a.length>0&&d.length===0&&re(!0),d.length>0&&A(t.flatMap((i,o)=>i.status==="rejected"?[g[o]]:[])),a.length>0&&(O==null||O(a.map(({value:i})=>i))),d.length>0){const i=r==="lab"?"request":"offer";p.error(`${d.length} ${i}${d.length===1?"":"s"} failed to send.`)}if(a.length===1&&d.length===0){const{patient:i,result:o}=a[0].value,b=i.firstName||i.email;r==="lab"?p.success(`Lab request sent to ${b}`):o!=null&&o.alreadyExists?p.info(`This ${m} already has an active offer for this product.`):o!=null&&o.emailQueued?p.success(`${r==="package"?"Package":r==="visit"?"Visit":"Product"} offer created for ${b}. Email queued.`):(o==null?void 0:o.emailSkippedReason)==="patient_has_no_email"?p.success(`${r==="package"?"Package":r==="visit"?"Visit":"Product"} offer created for ${b}. No email on file; they will see it on the dashboard.`):o!=null&&o.emailError?p.warning(`Offer created for ${b}, but the email could not be queued. Check the patient email and resend.`):p.success(`${r==="package"?"Package":r==="visit"?"Visit":"Product"} offer created for ${b}. Email delivery is unconfirmed.`)}else if(a.length>0){const i=a.filter(({value:o})=>{var b;return(b=o.result)==null?void 0:b.emailQueued}).length;r==="lab"?p.success(`${a.length} lab request${a.length===1?"":"s"} sent.`):i>0?p.success(`${a.length} offer${a.length===1?"":"s"} sent. ${i} email${i===1?"":"s"} queued.`):p.success(`${a.length} offer${a.length===1?"":"s"} sent.`)}}catch(t){at(t,{area:"products",surface:"Send product to patient",operation:"Send product to patient failed"}),p.error(t.message||`Unable to send ${r==="lab"?"lab request":"offer"}. Please try again.`)}finally{le(!1)}}},[g,w,m,r,O,Te]),Ee=n.useCallback(t=>{A(a=>a.some(i=>i.id===t.id)?a.filter(i=>i.id!==t.id):[...a,t])},[]),S=M.trim().toLowerCase(),ne=Oe(S),Qe=ne&&ie.some(t=>(t.email||"").toLowerCase()===S),Ke=ne&&g.some(t=>(t.email||"").toLowerCase()===S),_e=!!c&&ne&&!Qe&&!Ke&&!F,We=n.useCallback(()=>{!c||!Oe(S)||(A(t=>t.some(a=>(a.email||"").toLowerCase()===S)?t:[...t,Rt(S)]),W(""))},[c,S]),oe=n.useCallback(t=>{ye(t),E("patients")},[]);
1function Xe(){if(r!=="product"||!k)return null;const t=It(k,{oneTimePrice:s==null?void 0:s.customerPrice});if(!t)return null;const a=`${t.priceLabel} ${t.cadenceLabel}`;if(!T.requiresChoice)return e.jsx("p",{className:"text-sm text-content-tertiary max-lg:text-2xs","data-testid":v("text","send-product","billing-fixed"),children:T.showSubscription?`Offered as a subscription â ${a}.`:`Offered one-time â ${t.oneTimeLabel}.`});const d=[{mode:ce.SUBSCRIBE,title:`Subscribe â ${a}`,detail:t.renewalNote},{mode:ce.ONE_TIME,title:"One-time",detail:t.oneTimeLabel}];return e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",role:"radiogroup","aria-label":"How the patient is billed","data-testid":v("options","send-product","billing-mode"),children:d.map(i=>{const o=Ne===i.mode;return e.jsxs("button",{type:"button",role:"radio","aria-checked":o,onClick:()=>ve(i.mode),className:["min-w-0 rounded-xl border-2 p-3 text-left transition-colors max-lg:p-2.5",o?"bg-surface-raised":"border-subtle hover:border-slate-300 dark:hover:border-slate-600"].join(" "),style:o?{borderColor:G}:void 0,children:[e.jsx("p",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:i.title}),e.jsx("p",{className:"mt-0.5 text-sm text-content-tertiary max-lg:text-2xs max-lg:leading-snug",children:i.detail})]},i.mode)})})}const Me=n.useCallback(()=>{F||Y||!pe||V({page:D.current+1,append:!0})},[V,pe,Y,F]),Je=n.useCallback(t=>{const a=t.currentTarget;a.scrollHeight-a.clientHeight-a.scrollTop<=96&&Me()},[Me]);return l?e.jsx(lt,{open:l,onOpenChange:t=>{t||x()},contentTestId:v("dialog",h.testScope,`send-${r}-to-patient`),contentClassName:"w-full max-w-3xl",bodyClassName:"min-w-0 overflow-x-hidden p-0",title:h.title,description:h.description,titleClassName:"font-display text-xl font-semibold text-content-primary",footer:we?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"outline",className:"h-9 rounded-full px-4 max-lg:h-8 max-lg:px-3 max-lg:text-xs",onClick:x,disabled:ae,children:"Cancel"}),e.jsx(R,{type:"submit",form:"send-product-to-patient-modal-form",className:"h-9 rounded-full px-4 text-white max-lg:h-8 max-lg:px-3 max-lg:text-xs",style:{backgroundColor:G},disabled:Le,"data-testid":v("button",h.testScope,`send-${r}-offer`),children:ae?e.jsxs(e.Fragment,{children:[e.jsx(bt,{size:"md",className:"mr-2"}),"Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"mr-2 size-4"}),h.sendLabel,g.length>1?`s (${g.length})`:""]})})]}),footerClassName:"bg-slate-100 dark:bg-slate-900",children:e.jsx("form",{id:"send-product-to-patient-modal-form",className:$t,onSubmit:Lt(()=>void Ge(),{disabled:Le}),children:e.jsx(rt,{className:"min-w-0 overflow-hidden bg-surface-raised p-0",children:we?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 max-lg:gap-2 max-lg:py-4",children:[e.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-green-100 max-lg:size-9 dark:bg-green-900/30",children:e.jsx(ze,{className:"size-6 text-green-600 max-lg:size-4 dark:text-green-400","aria-hidden":!0})}),e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("p",{className:"font-semibold text-content-primary max-lg:text-sm",children:r==="lab"?"Request submitted":"Offer created"}),e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:text-xs max-lg:leading-snug",children:[Se.filter(({result:t})=>t==null?void 0:t.emailQueued).length," email(s) queued. Queued emails are awaiting delivery. Offers remain available on the patient dashboard."]})]}),Se.map(({patient:t,result:a})=>e.jsxs("p",{className:"text-sm text-muted-foreground",children:[L(t),": ",a!=null&&a.emailQueued?"Email queued":(a==null?void 0:a.emailSkippedReason)==="patient_has_no_email"?"No email on file; offer available on dashboard":a!=null&&a.emailError?"Email could not be queued; offer available on dashboard":"Offer available; email delivery unconfirmed"]},t.id||t.email)),r!=="lab"?e.jsx(R,{type:"button",variant:"outline",onClick:()=>{_.current=crypto.randomUUID(),re(!1)},children:"Resend offer"}):null,e.jsx(R,{type:"button",variant:"outline",onClick:x,className:"mt-1 rounded-full max-lg:h-8 max-lg:px-3 max-lg:text-xs",children:"Close"})]}):e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"px-5 py-5 max-lg:px-3 max-lg:py-2.5 sm:px-6",children:e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 max-lg:flex-row max-lg:gap-2.5 sm:flex-row",children:[e.jsx("div",{className:"h-28 w-full shrink-0 overflow-hidden rounded-xl border border-subtle bg-surface-sunken max-lg:size-20 sm:w-32",children:Ie?e.jsx("img",{src:Ie,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:r==="lab"?e.jsx(Tt,{className:"size-7 text-slate-300 max-lg:size-5 dark:text-slate-600","aria-hidden":!0}):r==="package"?e.jsx(it,{className:"size-7 text-slate-300 max-lg:size-5 dark:text-slate-600","aria-hidden":!0}):e.jsx(nt,{className:"size-7 text-slate-300 max-lg:size-5 dark:text-slate-600","aria-hidden":!0})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-base font-semibold text-content-primary max-lg:text-sm",children:De}),Ce?e.jsx("p",{className:"mt-1 line-clamp-3 text-sm text-content-secondary max-lg:text-2xs max-lg:leading-snug",children:Ce}):e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:text-2xs",children:["No ",h.itemLabel," description provided."]}),e.jsxs("div",{className:"mt-4 grid gap-3 max-lg:mt-2.5 max-lg:grid-cols-3 max-lg:gap-2 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase text-content-tertiary max-lg:text-3xs",children:r==="lab"?`${u} price`:r==="package"?"Package":r==="visit"?"Visit":"Product"}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:B(Ve)})]}),fe?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase text-content-tertiary max-lg:text-3xs",children:"Shipping"}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:B(s==null?void 0:s.shippingPrice,"Client default")})]}):null,fe?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase text-content-tertiary max-lg:text-3xs",children:"Assessment"}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:B(s==null?void 0:s.syncVisitPrice,"$0.00")})]}):null]}),r==="package"?e.jsxs("div",{className:"mt-4 rounded-xl border border-subtle bg-slate-50/70 p-3 max-lg:mt-2.5 max-lg:p-2 dark:bg-slate-800/50",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 max-lg:mb-1.5 max-lg:gap-1.5",children:[e.jsx(ot,{className:"size-4 text-content-tertiary max-lg:size-3.5","aria-hidden":!0}),e.jsx("p",{className:"text-xs font-semibold uppercase text-content-tertiary max-lg:text-3xs",children:"Included products"})]}),$e.length>0?e.jsx("div",{className:"space-y-1.5",children:$e.map((t,a)=>e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-raised px-3 py-2 max-lg:gap-2 max-lg:px-2 max-lg:py-1.5",children:[e.jsx("span",{className:"truncate text-sm font-medium text-slate-800 max-lg:text-xs dar
1k:text-slate-100",children:Ft(t)}),t.customerPrice!==null&&t.customerPrice!==void 0?e.jsx("span",{className:"shrink-0 text-xs font-semibold text-content-tertiary max-lg:text-3xs",children:B(t.customerPrice,"")}):null]},`${t.clientProductId||t.productId||a}`))}):e.jsx("p",{className:"text-sm text-content-tertiary max-lg:text-xs",children:"No included products listed."})]}):null]})]})}),e.jsx("section",{className:"border-t border-subtle px-5 py-5 max-lg:px-3 max-lg:py-2.5 sm:px-6",children:ge&&je==="action"?e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:["How should the ",m," satisfy this lab?"]}),e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs max-lg:leading-snug",children:["Sending to several ",y," at once always uses each ",m,"'s default linked consultation."]})]}),e.jsx(vt,{accentColor:G,columns:2,"data-testid":v("options","send-product","lab-request-mode"),options:[{id:"purchase_only",icon:dt,title:"Request purchase",description:`The ${m} pays for this lab to continue.`,testId:v("button","send-product","lab-request-mode-purchase"),onSelect:()=>{se("purchase_only"),E("patients")}},{id:"purchase_or_upload",icon:ct,title:"Request lab",description:`The ${m} pays, or uploads a recent result for you to review.`,testId:v("button","send-product","lab-request-mode-upload"),onSelect:()=>{se("purchase_or_upload"),E("patients")}}]})]}):ue&&je==="action"?e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:["What should the ",m," do first?"]}),e.jsx("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs max-lg:leading-snug",children:"Pick the payment and approval order for this offer."})]}),e.jsxs("div",{className:"grid gap-3 max-lg:gap-2 sm:grid-cols-3",children:[e.jsxs("button",{type:"button",onClick:()=>oe(z),className:["min-h-36 rounded-xl border p-4 text-left transition-colors max-lg:min-h-0 max-lg:p-2.5",N===z?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-subtle bg-surface-raised hover:border-blue-300 hover:bg-slate-50 dark:hover:border-blue-600 dark:hover:bg-slate-800/70"].join(" "),"aria-label":`Pay for ${h.itemLabel} first`,children:[e.jsx(de,{variant:"outline",className:"rounded-full border-blue-200 bg-blue-50 text-blue-700 max-lg:px-1.5 dark:border-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:"Product first checkout"}),e.jsxs("p",{className:"mt-3 text-sm font-semibold text-content-primary max-lg:mt-2 max-lg:text-xs",children:["Pay for the ",h.itemLabel," first"]}),e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs max-lg:leading-snug",children:["After account setup, the ",m," pays, then completes required intake and assessment."]})]}),e.jsxs("button",{type:"button",onClick:()=>oe(q),className:["min-h-36 rounded-xl border p-4 text-left transition-colors max-lg:min-h-0 max-lg:p-2.5",N===q?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-subtle bg-surface-raised hover:border-blue-300 hover:bg-slate-50 dark:hover:border-blue-600 dark:hover:bg-slate-800/70"].join(" "),"aria-label":"Complete intake first",children:[e.jsx(de,{variant:"outline",className:"rounded-full border-violet-200 bg-violet-50 text-violet-700 max-lg:px-1.5 dark:border-violet-800 dark:bg-violet-900/30 dark:text-violet-300",children:"Intake first"}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-content-primary max-lg:mt-2 max-lg:text-xs",children:"Complete intake before payment"}),e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs max-lg:leading-snug",children:["The ",m," completes the product's normal required intake, then pays for the product."]})]}),e.jsxs("button",{type:"button",onClick:()=>oe(I),className:["min-h-36 rounded-xl border p-4 text-left transition-colors max-lg:min-h-0 max-lg:p-2.5",N===I?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-subtle bg-surface-raised hover:border-blue-300 hover:bg-slate-50 dark:hover:border-blue-600 dar
1k:hover:bg-slate-800/70"].join(" "),"aria-label":"Get approved for product first",children:[e.jsx(de,{variant:"outline",className:"rounded-full border-emerald-200 bg-emerald-50 text-emerald-700 max-lg:px-1.5 dark:border-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300",children:"Assessment first"}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-content-primary max-lg:mt-2 max-lg:text-xs",children:"Get approved before product payment"}),e.jsxs("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs max-lg:leading-snug",children:["The ",m," completes intake and assessment first, then pays for the product if approved."]})]})]})]}):e.jsxs("div",{className:"min-w-0 space-y-4 max-lg:space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 max-lg:gap-2",children:[e.jsxs("div",{className:"max-lg:min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:["Select ",y]}),e.jsx("p",{className:"mt-1 text-sm text-content-tertiary max-lg:mt-0.5 max-lg:text-2xs",children:Be})]}),Q?e.jsxs(R,{type:"button",variant:"ghost",className:"shrink-0 rounded-full max-lg:h-7 max-lg:px-2.5 max-lg:text-2xs",onClick:()=>E("action"),children:[e.jsx(mt,{className:"mr-2 size-4 max-lg:mr-1 max-lg:size-3"}),"Change"]}):null]}),Xe(),e.jsxs("div",{className:"min-w-0 space-y-3 max-lg:space-y-2",children:[j?null:e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(xt,{className:"pointer-events-none absolute left-4 top-1/2 size-5 -translate-y-1/2 text-slate-400 max-lg:left-3 max-lg:size-4","aria-hidden":!0}),e.jsx(ut,{id:"send-product-patient-search",type:"search",placeholder:`Search by ${m} name or email...`,"aria-label":`Search ${y}`,value:he,onChange:t=>W(t.target.value),className:"h-12 w-full min-w-0 pl-11 text-base max-lg:h-10 max-lg:pl-9","data-testid":v("input",h.testScope,`send-${r}-patient-search`)})]}),g.length>0?e.jsx("div",{className:"flex flex-wrap gap-2 max-lg:gap-1.5",children:g.map(t=>e.jsxs("button",{type:"button",onClick:()=>!j&&Ee(t),className:"inline-flex max-w-full items-center gap-2 rounded-full border border-blue-200 bg-blue-50 px-3 py-1.5 text-sm font-medium text-blue-700 max-lg:gap-1.5 max-lg:px-2 max-lg:py-1 max-lg:text-2xs dark:border-blue-800 dark:bg-blue-900/30 dark:text-blue-300","aria-label":`Remove ${L(t,u)}`,children:[e.jsx("span",{className:"truncate",children:L(t,u)}),Fe(t)?e.jsx("span",{className:"shrink-0 rounded-full bg-blue-100 px-1.5 text-3xs font-semibold uppercase text-blue-700 dark:bg-blue-800/60 dark:text-blue-200",children:"New"}):null,j?null:e.jsx(gt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},t.id))}):null,j?null:e.jsx("div",{className:"max-h-[min(52vh,28rem)] min-w-0 overflow-y-auto overflow-x-hidden rounded-xl border border-subtle max-lg:max-h-[min(44vh,22rem)]",onScroll:Je,children:F?e.jsx("div",{className:"space-y-2 p-3 max-lg:space-y-1.5 max-lg:p-2",children:[1,2,3].map(t=>e.jsxs("div",{className:"flex items-center gap-3 px-1 py-1 max-lg:gap-2",children:[e.jsx($,{className:"size-9 shrink-0 rounded-full max-lg:size-7"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx($,{className:"h-3 w-1/2"}),e.jsx($,{className:"h-3 w-1/3"})]})]},t))}):ie.length===0&&!_e?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center max-lg:gap-1.5 max-lg:px-3 max-lg:py-5",children:[e.jsx(ft,{className:"size-6 text-slate-300 max-lg:size-5 dark:text-slate-600","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-content-tertiary max-lg:text-xs",children:M.trim()?`No ${y} found`:"Start typing to search"})]}):e.jsxs("div",{className:"divide-y divide-slate-100 dark:divide-slate-800",children:[_e?e.jsxs("button",{type:"button",onClick:We,className:"flex w-full min-w-0 items-center gap-3 px-3 py-3 text-left transition-colors hover:bg-slate-50 max-lg:gap-2 max-lg:px-2 max-lg:py-2 dark:hover:bg-slate-800/50","data-testid":v("button",h.testScope,`send-${r}-invite-patient`),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-blue-50 text-blue-600 max-lg:size-7 dark:bg-blue-900/30 dark:text-blue-300",children:e.jsx(ht,{className:"size-4 max-lg:size-3.5","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"truncate text-sm font-medium text-content-primary max-lg:text-xs",children:["Add ",S]}),e.jsxs("p",{className:"truncate text-xs text-content-tertiary max-lg:text-3xs",children:["New ",m," â inv
1ited when you send the ",r==="lab"?"request":"offer"]})]})]}):null,ie.map(t=>{var d,i;const a=He.has(t.id);return e.jsxs("button",{type:"button",onClick:()=>Ee(t),className:["flex w-full min-w-0 items-center gap-3 px-3 py-3 text-left transition-colors max-lg:gap-2 max-lg:px-2 max-lg:py-2",a?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-slate-50 dark:hover:bg-slate-800/50"].join(" "),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-slate-100 text-xs font-semibold text-content-secondary max-lg:size-7 max-lg:text-3xs dark:bg-slate-700",children:(((d=t.firstName)==null?void 0:d[0])||((i=t.email)==null?void 0:i[0])||"?").toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-content-primary max-lg:text-xs",children:L(t,u)}),t.email&&e.jsx("p",{className:"truncate text-xs text-content-tertiary max-lg:text-3xs",children:t.email})]}),a?e.jsx(ze,{className:"size-4 shrink-0 text-blue-600 max-lg:size-3.5 dark:text-blue-400","aria-hidden":!0}):null]},t.id)}),Y?e.jsx("div",{className:"space-y-2 border-t border-slate-100 p-3 max-lg:space-y-1.5 max-lg:p-2 dark:border-slate-800",children:[1,2].map(t=>e.jsxs("div",{className:"flex items-center gap-3 px-1 py-1 max-lg:gap-2",children:[e.jsx($,{className:"size-9 shrink-0 rounded-full max-lg:size-7"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx($,{className:"h-3 w-1/2"}),e.jsx($,{className:"h-3 w-1/3"})]})]},t))}):null]})})]})]})})]})})})}):null}export{es as default};
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.