"use strict";(globalThis.webpackChunkwp_graphql=globalThis.webpackChunkwp_graphql||[]).push([[253],{7437:(e,t,n)=>{function i(e,t){const n=[];let i=e;for(;null==i?void 0:i.kind;)n.push(i),i=i.prevState;for(let e=n.length-1;e>=0;e--)t(n[e])}n.d(t,{f:()=>i}),(0,Object.defineProperty)(i,"name",{value:"forEachState",configurable:!0})},9253:(e,t,n)=>{n.r(t);var i=n(3338),r=n(5549),l=n(7437),o=(n(166),n(1609),n(5795),Object.defineProperty),a=(e,t)=>o(e,"name",{value:t,configurable:!0});function s(e,t,n){const i=p(n,u(t.string));if(!i)return;const r=null!==t.type&&/"|\w/.test(t.string[0])?t.start:t.end;return{list:i,from:{line:e.line,ch:r},to:{line:e.line,ch:t.end}}}function p(e,t){return t?c(c(e.map((e=>({proximity:f(u(e.text),t),entry:e}))),(e=>e.proximity<=2)),(e=>!e.entry.isDeprecated)).sort(((e,t)=>(e.entry.isDeprecated?1:0)-(t.entry.isDeprecated?1:0)||e.proximity-t.proximity||e.entry.text.length-t.entry.text.length)).map((e=>e.entry)):c(e,(e=>!e.isDeprecated))}function c(e,t){const n=e.filter(t);return 0===n.length?e:n}function u(e){return e.toLowerCase().replace(/\W/g,"")}function f(e,t){let n=d(t,e);return e.length>t.length&&(n-=e.length-t.length-1,n+=0===e.indexOf(t)?0:.5),n}function d(e,t){let n,i;const r=[],l=e.length,o=t.length;for(n=0;n<=l;n++)r[n]=[n];for(i=1;i<=o;i++)r[0][i]=i;for(n=1;n<=l;n++)for(i=1;i<=o;i++){const l=e[n-1]===t[i-1]?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+l),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(r[n][i]=Math.min(r[n][i],r[n-2][i-2]+l))}return r[l][o]}function y(e,t,n){const i="Invalid"===t.state.kind?t.state.prevState:t.state,l=i.kind,o=i.step;if("Document"===l&&0===o)return s(e,t,[{text:"{"}]);const a=n.variableToType;if(!a)return;const p=h(a,t.state);if("Document"===l||"Variable"===l&&0===o)return s(e,t,Object.keys(a).map((e=>({text:`"${e}": `,type:a[e]}))));if(("ObjectValue"===l||"ObjectField"===l&&0===o)&&p.fields)return s(e,t,Object.keys(p.fields).map((e=>p.fields[e])).map((e=>({text:`"${e.name}": `,type:e.type,description:e.description}))));if("StringValue"===l||"NumberValue"===l||"BooleanValue"===l||"NullValue"===l||"ListValue"===l&&1===o||"ObjectField"===l&&2===o||"Variable"===l&&2===o){const n=p.type?(0,r.getNamedType)(p.type):void 0;if(n instanceof r.GraphQLInputObjectType)return s(e,t,[{text:"{"}]);if(n instanceof r.GraphQLEnumType)return s(e,t,n.getValues().map((e=>({text:`"${e.name}"`,type:n,description:e.description}))));if(n===r.GraphQLBoolean)return s(e,t,[{text:"true",type:r.GraphQLBoolean,description:"Not false."},{text:"false",type:r.GraphQLBoolean,description:"Not true."}])}}function h(e,t){const n={type:null,fields:null};return(0,l.f)(t,(t=>{if("Variable"===t.kind)n.type=e[t.name];else if("ListValue"===t.kind){const e=n.type?(0,r.getNullableType)(n.type):void 0;n.type=e instanceof r.GraphQLList?e.ofType:null}else if("ObjectValue"===t.kind){const e=n.type?(0,r.getNamedType)(n.type):void 0;n.fields=e instanceof r.GraphQLInputObjectType?e.getFields():null}else if("ObjectField"===t.kind){const e=t.name&&n.fields?n.fields[t.name]:null;n.type=null==e?void 0:e.type}})),n}a(s,"hintList"),a(p,"filterAndSortList"),a(c,"filterNonEmpty"),a(u,"normalizeText"),a(f,"getProximity"),a(d,"lexicalDistance"),i.C.registerHelper("hint","graphql-variables",((e,t)=>{const n=e.getCursor(),r=e.getTokenAt(n),l=y(n,r,t);return(null==l?void 0:l.list)&&l.list.length>0&&(l.from=i.C.Pos(l.from.line,l.from.ch),l.to=i.C.Pos(l.to.line,l.to.ch),i.C.signal(e,"hasCompletion",e,l,r)),l})),a(y,"getVariablesHint"),a(h,"getTypeInfo")}}]);