{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/backup-and-sync/types.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACT,8BAA8B;AAa/B;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAI,WAAsB,EAAE,EAAE,CACzD,MAAM,CAAC;IACL,KAAK,EAAE,WAAW;IAClB,aAAa,EAAE,MAAM,EAAE;CACxB,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;IAClD,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,8BAA8B,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CACpD,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,MAAM,CAAC;IACvD,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,MAAM,CAAC;IACzD,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACxB,CAAC,CAAC","sourcesContent":["import type {\n  AccountGroupId,\n  AccountGroupType,\n  AccountWalletId,\n  AccountWalletType,\n} from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport {\n  object,\n  string,\n  boolean,\n  number,\n  optional,\n} from '@metamask/superstruct';\nimport type { Infer, Struct } from '@metamask/superstruct';\n\nimport type { AccountTreeController } from '../AccountTreeController';\nimport type {\n  AccountGroupMultichainAccountObject,\n  AccountTreeGroupPersistedMetadata,\n} from '../group';\nimport type { RuleResult } from '../rule';\nimport type { AccountTreeControllerMessenger } from '../types';\nimport type { AccountTreeWalletPersistedMetadata } from '../wallet';\nimport type { BackupAndSyncEmitAnalyticsEventParams } from './analytics';\n\n/**\n * Schema for an updatable field with value and timestamp.\n *\n * @param valueSchema - The schema for the value field.\n * @returns A superstruct schema for an updatable field.\n */\nconst UpdatableFieldSchema = <T>(valueSchema: Struct<T>) =>\n  object({\n    value: valueSchema,\n    lastUpdatedAt: number(),\n  });\n\n/**\n * Superstruct schema for UserStorageSyncedWallet validation.\n */\nexport const UserStorageSyncedWalletSchema = object({\n  name: optional(UpdatableFieldSchema(string())),\n  isLegacyAccountSyncingDisabled: optional(boolean()),\n});\n\n/**\n * Superstruct schema for UserStorageSyncedWalletGroup validation.\n */\nexport const UserStorageSyncedWalletGroupSchema = object({\n  name: optional(UpdatableFieldSchema(string())),\n  pinned: optional(UpdatableFieldSchema(boolean())),\n  hidden: optional(UpdatableFieldSchema(boolean())),\n  groupIndex: number(),\n});\n\n/**\n * Superstruct schema for LegacyUserStorageSyncedAccount validation.\n */\nexport const LegacyUserStorageSyncedAccountSchema = object({\n  v: optional(string()),\n  i: optional(string()),\n  a: optional(string()),\n  n: optional(string()),\n  nlu: optional(number()),\n});\n\nexport type UserStorageSyncedWallet = AccountTreeWalletPersistedMetadata &\n  Infer<typeof UserStorageSyncedWalletSchema>;\n\nexport type UserStorageSyncedWalletGroup = AccountTreeGroupPersistedMetadata & {\n  groupIndex: AccountGroupMultichainAccountObject['metadata']['entropy']['groupIndex'];\n} & Infer<typeof UserStorageSyncedWalletGroupSchema>;\n\nexport type LegacyUserStorageSyncedAccount = Infer<\n  typeof LegacyUserStorageSyncedAccountSchema\n>;\n\nexport type BackupAndSyncContext = {\n  messenger: AccountTreeControllerMessenger;\n  controller: AccountTreeController;\n  controllerStateUpdateFn: AccountTreeController['update'];\n  traceFn: TraceCallback;\n  groupIdToWalletId: Map<AccountGroupId, AccountWalletId>;\n  emitAnalyticsEventFn: (event: BackupAndSyncEmitAnalyticsEventParams) => void;\n};\n\nexport type LegacyAccountSyncingContext = {\n  listAccounts: () => InternalAccount[];\n  getEntropyRule: () => {\n    match: (\n      account: InternalAccount,\n    ) =>\n      | RuleResult<\n          AccountWalletType.Entropy,\n          AccountGroupType.MultichainAccount\n        >\n      | undefined;\n  };\n};\n\nexport type AtomicSyncEvent = {\n  execute: () => Promise<void>;\n};\n"]}