{"version":3,"file":"button.cjs","sourceRoot":"","sources":["../../../src/ui/components/button.ts"],"names":[],"mappings":";;;AACA,uDAAgF;AAEhF,yDAAqD;AACrD,4CAA2C;AAC3C,wCAAmD;AAEnD,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;AACzB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAEY,QAAA,YAAY,GAAG,IAAA,oBAAM,EAChC,qBAAa,EACb,IAAA,oBAAM,EAAC;IACL,IAAI,EAAE,IAAA,mBAAO,EAAC,gBAAQ,CAAC,MAAM,CAAC;IAC9B,KAAK,EAAE,IAAA,oBAAM,GAAE;IACf,OAAO,EAAE,IAAA,sBAAQ,EACf,IAAA,mBAAK,EAAC;QACJ,IAAA,qBAAS,EAAC,aAAa,CAAC,OAAO,CAAC;QAChC,IAAA,qBAAS,EAAC,aAAa,CAAC,SAAS,CAAC;KACnC,CAAC,CACH;IACD,UAAU,EAAE,IAAA,sBAAQ,EAClB,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAS,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAA,qBAAS,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CACpE;IACD,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CACH,CAAC;AAaF;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,MAAM,GAAG,IAAA,uBAAa,EAAC,gBAAQ,CAAC,MAAM,EAAE,oBAAY,EAAE;IACjE,OAAO;IACP,YAAY;IACZ,MAAM;IACN,SAAS;CACV,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { assign, object, optional, string, union } from '@metamask/superstruct';\n\nimport { enumValue, literal } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport enum ButtonVariant {\n  Primary = 'primary',\n  Secondary = 'secondary',\n}\n\nexport enum ButtonType {\n  Button = 'button',\n  Submit = 'submit',\n}\n\nexport const ButtonStruct = assign(\n  LiteralStruct,\n  object({\n    type: literal(NodeType.Button),\n    value: string(),\n    variant: optional(\n      union([\n        enumValue(ButtonVariant.Primary),\n        enumValue(ButtonVariant.Secondary),\n      ]),\n    ),\n    buttonType: optional(\n      union([enumValue(ButtonType.Button), enumValue(ButtonType.Submit)]),\n    ),\n    name: optional(string()),\n  }),\n);\n\n/**\n * A button node, that renders either a primary or a secondary button.\n *\n * @property type - The type of the node, must be the string 'button'.\n * @property variant - The style variant of the node, must be either 'primary' or 'secondary'.\n * @property value - The text content of the node as plain text.\n * @property buttonType - The type of the button, must be either 'button' or 'submit'.\n * @property name - An optional name to identify the button.\n */\nexport type Button = Infer<typeof ButtonStruct>;\n\n/**\n * Create a {@link Button} node.\n *\n * @param args - The node arguments. This can be either a string, or an object\n * with a `value` property. A set of optional properties can be passed.\n * @param args.variant - The optional variant of the button.\n * @param args.value - The text content of the node.\n * @param args.name - The optional name of the button.\n * @returns The text node as object.\n * @deprecated Snaps component functions are deprecated, in favor of the new JSX\n * components. This function will be removed in a future release.\n * @example\n * ```typescript\n * const node = button({  variant: 'primary', text: 'Hello, world!', name: 'myButton' });\n * const node = button('Hello, world!', 'button', 'myButton', 'primary');\n * const node = button('Hello, world!');\n * ```\n */\nexport const button = createBuilder(NodeType.Button, ButtonStruct, [\n  'value',\n  'buttonType',\n  'name',\n  'variant',\n]);\n"]}