Files
2026-04-28 15:13:50 +02:00

2 lines
8.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*! For license information please see tos.js.LICENSE.txt */
(()=>{var e={5338:(e,t,o)=>{"use strict";var n=o(5795);t.H=n.createRoot,n.hydrateRoot},1020:(e,t,o)=>{"use strict";var n=o(1609),s=Symbol.for("react.element"),r=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(e,t,o){var n,a={},l=null,p=null;for(n in void 0!==o&&(l=""+o),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(p=t.ref),t)r.call(t,n)&&!i.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:s,type:e,key:l,ref:p,props:a,_owner:c.current}}t.jsx=a,t.jsxs=a},4848:(e,t,o)=>{"use strict";e.exports=o(1020)},1609:e=>{"use strict";e.exports=window.React},5795:e=>{"use strict";e.exports=window.ReactDOM}},t={};function o(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var s=n.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=n[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),o.p=window.wcpayAssets.url,(()=>{"use strict";var e=o(1609),t=o(5338);const n=window.wp.i18n;function s(e){return e.startsWith("{{/")?{type:"componentClose",value:e.replace(/\W/g,"")}:e.endsWith("/}}")?{type:"componentSelfClosing",value:e.replace(/\W/g,"")}:e.startsWith("{{")?{type:"componentOpen",value:e.replace(/\W/g,"")}:{type:"string",value:e}}function r(t,o){let n,s,c=[];for(let e=0;e<t.length;e++){const r=t[e];if("string"!==r.type){if(void 0===o[r.value])throw new Error(`Invalid interpolation, missing component node: \`${r.value}\``);if("object"!=typeof o[r.value])throw new Error(`Invalid interpolation, component node must be a ReactElement or null: \`${r.value}\``);if("componentClose"===r.type)throw new Error(`Missing opening component token: \`${r.value}\``);if("componentOpen"===r.type){n=o[r.value],s=e;break}c.push(o[r.value])}else c.push(r.value)}if(n){const i=function(e,t){const o=t[e];let n=0;for(let s=e+1;s<t.length;s++){const e=t[s];if(e.value===o.value){if("componentOpen"===e.type){n++;continue}if("componentClose"===e.type){if(0===n)return s;n--}}}throw new Error("Missing closing component token `"+o.value+"`")}(s,t),a=r(t.slice(s+1,i),o),l=(0,e.cloneElement)(n,{},a);if(c.push(l),i<t.length-1){const e=r(t.slice(i+1),o);c=c.concat(e)}}return c=c.filter(Boolean),0===c.length?null:1===c.length?c[0]:(0,e.createElement)(e.Fragment,null,...c)}function c(e){const{mixedString:t,components:o,throwErrors:n}=e;if(!o)return t;if("object"!=typeof o){if(n)throw new Error(`Interpolation Error: unable to process \`${t}\` because components is not an object`);return t}const c=function(e){return e.split(/(\{\{\/?\s*\w+\s*\/?\}\})/g).map(s)}(t);try{return r(c,o)}catch(e){if(n)throw new Error(`Interpolation Error: unable to process \`${t}\` because of error \`${e.message}\``);return t}}const i=window.wp.components,a=window.wp.url,l=(window.lodash,window.moment,window.wp.date,window.wc.number,e=>(0,a.addQueryArgs)("admin.php",e)),p=window.wp.apiFetch;var m=o.n(p);const u=window.wp.domReady;var d=o.n(u);const w=async({accept:e})=>m()({path:"/wc/v3/payments/tos",method:"POST",data:{accept:e}}),y=async()=>{const e=wcpay_tos_settings.trackStripeConnected;wcTracks.isEnabled&&e&&(((e,t={})=>{if(window.wcpaySettings){Object.assign(t,{is_test_mode:wcpaySettings.testMode,jetpack_connected:wcpaySettings.isJetpackConnected,wcpay_version:wcpaySettings.version,woo_country_code:wcpaySettings.connect.country,hosting_provider:wcpaySettings.trackingInfo?.hosting_provider});for(const e in t)void 0===t[e]&&delete t[e]}d()((()=>{var o;(null!==(o=wc?.tracks?.recordEvent)&&void 0!==o?o:wcTracks.recordEvent)(e,t)}))})("wcpay_stripe_connected",{is_existing_stripe_account:e.is_existing_stripe_account}),m()({path:"/wc/v3/payments/tos/stripe_track_connected",method:"POST"}))};var _=o(4848);const f=e=>(0,_.jsx)(i.ExternalLink,{...e,href:"https://wordpress.com/tos"}),h=({onAccept:e,onDecline:t,isBusy:o,hasError:s})=>{const r=(0,n.sprintf)((0,n.__)("%s: Terms of Service","woocommerce-payments"),"WooPayments"),a=c({mixedString:(0,n.sprintf)((0,n.__)("To continue using %s, please review and agree to our {{link}}Terms of Service{{/link}}. By clicking “Accept” you agree to the Terms of Service.","woocommerce-payments"),"WooPayments"),components:{link:(0,_.jsx)(f,{})}});return(0,_.jsxs)(i.Modal,{title:r,isDismissible:!1,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,onRequestClose:t,className:"woocommerce-payments__tos-modal",children:[s&&(0,_.jsx)(i.Notice,{status:"error",isDismissible:!1,className:"woocommerce-payments__tos-error",children:(0,n.__)("Something went wrong. Please try accepting the Terms of Service again!","woocommerce-payments")}),(0,_.jsxs)("div",{className:"woocommerce-payments__tos-wrapper",children:[(0,_.jsx)("div",{className:"woocommerce-payments__tos-modal-message",children:a}),(0,_.jsxs)("div",{className:"woocommerce-payments__tos-footer",children:[(0,_.jsx)(i.Button,{variant:"secondary",onClick:t,disabled:o,__next40pxDefaultSize:!0,children:(0,n.__)("Decline","woocommerce-payments")}),(0,_.jsx)(i.Button,{variant:"primary",onClick:e,isBusy:o,__next40pxDefaultSize:!0,children:(0,n.__)("Accept","woocommerce-payments")})]})]})]})},g=({onDisable:e,onCancel:t,isBusy:o,hasError:s})=>{const r=(0,n.sprintf)((0,n.__)("Disable %s","woocommerce-payments"),"WooPayments"),a=c({mixedString:(0,n.sprintf)((0,n.__)("By declining our {{link}}Terms of Service{{/link}}, youll no longer be able to capture credit card payments using %s. Your previous transaction and payout data will still be available.","woocommerce-payments"),"WooPayments"),components:{link:(0,_.jsx)(f,{})}});return(0,_.jsxs)(i.Modal,{title:r,isDismissible:!1,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,onRequestClose:e,className:"woocommerce-payments__tos-modal",children:[s&&(0,_.jsx)(i.Notice,{status:"error",isDismissible:!1,className:"woocommerce-payments__tos-error",children:(0,n.__)("Something went wrong. Please try again!","woocommerce-payments")}),(0,_.jsxs)("div",{className:"woocommerce-payments__tos-wrapper",children:[(0,_.jsx)("div",{className:"woocommerce-payments__tos-modal-message",children:a}),(0,_.jsxs)("div",{className:"woocommerce-payments__tos-footer",children:[(0,_.jsx)(i.Button,{variant:"tertiary",onClick:t,isBusy:o,__next40pxDefaultSize:!0,children:(0,n.__)("Back","woocommerce-payments")}),(0,_.jsx)(i.Button,{variant:"primary",onClick:e,isBusy:o,__next40pxDefaultSize:!0,children:(0,n.__)("Disable","woocommerce-payments")})]})]})]})},v=()=>{const[t,o]=(0,e.useState)(!0),[n,s]=(0,e.useState)(!1),[r,c]=(0,e.useState)(!1),[i,p]=(0,e.useState)(!1),[m,u]=(0,e.useState)(!1),d=()=>o(!1),f=()=>s(!1);return n?(0,_.jsx)(g,{onDisable:async()=>{try{u(!1),c(!0),await w({accept:!1}),f(),window.location.href=(0,a.addQueryArgs)(l({page:"wc-settings",tab:"checkout"}),{"tos-disabled":1})}catch(e){u(!0)}finally{c(!1)}},onCancel:()=>{f(),o(!0)},isBusy:r,hasError:m}):t?(0,_.jsx)(h,{onAccept:async()=>{try{p(!1),c(!0),await w({accept:!0}),y(),d()}catch(e){p(!0)}finally{c(!1)}},onDecline:()=>{d(),s(!0)},isBusy:r,hasError:i}):null},x=window.wp.data;wcpay_tos_settings.tosAgreementDeclined&&window.addEventListener("load",(()=>{const{settingsUrl:e}=wcpay_tos_settings;(e=>{const{createInfoNotice:t}=(0,x.dispatch)("core/notices");t((0,n.sprintf)((0,n.__)("Disabled %s","woocommerce-payments"),"WooPayments"),{actions:[{label:(0,n.__)("Undo","woocommerce-payments"),onClick:async()=>{try{await(async()=>m()({path:"/wc/v3/payments/tos/reactivate",method:"POST"}))()}finally{window.location=e}}}]})})(e)})),wcpay_tos_settings.tosAgreementRequired?function(){const e=document.createElement("div");e.id="wcpay-tos-container",document.body.appendChild(e),(0,t.H)(e).render((0,_.jsx)(v,{}))}():y()})()})();