{"version":3,"sources":["../../src/elements/code-block.ts"],"sourcesContent":["interface CodeBlock {\n  language?:\n    | 'apache'\n    | 'armasm'\n    | 'bash'\n    | 'c'\n    | 'coffeescript'\n    | 'cpp'\n    | 'csharp'\n    | 'css'\n    | 'd'\n    | 'diff'\n    | 'go'\n    | 'handlebars'\n    | 'haskell'\n    | 'http'\n    | 'ini'\n    | 'java'\n    | 'javascript'\n    | 'json'\n    | 'julia'\n    | 'kotlin'\n    | 'less'\n    | 'lua'\n    | 'makefile'\n    | 'markdown'\n    | 'nginx'\n    | 'objectivec'\n    | 'perl'\n    | 'php'\n    | 'plaintext'\n    | 'properties'\n    | 'python'\n    | 'r'\n    | 'ruby'\n    | 'rust'\n    | 'scala'\n    | 'scss'\n    | 'shell'\n    | 'sql'\n    | 'swift'\n    | 'typescript'\n    | 'x86asm'\n    | 'xml'\n    | 'yaml';\n  code: string;\n}\n\nexport const codeBlock = ({ language, code }: CodeBlock) => {\n  // Remove the new line at the start of the code block\n  const newCode = code.replace(/^\\n/, '');\n\n  // Get the whitespace from the first line\n  const match = newCode.match(/^(\\s+)/);\n  const whitespace = match ? match[1] : '';\n\n  // Decrease code indentation by the length of the whitespace from the first line\n  const lines = newCode\n    .trim()\n    .split('\\n')\n    .map((line) => line.replace(whitespace, ''));\n\n  return [`\\`\\`\\`${language ?? ''}`, lines.join('\\n'), '```'].join('\\n');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDO,MAAM,YAAY,CAAC,EAAE,UAAU,KAAK,MAAiB;AAE1D,QAAM,UAAU,KAAK,QAAQ,OAAO,EAAE;AAGtC,QAAM,QAAQ,QAAQ,MAAM,QAAQ;AACpC,QAAM,aAAa,QAAQ,MAAM,CAAC,IAAI;AAGtC,QAAM,QAAQ,QACX,KAAK,EACL,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,QAAQ,YAAY,EAAE,CAAC;AAE7C,SAAO,CAAC,SAAS,YAAY,EAAE,IAAI,MAAM,KAAK,IAAI,GAAG,KAAK,EAAE,KAAK,IAAI;AACvE;","names":[]}