<commit_before>// Integration of HMRC’s webchat solution

(function () {
  'use strict';
  var root = this,
    $ = root.jQuery;
  if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }

  var webchat = {

    shouldOpen: function(){
      var webchatEnabledPaths = [
        '/changes-affect-tax-credits',
        '/check-if-you-need-a-tax-return/y/employed-even-if-just-for-part-of-the-year/no/no/no-neither-of-us-claimed-child-benefit/no/no/no/none-of-these',
        '/check-if-you-need-a-tax-return/y/retired/no/no-neither-of-us-claimed-child-benefit/no/no/no/none-of-these',
        '/child-tax-credit/how-to-claim',
        '/childcare-costs-for-tax-credits/y/yes/yes/weekly_diff_amount',
        '/childcare-costs-for-tax-credits/y/no/regularly_less_than_year/monthly_diff_amount',
        '/lost-national-insurance-number',
        '/manage-your-tax-credits',
        '/renewing-your-tax-credits-claim',
        '/tax-credits-appeals-complaints',
        '/tax-credits-if-you-have-baby',
        '/tax-credits-overpayments',
        '/vat-registration/changes-to-your-details',
        '/when-is-your-next-tax-credits-payment',
        '/working-tax-credit/how-to-claim'
      ];

      return ($.inArray(window.location.pathname, webchatEnabledPaths) >= 0);
    },

    validOrigin: function(origin){
      return origin.match(/gov\.uk$/) || origin.match(/alphagov\.co\.uk$/);
    },

    sendMessage: function(message){
      webchat.$chatFrame.get(0).contentWindow.postMessage(JSON.stringify(message), '<%= ENV['GOVUK_ASSET_ROOT'] %>');
    },

    receiveMessage: function(e) {
      e = e.originalEvent;
      if (webchat.validOrigin(e.origin)) {
        var message = JSON.parse(e.data);

        if (message.evt === 'opened') {
          webchat.$banner.addClass('open');
          webchat.$banner.attr('aria-hidden', false);
          GOVUK.analytics.trackEvent('webchat', 'offered');
        } else if (message.evt === 'closed') {<commit_msg>Remove webchat offers from TC Non Digital and renewals pages<commit_after>// Integration of HMRC’s webchat solution

(function () {
  'use strict';
  var root = this,
    $ = root.jQuery;
  if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }

  var webchat = {

    shouldOpen: function(){
      var webchatEnabledPaths = [
        '/changes-affect-tax-credits',
        '/check-if-you-need-a-tax-return/y/employed-even-if-just-for-part-of-the-year/no/no/no-neither-of-us-claimed-child-benefit/no/no/no/none-of-these',
        '/check-if-you-need-a-tax-return/y/retired/no/no-neither-of-us-claimed-child-benefit/no/no/no/none-of-these',
        '/child-tax-credit/how-to-claim',
        '/lost-national-insurance-number',
        '/manage-your-tax-credits',
        '/tax-credits-appeals-complaints',
        '/tax-credits-if-you-have-baby',
        '/tax-credits-overpayments',
        '/vat-registration/changes-to-your-details',
        '/when-is-your-next-tax-credits-payment',
        '/working-tax-credit/how-to-claim'
      ];

      return ($.inArray(window.location.pathname, webchatEnabledPaths) >= 0);
    },

    validOrigin: function(origin){
      return origin.match(/gov\.uk$/) || origin.match(/alphagov\.co\.uk$/);
    },

    sendMessage: function(message){
      webchat.$chatFrame.get(0).contentWindow.postMessage(JSON.stringify(message), '<%= ENV['GOVUK_ASSET_ROOT'] %>');
    },

    receiveMessage: function(e) {
      e = e.originalEvent;
      if (webchat.validOrigin(e.origin)) {
        var message = JSON.parse(e.data);

        if (message.evt === 'opened') {
          webchat.$banner.addClass('open');
          webchat.$banner.attr('aria-hidden', false);
          GOVUK.analytics.trackEvent('webchat', 'offered');
        } else if (message.evt === 'closed') {
{'fraction_non_alphanumeric': 0.18012752391073325, 'fraction_numerical': 0.0010626992561105207, 'mean_word_length': 2.6695906432748537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3852666', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1285, 'n_words': 150}