@tellescope/react-components 1.234.1 → 1.235.0

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.
Files changed (39) hide show
  1. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  2. package/lib/cjs/Forms/forms.js +37 -35
  3. package/lib/cjs/Forms/forms.js.map +1 -1
  4. package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
  5. package/lib/cjs/Forms/forms.v2.js +37 -35
  6. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  7. package/lib/cjs/Forms/inputs.d.ts +17 -2
  8. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  9. package/lib/cjs/Forms/inputs.js +308 -36
  10. package/lib/cjs/Forms/inputs.js.map +1 -1
  11. package/lib/cjs/Forms/inputs.v2.d.ts +3 -2
  12. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  13. package/lib/cjs/Forms/inputs.v2.js +20 -293
  14. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  15. package/lib/cjs/Forms/types.d.ts +4 -0
  16. package/lib/cjs/Forms/types.d.ts.map +1 -1
  17. package/lib/esm/Forms/forms.d.ts.map +1 -1
  18. package/lib/esm/Forms/forms.js +38 -36
  19. package/lib/esm/Forms/forms.js.map +1 -1
  20. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  21. package/lib/esm/Forms/forms.v2.js +38 -36
  22. package/lib/esm/Forms/forms.v2.js.map +1 -1
  23. package/lib/esm/Forms/inputs.d.ts +17 -2
  24. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  25. package/lib/esm/Forms/inputs.js +306 -37
  26. package/lib/esm/Forms/inputs.js.map +1 -1
  27. package/lib/esm/Forms/inputs.v2.d.ts +3 -2
  28. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  29. package/lib/esm/Forms/inputs.v2.js +15 -289
  30. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  31. package/lib/esm/Forms/types.d.ts +4 -0
  32. package/lib/esm/Forms/types.d.ts.map +1 -1
  33. package/lib/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +9 -9
  35. package/src/Forms/forms.tsx +13 -6
  36. package/src/Forms/forms.v2.tsx +9 -2
  37. package/src/Forms/inputs.tsx +449 -65
  38. package/src/Forms/inputs.v2.tsx +12 -593
  39. package/src/Forms/types.ts +4 -2
@@ -97,7 +97,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
97
97
  return (mod && mod.__esModule) ? mod : { "default": mod };
98
98
  };
99
99
  Object.defineProperty(exports, "__esModule", { value: true });
100
- exports.ChargeebeeInput = exports.RichTextInput = exports.ConditionsInput = exports.AllergiesInput = exports.EmotiiInput = exports.HiddenValueInput = exports.RedirectInput = exports.include_current_url_parameters_if_templated = exports.HeightInput = exports.AppointmentBookingInput = exports.RelatedContactsInput = exports.contact_is_valid = exports.BelugaPatientPreferenceInput = exports.MedicationsInput = exports.CanvasMedicationsInput = exports.DatabaseSelectInput = exports.DropdownInput = exports.Progress = exports.StripeInput = exports.MultipleChoiceInput = exports.FilesInput = exports.safe_create_url = exports.FileInput = exports.convertHEIC = exports.SignatureInput = exports.ESignatureTerms = exports.AddressInput = exports.TimezoneInput = exports.TimeInput = exports.InsuranceInput = exports.NumberInput = exports.EmailInput = exports.PhoneInput = exports.StringLongInput = exports.StringInput = exports.DateStringInput = exports.AutoFocusTextField = exports.TableInput = exports.DateInput = exports.RankingInput = exports.RatingInput = exports.PdfViewer = exports.defaultButtonStyles = exports.defaultInputProps = exports.LanguageSelect = void 0;
100
+ exports.ChargeebeeInput = exports.RichTextInput = exports.ConditionsInput = exports.AllergiesInput = exports.EmotiiInput = exports.HiddenValueInput = exports.RedirectInput = exports.include_current_url_parameters_if_templated = exports.HeightInput = exports.AppointmentBookingInput = exports.RelatedContactsInput = exports.contact_is_valid = exports.BelugaPatientPreferenceInput = exports.MedicationsInput = exports.CanvasMedicationsInput = exports.DatabaseSelectInput = exports.DropdownInput = exports.Progress = exports.StripeInput = exports.MultipleChoiceInput = exports.FilesInput = exports.safe_create_url = exports.FileInput = exports.convertHEIC = exports.SignatureInput = exports.ESignatureTerms = exports.AddressInput = exports.TimezoneInput = exports.TimeInput = exports.BridgeEligibilityInput = exports.InsuranceInput = exports.NumberInput = exports.EmailInput = exports.PhoneInput = exports.StringLongInput = exports.StringInput = exports.DateStringInput = exports.AutoFocusTextField = exports.TableInput = exports.DateInput = exports.RankingInput = exports.RatingInput = exports.PdfViewer = exports.defaultButtonStyles = exports.defaultInputProps = exports.LanguageSelect = exports.setBridgeEligibilityUserIds = exports.getBridgeEligibilityUserIds = void 0;
101
101
  var jsx_runtime_1 = require("react/jsx-runtime");
