{"version":3,"file":"Button.js","names":["ButtonBehaviorFrame","ButtonBehaviorText","ButtonBehaviorIcon"],"sources":["esm/components/Button.js"],"sourcesContent":["import {\n  ButtonFrame as ButtonBehaviorFrame,\n  ButtonIcon as ButtonBehaviorIcon,\n  ButtonText as ButtonBehaviorText,\n  useButton\n} from \"@tamagui/button\";\nimport {\n  createStyledContext,\n  createStyledHOC,\n  resolveSizing,\n  styled,\n  Theme,\n  withStaticProperties\n} from \"@tamagui/core\";\nimport { getThemedIconSize } from \"@tamagui/helpers-tamagui\";\nimport React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst ButtonContext = createStyledContext({ size: \"md\" });\nconst buttonSizing = (size, env) => resolveSizing(size, env) ?? resolveSizing(void 0, env);\nconst getButtonFrameSize = styled.dynamic((val, env) => {\n  const sizing = resolveSizing(val, env);\n  if (!sizing) return;\n  return {\n    paddingInline: sizing.paddingInline,\n    paddingBlock: sizing.paddingBlock,\n    borderRadius: sizing.radius,\n    gap: sizing.gap,\n    // keep text buttons at the same outer height as circular buttons: the\n    // text's line box plus vertical padding, plus the frame's 1px border\n    minHeight: sizing.height + 2,\n    // `size` is a control preset, not square geometry. keep the frame's width\n    // content-driven even if an outer styled layer also recognizes `size` as\n    // the generic width/height shorthand.\n    width: \"auto\"\n  };\n});\nconst getButtonTextSize = styled.dynamic((val, env) => {\n  const sizing = resolveSizing(val, env);\n  if (!sizing) return;\n  return {\n    fontSize: sizing.fontSize,\n    lineHeight: sizing.lineHeight\n  };\n});\nconst ButtonFrameBase = styled(ButtonBehaviorFrame, {\n  context: ButtonContext,\n  displayName: \"ButtonFrame\",\n  className: \"tm-button\",\n  backgroundColor: \"background hover:background-hover press:background-press\",\n  // flat by default, the way current libraries draw a button (shadcn's\n  // default variant has no border): the fill carries it, and the outlined\n  // variant adds the border back. the transparent border keeps the 1px every\n  // height below accounts for, so the variants line up\n  borderColor: \"transparent\",\n  borderStyle: \"solid\",\n  borderWidth: 1,\n  cursor: \"web:pointer\",\n  opacity: \"press:0.7\",\n  outlineColor: \"focus-visible:outline-color\",\n  outlineStyle: \"focus-visible:solid\",\n  outlineWidth: \"focus-visible:2px\",\n  variants: {\n    size: getButtonFrameSize,\n    circular: styled.dynamic(),\n    disabled: {\n      true: {\n        opacity: 0.35\n      }\n    },\n    variant: {\n      outlined: {\n        backgroundColor: \"transparent\",\n        borderColor: \"border-color\"\n      },\n      quiet: {\n        backgroundColor: \"transparent\",\n        borderColor: \"transparent\"\n      }\n    }\n  },\n  defaultVariants: {\n    size: \"md\"\n  }\n});\nconst ButtonFrame = ButtonFrameBase.resolve((props, env) => {\n  if (!props.circular) return;\n  const sizing = buttonSizing(props.size, env);\n  if (!sizing) return;\n  const side = sizing.height + 2;\n  return {\n    borderRadius: 1e3,\n    paddingHorizontal: 0,\n    height: side,\n    maxHeight: side,\n    maxWidth: side,\n    minWidth: side,\n    width: side\n  };\n});\nconst ButtonText = styled(ButtonBehaviorText, {\n  context: ButtonContext,\n  displayName: \"ButtonText\",\n  color: \"color\",\n  fontWeight: \"600\",\n  userSelect: \"none\",\n  variants: {\n    size: getButtonTextSize\n  },\n  defaultVariants: {\n    size: \"md\"\n  }\n});\nconst ButtonIcon = ({ size, ...props }) => {\n  const context = ButtonContext.useStyledContext();\n  return /* @__PURE__ */ jsx(\n    ButtonBehaviorIcon,\n    {\n      ...props,\n      size: size ?? getThemedIconSize(buttonSizing(context?.size)?.icon)\n    }\n  );\n};\nconst ButtonComponent = createStyledHOC(\n  ButtonFrame,\n  function Button(props, ref) {\n    const { theme, ...buttonBehaviorProps } = props;\n    const content = /* @__PURE__ */ jsx(Theme, { name: \"level2\", children: /* @__PURE__ */ jsx(ButtonInner, { ref, buttonBehaviorProps }) });\n    return theme ? /* @__PURE__ */ jsx(Theme, { name: theme, children: content }) : content;\n  },\n  { disableTheme: true }\n);\nconst ButtonInner = React.forwardRef(function ButtonInner2({ buttonBehaviorProps }, ref) {\n  const size = buttonBehaviorProps.size ?? ButtonContext.useStyledContext()?.size ?? \"md\";\n  const { props: buttonProps } = useButton(buttonBehaviorProps, {\n    Text: ButtonText,\n    iconSize: getThemedIconSize(buttonSizing(size)?.icon)\n  });\n  return /* @__PURE__ */ jsx(ButtonFrame, { ref, ...buttonProps });\n});\nconst Button2 = withStaticProperties(ButtonComponent, {\n  Frame: ButtonFrame,\n  Icon: ButtonIcon,\n  Text: ButtonText\n});\nexport {\n  Button2 as Button,\n  ButtonFrame,\n  ButtonIcon,\n  ButtonText\n};\n//# sourceMappingURL=Button.js.map\n"],"mappings":";;;;;;;AAiBA,MAAM,gBAAgB,oBAAoB,EAAE,MAAM,KAAK,CAAC;AACxD,MAAM,gBAAgB,MAAM,QAAQ,cAAc,MAAM,GAAG,KAAK,cAAc,KAAK,GAAG,GAAG;AACzF,MAAM,qBAAqB,OAAO,SAAS,KAAK,QAAQ;CACtD,MAAM,SAAS,cAAc,KAAK,GAAG;CACrC,IAAI,CAAC,QAAQ;CACb,OAAO;EACL,eAAe,OAAO;EACtB,cAAc,OAAO;EACrB,cAAc,OAAO;EACrB,KAAK,OAAO;EAGZ,WAAW,OAAO,SAAS;EAI3B,OAAO;CACT;AACF,CAAC;AACD,MAAM,oBAAoB,OAAO,SAAS,KAAK,QAAQ;CACrD,MAAM,SAAS,cAAc,KAAK,GAAG;CACrC,IAAI,CAAC,QAAQ;CACb,OAAO;EACL,UAAU,OAAO;EACjB,YAAY,OAAO;CACrB;AACF,CAAC;AACD,MAAM,kBAAkB,OAAOA,eAAqB;CAClD,SAAS;CACT,aAAa;CACb,WAAW;CACX,iBAAiB;CAKjB,aAAa;CACb,aAAa;CACb,aAAa;CACb,QAAQ;CACR,SAAS;CACT,cAAc;CACd,cAAc;CACd,cAAc;CACd,UAAU;EACR,MAAM;EACN,UAAU,OAAO,QAAQ;EACzB,UAAU,EACR,MAAM,EACJ,SAAS,IACX,EACF;EACA,SAAS;GACP,UAAU;IACR,iBAAiB;IACjB,aAAa;GACf;GACA,OAAO;IACL,iBAAiB;IACjB,a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