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AEzB,EAAE/B,KAAKF,MACPqE,MAAO,CACHC,MAAO,QACPC,MAAO,OACPC,SAAS,EACTxC,MAAO3C,EAAO2C,MACdyC,OAAQ,aACRC,KAAM,aACNC,OAAQ,KAGhBtF,EAAOwC,UACT+C,MAAK,WAGH,GAER,EACAhD,mBAAoB,SAASvC,GACzBW,KAAKb,cACD,SAASU,GACLG,KAAKG,sBACDN,EACA,SAASS,GACLN,KAAKkC,oBAAoB5B,EAAwBjB,EACrD,EAAEa,KAAKF,MACPX,EAER,EAAEa,KAAKF,MACPX,EAER,GAGJ,SAAS+D,EAAeyB,EAAQC,GAC5B,IAAIC,EAAID,GAAe,CAAC,EAUxB,OARAE,OAAOC,KAAKJ,GAAQK,SAAQ,SAASC,GACN,iBAAhBN,EAAOM,GACdJ,EAAEI,GAAON,EAAOM,GAEhB/B,EAAeyB,EAAOM,GAAMJ,EAEpC,IAEOA,CACX,CAEAzF,OAAOkC,SAAWlC,OAAOkC,UAAY,CAAC,EACtClC,OAAOkC,SAASjC,UAAYL,C,2DChN5B,QArBuB,CACnBkG,WAAW,EACXrC,KAAM,SAASsC,GACNrF,KAAKoF,YACFC,GACAhC,IAAE,0CAA0CiC,SAAS,QAEzDjC,IACI,4KACFiC,SAAS,QACXtF,KAAKoF,WAAY,EAEzB,EACApB,KAAM,WACEhE,KAAKoF,YACL/B,IAAE,8CAA8CkC,SAChDvF,KAAKoF,WAAY,EAEzB,E,YCpBJI,EAAOC,QAAUC,M","sources":["webpack://front-end-build-system/./src/smartpak/httpstatus.js","webpack://front-end-build-system/./src/vendor/braintree/braintree.js","webpack://front-end-build-system/./src/views/shared/loadingmessage.js","webpack://front-end-build-system/external var \"jQuery\""],"sourcesContent":["/* eslint-disable one-var */\nexport const HTTP_STATUS_OK = 200;\nexport const HTTP_STATUS_CREATED = 201;\nexport const HTTP_STATUS_NOCONTENT = 204;\nexport const HTTP_STATUS_BADREQUEST = 400;\nexport const HTTP_STATUS_UNAUTHORIZED = 401;\nexport const HTTP_STATUS_NOTFOUND = 404;\nexport const HTTP_STATUS_INTERNALSERVERERROR = 500;\nexport const HTTP_STATUS_SERVICEUNAVAILABLE = 503;\n","import $ from 'jquery';\nimport { HTTP_STATUS_OK } from '../../smartpak/httpstatus';\nimport loadingMessage from \"../../views/shared/loadingmessage\";\n\nvar braintreeWrapper = {\n _clientCreate: function(onCreate, config) {\n window.braintree.client.create(\n {\n authorization:\n config.env === 'production'\n ? 'production_3833xk8m_zw2jcdvqjy6w8yx4'\n : 'sandbox_fwz8cscb_svz9tvmr2cgyktx5'\n },\n function(clientErr, clientInstance) {\n // Stop if there was a problem creating the client.\n // This could happen if there is a network error or if the authorization\n // is invalid.\n if (clientErr) {\n // eslint-disable-next-line no-console\n console.error('Error creating client:', clientErr);\n this._showErrorMessage(config);\n return;\n }\n\n if (onCreate) {\n onCreate(clientInstance);\n }\n }.bind(this)\n );\n },\n _paypalCheckoutCreate: function(clientInstance, onCreate, config) {\n // Create a PayPal Checkout component.\n window.braintree.paypalCheckout.create(\n {\n client: clientInstance\n },\n function(paypalCheckoutErr, paypalCheckoutInstance) {\n // Stop if there was a problem creating PayPal Checkout.\n // This could happen if there was a network error or if it's incorrectly\n // configured.\n if (paypalCheckoutErr) {\n // eslint-disable-next-line no-console\n console.error('Error creating PayPal Checkout:', paypalCheckoutErr);\n this._showErrorMessage(config);\n return;\n }\n\n if (onCreate) {\n onCreate(paypalCheckoutInstance);\n }\n }.bind(this)\n );\n },\n _getCopy: function(pathname) {\n return /cart/gi.test(pathname)\n ? \"We're sorry, there was an error preventing us from connecting to your PayPal account. Please try logging into PayPal again, or use our SmartPak checkout, in order to complete your order.\"\n : /checkout/gi.test(pathname)\n ? \"We're sorry, there was an error preventing us from connecting to your PayPal account. Please try logging into PayPal again, or enter a credit card instead, in order to complete your order.\"\n : \"We're sorry, there was an error preventing us from connecting to your PayPal account. Please try logging into PayPal again, or enter a credit card instead.\";\n },\n _getButtonCopy: function(pathname) {\n return /cart/gi.test(pathname) ? 'Complete Checkout' : 'Enter Credit Card';\n },\n _showErrorMessage: function(config) {\n if (this._errorModal) {\n return;\n }\n\n var modalButtonID = 'paypal-error-modal',\n buttons =\n '
',\n html = '

' + this._getCopy(location.pathname) + '