102
102
  var react_1 = __importStar(require("react"));
103
103
  var axios_1 = __importDefault(require("axios"));
@@ -122,6 +122,16 @@ var react_stripe_js_1 = require("@stripe/react-stripe-js");
122
122
  var stripe_js_1 = require("@stripe/stripe-js");
123
123
  var icons_material_1 = require("@mui/icons-material");
124
124
  var wysiwyg_1 = require("./wysiwyg");
125
+ // Bridge Eligibility - shared variable for storing most recent eligibility userIds
126
+ var bridgeEligibilityResult = {
127
+ userIds: [],
128
+ };
129
+ var getBridgeEligibilityUserIds = function () { return bridgeEligibilityResult.userIds; };
130
+ exports.getBridgeEligibilityUserIds = getBridgeEligibilityUserIds;
131
+ var setBridgeEligibilityUserIds = function (userIds) {
132
+ bridgeEligibilityResult.userIds = userIds;
133
+ };
134
+ exports.setBridgeEligibilityUserIds = setBridgeEligibilityUserIds;
125
135
  // Debounce hook for search functionality
126
136
  var useDebounce = function (value, delay) {
127
137
  var _a = (0, react_1.useState)(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
@@ -280,9 +290,15 @@ var TableInput = function (_a) {
280
290
  }), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, sx: { ml: 'auto', width: iconWidth } }, { children: (0, jsx_runtime_1.jsx)(__1.LabeledIconButton, { Icon: __1.CancelIcon, label: "Remove", onClick: function () { return handleRemove(i); }, disabled: !field.isOptional && value.length === 1 }) }))] }), i), (0, jsx_runtime_1.jsx)(material_1.Divider, { flexItem: true, sx: { my: 1 } })] })); }), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", size: "small", onClick: handleNewRow, sx: { width: 200 } }, { children: "Add new entry" }))] })));
281
291
  };
282
292
  exports.TableInput = TableInput;
283
- var AutoFocusTextField = function (props) { return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: exports.defaultInputProps }, props))); };
293
+ var AutoFocusTextField = function (props) {
294
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
295
+ return (0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: inputProps || exports.defaultInputProps }, textFieldProps));
296
+ };
284
297
  exports.AutoFocusTextField = AutoFocusTextField;
