{"version":3,"file":"webflow-BaHI8_fK.js","sources":["../../../app/frontend/javascript/app/features/MatomoTracker.js","../../../app/frontend/javascript/webflow/newsletter-signup_controller.js","../../../app/frontend/javascript/webflow/webflow-iframe_controller.js","../../../app/frontend/javascript/app/features/SteadyCheckoutWidget.js","../../../app/frontend/javascript/webflow/index.js"],"sourcesContent":["import RailsEnv from '@frontend/app/features/RailsEnv';\n\n// See https://developer.matomo.org/api-reference/tracking-javascript\nexport default class MatomoTracker {\n  static isReady() {\n    return !!(window.top.Matomo && window.top.ENV && window.top.ENV.matomo);\n  }\n\n  // Returns the 16 characters ID for the visitor\n  static getVisitorId() {\n    if (RailsEnv.isDev() || RailsEnv.isTest()) return 'testtesttesttest';\n\n    return this.getTracker().getVisitorId();\n  }\n\n  static trackGoal(id) {\n    this.getTracker().trackGoal(id);\n  }\n\n  static getTracker() {\n    return window.top.Matomo.getTracker(\n      window.top.ENV.matomo.url,\n      window.top.ENV.matomo.siteId\n    );\n  }\n}\n","import { Controller } from '@hotwired/stimulus';\nimport { extract as extractQueryParams } from '@frontend/utils/query-params';\nimport MatomoTracker from '@frontend/app/features/MatomoTracker';\n\nexport default class extends Controller {\n  static values = {\n    trackMatomoGoalId: { type: Number, default: -1 },\n  };\n\n  static targets = [\n    'utmCampaignInputField',\n    'failureMessage',\n    'successMessage',\n  ];\n\n  connect() {\n    this.form = this.element.querySelector('form');\n    this.form.addEventListener('ajax:success', this.handleSuccess.bind(this));\n    this.form.addEventListener('ajax:error', this.handleError.bind(this));\n    this.form.addEventListener('ajax:before', this.handleBefore.bind(this));\n    const utmCampaign = extractQueryParams(window.top.location.href)[\n      'utm_campaign'\n    ];\n    if (utmCampaign) {\n      this.utmCampaignInputFieldTarget.value = utmCampaign;\n    }\n  }\n\n  handleBefore() {\n    this.form.hidden = true;\n  }\n\n  handleSuccess(event) {\n    const [data] = event.detail;\n    if (data.status == 'ok') {\n      this.successMessageTarget.hidden = false;\n      this.successMessageTarget.innerHTML = data.messages.join('. ');\n      if (this.hasTrackMatomoGoalIdValue && this.trackMatomoGoalIdValue > 0) {\n        MatomoTracker.trackGoal(this.trackMatomoGoalIdValue);\n      }\n    }\n  }\n\n  handleError(event) {\n    const [data] = event.detail;\n    let failureMessage = '';\n    if (data.error_messages) {\n      failureMessage = data.error_messages.join('\\n<br/>');\n    } else {\n      failureMessage =\n        'Da ist etwas schiefgegangen. Kontaktiere unseren Support.';\n    }\n    this.failureMessageTarget.hidden = false;\n    this.failureMessageTarget.innerHTML = failureMessage;\n  }\n}\n","import { Controller } from '@hotwired/stimulus';\nimport { runWhenDomLoaded } from '@frontend/utils/dom';\n\nexport default class extends Controller {\n  connect() {\n    runWhenDomLoaded(() => {\n      const iframe = window.frameElement;\n      if (iframe) {\n        iframe.allowTransparency = true;\n        iframe.frameBorder = 0;\n        const body = this.element;\n        const iframeContentHeight = body.scrollHeight + 'px';\n        iframe.style.height = iframeContentHeight;\n      }\n    });\n  }\n}\n","import CampaignTracking from '@frontend/app/features/CampaignTracking';\nimport ConvertedWithTracking from '@frontend/app/features/ConvertedWithTracking';\nimport MatomoTracker from '@frontend/app/features/MatomoTracker';\nimport queryString from 'query-string';\n\nexport default class SteadyCheckoutWidget {\n  static init() {\n    if (window.top.__steadyCheckoutWidgetInitiated === true) return true;\n    window.top.__steadyCheckoutWidgetInitiated = true;\n    this.start();\n  }\n\n  static start() {\n    this.maxInitAttempts = 5;\n    this.initAttempt = this.initAttempt || 0;\n    this.initAttempt += 1;\n\n    if (!this.isReady() && this.initAttempt <= this.maxInitAttempts) {\n      setTimeout(() => this.start(), 500);\n    } else if (this.getSteadyCheckoutWidgetPlaceholder()) {\n      this.maybeAddUTMCampaignDataAttributes();\n      this.loadSteadyCheckoutWidgetJs();\n    }\n  }\n\n  static getSteadyCheckoutWidgetPlaceholderId() {\n    return 'insert_steady_checkout_here';\n  }\n\n  static isReady() {\n    return (\n      this.checkoutIsConfiguredAndEnabled() &&\n      this.getSteadyCheckoutWidgetPlaceholder() !== undefined &&\n      this.matomoTrackerIsReady()\n    );\n  }\n\n  static matomoTrackerIsReady() {\n    return MatomoTracker.isReady();\n  }\n\n  static checkoutIsConfiguredAndEnabled() {\n    return (\n      window &&\n      window.ENV &&\n      window.ENV.steady &&\n      window.ENV.steady.checkoutWidget.enabled &&\n      window.ENV.steady.checkoutWidget.url\n    );\n  }\n\n  static getSteadyCheckoutWidgetJsUrl() {\n    return window.ENV.steady.checkoutWidget.url;\n  }\n\n  static getSteadyOAuthAccessToken() {\n    return window.ENV.steady.checkoutWidget.oauthAccessToken;\n  }\n\n  static getSteadyCheckoutWidgetPlaceholder() {\n    return window.top.document.querySelector(\n      `#${this.getSteadyCheckoutWidgetPlaceholderId()}`\n    );\n  }\n\n  static maybeAddUTMCampaignDataAttributes() {\n    const steadyWidgetPlaceholder = this.getSteadyCheckoutWidgetPlaceholder();\n    steadyWidgetPlaceholder.dataset.utmCampaign =\n      this.currentSteadyPublisherUtmCampaignOrBuildUtmCampaign();\n  }\n\n  static currentSteadyPublisherUtmCampaignOrBuildUtmCampaign() {\n    const query = queryString.parse(window.top.location.search);\n    const overlayUrl = query['steady_overlay_url'];\n\n    if (overlayUrl) {\n      const overlayQuery = queryString.parse(overlayUrl);\n\n      if (overlayQuery['steady_publisher_utm_campaign']) {\n        return overlayQuery['steady_publisher_utm_campaign'];\n      }\n    }\n\n    return this.generateUtmCampaignTracking();\n  }\n\n  // Defines the custom utm_campaign-value we pass to steady as the `steady_publisher_utm_campaign`\n  // This special utm_campaign-value carries multiple dimensions of information.\n  //\n  // a) The original utm_campaign which was present when a user visited an article\n  // b) A converted_with value which identifies the article and an optional share-url\n  // c) A matomo visitor id which we use for the server-side goal tracking\n  static generateUtmCampaignTracking() {\n    let visitorId = this.getCurrentVisitorId();\n    if (0 === visitorId.length) {\n      visitorId = 'visitorid-unknown';\n    }\n\n    return [\n      this.getCurrentCampaignTracking(),\n      ConvertedWithTracking.getCurrentConvertedWith(),\n      visitorId,\n    ]\n      .filter((x) => x.length > 1)\n      .join('__');\n  }\n\n  static getCurrentCampaignTracking() {\n    const activeCampaign = CampaignTracking.getCurrentCampaign();\n    if (activeCampaign) {\n      return activeCampaign.replace('__', '--').substr(0, 200);\n    } else {\n      return '';\n    }\n  }\n\n  static getCurrentVisitorId() {\n    if (MatomoTracker.isReady()) {\n      return `visitorid-${MatomoTracker.getVisitorId()}`;\n    } else {\n      return '';\n    }\n  }\n\n  static loadSteadyCheckoutWidgetJs() {\n    if (window.___steadyCheckoutWidgetJsLoading) return true;\n\n    var script = document.createElement('script');\n    script.src = this.getSteadyCheckoutWidgetJsUrl();\n    if (this.getSteadyOAuthAccessToken()) {\n      script.dataset.steadyOauthAccessToken = this.getSteadyOAuthAccessToken();\n    }\n    window.top.document.body.appendChild(script);\n\n    window.___steadyCheckoutWidgetJsLoading = true;\n  }\n}\n","import { Application } from '@hotwired/stimulus';\nimport NavbarComponentController from '@components/navbar/component_controller';\nimport NewsletterSignupController from './newsletter-signup_controller';\nimport WebflowIframeController from './webflow-iframe_controller';\nimport { runWhenDomLoaded } from '@frontend/utils/dom';\n\nconst application = Application.start();\napplication.register('navbar--component', NavbarComponentController);\napplication.register('newsletter-signup', NewsletterSignupController);\napplication.register('webflow-iframe', WebflowIframeController);\n\nimport Rails from '@rails/ujs';\nimport CampaignTracking from '@frontend/app/features/CampaignTracking';\nimport ConvertedWithTracking from '@frontend/app/features/ConvertedWithTracking';\nimport ImgixHelper from '@frontend/app/features/ImgixHelper';\nimport SteadyCheckoutWidget from '@frontend/app/features/SteadyCheckoutWidget';\n\nrunWhenDomLoaded(() => {\n  if (window._rails_loaded !== true) {\n    Rails.start();\n  }\n\n  ImgixHelper.init();\n  CampaignTracking.init();\n  ConvertedWithTracking.init();\n  SteadyCheckoutWidget.init();\n});\n"],"names":["MatomoTracker","RailsEnv","id","NewsletterSignupController","Controller","utmCampaign","extractQueryParams","event","data","failureMessage","__publicField","WebflowIframeController","runWhenDomLoaded","iframe","iframeContentHeight","SteadyCheckoutWidget","steadyWidgetPlaceholder","overlayUrl","queryString","overlayQuery","visitorId","ConvertedWithTracking","x","activeCampaign","CampaignTracking","script","application","Application","NavbarComponentController","Rails","ImgixHelper"],"mappings":"wiBAGe,MAAMA,CAAc,CACjC,OAAO,SAAU,CACf,MAAO,CAAC,EAAE,OAAO,IAAI,QAAU,OAAO,IAAI,KAAO,OAAO,IAAI,IAAI,OACjE,CAGD,OAAO,cAAe,CACpB,OAAIC,EAAS,MAAO,GAAIA,EAAS,OAAM,EAAW,mBAE3C,KAAK,aAAa,cAC1B,CAED,OAAO,UAAUC,EAAI,CACnB,KAAK,WAAU,EAAG,UAAUA,CAAE,CAC/B,CAED,OAAO,YAAa,CAClB,OAAO,OAAO,IAAI,OAAO,WACvB,OAAO,IAAI,IAAI,OAAO,IACtB,OAAO,IAAI,IAAI,OAAO,MAC5B,CACG,CACH,CCrBe,MAAKC,UAASC,CAAW,CAWtC,SAAU,CACR,KAAK,KAAO,KAAK,QAAQ,cAAc,MAAM,EAC7C,KAAK,KAAK,iBAAiB,eAAgB,KAAK,cAAc,KAAK,IAAI,CAAC,EACxE,KAAK,KAAK,iBAAiB,aAAc,KAAK,YAAY,KAAK,IAAI,CAAC,EACpE,KAAK,KAAK,iBAAiB,cAAe,KAAK,aAAa,KAAK,IAAI,CAAC,EACtE,MAAMC,EAAcC,EAAmB,OAAO,IAAI,SAAS,IAAI,EAC7D,aAEED,IACF,KAAK,4BAA4B,MAAQA,EAE5C,CAED,cAAe,CACb,KAAK,KAAK,OAAS,EACpB,CAED,cAAcE,EAAO,CACnB,KAAM,CAACC,CAAI,EAAID,EAAM,OACjBC,EAAK,QAAU,OACjB,KAAK,qBAAqB,OAAS,GACnC,KAAK,qBAAqB,UAAYA,EAAK,SAAS,KAAK,IAAI,EACzD,KAAK,2BAA6B,KAAK,uBAAyB,GAClER,EAAc,UAAU,KAAK,sBAAsB,EAGxD,CAED,YAAYO,EAAO,CACjB,KAAM,CAACC,CAAI,EAAID,EAAM,OACrB,IAAIE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