' + buttons,\n modal = document.createElement('div');\n\n modal.classList.add('jsHide');\n modal.classList.add('paypal-error-modal-wrap');\n modal.innerHTML = html;\n document.body.appendChild(modal);\n\n this._errorModal = smartPak.ui.modal(modal, {\n removeContents: true,\n open: function() {\n this.createPayPalButton({\n buttonID: modalButtonID,\n env: config.env,\n postURL: config.postURL,\n returnURL: config.returnURL,\n label: 'paypal'\n });\n }.bind(this),\n close: function() {\n if (this._errorModal) {\n this._errorModal = null;\n }\n }.bind(this)\n });\n },\n _paypalButtonRender: function(paypalCheckoutInstance, config) {\n // Set up PayPal with the checkout.js library\n window.paypal.Button.render(\n {\n env: config.env, // 'sandbox' or 'production'\n\n payment: function() {\n return paypalCheckoutInstance.createPayment({\n flow: 'vault',\n billingAgreementDescription: '',\n enableShippingAddress: true,\n shippingAddressEditable: false\n });\n },\n\n onAuthorize: function(data) {\n loadingMessage.show(true);\n\n return paypalCheckoutInstance.tokenizePayment(\n data,\n function(err, payload) {\n if (err) {\n return;\n }\n\n var payloadResponse = flattenPayload(payload);\n\n if (this._errorModal) {\n this._errorModal.close();\n }\n\n $.ajax({\n url: config.postURL,\n type: 'POST',\n data: JSON.stringify({\n payload: payloadResponse\n }),\n contentType: 'application/json'\n })\n .done(\n function(response) {\n if (\n response &&\n response.status === HTTP_STATUS_OK &&\n response.content\n ) {\n if (config.onsuccess) {\n loadingMessage.hide();\n config.onsuccess(payloadResponse);\n return;\n }\n\n if (config.returnURL) {\n location.href = config.returnURL;\n }\n } else {\n this._showErrorMessage(config);\n }\n }.bind(this)\n )\n .fail(\n function() {\n this._showErrorMessage(config);\n }.bind(this)\n );\n }.bind(this)\n );\n }.bind(this),\n\n onCancel: function() {\n if (this._errorModal) {\n this._errorModal.close();\n }\n }.bind(this),\n\n onError: function(err) {\n // eslint-disable-next-line no-console\n console.error('checkout.js error', err);\n if (this._errorModal) {\n this._errorModal.close();\n }\n }.bind(this),\n style: {\n color: 'white',\n shape: 'rect',\n tagline: false,\n label: config.label,\n layout: 'horizontal',\n size: 'responsive',\n height: 48\n }\n },\n config.buttonID\n ).then(function() {\n // The PayPal button will be rendered in an html element with the id\n // `paypal-button`. This function will be called when the PayPal button\n // is set up and ready to be used.\n });\n },\n createPayPalButton: function(config) {\n this._clientCreate(\n function(clientInstance) {\n this._paypalCheckoutCreate(\n clientInstance,\n function(paypalCheckoutInstance) {\n this._paypalButtonRender(paypalCheckoutInstance, config);\n }.bind(this),\n config\n );\n }.bind(this),\n config\n );\n }\n};\n\nfunction flattenPayload(source, destination) {\n var d = destination || {};\n\n Object.keys(source).forEach(function(key) {\n if (typeof source[key] === 'string') {\n d[key] = source[key];\n } else {\n flattenPayload(source[key], d);\n }\n });\n\n return d;\n}\n\nwindow.smartPak = window.smartPak || {};\nwindow.smartPak.braintree = braintreeWrapper;","import $ from 'jquery';\r\n\r\nconst loadingMessage = {\r\n isVisible: false,\r\n show: function(includeOverlay) {\r\n if (!this.isVisible) {\r\n if (includeOverlay) {\r\n $('
').appendTo('body');\r\n }\r\n $(\r\n '
Loading
'\r\n ).appendTo('body');\r\n this.isVisible = true;\r\n }\r\n },\r\n hide: function() {\r\n if (this.isVisible) {\r\n $('.loader-msg-container, .loader-msg-overlay').remove();\r\n this.isVisible = false;\r\n }\r\n }\r\n};\r\n\r\nexport default loadingMessage;\r\n","module.exports = jQuery;"],"names":["HTTP_STATUS_OK","HTTP_STATUS_CREATED","HTTP_STATUS_NOCONTENT","HTTP_STATUS_BADREQUEST","HTTP_STATUS_UNAUTHORIZED","HTTP_STATUS_NOTFOUND","HTTP_STATUS_INTERNALSERVERERROR","HTTP_STATUS_SERVICEUNAVAILABLE","braintreeWrapper","_clientCreate","onCreate","config","window","braintree","client","create","authorization","env","clientErr","clientInstance","console","error","this","_showErrorMessage","bind","_paypalCheckoutCreate","paypalCheckout","paypalCheckoutErr","paypalCheckoutInstance","_getCopy","pathname","test","_getButtonCopy","_errorModal","modalButtonID","buttons","location","html","modal","document","createElement","classList","add","innerHTML","body","appendChild","smartPak","ui","removeContents","open","createPayPalButton","buttonID","postURL","returnURL","label","close","_paypalButtonRender","paypal","Button","render","payment","createPayment","flow","billingAgreementDescription","enableShippingAddress","shippingAddressEditable","onAuthorize","data","loadingMessage","show","tokenizePayment","err","payload","payloadResponse","flattenPayload","$","url","type","JSON","stringify","contentType","done","response","status","content","onsuccess","hide","href","fail","onCancel","onError","style","color","shape","tagline","layout","size","height","then","source","destination","d","Object","keys","forEach","key","isVisible","includeOverlay","appendTo","remove","module","exports","jQuery"],"sourceRoot":""}