285
- var CustomDateStringInput = (0, react_1.forwardRef)(function (props, ref) { return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: exports.defaultInputProps, fullWidth: true, inputRef: ref }, props))); });
298
+ var CustomDateStringInput = (0, react_1.forwardRef)(function (props, ref) {
299
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
300
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: inputProps || exports.defaultInputProps, fullWidth: true, inputRef: ref }, textFieldProps)));
301
+ });
286
302
  var DateStringInput = function (_a) {
287
303
  var _b;
288
304
  var field = _a.field, value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
@@ -370,7 +386,7 @@ var NumberInput = function (_a) {
370
386
  exports.NumberInput = NumberInput;
371
387
  var InsuranceInput = function (_a) {
372
388
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
373
- var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser"]);
389
+ var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser", "inputProps"]);
374
390
  var session = (0, __1.useResolvedSession)();
375
391
  var _t = (0, react_1.useState)([]), payers = _t[0], setPayers = _t[1];
376
392
  var _u = (0, react_1.useState)(''), query = _u[0], setQuery = _u[1];
@@ -391,9 +407,11 @@ var InsuranceInput = function (_a) {
391
407
  }, [enduser === null || enduser === void 0 ? void 0 : enduser.state, addressQuestion]);
392
408
  var loadRef = (0, react_1.useRef)(false); // so session changes don't cause
393
409
  (0, react_1.useEffect)(function () {
394
- var _a;
410
+ var _a, _b;
395
411
  if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE)
396
412
  return; // instead, look-up while typing against Canvas Search API
413
+ if (((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.BRIDGE_TITLE)
414
+ return; // instead, look-up while typing against Bridge Search API
397
415
  if (loadRef.current)
398
416
  return;
399
417
  loadRef.current = true;
@@ -418,8 +436,8 @@ var InsuranceInput = function (_a) {
418
436
  }, [session, state, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
419
437
  var searchRef = (0, react_1.useRef)(query);
420
438
  (0, react_1.useEffect)(function () {
421
- var _a;
422
- if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== constants_1.CANVAS_TITLE) {
439
+ var _a, _b, _d, _e;
440
+ if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== constants_1.CANVAS_TITLE && ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) !== constants_1.BRIDGE_TITLE) {
423
441
  return;
424
442
  }
425
443
  if (!query)
@@ -427,24 +445,30 @@ var InsuranceInput = function (_a) {
427
445
  if (searchRef.current === query)
428
446
  return;
429
447
  searchRef.current = query;
430
- session.api.integrations.proxy_read({
431
- integration: constants_1.CANVAS_TITLE,
448
+ var integration = ((_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource) === constants_1.CANVAS_TITLE ? constants_1.CANVAS_TITLE : constants_1.BRIDGE_TITLE;
449
+ var type = ((_e = field === null || field === void 0 ? void 0 : field.options) === null || _e === void 0 ? void 0 : _e.dataSource) === constants_1.CANVAS_TITLE ? 'organizations' : 'payers';
450
+ var t = setTimeout(function () { return (session.api.integrations.proxy_read({
451
+ integration: integration,
432
452
  query: query,
433
- type: 'organizations',
453
+ type: type,
434
454
  })
435
455
  .then(function (_a) {
436
456
  var data = _a.data;
437
457
  try {
438
- setPayers(data.map(function (d) { return ({
439
- id: d.resource.id,
440
- name: d.resource.name,
441
- }); }));
458
+ setPayers(data.map(function (d) {
459
+ var _a, _b;
460
+ return ({
461
+ id: ((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE ? d.resource.id : d.id,
462
+ name: ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.CANVAS_TITLE ? d.resource.name : d.name,
463
+ });
464
+ }));
442
465
  }
443
466
  catch (err) {
444
467
  console.error;
445
468
  }
446
469
  })
447
- .catch(console.error);
470
+ .catch(console.error)); }, 300);
471
+ return function () { clearTimeout(t); };
448
472
  }, [session, (_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource, query]);
449
473
  return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, sx: { mt: '0' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Autocomplete, { freeSolo: !((_e = field.options) === null || _e === void 0 ? void 0 : _e.requirePredefinedInsurer), options: payers.map(function (p) { return p.name; }), value: (value === null || value === void 0 ? void 0 : value.payerName) || '', onChange: function (e, v) {
450
474
  var _a, _b;
@@ -464,35 +488,275 @@ var InsuranceInput = function (_a) {
464
488
  }
465
489
  onChange(__assign(__assign({}, value), { payerName: v || '', payerId: ((_b = payers.find(function (p) { return p.name === v; })) === null || _b === void 0 ? void 0 : _b.id) || '', payerType: ((_d = payers.find(function (p) { return p.name === v; })) === null || _d === void 0 ? void 0 : _d.type) || '' }), field.id);
466
490
  }, renderInput: function (params) {
467
- var _a;
468
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: exports.defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: ((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE ? "Search insurer..." : "Insurer" })));
469
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Member ID", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Plan Name", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Plan Start Date", field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
491
+ var _a, _b;
492
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: (inputProps || exports.defaultInputProps).sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE || ((_b = field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.BRIDGE_TITLE) ? "Search insurer..." : "Insurer" })));
493
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Member ID", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Plan Name", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Plan Start Date", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
470
494
  return onChange(__assign(__assign({}, value), { startDate: startDate }), field.id);
471
495
  } }) })), ((_j = field.options) === null || _j === void 0 ? void 0 : _j.includeGroupNumber) &&
472
- (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Group Number", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { size: "small", label: "Relationship to Policy Owner", options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === constants_1.CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === constants_1.CANVAS_TITLE)
496
+ (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Group Number", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { size: "small", label: "Relationship to Policy Owner", inputProps: inputProps, options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === constants_1.CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === constants_1.CANVAS_TITLE)
473
497
  ? constants_1.INSURANCE_RELATIONSHIPS_CANVAS
474
498
  : constants_1.INSURANCE_RELATIONSHIPS)
475
499
  .sort(function (x, y) { return x.localeCompare(y); }), value: (value === null || value === void 0 ? void 0 : value.relationship) || 'Self', onChange: function (relationship) {
476
500
  return onChange(__assign(__assign({}, value), { relationship: relationship || 'Self' }), field.id);
477
501
  } }) })), ((value === null || value === void 0 ? void 0 : value.relationship) || 'Self') !== 'Self' &&
