{
  "version": 3,
  "sources": ["../../src/lib/component.ts"],
  "sourcesContent": ["import { VanillaMachine } from \"@zag-js/vanilla\";\n\ninterface ComponentInterface<Api> {\n  el: HTMLElement;\n  machine: VanillaMachine<any>;\n  api: Api;\n\n  init(): void;\n  destroy(): void;\n  render(): void;\n}\n\nexport abstract class Component<Props, Api> implements ComponentInterface<Api> {\n  el: HTMLElement;\n  machine: VanillaMachine<any>;\n  api: Api;\n\n  constructor(el: HTMLElement | null, props: Props) {\n    if (!el) throw new Error(\"Root element not found\");\n    this.el = el;\n    this.machine = this.initMachine(props);\n    this.api = this.initApi();\n  }\n\n  abstract initMachine(props: Props): VanillaMachine<any>;\n  abstract initApi(): Api;\n  abstract render(): void;\n\n  init = () => {\n    this.render();\n    this.machine.subscribe(() => {\n      this.api = this.initApi();\n      this.render();\n    });\n    this.machine.start();\n  };\n\n  destroy = () => {\n    this.machine.stop();\n  };\n}\n"],
  "mappings": "AAYO,IAAeA,EAAf,KAAwE,CAC7E,GACA,QACA,IAEA,YAAYC,EAAwBC,EAAc,CAChD,GAAI,CAACD,EAAI,MAAM,IAAI,MAAM,wBAAwB,EACjD,KAAK,GAAKA,EACV,KAAK,QAAU,KAAK,YAAYC,CAAK,EACrC,KAAK,IAAM,KAAK,QAAQ,CAC1B,CAMA,KAAO,IAAM,CACX,KAAK,OAAO,EACZ,KAAK,QAAQ,UAAU,IAAM,CAC3B,KAAK,IAAM,KAAK,QAAQ,EACxB,KAAK,OAAO,CACd,CAAC,EACD,KAAK,QAAQ,MAAM,CACrB,EAEA,QAAU,IAAM,CACd,KAAK,QAAQ,KAAK,CACpB,CACF",
  "names": ["Component", "el", "props"]
}
