#!/usr/bin/env node module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};e[t].call(r.exports,r,r.exports,__webpack_require__);r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(236)}return startup()}({2:function(e,t,n){"use strict";var r=n(324);e.exports=r;r.prototype.done=function(e,t){var n=arguments.length?this.then.apply(this,arguments):this;n.then(null,function(e){setTimeout(function(){throw e},0)})}},60:function(e,t,n){"use strict";var r=n(928);var o=[];e.exports=asap;function asap(e){var t;if(o.length){t=o.pop()}else{t=new RawTask}t.task=e;t.domain=process.domain;r(t)}function RawTask(){this.task=null;this.domain=null}RawTask.prototype.call=function(){if(this.domain){this.domain.enter()}var e=true;try{this.task.call();e=false;if(this.domain){this.domain.exit()}}finally{if(e){r.requestFlush()}this.task=null;this.domain=null;o.push(this)}}},87:function(e){e.exports=require("os")},129:function(e){e.exports=require("child_process")},184:function(e){e.exports=require("vm")},191:function(e){e.exports=require("querystring")},211:function(e){e.exports=require("https")},229:function(e){e.exports=require("domain")},234:function(e,t,n){var r=n(697);e.exports=function(){return function(e,t,n){if(e===" ")return e;switch(t%3){case 0:return r.red(e);case 1:return r.white(e);case 2:return r.blue(e)}}}()},236:function(__unusedmodule,exports,__webpack_require__){"use strict";const colors=__webpack_require__(493);const fs=__webpack_require__(747);const http=__webpack_require__(605);const https=__webpack_require__(211);const path=__webpack_require__(622);const program=__webpack_require__(721);const Promise=__webpack_require__(700);const querystring=__webpack_require__(191);const url=__webpack_require__(835);const util=__webpack_require__(669);const vm=__webpack_require__(184);const DEFAULT_USER_AGENT="amphtml-validator";function hasPrefix(e,t){return e.indexOf(t)==0}function isHttpOrHttpsUrl(e){return hasPrefix(e,"http://")||hasPrefix(e,"https://")}function readFromFile(e){return new Promise(function(t,n){fs.readFile(e,"utf8",function(e,r){if(e){n(e)}else{t(r.trim())}})})}function readFromReadable(e,t){return new Promise(function(n,r){const o=[];t.setEncoding("utf8");t.on("data",function(e){o.push(e)});t.on("end",function(){n(o.join(""))});t.on("error",function(t){r(new Error("Could not read from "+e+" - "+t.message))})})}function readFromStdin(){return readFromReadable("stdin",process.stdin).then(function(e){process.stdin.resume();return e})}function readFromUrl(e,t){return new Promise(function(n,r){const o=hasPrefix(e,"http://")?http:https;const i=o.request(e,function(t){if(t.statusCode!==200){t.resume();r(new Error("Unable to fetch "+e+" - HTTP Status "+t.statusCode))}else{n(t)}});i.setHeader("User-Agent",t);i.on("error",function(t){r(new Error("Unable to fetch "+e+" - "+t.message))});i.end()}).then(readFromReadable.bind(null,e))}function ValidationResult(){this.status="UNKNOWN";this.errors=[]}function ValidationError(){this.severity="UNKNOWN_SEVERITY";this.line=1;this.col=0;this.message="";this.specUrl=null;this.code="UNKNOWN_CODE";this.params=[]}function Validator(e){this.sandbox=vm.createContext();try{new vm.Script(e).runInContext(this.sandbox)}catch(e){throw new Error("Could not instantiate validator.js - "+e.message)}}Validator.prototype.validateString=function(e,t){const n=this.sandbox.amp.validator.validateString(e,t);const r=new ValidationResult;r.status=n.status;for(let e=0;e\n\n"+' Validates the files or urls provided as arguments. If "-" is\n'+" specified, reads from stdin instead.").option("--validator_js ","The Validator Javascript.\n"+" Latest published version by default, or\n"+" dist/validator_minified.js (built with build.py)\n"+" for development.","https://cdn.ampproject.org/v0/validator.js").option("--user-agent ","User agent string to use in requests.",DEFAULT_USER_AGENT).option("--html_format ","The input format to be validated.\n"+" AMP by default.","AMP").option("--format ","How to format the output.\n"+' "color" displays errors/warnings/success in\n'+" red/orange/green.\n"+' "text" avoids color (e.g., useful in terminals not\n'+" supporting color).\n"+' "json" emits json corresponding to the ValidationResult\n'+" message in validator.proto.","color").parse(process.argv);if(program.args.length===0){program.outputHelp();process.exit(1)}if(program.html_format!=="AMP"&&program.html_format!=="AMP4ADS"&&program.html_format!=="AMP4EMAIL"&&program.html_format!=="ACTIONS"){process.stderr.write('--html_format must be set to "AMP", "AMP4ADS", "AMP4EMAIL", or '+'"ACTIONS.\n',function(){process.exit(1)})}if(program.format!=="color"&&program.format!=="text"&&program.format!=="json"){process.stderr.write('--format must be set to "color", "text", or "json".\n',function(){process.exit(1)})}const e=[];for(let t=0;t "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+i+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":"+"res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");"+"break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(r,e)}r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments);var n=typeof t[t.length-1]==="function"?t.pop():null;var i=this;try{return e.apply(this,arguments).nodeify(n,i)}catch(e){if(n===null||typeof n=="undefined"){return new r(function(t,n){n(e)})}else{o(function(){n.call(i,e)})}}}};r.prototype.nodeify=function(e,t){if(typeof e!="function")return this;this.then(function(n){o(function(){e.call(t,null,n)})},function(n){o(function(){e.call(t,n)})})}},396:function(e){"use strict";e.exports=function(e,t){t=t||process.argv;var n=t.indexOf("--");var r=/^-{1,2}/.test(e)?"":"--";var o=t.indexOf(r+e);return o!==-1&&(n===-1?true:o1&&!/^[[<]/.test(e[1]))this.short=e.shift();this.long=e.shift();this.description=t||""}Option.prototype.name=function(){return this.long.replace("--","").replace("no-","")};Option.prototype.attributeName=function(){return camelcase(this.name())};Option.prototype.is=function(e){return this.short===e||this.long===e};function Command(e){this.commands=[];this.options=[];this._execs={};this._allowUnknownOption=false;this._args=[];this._name=e||""}Command.prototype.command=function(e,t,n){if(typeof t==="object"&&t!==null){n=t;t=null}n=n||{};var r=e.split(/ +/);var o=new Command(r.shift());if(t){o.description(t);this.executables=true;this._execs[o._name]=true;if(n.isDefault)this.defaultExecutable=o._name}o._noHelp=!!n.noHelp;this.commands.push(o);o.parseExpectedArgs(r);o.parent=this;if(t)return this;return o};Command.prototype.arguments=function(e){return this.parseExpectedArgs(e.split(/ +/))};Command.prototype.addImplicitHelpCommand=function(){this.command("help [cmd]","display help for [cmd]")};Command.prototype.parseExpectedArgs=function(e){if(!e.length)return;var t=this;e.forEach(function(e){var n={required:false,name:"",variadic:false};switch(e[0]){case"<":n.required=true;n.name=e.slice(1,-1);break;case"[":n.name=e.slice(1,-1);break}if(n.name.length>3&&n.name.slice(-3)==="..."){n.variadic=true;n.name=n.name.slice(0,-3)}if(n.name){t._args.push(n)}});return this};Command.prototype.action=function(e){var t=this;var n=function(n,r){n=n||[];r=r||[];var o=t.parseOptions(r);outputHelpIfNecessary(t,o.unknown);if(o.unknown.length>0){t.unknownOption(o.unknown[0])}if(o.args.length)n=o.args.concat(n);t._args.forEach(function(e,r){if(e.required&&n[r]==null){t.missingArgument(e.name)}else if(e.variadic){if(r!==t._args.length-1){t.variadicArgNotLast(e.name)}n[r]=n.splice(r)}});if(t._args.length){n[t._args.length]=t}else{n.push(t)}e.apply(t,n)};var r=this.parent||this;var o=r===this?"*":this._name;r.on("command:"+o,n);if(this._alias)r.on("command:"+this._alias,n);return this};Command.prototype.option=function(e,t,n,r){var o=this,i=new Option(e,t),s=i.name(),u=i.attributeName();if(typeof n!=="function"){if(n instanceof RegExp){var a=n;n=function(e,t){var n=a.exec(e);return n?n[0]:t}}else{r=n;n=null}}if(!i.bool||i.optional||i.required){if(!i.bool)r=true;if(r!==undefined){o[u]=r;i.defaultValue=r}}this.options.push(i);this.on("option:"+s,function(e){if(e!==null&&n){e=n(e,o[u]===undefined?r:o[u])}if(typeof o[u]==="boolean"||typeof o[u]==="undefined"){if(e==null){o[u]=i.bool?r||true:false}else{o[u]=e}}else if(e!==null){o[u]=e}});return this};Command.prototype.allowUnknownOption=function(e){this._allowUnknownOption=arguments.length===0||e;return this};Command.prototype.parse=function(e){if(this.executables)this.addImplicitHelpCommand();this.rawArgs=e;this._name=this._name||u(e[1],".js");if(this.executables&&e.length<3&&!this.defaultExecutable){e.push("--help")}var t=this.parseOptions(this.normalize(e.slice(2)));var n=this.args=t.args;var r=this.parseArgs(this.args,t.unknown);var o=r.args[0];var i=null;if(o){i=this.commands.filter(function(e){return e.alias()===o})[0]}if(this._execs[o]&&typeof this._execs[o]!=="function"){return this.executeSubCommand(e,n,t.unknown)}else if(i){n[0]=i._name;return this.executeSubCommand(e,n,t.unknown)}else if(this.defaultExecutable){n.unshift(this.defaultExecutable);return this.executeSubCommand(e,n,t.unknown)}return r};Command.prototype.executeSubCommand=function(e,t,n){t=t.concat(n);if(!t.length)this.help();if(t[0]==="help"&&t.length===1)this.help();if(t[0]==="help"){t[0]=t[1];t[1]="--help"}var r=e[1];var c=u(r,".js")+"-"+t[0];var f,l=a.lstatSync(r).isSymbolicLink()?a.readlinkSync(r):r;if(l!==r&&l.charAt(0)!=="/"){l=i.join(s(r),l)}f=s(l);var p=i.join(f,c);var h=false;if(exists(p+".js")){c=p+".js";h=true}else if(exists(p)){c=p}t=t.slice(1);var m;if(process.platform!=="win32"){if(h){t.unshift(c);t=(process.execArgv||[]).concat(t);m=o(process.argv[0],t,{stdio:"inherit",customFds:[0,1,2]})}else{m=o(c,t,{stdio:"inherit",customFds:[0,1,2]})}}else{t.unshift(c);m=o(process.execPath,t,{stdio:"inherit"})}var d=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];d.forEach(function(e){process.on(e,function(){if(m.killed===false&&m.exitCode===null){m.kill(e)}})});m.on("close",process.exit.bind(process));m.on("error",function(e){if(e.code==="ENOENT"){console.error("\n %s(1) does not exist, try --help\n",c)}else if(e.code==="EACCES"){console.error("\n %s(1) not executable. try chmod or run with root\n",c)}process.exit(1)});this.runningCommand=m};Command.prototype.normalize=function(e){var t=[],n,r,o;for(var i=0,s=e.length;i0){r=this.optionFor(e[i-1])}if(n==="--"){t=t.concat(e.slice(i));break}else if(r&&r.required){t.push(n)}else if(n.length>1&&n[0]==="-"&&n[1]!=="-"){n.slice(1).split("").forEach(function(e){t.push("-"+e)})}else if(/^--/.test(n)&&~(o=n.indexOf("="))){t.push(n.slice(0,o),n.slice(o+1))}else{t.push(n)}}return t};Command.prototype.parseArgs=function(e,t){var n;if(e.length){n=e[0];if(this.listeners("command:"+n).length){this.emit("command:"+e.shift(),e,t)}else{this.emit("command:*",e)}}else{outputHelpIfNecessary(this,t);if(t.length>0){this.unknownOption(t[0])}}return this};Command.prototype.optionFor=function(e){for(var t=0,n=this.options.length;t1&&i[0]==="-"){s.push(i);if(u+1e){e=this.largestArgLength()}}if(this.commands&&this.commands.length){if(this.largestCommandLength()>e){e=this.largestCommandLength()}}return e};Command.prototype.optionHelp=function(){var e=this.padWidth();return this.options.map(function(t){return pad(t.flags,e)+" "+t.description+(t.bool&&t.defaultValue!==undefined?" (default: "+t.defaultValue+")":"")}).concat([pad("-h, --help",e)+" "+"output usage information"]).join("\n")};Command.prototype.commandHelp=function(){if(!this.commands.length)return"";var e=this.prepareCommands();var t=this.padWidth();return[" Commands:","",e.map(function(e){var n=e[1]?" "+e[1]:"";return(n?pad(e[0],t):e[0])+n}).join("\n").replace(/^/gm," "),""].join("\n")};Command.prototype.helpInformation=function(){var e=[];if(this._description){e=[" "+this._description,""];var t=this._argsDescription;if(t&&this._args.length){var n=this.padWidth();e.push(" Arguments:");e.push("");this._args.forEach(function(r){e.push(" "+pad(r.name,n)+" "+t[r.name])});e.push("")}}var r=this._name;if(this._alias){r=r+"|"+this._alias}var o=[""," Usage: "+r+" "+this.usage(),""];var i=[];var s=this.commandHelp();if(s)i=[s];var u=[" Options:","",""+this.optionHelp().replace(/^/gm," "),""];return o.concat(e).concat(u).concat(i).join("\n")};Command.prototype.outputHelp=function(e){if(!e){e=function(e){return e}}process.stdout.write(e(this.helpInformation()));this.emit("--help")};Command.prototype.help=function(e){this.outputHelp(e);process.exit()};function camelcase(e){return e.split("-").reduce(function(e,t){return e+t[0].toUpperCase()+t.slice(1)})}function pad(e,t){var n=Math.max(0,t-e.length);return e+Array(n+1).join(" ")}function outputHelpIfNecessary(e,t){t=t||[];for(var n=0;n":"["+t+"]"}function exists(e){try{if(a.statSync(e).isFile()){return true}}catch(e){return false}}},747:function(e){e.exports=require("fs")},775:function(e,t,n){"use strict";var r=n(87);var o=n(396);var i=process.env;var s=void 0;if(o("no-color")||o("no-colors")||o("color=false")){s=false}else if(o("color")||o("colors")||o("color=true")||o("color=always")){s=true}if("FORCE_COLOR"in i){s=i.FORCE_COLOR.length===0||parseInt(i.FORCE_COLOR,10)!==0}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e){if(s===false){return 0}if(o("color=16m")||o("color=full")||o("color=truecolor")){return 3}if(o("color=256")){return 2}if(e&&!e.isTTY&&s!==true){return 0}var t=s?1:0;if(process.platform==="win32"){var n=r.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(n[0])>=10&&Number(n[2])>=10586){return Number(n[2])>=14931?3:2}return 1}if("CI"in i){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(e){return e in i})||i.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in i){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0}if("TERM_PROGRAM"in i){var u=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(i.TERM)){return 2}if(/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)){return 1}if("COLORTERM"in i){return 1}if(i.TERM==="dumb"){return t}return t}function getSupportLevel(e){var t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},835:function(e){e.exports=require("url")},837:function(e,t,n){"use strict";var r=n(324);e.exports=r;r.enableSynchronous=function(){r.prototype.isPending=function(){return this.getState()==0};r.prototype.isFulfilled=function(){return this.getState()==1};r.prototype.isRejected=function(){return this.getState()==2};r.prototype.getValue=function(){if(this._83===3){return this._18.getValue()}if(!this.isFulfilled()){throw new Error("Cannot get a value of an unfulfilled promise.")}return this._18};r.prototype.getReason=function(){if(this._83===3){return this._18.getReason()}if(!this.isRejected()){throw new Error("Cannot get a rejection reason of a non-rejected promise.")}return this._18};r.prototype.getState=function(){if(this._83===3){return this._18.getState()}if(this._83===-1||this._83===-2){return 0}return this._83}};r.disableSynchronous=function(){r.prototype.isPending=undefined;r.prototype.isFulfilled=undefined;r.prototype.isRejected=undefined;r.prototype.getValue=undefined;r.prototype.getReason=undefined;r.prototype.getState=undefined}},853:function(e,t,n){var r=n(697);e.exports=function(){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"];return function(t,n,o){return t===" "?t:r[e[Math.round(Math.random()*(e.length-2))]](t)}}()},899:function(e,t,n){var r=n(697);e.exports=function(e,t,n){return t%2===0?e:r.inverse(e)}},928:function(e,t,n){"use strict";var r;var o=typeof setImmediate==="function";e.exports=rawAsap;function rawAsap(e){if(!i.length){requestFlush();s=true}i[i.length]=e}var i=[];var s=false;var u=0;var a=1024;function flush(){while(ua){for(var t=0,n=i.length-u;t