{"version":3,"file":"vanilla.cjs","sources":["../src/vanilla.ts"],"sourcesContent":["import { WidgetController } from \"./lib/widget-controller\";\nimport type { FeedgetConfig } from \"./types\";\n\nexport type { FeedgetConfig };\n\nclass FeedgetWidget extends WidgetController {\n  init(): void {\n    this.attach(document.body, \"feedget-widget-root\");\n  }\n}\n\nlet feedgetInstance: FeedgetWidget | null = null;\n\nconst whenBodyReady = (callback: () => void) => {\n  if (document.body) callback();\n  else document.addEventListener(\"DOMContentLoaded\", callback, { once: true });\n};\n\nexport const Feedget = {\n  init(config: FeedgetConfig): void {\n    if (typeof document === \"undefined\") return;\n    if (!config?.apiKey) {\n      console.error(\"[Feedget] Informe a apiKey: Feedget.init({ apiKey: \\\"fgk_...\\\" }).\");\n      return;\n    }\n    if (feedgetInstance) {\n      console.warn(\n        \"Feedget already initialized. Use Feedget.updateConfig() to update configuration.\"\n      );\n      return;\n    }\n\n    const instance = new FeedgetWidget(config);\n    feedgetInstance = instance;\n    whenBodyReady(() => {\n      if (feedgetInstance === instance) instance.init();\n    });\n  },\n\n  destroy(): void {\n    if (feedgetInstance) {\n      feedgetInstance.destroy();\n      feedgetInstance = null;\n    }\n  },\n\n  updateConfig(config: Partial<FeedgetConfig>): void {\n    if (feedgetInstance) {\n      feedgetInstance.updateConfig(config);\n    } else {\n      console.error(\"Feedget not initialized. Call Feedget.init() first.\");\n    }\n  },\n};\n\ndeclare global {\n  interface Window {\n    Feedget: typeof Feedget;\n  }\n}\n\nif (typeof window !== \"undefined\") {\n  window.Feedget = Feedget;\n\n  const script = document.currentScript as HTMLScriptElement | null;\n  const apiKey = script?.dataset.apiKey;\n  if (apiKey) Feedget.init({ apiKey });\n}\n"],"names":["FeedgetWidget","WidgetController","feedgetInstance","whenBodyReady","callback","Feedget","config","instance","apiKey"],"mappings":"oIAKA,MAAMA,UAAsBC,EAAAA,gBAAiB,CAC3C,MAAa,CACX,KAAK,OAAO,SAAS,KAAM,qBAAqB,CAClD,CACF,CAEA,IAAIC,EAAwC,KAE5C,MAAMC,EAAiBC,GAAyB,CAC1C,SAAS,KAAMA,EAAA,WACL,iBAAiB,mBAAoBA,EAAU,CAAE,KAAM,GAAM,CAC7E,EAEaC,EAAU,CACrB,KAAKC,EAA6B,CAChC,GAAI,OAAO,SAAa,IAAa,OACrC,GAAI,CAACA,GAAQ,OAAQ,CACnB,QAAQ,MAAM,kEAAoE,EAClF,MACF,CACA,GAAIJ,EAAiB,CACnB,QAAQ,KACN,kFAAA,EAEF,MACF,CAEA,MAAMK,EAAW,IAAIP,EAAcM,CAAM,EACzCJ,EAAkBK,EAClBJ,EAAc,IAAM,CACdD,IAAoBK,GAAUA,EAAS,KAAA,CAC7C,CAAC,CACH,EAEA,SAAgB,CACVL,IACFA,EAAgB,QAAA,EAChBA,EAAkB,KAEtB,EAEA,aAAaI,EAAsC,CAC7CJ,EACFA,EAAgB,aAAaI,CAAM,EAEnC,QAAQ,MAAM,qDAAqD,CAEvE,CACF,EAQA,GAAI,OAAO,OAAW,IAAa,CACjC,OAAO,QAAUD,EAGjB,MAAMG,EADS,SAAS,eACD,QAAQ,OAC3BA,GAAQH,EAAQ,KAAK,CAAE,OAAAG,EAAQ,CACrC"}