478
- (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "First Name", size: "small", InputProps: exports.defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
502
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "First Name", size: "small", InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
479
503
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { fname: e.target.value }) }), field.id);
480
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Last Name", size: "small", InputProps: exports.defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
504
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Last Name", size: "small", InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
481
505
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { lname: e.target.value }) }), field.id);
482
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { options: constants_1.TELLESCOPE_GENDERS, size: "small", label: "Gender", value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
506
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { options: constants_1.TELLESCOPE_GENDERS, size: "small", label: "Gender", inputProps: inputProps, value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
483
507
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { gender: v }) }), field.id);
484
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Date of Birth", field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
508
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Date of Birth", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
485
509
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { dateOfBirth: dateOfBirth }) }), field.id);
486
510
  } }) }))] })] })));
487
511
  };
488
512
  exports.InsuranceInput = InsuranceInput;
489
513
  var StringSelector = function (_a) {
490
- var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue"]);
491
- return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: props.label }), (0, jsx_runtime_1.jsx)(material_1.Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: exports.defaultInputProps.sx }, { children: options.map(function (o, i) {
514
+ var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, inputProps = _a.inputProps, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue", "inputProps"]);
515
+ return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: props.label }), (0, jsx_runtime_1.jsx)(material_1.Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: (inputProps || exports.defaultInputProps).sx }, { children: options.map(function (o, i) {
492
516
  var _a;
493
517
  return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: o }, { children: (_a = getDisplayValue === null || getDisplayValue === void 0 ? void 0 : getDisplayValue(o)) !== null && _a !== void 0 ? _a : o }), o || i));
494
518
  }) }))] })));
495
519
  };
