PageSourceSearch

https://care.soberpedia.ai/assets/ProductDetailsDialog-qRBsFrxt.js

js soberpedia.ai collected 2026-10-05 15:11:19 UTC 119,152 bytes, 6 lines download raw bytes

1import{j as e,r as c,f as Zs,L as Jr}from"./react-vendor-CU6Sz31W.js";import{i as Xr,a as Zr}from"./ProductsClientView-BEf4Ev-A.js";import{a$ as ei,mG as ti,bN as et,bO as tt,bP as st,aY as qe,bQ as at,e as q,j as H,az as Rt,L as dr,eE as si,eF as ai,eG as ri,eI as ii,E as Et,aA as ea,I as ne,i as O,B as ni,gG as li,b as oi,K as ci,O as di,k5 as ui,go as mi,J as ur,ex as mt,cc as pi,ae as mr,nZ as xi,ag as pr,cd as hi,aQ as fi,n as gi,af as bi,gB as yi,g3 as vi,f7 as ki,g9 as At,cQ as _s,sd as Us,se as Xt,ma as ji,as as $e,t as L,fF as wi,e0 as zs,ax as Ni,c6 as _a,et as Pi,eu as Ci,ev as Xe,gi as Ze,nK as Si,dd as Li,hQ as Ua,U as It,fJ as za,c7 as Vs,c8 as $s,c9 as Bs,ca as Ws,cb as Te,h0 as Ii,fL as Va,ci as Zt,aL as Ri,S as ta,ad as Ai,au as sa,nL as Ei,dc as Ti,g as $a,z as qi,gs as Fi}from"./index-DEXJEDAi.js";import{C as Oi}from"./ClientFormularyMedicationsTable-DGS5GEg6.js";import{u as Di}from"./useProviderNetworkFormularyCustomNames-DLzu7zBJ.js";import{a as Mi,e as xr}from"./DataTableCard-BluwWKn_.js";import{f as _i}from"./labRecencyWindow-BLArGdSC.js";import{i as Ba,B as Ui,Y as zi,k as Vi,S as $i,t as Bi,a as Wi,O as Ki}from"./formularyMappings-C8mJfsp2.js";import{J as Hi,K as Yi,g as Qi}from"./formularyVariants-BV7CaEYS.js";import{j as Gi,m as Ji}from"./formularyRules-DurNzATt.js";import{a as Xi,S as Ks,n as Hs}from"./productSupplyUnit-CNM1yKaW.js";import{g as Zi}from"./ProductInlineEditPopovers-B7oRL8nE.js";import{F as en}from"./FormularyMappingManager-Cp-K-vjw.js";import{g as Wa,b as Ka,a as Ha,t as tn,L as sn,c as Ya,d as an}from"./productRefillReminder-B85vMVb4.js";import{C as rn}from"./CatalogItemFormsTab-DGZAm4cd.js";import{b as nn}from"./labDisplayUtils-D6xhR45u.js";import{L as ln}from"./lab-markers-popover-Dp7gAQYc.js";import{C as on}from"./CatalogStateExclusionsPanel-eJPBk-Pg.js";import{n as Qa}from"./catalogStateExclusions-C6BtORvT.js";import{Q as cn}from"./quill-editor-D-DS6c39.js";import{b as dn,f as un,n as mn}from"./clinicalRulesWindows-XIF-DYAK.js";import{C as pn,a as xn,b as hn,c as fn}from"./ClinicalRuleCards-DDP8Y6Vb.js";import{listLabQualificationReviews as gn,requestLabQualificationReview as bn}from"./labBiomarkerApi-Ck21Kuon.js";import{a as yn,b as vn,L as kn}from"./LabAdjudicationUnavailableNotice-Caxh_Djm.js";import{C as jn}from"./CheckoutShell-DPiImp5d.js";import{a as wn}from"./checkoutShellChrome-B_HUtum-.js";import{E as Ga}from"./EditorialCheckoutAccordion-BKtWmc-J.js";import{P as Nn,a as Pn}from"./PublicCheckoutContactStep-CBDZu5yA.js";import{C as Cn}from"./CheckoutPreviewViewport-D2aw1liL.js";import{P as Sn,c as Ln,C as ns,I as es,d as ts,S as Ys,e as Ja,i as hr,f as Qs,D as ls,g as In,h as Rn,j as An,n as Xa,k as En}from"./productCheckoutSummary-CjlX7xkp.js";import{A as Tn}from"./arrow-up-D6DFVL4j.js";import{A as qn}from"./arrow-down-BjUlbB4f.js";import{P as Fn}from"./pencil-CpqYHolO.js";import{M as On}from"./monitor-CzX6E2vl.js";import{P as Dn}from"./ProductSubscriptionRuleSection-SchGISa4.js";import{g as Mn,v as _n,d as Za}from"./productSubscriptionRule-Btb3VTHz.js";import{M as Un,o as zn}from"./modal-form-CqN5DZuv.js";import"./searchMatchPosition-D039Jv6R.js";import"./SubscriptionsManager-BDbX__WY.js";import"./calendar-RV2oTCrW.js";import"./addWeeks-1hrFjz19.js";import"./ExportCsvAction-BJr9eiP6.js";import"./modal-option-cards-Dksohkou.js";import"./patient-name-link-BAfQKbEs.js";import"./text-highlight-BFqqfcjs.js";import"./cells-Db2ZEFlu.js";import"./ellipsis-vertical-C-dQ6Kzj.js";import"./clientViewHelpers-DdlucuaE.js";import"./link-2-a8lhpkQ6.js";import"./useTableSort-KpNOL2n3.js";import"./useLocalStorageState-BlY8ICA4.js";import"./rawTableExport-DjSsUxyR.js";import"./firebase-w6DYUbFN.js";import"./ClientProductCouponsManager-B7-aMQgR.js";import"./usePatientTerminology-D5bkkKg2.js";import"./useOpenPatientProfile-CASNKG5E.js";import"./ban-DZ1NMSKK.js";import"./power-D6NB1cYy.js";import"./LabEnablementBlockedDialog-DsmO0bev.js";import"./useFormularyVisibility-DLbkVZJM.js";import"./pharmacyCoverage-Di9Ay0IK.js";import"./providerOperations-ELdKx_YD.js";import"./networkLicensurePolicy-Ct3PZM4V.js";import"./labsData-CkdRlz2Q.js";import"./manageLabApi-BUlVz8vT.js";import"./ProductStorefrontCard-Bfcwwd2M.js";import"./labIntegrationDefinitions-DsxE_lJg.js";import"./providerAssignments-C7MWOvAk.js";import"./integrationScopeAccess-DxVEy3Qu.js";import"./sliders-horizontal-Bt65nPrH.js";import"./file-spreadsheet-B-mAJD3-.js";import"./payment-icons-Daq1K3F1.js";import"./catalogCategoryVisibility-PKrVnYt-.js";import"./ellipsis-tooltip-CfKm8VFV.js";import"./useFormularyTypesenseSearch-b2YherGX.js";import"./collectExportPages-B1mgoF_8.js";import"./editor-D8UbQKN1.js";import"./use-unsaved-changes-B6nL5Xdd.js";import"./useFormularySendTiming-PW-jkqj4.js";import"./formularySendSchedules-hEX-RQcj.js";import"./formularySearchSeed-DFztyQr8.js";import"./index-BSuGcRaZ.js";import"./table-CxPdvV_9.js";import"./pill-filter-CtZSNPVl.js";import"./date-picker-filter-Qp1kqu9t.js";import"./clear-filters-button-DmPemFGr.js";import"./CatalogSelectionList-D9FsL1Nv.js";import"./CatalogItemAdminFormPreviewModal-BQ14I7dT.js";import"./IntakeVersionEditorDialog-AuX4y5Es.js";import"./FormBuilder-yfdeRhed.js";import"./date-of-birth-picker-BQ2yrZNI.js";import"./useEditorTranscription-CN2PcNng.js";import"./AssistantMarkdownContent-OjQ8GujO.js";import"./useOfflineFormDraftSync-D_7gScL0.js";import"./offlineFormDrafts-CAcyqTIL.js";import"./FormPreviewDialog-DrDrSHEH.js";import"./square-check-big-BIK4lrHD.js";import"./PatientFieldDefinitionDialog-BZBSN9SQ.js";import"./usePatientFieldDefinitions-DS6fhdRU.js";import"./patientFieldDefinitionCaches-PDqtgCkY.js";import"./redo-2-DoWP9VFC.js";import"./arrow-right-left-B4vnGqzD.js";import"./core.esm-DPjjHB-Z.js";import"./sortable.esm-Cj9Co3ow.js";import"./type-CJ1z0FOW.js";import"./circle-dot-B6AVn653.js";import"./user-round-c4EWOTq5.js";import"./keyboard-DLwPN9xF.js";import"./code-BEcI87AG.js";import"./git-branch-BaXsltg0.js";import"./ellipsis-C0FvDuxB.js";import"./hash-C7GcXMrW.js";import"./intakeVersionsApi-DctKdHHP.js";import"./collapsible-JRJGT2Lx.js";import"./audio-lines-GJL3_Ka2.js";import"./square-D7DkS8S2.js";import"./strikethrough-CiKozLGy.js";import"./underline-B_XtWKJP.js";import"./list-ordered-GNrnoOhB.js";import"./checkoutDisplay-6C7UrTTD.js";import"./package-check-BNvVCLtI.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Vn=[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]],$n=ei("LayoutPanelLeft",Vn),Bn=[{value:"platform_default",label:"2 weeks before supply end"},{value:"custom",label:"Custom"},{value:"disabled",label:"No reminder"}],Wn=[{value:"days",singular:"day",plural:"days"},{value:"hours",singular:"hour",plural:"hours"}],er=[{value:"before",label:"before"},{value:"after",label:"after"}],Kn=[{value:"supplyEnd",label:"last day of supply"},{value:"deliveredAt",label:"delivery date"}],Hn=q("inline font-semibold text-content-primary underline decoration-slate-400 underline-offset-4","transition-colors hover:decoration-slate-700 hover:text-slate-950","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-1","disabled:cursor-not-allowed disabled:opacity-50","dark:text-slate-100 dar
6k:decoration-slate-500 dark:hover:decoration-slate-300 dark:hover:text-white");function Gs({value:s,options:r,onChange:o,disabled:t=!1,testId:p,ariaLabel:b}){const w=r.find(N=>N.value===s)||r[0];return e.jsxs(si,{children:[e.jsx(ai,{asChild:!0,children:e.jsx("button",{type:"button",disabled:t,"aria-label":b,"data-testid":p,className:Hn,children:w==null?void 0:w.label})}),e.jsx(ri,{align:"start",children:r.map(N=>e.jsx(ii,{onSelect:()=>o(N.value),children:N.label},N.value))})]})}function Yn({form:s,onChange:r,accentColor:o,disabled:t=!1}){function p(d){r({...s,...d})}const b=Number(s.amount||0),w=Wn.map(d=>({value:d.value,label:b===1?d.singular:d.plural})),N=s.anchor==="supplyEnd"?er:er.filter(d=>d.value==="after");return e.jsxs("div",{className:"space-y-3 rounded-xl bg-surface-sunken p-3 max-lg:space-y-2 max-lg:p-2","data-testid":H("section","products","refill-reminder"),children:[e.jsxs("div",{className:"flex items-start gap-2 max-lg:gap-1.5",children:[e.jsx(ti,{className:"mt-0.5 size-4 text-content-tertiary max-lg:size-3.5"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:"Refill reminders"}),e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300","aria-label":"Refill reminders help",children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:"Choose when patients get a refill reminder for this product. Pick Custom to write your own timing—click any underlined word to change it. You can still set different reminders on individual prescriptions later."})]})})]})})]}),e.jsx("div",{children:e.jsx("div",{className:"grid grid-cols-3 overflow-hidden rounded-lg border border-subtle bg-surface-raised",role:"radiogroup","aria-label":"Refill reminder cadence",children:Bn.map((d,u)=>{const m=s.mode===d.value;return e.jsxs("button",{type:"button",role:"radio","aria-checked":m,disabled:t,onClick:()=>p({mode:d.value}),"data-testid":H("button","products","refill-reminder-mode",d.value),className:q("flex h-11 min-w-0 items-center gap-2 px-3 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-slate-300 disabled:cursor-not-allowed disabled:opacity-50 max-lg:h-10 max-lg:gap-1.5 max-lg:px-2 max-lg:text-2xs",u>0&&"border-l border-subtle",m?"bg-surface-sunken":"bg-surface-raised hover:bg-slate-50 dark:hover:bg-slate-800/50"),children:[e.jsx("span",{className:q("flex size-4 shrink-0 items-center justify-center rounded-full border max-lg:size-3.5",m?"border-slate-900 dark:border-slate-100":"border-default"),style:m&&o?{borderColor:o}:void 0,"aria-hidden":!0,children:m?e.jsx("span",{className:"size-2 rounded-full bg-slate-900 dark:bg-slate-100 max-lg:size-1.5",style:o?{backgroundColor:o}:void 0}):null}),e.jsx("span",{className:q("min-w-0 font-medium leading-snug",m?"text-content-primary":"text-slate-700 dark:text-slate-300"),children:d.label})]},d.value)})})}),s.mode==="custom"?e.jsxs("div",{className:"space-y-4 rounded-lg border border-subtle bg-surface-raised p-3 max-lg:space-y-2.5 max-lg:p-2",children:[e.jsxs("p",{className:"text-sm leading-relaxed text-content-secondary max-lg:text-xs",children:["Send a reminder"," ",e.jsx("input",{type:"number",min:"0",value:s.amount,disabled:t,onChange:d=>p({amount:Math.max(0,Number(d.target.value||0))}),"aria-label":"Reminder amount","data-testid":H("input","products","refill-reminder-amount"),className:q("mx-0.5 inline-block w-12 border-0 border-b border-slate-400 bg-transparent p-0 text-center text-sm font-semibold text-content-primary outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","focus:border-slate-700 disabled:cursor-not-allowed disabled:opacity-50","dark:border-slate-500 dark:text-slate-100 dar
6k:focus:border-slate-300","max-lg:w-10 max-lg:text-xs","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none")})," ",e.jsx(Gs,{value:s.unit,options:w,disabled:t,ariaLabel:"Reminder unit",testId:H("button","products","refill-reminder-unit"),onChange:d=>p({unit:d})})," ",s.anchor==="supplyEnd"?e.jsx(Gs,{value:s.direction,options:N,disabled:t,ariaLabel:"Reminder direction",testId:H("button","products","refill-reminder-direction"),onChange:d=>p({direction:d})}):e.jsx("span",{className:"font-semibold text-content-primary",children:"after"})," ",e.jsx(Gs,{value:s.anchor,options:Kn,disabled:t,ariaLabel:"Reminder timing anchor",testId:H("button","products","refill-reminder-anchor"),onChange:d=>p({anchor:d,direction:d==="supplyEnd"?s.direction:"after"})}),"."]}),e.jsx("div",{className:"flex flex-wrap gap-2 max-lg:gap-1.5",children:[{key:"email",label:"Email"},{key:"sms",label:"SMS"}].map(d=>{var m;const u=((m=s.channels)==null?void 0:m[d.key])===!0;return e.jsxs("button",{type:"button",disabled:t,"aria-pressed":u,onClick:()=>p({channels:{...s.channels,[d.key]:!u}}),"data-testid":H("button","products","refill-reminder-channel",d.key),className:q("inline-flex h-10 items-center gap-2 rounded-lg border px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 disabled:cursor-not-allowed disabled:opacity-50","max-lg:h-9 max-lg:gap-1.5 max-lg:px-2.5 max-lg:text-xs",u?"border-default bg-surface-sunken text-content-primary":"border-subtle bg-surface-raised text-slate-700 hover:border-slate-300 hover:bg-slate-50 dark:text-slate-300 dark:hover:border-slate-600"),style:u&&o?{borderColor:o}:void 0,children:[e.jsx(Rt,{checked:u,tabIndex:-1,"aria-hidden":!0,className:"pointer-events-none",style:u&&o?{borderColor:o}:void 0}),d.label]},d.key)})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(dr,{children:"Message template"}),e.jsx(cn,{value:s.messageHtml,onChange:d=>p({messageHtml:d}),placeholder:"Write the patient refill reminder",editorMinHeight:"160px",readOnly:t})]})]}):null]})}function Qn({windows:s=[],prices:r={},onPriceChange:o,defaultPrice:t="",subscriptionEnabled:p=!1,canEditPricing:b=!0,accentColor:w=null}){const[N,d]=c.useState(""),[u,m]=c.useState("all"),k=Array.isArray(s)?s:[],h=dn(k,{search:N,filter:u}),y=p===!0||!b,E=Number(t),j=String(t??"").trim()!==""&&Number.isFinite(E)?E.toFixed(2):"0.00",z=()=>{d(""),m("all")};return e.jsxs("div",{className:"space-y-4","data-testid":H("section","products","client-clinical-rules"),children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your provider network sets these rules. Set a refill price per rule, or leave it blank to use the Overview price."}),p?e.jsx("p",{className:"rounded-xl border border-status-info bg-status-info px-3 py-2 text-xs text-status-info",children:"Subscription is on, so rule prices don't apply. Membership billing covers payment, and refills still start from a patient request."}):b?null:e.jsx("p",{className:"rounded-xl border border-border bg-muted px-3 py-2 text-xs text-muted-foreground",children:"Rule prices are view-only for your role."}),k.length===0?e.jsx(Et,{reason:"empty",icon:null,title:"No rules yet",description:"Your provider network has not added clinical rules to this product. Later purchases use the Overview price."}):e.jsxs(e.Fragment,{children:[e.jsx(pn,{search:N,onSearchChange:d,filter:u,onFilterChange:m,accentColor:w}),e.jsx(xn,{shown:h.length,total:k.length}),h.length===0?e.jsx(Et,{reason:"filtered",icon:null,title:"No matching rules",description:"No rules match your search or requirement filter.",action:{label:"Clear filters",onClick:z}}):null,h.map(I=>{const P=`clinical-rule-price-${I.id}`;return e.jsx(hn,{rule:I,testId:H("card","products","client-clinical-rule"),children:e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 border-t border-border pt-3",children:[e.jsx(ea,{htmlFor:P,required:!1,optional:!0,children:"Refill price"}),e.jsxs("div",{className:"relative w-32 shrink-0",children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-content-tertiary",children:"$"}),e.jsx(ne,{id:P,inputMode:"decimal",placeholder:j,disabled:y,value:(r==null?void 0:r[I.id])??"",onChange:S=>o(I.id,S.target.value.replace(/[^0-9.]/g,"")),className:"h-9 pl-6 text-right tabular-nums","aria-label":`Refill price for ${un(I)}`})]})]})},I.id)})]}),e.jsx(fn,{showMatching:k.length>0,note:"First purchase uses the Overview price and requirements. Refills with no matching rule or previous approval use the default refill workflow."})]})}function Gn(s=[]){return s.flatMap(r=>r.requiresLabs!==!0?[]:Array.isArray(r.approvedLabProductIds)&&r.approvedLabProductIds.some(t=>typeof t=="string"&&t.trim())?[]:[{product:r,reason:"Select the required labs for this product."}])}function Jn({products:s,onProductEdit:r}){const o=new Set(Gn(s).map(({product:t})=>t));return e.jsxs("section",{"aria-label":"Included product lab requirements",className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Required labs"}),e.jsxs("p",{className:"text-xs leading-relaxed text-muted-foreground",children:[o.size>0?"Some included products have no required labs selected.":"Required lab selections are complete."," ","This does not block saving the package. Editing a product’s labs changes that product separately."]})]}),e.jsx("ul",{className:"divide-y divide-border",children:s.map(t=>{const p=t.displayName||t.name||"Untitled product",b=o.has(t);return e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"break-words text-sm font-medium text-foreground",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b?"No labs selected.":"Lab selection complete."})]}),r?e.jsx(O,{type:"button",variant:"outline",size:"sm",className:"shrink-0 rounded-full","aria-label":`Edit labs for ${p}`,onClick:()=>r(t),children:"Edit labs"}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask an administrator to edit this product’s labs if needed."})]},t.id||t.catalogEntryId||t.clientProductId)})})]})}const Xn={firstName:"Alex",lastName:"Morgan",email:"[email protected]",phone:"",dateOfBirth:"1990-01-15",sexAtBirth:"Female"},Zn=()=>{};function el(s){return s==="sharp"?"0rem":s==="medium"?"0.5rem":"1.5rem"}function tl({checkoutTheme:s,themeBranding:r,baseBranding:o,experience:t,summaryProps:p,cornerStyle:b,viewportWindow:w,device:N,interactive:d}){var $,Z;const u=N==="mobile",m=s==null?void 0:s.layoutPreset,k=ur(m),h=o||r||{},y=((r==null?void 0:r.appThemeMode)||h.appThemeMode)==="dark",E=li(h.backgroundColor),j=(r==null?void 0:r.accentColor)||oi,I=(($=ci({},s))==null?void 0:$.backgroundColor)||null||(y?"var(--client-dark-canvas)":(r==null?void 0:r.backgroundColor)||"var(--surface-muted)"),P=(r==null?void 0:r.name)||h.clientName||"",S=(r==null?void 0:r.logoUrl)||h.clientLogoUrl||"",fe=(r==null?void 0:r.website)||h.website||h.clientWebsite||"",V=!k&&(s==null?void 0:s.logoTreatment)!==di.HIDDEN&&!!S,Y=h.headerFont||(r==null?void 0:r.headerFont)||null;return e.jsx("main",{inert:!d,"data-client-theme":y?"dark":"light",className:q(y?"checkout-dark":"checkout-light","w-full",!k&&"p-0 lg:p-4",u?"min-h-0":"min-h-dvh"),style:{...y?{"--client-dark-canvas":E.canvas,"--client-dark-surface":E.surface,"--client-dark-surface-muted":E.surfaceMuted}:{},...mi(t),backgroundColor:k?"var(--surface-page)":I,"--checkout-accent":j,...Y?{"--font-display":`"${Y}", ui-serif, Georgia, serif`}:{}},children:e.jsx("div",{className:q("mx-auto w-full",k?"max-w-none":"max-w-7xl pb-3 pt-0 sm:pb-6 sm:pt-1"),children:e.jsx(jn,{...wn(m),viewportWindow:w,layoutPreset:(Z=t==null?void 0:t.storefront)==null?void 0:Z.layoutPreset,checkoutTheme:s,accentColor:j,backgroundColor:I,rightPanelColor:(r==null?void 0:r.rightPanelColor)||null,brandName:P,brandLogoUrl:S,brandWebsiteUrl:d?"":fe,logoWhiteBackgroun
6d:(r==null?void 0:r.logoWhiteBackground)===!0,forceDarkTheme:y,panelRadius:el(b),className:k?u?"min-h-0":"min-h-dvh":"bg-transparent",previewViewport:u?"mobile":"desktop",sidecarCenterContent:k,centerStepIndicator:!0,showStepIndicator:!1,headerContent:V?e.jsx("img",{src:S,alt:P||"Client",className:"h-12 w-auto object-contain sm:h-16"}):null,leftContent:e.jsx("div",{inert:!0,className:"opacity-80",children:e.jsxs(ui,{type:"single",value:"contact",className:q("space-y-4",k&&"space-y-3"),children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Nn,{isSidecarCheckout:k,accentColor:j,children:e.jsx(Pn,{billingInfo:Xn,setBillingInfo:Zn,isSidecarCheckout:k})}),e.jsx(Ga,{value:"shipping",number:"2",title:"Shipping address",disabled:!0})]}),e.jsx(Ga,{value:"payment",number:"3",title:"Payment",disabled:!0})]})}),summaryProps:p})})})}function sl({checkoutTheme:s,themeBranding:r,baseBranding:o=null,experience:t,summaryProps:p,cornerStyle:b="rounded",device:w="desktop",inlineViewport:N=!0,interactive:d=!1}){return e.jsx(Cn,{device:w,inline:N,children:u=>e.jsx(ni,{subscription:{branding:r,experience:t},children:e.jsx(tl,{checkoutTheme:s,themeBranding:r,baseBranding:o,experience:t,summaryProps:p,cornerStyle:b,viewportWindow:u,device:w,interactive:d})})})}const fr=c.createContext(null),al=160,gr={title:{field:"summaryTitle",label:"summary title",maxLength:120},description:{field:"primaryItemDescription",label:"product blurb",maxLength:2400},includedSectionTitle:{field:"includedSectionTitle",label:"included section title",maxLength:120},shippingRowLabel:{field:"shippingRowLabel",label:"shipping row label",maxLength:120},shippingFreeLabel:{field:"shippingFreeLabel",label:"free shipping text",maxLength:120},shippingNotIncludedLabel:{field:"shippingNotIncludedLabel",label:"shipping not included text",maxLength:120},consultationLabel:{field:"consultationLabel",label:"consultation row label",maxLength:120},totalLabel:{field:"totalLabel",label:"total label",maxLength:120}},rl=[{key:ns.CLASSIC,label:"Classic"},{key:ns.STORY,label:"Story"},{key:ns.COMPACT,label:"Compact"}],il=[{key:ts.CHECKS,label:"Checks"},{key:ts.ICONS,label:"Icons"},{key:ts.PILLS,label:"Pills"},{key:ts.MINIMAL,label:"Minimal"}],nl=[{key:Ja.STANDARD,label:"Standard"},{key:Ja.PROMINENT,label:"Prominent"}],ll=[{key:Ys.FREE_TEXT,label:"Free text"},{key:Ys.NOT_INCLUDED,label:"Not included"},{key:Ys.HIDE_ROW,label:"Hide row"}],ol=[{key:es.PRESCRIPTION,label:"Prescription / product benefit"},{key:es.LABS,label:"Lab work"},{key:es.CONSULTATION,label:"Provider consultation"},{key:es.SHIPPING_BENEFIT,label:"Shipping benefit line"}],ra={primaryCard:"product card",includedSection:"included list",subtotalRow:"subtotal row",shippingRow:"shipping row",consultationRow:"consultation row",totalRow:"total row"};function pt(){return c.useContext(fr)}function cs(s){return String(s||"").replace(/\s+/g," ").trim()}const br="outline-dashed outline-1 outline-transparent transition-[outline-color] duration-200 ease-out hover:duration-100",cl=q("cursor-pointer rounded-sm outline-offset-2 hover:outline-ring",br,"focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring"),dl="outline outline-2 outline-offset-2 outline-ring";function aa(s){var p,b;
6const r=(p=s==null?void 0:s.ownerDocument)==null?void 0:p.defaultView;if(!r||typeof s.animate!="function")return null;const o=((b=r.matchMedia)==null?void 0:b.call(r,"(prefers-reduced-motion: reduce)").matches)===!0,t=r.getComputedStyle(r.document.documentElement).getPropertyValue("--resize-ease").trim()||"cubic-bezier(0.22, 1, 0.36, 1)";return{reduced:o,ease:t}}function Js(s){var o;const r=(o=s==null?void 0:s.closest("li"))==null?void 0:o.parentElement;return r?Array.from(r.children):[]}function ul(s,r="[data-summary-edit-text]"){var o;(o=s==null?void 0:s.querySelector(`${r}:not(:disabled)`))==null||o.focus()}function yr({editKey:s,ariaLabel:r,displayText:o,onCommit:t}){const p=pt(),b=c.useRef(null),w=c.useRef(null),N=c.useRef(!1),d=c.useRef(!1),u=c.useRef(null),m=p.activeKey===s;c.useEffect(()=>{var h;m||!d.current||(d.current=!1,(h=w.current)==null||h.focus())},[m]),c.useLayoutEffect(()=>{var z;const h=b.current;if(!m||!h)return;N.current=!1,h.textContent=o,h.focus();const y=h.ownerDocument,E=(z=y.defaultView)==null?void 0:z.getSelection(),j=u.current;if(u.current=null,E){let I=null;if(j){if(typeof y.caretPositionFromPoint=="function"){const P=y.caretPositionFromPoint(j.x,j.y);P&&h.contains(P.offsetNode)&&(I=y.createRange(),I.setStart(P.offsetNode,P.offset))}else if(typeof y.caretRangeFromPoint=="function"){const P=y.caretRangeFromPoint(j.x,j.y);P&&h.contains(P.startContainer)&&(I=P)}I==null||I.collapse(!0)}I||(I=y.createRange(),I.selectNodeContents(h)),E.removeAllRanges(),E.addRange(I)}},[m]),c.useEffect(()=>{var E;if(!m)return;const h=((E=b.current)==null?void 0:E.ownerDocument.defaultView)||window;function y(j){j.key==="Escape"&&(j.stopPropagation(),j.preventDefault(),N.current=!0,d.current=!0,p.setActiveKey(null))}return h.addEventListener("keydown",y,!0),()=>h.removeEventListener("keydown",y,!0)},[m,p]);function k(){var y;if(N.current)return;N.current=!0;const h=cs((y=b.current)==null?void 0:y.textContent);h!==cs(o)&&t(h),p.activeKey===s&&p.setActiveKey(null)}return m?e.jsx("span",{ref:b,role:"textbox",tabIndex:0,"aria-label":r,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,"data-summary-edit-text":"","data-summary-edit-inner":"",className:q("inline-block min-w-[2ch] cursor-text whitespace-pre-wrap rounded-sm",dl),onClick:h=>h.stopPropagation(),onBlur:k,onPaste:h=>{h.preventDefault();const y=h.clipboardData.getData("text/plain").replace(/\s+/g," ");h.currentTarget.ownerDocument.execCommand("insertText",!1,y)},onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),d.current=!0,k())}}):e.jsx("span",{ref:w,role:"button",tabIndex:0,"aria-label":`Edit ${r}: ${o}`,title:"Click to edit","data-summary-edit-text":"","data-summary-edit-inner":"",className:cl,onClick:h=>{h.stopPropagation(),u.current=h.detail>0?{x:h.clientX,y:h.clientY}:null,p.setActiveKey(s)},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),h.stopPropagation(),p.setActiveKey(s))},children:o})}function ss({label:s,options:r,value:o,onChange:t}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-2xs font-medium text-content-secondary",children:s}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"group","aria-label":s,children:r.map(p=>{const b=p.key===o;return e.jsxs(O,{type:"button",size:"sm",variant:b?"default":"outline","aria-pressed":b,onClick:()=>t(p.key),className:"h-7 gap-1 rounded-full px-2.5 text-2xs",children:[b?e.jsx(fi,{className:"size-3","aria-hidden":!0}):null,p.label]},p.key)})})]})}function rt({id:s,label:r,hint:o=null,checked:t,onCheckedChange:p,disabled:b=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:s,className:"text-xs font-medium text-content-primary",children:r}),o?e.jsx("p",{className:"mt-0.5 text-2xs leading-snug text-content-tertiary",children:o}):null]}),e.jsx(mt,{id:s,checked:t,onCheckedChange:p,disabled:b})]})}function ml({blockKey:s,meta:r}){const{summary:o,patchSummary:t,hasCustomBullets:p,presetSlots:b,setActiveKey:w}=pt(),N=u=>{t(u),w(null)};if(s==="primaryCard")return e.jsxs(e.Fragment,{children:[e.jsx(ss,{label:"Card style",options:rl,value:o.layoutPreset,onChange:u=>t({layoutPreset:u})}),e.jsx(rt,{id:"summary-edit-show-blurb",label:"Show product blurb",hint:o.layoutPreset===ns.COMPACT?"Compact cards never show the blurb.":null,checked:o.showProductBlurb!==!1,onCheckedChange:u=>t({showProductBlurb:u===!0}
6)})]});if(s==="includedSection"){const u=ol.filter(m=>b==null||b.has(m.key));return e.jsxs(e.Fragment,{children:[e.jsx(ss,{label:"Item style",options:il,value:o.includedItemsStyle,onChange:m=>t({includedItemsStyle:m})}),p?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-2xs leading-snug text-content-tertiary",children:"This list is custom. Restore the lines checkout builds from this product's labs, consultation, and shipping."}),e.jsx(O,{type:"button",variant:"outline",size:"sm",className:"h-7 rounded-full text-2xs",onClick:()=>t({includedBullets:[]}),children:"Use product lines"})]}):u.length?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-2xs leading-snug text-content-tertiary",children:"Lines built from this product. Editing any line turns the list into custom items."}),u.map(m=>e.jsx(rt,{id:`summary-edit-preset-${m.key}`,label:m.label,checked:o.includedPresetVisibility[m.key]!==!1,onCheckedChange:k=>t({includedPresetVisibility:{...o.includedPresetVisibility,[m.key]:k===!0}})},m.key))]}):null,(r==null?void 0:r.count)===0?e.jsx("p",{className:"text-2xs leading-snug text-content-tertiary",children:"Patients do not see this section until it has an item."}):null,e.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"h-7 justify-start px-2 text-2xs",onClick:()=>N({showIncludedSection:!1}),children:"Hide section"})]})}if(s==="shippingRow")return e.jsxs(e.Fragment,{children:[e.jsx(ss,{label:"When shipping is $0",options:ll,value:o.shippingFreeDisplay,onChange:u=>t({shippingFreeDisplay:u})}),e.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"h-7 justify-start px-2 text-2xs",onClick:()=>N({showShippingRow:!1}),children:"Hide shipping row"})]});if(s==="totalRow")return e.jsx(ss,{label:"Total style",options:nl,value:o.totalStyle,onChange:u=>t({totalStyle:u})});const d=s==="subtotalRow"?"showSubtotal":"showConsultationRow";return e.jsxs(O,{type:"button",variant:"ghost",size:"sm",className:"h-7 justify-start px-2 text-2xs",onClick:()=>N({[d]:!1}),children:["Hide ",ra[s]]})}function pl({blockKey:s,meta:r,children:o,footer:t=null}){const p=pt(),b=c.useRef(null),w=`block:${s}`,N=p.activeKey===w,d=ra[s];function u(){p.setActiveKey(N?null:w)}return e.jsxs(mr,{modal:!1,open:N,onOpenChange:m=>{!m&&p.activeKey===w&&p.setActiveKey(null)},children:[e.jsx(xi,{asChild:!0,children:e.jsxs("div",{ref:b,"data-summary-edit-block":s,className:q("group/edit relative rounded-[inherit] outline-offset-4",br,N?"outline outline-2 outline-ring":"hover:outline-ring has-[>button:focus-visible]:outline-ring has-[[data-summary-edit-inner]:hover]:outline-transparent"),onClick:m=>{m.defaultPrevented||m.target.closest("[data-summary-edit-text], [data-summary-edit-inner], button")||u()},children:[o,t,e.jsxs(O,{type:"button",variant:"secondary",size:"sm","aria-expanded":N,"aria-label":`Edit ${d} options`,className:q("absolute -top-3 right-2 h-6 origin-bottom-right gap-1 rounded-full px-2 text-3xs shadow-sm [&_svg]:size-3","transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-opacity",N?"scale-100 opacity-100":q("pointer-events-none scale-95 opacity-0","group-hover/edit:pointer-events-auto group-hover/edit:scale-100 group-hover/edit:opacity-100 group-hover/edit:duration-150","focus-visible:scale-100 focus-visible:opacity-100 focus-visible:duration-150","group-has-[[data-summary-edit-inner]:hover]/edit:scale-95 group-has-[[data-summary-edit-inner]:hover]/edit:opacity-0")),onClick:m=>{m.stopPropagation(),u()},children:[e.jsx(Fn,{className:"size-3","aria-hidden":!0}),"Click to edit"]})]})}),e.jsxs(pr,{align:"start",sideOffset:10,className:"w-72 origin-[var(--radix-popover-content-transform-origin)] space-y-3 p-3",accessibleLabel:`${d} options`,onInteractOutside:m=>{var k;(k=b.current)!=null&&k.contains(m.target)&&m.preventDefault()},children:[e.jsx("p",{className:"text-xs font-semibold text-content-primary",children:d.charAt(0).toUpperCase()+d.slice(1)}),e.jsx(ml,{blockKey:s,meta:r})]})]})}function xl({index:s,label:r}){const o=pt(),{includedLabels:t}=o,p=t.length,b=c.useRef(null),w=c.useRef(!1);function N(m){o.patchSummary({includedBullets:m.map(k=>
6cs(k).slice(0,al)).filter(Boolean).map(k=>({label:k}))})}function d(m,k){var fe;const h=s+m;if(h<0||h>=p)return;const y=[...t];[y[s],y[h]]=[y[h],y[s]];const E=Js(b.current).map(V=>V.getBoundingClientRect());Zs.flushSync(()=>N(y));const j=Js(b.current),z=aa(b.current);z&&!z.reduced&&[[s,h],[h,s]].forEach(([V,Y])=>{const $=j[V];if(!$||!E[Y])return;const Z=$.getBoundingClientRect(),oe=E[Y].left-Z.left,ve=E[Y].top-Z.top;$.animate([{transform:`translate(${oe}px, ${ve}px)`},{transform:"none"}],{duration:250,easing:z.ease})});const I=k==="up"?"down":"up",P=j[h];(fe=(P==null?void 0:P.querySelector(`[data-bullet-action="${k}"]:not(:disabled)`))||(P==null?void 0:P.querySelector(`[data-bullet-action="${I}"]`)))==null||fe.focus()}function u(){var z;if(w.current)return;const m=(z=b.current)==null?void 0:z.closest("li"),k=()=>{const I=Js(m);Zs.flushSync(()=>N(t.filter((P,S)=>S!==s))),ul(s<p-1?I[s]:I[s-1])},h=aa(m);if(!m||!h){k();return}w.current=!0;const y=m.ownerDocument.defaultView.getComputedStyle(m),E=h.reduced?[{opacity:1},{opacity:0}]:y.display.startsWith("inline")?[{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(0.96)"}]:[{opacity:1,height:`${m.offsetHeight}px`,marginTop:y.marginTop,overflow:"hidden"},{opacity:0,height:"0px",marginTop:"0px",overflow:"hidden"}],j=m.animate(E,{duration:150,easing:h.ease,fill:"forwards"});j.finished.then(()=>{w.current=!1,k(),j.cancel()},()=>{w.current=!1})}return e.jsxs("span",{ref:b,"data-summary-edit-inner":"",className:"group/bullet inline-flex w-full min-w-0 items-center gap-1",children:[e.jsx(yr,{editKey:`text:includedItem:${s}`,ariaLabel:`included item ${s+1}`,displayText:r,onCommit:m=>{const k=[...t];k[s]=m,N(k)}}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center opacity-0 transition-opacity duration-200 ease-out group-focus-within/bullet:opacity-100 group-focus-within/bullet:duration-100 group-hover/bullet:opacity-100 group-hover/bullet:duration-100",children:[e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"size-6 [&_svg]:size-3","data-bullet-action":"up",disabled:s===0,"aria-label":`Move ${r} up`,onClick:m=>{m.stopPropagation(),d(-1,"up")},children:e.jsx(Tn,{className:"size-3","aria-hidden":!0})}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"size-6 [&_svg]:size-3","data-bullet-action":"down",disabled:s===p-1,"aria-label":`Move ${r} down`,onClick:m=>{m.stopPropagation(),d(1,"down")},children:e.jsx(qn,{className:"size-3","aria-hidden":!0})}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"size-6 [&_svg]:size-3","aria-label":`Remove ${r}`,onClick:m=>{m.stopPropagation(),u()},children:e.jsx(pi,{className:"size-3","aria-hidden":!0})})]})]})}function hl(){const s=pt(),r=c.useRef(null),{includedLabels:o}=s;return o.length>=Ln?null:e.jsxs(O,{ref:r,type:"button",variant:"ghost",size:"sm",className:"mt-2 h-7 gap-1 px-2 text-2xs",onClick:t=>{var m,k;t.stopPropagation();const p=[...o,"New item"],b=(m=r.current)==null?void 0:m.closest("[data-summary-edit-block]");Zs.flushSync(()=>{s.patchSummary({includedBullets:p.map(h=>({label:h}))}),s.setActiveKey(`text:includedItem:${p.length-1}`)});const w=(k=b==null?void 0:b.querySelector("ul"))==null?void 0:k.lastElementChild,N=aa(w);if(!w||!N)return;const d=w.ownerDocument.defaultView.getComputedStyle(w),u=N.reduced||d.display.startsWith("inline")?[{opacity:0},{opacity:1}]:[{opacity:0,height:"0px",marginTop:"0px",overflow:"hidden"},{opacity:1,height:`${w.offsetHeight}px`,marginTop:d.marginTop,overflow:"hidden"}];w.animate(u,{duration:250,easing:N.ease})},children:[e.jsx(hi,{className:"size-3.5","aria-hidden":!0}),"Add item"]})}function fl({slotKey:s,node:r,meta:o}){return s==="includedItem"?e.jsx(xl,{index:(o==null?void 0:o.index)??0,label:String(r??"")}):gr[s]?e.jsx(gl,{slotKey:s,displayText:String(r??"")}):ra[s]?e.jsx(pl,{blockKey:s,meta:o,footer:s==="includedSection"?e.jsx(hl,{}):null,children:r}):r}function gl({slotKey:s,displayText:r}){const o=pt(),t=gr[s],p=s==="description"?cs(o.productDescription):Sn[t.field];return e.jsx(yr,{editKey:`text:${s}`,ariaLabel:t.label,displayText:r,onCommit:b=>{const w=b===p?"":b.slice(0,t.maxLength);
6o.patchSummary({[t.field]:w})}})}function bl(s,r,o){return e.jsx(fl,{slotKey:s,node:r,meta:o})}const yl=[{key:"desktop",label:"Desktop",icon:On},{key:"mobile",label:"Mobile",icon:ki}];function vl({form:s,onFormChange:r,branding:o,experience:t,productDisplayName:p,productDescription:b,productImageUrl:w,customerPrice:N,shippingPrice:d,catalogProduct:u=null}){var ke,ge;const[m,k]=c.useState("desktop"),[h,y]=c.useState(null),E=t||(o==null?void 0:o.experienceConfig),j=hr(E),z=gi(E),I=((ke=z.portalChrome)==null?void 0:ke.cornerStyle)||"rounded",P=ur((ge=z.checkoutTheme)==null?void 0:ge.layoutPreset),S=c.useMemo(()=>Qs(s.productCheckoutSummary||ls),[s.productCheckoutSummary]),fe=c.useMemo(()=>{if(!u)return null;const R=In({product:u,shippingPrice:d});return R.shippingFreeLabel=S.shippingFreeLabel||"Free priority shipping",Rn(R)},[u,d,S.shippingFreeLabel]),V=c.useMemo(()=>An({productCheckoutSummary:S,productDisplayName:p,productDescription:b,productImageUrl:w,customerPrice:N,shippingPrice:d,catalogProduct:u,branding:o,experience:t}),[S,p,b,w,N,d,u,o,t]),Y=m==="desktop",$=c.useMemo(()=>Y?{...V.summaryProps,editSlot:bl}:V.summaryProps,[Y,V.summaryProps]),Z=c.useMemo(()=>JSON.stringify(Xa(S))===JSON.stringify(Xa(ls)),[S]);function oe(R){r({productCheckoutSummary:Qs({...S,...R})})}function ve(){const R=S;y(null),r({productCheckoutSummary:Qs(ls)}),At.undo("Checkout page reset to defaults",()=>r({productCheckoutSummary:R}))}const it={summary:S,patchSummary:oe,activeKey:h,setActiveKey:y,includedLabels:(V.summaryProps.includedItems||[]).map(R=>String(R.label||"")),hasCustomBullets:S.includedBullets.some(R=>R.label.trim().length>0),presetSlots:fe,productDescription:b};if(!j)return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-dashed border-default bg-surface-sunken",children:[e.jsx("div",{className:"border-b border-subtle bg-surface-raised px-5 py-4 max-lg:px-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-sunken text-content-secondary",children:e.jsx($n,{className:"size-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-display text-base font-semibold text-content-primary",children:"Per-product order summary is off"}),e.jsx("p",{className:"mt-1 max-w-xl text-sm leading-relaxed text-content-secondary",children:"Enable it once in Portal experience, then customize the checkout summary panel for each catalog product."})]})]})}),e.jsx("div",{className:"px-5 py-4 max-lg:px-4",children:e.jsx(O,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(Jr,{to:"/settings/patient-experience#patient-checkout-sequence",children:"Enable in Portal experience"})})})]});const ee=[S.showProductBlurb===!1,S.showSubtotal===!1,S.showShippingRow===!1,S.showConsultationRow===!1,S.showIncludedSection===!1].filter(Boolean).length,We=(u==null?void 0:u.syncVisitPrice)!=null&&u.syncVisitPrice!=="";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-content-primary",children:"Checkout page"}),e.jsx("p",{className:"mt-0.5 max-w-xl text-xs leading-relaxed text-content-secondary",children:Y?"Click any text or section in the preview to edit it. Changes go live when you save the product.":"Phones show the compact summary below. Switch to Desktop to edit."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(mr,{children:[e.jsx(bi,{asChild:!0,children:e.jsxs(O,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-full text-xs",children:[e.jsx(yi,{className:"size-3.5","aria-hidden":!0}),"Show or hide",ee?e.jsxs("span",{className:"rounded-full bg-surface-muted px-1.5 text-3xs font-semibold text-content-secondary",children:[ee," hidden"]}):null]})}),e.jsxs(pr,{align:"end",className:"w-80 origin-[var(--radix-popover-content-transform-origin)] space-y-3 p-3",accessibleLabel:"Checkout page visibility",children:[e.jsx("p",{className:"text-xs font-semibold text-content-primary",children:"What patients see"}),e.jsx(rt,{id:"checkout-summary-show-blurb",label:"Product blurb",checked:S.showProductBlurb!==!1,onCheckedChange:R=>oe({showProductBlurb:R===!0})}),e.jsx(rt,{id:"checkout-summary-show-subtotal",label:"Subtotal row",checked:S.showSubtotal!==!1,onCheckedChange:R=>oe({showSubtotal:R===!0})}),e.jsx(rt,{id:"checkout-summary-show-shipping",label:"Shipping row",checked:S.showShippingRow!==!1,onCheckedChange:R=>oe({showShippingRow:R===!0})}),e.jsx(rt,{id:"checkout-summary-show-consultation",label:"Medical consultation row",hint:We?null:"Shown only when this product has a consultation price.",checked:S.showConsultationRow!==!1,onCheckedChange:R=>oe({showConsultationRow:R===!0})}),e.jsx(rt,{id:"checkout-summary-show-included",label:"What's included 
6section",checked:S.showIncludedSection!==!1,onCheckedChange:R=>oe({showIncludedSection:R===!0})}),P?e.jsxs("div",{className:"space-y-1.5 border-t border-subtle pt-3",children:[e.jsx(dr,{htmlFor:"checkout-summary-title",className:"text-xs font-medium text-content-primary",children:"Summary title"}),e.jsx(ne,{id:"checkout-summary-title",value:S.summaryTitle,maxLength:120,onChange:R=>oe({summaryTitle:R.target.value}),placeholder:"Summary"}),e.jsx("p",{className:"text-2xs leading-snug text-content-tertiary",children:"Your Sidecar checkout layout does not show this title. It appears with the Editorial and Focused layouts."})]}):null]})]}),e.jsxs(O,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 rounded-full text-xs",onClick:ve,disabled:Z,children:[e.jsx(vi,{className:"size-3.5","aria-hidden":!0}),"Reset to defaults"]}),e.jsxs("div",{className:"relative grid grid-cols-2 rounded-full border border-subtle bg-surface-sunken p-0.5",role:"group","aria-label":"Preview device",children:[e.jsx("span",{"aria-hidden":!0,className:q("pointer-events-none absolute inset-y-0.5 left-0.5 w-[calc(50%-2px)] rounded-full bg-surface-raised shadow-sm","transition-transform [transition-duration:250ms] [transition-timing-function:var(--resize-ease)] motion-reduce:transition-none",m==="mobile"&&"translate-x-full")}),yl.map(R=>{const be=R.icon,Le=m===R.key;return e.jsxs(O,{type:"button",variant:"ghost",size:"sm","aria-pressed":Le,onClick:()=>{y(null),k(R.key)},className:q("relative h-7 w-full gap-1 rounded-full px-2.5 text-2xs transition-colors hover:bg-transparent",Le?"text-content-primary hover:text-content-primary":"text-content-tertiary hover:text-content-secondary"),children:[e.jsx(be,{className:"size-3.5","aria-hidden":!0}),R.label]},R.key)})]})]})]}),e.jsx(fr.Provider,{value:it,children:e.jsx(sl,{checkoutTheme:V.checkoutTheme,themeBranding:V.themeBranding,baseBranding:V.baseBranding,experience:V.experience,summaryProps:$,cornerStyle:I,device:m,interactive:Y})}),e.jsx("p",{className:"text-2xs leading-relaxed text-content-tertiary",children:"Name, price, and image come from this product. Logo, page layout, and pay button style come from Settings › Portal experience and apply to every product."})]})}const kl="px-3 py-2 sm:px-5 sm:py-3",tr="rounded-xl border border-subtle bg-surface-raised p-3 max-lg:p-2 sm:p-4 shadow-none",jl="border-0 bg-transparent p-0 shadow-none dark:bg-transparent max-lg:p-0",ze="rounded-xl bg-surface-sunken p-3 max-lg:p-2",wl="free_visit",Nl=[],Pl={no_client:"Lab options are unavailable for this account.",no_tenant_labs:"Add a lab to your catalog before requiring one.",no_supported_labs:"The provider network has not approved any labs for this product.",no_orderable_labs:"Your labs are not connected to an active lab integration.",missing_required_biomarkers:"No current lab contains every required biomarker.",integrations_unreadable:"Unable to verify lab integrations. Try again.",load_failed:"Unable to load lab options. Try again."};function sr(s){return Pl[s]||"No lab options are available to approve for this product."}function ar(s){if(!s||typeof window>"u")return;const r=s.closest('[role="dialog"]');r&&r.scrollTop&&(r.scrollTop=0);let o=s.parentElement;for(;o&&o!==r;){const t=window.getComputedStyle(o).overflowY;if((t==="auto"||t==="scroll")&&o.scrollHeight>o.clientHeight+1){const b=o.scrollTop+(s.getBoundingClientRect().top-o.getBoundingClientRect().top)-8;o.scrollTop=Math.max(0,b);return}o=o.parentElement}}const rr=10*1024*1024,ir={"image/jpeg":[".jpg",".jpeg"],"image/png":[".png"],"image/webp":[".webp"]};function D(s){return s==null?"":String(s).trim()}function as(s){const r=Number.parseInt((s||"").toString().trim(),10);return Number.isFinite(r)&&r>0?r:null}function Cl(s){const r=Number.parseInt((s??"").toString().trim(),10);return Number.isFinite(r)&&r>=0?r:null}function le(s=[]){return Array.from(new Set((Array.isArray(s)?s:[]).map(r=>r==null?"":String(r).trim()).filter(Boolean))).sort((r,o)=>r.localeCompare(o))}function nr(s={},r={}){const o=le([s.id,s.clientProductId,s.catalogEntryId,s.productId]),t=le([r.id,r.productId,r.clientProductId,r.catalogEntryId]);if(t.some(w=>o.includes(w)))return!0;
6if(t.length>0)return!1;const p=D(s.name).toLowerCase(),b=D(r.name).toLowerCase();return!!(p&&p===b)}function ue(s={}){return D(s.id||s.catalogEntryId||s.clientProductId||s.productId)}function lr(s){if(s==null||s==="")return null;const r=Number.parseFloat(s);return Number.isFinite(r)?r:null}function Sl(s){const r=(Array.isArray(s)?s:[]).map(o=>o==null?void 0:o.name).filter(Boolean);return r.length===0?"Required markers unavailable":r.length<=3?`Missing: ${r.join(", ")}`:`Missing ${r.length}: ${r.slice(0,3).join(", ")} +${r.length-3} more`}function Ve({children:s,info:r,className:o=""}){const t=typeof s=="string"?s:"Field";return e.jsxs("div",{className:q("mb-1 flex items-center gap-1.5",o),children:[e.jsx("label",{className:"block text-xs font-medium text-content-secondary",children:s}),r?e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300","aria-label":`${t} info`,children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:r})]})}):null]})}function Ll({lab:s}){return e.jsx(ln,{markers:nn(s),side:"right",align:"start"})}function vr(s){return s==null?"":String(s).trim()}function or(s={}){const r=Number(s.errorStatus||s.statusCode||s.status),o=vr(s.error||s.message).toLowerCase();return r===403||o.includes("status code 403")||o.includes("status 403")}function Il(s={}){if(!s||s.inactiveFormularyMappingOnly||s.active===!1||s.enabled===!1)return!1;const r=vr(s.status||s.integrationStatus||s.state).toLowerCase();return!["inactive","disabled","archived","deleted"].includes(r)}function os(s={}){return s.itemType==="package"?"package":String(s.type||s.itemType||"product").trim().toLowerCase()||"product"}function Xs(s={}){const r=os(s);return{product:"Product",protocol:"Protocol",visit:"Visit",lab:"Lab"}[r]||r.charAt(0).toUpperCase()+r.slice(1)}function Be(s={}){return D(s.providerNetworkId)}function rs(s={}){const r=Be(s);return r?[s.reviewNetworkLabel,s.providerNetworkName].map(o=>D(o)).find(o=>o&&o!==r)||"Provider network":"Client-owned"}function is(s={}){return s.requiresLabs===!0}function cr(s={}){var r;return s.requiresSyncVisit===!0||s.requiresSyncVisitOverride===!0||s.sourceRequiresSyncVisit===!0||s.isRequiredSyncVisit===!0||((r=s.labFirstWorkflow)==null?void 0:r.enabled)===!0}function Rl(s={}){const r=s.formularyReadiness||{},o=Number(s.formularyMappingCount||0);if(r.status==="eligible_unpaired")return{label:"Needs pairing",detail:"",className:"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900/40 dark:bg-amber-900/20 dark:text-amber-200"};if(o>0){const t=Array.isArray(s.formularyMedicationLabels)?s.formularyMedicationLabels.filter(Boolean):[];return{label:`${o} mapped`,detail:t.length>0?t.slice(0,2).join(", "):"",className:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-900/20 dark:text-emerald-200"}}return r.status==="ineligible_client_owned"||r.status==="ineligible_no_provider_network"?{label:"N/A",detail:r.label||"",className:"border-subtle bg-surface-sunken text-content-secondary"}:r.label?{label:r.label,detail:"",className:"border-subtle bg-surface-sunken text-content-secondary"}:{label:"No pairings",detail:"",className:"border-subtle bg-surface-sunken text-content-secondary"}}function Al(s="catalog-item"){var o,t;const r=((t=(o=window.crypto)==null?void 0:o.randomUUID)==null?void 0:t.call(o))||`${Date.now()}`;return`${s}-${r}`}function El({product:s,clientId:r,canEdit:o,prescribeByProductEnabled:t=!1,onMappingsSnapshot:p,focusRef:b,accentColor:w}){const[N,d]=c.useState(!1),[u,m]=c.useState(""),[k,h]=c.useState([]),[y,E]=c.useState({}),[j,z]=c.useState({}),[I,P]=c.useState(!1),[S,fe]=c.useState(!1),{getMedicationDisplayLabel:V}=Di(),[Y,$]=c.useState([]),[Z,oe]=c.useState([]),[ve,it]=c.useState(""),ee=c.useRef({}),We=c.useRef(""),ke=Object.values(y).some(Q=>Array.isArray(Q==null?void 0:Q.medicationIds)&&Q.medicationIds.length>0),ge=Ba(s),R=c.useMemo(()=>ge?{[ge]:y}:{},[y,ge]),be=N||!I,Le=c.useRef({product:s,onMappingsSnapshot:p});c.useEffect(()=>{Le.current={product:s,onMappingsSnapshot:p}},[s,p]),c.useEffect(()=>{const{product:Q}=Le.current;if(!r||!(Q!=null&&Q.id))return;let ce=!1;return d(!0),m(""),P(!1),fe(!1),(async()=>{var Ke,He;try{const B=t?Ui($e,{clientId:r}):Promise.resolve({enabled:!1,providerNetworkId:null}),[je,re,n,F,Fe]=await Promise.all([Fi({clientId:r}),zi($e,{clientId:r,product:Q}),Gi($e,r,{useCache:!1}),B,Hi($e,r,{includeInactive:!0}
6).catch(()=>new Map)]);if(ce)return;let xt=[];const Ie=(F==null?void 0:F.providerNetworkId)||"";if(t){const[_,nt]=await Promise.all([F!=null&&F.enabled&&Ie?Vi($e,Ie):Promise.resolve([]),$i($e,r)]);if(ce)return;const lt=new Set;for(const we of[..._,...nt]){const Ye=we==null?void 0:we.id;!Ye||lt.has(Ye)||(lt.add(Ye),xt.push(we))}}$(xt),oe(Object.values(Yi(Fe))),it(Ie||r);const ht=Array.isArray(je.pharmacies)?je.pharmacies:[],Tt=ht.filter(_=>Il(_)&&!or(_)),Oe=ht.filter(_=>_.error||or(_)),M=Oe.map(_=>`${_.id||_.pharmacyId}:${_.error}`).join("|");Oe.length>0&&M&&We.current!==M&&(We.current=M,L.error(`${Oe.length} OnlyScripts ${Oe.length===1?"pharmacy is":"pharmacies are"} not connected and hidden.`)),h(Tt),fe(Array.isArray(je.pharmacies)&&Oe.length===0),Bi(r,Tt),E(re),ee.current=re,z(Ji(n)),P(!0),(He=(Ke=Le.current).onMappingsSnapshot)==null||He.call(Ke,Q,re)}catch(B){if(ce)return;console.error("Error loading product formulary mappings:",B),m((B==null?void 0:B.message)||"Unable to load formulary mappings."),L.error((B==null?void 0:B.message)||"Unable to load formulary mappings."),h([]),E({}),z({}),P(!0),ee.current={}}finally{ce||d(!1)}})(),()=>{ce=!0}},[r,ge,t]);async function ds({drug:Q,pharmacy:ce,nextChecked:Ke}){const He=Qi(Q),B=Ba(s);if(!r||!He||!B||!s)return;const je=Wi(ce,r);try{const{mappingKey:re,payload:n}=await Ki($e,{clientId:r,product:s,pharmacy:je,drug:Q,nextChecked:Ke,mapping:ee.current,user:sa.currentUser}),F={...ee.current,[re]:{...n,source:"client",hasOverride:!0}};ee.current=F,E(F),p==null||p(s,F)}catch(re){console.error("Error saving formulary mapping:",re),L.error((re==null?void 0:re.message)||"Unable to save formulary mapping.")}}function ie(Q,ce){ee.current=ce||{},E(ce||{}),p==null||p(Q||s,ce||{})}return e.jsxs("div",{ref:b,className:"scroll-mt-6",children:[be?e.jsxs("p",{className:"inline-flex items-center gap-2 rounded-xl bg-surface-sunken px-3 py-2 text-xs text-content-tertiary max-lg:gap-1.5 max-lg:px-2 max-lg:py-1.5 max-lg:text-2xs",children:[e.jsx(ta,{size:"sm",label:"Loading formulary"}),"Loading formulary..."]}):null,!be&&u?e.jsx("p",{className:"text-sm text-red-600 max-lg:text-xs dark:text-red-400",role:"alert",children:u}):null,!be&&!u&&k.length===0&&!ke?e.jsx("p",{className:"text-sm text-content-tertiary max-lg:text-xs",children:"No connected pharmacies are enabled for this client."}):null,!be&&!u&&(k.length>0||ke)?e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsx(Oi,{exportReady:S,canExportCsv:!0,pharmacies:k,clientId:r,products:[s],mappingsByProductKey:R,canEdit:o,onToggleProduct:ds,accentColor:w,maxHeight:xr,surfaceId:"client-formulary-medications-product-modal",surfaceTitle:"Paired formulary",tableTestId:"table-client-formulary-medications-product-modal",pairedProductsHeader:"",priceOverridesByKey:j,getMedicationDisplayLabel:V,singleProductPairingFirst:!0,singleProductPairedRowsFirst:!0,customMedications:t?Y:[],formularyVariants:Z,customFormularyScopeId:ve||r}),e.jsx(en,{clientId:r,pharmacies:k,products:[s],fixedProduct:s,mappingsByProductKey:R,customMedications:t?Y:[],customFormularyScopeId:ve||r,priceOverridesByKey:j,canEdit:o,title:"Pair formulary",description:"Toggle medications for this product. Save applies the selected formulary pairings.",onMappingsChange:ie,loading:be})]}):null]})}function Hc({open:s,suspended:r=!1,onOpenChange:o,product:t,editorType:p="product",isCreating:b=!1,getInitialDetailForm:w,categories:N=[],accentColor:d,isClientOwnedProduct:u,getProductReviewNetworkLabel:m,getProductReviewNetworkColor:k,getProductSettingsRef:h,isBusinessTenant:y,catalogTenantId:E,clientId:j,clientName:z="Client",businessId:I=null,canEditPricing:P=!0,canEditStateExclusions:S=!1,canEditFormularyMappings:fe=!1,assertLabEnablementAllowed:V=null,prescribeByProductEnabled:Y=!1,showFormularyTab:$=!0,initialFocusSection:Z="",onFormularyMappingsSnapshot:oe,packageSelectableProducts:ve=Nl,onPackageSave:it,onPackageProductEdit:ee,onBack:We,onSaveSuccess:ke,onProductSubscriptionSave:ge,canChangeProductSource:R=!1,onRequestProductSourceChange:be,editorSessionKey:Le=null,sourcePickerOpen:ds=!1,sourceChangeResult:ie=null,copyableProductId:Q="",branding:ce=null,clientExperience:Ke=null,onCreateLabPanel:He,suspendForLabCreation:B=!1,returningLabSelection:je=null,onReturningLabHandled:re}){const[n,F]=c.useState({displayName:"",displayDescription:"",displayImageUrl:"",displayThumbnailUrl:"",displayImageBackgroun
6dColor:"",customerPrice:"",syncVisitPrice:"",shippingPrice:"",supplyUnit:"months",quantityMonths:"1",quantityWeeks:"",prescriptionFillQuantity:"",prescriptionRefills:"",displayCategoryIds:[],excludedStates:[],catalogActive:!0,showPatient:!0,showSupplyDetailsOnStorefront:!1,requiresLabs:!1,approvedLabProductIds:[],requiredLabPriceOverrides:[],requiredLabAudiences:[],freeVisitEnabled:!1,freeVisitCount:"",freeVisitExpiration:"",...Mn(),prescriptionDirections:"",clientPrescribingNote:"",clinicalDifferenceStatement:"",dirxMedicalNecessityStatement:"",sendToPatientDefaultFlow:"product_first",includedProductIds:[],requiresSyncVisitOverride:!1,syncVisitAudience:"all",labFirstWorkflow:Ka(),refillReminder:Wa(),clinicalRulesWindowPrices:{},productCheckoutSummary:{...ls}}),[Fe,xt]=c.useState(null),[Ie,ht]=c.useState(!1),[Tt,Oe]=c.useState(!1),[M,_]=c.useState("overview"),[nt,lt]=c.useState(""),[we,Ye]=c.useState([]),[ft,us]=c.useState([]),[gt,ms]=c.useState([]),[Ne,ps]=c.useState([]),[De,xs]=c.useState([]),[qt,bt]=c.useState(null),[Qe,Ft]=c.useState(!1),[Ot,yt]=c.useState(!1),[kr,ia]=c.useState(0),[jr,vt]=c.useState(0),[hs,na]=c.useState(0),[la,de]=c.useState(""),[kt,Dt]=c.useState({}),[Mt,_t]=c.useState({}),[wr,oa]=c.useState(!1),[Nr,fs]=c.useState([]),[gs,ca]=c.useState(""),[Re,jt]=c.useState(!1),[da,ua]=c.useState(0),v=p==="package"||(t==null?void 0:t.itemType)==="package",me=v?"package-details-dialog-form":"product-details-dialog-form",ma="overview",ye=t&&!v&&!y&&!u(t),Ut=P,ot=P&&!v,bs=!!((ot||v)&&ge),Pe=P&&!v,Ge=!!(j&&!v&&!y),ct=!!(j&&!v&&!y&&hr(Ke)),pa=c.useMemo(()=>mn(t==null?void 0:t.sourceClinicalRules),[t==null?void 0:t.sourceClinicalRules]),dt=!!(j&&!v&&!y&&t&&typeof u=="function"&&!u(t)),ys=c.useRef(null),xa=c.useRef(null),ha=c.useRef(null),vs=c.useRef(null),ks=(t==null?void 0:t.id)||null,Pr=c.useMemo(()=>_s({requiredLabTests:t==null?void 0:t.requiredLabTests,requiredLabTestIds:t==null?void 0:t.requiredLabTestIds}),[t==null?void 0:t.requiredLabTestIds,t==null?void 0:t.requiredLabTests]),zt=D(Q),js=(t==null?void 0:t.sourceRequiresLabs)===!0&&!(typeof u=="function"&&u(t))&&(t==null?void 0:t.supportedLabProductIds)||null,pe=c.useMemo(()=>(Array.isArray(ve)?ve:[]).filter(a=>Xr(a,j)),[ve,j]),fa=c.useMemo(()=>new Set(pe.map(ue).filter(Boolean)),[pe]),W=c.useMemo(()=>pe.filter(a=>n.includedProductIds.includes(ue(a))),[n.includedProductIds,pe]),Cr=c.useMemo(()=>_s({requiredLabTests:W.flatMap(a=>_s(a))}),[W]),wt=v?Cr:Pr,Me=wt.length>0,Sr=c.useMemo(()=>Array.from(new Map(pe.map(a=>[os(a),{id:os(a),label:Xs(a)}])).values()),[pe]),Lr=c.useMemo(()=>Array.from(new Map(pe.map(a=>[Be(a)||"client",{id:Be(a)||"client",label:rs(a)}])).values()),[pe]),Nt=!!(nt.trim()||we.length||ft.length||gt.length);function ga(){lt(""),Ye([]),us([]),ms([])}const ba=c.useMemo(()=>{const a=nt.trim().toLowerCase(),i=new Set(n.includedProductIds);return pe.filter(l=>{const f=i.has(ue(l))?"selected":"unselected";return we.length&&!we.includes(f)||ft.length&&!ft.includes(os(l))||gt.length&&!gt.includes(Be(l)||"client")?!1:a?[l.displayName||l.name,l.displayDescription||l.description,rs(l),Xs(l),ue(l),l.id,l.catalogEntryId,l.clientProductId,l.productId,l.clientId,l.businessId,l.providerNetworkId].some(g=>String(g||"").toLowerCase().includes(a)):!0}).sort((l,f)=>Number(i.has(ue(f)))-Number(i.has(ue(l)))||(l.displayName||l.name||"").localeCompare(f.displayName||f.name||""))},[pe,nt,we,ft,gt,n.includedProductIds]),ws=c.useMemo(()=>le(W.map(Be)),[W]),ya=W.filter(cr),Ns=ya.length>0,Vt=W.some(is),Ir=W.filter(is),Rr=Ns||n.requiresSyncVisitOverride===!0,$t=Vt||n.requiresLabs===!0,Ae=!!(t&&!v&&!u(t)&&t.sourceRequiresSyncVisit===!0),Je=!!(t&&!v&&!u(t)&&t.sourceRequiresLabs===!0),Ps=Je||v&&Vt,va=!!(t&&!v&&!u(t)&&t.sourceRequiresDeaPrescriber===!0),ka=Ae||n.requiresSyncVisitOverride===!0,Cs=Je||n.requiresLabs===!0,Pt=v?$t:Cs,ja=Pe||Pt,Ss=!!(t&&!v&&!u(t)&&t.sourceRequiresLabs===!0),wa=le(t==null?void 0:t.approvedLabProductIds).length,Ls=c.useRef({prices:{},audiences:{}});Ls.current={prices:kt,audiences:Mt};const Bt=P&&!v&&!y,Wt=P&&!v&&!y&&!!t&&!u(t)&&!!t.providerNetworkId,Is=n.labFirstWorkflow||Ka(),K=Wt&&Is.enabled===!0,Na=c.useMemo(()=>W.reduce((a,i)=>{const l=lr(i.customerPrice);return a+(l===null?0:l)},0),[W]),Pa=lr(n.customerPrice)||0,Ar=Na-Pa,Er=c.useMemo(()=>{const a=W.filter(i=>!(typeof u=="function"&&u(i))&&is(i)&&Array.isArray(i.supportedLabProductIds)).map(i=>le(i.supportedLabProductIds));return Zr(a)},[W,u]);function Rs(a){xt(i=>(i!=null&&i.previewUrl&&URL.revokeObjectURL(i.previewUrl),a?{file:a,previewUrl:URL.createObjectURL(a)}:null))}c.useEffect(()=>{if(!s){if(B)return;ys.current=null,jt(!1),ua(0);return}if(!t)return;const a=Le||t.id;if(ys.current===a)return;ys.current=a,F(w(t)),Oe(!1),Dt(Object.fromEntries(Us(t.requiredLabPriceOverrides).map(l=>[l.labProductId,(l.priceCents/100).toFixed(2)]))),_t(Object.fromEntries(Xt(t.requiredLabAudiences).map(l=>[l.labProductId,l.audience])));const i=!!(j&&t&&!u(t)&&$);_(Z==="formulary"&&i?"formulary":"overview"),de(""),na(0),yt(!1),vt(0),lt(""),Ye([]),us([]),ms([]),xt(l=>(l!=null&&l.previewUrl&&URL.revokeObjectURL(l.previewUrl),null))},[s,t,Le,w,Z,$,j,u,v,B]),c.useEffect(()=>{if(!ie||!t||ie.clientProductId!==(t.catalogEntryId||t.id))return;const a=le(ie.approvedLabProductIds),i=Object.entries(Ls.current.prices).filter(([,g])=>String(g??"").trim()!=="").map(([g,C])=>({labProductId:g,priceCents:Math.round(Number(String(C).trim())*100)})),l=Array.isArray(ie.requiredLabPriceOverrides)?Us(ie.requiredLabPriceOverrides):Ha(Us(i),a),f=Array.isArray(ie.requiredLabAudiences)?Xt(ie.requiredLabAudiences):Ha(Xt(Object.entries(Ls.current.audie
6nces).map(([g,C])=>({labProductId:g,audience:C}))),a);F(g=>({...g,approvedLabProductIds:a,requiredLabPriceOverrides:l,requiredLabAudiences:f,labFirstWorkflow:tn(ie.labFirstWorkflow),requiresLabs:ie.requiresLabs===!0,catalogActive:ie.status!=="inactive",showPatient:ie.showPatient!==!1})),Dt(Object.fromEntries(l.map(g=>[g.labProductId,(g.priceCents/100).toFixed(2)]))),_t(Object.fromEntries(f.map(g=>[g.labProductId,g.audience])))},[t,ie]),c.useEffect(()=>{if(!s||!Re||!vs.current)return;const a=vs.current;let i=0;const l=()=>{const C=Math.ceil(a.getBoundingClientRect().height);C>0&&ua(x=>Math.max(x,C))};l();const f=()=>{window.cancelAnimationFrame(i),i=window.requestAnimationFrame(l)},g=typeof ResizeObserver>"u"?null:new ResizeObserver(f);return g==null||g.observe(a),()=>{window.cancelAnimationFrame(i),g==null||g.disconnect()}},[M,Re,s]),c.useEffect(()=>{if(!s||!ks){if(B)return;jt(!1);return}jt(!1);const a=window.requestAnimationFrame(()=>jt(!0)),i=window.setTimeout(()=>jt(!0),80);return()=>{window.cancelAnimationFrame(a),window.clearTimeout(i)}},[s,ks,B]),c.useLayoutEffect(()=>
6{if(!s||!Re||Z!=="formulary"||!$||!t||u(t))return;const a=window.requestAnimationFrame(()=>{ar(xa.current)});return()=>window.cancelAnimationFrame(a)},[Re,Z,s,t,$,u]),c.useLayoutEffect(()=>{if(!s||!Re||Z!=="labs")return;const a=()=>{const l=ha.current;l&&(ar(l),l.focus({preventScroll:!0}))};a();const i=window.requestAnimationFrame(a);return()=>window.cancelAnimationFrame(i)},[Re,Z,s,ks]),c.useEffect(()=>{if(!s||!t)return;const a=!!(j&&!u(t)&&$),i=!!j;!a&&M==="formulary"&&_("overview"),!i&&M==="forms"&&_("overview"),!Ge&&M==="refill-reminder"&&_("overview"),!dt&&M==="clinical-rules"&&_("overview"),!ct&&M==="checkout"&&_("overview"),v&&M!=="overview"&&M!=="products"&&M!=="forms"&&_("overview"),!v&&M!=="overview"&&M!=="formulary"&&M!=="forms"&&M!=="refill-reminder"&&M!=="clinical-rules"&&M!=="checkout"&&_("overview")},[s,t,j,u,$,Ge,dt,ct,M,v]);const Ct=D((t==null?void 0:t.providerNetworkId)||""),ut=yn(t),St=Pe&&!y&&!!Ct,Ca=c.useMemo(()=>v?W.flatMap(a=>a.additionalLabConstraints||[]):t==null?void 0:t.additionalLabConstraints,[v,W,t==null?void 0:t.additionalLabConstraints]),As=v?Er:js;c.useEffect(()=>
6{if(!s||!Re||!(j||I)||!Pe){if(B)return;ps([]),xs([]),bt(null),Ft(!1),yt(!1),vt(0);return}let a=!1;return Ft(!0),yt(!1),bt(null),(async()=>{try{let i=[];if(St){let g=[];try{const C=await gn({providerNetworkId:Ct});g=Array.isArray(C==null?void 0:C.requests)?C.requests:[];const x=(C==null?void 0:C.approvedLabProductIdsByNetworkProduct)||{};i=Array.isArray(x[ut])?x[ut]:[]}catch(C){console.error("Error loading lab qualification reviews:",C)}if(a)return;fs(g)}else fs([]);const l=await ji($e,{clientId:j,businessId:I||null,networkQualifiedLabProductIds:i,additionalLabConstraints:Ca||[],supportedLabProductIds:Array.isArray(As)?As:null});if(a)return;const f=Array.isArray(l.eligibleLabs)?l.eligibleLabs:[];if(Me){const g=x=>{const T=x.map(G=>({...G.lab,coverage:G.coverage,...G.networkApproved?{networkApproved:!0}:{}})),Ce=T.filter(G=>G.coverage.qualified),Se=T.filter(G=>!G.coverage.qualified);ps(Ce),xs(Se),bt(Ce.length===0&&Se.length>0?"missing_required_biomarkers":l.eligibilityReason||null),vt(0)};oa(!1);const C=await vn({requiredLabTests:wt,labs:f,providerNetworkId:Ct||void 0,networkProductId:ut||void 0,onDeterministic:x=>{a||(g(x),Ft(!1))}});if(a)return;g(C.rows),oa(C.adjudicationUnavailable)}else ps(f),xs(St&&Array.isArray(l.omittedByAllowlist)?l.omittedByAllowlist.map(g=>({...g,needsNetworkApproval:!0})):[]),bt(l.eligibilityReason||null),vt(Number(l.omittedByAllowlistCount)||0);yt(!0)}catch(i){if(a)return;console.error("Error loading lab eligibility:",i),bt((i==null?void 0:i.eligibilityReason)==="integrations_unreadable"?"integrations_unreadable":"load_failed"),yt(!1),vt(0)}finally{a||Ft(!1)}})(),()=>{a=!0}},[s,Re,j,I,Ca,As,Pe,Me,wt,B,kr,St,Ct,ut]),c.useEffect(()=>{if(!Ot||Qe)return;const a=new Set(Ne.map(i=>i.id));F(i=>{const l=Array.isArray(i.approvedLabProductIds)?i.approvedLabProductIds:[],f=l.filter(C=>a.has(C)),g=l.length-f.length;return g>0&&na(g),f.length===l.length?i:{...i,approvedLabProductIds:f}})},[Ne,Qe,Ot]),c.useEffect(()=>{var i,l;if(!s||!je||!Ot||Qe)return;const a=Ne.find(f=>nr(f,je));if(a)F(f=>({...f,approvedLabProductIds:le([...f.approvedLabProductIds||[],a.id])})),de(""),L.success(`${a.name||"The new lab"} qualifies and was selected.`);else{const f=De.find(g=>nr(g,je));if(f){const g=((l=(i=f.coverage)==null?void 0:i.missing)==null?void 0:l.map(C=>C.name).filter(Boolean))||[];L.error(g.length>0?`${f.name||"The new lab"} still needs: ${g.join(", ")}.`:`${f.name||"The new lab"} does not meet this product's biomarker requirement.`)}else L.error("The new lab is not available for this product yet.")}re==null||re()},[Ne,Qe,Ot,De,re,s,je]);function Tr(a){return Nr.find(i=>i.labProductId===a&&i.networkProductId===ut)||null}async function qr(a){if(!(!St||gs)){ca(a.id);try{const i=await bn({providerNetworkId:Ct,networkProductId:ut,labProductId:a.id});fs(l=>[...l.filter(f=>f.requestId!==i.requestId),i]),At.success("Review requested. The provider network will be notified.")}catch(i){(i==null?void 0:i.code)==="LAB_ALREADY_QUALIFIES"||(i==null?void 0:i.status)===409?(At.success("This lab now qualifies — refresh the lab options."),ia(l=>l+1)):(console.error("Error requesting lab qualification review:",i),At.error(i))}finally{ca("")}}}function A(a,i){F(l=>({...l,[a]:i}))}function Fr(a){if(Ps){F(l=>({...l,requiresLabs:!0})),de("");return}const i=a===!0;F(l=>({...l,requiresLabs:i,approvedLabProductIds:i?l.approvedLabProductIds:[]})),de("")}function Or(a){const i=a==null?"":String(a).trim();i&&(F(l=>{const f=Array.isArray(l.approvedLabProductIds)?l.approvedLabProductIds:[],g=new Set(f.map(x=>String(x).trim()).filter(Boolean));g.has(i)?g.delete(i):g.add(i);const C=Array.from(g).sort((x,T)=>x.localeCompare(T));return{...l,approvedLabProductIds:C}}),_t(l=>{if(!(n.approvedLabProductIds||[]).includes(i))return l;const f={...l};return delete f[i],f}),Dt(l=>{if(!(n.approvedLabProductIds||[]).includes(i))return l;const f={...l};return delete f[i],f}),de(""))}function Dr(a,i){const l=String(i||"").replace(/[^0-9.]/g,"");Dt(f=>({...f,[a]:l})),de("")}function Mr(a,i){_t(l=>{const f={...l};return i==="initial"||i==="returning"?f[a]=i:delete f[a],f}),de("")}function _r(a){F(i=>({...i,displayCategoryIds:i.displayCategoryIds.includes(a)?i.displayCategoryIds.filter(l=>l!==a):[...i.displayCategoryIds,a]}))}function Kt(a){const i=Be(a);return!i||n.includedProductIds.includes(ue(a))?"":ws.find(f=>f!==i)?"Packages can include products from only one provider network.":""}function Ur(a){if(!fa.has(a))return;const i=pe.find(f=>ue(f)===a),l=i?Kt(i):"";if(l){L.error(l);return}F(f=>
6({...f,includedProductIds:f.includedProductIds.includes(a)?f.includedProductIds.filter(g=>g!==a):[...f.includedProductIds,a]}))}function zr(){if(!n.freeVisitEnabled)return{addOns:[]};const a=as(n.freeVisitCount);if(!a)return{error:"Enter an included visit count greater than 0"};const i=(n.freeVisitExpiration||"").toString().trim(),l=i?as(i):null;return i&&!l?{error:"Enter a valid expiration in days, or leave it blank"}:{addOns:[{type:wl,count:a,expiresInDays:l}]}}async function Vr(){var Oa;if(!(t!=null&&t.id))return;const a=D(n.displayName);if(v&&!a){L.error("Package name is required");return}const i=!P||n.customerPrice===""?null:Number.parseFloat(n.customerPrice);if(P&&n.customerPrice!==""&&!Number.isFinite(i)){L.error("Enter a valid price");return}if(v&&(!Number.isFinite(i)||i<0)){L.error("Enter a valid price");return}const l=_n(n,{priceCents:Number.isFinite(i)?Math.round(i*100):null});if(!l.ok){L.error(l.error);return}const f=!P||n.syncVisitPrice===""?null:Number.parseFloat(n.syncVisitPrice);if(P&&n.syncVisitPrice!==""&&!Number.isFinite(f)){L.error("Enter a valid assessment price");return}const g=!Ut||n.shippingPrice===""?null:Number.parseFloat(n.shippingPrice);if(Ut&&n.shippingPrice!==""&&(!Number.isFinite(g)||g<0)){L.error("Enter a valid shipping price");return}const C=Hs(n.supplyUnit),x=C===Ks,T=ye?as(x?n.quantityWeeks:n.quantityMonths):null;if(ye&&!T){L.error(x?"Enter a valid week supply":"Enter a valid month supply");return}const Ce=x?null:T,Se=x?T:null,G=String(n.prescriptionFillQuantity??"").trim(),_e=ye&&G!==""?as(G):null;if(ye&&G!==""&&!_e){L.error("Enter a valid quantity");return}const xe=String(n.prescriptionRefills??"").trim(),Aa=ye&&xe!==""?Cl(xe):null;if(ye&&xe!==""&&Aa===null){L.error("Enter a valid number of refills");return}const Fs=ot?zr():{addOns:[]};if(Fs.error){L.error(Fs.error);return}const Ea=Ge&&P;if(Ea&&((Oa=n.refillReminder)==null?void 0:Oa.mode)==="custom"){const te=n.refillReminder.channels||{};if(!te.email&&!te.sms){L.error("Enable email and/or SMS for the custom refill reminder");return}if(!String(n.refillReminder.messageHtml||"").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()){L.error("Enter refill reminder message content");return}}let Os=[],Ds=[];const Ta=Je&&!n.catalogActive;if(!v&&Pe&&Pt){if(Ne.length===0&&!Ta){L.error("Add an active lab to your catalog before requiring one.");return}const te=le(n.approvedLabProductIds);if(te.length===0&&!Ta){de("Choose at least one approved lab."),L.error("Select at least one lab option.");return}const Ue=new Set(Ne.map(se=>se.id));if(te.some(se=>!Ue.has(se))){de("Choose available labs."),L.error("Select available lab options.");return}if(!Je&&n.requiresLabs===!0&&(t==null?void 0:t.tenantRequiresLabs)!==!0&&typeof V=="function"&&!V({product:t,approvedLabProductIds:te}))return;for(const se of te){const U=Ne.find(Gt=>Gt.id===se),ae=Object.prototype.hasOwnProperty.call(kt,se)?String(kt[se]??"").trim():"";if(K){if(!Number.isInteger(U==null?void 0:U.catalogPriceCents)||U.catalogPriceCents<0){de(`${(U==null?void 0:U.name)||"Selected lab"} needs a Labs-page price.`),L.error("Lab-first products use the Labs-page price.");return}continue}if(!ae){if(!Number.isInteger(U==null?void 0:U.catalogPriceCents)||U.catalogPriceCents<0){de(`Enter a price for ${(U==null?void 0:U.name)||"the selected lab"}.`),L.error("Enter a price for every selected lab.");return}continue}const Lt=Number(ae);if(!Number.isFinite(Lt)||Lt<0){de(`Enter a valid price for ${(U==null?void 0:U.name)||"the selected lab"}.`),L.error("Lab prices must be $0 or greater.");return}Os.push({labProductId:se,priceCents:Math.round(Lt*100)})}Ds=Xt(te.map(se=>({labProductId:se,audience:Mt[se]})))}de("");const qa=Wt&&Is.enabled===!0,Qr={enabled:qa},Fa=le(n.includedProductIds),Ms=Fa.filter(te=>fa.has(te));if(v){if(!it){L.error("Package save handler is unavailable");return}if(Ms.length!==Fa.length){At.error("An included product is missing from this client catalog. Remove it or choose a replacement.");return}if(Ms.length<2){L.error("Select at least 2 products to include");return}if(ws.length>1){L.error("Packages can include products from only one provider network.");return}}ht(!0);try{const te=sa.currentUser;if(!te)throw new Error("Not authenticated");let Ue=D(n.displayImageUrl),Qt=D(n.displayThumbnailUrl);const se=(Fe==null?void 0:Fe.file)||null;if(se){if(!Object.keys(ir).includes(se.type))throw new Error("Invalid file type");if(se.size>rr)throw new Error("File size exceeds 10MB");const Ee=await Ei(se,{scope:y?"business-products":"client-products",targetId:v&&b?Al("package"):y?t.id:t.catalogEntryId||t.productId||t.id||t.clientProductId,tenantId:E});Ue=Ee.highResUrl,Qt=Ee.thumbnailUrl}if(v){const Ee=Ya({canEdit:Pe,lockedBySource:!1,tenantRequiresLab:$t,effectiveRequiresLab:$t,approvedLabProductIds:le(n.approvedLabProductIds),priceOverrides:Os,audiences:Ds,mirrorRequiresLabs:!0}
6),he={name:a,description:D(n.displayDescription),imageUrl:Ue,thumbnailUrl:Qt||Ue,imageBackgroundColor:zs(n.displayImageBackgroundColor),customerPrice:i,syncVisitPrice:f,shippingPrice:g!==null?g.toFixed(2):null,showPatient:n.catalogActive&&n.showPatient!==!1,status:n.catalogActive?"active":"inactive",displayCategoryIds:le(n.displayCategoryIds),...S?{excludedStates:Qa(n.excludedStates)}:{},includedProducts:Ms.map(Gr=>({clientProductId:Gr})),requiresSyncVisitOverride:n.requiresSyncVisitOverride===!0,...Ee,syncVisitAudience:n.syncVisitAudience||"all"},J=await it(he,{isUpdate:!b,product:t}),X=String((J==null?void 0:J.productId)||(t==null?void 0:t.id)||(t==null?void 0:t.clientProductId)||"").trim();if(!X)throw new Error("The package was saved without an identifier");const Jt=J!=null&&J.patch&&typeof J.patch=="object"&&!Array.isArray(J.patch)?J.patch:{},Ma={...he,...Jt,displayName:he.name,displayDescription:he.description,displayImageUrl:he.imageUrl,displayThumbnailUrl:he.thumbnailUrl,displayImageBackgroundColor:he.imageBackgroundColor};bs&&await ge({product:X?{...t,id:X,clientProductId:X,catalogEntryId:X}:t,...Za(n),payload:Ma}),ke==null||ke({product:t,payload:Ma,parsedPrice:i}),Rs(null),o(!1),L.success(b?"Package created":"Package updated");return}const U=h(t.id,t.clientProductId);if(!U)throw new Error("Client product not found");const Da=le(n.displayCategoryIds),ae={displayName:D(n.displayName),displayDescription:D(n.displayDescription),displayImageUrl:Ue,displayThumbnailUrl:Qt||Ue,displayImageBackgroundColor:zs(n.displayImageBackgroundColor),...P?{customerPrice:i,syncVisitPrice:f,...Ut?{shippingPrice:g!==null?g.toFixed(2):null}:{}}:{},...ye?{supplyUnit:C,quantityMonths:Ce,quantityWeeks:Se,prescriptionFillQuantity:_e,prescriptionRefills:Aa,showSupplyDetailsOnStorefront:n.showSupplyDetailsOnStorefront===!0}:{},displayCategoryIds:Da,...S?{excludedStates:Qa(n.excludedStates)}:{},showPatient:n.catalogActive&&n.showPatient!==!1,status:n.catalogActive?"active":"inactive",...Bt&&!Ae?{requiresSyncVisit:n.requiresSyncVisitOverride===!0,syncVisitAudience:n.syncVisitAudience||"all"}:{},...ot?{addOns:Fs.addOns}:{},prescriptionDirections:D(n.prescriptionDirections),clientPrescribingNote:D(n.clientPrescribingNote),clinicalDifferenceStatement:D(n.clinicalDifferenceStatement),dirxMedicalNecessityStatement:D(n.dirxMedicalNecessityStatement),...Ya({canEdit:Pe,lockedBySource:Je,tenantRequiresLab:n.requiresLabs===!0,effectiveRequiresLab:Cs,approvedLabProductIds:le(n.approvedLabProductIds),priceOverrides:Os,audiences:Ds,skipPriceOverrides:K}),...ct?En(n):{}};if(dt&&P){const Ee={};pa.forEach(he=>{var Jt;const J=(Jt=n.clinicalRulesWindowPrices)==null?void 0:Jt[he.id];if(J==null||String(J).trim()==="")return;const X=Number.parseFloat(String(J).replace(/[^0-9.]/g,""));Number.isFinite(X)&&X>=0&&(Ee[he.id]=X)}),ae.clinicalRulesWindowPrices=Ee}Wt&&(ae.labFirstWorkflow=Qr,qa&&(ae.requiresLabs=!0,Ae||(ae.requiresSyncVisit=!0),ae.sendToPatientDefaultFlow=Ti)),u(t)&&(ae.name=ae.displayName,ae.description=ae.displayDescription);const Lt=await $r({productId:U.id,payload:ae});Object.assign(ae,Lt),bs&&await ge({product:t,...Za(n),payload:ae});let Gt=(t==null?void 0:t.refillReminder)??null;if(Ea&&Tt){const Ee=an(n.refillReminder),he=await te.getIdToken(),J=await fetch($a("manageProduct"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${he}`},body:JSON.stringify({action:"updateClientProductRefillReminder",clientId:j,productId:U.id,refillReminder:Ee})}),X=await J.json().catch(()=>null);if(!J.ok||!(X!=null&&X.success))throw new Error((X==null?void 0:X.error)||"Unable to save refill reminder");Gt=X.refillReminder??null}ke({product:t,payload:{...ae,...Ge?{refillReminder:Gt}:{}},parsedPrice:i}),Rs(null),o(!1),L.success("Product updated")}catch(te){console.error("Error saving product details:",te),L.error(te.message||"Unable to save product.")}finally{ht(!1)}}async function $r({productId:a,payload:i}){const l=sa.currentUser;if(!l)throw new Error("You must be signed in to save this product");const f=await l.getIdToken(),g=await fetch($a("manageProduct"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({action:"saveTenantCatalogProduct",...y?{businessId:I}:{clientId:j},productId:a,...i})}),C=await g.json().catch(()=>null);if(!g.ok||!(C!=null&&C.success))throw new Error((C==null?void 0:C.error)||"Unable to save product");return Array.isArray(C.rejectedLabProductIds)&&C.rejectedLabProductIds.length>0&&L.warning("Some lab options were removed because this tenant no longer offers them."),C.patch||{}}function Sa(){if(!Pt)return null;const a=t==null?void 0:t.enforcedLabRecencyDays,i=_i({recencyDays:a,recencyUnit:t==null?void 0:t.enforcedLabRecencyUnit}),l=Number.isInteger(a)&&a>0,f=D(t==null?void 0:t.providerNetworkName)||"your provider network",g=Me,C=!g&&(jr>0||Ss&&Array.isArray(js)&&js.length>0&&Ne.length>0);if(!l&&!C&&!g)return null;const x=(t==null?void 0:t.enforcedLabRecencyDaysSource)==="category"?"Set by the category that requires labs.":Ss?`Set by ${f}.`:"",T=[l?`Results must be no older than ${i||`${a} days`}.${x?` ${x}`:""}`:null,C?`Only labs ${f}
6 approved for this product are listed.`:null,g?`Required biomarkers: ${wt.map(Ce=>Ce.name).join(", ")}.`:null].filter(Boolean).join(" ");return e.jsx("div",{className:"mt-3 border-t border-subtle pt-3 max-lg:mt-2 max-lg:pt-2","data-testid":H("section","products","lab-inherited-settings"),children:e.jsx(Ve,{className:"mb-0",info:T,children:Ss?`Lab rules set by ${f}`:"Lab rules for this product"})})}function Br(){if(!Pe||!Pt)return null;const a=D(t==null?void 0:t.providerNetworkName)||"your provider network",i=le(n.approvedLabProductIds),l=qt==="load_failed"||qt==="integrations_unreadable",f=i.map(x=>Mt[x]||"any"),g=f.some(x=>x!=="any"),C=g?f.some(x=>x==="any"||x==="initial")?f.some(x=>x==="any"||x==="returning")?"":"No lab is offered to returning patients, so they will see every option instead.":"No lab is offered to new patients, so they will see every option instead.":"";return e.jsxs("div",{className:"mt-3 border-t border-subtle pt-3 max-lg:mt-2 max-lg:pt-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 max-lg:mb-1.5",children:[e.jsx(Ve,{className:"mb-0",info:g?"A patient counts as returning once they have a completed order of this product. Patients can always reveal the other options if the match is wrong.":null,children:Me?"Qualifying lab options":"Required lab options"}),Me&&!y&&typeof He=="function"?e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:()=>He({product:t,requiredLabTests:wt}),"data-testid":"button-products-create-qualifying-lab",children:"Create lab panel"}):null]}),C?e.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-xs font-medium text-amber-700 max-lg:text-2xs dark:text-amber-300",children:[e.jsx(qe,{className:"mt-0.5 size-3.5 shrink-0"}),e.jsx("span",{children:C})]}):null,hs>0?e.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-2xs leading-snug text-content-tertiary",children:[e.jsx(qe,{className:"mt-0.5 size-3.5 shrink-0"}),e.jsx("span",{children:hs===1?"1 lab option is no longer available and was removed.":`${hs} lab options are no longer available and were removed.`})]}):null,la?e.jsx("p",{className:"mb-2 text-xs font-medium text-[var(--status-danger-text)] max-lg:mb-1.5 max-lg:text-2xs",children:la}):null,Qe?e.jsxs("p",{className:"flex items-center gap-2 px-1 py-3 text-xs text-content-tertiary max-lg:gap-1.5 max-lg:py-2 max-lg:text-2xs",children:[e.jsx(ta,{size:"md",label:"Loading lab options"}),"Loading lab options..."]}):l?e.jsx(Et,{reason:"error",title:"Lab options could not be verified",description:sr(qt),action:{label:"Try again",onClick:()=>ia(x=>x+1),testId:"button-products-retry-lab-eligibility",className:"rounded-md"},className:"min-h-36 rounded-xl border border-dashed border-default bg-surface-raised"}):Ne.length===0?e.jsx(Et,{reason:"empty",title:Me?"No qualifying lab yet":"No lab options available",description:sr(qt),className:"min-h-36 rounded-xl border border-dashed border-default bg-surface-raised"}):e.jsx("div",{className:"max-h-56 divide-y divide-border overflow-y-auto rounded-xl border border-subtle bg-surface-raised max-lg:max-h-48","data-testid":H("list","products","detail-approved-labs"),children:Ne.map(x=>{var G,_e;const T=(n.approvedLabProductIds||[]).includes(x.id),Se=Object.prototype.hasOwnProperty.call(kt,x.id)?kt[x.id]:Number.isInteger(x.catalogPriceCents)?(x.catalogPriceCents/100).toFixed(2):"";return e.jsxs("div",{className:q("flex items-center gap-3 px-3 py-2.5 text-sm max-lg:gap-2 max-lg:px-2 max-lg:py-1.5 max-lg:text-xs",T&&"bg-accent text-accent-foreground"),children:[e.jsx(Rt,{checked:T,onCheckedChange:()=>Or(x.id),className:"shrink-0","aria-label":`Approve lab ${x.name||x.id}`}),e.jsxs("span",{className:"min-w-0 flex-1 font-medium text-content-primary",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"min-w-0 truncate",children:x.name||"Lab"}),e.jsx(Ll,{lab:x})]}),x.networkApproved?e.jsx("span",{className:"block truncate text-2xs font-normal text-content-tertiary",children:`Approved for this protocol by ${a}`}):((_e=(G=x.coverage)==null?void 0:G.equivalentMatches)==null?void 0:_e.length)>
60?e.jsx("span",{className:"block truncate text-2xs font-normal text-content-tertiary",children:`${x.coverage.equivalentMatches.some(xe=>xe.source!=="ai")?`Matched by ${a}`:"Matched automatically"}: ${x.coverage.equivalentMatches.map(xe=>xe.requiredName||xe.requiredId).join(", ")}`}):null]}),T?e.jsxs(Vs,{value:Mt[x.id]||"any",onValueChange:xe=>Mr(x.id,xe),children:[e.jsx($s,{className:"h-8 w-36 shrink-0 text-xs max-lg:w-28","aria-label":`Who sees ${x.name||x.id}`,"data-testid":`select-products-required-lab-audience-${x.id}`,children:e.jsx(Bs,{})}),e.jsxs(Ws,{children:[e.jsx(Te,{value:"any",children:"Everyone"}),e.jsx(Te,{value:"initial",children:"New patients"}),e.jsx(Te,{value:"returning",children:"Returning patients"})]})]}):null,T&&K?Number.isInteger(x.catalogPriceCents)?e.jsxs("span",{className:"w-28 shrink-0 text-right text-sm font-medium tabular-nums text-content-primary max-lg:w-24 max-lg:text-xs",title:"Priced from your Labs catalog","data-testid":`text-products-required-lab-price-${x.id}`,children:["$",(x.catalogPriceCents/100).toFixed(2)]}):e.jsx("span",{className:"w-28 shrink-0 text-right text-xs font-medium text-amber-700 max-lg:w-24 max-lg:text-3xs dark:text-amber-300",children:"No Labs price"}):null,T&&!K?e.jsxs("div",{className:"relative w-28 shrink-0 max-lg:w-24",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-content-tertiary max-lg:left-2 max-lg:text-xs",children:"$"}),e.jsx(ne,{value:Se,onChange:xe=>Dr(x.id,xe.target.value),inputMode:"decimal",className:"h-8 pl-6 text-right max-lg:pl-5",placeholder:"0.00","aria-label":`Price for ${x.name||x.id}`,"data-testid":`input-products-required-lab-price-${x.id}`})]}):null,T&&(K?x.catalogPriceCents===0:Number(Se)===0)?e.jsx("span",{className:"w-14 shrink-0 text-right text-xs font-medium text-emerald-700 max-lg:w-12 max-lg:text-3xs dark:text-emerald-300",children:"Included"}):null]},x.id)})}),!Qe&&Me&&wr?e.jsx(kn,{}):null,!Qe&&De.length>0?e.jsxs("details",{className:"group mt-3","data-testid":"products-nonqualifying-labs",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-content-secondary hover:text-content-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(qi,{className:"size-3.5 shrink-0 transition-transform group-open:rotate-90","aria-hidden":!0}),Me?De.length===1?"Why 1 other lab does not qualify":`Why ${De.length} other labs do not qualify`:De.length===1?"1 other lab needs network approval":`${De.length} other labs need network approval`]}),e.jsx("div",{className:"mt-2 divide-y divide-border rounded-xl border border-subtle bg-surface-sunken",children:De.map(x=>{var _e;const T=Tr(x.id),Ce=(T==null?void 0:T.status)==="pending",Se=(T==null?void 0:T.status)==="declined",G=(T==null?void 0:T.status)==="stale";return e.jsx("div",{className:"px-3 py-2.5 text-xs",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-content-primary",children:x.name||"Lab"}),e.jsx("p",{className:"mt-0.5 text-content-tertiary",children:x.needsNetworkApproval?`Not on ${a}'s approved lab list`:Sl((_e=x.coverage)==null?void 0:_e.missing)}),Ce?e.jsx("p",{className:"mt-0.5 font-medium text-[var(--status-warning-text)]",children:"Review requested — waiting on the provider network."}):null,G?e.jsx("p",{className:"mt-0.5 text-content-tertiary",children:"The panel or protocol changed. Ask for approval again."}):null,Se?e.jsxs("p",{className:"mt-0.5 text-content-tertiary",children:[e.jsx("span",{className:"font-medium text-content-secondary",children:"Provider network reply:"})," ",T.reply||"The request was declined."]}):null]}),St&&!Ce?e.jsx(O,{type:"button",variant:"outline",size:"sm",className:"shrink-0",disabled:gs===x.id,onClick:()=>qr(x),"data-testid":`button-products-request-lab-review-${x.id}`,children:gs===x.id?"Sending...":Se||G?"Ask again":x.needsNetworkApproval?"Ask for approval":"Ask for review"}):null]})},x.id)})})]}):null]})}function Wr(){return!ot||n.freeVisitEnabled!==!0?null:e.jsxs("div",{className:"mt-3 grid gap-2 border-t border-subtle pt-3 max-lg:mt-2 max-lg:gap-1.5 max-lg:pt-2 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Included visits"}),e.jsx(ne,{type:"text",inputMode:"numeric",value:n.freeVisitCount,onChange:a=>A("freeVisitCount",a.target.value.replace(/[^0-9]/g,"")),className:"h-9",placeholder:"Enter count"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Expiration days"}
6),e.jsx(ne,{type:"text",inputMode:"numeric",value:n.freeVisitExpiration,onChange:a=>A("freeVisitExpiration",a.target.value.replace(/[^0-9]/g,"")),className:"h-9",placeholder:"Optional"})]})]})}const La=!!(t&&j&&!v&&(!u(t)||Y)),Es=La&&$,Ts=!!(j&&t),Kr=Number.isFinite(Number(t==null?void 0:t.formularyMappingCount))?Number(t.formularyMappingCount):0,Hr=Re&&t,qs=!!(t&&!v&&!u(t)),Ht=D(t==null?void 0:t.name),Ia=D(t==null?void 0:t.description),{thumbnailUrl:Yr}=wi(n),Ra=(Fe==null?void 0:Fe.previewUrl)||Yr,Yt=zs(n.displayImageBackgroundColor);return e.jsx(e.Fragment,{children:e.jsx(Ni,{open:s&&!r,onOpenChange:o,title:v?b?"Create package":"Edit package":"Edit product",description:v?"Update patient-facing package details.":"Update patient-facing product details.",contentClassName:"max-w-5xl !flex !min-h-0 !flex-col !overflow-hidden !max-h-[calc(100dvh-2rem)]",compactHeaderRow:!0,mobileFullHeight:!0,mobileStickyHeader:!0,mobileStickyFooter:!0,containChildOverlays:!0,preventOutsideDismiss:v||ds,headerRight:zt&&!v?e.jsxs("div",{className:"flex max-w-full items-center gap-1 rounded-md border border-slate-200/90 bg-slate-50/90 px-1.5 py-0.5 dark:border-slate-600 dark:bg-slate-900/60 sm:max-w-[min(100vw,20rem)]",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-3xs leading-tight text-content-tertiary",title:zt,children:zt}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-content-tertiary hover:text-slate-900 dark:hover:text-slate-100","aria-label":"Copy product ID","data-testid":H("button","products","copy-client-product-id"),onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(zt),L.success("ID copied")}catch{L.error("Could not copy ID")}})()},children:e.jsx(Ai,{className:"size-3"})})]}):null,headerClassName:"!space-y-0.5 !px-5 !pt-4 !pb-2 !pr-11 max-[1024px]:!px-3 max-[1024px]:!pt-3 max-[1024px]:!pb-2 max-[1024px]:!pr-11",bodyClassName:"!min-h-0 !flex-1 !overflow-y-auto overscroll-contain !p-0",footerClassName:"!px-5 !py-2.5 max-[1024px]:!px-3 max-[1024px]:!py-2 sm:!py-3",footer:e.jsxs("div",{className:"flex w-full items-center gap-2 max-lg:gap-1.5",children:[We?e.jsx(O,{type:"button",variant:"outline",size:"sm",className:"h-8 rounded-full px-3 text-xs max-lg:h-7 max-lg:px-2.5 max-lg:text-2xs",onClick:We,disabled:Ie,children:"Back"}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-2 max-lg:gap-1.5",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",className:"h-8 rounded-full px-3 text-xs max-lg:h-7 max-lg:px-2.5 max-lg:text-2xs",onClick:()=>o(!1),disabled:Ie,children:"Cancel"}),e.jsxs(O,{type:"submit",form:me,size:"sm",disabled:Ie,className:"h-8 rounded-full px-3 text-xs font-medium text-white max-lg:h-7 max-lg:px-2.5 max-lg:text-2xs",style:{backgroundColor:d},children:[Ie?e.jsx(ta,{size:"xs",className:"mr-1.5"}):null,"Save"]})]})]}),children:e.jsx("form",{id:me,className:Un,onSubmit:zn(Vr,{disabled:Ie}),children:e.jsx("div",{className:kl,children:Hr?e.jsx(Pi,{value:M,onValueChange:_,className:"flex flex-col",children:e.jsxs(_a,{className:M==="clinical-rules"?jl:tr,children:[v||Es||Ts||Ge||dt||ct?e.jsxs(Ci,{className:"mb-3 flex h-auto w-full justify-stretch rounded-lg border border-subtle bg-surface-raised p-1 max-lg:mb-2",indicatorClassName:"rounded-lg",children:[e.jsx(Xe,{value:ma,className:"flex-1 rounded-lg text-xs",children:"Overview"}),v?e.jsx(Xe,{value:"products",className:"flex-1 rounded-lg text-xs",children:"Products"}):null,Es?e.jsxs(Xe,{value:"formulary",className:"flex-1 rounded-lg text-xs",children:["Prescribing",e.jsx("span",{className:"ml-1.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-slate-200 px-1 text-3xs font-medium text-slate-700 dark:bg-slate-700 dark:text-slate-200",children:Kr})]}):null,Ts?e.jsx(Xe,{value:"forms",className:"flex-1 rounded-lg text-xs",children:"Forms"}):null,Ge?e.jsx(Xe,{value:"refill-reminder",className:"flex-1 rounded-lg text-xs","data-testid":H("tab","products","refill-reminder"),children:"Refill reminders"}):null,dt?e.jsx(Xe,{value:"clinical-rules",className:"flex-1 rounded-lg text-xs","data-testid":H("tab","products","clinical-rules"),children:"Clinical rules"}):null,ct?e.jsx(Xe,{value:"checkout",className:"flex-1 rounded-lg text-xs","data-testid":H("tab","products","checkout-summary"),children:"Order summary"}):null]}):null,e.jsxs("div",{ref:vs,className:"min-w-0",style:da?{minHeight:da}:void 0,children:[e.jsxs(Ze,{value:ma,className:"mt-0 space-y-3 max-lg:space-y-2",children:[e.jsxs("div",{className:"grid gap-3 max-lg:gap-2 md:grid-cols-[12rem_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsx(Si,{onDrop:(a,i)=>{if(i.length>0){L.error("Invalid file. Please upload a JPG, PNG, or WEBP under 10MB.");return}Rs(a[0]||null)},accept:ir,maxFiles:1,maxSize:rr,noClick:!0,noKeyboard:!0,children:({getRootProps:a,getInputProps:i,open:l})=>e.jsxs("div",{...a(),className:"space-y-2",children:[e.jsx("input",{...i()}),e.jsx("button",{type:"button",onClick:l,className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-xl border border-dashed border-default bg-surface-sunken",style:Yt?{backgroundColor:Yt}:void 0,"aria-label":v?"Upload package image":"Upload product image","data-testid":H("dropzone","products","detail-image"),children:Ra?e.jsx("img",{src:Ra,alt:n.displayName||(v?"Package":"Product"),className:"h-full w-full object-contain",loading:"lazy",decoding:"async"}):e.jsx(Li,{className:"size-8 text-slate-400 max-lg:size-6"})}),e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:l,className:"h-8 w-full rounded-full text-xs max-lg:h-7 max-lg:text-2xs",children:"Upload image"})]})}),e.jsxs("div",{className:"rounded-xl bg-surface-sunken px-3 py-2 max-lg:px-2 max-lg:py-1.5",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-content-secondary",children:"Image background"}),e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dar
6k:text-slate-500 dark:hover:text-slate-300","aria-label":"Image background help",children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:"Shown behind the product image in the patient storefront. Leave blank for the default."})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"relative size-8 shrink-0 cursor-pointer overflow-hidden rounded-full border border-subtle shadow-sm",style:{backgroundColor:Yt||"#ffffff"},title:"Pick image background color",children:e.jsx("input",{type:"color",value:Yt||"#ffffff",onChange:a=>A("displayImageBackgroundColor",a.target.value),className:"absolute inset-0 h-full w-full cursor-pointer opacity-0","aria-label":v?"Package image background color":"Product image background color","data-testid":H("input","products","detail-image-background-color")})}),e.jsx(ne,{value:n.displayImageBackgroundColor||"",onChange:a=>A("displayImageBackgroundColor",a.target.value),placeholder:"#ffffff",className:"h-8 flex-1 text-xs"}),n.displayImageBackgroundColor?e.jsx(O,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("displayImageBackgroundColor",""),className:"h-8 shrink-0 rounded-full px-2 text-xs text-content-tertiary hover:text-slate-700",children:"Clear"}):null]})]}),e.jsxs("label",{className:"flex items-center gap-3 rounded-xl bg-surface-sunken px-3 py-2 max-lg:gap-2 max-lg:px-2 max-lg:py-1.5",children:[e.jsx(mt,{checked:n.catalogActive,onCheckedChange:a=>{A("catalogActive",a),a||A("showPatient",!1)},className:"data-[state=checked]:bg-[var(--switch-checked)]",style:{"--switch-checked":d},"aria-label":v?"Package active":"Product active"}),e.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:"Active"})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-surface-sunken px-3 py-2 max-lg:gap-2 max-lg:px-2 max-lg:py-1.5",children:[e.jsx(Rt,{checked:n.catalogActive&&n.showPatient!==!1,onCheckedChange:a=>A("showPatient",a===!0),disabled:!n.catalogActive,className:"mt-0.5 size-5 rounded-[5px] border-default data-[state=checked]:border-transparent data-[state=checked]:bg-[var(--checkbox-checked)] data-[state=checked]:text-white",style:{"--checkbox-checked":d},"aria-label":v?"Show package on storefront":"Show product on storefront"}),e.jsx("span",{className:"min-w-0",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-slate-700 dark:text-slate-300",children:["Show on storefront",e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300","aria-label":"Storefront and dashboard visibility help",onClick:a=>a.preventDefault(),children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:"Storefront makes this product available in Products. Products cannot be added with Dashboard HTML; use Send to Patient to create a patient Dashboard offer."})]})})]})})]}),ye?e.jsxs("label",{className:"flex items-start gap-3 rounded-xl bg-surface-sunken px-3 py-2 max-lg:gap-2 max-lg:px-2 max-lg:py-1.5",children:[e.jsx(Rt,{checked:n.showSupplyDetailsOnStorefront===!0,onCheckedChange:a=>A("showSupplyDetailsOnStorefront",a===!0),disabled:!n.catalogActive||n.showPatient===!1,className:"mt-0.5 size-5 rounded-[5px] border-default data-[state=checked]:border-transparent data-[state=checked]:bg-[var(--checkbox-checked)] data-[state=checked]:text-white",style:{"--checkbox-checked":d},"aria-label":"Show supply details on storefront"}),e.jsx("span",{className:"min-w-0",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-slate-700 dark:text-slate-300",children:["Show supply details on storefront",e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dar
6k:text-slate-500 dark:hover:text-slate-300","aria-label":"Supply details on storefront help",onClick:a=>a.preventDefault(),children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:"When on, month supply and quantity always appear as capsules on the patient product tile. When off, they still appear automatically if month supply is greater than one month or fill quantity is set."})]})})]})})]}):null]}),e.jsxs("div",{className:"space-y-2.5 max-lg:space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx("label",{className:"block text-xs font-medium text-content-secondary",children:"Display name"}),qs&&Ht?e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300","aria-label":"Show provider network product name",children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-xs text-xs",children:Ht})]})}):null]}),e.jsx(ne,{value:n.displayName,onChange:a=>A("displayName",a.target.value),className:"h-9"}),qs&&Ht?e.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1 text-2xs text-content-tertiary",children:[e.jsxs("span",{className:"truncate",children:["Provider network name: ",e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-300",children:Ht})]}),R?e.jsx("button",{type:"button",onClick:()=>be==null?void 0:be(t),className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:text-slate-500 dark:hover:bg-slate-700 dark:hover:text-slate-200","aria-label":"Change provider network product","data-testid":"button-products-change-source-open",children:e.jsx(Ua,{className:"size-3"})}):null]}):null]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx("label",{className:"block text-xs font-medium text-content-secondary",children:"Display description"}),qs&&Ia?e.jsx(et,{delayDuration:150,children:e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300","aria-label":"Show provider network product description",children:e.jsx(qe,{className:"size-3.5"})})}),e.jsx(at,{side:"top",className:"max-w-sm text-xs",children:Ia})]})}):null]}),e.jsx(It,{value:n.displayDescription,onChange:a=>A("displayDescription",a.target.value),className:"min-h-28"})]}),e.jsxs("div",{className:"grid gap-3 max-lg:gap-2 sm:grid-cols-2",children:[P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(Ve,{info:"Patient-facing product price.",children:"Price"}),e.jsx(ne,{type:"text",inputMode:"decimal",value:n.customerPrice,onChange:a=>A("customerPrice",a.target.value.replace(/[^0-9.]/g,"")),className:"h-9"})]}),e.jsxs("div",{children:[e.jsx(Ve,{info:"Defaults to $0 when not set.",children:"Assessment price"}),e.jsx(ne,{type:"text",inputMode:"decimal",placeholder:"0",value:n.syncVisitPrice,onChange:a=>A("syncVisitPrice",a.target.value.replace(/[^0-9.]/g,"")),className:"h-9"})]}),Ut?e.jsxs("div",{children:[e.jsx(Ve,{info:"Defaults to the client default when not set.",children:"Shipping price"}),e.jsx(ne,{type:"text",inputMode:"decimal",placeholder:"0.00",value:n.shippingPrice,onChange:a=>A("shippingPrice",a.target.value.replace(/[^0-9.]/g,"")),className:"h-9"})]}):null]}):null,ye&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx(Ve,{className:"mb-0",info:"Stored as product metadata. Choose whether this product's supply is counted in months or weeks.",children:"Supply"}),e.jsx("div",{role:"tablist","aria-label":"Supply unit",className:"inline-flex rounded-md border border-subtle bg-surface-sunken p-0.5",children:[{unit:Xi,label:"Months"},{unit:Ks,label:"Weeks"}].map(({unit:a,label:i})=>{const l=Hs(n.supplyUnit)===a;return e.jsx("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>A("supplyUnit",a),className:q("rounded px-2 py-0.5 text-2xs font-medium transition-colors",l?"bg-surface-raised text-content-primary shadow-sm":"text-content-tertiary hover:text-slate-700 dark:hover:text-slate-200"),children:i},a)})})]}),Hs(n.supplyUnit)===Ks?e.jsx(ne,{type:"text",inputMode:"numeric",placeholder:"e.g. 12","aria-label":"Week supply",value:n.quantityWeeks,onChange:a=>A("quantityWeeks",a.target.value.replace(/[^0-9]/g,"")),className:"h-9"}):e.jsx(ne,{type:"text",inputMode:"numeric",placeholder:"1","aria-label":"Month supply",value:n.quantityMonths,onChange:a=>A("quantityMonths",a.target.value.replace(/[^0-9]/g,"")),className:"h-9"})]}),ye&&e.jsxs("div",{children:[e.jsx(Ve,{info:"Pharmacy fill quantity; pre-fills prescriptions but providers can edit.",children:"Quantity"}),e.jsx(ne,{type:"text",inputMode:"numeric",placeholder:"e.g. 42",value:n.prescriptionFillQuantity,onChange:a=>A("prescriptionFillQuantity",a.target.value.replace(/[^0-9]/g,"")),className:"h-9"})]}),ye&&e.jsxs("div",{children:[e.jsx(Ve,{info:"Number of refills; pre-fills prescriptions but providers can edit. Leave blank to use the pharmacy default.",children:"Refills"}),e.jsx(ne,{type:"text",inputMode:"numeric",placeholder:"e.g. 2",value:n.prescriptionRefills,onChange:a=>A("prescriptionRefills",a.target.value.replace(/[^0-9]/g,"")),className:"h-9"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-content-secondary max-lg:mb-1 max-lg:text-2xs",children:"Categories"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 max-lg:gap-1",children:N.length>0?N.map(a=>{const i=n.displayCategoryIds.includes(a.id);return e.jsx("button",{type:"button",onClick:()=>_r(a.id),className:Zi(i),style:i?{backgroundColor:d,borderColor:d}:void 0,"aria-pressed":i,children:a.name||"Category"},a.id)}):e.jsx("span",{className:"text-xs text-content-tertiary max-lg:text-2xs",children:"No categories available."})})]})]})]}),bs?e.jsx(Dn,{form:n,updateField:A,accentColor:d,panelClassName:ze}):null,v?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`${me}-package-sync`,className:q("flex items-start gap-3 max-lg:gap-2",ze),children:[e.jsx(mt,{id:`${me}-package-sync`,checked:n.requiresSyncVisitOverride===!0,onCheckedChange:a=>A("requiresSyncVisitOverride",a),className:"mt-0.5 data-[state=checked]:bg-[var(--switch-checked)]",style:{"--switch-checked":d},"aria-label":"Add a package sync visit requirement"}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:[e.jsx(za,{className:"size-3.5 shrink-0 text-content-tertiary"}),"Add a package sync visit requirement"]}),e.jsx("span",{className:"mt-1 block text-xs text-content-tertiary max-lg:mt-0.5 max-lg:text-3xs max-lg:leading-snug",children:"Included products’ sync visit requirements take precedence. This setting can only add a requirement."}),e.jsx("span",{className:"mt-1 block text-2xs font-medium text-content-tertiary",children:Ns?"Included-product requirements apply even when this 
6setting is off.":n.requiresSyncVisitOverride===!0?"Required for the package audience selected below.":"No package sync visit requirement added."})]})]}),Ns?e.jsxs("div",{className:"space-y-1 text-xs leading-relaxed text-muted-foreground","aria-live":"polite",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Sync visit required by included products"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4",children:ya.map(a=>e.jsx("li",{className:"break-words",children:a.displayName||a.name||"Untitled product"},ue(a)))}),e.jsx("p",{children:"Each product’s own audience still applies. The package audience cannot waive these requirements."})]}):null,n.requiresSyncVisitOverride===!0?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ea,{htmlFor:`${me}-sync-audience`,children:"Additional package requirement applies to"}),e.jsxs(Vs,{value:n.syncVisitAudience||"all",onValueChange:a=>A("syncVisitAudience",a),children:[e.jsx($s,{id:`${me}-sync-audience`,"aria-describedby":`${me}-sync-audience-help`,children:e.jsx(Bs,{})}),e.jsxs(Ws,{children:[e.jsx(Te,{value:"all",children:"All"}),e.jsx(Te,{value:"first_time_patient",children:"First-time patients"}),e.jsx(Te,{value:"first_purchase",children:"First purchase"})]})]}),e.jsx("p",{id:`${me}-sync-audience-help`,className:"text-xs leading-relaxed text-muted-foreground",children:n.syncVisitAudience==="first_time_patient"?"Patients with no completed purchase with this client.":n.syncVisitAudience==="first_purchase"?"Patients with no completed purchase of this package.":"Every purchase requires a live assessment."})]}):null,Vt?e.jsx("div",{className:ze,children:e.jsx(Jn,{products:Ir,onProductEdit:ee?a=>ee(a,{focusSection:"labs"}):void 0})}):null]}):ot||ja||Bt||va?e.jsxs("div",{className:"space-y-2",children:[ot?e.jsxs("div",{className:ze,children:[e.jsxs("div",{className:"flex items-start gap-3 max-lg:gap-2",children:[e.jsx(mt,{checked:n.freeVisitEnabled===!0,onCheckedChange:a=>A("freeVisitEnabled",a),className:"mt-0.5 data-[state=checked]:bg-[var(--switch-checked)]",style:{"--switch-checked":d},"aria-label":"Offer included visits"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-semibold text-content-primary max-lg:text-xs",children:"Offer included visits"}),e.jsx("span",{className:"mt-1 block text-xs text-content-tertiary max-lg:mt-0.5 max-lg:text-3xs max-lg:leading-snug",children:"Add included visit redemptions to this product purchase."})]})]}),Wr()]}):null,Bt?e.jsxs("label",{className:q("flex items-start gap-3 max-lg:gap-2",ze,(Ae||K)&&"opacity-80"),children:[e.jsx(mt,{checked:ka||K,disabled:Ae||K,onCheckedChange:a=>A("requiresSyncVisitOverride",a),className:"mt-0.5 data-[state=checked]:bg-[var(--switch-checked)]",style:{"--switch-checked":d},"aria-label":"Requires sync visit for this product"}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:[e.jsx(za,{className:"size-3.5 shrink-0 text-content-tertiary"}),"Requires sync visit"]}),e.jsx("span",{className:"mt-1 block text-xs text-content-tertiary max-lg:mt-0.5 max-lg:text-3xs max-lg:leading-snug",children:Ae?"Required by the provider network.":K?"Required by lab-first consultation.":"Require a live assessment before this product can be completed."})]})]}):null,Bt&&(ka||K)?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ea,{htmlFor:`${me}-sync-audience`,children:"Require sync visit for"}),e.jsxs(Vs,{value:Ae||K?"all":n.syncVisitAudience||"all",disabled:Ae||K,onValueChange:a=>A("syncVisitAudience",a),children:[e.jsx($s,{id:`${me}-sync-audience`,"aria-describedby":`${me}-sync-audience-help`,children:e.jsx(Bs,{})}),e.jsxs(Ws,{children:[e.jsx(Te,{value:"all",children:"All"}),e.jsx(Te,{value:"first_time_patient",children:"First-time patients"}),e.jsx(Te,{value:"first_purchase",children:"First purchase"})]})]}),e.jsx("p",{id:`${me}-sync-audience-help`,className:"text-xs leading-relaxed text-muted-foreground",children:Ae?"Required by the provider network for all patients.":K?"Required by lab-first consultation for all patients.":n.syncVisitAudience==="first_time_patient"?"Patients with no completed purchase with this client.":n.syncVisitAudience==="first_purchase"?"Patients with no completed purchase of this product.":"Every purchase requires a live assessment."})]}):null,va?e.jsxs("div",{className:q("flex items-start gap-3",ze,"opacity-80"),children:[e.jsx(Ii,{className:"mt-0.5 size-4 shrink-0 text-content-tertiary"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-content-primary",children:"Requires DEA-licensed provider"}),e.jsx("span",{className:"mt-1 block text-xs text-content-tertiary",children:"Required by the provider network. Booking, assignment, and claim allow only providers with a DEA on file."})]})]}):null,ja&&!Pe?e.jsx("div",{className:q("flex items-start gap-3 max-lg:gap-2",ze,"opacity-80"),children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:[e.jsx(Va,{className:"size-3.5 shrink-0 text-content-tertiary"}),"Labs required"]}),e.jsxs("span",{className:"mt-1 block text-xs text-content-tertiary max-lg:mt-0.5 max-lg:text-3xs max-lg:leading-snug",children:[Je?"Required by the provider network.":"This product requires a lab before it can be prescribed."," ",wa===1?"1 approved lab option.":`${wa} approved lab options.`]}),Sa()]})}):null,Pe?e.jsxs("div",{ref:ha,tabIndex:-1,"aria-label":"Product lab requirements",className:q(ze,"focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring"),children:[e.jsxs("div",{className:q("flex items-start gap-3 max-lg:gap-2",(Ps||K)&&"opacity-80"),children:[e.jsx(mt,{checked:Pt||K,disabled:Ps||K,onCheckedChange:Fr,className:"mt-0.5 data-[state=checked]:bg-[var(--switch-checked)]",style:{"--switch-checked":d},"aria-label":"Requires labs for this product"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-content-primary max-lg:text-xs",children:[e.jsx(Va,{className:"size-3.5 shrink-0 text-content-tertiary"}),"Requires labs"]}),e.jsx("span",{className:"mt-1 block text-xs text-content-tertiary max-lg:mt-0.5 max-lg:text-3xs max-lg:leading-snug",children:Je?"Required by the provider network.":v&&Vt?"Required by an included product.":K?"Required by lab-first consultation.":"Select accepted labs and patient prices."})]})]}
6),Br(),Wt&&(Cs||K)?e.jsx(sn,{value:Is,onChange:a=>{F(i=>({...i,labFirstWorkflow:a,...a.enabled===!0?{requiresSyncVisitOverride:!0}:{}}))},accentColor:d,className:"mt-3 border-t border-subtle pt-3"}):null,Sa()]}):null]}):null,S?e.jsx(on,{selectedStates:n.excludedStates,onChange:a=>A("excludedStates",a),accentColor:d,testScope:v?"packages-client":"products-client",lockedStates:(t==null?void 0:t.inheritedExcludedStates)||[],lockedOwnerLabel:(t==null?void 0:t.providerNetworkName)||"your provider network"}):null]}),v?e.jsxs(Ze,{value:"products",className:"mt-0 space-y-2.5 max-lg:space-y-2",children:[e.jsx(Mi,{id:"package-included-products",title:"Included products",accentColor:d,modal:!0,persistFilters:!1,countLabel:`${ba.length} of ${pe.length} products · ${W.length} selected`,tooltipDescription:"Selected products appear first. Select at least two items; provider-network products must belong to the same network. Client-owned products can be included alongside them.",search:{value:nt,onChange:lt,placeholder:"Search products"},filters:[{id:"selection",defaultLabel:"All selections",activeFilters:we,onFilterChange:Ye,filters:[{id:"selected",label:"Selected"},{id:"unselected",label:"Not selected"}]},{id:"type",defaultLabel:"All types",activeFilters:ft,onFilterChange:us,filters:Sr},{id:"owner",defaultLabel:"All owners",activeFilters:gt,onFilterChange:ms,filters:Lr,searchable:!0}],hasActiveFilters:Nt,onClearFilters:ga,headerExtra:e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-content-secondary tabular-nums",children:[e.jsxs("span",{children:["Products: ",Zt(Na)]}),e.jsxs("span",{children:["Package: ",Zt(Pa)]}),e.jsxs("span",{children:["Difference: ",Zt(-Ar)]}),Rr?e.jsx("span",{children:"Telehealth visit required"}):null,$t?e.jsx("span",{children:"Labs required"}):null]}),rows:ba,rowKey:ue,rowTestId:a=>H("row","package-products",ue(a)),rowClassName:a=>n.includedProductIds.includes(ue(a))?"bg-surface-sunken":"",tableLabel:"Products available for this package",maxHeight:xr,stickyLastColumn:!0,columns:[{id:"selection",header:e.jsx("span",{className:"sr-only",children:"Include product"}),width:44,minWidth:44,fixedWidth:!0,renderCell:a=>{const i=ue(a),l=n.includedProductIds.includes(i);return e.jsx(Rt,{checked:l,disabled:!i||!!Kt(a),onCheckedChange:()=>Ur(i),"aria-label":`${l?"Remove":"Include"} ${a.displayName||a.name||"Untitled"}`})}},{id:"product",header:"Product",minWidth:220,renderCell:a=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium text-content-primary",children:a.displayName||a.name||"Untitled"}),e.jsx("p",{className:"text-xs text-content-tertiary",children:Xs(a)}),Kt(a)?e.jsx("p",{className:"text-xs text-status-warning",children:Kt(a)}):null]})},{id:"owner",header:"Owner",minWidth:140,renderCell:a=>e.jsx("span",{className:"text-content-secondary",children:rs(a)})},{id:"price",header:"Price",minWidth:100,align:"right",renderCell:a=>e.jsx("span",{className:"tabular-nums",children:Zt(a.customerPrice)})},{id:"formulary",header:"Formulary",minWidth:160,renderCell:a=>{const i=Rl(a);return e.jsxs("div",{children:[e.jsx("p",{className:"text-content-secondary",children:i.label}),i.detail?e.jsx("p",{className:"text-xs text-content-tertiary",children:i.detail}):null]})}},{id:"requirements",header:"Needs",minWidth:120,renderCell:a=>[cr(a)&&"Telehealth visit",is(a)&&"Labs"].filter(Boolean).join(", ")||"None"},{id:"actions",header:e.jsx("span",{className:"sr-only",children:"Actions"}),width:52,minWidth:52,fixedWidth:!0,renderCell:a=>e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>ee==null?void 0:ee(a),"aria-label":`Edit ${a.displayName||a.name||"Untitled"}`,disabled:!ee,children:e.jsx(Ua,{className:"size-3.5"})})}],emptyMessage:e.jsx(Et,{reason:Nt?"filtered":"empty",title:Nt?"No matching products":"No products available",description:Nt?"Try another search or clear the filters.":"Add products to your client catalog before including them in a package.",action:Nt?{onClick:ga}:null})}),W.length===1?e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-xs text-status-warning",children:[e.jsx(Ri,{className:"size-3.5 shrink-0"}
6),"Select at least one more product to create a valid package."]}):null]}):null,Es?e.jsx(Ze,{value:"formulary",className:"mt-0 space-y-3 max-lg:space-y-2",children:La?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Directions for use"}),e.jsx(It,{value:n.prescriptionDirections,onChange:a=>A("prescriptionDirections",a.target.value),className:"min-h-24",placeholder:"e.g. Inject 20 units (0.6mg) subcutaneously Monday-Friday."}),e.jsx("p",{className:"mt-1 text-xs text-content-tertiary max-lg:text-2xs max-lg:leading-snug",children:"Pre-fills the directions on the prescription when a provider prescribes this product. Providers can still edit them, and a pharmacy-specific direction set from the formulary pairing takes precedence."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Note for provider network"}),e.jsx(It,{value:n.clientPrescribingNote,onChange:a=>A("clientPrescribingNote",a.target.value),className:"min-h-20",placeholder:"Optional note for the provider network during prescribing"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Clinical difference statement"}),e.jsx(It,{value:n.clinicalDifferenceStatement,onChange:a=>A("clinicalDifferenceStatement",a.target.value),className:"min-h-28",placeholder:"Optional clinical differentiation statement shown to providers during prescribing"}),e.jsx("p",{className:"mt-1 text-xs text-content-tertiary max-lg:text-2xs max-lg:leading-snug",children:"Used as the starting statement when this product is prescribed through Vios."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-content-secondary",children:"Medical necessity statement"}),e.jsx(It,{value:n.dirxMedicalNecessityStatement,onChange:a=>A("dirxMedicalNecessityStatement",a.target.value),className:"min-h-28",placeholder:"Optional medical-necessity statement shown to providers during DiRx prescribing"}),e.jsx("p",{className:"mt-1 text-xs text-content-tertiary max-lg:text-2xs max-lg:leading-snug",children:"Used as the starting statement when this product is prescribed through DiRx. Kept separate from the clinical difference statement above."})]}),e.jsx(El,{product:t,clientId:j,canEdit:fe,prescribeByProductEnabled:Y,focusRef:xa,accentColor:d,onMappingsSnapshot:oe})]}):e.jsx("p",{className:"text-sm text-content-secondary max-lg:text-xs",children:"Direct-sale client products do not use provider-network formulary mapping."})}):null,Ts?e.jsx(Ze,{value:"forms",className:"mt-0",children:e.jsx(rn,{clientId:j,providerNetworkIds:v?ws:void 0,catalogItem:t,catalogItemType:v?"package":"product",allowIntakeCustomization:!1,relatedItems:v?W:void 0,categoryIds:n.displayCategoryIds,clientName:z,clientAccentColor:d,getProviderNetworkLabel:a=>{if(!v)return(m==null?void 0:m(t))||"Provider network";const i=W.find(l=>Be(l)===a);return i?rs(i):"Provider network"},getProviderNetworkColor:a=>{if(!v)return(k==null?void 0:k(t))||(t==null?void 0:t.providerNetworkAccentColor)||d;const i=W.find(l=>Be(l)===a);return(i==null?void 0:i.providerNetworkAccentColor)||d}})}):null,Ge?e.jsx(Ze,{value:"refill-reminder",className:"mt-0",children:e.jsx(Yn,{form:n.refillReminder||Wa(),onChange:a=>{Oe(!0),A("refillReminder",a)},accentColor:d,disabled:!P})}):null,dt?e.jsx(Ze,{value:"clinical-rules",className:"mt-0",children:e.jsx(Qn,{windows:pa,prices:n.clinicalRulesWindowPrices,onPriceChange:(a,i)=>F(l=>({...l,clinicalRulesWindowPrices:{...l.clinicalRulesWindowPrices||{},[a]:i}})),defaultPrice:n.customerPrice,subscriptionEnabled:n.subscriptionEnabled===!0,canEditPricing:P,accentColor:d})}):null,ct?e.jsx(Ze,{value:"checkout",className:"mt-0",children:e.jsx(vl,{form:n,onFormChange:a=>F(i=>({...i,...a})),branding:ce,experience:Ke,accentColor:d,productDisplayName:D(n.displayName)||(t==null?void 0:t.displayName)||(t==null?void 0:t.name)||"Product",productDescription:D(n.displayDescription)||(t==null?void 0:t.displayDescription)||(t==null?void 0:t.description)||"",productImageUrl:n.displayImageUrl||(t==null?void 0:t.displayImageUrl)||(t==null?void 0:t.displayThumbnailUrl)||"",customerPrice:n.customerPrice??(t==null?void 0:t.customerPrice),shippingPrice:n.shippingPrice??(t==null?void 0:t.shippingPrice),catalogProduct:{requiresLabs:n.requiresLabs===!0,requiresSyncVisit:n.requiresSyncVisit===!0,syncVisitPrice:n.syncVisitPrice??(t==null?void 0:t.syncVisitPrice),providerNetworkId:t==null?void 0:t.providerNetworkId,sourceProductId:t==null?void 0:t.sourceProductId,isDuplicate:t==null?void 0:t.isDuplicate,type:t==null?void 0:t.type,itemType:t==null?void 0:t.itemType,addOns:n.addOns??(t==null?void 0:t.addOns)}})}):null]})]})}):e.jsx(_a,{className:tr,children:e.jsxs("div",{className:"grid gap-3 max-lg:gap-2 md:grid-cols-[12rem_minmax(0,1fr)]",children:[e.jsx("div",{className:"aspect-square rounded-xl border border-dashed border-default bg-surface-sunken"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-9 rounded-md bg-slate-100 dar
6k:bg-slate-800"}),e.jsx("div",{className:"h-28 rounded-md bg-slate-100 dark:bg-slate-800"}),e.jsx("div",{className:"h-9 rounded-md bg-slate-100 dark:bg-slate-800"})]})]})})})})})})}export{Hc 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.