import{a as e}from"./chunk-D9Tnb9aB.js";import{t}from"./codemirror-DtW92bSi.js";import{a as n,i as r,n as i,s as a,t as o}from"./definition-C7QrKMH2.js";var s=e(t());function c(e){l=e,u=e.length,d=f=p=-1,T(),E();let t=g();return x(`EOF`),t}var l,u,d,f,p,m,h;function g(){let e=d,t=[];if(x(`{`),!w(`}`)){do t.push(_());while(w(`,`));x(`}`)}return{kind:`Object`,start:e,end:p,members:t}}function _(){let e=d,t=h===`String`?b():null;x(`String`),x(`:`);let n=y();return{kind:`Member`,start:e,end:p,key:t,value:n}}function v(){let e=d,t=[];if(x(`[`),!w(`]`)){do t.push(y());while(w(`,`));x(`]`)}return{kind:`Array`,start:e,end:p,values:t}}function y(){switch(h){case`[`:return v();case`{`:return g();case`String`:case`Number`:case`Boolean`:case`Null`:let e=b();return E(),e}x(`Value`)}function b(){return{kind:h,start:d,end:f,value:JSON.parse(l.slice(d,f))}}function x(e){if(h===e){E();return}let t;if(h===`EOF`)t=`[end of file]`;else if(f-d>1)t="`"+l.slice(d,f)+"`";else{let e=l.slice(d).match(/^.+?\b/);t="`"+(e?e[0]:l[d])+"`"}throw C(`Expected ${e} but found ${t}.`)}var S=class extends Error{constructor(e,t){super(e),this.position=t}};function C(e){return new S(e,{start:d,end:f})}function w(e){if(h===e)return E(),!0}function T(){return f<u&&(f++,m=f===u?0:l.charCodeAt(f)),m}function E(){for(p=f;m===9||m===10||m===13||m===32;)T();if(m===0){h=`EOF`;return}switch(d=f,m){case 34:return h=`String`,D();case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return h=`Number`,k();case 102:if(l.slice(d,d+5)!==`false`)break;f+=4,T(),h=`Boolean`;return;case 110:if(l.slice(d,d+4)!==`null`)break;f+=3,T(),h=`Null`;return;case 116:if(l.slice(d,d+4)!==`true`)break;f+=3,T(),h=`Boolean`;return}h=l[d],T()}function D(){for(T();m!==34&&m>31;)if(m===92)switch(m=T(),m){case 34:case 47:case 92:case 98:case 102:case 110:case 114:case 116:T();break;case 117:T(),O(),O(),O(),O();break;default:throw C(`Bad character escape sequence.`)}else if(f===u)throw C(`Unterminated string.`);else T();if(m===34){T();return}throw C(`Unterminated string.`)}function O(){if(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102)return T();throw C(`Expected hexadecimal digit.`)}function k(){m===45&&T(),m===48?T():A(),m===46&&(T(),A()),(m===69||m===101)&&(m=T(),(m===43||m===45)&&T(),A())}function A(){if(m<48||m>57)throw C(`Expected decimal digit.`);do T();while(m>=48&&m<=57)}s.default.registerHelper(`lint`,`graphql-variables`,(e,t,n)=>{if(!e)return[];let r;try{r=c(e)}catch(e){if(e instanceof S)return[N(n,e.position,e.message)];throw e}let{variableToType:i}=t;return i?j(n,i,r):[]});function j(e,t,n){let r=[];for(let i of n.members)if(i){let n=i.key?.value,a=t[n];if(a)for(let[t,n]of M(a,i.value))r.push(N(e,t,n));else r.push(N(e,i.key,`Variable "$${n}" does not appear in any GraphQL query.`))}return r}function M(e,t){if(!e||!t)return[];if(e instanceof n)return t.kind===`Null`?[[t,`Type "${e}" is non-nullable and cannot be null.`]]:M(e.ofType,t);if(t.kind===`Null`)return[];if(e instanceof r){let n=e.ofType;return t.kind===`Array`?F(t.values||[],e=>M(n,e)):M(n,t)}if(e instanceof i){if(t.kind!==`Object`)return[[t,`Type "${e}" must be an Object.`]];let r=Object.create(null),i=F(t.members,t=>{let n=t?.key?.value;r[n]=!0;let i=e.getFields()[n];return i?M(i?i.type:void 0,t.value):[[t.key,`Type "${e}" does not have a field "${n}".`]]});for(let a of Object.keys(e.getFields())){let o=e.getFields()[a];!r[a]&&o.type instanceof n&&!o.defaultValue&&i.push([t,`Object of type "${e}" is missing required field "${a}".`])}return i}return e.name===`Boolean`&&t.kind!==`Boolean`||e.name===`String`&&t.kind!==`String`||e.name===`ID`&&t.kind!==`Number`&&t.kind!==`String`||e.name===`Float`&&t.kind!==`Number`||e.name===`Int`&&(t.kind!==`Number`||(t.value|0)!==t.value)||(e instanceof o||e instanceof a)&&(t.kind!==`String`&&t.kind!==`Number`&&t.kind!==`Boolean`&&t.kind!==`Null`||P(e.parseValue(t.value)))?[[t,`Expected value of type "${e}".`]]:[]}function N(e,t,n){return{message:n,severity:`error`,type:`validation`,from:e.posFromIndex(t.start),to:e.posFromIndex(t.end)}}function P(e){return e==null||e!==e}function F(e,t){return Array.prototype.concat.apply([],e.map(t))}
//# sourceMappingURL=lint-9bjU_Bu8.js.map