tianta/_server/CodeMirror/tern.min.js
2022-10-17 02:58:52 +13:00

1 line
75 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.tern||(e.tern={})).signal={})}(this,function(e){function t(e,t){var r=this._handlers||(this._handlers=Object.create(null));(r[e]||(r[e]=[])).push(t)}function r(e,t){var r=this._handlers&&this._handlers[e];if(r)for(var n=0;n<r.length;++n)if(r[n]==t){r.splice(n,1);break}}var n=[];function p(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length?r.slice():n}function o(e,t,r,n,o){for(var i=p(this,e),s=0;s<i.length;++s)i[s].call(this,t,r,n,o)}function i(e,t,r,n,o){for(var i=p(this,e),s=0;s<i.length;++s){var a=i[s].call(this,t,r,n,o);if(a)return a}}function s(e){var t=this._handlers&&this._handlers[e];return t&&0<t.length&&t}e.mixin=function(e){return e.on=t,e.off=r,e.signal=o,e.signalReturnFirst=i,e.hasHandler=s,e}}),function(e,t){"object"==typeof exports&&"object"==typeof module?t(exports,require("./infer"),require("./signal"),require("acorn"),require("acorn-walk")):"function"==typeof define&&define.amd?define(["exports","./infer","./signal","acorn/dist/acorn","acorn-walk/dist/walk"],t):t(e.tern||(e.tern={}),tern,tern.signal,acorn,acorn.walk)}(this,function(e,T,t,O,P){"use strict";var o=Object.create(null);e.registerPlugin=function(e,t){o[e]=t};var n=e.defaultOptions={debug:!1,async:!1,getFile:function(e,t){this.async&&t(null,null)},normalizeFilename:function(e){return e},defs:[],plugins:{},fetchTimeout:1e3,dependencyBudget:2e4,reuseInstances:!0,stripCRs:!1,ecmaVersion:9,projectDir:"/",parent:null},u={completions:{takesFile:!0,run:function(i,s,e){if(null==s.end)throw j("missing .query.end field");var t=i.signalReturnFirst("completion",e,s);if(t)return t;var r=N(e,s.end),n=r,o=e.text;for(;r&&O.isIdentifierChar(o.charCodeAt(r-1));)--r;if(!1!==s.expandWordForward)for(;n<o.length&&O.isIdentifierChar(o.charCodeAt(n));)++n;var a,p,u,f,l=o.slice(r,n),c=[];s.caseInsensitive&&(l=l.toLowerCase());function h(e,t,r,n){var o;(!d&&!1===s.omitObjectPrototype||t!=i.cx.protos.Object||l)&&(!1!==s.filter&&l&&0!==(s.caseInsensitive?e.toLowerCase():e).indexOf(l)||a&&a.props[e]||(o=D(s,c,e,t&&t.props[e],r),n&&o&&"string"!=typeof o&&n(o)))}var g,d,y=T.findExpressionAround(e.ast,null,r,e.scope);if(y){var v,m,b=y.node;if(!1===s.inLiteral&&"Literal"===b.type&&("string"==typeof b.value||b.regex))return{start:F(s,e,r),end:F(s,e,n),completions:[]};"MemberExpression"==b.type&&b.object.end<r?g=y:!function(e,t,r){return"Literal"==e.type&&"string"==typeof e.value&&e.start==t-1&&e.end<=r+1}(b,r,n)?"ObjectExpression"==b.type&&((m=C(b,n))?(d=y,P=f=m.key.name||m.key.value):l||/:\s*$/.test(e.text.slice(0,r))||(d=y,P=f=!0)):"MemberExpression"==(v=T.parentNode(b,e.ast)).type&&v.property==b&&(g={node:v,state:y.state})}if(d)u=T.typeFromContext(e.ast,d),a=d.node.objType;else if(g)P="Literal"==(P=g.node.property).type?P.value.slice(1):P.name,g.node=g.node.object,u=T.expressionType(g);else if("."==o.charAt(r-1)){for(var w=r-1;w&&("."==o.charAt(w-1)||O.isIdentifierChar(o.charCodeAt(w-1)));)w--;var x=o.slice(w,r-1);x&&(u=T.def.parsePath(x,e.scope).getObjType(),P=l)}if(null!=P){if(i.cx.completingProperty=P,u&&T.forAllPropertiesOf(u,h),!c.length&&!1!==s.guess&&u&&u.guessProperties&&u.guessProperties(function(e,t,r){e!=P&&"✖"!=e&&"<i>"!=e&&h(e,t,r)}),!c.length&&2<=l.length&&!1!==s.guess)for(var P in i.cx.props)h(P,i.cx.props[P][0],0);p="memberCompletion"}else T.forAllLocalsAt(e.ast,r,e.scope,h),s.includeKeywords&&(6<=i.options.ecmaVersion?I:k).forEach(function(e){h(e,null,0,function(e){e.isKeyword=!0})}),p="variableCompletion";i.signal(p,e,r,n,h),!1!==s.sort&&c.sort(S);return i.cx.completingProperty=null,{start:F(s,e,r),end:F(s,e,n),isProperty:!!P,isObjectKey:!!f,completions:c}}},properties:{run:function(e,t){var r=t.prefix,n=[];for(var o in e.cx.props)"<i>"==o||r&&0!==o.indexOf(r)||n.push(o);!1!==t.sort&&n.sort(S);return{completions:n}}},type:{takesFile:!0,run:function(e,t,r){var n,o,i,s=L(r,t),a=H(e,t,r,s);(n=a[0])||(s=q(r,t),a=H(e,t,r,s),n=a[0]);o=a[1],i=a[2];var p={guess:T.didGuess(),type:T.toString(i,t.depth),name:n&&n.name,exprName:o,doc:i.doc,url:i.url};n&&$(t,n,p);return w(p)}},documentation:{takesFile:!0,run:function(e,t,r){var n=L(r,t),o=V(e,t,r,n),i=o.getType();i||(n=q(r,t),o=V(e,t,r,n),i=o.getType());var s={url:o.url,doc:B(t,o.doc),type:T.toString(o)};i&&$(t,i,s);return w(s)}},definition:{takesFile:!0,run:function(e,t,r){var n=L(r,t),o=V(e,t,r,n);if(T.didGuess())return{};var i=G(o),s={url:o.url,doc:B(t,o.doc),origin:o.origin};if(o.types)for(var a=o.types.length-1;0<=a;--a){var p=o.types[a];$(t,p,s),i=i||G(p)}{var u,f,l,c;i&&i.node?(u=i.node.sourceFile||e.fileMap[i.origin],f=F(t,u,i.node.start),l=F(t,u,i.node.end),s.start=f,s.end=l,s.file=i.origin,c=Math.max(0,i.node.start-50),s.contextOffset=i.node.start-c,s.context=u.text.slice(c,c+50)):i&&(s.file=i.origin,z(e,t,i,s))}return w(s)}},refs:{takesFile:!0,fullFile:!0,run:function(e,t,r){var n=R(r,t,!0);{if(n&&"Identifier"==n.node.type)return W(e,t,r,n);if(n&&"MemberExpression"==n.node.type&&!n.node.computed){var o=n.node.property;return n.node=n.node.object,U(e,t,r,n,o)}if(n&&"ObjectExpression"==n.node.type)for(var i=N(r,t.end),s=0;s<n.node.properties.length;++s){var a=n.node.properties[s].key;if(a.start<=i&&a.end>=i)return U(e,t,r,n,a)}else if(n&&"MethodDefinition"==n.node.type){o=n.node.key;return U(e,t,r,n,o)}}throw j("Not at a variable or property name.")}},rename:{takesFile:!0,fullFile:!0,run:function(e,t,r){if("string"!=typeof t.newName)throw j(".query.newName should be a string");var n=R(r,t);if(!n||"Identifier"!=n.node.type)throw j("Not at a variable.");var o=W(e,t,r,n,t.newName),i=o.refs;delete o.refs,o.files=e.files.map(function(e){return e.name});for(var s=o.changes=[],a=0;a<i.length;++a){var p=i[a];p.isShorthand?p.text=n.node.name+": "+t.newName:p.text=t.newName,s.push(p)}return o}},files:{run:function(e){return{files:e.files.map(function(e){return e.name})}}}};function s(e,t){this.name=e,this.parent=t,this.scope=this.text=this.ast=this.lineOffsets=null}function A(e,t){var r={directSourceFile:t,allowReturnOutsideFunction:!0,allowImportExportEverywhere:!0,ecmaVersion:e.options.ecmaVersion,allowHashBang:!0},n=e.signalReturnFirst("preParse",t.text,r)||t.text,o=T.parse(n,r);return e.signal("postParse",o,n),o}e.defineQueryType=function(e,t){u[e]=t},s.prototype.asLineChar=function(e){return b(this,e)};var i=/[\uD800-\uDBFF]/g;function a(e,t,r){e.text=r.options.stripCRs?t.replace(/\r\n/g,"\n"):t,e.hasAstral=i.test(e.text),T.withContext(r.cx,function(){e.ast=A(r,e)}),e.lineOffsets=null}function f(e,t){return T.withContext(e.cx,function(){t.scope=e.cx.topScope,e.signal("beforeLoad",t),T.analyze(t.ast,t.name,t.scope),e.signal("afterLoad",t)}),t}function l(r,e,t,n){var o=r.findFile(e);if(o)return null!=n&&(o.scope&&(r.needsPurge.push(e),T.clearScopes(o.ast),o.scope=null),a(o,n,r)),void(g(r,o.parent)>g(r,t)&&(o.parent=t,o.excluded&&(o.excluded=null)));var i=new s(e,t);r.files.push(i),r.fileMap[e]=i,null!=n?a(i,n,r):r.options.async?(r.startAsyncAction(),r.options.getFile(e,function(e,t){a(i,t||"",r),r.finishAsyncAction(e)})):a(i,r.options.getFile(e)||"",r)}function c(e,t,r){var n=function(){e.off("everythingFetched",n),clearTimeout(o),h(e,t,r)};e.on("everythingFetched",n);var o=setTimeout(n,e.options.fetchTimeout)}function h(r,e,t){if(r.pending)return c(r,e,t);var n=r.fetchError;if(n)return r.fetchError=null,t(n);0<r.needsPurge.length&&T.withContext(r.cx,function(){T.purge(r.needsPurge),r.needsPurge.length=0});for(var o=!0,i=0;i<r.files.length;){for(var s=[];i<r.files.length;++i){null==(a=r.files[i]).text?o=!1:null!=a.scope||a.excluded||s.push(a)}s.sort(function(e,t){return g(r,e.parent)-g(r,t.parent)});for(var a,p=0;p<s.length;p++){if((a=s[p]).parent&&!d(r,a))a.excluded=!0;else if(e){var u=+new Date;try{T.withTimeout(e[0],function(){f(r,a)})}catch(n){if(n instanceof T.TimedOut)return t(n);throw n}e[0]-=new Date-u}else f(r,a)}}o?t():c(r,e,t)}function E(e){for(var t=0;e;++t,e=e.prev);return t}function j(e){var t=new Error(e);return t.name="TernError",t}function g(e,t){for(var r=0;t;)t=e.fileMap[t].parent,++r;return r}function d(e,t){var r,n,o=function(e,t){for(;;){var r=e.fileMap[t.parent];if(!r.parent)break;t=r}return t.name}(e,t),i=(r=t.ast,n=0,P.simple(r,{Expression:function(){++n}}),n),s=e.budgets[o];return null==s&&(s=e.budgets[o]=e.options.dependencyBudget),!(s<i)&&(e.budgets[o]=s-i,1)}function p(e){return"number"==typeof e||"object"==typeof e&&"number"==typeof e.line&&"number"==typeof e.ch}(e.Server=function(e){for(var t in this.cx=null,this.options=e||{},n)e.hasOwnProperty(t)||(e[t]=n[t]);for(var r in this.projectDir=e.projectDir.replace(/\\/g,"/"),/\/$/.test(this.projectDir)||(this.projectDir+="/"),this.parent=e.parent,this.handlers=Object.create(null),this.files=[],this.fileMap=Object.create(null),this.needsPurge=[],this.budgets=Object.create(null),this.uses=0,this.pending=0,this.asyncError=null,this.mod={},this.defs=e.defs.slice(0),this.plugins=Object.create(null),e.plugins)e.plugins.hasOwnProperty(r)&&this.loadPlugin(r,e.plugins[r]);this.reset()}).prototype=t.mixin({addFile:function(e,t,r){!r||r in this.fileMap||(r=null),e in this.fileMap||(e=this.normalizeFilename(e)),l(this,e,r,t)},delFile:function(e){var t=this.findFile(e);if(t){this.needsPurge.push(t.name);for(var r=0;r<this.files.length;r++)this.files[r]==t?this.files.splice(r--,1):this.files[r].parent==e&&(this.files[r].parent=null);delete this.fileMap[t.name]}},reset:function(){this.signal("reset"),this.cx=new T.Context(this.defs,this),this.uses=0,this.budgets=Object.create(null);for(var e=0;e<this.files.length;++e){var t=this.files[e];t.scope&&(T.clearScopes(t.ast),t.scope=null)}this.signal("postReset")},request:function(e,r){var t=function(e){if(e.query){if("string"!=typeof e.query.type)return".query.type must be a string";if(e.query.start&&!p(e.query.start))return".query.start must be a position";if(e.query.end&&!p(e.query.end))return".query.end must be a position"}if(e.files){if(!Array.isArray(e.files))return"Files property must be an array";for(var t=0;t<e.files.length;++t){var r=e.files[t];if("object"!=typeof r)return".files[n] must be objects";if("string"!=typeof r.name)return".files[n].name must be a string";if("delete"!=r.type){if("string"!=typeof r.text)return".files[n].text must be a string";if("part"==r.type){if(!p(r.offset)&&"number"!=typeof r.offsetLines)return".files[n].offset must be a position"}else if("full"!=r.type)return'.files[n].type must be "full" or "part"'}}}}(e);if(t)return r(t);var n=this;!function(n,e,o){if(e.query&&!u.hasOwnProperty(e.query.type))return o("No query type '"+e.query.type+"' defined");var i=e.query;i||o(null,{});var t=e.files||[];t.length&&++n.uses;for(var r=0;r<t.length;++r){var s=t[r];s.name=n.normalizeFilename(s.name),"delete"==s.type?n.delFile(s.name):l(n,s.name,null,"full"==s.type?s.text:null)}var a="number"==typeof e.timeout?[e.timeout]:null;if(!i)return h(n,a,function(){});var p=u[i.type];if(p.takesFile){if("string"!=typeof i.file)return o(".query.file must be a string");/^#/.test(i.file)||l(n,i.file,null)}h(n,a,function(e){if(e)return o(e);var r=p.takesFile&&function(g,e,t){var r=t.match(/^#(\d+)$/);if(!r)return g.findFile(t);var d=e[r[1]];if(!d||"delete"==d.type)throw j("Reference to unknown file "+t);if("full"==d.type)return g.fileMap[d.name];var y,v,m=d.backing=g.fileMap[d.name],n=N(m,null==d.offsetLines?d.offset:{line:d.offsetLines,ch:0},!0),b=function(e){var t=e.indexOf("\n");return t<0?e:e.slice(0,t)}(d.text),w=function(e,t,r){var n=Math.max(0,r-500),o=null;if(!/^\s*$/.test(e))for(;;){var i=t.indexOf(e,n);if(i<0||r+500<i)break;(null==o||Math.abs(o-r)>Math.abs(i-r))&&(o=i),n=i+e.length}return o}(b,m.text,n),x=null==w?Math.max(0,m.text.lastIndexOf("\n",n)):w;return T.withContext(g.cx,function(){T.purge(d.name,x,x+d.text.length);var e,t,r=d.text;if(!(e=r.match(/(?:"([^"]*)"|([\w$]+))\s*:\s*function\b/))||(t=P.findNodeAround(d.backing.ast,x,"ObjectExpression"))&&t.node.objType&&(y={type:t.node.objType,prop:e[2]||e[1]}),w&&(e=b.match(/^(.*?)\bfunction\b/))){for(var n=e[1].length,o="",i=0;i<n;++i)o+=" ";d.text=o+r.slice(n),v=!0}var s=T.scopeAt(m.ast,x,m.scope),a=T.scopeAt(m.ast,x+r.length,m.scope),p=d.scope=E(s)<E(a)?a:s;d.ast=A(g,d),T.analyze(d.ast,d.name,p);e:if(y||v){var u=T.scopeAt(d.ast,b.length,s);if(!u.fnType)break e;if(y)y.type.getProp(y.prop).addType(u.fnType);else if(v){var f=T.scopeAt(m.ast,x+b.length,m.scope);if(f==s||!f.fnType)break e;var l=f.fnType,c=u.fnType;if(!c||c.name!=l.name&&l.name)break e;for(var i=0,h=Math.min(l.args.length,c.args.length);i<h;++i)l.args[i].propagate(c.args[i]);l.self.propagate(c.self),c.retval.propagate(l.retval)}}}),d}(n,t,i.file);if(p.fullFile&&"part"==r.type)return o("Can't run a "+i.type+" query on a file fragment");T.resetGuessing(),T.withContext(n.cx,function(){function e(){t=p.run(n,i,r)}var t;try{a?T.withTimeout(a[0],e):e()}catch(e){return n.options.debug&&"TernError"!=e.name&&console.error(e.stack),o(e)}o(null,t)})})}(this,e,function(e,t){r(e,t),40<n.uses&&(n.reset(),h(n,null,function(){}))})},findFile:function(e){return this.fileMap[this.normalizeFilename(e)]},flush:function(t){var r=this.cx;h(this,null,function(e){if(e)return t(e);T.withContext(r,t)})},startAsyncAction:function(){++this.pending},finishAsyncAction:function(e){e&&(this.asyncError=e),0==--this.pending&&this.signal("everythingFetched")},addDefs:function(e,t){t?this.defs.unshift(e):this.defs.push(e),this.cx&&this.reset()},deleteDefs:function(e){for(var t=0;t<this.defs.length;t++)if(this.defs[t]["!name"]==e)return this.defs.splice(t,1),void(this.cx&&this.reset())},loadPlugin:function(e,t){if(1==arguments.length&&(t=this.options.plugins[e]||!0),!(e in this.plugins)&&e in o&&t){this.plugins[e]=!0;var r=o[e](this,t);if(r&&(r.defs&&this.addDefs(r.defs,r.loadFirst),r.passes))for(var n in r.passes)r.passes.hasOwnProperty(n)&&this.on(n,r.passes[n])}},normalizeFilename:function(e){var t=this.options.normalizeFilename(e).replace(/\\/g,"/");return 0==t.indexOf(this.projectDir)&&(t=t.slice(this.projectDir.length)),t}});var y=25;function v(e,t,r){var n,o=t+r;if(e.hasAstral)for(i.lastIndex=t;(n=i.exec(e.text))&&n.index<o;)o++;return o}var N=e.resolvePos=function(e,t,r){if("number"!=typeof t){var n=function(e,t){for(var r=e.text,n=e.lineOffsets||(e.lineOffsets=[0]),o=0,i=0,s=Math.min(Math.floor(t/y),n.length-1),o=n[s],i=s*y;i<t;){if(++i,0===(o=r.indexOf("\n",o)+1))return null;i%y==0&&n.push(o)}return o}(e,t.line);if(null==n){if(!r)throw j("File doesn't contain a line "+t.line);t=e.text.length}else t=v(e,n,t.ch)}else t=v(e,0,t);if(t>e.text.length){if(!r)throw j("Position "+t+" is outside of file.");t=e.text.length}return t};function m(e,t,r){var n,o=r-t;if(e.hasAstral)for(i.lastIndex=t;(n=i.exec(e.text))&&n.index<r;)o--;return o}function b(e,t){if(!e)return{line:0,ch:0};for(var r,n,o=e.lineOffsets||(e.lineOffsets=[0]),i=e.text,s=o.length-1;0<=s;--s)o[s]<=t&&(r=s*y,n=o[s]);for(;;){var a=i.indexOf("\n",n);if(t<=a||a<0)break;n=a+1,++r}return{line:r,ch:m(e,n,t)}}var F=e.outputPos=function(e,t,r){if(e.lineCharPositions){var n=b(t,r);return"part"==t.type&&(n.line+=null!=t.offsetLines?t.offsetLines:b(t.backing,t.offset).line),n}return m(t,0,r)+("part"==t.type?t.offset:0)};function w(e){for(var t in e)null==e[t]&&delete e[t];return e}function x(e,t,r){null!=r&&(e[t]=r)}function S(e,t){"string"!=typeof e&&(e=e.name,t=t.name);var r=/^[A-Z]/.test(e);return r==/^[A-Z]/.test(t)?e<t?-1:e==t?0:1:r?1:-1}function C(e,t){for(var r=0;r<e.properties.length;r++){var n=e.properties[r];if(n.key.start<=t&&n.key.end>=t)return n}}var k="break do instanceof typeof case else new var catch finally return void continue for switch while debugger function this with default if throw delete in try".split(" "),I=k.concat("export class extends const super yield import let static".split(" ")),D=e.addCompletion=function(e,t,r,n,o){for(var i=e.types||e.docs||e.urls||e.origins,s=i||e.depths,a=0;a<t.length;++a){var p=t[a];if((s?p.name:p)==r)return}var u,f=s?{name:r}:r;return t.push(f),n&&i&&(T.resetGuessing(),u=n.getType(),f.guess=T.didGuess(),e.types&&(f.type=T.toString(n)),e.docs&&x(f,"doc",B(e,n.doc||u&&u.doc)),e.urls&&x(f,"url",n.url||u&&u.url),e.origins&&x(f,"origin",n.origin||u&&u.origin)),e.depths&&(f.depth=o||0),f};function M(e,t){var r,n,o=e.body;return o&&(n=Array.isArray(o)?(r=o[0].start,o[o.length-1].end):(r=o.start,o.end),r<=t&&t<=n)}var L=e.findQueryExpr=function(e,t,r){if(null==t.end)throw j("missing .query.end field");if(t.variable){var n=T.scopeAt(e.ast,N(e,t.end),e.scope);return{node:{type:"Identifier",name:t.variable,start:t.end,end:t.end+1},state:n}}var o,i,s=t.start&&N(e,t.start),a=N(e,t.end),p=T.findExpressionAt(e.ast,s,a,e.scope);return p||(o=T.findClosestExpression(e.ast,s,a,e.scope))&&!M(o.node,a)&&(r||(null==s?a:s)-o.node.start<20||o.node.end-a<20)&&(p=o),p||(i=T.findExpressionAround(e.ast,s,a,e.scope))&&!M(i.node,a)&&("ObjectExpression"==i.node.type||r||(null==s?a:s)-i.node.start<20||i.node.end-a<20)&&(p=i),p};function q(e,t,r){var n=t.start&&N(e,t.start),o=N(e,t.end),i=null,s=T.findExpressionAround(e.ast,n,o,e.scope);return s&&!M(s.node,o)&&("ObjectExpression"==s.node.type||r||(null==n?o:n)-s.node.start<20||s.node.end-o<20)&&(i=s),i}function R(e,t,r){var n=L(e,t,r);if(n)return n;throw j("No expression at the given position.")}function _(e){return(e=e&&e.getType())&&e instanceof T.Obj?e:null}function V(e,t,r,n){var o;n&&(T.resetGuessing(),o=T.expressionType(n));var i,s,a,p,u=e.hasHandler("typeAt");if(u)for(var f=N(r,t.end),l=0;l<u.length;l++)o=u[l](r,f,n,o);if(!o)throw j("No type found at the given position.");return"ObjectExpression"==n.node.type&&null!=t.end&&(i=C(n.node,N(r,t.end)))&&(s=i.key.name,(a=_(T.typeFromContext(r.ast,n)))&&a.hasProp(s)?o=a.hasProp(s):(p=_(o))&&p.hasProp(s)&&(o=p.hasProp(s))),o}function H(e,t,r,n){var o,i=s=V(e,t,r,n),s=t.preferFunction&&s.getFunctionType()||s.getType();if(n&&("Identifier"==n.node.type?o=n.node.name:"MemberExpression"!=n.node.type||n.node.computed?"MethodDefinition"!=n.node.type||n.node.computed||(o=n.node.key.name):o=n.node.property.name),null!=t.depth&&"number"!=typeof t.depth)throw j(".query.depth must be a number");return[s,o,i]}function B(e,t){if(!t)return null;if("full"==e.docFormat)return t;var r=/.\n[\s@\n]/.exec(t);if(r&&(t=t.slice(0,r.index+1)),(t=t.replace(/\n\s*/g," ")).length<100)return t;var n=/[\.!?] [A-Z]/g;n.lastIndex=80;var o=n.exec(t);return o&&(t=t.slice(0,o.index+1)),t}function $(e,t,r){r.url||(r.url=t.url),r.doc||(r.doc=B(e,t.doc)),r.origin||(r.origin=t.origin);var n,o=T.cx().protos;!r.url&&!r.doc&&t.proto&&(n=t.proto.hasCtor)&&t.proto!=o.Object&&t.proto!=o.Function&&t.proto!=o.Array&&(r.url=n.url,r.doc=B(e,n.doc))}var G=e.getSpan=function(e){if(e.origin){if(e.originNode){var t=e.originNode;return/^Function/.test(t.type)&&t.id&&(t=t.id),{origin:e.origin,node:t}}return e.span?{origin:e.origin,span:e.span}:void 0}},z=e.storeSpan=function(e,t,r,n){var o,i;n.origin=r.origin,r.span?(o=/^(\d+)\[(\d+):(\d+)\]-(\d+)\[(\d+):(\d+)\]$/.exec(r.span),n.start=t.lineCharPositions?{line:Number(o[2]),ch:Number(o[3])}:Number(o[1]),n.end=t.lineCharPositions?{line:Number(o[5]),ch:Number(o[6])}:Number(o[4])):(i=e.fileMap[r.origin],n.start=F(t,i,r.node.start),n.end=F(t,i,r.node.end))};function W(e,p,t,r,u){for(var f=r.node.name,l=r.state;l&&!(f in l.props);l=l.prev);if(!l)throw j("Could not find a definition for "+f);var n,c=[];function o(a){return function(e,t,r){var n={file:a.name,start:F(p,a,e.start),end:F(p,a,e.end)};if(u){for(var o=t;o!=l;o=o.prev){var i=o.hasProp(u);if(i)throw j("Renaming `"+f+"` to `"+u+"` would make a variable at line "+(b(a,e.start).line+1)+" point to the definition at line "+(b(a,i.name.start).line+1))}var s=r[r.length-2];s&&"Property"==s.type&&s.key==s.value&&(n.isShorthand=!0)}c.push(n)}}if(l.originNode){if(n="local",u){for(var i=l.prev;i&&!(u in i.props);i=i.prev);i&&T.findRefs(l.originNode,l,u,i,function(e){throw j("Renaming `"+f+"` to `"+u+"` would shadow the definition used at line "+(b(t,e.start).line+1))})}T.findRefs(l.originNode,l,f,l,o(t))}else if(n="global",p.onlySourceFile)T.findRefs(t.ast,t.scope,f,l,o(t));else for(var s=0;s<e.files.length;++s){var a=e.files[s];T.findRefs(a.ast,a.scope,f,l,o(a))}return{refs:c,type:n,name:f}}function U(e,r,t,n,o){var i=T.expressionType(n);"MethodDefinition"==n.node.type&&(i=i.propertyOf);var s=i.getObjType();if(!s)throw j("Couldn't determine type of base object.");var a=[];function p(t){return function(e){a.push({file:t.name,start:F(r,t,e.start),end:F(r,t,e.end)})}}if(r.onlySourceFile)T.findPropRefs(t.ast,t.scope,s,o.name,p(t));else for(var u=0;u<e.files.length;++u){var f=e.files[u];T.findPropRefs(f.ast,f.scope,s,o.name,p(f))}return{refs:a,name:o.name}}e.version="0.24.1"}),function(e){"object"==typeof exports&&"object"==typeof module?exports.init=e:"function"==typeof define&&define.amd?define({init:e}):tern.def={init:e}}(function(e,P){"use strict";function l(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var h=e.TypeParser=function(e,t,r,n){this.pos=t||0,this.spec=e,this.base=r,this.forceNew=n};function T(e,t,r){return e.call?e(t,r):e}function o(e,t){if("!ret"!=t)return e.getProp(t);if(e.retval)return e.retval;var r=new P.AVal;return e.propagate(new P.IsCallee(P.ANull,[],null,r)),r}function i(e){if(e instanceof P.Fn&&e.args)for(var t=0;t<e.args.length;++t){var r=e.args[t];r instanceof P.Fn&&r.args&&r.args.length&&n(e,t)}}function n(r,n){g(r,function(e,t){t[n]&&t[n].propagate(new P.IsCallee(P.cx().topScope,r.args[n].args,null,P.ANull))})}function c(e,t,r,n){var o=new h(e,null,r,n).parseType(!1,t,!0);return o instanceof P.AVal?o.types.forEach(i):i(o),o}function g(e,i,s){var a=e.computeRet,p=e.retval;e.computeRet=function(e,t,r){var n=i(e,t,r),o=a?a(e,t,r):p;return s?n:o}}h.prototype={eat:function(e){if(1==e.length?this.spec.charAt(this.pos)==e:this.spec.indexOf(e,this.pos)==this.pos)return this.pos+=e.length,!0},word:function(e){for(var t,r="",e=e||/[\w$]/;(t=this.spec.charAt(this.pos))&&e.test(t);)r+=t,++this.pos;return r},error:function(){throw new Error("Unrecognized type spec: "+this.spec+" (at "+this.pos+")")},parseFnType:function(e,t,r,n){var o,i,s,a,p,u,f,l,c,h=[],g=[],d=!1;if(!this.eat(")"))for(;;0){var y,v=this.spec.indexOf(": ",this.pos);-1!=v&&(y=this.spec.slice(this.pos,v),/^(\.\.\.)?[$\w?]+$/.test(y)?this.pos=v+2:y=null),g.push(y);var m=this.parseType(e);if(m.call&&(d=!0),h.push(m),!this.eat(", ")){this.eat(")")||this.error();break}}return this.eat(" -> ")?(a=this.pos,(p=this.parseType(!0)).call&&!d&&(o=p,p=P.ANull,i=a)):p=P.ANull,d?(u=t,f=h,l=p,c=n,function(e,t){for(var r=[],n=0;n<f.length;n++)r.push(T(f[n],e,t));return new P.Fn(u,P.ANull,r,T(l,e,t),c)}):(r&&(s=this.base)?P.Fn.call(this.base,t,P.ANull,h,g,p,n):s=new P.Fn(t,P.ANull,h,g,p,n),o&&(s.computeRet=o),null!=i&&(s.computeRetSource=this.spec.slice(i,this.pos)),s)},parseType:function(e,t,r){var n=this.parseTypeMaybeProp(e,t,r);if(!this.eat("|"))return n;for(var o,i=[n],s=n.call;;){var a=this.parseTypeMaybeProp(e,t,r);if(i.push(a),a.call&&(s=!0),!this.eat("|"))break}if(s)return o=i,function(e,t){for(var r=new P.AVal,n=0;n<o.length;n++)T(o[n],e,t).propagate(r);return r.maxWeight=1e5,r};for(var p=new P.AVal,u=0;u<i.length;u++)i[u].propagate(p);return p.maxWeight=1e5,p},parseTypeMaybeProp:function(e,t,r){for(var n=this.parseTypeInner(e,t,r);e&&this.eat(".");)n=this.extendWithProp(n);return n},extendWithProp:function(r){var n=this.word(/[\w<>$!:]/)||this.error();return r.apply?function(e,t){return o(r(e,t),n)}:o(r,n)},parseTypeInner:function(e,t,r){var n,i,s,o,a;if(this.eat("fn(")||(n=this.eat("fn*(")))return this.parseFnType(e,t,r,n);if(this.eat("[")){for(var p=this.parseType(e),u=p.call;this.eat(", ");){l=l||[p];var f=this.parseType(e);l.push(f),u=u||f.call}return this.eat("]")||this.error(),u?l?(a=l,function(t,r){return new P.Arr(a.map(function(e){return T(e,t,r)}))}):(o=p,function(e,t){return new P.Arr(o(e,t))}):r&&this.base?(P.Arr.call(this.base,l||p),this.base):new P.Arr(l||p)}if(this.eat("{")){var l=[],c=[],u=!1;if(!this.eat("}"))for(;;0){var h,g=this.spec.indexOf(": ",this.pos);-1!=g&&(h=this.spec.slice(this.pos,g),/^[$\w?]+$/.test(h)?this.pos=g+2:h=null);var d=this.parseType(e);if(d.call&&(u=!0),c.push(h),l.push(d),!this.eat(", ")){this.eat("}")||this.error();break}}if(u)return i=c,s=l,function(r,n){var o=new P.Obj;return i.forEach(function(e,t){o.defProp(e).addType(T(s[t],r,n))}),o};var y=new P.Obj;return c.forEach(function(e,t){y.defProp(e).addType(l[t])}),y}if(this.eat("+")){var v=this.word(/[\w$<>\.:!]/),m=P.cx().localDefs[v+".prototype"];if(!m){if(!((m=O(v))instanceof P.Obj))return m;var b=A(m,["prototype"]);(b=b&&b.getObjType())&&(m=b)}return e&&this.eat("[")?this.parsePoly(m):r&&this.base?((t=(this.base.proto=m).hasCtor&&m.hasCtor.name||m.name)&&(this.base.name=t),this.base):r&&this.forceNew?new P.Obj(m):P.getInstance(m)}if(this.eat(":")){t=this.word(/[\w$\.]/);return P.getSymbol(t)}if(e&&this.eat("!")){var w=this.word(/\d/);if(w)return w=Number(w),function(e,t){return t[w]||P.ANull};if(this.eat("this"))return function(e){return e};if(this.eat("custom:")){var x=this.word(/[\w$]/);return E[x]||function(){return P.ANull}}return this.fromWord("!"+this.word(/[\w$<>\.!:]/))}return this.eat("?")?P.ANull:this.fromWord(this.word(/[\w$<>\.!:`]/))},fromWord:function(e){var t=P.cx();switch(e){case"number":return t.num;case"string":return t.str;case"bool":return t.bool;case"<top>":return t.topScope}return t.localDefs&&e in t.localDefs?t.localDefs[e]:O(e)},parsePoly:function(n){var e,o="<i>";(e=this.spec.slice(this.pos).match(/^\s*([\w$:]+)\s*=\s*/))&&(o=e[1],this.pos+=e[0].length);var i=this.parseType(!0);if(this.eat("]")||this.error(),i.call)return function(e,t){var r=new P.Obj(n);return i(e,t).propagate(r.defProp(o)),r};var t=new P.Obj(n);return i.propagate(t.defProp(o)),t}};var p,d=e.parseEffect=function(e,t){var r;if(0==e.indexOf("propagate ")){var n=(s=new h(e,10)).parseType(!0);s.eat(" ")||s.error();var o=s.parseType(!0);g(t,function(e,t){T(n,e,t).propagate(T(o,e,t))})}else if(0==e.indexOf("call ")){var a=5==e.indexOf("and return ",5),p=(s=new h(e,a?16:5)).parseType(!0),u=null,f=[];for(s.eat(" this=")&&(u=s.parseType(!0));s.eat(" ");)f.push(s.parseType(!0));g(t,function(e,t){for(var r=T(p,e,t),n=u?T(u,e,t):P.ANull,o=[],i=0;i<f.length;++i)o.push(T(f[i],e,t));var s=a?new P.AVal:P.ANull;return r.propagate(new P.IsCallee(n,o,null,s)),s},a)}else if(r=e.match(/^custom (\S+)\s*(.*)/)){var i=E[r[1]];i&&g(t,r[2]?i(r[2]):i)}else{if(0!=e.indexOf("copy "))throw new Error("Unknown effect type: "+e);var s,l=(s=new h(e,5)).parseType(!0);s.eat(" ");var c=s.parseType(!0);g(t,function(e,t){var r=T(l,e,t),n=T(c,e,t);r.forAllProps(function(e,t,r){r&&"<i>"!=e&&n.propagate(new P.DefProp(e,t))})})}},O=e.parsePath=function(e,t){var r=P.cx(),n=r.paths[e],o=e;if(null!=n)return n;r.paths[e]=P.ANull;var i=t||p||r.topScope;if(r.localDefs)for(var s in r.localDefs)if(0==e.indexOf(s)){if(e==s)return r.paths[e]=r.localDefs[e];if("."==e.charAt(s.length)){i=r.localDefs[s],e=e.slice(s.length+1);break}}var a=A(i,e.split("."));return r.paths[o]=a==P.ANull?null:a,a};function A(e,t){for(var r=0;r<t.length&&e!=P.ANull;++r){var n,o,i,s=t[r];e="!"==s.charAt(0)?"!proto"==s?e instanceof P.Obj&&e.proto||P.ANull:(n=e.getFunctionType())?"!ret"==s?n.retval&&n.retval.getType(!1)||P.ANull:(o=n.args&&n.args[Number(s.slice(1))])&&o.getType(!1)||P.ANull:P.ANull:!(e instanceof P.Obj&&("prototype"==s&&e instanceof P.Fn||e.hasProp(s)))||!(i=e.getProp(s))||i.isEmpty()?P.ANull:i.types[0]}return e}function a(e){var t=Object.create(e.prototype);return t.props=Object.create(null),t.isShell=!0,t}function y(e){if(e["!type"]&&!/^(fn\(|\[|\+)/.test(e["!type"])){for(var t in e)if("!type"!=t&&"!doc"!=t&&"!url"!=t&&"!span"!=t&&"!data"!=t)return;return 1}}function u(e,t,r){if(!e){var n=t["!type"];if(n)if(/^fn\(/.test(n))e=a(P.Fn);else if("["==n.charAt(0))e=a(P.Arr);else{if("+"!=n.charAt(0))throw new Error("Invalid !type spec: "+n);e=a(P.Obj)}else e=t["!stdProto"]?P.cx().protos[t["!stdProto"]]:a(P.Obj);e.name=r}for(var o in t)if(l(t,o)&&33!=o.charCodeAt(0)){var i=t[o];if("string"==typeof i||y(i))continue;var s=e.defProp(o);u(s.getObjType(),i,r?r+"."+o:o).propagate(s)}return e}function v(e,t,r){var n,o;e.isShell&&(delete e.isShell,(n=t["!type"])?c(n,r,e):(o=t["!proto"]&&c(t["!proto"]),P.Obj.call(e,!(o instanceof P.Obj)||o,r)));var i=t["!effects"];if(i&&e instanceof P.Fn)for(var s=0;s<i.length;++s)d(i[s],e);for(var a in!function(e,t){e["!doc"]&&(t.doc=e["!doc"]);e["!url"]&&(t.url=e["!url"]);e["!span"]&&(t.span=e["!span"]);e["!data"]&&(t.metaData=e["!data"])}(t,e),t)if(l(t,a)&&33!=a.charCodeAt(0)){var p=t[a],u=e.defProp(a),f=r?r+"."+a:a;if("string"==typeof p)u.isEmpty()&&c(p,f).propagate(u);else{if(y(p)){if(!u.isEmpty())continue;c(p["!type"],f,null,!0).propagate(u)}else v(u.getObjType(),p,f);p["!doc"]&&(u.doc=p["!doc"]),p["!url"]&&(u.url=p["!url"]),p["!span"]&&(u.span=p["!span"])}}return e}e.load=function(e,t){t=t||P.cx().topScope;var r=p;p=t;try{!function(e,t){var r=P.cx(),n=r.parent;P.addOrigin(r.curOrigin=e["!name"]||"env#"+r.origins.length),r.localDefs=r.definitions[r.curOrigin]=Object.create(null),n&&n.signal("preLoadDef",e),u(t,e);var o=e["!define"];if(o){for(var i in o){var s=o[i];r.localDefs[i]="string"==typeof s?O(s):u(null,s,i)}for(var i in o){"string"!=typeof(s=o[i])&&v(r.localDefs[i],o[i],i)}}v(t,e),n&&n.signal("postLoadDef",e),r.curOrigin=r.localDefs=null}(e,t)}finally{p=r}},e.parse=function(e,t,r){var n=P.cx();t&&(n.origin=t,n.localDefs=n.definitions[t]);try{return"string"==typeof e?c(e,r):v(u(null,e,r),e,r)}finally{t&&(n.origin=n.localDefs=null)}};var E=Object.create(null);P.registerFunction=function(e,t){E[e]=t};var s=P.constraint({construct:function(e,t,r){this.created=e,this.target=t,this.spec=r},addType:function(e){if(e instanceof P.Obj&&this.created++<5){var t=new P.Obj(e),r=this.spec;if(r instanceof P.AVal&&(r=r.getObjType(!1)),r instanceof P.Obj)for(var n in r.props){var o,i=r.props[n].types[0],s=t.defProp(n);i&&i instanceof P.Obj&&i.props.value&&((o=i.props.value.getType(!1))&&s.addType(o))}this.target.addType(t)}}});P.registerFunction("Object_create",function(e,t,r){if(r&&r.length&&"Literal"==r[0].type&&null==r[0].value)return new P.Obj;var n=new P.AVal;return t[0]&&t[0].propagate(new s(0,n,t[1])),n});var f=P.constraint({construct:function(e){this.target=e},addType:function(e){e instanceof P.Obj&&(e.hasProp("value")?e.getProp("value").propagate(this.target):e.hasProp("get")&&e.getProp("get").propagate(new P.IsCallee(P.ANull,[],null,this.target)))}});P.registerFunction("Object_defineProperty",function(e,t,r){var n,o;return r&&3<=r.length&&"Literal"==r[1].type&&"string"==typeof r[1].value&&(n=t[0],o=new P.AVal,n.propagate(new P.DefProp(r[1].value,o,r[1])),t[2].propagate(new f(o))),P.ANull}),P.registerFunction("Object_defineProperties",function(e,t,o){var i;return 2<=t.length&&(i=t[0],t[1].forAllProps(function(e,t,r){var n;r&&(n=new P.AVal,i.propagate(new P.DefProp(e,n,o&&o[1])),t.propagate(new f(n)))})),P.ANull});var m=P.constraint({construct:function(e,t,r){this.self=e,this.args=t,this.target=r},addType:function(e){if(e instanceof P.Fn){this.target.addType(new P.Fn(e.name,P.ANull,e.args.slice(this.args.length),e.argNames.slice(this.args.length),e.retval,e.generator)),this.self.propagate(e.self);for(var t=0;t<Math.min(e.args.length,this.args.length);++t)this.args[t].propagate(e.args[t])}}});function b(){var e=P.cx().definitions.ecmascript;return e&&new P.Obj(e["Promise.prototype"])}P.registerFunction("Function_bind",function(e,t){if(!t.length)return P.ANull;var r=new P.AVal;return e.propagate(new m(t[0],t.slice(1),r)),r}),P.registerFunction("Array_ctor",function(e,t){var r=new P.Arr;if(1!=t.length||!t[0].hasType(P.cx().num))for(var n=r.getProp("<i>"),o=0;o<t.length;++o)t[o].propagate(n);return r}),P.registerFunction("Promise_ctor",function(e,t,r){var n=b();if(!n||t.length<1)return P.ANull;var o=n.defProp(":t",r&&r[0]),i=new P.AVal;i.propagate(o);var s=new P.Fn("execute",P.ANull,[i],["value"],P.ANull),a=P.cx().definitions.ecmascript.Promise_reject;return t[0].propagate(new P.IsCallee(P.ANull,[s,a],null,P.ANull)),n}),P.registerFunction("Promise_resolve",function(e,t,r){var n,o,i=b();return i?(t.length&&(n=i.defProp(":t",r&&r[0]),(o=new P.AVal).propagate(n),t[0].propagate(new w(o))),i):P.ANull});var w=P.constraint({construct:function(e){this.output=e},addType:function(e){e.constructor==P.Obj&&"Promise"==e.name&&e.hasProp(":t")?e.getProp(":t").propagate(this.output):e.propagate(this.output)}});return P.registerFunction("Promise_then",function(e,t,r){var n=t.length&&t[0].getFunctionType(),o=P.cx().definitions.ecmascript;if(!n||!o)return e;var i,s=new P.Obj(o["Promise.prototype"]),a=s.defProp(":t",r&&r[0]);return n.retval.isEmpty()&&(i=e.getType())instanceof P.Obj&&i.hasProp(":t")&&i.getProp(":t").propagate(a,50),n.retval.propagate(new w(a)),s}),P.registerFunction("getOwnPropertySymbols",function(e,t){if(!t.length)return P.ANull;var n=new P.AVal;return t[0].forAllProps(function(e,t,r){r&&":"==e.charAt(0)&&n.addType(P.getSymbol(e.slice(1)))}),n}),P.registerFunction("getSymbol",function(e,t,r){return r&&r.length&&"Literal"==r[0].type&&"string"==typeof r[0].value?P.getSymbol(r[0].value):P.ANull}),e}),function(e){"object"==typeof exports&&"object"==typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(tern.comment||(tern.comment={}))}(function(r){function u(e){return e<14&&8<e||32===e||160===e}function f(e,t){for(;0<t;--t){var r=e.charCodeAt(t-1);if(10==r)break;if(!u(r))return}return 1}r.commentsBefore=function(e,t){var r,n=null,o=0;e:for(;0<t;){var i=e.charCodeAt(t-1);if(10==i)for(var s=--t,a=!1;0<s;--s){if(47==(i=e.charCodeAt(s-1))&&47==e.charCodeAt(s-2)){if(!f(e,s-2))break e;var p=e.slice(s,t);!o&&r?n[0]=p+"\n"+n[0]:(n=n||[]).unshift(p),r=!0,o=0,t=s-2;break}if(10==i){if(!a&&1<++o)break e;break}a||u(i)||(a=!0)}else if(47==i&&42==e.charCodeAt(t-2)){for(s=t-2;1<s;--s)if(42==e.charCodeAt(s-1)&&47==e.charCodeAt(s-2)){if(!f(e,s-2))break e;(n=n||[]).unshift(e.slice(s,t-2)),r=!1,o=0;break}t=s-2}else{if(!u(i))break;--t}}return n},r.commentAfter=function(e,t){for(;t<e.length;){var r=e.charCodeAt(t);if(47==r){var n,o=e.charCodeAt(t+1);if(47==o)n=e.indexOf("\n",t+2);else{if(42!=o)return;n=e.indexOf("*/",t+2)}return e.slice(t+2,n<0?e.length:n)}u(r)&&++t}},r.ensureCommentsBefore=function(e,t){return t.hasOwnProperty("commentsBefore")?t.commentsBefore:t.commentsBefore=r.commentsBefore(e,t.start)}}),function(e,t){"object"==typeof exports&&"object"==typeof module?t(exports,require("acorn"),require("acorn-loose"),require("acorn-walk"),require("./def"),require("./signal")):"function"==typeof define&&define.amd?define(["exports","acorn/dist/acorn","acorn-loose/dist/acorn-loose","acorn-walk/dist/walk","./def","./signal"],t):t(e.tern||(e.tern={}),acorn,acorn.loose,acorn.walk,tern.def,tern.signal)}(this,function(u,o,i,h,s,e){"use strict";var a=u.toString=function(e,t,r){return!e||e==r||t&&t<-3?"?":e.toString(t,r)},g=u.ANull=e.mixin({addType:function(){},propagate:function(){},getProp:function(){return g},forAllProps:function(){},hasType:function(){return!1},isEmpty:function(){return!0},getFunctionType:function(){},getObjType:function(){},getSymbolType:function(){},getType:function(){},gatherProperties:function(){},propagatesTo:function(){},typeHint:function(){},propHint:function(){},toString:function(){return"?"}});function t(e,t){var r=Object.create(e);if(t)for(var n in t)r[n]=t[n];return r}var f=1,d=u.AVal=function(){this.types=[],this.forward=null,this.maxWeight=0};function l(e,t,r){var n=e.getType(!1),o=t.getType(!1);return!n||!o||c(n,o,r)}function c(e,r,n){if(!e||5<=n)return r;if(!e||e==r)return e;if(!r)return e;if(e.constructor!=r.constructor)return!1;if(e.constructor!=q){if(e.constructor!=I)return e.constructor==L&&(!!(e.args.length==r.args.length&&e.args.every(function(e,t){return l(e,r.args[t],n+1)})&&l(e.retval,r.retval,n+1)&&l(e.self,r.self,n+1))&&e);var t=0,o=0,i=0;for(var s in e.props)t++,s in r.props&&l(e.props[s],r.props[s],n+1)&&i++;for(var s in r.props)o++;return!(t&&o&&i<Math.max(t,o)/2)&&(o<t?e:r)}var a=e.getProp("<i>").getType(!1);if(!a)return r;var p=r.getProp("<i>").getType(!1);return!p||c(a,p,n+1)?r:void 0}d.prototype=t(g,{addType:function(r,n){if(n=n||100,this.maxWeight<n){if(this.maxWeight=n,1==this.types.length&&this.types[0]==r)return;this.types.length=0}else if(this.maxWeight>n||-1<this.types.indexOf(r))return;this.signal("addType",r),this.types.push(r);var o=this.forward;o&&G(function(e){for(var t=0;t<o.length;++t)e(r,o[t],n)})},propagate:function(r,n){var o;r==g||r instanceof S&&this.forward&&2<this.forward.length||(n&&100!=n&&(r=new F(r,n)),(this.forward||(this.forward=[])).push(r),(o=this.types).length&&G(function(e){for(var t=0;t<o.length;++t)e(o[t],r,n)}))},getProp:function(e){if(M(e))return g;var t=(this.props||(this.props=Object.create(null)))[e];return t||(t=this.props[e]=new d,this.propagate(new p(e,t))),t},forAllProps:function(e){this.propagate(new m(e))},hasType:function(e){return-1<this.types.indexOf(e)},isEmpty:function(){return 0===this.types.length},getFunctionType:function(){for(var e=this.types.length-1;0<=e;--e)if(this.types[e]instanceof L)return this.types[e]},getObjType:function(){for(var e=null,t=this.types.length-1;0<=t;--t){var r=this.types[t];if(r instanceof I){if(r.name)return r;e=e||r}}return e},getSymbolType:function(){for(var e=this.types.length-1;0<=e;--e)if(this.types[e]instanceof R)return this.types[e]},getType:function(e){return 0===this.types.length&&!1!==e?this.makeupType():1===this.types.length?this.types[0]:y(this.types)},toString:function(t,r){if(0==this.types.length)return a(this.makeupType(),t,r);if(1==this.types.length)return a(this.types[0],t,r);var e=n(this.types);return 2<e.length?"?":e.map(function(e){return a(e,t,r)}).join("|")},makeupPropType:function(e){var t=this.propertyName,r=e.proto&&e.proto.hasProp(t);if(r){var n=r.getType();if(n)return n}if("<i>"!=t){var o=e.hasProp("<i>");if(o)return o.getType()}else if(e.props["<i>"]!=this)for(var i in e.props){var s=e.props[i];if(!s.isEmpty())return s.getType()}},makeupType:function(){var e=this.propertyOf&&this.makeupPropType(this.propertyOf);if(e)return e;if(!this.forward)return null;for(var t=this.forward.length-1;0<=t;--t){var r=this.forward[t].typeHint();if(r&&!r.isEmpty())return ke=!0,r}for(var n=Object.create(null),o=null,t=0;t<this.forward.length;++t){(p=this.forward[t].propHint())&&"length"!=p&&"<i>"!=p&&"✖"!=p&&p!=H.completingProperty&&(n[p]=!0,o=p)}if(!o)return null;var i=_(o);if(i){var s=[];e:for(t=0;t<i.length;++t){var a=i[t];for(var p in n)if(!a.hasProp(p))continue e;a.hasCtor&&(a=P(a)),s.push(a)}var u=y(s);if(u)return ke=!0,u}},typeHint:function(){return this.types.length?this.getType():null},propagatesTo:function(){return this},gatherProperties:function(e,t){for(var r=0;r<this.types.length;++r)this.types[r].gatherProperties(e,t)},guessProperties:function(e){if(this.forward)for(var t=0;t<this.forward.length;++t){var r=this.forward[t].propHint();r&&e(r,null,0)}var n=this.makeupType();n&&n.gatherProperties(e)}});var n=u.simplifyTypes=function(e){var t=[];e:for(var r=0;r<e.length;++r){for(var n=e[r],o=0;o<t.length;o++){var i=c(n,t[o],0);if(i){t[o]=i;continue e}}t.push(n)}return t};function y(e){for(var t=0,r=0,n=0,o=null,i=0;i<e.length;++i){if((p=e[i])instanceof q)++t;else if(p instanceof L)++r;else if(p instanceof I)++n;else if(p instanceof C){if(o&&p.name!=o.name)return null;o=p}}if(1<(t&&1)+(r&&1)+(n&&1)+(o&&1))return null;if(o)return o;for(var s=0,a=null,i=0;i<e.length;++i){var p=e[i],u=0;if(t)u=p.getProp("<i>").isEmpty()?1:2;else if(r){u=1;for(var f=0;f<p.args.length;++f)p.args[f].isEmpty()||++u;p.retval.isEmpty()||++u}else n&&(u=p.name?100:2);s<=u&&(s=u,a=p)}return a}var r=u.constraint=function(e){function t(){this.origin=H.curOrigin,this.construct.apply(this,arguments)}for(var r in t.prototype=Object.create(g),e)e.hasOwnProperty(r)&&(t.prototype[r]=e[r]);return t},p=r({construct:function(e,t){this.prop=e,this.target=t},addType:function(e,t){e.getProp&&e.getProp(this.prop).propagate(this.target,t)},propHint:function(){return this.prop},propagatesTo:function(){if("<i>"==this.prop||!/[^\w_]/.test(this.prop))return{target:this.target,pathExt:"."+this.prop}}}),v=u.PropHasSubset=u.DefProp=r({construct:function(e,t,r){this.prop=e,this.type=t,this.originNode=r},addType:function(e,t){var r;e instanceof I&&((r=e.defProp(this.prop,this.originNode)).origin||(r.origin=this.origin),this.type.propagate(r,t))},propHint:function(){return this.prop}}),m=r({construct:function(e){this.c=e},addType:function(e){e instanceof I&&e.forAllProps(this.c)}});var b=u.IsCallee=r({construct:function(e,t,r,n){this.self=e,this.args=t,this.argNodes=r,this.retval=n,this.disabled=H.disabledComputing},addType:function(e,t){if(e instanceof L){for(var r=0;r<this.args.length;++r)r<e.args.length&&this.args[r].propagate(e.args[r],t),e.arguments&&this.args[r].propagate(e.arguments,t);e.isArrowFn()||this.self.propagate(e.self,this.self==H.topScope?90:t);var n,o,i,s,a=e.computeRet,p=e.retval;if(a)for(var u=this.disabled;u;u=u.prev)(u.fn==e||e.originNode&&u.fn.originNode==e.originNode)&&(a=null);a&&(n=H.disabledComputing,H.disabledComputing=this.disabled,p=a(this.self,this.args,this.argNodes),H.disabledComputing=n),e.async&&!e.generator&&((o=p.getType())&&o.constructor==I&&"Promise"==o.name||(s=(i=H.definitions.ecmascript)&&new I(i["Promise.prototype"]))&&(s.getType().propagate(new v(":t",p)),p=s)),Ae(e,p).propagate(this.retval,t)}},typeHint:function(){for(var e=[],t=0;t<this.args.length;++t)e.push("?");return new L(null,this.self,this.args,e,g)},propagatesTo:function(){return{target:this.retval,pathExt:".!ret"}}}),w=r({construct:function(e,t,r,n){this.propName=e,this.args=t,this.argNodes=r,this.retval=n,this.disabled=H.disabledComputing},addType:function(e,t){var r=new b(e,this.args,this.argNodes,this.retval);r.disabled=this.disabled,e.getProp(this.propName).propagate(r,t)},propHint:function(){return this.propName}}),x=u.IsCtor=r({construct:function(e,t){this.target=e,this.noReuse=t},addType:function(e,t){e instanceof L&&(H.parent&&!H.parent.options.reuseInstances&&(this.noReuse=!0),e.getProp("prototype").propagate(new T(!this.noReuse&&e,this.target),t))}}),P=u.getInstance=function(e,t){if(!1===t||null==e)return new I(e);t=t||e.hasCtor,e.instances||(e.instances=[]);for(var r=0;r<e.instances.length;++r){var n=e.instances[r];if(n.ctor==t)return n.instance}var o=new I(e,t&&t.name);return o.origin=e.origin,e.instances.push({ctor:t,instance:o}),o},T=u.IsProto=r({construct:function(e,t){this.ctor=e,this.target=t},addType:function(e,t){e instanceof I&&(8<(this.count=(this.count||0)+1)||(e==H.protos.Array?this.target.addType(new q):this.target.addType(P(e,this.ctor))))}}),O=r({construct:function(e){this.fn=e},addType:function(e,t){var n;e instanceof I&&!e.hasCtor&&(e.hasCtor=this.fn,(n=new j(e,this.fn)).addType(this.fn),e.forAllProps(function(e,t,r){r&&t.propagate(n)}))}}),A=r({construct:function(e,t){this.other=e,this.target=t},addType:function(e,t){e==H.str?this.target.addType(H.str,t):e==H.num&&this.other.hasType(H.num)&&this.target.addType(H.num,t)},typeHint:function(){return this.other}}),E=u.IfObj=r({construct:function(e){this.target=e},addType:function(e,t){e instanceof I&&this.target.addType(e,t)},propagatesTo:function(){return this.target}}),j=r({construct:function(e,t){this.obj=e,this.ctor=t},addType:function(e){e instanceof L&&e.self&&e.self.addType(P(this.obj,this.ctor),4)}}),N=r({construct:function(e){this.obj=e},addType:function(e){e instanceof I&&this.obj.proto==H.protos.Object&&this.obj.replaceProto(e)}}),F=r({construct:function(e,t){this.inner=e,this.weight=t},addType:function(e,t){this.inner.addType(e,Math.min(t,this.weight))},propagatesTo:function(){return this.inner.propagatesTo()},typeHint:function(){return this.inner.typeHint()},propHint:function(){return this.inner.propHint()}}),S=u.Type=function(){};S.prototype=t(g,{constructor:S,propagate:function(e,t){e.addType(this,t)},hasType:function(e){return e==this},isEmpty:function(){return!1},typeHint:function(){return this},getType:function(){return this}});var C=u.Prim=function(e,t){this.name=t,this.proto=e};function k(e){var t=e.charCodeAt(0);return 48<=t&&t<=57&&!/\D/.test(e)}C.prototype=t(S.prototype,{constructor:C,toString:function(){return this.name},getProp:function(e){return this.proto.hasProp(e)||g},gatherProperties:function(e,t){this.proto&&this.proto.gatherProperties(e,t)}});var I=u.Obj=function(e,t){var r;this.props||(this.props=Object.create(null)),this.proto=!0===e?H.protos.Object:e,!e||e==H.protos.Object||t||!e.name||this instanceof L||(r=/^(.*)\.prototype$/.exec(this.proto.name))&&(t=r[1]),this.name=t,this.maybeProps=null,this.origin=H.curOrigin};I.prototype=t(S.prototype,{constructor:I,toString:function(e){if(null==e&&(e=0),e<=0&&this.name)return this.name;var t=[],r=!1;for(var n in this.props)if("<i>"!=n){if(5<t.length){r=!0;break}e?t.push(n+": "+a(this.props[n],e-1,this)):t.push(n)}return t.sort(),r&&t.push("..."),"{"+t.join(", ")+"}"},hasProp:function(e,t){k(e)&&(e=this.normalizeIntegerProp(e));var r=this.props[e];if(!1!==t)for(var n=this.proto;n&&!r;n=n.proto)r=n.props[e];return r},defProp:function(e,t){var r=this.hasProp(e,!1);if(r)return t&&!r.originNode&&(r.originNode=t),r;if(M(e))return g;k(e)&&(e=this.normalizeIntegerProp(e));var n=this.maybeProps&&this.maybeProps[e];return n?(delete this.maybeProps[e],this.maybeUnregProtoPropHandler()):((n=new d).propertyOf=this,n.propertyName=e),(this.props[e]=n).originNode=t,n.origin=H.curOrigin,this.broadcastProp(e,n,!0),n},getProp:function(e){var t=this.hasProp(e,!0)||this.maybeProps&&this.maybeProps[e];if(t)return t;if(M(e))return g;k(e)&&(e=this.normalizeIntegerProp(e));var r=this.ensureMaybeProps()[e]=new d;return r.propertyOf=this,r.propertyName=e,r},normalizeIntegerProp:function(e){return"<i>"},broadcastProp:function(e,t,r){var n,o;if(r&&(this.signal("addProp",e,t),this instanceof W||(n=e,o=this,(H.props[n]||(H.props[n]=[])).push(o))),this.onNewProp)for(var i=0;i<this.onNewProp.length;++i){var s=this.onNewProp[i];s.onProtoProp?s.onProtoProp(e,t,r):s(e,t,r)}},onProtoProp:function(e,t,r){var n=this.maybeProps&&this.maybeProps[e];n&&(delete this.maybeProps[e],this.maybeUnregProtoPropHandler(),this.proto.getProp(e).propagate(n)),this.broadcastProp(e,t,!1)},replaceProto:function(e){for(var t=e;t;t=t.proto)if(t==this)return;this.proto&&this.maybeProps&&this.proto.unregPropHandler(this),this.proto=e,this.maybeProps&&this.proto.forAllProps(this)},ensureMaybeProps:function(){return this.maybeProps||(this.proto&&this.proto.forAllProps(this),this.maybeProps=Object.create(null)),this.maybeProps},removeProp:function(e){var t=this.props[e];delete this.props[e],(this.ensureMaybeProps()[e]=t).types.length=0},forAllProps:function(e){this.onNewProp||(this.onNewProp=[],this.proto&&this.proto.forAllProps(this)),this.onNewProp.push(e);for(var t=this;t;t=t.proto)for(var r in t.props)e.onProtoProp?e.onProtoProp(r,t.props[r],t==this):e(r,t.props[r],t==this)},maybeUnregProtoPropHandler:function(){if(this.maybeProps){for(var e in this.maybeProps)return;this.maybeProps=null}!this.proto||this.onNewProp&&this.onNewProp.length||this.proto.unregPropHandler(this)},unregPropHandler:function(e){for(var t=0;t<this.onNewProp.length;++t)if(this.onNewProp[t]==e){this.onNewProp.splice(t,1);break}this.maybeUnregProtoPropHandler()},gatherProperties:function(e,t){for(var r in this.props)"<i>"!=r&&":"!=r.charAt(0)&&e(r,this,t);this.proto&&this.proto.gatherProperties(e,t+1)},getObjType:function(){return this}});var D="undefined"!=typeof StopIteration;function M(e){return"__proto__"==e||"✖"==e||D&&"__iterator__"==e}var L=u.Fn=function(e,t,r,n,o,i,s){I.call(this,H.protos.Function,e),this.self=t,this.args=r,this.argNames=n,this.retval=o,this.generator=i,this.async=s};L.prototype=t(I.prototype,{constructor:L,toString:function(e){null==e&&(e=0);for(var t=this.generator?"fn*(":"fn(",r=0;r<this.args.length;++r){r&&(t+=", ");var n=this.argNames[r];n&&"?"!=n&&(t+=n+": "),t+=-3<e?a(this.args[r],e-1,this):"?"}return t+=")",this.retval.isEmpty()||(t+=" -> "+(-3<e?a(this.retval,e-1,this):"?")),t},getProp:function(e){if("prototype"!=e)return I.prototype.getProp.call(this,e);var t,r=this.hasProp(e,!1);return r||(r=this.defProp(e),(t=new I(!0,this.name&&this.name+".prototype")).origin=this.origin,r.addType(t,10)),r},defProp:function(e,t){if("prototype"!=e)return I.prototype.defProp.call(this,e,t);var r=this.hasProp(e,!1);return r||((r=I.prototype.defProp.call(this,e,t)).origin=this.origin,r.propagate(new O(this)),r)},getFunctionType:function(){return this},isArrowFn:function(){return this.originNode&&"ArrowFunctionExpression"==this.originNode.type}});var q=u.Arr=function(e){I.call(this,H.protos.Array);var t=this.defProp("<i>");if(Array.isArray(e)){this.tuple=e.length;for(var r=0;r<e.length;r++){var n=this.defProp(String(r));e[r].propagate(n),n.propagate(t)}}else e&&(this.tuple=0,e.propagate(t))};q.prototype=t(I.prototype,{constructor:q,toString:function(e){if(null==e&&(e=0),e<=-3)return"[?]";var t="";if(this.tuple){for(var r=0;r in this.props;r++){var n=a(this.getProp(String(r)),e-1,this),o=(null==o||o==n)&&n;t+=(t?", ":"")+n}o&&(t=o)}else t=a(this.getProp("<i>"),e-1,this);return"["+t+"]"},normalizeIntegerProp:function(e){return+e<this.tuple?e:"<i>"}});var R=u.Sym=function(e,t){C.call(this,H.protos.Symbol,"Symbol"),this.symName=e,this.originNode=t};function _(e){return H.props[e]}R.prototype=t(C.prototype,{constructor:R,asPropName:function(){return":"+this.symName},getSymbolType:function(){return this}}),u.getSymbol=function(e,t){var r=e.replace(/[^\w$\.]/g,"_"),n=H.symbols[r];return n?(t&&!n.originNode&&(n.originNode=t),n):H.symbols[r]=new R(r,t)},u.Context=function(t,e){this.parent=e,this.props=Object.create(null),this.protos=Object.create(null),this.origins=[],this.curOrigin="ecmascript",this.paths=Object.create(null),this.definitions=Object.create(null),this.purgeGen=0,this.workList=null,this.disabledComputing=null,this.curSuperCtor=this.curSuper=null,this.symbols=Object.create(null),u.withContext(this,function(){if(H.protos.Object=new I(null,"Object.prototype"),H.topScope=new W,H.topScope.name="<top>",H.protos.Array=new I(!0,"Array.prototype"),H.protos.Function=new L("Function.prototype",g,[],[],g),H.protos.Function.proto=H.protos.Object,H.protos.RegExp=new I(!0,"RegExp.prototype"),H.protos.String=new I(!0,"String.prototype"),H.protos.Number=new I(!0,"Number.prototype"),H.protos.Boolean=new I(!0,"Boolean.prototype"),H.protos.Symbol=new I(!0,"Symbol.prototype"),H.str=new C(H.protos.String,"string"),H.bool=new C(H.protos.Boolean,"bool"),H.num=new C(H.protos.Number,"number"),H.curOrigin=null,t)for(var e=0;e<t.length;++e)s.load(t[e])})},u.Context.prototype.startAnalysis=function(){this.disabledComputing=this.workList=this.curSuperCtor=this.curSuper=null};var V,H=null;u.cx=function(){return H},u.withContext=function(e,t){var r=H;H=e;try{return t()}finally{H=r}},u.TimedOut=function(){this.message="Timed out",this.stack=(new Error).stack},u.TimedOut.prototype=Object.create(Error.prototype),u.TimedOut.prototype.name="infer.TimedOut",u.withTimeout=function(e,t){var r=+new Date+e,n=V;if(n&&n<r)return t();V=r;try{return t()}finally{V=n}},u.addOrigin=function(e){H.origins.indexOf(e)<0&&H.origins.push(e)};var B=20,$=1e-4;function G(e){if(H.workList)return e(H.workList);for(var n=[],o=0,t=e(H.workList=function(e,t,r){o<B-$*n.length&&n.push(e,t,r,o)}),r=0;r<n.length;r+=4){if(V&&+new Date>=V)throw new u.TimedOut;o=n[r+3]+1,n[r+1].addType(n[r],n[r+2])}return H.workList=null,t}function z(e,t,r){var n=H.curSuperCtor,o=H.curSuper;H.curSuperCtor=e,H.curSuper=t;var i=r();return H.curSuperCtor=n,H.curSuper=o,i}var W=u.Scope=function(e,t,r,n){I.call(this,e||!0),this.prev=e,this.originNode=t,this.isBlock=!!r,this.isCatch=!!n};function U(e,t){for(;e.isBlock||e.isCatch||!1===t&&e.fnType&&e.fnType.isArrowFn();)e=e.prev;return e}function K(e,t){var r=U(e).fnType;r&&(r.instantiateScore=(r.instantiateScore||0)+t)}W.prototype=t(I.prototype,{constructor:W,defVar:function(e,t){for(var r=this;;r=r.proto){var n=r.props[e];if(n)return n;if(!r.prev)return r.defProp(e,t)}}});var Z={};function J(e,t){var r=t.instantiateScore;if(!H.disabledComputing&&r&&t.args.length&&function(e,t){try{return h.simple(e,{Expression:function(){if(--t<=0)throw Z}}),1}catch(e){if(e==Z)return;throw e}}(e,5*r))return K(U(t.originNode.scope.prev),r/2),function(f,l){for(var c=f.scope,e=0;e<l.args.length;++e)l.args[e]=new d;l.self=new d,l.computeRet=function(p,u){return function(e,t){H.disabledComputing={fn:e,prev:H.disabledComputing};var r=t();return H.disabledComputing=H.disabledComputing.prev,r}(l,function(){var e=H.curOrigin;H.curOrigin=l.origin;var t=f.scope?f.scope:c,r=new W(t.prev,t.originNode);for(var n in t.props)for(var o=r.defProp(n,t.props[n].originNode),i=0;i<u.length;++i)l.argNames[i]==n&&i<u.length&&u[i].propagate(o);for(var s=l.argNames.length!=u.length?l.argNames.slice(0,u.length):l.argNames;s.length<u.length;)s.push("?");if(r.fnType=new L(l.name,p,u,s,g,l.generator,l.async),r.fnType.originNode=l.originNode,l.arguments){var a=r.fnType.arguments=new d;r.defProp("arguments").addType(new q(a));for(i=0;i<u.length;++i)u[i].propagate(a)}return f.scope=r,h.recursive(f.body,r,null,re),h.recursive(f.body,r,null,Pe),H.curOrigin=e,r.fnType.retval})}}(e,t),1;t.instantiateScore=null}function Q(e){var t,r,p=e.retval;if(p!=g&&!e.isArrowFn()){!p.isEmpty()&&(t=p.getType())instanceof q&&(p=r=t.getProp("<i>"));for(var n=u(e.self,"!this",0),o=0;!n&&o<e.args.length;++o)n=u(e.args[o],"!"+o,0);if(n){r&&(n="["+n+"]");var i=new s.TypeParser(n).parseType(!0);return e.computeRet=i.apply?i:function(){return i},e.computeRetSource=n,1}}function u(e,t,r){if(!(3<r)&&e.forward)for(var n=0;n<e.forward.length;++n){var o=e.forward[n].propagatesTo();if(o){var i,s=t;if(o instanceof d)i=o;else{if(!(o.target instanceof d))continue;s+=o.pathExt,i=o.target}if(i==p)return s;var a=u(i,s,r+1);if(a)return a}}}}function Y(e,t){return e.defProp(t.name,t)}function X(e){return"Identifier"==e.type?e.name:"AssignmentPattern"==e.type?X(e.left):"ObjectPattern"==e.type?"{"+e.properties.map(function(e){return X("RestElement"===e.type?e:e.value)}).join(", ")+"}":"ArrayPattern"==e.type?"["+e.elements.map(function(e){return e?X(e):""}).join(", ")+"]":"RestElement"==e.type?"..."+X(e.argument):"_"}function ee(e){return"VariableDeclaration"==e.type&&"var"!=e.kind||"FunctionDeclaration"==e.type||"ClassDeclaration"==e.type}function te(e,t){return{inner:e,outer:t||e}}var re=u.scopeGatherer=h.make({VariablePattern:function(e,t){t.inner&&Y(t.inner,e)},AssignmentPattern:function(e,t,r){r(e.left,t,"Pattern"),r(e.right,t.outer,"Expression")},AssignmentExpression:function(e,t,r){"MemberExpression"==e.left.type?r(e.left,t,"Expression"):r(e.left,te(!1,t),"Pattern"),r(e.right,t,"Expression")},MemberPattern:function(e,t,r){r(e,t.outer)},Function:function(e,t,r){for(var n=e.scope=new W(t,e),o=[],i=[],s=0;s<e.params.length;++s){var a,p=e.params[s];i.push(X(p)),"Identifier"==p.type?o.push(Y(n,p)):(a=new d,o.push(a),r(a.originNode=p,te(n),"Pattern"))}n.fnType=new L(e.id&&e.id.name,new d,o,i,g,e.generator,e.async),(n.fnType.originNode=e).id&&Y("FunctionDeclaration"==e.type?t:n,e.id),r(e.body,n,e.expression?"Expression":"Statement")},BlockStatement:function(e,t,r){!e.scope&&e.body.some(ee)&&(t=e.scope=new W(t,e,!0)),h.base.BlockStatement(e,t,r)},CatchClause:function(e,t,r){var n,o;t=e.scope=new W(t,e,!1,!0),"Identifier"==e.param.type?(n=Y(t,e.param),r(e.body,t,"Statement"),(o=H.definitions.ecmascript)&&n.isEmpty()&&P(o["Error.prototype"]).propagate(n,6)):r(e.param,te(t),"Pattern")},VariableDeclaration:function(e,t,r){for(var n="var"==e.kind?U(t):t,o=0;o<e.declarations.length;++o){var i=e.declarations[o];r(i.id,te(n,t),"Pattern"),i.init&&r(i.init,t,"Expression")}},ClassDeclaration:function(e,t,r){e.id&&Y(t,e.id),e.superClass&&r(e.superClass,t,"Expression");for(var n=0;n<e.body.body.length;n++)r(e.body.body[n],t)},ForInStatement:function(e,t,r){!e.scope&&ee(e.left)&&(t=e.scope=new W(t,e,!0)),h.base.ForInStatement(e,t,r)},ForStatement:function(e,t,r){!e.scope&&e.init&&ee(e.init)&&(t=e.scope=new W(t,e,!0)),h.base.ForStatement(e,t,r)},ImportDeclaration:function(e,t){for(var r=0;r<e.specifiers.length;r++)Y(t,e.specifiers[r].local)}});function ne(e){e.scope&&(e.scope=null)}re.ForOfStatement=re.ForInStatement;var oe={BlockStatement:ne,Function:ne,CatchClause:ne,ForInStateMent:ne,ForStatement:ne};u.clearScopes=function(e){h.simple(e,oe)};var ie=u.propName=function(e,t){var r=e.property||e.key;if(!e.computed&&"Identifier"==r.type)return r.name;if("Literal"==r.type){if("string"==typeof r.value)return r.value;if("number"==typeof r.value)return String(r.value)}if(t){var n=se(we(r,t));if(n)return e.propName=n}else if(e.propName)return e.propName;return"<i>"};function se(e){var t=e.getSymbolType();if(t)return t.asPropName()}function ae(e){switch(e){case"+":case"-":case"~":return H.num;case"!":return H.bool;case"typeof":return H.str;case"void":case"delete":return g}}function pe(e){switch(e){case"==":case"!=":case"===":case"!==":case"<":case">":case">=":case"<=":case"in":case"instanceof":return 1}}function ue(e){if(e.regex)return P(H.protos.RegExp);switch(typeof e.value){case"boolean":return H.bool;case"number":return H.num;case"string":return H.str;case"object":case"function":return e.value?P(H.protos.RegExp):g}}function fe(e,t){for(var r=0;r<e.params.length;r++){var n=e.params[r];"Identifier"!=n.type&&he(n,t,e.scope.fnType.args[r])}}function le(e,t){return t.hasProp(e.name)||H.topScope.defProp(e.name,e)}var ce=u.inferPatternVisitor={Identifier:function(e,t,r){r.propagate(le(e,t))},MemberExpression:function(e,t,r){var n=we(e.object,t),o=ie(e,t);n.propagate(new v(o,r,e.property))},RestElement:function(e,t,r){he(e.argument,t,new q(r))},ObjectPattern:function(e,t,r){for(var n=0;n<e.properties.length;++n){var o=e.properties[n];"RestElement"!=o.type&&he(o.value,t,r.getProp(ie(o)))}},ArrayPattern:function(e,t,r){for(var n=0;n<e.elements.length;n++)e.elements[n]&&he(e.elements[n],t,r.getProp(String(n)))},AssignmentPattern:function(e,t,r){he(e.left,t,function(e,t){if(e==t||t==g)return e;if(e==g)return t;var r=new d;return e.propagate(r),t.propagate(r),r}(r,we(e.right,t)))}};function he(e,t,r){var n=ce[e.type];n&&n(e,t,r)}function ge(e){var t=U(e);return t.fnType?t.fnType.self:t}function de(u,f,l){!l&&u.id&&(l=u.id.name);var e,t,r,n,o=H.protos.Object;u.superClass&&("Literal"==u.superClass.type&&null==u.superClass.value?o=null:(n=(t=we(u.superClass,f)).getFunctionType())&&(r=n.getProp("prototype").getObjType())?o=r:e=(n=t).getProp("prototype"));var c=new I(o,l&&l+".prototype");return e&&e.propagate(new N(c)),z(n,e||o,function(){for(var e,t=u.body.body,r=0;r<t.length;r++)"constructor"==t[r].kind&&(e=t[r].value);var n=u.objType=e?we(e,f):new L(l,g,[],null,g);n.originNode=u.id||e||u;var o=P(c,n);n.self.addType(o),n.defProp("prototype",u).addType(c);for(r=0;r<t.length;r++){var i,s,a,p=t[r];"constructor"!=p.kind&&("<i>"==(s=ie(p,f))||"set"==p.kind?i=g:((i=(p.static?n:c).defProp(s,p.key)).initializer=!0,"get"==p.kind&&(i=new b(o,[],null,i))),we(p.value,f,i),(a=i.getFunctionType())&&a.self.addType(o))}return n})}function ye(e,t,r){var n=1<e.length&&e.length<6;if(n){for(var o,i=!0,s=0;s<e.length;s++){var a=e[s];a?"Literal"!=a.type||o&&o!=typeof a.value?i=!1:o=typeof a.value:n=!1}i&&(n=!1)}if(n){for(var p=[],s=0;s<e.length;++s)p.push(r(e[s],t));return new q(p)}if(e.length<2)return new q(e[0]&&r(e[0],t));for(var u=new d,s=0;s<e.length;s++)e[s]&&r(e[s],t).propagate(u);return new q(u)}function ve(i){return function(e,t,r,n){var o=i(e,t,n);return r&&o.propagate(r),o}}function me(o){return function(e,t,r,n){return r=r||new d,o(e,t,r,n),r}}var be=u.inferExprVisitor={ArrayExpression:ve(function(e,t){return ye(e.elements,t,we)}),ObjectExpression:ve(function(s,a,e){for(var t,r=H.protos.Object,n=0;n<s.properties.length;++n){var o,i,p=s.properties[n];"SpreadElement"!=p.type&&"__proto__"==p.key.name&&("Literal"==p.value.type&&null==p.value.value?r=null:(i=(o=we(p.value,a)).getObjType())?r=i:t=o)}var u=s.objType=new I(r,e);return t&&t.propagate(new N(u)),u.originNode=s,z(null,t||r,function(){for(var e=0;e<s.properties.length;++e){var t,r,n,o=s.properties[e],i=o.key;"SpreadElement"==o.type||M(o.key.name)||("<i>"==(t=ie(o,a))||"set"==o.kind?r=g:((n=r=u.defProp(t,i)).initializer=!0,"get"==o.kind&&(r=new b(u,[],null,n))),we(o.value,a,r,t),"FunctionExpression"==o.value.type&&o.value.scope.fnType.self.addType(u,2))}}),u}),FunctionExpression:ve(function(e,t,r){var n=e.scope,o=n.fnType;return r&&!o.name&&(o.name=r),fe(e,n),e.expression?we(e.body,n,n.fnType.retval=new d):h.recursive(e.body,n,null,Pe,"Statement"),"ArrowFunctionExpression"==e.type&&ge(t).propagate(o.self),J(e,o)||Q(o),e.id&&n.getProp(e.id.name).addType(o),o}),ClassExpression:ve(de),SequenceExpression:ve(function(e,t){for(var r=0,n=e.expressions.length-1;r<n;++r)we(e.expressions[r],t,g);return we(e.expressions[n],t)}),UnaryExpression:ve(function(e,t){return we(e.argument,t,g),ae(e.operator)}),UpdateExpression:ve(function(e,t){return we(e.argument,t,g),H.num}),BinaryExpression:ve(function(e,t){if("+"!=e.operator)return we(e.left,t,g),we(e.right,t,g),pe(e.operator)?H.bool:H.num;var r=we(e.left,t),n=we(e.right,t);if(r.hasType(H.str)||n.hasType(H.str))return H.str;if(r.hasType(H.num)&&n.hasType(H.num))return H.num;var o=new d;return r.propagate(new A(n,o)),n.propagate(new A(r,o)),o}),AssignmentExpression:ve(function(e,t,r){var n,o;if("MemberExpression"==e.left.type?(o=ie(e.left,t),r=r||("Identifier"==e.left.object.type?e.left.object.name+"."+o:o)):r||"Identifier"!=e.left.type||(r=e.left.name),n=e.operator&&"="!=e.operator&&"+="!=e.operator?(we(e.right,t,g),H.num):we(e.right,t,null,r),"MemberExpression"==e.left.type){var i=we(e.left.object,t);if("prototype"==o&&K(t,20),"<i>"==o){var s=e.left.property.name,a=t.props[s],p=a&&a.iteratesOver;if(p){K(t,20);var u="MemberExpression"==e.right.type&&e.right.computed&&e.right.property.name==s;return p.forAllProps(function(e,t,r){r&&"prototype"!=e&&"<i>"!=e&&i.propagate(new v(e,u?t:g))}),n}}i.propagate(new v(o,n,e.left.property)),function e(t){t.isEmpty()&&t.propertyOf&&(t.propertyOf.getProp(t.propertyName).addType(new I,f),e(t.propertyOf))}(i),"FunctionExpression"==e.right.type&&i.propagate(e.right.scope.fnType.self,2)}else he(e.left,t,n);return n}),LogicalExpression:me(function(e,t,r){we(e.left,t,r),we(e.right,t,r)}),ConditionalExpression:me(function(e,t,r){we(e.test,t,g),we(e.consequent,t,r),we(e.alternate,t,r)}),NewExpression:me(function(e,t,r,n){"Identifier"==e.callee.type&&e.callee.name in t.props&&K(t,20);for(var o=0,i=[];o<e.arguments.length;++o)i.push(we(e.arguments[o],t));var s=we(e.callee,t),a=new d;s.propagate(new x(a,n&&/\.prototype$/.test(n))),a.propagate(r,90),s.propagate(new b(a,i,e.arguments,new E(r)))}),CallExpression:me(function(e,t,r){for(var n=0,o=[];n<e.arguments.length;++n)o.push(we(e.arguments[n],t));var i,s,a,p,u=U(t).fnType;"MemberExpression"==e.callee.type?(i=we(e.callee.object,t),s=ie(e.callee,t),u&&("call"==s||"apply"==s)&&-1<u.args.indexOf(i)&&K(t,30),i.propagate(new w(s,o,e.arguments,r))):"Super"==e.callee.type&&H.curSuperCtor?(e.callee.superType=H.curSuperCtor,H.curSuperCtor.propagate(new b(ge(t),o,e.arguments,r)),ge(t).propagate(r,90)):(a=we(e.callee,t),u&&-1<u.args.indexOf(a)&&K(t,30),(p=a.getFunctionType())&&p.instantiateScore&&u&&K(t,p.instantiateScore/5),a.propagate(new b(H.topScope,o,e.arguments,r)))}),AwaitExpression:me(function(e,t,r,n){var o=we(e.argument,t,null,n),i=o.getType();i&&i.constructor==I&&"Promise"==i.name?i.hasProp(":t")&&i.getProp(":t").propagate(r):o.propagate(r)}),MemberExpression:me(function(e,t,r){var n,o,i,s=ie(e);"<i>"==s&&((i=se(o=we(e.property,t)))?s=e.propName=i:o.hasType(H.num)||(n=6)),we(e.object,t).getProp(s).propagate(r,n)}),Identifier:ve(function(e,t){var r;return"arguments"==e.name&&(!(r=U(t,!1)).fnType||e.name in r.props||r.defProp(e.name,r.fnType.originNode).addType(new q(r.fnType.arguments=new d))),t.getProp(e.name)}),ThisExpression:ve(function(e,t){return ge(t)}),Super:ve(function(e){return e.superType=H.curSuper||g}),Literal:ve(ue),TemplateLiteral:ve(function(e,t){for(var r=0;r<e.expressions.length;++r)we(e.expressions[r],t,g);return H.str}),TaggedTemplateExpression:me(function(e,t,r){for(var n=[new q(H.str)],o=0;o<e.quasi.expressions.length;++o)n.push(we(e.quasi.expressions[o],t));we(e.tag,t,new b(H.topScope,n,e.quasi.expressions,r))}),YieldExpression:ve(function(e,t){var r=g,n=U(t).fnType;return n&&(n.retval==g&&(n.retval=new d),n.yieldval||(n.yieldval=new d),r=n.retval),e.argument&&(e.delegate?we(e.argument,t,new w("next",[],null,new p("value",r))):we(e.argument,t,r)),n?n.yieldval:g})};function we(e,t,r,n){var o=be[e.type];return o?o(e,t,r,n):g}function xe(e){return"VariableDeclaration"==e.type?e.declarations[0].id:e}be.ArrowFunctionExpression=be.FunctionExpression;var Pe=u.inferWrapper=h.make({Expression:function(e,t){we(e,e.scope||t,g)},ObjectExpression:function(e,t){we(e,e.scope||t,g)},FunctionDeclaration:function(e,t,r){var n=e.scope,o=n.fnType;fe(e,n),r(e.body,n,"Statement"),J(e,o)||Q(o),e.id&&t.getProp(e.id.name).addType(o)},Statement:function(e,t,r){r(e,e.scope||t)},ExportDefaultDeclaration:function(e,t,r){r(e.declaration,e.scope||t)},VariableDeclaration:function(e,t){for(var r=0;r<e.declarations.length;++r){var n,o=e.declarations[r];"Identifier"==o.id.type?(n=t.getProp(o.id.name),o.init&&we(o.init,t,n,o.id.name)):o.init&&he(o.id,t,we(o.init,t))}},ClassDeclaration:function(e,t){e.id?t.getProp(e.id.name).addType(de(e,t,e.id.name)):de(e,t)},ReturnStatement:function(e,t){var r,n;e.argument&&(r=g,(n=U(t).fnType)&&(n.retval==g&&(n.retval=new d),r=n.retval),we(e.argument,t,r))},ForInStatement:function(e,t,r){var n,o=we(e.right,t);("Identifier"==e.right.type&&e.right.name in t.props||"MemberExpression"==e.right.type&&"prototype"==e.right.property.name)&&(K(t,5),"Identifier"==(n=xe(e.left)).type?(n.name in t.props&&(t.getProp(n.name).iteratesOver=o),o.getProp("<i>").propagate(le(n,t))):he(n,t,o.getProp("<i>"))),r(e.body,t,"Statement")},ForOfStatement:function(e,t,r){var n,o=xe(e.left);"Identifier"==o.type?n=le(o,t):he(o,t,n=new d),e.await?we(e.right,t,new w(":Symbol.asyncIterator",[],null,new w("next",[],null,new p(":t",new p("value",n))))):we(e.right,t,new w(":Symbol.iterator",[],null,new w("next",[],null,new p("value",n)))),r(e.body,t,"Statement")}}),Te=u.parse=function(t,r,e){var n;r&&!Array.isArray(r)||(r=e);try{n=o.parse(t,r)}catch(e){n=i.parse(t,r)}return n};function Oe(e,t,r){var n=H.definitions.ecmascript,o=new I(!0);o.defProp("done").addType(H.bool),t.propagate(o.defProp("value"));var i=o;r&&n&&(i=new I(n["Promise.prototype"])).getType().propagate(new v(":t",o));var s=new L(null,g,e?[e]:[],e?["?"]:[],i),a=new I(!n||(r?n.async_generator_prototype:n.generator_prototype));return a.defProp("next").addType(s),a}function Ae(e,t){return e.generator?e.computeRet?Oe(e.yieldval,t,e.async):(!0===e.generator&&(e.generator=Oe(e.yieldval,t,e.async)),e.generator):t}function Ee(e,t,r){var n=Ne(e,r).getFunctionType();if(!n)return g;var o=n.retval;if(n.computeRet){for(var i=0,s=[];i<t.length;++i)s.push(Ne(t[i],r));var a=g;"MemberExpression"==e.type&&(a=Ne(e.object,r)),o=n.computeRet(a,s,t)}return Ae(n,o)}u.analyze=function(e,t,r){"string"==typeof e&&(e=Te(e)),t=t||"file#"+H.origins.length,u.addOrigin(H.curOrigin=t),r=r||H.topScope,H.startAnalysis(),h.recursive(e,r,null,re),H.parent&&H.parent.signal("preInfer",e,r),h.recursive(e,r,null,Pe),H.parent&&H.parent.signal("postInfer",e,r),H.curOrigin=null},u.purge=function(e,t,r){var n=function(r,n,o){var e=Array.isArray(r);e&&1==r.length&&(r=r[0],e=!1);return e?null==o?function(e){return-1<r.indexOf(e.origin)}:function(e,t){return t&&t.start>=n&&t.end<=o&&-1<r.indexOf(e.origin)}:null==o?function(e){return e.origin==r}:function(e,t){return t&&t.start>=n&&t.end<=o&&e.origin==r}}(e,t,r);for(var o in++H.purgeGen,H.topScope.purge(n),H.props){for(var i=H.props[o],s=0;s<i.length;++s){var a=i[s].props[o];a&&!n(a,a.originNode)||i.splice(s--,1)}i.length||delete H.props[o]}},d.prototype.purge=function(e){if(this.purgeGen!=H.purgeGen){this.purgeGen=H.purgeGen;for(var t=0;t<this.types.length;++t){var r=this.types[t];e(r,r.originNode)?this.types.splice(t--,1):r.purge(e)}if(this.types.length||(this.maxWeight=0),this.forward)for(t=0;t<this.forward.length;++t){var n=this.forward[t];e(n)?(this.forward.splice(t--,1),this.props&&(this.props=null)):n.purge&&n.purge(e)}}},g.purge=function(){},I.prototype.purge=function(e){if(this.purgeGen==H.purgeGen)return!0;for(var t in this.purgeGen=H.purgeGen,this.props){var r=this.props[t];e(r,r.originNode)&&this.removeProp(t),r.purge(e)}},L.prototype.purge=function(e){if(!I.prototype.purge.call(this,e)){this.self.purge(e),this.retval.purge(e);for(var t=0;t<this.args.length;++t)this.args[t].purge(e)}};var je=u.typeFinder={ArrayExpression:function(e,t){return ye(e.elements,t,Ne)},ObjectExpression:function(e){return e.objType},ClassDeclaration:function(e){return e.objType},ClassExpression:function(e){return e.objType},FunctionDeclaration:function(e){return e.scope.fnType},FunctionExpression:function(e){return e.scope.fnType},ArrowFunctionExpression:function(e){return e.scope.fnType},SequenceExpression:function(e,t){return Ne(e.expressions[e.expressions.length-1],t)},UnaryExpression:function(e){return ae(e.operator)},UpdateExpression:function(){return H.num},BinaryExpression:function(e,t){if(pe(e.operator))return H.bool;if("+"==e.operator){var r=Ne(e.left,t),n=Ne(e.right,t);if(r.hasType(H.str)||n.hasType(H.str))return H.str}return H.num},AssignmentExpression:function(e,t){return Ne(e.right,t)},LogicalExpression:function(e,t){var r=Ne(e.left,t);return r.isEmpty()?Ne(e.right,t):r},ConditionalExpression:function(e,t){var r=Ne(e.consequent,t);return r.isEmpty()?Ne(e.alternate,t):r},NewExpression:function(e,t){var r=Ne(e.callee,t).getFunctionType(),n=r&&r.getProp("prototype").getObjType();return n?P(n,r):g},CallExpression:function(e,t){return Ee(e.callee,e.arguments,t)},MemberExpression:function(e,t){var r=ie(e),n=Ne(e.object,t).getType();return n?n.getProp(r):"<i>"==r?g:function(e){ke=!0;var t=_(e);if(t)for(var r=0;r<t.length;++r){var n=t[r].getProp(e);if(!n.isEmpty())return n}return g}(r)},MethodDefinition:function(e){var t=ie(e),r=ge(e.value.scope).getType();return r?r.getProp(t):g},Identifier:function(e,t){return t.hasProp(e.name)||g},ThisExpression:function(e,t){return ge(t)},Literal:ue,Super:ve(function(e){return e.superType}),TemplateLiteral:function(){return H.str},TaggedTemplateExpression:function(e,t){return Ee(e.tag,e.quasi.expressions,t)},YieldExpression:function(e,t){var r=U(t).fnType;return r?r.yieldval:g}};function Ne(e,t){var r=je[e.type];return r?r(e,t):g}var Fe=u.searchVisitor=h.make({Function:function(e,t,r){h.base.Function(e,e.scope,r)},CatchClause:function(e,t,r){h.base.CatchClause(e,e.scope,r)},Property:function(e,t,r){e.computed&&r(e.key,t,"Expression"),e.key!=e.value&&r(e.value,t,"Expression")},Statement:function(e,t,r){r(e,e.scope||t)},ImportSpecifier:function(e,t,r){r(e.local,t)},ImportDefaultSpecifier:function(e,t,r){r(e.local,t)},ImportNamespaceSpecifier:function(e,t,r){r(e.local,t)}}),Se=u.searchExprVisitor=h.make({MemberExpression:function(e,t,r){r(e.object,t,"Expression"),e.computed&&r(e.property,t,"Expression")},Property:function(e,t,r){e.computed&&r(e.key,t,"Expression"),r(e.value,t,"Expression")}},Fe);u.fullVisitor=h.make({MemberExpression:function(e,t,r){r(e.object,t,"Expression"),r(e.property,t,e.computed?"Expression":null)},Property:function(e,t,r){e.computed&&r(e.key,t,"Expression"),r(e.value,t,"Expression")}},Fe),u.findExpressionAt=function(e,t,r,n,o){var i=o||function(e,t){return("Identifier"!=t.type||"✖"!=t.name)&&je.hasOwnProperty(t.type)};return h.findNodeAt(e,t,r,i,Se,n||H.topScope)},u.findClosestExpression=function(e,r,t,n,o){var i=o||function(e,t){return!(null!=r&&t.start>r)&&(("Identifier"!=t.type||"✖"!=t.name)&&je.hasOwnProperty(t.type))};return h.findNodeAround(e,t,i,Se,n||H.topScope)},u.findExpressionAround=function(e,r,t,n,o){var i=o||function(e,t){return!(null!=r&&t.start>r)&&(("Identifier"!=t.type||"✖"!=t.name)&&je.hasOwnProperty(t.type))};return h.findNodeAround(e,t,i,Fe,n||H.topScope)},u.expressionType=function(e){return Ne(e.node,e.state)},u.parentNode=function(i,e){var s=[];try{!function e(t,r,n){if(t.start<=i.start&&t.end>=i.end){var o=s[s.length-1];if(t==i)throw{found:o};o!=t&&s.push(t),h.base[n||t.type](t,r,e),o!=t&&s.pop()}}(e,null)}catch(e){if(e.found)return e.found;throw e}};var Ce=u.findTypeFromContext={ArrayExpression:function(e,t,r){return r(e,!0).getProp("<i>")},ObjectExpression:function(e,t,r){for(var n=0;n<e.properties.length;++n){var o=t.properties[n];if(o.value==t)return r(e,!0).getProp(ie(o))}},UnaryExpression:function(e){return ae(e.operator)},UpdateExpression:function(){return H.num},BinaryExpression:function(e){return pe(e.operator)?H.bool:H.num},AssignmentExpression:function(e,t,r){return r(e.left)},LogicalExpression:function(e,t,r){return r(e,!0)},ConditionalExpression:function(e,t,r){if(e.consequent==t||e.alternate==t)return r(e,!0)},CallExpression:function(e,t,r){for(var n=0;n<e.arguments.length;n++){if(e.arguments[n]==t){var o=r(e.callee).getFunctionType();if(o instanceof L)return o.args[n];break}}},ReturnStatement:function(e,t,r){var n=h.findNodeAround(t.sourceFile.ast,t.start-1,"Function");if(n){var o="FunctionDeclaration"!=n.node.type?r(n.node,!0).getFunctionType():n.node.scope.fnType;if(o)return o.retval.getType()}},VariableDeclarator:function(e,t,r){if(e.init==t)return r(e.id)}};Ce.NewExpression=Ce.CallExpression;var ke=!(u.typeFromContext=function(n,o){var e,t=u.parentNode(o.node,n),r=null;return Ce.hasOwnProperty(t.type)&&(r=(e=Ce[t.type])&&e(t,o.node,function(e,t){var r={node:e,state:o.state};return(t?u.typeFromContext(n,r):u.expressionType(r))||g})),r||u.expressionType(o)});u.resetGuessing=function(e){ke=e},u.didGuess=function(){return ke},u.forAllPropertiesOf=function(e,t){e.gatherProperties(t,0)},u.findRefs=function(i,e,s,a,p){function t(e,t,r){var n=r[r.length-2];if(("MemberExpression"!=n.type||n.computed||!e.object)&&e.name==s&&(e!=i.id||"FunctionDeclaration"!=i.type)&&n.property!==e)for(var o=t;o;o=o.prev)if(o==a&&p(e,t,r),s in o.props)return}h.ancestor(i,{Identifier:t,VariablePattern:t},u.fullVisitor,e)};var Ie=h.make({Function:function(e,t,r){r(e.body,e.scope,e.expression?"Expression":"Statement")},Statement:function(e,t,r){r(e,e.scope||t)}});u.findPropRefs=function(e,t,n,o,i){for(;n&&!n.props[o]&&(!n.maybeProps||!n.maybeProps[o]);)n=n.proto;if(!n)throw new Error("Couldn't locate property in the base object type.");function r(e){for(;e&&e!=n;){if(e.props[o]||e.maybeProps&&e.maybeProps[o])return;e=e.proto}return e}h.simple(e,{MemberExpression:function(e,t){e.computed||ie(e)!=o||r(Ne(e.object,t).getType())&&i(e.property,t)},ObjectExpression:function(e,t){if(Ne(e,t).getType()==n)for(var r=0;r<e.properties.length;++r)ie(e.properties[r])==o&&i(e.properties[r].key,t)},MethodDefinition:function(e){ie(e)==o&&e.value&&r(ge(e.value.scope).getType())&&i(e.key,e.value.scope)}},Ie,t)};var De=u.scopeAt=function(e,t,r){var n=h.findNodeAround(e,t,function(e,t){return t.scope});return n?n.node.scope:r||H.topScope};u.forAllLocalsAt=function(e,t,r,n){De(e,t,r).gatherProperties(n,0)},s=u.def=s.init({},u)}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/infer"),require("../lib/tern"),require("acorn-walk")):"function"==typeof define&&define.amd?define(["../lib/infer","../lib/tern","acorn-walk/dist/walk"],e):e(tern,tern,acorn.walk)}(function(u,f,e){"use strict";function r(t){var r=u.cx().parent.mod.completeStrings;e.simple(t,{Literal:function(e){"string"==typeof e.value&&e.value&&e.value.length<r.maxLen&&(r.seen[e.value]=t.sourceFile.name)}})}function n(e,t){var r=f.resolvePos(e,t.end),n=u.findExpressionAround(e.ast,null,r,e.scope,"Literal");if(n&&"string"==typeof n.node.value){var o,i=n.node.value.slice(0,r-n.node.start-1),s=[],a=u.cx().parent.mod.completeStrings.seen;for(var p in a){p.length>i.length&&0==p.indexOf(i)&&(t.types||t.docs||t.urls||t.origins?(o={name:JSON.stringify(p),displayName:p},s.push(o),t.types&&(o.type="string"),t.origins&&(o.origin=a[p])):s.push(JSON.stringify(p)))}return s.length?{start:f.outputPos(t,e,n.node.start),end:f.outputPos(t,e,r+(e.text.charAt(r)==e.text.charAt(n.node.start)?1:0)),isProperty:!1,completions:s}:void 0}}f.registerPlugin("complete_strings",function(e,t){e.mod.completeStrings={maxLen:t&&t.maxLength||15,seen:Object.create(null)},e.on("reset",function(){e.mod.completeStrings.seen=Object.create(null)}),e.on("postParse",r),e.on("completion",n)})});