@delopay/sdk 0.74.0 → 0.75.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.
package/dist/index.d.cts CHANGED
@@ -5724,6 +5724,20 @@ interface CustomFieldOption {
5724
5724
  label: string;
5725
5725
  labelTranslations: CustomFieldTranslations;
5726
5726
  }
5727
+ type CustomFieldConditionSource = 'metadata' | 'currency' | 'amount';
5728
+ type CustomFieldOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'in' | 'not_in' | 'exists' | 'not_exists' | 'gt' | 'gte' | 'lt' | 'lte';
5729
+ interface CustomFieldCondition {
5730
+ id: string;
5731
+ source: CustomFieldConditionSource;
5732
+ key: string;
5733
+ operator: CustomFieldOperator;
5734
+ value: string;
5735
+ }
5736
+ interface CustomFieldVisibility {
5737
+ mode: 'always' | 'match';
5738
+ match: 'all' | 'any';
5739
+ conditions: CustomFieldCondition[];
5740
+ }
5727
5741
  interface CheckoutCustomField {
5728
5742
  id: string;
5729
5743
  key: string;
@@ -5740,6 +5754,7 @@ interface CheckoutCustomField {
5740
5754
  maxLength: number | null;
5741
5755
  defaultValue: string;
5742
5756
  options: CustomFieldOption[];
5757
+ visibility: CustomFieldVisibility;
5743
5758
  }
5744
5759
  interface CheckoutBranding {
5745
5760
  displayName: string;
@@ -5834,9 +5849,44 @@ declare function encodeBadges(badges: TrustBadge[]): string;
5834
5849
  declare const CUSTOM_FIELDS_MAX = 20;
5835
5850
  declare const CUSTOM_FIELD_KEY_PATTERN: RegExp;
5836
5851
  declare const ALL_CUSTOM_FIELD_TYPES: readonly CustomFieldType[];
5852
+ declare const CUSTOM_FIELD_CONDITIONS_MAX = 10;
5853
+ declare const ALL_CUSTOM_FIELD_CONDITION_SOURCES: readonly CustomFieldConditionSource[];
5854
+ declare const ALL_CUSTOM_FIELD_OPERATORS: readonly CustomFieldOperator[];
5855
+ declare const CUSTOM_FIELD_OPERATORS_BY_SOURCE: Record<CustomFieldConditionSource, readonly CustomFieldOperator[]>;
5856
+ declare const CUSTOM_FIELD_VALUELESS_OPERATORS: readonly CustomFieldOperator[];
5857
+ declare function customFieldOperatorTakesValue(operator: CustomFieldOperator): boolean;
5858
+ declare function defaultOperatorForSource(source: CustomFieldConditionSource): CustomFieldOperator;
5859
+ declare function defaultCustomFieldVisibility(): CustomFieldVisibility;
5837
5860
  declare function parseCustomFieldsLoose(raw: unknown): CheckoutCustomField[] | null;
5838
5861
  declare function decodeCustomFields(raw: string | undefined): CheckoutCustomField[] | null;
5839
5862
  declare function encodeCustomFields(fields: CheckoutCustomField[]): string;
5863
+ /** Facts a rule can read. `amount` is in the currency's minor unit (what
5864
+ * the payment intent stores); `metadata` values are already flattened to
5865
+ * strings by `customFieldContextFromMetadata`. */
5866
+ interface CustomFieldContext {
5867
+ amount: number;
5868
+ currency: string;
5869
+ metadata: Record<string, string>;
5870
+ }
5871
+ /** Flatten a payment's raw `metadata` object into the string map a rule
5872
+ * compares against. Arrays join on `,` so a list-shaped value stays usable
5873
+ * with `contains` / `in`; objects fall back to JSON. Mirrors the Rust
5874
+ * side's `flatten_metadata`. */
5875
+ declare function customFieldContextFromMetadata(raw: unknown): Record<string, string>;
5876
+ declare function evaluateCustomFieldCondition(condition: CustomFieldCondition, ctx: CustomFieldContext): boolean;
5877
+ /**
5878
+ * Whether a field's rule matches the payment.
5879
+ *
5880
+ * Fail-open in two spots, deliberately: `mode: 'always'` and a `match` rule
5881
+ * with no conditions both resolve to visible. A half-authored rule should
5882
+ * never silently swallow a field the merchant needs collected — the
5883
+ * control-center flags the empty rule as a validation issue instead.
5884
+ */
5885
+ declare function evaluateCustomFieldVisibility(field: CheckoutCustomField, ctx: CustomFieldContext): boolean;
5886
+ /** Filter a field list to what the buyer should see for this payment.
5887
+ * Disabled fields are dropped here too — the two reasons a field doesn't
5888
+ * render are the same to every consumer. */
5889
+ declare function visibleCustomFields(fields: CheckoutCustomField[], ctx: CustomFieldContext): CheckoutCustomField[];
5840
5890
  declare function customFieldText(field: CheckoutCustomField, part: 'label' | 'placeholder' | 'helpText', locale?: string): string;
5841
5891
  declare function customFieldOptionLabel(option: CustomFieldOption, locale?: string): string;
5842
5892
  declare function decodeBranding(source: BrandingSource | null | undefined): CheckoutBranding;
@@ -5869,4 +5919,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
5869
5919
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
5870
5920
  declare function shadowFor(style: SurfaceStyle): string;
5871
5921
 
5872
- export { ALL_CUSTOM_FIELD_TYPES, type AddUserRequest, type AddUserResponse, type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsMethodSlice, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyListConstraints, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AttemptStatus, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, CUSTOM_FIELDS_MAX, CUSTOM_FIELD_KEY_PATTERN, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type CheckoutCustomField, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCloneRequest, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorSelection, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CurrencyRevenue, type CustomFieldOption, type CustomFieldTranslations, type CustomFieldType, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, type DeleteUserRoleRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceBlock, type DisputeEvidenceRequest, type DisputeEvidenceType, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type ImpersonateEmployeeRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type ListUsersInLineageParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type MinimalRoleInfo, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentAttemptResponse, type PaymentAttemptsListResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentErrorDetails, type PaymentExperience, type PaymentIdFormatConfig, type PaymentIdStyle, type PaymentIntentStateMetadata, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentStatusHistoryEntityType, type PaymentStatusHistoryEvent, type PaymentStatusHistoryResponse, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProgramConnectorSelection, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundAggregateResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type RuleConnectorSelection, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopStatsResponse, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StatsPeriod, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UpdateUserRoleRequest, type UserInLineage, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, type WebhookRegistrationEnvironment, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, cloneCustomField, customFieldOptionLabel, customFieldText, decodeBadges, decodeBranding, decodeCustomFields, defaultBranding, encodeBadges, encodeBranding, encodeCustomFields, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseCustomFieldsLoose, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
5922
+ export { ALL_CUSTOM_FIELD_CONDITION_SOURCES, ALL_CUSTOM_FIELD_OPERATORS, ALL_CUSTOM_FIELD_TYPES, type AddUserRequest, type AddUserResponse, type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsMethodSlice, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyListConstraints, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AttemptStatus, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, CUSTOM_FIELDS_MAX, CUSTOM_FIELD_CONDITIONS_MAX, CUSTOM_FIELD_KEY_PATTERN, CUSTOM_FIELD_OPERATORS_BY_SOURCE, CUSTOM_FIELD_VALUELESS_OPERATORS, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type CheckoutCustomField, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCloneRequest, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorSelection, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CurrencyRevenue, type CustomFieldCondition, type CustomFieldConditionSource, type CustomFieldContext, type CustomFieldOperator, type CustomFieldOption, type CustomFieldTranslations, type CustomFieldType, type CustomFieldVisibility, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, type DeleteUserRoleRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceBlock, type DisputeEvidenceRequest, type DisputeEvidenceType, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type ImpersonateEmployeeRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type ListUsersInLineageParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type MinimalRoleInfo, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentAttemptResponse, type PaymentAttemptsListResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentErrorDetails, type PaymentExperience, type PaymentIdFormatConfig, type PaymentIdStyle, type PaymentIntentStateMetadata, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentStatusHistoryEntityType, type PaymentStatusHistoryEvent, type PaymentStatusHistoryResponse, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProgramConnectorSelection, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundAggregateResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type RuleConnectorSelection, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopStatsResponse, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StatsPeriod, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UpdateUserRoleRequest, type UserInLineage, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, type WebhookRegistrationEnvironment, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, cloneCustomField, customFieldContextFromMetadata, customFieldOperatorTakesValue, customFieldOptionLabel, customFieldText, decodeBadges, decodeBranding, decodeCustomFields, defaultBranding, defaultCustomFieldVisibility, defaultOperatorForSource, encodeBadges, encodeBranding, encodeCustomFields, evaluateCustomFieldCondition, evaluateCustomFieldVisibility, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseCustomFieldsLoose, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue, visibleCustomFields };
package/dist/index.d.ts CHANGED
@@ -5724,6 +5724,20 @@ interface CustomFieldOption {
5724
5724
  label: string;
5725
5725
  labelTranslations: CustomFieldTranslations;
5726
5726
  }
5727
+ type CustomFieldConditionSource = 'metadata' | 'currency' | 'amount';
5728
+ type CustomFieldOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'in' | 'not_in' | 'exists' | 'not_exists' | 'gt' | 'gte' | 'lt' | 'lte';
5729
+ interface CustomFieldCondition {
5730
+ id: string;
5731
+ source: CustomFieldConditionSource;
5732
+ key: string;
5733
+ operator: CustomFieldOperator;
5734
+ value: string;
5735
+ }
5736
+ interface CustomFieldVisibility {
5737
+ mode: 'always' | 'match';
5738
+ match: 'all' | 'any';
5739
+ conditions: CustomFieldCondition[];
5740
+ }
5727
5741
  interface CheckoutCustomField {
5728
5742
  id: string;
5729
5743
  key: string;
@@ -5740,6 +5754,7 @@ interface CheckoutCustomField {
5740
5754
  maxLength: number | null;
5741
5755
  defaultValue: string;
5742
5756
  options: CustomFieldOption[];
5757
+ visibility: CustomFieldVisibility;
5743
5758
  }
5744
5759
  interface CheckoutBranding {
5745
5760
  displayName: string;
@@ -5834,9 +5849,44 @@ declare function encodeBadges(badges: TrustBadge[]): string;
5834
5849
  declare const CUSTOM_FIELDS_MAX = 20;
5835
5850
  declare const CUSTOM_FIELD_KEY_PATTERN: RegExp;
5836
5851
  declare const ALL_CUSTOM_FIELD_TYPES: readonly CustomFieldType[];
5852
+ declare const CUSTOM_FIELD_CONDITIONS_MAX = 10;
5853
+ declare const ALL_CUSTOM_FIELD_CONDITION_SOURCES: readonly CustomFieldConditionSource[];
5854
+ declare const ALL_CUSTOM_FIELD_OPERATORS: readonly CustomFieldOperator[];
5855
+ declare const CUSTOM_FIELD_OPERATORS_BY_SOURCE: Record<CustomFieldConditionSource, readonly CustomFieldOperator[]>;
5856
+ declare const CUSTOM_FIELD_VALUELESS_OPERATORS: readonly CustomFieldOperator[];
5857
+ declare function customFieldOperatorTakesValue(operator: CustomFieldOperator): boolean;
5858
+ declare function defaultOperatorForSource(source: CustomFieldConditionSource): CustomFieldOperator;
5859
+ declare function defaultCustomFieldVisibility(): CustomFieldVisibility;
5837
5860
  declare function parseCustomFieldsLoose(raw: unknown): CheckoutCustomField[] | null;
5838
5861
  declare function decodeCustomFields(raw: string | undefined): CheckoutCustomField[] | null;
5839
5862
  declare function encodeCustomFields(fields: CheckoutCustomField[]): string;
5863
+ /** Facts a rule can read. `amount` is in the currency's minor unit (what
5864
+ * the payment intent stores); `metadata` values are already flattened to
5865
+ * strings by `customFieldContextFromMetadata`. */
5866
+ interface CustomFieldContext {
5867
+ amount: number;
5868
+ currency: string;
5869
+ metadata: Record<string, string>;
5870
+ }
5871
+ /** Flatten a payment's raw `metadata` object into the string map a rule
5872
+ * compares against. Arrays join on `,` so a list-shaped value stays usable
5873
+ * with `contains` / `in`; objects fall back to JSON. Mirrors the Rust
5874
+ * side's `flatten_metadata`. */
5875
+ declare function customFieldContextFromMetadata(raw: unknown): Record<string, string>;
5876
+ declare function evaluateCustomFieldCondition(condition: CustomFieldCondition, ctx: CustomFieldContext): boolean;
5877
+ /**
5878
+ * Whether a field's rule matches the payment.
5879
+ *
5880
+ * Fail-open in two spots, deliberately: `mode: 'always'` and a `match` rule
5881
+ * with no conditions both resolve to visible. A half-authored rule should
5882
+ * never silently swallow a field the merchant needs collected — the
5883
+ * control-center flags the empty rule as a validation issue instead.
5884
+ */
5885
+ declare function evaluateCustomFieldVisibility(field: CheckoutCustomField, ctx: CustomFieldContext): boolean;
5886
+ /** Filter a field list to what the buyer should see for this payment.
5887
+ * Disabled fields are dropped here too — the two reasons a field doesn't
5888
+ * render are the same to every consumer. */
5889
+ declare function visibleCustomFields(fields: CheckoutCustomField[], ctx: CustomFieldContext): CheckoutCustomField[];
5840
5890
  declare function customFieldText(field: CheckoutCustomField, part: 'label' | 'placeholder' | 'helpText', locale?: string): string;
5841
5891
  declare function customFieldOptionLabel(option: CustomFieldOption, locale?: string): string;
5842
5892
  declare function decodeBranding(source: BrandingSource | null | undefined): CheckoutBranding;
@@ -5869,4 +5919,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
5869
5919
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
5870
5920
  declare function shadowFor(style: SurfaceStyle): string;
5871
5921
 
5872
- export { ALL_CUSTOM_FIELD_TYPES, type AddUserRequest, type AddUserResponse, type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsMethodSlice, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyListConstraints, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AttemptStatus, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, CUSTOM_FIELDS_MAX, CUSTOM_FIELD_KEY_PATTERN, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type CheckoutCustomField, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCloneRequest, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorSelection, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CurrencyRevenue, type CustomFieldOption, type CustomFieldTranslations, type CustomFieldType, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, type DeleteUserRoleRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceBlock, type DisputeEvidenceRequest, type DisputeEvidenceType, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type ImpersonateEmployeeRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type ListUsersInLineageParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type MinimalRoleInfo, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentAttemptResponse, type PaymentAttemptsListResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentErrorDetails, type PaymentExperience, type PaymentIdFormatConfig, type PaymentIdStyle, type PaymentIntentStateMetadata, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentStatusHistoryEntityType, type PaymentStatusHistoryEvent, type PaymentStatusHistoryResponse, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProgramConnectorSelection, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundAggregateResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type RuleConnectorSelection, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopStatsResponse, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StatsPeriod, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UpdateUserRoleRequest, type UserInLineage, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, type WebhookRegistrationEnvironment, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, cloneCustomField, customFieldOptionLabel, customFieldText, decodeBadges, decodeBranding, decodeCustomFields, defaultBranding, encodeBadges, encodeBranding, encodeCustomFields, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseCustomFieldsLoose, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
5922
+ export { ALL_CUSTOM_FIELD_CONDITION_SOURCES, ALL_CUSTOM_FIELD_OPERATORS, ALL_CUSTOM_FIELD_TYPES, type AddUserRequest, type AddUserResponse, type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsMethodSlice, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyListConstraints, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AttemptStatus, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, CUSTOM_FIELDS_MAX, CUSTOM_FIELD_CONDITIONS_MAX, CUSTOM_FIELD_KEY_PATTERN, CUSTOM_FIELD_OPERATORS_BY_SOURCE, CUSTOM_FIELD_VALUELESS_OPERATORS, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type CheckoutCustomField, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCloneRequest, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorSelection, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CurrencyRevenue, type CustomFieldCondition, type CustomFieldConditionSource, type CustomFieldContext, type CustomFieldOperator, type CustomFieldOption, type CustomFieldTranslations, type CustomFieldType, type CustomFieldVisibility, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, type DeleteUserRoleRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceBlock, type DisputeEvidenceRequest, type DisputeEvidenceType, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type ImpersonateEmployeeRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type ListUsersInLineageParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type MinimalRoleInfo, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentAttemptResponse, type PaymentAttemptsListResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentErrorDetails, type PaymentExperience, type PaymentIdFormatConfig, type PaymentIdStyle, type PaymentIntentStateMetadata, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentStatusHistoryEntityType, type PaymentStatusHistoryEvent, type PaymentStatusHistoryResponse, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProgramConnectorSelection, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundAggregateResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type RuleConnectorSelection, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopStatsResponse, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StatsPeriod, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UpdateUserRoleRequest, type UserInLineage, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, type WebhookRegistrationEnvironment, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, cloneCustomField, customFieldContextFromMetadata, customFieldOperatorTakesValue, customFieldOptionLabel, customFieldText, decodeBadges, decodeBranding, decodeCustomFields, defaultBranding, defaultCustomFieldVisibility, defaultOperatorForSource, encodeBadges, encodeBranding, encodeCustomFields, evaluateCustomFieldCondition, evaluateCustomFieldVisibility, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseCustomFieldsLoose, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue, visibleCustomFields };
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import {
2
+ ALL_CUSTOM_FIELD_CONDITION_SOURCES,
3
+ ALL_CUSTOM_FIELD_OPERATORS,
2
4
  ALL_CUSTOM_FIELD_TYPES,
3
5
  Analytics,
4
6
  AnalyticsDashboard,
@@ -7,7 +9,10 @@ import {
7
9
  BRANDING_EXPORT_VERSION,
8
10
  CUSTOM_CSS_MAX_LENGTH,
9
11
  CUSTOM_FIELDS_MAX,
12
+ CUSTOM_FIELD_CONDITIONS_MAX,
10
13
  CUSTOM_FIELD_KEY_PATTERN,
14
+ CUSTOM_FIELD_OPERATORS_BY_SOURCE,
15
+ CUSTOM_FIELD_VALUELESS_OPERATORS,
11
16
  Cards,
12
17
  DEFAULT_BADGES,
13
18
  DEFAULT_BADGES_DARK,
@@ -32,15 +37,21 @@ import {
32
37
  buttonPadValue,
33
38
  cloneBranding,
34
39
  cloneCustomField,
40
+ customFieldContextFromMetadata,
41
+ customFieldOperatorTakesValue,
35
42
  customFieldOptionLabel,
36
43
  customFieldText,
37
44
  decodeBadges,
38
45
  decodeBranding,
39
46
  decodeCustomFields,
40
47
  defaultBranding,
48
+ defaultCustomFieldVisibility,
49
+ defaultOperatorForSource,
41
50
  encodeBadges,
42
51
  encodeBranding,
43
52
  encodeCustomFields,
53
+ evaluateCustomFieldCondition,
54
+ evaluateCustomFieldVisibility,
44
55
  feeProgram,
45
56
  fontStack,
46
57
  fontWeightValue,
@@ -57,9 +68,12 @@ import {
57
68
  sanitizeCustomCss,
58
69
  shadowFor,
59
70
  surfacePadValue,
60
- verticalGapValue
61
- } from "./chunk-5FA2IFIU.js";
71
+ verticalGapValue,
72
+ visibleCustomFields
73
+ } from "./chunk-5J763YMV.js";
62
74
  export {
75
+ ALL_CUSTOM_FIELD_CONDITION_SOURCES,
76
+ ALL_CUSTOM_FIELD_OPERATORS,
63
77
  ALL_CUSTOM_FIELD_TYPES,
64
78
  Analytics,
65
79
  AnalyticsDashboard,
@@ -68,7 +82,10 @@ export {
68
82
  BRANDING_EXPORT_VERSION,
69
83
  CUSTOM_CSS_MAX_LENGTH,
70
84
  CUSTOM_FIELDS_MAX,
85
+ CUSTOM_FIELD_CONDITIONS_MAX,
71
86
  CUSTOM_FIELD_KEY_PATTERN,
87
+ CUSTOM_FIELD_OPERATORS_BY_SOURCE,
88
+ CUSTOM_FIELD_VALUELESS_OPERATORS,
72
89
  Cards,
73
90
  DEFAULT_BADGES,
74
91
  DEFAULT_BADGES_DARK,
@@ -93,15 +110,21 @@ export {
93
110
  buttonPadValue,
94
111
  cloneBranding,
95
112
  cloneCustomField,
113
+ customFieldContextFromMetadata,
114
+ customFieldOperatorTakesValue,
96
115
  customFieldOptionLabel,
97
116
  customFieldText,
98
117
  decodeBadges,
99
118
  decodeBranding,
100
119
  decodeCustomFields,
101
120
  defaultBranding,
121
+ defaultCustomFieldVisibility,
122
+ defaultOperatorForSource,
102
123
  encodeBadges,
103
124
  encodeBranding,
104
125
  encodeCustomFields,
126
+ evaluateCustomFieldCondition,
127
+ evaluateCustomFieldVisibility,
105
128
  feeProgram,
106
129
  fontStack,
107
130
  fontWeightValue,
@@ -118,6 +141,7 @@ export {
118
141
  sanitizeCustomCss,
119
142
  shadowFor,
120
143
  surfacePadValue,
121
- verticalGapValue
144
+ verticalGapValue,
145
+ visibleCustomFields
122
146
  };
123
147
  //# sourceMappingURL=index.js.map
package/dist/internal.cjs CHANGED
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/internal.ts
21
21
  var internal_exports = {};
22
22
  __export(internal_exports, {
23
+ ALL_CUSTOM_FIELD_CONDITION_SOURCES: () => ALL_CUSTOM_FIELD_CONDITION_SOURCES,
24
+ ALL_CUSTOM_FIELD_OPERATORS: () => ALL_CUSTOM_FIELD_OPERATORS,
23
25
  ALL_CUSTOM_FIELD_TYPES: () => ALL_CUSTOM_FIELD_TYPES,
24
26
  Admin: () => Admin,
25
27
  AdminPortal: () => AdminPortal,
@@ -31,7 +33,10 @@ __export(internal_exports, {
31
33
  BRANDING_EXPORT_VERSION: () => BRANDING_EXPORT_VERSION,
32
34
  CUSTOM_CSS_MAX_LENGTH: () => CUSTOM_CSS_MAX_LENGTH,
33
35
  CUSTOM_FIELDS_MAX: () => CUSTOM_FIELDS_MAX,
36
+ CUSTOM_FIELD_CONDITIONS_MAX: () => CUSTOM_FIELD_CONDITIONS_MAX,
34
37
  CUSTOM_FIELD_KEY_PATTERN: () => CUSTOM_FIELD_KEY_PATTERN,
38
+ CUSTOM_FIELD_OPERATORS_BY_SOURCE: () => CUSTOM_FIELD_OPERATORS_BY_SOURCE,
39
+ CUSTOM_FIELD_VALUELESS_OPERATORS: () => CUSTOM_FIELD_VALUELESS_OPERATORS,
35
40
  Cache: () => Cache,
36
41
  CardIssuers: () => CardIssuers,
37
42
  Cards: () => Cards,
@@ -65,15 +70,21 @@ __export(internal_exports, {
65
70
  buttonPadValue: () => buttonPadValue,
66
71
  cloneBranding: () => cloneBranding,
67
72
  cloneCustomField: () => cloneCustomField,
73
+ customFieldContextFromMetadata: () => customFieldContextFromMetadata,
74
+ customFieldOperatorTakesValue: () => customFieldOperatorTakesValue,
68
75
  customFieldOptionLabel: () => customFieldOptionLabel,
69
76
  customFieldText: () => customFieldText,
70
77
  decodeBadges: () => decodeBadges,
71
78
  decodeBranding: () => decodeBranding,
72
79
  decodeCustomFields: () => decodeCustomFields,
73
80
  defaultBranding: () => defaultBranding,
81
+ defaultCustomFieldVisibility: () => defaultCustomFieldVisibility,
82
+ defaultOperatorForSource: () => defaultOperatorForSource,
74
83
  encodeBadges: () => encodeBadges,
75
84
  encodeBranding: () => encodeBranding,
76
85
  encodeCustomFields: () => encodeCustomFields,
86
+ evaluateCustomFieldCondition: () => evaluateCustomFieldCondition,
87
+ evaluateCustomFieldVisibility: () => evaluateCustomFieldVisibility,
77
88
  feeProgram: () => feeProgram,
78
89
  fontStack: () => fontStack,
79
90
  fontWeightValue: () => fontWeightValue,
@@ -90,7 +101,8 @@ __export(internal_exports, {
90
101
  sanitizeCustomCss: () => sanitizeCustomCss,
91
102
  shadowFor: () => shadowFor,
92
103
  surfacePadValue: () => surfacePadValue,
93
- verticalGapValue: () => verticalGapValue
104
+ verticalGapValue: () => verticalGapValue,
105
+ visibleCustomFields: () => visibleCustomFields
94
106
  });
95
107
  module.exports = __toCommonJS(internal_exports);
96
108
 
@@ -4007,7 +4019,11 @@ function cloneCustomField(f) {
4007
4019
  labelTranslations: { ...f.labelTranslations },
4008
4020
  placeholderTranslations: { ...f.placeholderTranslations },
4009
4021
  helpTextTranslations: { ...f.helpTextTranslations },
4010
- options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } }))
4022
+ options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } })),
4023
+ visibility: {
4024
+ ...f.visibility,
4025
+ conditions: f.visibility.conditions.map((c) => ({ ...c }))
4026
+ }
4011
4027
  };
4012
4028
  }
4013
4029
  var CUSTOM_CSS_MAX_LENGTH = 5e4;
@@ -4095,6 +4111,46 @@ var ALL_CUSTOM_FIELD_TYPES = [
4095
4111
  "email",
4096
4112
  "select"
4097
4113
  ];
4114
+ var CUSTOM_FIELD_CONDITIONS_MAX = 10;
4115
+ var ALL_CUSTOM_FIELD_CONDITION_SOURCES = [
4116
+ "metadata",
4117
+ "currency",
4118
+ "amount"
4119
+ ];
4120
+ var ALL_CUSTOM_FIELD_OPERATORS = [
4121
+ "equals",
4122
+ "not_equals",
4123
+ "contains",
4124
+ "not_contains",
4125
+ "starts_with",
4126
+ "ends_with",
4127
+ "in",
4128
+ "not_in",
4129
+ "exists",
4130
+ "not_exists",
4131
+ "gt",
4132
+ "gte",
4133
+ "lt",
4134
+ "lte"
4135
+ ];
4136
+ var CUSTOM_FIELD_OPERATORS_BY_SOURCE = {
4137
+ metadata: ALL_CUSTOM_FIELD_OPERATORS,
4138
+ currency: ["equals", "not_equals", "in", "not_in"],
4139
+ amount: ["equals", "not_equals", "gt", "gte", "lt", "lte"]
4140
+ };
4141
+ var CUSTOM_FIELD_VALUELESS_OPERATORS = [
4142
+ "exists",
4143
+ "not_exists"
4144
+ ];
4145
+ function customFieldOperatorTakesValue(operator) {
4146
+ return !CUSTOM_FIELD_VALUELESS_OPERATORS.includes(operator);
4147
+ }
4148
+ function defaultOperatorForSource(source) {
4149
+ return CUSTOM_FIELD_OPERATORS_BY_SOURCE[source][0] ?? "equals";
4150
+ }
4151
+ function defaultCustomFieldVisibility() {
4152
+ return { mode: "always", match: "all", conditions: [] };
4153
+ }
4098
4154
  function parseTranslations(raw) {
4099
4155
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
4100
4156
  const out = {};
@@ -4103,6 +4159,41 @@ function parseTranslations(raw) {
4103
4159
  }
4104
4160
  return out;
4105
4161
  }
4162
+ function normalizeCondition(raw, index) {
4163
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
4164
+ const c = raw;
4165
+ const source = pickEnum(
4166
+ c["source"],
4167
+ ALL_CUSTOM_FIELD_CONDITION_SOURCES,
4168
+ "metadata"
4169
+ );
4170
+ const allowed = CUSTOM_FIELD_OPERATORS_BY_SOURCE[source];
4171
+ const operator = pickEnum(
4172
+ c["operator"],
4173
+ allowed,
4174
+ defaultOperatorForSource(source)
4175
+ );
4176
+ const rawValue = c["value"];
4177
+ return {
4178
+ id: typeof c["id"] === "string" && c["id"] ? c["id"] : `cond-${index}`,
4179
+ source,
4180
+ // Only metadata conditions carry a key; drop anything else so the
4181
+ // encoded form stays canonical.
4182
+ key: source === "metadata" && typeof c["key"] === "string" ? c["key"].trim() : "",
4183
+ operator,
4184
+ value: typeof rawValue === "string" ? rawValue : typeof rawValue === "number" || typeof rawValue === "boolean" ? String(rawValue) : ""
4185
+ };
4186
+ }
4187
+ function normalizeVisibility(raw) {
4188
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return defaultCustomFieldVisibility();
4189
+ const v = raw;
4190
+ const conditions = Array.isArray(v["conditions"]) ? v["conditions"].slice(0, CUSTOM_FIELD_CONDITIONS_MAX).map(normalizeCondition).filter((c) => c !== null) : [];
4191
+ return {
4192
+ mode: pickEnum(v["mode"], ["always", "match"], "always"),
4193
+ match: pickEnum(v["match"], ["all", "any"], "all"),
4194
+ conditions
4195
+ };
4196
+ }
4106
4197
  function parseBoundedInt(raw) {
4107
4198
  const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
4108
4199
  if (!Number.isInteger(n) || n < 0) return null;
@@ -4140,7 +4231,8 @@ function normalizeCustomField(raw, index) {
4140
4231
  // Guard inverted bounds at decode so consumers never see min > max.
4141
4232
  maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
4142
4233
  defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
4143
- options
4234
+ options,
4235
+ visibility: normalizeVisibility(f["visibility"])
4144
4236
  };
4145
4237
  }
4146
4238
  function parseCustomFieldsLoose(raw) {
@@ -4184,10 +4276,118 @@ function encodeCustomFields(fields) {
4184
4276
  ...f.minLength !== null ? { minLength: f.minLength } : {},
4185
4277
  ...f.maxLength !== null ? { maxLength: f.maxLength } : {},
4186
4278
  ...f.defaultValue ? { defaultValue: f.defaultValue } : {},
4187
- ...f.type === "select" ? { options: f.options } : {}
4279
+ ...f.type === "select" ? { options: f.options } : {},
4280
+ // Omitted for unconditional fields so the stored blob (and every
4281
+ // pre-feature payload) stays byte-identical to what it was.
4282
+ ...f.visibility.mode === "match" ? { visibility: encodeVisibility(f.visibility) } : {}
4188
4283
  }))
4189
4284
  );
4190
4285
  }
4286
+ function encodeVisibility(v) {
4287
+ return {
4288
+ mode: v.mode,
4289
+ match: v.match,
4290
+ conditions: v.conditions.map((c) => ({
4291
+ id: c.id,
4292
+ source: c.source,
4293
+ ...c.source === "metadata" && c.key ? { key: c.key } : {},
4294
+ operator: c.operator,
4295
+ ...customFieldOperatorTakesValue(c.operator) && c.value ? { value: c.value } : {}
4296
+ }))
4297
+ };
4298
+ }
4299
+ function customFieldContextFromMetadata(raw) {
4300
+ const out = {};
4301
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return out;
4302
+ for (const [key, value] of Object.entries(raw)) {
4303
+ const flat = flattenMetadataValue(value);
4304
+ if (flat !== null) out[key] = flat;
4305
+ }
4306
+ return out;
4307
+ }
4308
+ function flattenMetadataValue(value) {
4309
+ if (typeof value === "string") return value;
4310
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
4311
+ if (value === null || value === void 0) return null;
4312
+ if (Array.isArray(value)) {
4313
+ return value.map((v) => flattenMetadataValue(v)).filter((v) => v !== null).join(",");
4314
+ }
4315
+ try {
4316
+ return JSON.stringify(value);
4317
+ } catch {
4318
+ return null;
4319
+ }
4320
+ }
4321
+ function norm(value) {
4322
+ return value.trim().toLowerCase();
4323
+ }
4324
+ var DECIMAL_NUMBER_PATTERN = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
4325
+ function numeric(value) {
4326
+ const trimmed = value.trim();
4327
+ if (!DECIMAL_NUMBER_PATTERN.test(trimmed)) return null;
4328
+ const n = Number(trimmed);
4329
+ return Number.isFinite(n) ? n : null;
4330
+ }
4331
+ function splitList(value) {
4332
+ return value.split(",").map((part) => norm(part)).filter((part) => part.length > 0);
4333
+ }
4334
+ function operandFor(condition, ctx) {
4335
+ switch (condition.source) {
4336
+ case "currency":
4337
+ return ctx.currency;
4338
+ case "amount":
4339
+ return String(ctx.amount);
4340
+ case "metadata":
4341
+ return Object.prototype.hasOwnProperty.call(ctx.metadata, condition.key) ? ctx.metadata[condition.key] : void 0;
4342
+ }
4343
+ }
4344
+ function evaluateCustomFieldCondition(condition, ctx) {
4345
+ const raw = operandFor(condition, ctx);
4346
+ const actual = raw ?? "";
4347
+ const expected = condition.value;
4348
+ switch (condition.operator) {
4349
+ case "exists":
4350
+ return raw !== void 0 && raw.trim().length > 0;
4351
+ case "not_exists":
4352
+ return raw === void 0 || raw.trim().length === 0;
4353
+ case "equals":
4354
+ return norm(actual) === norm(expected);
4355
+ case "not_equals":
4356
+ return norm(actual) !== norm(expected);
4357
+ case "contains":
4358
+ return norm(actual).includes(norm(expected));
4359
+ case "not_contains":
4360
+ return !norm(actual).includes(norm(expected));
4361
+ case "starts_with":
4362
+ return norm(actual).startsWith(norm(expected));
4363
+ case "ends_with":
4364
+ return norm(actual).endsWith(norm(expected));
4365
+ case "in":
4366
+ return splitList(expected).includes(norm(actual));
4367
+ case "not_in":
4368
+ return !splitList(expected).includes(norm(actual));
4369
+ case "gt":
4370
+ case "gte":
4371
+ case "lt":
4372
+ case "lte": {
4373
+ const a = numeric(actual);
4374
+ const b = numeric(expected);
4375
+ if (a === null || b === null) return false;
4376
+ if (condition.operator === "gt") return a > b;
4377
+ if (condition.operator === "gte") return a >= b;
4378
+ if (condition.operator === "lt") return a < b;
4379
+ return a <= b;
4380
+ }
4381
+ }
4382
+ }
4383
+ function evaluateCustomFieldVisibility(field, ctx) {
4384
+ const { mode, match, conditions } = field.visibility;
4385
+ if (mode !== "match" || conditions.length === 0) return true;
4386
+ return match === "any" ? conditions.some((c) => evaluateCustomFieldCondition(c, ctx)) : conditions.every((c) => evaluateCustomFieldCondition(c, ctx));
4387
+ }
4388
+ function visibleCustomFields(fields, ctx) {
4389
+ return fields.filter((f) => f.enabled && evaluateCustomFieldVisibility(f, ctx));
4390
+ }
4191
4391
  function translationFor(map, locale) {
4192
4392
  if (!locale) return null;
4193
4393
  const own = (k) => {
@@ -5128,6 +5328,8 @@ var DelopayInternal = class extends Delopay {
5128
5328
  };
5129
5329
  // Annotate the CommonJS export names for ESM import in node:
5130
5330
  0 && (module.exports = {
5331
+ ALL_CUSTOM_FIELD_CONDITION_SOURCES,
5332
+ ALL_CUSTOM_FIELD_OPERATORS,
5131
5333
  ALL_CUSTOM_FIELD_TYPES,
5132
5334
  Admin,
5133
5335
  AdminPortal,
@@ -5139,7 +5341,10 @@ var DelopayInternal = class extends Delopay {
5139
5341
  BRANDING_EXPORT_VERSION,
5140
5342
  CUSTOM_CSS_MAX_LENGTH,
5141
5343
  CUSTOM_FIELDS_MAX,
5344
+ CUSTOM_FIELD_CONDITIONS_MAX,
5142
5345
  CUSTOM_FIELD_KEY_PATTERN,
5346
+ CUSTOM_FIELD_OPERATORS_BY_SOURCE,
5347
+ CUSTOM_FIELD_VALUELESS_OPERATORS,
5143
5348
  Cache,
5144
5349
  CardIssuers,
5145
5350
  Cards,
@@ -5173,15 +5378,21 @@ var DelopayInternal = class extends Delopay {
5173
5378
  buttonPadValue,
5174
5379
  cloneBranding,
5175
5380
  cloneCustomField,
5381
+ customFieldContextFromMetadata,
5382
+ customFieldOperatorTakesValue,
5176
5383
  customFieldOptionLabel,
5177
5384
  customFieldText,
5178
5385
  decodeBadges,
5179
5386
  decodeBranding,
5180
5387
  decodeCustomFields,
5181
5388
  defaultBranding,
5389
+ defaultCustomFieldVisibility,
5390
+ defaultOperatorForSource,
5182
5391
  encodeBadges,
5183
5392
  encodeBranding,
5184
5393
  encodeCustomFields,
5394
+ evaluateCustomFieldCondition,
5395
+ evaluateCustomFieldVisibility,
5185
5396
  feeProgram,
5186
5397
  fontStack,
5187
5398
  fontWeightValue,
@@ -5198,6 +5409,7 @@ var DelopayInternal = class extends Delopay {
5198
5409
  sanitizeCustomCss,
5199
5410
  shadowFor,
5200
5411
  surfacePadValue,
5201
- verticalGapValue
5412
+ verticalGapValue,
5413
+ visibleCustomFields
5202
5414
  });
5203
5415
  //# sourceMappingURL=internal.cjs.map