520
+ var BridgeEligibilityInput = function (_a) {
521
+ var _b, _d, _e, _f;
522
+ var field = _a.field, value = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, enduserId = _a.enduserId, props = __rest(_a, ["field", "value", "onChange", "responses", "enduser", "inputProps", "enduserId"]);
523
+ var session = (0, __1.useResolvedSession)();
524
+ var _g = (0, react_1.useState)(false), loading = _g[0], setLoading = _g[1];
525
+ var _h = (0, react_1.useState)(false), polling = _h[0], setPolling = _h[1];
526
+ var _j = (0, react_1.useState)(), error = _j[0], setError = _j[1];
527
+ // single-page form must require button-click to check, but 1-page-at-a-time enduser sessions should auto-check
528
+ var isEnduserSession = session.type === 'enduser';
529
+ var eligibilityType = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.bridgeEligibilityType) || 'Soft';
530
+ // Extract payerId from Insurance question response
531
+ var _k = (0, react_1.useMemo)(function () {
532
+ var _a, _b, _d, _e;
533
+ var insuranceResponse = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { var _a, _b, _d; return ((_a = r.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.payerId); });
534
+ if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
535
+ return [
536
+ (_b = insuranceResponse.answer.value) === null || _b === void 0 ? void 0 : _b.payerId,
537
+ (_d = insuranceResponse.answer.value) === null || _d === void 0 ? void 0 : _d.memberId,
538
+ (_e = insuranceResponse.answer.value) === null || _e === void 0 ? void 0 : _e.payerName,
539
+ ];
540
+ }
541
+ // existing payer id is automatically resolved on the backend as default
542
+ return [];
543
+ }, [responses]), payerId = _k[0], memberId = _k[1], payerName = _k[2];
544
+ // Extract state from Address question or enduser
545
+ var state = (0, react_1.useMemo)(function () {
546
+ var _a, _b;
547
+ // Find Address field with state value
548
+ var addressResponse = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { var _a, _b, _d; return ((_a = r.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.state); });
549
+ if (((_a = addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address') {
550
+ return (_b = addressResponse.answer.value) === null || _b === void 0 ? void 0 : _b.state;
551
+ }
552
+ // enduser state is automatically resolved on the backend as default
553
+ }, [responses]);
554
+ // Soft eligibility check function
555
+ var checkProviderEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
556
+ var serviceTypeId, data, userIds, err_1;
557
+ var _a;
558
+ return __generator(this, function (_b) {
559
+ switch (_b.label) {
560
+ case 0:
561
+ serviceTypeId = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeId;
562
+ if (!serviceTypeId) {
563
+ setError('Bridge Service Type ID not configured');
564
+ return [2 /*return*/];
565
+ }
566
+ // payerId and state can be automatically resolved on the backend, if already saved on Enduser, so not required here
567
+ setLoading(true);
568
+ setError(undefined);
569
+ _b.label = 1;
570
+ case 1:
571
+ _b.trys.push([1, 3, 4, 5]);
572
+ return [4 /*yield*/, session.api.integrations.proxy_read({
573
+ id: enduserId,
574
+ integration: constants_1.BRIDGE_TITLE,
575
+ type: 'provider-eligibility',
576
+ query: JSON.stringify({
577
+ serviceTypeId: serviceTypeId,
578
+ payerId: payerId,
579
+ state: state,
580
+ }),
581
+ })
582
+ // Store userIds in shared variable for Appointment Booking to use
583
+ ];
584
+ case 2:
585
+ data = (_b.sent()).data;
586
+ userIds = (data === null || data === void 0 ? void 0 : data.userIds) || [];
587
+ (0, exports.setBridgeEligibilityUserIds)(userIds);
588
+ // Update the answer with the eligibility result
589
+ onChange({
590
+ status: (data === null || data === void 0 ? void 0 : data.status) || 'unknown',
591
+ userIds: userIds,
592
+ }, field.id);
593
+ return [3 /*break*/, 5];
594
+ case 3:
595
+ err_1 = _b.sent();
596
+ setError((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || 'Failed to check eligibility');
597
+ console.error('Provider eligibility check failed:', err_1);
598
+ return [3 /*break*/, 5];
599
+ case 4:
600
+ setLoading(false);
601
+ return [7 /*endfinally*/];
602
+ case 5: return [2 /*return*/];
603
+ }
604
+ });
605
+ }); }, [session, field, payerId, state, onChange, enduserId]);
606
+ // Hard eligibility check function with polling
607
+ var checkServiceEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
608
+ var serviceTypeId, data, serviceEligibilityId_1, pollForResults, err_2;
609
+ var _a;
610
+ return __generator(this, function (_b) {
611
+ switch (_b.label) {
612
+ case 0:
613
+ serviceTypeId = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeId;
614
+ if (!serviceTypeId) {
615
+ setError('Bridge Service Type ID not configured');
616
+ return [2 /*return*/];
617
+ }
618
+ setLoading(true);
619
+ setError(undefined);
620
+ _b.label = 1;
621
+ case 1:
622
+ _b.trys.push([1, 3, , 4]);
623
+ return [4 /*yield*/, session.api.integrations.proxy_read({
624
+ id: enduserId,
625
+ integration: constants_1.BRIDGE_TITLE,
626
+ type: 'service-eligibility',
627
+ query: JSON.stringify({
628
+ serviceTypeId: serviceTypeId,
629
+ payerId: payerId,
630
+ memberId: memberId,
631
+ state: state,
632
+ }),
633
+ })];
634
+ case 2:
635
+ data = (_b.sent()).data;
636
+ serviceEligibilityId_1 = data === null || data === void 0 ? void 0 : data.id;
637
+ if (!serviceEligibilityId_1) {
638
+ throw new Error('No service eligibility ID returned');
639
+ }
640
+ setLoading(false);
641
+ setPolling(true);
642
+ pollForResults = function () { return __awaiter(void 0, void 0, void 0, function () {
643
+ var maxAttempts, attempts, poll;
644
+ return __generator(this, function (_a) {
645
+ maxAttempts = 60 // Poll for up to 60 attempts (2 minutes at 2s intervals)
646
+ ;
647
+ attempts = 0;
648
+ poll = function () { return __awaiter(void 0, void 0, void 0, function () {
649
+ var pollData, status_1, userIds, err_3;
650
+ return __generator(this, function (_a) {
651
+ switch (_a.label) {
652
+ case 0:
653
+ if (attempts >= maxAttempts) {
654
+ setError('Eligibility check timed out. Please try again.');
655
+ setPolling(false);
656
+ return [2 /*return*/];
657
+ }
658
+ attempts++;
659
+ _a.label = 1;
660
+ case 1:
661
+ _a.trys.push([1, 3, , 4]);
662
+ return [4 /*yield*/, session.api.integrations.proxy_read({
663
+ id: serviceEligibilityId_1,
664
+ integration: constants_1.BRIDGE_TITLE,
665
+ type: 'service-eligibility-poll',
666
+ })];
667
+ case 2:
668
+ pollData = (_a.sent()).data;
669
+ status_1 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
670
+ // Check if we're in a terminal state
671
+ if (status_1 && status_1 !== 'PENDING') {
672
+ userIds = (pollData === null || pollData === void 0 ? void 0 : pollData.userIds) || [];
673
+ (0, exports.setBridgeEligibilityUserIds)(userIds);
674
+ // Update the answer with the eligibility result
675
+ onChange({
676
+ status: status_1 || 'unknown',
677
+ userIds: userIds,
678
+ }, field.id);
679
+ setPolling(false);
680
+ return [2 /*return*/];
681
+ }
682
+ // Still pending, poll again after delay
683
+ setTimeout(poll, 2000); // Poll every 2 seconds
684
+ return [3 /*break*/, 4];
685
+ case 3:
686
+ err_3 = _a.sent();
687
+ setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to poll eligibility status');
688
+ console.error('Service eligibility polling failed:', err_3);
689
+ setPolling(false);
690
+ return [3 /*break*/, 4];
691
+ case 4: return [2 /*return*/];
692
+ }
693
+ });
694
+ }); };
695
+ poll();
696
+ return [2 /*return*/];
697
+ });
698
+ }); };
699
+ pollForResults();
700
+ return [3 /*break*/, 4];
701
+ case 3:
702
+ err_2 = _b.sent();
703
+ setError((err_2 === null || err_2 === void 0 ? void 0 : err_2.message) || 'Failed to check service eligibility');
704
+ console.error('Service eligibility check failed:', err_2);
705
+ setLoading(false);
706
+ setPolling(false);
707
+ return [3 /*break*/, 4];
708
+ case 4: return [2 /*return*/];
709
+ }
710
+ });
711
+ }); }, [session, field, payerId, memberId, state, onChange, enduserId]);
712
+ // Auto-check eligibility for enduser sessions
713
+ var autoCheckRef = (0, react_1.useRef)(false);
714
+ (0, react_1.useEffect)(function () {
715
+ if (!isEnduserSession)
716
+ return;
717
+ if (autoCheckRef.current)
718
+ return;
719
+ autoCheckRef.current = true;
720
+ if (eligibilityType === 'Hard') {
721
+ checkServiceEligibility();
722
+ }
723
+ else {
724
+ checkProviderEligibility();
725
+ }
726
+ }, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility]);
727
+ var errorComponent = (0, react_1.useMemo)(function () { return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, __assign({ style: {
728
+ padding: 16,
729
+ backgroundColor: '#ffebee',
730
+ border: '2px solid #f44336'
731
+ } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h2", style: { color: '#f44336' } }, { children: "\u26A0\uFE0F" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", align: "center", color: "error" }, { children: "Unable to Check Eligibility" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", align: "center", style: { color: '#d32f2f' } }, { children: error })) }))] })) })) })) }))); }, [error]);
732
+ var checkingEligibilityComponent = (0, react_1.useMemo)(function () { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 40 }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1" }, { children: polling ? 'Verifying eligibility with insurance...' : 'Checking eligibility...' })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: polling ? 'This usually takes 15-30 seconds' : 'This may take a few moments' })) }))] }))); }, [polling]);
733
+ var resultsComponent = (0, react_1.useMemo)(function () {
734
+ var isEligible = (value === null || value === void 0 ? void 0 : value.status) === 'ELIGIBLE';
735
+ return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, __assign({ style: {
736
+ padding: 16,
737
+ backgroundColor: isEligible ? '#e8f5e9' : '#fff3e0',
738
+ border: "2px solid ".concat(isEligible ? '#4caf50' : '#ff9800')
739
+ } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: isEligible ? ((0, jsx_runtime_1.jsx)(icons_material_1.CheckCircleOutline, { style: { fontSize: 48, color: '#4caf50' } })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h2", style: { color: '#ff9800' } }, { children: "\u26A0\uFE0F" }))) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", align: "center" }, { children: isEligible
740
+ ? "".concat(payerName || 'Your insurance provider', " is accepted!")
741
+ : 'Eligibility Status: ' + (0, utilities_1.first_letter_capitalized)(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
742
+ }, [value]);
743
+ // Loading/polling state for enduser sessions
744
+ if (isEnduserSession) {
745
+ if (loading || polling) {
746
+ return checkingEligibilityComponent;
747
+ }
748
+ if (error) {
749
+ return errorComponent;
750
+ }
751
+ if (value === null || value === void 0 ? void 0 : value.status) {
752
+ return resultsComponent;
753
+ }
754
+ return errorComponent;
755
+ }
756
+ // User/admin interface (non-enduser sessions)
757
+ return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Service Type: ", ((_d = field.options) === null || _d === void 0 ? void 0 : _d.bridgeServiceTypeId) || 'Not configured'] })), state && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["State: ", state] })), payerId && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Payer ID: ", payerId] })), memberId && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Member ID: ", memberId] }))] })), error && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "error" }, { children: error })) }))), polling && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "primary" }, { children: "Polling for results... (this may take 15-30 seconds)" })) }))), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(__1.LoadingButton, { variant: "outlined", onClick: checkProviderEligibility, submitText: "Check Provider Eligibility (Free)", submittingText: "Checking...", submitting: loading && !polling, disabled: !((_e = field.options) === null || _e === void 0 ? void 0 : _e.bridgeServiceTypeId) || loading || polling }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(__1.LoadingButton, { variant: "outlined", onClick: checkServiceEligibility, submitText: "Check Service Eligibility (Paid)", submittingText: polling ? "Polling..." : "Initiating...", submitting: loading || polling, disabled: !((_f = field.options) === null || _f === void 0 ? void 0 : _f.bridgeServiceTypeId) || loading || polling }) }))] })), value && ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "textSecondary" }, { children: "Current Answer:" })), (0, jsx_runtime_1.jsx)("pre", __assign({ style: { fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-word' } }, { children: JSON.stringify(value, null, 2) }))] })))] })));
758
+ };
759
+ exports.BridgeEligibilityInput = BridgeEligibilityInput;
496
760
  var HourSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: Array(12).fill('').map(function (_, i) { return (i + 1) <= 9 ? "0".concat(i + 1) : (i + 1).toString(); }) }))); };
