1(()=>{"use strict";var e={20(e,t,r){var a=r(609),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var a,s={},l=null,d=null;for(a in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!c.hasOwnProperty(a)&&(s[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===s[a]&&(s[a]=t[a]);return{$$typeof:n,type:e,key:l,ref:d,props:s,_owner:i.current}}t.Fragment=s,t.jsx=l,t.jsxs=l},848(e,t,r){e.exports=r(20)},609(e){e.exports=window.React}},t={};const r=window.wc.wcBlocksRegistry,a=window.wp.i18n,n=window.wp.data,s="braintree_credit_card",o="braintree-credit-card",i=window.wc.wcSettings;let c=null;const l=()=>{if(null!==c)return c;const e=(0,i.getSetting)(`${s}_data`,null);if(!e)throw new Error("Braintree Credit Card initialization data is not available");return c={ajaxUrl:e.ajax_url||"",cartContainsSubscription:e.cart_contains_subscription||!1,clientTokenNonce:e.client_token_nonce||"",cscRequired:!1!==e.csc_required,debug:e.debug||!1,description:e.description||"",enabledCardTypes:e.enabled_card_types||[],fastlaneEnabled:e.fastlane_enabled||!1,fieldsErrorMessages:e.fields_error_messages||{},hostedFieldsStyles:e.hosted_fields_styles||{},icons:e.icons||{},integrationErrorMessage:e.integration_error_message||"Unknown error",isTestEnvironment:e.is_test_environment||!1,isAdvancedFraudTool:e.is_advanced_fraud_tool||!1,orderTotal3DSecure:e.order_total_for_3ds||0,paymentErrorMessage:e.payment_error_message||"Unknown error",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{},title:e.title||"",threeds:e.threeds||{},tokenDataNonce:e.token_data_nonce||"",tokenizationForced:e.tokenization_forced||!1},c},d=(e=!1)=>{const{cscRequired:t,hostedFieldsStyles:r}=l(),n={styles:{...r,input:{"font-size":"16px","line-height":"1.375"},"::placeholder":{color:"transparent"},":focus::placeholder":{color:"#757575"},".invalid":{color:"#cc1818"}},fields:{}};if(e||(n.fields={number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:"â¢â¢â¢â¢ â¢â¢â¢â¢ â¢â¢â¢â¢ â¢â¢â¢â¢"},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:(0,a.__)("MM / YY","woocommerce-gateway-paypal-powered-by-braintree")}}),t){const t=e?"#wc-braintree-credit-card-csc-hosted-token":"#wc-braintree-credit-card-csc-hosted";n.fields.cvv={selector:t,placeholder:(0,a.__)("CSC","woocommerce-gateway-paypal-powered-by-braintree")}}return n},u=(e,t=!1)=>{const r=[],{fieldsErrorMessages:a,cscRequired:n}=l();if(!e||!e.type)return e.message||"";if("CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":t||(r.push(a.card_number_required),r.push(a.card_expirationDate_required)),n&&r.push(a.card_cvv_required);break;case"HOSTED_FIELDS_FIELDS_INVALID":if(e.details&&e.details.invalidFieldKeys)for(const t of e.details.invalidFieldKeys)r.push(a[`card_${t}
1_invalid`]||"");break;default:if(r.push(e.message||""),r.push(e.error&&e.error.message||""),e.details&&e.details.originalError){const t=u(e.details.originalError);t&&r.push(t)}}else"NETWORK"===e.type&&e.details&&e.details.originalError&&e.details.originalError.error&&r.push(e.details.originalError.error.message||"");return r.length?r.filter(e=>e).join(". "):""},p=(e,t=null)=>{l().debug&&(console.log(`Braintree (Credit Card): ${e}`),t&&console.log(t))},m=()=>{const{icons:e={}}=l();return Object.entries(e).map(([e,{src:t,alt:r}])=>({id:e,src:t,alt:r}))},h=window.wp.element,y=(e,t,r)=>{const a=new FormData;return a.append("action",`wc_${t}_get_client_token`),a.append("nonce",r),fetch(e,{method:"POST",body:a}).then(e=>e.json()).then(e=>{if(e&&!e.success){const t=e.data&&e.data.message||"";throw new Error(`Could not retrieve the client token via AJAX: ${t}`)}if(e&&e.success&&e.data)return e.data})},{ajaxUrl:g,clientTokenNonce:w,tokenizationForced:b,threeds:f,isAdvancedFraudTool:_,cartContainsSubscription:C,orderTotal3DSecure:k,cscRequired:S}=l(),v=({billing:e,shippingData:{shippingAddress:t},shouldSavePayment:r,token:a=null})=>{const{cartTotal:n,currency:i}=e,c=(n.value/10**i.minorUnit).toFixed(2),[u,m]=(0,h.useState)(""),[v,x]=(0,h.useState)(""),[E,D]=(0,h.useState)(null),[j,N]=(0,h.useState)(null),F=(0,h.useMemo)(()=>!r&&!b,[r]),T=!!a,R=(0,h.useCallback)(async()=>{const{braintree:e}=window;let t,r,a;const n=f&&f.enabled&&e&&e.threeDSecure,o=await y(g,s,w);p("Creating client");const i=await e.client.create({authorization:o});return p("Client Ready"),T&&!S||(p("Creating integration"),a=await e.hostedFields.create({...d(T),client:i}),D(a),(e=>{function t(e,t){const r=e.fields[e.emittedBy];r&&r.container.classList.add(t)}function r(e,t){const r=e.fields[e.emittedBy];r&&r.container.classList.remove(t)}e.on("focus",e=>{t(e,"focused")}),e.on("blur",e=>{const a=e.fields[e.emittedBy];r(e,"focused"),a.isEmpty&&t(e,"empty")}),e.on("empty",e=>{t(e,"empty")}),e.on("notEmpty",function(e){r(e,"empty")}),e.on("cardTypeChange",function(e){if(!e.cards)return;const t=document.getElementById("wc-braintree-credit-card-account-number-hosted");if(t.classList.forEach(e=>{e.startsWith("card-type-")&&t.classList.remove(e)}),!e.cards.length)return t.classList.add("card-type-invalid");if(1===e.cards.length){const r=e.cards[0],{enabledCardTypes:a}=l();r.type&&a.includes(r.type)?t.classList.add(`card-type-${r.type}`):t.classList.add("card-type-invalid")}})})(a),p("Integration ready")),_&&e&&e.dataCollector&&(t=await e.dataCollector.create({client:i}),t&&t.deviceData&&x(t.deviceData)),n&&i.getConfiguration().gatewayConfiguration.threeDSecureEnabled&&(r=await e.threeDSecure.create({version:2,client:i}),N(r)),{hostedFields:a,dataCollector:t,threeDSecure:r}},[T]),M=(0,h.useMemo)(()=>{const r={amount:c.toString(),email:e.billingData.email||"",challengeRequested:!0,billingAddress:{givenName:e.billingData.first_name||"",surname:e.billingData.last_name||"",phoneNumber:e.billingData.phone||"",streetAddress:e.billingData.address_1||"",extendedAddress:e.billingData.address_2||"",locality:e.billingData.city||"",region:e.billingData.state.length<=2?e.billingData.state:"",postalCode:e.billingData.postcode||"",countryCodeAlpha2:e.billingData.country.length<=2?e.billingData.country:""},additionalInformation:{shippingGivenName:t.first_name||"",shippingSurname:t.last_name||"",shippingPhone:t.phone||"",shippingAddress:{streetAddress:t.address_1||"",extendedAddress:t.address_2||"",locality:t.city||"",region:t.state.length<=2?t.state:"",postalCode:t.postcode||"",countryCodeAlpha2:t.country.length<=2?t.country:""}}};return C&&"0.00"===c&&k&&(r.amount=k.toFixed(2)),r},[c,e.billingData,t]),L=(0,h.useCallback)((e,t)=>(p("Verifying 3D Secure.",M),j.verifyCard({...M,nonce:e,bin:t,onLookupComplete:(e,t)=>{p("3DS lookup complete",e),t()}})),[j,M]),A=(0,h.useCallback)(()=>{const e={wc_braintree_device_data:v};return F||(e[`wc-${o}-tokenize-payment-method`]=!0),u&&(e[`wc-${o}-test-amount`]=u),e},[v,F,u]);return{testAmount:u,setTestAmount:m,setupIntegration:R,getPaymentMethodData:A,verify3DSecure:L,hostedFieldsInstance:E,threeDSecureInstance:j}},x=window.wc.blocksCheckout;var E=function r(a){var n=t[a];if(void 0!==n)return n.exports;var s=t[a]={exports:{}};return e[a](s,s.exports,r),s.exports}(848);const{fieldsErrorMessages:D,cscRequired:j}=l(),N=e=>{const{components:{LoadingMask:t},isLoaded:r,hostedFieldsInstance:n,token:s=null}=e,[i,c]=(0,h.useState)({number:"",expirationDate:"",cvv:""});return(0,h.useEffect)(()=>{n&&n.on("validityChange",function(e){const t=e.fields[e.emittedBy];t.isValid||t.isPotentiallyValid?(c(t=>({...t,[e.emittedBy]:""})),t.container.classList.remove("has-error")):(c(t=>({...t,[e.emittedBy]:D[`card_${e.emittedBy}_invalid`]||(0,a.sprintf)(/** translators: Placeholders: %s - invalid field name */ /** translators: Placeholders: %s - invalid field name */
2(0,a.__)("%s is invalid","woocommerce-gateway-paypal-powered-by-braintree"),e.emittedBy)})),t.container.classList.add("has-error"))})},[n]),(0,E.jsx)(t,{isLoading:!r,showSpinner:!0,children:(0,E.jsxs)("div",{className:"wc-block-card-elements payment_method_braintree_credit_card",children:[!s&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"wc-block-gateway-container wc-card-number-element",children:[(0,E.jsx)("div",{id:`wc-${o}-account-number-hosted`,className:"wc-block-gateway-input empty wc-braintree-hosted-field-card-number"}),(0,E.jsx)("label",{htmlFor:`wc-${o}-account-number-hosted`,children:(0,a.__)("Card Number","woocommerce-gateway-paypal-powered-by-braintree")}),(0,E.jsx)(x.ValidationInputError,{errorMessage:i.number})]}),(0,E.jsxs)("div",{className:"wc-block-gateway-container wc-card-expiry-element",children:[(0,E.jsx)("div",{id:`wc-${o}-expiry-hosted`,className:"wc-block-gateway-input empty wc-braintree-hosted-field-expiry"}),(0,E.jsx)("label",{htmlFor:`wc-${o}-expiry-hosted`,children:(0,a.__)("Expiry date","woocommerce-gateway-paypal-powered-by-braintree")}),(0,E.jsx)(x.ValidationInputError,{errorMessage:i.expirationDate})]})]}),j&&(0,E.jsxs)("div",{className:"wc-block-gateway-container wc-card-cvc-element",children:[(0,E.jsx)("div",{id:`wc-${o}-csc-hosted${s?"-token":""}`,className:"wc-block-gateway-input empty wc-braintree-hosted-field-csc"}),(0,E.jsx)("label",{htmlFor:`wc-${o}-csc-hosted${s?"-token":""}`,children:(0,a.__)("Security Code","woocommerce-gateway-paypal-powered-by-braintree")}),(0,E.jsx)(x.ValidationInputError,{errorMessage:i.cvv})]})]})})},F=window.wp.htmlEntities,T=window.wc.wcBlocksData,{threeds:R,integrationErrorMessage:M,paymentErrorMessage:L,cscRequired:A}=l(),I=(e,t,r)=>{(0,h.useEffect)(()=>{const a=e=>{let t={type:r.responseTypes.SUCCESS};const{paymentStatus:a,paymentDetails:n}=e.processingResponse;return a===r.responseTypes.FAIL&&n.result===r.responseTypes.FAIL&&n.message&&(t={type:r.responseTypes.FAIL,message:n.message,messageContext:r.noticeContexts.PAYMENTS,retry:!0}),t},n=e(a),s=t(a);return()=>{n(),s()}},[e,t,r.noticeContexts.PAYMENTS,r.responseTypes.FAIL,r.responseTypes.SUCCESS])},P=({checkoutFormHandler:e,eventRegistration:t,emitResponse:r,token:a=null})=>{const{onPaymentSetup:i,onCheckoutFail:c,onCheckoutSuccess:d}=t,{getPaymentMethodData:m,hostedFieldsInstance:y,verify3DSecure:g}=e;return((e,t,r,a,i,c=null)=>{(0,h.useEffect)(()=>{const d={type:t.responseTypes.ERROR,messageContext:t.noticeContexts.PAYMENTS},m=R&&R.enabled&&window.braintree&&window.braintree.threeDSecure,h=!(c&&!A);let y=!1;const g=e(async()=>{if(!T.validationStore||!(0,n.select)(T.validationStore).hasValidationErrors()){if(h&&!i)return{...d,message:M};try{const e=r();let n,u,g,w;if(h){const t=await i.tokenize();if([n,u,g,w]=[t.nonce,t.details.bin,t.details.cardType,t.type],!n)return{...d,message:t.message};e.wc_braintree_credit_card_payment_nonce=n}if(c)try{const t=await(async e=>{const{ajaxUrl:t,tokenDataNonce:r,paymentErrorMessage:a}=l(),n=new FormData;n.append("action",`wc_${s}_get_token_data`),n.append("token_id",e),n.append("nonce",r);const o=await fetch(t,{method:"POST",body:n}),i=await o.json();if(i&&!i.success){const e=i.data&&i.data.message||a;throw new Error(e)}if(i&&i.success&&i.data)return i.data;throw new Error(a)})(c);t&&t.nonce&&(n=t.nonce,u=t.bin,y=!0),e.token=t.token,e[`wc-${o}-payment-token`]=t.token}catch(e){return{...d,message:e.message||L}}if(m&&(c&&y||"CreditCard"===w&&R.card_types.includes(g))){const t=await a(n,u);if(p("3D Secure Response received",t),R.liability_shift_always_required&&!t.liabilityShifted)return{...d,message:R.liability_shift_message};e[`wc-${o}-card-type`]=c?"":g.replace(" ","").toLowerCase(),e[`wc-${o}-3d-secure-enabled`]="1",e[`wc-${o}-3d-secure-verified`]="1",e.wc_braintree_credit_card_payment_nonce=t.nonce}return{type:t.responseTypes.SUCCESS,meta:{paymentMethodData:e}}}catch(e){p(`Payment Error: ${e.message}`,e);const t=u(e,c)||e.message;return{...d,message:(0,F.decodeEntities)(t)}}}});return g},[t.responseTypes.SUCCESS,t.responseTypes.ERROR,t.noticeContexts.PAYMENTS,e,r,i,a,c])})(i,r,m,g,y,a),I(c,d,r),null},$=()=>"undefined"!=typeof navigator&&!!navigator.clipboard&&"function"==typeof navigator.clipboard.writeText,B=()=>(0,E.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false",children:[(0,E.jsx)("rect",{x:"4",y:"4",width:"9",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),(0,E.jsx)("path",{d:"M3 11V3.5A1.5 1.5 0 0 1 4.5 2H11",stroke:"currentColor",strokeWidth:"1.2"})]}),U=({number:e})=>{const[t,r]=(0,h.useState)(!1),n=(0,h.useRef)(null),s=$();return(0,h.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),(0,E.jsxs)("span",{className:"wc-braintree-test-mode-copy",children:[(0,E.jsx)("span",{children:e}),s&&(0,E.jsxs)("button",{type:"button",className:"wc-braintree-test-mode-copy__button","aria-label":(0,a.__)("Copy test card number","woocommerce-gateway-paypal-powered-by-braintree"),onClick:async()=>{await(async e=>{if(!$())return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}})(e)&&(r(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(!1),2e3))},children:[(0,E.jsx)(B,{}),(0,E.jsx)("span",{className:"wc-braintree-sr-only","aria-live":"polite",children:t?(0,a.__)("Copied!","woocommerce-gateway-paypal-powered-by-braintree"):""})]})]})},z=({gatewayId:e,testAmount:t,setTestAmount:r,showCardNumber:n=!1,testCardNumber:s="4111 1111 1111 1111",testingGuideUrl:o="https://developers.braintreepayments.com/reference/general/testing/php#test-amounts"})=>{const i=(0,h.createInterpolateElement)((0,a.__)("Enter a <guide>test amount</guide> to trigger a specific error, or leave blank.","woocommerce-gateway-paypal-powered-by-braintree"),{guide:(0,E.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer"})});return(0,E.jsxs)("div",{className:"wc-braintree-test-mode",children:[(0,E.jsx)("p",{children:i}),(0,E.jsx)(x.ValidatedTextInput,{id:`wc-${e}-test-amount`,type:"text",label:(0,a.__)("Test amount","woocommerce-gateway-paypal-powered-by-braintree"),value:t,onChange:r}),n&&(0,E.jsx)("p",{children:(0,h.createInterpolateElement)((0,a.__)("Use test card <card/> or refer to our <guide>testing guide</guide>.","woocommerce-gateway-paypal-powered-by-braintree"),{card:(0,E.jsx)(U,{number:s}),guide:(0,E.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer"})})})]})},{description:O,isTestEnvironment:q}=l(),H=({testAmount:e,setTestAmount:t})=>(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("p",{children:(0,F.decodeEntities)(O||"")}),!!q&&(0,E.jsx)(z,{gatewayId:o,testAmount:e,setTestAmount:t,showCardNumber:!0})]}),V=e=>!(!e||"string"!=typeof e)&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),Y=e=>{const t=e?.paymentSource?.card,r=t?.billingAddress||{},{firstName:a,lastName:n}=(e=>{if(!e)return{firstName:"",lastName:""};const t=e.split(" "),r=t.pop()||"";return{firstName:t.join(" ")||"",lastName:r}})(t?.name);
2return{...r,firstName:a,lastName:n}},W=e=>e?{first_name:e.firstName||"",last_name:e.lastName||"",address_1:e.streetAddress||"",address_2:e.extendedAddress||"",city:e.locality||"",state:e.region||"",postcode:e.postalCode||"",country:e.countryCodeAlpha2||"",phone:e.phoneNumber||""}:{},K=(e,t,r=null)=>{e&&(console.log(`Braintree Fastlane: ${t}`),r&&console.log(r))};class G{constructor(){this.fastlane=null,this.identity=null,this.profile=null,this.client=null,this.deviceData="",this.serverData=null,this.isInitializing=!1,this.isReady=!1,this.error=null,this.isMember=!1,this.isLookingUp=!1,this.profileData=null,this.lastLookedUpEmail="",this.listeners=new Set,this.debouncedLookup=(e=>{let t;return function(...r){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),e(...r)},500)}})(e=>{this.lookupEmail(e)})}getServerData(){return this.serverData||(this.serverData=l()),this.serverData}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.getState()))}getState(){return{fastlane:this.fastlane,identity:this.identity,profile:this.profile,client:this.client,deviceData:this.deviceData,isReady:this.isReady,isInitializing:this.isInitializing,error:this.error,isMember:this.isMember,isLookingUp:this.isLookingUp,profileData:this.profileData}}async initialize(){if(this.isReady)return this.getState();if(this.isInitializing)return new Promise(e=>{const t=this.subscribe(r=>{(r.isReady||r.error)&&(t(),e(r))})});this.isInitializing=!0,this.notifyListeners();const{ajaxUrl:e,clientTokenNonce:t,debug:r,isAdvancedFraudTool:a}=this.getServerData();try{const{braintree:n}=window;if(!n||!n.fastlane)throw new Error("Braintree Fastlane SDK not available");K(r,"Initializing Fastlane SDK (global)");const o=await y(e,s,t);if(this.client=await n.client.create({authorization:o}),a&&n.dataCollector)try{const e=await n.dataCollector.create({client:this.client});e?.deviceData&&(this.deviceData=e.deviceData)}catch(e){K(r,"Data collector setup failed",e)}return this.fastlane=await n.fastlane.create({authorization:o,client:this.client}),this.identity=this.fastlane.identity,this.profile=this.fastlane.profile,this.isReady=!0,this.isInitializing=!1,K(r,"Fastlane SDK initialized successfully (global)"),this.notifyListeners(),this.getState()}catch(e){throw K(r,"Fastlane initialization failed",e),this.error=e,this.isInitializing=!1,this.notifyListeners(),e}}async lookupEmail(e){if(!this.identity||!e||!V(e))return;if(e===this.lastLookedUpEmail)return;const{debug:t}=this.getServerData();this.isLookingUp=!0,this.lastLookedUpEmail=e,this.notifyListeners();try{K(t,"Looking up email",e);const{customerContextId:r}=await this.identity.lookupCustomerByEmail(e);if(r){K(t,"Fastlane member found, triggering auth");const e=await this.identity.triggerAuthenticationFlow(r);"succeeded"===e.authenticationState?(K(t,"Authentication succeeded",e.profileData),this.isMember=!0,this.profileData=e.profileData):(K(t,"Authentication cancelled or failed"),this.isMember=!1,this.profileData=null)}else K(t,"Not a Fastlane member"),this.isMember=!1,this.profileData=null}catch(e){K(t,"Email lookup failed",e),this.isMember=!1,this.profileData=null}finally{this.isLookingUp=!1,this.notifyListeners()}}triggerEmailLookup(e){V(e)&&e!==this.lastLookedUpEmail&&this.debouncedLookup(e)}resetMemberState(){this.isMember=!1,this.profileData=null,this.lastLookedUpEmail="",this.notifyListeners()}getBillingAddress(){if(!this.profileData?.card)return null;const e=Y(this.profileData.card);return e?W(e):null}getShippingAddress(){return this.profileData?.shippingAddress?W(this.profileData.shippingAddress):null}}const{debug:J}=l(),X={input:["#billing-first_name","#shipping-first_name","#email",".wc-block-components-text-input input"],primaryColor:[".wc-block-components-button",".wp-element-button",".wc-block-components-checkout-place-order-button","a"],container:[".wc-block-checkout",".wc-block-components-main",".wp-block-woocommerce-checkout"]},Q={input:["#billing_first_name","#shipping_first_name","#billing_email",'.woocommerce-checkout input[type="text"]'],primaryColor:[".woocommerce .button",".woocommerce-checkout .button",'button[type="submit"]',"a"],container:[".payment_box","form.checkout",".woocommerce-checkout","#customer_details"]}
2,Z=["Arial","Brush Script MT","Courier New","Garamond","Georgia","PayPal-Open","Tahoma","Times New Roman","Trebuchet MS","Verdana"],ee=e=>{if(!e)return e;if(e.startsWith("#"))return e;const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return t?"#"+(1<<24|parseInt(t[1],10)<<16|parseInt(t[2],10)<<8|parseInt(t[3],10)).toString(16).slice(1):e},te=e=>!(!e||"transparent"===e||e.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0\s*\)/)),re=(e,t,r)=>{const a=(e=>{if(!e)return null;const t=e.match(/^([\d.]+)/);return t?parseFloat(t[1]):null})(e);return null===a?null:`${Math.round(Math.min(Math.max(a,t),r))}px`},ae=e=>{for(const t of e){const e=document.querySelector(t);if(e)return e}return null},ne=e=>e?window.getComputedStyle(e):null,se=({isBlocksCheckout:e=!0}={})=>{const t=(e=>e?X:Q)(e),r={root:{},input:{}},a=ae(t.input);if(a){const e=ne(a),t=(e=>{if(!e)return{};const t={},r=e.backgroundColor;te(r)&&(t.backgroundColor=ee(r));const a=re(e.borderRadius,0,32);a&&(t.borderRadius=a);const n=e.borderColor;te(n)&&(t.borderColor=ee(n));const s=re(e.borderWidth,1,5);s&&(t.borderWidth=s);const o=e.color;return te(o)&&(t.textColorBase=ee(o)),t})(e);Object.assign(r.input,t);const n=(e=>{if(!e)return{};const t={},r=(e=>{if(!e)return null;const t=e.toLowerCase();for(const e of Z)if(t.includes(e.toLowerCase()))return`${e}, sans-serif`;return null})(e.fontFamily);r&&(t.fontFamily=r);const a=re(e.fontSize,13,24);return a&&(t.fontSizeBase=a),t})(e);Object.assign(r.root,n)}const n=ae(t.primaryColor);if(n){const e=(e=>{if(!e)return null;const t=e.backgroundColor;if(te(t))return ee(t);const r=e.color;return te(r)?ee(r):null})(ne(n));e&&(r.root.primaryColor=e,r.input.focusBorderColor=e)}const s=ae(t.container);if(s){const e=(e=>{let t=e;for(;t;){const e=window.getComputedStyle(t).backgroundColor;if(te(e))return ee(e);t=t.parentElement}return null})(s);e&&(r.root.backgroundColor=e);const t=ne(s).color;te(t)&&(r.root.textColorBase=ee(t))}return r},{debug:oe}=l(),ie=({fastlane:e,onReady:t,onError:r})=>{const a=(0,h.useRef)(null),[,s]=(0,h.useState)(null),[o,i]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),d=(0,h.useRef)(t),u=(0,h.useRef)(r);return d.current=t,u.current=r,(0,h.useEffect)(()=>{if(!e||!a.current||o)return;if(!e.FastlaneCardComponent){const e=new Error("FastlaneCardComponent not available");return K(oe,e.message),l(e),void u.current?.(e)}(async()=>{i(!0),l(null);try{a.current&&(a.current.innerHTML="");const r=(0,n.select)("wc/store/cart"),o=r?.getCustomerData()?.billingAddress||{},{cardholderName:i,phoneNumber:c}=(t=o)?{cardholderName:`${t.firstName||t.first_name||""} ${t.lastName||t.last_name||""}`.trim(),phoneNumber:t.phone||t.phoneNumber||""}:{cardholderName:"",phoneNumber:""},l=se({isBlocksCheckout:!0});K(oe,"Rendering FastlaneCardComponent",{cardholderName:i,phoneNumber:c,styles:l});const u=await e.FastlaneCardComponent({fields:{cardholderName:{prefill:i},phoneNumber:{prefill:c}},styles:l});a.current&&(await u.render("#wc-braintree-fastlane-card-container"),s(u),d.current?.(u),K(oe,"FastlaneCardComponent rendered"))}catch(e){K(oe,"FastlaneCardComponent render failed",e),l(e),u.current?.(e)}finally{i(!1)}var t})();const t=a.current;return()=>{t&&(t.innerHTML=""),s(null)}},[e]),c?null:(0,E.jsx)("div",{id:"wc-braintree-fastlane-card-container",ref:a,className:"wc-braintree-fastlane-card-component "+(o?"is-loading":"")})},ce=({card:e,icons:t={},onEdit:r})=>{const n=(e=>{const t=e?.paymentSource?.card||e||{};return{id:e?.id||"",brand:t.brand||"Card",lastDigits:t.lastDigits||"****",expiry:t.expiry||""}})(e),s=t[n.brand.toLowerCase()]||null,o=s?.src||s||null;return(0,E.jsxs)("div",{className:"wc-braintree-fastlane-payment-option",children:[(0,E.jsx)("div",{className:"wc-braintree-fastlane-payment-option__icon-wrapper",children:o&&(0,E.jsx)("img",{src:o,alt:n.brand,className:"wc-braintree-fastlane-payment-option__icon"})}),(0,E.jsxs)("span",{className:"wc-braintree-fastlane-payment-option__details",children:[n.brand," â¢â¢â¢â¢"," ",n.lastDigits]}),(0,E.jsx)("button",{type:"button",className:"wc-braintree-fastlane-payment-option__edit",onClick:r,children:(0,a.__)("Edit c
2ard","woocommerce-gateway-paypal-powered-by-braintree")})]})},{icons:le,tokenizationForced:de}=l(),ue=({paymentFormHandler:e,eventRegistration:t,emitResponse:r})=>{const{onPaymentSetup:n,onCheckoutFail:s,onCheckoutSuccess:o}=t,{getPaymentMethodData:i,fastlaneState:c}=e,{isMember:l,selectedCard:d,cardComponent:u,getMemberPaymentToken:p,getNonMemberPaymentToken:m}=c||{};return(0,h.useEffect)(()=>{const e=n(async()=>{try{let e;if(l&&d){if(e=p?.(),!e)throw new Error((0,a.__)("No payment card selected","woocommerce-gateway-paypal-powered-by-braintree"))}else{if(!u)throw new Error((0,a.__)("Payment form not ready","woocommerce-gateway-paypal-powered-by-braintree"));if(e=await(m?.()),!e)throw new Error((0,a.__)("Failed to process card details","woocommerce-gateway-paypal-powered-by-braintree"))}return{type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{...i(),wc_braintree_credit_card_payment_nonce:e}}}}catch(e){return{type:r.responseTypes.ERROR,message:e.message||(0,a.__)("Payment processing failed","woocommerce-gateway-paypal-powered-by-braintree"),messageContext:r.noticeContexts.PAYMENTS}}});return()=>e()},[n,r,l,d,u,p,m,i]),I(s,o,r),null},pe=e=>{const{emitResponse:t,eventRegistration:r,onFastlaneFailed:s}=e,[i,c]=(0,h.useState)(null),[l,d]=(0,h.useState)(null),{fastlane:u,profile:p,isReady:m,isMember:y,profileData:g,deviceData:w,error:b}=(({onError:e}={})=>{const t=(window.wcBraintreeFastlaneManager||(window.wcBraintreeFastlaneManager=new G),window.wcBraintreeFastlaneManager),[r,a]=(0,h.useState)(()=>t.getState());(0,h.useEffect)(()=>{const r=t.subscribe(t=>{a(t),t.error&&e&&e(t.error)}),n=t.getState();return n.error&&e&&e(n.error),r},[e,t]);const n=(0,h.useCallback)(()=>{t.resetMemberState()},[t]);return{fastlane:r.fastlane,identity:r.identity,profile:r.profile,client:r.client,isReady:r.isReady,isLookingUp:r.isLookingUp,isMember:r.isMember,profileData:r.profileData,deviceData:r.deviceData,error:r.error,lookupEmail:e=>t.triggerEmailLookup(e),resetMemberState:n}})({onError:e=>{c(e),s?.()}}),{selectedCard:f,handleEditCard:_,getPaymentToken:C}=(({profileData:e,profile:t})=>{const[r,a]=(0,h.useState)(e?.card||null),{setBillingAddress:s}=(0,n.useDispatch)("wc/store/cart");(0,h.useEffect)(()=>{e?.card&&(K(J,"Profile data updated, setting selected card",e.card),a(e.card))},[e]);const o=(0,h.useCallback)(async()=>{if(t&&t.showCardSelector)try{K(J,"Opening Fastlane card selector");const{selectionChanged:e,selectedCard:r}=await t.showCardSelector();if(e&&r){K(J,"Card selection changed",r),a(r);const e=Y(r);if(e){const t=W(e);K(J,"Updating billing from selected card",t),s(t)}}}catch(e){K(J,"Error showing card selector",e)}else K(J,"Card selector not available")},[t,s]),i=(0,h.useCallback)(()=>r?.id?r.id:null,[r]),c=(0,h.useCallback)(e=>{a(e)},[]);return{selectedCard:r,handleEditCard:o,getPaymentToken:i,updateSelectedCard:c}})({profileData:g,profile:p}),{onReady:k,getPaymentToken:S}=(()=>{const[e,t]=(0,h.useState)(null),r=(0,h.useCallback)(e=>{t(e)},[]),a=(0,h.useCallback)(async(t=null)=>{if(!e)throw new Error("Card component not ready");const r=(0,n.select)("wc/store/cart"),a=(s=t||r?.getCustomerData()?.billingAddress||{})?{firstName:s.first_name||"",lastName:s.last_name||"",streetAddress:s.address_1||"",extendedAddress:s.address_2||"",locality:s.city||"",region:s.state||"",postalCode:s.postcode||"",countryCodeAlpha2:s.country||"",phoneNumber:s.phone||""}:{};var s;K(oe,"useFastlaneCardComponent.getPaymentToken",{billingAddress:a});const o=await e.getPaymentToken({billingAddress:a});if(!o?.id)throw new Error("Failed to get payment token");return o.id},[e]);return{cardComponent:e,onReady:r,getPaymentToken:a,isReady:!!e}})(),v=(0,h.useCallback)(e=>{d(e),k(e)},[k]),x=(0,h.useCallback)(e=>{c(e),s?.()},[s]);if(i||b)return null;const D=(0,h.useCallback)(()=>{const e={wc_braintree_device_data:w};return de&&(e[`wc-${o}-tokenize-payment-method`]=!0),e},[w]),j=(0,h.useMemo)(()=>({isMember:y,selectedCard:f,cardComponent:l,getMemberPaymentToken:C,getNonMemberPaymentToken:S}),[y,f,l,C,S]),N=(0,h.useMemo)(()=>({getPaymentMethodData:D,fastlaneState:j}),[D,j]);return(0,E.jsxs)("div",{className:"wc-braintree-fastlane-credit-card",children:[(0,E.jsx)("div",{className:"wc-braintree-fastlane-payment",children:y&&f?(0,E.jsx)(ce,{card:f,icons:le,onEdit:_}):m&&(0,E.jsx)(ie,{fastlane:u,onReady:v,onError:x})}),!m&&(0,E.jsx)("div",{className:"wc-braintree-fastlane-loading",children:(0,a.__)("Lo
2ading payment formâ¦","woocommerce-gateway-paypal-powered-by-braintree")}),(0,E.jsx)(ue,{paymentFormHandler:N,eventRegistration:r,emitResponse:t})]})},{integrationErrorMessage:me,fastlaneEnabled:he}=l(),ye=m(),ge=(0,i.getSetting)("isBlockTheme")?"wc-block-components-notice-banner is-error":"woocommerce-error",we=e=>{const{emitResponse:t,eventRegistration:r}=e,{PaymentMethodIcons:a}=e.components,n=v(e),{setupIntegration:s,hostedFieldsInstance:o,testAmount:i,setTestAmount:c}=n,[l,d]=(0,h.useState)(""),[u,m]=(0,h.useState)(!1),[y,g]=(0,h.useState)(!1),w=he&&void 0!==window.braintree?.fastlane,b=he&&!y;return(0,h.useEffect)(()=>{if(b&&w)return;let e,t,r;return async function(){try{const{hostedFields:a,dataCollector:n,threeDSecure:o}=await s();[e,t,r]=[a,n,o],m(!0)}catch(e){p(`Integration Error: ${e.message}`,e),d(me)}}(),()=>{m(!1),e&&e.teardown(),t&&t.teardown(),r&&r.teardown()}},[s,b,w]),l?(0,E.jsx)("div",{className:ge,children:l}):b&&w?(0,E.jsx)(pe,{...e,onFastlaneFailed:()=>{p("Fastlane failed, falling back to Hosted Fields"),g(!0)}}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(H,{testAmount:i,setTestAmount:c}),(0,E.jsx)(N,{...e,isLoaded:u,hostedFieldsInstance:o}),!!a&&!!ye.length&&(0,E.jsx)(a,{icons:ye,align:"left"}),(0,E.jsx)(P,{checkoutFormHandler:n,eventRegistration:r,emitResponse:t})]})},be=(0,i.getSetting)("isBlockTheme")?"wc-block-components-notice-banner is-error":"woocommerce-error",{cscRequired:fe,integrationErrorMessage:_e}=l(),Ce=()=>(0,E.jsxs)("span",{className:"wc-braintree-test-badge",children:[(0,a.__)("Test","woocommerce-gateway-paypal-powered-by-braintree"),(0,E.jsx)("span",{className:"wc-braintree-sr-only",children:/* translators: suffix to the "Test" badge label, announced only to screen readers */ /* translators: suffix to the "Test" badge label, announced only to screen readers */ 3(0,a.__)(" mode","woocommerce-gateway-paypal-powered-by-braintree")})]}),ke=m(),{title:Se,showSavedCards:ve,showSaveOption:xe,supports:Ee,isTestEnvironment:De}=l(),je=e=>{const{PaymentMethodLabel:t}=e.components;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(t,{text:Se}),!!De&&(0,E.jsx)(Ce,{})]})},Ne=({RenderedComponent:e,...t})=>(0,n.select)("core/editor")?null:(0,E.jsx)(e,{...t}),Fe={name:s,label:(0,E.jsx)(je,{}),ariaLabel:(0,a.__)("PayPal Enterprise Payments Credit Card Payment Method","woocommerce-gateway-paypal-powered-by-braintree"),canMakePayment:()=>!0,content:(0,E.jsx)(Ne,{RenderedComponent:we}),edit:(0,E.jsx)(Ne,{RenderedComponent:we}),savedTokenComponent:(0,E.jsx)(Ne,{RenderedComponent:e=>{const{emitResponse:t,eventRegistration:r,token:n}=e,s=v(e),{setupIntegration:o,hostedFieldsInstance:i}=s,[c,l]=(0,h.useState)(""),[d,u]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let e,t,r;return async function(){try{const{hostedFields:a,dataCollector:n,threeDSecure:s}=await o();[e,t,r]=[a,n,s],u(!0)}catch(e){p(`Integration Error: ${e.message}`,e),l(_e)}}(),()=>{u(!1),e&&e.teardown(),t&&t.teardown(),r&&r.teardown()}},[o]),c?(0,E.jsx)("div",{className:be,children:c}):(0,E.jsxs)("div",{className:"wc-braintree-hosted-fields-saved-token is-small",children:[fe&&(0,E.jsx)("p",{className:"wc-block-components-checkout-step__description",children:(0,a.__)("Card Security Code is required to make payments using saved cards","woocommerce-gateway-paypal-powered-by-braintree")}),(0,E.jsx)(N,{...e,token:n,isLoaded:d,hostedFieldsInstance:i}),(0,E.jsx)(P,{checkoutFormHandler:s,eventRegistration:r,emitResponse:t,token:n})]})}}),icons:ke,supports:{showSavedCards:ve||!1,showSaveOption:xe||!1,features:Ee||[]}};(0,r.registerPaymentMethod)(Fe)})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.