{"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import { defineSchema } from \"@json-render/core\";\n\n/**\n * The schema for @json-render/react-email\n *\n * Defines:\n * - Spec: A flat tree of elements with keys, types, props, and children references\n * - Catalog: Components with props schemas\n *\n * Reuses the same { root, elements } spec format as the React and React Native renderers.\n */\nexport const schema = defineSchema(\n  (s) => ({\n    spec: s.object({\n      root: s.string(),\n      elements: s.record(\n        s.object({\n          type: s.ref(\"catalog.components\"),\n          props: s.propsOf(\"catalog.components\"),\n          children: s.array(s.string()),\n          visible: { ...s.any(), ...s.optional() },\n          repeat: { ...s.any(), ...s.optional() },\n        }),\n      ),\n    }),\n\n    catalog: s.object({\n      components: s.map({\n        props: s.zod(),\n        slots: s.array(s.string()),\n        description: s.string(),\n        example: s.any(),\n      }),\n    }),\n  }),\n  {\n    defaultRules: [\n      \"The root element MUST be an Html component. Its children MUST include Head and Body components.\",\n      \"Body should contain a Container component to constrain width (typically 600px max for email clients).\",\n      \"All styles MUST be inline. Email clients strip <style> tags, so every component that accepts a style prop should use it for visual customization.\",\n      \"Image src must be a fully qualified URL (absolute, not relative). For placeholder images use https://picsum.photos/{width}/{height}?random={n}.\",\n      \"Emails are static documents. There are no interactive actions or form inputs.\",\n      \"Use Section, Row, and Column for layout. These map to table-based email structures for maximum compatibility.\",\n      \"Use Preview to set the preview text shown in email client inboxes before opening.\",\n      \"Use Heading (h1-h6) and Text for all text content. Raw strings are not supported.\",\n      \"Button renders as a link styled as a button. Always provide both text and href.\",\n      \"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist.\",\n      'REQUIRED FIELDS: Every element MUST include a \"children\" array. Leaf elements (text, badges, inputs, images) use an empty array: \"children\": []. Omitting \"children\" fails validation.',\n    ],\n  },\n);\n\nexport type ReactEmailSchema = typeof schema;\n\nexport type ReactEmailSpec<TCatalog> = typeof schema extends {\n  createCatalog: (catalog: TCatalog) => { _specType: infer S };\n}\n  ? S\n  : never;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAWtB,IAAM,SAAS;AAAA,EACpB,CAAC,OAAO;AAAA,IACN,MAAM,EAAE,OAAO;AAAA,MACb,MAAM,EAAE,OAAO;AAAA,MACf,UAAU,EAAE;AAAA,QACV,EAAE,OAAO;AAAA,UACP,MAAM,EAAE,IAAI,oBAAoB;AAAA,UAChC,OAAO,EAAE,QAAQ,oBAAoB;AAAA,UACrC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,UAC5B,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA,UACvC,QAAQ,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA,QACxC,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,IAED,SAAS,EAAE,OAAO;AAAA,MAChB,YAAY,EAAE,IAAI;AAAA,QAChB,OAAO,EAAE,IAAI;AAAA,QACb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,QACzB,aAAa,EAAE,OAAO;AAAA,QACtB,SAAS,EAAE,IAAI;AAAA,MACjB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EACA;AAAA,IACE,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}