{"version":3,"file":"notifizz-angular-test.mjs","sources":["../../../projects/notifizz-angular/src/lib/widget.ts","../../../projects/notifizz-angular/src/lib/notifizz-angular.component.ts","../../../projects/notifizz-angular/src/public-api.ts","../../../projects/notifizz-angular/src/notifizz-angular-test.ts"],"sourcesContent":["export interface NotifizzConfig {\n  apiKey: string;\n  apiUrl: string;\n  serverUrl: string;\n  widgetPath: string;\n}\n\nexport function importScriptInBrowser(config: NotifizzConfig) {\n  const head = document.head;\n  // Check if the script is already loaded\n  const existingScript = document.querySelector(\n    'script[data-widget=\"notifizz\"]'\n  );\n  if (existingScript) {\n    console.warn('Widget script is already loaded.');\n    return;\n  }\n  const script = document.createElement('script');\n\n  script.type = 'module';\n  script.dataset['widget'] = 'notifizz';\n  script.textContent = `(function (n, o, t, i, f) {\n    (n._notifizz = n._notifizz || {}),\n      (n._notifizz._queue = n._notifizz._queue || []),\n      (n.notifizz =\n        n.notifizz ||\n        function () {\n          let args = [];\n          for (i = 0; i < arguments.length; i++) args.push(arguments[i]);\n          n._notifizz._queue.push(args);\n        }),\n      (n._notifizz._notifizzSettings = {\n        apiKey: \"${config.apiKey}\",\n        loaderVersion: \"1\",\n        server: t,\n        apiUrl: \"${config.apiUrl}\"\n      }),\n      (f = o.getElementsByTagName(\"head\")[0]);\n    let r = o.createElement(\"script\");\n    r.type = 'module';\n    (r.async = !0), (r.src = t + i), f.appendChild(r);\n  })(window, document, \"${config.serverUrl}\", \"${config.widgetPath}\")`;\n\n  script.onerror = () => {\n    console.error('Failed to load the widget script.');\n  };\n\n  head.appendChild(script);\n}\n","import { Component, Input } from '@angular/core';\nimport { importScriptInBrowser } from './widget';\n\ndeclare global {\n  interface Window {\n    notifizz: (...args: any[]) => void;\n    initNotifizz: (...args: any[]) => void;\n    _notifizz: {\n      _notifizzSettings: {\n        apiKey: string;\n        server: string;\n        loaderVersion: number;\n        apiUrl: string;\n      };\n      _queue: any[][];\n    };\n  }\n}\n\n@Component({\n  selector: 'notifizz-bell',\n  template: ` <div id=\"notifizz-notifications\"></div> `,\n  styles: [],\n  standalone: true,\n})\nexport class NotifizzAngularComponent {\n  @Input() options: {\n    apiKey: string | undefined;\n    token: string;\n    authType: string;\n  } = {\n    apiKey: undefined,\n    token: '',\n    authType: 'firebase',\n  };\n\n  constructor() {}\n\n  ngOnInit(): void {\n    if (!this.options.apiKey || !this.options.authType) {\n      throw new Error(\n        'Missing required options: apiKey and authType are required'\n      );\n    }\n    importScriptInBrowser({\n      apiKey: this.options.apiKey,\n      serverUrl: 'http://localhost:5174',\n      apiUrl: 'http://localhost:6001/api',\n      widgetPath: '/dist-widget/index._c0wOqVX.es.js',\n    });\n\n    const observer = new MutationObserver((mutations, obs) => {\n      const myDiv = document.getElementById('notifizz-notifications');\n      if (myDiv) {\n        window.notifizz('authenticateWithFirebase', this.options.token);\n        obs.disconnect();\n      }\n    });\n    observer.observe(document, { childList: true, subtree: true });\n  }\n}\n","/*\n * Public API Surface of notifizz-angular\n */\n\nexport * from './lib/notifizz-angular.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAOM,SAAU,qBAAqB,CAAC,MAAsB,EAAA;AAC1D,IAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI;;IAE1B,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAC3C,gCAAgC,CACjC;AACD,IAAA,IAAI,cAAc,EAAE;AAClB,QAAA,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;QAChD;AACD;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;AAE/C,IAAA,MAAM,CAAC,IAAI,GAAG,QAAQ;AACtB,IAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU;IACrC,MAAM,CAAC,WAAW,GAAG,CAAA;;;;;;;;;;;AAWJ,iBAAA,EAAA,MAAM,CAAC,MAAM,CAAA;;;AAGb,iBAAA,EAAA,MAAM,CAAC,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