"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var CryptoIcons_stories_exports = {};
__export(CryptoIcons_stories_exports, {
  ListCryptoIcons: () => ListCryptoIcons,
  SingleCryptoIcon: () => SingleCryptoIcon,
  default: () => CryptoIcons_stories_default
});
module.exports = __toCommonJS(CryptoIcons_stories_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import__ = require("../../..");
var cryptoIcons = __toESM(require("@ledgerhq/crypto-icons-ui/react"));
const description = `
### A customizable crypto-icon component.

### Props

\`\`\`tsx
type Props = {
  name: string;
  size?: number;
  color?: string;
  backgroundColor?: string; // overrides background color to ensure contrast with icon color
  circleIcon?: boolean; // if icon is in a circle or not
  tokenIcon?: string; // ref to the token icon to show as a sub icon
  disabled?: boolean;
  fallback?: JSX.Element; // fallback element if no icon found - defaults to an icon with first letter of icon name
};
\`\`\`
`;
const ScrollArea = (0, import_styled_components.default)(import__.Grid)`
  flex: 1;
  height: auto;
  ${(p) => p.theme.overflow.y};
`;
const Container = (0, import_styled_components.default)(import__.Flex).attrs({
  flex: 1,
  flexDirection: "column",
  p: 4
})`
  overflow: hidden;
  height: calc(100vh - 4em);
`;
const IconContainer = (0, import_styled_components.default)(import__.Flex).attrs({
  flexDirection: "column",
  justifyContent: "flex-end",
  alignItems: "center",
  p: 4
})`
  ${(p) => p.active ? `background-color: ${p.theme.colors.neutral.c20};` : ``}
  border-radius: 4px;
  height: 100px;
`;
const Bold = import_styled_components.default.b`
  color: ${(p) => p.theme.colors.primary.c80};
`;
const Story = {
  title: "Asorted/CryptoIcons",
  argTypes: {
    size: {
      type: "number",
      description: "Icon size for preview"
    },
    color: {
      type: "string",
      description: "Color",
      control: { control: "color" }
    },
    name: {
      type: "enum",
      description: "[Only for single icon], Icon name",
      options: Object.keys(cryptoIcons),
      control: {
        type: "select"
      }
    },
    circleIcon: {
      type: "boolean",
      description: "if icon is in a circle or not"
    },
    disabled: {
      type: "boolean",
      description: "if icon is in a disabled or not"
    },
    tokenIcon: {
      type: "string",
      description: "ref to the token icon to show as a sub icon"
    }
  },
  args: {
    size: 32,
    name: "BTC",
    circleIcon: false,
    disabled: false,
    tokenIcon: ""
  },
  parameters: {
    docs: {
      description: {
        component: description
      }
    }
  }
};
var CryptoIcons_stories_default = Story;
const ListTemplate = (args) => {
  const color = args.color || void 0;
  const [search, setSearch] = (0, import_react.useState)("");
  const s = search.toLowerCase();
  const regexp = new RegExp(s, "i");
  const { tokenIcon, disabled, circleIcon, size } = args;
  return /* @__PURE__ */ import_react.default.createElement(Container, null, /* @__PURE__ */ import_react.default.createElement(import__.SearchInput, { value: search, onChange: setSearch }), /* @__PURE__ */ import_react.default.createElement(
    ScrollArea,
    {
      gridTemplateColumns: "repeat(auto-fill, 100px);",
      gridTemplateRows: "repeat(auto-fill, 100px);",
      gridGap: 4,
      mt: 4
    },
    Object.keys(cryptoIcons).sort((a, b) => {
      return s ? b.toLowerCase().indexOf(s) - a.toLowerCase().indexOf(s) : a.localeCompare(b);
    }).map((name) => {
      const match = name.match(regexp);
      const active = s && match;
      const index = (match == null ? void 0 : match.index) ?? 0;
      return /* @__PURE__ */ import_react.default.createElement(IconContainer, { active: !!active }, /* @__PURE__ */ import_react.default.createElement(import__.Flex, { flex: 1, justifyContent: "center", alignItems: "center" }, /* @__PURE__ */ import_react.default.createElement(
        import__.CryptoIcon,
        {
          key: name,
          name,
          size,
          color,
          disabled,
          circleIcon,
          tokenIcon
        }
      )), /* @__PURE__ */ import_react.default.createElement(import__.Text, { variant: "extraSmall" }, active ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, name.substr(0, index), /* @__PURE__ */ import_react.default.createElement(Bold, null, name.substr(index, s.length)), name.substr(index + s.length)) : name));
    })
  ));
};
const IconTemplate = (args) => {
  const color = args.color || void 0;
  return /* @__PURE__ */ import_react.default.createElement(import__.CryptoIcon, { ...args, color });
};
const ListCryptoIcons = ListTemplate.bind({});
const SingleCryptoIcon = IconTemplate.bind({});
//# sourceMappingURL=CryptoIcons.stories.js.map
