/**
 * 2014 - 2023 Watt Is It
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the MIT License X11
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/mit-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to contact@paygreen.fr so we can send you a copy immediately.
 *
 * @author    PayGreen <contact@paygreen.fr>
 * @copyright 2014 - 2023 Watt Is It
 * @license   https://opensource.org/licenses/mit-license.php MIT License X11
 * @version   1.3.7
 *
 */
!function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="../",i(i.s="0/lD")}({"0/lD":function(t,e){t={pgClimateBotColor:null,pgClimateBotPosition:null,pgClimateBotCorner:null,pgClimateBotTemplateUrl:null,pgClimateBotMobile:null,pgCreateFootprintUrl:null,install:function(){this.apiUrl="https://"+window.paygreen_tree_climatebot_api_url,this.locale=window.paygreen_tree_climatebot_locale,this.color=window.paygreen_tree_climatebot_color,this.position=window.paygreen_tree_climatebot_position,this.engagementLink=window.paygreen_tree_climatebot_url,this.showOnMobile=window.paygreen_tree_climatebot_mobile,this.shopName=window.paygreen_tree_climatebot_name,this.testMode=window.paygreen_tree_climatebot_test_mode,this.description=window.paygreen_tree_climatebot_description,this.title=window.paygreen_tree_climatebot_title,this.offset=window.paygreen_tree_climatebot_offset,this.pgCreateFootprintUrl=window.paygreen_create_footprint_url,this.addContributionAction=window.paygreen_add_contribution_action,this.removeContributionAction=window.paygreen_remove_contribution_action,this.hasContributionInCart=window.paygreen_has_contribution_in_cart,this.carbonBotActivated=window.paygreen_carbon_bot_activated,this.contributionActivated=window.paygreen_contribution_activated,this.addCarbonBotScript(),this.makeXmlHttpRequest("get",this.pgCreateFootprintUrl)},handleMobileDeactivation:function(){document.querySelector(".pgclimatebot__button").classList.add("pgHideOnMobile")},addCarbonBotScript:function(){var t=document.createElement("script");t.onload=function(){if(carbonBot.init({endpoint:this.apiUrl,testMode:"true"===this.testMode,locale:this.locale,shopName:this.shopName,showDemoData:!1,bot:{position:"RIGHT"===this.position?"right":"left",colors:{primary:this.color},engagementLink:this.engagementLink,displayed:"true"===this.carbonBotActivated},banner:{removeContributionAction:function(){window.location.replace(this.removeContributionAction)}.bind(this),hasContributionInCart:"true"===this.hasContributionInCart,displayed:"true"===this.contributionActivated},translations:{en:{title:this.title,engagementDescription:this.description,offset:this.offset},fr:{title:this.title,engagementDescription:this.description,offset:this.offset}}}),"false"===this.showOnMobile){var t=document.querySelector("[data-paygreen-carbon-bot]");t&&t.classList.add("pgHideOnMobile")}}.bind(this),t.src="https://carbonbot.paygreen.fr/1.2/carbon-bot.js",document.head.appendChild(t)},makeXmlHttpRequest:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=new XMLHttpRequest;n.open(t,e,i),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.onreadystatechange=function(){if(4===n.readyState){var t=JSON.parse(n.response),e={bot:{user:t.data.userId,footprint:t.data.fingerprint,token:t.data.token},cart:{price:null,weight:0,shippingFromAddress:{street:null,city:null,postcode:null,country:"France"},shippingToAddress:{street:null,city:null,postcode:null,country:"France"},deliveryService:null,items:null},banner:{addContributionAction:function(e){window.location.replace(this.addContributionAction+"&pgdata[0]="+e+"&pgdata[1]="+t.data.fingerprint)}.bind(this)}};t.data.cart&&(e.cart.items=t.data.cart.items,e.cart.price=t.data.cart.price,e.cart.weight=t.data.cart.weight),t.data.shippingFromAddress&&t.data.shippingToAddress&&(e.cart.shippingFromAddress=t.data.shippingFromAddress,e.cart.shippingToAddress=t.data.shippingToAddress,e.cart.deliveryService=t.data.deliveryService),carbonBot.updateConfig(e)}}.bind(this),n.send()}};window.addEventListener("DOMContentLoaded",(function(e){t.install()}))}});