var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import styled, { css } from "styled-components";
import { node, string } from "prop-types";
import Box from "../../../Box";
import Text from "../../../Text";
const PLAN_LINE_HEIGHT = 4;
const DISCOUNT_HEIGHT = 28;
const Plan = styled.article`
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  max-width: 312px;

  overflow: hidden;

  ${(props) => {
  const theme = props.theme.yoga;
  const { plan } = theme.components.card;
  return css`
      padding: ${plan.padding.top}px ${plan.padding.right}px
        ${plan.padding.bottom}px ${plan.padding.left}px;
      border: ${theme.borders.small}px solid ${theme.colors.light};
      border-radius: ${plan.radius}px;

      background-color: ${theme.colors.white};
    `;
}}
`;
const Border = styled.span`
  ${({ variant, hasRightMask, theme }) => {
  const { spacing, colors } = theme.yoga;
  const color = colors[variant] || variant;
  const MASK_SIZE = 112;
  const baseMaskStyle = css`
      position: absolute;
      height: ${MASK_SIZE}px;
      width: ${MASK_SIZE}px;
      content: '';
      background: radial-gradient(
        50% 50% at 50% 50%,
        ${colors.white} 0%,
        transparent 100%
      );
      border-radius: 50%;
    `;
  return css`
      position: absolute;
      top: 0;
      left: 0;

      display: inline-block;
      width: 100%;

      height: ${PLAN_LINE_HEIGHT}px;
      background-color: ${color};

      ::before {
        ${baseMaskStyle}
        left: ${spacing.large}px;
        top: -${MASK_SIZE - DISCOUNT_HEIGHT}px;
        opacity: 0.8;
      }

      ${hasRightMask && css`
        ::after {
          ${baseMaskStyle}
          top: -${MASK_SIZE - DISCOUNT_HEIGHT + PLAN_LINE_HEIGHT}px;
          right: ${spacing.large}px;
          opacity: 0.5;
        }
      `}
    `;
}}
`;
const DiscountWrapper = styled(Box).attrs({
  ph: "xsmall",
  pv: "xxxsmall"
})`
  ${({ bg, theme }) => {
  const { spacing, colors } = theme.yoga;
  return css`
      position: absolute;
      top: 0;
      right: 0;
      display: flex;
      align-items: center;
      min-height: ${DISCOUNT_HEIGHT}px;
      border-bottom-left-radius: ${spacing.small}px;

      ::before {
        content: '';
        position: absolute;
        left: -${DISCOUNT_HEIGHT}px;
        height: ${DISCOUNT_HEIGHT / 2 - PLAN_LINE_HEIGHT}px;
        width: ${DISCOUNT_HEIGHT}px;
        top: ${PLAN_LINE_HEIGHT}px;
        background: transparent;
        border-top-right-radius: ${spacing.small}px;
        box-shadow: ${colors[bg] || bg} ${spacing.xsmall}px -1px;
      }
    `;
}}
`;
function PlanCard(_a) {
  var _b = _a, { children, discount, variant = "deepPurple" } = _b, rest = __objRest(_b, ["children", "discount", "variant"]);
  const hasDiscount = !!discount;
  return /* @__PURE__ */ jsxs(Plan, __spreadProps(__spreadValues({}, rest), { children: [
    hasDiscount && /* @__PURE__ */ jsx(DiscountWrapper, { bg: variant, children: /* @__PURE__ */ jsx(Text.Tiny, { color: "white", fontWeight: "medium", children: discount }) }),
    /* @__PURE__ */ jsx(Border, { variant, hasRightMask: hasDiscount }),
    children
  ] }));
}
PlanCard.propTypes = {
  children: node,
  discount: string,
  variant: string
};
PlanCard.displayName = "PlanCard";
var PlanCard_default = PlanCard;
export {
  PLAN_LINE_HEIGHT,
  PlanCard_default as default
};
