{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-TZAGH7A7.cjs","../src/core/templates/act-manager.ts"],"names":["ActTemplateManager","DatabaseAdapter","template","id","updates","row"],"mappings":"AAAA;AACA,wDAAmC,ICQtBA,CAAAA,CAAN,KAAyB,CACtB,WAER,CAAA,CAAc,CACZ,IAAA,CAAK,OAAA,CAAU,IAAIC,mBACrB,CAEA,MAAM,cAAA,CAAeC,CAAAA,CAMH,CAEhB,EAAA,CADe,MAAM,IAAA,CAAK,OAAA,CAAQ,cAAA,CAAeA,CAAAA,CAAS,EAAE,CAAA,CAE1D,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqBA,CAAAA,CAAS,EAAE,CAAA,gBAAA,CAAkB,CAAA,CAGpE,MAAM,IAAA,CAAK,OAAA,CAAQ,iBAAA,CAAkBA,CAAQ,CAC/C,CAEA,MAAM,cAAA,CACJC,CAAAA,CACAC,CAAAA,CAGe,CAEf,EAAA,CAAI,CADY,MAAM,IAAA,CAAK,OAAA,CAAQ,iBAAA,CAAkBD,CAAAA,CAAIC,CAAO,CAAA,CAE9D,MAAM,IAAI,KAAA,CAAM,CAAA,UAAA,EAAaD,CAAE,CAAA,mCAAA,CAAqC,CAExE,CAEA,MAAM,cAAA,CAAeA,CAAAA,CAA2B,CAE9C,EAAA,CAAI,CADY,MAAM,IAAA,CAAK,OAAA,CAAQ,iBAAA,CAAkBA,CAAE,CAAA,CAErD,MAAM,IAAI,KAAA,CAAM,CAAA,UAAA,EAAaA,CAAE,CAAA,mCAAA,CAAqC,CAExE,CAEA,MAAM,WAAA,CAAYA,CAAAA,CAA+C,CAC/D,IAAME,CAAAA,CAAM,MAAM,IAAA,CAAK,OAAA,CAAQ,cAAA,CAAeF,CAAE,CAAA,CAChD,OAAOE,CAAAA,CAAM,IAAA,CAAK,sBAAA,CAAuBA,CAAG,CAAA,CAAI,IAClD,CAEA,MAAM,mBAAA,CAAA,CAAoD,CAExD,MAAA,CADa,MAAM,IAAA,CAAK,OAAA,CAAQ,gBAAA,CAAiB,CAAA,CAAI,CAAA,CAAA,CACzC,GAAA,CAAI,IAAA,CAAK,sBAAsB,CAC7C,CAEA,MAAM,gBAAA,CAAA,CAAiD,CAErD,MAAA,CADa,MAAM,IAAA,CAAK,OAAA,CAAQ,gBAAA,CAAiB,CAAA,CAAK,CAAA,CAAA,CAC1C,GAAA,CAAI,IAAA,CAAK,sBAAsB,CAC7C,CAEQ,sBAAA,CAAuBA,CAAAA,CAA6B,CAC1D,MAAO,CACL,EAAA,CAAIA,CAAAA,CAAI,EAAA,CACR,KAAA,CAAOA,CAAAA,CAAI,KAAA,CACX,QAAA,CAAUA,CAAAA,CAAI,QAAA,CACd,WAAA,CAAaA,CAAAA,CAAI,WAAA,CACjB,QAAA,CAAUA,CAAAA,CAAI,QAAA,CACd,SAAA,CAAW,CAAA,CAAQA,CAAAA,CAAI,WAAA,CACvB,SAAA,CAAW,IAAI,IAAA,CAAKA,CAAAA,CAAI,UAAA,CAAa,GAAI,CAAA,CACzC,SAAA,CAAW,IAAI,IAAA,CAAKA,CAAAA,CAAI,UAAA,CAAa,GAAI,CAC3C,CACF,CACF,CAAA,CAAA,cAAA;AD3EA","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-TZAGH7A7.cjs","sourcesContent":[null,"import {DatabaseAdapter} from '../database/adapter.js';\nimport type {ActTemplate} from './act.js';\n\nexport interface CustomActTemplate extends ActTemplate {\n  isBuiltIn: boolean;\n  createdAt: Date;\n  updatedAt: Date;\n}\n\nexport class ActTemplateManager {\n  private adapter: DatabaseAdapter;\n\n  constructor() {\n    this.adapter = new DatabaseAdapter();\n  }\n\n  async createTemplate(template: {\n    id: string;\n    label: string;\n    category: string;\n    description: string;\n    template: string;\n  }): Promise<void> {\n    const exists = await this.adapter.templateExists(template.id);\n    if (exists) {\n      throw new Error(`Template with ID '${template.id}' already exists`);\n    }\n\n    await this.adapter.createActTemplate(template);\n  }\n\n  async updateTemplate(\n    id: string,\n    updates: Partial<\n      Pick<CustomActTemplate, 'label' | 'category' | 'description' | 'template'>\n    >,\n  ): Promise<void> {\n    const updated = await this.adapter.updateActTemplate(id, updates);\n    if (!updated) {\n      throw new Error(`Template '${id}' not found or could not be updated`);\n    }\n  }\n\n  async deleteTemplate(id: string): Promise<void> {\n    const deleted = await this.adapter.deleteActTemplate(id);\n    if (!deleted) {\n      throw new Error(`Template '${id}' not found or could not be deleted`);\n    }\n  }\n\n  async getTemplate(id: string): Promise<CustomActTemplate | null> {\n    const row = await this.adapter.getActTemplate(id);\n    return row ? this.mapToCustomActTemplate(row) : null;\n  }\n\n  async listCustomTemplates(): Promise<CustomActTemplate[]> {\n    const rows = await this.adapter.listActTemplates(true);\n    return rows.map(this.mapToCustomActTemplate);\n  }\n\n  async listAllTemplates(): Promise<CustomActTemplate[]> {\n    const rows = await this.adapter.listActTemplates(false);\n    return rows.map(this.mapToCustomActTemplate);\n  }\n\n  private mapToCustomActTemplate(row: any): CustomActTemplate {\n    return {\n      id: row.id,\n      label: row.label,\n      category: row.category,\n      description: row.description,\n      template: row.template,\n      isBuiltIn: Boolean(row.is_built_in),\n      createdAt: new Date(row.created_at * 1000),\n      updatedAt: new Date(row.updated_at * 1000),\n    };\n  }\n}\n"]}