@everfur/sdk 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -26
- package/care/package.json +8 -0
- package/dist/{Chat.d-uETscjrL.d.ts → Chat.d-Bz4iJ7d2.d.ts} +1 -1
- package/dist/{Chat.d-BYY1U61e.d.cts → Chat.d-C2ddC2u7.d.cts} +1 -1
- package/dist/{DepthViews.d-BsZ73mzL.d.ts → DepthViews.d-C6-Kzs6H.d.ts} +1 -1
- package/dist/{DepthViews.d-D_Qp4glO.d.cts → DepthViews.d-Chjs8H9V.d.cts} +1 -1
- package/dist/{DepthViews.d-DL8MP_kA.d.cts → DepthViews.d-pFL_ZBZT.d.cts} +1 -1
- package/dist/{DepthViews.d-B4SE5GUD.d.ts → DepthViews.d-qXt9OMgz.d.ts} +1 -1
- package/dist/{RecordsPage.d-CYotk2R9.d.cts → RecordsPage.d-Cmny6Q7g.d.cts} +2 -2
- package/dist/{RecordsPage.d-D4gP4leq.d.ts → RecordsPage.d-sNRolVdy.d.ts} +2 -2
- package/dist/animations/index.d.cts +5 -5
- package/dist/animations/index.d.ts +5 -5
- package/dist/{appStateLifecycle.d-DJXdDOJY.d.cts → appStateLifecycle.d-Bt70TQog.d.cts} +7 -7
- package/dist/{appStateLifecycle.d-CXJzBS3c.d.ts → appStateLifecycle.d-Jdg9_PFt.d.ts} +7 -7
- package/dist/{attachments.d-B8kOCb6q.d.cts → attachments.d-BVp3r6Ms.d.cts} +5 -5
- package/dist/{attachments.d-C61URT8r.d.cts → attachments.d-CF4_n-DZ.d.cts} +2 -2
- package/dist/{attachments.d-BTIGzXWD.d.ts → attachments.d-DnSCMjH0.d.ts} +5 -5
- package/dist/{attachments.d-BgatKf7d.d.ts → attachments.d-DsUZpMad.d.ts} +2 -2
- package/dist/{bookingCopy.d-B-bSYgqS.d.cts → bookingCopy.d-BHqE9Ozq.d.cts} +16 -16
- package/dist/{bookingCopy.d-JQW2SLM-.d.ts → bookingCopy.d-Ca4AQGZ7.d.ts} +16 -16
- package/dist/{branding.d-Bbc6p1XY.d.cts → branding.d-BFauULV6.d.cts} +1 -1
- package/dist/{branding.d-y6c0UwhE.d.ts → branding.d-DpNGEdDL.d.ts} +1 -1
- package/dist/care/index.cjs +3 -0
- package/dist/care/index.d.cts +434 -0
- package/dist/care/index.d.ts +434 -0
- package/dist/care/index.js +3 -0
- package/dist/{casesRepository.d-CVG2EXcg.d.cts → casesRepository.d-DFwD2kiS.d.cts} +1 -1
- package/dist/{casesRepository.d-CHEjzT4h.d.ts → casesRepository.d-VzxEyq2N.d.ts} +1 -1
- package/dist/chat/index.cjs +14 -13
- package/dist/chat/index.d.cts +13 -13
- package/dist/chat/index.d.ts +13 -13
- package/dist/chat/index.js +14 -13
- package/dist/chat/lite/index.cjs +14 -13
- package/dist/chat/lite/index.d.cts +13 -13
- package/dist/chat/lite/index.d.ts +13 -13
- package/dist/chat/lite/index.js +14 -13
- package/dist/chunk-Y3Q4GW47.js +31 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +10 -10
- package/dist/client/index.d.ts +10 -10
- package/dist/client/index.js +1 -1
- package/dist/{clinicBatch.d-DdlFy4pD.d.cts → clinicBatch.d-CLqaih2C.d.cts} +2 -2
- package/dist/{clinicBatch.d-oNwH_dbI.d.ts → clinicBatch.d-DXDIL1lC.d.ts} +2 -2
- package/dist/{config.d-Cy_hJBJG.d.cts → config.d-7bCXvOGn.d.cts} +1 -1
- package/dist/{config.d-DopRLD4f.d.ts → config.d-cqyvpzDb.d.ts} +1 -1
- package/dist/consent/index.d.cts +5 -5
- package/dist/consent/index.d.ts +5 -5
- package/dist/{context.d-C42juGn6.d.cts → context.d-BeRanUXQ.d.cts} +7 -7
- package/dist/{context.d-Ban-Hhqu.d.ts → context.d-DAnmDYGr.d.ts} +7 -7
- package/dist/{copy.d-BTS5l6Ri.d.cts → copy.d-BPqs8swm.d.cts} +2 -2
- package/dist/{copy.d-qdbygul9.d.ts → copy.d-CxFzeuvo.d.ts} +2 -2
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +17 -17
- package/dist/core/index.d.ts +17 -17
- package/dist/core/index.js +1 -1
- package/dist/{depth.d-BGkHm2Se.d.ts → depth.d-C6XbnFig.d.ts} +2 -2
- package/dist/{depth.d-BfVrhq9o.d.cts → depth.d-qHdXHDd-.d.cts} +2 -2
- package/dist/{entitlementRepository.d-npT7L_7_.d.cts → entitlementRepository.d-C6uTDswj.d.cts} +4 -4
- package/dist/{entitlementRepository.d-CjwqCyhS.d.ts → entitlementRepository.d-D_cc7g4l.d.ts} +4 -4
- package/dist/{focus.d-S0nq_k1A.d.ts → focus.d-DiWvQR2j.d.ts} +193 -21
- package/dist/{focus.d-DS7Ze1Pp.d.cts → focus.d-HSkMHd-i.d.cts} +193 -21
- package/dist/health-plan/index.cjs +261 -176
- package/dist/health-plan/index.d.cts +627 -19
- package/dist/health-plan/index.d.ts +627 -19
- package/dist/health-plan/index.js +261 -176
- package/dist/{idempotency.d-COIrwuCb.d.ts → idempotency.d-CF5AvlYp.d.ts} +18 -639
- package/dist/{idempotency.d-gfiN4Qnp.d.cts → idempotency.d-DrO2zEZO.d.cts} +18 -639
- package/dist/{identity.d-D76vXtkJ.d.cts → identity.d-84x0dV7-.d.cts} +1 -1
- package/dist/{identity.d-B3mFvvRq.d.ts → identity.d-BXztMVYM.d.ts} +1 -1
- package/dist/index.cjs +12 -11
- package/dist/index.d.cts +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +12 -11
- package/dist/{introEvents.d-3FLEemX3.d.cts → introEvents.d-Cwv72ER-.d.cts} +11 -11
- package/dist/{introEvents.d-BYnr37bd.d.ts → introEvents.d-DYU3znJs.d.ts} +11 -11
- package/dist/notifications/index.d.cts +4 -4
- package/dist/notifications/index.d.ts +4 -4
- package/dist/omsErrors.d-VF5tnr20.d.cts +633 -0
- package/dist/omsErrors.d-VF5tnr20.d.ts +633 -0
- package/dist/omsFields.d-BHntKIAH.d.cts +153 -0
- package/dist/omsFields.d-Cvfw8wWU.d.ts +153 -0
- package/dist/{optInView.d-DXRUGDiD.d.cts → optInView.d-4Hl4HbQh.d.cts} +3 -3
- package/dist/{optInView.d-BqFMcum4.d.ts → optInView.d-pq8tUTf6.d.ts} +3 -3
- package/dist/{parse.d-CY22hFxb.d.ts → parse.d-BJhhYfkv.d.ts} +1 -1
- package/dist/{parse.d-rvA_aRSO.d.cts → parse.d-D0v06qxx.d.cts} +1 -1
- package/dist/{pets.d-Cicz-aIO.d.ts → pets.d-1_CHpfgB.d.ts} +1 -1
- package/dist/{pets.d-RoHTZsaV.d.cts → pets.d-C4n-MDC4.d.cts} +1 -1
- package/dist/{petsRepository.d-DtAZf_Ja.d.ts → petsRepository.d-BuomdFjZ.d.ts} +1 -1
- package/dist/{petsRepository.d-BxMyt6Aj.d.cts → petsRepository.d-Dd95xh-M.d.cts} +1 -1
- package/dist/{ports.d-D7cjFUoL.d.cts → ports.d-Bf3tp7Pn.d.cts} +4 -4
- package/dist/{ports.d-DrgKa73F.d.ts → ports.d-ChZHFd-q.d.ts} +4 -4
- package/dist/{presentation.d-vy8kTGfR.d.cts → presentation.d-Bs8xQ4gD.d.cts} +4 -4
- package/dist/{presentation.d-vy8kTGfR.d.ts → presentation.d-Bs8xQ4gD.d.ts} +4 -4
- package/dist/records/depth/index.d.cts +9 -9
- package/dist/records/depth/index.d.ts +9 -9
- package/dist/records/index.cjs +11 -10
- package/dist/records/index.d.cts +24 -23
- package/dist/records/index.d.ts +24 -23
- package/dist/records/index.js +11 -10
- package/dist/{requestFunnel.d-BdQf53zs.d.cts → requestFunnel.d-CWI2pD3V.d.cts} +2 -2
- package/dist/{requestFunnel.d-B5y7Py8Z.d.ts → requestFunnel.d-DcQIAs45.d.ts} +2 -2
- package/dist/{resolve.d-CoQWUy1Y.d.cts → resolve.d-BTC3b6FW.d.cts} +1 -1
- package/dist/{resolve.d-CoQWUy1Y.d.ts → resolve.d-BTC3b6FW.d.ts} +1 -1
- package/dist/{runtimeTypes.d-r4Q5vASZ.d.cts → runtimeTypes.d-CIOVzjEK.d.cts} +6 -6
- package/dist/{runtimeTypes.d-D5EDgS3Y.d.ts → runtimeTypes.d-rbuONrIv.d.ts} +6 -6
- package/dist/{screenProps.d-v4a4kzxA.d.cts → screenProps.d-CFZe27oI.d.cts} +1 -1
- package/dist/{screenProps.d-KLCrP43b.d.ts → screenProps.d-yUA4k6yK.d.ts} +1 -1
- package/dist/server/events/index.cjs +2 -2
- package/dist/server/events/index.d.cts +49 -6
- package/dist/server/events/index.d.ts +49 -6
- package/dist/server/events/index.js +2 -2
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +1 -1
- package/dist/shop/index.cjs +6 -6
- package/dist/shop/index.d.cts +9 -8
- package/dist/shop/index.d.ts +9 -8
- package/dist/shop/index.js +6 -6
- package/dist/shop/orders-v2/index.d.cts +2 -2
- package/dist/shop/orders-v2/index.d.ts +2 -2
- package/dist/tabs/index.cjs +4 -4
- package/dist/tabs/index.d.cts +14 -14
- package/dist/tabs/index.d.ts +14 -14
- package/dist/tabs/index.js +4 -4
- package/dist/{tabsModel.d-B7QMug1u.d.ts → tabsModel.d-D9GWPFrL.d.cts} +1 -1
- package/dist/{tabsModel.d-B7QMug1u.d.cts → tabsModel.d-D9GWPFrL.d.ts} +1 -1
- package/dist/televet/booking/index.d.cts +6 -6
- package/dist/televet/booking/index.d.ts +6 -6
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +85 -2
- package/dist/testing/index.d.ts +85 -2
- package/dist/testing/index.js +1 -1
- package/dist/testing/rn/index.d.cts +10 -10
- package/dist/testing/rn/index.d.ts +10 -10
- package/dist/testing/web/index.d.cts +10 -10
- package/dist/testing/web/index.d.ts +10 -10
- package/dist/texting/index.d.cts +6 -6
- package/dist/texting/index.d.ts +6 -6
- package/dist/{threadOptions.d-EFJaNBP1.d.cts → threadOptions.d-CRbFXnlq.d.cts} +66 -11
- package/dist/{threadOptions.d-GPJPprkn.d.cts → threadOptions.d-CW51PyVd.d.cts} +28 -1
- package/dist/{threadOptions.d-GPJPprkn.d.ts → threadOptions.d-CW51PyVd.d.ts} +28 -1
- package/dist/{threadOptions.d-B0folrKm.d.cts → threadOptions.d-U5YBUKM-.d.ts} +2 -2
- package/dist/{threadOptions.d-Crh_LiDe.d.ts → threadOptions.d-aK8FkszA.d.ts} +66 -11
- package/dist/{threadOptions.d-DTsJFkL-.d.ts → threadOptions.d-bEAFkIsC.d.cts} +2 -2
- package/dist/{timelineRows.d-DpSis9HR.d.ts → timelineRows.d-BbCLvjy1.d.ts} +1 -1
- package/dist/{timelineRows.d-6-Cw8xGd.d.cts → timelineRows.d-BvA_BoOe.d.cts} +1 -1
- package/dist/{typeStyle.d-B3Kdtjie.d.ts → typeStyle.d-B9Jo5mDX.d.ts} +1 -1
- package/dist/{typeStyle.d-DmlwyJq-.d.cts → typeStyle.d-Ckdh_S-t.d.cts} +1 -1
- package/dist/types.d-d3RdaeAA.d.cts +317 -0
- package/dist/types.d-d3RdaeAA.d.ts +317 -0
- package/dist/ui/index.cjs +68 -0
- package/dist/ui/index.d.cts +73 -0
- package/dist/ui/index.d.ts +73 -0
- package/dist/ui/index.js +68 -0
- package/dist/useHealthPlanSubscription.d-BN40CVK6.d.cts +756 -0
- package/dist/useHealthPlanSubscription.d-BYehTI7R.d.ts +756 -0
- package/dist/{usePresentation.d-CRG3Gaaq.d.ts → usePresentation.d-BfcyAEFt.d.ts} +66 -7
- package/dist/{usePresentation.d-C8rqY56C.d.cts → usePresentation.d-C39kKhoO.d.cts} +66 -7
- package/dist/{useRecordsDepth.d-DlRda5jp.d.ts → useRecordsDepth.d-B2ewVbRm.d.ts} +1 -1
- package/dist/{useRecordsDepth.d-BYk7m7gF.d.cts → useRecordsDepth.d-CKXAAHXI.d.cts} +1 -1
- package/dist/{view.d-DuIXHr08.d.ts → view.d-BnUDSQXz.d.ts} +3 -3
- package/dist/{view.d-B31M8rCG.d.cts → view.d-CbcJKNJj.d.cts} +1 -1
- package/dist/{view.d-B31M8rCG.d.ts → view.d-CbcJKNJj.d.ts} +1 -1
- package/dist/{view.d-CLpEHKOp.d.cts → view.d-DTNPjiZ1.d.cts} +3 -3
- package/dist/web/consent/index.d.cts +5 -5
- package/dist/web/consent/index.d.ts +5 -5
- package/dist/web/health-plan/index.cjs +335 -180
- package/dist/web/health-plan/index.d.cts +576 -19
- package/dist/web/health-plan/index.d.ts +576 -19
- package/dist/web/health-plan/index.js +297 -162
- package/dist/web/health-plan/styles.css +233 -0
- package/dist/web/health-plan/today/index.cjs +7 -0
- package/dist/web/health-plan/today/index.d.cts +15 -0
- package/dist/web/health-plan/today/index.d.ts +15 -0
- package/dist/web/health-plan/today/index.js +7 -0
- package/dist/web/index.cjs +36 -33
- package/dist/web/index.d.cts +60 -37
- package/dist/web/index.d.ts +60 -37
- package/dist/web/index.js +36 -33
- package/dist/web/intro/index.cjs +2 -2
- package/dist/web/intro/index.d.cts +8 -8
- package/dist/web/intro/index.d.ts +8 -8
- package/dist/web/intro/index.js +2 -2
- package/dist/web/notifications/index.d.cts +3 -3
- package/dist/web/notifications/index.d.ts +3 -3
- package/dist/web/records/depth/index.d.cts +9 -9
- package/dist/web/records/depth/index.d.ts +9 -9
- package/dist/web/records/index.cjs +1 -1
- package/dist/web/records/index.d.cts +11 -11
- package/dist/web/records/index.d.ts +11 -11
- package/dist/web/records/index.js +1 -1
- package/dist/web/records-sheet/index.cjs +13 -12
- package/dist/web/records-sheet/index.d.cts +13 -10
- package/dist/web/records-sheet/index.d.ts +13 -10
- package/dist/web/records-sheet/index.js +13 -12
- package/dist/web/shop/index.cjs +6 -6
- package/dist/web/shop/index.d.cts +8 -7
- package/dist/web/shop/index.d.ts +8 -7
- package/dist/web/shop/index.js +6 -6
- package/dist/web/shop/orders-v2/index.d.cts +1 -1
- package/dist/web/shop/orders-v2/index.d.ts +1 -1
- package/dist/web/televet/booking/index.cjs +1 -1
- package/dist/web/televet/booking/index.d.cts +6 -6
- package/dist/web/televet/booking/index.d.ts +6 -6
- package/dist/web/televet/booking/index.js +1 -1
- package/dist/web/texting/index.cjs +1 -1
- package/dist/web/texting/index.d.cts +6 -6
- package/dist/web/texting/index.d.ts +6 -6
- package/dist/web/texting/index.js +1 -1
- package/dist/web/ui/index.cjs +70 -0
- package/dist/web/ui/index.d.cts +78 -0
- package/dist/web/ui/index.d.ts +78 -0
- package/dist/web/ui/index.js +48 -0
- package/dist/web/ui/styles.css +244 -0
- package/package.json +71 -5
- package/ui/package.json +8 -0
- package/web/health-plan/today/native-blocked.cjs +12 -0
- package/web/health-plan/today/package.json +8 -0
- package/web/ui/native-blocked.cjs +12 -0
- package/web/ui/package.json +8 -0
- package/dist/useHealthPlanSubscription.d-DD30EkUR.d.ts +0 -205
- package/dist/useHealthPlanSubscription.d-DWrzUXf4.d.cts +0 -205
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The design's Care > Orders v2 page for the web shop, as `@everfur/sdk/web/shop/orders-v2` exports it. `EverfurShop` loads it
|
|
4
4
|
* by itself when `ordersDesign="v2"`; a host never needs to touch it.
|
|
5
5
|
*/
|
|
6
6
|
interface EverfurShopOrdersV2Page {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The design's Care > Orders v2 page for the web shop, as `@everfur/sdk/web/shop/orders-v2` exports it. `EverfurShop` loads it
|
|
4
4
|
* by itself when `ordersDesign="v2"`; a host never needs to touch it.
|
|
5
5
|
*/
|
|
6
6
|
interface EverfurShopOrdersV2Page {
|
|
@@ -186,7 +186,7 @@ return jsxRuntime.jsxs("section",{style:styles.screen,"aria-labelledby":titleId,
|
|
|
186
186
|
/* @__PURE__ */jsxRuntime.jsx("span",{"aria-hidden":"true",style:styles.stepNumber,children:String(i+1).padStart(2,"0")}),
|
|
187
187
|
/* @__PURE__ */jsxRuntime.jsx("span",{style:styles.stepText,children:step.trim()})]},step))})}),
|
|
188
188
|
/* @__PURE__ */jsxRuntime.jsxs("div",{style:styles.actions,children:[onAddToCalendar?/* @__PURE__ */jsxRuntime.jsx(TelevetButton,{label:calendarState==="saved"?TELEVET_BOOKING_COPY_WEB.booked.calendarAdded:TELEVET_BOOKING_COPY_WEB.addToCalendarCta,kind:"secondary",size:"lg",fullWidth:false,loading:calendarState==="saving",disabled:calendarState==="saving"||calendarState==="saved",onPress:()=>{addToCalendar()},testID:"televet-booked-calendar"}):null,
|
|
189
|
-
/* @__PURE__ */jsxRuntime.jsx(TelevetButton,{label:TELEVET_BOOKING_COPY_WEB.doneCta,kind:"primary",size:"lg",fullWidth:false,onPress:onDone,testID:"televet-booked-done"})]}),calendarState==="failed"?/* @__PURE__ */jsxRuntime.jsx("p",{role:"status",style:{...shared.failure,...styles.calendarNote},"data-testid":"televet-booked-calendar-failed",children:TELEVET_BOOKING_COPY_WEB.booked.calendarFailedBody}):null]})}function makeStyles2(theme){let{space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),rem=n=>`${String(n)}px`,cardInk=slots.card?.textColor===void 0?{}:{color:slots.card.textColor};return{screen:{display:"flex",flexDirection:"column",alignItems:"center",flex:"1 1 auto",minHeight:0,gap:rem(space.md),paddingTop:rem(space.xl),paddingBottom:rem(space.xl),boxSizing:"border-box",textAlign:"center"},avatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 6px ${look.surface}, 0 0 0 10px ${look.go}`,margin:rem(10),display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(40),lineHeight:"1"},title:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",30)),lineHeight:"1.1",letterSpacing:"-0.03em",textWrap:"balance",paddingTop:rem(space.md)},when:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},card:{width:"min(560px, 100%)",marginTop:rem(space.md),padding:`${rem(space.sm)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,boxSizing:"border-box",textAlign:"left",...slotLonghandCss(slots.card,1)},steps:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},step:{display:"grid",gridTemplateColumns:"44px 1fr",gap:rem(10),paddingTop:rem(14),paddingBottom:rem(14),borderBottomStyle:"solid",borderBottomWidth:1,borderBottomColor:look.line},stepLast:{borderBottomWidth:0},stepNumber:{...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(13),lineHeight:String(lineHeight.relaxed),paddingTop:2,...cardInk},stepText:{minWidth:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...cardInk},actions:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:rem(space.md),marginTop:rem(space.lg)},calendarNote:{textAlign:"center"}}}function createTelevetBackChannel(){let handlers=[];return{register(handler){return handlers=[...handlers,handler],()=>{handlers=handlers.filter(h=>h!==handler)}},dispatch(){for(let handler of[...handlers].reverse())try{if(handler())return!0}catch{}return false}}}var TelevetBackChannelContext=react.createContext(null);function useTelevetBackChannel(handler,enabled=true){let channel=react.useContext(TelevetBackChannelContext),current=react.useRef(handler);current.current=handler,react.useEffect(()=>{if(!(channel===null||!enabled))return channel.register(()=>current.current())},[channel,enabled])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function ownsEscape(node,event){if(event.isDefaultPrevented()||event.nativeEvent.isComposing)return false;let target=event.target;return!(target instanceof Element)||target.closest("dialog")===node}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=react.useRef(null),wasOpen=react.useRef(false),opener=react.useRef(null),trigger=react.useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=react.useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||
|
|
189
|
+
/* @__PURE__ */jsxRuntime.jsx(TelevetButton,{label:TELEVET_BOOKING_COPY_WEB.doneCta,kind:"primary",size:"lg",fullWidth:false,onPress:onDone,testID:"televet-booked-done"})]}),calendarState==="failed"?/* @__PURE__ */jsxRuntime.jsx("p",{role:"status",style:{...shared.failure,...styles.calendarNote},"data-testid":"televet-booked-calendar-failed",children:TELEVET_BOOKING_COPY_WEB.booked.calendarFailedBody}):null]})}function makeStyles2(theme){let{space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),rem=n=>`${String(n)}px`,cardInk=slots.card?.textColor===void 0?{}:{color:slots.card.textColor};return{screen:{display:"flex",flexDirection:"column",alignItems:"center",flex:"1 1 auto",minHeight:0,gap:rem(space.md),paddingTop:rem(space.xl),paddingBottom:rem(space.xl),boxSizing:"border-box",textAlign:"center"},avatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 6px ${look.surface}, 0 0 0 10px ${look.go}`,margin:rem(10),display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(40),lineHeight:"1"},title:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",30)),lineHeight:"1.1",letterSpacing:"-0.03em",textWrap:"balance",paddingTop:rem(space.md)},when:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},card:{width:"min(560px, 100%)",marginTop:rem(space.md),padding:`${rem(space.sm)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,boxSizing:"border-box",textAlign:"left",...slotLonghandCss(slots.card,1)},steps:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},step:{display:"grid",gridTemplateColumns:"44px 1fr",gap:rem(10),paddingTop:rem(14),paddingBottom:rem(14),borderBottomStyle:"solid",borderBottomWidth:1,borderBottomColor:look.line},stepLast:{borderBottomWidth:0},stepNumber:{...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(13),lineHeight:String(lineHeight.relaxed),paddingTop:2,...cardInk},stepText:{minWidth:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...cardInk},actions:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:rem(space.md),marginTop:rem(space.lg)},calendarNote:{textAlign:"center"}}}function createTelevetBackChannel(){let handlers=[];return{register(handler){return handlers=[...handlers,handler],()=>{handlers=handlers.filter(h=>h!==handler)}},dispatch(){for(let handler of[...handlers].reverse())try{if(handler())return!0}catch{}return false}}}var TelevetBackChannelContext=react.createContext(null);function useTelevetBackChannel(handler,enabled=true){let channel=react.useContext(TelevetBackChannelContext),current=react.useRef(handler);current.current=handler,react.useEffect(()=>{if(!(channel===null||!enabled))return channel.register(()=>current.current())},[channel,enabled])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function ownsEscape(node,event){if(event.isDefaultPrevented()||event.nativeEvent.isComposing)return false;let target=event.target;return!(target instanceof Element)||target.closest("dialog")===node}function activeIn(node){if(typeof document>"u")return null;let root=node?.getRootNode();return root&&root!==document&&"activeElement"in root?root.activeElement:document.activeElement}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=react.useRef(null),wasOpen=react.useRef(false),opener=react.useRef(null),trigger=react.useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=react.useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||activeIn(target)===target)&&(opener.current=null)},[]);react.useEffect(()=>{let node=dialogRef.current;if(!wasOpen.current){let active=activeIn(node);active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(activeIn(node))||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),react.useEffect(()=>restoreFocus,[restoreFocus]),react.useEffect(()=>{let node=dialogRef.current;if(node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&activeIn(dialog)!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=react.useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown&&ownsEscape(node,event)){event.preventDefault(),onClose();return}if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=activeIn(node);event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=react.useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}function BrandImage({src:src,alt:alt,decorative:decorative=false,style:style,height:height,fallback:fallback=null,onFailed:onFailed}){let[failed,setFailed]=react.useState(null);return src===null||failed===src?fallback:/* @__PURE__ */jsxRuntime.jsx("img",{src:src,alt:decorative?"":alt,...decorative?{"aria-hidden":true}:{},...height===void 0?{}:{height:height},style:style,decoding:"async",referrerPolicy:"no-referrer",onError:()=>{setFailed(src),onFailed?.()}})}var LOGO_HEIGHT=28,LOGO_MAX_WIDTH=160,LOGO_STYLE=/* @__PURE__ */Object.freeze({display:"block",height:LOGO_HEIGHT,width:"auto",maxWidth:LOGO_MAX_WIDTH,objectFit:"contain"});function BrandLogo({logoUrl:logoUrl,name:name,styles:styles}){/* @__PURE__ */
|
|
190
190
|
return jsxRuntime.jsx(BrandImage,{src:logoUrl,alt:name,height:LOGO_HEIGHT,style:styles?.logo??LOGO_STYLE})}var TELEVET_EASE_OUT="cubic-bezier(0.23, 1, 0.32, 1)",TELEVET_EASE_IO="cubic-bezier(0.77, 0, 0.175, 1)";function makeLocalStyles(theme){let{color:color,space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),reduced=theme.motion.reducedMotion,rem=n=>`${String(n)}px`,settle=reduced?"none":"border-color 200ms ease, background-color 200ms ease",stepSlot=slots.bookingStep,stepBoxed=stepSlot?.backgroundColor!==void 0||stepSlot?.borderColor!==void 0,ink=slot=>slot?.textColor===void 0?{}:{color:slot.textColor};return{marker:{minHeight:1},visuallyHiddenHeading:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},stepBody:{display:"flex",flexDirection:"column",gap:rem(space.xl),paddingTop:rem(space.xs),paddingBottom:rem(space.xl),...slotLonghandCss(stepSlot,1),...stepBoxed?{paddingTop:rem(space.lg),paddingLeft:rem(space.lg),paddingRight:rem(space.lg)}:null},stepInk:ink(stepSlot),head:{display:"flex",flexDirection:"column",gap:rem(space.sm)},footer:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:rem(space.lg),paddingTop:rem(space.lg),paddingBottom:rem(space.lg),flexShrink:0},footerMain:{marginLeft:"auto",flex:"1 1 200px",maxWidth:360,display:"flex"},fieldLabel:{margin:0,...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(12),letterSpacing:"0.08em",textTransform:"uppercase",lineHeight:String(lineHeight.snug)},note:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},alertLine:{margin:0,...faceCss(theme,"bold"),color:look.alert,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},options:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:rem(space.md)},optionsStack:{gridTemplateColumns:"minmax(0, 1fr)"},option:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",gap:rem(space.lg),padding:`${rem(18)} ${rem(20)}`,minHeight:64,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,color:look.text,textAlign:"left",cursor:"pointer",boxSizing:"border-box",transition:settle,...slotRadius(slots.card)},optionSelected:{borderColor:look.ink,backgroundColor:look.pinkSoft},optionRest:slotLonghandCss(slots.card,1.5),optionRestInk:ink(slots.card),optionDot:{width:22,height:22,flexShrink:0,borderRadius:"50%",borderStyle:"solid",borderWidth:1.5,borderColor:look.ink,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},optionDotFill:{width:12,height:12,borderRadius:"50%",backgroundColor:look.ink,transform:"scale(0)",transition:reduced?"none":`transform 320ms ${TELEVET_EASE_OUT}`},optionDotFillOn:{transform:"scale(1)"},optionText:{display:"flex",flexDirection:"column",minWidth:0,gap:2,flex:"1 1 auto"},optionTitle:{...faceCss(theme,"bold"),color:look.ink,fontSize:rem(18),lineHeight:String(lineHeight.snug),overflowWrap:"anywhere"},optionMeta:{...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.normal),overflowWrap:"anywhere"},optionAvatar:{width:56,height:56,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(size.subtitle),lineHeight:"1"},select:{width:"100%",minHeight:52,padding:`0 ${rem(space.lg)}`,borderRadius:rem(radius.md),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,color:look.text,...faceCss(theme,"regular"),fontSize:rem(size.body),boxSizing:"border-box",...slotLonghandCss(slots.input,1.5)},callout:{margin:0,padding:`${rem(space.md)} ${rem(space.lg)}`,borderRadius:rem(radius.md),backgroundColor:look.mist,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},chipRow:{display:"flex",flexWrap:"wrap",gap:rem(10)},chip:{minHeight:44,display:"inline-flex",alignItems:"center",gap:rem(space.sm),padding:`0 ${rem(space.lg)}`,borderRadius:rem(radius.pill),borderStyle:"solid",borderWidth:1.5,borderColor:look.ink,backgroundColor:look.surface,color:look.ink,cursor:"pointer",...faceCss(theme,"bold"),fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.snug),transition:settle,...slotRadius(slots.chip)},chipOn:{backgroundColor:look.pink,color:look.onPink},chipRest:slotLonghandCss(slots.chip,1.5),field:{display:"flex",flexDirection:"column",gap:rem(10)},reasonInput:{width:"100%",minHeight:150,resize:"vertical",borderStyle:"solid",borderWidth:1.5,borderColor:look.line,borderRadius:rem(radius.lg),padding:`${rem(space.lg)} ${rem(18)}`,backgroundColor:look.surface,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),boxSizing:"border-box",transition:reduced?"none":"border-color 200ms ease",...slotLonghandCss(slots.input,1.5)},reasonInputFocus:{borderColor:look.ink,outline:"none"},signs:{margin:0,paddingLeft:rem(22),display:"flex",flexDirection:"column",gap:rem(space.sm),...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},emergencyBanner:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:rem(space.md),padding:rem(20),borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1.5,borderColor:look.alert,backgroundColor:look.alertWash,boxSizing:"border-box"},emergencyTitle:{margin:0,...faceCss(theme,"bold"),color:color.errorRed,fontSize:rem(size.subtitle),lineHeight:String(lineHeight.snug)},emergencyLede:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},linkButton:{alignSelf:"flex-start",minHeight:44,padding:0,borderStyle:"none",background:"transparent",cursor:"pointer",textAlign:"left",...faceCss(theme,"bold"),color:look.ink,fontSize:rem(size.body),lineHeight:String(lineHeight.snug),textDecorationLine:"underline",textUnderlineOffset:3},meet:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",gap:rem(6),padding:`${rem(space.xxl)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,...slotLonghandCss(slots.card,1)},vetAvatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 4px ${look.surface}, 0 0 0 6px ${look.go}`,display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",40)),lineHeight:"1",marginBottom:rem(space.sm)},vetName:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,...ink(slots.card),fontSize:rem(size.heading),lineHeight:String(lineHeight.snug)},vetCredentials:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.normal),...ink(slots.card)},pills:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:rem(space.sm),margin:`${rem(space.sm)} 0`},pill:{display:"inline-flex",alignItems:"center",height:24,padding:`0 ${rem(10)}`,borderRadius:rem(radius.pill),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,...faceCss(theme,"monoBold"),color:look.muted,fontSize:rem(11.5),letterSpacing:"0.08em",textTransform:"uppercase",whiteSpace:"nowrap"},vetRating:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.caption),lineHeight:String(lineHeight.normal),...ink(slots.card)},vetBio:{margin:0,maxWidth:"52ch",...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...ink(slots.card)}}}function TelevetBookingChrome({step:step,furthestIndex:furthestIndex,title:title,canGoBack:canGoBack,showBack:showBack=true,isDirty:isDirty,onBack:onBack,onClose:onClose,onConfirmDiscard:onConfirmDiscard,headingLevel:level=DEFAULT_ROOT_HEADING_LEVEL,triageOpen:triageOpen=false,stepContext:stepContext}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeStyles3(theme),[theme]),[confirming,setConfirming]=react.useState(false),closeRef=react.useRef(null),closeHintId=`${react.useId()}-close-hint`,Title=headingTag(level);react.useEffect(()=>{if(!isDirty||typeof window>"u")return;let onBeforeUnload=event=>{event.preventDefault(),event.returnValue=""};return window.addEventListener("beforeunload",onBeforeUnload),()=>window.removeEventListener("beforeunload",onBeforeUnload)},[isDirty]);let confirmClose=react.useCallback(()=>{if(!isDirty){onClose();return}let prompt={title:TELEVET_BOOKING_COPY_WEB.chrome.discardTitle,body:TELEVET_BOOKING_COPY_WEB.chrome.discardBody,confirmLabel:TELEVET_BOOKING_COPY_WEB.chrome.discardConfirmCta,keepLabel:TELEVET_BOOKING_COPY_WEB.chrome.discardKeepCta};if(onConfirmDiscard){Promise.resolve(onConfirmDiscard(prompt)).then(leave=>{leave&&onClose()},()=>{});return}setConfirming(true)},[isDirty,onClose,onConfirmDiscard]);useTelevetBackChannel(()=>(confirmClose(),true));let steps=react.useMemo(()=>televetBarSteps(stepContext),[stepContext]),{current:current,total:total}=televetBarPosition(step,steps,triageOpen),label=step==="booked"?TELEVET_BOOKING_COPY_WEB.bookedStepLabel:fill(TELEVET_BOOKING_COPY_WEB.loading.progressTemplate,{step:String(current),total:String(total)});/* @__PURE__ */
|
|
191
191
|
return jsxRuntime.jsxs("div",{style:styles.wrap,children:[
|
|
192
192
|
/* @__PURE__ */jsxRuntime.jsxs("header",{style:styles.bar,children:[
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
3
|
import { P as PetRef } from '../../../ids.d-B2GAAifq.cjs';
|
|
4
4
|
export { B as Brand, _ as __brand } from '../../../ids.d-B2GAAifq.cjs';
|
|
5
|
-
import { c as TelevetBookingStep, d as TelevetBookingContext, e as TelevetBookingController, f as TelevetTriageRead, g as TelevetStateInterestWrite, T as TelevetEmptyRosterCause, a as TelevetStateInterestAction$1, b as TelevetMediaShortfall, h as TelevetVetThreadTarget, i as TelevetDayPeriod } from '../../../bookingCopy.d-
|
|
6
|
-
export { C as CONSULT_MINUTES, N as NO_MEDIA_SHORTFALL, j as TELEVET_BOOKING_BASE, k as TELEVET_BOOKING_COPY, l as TELEVET_BOOKING_STEPS, m as TELEVET_CONSULT_PAGE_LIMIT, n as TELEVET_JOIN_CLOSES_MINUTES_AFTER, o as TELEVET_JOIN_OPENS_MINUTES_BEFORE, p as TELEVET_MESSAGE_THREADS_PATH, q as TelevetAttachmentMeta, r as TelevetAttachmentPolicy, s as TelevetBookingAction, t as TelevetBookingControllerDeps, u as TelevetBookingCopy, v as TelevetBookingDraft, w as TelevetBookingFailure, x as TelevetBookingRefusal, y as TelevetBookingState, z as TelevetEarlyTriage, A as TelevetEmptyRosterView, aT as TelevetJoinBlock, aU as TelevetJoinDecision, D as TelevetJoinState, E as TelevetMediaRefusal, F as TelevetRead, G as TelevetStateInterestReason, H as TelevetWrite, U as UpcomingTelevetVisitState, I as UseVetThreadOptions, V as VET_MESSAGES_COPY, J as VET_MESSAGE_CONTENT_MAX, K as VET_MESSAGE_PAGE_DEFAULT, L as VET_MESSAGE_PAGE_MAX, M as VetMessage, O as VetMessagePage, P as VetMessageRole, Q as VetMessagesAvailability, R as VetSendFailure, S as VetThread, W as VetThreadState, X as VetThreadsState, Y as VisitSummary, Z as VisitSummaryMedication, _ as VisitSummaryState, $ as attestation, a0 as canConfirm, a1 as canManageTelevetVisit, a2 as createTelevetBookingController, a3 as currentStep, a4 as emptyTelevetDraft, a5 as formatVisitRange, a6 as formatWhen, a7 as formatWhenWithDay, a8 as hasPreviousStep, a9 as initialTelevetBookingState, aa as isHoldExpired, ab as isMediaShortfallEmpty, ac as isSkipped, ad as isTelevetBookingCopyReady, ae as isVetMessagesDark, af as isVetThreadVetFirst, ag as mediaShortfallFromUnsentPicks, ah as splitTelevetVisits, ai as televetBookingKey, aj as televetBookingReducer, ak as televetBookingRefusal, al as televetCancelCall, am as televetConsultCall, an as televetEmptyRosterCause, ao as televetEmptyRosterView, ap as televetHoldCall, aq as televetJoinCall, aV as televetJoinDecision, ar as televetJoinOpensAtMs, at as televetMediaShortfallLines, au as televetRescheduleCall, av as televetThreadMessagesCall, aw as televetThreadReadCall, ax as televetVisitSummaryCall, ay as useEarlyTriage, az as useStateInterest, aA as useTelevetBookConsult, aB as useTelevetBookingAvailable, aC as useTelevetBookingController, aD as useTelevetBookingEntitlement, aE as useTelevetCancellationPolicy, aF as useTelevetClinicians, aG as useTelevetHoldSlot, aH as useTelevetJoin, aI as useTelevetNextSlot, aJ as useTelevetRescheduleConsult, aK as useTelevetSlots, aL as useTelevetStatePolicy, aM as useUpcomingTelevetVisit, aN as useVetThread, aO as useVetThreads, aP as useVisitSummary, aQ as validateBookingBody, aR as vetThreadPetRef, aS as withUnsentPicks } from '../../../bookingCopy.d-
|
|
5
|
+
import { c as TelevetBookingStep, d as TelevetBookingContext, e as TelevetBookingController, f as TelevetTriageRead, g as TelevetStateInterestWrite, T as TelevetEmptyRosterCause, a as TelevetStateInterestAction$1, b as TelevetMediaShortfall, h as TelevetVetThreadTarget, i as TelevetDayPeriod } from '../../../bookingCopy.d-BHqE9Ozq.cjs';
|
|
6
|
+
export { C as CONSULT_MINUTES, N as NO_MEDIA_SHORTFALL, j as TELEVET_BOOKING_BASE, k as TELEVET_BOOKING_COPY, l as TELEVET_BOOKING_STEPS, m as TELEVET_CONSULT_PAGE_LIMIT, n as TELEVET_JOIN_CLOSES_MINUTES_AFTER, o as TELEVET_JOIN_OPENS_MINUTES_BEFORE, p as TELEVET_MESSAGE_THREADS_PATH, q as TelevetAttachmentMeta, r as TelevetAttachmentPolicy, s as TelevetBookingAction, t as TelevetBookingControllerDeps, u as TelevetBookingCopy, v as TelevetBookingDraft, w as TelevetBookingFailure, x as TelevetBookingRefusal, y as TelevetBookingState, z as TelevetEarlyTriage, A as TelevetEmptyRosterView, aT as TelevetJoinBlock, aU as TelevetJoinDecision, D as TelevetJoinState, E as TelevetMediaRefusal, F as TelevetRead, G as TelevetStateInterestReason, H as TelevetWrite, U as UpcomingTelevetVisitState, I as UseVetThreadOptions, V as VET_MESSAGES_COPY, J as VET_MESSAGE_CONTENT_MAX, K as VET_MESSAGE_PAGE_DEFAULT, L as VET_MESSAGE_PAGE_MAX, M as VetMessage, O as VetMessagePage, P as VetMessageRole, Q as VetMessagesAvailability, R as VetSendFailure, S as VetThread, W as VetThreadState, X as VetThreadsState, Y as VisitSummary, Z as VisitSummaryMedication, _ as VisitSummaryState, $ as attestation, a0 as canConfirm, a1 as canManageTelevetVisit, a2 as createTelevetBookingController, a3 as currentStep, a4 as emptyTelevetDraft, a5 as formatVisitRange, a6 as formatWhen, a7 as formatWhenWithDay, a8 as hasPreviousStep, a9 as initialTelevetBookingState, aa as isHoldExpired, ab as isMediaShortfallEmpty, ac as isSkipped, ad as isTelevetBookingCopyReady, ae as isVetMessagesDark, af as isVetThreadVetFirst, ag as mediaShortfallFromUnsentPicks, ah as splitTelevetVisits, ai as televetBookingKey, aj as televetBookingReducer, ak as televetBookingRefusal, al as televetCancelCall, am as televetConsultCall, an as televetEmptyRosterCause, ao as televetEmptyRosterView, ap as televetHoldCall, aq as televetJoinCall, aV as televetJoinDecision, ar as televetJoinOpensAtMs, at as televetMediaShortfallLines, au as televetRescheduleCall, av as televetThreadMessagesCall, aw as televetThreadReadCall, ax as televetVisitSummaryCall, ay as useEarlyTriage, az as useStateInterest, aA as useTelevetBookConsult, aB as useTelevetBookingAvailable, aC as useTelevetBookingController, aD as useTelevetBookingEntitlement, aE as useTelevetCancellationPolicy, aF as useTelevetClinicians, aG as useTelevetHoldSlot, aH as useTelevetJoin, aI as useTelevetNextSlot, aJ as useTelevetRescheduleConsult, aK as useTelevetSlots, aL as useTelevetStatePolicy, aM as useUpcomingTelevetVisit, aN as useVetThread, aO as useVetThreads, aP as useVisitSummary, aQ as validateBookingBody, aR as vetThreadPetRef, aS as withUnsentPicks } from '../../../bookingCopy.d-BHqE9Ozq.cjs';
|
|
7
7
|
import { T as TelevetConsult, E as EverfurTelevetFlowRequest, c as TelevetSlot } from '../../../televetGlobal.d-CKwDCbmN.cjs';
|
|
8
8
|
export { C as CANCELLATION_POLICY_VERSION_MAX, d as CANCEL_REASON_MAX, e as CONSULT_KINDS, f as CONSULT_STATUSES, g as ConsultKind, h as ConsultStatus, M as MEDIA_REFS_MAX, R as REASON_TEXT_MAX, i as TERMINAL_CONSULT_STATUSES, j as TelevetBookingBody, k as TelevetBookingEntitlement, b as TelevetCancelReceipt, l as TelevetCancellationPolicy, m as TelevetClinician, n as TelevetSlotHold, o as TelevetStatePolicy, p as TelevetTriageVerdict, q as isWellFormedStateCode } from '../../../televetGlobal.d-CKwDCbmN.cjs';
|
|
9
9
|
import { V as VetVisitIntent } from '../../../visitIntent.d-D7_yVp1I.cjs';
|
|
@@ -13,11 +13,11 @@ import { m as EverfurTheme } from '../../../tokens.d-BUVqme2D.cjs';
|
|
|
13
13
|
export { b as VetCallCredential, c as VetCallJoinRefusal, d as VetCallLimits, p as parseVetCallCredential, v as vetCallJoinReason, e as vetCallJoinRefusal } from '../../../callRoom.d-B1DoYdJe.cjs';
|
|
14
14
|
export { E as EverfurError, a as EverfurErrorCategory, b as EverfurErrorCode } from '../../../EverfurError.d-8NHtlgzA.cjs';
|
|
15
15
|
export { E as EverfurResult } from '../../../EverfurResult.d-BFH-3s6E.cjs';
|
|
16
|
-
export { W as WidgetPet } from '../../../petsRepository.d-
|
|
17
|
-
import '../../../requestFunnel.d-
|
|
16
|
+
export { W as WidgetPet } from '../../../petsRepository.d-Dd95xh-M.cjs';
|
|
17
|
+
import '../../../requestFunnel.d-CWI2pD3V.cjs';
|
|
18
18
|
import '../../../ErrorPolicyPort.d-DirW9hgO.cjs';
|
|
19
|
-
import '../../../config.d-
|
|
20
|
-
import '../../../identity.d-
|
|
19
|
+
import '../../../config.d-7bCXvOGn.cjs';
|
|
20
|
+
import '../../../identity.d-84x0dV7-.cjs';
|
|
21
21
|
import '../../../TelemetryPort.d-BDNr00hu.cjs';
|
|
22
22
|
import '../../../profile.d-CSs1wlXT.cjs';
|
|
23
23
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
3
|
import { P as PetRef } from '../../../ids.d-B2GAAifq.js';
|
|
4
4
|
export { B as Brand, _ as __brand } from '../../../ids.d-B2GAAifq.js';
|
|
5
|
-
import { c as TelevetBookingStep, d as TelevetBookingContext, e as TelevetBookingController, f as TelevetTriageRead, g as TelevetStateInterestWrite, T as TelevetEmptyRosterCause, a as TelevetStateInterestAction$1, b as TelevetMediaShortfall, h as TelevetVetThreadTarget, i as TelevetDayPeriod } from '../../../bookingCopy.d-
|
|
6
|
-
export { C as CONSULT_MINUTES, N as NO_MEDIA_SHORTFALL, j as TELEVET_BOOKING_BASE, k as TELEVET_BOOKING_COPY, l as TELEVET_BOOKING_STEPS, m as TELEVET_CONSULT_PAGE_LIMIT, n as TELEVET_JOIN_CLOSES_MINUTES_AFTER, o as TELEVET_JOIN_OPENS_MINUTES_BEFORE, p as TELEVET_MESSAGE_THREADS_PATH, q as TelevetAttachmentMeta, r as TelevetAttachmentPolicy, s as TelevetBookingAction, t as TelevetBookingControllerDeps, u as TelevetBookingCopy, v as TelevetBookingDraft, w as TelevetBookingFailure, x as TelevetBookingRefusal, y as TelevetBookingState, z as TelevetEarlyTriage, A as TelevetEmptyRosterView, aT as TelevetJoinBlock, aU as TelevetJoinDecision, D as TelevetJoinState, E as TelevetMediaRefusal, F as TelevetRead, G as TelevetStateInterestReason, H as TelevetWrite, U as UpcomingTelevetVisitState, I as UseVetThreadOptions, V as VET_MESSAGES_COPY, J as VET_MESSAGE_CONTENT_MAX, K as VET_MESSAGE_PAGE_DEFAULT, L as VET_MESSAGE_PAGE_MAX, M as VetMessage, O as VetMessagePage, P as VetMessageRole, Q as VetMessagesAvailability, R as VetSendFailure, S as VetThread, W as VetThreadState, X as VetThreadsState, Y as VisitSummary, Z as VisitSummaryMedication, _ as VisitSummaryState, $ as attestation, a0 as canConfirm, a1 as canManageTelevetVisit, a2 as createTelevetBookingController, a3 as currentStep, a4 as emptyTelevetDraft, a5 as formatVisitRange, a6 as formatWhen, a7 as formatWhenWithDay, a8 as hasPreviousStep, a9 as initialTelevetBookingState, aa as isHoldExpired, ab as isMediaShortfallEmpty, ac as isSkipped, ad as isTelevetBookingCopyReady, ae as isVetMessagesDark, af as isVetThreadVetFirst, ag as mediaShortfallFromUnsentPicks, ah as splitTelevetVisits, ai as televetBookingKey, aj as televetBookingReducer, ak as televetBookingRefusal, al as televetCancelCall, am as televetConsultCall, an as televetEmptyRosterCause, ao as televetEmptyRosterView, ap as televetHoldCall, aq as televetJoinCall, aV as televetJoinDecision, ar as televetJoinOpensAtMs, at as televetMediaShortfallLines, au as televetRescheduleCall, av as televetThreadMessagesCall, aw as televetThreadReadCall, ax as televetVisitSummaryCall, ay as useEarlyTriage, az as useStateInterest, aA as useTelevetBookConsult, aB as useTelevetBookingAvailable, aC as useTelevetBookingController, aD as useTelevetBookingEntitlement, aE as useTelevetCancellationPolicy, aF as useTelevetClinicians, aG as useTelevetHoldSlot, aH as useTelevetJoin, aI as useTelevetNextSlot, aJ as useTelevetRescheduleConsult, aK as useTelevetSlots, aL as useTelevetStatePolicy, aM as useUpcomingTelevetVisit, aN as useVetThread, aO as useVetThreads, aP as useVisitSummary, aQ as validateBookingBody, aR as vetThreadPetRef, aS as withUnsentPicks } from '../../../bookingCopy.d-
|
|
5
|
+
import { c as TelevetBookingStep, d as TelevetBookingContext, e as TelevetBookingController, f as TelevetTriageRead, g as TelevetStateInterestWrite, T as TelevetEmptyRosterCause, a as TelevetStateInterestAction$1, b as TelevetMediaShortfall, h as TelevetVetThreadTarget, i as TelevetDayPeriod } from '../../../bookingCopy.d-Ca4AQGZ7.js';
|
|
6
|
+
export { C as CONSULT_MINUTES, N as NO_MEDIA_SHORTFALL, j as TELEVET_BOOKING_BASE, k as TELEVET_BOOKING_COPY, l as TELEVET_BOOKING_STEPS, m as TELEVET_CONSULT_PAGE_LIMIT, n as TELEVET_JOIN_CLOSES_MINUTES_AFTER, o as TELEVET_JOIN_OPENS_MINUTES_BEFORE, p as TELEVET_MESSAGE_THREADS_PATH, q as TelevetAttachmentMeta, r as TelevetAttachmentPolicy, s as TelevetBookingAction, t as TelevetBookingControllerDeps, u as TelevetBookingCopy, v as TelevetBookingDraft, w as TelevetBookingFailure, x as TelevetBookingRefusal, y as TelevetBookingState, z as TelevetEarlyTriage, A as TelevetEmptyRosterView, aT as TelevetJoinBlock, aU as TelevetJoinDecision, D as TelevetJoinState, E as TelevetMediaRefusal, F as TelevetRead, G as TelevetStateInterestReason, H as TelevetWrite, U as UpcomingTelevetVisitState, I as UseVetThreadOptions, V as VET_MESSAGES_COPY, J as VET_MESSAGE_CONTENT_MAX, K as VET_MESSAGE_PAGE_DEFAULT, L as VET_MESSAGE_PAGE_MAX, M as VetMessage, O as VetMessagePage, P as VetMessageRole, Q as VetMessagesAvailability, R as VetSendFailure, S as VetThread, W as VetThreadState, X as VetThreadsState, Y as VisitSummary, Z as VisitSummaryMedication, _ as VisitSummaryState, $ as attestation, a0 as canConfirm, a1 as canManageTelevetVisit, a2 as createTelevetBookingController, a3 as currentStep, a4 as emptyTelevetDraft, a5 as formatVisitRange, a6 as formatWhen, a7 as formatWhenWithDay, a8 as hasPreviousStep, a9 as initialTelevetBookingState, aa as isHoldExpired, ab as isMediaShortfallEmpty, ac as isSkipped, ad as isTelevetBookingCopyReady, ae as isVetMessagesDark, af as isVetThreadVetFirst, ag as mediaShortfallFromUnsentPicks, ah as splitTelevetVisits, ai as televetBookingKey, aj as televetBookingReducer, ak as televetBookingRefusal, al as televetCancelCall, am as televetConsultCall, an as televetEmptyRosterCause, ao as televetEmptyRosterView, ap as televetHoldCall, aq as televetJoinCall, aV as televetJoinDecision, ar as televetJoinOpensAtMs, at as televetMediaShortfallLines, au as televetRescheduleCall, av as televetThreadMessagesCall, aw as televetThreadReadCall, ax as televetVisitSummaryCall, ay as useEarlyTriage, az as useStateInterest, aA as useTelevetBookConsult, aB as useTelevetBookingAvailable, aC as useTelevetBookingController, aD as useTelevetBookingEntitlement, aE as useTelevetCancellationPolicy, aF as useTelevetClinicians, aG as useTelevetHoldSlot, aH as useTelevetJoin, aI as useTelevetNextSlot, aJ as useTelevetRescheduleConsult, aK as useTelevetSlots, aL as useTelevetStatePolicy, aM as useUpcomingTelevetVisit, aN as useVetThread, aO as useVetThreads, aP as useVisitSummary, aQ as validateBookingBody, aR as vetThreadPetRef, aS as withUnsentPicks } from '../../../bookingCopy.d-Ca4AQGZ7.js';
|
|
7
7
|
import { T as TelevetConsult, E as EverfurTelevetFlowRequest, c as TelevetSlot } from '../../../televetGlobal.d-CC-DrqkQ.js';
|
|
8
8
|
export { C as CANCELLATION_POLICY_VERSION_MAX, d as CANCEL_REASON_MAX, e as CONSULT_KINDS, f as CONSULT_STATUSES, g as ConsultKind, h as ConsultStatus, M as MEDIA_REFS_MAX, R as REASON_TEXT_MAX, i as TERMINAL_CONSULT_STATUSES, j as TelevetBookingBody, k as TelevetBookingEntitlement, b as TelevetCancelReceipt, l as TelevetCancellationPolicy, m as TelevetClinician, n as TelevetSlotHold, o as TelevetStatePolicy, p as TelevetTriageVerdict, q as isWellFormedStateCode } from '../../../televetGlobal.d-CC-DrqkQ.js';
|
|
9
9
|
import { V as VetVisitIntent } from '../../../visitIntent.d-D7_yVp1I.js';
|
|
@@ -13,11 +13,11 @@ import { m as EverfurTheme } from '../../../tokens.d-BUVqme2D.js';
|
|
|
13
13
|
export { b as VetCallCredential, c as VetCallJoinRefusal, d as VetCallLimits, p as parseVetCallCredential, v as vetCallJoinReason, e as vetCallJoinRefusal } from '../../../callRoom.d-Dqm1rUqT.js';
|
|
14
14
|
export { E as EverfurError, a as EverfurErrorCategory, b as EverfurErrorCode } from '../../../EverfurError.d-8NHtlgzA.js';
|
|
15
15
|
export { E as EverfurResult } from '../../../EverfurResult.d-D_-254ZY.js';
|
|
16
|
-
export { W as WidgetPet } from '../../../petsRepository.d-
|
|
17
|
-
import '../../../requestFunnel.d-
|
|
16
|
+
export { W as WidgetPet } from '../../../petsRepository.d-BuomdFjZ.js';
|
|
17
|
+
import '../../../requestFunnel.d-DcQIAs45.js';
|
|
18
18
|
import '../../../ErrorPolicyPort.d-68yrE3BE.js';
|
|
19
|
-
import '../../../config.d-
|
|
20
|
-
import '../../../identity.d-
|
|
19
|
+
import '../../../config.d-cqyvpzDb.js';
|
|
20
|
+
import '../../../identity.d-BXztMVYM.js';
|
|
21
21
|
import '../../../TelemetryPort.d-BDNr00hu.js';
|
|
22
22
|
import '../../../profile.d-CSs1wlXT.js';
|
|
23
23
|
|
|
@@ -186,7 +186,7 @@ return jsxs("section",{style:styles.screen,"aria-labelledby":titleId,"data-testi
|
|
|
186
186
|
/* @__PURE__ */jsx("span",{"aria-hidden":"true",style:styles.stepNumber,children:String(i+1).padStart(2,"0")}),
|
|
187
187
|
/* @__PURE__ */jsx("span",{style:styles.stepText,children:step.trim()})]},step))})}),
|
|
188
188
|
/* @__PURE__ */jsxs("div",{style:styles.actions,children:[onAddToCalendar?/* @__PURE__ */jsx(TelevetButton,{label:calendarState==="saved"?TELEVET_BOOKING_COPY_WEB.booked.calendarAdded:TELEVET_BOOKING_COPY_WEB.addToCalendarCta,kind:"secondary",size:"lg",fullWidth:false,loading:calendarState==="saving",disabled:calendarState==="saving"||calendarState==="saved",onPress:()=>{addToCalendar()},testID:"televet-booked-calendar"}):null,
|
|
189
|
-
/* @__PURE__ */jsx(TelevetButton,{label:TELEVET_BOOKING_COPY_WEB.doneCta,kind:"primary",size:"lg",fullWidth:false,onPress:onDone,testID:"televet-booked-done"})]}),calendarState==="failed"?/* @__PURE__ */jsx("p",{role:"status",style:{...shared.failure,...styles.calendarNote},"data-testid":"televet-booked-calendar-failed",children:TELEVET_BOOKING_COPY_WEB.booked.calendarFailedBody}):null]})}function makeStyles2(theme){let{space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),rem=n=>`${String(n)}px`,cardInk=slots.card?.textColor===void 0?{}:{color:slots.card.textColor};return{screen:{display:"flex",flexDirection:"column",alignItems:"center",flex:"1 1 auto",minHeight:0,gap:rem(space.md),paddingTop:rem(space.xl),paddingBottom:rem(space.xl),boxSizing:"border-box",textAlign:"center"},avatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 6px ${look.surface}, 0 0 0 10px ${look.go}`,margin:rem(10),display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(40),lineHeight:"1"},title:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",30)),lineHeight:"1.1",letterSpacing:"-0.03em",textWrap:"balance",paddingTop:rem(space.md)},when:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},card:{width:"min(560px, 100%)",marginTop:rem(space.md),padding:`${rem(space.sm)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,boxSizing:"border-box",textAlign:"left",...slotLonghandCss(slots.card,1)},steps:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},step:{display:"grid",gridTemplateColumns:"44px 1fr",gap:rem(10),paddingTop:rem(14),paddingBottom:rem(14),borderBottomStyle:"solid",borderBottomWidth:1,borderBottomColor:look.line},stepLast:{borderBottomWidth:0},stepNumber:{...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(13),lineHeight:String(lineHeight.relaxed),paddingTop:2,...cardInk},stepText:{minWidth:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...cardInk},actions:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:rem(space.md),marginTop:rem(space.lg)},calendarNote:{textAlign:"center"}}}function createTelevetBackChannel(){let handlers=[];return{register(handler){return handlers=[...handlers,handler],()=>{handlers=handlers.filter(h=>h!==handler)}},dispatch(){for(let handler of[...handlers].reverse())try{if(handler())return!0}catch{}return false}}}var TelevetBackChannelContext=createContext(null);function useTelevetBackChannel(handler,enabled=true){let channel=useContext(TelevetBackChannelContext),current=useRef(handler);current.current=handler,useEffect(()=>{if(!(channel===null||!enabled))return channel.register(()=>current.current())},[channel,enabled])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function ownsEscape(node,event){if(event.isDefaultPrevented()||event.nativeEvent.isComposing)return false;let target=event.target;return!(target instanceof Element)||target.closest("dialog")===node}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=useRef(null),wasOpen=useRef(false),opener=useRef(null),trigger=useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||
|
|
189
|
+
/* @__PURE__ */jsx(TelevetButton,{label:TELEVET_BOOKING_COPY_WEB.doneCta,kind:"primary",size:"lg",fullWidth:false,onPress:onDone,testID:"televet-booked-done"})]}),calendarState==="failed"?/* @__PURE__ */jsx("p",{role:"status",style:{...shared.failure,...styles.calendarNote},"data-testid":"televet-booked-calendar-failed",children:TELEVET_BOOKING_COPY_WEB.booked.calendarFailedBody}):null]})}function makeStyles2(theme){let{space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),rem=n=>`${String(n)}px`,cardInk=slots.card?.textColor===void 0?{}:{color:slots.card.textColor};return{screen:{display:"flex",flexDirection:"column",alignItems:"center",flex:"1 1 auto",minHeight:0,gap:rem(space.md),paddingTop:rem(space.xl),paddingBottom:rem(space.xl),boxSizing:"border-box",textAlign:"center"},avatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 6px ${look.surface}, 0 0 0 10px ${look.go}`,margin:rem(10),display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(40),lineHeight:"1"},title:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",30)),lineHeight:"1.1",letterSpacing:"-0.03em",textWrap:"balance",paddingTop:rem(space.md)},when:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},card:{width:"min(560px, 100%)",marginTop:rem(space.md),padding:`${rem(space.sm)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,boxSizing:"border-box",textAlign:"left",...slotLonghandCss(slots.card,1)},steps:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column"},step:{display:"grid",gridTemplateColumns:"44px 1fr",gap:rem(10),paddingTop:rem(14),paddingBottom:rem(14),borderBottomStyle:"solid",borderBottomWidth:1,borderBottomColor:look.line},stepLast:{borderBottomWidth:0},stepNumber:{...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(13),lineHeight:String(lineHeight.relaxed),paddingTop:2,...cardInk},stepText:{minWidth:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...cardInk},actions:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:rem(space.md),marginTop:rem(space.lg)},calendarNote:{textAlign:"center"}}}function createTelevetBackChannel(){let handlers=[];return{register(handler){return handlers=[...handlers,handler],()=>{handlers=handlers.filter(h=>h!==handler)}},dispatch(){for(let handler of[...handlers].reverse())try{if(handler())return!0}catch{}return false}}}var TelevetBackChannelContext=createContext(null);function useTelevetBackChannel(handler,enabled=true){let channel=useContext(TelevetBackChannelContext),current=useRef(handler);current.current=handler,useEffect(()=>{if(!(channel===null||!enabled))return channel.register(()=>current.current())},[channel,enabled])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function ownsEscape(node,event){if(event.isDefaultPrevented()||event.nativeEvent.isComposing)return false;let target=event.target;return!(target instanceof Element)||target.closest("dialog")===node}function activeIn(node){if(typeof document>"u")return null;let root=node?.getRootNode();return root&&root!==document&&"activeElement"in root?root.activeElement:document.activeElement}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=useRef(null),wasOpen=useRef(false),opener=useRef(null),trigger=useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||activeIn(target)===target)&&(opener.current=null)},[]);useEffect(()=>{let node=dialogRef.current;if(!wasOpen.current){let active=activeIn(node);active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(activeIn(node))||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),useEffect(()=>restoreFocus,[restoreFocus]),useEffect(()=>{let node=dialogRef.current;if(node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&activeIn(dialog)!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown&&ownsEscape(node,event)){event.preventDefault(),onClose();return}if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=activeIn(node);event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}function BrandImage({src:src,alt:alt,decorative:decorative=false,style:style,height:height,fallback:fallback=null,onFailed:onFailed}){let[failed,setFailed]=useState(null);return src===null||failed===src?fallback:/* @__PURE__ */jsx("img",{src:src,alt:decorative?"":alt,...decorative?{"aria-hidden":true}:{},...height===void 0?{}:{height:height},style:style,decoding:"async",referrerPolicy:"no-referrer",onError:()=>{setFailed(src),onFailed?.()}})}var LOGO_HEIGHT=28,LOGO_MAX_WIDTH=160,LOGO_STYLE=/* @__PURE__ */Object.freeze({display:"block",height:LOGO_HEIGHT,width:"auto",maxWidth:LOGO_MAX_WIDTH,objectFit:"contain"});function BrandLogo({logoUrl:logoUrl,name:name,styles:styles}){/* @__PURE__ */
|
|
190
190
|
return jsx(BrandImage,{src:logoUrl,alt:name,height:LOGO_HEIGHT,style:styles?.logo??LOGO_STYLE})}var TELEVET_EASE_OUT="cubic-bezier(0.23, 1, 0.32, 1)",TELEVET_EASE_IO="cubic-bezier(0.77, 0, 0.175, 1)";function makeLocalStyles(theme){let{color:color,space:space,radius:radius,type:type,slots:slots}=theme,{size:size,lineHeight:lineHeight}=type,look=televetLook(theme),reduced=theme.motion.reducedMotion,rem=n=>`${String(n)}px`,settle=reduced?"none":"border-color 200ms ease, background-color 200ms ease",stepSlot=slots.bookingStep,stepBoxed=stepSlot?.backgroundColor!==void 0||stepSlot?.borderColor!==void 0,ink=slot=>slot?.textColor===void 0?{}:{color:slot.textColor};return{marker:{minHeight:1},visuallyHiddenHeading:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},stepBody:{display:"flex",flexDirection:"column",gap:rem(space.xl),paddingTop:rem(space.xs),paddingBottom:rem(space.xl),...slotLonghandCss(stepSlot,1),...stepBoxed?{paddingTop:rem(space.lg),paddingLeft:rem(space.lg),paddingRight:rem(space.lg)}:null},stepInk:ink(stepSlot),head:{display:"flex",flexDirection:"column",gap:rem(space.sm)},footer:{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:rem(space.lg),paddingTop:rem(space.lg),paddingBottom:rem(space.lg),flexShrink:0},footerMain:{marginLeft:"auto",flex:"1 1 200px",maxWidth:360,display:"flex"},fieldLabel:{margin:0,...faceCss(theme,"monoBold"),color:look.ink,fontSize:rem(12),letterSpacing:"0.08em",textTransform:"uppercase",lineHeight:String(lineHeight.snug)},note:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},alertLine:{margin:0,...faceCss(theme,"bold"),color:look.alert,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},options:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:rem(space.md)},optionsStack:{gridTemplateColumns:"minmax(0, 1fr)"},option:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",gap:rem(space.lg),padding:`${rem(18)} ${rem(20)}`,minHeight:64,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,color:look.text,textAlign:"left",cursor:"pointer",boxSizing:"border-box",transition:settle,...slotRadius(slots.card)},optionSelected:{borderColor:look.ink,backgroundColor:look.pinkSoft},optionRest:slotLonghandCss(slots.card,1.5),optionRestInk:ink(slots.card),optionDot:{width:22,height:22,flexShrink:0,borderRadius:"50%",borderStyle:"solid",borderWidth:1.5,borderColor:look.ink,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},optionDotFill:{width:12,height:12,borderRadius:"50%",backgroundColor:look.ink,transform:"scale(0)",transition:reduced?"none":`transform 320ms ${TELEVET_EASE_OUT}`},optionDotFillOn:{transform:"scale(1)"},optionText:{display:"flex",flexDirection:"column",minWidth:0,gap:2,flex:"1 1 auto"},optionTitle:{...faceCss(theme,"bold"),color:look.ink,fontSize:rem(18),lineHeight:String(lineHeight.snug),overflowWrap:"anywhere"},optionMeta:{...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.normal),overflowWrap:"anywhere"},optionAvatar:{width:56,height:56,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(size.subtitle),lineHeight:"1"},select:{width:"100%",minHeight:52,padding:`0 ${rem(space.lg)}`,borderRadius:rem(radius.md),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,color:look.text,...faceCss(theme,"regular"),fontSize:rem(size.body),boxSizing:"border-box",...slotLonghandCss(slots.input,1.5)},callout:{margin:0,padding:`${rem(space.md)} ${rem(space.lg)}`,borderRadius:rem(radius.md),backgroundColor:look.mist,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.relaxed)},chipRow:{display:"flex",flexWrap:"wrap",gap:rem(10)},chip:{minHeight:44,display:"inline-flex",alignItems:"center",gap:rem(space.sm),padding:`0 ${rem(space.lg)}`,borderRadius:rem(radius.pill),borderStyle:"solid",borderWidth:1.5,borderColor:look.ink,backgroundColor:look.surface,color:look.ink,cursor:"pointer",...faceCss(theme,"bold"),fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.snug),transition:settle,...slotRadius(slots.chip)},chipOn:{backgroundColor:look.pink,color:look.onPink},chipRest:slotLonghandCss(slots.chip,1.5),field:{display:"flex",flexDirection:"column",gap:rem(10)},reasonInput:{width:"100%",minHeight:150,resize:"vertical",borderStyle:"solid",borderWidth:1.5,borderColor:look.line,borderRadius:rem(radius.lg),padding:`${rem(space.lg)} ${rem(18)}`,backgroundColor:look.surface,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),boxSizing:"border-box",transition:reduced?"none":"border-color 200ms ease",...slotLonghandCss(slots.input,1.5)},reasonInputFocus:{borderColor:look.ink,outline:"none"},signs:{margin:0,paddingLeft:rem(22),display:"flex",flexDirection:"column",gap:rem(space.sm),...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},emergencyBanner:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:rem(space.md),padding:rem(20),borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1.5,borderColor:look.alert,backgroundColor:look.alertWash,boxSizing:"border-box"},emergencyTitle:{margin:0,...faceCss(theme,"bold"),color:color.errorRed,fontSize:rem(size.subtitle),lineHeight:String(lineHeight.snug)},emergencyLede:{margin:0,...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed)},linkButton:{alignSelf:"flex-start",minHeight:44,padding:0,borderStyle:"none",background:"transparent",cursor:"pointer",textAlign:"left",...faceCss(theme,"bold"),color:look.ink,fontSize:rem(size.body),lineHeight:String(lineHeight.snug),textDecorationLine:"underline",textUnderlineOffset:3},meet:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",gap:rem(6),padding:`${rem(space.xxl)} ${rem(space.xl)}`,borderRadius:rem(radius.lg),borderStyle:"solid",borderWidth:1,borderColor:look.line,backgroundColor:look.surface,...slotLonghandCss(slots.card,1)},vetAvatar:{width:112,height:112,flexShrink:0,borderRadius:"50%",backgroundColor:look.mist,boxShadow:`0 0 0 4px ${look.surface}, 0 0 0 6px ${look.go}`,display:"inline-flex",alignItems:"center",justifyContent:"center",...faceCss(theme,"medium"),color:look.ink,fontSize:rem(tierPx(theme,"heading",40)),lineHeight:"1",marginBottom:rem(space.sm)},vetName:{margin:0,...headingFaceCss(theme,"medium"),color:look.ink,...ink(slots.card),fontSize:rem(size.heading),lineHeight:String(lineHeight.snug)},vetCredentials:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.bodyTight),lineHeight:String(lineHeight.normal),...ink(slots.card)},pills:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:rem(space.sm),margin:`${rem(space.sm)} 0`},pill:{display:"inline-flex",alignItems:"center",height:24,padding:`0 ${rem(10)}`,borderRadius:rem(radius.pill),borderStyle:"solid",borderWidth:1.5,borderColor:look.line,backgroundColor:look.surface,...faceCss(theme,"monoBold"),color:look.muted,fontSize:rem(11.5),letterSpacing:"0.08em",textTransform:"uppercase",whiteSpace:"nowrap"},vetRating:{margin:0,...faceCss(theme,"regular"),color:look.muted,fontSize:rem(size.caption),lineHeight:String(lineHeight.normal),...ink(slots.card)},vetBio:{margin:0,maxWidth:"52ch",...faceCss(theme,"regular"),color:look.text,fontSize:rem(size.body),lineHeight:String(lineHeight.relaxed),...ink(slots.card)}}}function TelevetBookingChrome({step:step,furthestIndex:furthestIndex,title:title,canGoBack:canGoBack,showBack:showBack=true,isDirty:isDirty,onBack:onBack,onClose:onClose,onConfirmDiscard:onConfirmDiscard,headingLevel:level=DEFAULT_ROOT_HEADING_LEVEL,triageOpen:triageOpen=false,stepContext:stepContext}){let theme=useEverfurTheme(),styles=useMemo(()=>makeStyles3(theme),[theme]),[confirming,setConfirming]=useState(false),closeRef=useRef(null),closeHintId=`${useId()}-close-hint`,Title=headingTag(level);useEffect(()=>{if(!isDirty||typeof window>"u")return;let onBeforeUnload=event=>{event.preventDefault(),event.returnValue=""};return window.addEventListener("beforeunload",onBeforeUnload),()=>window.removeEventListener("beforeunload",onBeforeUnload)},[isDirty]);let confirmClose=useCallback(()=>{if(!isDirty){onClose();return}let prompt={title:TELEVET_BOOKING_COPY_WEB.chrome.discardTitle,body:TELEVET_BOOKING_COPY_WEB.chrome.discardBody,confirmLabel:TELEVET_BOOKING_COPY_WEB.chrome.discardConfirmCta,keepLabel:TELEVET_BOOKING_COPY_WEB.chrome.discardKeepCta};if(onConfirmDiscard){Promise.resolve(onConfirmDiscard(prompt)).then(leave=>{leave&&onClose()},()=>{});return}setConfirming(true)},[isDirty,onClose,onConfirmDiscard]);useTelevetBackChannel(()=>(confirmClose(),true));let steps=useMemo(()=>televetBarSteps(stepContext),[stepContext]),{current:current,total:total}=televetBarPosition(step,steps,triageOpen),label=step==="booked"?TELEVET_BOOKING_COPY_WEB.bookedStepLabel:fill(TELEVET_BOOKING_COPY_WEB.loading.progressTemplate,{step:String(current),total:String(total)});/* @__PURE__ */
|
|
191
191
|
return jsxs("div",{style:styles.wrap,children:[
|
|
192
192
|
/* @__PURE__ */jsxs("header",{style:styles.bar,children:[
|
|
@@ -155,7 +155,7 @@ return jsxRuntime.jsxs("div",{style:styles.petRow,children:[
|
|
|
155
155
|
/* @__PURE__ */jsxRuntime.jsx("label",{htmlFor:`${ids}-pet`,style:styles.label,children:copy.defaultPetLabel}),
|
|
156
156
|
/* @__PURE__ */jsxRuntime.jsxs("select",{id:`${ids}-pet`,value:value,disabled:saving,onChange:event=>onChoose(event.currentTarget.value),style:styles.input,children:[value===""?/* @__PURE__ */jsxRuntime.jsx("option",{value:"",children:copy.noPetSelected}):null,pets.map(pet=>/* @__PURE__ */jsxRuntime.jsx("option",{value:pet.petRef,children:pet.name??pet.petRef},pet.petRef))]}),
|
|
157
157
|
/* @__PURE__ */jsxRuntime.jsxs("div",{style:styles.links,children:[
|
|
158
|
-
/* @__PURE__ */jsxRuntime.jsx("button",{type:"button",disabled:!changed||saving,"aria-busy":saving?"true":void 0,onClick:()=>onSave(value),style:styles.secondary,children:saving?copy.savingPet:copy.savePet}),saved&&!changed?/* @__PURE__ */jsxRuntime.jsx("p",{style:styles.footnote,role:"status",children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,line=size=>`${Math.round(size*type.lineHeight.snug)}px`,text3=(size,ink,weight)=>({margin:0,...faceCss(theme,weight),fontSize:size,lineHeight:line(size),color:ink}),cardInk=slots.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:space.md,padding:space.lg,borderRadius:radius.lg,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,...slotCss(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${space.md}px`,borderRadius:radius.md,border:`1px solid ${color.controlEdge}`,backgroundColor:color.surface,...faceCss(theme,"regular"),fontSize:type.size.body,color:color.text.primary,...slotCss(slots.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:space.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:color.brand,cursor:"pointer"},consentText:{...text3(type.size.caption,cardInk??color.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:"none",backgroundColor:color.brand,color:color.text.onBrand,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.body,...slotCss(slots.primaryButton)},secondary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,color:color.brandInk,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption,color:color.linkInk,...slotCss(slots.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:space.xs},skeleton:{height:96,borderRadius:radius.md,backgroundColor:color.skeleton}}}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return react.useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=react.useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=react.useSyncExternalStore(subscribe2,read,read);return react.useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=react.useState({user:null,value:IDLE});return react.useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=react.useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=react.useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=react.useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=react.useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});react.useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);react.useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),react.useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;react.useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),react.useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=react.useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=react.useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=react.useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=react.useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=react.useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=react.useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return react.useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=react.useRef(null),wasOpen=react.useRef(false),opener=react.useRef(null),trigger=react.useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=react.useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||document.activeElement===target)&&(opener.current=null)},[]);react.useEffect(()=>{if(!open){restoreFocus();return}let node=dialogRef.current;if(!wasOpen.current){let active=typeof document>"u"?null:document.activeElement;active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(document.activeElement)||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),react.useEffect(()=>restoreFocus,[restoreFocus]),react.useEffect(()=>{let node=dialogRef.current;if(!open||node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&document.activeElement!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=react.useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown);if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=document.activeElement;event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=react.useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}var FOCUS_RING_WIDTH=2,SELF_FOCUS_RING_ATTRIBUTE="data-ef-focus-ring";function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return react.useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */jsxRuntime.jsx("button",{type:"button",disabled:!changed||saving,"aria-busy":saving?"true":void 0,onClick:()=>onSave(value),style:styles.secondary,children:saving?copy.savingPet:copy.savePet}),saved&&!changed?/* @__PURE__ */jsxRuntime.jsx("p",{style:styles.footnote,role:"status",children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,line=size=>`${Math.round(size*type.lineHeight.snug)}px`,text3=(size,ink,weight)=>({margin:0,...faceCss(theme,weight),fontSize:size,lineHeight:line(size),color:ink}),cardInk=slots.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:space.md,padding:space.lg,borderRadius:radius.lg,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,...slotCss(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${space.md}px`,borderRadius:radius.md,border:`1px solid ${color.controlEdge}`,backgroundColor:color.surface,...faceCss(theme,"regular"),fontSize:type.size.body,color:color.text.primary,...slotCss(slots.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:space.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:color.brand,cursor:"pointer"},consentText:{...text3(type.size.caption,cardInk??color.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:"none",backgroundColor:color.brand,color:color.text.onBrand,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.body,...slotCss(slots.primaryButton)},secondary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,color:color.brandInk,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption,color:color.linkInk,...slotCss(slots.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:space.xs},skeleton:{height:96,borderRadius:radius.md,backgroundColor:color.skeleton}}}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return react.useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=react.useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=react.useSyncExternalStore(subscribe2,read,read);return react.useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=react.useState({user:null,value:IDLE});return react.useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=react.useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=react.useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=react.useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=react.useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});react.useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);react.useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),react.useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;react.useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),react.useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=react.useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=react.useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=react.useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=react.useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=react.useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=react.useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return react.useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function activeIn(node){if(typeof document>"u")return null;let root=node?.getRootNode();return root&&root!==document&&"activeElement"in root?root.activeElement:document.activeElement}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=react.useRef(null),wasOpen=react.useRef(false),opener=react.useRef(null),trigger=react.useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=react.useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||activeIn(target)===target)&&(opener.current=null)},[]);react.useEffect(()=>{if(!open){restoreFocus();return}let node=dialogRef.current;if(!wasOpen.current){let active=activeIn(node);active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(activeIn(node))||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),react.useEffect(()=>restoreFocus,[restoreFocus]),react.useEffect(()=>{let node=dialogRef.current;if(!open||node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&activeIn(dialog)!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=react.useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown);if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=activeIn(node);event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=react.useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}var FOCUS_RING_WIDTH=2,SELF_FOCUS_RING_ATTRIBUTE="data-ef-focus-ring";function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return react.useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=react.useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
159
159
|
return jsxRuntime.jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let ids=react.useId(),{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=react.useState(""),[consented,setConsented]=react.useState(false),[code,setCode]=react.useState(""),[problem,setProblem]=react.useState(null),phoneRef=react.useRef(null),codeRef=react.useRef(null),[fieldFocused,setFieldFocused]=react.useState(false),fieldFocus={[SELF_FOCUS_RING_ATTRIBUTE]:"self",onFocus:()=>setFieldFocused(true),onBlur:()=>setFieldFocused(false)},pill=fieldFocused?{...styles.pill,...styles.pillFocused}:styles.pill,onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting";react.useEffect(()=>{setProblem(null)},[status]),react.useEffect(()=>{onNumber?phoneRef.current?.focus():onCode&&codeRef.current?.focus()},[onNumber,onCode]);let close=/* @__PURE__ */jsxRuntime.jsx("button",{type:"button","aria-label":TEXTING_COPY.close,onClick:ask.close,style:styles.close,children:/* @__PURE__ */jsxRuntime.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:/* @__PURE__ */jsxRuntime.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",fill:"none"})})}),refusal=snapshot.error===null?null:/* @__PURE__ */jsxRuntime.jsxs("div",{role:"alert",style:styles.notice,children:[
|
|
160
160
|
/* @__PURE__ */jsxRuntime.jsx("p",{style:styles.noticeText,children:textingErrorText(snapshot.error,snapshot.failedAction,snapshot.codeRefusal)}),textingSupportText(snapshot.error)===null?null:/* @__PURE__ */jsxRuntime.jsx("p",{style:styles.footnote,children:textingSupportText(snapshot.error)})]}),inputProblem=problem===null?null:/* @__PURE__ */jsxRuntime.jsx("p",{role:"alert",style:styles.noticeText,children:textingInputProblemText(problem)});if(profile===null)return null;if(status==="loading"||status==="failed"||status==="signedOut"||status==="unavailable")/* @__PURE__ */
|
|
161
161
|
return jsxRuntime.jsx("div",{style:styles.root,"data-everfur-texting-ask":"entry","aria-busy":status==="loading"?"true":void 0,children:/* @__PURE__ */jsxRuntime.jsxs("div",{style:styles.head,children:[
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { a as CapabilityDecision } from '../../resolve.d-
|
|
3
|
+
import { a as CapabilityDecision } from '../../resolve.d-BTC3b6FW.cjs';
|
|
4
4
|
import { E as EverfurError } from '../../EverfurError.d-8NHtlgzA.cjs';
|
|
5
5
|
export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../../EverfurError.d-8NHtlgzA.cjs';
|
|
6
|
-
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../../optInView.d-
|
|
7
|
-
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../../optInView.d-
|
|
8
|
-
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../../identity.d-
|
|
9
|
-
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../../config.d-
|
|
6
|
+
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../../optInView.d-4Hl4HbQh.cjs';
|
|
7
|
+
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../../optInView.d-4Hl4HbQh.cjs';
|
|
8
|
+
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../../identity.d-84x0dV7-.cjs';
|
|
9
|
+
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../../config.d-7bCXvOGn.cjs';
|
|
10
10
|
export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../../ids.d-B2GAAifq.cjs';
|
|
11
11
|
export { E as EverfurResult } from '../../EverfurResult.d-BFH-3s6E.cjs';
|
|
12
12
|
export { E as ErrorPolicyPort } from '../../ErrorPolicyPort.d-DirW9hgO.cjs';
|
|
13
|
-
import '../../requestFunnel.d-
|
|
13
|
+
import '../../requestFunnel.d-CWI2pD3V.cjs';
|
|
14
14
|
|
|
15
15
|
interface EverfurTextingOptInProps {
|
|
16
16
|
/** Called when the member's step changes (for example to `verified` or `optedOut`). A throw is swallowed. */
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { a as CapabilityDecision } from '../../resolve.d-
|
|
3
|
+
import { a as CapabilityDecision } from '../../resolve.d-BTC3b6FW.js';
|
|
4
4
|
import { E as EverfurError } from '../../EverfurError.d-8NHtlgzA.js';
|
|
5
5
|
export { a as EverfurErrorCategory, b as EverfurErrorCode } from '../../EverfurError.d-8NHtlgzA.js';
|
|
6
|
-
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../../optInView.d-
|
|
7
|
-
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../../optInView.d-
|
|
8
|
-
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../../identity.d-
|
|
9
|
-
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../../config.d-
|
|
6
|
+
import { E as EverfurTextingViewStatus, T as TextingCopy, a as TextingBrandCopy, b as TextingAsk } from '../../optInView.d-pq8tUTf6.js';
|
|
7
|
+
export { C as COPY_PLACEHOLDER_PREFIX, c as EVERFUR_TEXTING_STATUSES, d as EverfurTextingChallenge, e as EverfurTextingIdentity, f as EverfurTextingInputProblem, g as EverfurTextingProfile, h as EverfurTextingReason, i as EverfurTextingState, j as EverfurTextingStatus, k as EverfurTextingVerificationInput, l as TEXTING_ASK_MAX_ASKS, m as TEXTING_ASK_SCHEDULE_KEY, n as TEXTING_ASK_SNOOZE_MS, o as TEXTING_BRAND_COPY, p as TEXTING_CODE_PATTERN, q as TEXTING_COPY, r as TEXTING_COPY_PLACEHOLDERS, s as TEXTING_UI_CODE_LENGTH, t as TextingAction, u as TextingAskDue, v as TextingAskDueInput, w as TextingAskEntry, x as TextingAskIdentity, y as TextingAskOptions, z as TextingAskScheduleRead, A as TextingAskStage, B as TextingAskThreadMessage, D as TextingAskThreadState, F as TextingCodeRefusal, G as TextingController, H as TextingPhase, I as TextingRepository, J as TextingRepositoryDeps, K as TextingRuntime, L as TextingSnapshot, M as createTextingRepository, N as createTextingRepositoryOver, O as formatTextingPhone, P as isE164, Q as isTextingAskEligible, R as parseTextingProfile, S as resolveTextingAskDue, U as textingAskThreadReady, V as textingErrorText, W as textingIdentityFromWire, X as textingInputProblemText, Y as textingOptedOutBody, Z as textingReasonOf, _ as textingSupportText, $ as toTextingE164, a0 as useEverfurTexting, a1 as useEverfurTextingProfile, a2 as useEverfurTextingRepository, a3 as useTextingAsk, a4 as validateTextingCode, a5 as validateTextingEnroll } from '../../optInView.d-pq8tUTf6.js';
|
|
8
|
+
export { A as AuthContext, I as IdentityProvider, M as MintedToken, T as TokenProvider } from '../../identity.d-BXztMVYM.js';
|
|
9
|
+
export { A as AcceptedFrame, a as AnalysisCompleteFrame, b as AnalysisStartedFrame, D as DeltaFrame, c as DoneFrame, E as ErrorFrame, d as EverfurRequest, e as EverfurRequestBase, F as Frame, f as FrameBase, g as FrameKind, H as HeartbeatFrame, h as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, i as UrgencyLevel } from '../../config.d-cqyvpzDb.js';
|
|
10
10
|
export { B as Brand, C as ConversationId, P as PetRef, R as RecordsRequestId, U as UserRef, _ as __brand } from '../../ids.d-B2GAAifq.js';
|
|
11
11
|
export { E as EverfurResult } from '../../EverfurResult.d-D_-254ZY.js';
|
|
12
12
|
export { E as ErrorPolicyPort } from '../../ErrorPolicyPort.d-68yrE3BE.js';
|
|
13
|
-
import '../../requestFunnel.d-
|
|
13
|
+
import '../../requestFunnel.d-DcQIAs45.js';
|
|
14
14
|
|
|
15
15
|
interface EverfurTextingOptInProps {
|
|
16
16
|
/** Called when the member's step changes (for example to `verified` or `optedOut`). A throw is swallowed. */
|
|
@@ -155,7 +155,7 @@ return jsxs("div",{style:styles.petRow,children:[
|
|
|
155
155
|
/* @__PURE__ */jsx("label",{htmlFor:`${ids}-pet`,style:styles.label,children:copy.defaultPetLabel}),
|
|
156
156
|
/* @__PURE__ */jsxs("select",{id:`${ids}-pet`,value:value,disabled:saving,onChange:event=>onChoose(event.currentTarget.value),style:styles.input,children:[value===""?/* @__PURE__ */jsx("option",{value:"",children:copy.noPetSelected}):null,pets.map(pet=>/* @__PURE__ */jsx("option",{value:pet.petRef,children:pet.name??pet.petRef},pet.petRef))]}),
|
|
157
157
|
/* @__PURE__ */jsxs("div",{style:styles.links,children:[
|
|
158
|
-
/* @__PURE__ */jsx("button",{type:"button",disabled:!changed||saving,"aria-busy":saving?"true":void 0,onClick:()=>onSave(value),style:styles.secondary,children:saving?copy.savingPet:copy.savePet}),saved&&!changed?/* @__PURE__ */jsx("p",{style:styles.footnote,role:"status",children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,line=size=>`${Math.round(size*type.lineHeight.snug)}px`,text3=(size,ink,weight)=>({margin:0,...faceCss(theme,weight),fontSize:size,lineHeight:line(size),color:ink}),cardInk=slots.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:space.md,padding:space.lg,borderRadius:radius.lg,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,...slotCss(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${space.md}px`,borderRadius:radius.md,border:`1px solid ${color.controlEdge}`,backgroundColor:color.surface,...faceCss(theme,"regular"),fontSize:type.size.body,color:color.text.primary,...slotCss(slots.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:space.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:color.brand,cursor:"pointer"},consentText:{...text3(type.size.caption,cardInk??color.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:"none",backgroundColor:color.brand,color:color.text.onBrand,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.body,...slotCss(slots.primaryButton)},secondary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,color:color.brandInk,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption,color:color.linkInk,...slotCss(slots.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:space.xs},skeleton:{height:96,borderRadius:radius.md,backgroundColor:color.skeleton}}}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=useSyncExternalStore(subscribe2,read,read);return useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=useState({user:null,value:IDLE});return useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=useRef(null),wasOpen=useRef(false),opener=useRef(null),trigger=useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||document.activeElement===target)&&(opener.current=null)},[]);useEffect(()=>{if(!open){restoreFocus();return}let node=dialogRef.current;if(!wasOpen.current){let active=typeof document>"u"?null:document.activeElement;active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(document.activeElement)||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),useEffect(()=>restoreFocus,[restoreFocus]),useEffect(()=>{let node=dialogRef.current;if(!open||node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&document.activeElement!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown);if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=document.activeElement;event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}var FOCUS_RING_WIDTH=2,SELF_FOCUS_RING_ATTRIBUTE="data-ef-focus-ring";function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */jsx("button",{type:"button",disabled:!changed||saving,"aria-busy":saving?"true":void 0,onClick:()=>onSave(value),style:styles.secondary,children:saving?copy.savingPet:copy.savePet}),saved&&!changed?/* @__PURE__ */jsx("p",{style:styles.footnote,role:"status",children:copy.petSaved}):null]})]})}function makeStyles2(theme){let{color:color,radius:radius,space:space,type:type,slots:slots}=theme,line=size=>`${Math.round(size*type.lineHeight.snug)}px`,text3=(size,ink,weight)=>({margin:0,...faceCss(theme,weight),fontSize:size,lineHeight:line(size),color:ink}),cardInk=slots.card?.textColor;return{card:{boxSizing:"border-box",display:"flex",flexDirection:"column",gap:space.md,padding:space.lg,borderRadius:radius.lg,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,...slotCss(slots.card,1)},title:text3(type.size.subtitle,cardInk??color.text.primary,"bold"),subtitle:text3(type.size.body,cardInk??color.text.primary,"bold"),body:text3(type.size.body,cardInk??color.text.secondary,"regular"),footnote:text3(type.size.caption,color.text.muted,"regular"),phone:text3(type.size.body,cardInk??color.text.primary,"bold"),label:text3(type.size.caption,cardInk??color.text.primary,"bold"),input:{boxSizing:"border-box",width:"100%",minHeight:44,padding:`0 ${space.md}px`,borderRadius:radius.md,border:`1px solid ${color.controlEdge}`,backgroundColor:color.surface,...faceCss(theme,"regular"),fontSize:type.size.body,color:color.text.primary,...slotCss(slots.input,1)},consentRow:{display:"flex",alignItems:"flex-start",gap:space.sm,cursor:"pointer"},box:{width:24,height:24,minWidth:24,margin:0,accentColor:color.brand,cursor:"pointer"},consentText:{...text3(type.size.caption,cardInk??color.text.secondary,"regular"),whiteSpace:"pre-wrap"},primary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:"none",backgroundColor:color.brand,color:color.text.onBrand,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.body,...slotCss(slots.primaryButton)},secondary:{minHeight:44,padding:`0 ${space.lg}px`,borderRadius:radius.pill,border:`1px solid ${color.brandBorder}`,backgroundColor:color.surface,color:color.brandInk,cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption},link:{alignSelf:"flex-start",minHeight:44,padding:0,border:"none",background:"none",cursor:"pointer",...faceCss(theme,"bold"),fontSize:type.size.caption,color:color.linkInk,...slotCss(slots.link)},links:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:space.md},notice:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:space.xs},noticeText:text3(type.size.caption,color.errorRed,"regular"),confirm:{display:"flex",flexDirection:"column",gap:space.sm,padding:space.md,borderRadius:radius.md,backgroundColor:color.surfaceSubtle},petRow:{display:"flex",flexDirection:"column",gap:space.xs},skeleton:{height:96,borderRadius:radius.md,backgroundColor:color.skeleton}}}var INTRO_OPEN_SYMBOL=/* @__PURE__ */Symbol.for("@everfur/sdk#IntroOpen@v1"),host=globalThis;function isIntroOpenState(value){if(typeof value!="object"||value===null)return false;let v=value;return v.holds instanceof Set&&v.listeners instanceof Set}var stored=host[INTRO_OPEN_SYMBOL],fresh=()=>({holds:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set}),state=isIntroOpenState(stored)?stored:host[INTRO_OPEN_SYMBOL]=fresh();function isIntroOpen(){return state.holds.size>0}function subscribe(listener){return state.listeners.add(listener),()=>{state.listeners.delete(listener)}}function useIntroOpen(){return useSyncExternalStore(subscribe,isIntroOpen,isIntroOpen)}function resolveTextingAskDue(input){let readEnabled=input.enabled&&input.capabilityGranted&&input.hasProfile&&input.signedIn&&input.scheduleEligible&&!input.offeredThisSession,due=readEnabled&&input.identity==="none"&&input.surfaceReady;return{readEnabled:readEnabled,due:due}}var URGENT_LEVELS=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(chat){if(chat.isBootstrapping===true||chat.isLoadingHistory===true||chat.isStreaming===true||chat.status==="error"||chat.stopped===true)return false;let last=chat.messages[chat.messages.length-1];return last===void 0||last.role!=="assistant"||last.pending===true||last.checkin!==void 0||last.text.trim().length===0?false:!(typeof last.urgencyLevel=="string"&&URGENT_LEVELS.has(last.urgencyLevel))}var IN_MEMORY_KVS=/* @__PURE__ */new WeakSet;function isInMemoryKv(kv){return IN_MEMORY_KVS.has(kv)}var TEXTING_ASK_SCHEDULE_KEY="everfur.texting.askSchedule.v1",TEXTING_ASK_SNOOZE_MS=2880*60*1e3,TEXTING_ASK_MAX_ASKS=3,EMPTY_TEXTING_ASK_ENTRY=/* @__PURE__ */Object.freeze({askCount:0,nextAskAt:null,completed:false});function isTextingAskEligible(read,now){if(read.status!=="ok")return false;let{entry:entry}=read;return entry.completed||entry.askCount>=TEXTING_ASK_MAX_ASKS?false:entry.nextAskAt===null||now>=entry.nextAskAt}function applyTextingAsk(entry,now){return{askCount:Math.min(entry.askCount+1,TEXTING_ASK_MAX_ASKS),nextAskAt:now+TEXTING_ASK_SNOOZE_MS,completed:entry.completed}}function applyTextingAskSnooze(entry,now){return{...entry,nextAskAt:now+TEXTING_ASK_SNOOZE_MS}}function applyTextingAskCompleted(entry){return{...entry,completed:true}}function nextTextingAskNumber(entry){return entry.askCount<=0?1:entry.askCount===1?2:3}function entryOf(raw){if(raw===null||typeof raw!="object"||Array.isArray(raw))return null;let o=raw,{askCount:askCount,nextAskAt:nextAskAt,completed:completed}=o;return typeof askCount!="number"||!Number.isInteger(askCount)||askCount<0||nextAskAt!==null&&(typeof nextAskAt!="number"||!Number.isFinite(nextAskAt))||typeof completed!="boolean"?null:{askCount:Math.min(askCount,TEXTING_ASK_MAX_ASKS),nextAskAt:nextAskAt,completed:completed}}function parseTextingAskMap(raw){let value;try{value=JSON.parse(raw)}catch{return null}if(value===null||typeof value!="object"||Array.isArray(value))return null;let out={};for(let[key,item]of Object.entries(value)){let entry=entryOf(item);if(entry===null)return null;out[key]=entry}return out}var SLOT=/* @__PURE__ */Symbol.for("@everfur/sdk/texting/ask-schedule@v1");function shared(){let host2=globalThis,state2=host2[SLOT];return state2===void 0&&(state2={sessions:/* @__PURE__ */new Map,sessionListeners:/* @__PURE__ */new Set,listeners:/* @__PURE__ */new Set,writeChain:Promise.resolve()},host2[SLOT]=state2),state2.sessionListeners===void 0&&(state2.sessionListeners=/* @__PURE__ */new Set),state2}async function load(kv){if(isInMemoryKv(kv))return{status:"unreadable"};let raw;try{raw=await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)}catch{return{status:"unreadable"}}if(raw===null)try{return await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,"{}"),await kv.getItem(TEXTING_ASK_SCHEDULE_KEY)===null?{status:"unreadable"}:{status:"ok",map:{}}}catch{return{status:"unreadable"}}let map=parseTextingAskMap(raw);if(map!==null)return{status:"ok",map:map};try{await kv.removeItem(TEXTING_ASK_SCHEDULE_KEY)}catch{}return{status:"unreadable"}}function subscribeTextingAskSchedule(listener){let{listeners:listeners2}=shared();return listeners2.add(listener),()=>{listeners2.delete(listener)}}function update(kv,userRef,change){let state2=shared(),run=async()=>{let loaded=await load(kv);if(loaded.status!=="ok")return;let current=loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY;try{await kv.setItem(TEXTING_ASK_SCHEDULE_KEY,JSON.stringify({...loaded.map,[userRef]:change(current)}))}catch{return}for(let listener of[...state2.listeners])listener()},next=state2.writeChain.then(run,run);return state2.writeChain=next.catch(()=>{}),next}async function readTextingAskSchedule(kv,userRef){let loaded=await load(kv);return loaded.status!=="ok"?{status:"unreadable"}:{status:"ok",entry:loaded.map[userRef]??EMPTY_TEXTING_ASK_ENTRY}}function recordTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAsk(entry,now))}function snoozeTextingAsk(kv,userRef,now=Date.now()){return update(kv,userRef,entry=>applyTextingAskSnooze(entry,now))}function markTextingAskCompleted(kv,userRef){return update(kv,userRef,applyTextingAskCompleted)}function textingAskSession(userRef){return shared().sessions.get(userRef)??null}function setTextingAskSession(userRef,entry){let state2=shared();state2.sessions.set(userRef,entry);for(let listener of[...state2.sessionListeners])listener()}function subscribeTextingAskSessions(listener){let{sessionListeners:sessionListeners}=shared();return sessionListeners.add(listener),()=>{sessionListeners.delete(listener)}}var NO_SNAPSHOT=()=>null;function useTextingGranted(){let{runtime:runtime}=useEverfurContext(),source=runtime.entitlements??null,subscribe2=useCallback(listener=>source===null?()=>{}:source.subscribe(listener),[source]),read=source===null?NO_SNAPSHOT:source.getSnapshot,snapshot=useSyncExternalStore(subscribe2,read,read);return useMemo(()=>snapshot!==null&&decideCapability("texting",snapshot.decisions,{isPending:snapshot.isPending}).enabled,[snapshot])}var IDLE=/* @__PURE__ */Object.freeze({status:"idle"});function useAskSchedule(userRef){let{runtime:runtime}=useEverfurContext(),kv=runtime.registry.services.kv,[state2,setState]=useState({user:null,value:IDLE});return useEffect(()=>{if(userRef===null)return;let live=true,read=()=>{readTextingAskSchedule(kv,userRef).then(value=>{live&&setState({user:userRef,value:{status:"ready",read:value}})})};read();let unsubscribe=subscribeTextingAskSchedule(read);return()=>{live=false,unsubscribe()}},[kv,userRef]),state2.user===userRef?state2.value:IDLE}function identityOf(texting){switch(texting.status){case"enroll":case"requesting":case"code":case"confirming":return"none";case"verified":case"optingOut":case"optedOut":return"exists";default:return"unknown"}}function useTextingAsk(options={}){let enabled=options.enabled!==false,ready=options.ready!==false,surface=options.surface??"prompt",entryWanted=options.entry===true,{runtime:runtime,userRef:userRef}=useEverfurContext(),kv=runtime.registry.services.kv,granted=useTextingGranted(),schedule=useAskSchedule(enabled&&userRef!==null?userRef:null),readSession=useCallback(()=>userRef===null?null:textingAskSession(userRef),[userRef]),current=useSyncExternalStore(subscribeTextingAskSessions,readSession,readSession),update2=useCallback(entry=>{userRef!==null&&setTextingAskSession(userRef,entry)},[userRef]),mine=current!==null&¤t.surface===surface,handedOff=current!==null&¤t.fromPrompt===true,stage=mine?current.stage==="handoff"?"hidden":current.stage:surface==="prompt"&&handedOff?"dismissed":"hidden",now=Date.now(),scheduleEligible=schedule.status==="ready"&&isTextingAskEligible(schedule.read,now),[readFor,setReadFor]=useState(null),entryRead=entryWanted&&userRef!==null&&granted,texting=useTextingState(userRef!==null&&readFor===userRef||stage!=="hidden"||mine||entryRead),identity=identityOf(texting),{readEnabled:readEnabled,due:due}=resolveTextingAskDue({enabled:enabled,capabilityGranted:granted,hasProfile:texting.profile!==null,signedIn:userRef!==null,scheduleEligible:scheduleEligible,offeredThisSession:current!==null,identity:identity,surfaceReady:ready});useEffect(()=>{readEnabled&&userRef!==null&&setReadFor(userRef)},[readEnabled,userRef]);let askNumber=current?.askNumber??(schedule.status==="ready"&&schedule.read.status==="ok"?nextTextingAskNumber(schedule.read.entry):1);useEffect(()=>{!due||userRef===null||textingAskSession(userRef)!==null||update2({surface:surface,stage:"offered",answered:false,askNumber:askNumber})},[due,userRef,update2,askNumber,surface]),useEffect(()=>{!mine||current.stage!=="handoff"||enabled&&ready&&granted&&texting.profile!==null&&identity==="none"&&update2({...current,stage:"offered"})},[mine,current,enabled,ready,granted,texting.profile,identity,update2]);let completed=schedule.status==="ready"&&schedule.read.status==="ok"&&schedule.read.entry.completed;useEffect(()=>{userRef===null||identity!=="exists"||completed||schedule.status!=="ready"||markTextingAskCompleted(kv,userRef)},[identity,completed,schedule.status,kv,userRef]),useEffect(()=>{mine&¤t.stage==="enrolling"&&texting.status==="verified"&&update2({...current,stage:"verified"})},[mine,current,texting.status,update2]);let answer=useCallback(entry=>userRef===null||entry.answered?entry:(recordTextingAsk(kv,userRef),{...entry,answered:true}),[kv,userRef]),accept=useCallback(()=>{mine&¤t.stage==="offered"&&update2({...current,stage:"enrolling"})},[mine,current,update2]),close=useCallback(()=>{if(!mine||current.stage!=="enrolling")return;let{back:back,...rest}=current;update2({...rest,stage:back??"offered"})},[mine,current,update2]),dismiss=useCallback(()=>{if(!(!mine||current.stage!=="offered"&¤t.stage!=="enrolling")){if(surface==="prompt"){update2({...answer(current),surface:"chat",stage:"handoff",fromPrompt:true});return}current.fromPrompt===true&¤t.answered&&userRef!==null&&snoozeTextingAsk(kv,userRef),update2({...answer(current),stage:"dismissed"})}},[mine,current,surface,update2,answer,kv,userRef]),{start:startCode}=texting,start=useCallback(async phone=>!mine||current.stage!=="enrolling"?false:(current.answered||update2(answer(current)),startCode(phone)),[mine,current,update2,answer,startCode]),canOpen=entryRead&&texting.profile!==null&&identity==="none"&&stage!=="enrolling"&&stage!=="verified",open=useCallback(()=>{if(!canOpen||userRef===null)return;let was=mine?current:null;update2({surface:surface,stage:"enrolling",answered:was?.answered??false,askNumber:current?.askNumber??askNumber,...was?.fromPrompt===true?{fromPrompt:true}:{},back:was?.stage==="offered"?"offered":"dismissed"})},[canOpen,userRef,mine,current,update2,surface,askNumber]),brand=texting.profile?.brandName??"";return useMemo(()=>({stage:userRef===null?"hidden":stage,brand:brand,askNumber:askNumber,texting:texting,accept:accept,dismiss:dismiss,close:close,start:start,canOpen:canOpen,open:open}),[userRef,stage,brand,askNumber,texting,accept,dismiss,close,start,canOpen,open])}var FOCUSABLE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';function isDialogElement(node){return node.tagName==="DIALOG"}function activeIn(node){if(typeof document>"u")return null;let root=node?.getRootNode();return root&&root!==document&&"activeElement"in root?root.activeElement:document.activeElement}function useModalDialog(open,onClose,returnFocusTo,options){let escapeAtKeyDown=options?.escapeAtKeyDown===true,dialogRef=useRef(null),wasOpen=useRef(false),opener=useRef(null),trigger=useRef(returnFocusTo);trigger.current=returnFocusTo;let restoreFocus=useCallback(()=>{if(!wasOpen.current)return;wasOpen.current=false;let target=trigger.current===void 0?opener.current:trigger.current.current;target&&target.isConnected&&target.focus(),(!target||!target.isConnected||activeIn(target)===target)&&(opener.current=null)},[]);useEffect(()=>{if(!open){restoreFocus();return}let node=dialogRef.current;if(!wasOpen.current){let active=activeIn(node);active!==null&&node!==null&&node.contains(active)||(opener.current=active instanceof HTMLElement?active:null)}if(wasOpen.current=true,node===null)return;if(!isDialogElement(node)){node.contains(activeIn(node))||(node.querySelector(FOCUSABLE)??node).focus();return}let dialog=node;typeof dialog.showModal=="function"?dialog.open||dialog.showModal():dialog.setAttribute("open","")},[open,restoreFocus]),useEffect(()=>restoreFocus,[restoreFocus]),useEffect(()=>{let node=dialogRef.current;if(!open||node===null||!isDialogElement(node))return;let dialog=node;if(typeof dialog.showModal!="function")return;let lastFocused=null,onFocusIn=event=>{event.target instanceof HTMLElement&&(lastFocused=event.target)},onNativeClose=()=>{if(!dialog.isConnected||dialog.open)return;let back=lastFocused;dialog.showModal(),back!==null&&back.isConnected&&dialog.contains(back)&&activeIn(dialog)!==back&&back.focus()};return dialog.addEventListener("focusin",onFocusIn),dialog.addEventListener("close",onNativeClose),()=>{dialog.removeEventListener("focusin",onFocusIn),dialog.removeEventListener("close",onNativeClose)}},[open]);let onKeyDown=useCallback(event=>{let node=dialogRef.current;if(node===null)return;if(event.key==="Escape"&&!isDialogElement(node)){event.preventDefault(),event.stopPropagation(),onClose();return}if(event.key==="Escape"&&escapeAtKeyDown);if(event.key!=="Tab")return;let focusable=Array.from(node.querySelectorAll(FOCUSABLE)),first=focusable[0],last=focusable[focusable.length-1];if(!first||!last){event.preventDefault();return}let active=activeIn(node);event.shiftKey&&(active===first||!node.contains(active))?(event.preventDefault(),last.focus()):!event.shiftKey&&(active===last||!node.contains(active))&&(event.preventDefault(),first.focus())},[onClose,escapeAtKeyDown]),onCancel=useCallback(event=>{event.target===event.currentTarget&&(event.preventDefault(),onClose())},[onClose]);return{dialogRef:dialogRef,onKeyDown:onKeyDown,onCancel:onCancel}}var FOCUS_RING_WIDTH=2,SELF_FOCUS_RING_ATTRIBUTE="data-ef-focus-ring";function ChatTextingAskController({enabled:enabled,ready:ready,onAsk:onAsk,entry:entry=false}){let ask=useTextingAsk({enabled:enabled,ready:ready,surface:"chat",entry:entry});return useEffect(()=>{callHost(onAsk,ask)},[ask,onAsk]),null}function textingAskLines(ask){return{line:TEXTING_BRAND_COPY.chatAskLine(ask.brand),accept:TEXTING_COPY.promptAccept,dismiss:TEXTING_COPY.promptDismiss,verified:TEXTING_BRAND_COPY.chatAskVerified(ask.brand)}}function ChatTextingAskComposer({ask:ask}){let theme=useEverfurTheme(),styles=useMemo(()=>makeAskStyles(theme),[theme]);/* @__PURE__ */
|
|
159
159
|
return jsx(AskEntry,{ask:ask,styles:styles})}function AskEntry({ask:ask,styles:styles}){let ids=useId(),{texting:texting}=ask,{status:status,profile:profile,snapshot:snapshot}=texting,[phone,setPhone]=useState(""),[consented,setConsented]=useState(false),[code,setCode]=useState(""),[problem,setProblem]=useState(null),phoneRef=useRef(null),codeRef=useRef(null),[fieldFocused,setFieldFocused]=useState(false),fieldFocus={[SELF_FOCUS_RING_ATTRIBUTE]:"self",onFocus:()=>setFieldFocused(true),onBlur:()=>setFieldFocused(false)},pill=fieldFocused?{...styles.pill,...styles.pillFocused}:styles.pill,onNumber=status==="enroll"||status==="requesting"&&!snapshot.resending,onCode=status==="code"||status==="confirming"||status==="requesting";useEffect(()=>{setProblem(null)},[status]),useEffect(()=>{onNumber?phoneRef.current?.focus():onCode&&codeRef.current?.focus()},[onNumber,onCode]);let close=/* @__PURE__ */jsx("button",{type:"button","aria-label":TEXTING_COPY.close,onClick:ask.close,style:styles.close,children:/* @__PURE__ */jsx("svg",{width:18,height:18,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:/* @__PURE__ */jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",fill:"none"})})}),refusal=snapshot.error===null?null:/* @__PURE__ */jsxs("div",{role:"alert",style:styles.notice,children:[
|
|
160
160
|
/* @__PURE__ */jsx("p",{style:styles.noticeText,children:textingErrorText(snapshot.error,snapshot.failedAction,snapshot.codeRefusal)}),textingSupportText(snapshot.error)===null?null:/* @__PURE__ */jsx("p",{style:styles.footnote,children:textingSupportText(snapshot.error)})]}),inputProblem=problem===null?null:/* @__PURE__ */jsx("p",{role:"alert",style:styles.noticeText,children:textingInputProblemText(problem)});if(profile===null)return null;if(status==="loading"||status==="failed"||status==="signedOut"||status==="unavailable")/* @__PURE__ */
|
|
161
161
|
return jsx("div",{style:styles.root,"data-everfur-texting-ask":"entry","aria-busy":status==="loading"?"true":void 0,children:/* @__PURE__ */jsxs("div",{style:styles.head,children:[
|