@busha/commerce-js 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +6 -0
- package/cypress/e2e/basic.cy.ts +82 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.ts +9 -0
- package/cypress/support/e2e.ts +20 -0
- package/cypress/support/index.d.ts +39 -0
- package/cypress/tsconfig.json +8 -0
- package/cypress.config.ts +17 -0
- package/dist/index.js +1 -1
- package/dist/index.min.js +1 -1
- package/dist/types.d.ts +1 -1
- package/jest.config.ts +195 -0
- package/package.json +23 -5
- package/rollup.config.ts +1 -0
- package/src/constants/variables.ts +2 -0
- package/src/helper.ts +21 -8
- package/src/index.ts +17 -3
- package/src/types.ts +1 -1
- package/tests/index.test.ts +97 -0
package/babel.config.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CONTAINER_ID } from "../../src/constants/variables";
|
|
2
|
+
|
|
3
|
+
describe("Pay with commerce-js basic", () => {
|
|
4
|
+
it("Visit example page", () => {
|
|
5
|
+
cy.visitBasicExamplePage();
|
|
6
|
+
|
|
7
|
+
cy.window().its("BushaCommerce");
|
|
8
|
+
|
|
9
|
+
cy.get("#business_id")
|
|
10
|
+
.type(Cypress.env("BUSINESS_ID"))
|
|
11
|
+
.should("have.value", Cypress.env("BUSINESS_ID"));
|
|
12
|
+
|
|
13
|
+
cy.findByRole("button", { name: /pay/i }).should("exist");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("Opens popup on submit pay form", () => {
|
|
17
|
+
cy.visitBasicExamplePage();
|
|
18
|
+
|
|
19
|
+
cy.window().its("BushaCommerce");
|
|
20
|
+
|
|
21
|
+
cy.get("#local_amount").clear().type("500");
|
|
22
|
+
cy.get("#business_id").type(Cypress.env("BUSINESS_ID"));
|
|
23
|
+
|
|
24
|
+
cy.findByRole("button", { name: /pay/i }).click();
|
|
25
|
+
|
|
26
|
+
cy.findByTestId(CONTAINER_ID)
|
|
27
|
+
.should("exist")
|
|
28
|
+
.find("form")
|
|
29
|
+
.should("not.be.undefined")
|
|
30
|
+
.should("not.be.visible");
|
|
31
|
+
|
|
32
|
+
cy.iframe()
|
|
33
|
+
.find("#root")
|
|
34
|
+
.should("not.be.undefined")
|
|
35
|
+
.contains(/Select the payment method you want to use/i);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("Popup is notified when pay app initializes", () => {
|
|
39
|
+
cy.visitBasicExamplePage({
|
|
40
|
+
onBeforeLoad(win) {
|
|
41
|
+
cy.spy(win, "postMessage").as("postMessage");
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
cy.get("#local_amount").clear().type("500");
|
|
46
|
+
cy.get("#business_id").type(Cypress.env("BUSINESS_ID"));
|
|
47
|
+
|
|
48
|
+
cy.findByRole("button", { name: /pay/i }).click();
|
|
49
|
+
|
|
50
|
+
cy.findByTestId(CONTAINER_ID).should("exist");
|
|
51
|
+
|
|
52
|
+
cy.get("@postMessage").should("have.been.called");
|
|
53
|
+
|
|
54
|
+
cy.iframe().find("#root").should("not.be.undefined");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("Closes popup when close button on pay widget is clicked", () => {
|
|
58
|
+
cy.visitBasicExamplePage();
|
|
59
|
+
|
|
60
|
+
cy.get("#local_amount").clear().type("500");
|
|
61
|
+
cy.get("#business_id").type(Cypress.env("BUSINESS_ID"));
|
|
62
|
+
|
|
63
|
+
cy.findByRole("button", { name: /pay/i }).click();
|
|
64
|
+
|
|
65
|
+
cy.iframe().find("#root .header button").should("exist").click();
|
|
66
|
+
|
|
67
|
+
cy.iframe()
|
|
68
|
+
.find("#root .content")
|
|
69
|
+
.contains(
|
|
70
|
+
"Your transaction is not completed yet. Are you sure you want to cancel?"
|
|
71
|
+
)
|
|
72
|
+
.should("be.visible");
|
|
73
|
+
|
|
74
|
+
cy.iframe()
|
|
75
|
+
.find("#root .content")
|
|
76
|
+
.find("div button:last-of-type")
|
|
77
|
+
.should("exist")
|
|
78
|
+
.click();
|
|
79
|
+
|
|
80
|
+
cy.findByTestId(CONTAINER_ID).should("not.exist");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.ts is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************
|
|
3
|
+
// This example commands.ts shows you how to
|
|
4
|
+
// create various custom commands and overwrite
|
|
5
|
+
// existing commands.
|
|
6
|
+
//
|
|
7
|
+
// For more comprehensive examples of custom
|
|
8
|
+
// commands please read more here:
|
|
9
|
+
// https://on.cypress.io/custom-commands
|
|
10
|
+
// ***********************************************
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
// -- This is a parent command --
|
|
14
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
// -- This is a child command --
|
|
18
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// -- This is a dual command --
|
|
22
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
23
|
+
//
|
|
24
|
+
//
|
|
25
|
+
// -- This will overwrite an existing command --
|
|
26
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
27
|
+
//
|
|
28
|
+
declare namespace Cypress {
|
|
29
|
+
interface Chainable {
|
|
30
|
+
/**
|
|
31
|
+
* Goto example pay page example/basic/index.html
|
|
32
|
+
* @example
|
|
33
|
+
* cy.visitBasicExamplePage()
|
|
34
|
+
*/
|
|
35
|
+
visitBasicExamplePage(
|
|
36
|
+
options?: Partial<Cypress.VisitOptions>
|
|
37
|
+
): Chainable<void>;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from "cypress";
|
|
2
|
+
import {config} from "dotenv";
|
|
3
|
+
|
|
4
|
+
config()
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
chromeWebSecurity: false,
|
|
8
|
+
env: {
|
|
9
|
+
BASIC_EXAMPLE_PAGE: "./example/basic/index.html",
|
|
10
|
+
BUSINESS_ID: process.env.CYPRESS_BUSINESS_ID
|
|
11
|
+
},
|
|
12
|
+
e2e: {
|
|
13
|
+
setupNodeEvents(on, config) {
|
|
14
|
+
// implement node event listeners here
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="busha-commerce-container",t="busha-commerce-loader",s="busha-commerce-styles",n="busha-commerce-close-btn",r="https://pay.busha.co/pay";function i(e){this._maxSize=e,this.clear()}i.prototype.clear=function(){this._size=0,this._values=Object.create(null)},i.prototype.get=function(e){return this._values[e]},i.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var a=/[^.^\]^[]+|(?=\[\]|\.\.)/g,o=/^\d+$/,u=/^\d/,l=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,c=/^\s*(['"]?)(.*?)(\1)\s*$/,h=new i(512),f=new i(512),d=new i(512),p={Cache:i,split:y,normalizePath:m,setter:function(e){var t=m(e);return f.get(e)||f.set(e,(function(e,s){for(var n=0,r=t.length,i=e;n<r-1;){var a=t[n];if("__proto__"===a||"constructor"===a||"prototype"===a)return e;i=i[t[n++]]}i[t[n]]=s}))},getter:function(e,t){var s=m(e);return d.get(e)||d.set(e,(function(e){for(var n=0,r=s.length;n<r;){if(null==e&&t)return;e=e[s[n++]]}return e}))},join:function(e){return e.reduce((function(e,t){return e+(g(t)||o.test(t)?"["+t+"]":(e?".":"")+t)}),"")},forEach:function(e,t,s){!function(e,t,s){var n,r,i,a,o=e.length;for(r=0;r<o;r++)(n=e[r])&&(v(n)&&(n='"'+n+'"'),i=!(a=g(n))&&/^\d+$/.test(n),t.call(s,n,a,i,r,e))}(Array.isArray(e)?e:y(e),t,s)}};function m(e){return h.get(e)||h.set(e,y(e).map((function(e){return e.replace(c,"$2")})))}function y(e){return e.match(a)||[""]}function g(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function v(e){return!g(e)&&(function(e){return e.match(u)&&!e.match(o)}(e)||function(e){return l.test(e)}(e))}const b=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,x=e=>e.match(b)||[],w=(e,t)=>x(e).join(t).toLowerCase(),F=e=>x(e).reduce(((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`),"");var E=F,_=e=>w(e,"_"),O={};function $(e,t){var s=e.length,n=new Array(s),r={},i=s,a=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++){var r=e[s];t.has(r[0])||t.set(r[0],new Set),t.has(r[1])||t.set(r[1],new Set),t.get(r[0]).add(r[1])}return t}(t),o=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++)t.set(e[s],s);return t}(e);for(t.forEach((function(e){if(!o.has(e[0])||!o.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")}));i--;)r[i]||u(e[i],i,new Set);return n;function u(e,t,i){if(i.has(e)){var l;try{l=", node was:"+JSON.stringify(e)}catch(e){l=""}throw new Error("Cyclic dependency"+l)}if(!o.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!r[t]){r[t]=!0;var c=a.get(e)||new Set;if(t=(c=Array.from(c)).length){i.add(e);do{var h=c[--t];u(h,o.get(h),i)}while(t);i.delete(e)}n[--s]=e}}}({get exports(){return O},set exports(e){O=e}}).exports=function(e){return $(function(e){for(var t=new Set,s=0,n=e.length;s<n;s++){var r=e[s];t.add(r[0]),t.add(r[1])}return Array.from(t)}(e),e)},O.array=$;const k=Object.prototype.toString,T=Error.prototype.toString,A=RegExp.prototype.toString,D="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",S=/^Symbol\((.*)\)(.*)$/;function j(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const s=typeof e;if("number"===s)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===s)return t?`"${e}"`:e;if("function"===s)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===s)return D.call(e).replace(S,"Symbol($1)");const n=k.call(e).slice(8,-1);return"Date"===n?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===n||e instanceof Error?"["+T.call(e)+"]":"RegExp"===n?A.call(e):null}function C(e,t){let s=j(e,t);return null!==s?s:JSON.stringify(e,(function(e,s){let n=j(this[e],t);return null!==n?n:s}),2)}function N(e){return null==e?[]:[].concat(e)}let z=/\$\{\s*(\w+)\s*\}/g;class I extends Error{static formatError(e,t){const s=t.label||t.path||"this";return s!==t.path&&(t=Object.assign({},t,{path:s})),"string"==typeof e?e.replace(z,((e,s)=>C(t[s]))):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,s,n){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=s,this.type=n,this.errors=[],this.inner=[],N(e).forEach((e=>{I.isError(e)?(this.errors.push(...e.errors),this.inner=this.inner.concat(e.inner.length?e.inner:e)):this.errors.push(e)})),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,I)}}let P={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:s,originalValue:n})=>{const r=null!=n&&n!==s?` (cast from the value \`${C(n,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${C(s,!0)}\``+r:`${e} must match the configured type. The validated value was: \`${C(s,!0)}\``+r}},V={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},M={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},L={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},q={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:P,string:V,number:M,date:L,object:q,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:{isValue:"${path} field must be ${value}"}});const R=e=>e&&e.__isYupSchema__;class Z{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:s,then:n,otherwise:r}=t,i="function"==typeof s?s:(...e)=>e.every((e=>e===s));return new Z(e,((e,t)=>{var s;let a=i(...e)?n:r;return null!=(s=null==a?void 0:a(t))?s:t}))}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let s=this.refs.map((e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context))),n=this.fn(s,e,t);if(void 0===n||n===e)return e;if(!R(n))throw new TypeError("conditions must return a schema object");return n.resolve(t)}}const U="$",Y=".";class B{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===U,this.isValue=this.key[0]===Y,this.isSibling=!this.isContext&&!this.isValue;let s=this.isContext?U:this.isValue?Y:"";this.path=this.key.slice(s.length),this.getter=this.path&&p.getter(this.path,!0),this.map=t.map}getValue(e,t,s){let n=this.isContext?s:this.isValue?e:t;return this.getter&&(n=this.getter(n||{})),this.map&&(n=this.map(n)),n}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}B.prototype.__isYupRef=!0;const J=e=>null==e;function K(e){function t({value:t,path:s="",options:n,originalValue:r,schema:i},a,o){const{name:u,test:l,params:c,message:h,skipAbsent:f}=e;let{parent:d,context:p,abortEarly:m=i.spec.abortEarly}=n;function y(e){return B.isRef(e)?e.getValue(t,d,p):e}function g(e={}){const n=Object.assign({value:t,originalValue:r,label:i.spec.label,path:e.path||s,spec:i.spec},c,e.params);for(const e of Object.keys(n))n[e]=y(n[e]);const a=new I(I.formatError(e.message||h,n),t,n.path,e.type||u);return a.params=n,a}const v=m?a:o;let b={path:s,parent:d,type:u,from:n.from,createError:g,resolve:y,options:n,originalValue:r,schema:i};const x=e=>{I.isError(e)?v(e):e?o(null):v(g())},w=e=>{I.isError(e)?v(e):a(e)},F=f&&J(t);if(!n.sync){try{Promise.resolve(!!F||l.call(b,t,b)).then(x,w)}catch(e){w(e)}return}let E;try{var _;if(E=!!F||l.call(b,t,b),"function"==typeof(null==(_=E)?void 0:_.then))throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(e){return void w(e)}x(E)}return t.OPTIONS=e,t}function H(e,t,s,n=s){let r,i,a;return t?(p.forEach(t,((o,u,l)=>{let c=u?o.slice(1,o.length-1):o,h="tuple"===(e=e.resolve({context:n,parent:r,value:s})).type,f=l?parseInt(c,10):0;if(e.innerType||h){if(h&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);if(s&&f>=s.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${t}. because there is no value at that index. `);r=s,s=s&&s[f],e=h?e.spec.types[f]:e.innerType}if(!l){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${e.type}")`);r=s,s=s&&s[c],e=e.fields[c]}i=c,a=u?"["+o+"]":"."+o})),{schema:e,parent:r,parentPath:i}):{parent:r,parentPath:t,schema:e}}class G extends Set{describe(){const e=[];for(const t of this.values())e.push(B.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const s of this.values())t.push(e(s));return t}clone(){return new G(this.values())}merge(e,t){const s=this.clone();return e.forEach((e=>s.add(e))),t.forEach((e=>s.delete(e))),s}}function Q(e,t=new Map){if(R(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let s;if(e instanceof Date)s=new Date(e.getTime()),t.set(e,s);else if(e instanceof RegExp)s=new RegExp(e),t.set(e,s);else if(Array.isArray(e)){s=new Array(e.length),t.set(e,s);for(let n=0;n<e.length;n++)s[n]=Q(e[n],t)}else if(e instanceof Map){s=new Map,t.set(e,s);for(const[n,r]of e.entries())s.set(n,Q(r,t))}else if(e instanceof Set){s=new Set,t.set(e,s);for(const n of e)s.add(Q(n,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);s={},t.set(e,s);for(const[n,r]of Object.entries(e))s[n]=Q(r,t)}return s}class W{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new G,this._blacklist=new G,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation((()=>{this.typeError(P.notType)})),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation((e=>{e.nonNullable()}))}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Q(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let s=e(this);return this._mutate=t,s}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,s=e.clone();const n=Object.assign({},t.spec,s.spec);return s.spec=n,s.internalTests=Object.assign({},t.internalTests,s.internalTests),s._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),s._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),s.tests=t.tests,s.exclusiveTests=t.exclusiveTests,s.withMutation((t=>{e.tests.forEach((e=>{t.test(e.OPTIONS)}))})),s.transforms=[...t.transforms,...s.transforms],s}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let s=t.conditions;t=t.clone(),t.conditions=[],t=s.reduce(((t,s)=>s.resolve(t,e)),t),t=t.resolve(e)}return t}resolveOptions(e){var t,s,n;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(s=e.abortEarly)?s:this.spec.abortEarly,recursive:null!=(n=e.recursive)?n:this.spec.recursive})}cast(e,t={}){let s=this.resolve(Object.assign({value:e},t)),n="ignore-optionality"===t.assert,r=s._cast(e,t);if(!1!==t.assert&&!s.isType(r)){if(n&&J(r))return r;let i=C(e),a=C(r);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${s.type}". \n\nattempted value: ${i} \n`+(a!==i?`result of cast: ${a}`:""))}return r}_cast(e,t){let s=void 0===e?e:this.transforms.reduce(((t,s)=>s.call(this,t,e,this)),e);return void 0===s&&(s=this.getDefault()),s}_validate(e,t={},s,n){let{path:r,originalValue:i=e,strict:a=this.spec.strict}=t,o=e;a||(o=this._cast(o,Object.assign({assert:!1},t)));let u=[];for(let e of Object.values(this.internalTests))e&&u.push(e);this.runTests({path:r,value:o,originalValue:i,options:t,tests:u},s,(e=>{if(e.length)return n(e,o);this.runTests({path:r,value:o,originalValue:i,options:t,tests:this.tests},s,n)}))}runTests(e,t,s){let n=!1,{tests:r,value:i,originalValue:a,path:o,options:u}=e,l=e=>{n||(n=!0,t(e,i))},c=e=>{n||(n=!0,s(e,i))},h=r.length,f=[];if(!h)return c([]);let d={value:i,originalValue:a,path:o,options:u,schema:this};for(let e=0;e<r.length;e++){(0,r[e])(d,l,(function(e){e&&(f=f.concat(e)),--h<=0&&c(f)}))}}asNestedTest({key:e,index:t,parent:s,parentPath:n,originalParent:r,options:i}){const a=null!=e?e:t;if(null==a)throw TypeError("Must include `key` or `index` for nested validations");const o="number"==typeof a;let u=s[a];const l=Object.assign({},i,{strict:!0,parent:s,value:u,originalValue:r[a],key:void 0,[o?"index":"key"]:a,path:o||a.includes(".")?`${n||""}[${u?a:`"${a}"`}]`:(n?`${n}.`:"")+e});return(e,t,s)=>this.resolve(l)._validate(u,l,t,s)}validate(e,t){let s=this.resolve(Object.assign({},t,{value:e}));return new Promise(((n,r)=>s._validate(e,t,((e,t)=>{I.isError(e)&&(e.value=t),r(e)}),((e,t)=>{e.length?r(new I(e,t)):n(t)}))))}validateSync(e,t){let s;return this.resolve(Object.assign({},t,{value:e}))._validate(e,Object.assign({},t,{sync:!0}),((e,t)=>{throw I.isError(e)&&(e.value=t),e}),((t,n)=>{if(t.length)throw new I(t,e);s=n})),s}isValid(e,t){return this.validate(e,t).then((()=>!0),(e=>{if(I.isError(e))return!1;throw e}))}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(I.isError(e))return!1;throw e}}_getDefault(){let e=this.spec.default;return null==e?e:"function"==typeof e?e.call(this):Q(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const s=this.clone({nullable:e});return s.internalTests.nullable=K({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),s}optionality(e,t){const s=this.clone({optional:e});return s.internalTests.optionality=K({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),s}optional(){return this.optionality(!0)}defined(e=P.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=P.notNull){return this.nullability(!1,e)}required(e=P.required){return this.clone().withMutation((t=>t.nonNullable(e).defined(e)))}notRequired(){return this.clone().withMutation((e=>e.nullable().optional()))}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=P.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let s=this.clone(),n=K(t),r=t.exclusive||t.name&&!0===s.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(s.exclusiveTests[t.name]=!!t.exclusive),s.tests=s.tests.filter((e=>{if(e.OPTIONS.name===t.name){if(r)return!1;if(e.OPTIONS.test===n.OPTIONS.test)return!1}return!0})),s.tests.push(n),s}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let s=this.clone(),n=N(e).map((e=>new B(e)));return n.forEach((e=>{e.isSibling&&s.deps.push(e.key)})),s.conditions.push("function"==typeof t?new Z(n,t):Z.fromOptions(n,t)),s}typeError(e){let t=this.clone();return t.internalTests.typeError=K({message:e,name:"typeError",test(e){return!(!J(e)&&!this.schema._typeCheck(e))||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=P.oneOf){let s=this.clone();return e.forEach((e=>{s._whitelist.add(e),s._blacklist.delete(e)})),s.internalTests.whiteList=K({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,s=t.resolveAll(this.resolve);return!!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}notOneOf(e,t=P.notOneOf){let s=this.clone();return e.forEach((e=>{s._blacklist.add(e),s._whitelist.delete(e)})),s.internalTests.blacklist=K({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,s=t.resolveAll(this.resolve);return!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:s,meta:n,optional:r,nullable:i}=t.spec;return{meta:n,label:s,optional:r,nullable:i,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map((e=>({name:e.OPTIONS.name,params:e.OPTIONS.params}))).filter(((e,t,s)=>s.findIndex((t=>t.name===e.name))===t))}}}W.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])W.prototype[`${e}At`]=function(t,s,n={}){const{parent:r,parentPath:i,schema:a}=H(this,t,s,n.context);return a[e](r&&r[i],Object.assign({},n,{parent:r,path:t}))};for(const e of["equals","is"])W.prototype[e]=W.prototype.oneOf;for(const e of["not","nope"])W.prototype[e]=W.prototype.notOneOf;let X=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ee=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,te=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,se=e=>J(e)||e===e.trim(),ne={}.toString();function re(){return new ie}class ie extends W{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce||s.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===ne?e:n}))}))}required(e){return super.required(e).withMutation((t=>t.test({message:e||P.required,name:"required",skipAbsent:!0,test:e=>!!e.length})))}notRequired(){return super.notRequired().withMutation((e=>(e.tests=e.tests.filter((e=>"required"!==e.OPTIONS.name)),e)))}length(e,t=V.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=V.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=V.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let s,n,r=!1;return t&&("object"==typeof t?({excludeEmptyString:r=!1,message:s,name:n}=t):s=t),this.test({name:n||"matches",message:s||V.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&r||-1!==t.search(e)})}email(e=V.email){return this.matches(X,{name:"email",message:e,excludeEmptyString:!0})}url(e=V.url){return this.matches(ee,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=V.uuid){return this.matches(te,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform((e=>null===e?"":e))}trim(e=V.trim){return this.transform((e=>null!=e?e.trim():e)).test({message:e,name:"trim",test:se})}lowercase(e=V.lowercase){return this.transform((e=>J(e)?e:e.toLowerCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>J(e)||e===e.toLowerCase()})}uppercase(e=V.uppercase){return this.transform((e=>J(e)?e:e.toUpperCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>J(e)||e===e.toUpperCase()})}}re.prototype=ie.prototype;function ae(){return new oe}class oe extends W{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return s.isType(n)?n:parseFloat(n)}))}))}min(e,t=M.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=M.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=M.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=M.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=M.positive){return this.moreThan(0,e)}negative(e=M.negative){return this.lessThan(0,e)}integer(e=M.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform((e=>J(e)?e:0|e))}round(e){var t;let s=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===s.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+s.join(", "));return this.transform((t=>J(t)?t:Math[e](t)))}}ae.prototype=oe.prototype;var ue=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;let le=new Date("");class ce extends W{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation((()=>{this.transform(((e,t,s)=>!s.spec.coerce||s.isType(e)?e:(e=function(e){var t,s,n=[1,4,5,6,7,10,11],r=0;if(s=ue.exec(e)){for(var i,a=0;i=n[a];++a)s[i]=+s[i]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,void 0!==s[8]&&""!==s[8]||void 0!==s[9]&&""!==s[9]?("Z"!==s[8]&&void 0!==s[9]&&(r=60*s[10]+s[11],"+"===s[9]&&(r=0-r)),t=Date.UTC(s[1],s[2],s[3],s[4],s[5]+r,s[6],s[7])):t=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7])}else t=Date.parse?Date.parse(e):NaN;return t}(e),isNaN(e)?ce.INVALID_DATE:new Date(e))))}))}prepareParam(e,t){let s;if(B.isRef(e))s=e;else{let n=this.cast(e);if(!this._typeCheck(n))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);s=n}return s}min(e,t=L.min){let s=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(s)}})}max(e,t=L.max){let s=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(s)}})}}function he(e,t){let s=1/0;return e.some(((e,n)=>{var r;if(null!=(r=t.path)&&r.includes(e))return s=n,!0})),s}function fe(e){return(t,s)=>he(e,t)-he(e,s)}ce.INVALID_DATE=le,ce.prototype;const de=(e,t,s)=>{if("string"!=typeof e)return e;let n=e;try{n=JSON.parse(e)}catch(e){}return s.isType(n)?n:e};function pe(e){if("fields"in e){const t={};for(const[s,n]of Object.entries(e.fields))t[s]=pe(n);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=pe(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(pe)}):"optional"in e?e.optional():e}let me=e=>"[object Object]"===Object.prototype.toString.call(e);const ye=fe([]);function ge(e){return new ve(e)}class ve extends W{constructor(e){super({type:"object",check:e=>me(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=ye,this._nodes=[],this._excludedEdges=[],this.withMutation((()=>{e&&this.shape(e)}))}_cast(e,t={}){var s;let n=super._cast(e,t);if(void 0===n)return this.getDefault();if(!this._typeCheck(n))return n;let r=this.fields,i=null!=(s=t.stripUnknown)?s:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(n).filter((e=>!this._nodes.includes(e)))),o={},u=Object.assign({},t,{parent:o,__validating:t.__validating||!1}),l=!1;for(const e of a){let s=r[e],a=e in n;if(s){let r,i=n[e];u.path=(t.path?`${t.path}.`:"")+e,s=s.resolve({value:i,context:t.context,parent:o});let a=s instanceof W?s.spec:void 0,c=null==a?void 0:a.strict;if(null!=a&&a.strip){l=l||e in n;continue}r=t.__validating&&c?n[e]:s.cast(n[e],u),void 0!==r&&(o[e]=r)}else a&&!i&&(o[e]=n[e]);a===e in o&&o[e]===n[e]||(l=!0)}return l?o:n}_validate(e,t={},s,n){let{from:r=[],originalValue:i=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:i},...r],t.__validating=!0,t.originalValue=i,super._validate(e,t,s,((e,r)=>{if(!a||!me(r))return void n(e,r);i=i||r;let o=[];for(let e of this._nodes){let s=this.fields[e];s&&!B.isRef(s)&&o.push(s.asNestedTest({options:t,key:e,parent:r,parentPath:t.path,originalParent:i}))}this.runTests({tests:o,value:r,originalValue:i,options:t},s,(t=>{n(t.sort(this._sortErrors).concat(e),r)}))}))}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),s=t.fields;for(let[e,t]of Object.entries(this.fields)){const n=s[e];s[e]=void 0===n?t:n}return t.withMutation((e=>e.setFields(s,this._excludedEdges)))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach((t=>{const s=this.fields[t];e[t]=s&&"getDefault"in s?s.getDefault():void 0})),e}setFields(e,t){let s=this.clone();return s.fields=e,s._nodes=function(e,t=[]){let s=[],n=new Set,r=new Set(t.map((([e,t])=>`${e}-${t}`)));function i(e,t){let i=p.split(e)[0];n.add(i),r.has(`${t}-${i}`)||s.push([t,i])}for(const t of Object.keys(e)){let s=e[t];n.add(t),B.isRef(s)&&s.isSibling?i(s.path,t):R(s)&&"deps"in s&&s.deps.forEach((e=>i(e,t)))}return O.array(Array.from(n),s).reverse()}(e,t),s._sortErrors=fe(Object.keys(e)),t&&(s._excludedEdges=t),s}shape(e,t=[]){return this.clone().withMutation((s=>{let n=s._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),n=[...s._excludedEdges,...t]),s.setFields(Object.assign(s.fields,e),n)}))}partial(){const e={};for(const[t,s]of Object.entries(this.fields))e[t]="optional"in s&&s.optional instanceof Function?s.optional():s;return this.setFields(e)}deepPartial(){return pe(this)}pick(e){const t={};for(const s of e)this.fields[s]&&(t[s]=this.fields[s]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const s of e)delete t[s];return this.setFields(t)}from(e,t,s){let n=p.getter(e,!0);return this.transform((r=>{if(!r)return r;let i=r;return((e,t)=>{const s=[...p.normalizePath(t)];if(1===s.length)return s[0]in e;let n=s.pop(),r=p.getter(p.join(s),!0)(e);return!(!r||!(n in r))})(r,e)&&(i=Object.assign({},r),s||delete i[e],i[t]=n(r)),i}))}json(){return this.transform(de)}noUnknown(e=!0,t=q.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let s=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const s=function(e,t){let s=Object.keys(e.fields);return Object.keys(t).filter((e=>-1===s.indexOf(e)))}(this.schema,t);return!e||0===s.length||this.createError({params:{unknown:s.join(", ")}})}});return s.spec.noUnknown=e,s}unknown(e=!0,t=q.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform((t=>{if(!t)return t;const s={};for(const n of Object.keys(t))s[e(n)]=t[n];return s}))}camelCase(){return this.transformKeys(E)}snakeCase(){return this.transformKeys(_)}constantCase(){return this.transformKeys((e=>_(e).toUpperCase()))}describe(e){let t=super.describe(e);t.fields={};for(const[n,r]of Object.entries(this.fields)){var s;let i=e;null!=(s=i)&&s.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),t.fields[n]=r.describe(i)}return t}}ge.prototype=ve.prototype;const be="#000639",xe='<svg width="40" height="41" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 10.5C0 4.977 4.477.5 10 .5h20c5.523 0 10 4.477 10 10v20c0 5.523-4.477 10-10 10H10c-5.523 0-10-4.477-10-10v-20Z" fill="#F1F1F1"/><path fill-rule="evenodd" clip-rule="evenodd" d="M25.927 15.78a.75.75 0 1 0-1.06-1.06l-4.793 4.793-4.793-4.793a.75.75 0 0 0-1.061 1.06l4.793 4.793-4.793 4.793a.75.75 0 1 0 1.06 1.061l4.794-4.793 4.793 4.793a.75.75 0 0 0 1.06-1.06l-4.793-4.794 4.793-4.793Z" fill="#000639"/></svg>';let we;function Fe(i){var a;!function(){if(document.head.querySelector(`#${s}`))return;const n=document.createElement("style");n.id=s,document.head.appendChild(n),n.textContent=`\n \n #${e}, #${e} * {\n margin: 0;\n padding: 0px;\n box-sizing: border-box;\n }\n \n #${t} {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n `}(),function(e){ge({local_amount:ae().required(),local_currency:re().required(),business_id:re().required(),reference:re(),callback_url:re(),mode:re().matches(/(test|live)/),meta:ge({email:re().email(),name:re().min(2)}).default(void 0)}).validateSync(e)}(i),we=i;const o=function(){const t=document.createElement("div");return t.id=e,t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex="999999999",t.style.backgroundColor="rgba(0, 0, 0, 0.4)",t}(),u=function(){const e=document.createElement("div");return e.id=t,e.style.width="40px",e.style.height="40px",e.style.backgroundColor="transparent",e.style.border=`2px solid ${be}`,e.style.borderLeftColor="transparent",e.style.borderBottomColor="transparent",e.style.borderRadius="100%",e.animate([{transform:"rotate(0)"},{transform:"rotate(360deg)"}],{duration:300,iterations:1/0}),e}(),l=function(){const e=document.createElement("button");return e.id=n,e.setAttribute("type","button"),e.style.width="40px",e.style.height="40px",e.style.position="absolute",e.style.right="0",e.style.zIndex="40",e.style.backgroundColor="transparent",e.style.border="none",e.innerHTML=xe,e}();l.addEventListener("click",Ee),o.appendChild(u),o.appendChild(l);const c=function(){const e=document.createElement("iframe");return e.allow="clipboard-read; clipboard-write",e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.left="50%",e.style.top="0px",e.style.transform="translate(-50%, 0)",e.style.zIndex="20",e}();o.appendChild(c),document.body.appendChild(o);const h=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(s[n[r]]=e[n[r]])}return s}(i,["onClose","onSuccess"]),f=function(e){const t=document.createElement("form");t.action=r,t.method="POST",t.style.display="none",(s=>{for(const s in e){if(!e.hasOwnProperty(s))continue;const n=e[s];if("object"==typeof n)for(const e in n){if(!n.hasOwnProperty(e))continue;const r=document.createElement("input");r.name=`${s}[${e}]`,r.value=String(n[e]),t.appendChild(r)}else{const e=document.createElement("input");e.name=s,e.value=String(n),t.appendChild(e)}}})();const s=document.createElement("input");s.name="displayMode",s.value="INLINE";const n=document.createElement("input");return n.name="parentOrigin",n.value=window.location.origin,t.appendChild(s),t.appendChild(n),t}(h);null===(a=c.contentDocument)||void 0===a||a.body.appendChild(f),f.submit(),window.addEventListener("message",_e)}function Ee(){const t=document.getElementById(e),s=document.getElementById(n);null==s||s.removeEventListener("click",Ee),window.removeEventListener("message",_e),t&&document.body.removeChild(t)}const _e=s=>{const i=new URL(r);if(s.origin===i.origin&&we){if("INITIALIZED"===s.data.status){const s=document.getElementById(e),r=document.getElementById(t),i=document.getElementById(n);if(!r||!i)return;null==s||s.removeChild(r),null==s||s.removeChild(i)}"CANCELLED"===s.data.status&&(Ee(),we.onClose&&we.onClose(s.data)),"COMPLETED"===s.data.status&&(Ee(),we.onSuccess&&we.onSuccess(s.data))}};export{Fe as default};
|
|
1
|
+
const e="busha-commerce-container",t="busha-commerce-loader",s="busha-commerce-styles",n="busha-commerce-close-btn",r="busha-commerce-iframe",i="busha-commerce-form",a="https://pay.busha.co/pay",o="CANCELLED";function u(e){this._maxSize=e,this.clear()}u.prototype.clear=function(){this._size=0,this._values=Object.create(null)},u.prototype.get=function(e){return this._values[e]},u.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var l=/[^.^\]^[]+|(?=\[\]|\.\.)/g,c=/^\d+$/,h=/^\d/,f=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,d=/^\s*(['"]?)(.*?)(\1)\s*$/,p=new u(512),m=new u(512),y=new u(512),g={Cache:u,split:b,normalizePath:v,setter:function(e){var t=v(e);return m.get(e)||m.set(e,(function(e,s){for(var n=0,r=t.length,i=e;n<r-1;){var a=t[n];if("__proto__"===a||"constructor"===a||"prototype"===a)return e;i=i[t[n++]]}i[t[n]]=s}))},getter:function(e,t){var s=v(e);return y.get(e)||y.set(e,(function(e){for(var n=0,r=s.length;n<r;){if(null==e&&t)return;e=e[s[n++]]}return e}))},join:function(e){return e.reduce((function(e,t){return e+(x(t)||c.test(t)?"["+t+"]":(e?".":"")+t)}),"")},forEach:function(e,t,s){!function(e,t,s){var n,r,i,a,o=e.length;for(r=0;r<o;r++)(n=e[r])&&(w(n)&&(n='"'+n+'"'),i=!(a=x(n))&&/^\d+$/.test(n),t.call(s,n,a,i,r,e))}(Array.isArray(e)?e:b(e),t,s)}};function v(e){return p.get(e)||p.set(e,b(e).map((function(e){return e.replace(d,"$2")})))}function b(e){return e.match(l)||[""]}function x(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function w(e){return!x(e)&&(function(e){return e.match(h)&&!e.match(c)}(e)||function(e){return f.test(e)}(e))}const F=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,E=e=>e.match(F)||[],_=(e,t)=>E(e).join(t).toLowerCase(),$=e=>E(e).reduce(((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`),"");var O=$,k=e=>_(e,"_"),T={};function A(e,t){var s=e.length,n=new Array(s),r={},i=s,a=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++){var r=e[s];t.has(r[0])||t.set(r[0],new Set),t.has(r[1])||t.set(r[1],new Set),t.get(r[0]).add(r[1])}return t}(t),o=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++)t.set(e[s],s);return t}(e);for(t.forEach((function(e){if(!o.has(e[0])||!o.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")}));i--;)r[i]||u(e[i],i,new Set);return n;function u(e,t,i){if(i.has(e)){var l;try{l=", node was:"+JSON.stringify(e)}catch(e){l=""}throw new Error("Cyclic dependency"+l)}if(!o.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!r[t]){r[t]=!0;var c=a.get(e)||new Set;if(t=(c=Array.from(c)).length){i.add(e);do{var h=c[--t];u(h,o.get(h),i)}while(t);i.delete(e)}n[--s]=e}}}({get exports(){return T},set exports(e){T=e}}).exports=function(e){return A(function(e){for(var t=new Set,s=0,n=e.length;s<n;s++){var r=e[s];t.add(r[0]),t.add(r[1])}return Array.from(t)}(e),e)},T.array=A;const D=Object.prototype.toString,C=Error.prototype.toString,S=RegExp.prototype.toString,j="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",N=/^Symbol\((.*)\)(.*)$/;function z(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const s=typeof e;if("number"===s)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===s)return t?`"${e}"`:e;if("function"===s)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===s)return j.call(e).replace(N,"Symbol($1)");const n=D.call(e).slice(8,-1);return"Date"===n?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===n||e instanceof Error?"["+C.call(e)+"]":"RegExp"===n?S.call(e):null}function I(e,t){let s=z(e,t);return null!==s?s:JSON.stringify(e,(function(e,s){let n=z(this[e],t);return null!==n?n:s}),2)}function P(e){return null==e?[]:[].concat(e)}let V=/\$\{\s*(\w+)\s*\}/g;class M extends Error{static formatError(e,t){const s=t.label||t.path||"this";return s!==t.path&&(t=Object.assign({},t,{path:s})),"string"==typeof e?e.replace(V,((e,s)=>I(t[s]))):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,s,n){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=s,this.type=n,this.errors=[],this.inner=[],P(e).forEach((e=>{M.isError(e)?(this.errors.push(...e.errors),this.inner=this.inner.concat(e.inner.length?e.inner:e)):this.errors.push(e)})),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,M)}}let L={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:s,originalValue:n})=>{const r=null!=n&&n!==s?` (cast from the value \`${I(n,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${I(s,!0)}\``+r:`${e} must match the configured type. The validated value was: \`${I(s,!0)}\``+r}},q={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},R={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Z={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},U={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:L,string:q,number:R,date:Z,object:U,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:{isValue:"${path} field must be ${value}"}});const Y=e=>e&&e.__isYupSchema__;class B{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:s,then:n,otherwise:r}=t,i="function"==typeof s?s:(...e)=>e.every((e=>e===s));return new B(e,((e,t)=>{var s;let a=i(...e)?n:r;return null!=(s=null==a?void 0:a(t))?s:t}))}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let s=this.refs.map((e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context))),n=this.fn(s,e,t);if(void 0===n||n===e)return e;if(!Y(n))throw new TypeError("conditions must return a schema object");return n.resolve(t)}}const J="$",K=".";class H{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===J,this.isValue=this.key[0]===K,this.isSibling=!this.isContext&&!this.isValue;let s=this.isContext?J:this.isValue?K:"";this.path=this.key.slice(s.length),this.getter=this.path&&g.getter(this.path,!0),this.map=t.map}getValue(e,t,s){let n=this.isContext?s:this.isValue?e:t;return this.getter&&(n=this.getter(n||{})),this.map&&(n=this.map(n)),n}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}H.prototype.__isYupRef=!0;const G=e=>null==e;function Q(e){function t({value:t,path:s="",options:n,originalValue:r,schema:i},a,o){const{name:u,test:l,params:c,message:h,skipAbsent:f}=e;let{parent:d,context:p,abortEarly:m=i.spec.abortEarly}=n;function y(e){return H.isRef(e)?e.getValue(t,d,p):e}function g(e={}){const n=Object.assign({value:t,originalValue:r,label:i.spec.label,path:e.path||s,spec:i.spec},c,e.params);for(const e of Object.keys(n))n[e]=y(n[e]);const a=new M(M.formatError(e.message||h,n),t,n.path,e.type||u);return a.params=n,a}const v=m?a:o;let b={path:s,parent:d,type:u,from:n.from,createError:g,resolve:y,options:n,originalValue:r,schema:i};const x=e=>{M.isError(e)?v(e):e?o(null):v(g())},w=e=>{M.isError(e)?v(e):a(e)},F=f&&G(t);if(!n.sync){try{Promise.resolve(!!F||l.call(b,t,b)).then(x,w)}catch(e){w(e)}return}let E;try{var _;if(E=!!F||l.call(b,t,b),"function"==typeof(null==(_=E)?void 0:_.then))throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(e){return void w(e)}x(E)}return t.OPTIONS=e,t}function W(e,t,s,n=s){let r,i,a;return t?(g.forEach(t,((o,u,l)=>{let c=u?o.slice(1,o.length-1):o,h="tuple"===(e=e.resolve({context:n,parent:r,value:s})).type,f=l?parseInt(c,10):0;if(e.innerType||h){if(h&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);if(s&&f>=s.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${t}. because there is no value at that index. `);r=s,s=s&&s[f],e=h?e.spec.types[f]:e.innerType}if(!l){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${e.type}")`);r=s,s=s&&s[c],e=e.fields[c]}i=c,a=u?"["+o+"]":"."+o})),{schema:e,parent:r,parentPath:i}):{parent:r,parentPath:t,schema:e}}class X extends Set{describe(){const e=[];for(const t of this.values())e.push(H.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const s of this.values())t.push(e(s));return t}clone(){return new X(this.values())}merge(e,t){const s=this.clone();return e.forEach((e=>s.add(e))),t.forEach((e=>s.delete(e))),s}}function ee(e,t=new Map){if(Y(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let s;if(e instanceof Date)s=new Date(e.getTime()),t.set(e,s);else if(e instanceof RegExp)s=new RegExp(e),t.set(e,s);else if(Array.isArray(e)){s=new Array(e.length),t.set(e,s);for(let n=0;n<e.length;n++)s[n]=ee(e[n],t)}else if(e instanceof Map){s=new Map,t.set(e,s);for(const[n,r]of e.entries())s.set(n,ee(r,t))}else if(e instanceof Set){s=new Set,t.set(e,s);for(const n of e)s.add(ee(n,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);s={},t.set(e,s);for(const[n,r]of Object.entries(e))s[n]=ee(r,t)}return s}class te{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new X,this._blacklist=new X,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation((()=>{this.typeError(L.notType)})),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation((e=>{e.nonNullable()}))}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=ee(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let s=e(this);return this._mutate=t,s}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,s=e.clone();const n=Object.assign({},t.spec,s.spec);return s.spec=n,s.internalTests=Object.assign({},t.internalTests,s.internalTests),s._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),s._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),s.tests=t.tests,s.exclusiveTests=t.exclusiveTests,s.withMutation((t=>{e.tests.forEach((e=>{t.test(e.OPTIONS)}))})),s.transforms=[...t.transforms,...s.transforms],s}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let s=t.conditions;t=t.clone(),t.conditions=[],t=s.reduce(((t,s)=>s.resolve(t,e)),t),t=t.resolve(e)}return t}resolveOptions(e){var t,s,n;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(s=e.abortEarly)?s:this.spec.abortEarly,recursive:null!=(n=e.recursive)?n:this.spec.recursive})}cast(e,t={}){let s=this.resolve(Object.assign({value:e},t)),n="ignore-optionality"===t.assert,r=s._cast(e,t);if(!1!==t.assert&&!s.isType(r)){if(n&&G(r))return r;let i=I(e),a=I(r);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${s.type}". \n\nattempted value: ${i} \n`+(a!==i?`result of cast: ${a}`:""))}return r}_cast(e,t){let s=void 0===e?e:this.transforms.reduce(((t,s)=>s.call(this,t,e,this)),e);return void 0===s&&(s=this.getDefault()),s}_validate(e,t={},s,n){let{path:r,originalValue:i=e,strict:a=this.spec.strict}=t,o=e;a||(o=this._cast(o,Object.assign({assert:!1},t)));let u=[];for(let e of Object.values(this.internalTests))e&&u.push(e);this.runTests({path:r,value:o,originalValue:i,options:t,tests:u},s,(e=>{if(e.length)return n(e,o);this.runTests({path:r,value:o,originalValue:i,options:t,tests:this.tests},s,n)}))}runTests(e,t,s){let n=!1,{tests:r,value:i,originalValue:a,path:o,options:u}=e,l=e=>{n||(n=!0,t(e,i))},c=e=>{n||(n=!0,s(e,i))},h=r.length,f=[];if(!h)return c([]);let d={value:i,originalValue:a,path:o,options:u,schema:this};for(let e=0;e<r.length;e++){(0,r[e])(d,l,(function(e){e&&(f=f.concat(e)),--h<=0&&c(f)}))}}asNestedTest({key:e,index:t,parent:s,parentPath:n,originalParent:r,options:i}){const a=null!=e?e:t;if(null==a)throw TypeError("Must include `key` or `index` for nested validations");const o="number"==typeof a;let u=s[a];const l=Object.assign({},i,{strict:!0,parent:s,value:u,originalValue:r[a],key:void 0,[o?"index":"key"]:a,path:o||a.includes(".")?`${n||""}[${u?a:`"${a}"`}]`:(n?`${n}.`:"")+e});return(e,t,s)=>this.resolve(l)._validate(u,l,t,s)}validate(e,t){let s=this.resolve(Object.assign({},t,{value:e}));return new Promise(((n,r)=>s._validate(e,t,((e,t)=>{M.isError(e)&&(e.value=t),r(e)}),((e,t)=>{e.length?r(new M(e,t)):n(t)}))))}validateSync(e,t){let s;return this.resolve(Object.assign({},t,{value:e}))._validate(e,Object.assign({},t,{sync:!0}),((e,t)=>{throw M.isError(e)&&(e.value=t),e}),((t,n)=>{if(t.length)throw new M(t,e);s=n})),s}isValid(e,t){return this.validate(e,t).then((()=>!0),(e=>{if(M.isError(e))return!1;throw e}))}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(M.isError(e))return!1;throw e}}_getDefault(){let e=this.spec.default;return null==e?e:"function"==typeof e?e.call(this):ee(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const s=this.clone({nullable:e});return s.internalTests.nullable=Q({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),s}optionality(e,t){const s=this.clone({optional:e});return s.internalTests.optionality=Q({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),s}optional(){return this.optionality(!0)}defined(e=L.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=L.notNull){return this.nullability(!1,e)}required(e=L.required){return this.clone().withMutation((t=>t.nonNullable(e).defined(e)))}notRequired(){return this.clone().withMutation((e=>e.nullable().optional()))}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=L.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let s=this.clone(),n=Q(t),r=t.exclusive||t.name&&!0===s.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(s.exclusiveTests[t.name]=!!t.exclusive),s.tests=s.tests.filter((e=>{if(e.OPTIONS.name===t.name){if(r)return!1;if(e.OPTIONS.test===n.OPTIONS.test)return!1}return!0})),s.tests.push(n),s}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let s=this.clone(),n=P(e).map((e=>new H(e)));return n.forEach((e=>{e.isSibling&&s.deps.push(e.key)})),s.conditions.push("function"==typeof t?new B(n,t):B.fromOptions(n,t)),s}typeError(e){let t=this.clone();return t.internalTests.typeError=Q({message:e,name:"typeError",test(e){return!(!G(e)&&!this.schema._typeCheck(e))||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=L.oneOf){let s=this.clone();return e.forEach((e=>{s._whitelist.add(e),s._blacklist.delete(e)})),s.internalTests.whiteList=Q({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,s=t.resolveAll(this.resolve);return!!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}notOneOf(e,t=L.notOneOf){let s=this.clone();return e.forEach((e=>{s._blacklist.add(e),s._whitelist.delete(e)})),s.internalTests.blacklist=Q({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,s=t.resolveAll(this.resolve);return!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:s,meta:n,optional:r,nullable:i}=t.spec;return{meta:n,label:s,optional:r,nullable:i,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map((e=>({name:e.OPTIONS.name,params:e.OPTIONS.params}))).filter(((e,t,s)=>s.findIndex((t=>t.name===e.name))===t))}}}te.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])te.prototype[`${e}At`]=function(t,s,n={}){const{parent:r,parentPath:i,schema:a}=W(this,t,s,n.context);return a[e](r&&r[i],Object.assign({},n,{parent:r,path:t}))};for(const e of["equals","is"])te.prototype[e]=te.prototype.oneOf;for(const e of["not","nope"])te.prototype[e]=te.prototype.notOneOf;let se=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ne=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,re=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,ie=e=>G(e)||e===e.trim(),ae={}.toString();function oe(){return new ue}class ue extends te{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce||s.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===ae?e:n}))}))}required(e){return super.required(e).withMutation((t=>t.test({message:e||L.required,name:"required",skipAbsent:!0,test:e=>!!e.length})))}notRequired(){return super.notRequired().withMutation((e=>(e.tests=e.tests.filter((e=>"required"!==e.OPTIONS.name)),e)))}length(e,t=q.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=q.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=q.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let s,n,r=!1;return t&&("object"==typeof t?({excludeEmptyString:r=!1,message:s,name:n}=t):s=t),this.test({name:n||"matches",message:s||q.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&r||-1!==t.search(e)})}email(e=q.email){return this.matches(se,{name:"email",message:e,excludeEmptyString:!0})}url(e=q.url){return this.matches(ne,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=q.uuid){return this.matches(re,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform((e=>null===e?"":e))}trim(e=q.trim){return this.transform((e=>null!=e?e.trim():e)).test({message:e,name:"trim",test:ie})}lowercase(e=q.lowercase){return this.transform((e=>G(e)?e:e.toLowerCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>G(e)||e===e.toLowerCase()})}uppercase(e=q.uppercase){return this.transform((e=>G(e)?e:e.toUpperCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>G(e)||e===e.toUpperCase()})}}oe.prototype=ue.prototype;function le(){return new ce}class ce extends te{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return s.isType(n)?n:parseFloat(n)}))}))}min(e,t=R.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=R.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=R.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=R.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=R.positive){return this.moreThan(0,e)}negative(e=R.negative){return this.lessThan(0,e)}integer(e=R.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform((e=>G(e)?e:0|e))}round(e){var t;let s=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===s.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+s.join(", "));return this.transform((t=>G(t)?t:Math[e](t)))}}le.prototype=ce.prototype;var he=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;let fe=new Date("");class de extends te{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation((()=>{this.transform(((e,t,s)=>!s.spec.coerce||s.isType(e)?e:(e=function(e){var t,s,n=[1,4,5,6,7,10,11],r=0;if(s=he.exec(e)){for(var i,a=0;i=n[a];++a)s[i]=+s[i]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,void 0!==s[8]&&""!==s[8]||void 0!==s[9]&&""!==s[9]?("Z"!==s[8]&&void 0!==s[9]&&(r=60*s[10]+s[11],"+"===s[9]&&(r=0-r)),t=Date.UTC(s[1],s[2],s[3],s[4],s[5]+r,s[6],s[7])):t=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7])}else t=Date.parse?Date.parse(e):NaN;return t}(e),isNaN(e)?de.INVALID_DATE:new Date(e))))}))}prepareParam(e,t){let s;if(H.isRef(e))s=e;else{let n=this.cast(e);if(!this._typeCheck(n))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);s=n}return s}min(e,t=Z.min){let s=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(s)}})}max(e,t=Z.max){let s=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(s)}})}}function pe(e,t){let s=1/0;return e.some(((e,n)=>{var r;if(null!=(r=t.path)&&r.includes(e))return s=n,!0})),s}function me(e){return(t,s)=>pe(e,t)-pe(e,s)}de.INVALID_DATE=fe,de.prototype;const ye=(e,t,s)=>{if("string"!=typeof e)return e;let n=e;try{n=JSON.parse(e)}catch(e){}return s.isType(n)?n:e};function ge(e){if("fields"in e){const t={};for(const[s,n]of Object.entries(e.fields))t[s]=ge(n);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=ge(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(ge)}):"optional"in e?e.optional():e}let ve=e=>"[object Object]"===Object.prototype.toString.call(e);const be=me([]);function xe(e){return new we(e)}class we extends te{constructor(e){super({type:"object",check:e=>ve(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=be,this._nodes=[],this._excludedEdges=[],this.withMutation((()=>{e&&this.shape(e)}))}_cast(e,t={}){var s;let n=super._cast(e,t);if(void 0===n)return this.getDefault();if(!this._typeCheck(n))return n;let r=this.fields,i=null!=(s=t.stripUnknown)?s:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(n).filter((e=>!this._nodes.includes(e)))),o={},u=Object.assign({},t,{parent:o,__validating:t.__validating||!1}),l=!1;for(const e of a){let s=r[e],a=e in n;if(s){let r,i=n[e];u.path=(t.path?`${t.path}.`:"")+e,s=s.resolve({value:i,context:t.context,parent:o});let a=s instanceof te?s.spec:void 0,c=null==a?void 0:a.strict;if(null!=a&&a.strip){l=l||e in n;continue}r=t.__validating&&c?n[e]:s.cast(n[e],u),void 0!==r&&(o[e]=r)}else a&&!i&&(o[e]=n[e]);a===e in o&&o[e]===n[e]||(l=!0)}return l?o:n}_validate(e,t={},s,n){let{from:r=[],originalValue:i=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:i},...r],t.__validating=!0,t.originalValue=i,super._validate(e,t,s,((e,r)=>{if(!a||!ve(r))return void n(e,r);i=i||r;let o=[];for(let e of this._nodes){let s=this.fields[e];s&&!H.isRef(s)&&o.push(s.asNestedTest({options:t,key:e,parent:r,parentPath:t.path,originalParent:i}))}this.runTests({tests:o,value:r,originalValue:i,options:t},s,(t=>{n(t.sort(this._sortErrors).concat(e),r)}))}))}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),s=t.fields;for(let[e,t]of Object.entries(this.fields)){const n=s[e];s[e]=void 0===n?t:n}return t.withMutation((e=>e.setFields(s,this._excludedEdges)))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach((t=>{const s=this.fields[t];e[t]=s&&"getDefault"in s?s.getDefault():void 0})),e}setFields(e,t){let s=this.clone();return s.fields=e,s._nodes=function(e,t=[]){let s=[],n=new Set,r=new Set(t.map((([e,t])=>`${e}-${t}`)));function i(e,t){let i=g.split(e)[0];n.add(i),r.has(`${t}-${i}`)||s.push([t,i])}for(const t of Object.keys(e)){let s=e[t];n.add(t),H.isRef(s)&&s.isSibling?i(s.path,t):Y(s)&&"deps"in s&&s.deps.forEach((e=>i(e,t)))}return T.array(Array.from(n),s).reverse()}(e,t),s._sortErrors=me(Object.keys(e)),t&&(s._excludedEdges=t),s}shape(e,t=[]){return this.clone().withMutation((s=>{let n=s._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),n=[...s._excludedEdges,...t]),s.setFields(Object.assign(s.fields,e),n)}))}partial(){const e={};for(const[t,s]of Object.entries(this.fields))e[t]="optional"in s&&s.optional instanceof Function?s.optional():s;return this.setFields(e)}deepPartial(){return ge(this)}pick(e){const t={};for(const s of e)this.fields[s]&&(t[s]=this.fields[s]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const s of e)delete t[s];return this.setFields(t)}from(e,t,s){let n=g.getter(e,!0);return this.transform((r=>{if(!r)return r;let i=r;return((e,t)=>{const s=[...g.normalizePath(t)];if(1===s.length)return s[0]in e;let n=s.pop(),r=g.getter(g.join(s),!0)(e);return!(!r||!(n in r))})(r,e)&&(i=Object.assign({},r),s||delete i[e],i[t]=n(r)),i}))}json(){return this.transform(ye)}noUnknown(e=!0,t=U.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let s=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const s=function(e,t){let s=Object.keys(e.fields);return Object.keys(t).filter((e=>-1===s.indexOf(e)))}(this.schema,t);return!e||0===s.length||this.createError({params:{unknown:s.join(", ")}})}});return s.spec.noUnknown=e,s}unknown(e=!0,t=U.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform((t=>{if(!t)return t;const s={};for(const n of Object.keys(t))s[e(n)]=t[n];return s}))}camelCase(){return this.transformKeys(O)}snakeCase(){return this.transformKeys(k)}constantCase(){return this.transformKeys((e=>k(e).toUpperCase()))}describe(e){let t=super.describe(e);t.fields={};for(const[n,r]of Object.entries(this.fields)){var s;let i=e;null!=(s=i)&&s.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),t.fields[n]=r.describe(i)}return t}}xe.prototype=we.prototype;const Fe="#000639",Ee='<svg width="40" height="41" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 10.5C0 4.977 4.477.5 10 .5h20c5.523 0 10 4.477 10 10v20c0 5.523-4.477 10-10 10H10c-5.523 0-10-4.477-10-10v-20Z" fill="#F1F1F1"/><path fill-rule="evenodd" clip-rule="evenodd" d="M25.927 15.78a.75.75 0 1 0-1.06-1.06l-4.793 4.793-4.793-4.793a.75.75 0 0 0-1.061 1.06l4.793 4.793-4.793 4.793a.75.75 0 1 0 1.06 1.061l4.794-4.793 4.793 4.793a.75.75 0 0 0 1.06-1.06l-4.793-4.794 4.793-4.793Z" fill="#000639"/></svg>';let _e;function $e(u){!function(){if(document.head.querySelector(`#${s}`))return;const n=document.createElement("style");n.id=s,n.dataset.testid=s,document.head.appendChild(n),n.textContent=`\n \n #${e}, #${e} * {\n margin: 0;\n padding: 0px;\n box-sizing: border-box;\n }\n \n #${t} {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n `}(),function(e){xe({local_amount:le().required(),local_currency:oe().required(),business_id:oe().required(),reference:oe(),callback_url:oe(),mode:oe().matches(/(test|live)/),meta:xe({email:oe().email(),name:oe().min(2)}).default(void 0)}).validateSync(e)}(u),_e=u;const l=function(){const t=document.createElement("div");return t.id=e,t.dataset.testid=e,t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex="999999999",t.style.backgroundColor="rgba(0, 0, 0, 0.4)",t}(),c=function(){const e=document.createElement("div");return e.id=t,e.dataset.testid=t,e.style.width="40px",e.style.height="40px",e.style.backgroundColor="transparent",e.style.border=`2px solid ${Fe}`,e.style.borderLeftColor="transparent",e.style.borderBottomColor="transparent",e.style.borderRadius="100%",e.animate&&e.animate([{transform:"rotate(0)"},{transform:"rotate(360deg)"}],{duration:300,iterations:1/0}),e}(),h=function(){const e=document.createElement("button");return e.id=n,e.dataset.testid=n,e.setAttribute("type","button"),e.style.width="40px",e.style.height="40px",e.style.position="absolute",e.style.right="0",e.style.zIndex="40",e.style.backgroundColor="transparent",e.style.border="none",e.innerHTML=Ee,e}();h.addEventListener("click",(e=>{e.preventDefault(),Oe(),_e.onClose&&_e.onClose({status:o,data:{reference:_e.reference}})})),l.appendChild(c),l.appendChild(h);const f=function(){const e=document.createElement("iframe");return e.dataset.testid=r,e.name=r,e.allow=`clipboard-write self ${a}`,e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.left="50%",e.style.top="0px",e.style.transform="translate(-50%, 0)",e.style.zIndex="20",e}();l.appendChild(f),document.body.appendChild(l);const d=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(s[n[r]]=e[n[r]])}return s}(u,["onClose","onSuccess"]),p=function(e){const t=document.createElement("form");t.target=r,t.dataset.testid=i,t.action=a,t.method="POST",t.style.display="none",(s=>{for(const s in e){if(!e.hasOwnProperty(s))continue;const n=e[s];if("object"==typeof n)for(const e in n){if(!n.hasOwnProperty(e))continue;const r=document.createElement("input");r.name=`${s}[${e}]`,r.value=String(n[e]),t.appendChild(r)}else{const e=document.createElement("input");e.name=s,e.value=String(n),t.appendChild(e)}}})();const s=document.createElement("input");s.name="displayMode",s.value="INLINE";const n=document.createElement("input");return n.name="parentOrigin",n.value=window.location.origin,t.appendChild(s),t.appendChild(n),t}(d);l.appendChild(p),p.submit(),window.addEventListener("message",ke)}function Oe(){const t=document.getElementById(e),s=document.getElementById(n);null==s||s.removeEventListener("click",Oe),window.removeEventListener("message",ke),t&&document.body.removeChild(t)}const ke=s=>{const r=new URL(a);if(s.origin===r.origin&&_e){if("INITIALIZED"===s.data.status){const s=document.getElementById(e),r=document.getElementById(t),i=document.getElementById(n);if(!r||!i)return;null==s||s.removeChild(r),null==s||s.removeChild(i)}s.data.status===o&&(Oe(),_e.onClose&&_e.onClose(s.data)),"COMPLETED"===s.data.status&&(Oe(),_e.onSuccess&&_e.onSuccess(s.data))}};export{$e as default};
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var BushaCommerce=function(){"use strict";const e="busha-commerce-container",t="busha-commerce-loader",s="busha-commerce-styles",n="busha-commerce-close-btn",r="https://pay.busha.co/pay";function i(e){this._maxSize=e,this.clear()}i.prototype.clear=function(){this._size=0,this._values=Object.create(null)},i.prototype.get=function(e){return this._values[e]},i.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var a=/[^.^\]^[]+|(?=\[\]|\.\.)/g,o=/^\d+$/,u=/^\d/,l=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,c=/^\s*(['"]?)(.*?)(\1)\s*$/,h=new i(512),f=new i(512),d=new i(512),p={Cache:i,split:y,normalizePath:m,setter:function(e){var t=m(e);return f.get(e)||f.set(e,(function(e,s){for(var n=0,r=t.length,i=e;n<r-1;){var a=t[n];if("__proto__"===a||"constructor"===a||"prototype"===a)return e;i=i[t[n++]]}i[t[n]]=s}))},getter:function(e,t){var s=m(e);return d.get(e)||d.set(e,(function(e){for(var n=0,r=s.length;n<r;){if(null==e&&t)return;e=e[s[n++]]}return e}))},join:function(e){return e.reduce((function(e,t){return e+(g(t)||o.test(t)?"["+t+"]":(e?".":"")+t)}),"")},forEach:function(e,t,s){!function(e,t,s){var n,r,i,a,o=e.length;for(r=0;r<o;r++)(n=e[r])&&(v(n)&&(n='"'+n+'"'),i=!(a=g(n))&&/^\d+$/.test(n),t.call(s,n,a,i,r,e))}(Array.isArray(e)?e:y(e),t,s)}};function m(e){return h.get(e)||h.set(e,y(e).map((function(e){return e.replace(c,"$2")})))}function y(e){return e.match(a)||[""]}function g(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function v(e){return!g(e)&&(function(e){return e.match(u)&&!e.match(o)}(e)||function(e){return l.test(e)}(e))}const b=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,x=e=>e.match(b)||[],w=(e,t)=>x(e).join(t).toLowerCase(),F=e=>x(e).reduce(((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`),"");var E=F,_=e=>w(e,"_"),O={};function $(e,t){var s=e.length,n=new Array(s),r={},i=s,a=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++){var r=e[s];t.has(r[0])||t.set(r[0],new Set),t.has(r[1])||t.set(r[1],new Set),t.get(r[0]).add(r[1])}return t}(t),o=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++)t.set(e[s],s);return t}(e);for(t.forEach((function(e){if(!o.has(e[0])||!o.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")}));i--;)r[i]||u(e[i],i,new Set);return n;function u(e,t,i){if(i.has(e)){var l;try{l=", node was:"+JSON.stringify(e)}catch(e){l=""}throw new Error("Cyclic dependency"+l)}if(!o.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!r[t]){r[t]=!0;var c=a.get(e)||new Set;if(t=(c=Array.from(c)).length){i.add(e);do{var h=c[--t];u(h,o.get(h),i)}while(t);i.delete(e)}n[--s]=e}}}({get exports(){return O},set exports(e){O=e}}).exports=function(e){return $(function(e){for(var t=new Set,s=0,n=e.length;s<n;s++){var r=e[s];t.add(r[0]),t.add(r[1])}return Array.from(t)}(e),e)},O.array=$;const k=Object.prototype.toString,T=Error.prototype.toString,A=RegExp.prototype.toString,D="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",S=/^Symbol\((.*)\)(.*)$/;function C(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const s=typeof e;if("number"===s)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===s)return t?`"${e}"`:e;if("function"===s)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===s)return D.call(e).replace(S,"Symbol($1)");const n=k.call(e).slice(8,-1);return"Date"===n?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===n||e instanceof Error?"["+T.call(e)+"]":"RegExp"===n?A.call(e):null}function j(e,t){let s=C(e,t);return null!==s?s:JSON.stringify(e,(function(e,s){let n=C(this[e],t);return null!==n?n:s}),2)}function N(e){return null==e?[]:[].concat(e)}let z=/\$\{\s*(\w+)\s*\}/g;class I extends Error{static formatError(e,t){const s=t.label||t.path||"this";return s!==t.path&&(t=Object.assign({},t,{path:s})),"string"==typeof e?e.replace(z,((e,s)=>j(t[s]))):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,s,n){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=s,this.type=n,this.errors=[],this.inner=[],N(e).forEach((e=>{I.isError(e)?(this.errors.push(...e.errors),this.inner=this.inner.concat(e.inner.length?e.inner:e)):this.errors.push(e)})),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,I)}}let P={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:s,originalValue:n})=>{const r=null!=n&&n!==s?` (cast from the value \`${j(n,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${j(s,!0)}\``+r:`${e} must match the configured type. The validated value was: \`${j(s,!0)}\``+r}},V={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},M={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},L={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},q={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:P,string:V,number:M,date:L,object:q,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:{isValue:"${path} field must be ${value}"}});const R=e=>e&&e.__isYupSchema__;class Z{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:s,then:n,otherwise:r}=t,i="function"==typeof s?s:(...e)=>e.every((e=>e===s));return new Z(e,((e,t)=>{var s;let a=i(...e)?n:r;return null!=(s=null==a?void 0:a(t))?s:t}))}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let s=this.refs.map((e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context))),n=this.fn(s,e,t);if(void 0===n||n===e)return e;if(!R(n))throw new TypeError("conditions must return a schema object");return n.resolve(t)}}const U="$",B=".";class Y{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===U,this.isValue=this.key[0]===B,this.isSibling=!this.isContext&&!this.isValue;let s=this.isContext?U:this.isValue?B:"";this.path=this.key.slice(s.length),this.getter=this.path&&p.getter(this.path,!0),this.map=t.map}getValue(e,t,s){let n=this.isContext?s:this.isValue?e:t;return this.getter&&(n=this.getter(n||{})),this.map&&(n=this.map(n)),n}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}Y.prototype.__isYupRef=!0;const J=e=>null==e;function K(e){function t({value:t,path:s="",options:n,originalValue:r,schema:i},a,o){const{name:u,test:l,params:c,message:h,skipAbsent:f}=e;let{parent:d,context:p,abortEarly:m=i.spec.abortEarly}=n;function y(e){return Y.isRef(e)?e.getValue(t,d,p):e}function g(e={}){const n=Object.assign({value:t,originalValue:r,label:i.spec.label,path:e.path||s,spec:i.spec},c,e.params);for(const e of Object.keys(n))n[e]=y(n[e]);const a=new I(I.formatError(e.message||h,n),t,n.path,e.type||u);return a.params=n,a}const v=m?a:o;let b={path:s,parent:d,type:u,from:n.from,createError:g,resolve:y,options:n,originalValue:r,schema:i};const x=e=>{I.isError(e)?v(e):e?o(null):v(g())},w=e=>{I.isError(e)?v(e):a(e)},F=f&&J(t);if(!n.sync){try{Promise.resolve(!!F||l.call(b,t,b)).then(x,w)}catch(e){w(e)}return}let E;try{var _;if(E=!!F||l.call(b,t,b),"function"==typeof(null==(_=E)?void 0:_.then))throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(e){return void w(e)}x(E)}return t.OPTIONS=e,t}function H(e,t,s,n=s){let r,i,a;return t?(p.forEach(t,((o,u,l)=>{let c=u?o.slice(1,o.length-1):o,h="tuple"===(e=e.resolve({context:n,parent:r,value:s})).type,f=l?parseInt(c,10):0;if(e.innerType||h){if(h&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);if(s&&f>=s.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${t}. because there is no value at that index. `);r=s,s=s&&s[f],e=h?e.spec.types[f]:e.innerType}if(!l){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${e.type}")`);r=s,s=s&&s[c],e=e.fields[c]}i=c,a=u?"["+o+"]":"."+o})),{schema:e,parent:r,parentPath:i}):{parent:r,parentPath:t,schema:e}}class G extends Set{describe(){const e=[];for(const t of this.values())e.push(Y.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const s of this.values())t.push(e(s));return t}clone(){return new G(this.values())}merge(e,t){const s=this.clone();return e.forEach((e=>s.add(e))),t.forEach((e=>s.delete(e))),s}}function Q(e,t=new Map){if(R(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let s;if(e instanceof Date)s=new Date(e.getTime()),t.set(e,s);else if(e instanceof RegExp)s=new RegExp(e),t.set(e,s);else if(Array.isArray(e)){s=new Array(e.length),t.set(e,s);for(let n=0;n<e.length;n++)s[n]=Q(e[n],t)}else if(e instanceof Map){s=new Map,t.set(e,s);for(const[n,r]of e.entries())s.set(n,Q(r,t))}else if(e instanceof Set){s=new Set,t.set(e,s);for(const n of e)s.add(Q(n,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);s={},t.set(e,s);for(const[n,r]of Object.entries(e))s[n]=Q(r,t)}return s}class W{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new G,this._blacklist=new G,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation((()=>{this.typeError(P.notType)})),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation((e=>{e.nonNullable()}))}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Q(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let s=e(this);return this._mutate=t,s}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,s=e.clone();const n=Object.assign({},t.spec,s.spec);return s.spec=n,s.internalTests=Object.assign({},t.internalTests,s.internalTests),s._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),s._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),s.tests=t.tests,s.exclusiveTests=t.exclusiveTests,s.withMutation((t=>{e.tests.forEach((e=>{t.test(e.OPTIONS)}))})),s.transforms=[...t.transforms,...s.transforms],s}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let s=t.conditions;t=t.clone(),t.conditions=[],t=s.reduce(((t,s)=>s.resolve(t,e)),t),t=t.resolve(e)}return t}resolveOptions(e){var t,s,n;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(s=e.abortEarly)?s:this.spec.abortEarly,recursive:null!=(n=e.recursive)?n:this.spec.recursive})}cast(e,t={}){let s=this.resolve(Object.assign({value:e},t)),n="ignore-optionality"===t.assert,r=s._cast(e,t);if(!1!==t.assert&&!s.isType(r)){if(n&&J(r))return r;let i=j(e),a=j(r);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${s.type}". \n\nattempted value: ${i} \n`+(a!==i?`result of cast: ${a}`:""))}return r}_cast(e,t){let s=void 0===e?e:this.transforms.reduce(((t,s)=>s.call(this,t,e,this)),e);return void 0===s&&(s=this.getDefault()),s}_validate(e,t={},s,n){let{path:r,originalValue:i=e,strict:a=this.spec.strict}=t,o=e;a||(o=this._cast(o,Object.assign({assert:!1},t)));let u=[];for(let e of Object.values(this.internalTests))e&&u.push(e);this.runTests({path:r,value:o,originalValue:i,options:t,tests:u},s,(e=>{if(e.length)return n(e,o);this.runTests({path:r,value:o,originalValue:i,options:t,tests:this.tests},s,n)}))}runTests(e,t,s){let n=!1,{tests:r,value:i,originalValue:a,path:o,options:u}=e,l=e=>{n||(n=!0,t(e,i))},c=e=>{n||(n=!0,s(e,i))},h=r.length,f=[];if(!h)return c([]);let d={value:i,originalValue:a,path:o,options:u,schema:this};for(let e=0;e<r.length;e++){(0,r[e])(d,l,(function(e){e&&(f=f.concat(e)),--h<=0&&c(f)}))}}asNestedTest({key:e,index:t,parent:s,parentPath:n,originalParent:r,options:i}){const a=null!=e?e:t;if(null==a)throw TypeError("Must include `key` or `index` for nested validations");const o="number"==typeof a;let u=s[a];const l=Object.assign({},i,{strict:!0,parent:s,value:u,originalValue:r[a],key:void 0,[o?"index":"key"]:a,path:o||a.includes(".")?`${n||""}[${u?a:`"${a}"`}]`:(n?`${n}.`:"")+e});return(e,t,s)=>this.resolve(l)._validate(u,l,t,s)}validate(e,t){let s=this.resolve(Object.assign({},t,{value:e}));return new Promise(((n,r)=>s._validate(e,t,((e,t)=>{I.isError(e)&&(e.value=t),r(e)}),((e,t)=>{e.length?r(new I(e,t)):n(t)}))))}validateSync(e,t){let s;return this.resolve(Object.assign({},t,{value:e}))._validate(e,Object.assign({},t,{sync:!0}),((e,t)=>{throw I.isError(e)&&(e.value=t),e}),((t,n)=>{if(t.length)throw new I(t,e);s=n})),s}isValid(e,t){return this.validate(e,t).then((()=>!0),(e=>{if(I.isError(e))return!1;throw e}))}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(I.isError(e))return!1;throw e}}_getDefault(){let e=this.spec.default;return null==e?e:"function"==typeof e?e.call(this):Q(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const s=this.clone({nullable:e});return s.internalTests.nullable=K({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),s}optionality(e,t){const s=this.clone({optional:e});return s.internalTests.optionality=K({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),s}optional(){return this.optionality(!0)}defined(e=P.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=P.notNull){return this.nullability(!1,e)}required(e=P.required){return this.clone().withMutation((t=>t.nonNullable(e).defined(e)))}notRequired(){return this.clone().withMutation((e=>e.nullable().optional()))}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=P.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let s=this.clone(),n=K(t),r=t.exclusive||t.name&&!0===s.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(s.exclusiveTests[t.name]=!!t.exclusive),s.tests=s.tests.filter((e=>{if(e.OPTIONS.name===t.name){if(r)return!1;if(e.OPTIONS.test===n.OPTIONS.test)return!1}return!0})),s.tests.push(n),s}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let s=this.clone(),n=N(e).map((e=>new Y(e)));return n.forEach((e=>{e.isSibling&&s.deps.push(e.key)})),s.conditions.push("function"==typeof t?new Z(n,t):Z.fromOptions(n,t)),s}typeError(e){let t=this.clone();return t.internalTests.typeError=K({message:e,name:"typeError",test(e){return!(!J(e)&&!this.schema._typeCheck(e))||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=P.oneOf){let s=this.clone();return e.forEach((e=>{s._whitelist.add(e),s._blacklist.delete(e)})),s.internalTests.whiteList=K({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,s=t.resolveAll(this.resolve);return!!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}notOneOf(e,t=P.notOneOf){let s=this.clone();return e.forEach((e=>{s._blacklist.add(e),s._whitelist.delete(e)})),s.internalTests.blacklist=K({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,s=t.resolveAll(this.resolve);return!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:s,meta:n,optional:r,nullable:i}=t.spec;return{meta:n,label:s,optional:r,nullable:i,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map((e=>({name:e.OPTIONS.name,params:e.OPTIONS.params}))).filter(((e,t,s)=>s.findIndex((t=>t.name===e.name))===t))}}}W.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])W.prototype[`${e}At`]=function(t,s,n={}){const{parent:r,parentPath:i,schema:a}=H(this,t,s,n.context);return a[e](r&&r[i],Object.assign({},n,{parent:r,path:t}))};for(const e of["equals","is"])W.prototype[e]=W.prototype.oneOf;for(const e of["not","nope"])W.prototype[e]=W.prototype.notOneOf;let X=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ee=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,te=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,se=e=>J(e)||e===e.trim(),ne={}.toString();function re(){return new ie}class ie extends W{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce||s.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===ne?e:n}))}))}required(e){return super.required(e).withMutation((t=>t.test({message:e||P.required,name:"required",skipAbsent:!0,test:e=>!!e.length})))}notRequired(){return super.notRequired().withMutation((e=>(e.tests=e.tests.filter((e=>"required"!==e.OPTIONS.name)),e)))}length(e,t=V.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=V.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=V.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let s,n,r=!1;return t&&("object"==typeof t?({excludeEmptyString:r=!1,message:s,name:n}=t):s=t),this.test({name:n||"matches",message:s||V.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&r||-1!==t.search(e)})}email(e=V.email){return this.matches(X,{name:"email",message:e,excludeEmptyString:!0})}url(e=V.url){return this.matches(ee,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=V.uuid){return this.matches(te,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform((e=>null===e?"":e))}trim(e=V.trim){return this.transform((e=>null!=e?e.trim():e)).test({message:e,name:"trim",test:se})}lowercase(e=V.lowercase){return this.transform((e=>J(e)?e:e.toLowerCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>J(e)||e===e.toLowerCase()})}uppercase(e=V.uppercase){return this.transform((e=>J(e)?e:e.toUpperCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>J(e)||e===e.toUpperCase()})}}re.prototype=ie.prototype;function ae(){return new oe}class oe extends W{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return s.isType(n)?n:parseFloat(n)}))}))}min(e,t=M.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=M.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=M.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=M.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=M.positive){return this.moreThan(0,e)}negative(e=M.negative){return this.lessThan(0,e)}integer(e=M.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform((e=>J(e)?e:0|e))}round(e){var t;let s=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===s.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+s.join(", "));return this.transform((t=>J(t)?t:Math[e](t)))}}ae.prototype=oe.prototype;var ue=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;let le=new Date("");class ce extends W{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation((()=>{this.transform(((e,t,s)=>!s.spec.coerce||s.isType(e)?e:(e=function(e){var t,s,n=[1,4,5,6,7,10,11],r=0;if(s=ue.exec(e)){for(var i,a=0;i=n[a];++a)s[i]=+s[i]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,void 0!==s[8]&&""!==s[8]||void 0!==s[9]&&""!==s[9]?("Z"!==s[8]&&void 0!==s[9]&&(r=60*s[10]+s[11],"+"===s[9]&&(r=0-r)),t=Date.UTC(s[1],s[2],s[3],s[4],s[5]+r,s[6],s[7])):t=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7])}else t=Date.parse?Date.parse(e):NaN;return t}(e),isNaN(e)?ce.INVALID_DATE:new Date(e))))}))}prepareParam(e,t){let s;if(Y.isRef(e))s=e;else{let n=this.cast(e);if(!this._typeCheck(n))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);s=n}return s}min(e,t=L.min){let s=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(s)}})}max(e,t=L.max){let s=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(s)}})}}function he(e,t){let s=1/0;return e.some(((e,n)=>{var r;if(null!=(r=t.path)&&r.includes(e))return s=n,!0})),s}function fe(e){return(t,s)=>he(e,t)-he(e,s)}ce.INVALID_DATE=le,ce.prototype;const de=(e,t,s)=>{if("string"!=typeof e)return e;let n=e;try{n=JSON.parse(e)}catch(e){}return s.isType(n)?n:e};function pe(e){if("fields"in e){const t={};for(const[s,n]of Object.entries(e.fields))t[s]=pe(n);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=pe(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(pe)}):"optional"in e?e.optional():e}let me=e=>"[object Object]"===Object.prototype.toString.call(e);const ye=fe([]);function ge(e){return new ve(e)}class ve extends W{constructor(e){super({type:"object",check:e=>me(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=ye,this._nodes=[],this._excludedEdges=[],this.withMutation((()=>{e&&this.shape(e)}))}_cast(e,t={}){var s;let n=super._cast(e,t);if(void 0===n)return this.getDefault();if(!this._typeCheck(n))return n;let r=this.fields,i=null!=(s=t.stripUnknown)?s:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(n).filter((e=>!this._nodes.includes(e)))),o={},u=Object.assign({},t,{parent:o,__validating:t.__validating||!1}),l=!1;for(const e of a){let s=r[e],a=e in n;if(s){let r,i=n[e];u.path=(t.path?`${t.path}.`:"")+e,s=s.resolve({value:i,context:t.context,parent:o});let a=s instanceof W?s.spec:void 0,c=null==a?void 0:a.strict;if(null!=a&&a.strip){l=l||e in n;continue}r=t.__validating&&c?n[e]:s.cast(n[e],u),void 0!==r&&(o[e]=r)}else a&&!i&&(o[e]=n[e]);a===e in o&&o[e]===n[e]||(l=!0)}return l?o:n}_validate(e,t={},s,n){let{from:r=[],originalValue:i=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:i},...r],t.__validating=!0,t.originalValue=i,super._validate(e,t,s,((e,r)=>{if(!a||!me(r))return void n(e,r);i=i||r;let o=[];for(let e of this._nodes){let s=this.fields[e];s&&!Y.isRef(s)&&o.push(s.asNestedTest({options:t,key:e,parent:r,parentPath:t.path,originalParent:i}))}this.runTests({tests:o,value:r,originalValue:i,options:t},s,(t=>{n(t.sort(this._sortErrors).concat(e),r)}))}))}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),s=t.fields;for(let[e,t]of Object.entries(this.fields)){const n=s[e];s[e]=void 0===n?t:n}return t.withMutation((e=>e.setFields(s,this._excludedEdges)))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach((t=>{const s=this.fields[t];e[t]=s&&"getDefault"in s?s.getDefault():void 0})),e}setFields(e,t){let s=this.clone();return s.fields=e,s._nodes=function(e,t=[]){let s=[],n=new Set,r=new Set(t.map((([e,t])=>`${e}-${t}`)));function i(e,t){let i=p.split(e)[0];n.add(i),r.has(`${t}-${i}`)||s.push([t,i])}for(const t of Object.keys(e)){let s=e[t];n.add(t),Y.isRef(s)&&s.isSibling?i(s.path,t):R(s)&&"deps"in s&&s.deps.forEach((e=>i(e,t)))}return O.array(Array.from(n),s).reverse()}(e,t),s._sortErrors=fe(Object.keys(e)),t&&(s._excludedEdges=t),s}shape(e,t=[]){return this.clone().withMutation((s=>{let n=s._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),n=[...s._excludedEdges,...t]),s.setFields(Object.assign(s.fields,e),n)}))}partial(){const e={};for(const[t,s]of Object.entries(this.fields))e[t]="optional"in s&&s.optional instanceof Function?s.optional():s;return this.setFields(e)}deepPartial(){return pe(this)}pick(e){const t={};for(const s of e)this.fields[s]&&(t[s]=this.fields[s]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const s of e)delete t[s];return this.setFields(t)}from(e,t,s){let n=p.getter(e,!0);return this.transform((r=>{if(!r)return r;let i=r;return((e,t)=>{const s=[...p.normalizePath(t)];if(1===s.length)return s[0]in e;let n=s.pop(),r=p.getter(p.join(s),!0)(e);return!(!r||!(n in r))})(r,e)&&(i=Object.assign({},r),s||delete i[e],i[t]=n(r)),i}))}json(){return this.transform(de)}noUnknown(e=!0,t=q.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let s=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const s=function(e,t){let s=Object.keys(e.fields);return Object.keys(t).filter((e=>-1===s.indexOf(e)))}(this.schema,t);return!e||0===s.length||this.createError({params:{unknown:s.join(", ")}})}});return s.spec.noUnknown=e,s}unknown(e=!0,t=q.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform((t=>{if(!t)return t;const s={};for(const n of Object.keys(t))s[e(n)]=t[n];return s}))}camelCase(){return this.transformKeys(E)}snakeCase(){return this.transformKeys(_)}constantCase(){return this.transformKeys((e=>_(e).toUpperCase()))}describe(e){let t=super.describe(e);t.fields={};for(const[n,r]of Object.entries(this.fields)){var s;let i=e;null!=(s=i)&&s.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),t.fields[n]=r.describe(i)}return t}}ge.prototype=ve.prototype;const be="#000639",xe='<svg width="40" height="41" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 10.5C0 4.977 4.477.5 10 .5h20c5.523 0 10 4.477 10 10v20c0 5.523-4.477 10-10 10H10c-5.523 0-10-4.477-10-10v-20Z" fill="#F1F1F1"/><path fill-rule="evenodd" clip-rule="evenodd" d="M25.927 15.78a.75.75 0 1 0-1.06-1.06l-4.793 4.793-4.793-4.793a.75.75 0 0 0-1.061 1.06l4.793 4.793-4.793 4.793a.75.75 0 1 0 1.06 1.061l4.794-4.793 4.793 4.793a.75.75 0 0 0 1.06-1.06l-4.793-4.794 4.793-4.793Z" fill="#000639"/></svg>';let we;function Fe(){const t=document.getElementById(e),s=document.getElementById(n);null==s||s.removeEventListener("click",Fe),window.removeEventListener("message",Ee),t&&document.body.removeChild(t)}const Ee=s=>{const i=new URL(r);if(s.origin===i.origin&&we){if("INITIALIZED"===s.data.status){const s=document.getElementById(e),r=document.getElementById(t),i=document.getElementById(n);if(!r||!i)return;null==s||s.removeChild(r),null==s||s.removeChild(i)}"CANCELLED"===s.data.status&&(Fe(),we.onClose&&we.onClose(s.data)),"COMPLETED"===s.data.status&&(Fe(),we.onSuccess&&we.onSuccess(s.data))}};return function(i){var a;!function(){if(document.head.querySelector(`#${s}`))return;const n=document.createElement("style");n.id=s,document.head.appendChild(n),n.textContent=`\n \n #${e}, #${e} * {\n margin: 0;\n padding: 0px;\n box-sizing: border-box;\n }\n \n #${t} {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n `}(),function(e){ge({local_amount:ae().required(),local_currency:re().required(),business_id:re().required(),reference:re(),callback_url:re(),mode:re().matches(/(test|live)/),meta:ge({email:re().email(),name:re().min(2)}).default(void 0)}).validateSync(e)}(i),we=i;const o=function(){const t=document.createElement("div");return t.id=e,t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex="999999999",t.style.backgroundColor="rgba(0, 0, 0, 0.4)",t}(),u=function(){const e=document.createElement("div");return e.id=t,e.style.width="40px",e.style.height="40px",e.style.backgroundColor="transparent",e.style.border=`2px solid ${be}`,e.style.borderLeftColor="transparent",e.style.borderBottomColor="transparent",e.style.borderRadius="100%",e.animate([{transform:"rotate(0)"},{transform:"rotate(360deg)"}],{duration:300,iterations:1/0}),e}(),l=function(){const e=document.createElement("button");return e.id=n,e.setAttribute("type","button"),e.style.width="40px",e.style.height="40px",e.style.position="absolute",e.style.right="0",e.style.zIndex="40",e.style.backgroundColor="transparent",e.style.border="none",e.innerHTML=xe,e}();l.addEventListener("click",Fe),o.appendChild(u),o.appendChild(l);const c=function(){const e=document.createElement("iframe");return e.allow="clipboard-read; clipboard-write",e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.left="50%",e.style.top="0px",e.style.transform="translate(-50%, 0)",e.style.zIndex="20",e}();o.appendChild(c),document.body.appendChild(o);const h=function(e){const t=document.createElement("form");t.action=r,t.method="POST",t.style.display="none",(s=>{for(const s in e){if(!e.hasOwnProperty(s))continue;const n=e[s];if("object"==typeof n)for(const e in n){if(!n.hasOwnProperty(e))continue;const r=document.createElement("input");r.name=`${s}[${e}]`,r.value=String(n[e]),t.appendChild(r)}else{const e=document.createElement("input");e.name=s,e.value=String(n),t.appendChild(e)}}})();const s=document.createElement("input");s.name="displayMode",s.value="INLINE";const n=document.createElement("input");return n.name="parentOrigin",n.value=window.location.origin,t.appendChild(s),t.appendChild(n),t}(function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(s[n[r]]=e[n[r]])}return s}(i,["onClose","onSuccess"]));null===(a=c.contentDocument)||void 0===a||a.body.appendChild(h),h.submit(),window.addEventListener("message",Ee)}}();
|
|
1
|
+
var BushaCommerce=function(){"use strict";const e="busha-commerce-container",t="busha-commerce-loader",s="busha-commerce-styles",n="busha-commerce-close-btn",r="busha-commerce-iframe",i="busha-commerce-form",a="https://pay.busha.co/pay",o="CANCELLED";function u(e){this._maxSize=e,this.clear()}u.prototype.clear=function(){this._size=0,this._values=Object.create(null)},u.prototype.get=function(e){return this._values[e]},u.prototype.set=function(e,t){return this._size>=this._maxSize&&this.clear(),e in this._values||this._size++,this._values[e]=t};var l=/[^.^\]^[]+|(?=\[\]|\.\.)/g,c=/^\d+$/,h=/^\d/,f=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,d=/^\s*(['"]?)(.*?)(\1)\s*$/,p=new u(512),m=new u(512),y=new u(512),g={Cache:u,split:b,normalizePath:v,setter:function(e){var t=v(e);return m.get(e)||m.set(e,(function(e,s){for(var n=0,r=t.length,i=e;n<r-1;){var a=t[n];if("__proto__"===a||"constructor"===a||"prototype"===a)return e;i=i[t[n++]]}i[t[n]]=s}))},getter:function(e,t){var s=v(e);return y.get(e)||y.set(e,(function(e){for(var n=0,r=s.length;n<r;){if(null==e&&t)return;e=e[s[n++]]}return e}))},join:function(e){return e.reduce((function(e,t){return e+(x(t)||c.test(t)?"["+t+"]":(e?".":"")+t)}),"")},forEach:function(e,t,s){!function(e,t,s){var n,r,i,a,o=e.length;for(r=0;r<o;r++)(n=e[r])&&(w(n)&&(n='"'+n+'"'),i=!(a=x(n))&&/^\d+$/.test(n),t.call(s,n,a,i,r,e))}(Array.isArray(e)?e:b(e),t,s)}};function v(e){return p.get(e)||p.set(e,b(e).map((function(e){return e.replace(d,"$2")})))}function b(e){return e.match(l)||[""]}function x(e){return"string"==typeof e&&e&&-1!==["'",'"'].indexOf(e.charAt(0))}function w(e){return!x(e)&&(function(e){return e.match(h)&&!e.match(c)}(e)||function(e){return f.test(e)}(e))}const F=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,E=e=>e.match(F)||[],_=(e,t)=>E(e).join(t).toLowerCase(),$=e=>E(e).reduce(((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`),"");var O=$,k=e=>_(e,"_"),T={};function A(e,t){var s=e.length,n=new Array(s),r={},i=s,a=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++){var r=e[s];t.has(r[0])||t.set(r[0],new Set),t.has(r[1])||t.set(r[1],new Set),t.get(r[0]).add(r[1])}return t}(t),o=function(e){for(var t=new Map,s=0,n=e.length;s<n;s++)t.set(e[s],s);return t}(e);for(t.forEach((function(e){if(!o.has(e[0])||!o.has(e[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")}));i--;)r[i]||u(e[i],i,new Set);return n;function u(e,t,i){if(i.has(e)){var l;try{l=", node was:"+JSON.stringify(e)}catch(e){l=""}throw new Error("Cyclic dependency"+l)}if(!o.has(e))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(e));if(!r[t]){r[t]=!0;var c=a.get(e)||new Set;if(t=(c=Array.from(c)).length){i.add(e);do{var h=c[--t];u(h,o.get(h),i)}while(t);i.delete(e)}n[--s]=e}}}({get exports(){return T},set exports(e){T=e}}).exports=function(e){return A(function(e){for(var t=new Set,s=0,n=e.length;s<n;s++){var r=e[s];t.add(r[0]),t.add(r[1])}return Array.from(t)}(e),e)},T.array=A;const D=Object.prototype.toString,C=Error.prototype.toString,S=RegExp.prototype.toString,j="undefined"!=typeof Symbol?Symbol.prototype.toString:()=>"",N=/^Symbol\((.*)\)(.*)$/;function z(e,t=!1){if(null==e||!0===e||!1===e)return""+e;const s=typeof e;if("number"===s)return function(e){return e!=+e?"NaN":0===e&&1/e<0?"-0":""+e}(e);if("string"===s)return t?`"${e}"`:e;if("function"===s)return"[Function "+(e.name||"anonymous")+"]";if("symbol"===s)return j.call(e).replace(N,"Symbol($1)");const n=D.call(e).slice(8,-1);return"Date"===n?isNaN(e.getTime())?""+e:e.toISOString(e):"Error"===n||e instanceof Error?"["+C.call(e)+"]":"RegExp"===n?S.call(e):null}function I(e,t){let s=z(e,t);return null!==s?s:JSON.stringify(e,(function(e,s){let n=z(this[e],t);return null!==n?n:s}),2)}function P(e){return null==e?[]:[].concat(e)}let V=/\$\{\s*(\w+)\s*\}/g;class M extends Error{static formatError(e,t){const s=t.label||t.path||"this";return s!==t.path&&(t=Object.assign({},t,{path:s})),"string"==typeof e?e.replace(V,((e,s)=>I(t[s]))):"function"==typeof e?e(t):e}static isError(e){return e&&"ValidationError"===e.name}constructor(e,t,s,n){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=s,this.type=n,this.errors=[],this.inner=[],P(e).forEach((e=>{M.isError(e)?(this.errors.push(...e.errors),this.inner=this.inner.concat(e.inner.length?e.inner:e)):this.errors.push(e)})),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,M)}}let L={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:s,originalValue:n})=>{const r=null!=n&&n!==s?` (cast from the value \`${I(n,!0)}\`).`:".";return"mixed"!==t?`${e} must be a \`${t}\` type, but the final value was: \`${I(s,!0)}\``+r:`${e} must match the configured type. The validated value was: \`${I(s,!0)}\``+r}},q={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},R={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Z={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},U={noUnknown:"${path} field has unspecified keys: ${unknown}"};Object.assign(Object.create(null),{mixed:L,string:q,number:R,date:Z,object:U,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:{isValue:"${path} field must be ${value}"}});const B=e=>e&&e.__isYupSchema__;class Y{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:s,then:n,otherwise:r}=t,i="function"==typeof s?s:(...e)=>e.every((e=>e===s));return new Y(e,((e,t)=>{var s;let a=i(...e)?n:r;return null!=(s=null==a?void 0:a(t))?s:t}))}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let s=this.refs.map((e=>e.getValue(null==t?void 0:t.value,null==t?void 0:t.parent,null==t?void 0:t.context))),n=this.fn(s,e,t);if(void 0===n||n===e)return e;if(!B(n))throw new TypeError("conditions must return a schema object");return n.resolve(t)}}const J="$",K=".";class H{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,"string"!=typeof e)throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),""===e)throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===J,this.isValue=this.key[0]===K,this.isSibling=!this.isContext&&!this.isValue;let s=this.isContext?J:this.isValue?K:"";this.path=this.key.slice(s.length),this.getter=this.path&&g.getter(this.path,!0),this.map=t.map}getValue(e,t,s){let n=this.isContext?s:this.isValue?e:t;return this.getter&&(n=this.getter(n||{})),this.map&&(n=this.map(n)),n}cast(e,t){return this.getValue(e,null==t?void 0:t.parent,null==t?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}H.prototype.__isYupRef=!0;const G=e=>null==e;function Q(e){function t({value:t,path:s="",options:n,originalValue:r,schema:i},a,o){const{name:u,test:l,params:c,message:h,skipAbsent:f}=e;let{parent:d,context:p,abortEarly:m=i.spec.abortEarly}=n;function y(e){return H.isRef(e)?e.getValue(t,d,p):e}function g(e={}){const n=Object.assign({value:t,originalValue:r,label:i.spec.label,path:e.path||s,spec:i.spec},c,e.params);for(const e of Object.keys(n))n[e]=y(n[e]);const a=new M(M.formatError(e.message||h,n),t,n.path,e.type||u);return a.params=n,a}const v=m?a:o;let b={path:s,parent:d,type:u,from:n.from,createError:g,resolve:y,options:n,originalValue:r,schema:i};const x=e=>{M.isError(e)?v(e):e?o(null):v(g())},w=e=>{M.isError(e)?v(e):a(e)},F=f&&G(t);if(!n.sync){try{Promise.resolve(!!F||l.call(b,t,b)).then(x,w)}catch(e){w(e)}return}let E;try{var _;if(E=!!F||l.call(b,t,b),"function"==typeof(null==(_=E)?void 0:_.then))throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(e){return void w(e)}x(E)}return t.OPTIONS=e,t}function W(e,t,s,n=s){let r,i,a;return t?(g.forEach(t,((o,u,l)=>{let c=u?o.slice(1,o.length-1):o,h="tuple"===(e=e.resolve({context:n,parent:r,value:s})).type,f=l?parseInt(c,10):0;if(e.innerType||h){if(h&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);if(s&&f>=s.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${t}. because there is no value at that index. `);r=s,s=s&&s[f],e=h?e.spec.types[f]:e.innerType}if(!l){if(!e.fields||!e.fields[c])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${a} which is a type: "${e.type}")`);r=s,s=s&&s[c],e=e.fields[c]}i=c,a=u?"["+o+"]":"."+o})),{schema:e,parent:r,parentPath:i}):{parent:r,parentPath:t,schema:e}}class X extends Set{describe(){const e=[];for(const t of this.values())e.push(H.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const s of this.values())t.push(e(s));return t}clone(){return new X(this.values())}merge(e,t){const s=this.clone();return e.forEach((e=>s.add(e))),t.forEach((e=>s.delete(e))),s}}function ee(e,t=new Map){if(B(e)||!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);let s;if(e instanceof Date)s=new Date(e.getTime()),t.set(e,s);else if(e instanceof RegExp)s=new RegExp(e),t.set(e,s);else if(Array.isArray(e)){s=new Array(e.length),t.set(e,s);for(let n=0;n<e.length;n++)s[n]=ee(e[n],t)}else if(e instanceof Map){s=new Map,t.set(e,s);for(const[n,r]of e.entries())s.set(n,ee(r,t))}else if(e instanceof Set){s=new Set,t.set(e,s);for(const n of e)s.add(ee(n,t))}else{if(!(e instanceof Object))throw Error(`Unable to clone ${e}`);s={},t.set(e,s);for(const[n,r]of Object.entries(e))s[n]=ee(r,t)}return s}class te{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new X,this._blacklist=new X,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation((()=>{this.typeError(L.notType)})),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},null==e?void 0:e.spec),this.withMutation((e=>{e.nonNullable()}))}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=ee(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(0===e.length)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let s=e(this);return this._mutate=t,s}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&"mixed"!==this.type)throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,s=e.clone();const n=Object.assign({},t.spec,s.spec);return s.spec=n,s.internalTests=Object.assign({},t.internalTests,s.internalTests),s._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),s._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),s.tests=t.tests,s.exclusiveTests=t.exclusiveTests,s.withMutation((t=>{e.tests.forEach((e=>{t.test(e.OPTIONS)}))})),s.transforms=[...t.transforms,...s.transforms],s}isType(e){return null==e?!(!this.spec.nullable||null!==e)||!(!this.spec.optional||void 0!==e):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let s=t.conditions;t=t.clone(),t.conditions=[],t=s.reduce(((t,s)=>s.resolve(t,e)),t),t=t.resolve(e)}return t}resolveOptions(e){var t,s,n;return Object.assign({},e,{from:e.from||[],strict:null!=(t=e.strict)?t:this.spec.strict,abortEarly:null!=(s=e.abortEarly)?s:this.spec.abortEarly,recursive:null!=(n=e.recursive)?n:this.spec.recursive})}cast(e,t={}){let s=this.resolve(Object.assign({value:e},t)),n="ignore-optionality"===t.assert,r=s._cast(e,t);if(!1!==t.assert&&!s.isType(r)){if(n&&G(r))return r;let i=I(e),a=I(r);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${s.type}". \n\nattempted value: ${i} \n`+(a!==i?`result of cast: ${a}`:""))}return r}_cast(e,t){let s=void 0===e?e:this.transforms.reduce(((t,s)=>s.call(this,t,e,this)),e);return void 0===s&&(s=this.getDefault()),s}_validate(e,t={},s,n){let{path:r,originalValue:i=e,strict:a=this.spec.strict}=t,o=e;a||(o=this._cast(o,Object.assign({assert:!1},t)));let u=[];for(let e of Object.values(this.internalTests))e&&u.push(e);this.runTests({path:r,value:o,originalValue:i,options:t,tests:u},s,(e=>{if(e.length)return n(e,o);this.runTests({path:r,value:o,originalValue:i,options:t,tests:this.tests},s,n)}))}runTests(e,t,s){let n=!1,{tests:r,value:i,originalValue:a,path:o,options:u}=e,l=e=>{n||(n=!0,t(e,i))},c=e=>{n||(n=!0,s(e,i))},h=r.length,f=[];if(!h)return c([]);let d={value:i,originalValue:a,path:o,options:u,schema:this};for(let e=0;e<r.length;e++){(0,r[e])(d,l,(function(e){e&&(f=f.concat(e)),--h<=0&&c(f)}))}}asNestedTest({key:e,index:t,parent:s,parentPath:n,originalParent:r,options:i}){const a=null!=e?e:t;if(null==a)throw TypeError("Must include `key` or `index` for nested validations");const o="number"==typeof a;let u=s[a];const l=Object.assign({},i,{strict:!0,parent:s,value:u,originalValue:r[a],key:void 0,[o?"index":"key"]:a,path:o||a.includes(".")?`${n||""}[${u?a:`"${a}"`}]`:(n?`${n}.`:"")+e});return(e,t,s)=>this.resolve(l)._validate(u,l,t,s)}validate(e,t){let s=this.resolve(Object.assign({},t,{value:e}));return new Promise(((n,r)=>s._validate(e,t,((e,t)=>{M.isError(e)&&(e.value=t),r(e)}),((e,t)=>{e.length?r(new M(e,t)):n(t)}))))}validateSync(e,t){let s;return this.resolve(Object.assign({},t,{value:e}))._validate(e,Object.assign({},t,{sync:!0}),((e,t)=>{throw M.isError(e)&&(e.value=t),e}),((t,n)=>{if(t.length)throw new M(t,e);s=n})),s}isValid(e,t){return this.validate(e,t).then((()=>!0),(e=>{if(M.isError(e))return!1;throw e}))}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(e){if(M.isError(e))return!1;throw e}}_getDefault(){let e=this.spec.default;return null==e?e:"function"==typeof e?e.call(this):ee(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){if(0===arguments.length)return this._getDefault();return this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const s=this.clone({nullable:e});return s.internalTests.nullable=Q({message:t,name:"nullable",test(e){return null!==e||this.schema.spec.nullable}}),s}optionality(e,t){const s=this.clone({optional:e});return s.internalTests.optionality=Q({message:t,name:"optionality",test(e){return void 0!==e||this.schema.spec.optional}}),s}optional(){return this.optionality(!0)}defined(e=L.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=L.notNull){return this.nullability(!1,e)}required(e=L.required){return this.clone().withMutation((t=>t.nonNullable(e).defined(e)))}notRequired(){return this.clone().withMutation((e=>e.nullable().optional()))}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(t=1===e.length?"function"==typeof e[0]?{test:e[0]}:e[0]:2===e.length?{name:e[0],test:e[1]}:{name:e[0],message:e[1],test:e[2]},void 0===t.message&&(t.message=L.default),"function"!=typeof t.test)throw new TypeError("`test` is a required parameters");let s=this.clone(),n=Q(t),r=t.exclusive||t.name&&!0===s.exclusiveTests[t.name];if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(s.exclusiveTests[t.name]=!!t.exclusive),s.tests=s.tests.filter((e=>{if(e.OPTIONS.name===t.name){if(r)return!1;if(e.OPTIONS.test===n.OPTIONS.test)return!1}return!0})),s.tests.push(n),s}when(e,t){Array.isArray(e)||"string"==typeof e||(t=e,e=".");let s=this.clone(),n=P(e).map((e=>new H(e)));return n.forEach((e=>{e.isSibling&&s.deps.push(e.key)})),s.conditions.push("function"==typeof t?new Y(n,t):Y.fromOptions(n,t)),s}typeError(e){let t=this.clone();return t.internalTests.typeError=Q({message:e,name:"typeError",test(e){return!(!G(e)&&!this.schema._typeCheck(e))||this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=L.oneOf){let s=this.clone();return e.forEach((e=>{s._whitelist.add(e),s._blacklist.delete(e)})),s.internalTests.whiteList=Q({message:t,name:"oneOf",skipAbsent:!0,test(e){let t=this.schema._whitelist,s=t.resolveAll(this.resolve);return!!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}notOneOf(e,t=L.notOneOf){let s=this.clone();return e.forEach((e=>{s._blacklist.add(e),s._whitelist.delete(e)})),s.internalTests.blacklist=Q({message:t,name:"notOneOf",test(e){let t=this.schema._blacklist,s=t.resolveAll(this.resolve);return!s.includes(e)||this.createError({params:{values:Array.from(t).join(", "),resolved:s}})}}),s}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:s,meta:n,optional:r,nullable:i}=t.spec;return{meta:n,label:s,optional:r,nullable:i,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map((e=>({name:e.OPTIONS.name,params:e.OPTIONS.params}))).filter(((e,t,s)=>s.findIndex((t=>t.name===e.name))===t))}}}te.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])te.prototype[`${e}At`]=function(t,s,n={}){const{parent:r,parentPath:i,schema:a}=W(this,t,s,n.context);return a[e](r&&r[i],Object.assign({},n,{parent:r,path:t}))};for(const e of["equals","is"])te.prototype[e]=te.prototype.oneOf;for(const e of["not","nope"])te.prototype[e]=te.prototype.notOneOf;let se=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ne=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,re=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,ie=e=>G(e)||e===e.trim(),ae={}.toString();function oe(){return new ue}class ue extends te{constructor(){super({type:"string",check:e=>(e instanceof String&&(e=e.valueOf()),"string"==typeof e)}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce||s.isType(e))return e;if(Array.isArray(e))return e;const n=null!=e&&e.toString?e.toString():e;return n===ae?e:n}))}))}required(e){return super.required(e).withMutation((t=>t.test({message:e||L.required,name:"required",skipAbsent:!0,test:e=>!!e.length})))}notRequired(){return super.notRequired().withMutation((e=>(e.tests=e.tests.filter((e=>"required"!==e.OPTIONS.name)),e)))}length(e,t=q.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(t){return t.length===this.resolve(e)}})}min(e,t=q.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t.length>=this.resolve(e)}})}max(e,t=q.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(t){return t.length<=this.resolve(e)}})}matches(e,t){let s,n,r=!1;return t&&("object"==typeof t?({excludeEmptyString:r=!1,message:s,name:n}=t):s=t),this.test({name:n||"matches",message:s||q.matches,params:{regex:e},skipAbsent:!0,test:t=>""===t&&r||-1!==t.search(e)})}email(e=q.email){return this.matches(se,{name:"email",message:e,excludeEmptyString:!0})}url(e=q.url){return this.matches(ne,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=q.uuid){return this.matches(re,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform((e=>null===e?"":e))}trim(e=q.trim){return this.transform((e=>null!=e?e.trim():e)).test({message:e,name:"trim",test:ie})}lowercase(e=q.lowercase){return this.transform((e=>G(e)?e:e.toLowerCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>G(e)||e===e.toLowerCase()})}uppercase(e=q.uppercase){return this.transform((e=>G(e)?e:e.toUpperCase())).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:e=>G(e)||e===e.toUpperCase()})}}oe.prototype=ue.prototype;function le(){return new ce}class ce extends te{constructor(){super({type:"number",check:e=>(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&!(e=>e!=+e)(e))}),this.withMutation((()=>{this.transform(((e,t,s)=>{if(!s.spec.coerce)return e;let n=e;if("string"==typeof n){if(n=n.replace(/\s/g,""),""===n)return NaN;n=+n}return s.isType(n)?n:parseFloat(n)}))}))}min(e,t=R.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(t){return t>=this.resolve(e)}})}max(e,t=R.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(t){return t<=this.resolve(e)}})}lessThan(e,t=R.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(t){return t<this.resolve(e)}})}moreThan(e,t=R.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(t){return t>this.resolve(e)}})}positive(e=R.positive){return this.moreThan(0,e)}negative(e=R.negative){return this.lessThan(0,e)}integer(e=R.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:e=>Number.isInteger(e)})}truncate(){return this.transform((e=>G(e)?e:0|e))}round(e){var t;let s=["ceil","floor","round","trunc"];if("trunc"===(e=(null==(t=e)?void 0:t.toLowerCase())||"round"))return this.truncate();if(-1===s.indexOf(e.toLowerCase()))throw new TypeError("Only valid options for round() are: "+s.join(", "));return this.transform((t=>G(t)?t:Math[e](t)))}}le.prototype=ce.prototype;var he=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;let fe=new Date("");class de extends te{constructor(){super({type:"date",check(e){return t=e,"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(e.getTime());var t}}),this.withMutation((()=>{this.transform(((e,t,s)=>!s.spec.coerce||s.isType(e)?e:(e=function(e){var t,s,n=[1,4,5,6,7,10,11],r=0;if(s=he.exec(e)){for(var i,a=0;i=n[a];++a)s[i]=+s[i]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,void 0!==s[8]&&""!==s[8]||void 0!==s[9]&&""!==s[9]?("Z"!==s[8]&&void 0!==s[9]&&(r=60*s[10]+s[11],"+"===s[9]&&(r=0-r)),t=Date.UTC(s[1],s[2],s[3],s[4],s[5]+r,s[6],s[7])):t=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7])}else t=Date.parse?Date.parse(e):NaN;return t}(e),isNaN(e)?de.INVALID_DATE:new Date(e))))}))}prepareParam(e,t){let s;if(H.isRef(e))s=e;else{let n=this.cast(e);if(!this._typeCheck(n))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);s=n}return s}min(e,t=Z.min){let s=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(e){return e>=this.resolve(s)}})}max(e,t=Z.max){let s=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(e){return e<=this.resolve(s)}})}}function pe(e,t){let s=1/0;return e.some(((e,n)=>{var r;if(null!=(r=t.path)&&r.includes(e))return s=n,!0})),s}function me(e){return(t,s)=>pe(e,t)-pe(e,s)}de.INVALID_DATE=fe,de.prototype;const ye=(e,t,s)=>{if("string"!=typeof e)return e;let n=e;try{n=JSON.parse(e)}catch(e){}return s.isType(n)?n:e};function ge(e){if("fields"in e){const t={};for(const[s,n]of Object.entries(e.fields))t[s]=ge(n);return e.setFields(t)}if("array"===e.type){const t=e.optional();return t.innerType&&(t.innerType=ge(t.innerType)),t}return"tuple"===e.type?e.optional().clone({types:e.spec.types.map(ge)}):"optional"in e?e.optional():e}let ve=e=>"[object Object]"===Object.prototype.toString.call(e);const be=me([]);function xe(e){return new we(e)}class we extends te{constructor(e){super({type:"object",check:e=>ve(e)||"function"==typeof e}),this.fields=Object.create(null),this._sortErrors=be,this._nodes=[],this._excludedEdges=[],this.withMutation((()=>{e&&this.shape(e)}))}_cast(e,t={}){var s;let n=super._cast(e,t);if(void 0===n)return this.getDefault();if(!this._typeCheck(n))return n;let r=this.fields,i=null!=(s=t.stripUnknown)?s:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(n).filter((e=>!this._nodes.includes(e)))),o={},u=Object.assign({},t,{parent:o,__validating:t.__validating||!1}),l=!1;for(const e of a){let s=r[e],a=e in n;if(s){let r,i=n[e];u.path=(t.path?`${t.path}.`:"")+e,s=s.resolve({value:i,context:t.context,parent:o});let a=s instanceof te?s.spec:void 0,c=null==a?void 0:a.strict;if(null!=a&&a.strip){l=l||e in n;continue}r=t.__validating&&c?n[e]:s.cast(n[e],u),void 0!==r&&(o[e]=r)}else a&&!i&&(o[e]=n[e]);a===e in o&&o[e]===n[e]||(l=!0)}return l?o:n}_validate(e,t={},s,n){let{from:r=[],originalValue:i=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:i},...r],t.__validating=!0,t.originalValue=i,super._validate(e,t,s,((e,r)=>{if(!a||!ve(r))return void n(e,r);i=i||r;let o=[];for(let e of this._nodes){let s=this.fields[e];s&&!H.isRef(s)&&o.push(s.asNestedTest({options:t,key:e,parent:r,parentPath:t.path,originalParent:i}))}this.runTests({tests:o,value:r,originalValue:i,options:t},s,(t=>{n(t.sort(this._sortErrors).concat(e),r)}))}))}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),s=t.fields;for(let[e,t]of Object.entries(this.fields)){const n=s[e];s[e]=void 0===n?t:n}return t.withMutation((e=>e.setFields(s,this._excludedEdges)))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach((t=>{const s=this.fields[t];e[t]=s&&"getDefault"in s?s.getDefault():void 0})),e}setFields(e,t){let s=this.clone();return s.fields=e,s._nodes=function(e,t=[]){let s=[],n=new Set,r=new Set(t.map((([e,t])=>`${e}-${t}`)));function i(e,t){let i=g.split(e)[0];n.add(i),r.has(`${t}-${i}`)||s.push([t,i])}for(const t of Object.keys(e)){let s=e[t];n.add(t),H.isRef(s)&&s.isSibling?i(s.path,t):B(s)&&"deps"in s&&s.deps.forEach((e=>i(e,t)))}return T.array(Array.from(n),s).reverse()}(e,t),s._sortErrors=me(Object.keys(e)),t&&(s._excludedEdges=t),s}shape(e,t=[]){return this.clone().withMutation((s=>{let n=s._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),n=[...s._excludedEdges,...t]),s.setFields(Object.assign(s.fields,e),n)}))}partial(){const e={};for(const[t,s]of Object.entries(this.fields))e[t]="optional"in s&&s.optional instanceof Function?s.optional():s;return this.setFields(e)}deepPartial(){return ge(this)}pick(e){const t={};for(const s of e)this.fields[s]&&(t[s]=this.fields[s]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const s of e)delete t[s];return this.setFields(t)}from(e,t,s){let n=g.getter(e,!0);return this.transform((r=>{if(!r)return r;let i=r;return((e,t)=>{const s=[...g.normalizePath(t)];if(1===s.length)return s[0]in e;let n=s.pop(),r=g.getter(g.join(s),!0)(e);return!(!r||!(n in r))})(r,e)&&(i=Object.assign({},r),s||delete i[e],i[t]=n(r)),i}))}json(){return this.transform(ye)}noUnknown(e=!0,t=U.noUnknown){"boolean"!=typeof e&&(t=e,e=!0);let s=this.test({name:"noUnknown",exclusive:!0,message:t,test(t){if(null==t)return!0;const s=function(e,t){let s=Object.keys(e.fields);return Object.keys(t).filter((e=>-1===s.indexOf(e)))}(this.schema,t);return!e||0===s.length||this.createError({params:{unknown:s.join(", ")}})}});return s.spec.noUnknown=e,s}unknown(e=!0,t=U.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform((t=>{if(!t)return t;const s={};for(const n of Object.keys(t))s[e(n)]=t[n];return s}))}camelCase(){return this.transformKeys(O)}snakeCase(){return this.transformKeys(k)}constantCase(){return this.transformKeys((e=>k(e).toUpperCase()))}describe(e){let t=super.describe(e);t.fields={};for(const[n,r]of Object.entries(this.fields)){var s;let i=e;null!=(s=i)&&s.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),t.fields[n]=r.describe(i)}return t}}xe.prototype=we.prototype;const Fe="#000639",Ee='<svg width="40" height="41" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 10.5C0 4.977 4.477.5 10 .5h20c5.523 0 10 4.477 10 10v20c0 5.523-4.477 10-10 10H10c-5.523 0-10-4.477-10-10v-20Z" fill="#F1F1F1"/><path fill-rule="evenodd" clip-rule="evenodd" d="M25.927 15.78a.75.75 0 1 0-1.06-1.06l-4.793 4.793-4.793-4.793a.75.75 0 0 0-1.061 1.06l4.793 4.793-4.793 4.793a.75.75 0 1 0 1.06 1.061l4.794-4.793 4.793 4.793a.75.75 0 0 0 1.06-1.06l-4.793-4.794 4.793-4.793Z" fill="#000639"/></svg>';let _e;function $e(){const t=document.getElementById(e),s=document.getElementById(n);null==s||s.removeEventListener("click",$e),window.removeEventListener("message",Oe),t&&document.body.removeChild(t)}const Oe=s=>{const r=new URL(a);if(s.origin===r.origin&&_e){if("INITIALIZED"===s.data.status){const s=document.getElementById(e),r=document.getElementById(t),i=document.getElementById(n);if(!r||!i)return;null==s||s.removeChild(r),null==s||s.removeChild(i)}s.data.status===o&&($e(),_e.onClose&&_e.onClose(s.data)),"COMPLETED"===s.data.status&&($e(),_e.onSuccess&&_e.onSuccess(s.data))}};return function(u){!function(){if(document.head.querySelector(`#${s}`))return;const n=document.createElement("style");n.id=s,n.dataset.testid=s,document.head.appendChild(n),n.textContent=`\n \n #${e}, #${e} * {\n margin: 0;\n padding: 0px;\n box-sizing: border-box;\n }\n \n #${t} {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n `}(),function(e){xe({local_amount:le().required(),local_currency:oe().required(),business_id:oe().required(),reference:oe(),callback_url:oe(),mode:oe().matches(/(test|live)/),meta:xe({email:oe().email(),name:oe().min(2)}).default(void 0)}).validateSync(e)}(u),_e=u;const l=function(){const t=document.createElement("div");return t.id=e,t.dataset.testid=e,t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex="999999999",t.style.backgroundColor="rgba(0, 0, 0, 0.4)",t}(),c=function(){const e=document.createElement("div");return e.id=t,e.dataset.testid=t,e.style.width="40px",e.style.height="40px",e.style.backgroundColor="transparent",e.style.border=`2px solid ${Fe}`,e.style.borderLeftColor="transparent",e.style.borderBottomColor="transparent",e.style.borderRadius="100%",e.animate&&e.animate([{transform:"rotate(0)"},{transform:"rotate(360deg)"}],{duration:300,iterations:1/0}),e}(),h=function(){const e=document.createElement("button");return e.id=n,e.dataset.testid=n,e.setAttribute("type","button"),e.style.width="40px",e.style.height="40px",e.style.position="absolute",e.style.right="0",e.style.zIndex="40",e.style.backgroundColor="transparent",e.style.border="none",e.innerHTML=Ee,e}();h.addEventListener("click",(e=>{e.preventDefault(),$e(),_e.onClose&&_e.onClose({status:o,data:{reference:_e.reference}})})),l.appendChild(c),l.appendChild(h);const f=function(){const e=document.createElement("iframe");return e.dataset.testid=r,e.name=r,e.allow=`clipboard-write self ${a}`,e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.left="50%",e.style.top="0px",e.style.transform="translate(-50%, 0)",e.style.zIndex="20",e}();l.appendChild(f),document.body.appendChild(l);const d=function(e){const t=document.createElement("form");t.target=r,t.dataset.testid=i,t.action=a,t.method="POST",t.style.display="none",(s=>{for(const s in e){if(!e.hasOwnProperty(s))continue;const n=e[s];if("object"==typeof n)for(const e in n){if(!n.hasOwnProperty(e))continue;const r=document.createElement("input");r.name=`${s}[${e}]`,r.value=String(n[e]),t.appendChild(r)}else{const e=document.createElement("input");e.name=s,e.value=String(n),t.appendChild(e)}}})();const s=document.createElement("input");s.name="displayMode",s.value="INLINE";const n=document.createElement("input");return n.name="parentOrigin",n.value=window.location.origin,t.appendChild(s),t.appendChild(n),t}(function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(s[n[r]]=e[n[r]])}return s}(u,["onClose","onSuccess"]));l.appendChild(d),d.submit(),window.addEventListener("message",Oe)}}();
|
package/dist/types.d.ts
CHANGED
package/jest.config.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
3
|
+
* https://jestjs.io/docs/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
// All imported modules in your tests should be mocked automatically
|
|
8
|
+
// automock: false,
|
|
9
|
+
|
|
10
|
+
// Stop running tests after `n` failures
|
|
11
|
+
// bail: 0,
|
|
12
|
+
|
|
13
|
+
// The directory where Jest should store its cached dependency information
|
|
14
|
+
// cacheDirectory: "/private/var/folders/hc/3_zh1vzd17d8c6t1yycchrpc0000gp/T/jest_dy",
|
|
15
|
+
|
|
16
|
+
// Automatically clear mock calls, instances, contexts and results before every test
|
|
17
|
+
// clearMocks: false,
|
|
18
|
+
|
|
19
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
20
|
+
// collectCoverage: false,
|
|
21
|
+
|
|
22
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
23
|
+
// collectCoverageFrom: undefined,
|
|
24
|
+
|
|
25
|
+
// The directory where Jest should output its coverage files
|
|
26
|
+
// coverageDirectory: undefined,
|
|
27
|
+
|
|
28
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
29
|
+
// coveragePathIgnorePatterns: [
|
|
30
|
+
// "/node_modules/"
|
|
31
|
+
// ],
|
|
32
|
+
|
|
33
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
34
|
+
// coverageProvider: "babel",
|
|
35
|
+
|
|
36
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
37
|
+
// coverageReporters: [
|
|
38
|
+
// "json",
|
|
39
|
+
// "text",
|
|
40
|
+
// "lcov",
|
|
41
|
+
// "clover"
|
|
42
|
+
// ],
|
|
43
|
+
|
|
44
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
45
|
+
// coverageThreshold: undefined,
|
|
46
|
+
|
|
47
|
+
// A path to a custom dependency extractor
|
|
48
|
+
// dependencyExtractor: undefined,
|
|
49
|
+
|
|
50
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
51
|
+
// errorOnDeprecated: false,
|
|
52
|
+
|
|
53
|
+
// The default configuration for fake timers
|
|
54
|
+
// fakeTimers: {
|
|
55
|
+
// "enableGlobally": false
|
|
56
|
+
// },
|
|
57
|
+
|
|
58
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
59
|
+
// forceCoverageMatch: [],
|
|
60
|
+
|
|
61
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
62
|
+
// globalSetup: undefined,
|
|
63
|
+
|
|
64
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
65
|
+
// globalTeardown: undefined,
|
|
66
|
+
|
|
67
|
+
// A set of global variables that need to be available in all test environments
|
|
68
|
+
// globals: {},
|
|
69
|
+
|
|
70
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
71
|
+
// maxWorkers: "50%",
|
|
72
|
+
|
|
73
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
74
|
+
// moduleDirectories: [
|
|
75
|
+
// "node_modules"
|
|
76
|
+
// ],
|
|
77
|
+
|
|
78
|
+
// An array of file extensions your modules use
|
|
79
|
+
// moduleFileExtensions: [
|
|
80
|
+
// "js",
|
|
81
|
+
// "mjs",
|
|
82
|
+
// "cjs",
|
|
83
|
+
// "jsx",
|
|
84
|
+
// "ts",
|
|
85
|
+
// "tsx",
|
|
86
|
+
// "json",
|
|
87
|
+
// "node"
|
|
88
|
+
// ],
|
|
89
|
+
|
|
90
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
91
|
+
// moduleNameMapper: {},
|
|
92
|
+
|
|
93
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
94
|
+
// modulePathIgnorePatterns: [],
|
|
95
|
+
|
|
96
|
+
// Activates notifications for test results
|
|
97
|
+
// notify: false,
|
|
98
|
+
|
|
99
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
100
|
+
// notifyMode: "failure-change",
|
|
101
|
+
|
|
102
|
+
// A preset that is used as a base for Jest's configuration
|
|
103
|
+
preset: "ts-jest",
|
|
104
|
+
|
|
105
|
+
// Run tests from one or more projects
|
|
106
|
+
// projects: undefined,
|
|
107
|
+
|
|
108
|
+
// Use this configuration option to add custom reporters to Jest
|
|
109
|
+
// reporters: undefined,
|
|
110
|
+
|
|
111
|
+
// Automatically reset mock state before every test
|
|
112
|
+
// resetMocks: false,
|
|
113
|
+
|
|
114
|
+
// Reset the module registry before running each individual test
|
|
115
|
+
// resetModules: false,
|
|
116
|
+
|
|
117
|
+
// A path to a custom resolver
|
|
118
|
+
// resolver: undefined,
|
|
119
|
+
|
|
120
|
+
// Automatically restore mock state and implementation before every test
|
|
121
|
+
// restoreMocks: false,
|
|
122
|
+
|
|
123
|
+
// The root directory that Jest should scan for tests and modules within
|
|
124
|
+
// rootDir: undefined,
|
|
125
|
+
|
|
126
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
127
|
+
// roots: [
|
|
128
|
+
// "<rootDir>"
|
|
129
|
+
// ],
|
|
130
|
+
|
|
131
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
132
|
+
// runner: "jest-runner",
|
|
133
|
+
|
|
134
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
135
|
+
// setupFiles: [],
|
|
136
|
+
|
|
137
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
138
|
+
// setupFilesAfterEnv: [],
|
|
139
|
+
|
|
140
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
141
|
+
// slowTestThreshold: 5,
|
|
142
|
+
|
|
143
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
144
|
+
// snapshotSerializers: [],
|
|
145
|
+
|
|
146
|
+
// The test environment that will be used for testing
|
|
147
|
+
testEnvironment: "jest-environment-jsdom",
|
|
148
|
+
|
|
149
|
+
// Options that will be passed to the testEnvironment
|
|
150
|
+
// testEnvironmentOptions: {},
|
|
151
|
+
|
|
152
|
+
// Adds a location field to test results
|
|
153
|
+
// testLocationInResults: false,
|
|
154
|
+
|
|
155
|
+
// The glob patterns Jest uses to detect test files
|
|
156
|
+
// testMatch: [
|
|
157
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
158
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
159
|
+
// ],
|
|
160
|
+
|
|
161
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
162
|
+
// testPathIgnorePatterns: [
|
|
163
|
+
// "/node_modules/"
|
|
164
|
+
// ],
|
|
165
|
+
|
|
166
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
167
|
+
// testRegex: [],
|
|
168
|
+
|
|
169
|
+
// This option allows the use of a custom results processor
|
|
170
|
+
// testResultsProcessor: undefined,
|
|
171
|
+
|
|
172
|
+
// This option allows use of a custom test runner
|
|
173
|
+
// testRunner: "jest-circus/runner",
|
|
174
|
+
|
|
175
|
+
// A map from regular expressions to paths to transformers
|
|
176
|
+
// transform: undefined,
|
|
177
|
+
|
|
178
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
179
|
+
// transformIgnorePatterns: [
|
|
180
|
+
// "/node_modules/",
|
|
181
|
+
// "\\.pnp\\.[^\\/]+$"
|
|
182
|
+
// ],
|
|
183
|
+
|
|
184
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
185
|
+
// unmockedModulePathPatterns: undefined,
|
|
186
|
+
|
|
187
|
+
// Indicates whether each individual test should be reported during the run
|
|
188
|
+
// verbose: undefined,
|
|
189
|
+
|
|
190
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
191
|
+
// watchPathIgnorePatterns: [],
|
|
192
|
+
|
|
193
|
+
// Whether to use watchman for file crawling
|
|
194
|
+
// watchman: true,
|
|
195
|
+
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"devDependencies": {
|
|
3
|
+
"@babel/core": "^7.21.3",
|
|
4
|
+
"@babel/preset-env": "^7.20.2",
|
|
5
|
+
"@babel/preset-typescript": "^7.21.0",
|
|
3
6
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
4
7
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
5
8
|
"@rollup/plugin-replace": "^5.0.2",
|
|
6
9
|
"@rollup/plugin-terser": "^0.4.0",
|
|
7
10
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
11
|
+
"@testing-library/cypress": "^9.0.0",
|
|
12
|
+
"@testing-library/dom": "^9.0.1",
|
|
13
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
14
|
+
"@types/jest": "^29.4.4",
|
|
8
15
|
"@types/node": "^18.14.0",
|
|
16
|
+
"babel-jest": "^29.5.0",
|
|
17
|
+
"cypress": "^12.8.1",
|
|
18
|
+
"cypress-iframe": "^1.0.1",
|
|
19
|
+
"dotenv": "^16.0.3",
|
|
20
|
+
"jest": "^29.5.0",
|
|
21
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
9
22
|
"rollup": "^3.17.2",
|
|
10
|
-
"
|
|
23
|
+
"ts-jest": "^29.0.5",
|
|
24
|
+
"ts-node": "^10.9.1",
|
|
25
|
+
"tslib": "^2.5.0",
|
|
26
|
+
"typescript": "^4.9.5"
|
|
11
27
|
},
|
|
12
28
|
"scripts": {
|
|
13
29
|
"build": "rollup -c rollup.config.ts --configPlugin typescript",
|
|
14
30
|
"start": "rollup -w -c rollup.config.ts --configPlugin typescript",
|
|
15
|
-
"dist:cleanup": "rm -rf dist/constants dist/helper.d.ts output"
|
|
31
|
+
"dist:cleanup": "rm -rf dist/constants dist/helper.d.ts output",
|
|
32
|
+
"test": "jest --watch",
|
|
33
|
+
"test:ci": "jest",
|
|
34
|
+
"test:e2e": "cypress open",
|
|
35
|
+
"test:e2e:ci": "cypress run -b chrome"
|
|
16
36
|
},
|
|
17
37
|
"dependencies": {
|
|
18
|
-
"dotenv": "^16.0.3",
|
|
19
|
-
"typescript": "^4.9.5",
|
|
20
38
|
"yup": "^1.0.0"
|
|
21
39
|
},
|
|
22
40
|
"name": "@busha/commerce-js",
|
|
23
41
|
"description": "Busha commerce js library",
|
|
24
|
-
"version": "1.0.
|
|
42
|
+
"version": "1.0.9",
|
|
25
43
|
"main": "./dist/index.js",
|
|
26
44
|
"types": "./dist/index.d.ts",
|
|
27
45
|
"directories": {
|
package/rollup.config.ts
CHANGED
|
@@ -2,6 +2,8 @@ export const CONTAINER_ID = "busha-commerce-container";
|
|
|
2
2
|
export const LOADER_ID = "busha-commerce-loader";
|
|
3
3
|
export const STYLESHEET_ID = "busha-commerce-styles";
|
|
4
4
|
export const CLOSE_BUTTON_ID = "busha-commerce-close-btn";
|
|
5
|
+
export const IFRAME_ID = "busha-commerce-iframe";
|
|
6
|
+
export const FORM_ID = "busha-commerce-form";
|
|
5
7
|
|
|
6
8
|
export const PAY_UI = process.env.PAYMENT_UI;
|
|
7
9
|
|
package/src/helper.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
LOADER_ID,
|
|
8
8
|
CLOSE_BUTTON_ID,
|
|
9
9
|
PAY_UI,
|
|
10
|
+
IFRAME_ID,
|
|
11
|
+
FORM_ID,
|
|
10
12
|
} from "./constants/variables";
|
|
11
13
|
import { BushaCommercePayload } from "./types";
|
|
12
14
|
import { close } from "./constants/icons";
|
|
@@ -18,6 +20,7 @@ export function injectGlobalStyles() {
|
|
|
18
20
|
|
|
19
21
|
const styleEl = document.createElement("style");
|
|
20
22
|
styleEl.id = STYLESHEET_ID;
|
|
23
|
+
styleEl.dataset.testid = STYLESHEET_ID;
|
|
21
24
|
|
|
22
25
|
document.head.appendChild(styleEl);
|
|
23
26
|
|
|
@@ -60,6 +63,7 @@ export function validatePayload(p: BushaCommercePayload) {
|
|
|
60
63
|
export function createContainerEl() {
|
|
61
64
|
const containerEl = document.createElement("div");
|
|
62
65
|
containerEl.id = CONTAINER_ID;
|
|
66
|
+
containerEl.dataset.testid = CONTAINER_ID;
|
|
63
67
|
containerEl.style.position = "fixed";
|
|
64
68
|
containerEl.style.top = "0px";
|
|
65
69
|
containerEl.style.left = "0px";
|
|
@@ -74,6 +78,7 @@ export function createContainerEl() {
|
|
|
74
78
|
export function createCloseBtnEl() {
|
|
75
79
|
const closeBtnEl = document.createElement("button");
|
|
76
80
|
closeBtnEl.id = CLOSE_BUTTON_ID;
|
|
81
|
+
closeBtnEl.dataset.testid = CLOSE_BUTTON_ID;
|
|
77
82
|
closeBtnEl.setAttribute("type", "button");
|
|
78
83
|
closeBtnEl.style.width = "40px";
|
|
79
84
|
closeBtnEl.style.height = "40px";
|
|
@@ -90,6 +95,7 @@ export function createCloseBtnEl() {
|
|
|
90
95
|
export function createSpinnerEl() {
|
|
91
96
|
const spinnerEl = document.createElement("div");
|
|
92
97
|
spinnerEl.id = LOADER_ID;
|
|
98
|
+
spinnerEl.dataset.testid = LOADER_ID;
|
|
93
99
|
spinnerEl.style.width = "40px";
|
|
94
100
|
spinnerEl.style.height = "40px";
|
|
95
101
|
spinnerEl.style.backgroundColor = "transparent";
|
|
@@ -97,20 +103,25 @@ export function createSpinnerEl() {
|
|
|
97
103
|
spinnerEl.style.borderLeftColor = "transparent";
|
|
98
104
|
spinnerEl.style.borderBottomColor = "transparent";
|
|
99
105
|
spinnerEl.style.borderRadius = "100%";
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
if (spinnerEl.animate)
|
|
108
|
+
spinnerEl.animate(
|
|
109
|
+
[{ transform: "rotate(0)" }, { transform: "rotate(360deg)" }],
|
|
110
|
+
{
|
|
111
|
+
duration: 300,
|
|
112
|
+
iterations: Infinity,
|
|
113
|
+
}
|
|
114
|
+
);
|
|
107
115
|
|
|
108
116
|
return spinnerEl;
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
export function createIframeEl() {
|
|
112
120
|
const iframeEl = document.createElement("iframe");
|
|
113
|
-
|
|
121
|
+
|
|
122
|
+
iframeEl.dataset.testid = IFRAME_ID;
|
|
123
|
+
iframeEl.name = IFRAME_ID;
|
|
124
|
+
iframeEl.allow = `clipboard-write self ${PAY_UI}`;
|
|
114
125
|
iframeEl.style.width = "100%";
|
|
115
126
|
// iframeEl.style.maxWidth = "100%";
|
|
116
127
|
iframeEl.style.height = "100%";
|
|
@@ -128,6 +139,8 @@ type FormPayload = Omit<BushaCommercePayload, "onClose" | "onSuccess">;
|
|
|
128
139
|
|
|
129
140
|
export function createFormEl(payload: FormPayload) {
|
|
130
141
|
const formEl = document.createElement("form");
|
|
142
|
+
formEl.target = IFRAME_ID;
|
|
143
|
+
formEl.dataset.testid = FORM_ID;
|
|
131
144
|
formEl.action = PAY_UI ?? "";
|
|
132
145
|
formEl.method = "POST";
|
|
133
146
|
formEl.style.display = "none";
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,17 @@ export default function BushaCommerce(p: BushaCommercePayload) {
|
|
|
31
31
|
|
|
32
32
|
const spinner = createSpinnerEl();
|
|
33
33
|
const closeBtn = createCloseBtnEl();
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
closeBtn.addEventListener("click", (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
cleanup();
|
|
38
|
+
if (payload.onClose) {
|
|
39
|
+
payload.onClose({
|
|
40
|
+
status: CANCELLED_STATUS,
|
|
41
|
+
data: { reference: payload.reference },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
35
45
|
|
|
36
46
|
container.appendChild(spinner);
|
|
37
47
|
container.appendChild(closeBtn);
|
|
@@ -45,9 +55,13 @@ export default function BushaCommerce(p: BushaCommercePayload) {
|
|
|
45
55
|
|
|
46
56
|
const iframeForm = createFormEl(rest);
|
|
47
57
|
|
|
48
|
-
|
|
58
|
+
container.appendChild(iframeForm);
|
|
59
|
+
|
|
60
|
+
// iframe.contentDocument?.body.appendChild(iframeForm);
|
|
49
61
|
|
|
50
|
-
|
|
62
|
+
if (process.env.NODE_ENV !== "test") {
|
|
63
|
+
iframeForm.submit();
|
|
64
|
+
}
|
|
51
65
|
|
|
52
66
|
window.addEventListener("message", onMessage);
|
|
53
67
|
}
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getByText, screen, waitFor, within } from "@testing-library/dom";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
|
|
4
|
+
import BushaCommerce from "../src";
|
|
5
|
+
import {
|
|
6
|
+
CLOSE_BUTTON_ID,
|
|
7
|
+
CONTAINER_ID,
|
|
8
|
+
FORM_ID,
|
|
9
|
+
IFRAME_ID,
|
|
10
|
+
} from "../src/constants/variables";
|
|
11
|
+
|
|
12
|
+
const onClose = jest.fn();
|
|
13
|
+
|
|
14
|
+
function setup() {
|
|
15
|
+
const container = document.createElement("div");
|
|
16
|
+
|
|
17
|
+
container.innerHTML = `
|
|
18
|
+
<button type="button">Pay</button>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const button = container.querySelector("button");
|
|
22
|
+
|
|
23
|
+
button?.addEventListener("click", () => {
|
|
24
|
+
BushaCommerce({
|
|
25
|
+
business_id: "1234",
|
|
26
|
+
local_amount: 2000,
|
|
27
|
+
local_currency: "NGN",
|
|
28
|
+
onSuccess: jest.fn(),
|
|
29
|
+
onClose,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return container;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
const containerEl = document.getElementById(CONTAINER_ID);
|
|
38
|
+
|
|
39
|
+
if (containerEl) document.body.removeChild(containerEl);
|
|
40
|
+
|
|
41
|
+
jest.clearAllMocks();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Shows loader, iframe and close button when called", async () => {
|
|
45
|
+
const container = setup();
|
|
46
|
+
|
|
47
|
+
getByText(container, "Pay").click();
|
|
48
|
+
|
|
49
|
+
await waitFor(async () => {
|
|
50
|
+
expect(screen.queryByTestId(CONTAINER_ID)).toBeInTheDocument();
|
|
51
|
+
expect(screen.queryByTestId(CLOSE_BUTTON_ID)).toBeInTheDocument();
|
|
52
|
+
expect(screen.queryByTestId(IFRAME_ID)).toBeInTheDocument();
|
|
53
|
+
expect(screen.queryByTestId(FORM_ID)).toBeInTheDocument();
|
|
54
|
+
// expect(screen.queryByRole("form")).toBeInTheDocument(); // weird, doesn't work
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("cleanups after close button is clicked", async () => {
|
|
59
|
+
const container = setup();
|
|
60
|
+
|
|
61
|
+
getByText(container, "Pay").click();
|
|
62
|
+
|
|
63
|
+
await waitFor(async () => {
|
|
64
|
+
expect(screen.queryByTestId(CONTAINER_ID)).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const closeButton = screen.getByTestId(CLOSE_BUTTON_ID);
|
|
68
|
+
|
|
69
|
+
closeButton.click();
|
|
70
|
+
|
|
71
|
+
await waitFor(() => {
|
|
72
|
+
expect(screen.queryByTestId(CONTAINER_ID)).not.toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("calls onClose callback after close button is clicked", async () => {
|
|
77
|
+
const container = setup();
|
|
78
|
+
|
|
79
|
+
getByText(container, "Pay").click();
|
|
80
|
+
|
|
81
|
+
await waitFor(async () => {
|
|
82
|
+
expect(screen.queryByTestId(IFRAME_ID)).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const closeButton = screen.getByTestId(CLOSE_BUTTON_ID);
|
|
86
|
+
|
|
87
|
+
closeButton.click();
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(screen.queryByTestId(CONTAINER_ID)).not.toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
expect(onClose).toBeCalledTimes(1);
|
|
94
|
+
expect(onClose).toHaveBeenCalledWith(
|
|
95
|
+
expect.objectContaining({ status: expect.any(String) })
|
|
96
|
+
);
|
|
97
|
+
});
|