@springmicro/cart 0.6.2 → 0.6.3

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/dist/index.js CHANGED
@@ -33185,16 +33185,23 @@ async function _I(e, t, n) {
33185
33185
  return i.searchParams.set("orderId", a.id), i.searchParams.set("orderRef", a.reference), window.history.pushState({}, "", i), a;
33186
33186
  }
33187
33187
  async function jI(e, t, n, r, a, i) {
33188
- i && console.log("Getting tax");
33188
+ i && console.log("Getting tax", n), i && console.log(
33189
+ "Getting product data",
33190
+ a,
33191
+ a[n[0].product_id]
33192
+ );
33189
33193
  const s = n.filter(
33190
- (c) => c.unit_amount > 0 && a[c.product_id].type !== "DONATION"
33194
+ (c) => c.unit_amount > 0 && a[c.product_id].type != "DONATION"
33191
33195
  );
33192
33196
  return i && console.log("Taxable items", s), s.length === 0 ? { tax_amount: 0 } : await (await fetch(
33193
33197
  `${e}/api/ecommerce/tax?tax_provider=${t ?? "dummy"}`,
33194
33198
  {
33195
33199
  method: "POST",
33196
33200
  body: JSON.stringify({
33197
- cart_data: s,
33201
+ cart_data: s.map((c) => ({
33202
+ amount: c.unit_amount,
33203
+ reference: c.reference
33204
+ })),
33198
33205
  address: {
33199
33206
  country: r.country,
33200
33207
  city: r.locality,
@@ -33233,14 +33240,15 @@ function DI({
33233
33240
  N && console.log({ products: l, prices: s });
33234
33241
  const [I, R] = qt(!0), [h, T] = qt(void 0), w = Yo(), V = Sy(w.breakpoints.down("lg")), [_, $] = a, [P, g] = n, [O, A] = u;
33235
33242
  async function L(ee) {
33236
- T(void 0), R(!0), Promise.all([
33243
+ T(void 0), R(!0), N && console.log("Cart items", i.items), Promise.all([
33237
33244
  _I(i, c, N),
33238
33245
  jI(
33239
33246
  c,
33240
33247
  f,
33241
33248
  i.items.map((G) => ({
33242
- amount: s[G.price_id].unit_amount,
33243
- reference: G.name
33249
+ unit_amount: s[G.price_id].unit_amount,
33250
+ reference: G.name,
33251
+ product_id: G.product_id
33244
33252
  })),
33245
33253
  ee,
33246
33254
  l,
@@ -33248,8 +33256,8 @@ function DI({
33248
33256
  )
33249
33257
  ]).then(([G, q]) => {
33250
33258
  g(q), A(G), $(1), R(!1);
33251
- }).catch(() => {
33252
- T(!0), R(!1);
33259
+ }).catch((G) => {
33260
+ N && console.log("Submit error", G), T(!0), R(!1);
33253
33261
  });
33254
33262
  }
33255
33263
  async function B(ee) {
@@ -202,5 +202,5 @@ const theme2 = createTheme({ palette: {
202
202
  attempted value: ${s}
203
203
  `+(l!==s?`result of cast: ${l}`:""))}return i}_cast(t,n){let r=t===void 0?t:this.transforms.reduce((a,i)=>i.call(this,a,t,this),t);return r===void 0&&(r=this.getDefault(n)),r}_validate(t,n={},r,a){let{path:i,originalValue:s=t,strict:l=this.spec.strict}=n,c=t;l||(c=this._cast(c,Object.assign({assert:!1},n)));let u=[];for(let d of Object.values(this.internalTests))d&&u.push(d);this.runTests({path:i,value:c,originalValue:s,options:n,tests:u},r,d=>{if(d.length)return a(d,c);this.runTests({path:i,value:c,originalValue:s,options:n,tests:this.tests},r,a)})}runTests(t,n,r){let a=!1,{tests:i,value:s,originalValue:l,path:c,options:u}=t,d=y=>{a||(a=!0,n(y,s))},p=y=>{a||(a=!0,r(y,s))},f=i.length,b=[];if(!f)return p([]);let x={value:s,originalValue:l,path:c,options:u,schema:this};for(let y=0;y<i.length;y++){const v=i[y];v(x,d,function(N){N&&(Array.isArray(N)?b.push(...N):b.push(N)),--f<=0&&p(b)})}}asNestedTest({key:t,index:n,parent:r,parentPath:a,originalParent:i,options:s}){const l=t??n;if(l==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof l=="number";let u=r[l];const d=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[l],key:void 0,[c?"index":"key"]:l,path:c||l.includes(".")?`${a||""}[${c?l:`"${l}"`}]`:(a?`${a}.`:"")+t});return(p,f,b)=>this.resolve(d)._validate(u,d,f,b)}validate(t,n){var r;let a=this.resolve(Object.assign({},n,{value:t})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:a.spec.disableStackTrace;return new Promise((s,l)=>a._validate(t,n,(c,u)=>{Rt.isError(c)&&(c.value=u),l(c)},(c,u)=>{c.length?l(new Rt(c,u,void 0,void 0,i)):s(u)}))}validateSync(t,n){var r;let a=this.resolve(Object.assign({},n,{value:t})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:a.spec.disableStackTrace;return a._validate(t,Object.assign({},n,{sync:!0}),(l,c)=>{throw Rt.isError(l)&&(l.value=c),l},(l,c)=>{if(l.length)throw new Rt(l,t,void 0,void 0,s);i=c}),i}isValid(t,n){return this.validate(t,n).then(()=>!0,r=>{if(Rt.isError(r))return!1;throw r})}isValidSync(t,n){try{return this.validateSync(t,n),!0}catch(r){if(Rt.isError(r))return!1;throw r}}_getDefault(t){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,t):Jr(n)}getDefault(t){return this.resolve(t||{})._getDefault(t)}default(t){return arguments.length===0?this._getDefault():this.clone({default:t})}strict(t=!0){return this.clone({strict:t})}nullability(t,n){const r=this.clone({nullable:t});return r.internalTests.nullable=Yr({message:n,name:"nullable",test(a){return a===null?this.schema.spec.nullable:!0}}),r}optionality(t,n){const r=this.clone({optional:t});return r.internalTests.optionality=Yr({message:n,name:"optionality",test(a){return a===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(t=hn.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=hn.notNull){return this.nullability(!1,t)}required(t=hn.required){return this.clone().withMutation(n=>n.nonNullable(t).defined(t))}notRequired(){return this.clone().withMutation(t=>t.nullable().optional())}transform(t){let n=this.clone();return n.transforms.push(t),n}test(...t){let n;if(t.length===1?typeof t[0]=="function"?n={test:t[0]}:n=t[0]:t.length===2?n={name:t[0],test:t[1]}:n={name:t[0],message:t[1],test:t[2]},n.message===void 0&&(n.message=hn.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),a=Yr(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===a.OPTIONS.test))),r.tests.push(a),r}when(t,n){!Array.isArray(t)&&typeof t!="string"&&(n=t,t=".");let r=this.clone(),a=mf(t).map(i=>new or(i));return a.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new wi(a,n):wi.fromOptions(a,n)),r}typeError(t){let n=this.clone();return n.internalTests.typeError=Yr({message:t,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(t,n=hn.oneOf){let r=this.clone();return t.forEach(a=>{r._whitelist.add(a),r._blacklist.delete(a)}),r.internalTests.whiteList=Yr({message:n,name:"oneOf",skipAbsent:!0,test(a){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(a)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(t,n=hn.notOneOf){let r=this.clone();return t.forEach(a=>{r._blacklist.add(a),r._whitelist.delete(a)}),r.internalTests.blacklist=Yr({message:n,name:"notOneOf",test(a){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(a)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(t=!0){let n=this.clone();return n.spec.strip=t,n}describe(t){const n=(t?this.resolve(t):this).clone(),{label:r,meta:a,optional:i,nullable:s}=n.spec;return{meta:a,label:r,optional:i,nullable:s,default:n.getDefault(t),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,d)=>d.findIndex(p=>p.name===c.name)===u)}}}gn.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])gn.prototype[`${e}At`]=function(t,n,r={}){const{parent:a,parentPath:i,schema:s}=AC(this,t,n,r.context);return s[e](a&&a[i],Object.assign({},r,{parent:a,path:t}))};for(const e of["equals","is"])gn.prototype[e]=gn.prototype.oneOf;for(const e of["not","nope"])gn.prototype[e]=gn.prototype.notOneOf;const MC=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function _C(e){const t=jl(e);if(!t)return Date.parse?Date.parse(e):Number.NaN;if(t.z===void 0&&t.plusMinus===void 0)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let n=0;return t.z!=="Z"&&t.plusMinus!==void 0&&(n=t.hourOffset*60+t.minuteOffset,t.plusMinus==="+"&&(n=0-n)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+n,t.second,t.millisecond)}function jl(e){var t,n;const r=MC.exec(e);return r?{year:Rn(r[1]),month:Rn(r[2],1)-1,day:Rn(r[3],1),hour:Rn(r[4]),minute:Rn(r[5]),second:Rn(r[6]),millisecond:r[7]?Rn(r[7].substring(0,3)):0,precision:(t=(n=r[7])==null?void 0:n.length)!=null?t:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Rn(r[10]),minuteOffset:Rn(r[11])}:null}function Rn(e,t=0){return Number(e)||t}let $C=/^[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])?)*$/,jC=/^((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,kC=/^(?:[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,DC="^\\d{4}-\\d{2}-\\d{2}",BC="\\d{2}:\\d{2}:\\d{2}",LC="(([+-]\\d{2}(:?\\d{2})?)|Z)",FC=new RegExp(`${DC}T${BC}(\\.\\d+)?${LC}$`),VC=e=>ar(e)||e===e.trim(),zC={}.toString();function yn(){return new vf}class vf extends gn{constructor(){super({type:"string",check(t){return t instanceof String&&(t=t.valueOf()),typeof t=="string"}}),this.withMutation(()=>{this.transform((t,n,r)=>{if(!r.spec.coerce||r.isType(t)||Array.isArray(t))return t;const a=t!=null&&t.toString?t.toString():t;return a===zC?t:a})})}required(t){return super.required(t).withMutation(n=>n.test({message:t||hn.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(t=>(t.tests=t.tests.filter(n=>n.OPTIONS.name!=="required"),t))}length(t,n=Nt.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(r){return r.length===this.resolve(t)}})}min(t,n=Nt.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(r){return r.length>=this.resolve(t)}})}max(t,n=Nt.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:t},skipAbsent:!0,test(r){return r.length<=this.resolve(t)}})}matches(t,n){let r=!1,a,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:a,name:i}=n:a=n),this.test({name:i||"matches",message:a||Nt.matches,params:{regex:t},skipAbsent:!0,test:s=>s===""&&r||s.search(t)!==-1})}email(t=Nt.email){return this.matches($C,{name:"email",message:t,excludeEmptyString:!0})}url(t=Nt.url){return this.matches(jC,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=Nt.uuid){return this.matches(kC,{name:"uuid",message:t,excludeEmptyString:!1})}datetime(t){let n="",r,a;return t&&(typeof t=="object"?{message:n="",allowOffset:r=!1,precision:a=void 0}=t:n=t),this.matches(FC,{name:"datetime",message:n||Nt.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||Nt.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=jl(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||Nt.datetime_precision,params:{precision:a},skipAbsent:!0,test:i=>{if(!i||a==null)return!0;const s=jl(i);return s?s.precision===a:!1}})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=Nt.trim){return this.transform(n=>n!=null?n.trim():n).test({message:t,name:"trim",test:VC})}lowercase(t=Nt.lowercase){return this.transform(n=>ar(n)?n:n.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ar(n)||n===n.toLowerCase()})}uppercase(t=Nt.uppercase){return this.transform(n=>ar(n)?n:n.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ar(n)||n===n.toUpperCase()})}}yn.prototype=vf.prototype;let UC=new Date(""),HC=e=>Object.prototype.toString.call(e)==="[object Date]";class Ai extends gn{constructor(){super({type:"date",check(t){return HC(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,n,r)=>!r.spec.coerce||r.isType(t)||t===null?t:(t=_C(t),isNaN(t)?Ai.INVALID_DATE:new Date(t)))})}prepareParam(t,n){let r;if(or.isRef(t))r=t;else{let a=this.cast(t);if(!this._typeCheck(a))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=a}return r}min(t,n=Ml.min){let r=this.prepareParam(t,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(a){return a>=this.resolve(r)}})}max(t,n=Ml.max){let r=this.prepareParam(t,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(a){return a<=this.resolve(r)}})}}Ai.INVALID_DATE=UC,Ai.prototype;function GC(e,t=[]){let n=[],r=new Set,a=new Set(t.map(([s,l])=>`${s}-${l}`));function i(s,l){let c=rr.split(s)[0];r.add(c),a.has(`${l}-${c}`)||n.push([l,c])}for(const s of Object.keys(e)){let l=e[s];r.add(s),or.isRef(l)&&l.isSibling?i(l.path,s):$l(l)&&"deps"in l&&l.deps.forEach(c=>i(c,s))}return SC.array(Array.from(r),n).reverse()}function xf(e,t){let n=1/0;return e.some((r,a)=>{var i;if((i=t.path)!=null&&i.includes(r))return n=a,!0}),n}function Sf(e){return(t,n)=>xf(e,t)-xf(e,n)}const WC=(e,t,n)=>{if(typeof e!="string")return e;let r=e;try{r=JSON.parse(e)}catch{}return n.isType(r)?r:e};function Mi(e){if("fields"in e){const t={};for(const[n,r]of Object.entries(e.fields))t[n]=Mi(r);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=Mi(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(Mi)}):"optional"in e?e.optional():e}const KC=(e,t)=>{const n=[...rr.normalizePath(t)];if(n.length===1)return n[0]in e;let r=n.pop(),a=rr.getter(rr.join(n),!0)(e);return!!(a&&r in a)};let Ef=e=>Object.prototype.toString.call(e)==="[object Object]";function qC(e,t){let n=Object.keys(e.fields);return Object.keys(t).filter(r=>n.indexOf(r)===-1)}const YC=Sf([]);function Of(e){return new Cf(e)}class Cf extends gn{constructor(t){super({type:"object",check(n){return Ef(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=YC,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,n={}){var r;let a=super._cast(t,n);if(a===void 0)return this.getDefault(n);if(!this._typeCheck(a))return a;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,l=[].concat(this._nodes,Object.keys(a).filter(p=>!this._nodes.includes(p))),c={},u=Object.assign({},n,{parent:c,__validating:n.__validating||!1}),d=!1;for(const p of l){let f=i[p],b=p in a;if(f){let x,y=a[p];u.path=(n.path?`${n.path}.`:"")+p,f=f.resolve({value:y,context:n.context,parent:c});let v=f instanceof gn?f.spec:void 0,C=v==null?void 0:v.strict;if(v!=null&&v.strip){d=d||p in a;continue}x=!n.__validating||!C?f.cast(a[p],u):a[p],x!==void 0&&(c[p]=x)}else b&&!s&&(c[p]=a[p]);(b!==p in c||c[p]!==a[p])&&(d=!0)}return d?c:a}_validate(t,n={},r,a){let{from:i=[],originalValue:s=t,recursive:l=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(t,n,r,(c,u)=>{if(!l||!Ef(u)){a(c,u);return}s=s||u;let d=[];for(let p of this._nodes){let f=this.fields[p];!f||or.isRef(f)||d.push(f.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:d,value:u,originalValue:s,options:n},r,p=>{a(p.sort(this._sortErrors).concat(c),u)})})}clone(t){const n=super.clone(t);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(t){let n=super.concat(t),r=n.fields;for(let[a,i]of Object.entries(this.fields)){const s=r[a];r[a]=s===void 0?i:s}return n.withMutation(a=>a.setFields(r,[...this._excludedEdges,...t._excludedEdges]))}_getDefault(t){if("default"in this.spec)return super._getDefault(t);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var a;const i=this.fields[r];let s=t;(a=s)!=null&&a.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(t,n){let r=this.clone();return r.fields=t,r._nodes=GC(t,n),r._sortErrors=Sf(Object.keys(t)),n&&(r._excludedEdges=n),r}shape(t,n=[]){return this.clone().withMutation(r=>{let a=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),a=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,t),a)})}partial(){const t={};for(const[n,r]of Object.entries(this.fields))t[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(t)}deepPartial(){return Mi(this)}pick(t){const n={};for(const r of t)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,a])=>t.includes(r)&&t.includes(a)))}omit(t){const n=[];for(const r of Object.keys(this.fields))t.includes(r)||n.push(r);return this.pick(n)}from(t,n,r){let a=rr.getter(t,!0);return this.transform(i=>{if(!i)return i;let s=i;return KC(i,t)&&(s=Object.assign({},i),r||delete s[t],s[n]=a(i)),s})}json(){return this.transform(WC)}noUnknown(t=!0,n=_l.noUnknown){typeof t!="boolean"&&(n=t,t=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(a){if(a==null)return!0;const i=qC(this.schema,a);return!t||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=t,r}unknown(t=!0,n=_l.noUnknown){return this.noUnknown(!t,n)}transformKeys(t){return this.transform(n=>{if(!n)return n;const r={};for(const a of Object.keys(n))r[t(a)]=n[a];return r})}camelCase(){return this.transformKeys(Nl.camelCase)}snakeCase(){return this.transformKeys(Nl.snakeCase)}constantCase(){return this.transformKeys(t=>Nl.snakeCase(t).toUpperCase())}describe(t){const n=(t?this.resolve(t):this).clone(),r=super.describe(t);r.fields={};for(const[i,s]of Object.entries(n.fields)){var a;let l=t;(a=l)!=null&&a.value&&(l=Object.assign({},l,{parent:l.value,value:l.value[i]})),r.fields[i]=s.describe(l)}return r}}Of.prototype=Cf.prototype;var JC=function(t){return ZC(t)&&!XC(t)};function ZC(e){return!!e&&typeof e=="object"}function XC(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||tT(e)}var QC=typeof Symbol=="function"&&Symbol.for,eT=QC?Symbol.for("react.element"):60103;function tT(e){return e.$$typeof===eT}function nT(e){return Array.isArray(e)?[]:{}}function _i(e,t){return t.clone!==!1&&t.isMergeableObject(e)?qo(nT(e),e,t):e}function rT(e,t,n){return e.concat(t).map(function(r){return _i(r,n)})}function oT(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(a){r[a]=_i(e[a],n)}),Object.keys(t).forEach(function(a){!n.isMergeableObject(t[a])||!e[a]?r[a]=_i(t[a],n):r[a]=qo(e[a],t[a],n)}),r}function qo(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||rT,n.isMergeableObject=n.isMergeableObject||JC;var r=Array.isArray(t),a=Array.isArray(e),i=r===a;return i?r?n.arrayMerge(e,t,n):oT(e,t,n):_i(t,n)}qo.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,a){return qo(r,a,n)},{})};var kl=qo,Tf=typeof global=="object"&&global&&global.Object===Object&&global,aT=typeof self=="object"&&self&&self.Object===Object&&self,bn=Tf||aT||Function("return this")(),Hn=bn.Symbol,Pf=Object.prototype,iT=Pf.hasOwnProperty,sT=Pf.toString,Yo=Hn?Hn.toStringTag:void 0;function lT(e){var t=iT.call(e,Yo),n=e[Yo];try{e[Yo]=void 0;var r=!0}catch{}var a=sT.call(e);return r&&(t?e[Yo]=n:delete e[Yo]),a}var cT=Object.prototype,uT=cT.toString;function dT(e){return uT.call(e)}var pT="[object Null]",fT="[object Undefined]",If=Hn?Hn.toStringTag:void 0;function ir(e){return e==null?e===void 0?fT:pT:If&&If in Object(e)?lT(e):dT(e)}function wf(e,t){return function(n){return e(t(n))}}var Dl=wf(Object.getPrototypeOf,Object);function sr(e){return e!=null&&typeof e=="object"}var mT="[object Object]",hT=Function.prototype,gT=Object.prototype,Rf=hT.toString,yT=gT.hasOwnProperty,bT=Rf.call(Object);function Nf(e){if(!sr(e)||ir(e)!=mT)return!1;var t=Dl(e);if(t===null)return!0;var n=yT.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Rf.call(n)==bT}function vT(){this.__data__=[],this.size=0}function Af(e,t){return e===t||e!==e&&t!==t}function $i(e,t){for(var n=e.length;n--;)if(Af(e[n][0],t))return n;return-1}var xT=Array.prototype,ST=xT.splice;function ET(e){var t=this.__data__,n=$i(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():ST.call(t,n,1),--this.size,!0}function OT(e){var t=this.__data__,n=$i(t,e);return n<0?void 0:t[n][1]}function CT(e){return $i(this.__data__,e)>-1}function TT(e,t){var n=this.__data__,r=$i(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Nn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Nn.prototype.clear=vT,Nn.prototype.delete=ET,Nn.prototype.get=OT,Nn.prototype.has=CT,Nn.prototype.set=TT;function PT(){this.__data__=new Nn,this.size=0}function IT(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function wT(e){return this.__data__.get(e)}function RT(e){return this.__data__.has(e)}function Jo(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var NT="[object AsyncFunction]",AT="[object Function]",MT="[object GeneratorFunction]",_T="[object Proxy]";function Mf(e){if(!Jo(e))return!1;var t=ir(e);return t==AT||t==MT||t==NT||t==_T}var Bl=bn["__core-js_shared__"],_f=function(){var e=/[^.]+$/.exec(Bl&&Bl.keys&&Bl.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function $T(e){return!!_f&&_f in e}var jT=Function.prototype,kT=jT.toString;function lr(e){if(e!=null){try{return kT.call(e)}catch{}try{return e+""}catch{}}return""}var DT=/[\\^$.*+?()[\]{}|]/g,BT=/^\[object .+?Constructor\]$/,LT=Function.prototype,FT=Object.prototype,VT=LT.toString,zT=FT.hasOwnProperty,UT=RegExp("^"+VT.call(zT).replace(DT,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function HT(e){if(!Jo(e)||$T(e))return!1;var t=Mf(e)?UT:BT;return t.test(lr(e))}function GT(e,t){return e==null?void 0:e[t]}function cr(e,t){var n=GT(e,t);return HT(n)?n:void 0}var Zo=cr(bn,"Map"),Xo=cr(Object,"create");function WT(){this.__data__=Xo?Xo(null):{},this.size=0}function KT(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var qT="__lodash_hash_undefined__",YT=Object.prototype,JT=YT.hasOwnProperty;function ZT(e){var t=this.__data__;if(Xo){var n=t[e];return n===qT?void 0:n}return JT.call(t,e)?t[e]:void 0}var XT=Object.prototype,QT=XT.hasOwnProperty;function eP(e){var t=this.__data__;return Xo?t[e]!==void 0:QT.call(t,e)}var tP="__lodash_hash_undefined__";function nP(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Xo&&t===void 0?tP:t,this}function ur(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ur.prototype.clear=WT,ur.prototype.delete=KT,ur.prototype.get=ZT,ur.prototype.has=eP,ur.prototype.set=nP;function rP(){this.size=0,this.__data__={hash:new ur,map:new(Zo||Nn),string:new ur}}function oP(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ji(e,t){var n=e.__data__;return oP(t)?n[typeof t=="string"?"string":"hash"]:n.map}function aP(e){var t=ji(this,e).delete(e);return this.size-=t?1:0,t}function iP(e){return ji(this,e).get(e)}function sP(e){return ji(this,e).has(e)}function lP(e,t){var n=ji(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Gn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Gn.prototype.clear=rP,Gn.prototype.delete=aP,Gn.prototype.get=iP,Gn.prototype.has=sP,Gn.prototype.set=lP;var cP=200;function uP(e,t){var n=this.__data__;if(n instanceof Nn){var r=n.__data__;if(!Zo||r.length<cP-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(e,t),this.size=n.size,this}function Zr(e){var t=this.__data__=new Nn(e);this.size=t.size}Zr.prototype.clear=PT,Zr.prototype.delete=IT,Zr.prototype.get=wT,Zr.prototype.has=RT,Zr.prototype.set=uP;function dP(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var $f=function(){try{var e=cr(Object,"defineProperty");return e({},"",{}),e}catch{}}();function jf(e,t,n){t=="__proto__"&&$f?$f(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var pP=Object.prototype,fP=pP.hasOwnProperty;function kf(e,t,n){var r=e[t];(!(fP.call(e,t)&&Af(r,n))||n===void 0&&!(t in e))&&jf(e,t,n)}function ki(e,t,n,r){var a=!n;n||(n={});for(var i=-1,s=t.length;++i<s;){var l=t[i],c=void 0;c===void 0&&(c=e[l]),a?jf(n,l,c):kf(n,l,c)}return n}function mP(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var hP="[object Arguments]";function Df(e){return sr(e)&&ir(e)==hP}var Bf=Object.prototype,gP=Bf.hasOwnProperty,yP=Bf.propertyIsEnumerable,bP=Df(function(){return arguments}())?Df:function(e){return sr(e)&&gP.call(e,"callee")&&!yP.call(e,"callee")},Qo=Array.isArray;function vP(){return!1}var Lf=typeof Le=="object"&&Le&&!Le.nodeType&&Le,Ff=Lf&&typeof module=="object"&&module&&!module.nodeType&&module,xP=Ff&&Ff.exports===Lf,Vf=xP?bn.Buffer:void 0,SP=Vf?Vf.isBuffer:void 0,zf=SP||vP,EP=9007199254740991,OP=/^(?:0|[1-9]\d*)$/;function CP(e,t){var n=typeof e;return t=t??EP,!!t&&(n=="number"||n!="symbol"&&OP.test(e))&&e>-1&&e%1==0&&e<t}var TP=9007199254740991;function Uf(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=TP}var PP="[object Arguments]",IP="[object Array]",wP="[object Boolean]",RP="[object Date]",NP="[object Error]",AP="[object Function]",MP="[object Map]",_P="[object Number]",$P="[object Object]",jP="[object RegExp]",kP="[object Set]",DP="[object String]",BP="[object WeakMap]",LP="[object ArrayBuffer]",FP="[object DataView]",VP="[object Float32Array]",zP="[object Float64Array]",UP="[object Int8Array]",HP="[object Int16Array]",GP="[object Int32Array]",WP="[object Uint8Array]",KP="[object Uint8ClampedArray]",qP="[object Uint16Array]",YP="[object Uint32Array]",et={};et[VP]=et[zP]=et[UP]=et[HP]=et[GP]=et[WP]=et[KP]=et[qP]=et[YP]=!0,et[PP]=et[IP]=et[LP]=et[wP]=et[FP]=et[RP]=et[NP]=et[AP]=et[MP]=et[_P]=et[$P]=et[jP]=et[kP]=et[DP]=et[BP]=!1;function JP(e){return sr(e)&&Uf(e.length)&&!!et[ir(e)]}function Ll(e){return function(t){return e(t)}}var Hf=typeof Le=="object"&&Le&&!Le.nodeType&&Le,ea=Hf&&typeof module=="object"&&module&&!module.nodeType&&module,ZP=ea&&ea.exports===Hf,Fl=ZP&&Tf.process,Xr=function(){try{var e=ea&&ea.require&&ea.require("util").types;return e||Fl&&Fl.binding&&Fl.binding("util")}catch{}}(),Gf=Xr&&Xr.isTypedArray,XP=Gf?Ll(Gf):JP,QP=Object.prototype,e2=QP.hasOwnProperty;function Wf(e,t){var n=Qo(e),r=!n&&bP(e),a=!n&&!r&&zf(e),i=!n&&!r&&!a&&XP(e),s=n||r||a||i,l=s?mP(e.length,String):[],c=l.length;for(var u in e)(t||e2.call(e,u))&&!(s&&(u=="length"||a&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||CP(u,c)))&&l.push(u);return l}var t2=Object.prototype;function Vl(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||t2;return e===n}var n2=wf(Object.keys,Object),r2=Object.prototype,o2=r2.hasOwnProperty;function a2(e){if(!Vl(e))return n2(e);var t=[];for(var n in Object(e))o2.call(e,n)&&n!="constructor"&&t.push(n);return t}function Kf(e){return e!=null&&Uf(e.length)&&!Mf(e)}function zl(e){return Kf(e)?Wf(e):a2(e)}function i2(e,t){return e&&ki(t,zl(t),e)}function s2(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var l2=Object.prototype,c2=l2.hasOwnProperty;function u2(e){if(!Jo(e))return s2(e);var t=Vl(e),n=[];for(var r in e)r=="constructor"&&(t||!c2.call(e,r))||n.push(r);return n}function Ul(e){return Kf(e)?Wf(e,!0):u2(e)}function d2(e,t){return e&&ki(t,Ul(t),e)}var qf=typeof Le=="object"&&Le&&!Le.nodeType&&Le,Yf=qf&&typeof module=="object"&&module&&!module.nodeType&&module,p2=Yf&&Yf.exports===qf,Jf=p2?bn.Buffer:void 0,Zf=Jf?Jf.allocUnsafe:void 0;function f2(e,t){if(t)return e.slice();var n=e.length,r=Zf?Zf(n):new e.constructor(n);return e.copy(r),r}function Xf(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}function m2(e,t){for(var n=-1,r=e==null?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}function Qf(){return[]}var h2=Object.prototype,g2=h2.propertyIsEnumerable,em=Object.getOwnPropertySymbols,Hl=em?function(e){return e==null?[]:(e=Object(e),m2(em(e),function(t){return g2.call(e,t)}))}:Qf;function y2(e,t){return ki(e,Hl(e),t)}function tm(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}var b2=Object.getOwnPropertySymbols,nm=b2?function(e){for(var t=[];e;)tm(t,Hl(e)),e=Dl(e);return t}:Qf;function v2(e,t){return ki(e,nm(e),t)}function rm(e,t,n){var r=t(e);return Qo(e)?r:tm(r,n(e))}function x2(e){return rm(e,zl,Hl)}function S2(e){return rm(e,Ul,nm)}var Gl=cr(bn,"DataView"),Wl=cr(bn,"Promise"),Kl=cr(bn,"Set"),ql=cr(bn,"WeakMap"),om="[object Map]",E2="[object Object]",am="[object Promise]",im="[object Set]",sm="[object WeakMap]",lm="[object DataView]",O2=lr(Gl),C2=lr(Zo),T2=lr(Wl),P2=lr(Kl),I2=lr(ql),An=ir;(Gl&&An(new Gl(new ArrayBuffer(1)))!=lm||Zo&&An(new Zo)!=om||Wl&&An(Wl.resolve())!=am||Kl&&An(new Kl)!=im||ql&&An(new ql)!=sm)&&(An=function(e){var t=ir(e),n=t==E2?e.constructor:void 0,r=n?lr(n):"";if(r)switch(r){case O2:return lm;case C2:return om;case T2:return am;case P2:return im;case I2:return sm}return t});var w2=Object.prototype,R2=w2.hasOwnProperty;function N2(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&R2.call(e,"index")&&(n.index=e.index,n.input=e.input),n}var cm=bn.Uint8Array;function Yl(e){var t=new e.constructor(e.byteLength);return new cm(t).set(new cm(e)),t}function A2(e,t){var n=t?Yl(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var M2=/\w*$/;function _2(e){var t=new e.constructor(e.source,M2.exec(e));return t.lastIndex=e.lastIndex,t}var um=Hn?Hn.prototype:void 0,dm=um?um.valueOf:void 0;function $2(e){return dm?Object(dm.call(e)):{}}function j2(e,t){var n=t?Yl(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var k2="[object Boolean]",D2="[object Date]",B2="[object Map]",L2="[object Number]",F2="[object RegExp]",V2="[object Set]",z2="[object String]",U2="[object Symbol]",H2="[object ArrayBuffer]",G2="[object DataView]",W2="[object Float32Array]",K2="[object Float64Array]",q2="[object Int8Array]",Y2="[object Int16Array]",J2="[object Int32Array]",Z2="[object Uint8Array]",X2="[object Uint8ClampedArray]",Q2="[object Uint16Array]",eI="[object Uint32Array]";function tI(e,t,n){var r=e.constructor;switch(t){case H2:return Yl(e);case k2:case D2:return new r(+e);case G2:return A2(e,n);case W2:case K2:case q2:case Y2:case J2:case Z2:case X2:case Q2:case eI:return j2(e,n);case B2:return new r;case L2:case z2:return new r(e);case F2:return _2(e);case V2:return new r;case U2:return $2(e)}}var pm=Object.create,nI=function(){function e(){}return function(t){if(!Jo(t))return{};if(pm)return pm(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function rI(e){return typeof e.constructor=="function"&&!Vl(e)?nI(Dl(e)):{}}var oI="[object Map]";function aI(e){return sr(e)&&An(e)==oI}var fm=Xr&&Xr.isMap,iI=fm?Ll(fm):aI,sI="[object Set]";function lI(e){return sr(e)&&An(e)==sI}var mm=Xr&&Xr.isSet,cI=mm?Ll(mm):lI,uI=1,dI=2,pI=4,hm="[object Arguments]",fI="[object Array]",mI="[object Boolean]",hI="[object Date]",gI="[object Error]",gm="[object Function]",yI="[object GeneratorFunction]",bI="[object Map]",vI="[object Number]",ym="[object Object]",xI="[object RegExp]",SI="[object Set]",EI="[object String]",OI="[object Symbol]",CI="[object WeakMap]",TI="[object ArrayBuffer]",PI="[object DataView]",II="[object Float32Array]",wI="[object Float64Array]",RI="[object Int8Array]",NI="[object Int16Array]",AI="[object Int32Array]",MI="[object Uint8Array]",_I="[object Uint8ClampedArray]",$I="[object Uint16Array]",jI="[object Uint32Array]",Xe={};Xe[hm]=Xe[fI]=Xe[TI]=Xe[PI]=Xe[mI]=Xe[hI]=Xe[II]=Xe[wI]=Xe[RI]=Xe[NI]=Xe[AI]=Xe[bI]=Xe[vI]=Xe[ym]=Xe[xI]=Xe[SI]=Xe[EI]=Xe[OI]=Xe[MI]=Xe[_I]=Xe[$I]=Xe[jI]=!0,Xe[gI]=Xe[gm]=Xe[CI]=!1;function ta(e,t,n,r,a,i){var s,l=t&uI,c=t&dI,u=t&pI;if(s!==void 0)return s;if(!Jo(e))return e;var d=Qo(e);if(d){if(s=N2(e),!l)return Xf(e,s)}else{var p=An(e),f=p==gm||p==yI;if(zf(e))return f2(e,l);if(p==ym||p==hm||f&&!a){if(s=c||f?{}:rI(e),!l)return c?v2(e,d2(s,e)):y2(e,i2(s,e))}else{if(!Xe[p])return a?e:{};s=tI(e,p,l)}}i||(i=new Zr);var b=i.get(e);if(b)return b;i.set(e,s),cI(e)?e.forEach(function(v){s.add(ta(v,t,n,v,e,i))}):iI(e)&&e.forEach(function(v,C){s.set(C,ta(v,t,n,C,e,i))});var x=u?c?S2:x2:c?Ul:zl,y=d?void 0:x(e);return dP(y||e,function(v,C){y&&(C=v,v=e[C]),kf(s,C,ta(v,t,n,C,e,i))}),s}var kI=1,DI=4;function Di(e){return ta(e,kI|DI)}var bm=Array.isArray,vm=Object.keys,BI=Object.prototype.hasOwnProperty,LI=typeof Element<"u";function Jl(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=bm(e),r=bm(t),a,i,s;if(n&&r){if(i=e.length,i!=t.length)return!1;for(a=i;a--!==0;)if(!Jl(e[a],t[a]))return!1;return!0}if(n!=r)return!1;var l=e instanceof Date,c=t instanceof Date;if(l!=c)return!1;if(l&&c)return e.getTime()==t.getTime();var u=e instanceof RegExp,d=t instanceof RegExp;if(u!=d)return!1;if(u&&d)return e.toString()==t.toString();var p=vm(e);if(i=p.length,i!==vm(t).length)return!1;for(a=i;a--!==0;)if(!BI.call(t,p[a]))return!1;if(LI&&e instanceof Element&&t instanceof Element)return e===t;for(a=i;a--!==0;)if(s=p[a],!(s==="_owner"&&e.$$typeof)&&!Jl(e[s],t[s]))return!1;return!0}return e!==e&&t!==t}var FI=function(t,n){try{return Jl(t,n)}catch(r){if(r.message&&r.message.match(/stack|recursion/i)||r.number===-2146828260)return console.warn("Warning: react-fast-compare does not handle circular references.",r.name,r.message),!1;throw r}};const dr=Vi(FI);var VI=process.env.NODE_ENV==="production";function Qr(e,t){if(!VI){var n="Warning: "+t;typeof console<"u"&&console.warn(n);try{throw Error(n)}catch{}}}var zI=4;function xm(e){return ta(e,zI)}function Sm(e,t){for(var n=-1,r=e==null?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}var UI="[object Symbol]";function Zl(e){return typeof e=="symbol"||sr(e)&&ir(e)==UI}var HI="Expected a function";function Xl(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(HI);var n=function(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(Xl.Cache||Gn),n}Xl.Cache=Gn;var GI=500;function WI(e){var t=Xl(e,function(r){return n.size===GI&&n.clear(),r}),n=t.cache;return t}var KI=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qI=/\\(\\)?/g,YI=WI(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(KI,function(n,r,a,i){t.push(a?i.replace(qI,"$1"):r||n)}),t}),JI=1/0;function ZI(e){if(typeof e=="string"||Zl(e))return e;var t=e+"";return t=="0"&&1/e==-JI?"-0":t}var XI=1/0,Em=Hn?Hn.prototype:void 0,Om=Em?Em.toString:void 0;function Cm(e){if(typeof e=="string")return e;if(Qo(e))return Sm(e,Cm)+"";if(Zl(e))return Om?Om.call(e):"";var t=e+"";return t=="0"&&1/e==-XI?"-0":t}function QI(e){return e==null?"":Cm(e)}function Tm(e){return Qo(e)?Sm(e,ZI):Zl(e)?[e]:Xf(YI(QI(e)))}function gt(){return gt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gt.apply(this,arguments)}function Pm(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}var Bi=U.createContext(void 0);Bi.displayName="FormikContext",Bi.Provider,Bi.Consumer;function ew(){var e=U.useContext(Bi);return e||(process.env.NODE_ENV!=="production"?Qr(!1,"Formik context is undefined, please verify you are calling useFormikContext() as child of a <Formik> component."):Qr()),e}var rn=function(t){return typeof t=="function"},Li=function(t){return t!==null&&typeof t=="object"},tw=function(t){return String(Math.floor(Number(t)))===t},Ql=function(t){return Object.prototype.toString.call(t)==="[object String]"},ec=function(t){return Li(t)&&rn(t.then)};function nw(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function zt(e,t,n,r){r===void 0&&(r=0);for(var a=Tm(t);e&&r<a.length;)e=e[a[r++]];return r!==a.length&&!e||e===void 0?n:e}function pr(e,t,n){for(var r=xm(e),a=r,i=0,s=Tm(t);i<s.length-1;i++){var l=s[i],c=zt(e,s.slice(0,i+1));if(c&&(Li(c)||Array.isArray(c)))a=a[l]=xm(c);else{var u=s[i+1];a=a[l]=tw(u)&&Number(u)>=0?[]:{}}}return(i===0?e:a)[s[i]]===n?e:(n===void 0?delete a[s[i]]:a[s[i]]=n,i===0&&n===void 0&&delete r[s[i]],r)}function Im(e,t,n,r){n===void 0&&(n=new WeakMap),r===void 0&&(r={});for(var a=0,i=Object.keys(e);a<i.length;a++){var s=i[a],l=e[s];Li(l)?n.get(l)||(n.set(l,!0),r[s]=Array.isArray(l)?[]:{},Im(l,t,n,r[s])):r[s]=t}return r}function rw(e,t){switch(t.type){case"SET_VALUES":return gt({},e,{values:t.payload});case"SET_TOUCHED":return gt({},e,{touched:t.payload});case"SET_ERRORS":return dr(e.errors,t.payload)?e:gt({},e,{errors:t.payload});case"SET_STATUS":return gt({},e,{status:t.payload});case"SET_ISSUBMITTING":return gt({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return gt({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return gt({},e,{values:pr(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return gt({},e,{touched:pr(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return gt({},e,{errors:pr(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":return gt({},e,t.payload);case"SET_FORMIK_STATE":return t.payload(e);case"SUBMIT_ATTEMPT":return gt({},e,{touched:Im(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":return gt({},e,{isSubmitting:!1});case"SUBMIT_SUCCESS":return gt({},e,{isSubmitting:!1});default:return e}}var fr={},Fi={};function ow(e){var t=e.validateOnChange,n=t===void 0?!0:t,r=e.validateOnBlur,a=r===void 0?!0:r,i=e.validateOnMount,s=i===void 0?!1:i,l=e.isInitialValid,c=e.enableReinitialize,u=c===void 0?!1:c,d=e.onSubmit,p=Pm(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),f=gt({validateOnChange:n,validateOnBlur:a,validateOnMount:s,onSubmit:d},p),b=U.useRef(f.initialValues),x=U.useRef(f.initialErrors||fr),y=U.useRef(f.initialTouched||Fi),v=U.useRef(f.initialStatus),C=U.useRef(!1),N=U.useRef({});process.env.NODE_ENV!=="production"&&U.useEffect(function(){typeof l>"u"||(process.env.NODE_ENV!=="production"?Qr(!1,"isInitialValid has been deprecated and will be removed in future versions of Formik. Please use initialErrors or validateOnMount instead."):Qr())},[]),U.useEffect(function(){return C.current=!0,function(){C.current=!1}},[]);var w=U.useState(0),I=w[1],h=U.useRef({values:Di(f.initialValues),errors:Di(f.initialErrors)||fr,touched:Di(f.initialTouched)||Fi,status:Di(f.initialStatus),isSubmitting:!1,isValidating:!1,submitCount:0}),T=h.current,R=U.useCallback(function(j){var ee=h.current;h.current=rw(ee,j),ee!==h.current&&I(function(re){return re+1})},[]),V=U.useCallback(function(j,ee){return new Promise(function(re,me){var Te=f.validate(j,ee);Te==null?re(fr):ec(Te)?Te.then(function(Ie){re(Ie||fr)},function(Ie){process.env.NODE_ENV!=="production"&&console.warn("Warning: An unhandled error was caught during validation in <Formik validate />",Ie),me(Ie)}):re(Te)})},[f.validate]),$=U.useCallback(function(j,ee){var re=f.validationSchema,me=rn(re)?re(ee):re,Te=ee&&me.validateAt?me.validateAt(ee,j):iw(j,me);return new Promise(function(Ie,be){Te.then(function(){Ie(fr)},function(le){le.name==="ValidationError"?Ie(aw(le)):(process.env.NODE_ENV!=="production"&&console.warn("Warning: An unhandled error was caught during validation in <Formik validationSchema />",le),be(le))})})},[f.validationSchema]),_=U.useCallback(function(j,ee){return new Promise(function(re){return re(N.current[j].validate(ee))})},[]),P=U.useCallback(function(j){var ee=Object.keys(N.current).filter(function(me){return rn(N.current[me].validate)}),re=ee.length>0?ee.map(function(me){return _(me,zt(j,me))}):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(re).then(function(me){return me.reduce(function(Te,Ie,be){return Ie==="DO_NOT_DELETE_YOU_WILL_BE_FIRED"||Ie&&(Te=pr(Te,ee[be],Ie)),Te},{})})},[_]),g=U.useCallback(function(j){return Promise.all([P(j),f.validationSchema?$(j):{},f.validate?V(j):{}]).then(function(ee){var re=ee[0],me=ee[1],Te=ee[2],Ie=kl.all([re,me,Te],{arrayMerge:sw});return Ie})},[f.validate,f.validationSchema,P,V,$]),O=tn(function(j){return j===void 0&&(j=T.values),R({type:"SET_ISVALIDATING",payload:!0}),g(j).then(function(ee){return C.current&&(R({type:"SET_ISVALIDATING",payload:!1}),R({type:"SET_ERRORS",payload:ee})),ee})});U.useEffect(function(){s&&C.current===!0&&dr(b.current,f.initialValues)&&O(b.current)},[s,O]);var A=U.useCallback(function(j){var ee=j&&j.values?j.values:b.current,re=j&&j.errors?j.errors:x.current?x.current:f.initialErrors||{},me=j&&j.touched?j.touched:y.current?y.current:f.initialTouched||{},Te=j&&j.status?j.status:v.current?v.current:f.initialStatus;b.current=ee,x.current=re,y.current=me,v.current=Te;var Ie=function(){R({type:"RESET_FORM",payload:{isSubmitting:!!j&&!!j.isSubmitting,errors:re,touched:me,status:Te,values:ee,isValidating:!!j&&!!j.isValidating,submitCount:j&&j.submitCount&&typeof j.submitCount=="number"?j.submitCount:0}})};if(f.onReset){var be=f.onReset(T.values,Ee);ec(be)?be.then(Ie):Ie()}else Ie()},[f.initialErrors,f.initialStatus,f.initialTouched,f.onReset]);U.useEffect(function(){C.current===!0&&!dr(b.current,f.initialValues)&&u&&(b.current=f.initialValues,A(),s&&O(b.current))},[u,f.initialValues,A,s,O]),U.useEffect(function(){u&&C.current===!0&&!dr(x.current,f.initialErrors)&&(x.current=f.initialErrors||fr,R({type:"SET_ERRORS",payload:f.initialErrors||fr}))},[u,f.initialErrors]),U.useEffect(function(){u&&C.current===!0&&!dr(y.current,f.initialTouched)&&(y.current=f.initialTouched||Fi,R({type:"SET_TOUCHED",payload:f.initialTouched||Fi}))},[u,f.initialTouched]),U.useEffect(function(){u&&C.current===!0&&!dr(v.current,f.initialStatus)&&(v.current=f.initialStatus,R({type:"SET_STATUS",payload:f.initialStatus}))},[u,f.initialStatus,f.initialTouched]);var L=tn(function(j){if(N.current[j]&&rn(N.current[j].validate)){var ee=zt(T.values,j),re=N.current[j].validate(ee);return ec(re)?(R({type:"SET_ISVALIDATING",payload:!0}),re.then(function(me){return me}).then(function(me){R({type:"SET_FIELD_ERROR",payload:{field:j,value:me}}),R({type:"SET_ISVALIDATING",payload:!1})})):(R({type:"SET_FIELD_ERROR",payload:{field:j,value:re}}),Promise.resolve(re))}else if(f.validationSchema)return R({type:"SET_ISVALIDATING",payload:!0}),$(T.values,j).then(function(me){return me}).then(function(me){R({type:"SET_FIELD_ERROR",payload:{field:j,value:zt(me,j)}}),R({type:"SET_ISVALIDATING",payload:!1})});return Promise.resolve()}),B=U.useCallback(function(j,ee){var re=ee.validate;N.current[j]={validate:re}},[]),z=U.useCallback(function(j){delete N.current[j]},[]),H=tn(function(j,ee){R({type:"SET_TOUCHED",payload:j});var re=ee===void 0?a:ee;return re?O(T.values):Promise.resolve()}),ie=U.useCallback(function(j){R({type:"SET_ERRORS",payload:j})},[]),F=tn(function(j,ee){var re=rn(j)?j(T.values):j;R({type:"SET_VALUES",payload:re});var me=ee===void 0?n:ee;return me?O(re):Promise.resolve()}),J=U.useCallback(function(j,ee){R({type:"SET_FIELD_ERROR",payload:{field:j,value:ee}})},[]),oe=tn(function(j,ee,re){R({type:"SET_FIELD_VALUE",payload:{field:j,value:ee}});var me=re===void 0?n:re;return me?O(pr(T.values,j,ee)):Promise.resolve()}),ae=U.useCallback(function(j,ee){var re=ee,me=j,Te;if(!Ql(j)){j.persist&&j.persist();var Ie=j.target?j.target:j.currentTarget,be=Ie.type,le=Ie.name,Me=Ie.id,rt=Ie.value,ot=Ie.checked,ft=Ie.outerHTML,xe=Ie.options,we=Ie.multiple;re=ee||le||Me,!re&&process.env.NODE_ENV!=="production"&&wm({htmlContent:ft,documentationAnchorLink:"handlechange-e-reactchangeeventany--void",handlerName:"handleChange"}),me=/number|range/.test(be)?(Te=parseFloat(rt),isNaN(Te)?"":Te):/checkbox/.test(be)?cw(zt(T.values,re),ot,rt):xe&&we?lw(xe):rt}re&&oe(re,me)},[oe,T.values]),G=tn(function(j){if(Ql(j))return function(ee){return ae(ee,j)};ae(j)}),ne=tn(function(j,ee,re){ee===void 0&&(ee=!0),R({type:"SET_FIELD_TOUCHED",payload:{field:j,value:ee}});var me=re===void 0?a:re;return me?O(T.values):Promise.resolve()}),ce=U.useCallback(function(j,ee){j.persist&&j.persist();var re=j.target,me=re.name,Te=re.id,Ie=re.outerHTML,be=ee||me||Te;!be&&process.env.NODE_ENV!=="production"&&wm({htmlContent:Ie,documentationAnchorLink:"handleblur-e-any--void",handlerName:"handleBlur"}),ne(be,!0)},[ne]),te=tn(function(j){if(Ql(j))return function(ee){return ce(ee,j)};ce(j)}),W=U.useCallback(function(j){rn(j)?R({type:"SET_FORMIK_STATE",payload:j}):R({type:"SET_FORMIK_STATE",payload:function(){return j}})},[]),Y=U.useCallback(function(j){R({type:"SET_STATUS",payload:j})},[]),ye=U.useCallback(function(j){R({type:"SET_ISSUBMITTING",payload:j})},[]),he=tn(function(){return R({type:"SUBMIT_ATTEMPT"}),O().then(function(j){var ee=j instanceof Error,re=!ee&&Object.keys(j).length===0;if(re){var me;try{if(me=Q(),me===void 0)return}catch(Te){throw Te}return Promise.resolve(me).then(function(Te){return C.current&&R({type:"SUBMIT_SUCCESS"}),Te}).catch(function(Te){if(C.current)throw R({type:"SUBMIT_FAILURE"}),Te})}else if(C.current&&(R({type:"SUBMIT_FAILURE"}),ee))throw j})}),K=tn(function(j){if(j&&j.preventDefault&&rn(j.preventDefault)&&j.preventDefault(),j&&j.stopPropagation&&rn(j.stopPropagation)&&j.stopPropagation(),process.env.NODE_ENV!=="production"&&typeof document<"u"){var ee=nw();ee!==null&&ee instanceof HTMLButtonElement&&(ee.attributes&&ee.attributes.getNamedItem("type")||(process.env.NODE_ENV!=="production"?Qr(!1,'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.'):Qr()))}he().catch(function(re){console.warn("Warning: An unhandled error was caught from submitForm()",re)})}),Ee={resetForm:A,validateForm:O,validateField:L,setErrors:ie,setFieldError:J,setFieldTouched:ne,setFieldValue:oe,setStatus:Y,setSubmitting:ye,setTouched:H,setValues:F,setFormikState:W,submitForm:he},Q=tn(function(){return d(T.values,Ee)}),ve=tn(function(j){j&&j.preventDefault&&rn(j.preventDefault)&&j.preventDefault(),j&&j.stopPropagation&&rn(j.stopPropagation)&&j.stopPropagation(),A()}),pe=U.useCallback(function(j){return{value:zt(T.values,j),error:zt(T.errors,j),touched:!!zt(T.touched,j),initialValue:zt(b.current,j),initialTouched:!!zt(y.current,j),initialError:zt(x.current,j)}},[T.errors,T.touched,T.values]),Je=U.useCallback(function(j){return{setValue:function(re,me){return oe(j,re,me)},setTouched:function(re,me){return ne(j,re,me)},setError:function(re){return J(j,re)}}},[oe,ne,J]),Ce=U.useCallback(function(j){var ee=Li(j),re=ee?j.name:j,me=zt(T.values,re),Te={name:re,value:me,onChange:G,onBlur:te};if(ee){var Ie=j.type,be=j.value,le=j.as,Me=j.multiple;Ie==="checkbox"?be===void 0?Te.checked=!!me:(Te.checked=!!(Array.isArray(me)&&~me.indexOf(be)),Te.value=be):Ie==="radio"?(Te.checked=me===be,Te.value=be):le==="select"&&Me&&(Te.value=Te.value||[],Te.multiple=!0)}return Te},[te,G,T.values]),De=U.useMemo(function(){return!dr(b.current,T.values)},[b.current,T.values]),Be=U.useMemo(function(){return typeof l<"u"?De?T.errors&&Object.keys(T.errors).length===0:l!==!1&&rn(l)?l(f):l:T.errors&&Object.keys(T.errors).length===0},[l,De,T.errors,f]),Ae=gt({},T,{initialValues:b.current,initialErrors:x.current,initialTouched:y.current,initialStatus:v.current,handleBlur:te,handleChange:G,handleReset:ve,handleSubmit:K,resetForm:A,setErrors:ie,setFormikState:W,setFieldTouched:ne,setFieldValue:oe,setFieldError:J,setStatus:Y,setSubmitting:ye,setTouched:H,setValues:F,submitForm:he,validateForm:O,validateField:L,isValid:Be,dirty:De,unregisterField:z,registerField:B,getFieldProps:Ce,getFieldMeta:pe,getFieldHelpers:Je,validateOnBlur:a,validateOnChange:n,validateOnMount:s});return Ae}function wm(e){var t=e.htmlContent,n=e.documentationAnchorLink,r=e.handlerName;console.warn("Warning: Formik called `"+r+"`, but you forgot to pass an `id` or `name` attribute to your input:\n "+t+`
204
204
  Formik cannot determine which value to update. For more info see https://formik.org/docs/api/formik#`+n+`
205
- `)}function aw(e){var t={};if(e.inner){if(e.inner.length===0)return pr(t,e.path,e.message);for(var a=e.inner,n=Array.isArray(a),r=0,a=n?a:a[Symbol.iterator]();;){var i;if(n){if(r>=a.length)break;i=a[r++]}else{if(r=a.next(),r.done)break;i=r.value}var s=i;zt(t,s.path)||(t=pr(t,s.path,s.message))}}return t}function iw(e,t,n,r){n===void 0&&(n=!1);var a=tc(e);return t[n?"validateSync":"validate"](a,{abortEarly:!1,context:a})}function tc(e){var t=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=String(n);Array.isArray(e[r])===!0?t[r]=e[r].map(function(a){return Array.isArray(a)===!0||Nf(a)?tc(a):a!==""?a:void 0}):Nf(e[r])?t[r]=tc(e[r]):t[r]=e[r]!==""?e[r]:void 0}return t}function sw(e,t,n){var r=e.slice();return t.forEach(function(i,s){if(typeof r[s]>"u"){var l=n.clone!==!1,c=l&&n.isMergeableObject(i);r[s]=c?kl(Array.isArray(i)?[]:{},i,n):i}else n.isMergeableObject(i)?r[s]=kl(e[s],i,n):e.indexOf(i)===-1&&r.push(i)}),r}function lw(e){return Array.from(e).filter(function(t){return t.selected}).map(function(t){return t.value})}function cw(e,t,n){if(typeof e=="boolean")return!!t;var r=[],a=!1,i=-1;if(Array.isArray(e))r=e,i=e.indexOf(n),a=i>=0;else if(!n||n=="true"||n=="false")return!!t;return t&&n&&!a?r.concat(n):a?r.slice(0,i).concat(r.slice(i+1)):r}var uw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?U.useLayoutEffect:U.useEffect;function tn(e){var t=U.useRef(e);return uw(function(){t.current=e}),U.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current.apply(void 0,r)},[])}var dw=U.forwardRef(function(e,t){var n=e.action,r=Pm(e,["action"]),a=n??"#",i=ew(),s=i.handleReset,l=i.handleSubmit;return U.createElement("form",gt({onSubmit:l,ref:t,onReset:s,action:a},r))});dw.displayName="Form";function pw(e){const t={method:"POST",headers:{"Content-Type":"application/json"}};return typeof e=="string"?{...t,body:e}:{...t,body:JSON.stringify(e)}}async function fw(e){return e.status===200?await e.json():e}async function mw(e,t,n,r,a,i){const s=new URL(`${e}/api/ecommerce/checkout/${t}/${n}`);s.searchParams.set("payment_provider",a),i!==void 0&&s.searchParams.set("invoice_id",i);const l=await fetch(s,pw(r));return await fw(l)}async function hw(e,t,n){if(n&&console.log("Creating order"),e.order&&e.order.id&&e.order.reference){const l=await(await fetch(`${t}/api/ecommerce/orders/${e.order.id}/reference/${e.order.reference}`)).json(),c=new URL(window.location.href);return c.searchParams.set("orderId",l.id),c.searchParams.set("orderRef",l.reference),window.history.pushState({},"",c),l}const a=await(await fetch(t+"/api/ecommerce/orders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({customer_id:1,cart_data:{items:e.items.map(s=>({...s,name:void 0,image:void 0}))}})})).json();if(!a)throw"Missing order";Fp({id:a.id,reference:a.reference});const i=new URL(window.location.href);return i.searchParams.set("orderId",a.id),i.searchParams.set("orderRef",a.reference),window.history.pushState({},"",i),a}async function gw(e,t,n,r,a,i){i&&console.log("Getting tax");const s=n.filter(c=>c.unit_amount>0&&a[c.product_id].type!=="DONATION");return i&&console.log("Taxable items",s),s.length===0?{tax_amount:0}:await(await fetch(`${e}/api/ecommerce/tax?tax_provider=${t??"dummy"}`,{method:"POST",body:JSON.stringify({cart_data:s,address:{country:r.country,city:r.locality,line1:r.street_address,postal_code:r.postal_code,state:r.region}}),headers:{"Content-Type":"application/json"}})).json()}function Rm({subtotal:e,discount:t,taxState:n,shipping:r,statusState:a,cart:i,prices:s,products:l,apiBaseUrl:c,orderState:u,disableProductLink:d,disableMissingImage:p,taxProvider:f,setSuccessData:b,invoiceId:x=void 0,onPlacement:y=void 0,CollectExtraInfo:v=void 0,defaultValues:C={},dev:N}){N&&console.log({products:l,prices:s});const[w,I]=U.useState(!0),[h,T]=U.useState(void 0),R=Eo(),V=uy(R.breakpoints.down("lg")),[$,_]=a,[P,g]=n,[O,A]=u;async function L(te){T(void 0),I(!0),Promise.all([hw(i,c,N),gw(c,f,i.items.map(W=>({amount:s[W.price_id].unit_amount,reference:W.name})),te,l,N)]).then(([W,Y])=>{g(Y),A(W),_(1),I(!1)}).catch(()=>{T(!0),I(!1)})}async function B(te){N&&console.log("Confirm order"),T(void 0),I(!0),mw(c,O.id,O.reference,te,"stripe",x).then(W=>{if(N&&console.log("Checkout submitted"),W instanceof Response)T(!0),N&&alert(W.statusText);else{b(W),y&&y();const Y=new URL(window.location.href);Y.searchParams.set("showReceipt","1"),Y.searchParams.set("orderId",O.id),Y.searchParams.set("orderRef",O.reference),N&&console.log("Checkout success!"),window.history.pushState({},"",Y)}I(!1)}).catch(W=>{N&&console.log("Checkout error",W),T(!0),I(!1)})}const z=typeof e=="string"||e>0,H={cvc:"",expiry:"",focus:"number",name:"",number:""},ie="US",F={country:ie,email:"",region:"",line1:"",line2:"",organization:"",city:"",postal_code:vi(ie)},J={...H,...F,...C},oe={expiry:yn().test("exp-date","Expiry date has already passed.",te=>{if((te==null?void 0:te.length)===5){if(te.indexOf("/")!==2)return!1;const[W,Y]=iC(te);return sC(W,Y)}else return!0}).required("Expiry date is required."),number:yn().required("Card Number is required."),name:yn().required("Cardholder Name is required."),cvc:yn().required("CVC is required.")},ae={country:yn().required("Country is required."),email:yn().email().required("Email is required."),line1:yn().required("Street Address 1 is required."),city:yn().required("City is required."),postal_code:yn().required("Postal Code is required.")},G=ow({initialValues:J,validationSchema:Of(z?{...oe,...ae}:{}),onSubmit:async(te,W)=>{N&&console.log("Formik submit");const Y={...te},ye=$===0?L:B;ye?(Y.street_address=Y.line2?`${Y.line1}
205
+ `)}function aw(e){var t={};if(e.inner){if(e.inner.length===0)return pr(t,e.path,e.message);for(var a=e.inner,n=Array.isArray(a),r=0,a=n?a:a[Symbol.iterator]();;){var i;if(n){if(r>=a.length)break;i=a[r++]}else{if(r=a.next(),r.done)break;i=r.value}var s=i;zt(t,s.path)||(t=pr(t,s.path,s.message))}}return t}function iw(e,t,n,r){n===void 0&&(n=!1);var a=tc(e);return t[n?"validateSync":"validate"](a,{abortEarly:!1,context:a})}function tc(e){var t=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=String(n);Array.isArray(e[r])===!0?t[r]=e[r].map(function(a){return Array.isArray(a)===!0||Nf(a)?tc(a):a!==""?a:void 0}):Nf(e[r])?t[r]=tc(e[r]):t[r]=e[r]!==""?e[r]:void 0}return t}function sw(e,t,n){var r=e.slice();return t.forEach(function(i,s){if(typeof r[s]>"u"){var l=n.clone!==!1,c=l&&n.isMergeableObject(i);r[s]=c?kl(Array.isArray(i)?[]:{},i,n):i}else n.isMergeableObject(i)?r[s]=kl(e[s],i,n):e.indexOf(i)===-1&&r.push(i)}),r}function lw(e){return Array.from(e).filter(function(t){return t.selected}).map(function(t){return t.value})}function cw(e,t,n){if(typeof e=="boolean")return!!t;var r=[],a=!1,i=-1;if(Array.isArray(e))r=e,i=e.indexOf(n),a=i>=0;else if(!n||n=="true"||n=="false")return!!t;return t&&n&&!a?r.concat(n):a?r.slice(0,i).concat(r.slice(i+1)):r}var uw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?U.useLayoutEffect:U.useEffect;function tn(e){var t=U.useRef(e);return uw(function(){t.current=e}),U.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current.apply(void 0,r)},[])}var dw=U.forwardRef(function(e,t){var n=e.action,r=Pm(e,["action"]),a=n??"#",i=ew(),s=i.handleReset,l=i.handleSubmit;return U.createElement("form",gt({onSubmit:l,ref:t,onReset:s,action:a},r))});dw.displayName="Form";function pw(e){const t={method:"POST",headers:{"Content-Type":"application/json"}};return typeof e=="string"?{...t,body:e}:{...t,body:JSON.stringify(e)}}async function fw(e){return e.status===200?await e.json():e}async function mw(e,t,n,r,a,i){const s=new URL(`${e}/api/ecommerce/checkout/${t}/${n}`);s.searchParams.set("payment_provider",a),i!==void 0&&s.searchParams.set("invoice_id",i);const l=await fetch(s,pw(r));return await fw(l)}async function hw(e,t,n){if(n&&console.log("Creating order"),e.order&&e.order.id&&e.order.reference){const l=await(await fetch(`${t}/api/ecommerce/orders/${e.order.id}/reference/${e.order.reference}`)).json(),c=new URL(window.location.href);return c.searchParams.set("orderId",l.id),c.searchParams.set("orderRef",l.reference),window.history.pushState({},"",c),l}const a=await(await fetch(t+"/api/ecommerce/orders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({customer_id:1,cart_data:{items:e.items.map(s=>({...s,name:void 0,image:void 0}))}})})).json();if(!a)throw"Missing order";Fp({id:a.id,reference:a.reference});const i=new URL(window.location.href);return i.searchParams.set("orderId",a.id),i.searchParams.set("orderRef",a.reference),window.history.pushState({},"",i),a}async function gw(e,t,n,r,a,i){i&&console.log("Getting tax",n),i&&console.log("Getting product data",a,a[n[0].product_id]);const s=n.filter(c=>c.unit_amount>0&&a[c.product_id].type!="DONATION");return i&&console.log("Taxable items",s),s.length===0?{tax_amount:0}:await(await fetch(`${e}/api/ecommerce/tax?tax_provider=${t??"dummy"}`,{method:"POST",body:JSON.stringify({cart_data:s.map(c=>({amount:c.unit_amount,reference:c.reference})),address:{country:r.country,city:r.locality,line1:r.street_address,postal_code:r.postal_code,state:r.region}}),headers:{"Content-Type":"application/json"}})).json()}function Rm({subtotal:e,discount:t,taxState:n,shipping:r,statusState:a,cart:i,prices:s,products:l,apiBaseUrl:c,orderState:u,disableProductLink:d,disableMissingImage:p,taxProvider:f,setSuccessData:b,invoiceId:x=void 0,onPlacement:y=void 0,CollectExtraInfo:v=void 0,defaultValues:C={},dev:N}){N&&console.log({products:l,prices:s});const[w,I]=U.useState(!0),[h,T]=U.useState(void 0),R=Eo(),V=uy(R.breakpoints.down("lg")),[$,_]=a,[P,g]=n,[O,A]=u;async function L(te){T(void 0),I(!0),N&&console.log("Cart items",i.items),Promise.all([hw(i,c,N),gw(c,f,i.items.map(W=>({unit_amount:s[W.price_id].unit_amount,reference:W.name,product_id:W.product_id})),te,l,N)]).then(([W,Y])=>{g(Y),A(W),_(1),I(!1)}).catch(W=>{N&&console.log("Submit error",W),T(!0),I(!1)})}async function B(te){N&&console.log("Confirm order"),T(void 0),I(!0),mw(c,O.id,O.reference,te,"stripe",x).then(W=>{if(N&&console.log("Checkout submitted"),W instanceof Response)T(!0),N&&alert(W.statusText);else{b(W),y&&y();const Y=new URL(window.location.href);Y.searchParams.set("showReceipt","1"),Y.searchParams.set("orderId",O.id),Y.searchParams.set("orderRef",O.reference),N&&console.log("Checkout success!"),window.history.pushState({},"",Y)}I(!1)}).catch(W=>{N&&console.log("Checkout error",W),T(!0),I(!1)})}const z=typeof e=="string"||e>0,H={cvc:"",expiry:"",focus:"number",name:"",number:""},ie="US",F={country:ie,email:"",region:"",line1:"",line2:"",organization:"",city:"",postal_code:vi(ie)},J={...H,...F,...C},oe={expiry:yn().test("exp-date","Expiry date has already passed.",te=>{if((te==null?void 0:te.length)===5){if(te.indexOf("/")!==2)return!1;const[W,Y]=iC(te);return sC(W,Y)}else return!0}).required("Expiry date is required."),number:yn().required("Card Number is required."),name:yn().required("Cardholder Name is required."),cvc:yn().required("CVC is required.")},ae={country:yn().required("Country is required."),email:yn().email().required("Email is required."),line1:yn().required("Street Address 1 is required."),city:yn().required("City is required."),postal_code:yn().required("Postal Code is required.")},G=ow({initialValues:J,validationSchema:Of(z?{...oe,...ae}:{}),onSubmit:async(te,W)=>{N&&console.log("Formik submit");const Y={...te},ye=$===0?L:B;ye?(Y.street_address=Y.line2?`${Y.line1}
206
206
  ${Y.line2}`:Y.line1,Y.locality=Y.city,delete Y.line1,delete Y.line2,delete Y.city,Object.keys(bi).includes(Y.country)&&(Y.country=bi[Y.country]),Y.card_number=Y.number,Y.expiry_date=Y.expiry,delete Y.focus,delete Y.expiry,delete Y.number,ye(Y).then(he=>{}).catch(he=>{N&&console.log("Submit errors",he)})):I(!1)}}),ne=te=>{const W=te.target.getAttribute("name");W&&G.setValues({...G.values,focus:W})},ce=te=>{te.target.name==="card_number"?te.target.value=rC(te.target.value):te.target.name==="expiry"?te.target.value=aC(te.target.value):te.target.name==="cvc"&&(te.target.value=oC(te.target.value)),G.handleChange(te)};return U.useEffect(()=>{N&&(Object.keys(G.errors).length>0?console.log("Formik errors",G.errors):console.log("No formik errors")),I(Object.keys(G.errors).length>0)},[G.errors]),m.jsxs(Ye,{sx:{mt:2,display:"flex",flexDirection:{xs:"column",xl:"row"},justifyContent:"center",alignItems:{xs:void 0,xl:"flex-start"},px:{xs:32,xl:16},"&>div":{width:{xs:void 0,xl:"50%"}}},children:[m.jsx(XO,{statusState:[$,_],cart:i,subtotal:e,tax:P,shipping:r,discount:t,prices:s,products:l,disableMissingImage:p,disableProductLink:d,formik:G,formDisabled:w,formErrorState:[h,T]}),$===0&&m.jsxs(Ye,{sx:{flexGrow:1,display:"flex",flexDirection:"column",gap:2},children:[v&&m.jsx(v,{formik:G}),m.jsx(yw,{formik:G,prices:s,products:l}),m.jsx(Zp,{cardRequired:z,onSubmit:L,stacked:V,formData:{formik:G,handleInputChange:ce,handleInputFocus:ne,formDisabled:w,formError:h}})]})]})}function yw({formik:e,products:t,prices:n}){const r=[...Object.keys(t).flatMap(s=>(t[s].actions??[]).flatMap(l=>l.checkout_fields??[])),...Object.keys(n).flatMap(s=>(n[s].actions??[]).flatMap(l=>l.checkout_fields??[]))].reduce((s,l)=>({...s,[l.name]:l}),{}),a=s=>{const l=s.target.getAttribute("name");l&&e.setValues({...e.values,focus:l})},i=s=>{e.handleChange(s)};return m.jsx(Ye,{sx:{display:"flex",flexDirection:"column",mx:3,gap:2},children:Object.keys(r).map(s=>{const{name:l,label:c,type:u="string",required:d=!0}=r[s];return m.jsx(wt,{fullWidth:!0,name:l,label:c,required:d===!0||d==="true",onBlur:e.handleBlur,onChange:i,onFocus:a,variant:"outlined",value:e.values[l],error:!!(e.touched[l]&&e.errors[l]),helperText:e.touched[l]&&e.errors[l]})})})}var nc={},bw=Nr;Object.defineProperty(nc,"__esModule",{value:!0});var Nm=nc.default=void 0,vw=bw(ui()),xw=m;Nm=nc.default=(0,vw.default)((0,xw.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack");function Sw({status:e,backlink:t=""}){return m.jsxs(Ye,{style:{display:"flex",justifyContent:"center",flexDirection:"row"},children:[m.jsx(Ye,{sx:{flex:"1 1"},children:m.jsx(Vo,{title:"Exit checkout",children:m.jsx(kn,{href:`/${t}`,children:m.jsx(Nm,{})})})}),m.jsxs("div",{id:"status-bar",children:[m.jsx(Ze,{className:"status-text active",children:"PAYMENT DETAILS"}),m.jsx("div",{className:"status-bar"+(e>0?" active":"")}),m.jsx(Ze,{className:"status-text"+(e>0?" active":""),children:"CONFIRMATION"}),m.jsx("div",{className:"status-bar"+(e>1?" active":"")}),m.jsx(Ze,{className:"status-text"+(e>1?" active":""),children:"ORDER PLACED"})]}),m.jsx(Ye,{sx:{flex:"1 1"}})]})}function Ew({apiBaseUrl:e,taxProvider:t,emptyCartLink:n="",disableProductLink:r=!1,disableMissingImage:a=!1,CollectExtraInfo:i,defaultValues:s,dev:l}){const c=ul(ut),u=U.useMemo(()=>JSON.parse(c),[c]),[d,p]=U.useState({}),[f,b]=U.useState({}),[x,y]=U.useState("Loading prices..."),v=U.useState({tax_amount:"TBD"}),C=0,N=0,[w,I]=U.useState(0),[h,T]=U.useState(void 0),[R,V]=U.useState(null);return U.useEffect(()=>{const $=new URLSearchParams(window.location.search);$.get("showReceipt");const _=$.get("orderId"),P=$.get("orderRef");_&&P&&fetch(`${e}/api/ecommerce/orders/${_}/reference/${P}`).then(async g=>await g.json().then(O=>{T(O),I(O.charge_id||!["pending","awaiting_payment"].includes(O.status)?2:0)}))},[]),U.useEffect(()=>{const $=u.items.map(A=>A.price_id).filter(A=>Object.keys(d).findIndex(L=>L==A)===-1),_=u.items.map(A=>A.product_id).filter(A=>Object.keys(d).findIndex(L=>L==A)===-1),P=`${e}/api/ecommerce/price?filter={'ids':[${$.join(",")}]}`,g=`${e}/api/ecommerce/products?filter={'ids':[${_.join(",")}]}`,O={method:"GET",headers:{"Content-Type":"application/json"}};$.length===0&&_.length===0||Promise.all([$.length!==0?fetch(P,O):Promise.resolve(null),_.length!==0?fetch(g,O):Promise.resolve(null)]).then(([A,L])=>{Promise.all([A!=null?A.json():Promise.resolve(null),L!=null?L.json():Promise.resolve(null)]).then(([B,z])=>{if(B!=null){const H=B.reduce((ie,F)=>({...ie,[F.id]:F}),f);b(H)}if(z!=null){const H=z.reduce((ie,F)=>({...ie,[F.id]:F}),d);p(H)}})})},[u]),U.useEffect(()=>{y(u.items.map($=>{var _;return(_=f[$.price_id])==null?void 0:_.unit_amount}).reduce(($,_)=>_?$+_:$,0))},[u,f]),U.useEffect(()=>{u.items.filter(_=>{var P,g;return((P=f[_.price_id])==null?void 0:P.unit_amount)>0&&((g=d[_.product_id])==null?void 0:g.type)!=="DONATION"}).length===0&&v[1]({tax_amount:0})},[u,f,d]),w===0&&u.items.length===0?m.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",flexDirection:"column",gap:8},children:[m.jsx(Ze,{style:{fontSize:32,fontWeight:600},children:"Cart is empty"}),m.jsx("a",{className:"shopping-button",href:`/${n}`,children:m.jsx(Ze,{children:"BACK"})})]}):m.jsxs("div",{children:[m.jsx(Sw,{status:w}),m.jsxs("div",{children:[w<2&&m.jsx(Rm,{subtotal:x,discount:N,shipping:C,taxProvider:t,taxState:v,statusState:[w,I],cart:u,prices:f,products:d,apiBaseUrl:e,orderState:[h,T],disableProductLink:r,disableMissingImage:a,setSuccessData:V,onPlacement:()=>{ml(),I(2)},CollectExtraInfo:i,defaultValues:s,dev:l}),w===2&&h!==void 0&&m.jsx(Xp,{order:h,successData:R})]})]})}Le.AddCard=Zp,Le.AddToCartForm=gO,Le.CartButton=fO,Le.Checkout=Ew,Le.Invoice=Xp,Le.ProductCard=YO,Le.ReviewCartAndCalculateTaxes=Rm,Le.addToCart=fl,Le.cartStore=ut,Le.clearCart=ml,Le.login=dO,Le.logout=pO,Le.removeFromCart=mi,Le.setOrder=Fp,Object.defineProperty(Le,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@springmicro/cart",
3
3
  "private": false,
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@nanostores/persistent": "^0.10.1",
25
25
  "@nanostores/query": "^0.3.3",
26
26
  "@nanostores/react": "^0.7.2",
27
- "@springmicro/utils": "0.6.2",
27
+ "@springmicro/utils": "0.6.3",
28
28
  "dotenv": "^16.4.5",
29
29
  "nanostores": "^0.10.3",
30
30
  "react": "^18.2.0",
@@ -49,5 +49,5 @@
49
49
  "vite-plugin-css-injected-by-js": "^3.5.1",
50
50
  "yup": "^1.4.0"
51
51
  },
52
- "gitHead": "f0aee01ae9b45595f59d70a5fdf9cae8933edb24"
52
+ "gitHead": "019c24a20cf964d4987dd3bcc8672047a0001313"
53
53
  }
Binary file
@@ -73,9 +73,15 @@ async function createOrder(cart, apiBaseUrl, dev) {
73
73
  }
74
74
 
75
75
  async function getTax(apiBaseUrl, taxProvider, items, v, products, dev) {
76
- dev && console.log("Getting tax");
76
+ dev && console.log("Getting tax", items);
77
+ dev &&
78
+ console.log(
79
+ "Getting product data",
80
+ products,
81
+ products[items[0].product_id]
82
+ );
77
83
  const taxable_items = items.filter(
78
- (i) => i.unit_amount > 0 && products[i.product_id].type !== "DONATION"
84
+ (i) => i.unit_amount > 0 && products[i.product_id].type != "DONATION"
79
85
  );
80
86
  dev && console.log("Taxable items", taxable_items);
81
87
  if (taxable_items.length === 0) return { tax_amount: 0 };
@@ -85,7 +91,10 @@ async function getTax(apiBaseUrl, taxProvider, items, v, products, dev) {
85
91
  {
86
92
  method: "POST",
87
93
  body: JSON.stringify({
88
- cart_data: taxable_items,
94
+ cart_data: taxable_items.map((i) => ({
95
+ amount: i.unit_amount,
96
+ reference: i.reference,
97
+ })),
89
98
  address: {
90
99
  country: v.country,
91
100
  city: v.locality,
@@ -138,14 +147,16 @@ export default function ReviewAndCalculateTaxes({
138
147
  setFormDisabled(true);
139
148
  // status === 0 when this is clicked.
140
149
  // Creates an order and calculates tax.
150
+ dev && console.log("Cart items", cart.items);
141
151
  Promise.all([
142
152
  createOrder(cart, apiBaseUrl, dev),
143
153
  getTax(
144
154
  apiBaseUrl,
145
155
  taxProvider,
146
156
  cart.items.map((i) => ({
147
- amount: prices[i.price_id].unit_amount,
157
+ unit_amount: prices[i.price_id].unit_amount,
148
158
  reference: i.name,
159
+ product_id: i.product_id,
149
160
  })),
150
161
  values,
151
162
  products,
@@ -158,7 +169,8 @@ export default function ReviewAndCalculateTaxes({
158
169
  setStatus(1);
159
170
  setFormDisabled(false);
160
171
  })
161
- .catch(() => {
172
+ .catch((e) => {
173
+ dev && console.log("Submit error", e);
162
174
  setFormError(true);
163
175
  setFormDisabled(false);
164
176
  });