"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../../../../../../../../_virtual/utils.js"),B=require("../validators/is.js"),J=require("../validators/validate.js");var L;function M(){if(L)return i.__exports;L=1,Object.defineProperty(i.__exports,"__esModule",{value:!0}),i.__exports.VISITOR_KEYS=i.__exports.NODE_PARENT_VALIDATIONS=i.__exports.NODE_FIELDS=i.__exports.FLIPPED_ALIAS_KEYS=i.__exports.DEPRECATED_KEYS=i.__exports.BUILDER_KEYS=i.__exports.ALIAS_KEYS=void 0,i.__exports.arrayOf=N,i.__exports.arrayOfType=D,i.__exports.assertEach=$,i.__exports.assertNodeOrValueType=V,i.__exports.assertNodeType=O,i.__exports.assertOneOf=k,i.__exports.assertOptionalChainStart=F,i.__exports.assertShape=C,i.__exports.assertValueType=v,i.__exports.chain=g,i.__exports.default=P,i.__exports.defineAliasedType=U,i.__exports.typeIs=y,i.__exports.validate=E,i.__exports.validateArrayOfType=j,i.__exports.validateOptional=Y,i.__exports.validateOptionalType=R,i.__exports.validateType=K;var h=B.__require(),_=J.__require();const S={};i.__exports.VISITOR_KEYS=S;const T={};i.__exports.ALIAS_KEYS=T;const c={};i.__exports.FLIPPED_ALIAS_KEYS=c;const A={};i.__exports.NODE_FIELDS=A;const I={};i.__exports.BUILDER_KEYS=I;const b={};i.__exports.DEPRECATED_KEYS=b;const w={};i.__exports.NODE_PARENT_VALIDATIONS=w;function p(e){return Array.isArray(e)?"array":e===null?"null":typeof e}function E(e){return{validate:e}}function y(e){return typeof e=="string"?O(e):O(...e)}function K(e){return E(y(e))}function Y(e){return{validate:e,optional:!0}}function R(e){return{validate:y(e),optional:!0}}function N(e){return g(v("array"),$(e))}function D(e){return N(y(e))}function j(e){return E(D(e))}function $(e){function t(n,r,o){if(!!Array.isArray(o))for(let s=0;s<o.length;s++){const l=`${r}[${s}]`,a=o[s];e(n,l,a),process.env.BABEL_TYPES_8_BREAKING&&(0,_.validateChild)(n,l,a)}}return t.each=e,t}function k(...e){function t(n,r,o){if(e.indexOf(o)<0)throw new TypeError(`Property ${r} expected value to be one of ${JSON.stringify(e)} but got ${JSON.stringify(o)}`)}return t.oneOf=e,t}function O(...e){function t(n,r,o){for(const s of e)if((0,h.default)(s,o)){(0,_.validateChild)(n,r,o);return}throw new TypeError(`Property ${r} of ${n.type} expected node to be of a type ${JSON.stringify(e)} but instead got ${JSON.stringify(o==null?void 0:o.type)}`)}return t.oneOfNodeTypes=e,t}function V(...e){function t(n,r,o){for(const s of e)if(p(o)===s||(0,h.default)(s,o)){(0,_.validateChild)(n,r,o);return}throw new TypeError(`Property ${r} of ${n.type} expected node to be of a type ${JSON.stringify(e)} but instead got ${JSON.stringify(o==null?void 0:o.type)}`)}return t.oneOfNodeOrValueTypes=e,t}function v(e){function t(n,r,o){if(!(p(o)===e))throw new TypeError(`Property ${r} expected type of ${e} but got ${p(o)}`)}return t.type=e,t}function C(e){function t(n,r,o){const s=[];for(const l of Object.keys(e))try{(0,_.validateField)(n,l,o[l],e[l])}catch(a){if(a instanceof TypeError){s.push(a.message);continue}throw a}if(s.length)throw new TypeError(`Property ${r} of ${n.type} expected to have the following:
${s.join(`
`)}`)}return t.shapeOf=e,t}function F(){function e(t){var n;let r=t;for(;t;){const{type:o}=r;if(o==="OptionalCallExpression"){if(r.optional)return;r=r.callee;continue}if(o==="OptionalMemberExpression"){if(r.optional)return;r=r.object;continue}break}throw new TypeError(`Non-optional ${t.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(n=r)==null?void 0:n.type}`)}return e}function g(...e){function t(...n){for(const r of e)r(...n)}if(t.chainOf=e,e.length>=2&&"type"in e[0]&&e[0].type==="array"&&!("each"in e[1]))throw new Error('An assertValueType("array") validator can only be followed by an assertEach(...) validator.');return t}const m=["aliases","builder","deprecatedAlias","fields","inherits","visitor","validate"],q=["default","optional","validate"];function U(...e){return(t,n={})=>{let r=n.aliases;if(!r){var o,s;n.inherits&&(r=(o=x[n.inherits].aliases)==null?void 0:o.slice()),(s=r)!=null||(r=[]),n.aliases=r}const l=e.filter(a=>!r.includes(a));return r.unshift(...l),P(t,n)}}function P(e,t={}){const n=t.inherits&&x[t.inherits]||{};let r=t.fields;if(!r&&(r={},n.fields)){const a=Object.getOwnPropertyNames(n.fields);for(const f of a){const u=n.fields[f],d=u.default;if(Array.isArray(d)?d.length>0:d&&typeof d=="object")throw new Error("field defaults can only be primitives or empty arrays currently");r[f]={default:Array.isArray(d)?[]:d,optional:u.optional,validate:u.validate}}}const o=t.visitor||n.visitor||[],s=t.aliases||n.aliases||[],l=t.builder||n.builder||t.visitor||[];for(const a of Object.keys(t))if(m.indexOf(a)===-1)throw new Error(`Unknown type option "${a}" on ${e}`);t.deprecatedAlias&&(b[t.deprecatedAlias]=e);for(const a of o.concat(l))r[a]=r[a]||{};for(const a of Object.keys(r)){const f=r[a];f.default!==void 0&&l.indexOf(a)===-1&&(f.optional=!0),f.default===void 0?f.default=null:!f.validate&&f.default!=null&&(f.validate=v(p(f.default)));for(const u of Object.keys(f))if(q.indexOf(u)===-1)throw new Error(`Unknown field key "${u}" on ${e}.${a}`)}S[e]=t.visitor=o,I[e]=t.builder=l,A[e]=t.fields=r,T[e]=t.aliases=s,s.forEach(a=>{c[a]=c[a]||[],c[a].push(e)}),t.validate&&(w[e]=t.validate),x[e]=t}const x={};return i.__exports}exports.__require=M;
//# sourceMappingURL=utils.js.map
