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\n  array,\n  assert,\n  boolean,\n  number,\n  optional,\n  pattern,\n  string,\n  type,\n} from '@metamask/superstruct';\n\nimport type { DelegationResponse, NotificationPreferences } from './types';\n\n/**\n * Matches a 0x-prefixed hex string with zero or more hex digits.\n * Unlike `StrictHexStruct` from `@metamask/utils` (which requires at least\n * one digit after the prefix), this also accepts `\"0x\"` — the standard\n * encoding for empty bytes that the delegation API returns.\n */\nconst HexDataStruct = pattern(string(), /^0x[0-9a-f]*$/iu);\n\nconst CaveatSchema = type({\n  enforcer: HexDataStruct,\n  terms: HexDataStruct,\n  args: HexDataStruct,\n});\n\nconst SignedDelegationSchema = type({\n  delegate: HexDataStruct,\n  delegator: HexDataStruct,\n  authority: HexDataStruct,\n  caveats: array(CaveatSchema),\n  salt: HexDataStruct,\n  signature: HexDataStruct,\n});\n\nconst DelegationMetadataSchema = type({\n  delegationHash: HexDataStruct,\n  chainIdHex: HexDataStruct,\n  allowance: HexDataStruct,\n  tokenSymbol: string(),\n  tokenAddress: HexDataStruct,\n  type: string(),\n});\n\nconst DelegationResponseSchema = type({\n  signedDelegation: SignedDelegationSchema,\n  metadata: DelegationMetadataSchema,\n});\n\nconst WalletActivityAccountSchema = type({\n  address: HexDataStruct,\n  enabled: boolean(),\n});\n\nconst WalletActivityPreferenceSchema = type({\n  enabled: boolean(),\n  accounts: array(WalletActivityAccountSchema),\n});\n\nconst MarketingPreferenceSchema = type({\n  enabled: boolean(),\n});\n\nconst PerpsWatchlistExchangeSchema = type({\n  testnet: array(string()),\n  mainnet: array(string()),\n});\n\nconst PerpsWatchlistMarketsSchema = type({\n  hyperliquid: PerpsWatchlistExchangeSchema,\n  myx: PerpsWatchlistExchangeSchema,\n});\n\nconst PerpsPreferenceSchema = type({\n  enabled: boolean(),\n  watchlistMarkets: optional(PerpsWatchlistMarketsSchema),\n});\n\nconst SocialAIPreferenceSchema = type({\n  enabled: boolean(),\n  txAmountLimit: optional(number()),\n  traderProfileIds: array(string()),\n});\n\nconst NotificationPreferencesSchema = type({\n  walletActivity: WalletActivityPreferenceSchema,\n  marketing: MarketingPreferenceSchema,\n  perps: PerpsPreferenceSchema,\n  socialAI: SocialAIPreferenceSchema,\n});\n\n/**\n * Asserts that the given value is a valid `DelegationResponse[]`.\n *\n * @param data - The unknown value to validate.\n * @throws If the value does not match the expected schema.\n */\nexport function assertDelegationResponseArray(\n  data: unknown,\n): asserts data is DelegationResponse[] {\n  assert(data, array(DelegationResponseSchema));\n}\n\n/**\n * Asserts that the given value is a valid `NotificationPreferences`.\n *\n * @param data - The unknown value to validate.\n * @throws If the value does not match the expected schema.\n */\nexport function assertNotificationPreferences(\n  data: unknown,\n): asserts data is NotificationPreferences {\n  assert(data, NotificationPreferencesSchema);\n}\n"]}