497
761
  var MinuteSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: Array(60).fill('').map(function (_, i) { return i <= 9 ? "0".concat(i) : i.toString(); }) }))); };
498
762
  var AmPmSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: ['AM', 'PM'] }))); };
@@ -1886,17 +2150,17 @@ var RelatedContactsInput = function (_a) {
1886
2150
  };
1887
2151
  exports.RelatedContactsInput = RelatedContactsInput;
1888
2152
  var AppointmentBookingInput = function (_a) {
1889
- var _b, _d, _e, _f, _g, _h, _j, _k, _l;
2153
+ var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1890
2154
  var formResponseId = _a.formResponseId, field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, goToPreviousField = _a.goToPreviousField, isPreviousDisabled = _a.isPreviousDisabled, enduserId = _a.enduserId, props = __rest(_a, ["formResponseId", "field", "value", "onChange", "form", "responses", "goToPreviousField", "isPreviousDisabled", "enduserId"]);
1891
2155
  var session = (0, __1.useResolvedSession)();
1892
- var _m = (0, react_1.useState)(), loaded = _m[0], setLoaded = _m[1];
1893
- var _o = (0, react_1.useState)(''), error = _o[0], setError = _o[1];
1894
- var _p = (0, react_1.useState)(false), acknowledgedWarning = _p[0], setAcknowledgedWarning = _p[1];
1895
- var _q = (0, react_1.useState)(450), height = _q[0], setHeight = _q[1];
1896
- var _r = (0, react_1.useState)(false), confirming = _r[0], setConfirming = _r[1];
2156
+ var _o = (0, react_1.useState)(), loaded = _o[0], setLoaded = _o[1];
2157
+ var _p = (0, react_1.useState)(''), error = _p[0], setError = _p[1];
2158
+ var _q = (0, react_1.useState)(false), acknowledgedWarning = _q[0], setAcknowledgedWarning = _q[1];
2159
+ var _r = (0, react_1.useState)(450), height = _r[0], setHeight = _r[1];
2160
+ var _s = (0, react_1.useState)(false), confirming = _s[0], setConfirming = _s[1];
1897
2161
  var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
1898
2162
  var downloadICS = (0, react_1.useCallback)(function (event) { return __awaiter(void 0, void 0, void 0, function () {
1899
- var _a, err_1;
2163
+ var _a, err_4;
1900
2164
  return __generator(this, function (_b) {
1901
2165
  switch (_b.label) {
1902
2166
  case 0:
@@ -1908,8 +2172,8 @@ var AppointmentBookingInput = function (_a) {
1908
2172
  { name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
1909
2173
  return [3 /*break*/, 3];
1910
2174
  case 2:
1911
- err_1 = _b.sent();
1912
- console.error(err_1);
2175
+ err_4 = _b.sent();
2176
+ console.error(err_4);
1913
2177
  return [3 /*break*/, 3];
1914
2178
  case 3: return [2 /*return*/];
1915
2179
  }
@@ -2045,12 +2309,20 @@ var AppointmentBookingInput = function (_a) {
2045
2309
  })
2046
2310
  .join(','));
2047
2311
  }
2312
+ // Filter to Bridge eligibility userIds if option is enabled
2313
+ if ((_h = field.options) === null || _h === void 0 ? void 0 : _h.useBridgeEligibilityResult) {
2314
+ var bridgeUserIds = (0, exports.getBridgeEligibilityUserIds)();
2315
+ if (bridgeUserIds.length === 0) {
2316
+ return (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "No eligible users found for booking" });
2317
+ }
2318
+ bookingURL += "&userIds=".concat(bridgeUserIds.join(','));
2319
+ }
2048
2320
  // need to use form?.id for internally-submitted forms because formResponseId isn't generated until initial submission or saved draft
2049
- if (((_h = field.options) === null || _h === void 0 ? void 0 : _h.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
2321
+ if (((_j = field.options) === null || _j === void 0 ? void 0 : _j.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
2050
2322
  bookingURL += "&formResponseId=".concat(formResponseId || (field === null || field === void 0 ? void 0 : field.id));
2051
2323
  bookingURL += "&holdAppointmentMinutes=".concat(field.options.holdAppointmentMinutes);
2052
2324
  }
2053
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_k = (_j = field.options) === null || _j === void 0 ? void 0 : _j.userFilterTags) === null || _k === void 0 ? void 0 : _k.length) && !((_l = field.options.userTags) === null || _l === void 0 ? void 0 : _l.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
2325
+ return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_l = (_k = field.options) === null || _k === void 0 ? void 0 : _k.userFilterTags) === null || _l === void 0 ? void 0 : _l.length) && !((_m = field.options.userTags) === null || _m === void 0 ? void 0 : _m.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
2054
2326
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, alignSelf: "flex-start" }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", onClick: goToPreviousField, sx: { height: 25, p: 0.5, px: 1 } }, { children: "Back" })) })), loaded.warningMessage &&
2055
2327
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", sx: { fontSize: 20, fontWeight: 'bold' } }, { children: loaded.warningMessage })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (!loaded.warningMessage || acknowledgedWarning)
2056
2328
  ? ((0, jsx_runtime_1.jsx)("iframe", { title: "Appointment Booking Embed", src: bookingURL, style: { border: 'none', width: '100%', height: height } }))