import {
  markdownToPlainText
} from "./chunk-NMKKU2UG.js";
import {
  ArtifactServices,
  artifactToClipboardText
} from "./chunk-XFJ6XMJZ.js";
import {
  typographyMixin,
  typographyTypes
} from "./chunk-UXT2H3FM.js";
import {
  colors
} from "./chunk-JF3P66JF.js";

// src/components/blocks/types.ts
var blockTypes = {
  TEXT: "TEXT",
  ARTIFACT_REF: "ARTIFACT_REF"
};

// src/components/blocks/artifact-ref-block/artifact-ref-block.tsx
import { jsx } from "react/jsx-runtime";
function ArtifactRefBlock({ block }) {
  const { artifact, labels, callbacks } = block.payload;
  const entry = ArtifactServices[artifact.type];
  if (!entry) return null;
  const Component = entry.Component;
  return /* @__PURE__ */ jsx(Component, { artifact, labels, callbacks });
}

// src/components/blocks/block-services/artifact-ref-block-service.ts
var ArtifactRefBlockService = {
  type: blockTypes.ARTIFACT_REF,
  Component: ArtifactRefBlock,
  /**
   * Delegates to the registered artifact component's `toClipboardText`. Falls back to
   * `[Artifact: <title>]` via `artifactToClipboardText`'s own fallback when the artifact type
   * has no registered component, so copy never silently produces an empty string.
   */
  toClipboardText: (block) => artifactToClipboardText(block.payload.artifact)
};

// src/components/blocks/text-block/text-block.tsx
import ReactMarkdown from "react-markdown";
import remarkBreaks from "remark-breaks";
import remarkGfm from "remark-gfm";

// src/components/blocks/scrollable-table/scrollable-table-styles.ts
import styled from "styled-components";
var TableContainer = styled.div`
  position: relative;
  margin-block: 8px 16px;
`;
var TableScroll = styled.div`
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
`;

// src/components/blocks/scrollable-table/scrollable-table.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
function ScrollableTable({ node: _node, ...props }) {
  return /* @__PURE__ */ jsx2(TableContainer, { children: /* @__PURE__ */ jsx2(TableScroll, { children: /* @__PURE__ */ jsx2("table", { ...props }) }) });
}

// src/components/blocks/text-block/sanitize.ts
function sanitize(text) {
  return text.split("\n").filter((line) => {
    const t = line.trim();
    return !(t.startsWith("<!-- table-title:") && t.endsWith("-->"));
  }).join("\n");
}

// src/components/blocks/text-block/text-block-styles.ts
import styled2 from "styled-components";
var TextBlockWrapper = styled2.div`
  ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};
  color: ${colors["brown-100"]};
  word-break: break-word;

  & h1 {
    ${typographyMixin(typographyTypes.GEIST_HEADING_S_BOLD)};
    margin-block: 20px;
  }

  & h2 {
    ${typographyMixin(typographyTypes.GEIST_BODY_L_SEMI_BOLD)};
    margin-block: 12px;
  }

  & h3,
  & h4,
  & h5,
  & h6 {
    ${typographyMixin(typographyTypes.GEIST_BODY_M_SEMI_BOLD)};
    margin-block: 8px;
  }

  & strong {
    ${typographyMixin(typographyTypes.GEIST_BODY_S_SEMI_BOLD)};
  }

  & p {
    margin-block: 0px;
  }

  & p + p {
    margin-block: 8px 0px;
  }

  & ul,
  & ol {
    margin-block: 16px;
    padding-left: 20px;
  }

  & li + li {
    margin-block: 4px;
  }

  & ul {
    list-style-type: disc;
  }

  & ul ul {
    list-style-type: circle;
  }

  & ul ul ul {
    list-style-type: square;
  }

  & ol {
    list-style-type: decimal;
  }

  & ol ol {
    list-style-type: lower-alpha;
  }

  & ol ol ol {
    list-style-type: lower-roman;
  }

  & a {
    color: inherit;
    text-decoration-line: underline;
    text-decoration-style: dotted;
    text-decoration-thickness: auto;
    text-underline-offset: auto;
    text-underline-position: from-font;
    transition: color 75ms ease-in-out;

    &:hover {
      color: ${colors["blue-600"]};
    }
  }

  & hr {
    border: none;
    border-top: 1px solid ${colors["brown-40"]};
    margin-block: 20px;
  }

  & table {
    margin: 0;
    width: 100%;
    border-collapse: collapse;
  }

  & th,
  & td {
    border: none;
    border-bottom: 1px solid ${colors["brown-40"]};
    text-align: left;
  }

  & th {
    ${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};
    padding: 8px;
  }

  & td {
    ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
    padding: 16px 8px;
    min-width: 150px;
    width: 1%;
  }

  & td strong {
    font-weight: inherit;
    font-size: inherit;
    line-height: inherit;
  }

  & blockquote {
    margin-block: 4px;
    margin-inline: 0px;
    padding-left: 16px;
    border-left: 4px solid ${colors["brown-40"]};
    color: ${colors["brown-80"]};
  }
`;

// src/components/blocks/text-block/text-block.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
var markdownComponents = {
  table: ((tableProps) => /* @__PURE__ */ jsx3(ScrollableTable, { ...tableProps }))
};
function TextBlock({ block }) {
  return /* @__PURE__ */ jsx3(TextBlockWrapper, { children: /* @__PURE__ */ jsx3(ReactMarkdown, { remarkPlugins: [remarkGfm, remarkBreaks], components: markdownComponents, children: sanitize(block.payload.text) }) });
}

// src/components/blocks/block-services/text-block-service.ts
var TextBlockService = {
  type: blockTypes.TEXT,
  Component: TextBlock,
  /**
   * Converts the block's markdown source to plain text so the final clipboard value is clean
   * when pasted into tools that don't render markdown. Each block type owns its own clipboard
   * conversion so `useCopyToClipboard` can write text verbatim without a second pass.
   */
  toClipboardText: (block) => markdownToPlainText(block.payload.text)
};

// src/components/blocks/block-services/index.ts
var BlockServices = {
  [blockTypes.TEXT]: TextBlockService,
  [blockTypes.ARTIFACT_REF]: ArtifactRefBlockService
};

// src/components/blocks/block/block.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
function Block({ block }) {
  const service = BlockServices[block.type];
  if (!service) return null;
  const { Component } = service;
  return /* @__PURE__ */ jsx4(Component, { block });
}

export {
  blockTypes,
  ArtifactRefBlock,
  ArtifactRefBlockService,
  TextBlockService,
  BlockServices,
  Block
};
//# sourceMappingURL=chunk-MDAWYZBI.js.map