UNPKG

78.4 kBJavaScriptView Raw
1
2(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define(["exports"],factory);}else if(typeof exports!=="undefined"){factory(exports);}else if(typeof module!=="undefined"&&module.exports){factory(module.exports);}else{var newGpf={};factory(newGpf);root.gpf=newGpf;}}(this,function(gpf){"use strict";function _gpfEmptyFunc(){}var _gpfVersion="0.2.2",_GPF_HOST={BROWSER:"browser",NODEJS:"nodejs",PHANTOMJS:"phantomjs",RHINO:"rhino",UNKNOWN:"unknown",WSCRIPT:"wscript"},_gpfHost=_GPF_HOST.UNKNOWN,_gpfDosPath=false,_gpfMainContext=this,_gpfExit=_gpfEmptyFunc,_gpfWebWindow,_gpfWebDocument,_gpfMsFSO,_gpfNodeFs,_gpfNodePath,_gpfBootImplByHost={};if("undefined"!==typeof WScript){_gpfHost=_GPF_HOST.WSCRIPT;_gpfDosPath=true;}else if("undefined"!==typeof print&&"undefined"!==typeof java){_gpfHost=_GPF_HOST.RHINO;_gpfDosPath=false;}else if("undefined"!==typeof phantom&&phantom.version&&!document.currentScript){_gpfHost=_GPF_HOST.PHANTOMJS;_gpfDosPath=require("fs").separator==="\\";_gpfMainContext=window;}else if("undefined"!==typeof module&&module.exports){_gpfHost=_GPF_HOST.NODEJS;_gpfNodePath=require("path");_gpfDosPath=_gpfNodePath.sep==="\\";_gpfMainContext=global;}else if("undefined"!==typeof window){_gpfHost=_GPF_HOST.BROWSER;_gpfMainContext=window;}gpf.hosts={browser:_GPF_HOST.BROWSER,nodejs:_GPF_HOST.NODEJS,phantomjs:_GPF_HOST.PHANTOMJS,rhino:_GPF_HOST.RHINO,unknown:_GPF_HOST.UNKNOWN,wscript:_GPF_HOST.WSCRIPT};gpf.host=function(){return _gpfHost;};gpf.version=function(){return _gpfVersion;};function _gpfConsoleGenerate(outputLine){return{log:function(text){outputLine(" "+text);},info:function(text){outputLine("[?] "+text);},warn:function(text){outputLine("/!\\ "+text);},error:function(text){outputLine("(X) "+text);}};}_gpfBootImplByHost[_GPF_HOST.BROWSER]=function(){_gpfExit=function(code){window.location="https://arnaudbuchholz.github.io/gpf/exit.html?"+(code||0);};_gpfWebWindow=window;_gpfWebDocument=document;};var _gpfNodeHttp,_gpfNodeUrl;gpf.node={};_gpfBootImplByHost[_GPF_HOST.NODEJS]=function(){_gpfNodeFs=require("fs");_gpfNodeHttp=require("http");_gpfNodeUrl=require("url");_gpfExit=function(code){process.exit(code);};};_gpfBootImplByHost[_GPF_HOST.PHANTOMJS]=function(){_gpfExit=function(code){phantom.exit(code);};_gpfWebWindow=window;_gpfWebDocument=document;_gpfNodeFs=require("fs");};gpf.rhino={};_gpfBootImplByHost[_GPF_HOST.RHINO]=function(){_gpfMainContext.console=_gpfConsoleGenerate(print);_gpfExit=function(code){java.lang.System.exit(code);};};_gpfBootImplByHost[_GPF_HOST.UNKNOWN]=_gpfEmptyFunc;gpf.wscript={};function _gpfWScriptEcho(text){WScript.Echo(text);}_gpfBootImplByHost[_GPF_HOST.WSCRIPT]=function(){_gpfMsFSO=new ActiveXObject("Scripting.FileSystemObject");_gpfMainContext.console=_gpfConsoleGenerate(_gpfWScriptEcho);_gpfExit=function(code){WScript.Quit(code);};};_gpfBootImplByHost[_gpfHost]();var _gpfIsArray=Array.isArray;function _gpfArrayHasValidLengthProperty(obj){if(obj){return Math.floor(obj.length)===obj.length;}return false;}function _gpfIsArrayLike(obj){return _gpfIsArray(obj)||_gpfArrayHasValidLengthProperty(obj);}gpf.isArrayLike=_gpfIsArrayLike;function _gpfArrayForEach(array,callback,thisArg){var index,length=array.length;for(index=0;index<length;++index){callback.call(thisArg,array[index],index,array);}}function _gpfObjectForEachOwnProperty(object,callback,thisArg){for(var property in object){if(object.hasOwnProperty(property)){callback.call(thisArg,object[property],property,object);}}}function _gpfObjectForEachOwnPropertyWScript(object,callback,thisArg){_gpfObjectForEachOwnProperty(object,callback,thisArg);["constructor","toString"].forEach(function(property){if(object.hasOwnProperty(property)){callback.call(thisArg,object[property],property,object);}});}function _gpfArrayForEachFalsy(array,callback,thisArg){var result,index,length=array.length;for(index=0;index<length&&!result;++index){result=callback.call(thisArg,array[index],index,array);}return result;}var _gpfObjectForEach;if(_GPF_HOST.WSCRIPT===_gpfHost){_gpfObjectForEach=_gpfObjectForEachOwnPropertyWScript;}else{_gpfObjectForEach=_gpfObjectForEachOwnProperty;}gpf.forEach=function(container,callback,thisArg){if(_gpfIsArrayLike(container)){_gpfArrayForEach(container,callback,thisArg);return;}_gpfObjectForEach(container,callback,thisArg);};var _gpfAssert,_gpfAsserts,_gpfAssertWarn=true;function _gpfAssertConsoleWarn(message){if(_gpfAssertWarn){console.warn("ASSERTION FAILED: "+message);}}function _gpfAssertFailIfConditionFalsy(condition,message){if(!condition){_gpfAssertConsoleWarn(message);gpf.Error.assertionFailed({message:message});}}function _gpfAssertImpl(condition,message){if(undefined===message){message="Assertion with no message";condition=false;}_gpfAssertFailIfConditionFalsy(condition,message);}function _gpfAssertsImpl(assertions){_gpfObjectForEach(assertions,_gpfAssertFailIfConditionFalsy);}gpf.assert=_gpfAssertImpl;gpf.asserts=_gpfAssertsImpl;gpf.preventAssertWarnings=function(silent){_gpfAssertWarn=!silent;};var _GpfFunc=Function,_gpfMax31=2147483647,_gpfMax32=4294967295,_gpfAlpha="abcdefghijklmnopqrstuvwxyz",_gpfALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",_gpfDigit="0123456789",_gpfIdentifierFirstChar=_gpfAlpha+_gpfALPHA+"_$",_gpfIdentifierOtherChars=_gpfAlpha+_gpfALPHA+_gpfDigit+"_$",_gpfJsKeywords=["abstract","arguments","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","eval","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"];function _gpfFuncUnsafe(params,source){var args;if(0===params.length){return _GpfFunc(source);}args=[].concat(params);args.push(source);return _GpfFunc.apply(null,args);}function _gpfFuncImpl(params,source){return _gpfFuncUnsafe(params,source);}function _gpfFunc(params,source){if(undefined===source){source=params;params=[];}return _gpfFuncImpl(params,source);}function _gpfIsInRange(value,min,max){return min<=value&&value<=max;}gpf.web={};function _gpfStringCapitalize(that){return that.charAt(0).toUpperCase()+that.substr(1);}function _gpfStringReplaceEx(that,replacements){var result=that;_gpfObjectForEach(replacements,function(replacement,key){result=result.split(key).join(replacement);});return result;}var _gpfStringEscapes={};function _gpfStringEscapePostProcessFor(that,language){if("javascript"===language){return"\""+that+"\"";}return that;}function _gpfStringEscapeFor(that,language){return _gpfStringEscapePostProcessFor(_gpfStringReplaceEx(that,_gpfStringEscapes[language]),language);}_gpfStringEscapes.javascript={"\\":"\\\\","\"":"\\\"","\n":"\\n","\r":"\\r","\t":"\\t"};_gpfStringEscapes.xml={"&":"&amp;","<":"&lt;",">":"&gt;"};function _gpfInstallMissingMembers(on,members){_gpfObjectForEach(members,function(value,memberName){if(on[memberName]===undefined){on[memberName]=value;}});}function _gpfInstallCompatibleMethods(on,methods){if(methods){_gpfInstallMissingMembers(on.prototype,methods);}}function _gpfInstallCompatibleStatics(on,statics){if(statics){_gpfInstallMissingMembers(on,statics);}}function _gpfInstallCompatibility(typeName,description){var on=description.on;_gpfInstallCompatibleMethods(on,description.methods);_gpfInstallCompatibleStatics(on,description.statics);}function _gpfArrayBind(callback,thisArg){if(undefined!==thisArg){return callback.bind(thisArg);}return callback;}function _gpfArrayForEachOwn(array,callback){var len=array.length,idx=0;while(idx<len){if(array.hasOwnProperty(idx)){callback(array[idx],idx,array);}++idx;}}function _gpfArrayEveryOwn(array,callback,idx){var len=array.length;while(idx<len){if(array.hasOwnProperty(idx)&&true!==callback(array[idx],idx,array)){return false;}++idx;}return true;}function _gpfArrayEveryOwnFrom0(array,callback){return _gpfArrayEveryOwn(array,callback,0);}function _gpfArrayFromString(array,string){var length=string.length,index;for(index=0;index<length;++index){array.push(string.charAt(index));}}function _gpfArrayConvertFrom(arrayLike){var array=[];if("string"===typeof arrayLike){_gpfArrayFromString(array,arrayLike);}else{_gpfArrayForEach(arrayLike,function(value){array.push(value);},0);}return array;}function _gpfArrayFrom(arrayLike){var array=_gpfArrayConvertFrom(arrayLike),callback=arguments[1];if("function"===typeof callback){array=array.map(callback,arguments[2]);}return array;}_gpfInstallCompatibility("Array",{on:Array,methods:{every:function(callback){return _gpfArrayEveryOwnFrom0(this,_gpfArrayBind(callback,arguments[1]));},filter:function(callback){var result=[];callback=_gpfArrayBind(callback,arguments[1]);_gpfArrayForEachOwn(this,function(item,idx,array){if(callback(item,idx,array)){result.push(item);}});return result;},forEach:function(callback){_gpfArrayForEachOwn(this,_gpfArrayBind(callback,arguments[1]));},indexOf:function(searchElement){var result=-1;_gpfArrayEveryOwn(this,function(value,index){if(value===searchElement){result=index;return false;}return true;},arguments[1]||0);return result;},map:function(callback){var result=new Array(this.length);callback=_gpfArrayBind(callback,arguments[1]);_gpfArrayForEachOwn(this,function(item,index,array){result[index]=callback(item,index,array);});return result;},some:function(callback){callback=_gpfArrayBind(callback,arguments[1]);return!_gpfArrayEveryOwnFrom0(this,function(item,index,array){return!callback(item,index,array);});},reduce:function(callback){var initialValue=arguments[1],thisLength=this.length,index=0,value;if(undefined===initialValue){value=this[index++];}else{value=initialValue;}for(;index<thisLength;++index){value=callback(value,this[index],index,this);}return value;}},statics:{from:_gpfArrayFrom,isArray:function(arrayLike){return"[object Array]"==={}.toString.call(arrayLike);}}});if(!_gpfIsArray){_gpfIsArray=Array.isArray;}function _gpfBuildFunctionParameterList(count){if(0===count){return[];}return new Array(count).join(" ").split(" ").map(function(value,index){return"p"+index;});}function _gpfGenerateGenericFactorySource(parameters){var src=["var C = this, l = arguments.length;","if (0 === l) { return new C();}"];parameters.forEach(function(value,index){var count=index+1;src.push("if ("+count+" === l) { return new C("+parameters.slice(0,count).join(", ")+");}");});return src.join("\r\n");}function _gpfGenerateGenericFactory(maxParameters){var parameters=_gpfBuildFunctionParameterList(maxParameters);return _gpfFunc(parameters,_gpfGenerateGenericFactorySource(parameters));}var _gpfGenericFactory=_gpfGenerateGenericFactory(10);function _gpfNewApply(Constructor,parameters){if(parameters.length>_gpfGenericFactory.length){_gpfGenericFactory=_gpfGenerateGenericFactory(parameters.length);}return _gpfGenericFactory.apply(Constructor,parameters);}function _pad(number){if(10>number){return"0"+number;}return number;}function _gpfDateToISOString(date){return date.getUTCFullYear()+"-"+_pad(date.getUTCMonth()+1)+"-"+_pad(date.getUTCDate())+"T"+_pad(date.getUTCHours())+":"+_pad(date.getUTCMinutes())+":"+_pad(date.getUTCSeconds())+"."+(date.getUTCMilliseconds()/1000).toFixed(3).slice(2,5)+"Z";}_gpfInstallCompatibility("Date",{on:Date,methods:{toISOString:function(){return _gpfDateToISOString(this);}},statics:{now:function(){return new Date().getTime();}}});var _gpfISO8601RegExp=new RegExp("^([0-9][0-9][0-9][0-9])\\-([0-9][0-9])\\-([0-9][0-9])"+"(?:T([0-9][0-9])\\:([0-9][0-9])\\:([0-9][0-9])(?:\\.([0-9][0-9][0-9])Z)?)?$");function _gpfIsValidDateInDateArray(dateArray){return dateArray[1]<12&&dateArray[2]<32;}function _gpfIsValidTimeInDateArray(dateArray){return dateArray[3]<24&&dateArray[4]<60&&dateArray[5]<60;}function _gpfCheckDateArray(dateArray){if(_gpfIsValidDateInDateArray(dateArray)&&_gpfIsValidTimeInDateArray(dateArray)){return dateArray;}}function _gpfAddDatePartToArray(dateArray,datePart){if(datePart){dateArray.push(parseInt(datePart,10));}else{dateArray.push(0);}}function _gpfToDateArray(matchResult){var dateArray=[],len=matchResult.length,idx;for(idx=1;idx<len;++idx){_gpfAddDatePartToArray(dateArray,matchResult[idx]);}return dateArray;}function _gpfProcessISO8601MatchResult(matchResult){var dateArray;if(matchResult){dateArray=_gpfToDateArray(matchResult);--dateArray[1];return _gpfCheckDateArray(dateArray);}}function _gpfIsISO8601String(value){if("string"===typeof value){_gpfISO8601RegExp.lastIndex=0;return _gpfProcessISO8601MatchResult(_gpfISO8601RegExp.exec(value));}}var _GpfGenuineDate=_gpfMainContext.Date;function _GpfDate(){var firstArgument=arguments[0],values=_gpfIsISO8601String(firstArgument);if(values){return new _GpfGenuineDate(_GpfGenuineDate.UTC.apply(_GpfGenuineDate.UTC,values));}return _gpfNewApply(_GpfGenuineDate,arguments);}function _gpfCopyDateStatics(){_gpfArrayForEach(["prototype","UTC","parse","now"],function(member){_GpfDate[member]=_GpfGenuineDate[member];});}function _gpfInstallCompatibleDate(){_gpfCopyDateStatics();var longDateAsString,shortDateAsString;try{longDateAsString=_gpfDateToISOString(new Date("2003-01-22T22:45:34.075Z"));shortDateAsString=_gpfDateToISOString(new Date("2003-01-22"));}catch(e){}if(longDateAsString!=="2003-01-22T22:45:34.075Z"||shortDateAsString!=="2003-01-22T00:00:00.000Z"){_gpfMainContext.Date=_GpfDate;}}_gpfInstallCompatibleDate();var _gpfArrayPrototypeSlice=Array.prototype.slice;function _generateBindBuilderSource(length){return"var me = this;\n"+"return function ("+_gpfBuildFunctionParameterList(length).join(", ")+") {\n"+" var args = _gpfArrayPrototypeSlice.call(arguments, 0);\n"+" return me.apply(thisArg, prependArgs.concat(args));\n"+"};";}_gpfInstallCompatibility("Function",{on:Function,methods:{bind:function(thisArg){var me=this,prependArgs=_gpfArrayPrototypeSlice.call(arguments,1),builderSource=_generateBindBuilderSource(Math.max(this.length-prependArgs.length,0));return _gpfFunc(["thisArg","prependArgs","_gpfArrayPrototypeSlice"],builderSource).call(me,thisArg,prependArgs,_gpfArrayPrototypeSlice);}}});var _gpfJsCommentsRegExp=new RegExp("//.*$|/\\*(?:[^\\*]*|\\*[^/]*)\\*/","gm");function _gpfGetFunctionName(){var functionSource=_gpfEmptyFunc.toString.call(this),functionKeywordPos=functionSource.indexOf("function"),parameterListStartPos=functionSource.indexOf("(",functionKeywordPos);return functionSource.substr(functionKeywordPos+9,parameterListStartPos-functionKeywordPos-9).replace(_gpfJsCommentsRegExp,"").trim();}if(function(){var testFunction=_gpfFunc("return function functionName () {};")();return testFunction.name!=="functionName";}()){Function.prototype.compatibleName=_gpfGetFunctionName;}else{Function.prototype.compatibleName=function(){return this.name;};}function _gpfObjectAssign(value,memberName){this[memberName]=value;}_gpfInstallCompatibility("Object",{on:Object,statics:{assign:function(destination,source){[].slice.call(arguments,1).forEach(function(nthSource){_gpfObjectForEach(nthSource,_gpfObjectAssign,destination);});return destination;},create:function(){function Temp(){}return function(O){Temp.prototype=O;var obj=new Temp;Temp.prototype=null;if(!obj.__proto__){obj.__proto__=O;}return obj;};}(),getPrototypeOf:function(object){if(object.__proto__){return object.__proto__;}return object.constructor.prototype;},keys:function(object){var result=[],key;for(key in object){if(object.hasOwnProperty(key)){result.push(key);}}return result;},values:function(object){var result=[],key;for(key in object){if(object.hasOwnProperty(key)){result.push(object[key]);}}return result;}}});_gpfInstallCompatibility("String",{on:String,methods:{trim:function(){var rtrim=new RegExp("^[\\s\uFEFF\xA0]+|[\\s\uFEFF\xA0]+$","g");return function(){return this.replace(rtrim,"");};}()}});function _gpfPromiseSafeResolve(fn,onFulfilled,onRejected){var safe=true;function makeSafe(callback){return function(value){if(safe){safe=false;callback(value);}};}try{fn(makeSafe(onFulfilled),makeSafe(onRejected));}catch(e){if(safe){safe=false;onRejected(e);}}}function _gpfPromiseFinale(){var me=this;me._handlers.forEach(function(handler){handler.process(me);});me._handlers=[];}function _gpfPromiseReject(newValue){var me=this;me._state=false;me._value=newValue;_gpfPromiseFinale.call(me);}function _gpfPromiseResolve(newValue){var me=this;try{if(newValue&&(typeof newValue==="object"||typeof newValue==="function")){var then=newValue.then;if("function"===typeof then){_gpfPromiseSafeResolve(then.bind(newValue),_gpfPromiseResolve.bind(me),_gpfPromiseReject.bind(me));return;}}me._state=true;me._value=newValue;_gpfPromiseFinale.call(me);}catch(e){_gpfPromiseReject.call(me,e);}}var _GpfPromise=gpf.Promise=function(fn){_gpfPromiseSafeResolve(fn,_gpfPromiseResolve.bind(this),_gpfPromiseReject.bind(this));};function _gpfPromiseHandler(){}_gpfPromiseHandler.prototype={onFulfilled:null,onRejected:null,resolve:null,reject:null,process:function(promise){var me=this;if(promise._state===null){if(!promise.hasOwnProperty("_handlers")){promise._handlers=[];}promise._handlers.push(me);return;}setTimeout(function(){var callback,result;if(promise._state){callback=me.onFulfilled;}else{callback=me.onRejected;}if(null===callback){if(promise._state){me.resolve(promise._value);}else{me.reject(promise._value);}return;}try{result=callback(promise._value);}catch(e){me.reject(e);return;}me.resolve(result);},0);}};_GpfPromise.prototype={_state:null,_value:null,_handlers:[],then:function(onFulfilled,onRejected){var me=this;return new _GpfPromise(function(resolve,reject){var handler=new _gpfPromiseHandler;if(undefined!==onFulfilled){handler.onFulfilled=onFulfilled;}if(undefined!==onRejected){handler.onRejected=onRejected;}handler.resolve=resolve;handler.reject=reject;handler.process(me);});},"catch":function(onRejected){return this.then(null,onRejected);}};_GpfPromise.resolve=function(value){return new _GpfPromise(function(resolve){resolve(value);});};_GpfPromise.reject=function(value){return new _GpfPromise(function(resolve,reject){reject(value);});};_GpfPromise.all=function(promises){if(0===promises.length){return _GpfPromise.resolve([]);}return new _GpfPromise(function(resolve,reject){var remaining=promises.length;function handle(result,index){try{if(result&&result instanceof _GpfPromise){result.then(function(value){handle(value,index);},reject);return;}promises[index]=result;if(--remaining===0){resolve(promises);}}catch(e){reject(e);}}promises.forEach(handle);});};_GpfPromise.race=function(promises){return new _GpfPromise(function(resolve,reject){promises.forEach(function(promise){promise.then(resolve,reject);});});};if(undefined===_gpfMainContext.Promise){_gpfMainContext.Promise=_GpfPromise;}var _gpfTimeoutQueue=[],_gpfTimeoutID=0,_gpfSleep=_gpfEmptyFunc;gpf.handleTimeout=_gpfEmptyFunc;function _gpfSortOnDt(a,b){if(a.dt===b.dt){return a.id-b.id;}return a.dt-b.dt;}function _gpSetTimeoutPolyfill(callback,timeout){var timeoutItem={id:++_gpfTimeoutID,dt:new Date().getTime()+timeout,cb:callback};_gpfTimeoutQueue.push(timeoutItem);_gpfTimeoutQueue.sort(_gpfSortOnDt);return _gpfTimeoutID;}function _gpfClearTimeoutPolyfill(timeoutId){var pos;if(!_gpfTimeoutQueue.every(function(timeoutItem,index){if(timeoutItem.id===timeoutId){pos=index;return false;}return true;})){_gpfTimeoutQueue.splice(pos,1);}}function _gpfHandleTimeout(){var queue=_gpfTimeoutQueue,timeoutItem,now;while(queue.length){timeoutItem=queue.shift();now=new Date().getTime();while(timeoutItem.dt>now){_gpfSleep(timeoutItem.dt-now);now=new Date().getTime();}timeoutItem.cb();}}if("undefined"===typeof setTimeout){if(_GPF_HOST.WSCRIPT===_gpfHost){_gpfSleep=function(t){WScript.Sleep(t);};}else if(_GPF_HOST.RHINO===_gpfHost){_gpfSleep=java.lang.Thread.sleep;}else{console.warn("No implementation for setTimeout");}_gpfMainContext.setTimeout=_gpSetTimeoutPolyfill;_gpfMainContext.clearTimeout=_gpfClearTimeoutPolyfill;gpf.handleTimeout=_gpfHandleTimeout;}var _gpfJsonStringify,_gpfJsonParse;function _gpfPreprocessValueForJson(callback){return function(value,index){if("function"===typeof value){return;}callback(_gpfJsonStringifyPolyfill(value),index);};}function _gpfObject2Json(object){var isArray,results;isArray=object instanceof Array;results=[];if(isArray){_gpfArrayForEach(object,_gpfPreprocessValueForJson(function(value){results.push(value);}));return"["+results.join(",")+"]";}_gpfObjectForEach(object,_gpfPreprocessValueForJson(function(value,property){results.push(_gpfStringEscapeFor(property,"javascript")+":"+value);}));return"{"+results.join(",")+"}";}function _gpfJsonStringifyObject(object){return object.toString();}var _gpfJsonStringifyMapping={undefined:_gpfEmptyFunc,"function":_gpfEmptyFunc,number:_gpfJsonStringifyObject,"boolean":_gpfJsonStringifyObject,string:function(object){return _gpfStringEscapeFor(object,"javascript");},object:function(object){if(null===object){return"null";}return _gpfObject2Json(object);}};function _gpfJsonStringifyPolyfill(object){return _gpfJsonStringifyMapping[typeof object](object);}function _gpfJsonParsePolyfill(test){return _gpfFunc("return "+test)();}if("undefined"===typeof JSON){_gpfJsonStringify=_gpfJsonStringifyPolyfill;_gpfJsonParse=_gpfJsonParsePolyfill;_gpfMainContext.JSON={stringify:_gpfJsonStringify,parse:_gpfJsonParse};}else{_gpfJsonStringify=JSON.stringify;_gpfJsonParse=JSON.parse;}function _gpfGetObjectProperty(parent,name){if(undefined!==parent){return parent[name];}}function _gpfGetOrCreateObjectProperty(parent,name){var result=parent[name];if(undefined===result){result=parent[name]={};}return result;}function _gpfReduceContext(path,reducer){var rootContext;if(path[0]==="gpf"){rootContext=gpf;path=path.slice(1);}else{rootContext=_gpfMainContext;}return path.reduce(reducer,rootContext);}function _gpfContext(path,createMissingParts){var reducer;if(createMissingParts){reducer=_gpfGetOrCreateObjectProperty;}else{reducer=_gpfGetObjectProperty;}return _gpfReduceContext(path,reducer);}gpf.context=function(path){if(undefined===path){return _gpfMainContext;}return _gpfContext(path.split("."));};gpf.extend=Object.assign;_gpfStringEscapes.html=Object.assign({},_gpfStringEscapes.xml,{"à":"&agrave;","á":"&aacute;","è":"&egrave;","é":"&eacute;","ê":"&ecirc;"});var _GpfError=gpf.Error=function(){};_GpfError.prototype=new Error;Object.assign(_GpfError.prototype,{constructor:_GpfError,code:0,name:"Error",message:"",_buildMessage:function(context){var replacements;if(context){replacements={};_gpfObjectForEach(context,function(value,key){replacements["{"+key+"}"]=value.toString();});this.message=_gpfStringReplaceEx(this.message,replacements);}}});function _gpfErrorFactory(code,name,message){function NewErrorClass(context){this._buildMessage(context);}NewErrorClass.prototype=new _GpfError;Object.assign(NewErrorClass.prototype,{code:code,name:name,message:message});NewErrorClass.prototype.constructor=NewErrorClass;_GpfError[_gpfStringCapitalize(name)]=NewErrorClass;return function(context){throw new NewErrorClass(context);};}function _gpfGenenerateErrorFunction(code,name,message){var result=_gpfErrorFactory(code,name,message);result.CODE=code;result.NAME=name;result.MESSAGE=message;return result;}var _gpfLastErrorCode=0;function _gpfErrorDeclare(source,dictionary){_gpfObjectForEach(dictionary,function(message,name){var code=++_gpfLastErrorCode;gpf.Error["CODE_"+name.toUpperCase()]=code;gpf.Error[name]=_gpfGenenerateErrorFunction(code,name,message);});}_gpfErrorDeclare("error",{notImplemented:"Not implemented",assertionFailed:"Assertion failed: {message}",invalidParameter:"Invalid parameter"});function _gpfStringTrim(that){return that.trim();}function _gpfFunctionDescribeName(functionToDescribe,resultDescription){var name=functionToDescribe.compatibleName();if(name){resultDescription.name=name;}}function _gpfFunctionDescribeParameters(functionToDescribe,functionSource,resultDescription){if(functionToDescribe.length){resultDescription.parameters=new RegExp("\\(\\s*(\\w+(?:\\s*,\\s*\\w+)*)\\s*\\)").exec(functionSource)[1].split(",").map(_gpfStringTrim);}}function _gpfFunctionDescribeBody(functionSource,resultDescription){var body=_gpfStringTrim(new RegExp("{((?:.*\\n)*.*)}").exec(functionSource)[1]);if(body){resultDescription.body=body;}}function _gpfFunctionDescribeSource(functionToDescribe,resultDescription){var source=_gpfEmptyFunc.toString.call(functionToDescribe).replace(_gpfJsCommentsRegExp,"");_gpfFunctionDescribeParameters(functionToDescribe,source,resultDescription);_gpfFunctionDescribeBody(source,resultDescription);}function _gpfFunctionDescribe(functionToDescribe){var result={};_gpfFunctionDescribeName(functionToDescribe,result);_gpfFunctionDescribeSource(functionToDescribe,result);return result;}function _gpfFunctionBuildSourceName(functionDescription){if(functionDescription.name){return" "+functionDescription.name;}return"";}function _gpfFunctionBuildSourceParameters(functionDescription){if(functionDescription.parameters){return functionDescription.parameters.join(", ");}return"";}function _gpfFunctionBuildSourceBody(functionDescription){if(functionDescription.body){return functionDescription.body.toString();}return"";}function _gpfFunctionBuildSource(functionDescription){return"function"+_gpfFunctionBuildSourceName(functionDescription)+"("+_gpfFunctionBuildSourceParameters(functionDescription)+") {\n\t\"use strict\"\n"+_gpfFunctionBuildSourceBody(functionDescription)+"\n}";}function _gpfFunctionBuildWithContext(functionSource,context){var parameterNames=Object.keys(context),parameterValues=parameterNames.map(function(name){return context[name];});return _gpfFunc(parameterNames,"return "+functionSource).apply(null,parameterValues);}function _gpfFunctionBuild(functionDescription,context){return _gpfFunctionBuildWithContext(_gpfFunctionBuildSource(functionDescription),context||{});}_gpfErrorDeclare("define/detect",{invalidEntityType:"Invalid entity type"});var _gpfDefineTypedBuilders={};function _gpfDefineRead$TypedProperties(definition){var ResultEntityBuilder;_gpfObjectForEach(_gpfDefineTypedBuilders,function(TypedEntityBuilder,type){if(definition["$"+type]){ResultEntityBuilder=TypedEntityBuilder;}});return ResultEntityBuilder;}function _gpfDefineCheck$TypeProperty(definition){var typedEntityBuilder=_gpfDefineTypedBuilders[definition.$type];if(undefined===typedEntityBuilder){gpf.Error.invalidEntityType();}return typedEntityBuilder;}function _gpfDefineBuildTypedEntity(definition){var EntityBuilder=_gpfDefineRead$TypedProperties(definition),entityDefinition;if(!EntityBuilder){EntityBuilder=_gpfDefineCheck$TypeProperty(definition);}entityDefinition=new EntityBuilder(definition);entityDefinition.check();return entityDefinition;}function _gpfRegExpGetNextMatch(regexp,string){return regexp.exec(string);}function _gpfRegExpGetFirstMatch(regexp,string){regexp.lastIndex=0;return _gpfRegExpGetNextMatch(regexp,string);}function _gpfRegExpForEach(regexp,string){var matches=[],match=_gpfRegExpGetFirstMatch(regexp,string);while(match){matches.push(match);match=_gpfRegExpGetNextMatch(regexp,string);}return matches;}function _GpfEntityDefinition(definition){this._initialDefinition=definition;}_GpfEntityDefinition.prototype={constructor:_GpfEntityDefinition,_initialDefinition:{}};_gpfErrorDeclare("abstract",{abstractMethod:"Abstract method"});function _gpfCreateAbstractFunction(numberOfParameters){return _gpfFunctionBuild({parameters:_gpfBuildFunctionParameterList(numberOfParameters),body:"_throw_();"},{_throw_:gpf.Error.abstractMethod});}_gpfErrorDeclare("define/check",{invalidEntity$Property:"Invalid entity $ property",missingEntityName:"Missing entity name",invalidEntityNamespace:"Invalid entity namespace"});function _gpfDefineEntityCheck$PropertyInAllowed$Properties(name,allowedList){if(-1===allowedList.indexOf(name)){gpf.Error.invalidEntity$Property();}}function _gpfDefineEntityCheckProperty(value,name){if(name.charAt(0)==="$"){this._check$Property(name.substr(1),value);}else{this._checkProperty(name,value);}}Object.assign(_GpfEntityDefinition.prototype,{_type:"",_allowed$Properties:"type,name,namespace".split(","),_check$Property:function(name,value){if(name!==this._type){_gpfDefineEntityCheck$PropertyInAllowed$Properties(name,this._allowed$Properties);}},_throwInvalidProperty:_gpfCreateAbstractFunction(0),_reMemberName:new RegExp(".*"),_checkMemberName:function(name){if(!this._reMemberName.exec(name)){this._throwInvalidProperty();}},_reservedNames:"super,class,public,private,protected,static,mixin".split(","),_checkReservedMemberName:function(name){if(-1!==this._reservedNames.indexOf(name)){this._throwInvalidProperty();}},_checkMemberValue:_gpfFunc(["name","value"]," "),_checkProperty:function(name,value){this._checkMemberName(name);this._checkReservedMemberName(name);this._checkMemberValue(name,value);},_checkProperties:function(){_gpfObjectForEach(this._initialDefinition,_gpfDefineEntityCheckProperty,this);},_name:"",_readName:function(){var definition=this._initialDefinition;this._name=definition["$"+this._type]||definition.$name;},_checkNameIsNotEmpty:function(){if(!this._name){gpf.Error.missingEntityName();}},_throwInvalidName:_gpfCreateAbstractFunction(0),_reName:new RegExp(".*"),_checkName:function(){if(!this._reName.exec(this._name)){this._throwInvalidName();}},_namespace:"",_extractRelativeNamespaceFromName:function(){var parts=new RegExp("(.*)\\.([^\\.]+)$").exec(this._name);if(parts){this._name=parts[2];return parts[1];}},_readNamespace:function(){var namespaces=[this._initialDefinition.$namespace,this._extractRelativeNamespaceFromName()].filter(function(namespacePart){return namespacePart;});if(namespaces.length>0){this._namespace=namespaces.join(".");}},_checkNamespace:function(){if(!new RegExp("^(:?[a-z_$][a-zA-Z0-9]+(:?\\.[a-z_$][a-zA-Z0-9]+)*)?$").exec(this._namespace)){gpf.Error.invalidEntityNamespace();}},check:function(){this._checkProperties();this._readName();this._checkNameIsNotEmpty();this._readNamespace();this._checkName();this._checkNamespace();}});Object.assign(_GpfEntityDefinition.prototype,{_instanceBuilder:null,getInstanceBuilder:function(){if(!this._instanceBuilder){this._setInstanceBuilder(this._build());}return this._instanceBuilder;},_setInstanceBuilder:function(value){if(this._namespace){_gpfContext(this._namespace.split("."),true)[this._name]=value;}this._instanceBuilder=value;},_build:_gpfEmptyFunc});function _GpfClassDefinition(definition){_GpfEntityDefinition.call(this,definition);}_GpfClassDefinition.prototype=Object.create(_GpfEntityDefinition.prototype);Object.assign(_GpfClassDefinition.prototype,{constructor:_GpfClassDefinition,_type:"class"});_gpfDefineTypedBuilders["class"]=_GpfClassDefinition;_gpfErrorDeclare("define/class/check",{invalidClassName:"Invalid class name",invalidClassProperty:"Invalid class property",invalidClassExtend:"Invalid class extend",invalidClassConstructor:"Invalid class constructor",invalidClassOverride:"Invalid class override"});function _gpfDefineClassDecontextifyExtend(extend){if("string"===typeof extend){return _gpfContext(extend.split("."));}return extend;}Object.assign(_GpfClassDefinition.prototype,{_allowed$Properties:_GpfEntityDefinition.prototype._allowed$Properties.concat(["extend"]),_throwInvalidProperty:gpf.Error.invalidClassProperty,_reMemberName:new RegExp("^[a-z_][a-zA-Z0-9]*$"),_checkConstructorMember:function(constructorValue){if("function"!==typeof constructorValue){gpf.Error.invalidClassConstructor();}},_checkOverridenMember:function(value,overriddenValue){if(typeof value!==typeof overriddenValue){gpf.Error.invalidClassOverride();}},_checkIfOverriddenMember:function(name,value){var overriddenMember=this._extend.prototype[name];if(undefined!==overriddenMember){this._checkOverridenMember(value,overriddenMember);}},_checkMemberValue:function(name,value){if("constructor"===name){this._checkConstructorMember(value);}else{this._checkIfOverriddenMember(name,value);}},_reName:new RegExp("^[A-Z_$][a-zA-Z0-9]*$"),_throwInvalidName:gpf.Error.invalidClassName,_extend:Object,_readExtend:function(){var extend=_gpfDefineClassDecontextifyExtend(this._initialDefinition.$extend);if(extend){this._extend=extend;}},_checkExtendIsNotAnInterface:function(){if(-1!==_gpfEmptyFunc.toString.call(this._extend).indexOf("interfaceConstructorFunction")){gpf.Error.invalidClassExtend();}},_checkExtend:function(){if("function"!==typeof this._extend){gpf.Error.invalidClassExtend();}this._checkExtendIsNotAnInterface();},check:function(){this._readExtend();this._checkExtend();_GpfEntityDefinition.prototype.check.call(this);}});_gpfErrorDeclare("define/class/constructor",{"classConstructorFunction":"This is a class constructor function, use with new"});Object.assign(_GpfClassDefinition.prototype,{_resolvedConstructor:_gpfEmptyFunc});function _gpfDefineGetClassSecuredConstructorDefinition(classDefinition){var name=classDefinition._name;return{name:name,parameters:_gpfFunctionDescribe(classDefinition._resolvedConstructor).parameters,body:"if (!(this instanceof _classDef_._instanceBuilder)) gpf.Error.classConstructorFunction();\n"+"_classDef_._resolvedConstructor.apply(this, arguments);"};}function _gpfDefineGetClassSecuredConstructorContext(classDefinition){return{gpf:gpf,_classDef_:classDefinition};}function _gpfDefineGetClassSecuredConstructor(classDefinition){return _gpfFunctionBuild(_gpfDefineGetClassSecuredConstructorDefinition(classDefinition),_gpfDefineGetClassSecuredConstructorContext(classDefinition));}_gpfErrorDeclare("define/class/super",{invalidClassSuper:"Invalid class super",invalidClassSuperMember:"Invalid class super member"});function _gpfClassNoSuper(){gpf.Error.invalidClassSuper();}function _gpfClassSuperCreateWithSameSignature(superMethod){var definition=_gpfFunctionDescribe(superMethod);definition.body="return _superMethod_.apply(this, arguments);";return _gpfFunctionBuild(definition,{_superMethod_:superMethod});}function _gpfClassSuperCreate(superMember){if("function"!==typeof superMember){superMember=_gpfClassNoSuper;}return _gpfClassSuperCreateWithSameSignature(superMember);}function _gpfClassSuperCreateWeakBoundWithSameSignature(that,$super,superMethod){var definition=_gpfFunctionDescribe(superMethod);definition.body="return _superMethod_.apply(this === _$super_ ? _that_ : this, arguments);";return _gpfFunctionBuild(definition,{_that_:that,_$super_:$super,_superMethod_:superMethod});}function _gpfClassSuperCreateMember(that,$super,superMethod){if("function"!==typeof superMethod){gpf.Error.invalidClassSuperMember();}return _gpfClassSuperCreateWeakBoundWithSameSignature(that,$super,superMethod);}var _gpfClassSuperRegExp=new RegExp("\\.\\$super\\.(\\w+)\\b","g");function _gpfClassMethodExtractSuperMembers(method){return _gpfRegExpForEach(_gpfClassSuperRegExp,method).map(function(match){return match[1];});}Object.assign(_GpfClassDefinition.prototype,{_get$Super:function(that,methodName,superMembers){var superProto=this._extend.prototype,$super=_gpfClassSuperCreate(superProto[methodName]);superMembers.forEach(function(memberName){$super[memberName]=_gpfClassSuperCreateMember(that,$super,superProto[memberName]);});return $super;},_superifiedBody:"var _super_;\n"+"if (this.hasOwnProperty(\"$super\")) {\n"+" _super_ = this.$super;\n"+"}\n"+"this.$super = _classDef_._get$Super(this, _methodName_, _superMembers_);\n"+"try{\n"+" var _result_ = _method_.apply(this, arguments);\n"+"} finally {\n"+" if (undefined === _super_) {\n"+" delete this.$super;\n"+" } else {\n"+" this.$super = _super_;\n"+" }\n"+"}\n"+"return _result_;",_getSuperifiedContext:function(method,methodName,superMembers){return{_method_:method,_methodName_:methodName,_superMembers_:superMembers,_classDef_:this};},_createSuperified:function(method,methodName,superMembers){var description=_gpfFunctionDescribe(method);description.body=this._superifiedBody;return _gpfFunctionBuild(description,this._getSuperifiedContext(method,methodName,superMembers));},_superify:function(method,methodName){if(new RegExp("\\.\\$super\\b").exec(method)){return this._createSuperified(method,methodName,_gpfClassMethodExtractSuperMembers(method));}return method;}});Object.assign(_GpfClassDefinition.prototype,{_build:function(){var newClass,newPrototype;this._resolveConstructor();newClass=_gpfDefineGetClassSecuredConstructor(this);newPrototype=Object.create(this._extend.prototype);newClass.prototype=newPrototype;newPrototype.constructor=newClass;this._buildPrototype(newPrototype);return newClass;},_addMethodToPrototype:function(newPrototype,methodName,method){newPrototype[methodName]=this._superify(method,methodName);},_addMemberToPrototype:function(newPrototype,memberName,value){if("function"===typeof value){this._addMethodToPrototype(newPrototype,memberName,value);}else{newPrototype[memberName]=value;}},_buildPrototype:function(newPrototype){_gpfObjectForEach(this._initialDefinition,function(value,memberName){if(memberName.charAt(0)!=="$"&&memberName!=="constructor"){this._addMemberToPrototype(newPrototype,memberName,value);}},this);},_setResolvedConstructorToInherited:function(){if(this._extend!==Object){this._resolvedConstructor=this._extend;}},_resolveConstructor:function(){if(this._initialDefinition.hasOwnProperty("constructor")){this._resolvedConstructor=this._superify(this._initialDefinition["constructor"],"constructor");}else{this._setResolvedConstructorToInherited();}}});function _GpfInterfaceDefinition(definition){_GpfEntityDefinition.call(this,definition);}_GpfInterfaceDefinition.prototype=Object.create(_GpfEntityDefinition.prototype);Object.assign(_GpfInterfaceDefinition.prototype,{constructor:_GpfInterfaceDefinition,_type:"interface"});_gpfDefineTypedBuilders["interface"]=_GpfInterfaceDefinition;_gpfErrorDeclare("define/interface/check",{invalidInterfaceName:"Invalid interface name",invalidInterfaceProperty:"Invalid interface property"});Object.assign(_GpfInterfaceDefinition.prototype,{_throwInvalidProperty:gpf.Error.invalidInterfaceProperty,_reMemberName:new RegExp("^[a-z][a-zA-Z0-9]*$"),_reservedNames:_GpfEntityDefinition.prototype._reservedNames.concat("constructor"),_checkMemberValue:function(name,value){if("function"!==typeof value){gpf.Error.invalidInterfaceProperty();}},_reName:new RegExp("^I[a-zA-Z0-9]*$"),_throwInvalidName:gpf.Error.invalidInterfaceName});_gpfErrorDeclare("define/interface/constructor",{"interfaceConstructorFunction":"This is an interface constructor function, do not invoke"});function _gpfDefineGetInterfaceConstructorDefinition(interfaceDefinition){var name=interfaceDefinition._name;return{name:name,body:"gpf.Error.interfaceConstructorFunction();"};}function _gpfDefineGetInterfaceConstructorContext(interfaceDefinition){return{gpf:gpf,_classDef_:interfaceDefinition};}function _gpfDefineGetInterfaceConstructor(interfaceDefinition){return _gpfFunctionBuild(_gpfDefineGetInterfaceConstructorDefinition(interfaceDefinition),_gpfDefineGetInterfaceConstructorContext(interfaceDefinition));}Object.assign(_GpfInterfaceDefinition.prototype,{_build:function(){var newClass,newPrototype;newClass=_gpfDefineGetInterfaceConstructor(this);newPrototype=newClass.prototype;delete newPrototype.constructor;this._buildPrototype(newPrototype);return newClass;},_buildPrototype:function(newPrototype){_gpfObjectForEach(this._initialDefinition,function(value,memberName){if(memberName.charAt(0)!=="$"){newPrototype[memberName]=value;}},this);}});function _gpfDefine(definition){var entityDefinition=_gpfDefineBuildTypedEntity(definition);return entityDefinition.getInstanceBuilder();}gpf.define=_gpfDefine;_gpfErrorDeclare("interfaces",{interfaceExpected:"Expected interface not implemented: {name}"});function _gpfInterfaceIsInvalidMethod(referenceMethod,method){return"function"!==typeof method||referenceMethod.length!==method.length;}function _gpfInterfaceIsImplementedBy(interfaceSpecifier,inspectedObject){var result=true;_gpfObjectForEach(interfaceSpecifier.prototype,function(referenceMethod,name){if(_gpfInterfaceIsInvalidMethod(referenceMethod,inspectedObject[name])){result=false;}});return result;}function _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier,queriedObject){var result=queriedObject.queryInterface(interfaceSpecifier);return result;}function _gpfInterfaceQueryTryIUnknown(interfaceSpecifier,queriedObject){if(_gpfInterfaceIsImplementedBy(gpf.interfaces.IUnknown,queriedObject)){return _gpfInterfaceQueryThroughIUnknown(interfaceSpecifier,queriedObject);}}function _gpfInterfaceQuery(interfaceSpecifier,queriedObject){if(_gpfInterfaceIsImplementedBy(interfaceSpecifier,queriedObject)){return queriedObject;}return _gpfInterfaceQueryTryIUnknown(interfaceSpecifier,queriedObject);}function _gpfInterfaceResolveSpecifier(interfaceSpecifier){if("string"===typeof interfaceSpecifier){return _gpfContext(interfaceSpecifier.split("."));}return interfaceSpecifier;}function _gpfInterfaceToInspectableObject(inspectedObject){if(inspectedObject instanceof Function){return inspectedObject.prototype;}return inspectedObject;}var _gpfI=gpf.interfaces={isImplementedBy:function(interfaceSpecifier,inspectedObject){if(!inspectedObject){return false;}return _gpfInterfaceIsImplementedBy(_gpfInterfaceResolveSpecifier(interfaceSpecifier),_gpfInterfaceToInspectableObject(inspectedObject));},query:function(interfaceSpecifier,queriedObject){return _gpfInterfaceQuery(_gpfInterfaceResolveSpecifier(interfaceSpecifier),queriedObject);}};function _gpfDefineInterface(name,definition){var interfaceDefinition={$interface:"gpf.interfaces.I"+name};Object.keys(definition).forEach(function(methodName){interfaceDefinition[methodName]=_gpfCreateAbstractFunction(definition[methodName]);});return _gpfDefine(interfaceDefinition);}_gpfDefineInterface("Unknown",{"queryInterface":1});function _gpfCreateSortVariables(specifications){return"var "+specifications.map(function(specification,index){return"a"+index+"=a."+specification.property+",b"+index+"=b."+specification.property;}).join(",")+";";}function _gpfCreateSortComparison(type,left,right){if("string"===type){return left+".localeCompare("+right+")";}return left+"-"+right;}function _gpfCreateSortCondition(specification,index){var left,right;if(specification.ascending===false){left="b"+index;right="a"+index;}else{left="a"+index;right="b"+index;}return"if("+left+"!=="+right+")return "+_gpfCreateSortComparison(specification.type,left,right)+";";}function _gpfCreateSortBody(specifications){return _gpfCreateSortVariables(specifications)+specifications.map(_gpfCreateSortCondition).join("")+"return 0;";}function _gpfCreateSortFunction(specifications){return _gpfFunc(["a","b"],_gpfCreateSortBody(specifications));}gpf.createSortFunction=function(specifications){if(!_gpfIsArray(specifications)){specifications=[specifications];}return _gpfCreateSortFunction(specifications);};var _gpfCreateFilterConvert;function _gpfCreateFilterArrayConverter(member,operator){return function(specification){return"("+specification[member].map(_gpfCreateFilterConvert).join(operator)+")";};}function _gpfCreateFilterLike(specification){return"/"+specification.regexp+"/.exec("+_gpfCreateFilterConvert(specification.like)+")";}var _gpfCreateFilterConverters={property:function(specification){return"i."+specification.property;},eq:_gpfCreateFilterArrayConverter("eq","==="),ne:_gpfCreateFilterArrayConverter("ne","!=="),lt:_gpfCreateFilterArrayConverter("lt","<"),lte:_gpfCreateFilterArrayConverter("lte","<="),gt:_gpfCreateFilterArrayConverter("gt",">"),gte:_gpfCreateFilterArrayConverter("gte",">="),not:function(specification){return"!"+_gpfCreateFilterConvert(specification.not);},like:function(specification){var like=_gpfCreateFilterLike(specification);if(specification.group){return"("+like+"||[])["+specification.group+"]";}return like;},or:_gpfCreateFilterArrayConverter("or","||"),and:_gpfCreateFilterArrayConverter("and","&&"),undefined:function(specification){return JSON.stringify(specification);}},_gpfCreateFilterTypes=Object.keys(_gpfCreateFilterConverters);function _gpfCreateFilterGetType(specification){if("object"===typeof specification){return Object.keys(specification).filter(function(property){return-1<_gpfCreateFilterTypes.indexOf(property);})[0];}}_gpfCreateFilterConvert=function(specification){var type=_gpfCreateFilterGetType(specification),converter=_gpfCreateFilterConverters[type];return converter(specification);};function _gpfCreateFilterBody(specification){return"return "+_gpfCreateFilterConvert(specification);}gpf.createFilterFunction=function(specification){return _gpfFunc(["i"],_gpfCreateFilterBody(specification));};var _gpfIReadableStream=_gpfDefineInterface("ReadableStream",{"read":1});var _gpfIWritableStream=_gpfDefineInterface("WritableStream",{"write":1});_gpfDefineInterface("Enumerator",{"reset":0,"moveNext":0,"getCurrent":0});_gpfDefineInterface("FileStorage",{"getInfo":1,"openTextStream":2,"close":1,"explore":1,"createDirectory":1,"deleteFile":1,"deleteDirectory":1});_gpfErrorDeclare("stream",{readInProgress:"A read operation is already in progress",writeInProgress:"A write operation is already in progress",invalidStreamState:"Stream is in an invalid state"});gpf.stream={};function _gpfStreamQueryReadable(queriedObject){var iReadableStream=_gpfInterfaceQuery(_gpfIReadableStream,queriedObject);if(!iReadableStream){gpf.Error.interfaceExpected({name:"gpf.interfaces.IReadableStream"});}return iReadableStream;}function _gpfStreamQueryWritable(queriedObject){var iWritableStream=_gpfInterfaceQuery(_gpfIWritableStream,queriedObject);if(!iWritableStream){gpf.Error.interfaceExpected({name:"gpf.interfaces.IWritableStream"});}return iWritableStream;}var _gpfStreamInProgressPropertyName="gpf.stream#inProgress";function _gpfStreamSecureInstallProgressFlag(constructor){constructor.prototype[_gpfStreamInProgressPropertyName]=false;}function _gpfStreamSecureRead(read){return function(output){var me=this;if(me[_gpfStreamInProgressPropertyName]){gpf.Error.readInProgress();}var iWritableStream=_gpfStreamQueryWritable(output);me[_gpfStreamInProgressPropertyName]=true;return read.call(me,iWritableStream).then(function(result){me[_gpfStreamInProgressPropertyName]=false;return Promise.resolve(result);},function(reason){me[_gpfStreamInProgressPropertyName]=false;return Promise.reject(reason);});};}function _gpfStreamSecureWrite(write){return function(buffer){var me=this;if(me[_gpfStreamInProgressPropertyName]){gpf.Error.writeInProgress();}me[_gpfStreamInProgressPropertyName]=true;return write.call(me,buffer).then(function(result){me[_gpfStreamInProgressPropertyName]=false;return Promise.resolve(result);},function(reason){me[_gpfStreamInProgressPropertyName]=false;return Promise.reject(reason);});};}var _GpfStreamReadableString=_gpfDefine({$class:"gpf.stream.ReadableString",constructor:function(buffer){this._buffer=buffer;},read:_gpfStreamSecureRead(function(output){return output.write(this._buffer);}),_buffer:""}),_GpfStreamWritableString=_gpfDefine({$class:"gpf.stream.WritableString",constructor:function(){this._buffer=[];},write:_gpfStreamSecureWrite(function(buffer){this._buffer.push(buffer.toString());return Promise.resolve();}),toString:function(){return this._buffer.join("");},_buffer:[]});_gpfStreamSecureInstallProgressFlag(_GpfStreamReadableString);_gpfStreamSecureInstallProgressFlag(_GpfStreamWritableString);_gpfErrorDeclare("fs",{incompatibleStream:"Incompatible stream"});var _GPF_FS_TYPES={NOT_FOUND:0,DIRECTORY:1,FILE:2,UNKNOWN:3},_GPF_FS_OPENFOR={READING:0,APPENDING:1},_gpfFileStorageByHost={},_gpfFsReadImplByHost={};function _gpfFileStorageRead(path){var fs=_gpfFileStorageByHost[_gpfHost],iWritableStream=new _GpfStreamWritableString;return fs.openTextStream(path,_GPF_FS_OPENFOR.READING).then(function(iReadStream){return iReadStream.read(iWritableStream);}).then(function(){return iWritableStream.toString();});}function _gpfFsRead(path){return _gpfFsReadImplByHost[_gpfHost](path);}gpf.fs={types:{notFound:_GPF_FS_TYPES.NOT_FOUND,directory:_GPF_FS_TYPES.DIRECTORY,file:_GPF_FS_TYPES.FILE,unknown:_GPF_FS_TYPES.UNKNOWN},openFor:{reading:_GPF_FS_OPENFOR.READING,appending:_GPF_FS_OPENFOR.APPENDING},getFileStorage:function(){return _gpfFileStorageByHost[_gpfHost]||null;},read:_gpfFsRead};_gpfErrorDeclare("path",{unreachablePath:"Unreachable path"});function _gpfPathSplit(path){if(-1<path.indexOf("\\")){return path.toLowerCase().split("\\");}return path.split("/");}function _gpfPathRemoveTrailingBlank(splitPath){if(!splitPath[splitPath.length-1]){splitPath.pop();}}function _gpfPathUp(splitPath){if(splitPath.length){splitPath.pop();}else{gpf.Error.unreachablePath();}}function _gpfPathDecompose(path){var splitPath=_gpfPathSplit(path);_gpfPathRemoveTrailingBlank(splitPath);return splitPath;}function _gpfPathNormalize(path){return _gpfPathDecompose(path).join("/");}function _gpfPathName(path){if(path){return _gpfPathDecompose(path).pop();}return"";}function _gpfPathExtension(path){var name=_gpfPathName(path),pos=name.lastIndexOf(".");if(-1===pos){return"";}return name.substr(pos);}function _gpfPathAppend(splitPath,relativePath){_gpfPathDecompose(relativePath).forEach(function(relativeItem){if(".."===relativeItem){_gpfPathUp(splitPath);}else{splitPath.push(relativeItem);}});}function _gpfPathJoin(path){var splitPath=_gpfPathDecompose(path);[].slice.call(arguments,1).forEach(_gpfPathAppend.bind(null,splitPath));return splitPath.join("/");}function _gpfPathSafeShiftIdenticalBeginning(splitFromPath,splitToPath){while(splitFromPath[0]===splitToPath[0]){splitFromPath.shift();splitToPath.shift();}}function _gpfPathShiftIdenticalBeginning(splitFromPath,splitToPath){if(splitFromPath.length*splitToPath.length){_gpfPathSafeShiftIdenticalBeginning(splitFromPath,splitToPath);}}function _gpfPathParent(path){path=_gpfPathDecompose(path);_gpfPathUp(path);return path.join("/");}function _gpfPathRelative(from,to){var length,splitFrom=_gpfPathDecompose(from),splitTo=_gpfPathDecompose(to);_gpfPathShiftIdenticalBeginning(splitFrom,splitTo);length=splitFrom.length+1;while(--length){splitTo.unshift("..");}return splitTo.join("/");}gpf.path={join:_gpfPathJoin,parent:_gpfPathParent,name:_gpfPathName,nameOnly:function(path){var name=_gpfPathName(path),pos=name.lastIndexOf(".");if(-1===pos){return name;}return name.substr(0,pos);},extension:_gpfPathExtension,relative:_gpfPathRelative};function _gpfFsExploreEnumerator(iFileStorage,listOfPaths){var pos=-1,info;return{reset:function(){pos=-1;return Promise.resolve();},moveNext:function(){++pos;info=undefined;if(pos<listOfPaths.length){return iFileStorage.getInfo(listOfPaths[pos]).then(function(fsInfo){info=fsInfo;return info;});}return Promise.resolve();},getCurrent:function(){return info;}};}var _GpfNodeBaseStream=_gpfDefine({$class:"gpf.node.BaseStream",constructor:function(stream,close){this._stream=stream;if("function"===typeof close){this._close=close;}stream.on("error",this._onError.bind(this));},_close:_gpfEmptyFunc,close:function(){return this._close();},_stream:null,_invalid:false,_reject:gpf.Error.invalidStreamState,_checkIfValid:function(){if(this._invalid){gpf.Error.invalidStreamState();}},_onError:function(error){this._invalid=true;this._reject(error);}}),_GpfNodeReadableStream=_gpfDefine({$class:"gpf.node.ReadableStream",$extend:"gpf.node.BaseStream",read:_gpfStreamSecureRead(function(output){var me=this,stream=me._stream;return new Promise(function(resolve,reject){me._reject=reject;me._checkIfValid();stream.on("data",me._onData.bind(me,output)).on("end",function(){me._invalid=true;resolve();});});}),_onData:function(output,chunk){var me=this,stream=me._stream;stream.pause();output.write(chunk).then(function(){stream.resume();},me._reject);}}),_GpfNodeWritableStream=_gpfDefine({$class:"gpf.node.WritableStream",$extend:"gpf.node.BaseStream",write:_gpfStreamSecureWrite(function(buffer){var me=this,stream=me._stream;return new Promise(function(resolve,reject){me._reject=reject;me._checkIfValid();if(stream.write(buffer)){return resolve();}stream.once("drain",resolve);});})});function _gpfFsNodeFsCall(methodName,args){return new Promise(function(resolve,reject){_gpfNodeFs[methodName].apply(_gpfNodeFs,args.concat([function(err,result){if(err){reject(err);}else{resolve(result);}}]));});}function _gpfFsNodeFsCallWithPath(methodName,path){return _gpfFsNodeFsCall(methodName,[_gpfPathNormalize(path)]);}function _gpfFsNodeOpenTextStream(path,options){return _gpfFsNodeFsCall("open",[_gpfPathNormalize(path),options.flags]).then(function(fd){return new options.GpfStream(_gpfNodeFs[options.nodeStream]("",{fd:fd,autoClose:false}),_gpfFsNodeFsCall.bind(null,"close",[fd]));});}function _gpfFsNodeOpenTextStreamForReading(path){return _gpfFsNodeOpenTextStream(path,{flags:"r",GpfStream:_GpfNodeReadableStream,nodeStream:"createReadStream"});}function _gpfFsNodeOpenTextStreamForAppending(path){return _gpfFsNodeOpenTextStream(path,{flags:"a",GpfStream:_GpfNodeWritableStream,nodeStream:"createWriteStream"});}function _gpfFsNodeGetFileType(stats){if(stats.isFile()){return _GPF_FS_TYPES.FILE;}return _GPF_FS_TYPES.UNKNOWN;}function _gpfFsNodeGetType(stats){if(stats.isDirectory()){return _GPF_FS_TYPES.DIRECTORY;}return _gpfFsNodeGetFileType(stats);}var _GpfNodeFileStorage=_gpfDefine({$class:"gpf.node.FileStorage",getInfo:function(path){path=_gpfPathNormalize(path);return new Promise(function(resolve){_gpfNodeFs.exists(path,resolve);}).then(function(exists){if(exists){return _gpfFsNodeFsCallWithPath("stat",path).then(function(stats){return{fileName:_gpfNodePath.basename(path),filePath:_gpfPathNormalize(_gpfNodePath.resolve(path)),size:stats.size,createdDateTime:stats.ctime,modifiedDateTime:stats.mtime,type:_gpfFsNodeGetType(stats)};});}return{type:_GPF_FS_TYPES.NOT_FOUND};});},openTextStream:function(path,mode){if(_GPF_FS_OPENFOR.READING===mode){return _gpfFsNodeOpenTextStreamForReading(path);}return _gpfFsNodeOpenTextStreamForAppending(path);},close:function(stream){if(stream instanceof _GpfNodeBaseStream){return stream.close();}return Promise.reject(new gpf.Error.IncompatibleStream);},explore:function(path){var me=this;return _gpfFsNodeFsCallWithPath("readdir",path).then(function(content){return _gpfFsExploreEnumerator(me,content.map(function(name){return _gpfPathJoin(path,name);}));});},createDirectory:_gpfFsNodeFsCallWithPath.bind(null,"mkdir"),deleteFile:_gpfFsNodeFsCallWithPath.bind(null,"unlink"),deleteDirectory:_gpfFsNodeFsCallWithPath.bind(null,"rmdir")});_gpfFileStorageByHost[_GPF_HOST.NODEJS]=new _GpfNodeFileStorage;_gpfFsReadImplByHost[_GPF_HOST.NODEJS]=_gpfFileStorageRead;var _GpfWscriptBaseStream=_gpfDefine({$class:"gpf.wscript.BaseStream",constructor:function(file){this._file=file;},close:function(){return new Promise(function(resolve){this._file.Close();resolve();}.bind(this));}}),_GpfWscriptReadableStream=_gpfDefine({$class:"gpf.wscript.ReadableStream",$extend:"gpf.wscript.BaseStream",read:_gpfStreamSecureRead(function(output){var me=this,file=me._file;return new Promise(function(resolve){function read(){return output.write(file.Read(4096)).then(function(){if(!file.AtEndOfStream){return read();}});}return read().then(resolve);});})}),_GpfWscriptWritableStream=_gpfDefine({$class:"gpf.wscript.WritableStream",$extend:"gpf.wscript.BaseStream",write:_gpfStreamSecureWrite(function(buffer){var me=this,file=me._file;return new Promise(function(resolve){file.Write(buffer);resolve();});})});_gpfErrorDeclare("fs/wscript",{pathNotExplorable:"Path not explorable"});function _gpfFsWScriptObjToFileStorageInfo(obj,type){return{type:type,fileName:obj.Name.toLowerCase(),filePath:_gpfPathNormalize(obj.Path),size:obj.Size,createdDateTime:new Date(obj.DateCreated),modifiedDateTime:new Date(obj.DateLastModified)};}function _gpfFsWscriptFSOCallWithArg(name,path){return new Promise(function(resolve){_gpfMsFSO[name](_gpfPathDecompose(path).join("\\"));resolve();});}function _gpfFsWscriptFSOCallWithArgAndTrue(name,path){return new Promise(function(resolve){_gpfMsFSO[name](_gpfPathDecompose(path).join("\\"),true);resolve();});}function _gpfFsWscriptGetFileInfo(path){if(_gpfMsFSO.FileExists(path)){return _gpfFsWScriptObjToFileStorageInfo(_gpfMsFSO.GetFile(path),_GPF_FS_TYPES.FILE);}return{type:_GPF_FS_TYPES.NOT_FOUND};}function _gpfFsWscriptGetInfo(path){if(_gpfMsFSO.FolderExists(path)){return _gpfFsWScriptObjToFileStorageInfo(_gpfMsFSO.GetFolder(path),_GPF_FS_TYPES.DIRECTORY);}return _gpfFsWscriptGetFileInfo(path);}function _gpfFsWScriptExploreList(collection){var fsoEnum=new Enumerator(collection),results=[];for(;!fsoEnum.atEnd();fsoEnum.moveNext()){results.push(fsoEnum.item().Path);}return results;}function _gpfFsWScriptExplore(path){var folder;if(_gpfMsFSO.FolderExists(path)){folder=_gpfMsFSO.GetFolder(path);return _gpfFsWScriptExploreList(folder.SubFolders).concat(_gpfFsWScriptExploreList(folder.Files));}gpf.Error.pathNotExplorable();}var _GpfWScriptFileStorage=_gpfDefine({$class:"gpf.wscript.FileStorage",getInfo:function(path){return Promise.resolve(_gpfFsWscriptGetInfo(_gpfPathDecompose(path).join("\\")));},openTextStream:function(path,mode){path=_gpfPathDecompose(path).join("\\");return new Promise(function(resolve){var stream;if(_GPF_FS_OPENFOR.READING===mode){stream=new _GpfWscriptReadableStream(_gpfMsFSO.OpenTextFile(path,1,false));}else{stream=new _GpfWscriptWritableStream(_gpfMsFSO.OpenTextFile(path,8,true));}resolve(stream);});},close:function(stream){if(stream instanceof _GpfWscriptBaseStream){return stream.close();}return Promise.reject(new gpf.Error.IncompatibleStream);},explore:function(path){var me=this;return new Promise(function(resolve){resolve(_gpfFsExploreEnumerator(me,_gpfFsWScriptExplore(_gpfPathDecompose(path).join("\\"))));});},createDirectory:_gpfFsWscriptFSOCallWithArg.bind(null,"CreateFolder"),deleteFile:_gpfFsWscriptFSOCallWithArgAndTrue.bind(null,"DeleteFile"),deleteDirectory:_gpfFsWscriptFSOCallWithArgAndTrue.bind(null,"DeleteFolder")});_gpfFileStorageByHost[_GPF_HOST.WSCRIPT]=new _GpfWScriptFileStorage;_gpfFsReadImplByHost[_GPF_HOST.WSCRIPT]=_gpfFileStorageRead;_gpfFsReadImplByHost[_GPF_HOST.BROWSER]=gpf.Error.notImplemented;_gpfFsReadImplByHost[_GPF_HOST.RHINO]=function(path){return new Promise(function(resolve){resolve(readFile(path));});};_gpfFsReadImplByHost[_GPF_HOST.PHANTOMJS]=function(path){return new Promise(function(resolve,reject){try{resolve(_gpfNodeFs.read(path));}catch(e){reject(new Error(e));}});};var _gpfObjectToString=Object.prototype.toString;function _gpfIsLiteralObject(value){return value instanceof Object&&_gpfObjectToString.call(value)==="[object Object]"&&Object.getPrototypeOf(value)===Object.getPrototypeOf({});}gpf.isLiteralObject=_gpfIsLiteralObject;_gpfErrorDeclare("web/tag",{missingNodeName:"Missing node name",unknownNamespacePrefix:"Unknown namespace prefix",unableToUseNamespaceInString:"Unable to use namespace in string"});var _gpfWebTagAttributeAliases={"className":"class"};var _gpfWebNamespacePrefix={"svg":"http://www.w3.org/2000/svg","xlink":"http://www.w3.org/1999/xlink"};function _gpfWebGetNamespace(prefix){var namespace=_gpfWebNamespacePrefix[prefix];if(undefined===namespace){gpf.Error.unknownNamespacePrefix();}return namespace;}function _gpfWebGetNamespaceAndName(name){var parts=name.split(":");if(parts.length===2){return{namespace:_gpfWebGetNamespace(parts[0]),name:parts[1]};}}function _gpfWebCheckNamespaceSafe(name){if(-1!==name.indexOf(":")){gpf.Error.unableToUseNamespaceInString();}}function _gpfWebTagAttributeAlias(name){return _gpfWebTagAttributeAliases[name]||name;}function _gpfWebTagFlattenChildren(array,callback){array.forEach(function(item){if(_gpfIsArray(item)){_gpfWebTagFlattenChildren(item,callback);}else{callback(item);}});}var _GpfWebTag=_gpfDefine({$class:"gpf.web.Tag",constructor:function(nodeName,attributes,children){this._nodeName=nodeName;this._attributes=attributes||{};this._children=children;},_nodeName:"",_attributes:{},_children:[],_getAttributesAsString:function(){return Object.keys(this._attributes).map(function(name){_gpfWebCheckNamespaceSafe(name);return" "+_gpfWebTagAttributeAlias(name)+"=\""+_gpfStringEscapeFor(this._attributes[name],"html")+"\"";},this).join("");},_getChildrenAsString:function(){var result=[];_gpfWebTagFlattenChildren(this._children,function(child){result.push(child.toString());});return result.join("");},_getClosingString:function(){if(this._children.length){return">"+this._getChildrenAsString()+"</"+this._nodeName+">";}return"/>";},toString:function(){_gpfWebCheckNamespaceSafe(this._nodeName);return"<"+this._nodeName+this._getAttributesAsString()+this._getClosingString();},_createElement:function(node){var ownerDocument=node.ownerDocument,qualified=_gpfWebGetNamespaceAndName(this._nodeName);if(qualified){return ownerDocument.createElementNS(qualified.namespace,qualified.name);}return ownerDocument.createElement(this._nodeName);},_setAttributesTo:function(node){_gpfObjectForEach(this._attributes,function(value,name){var qualified=_gpfWebGetNamespaceAndName(name);if(qualified){node.setAttributeNS(qualified.namespace,_gpfWebTagAttributeAlias(qualified.name),value);}else{node.setAttribute(_gpfWebTagAttributeAlias(name),value);}});},_appendChildrenTo:function(node){var ownerDocument=node.ownerDocument;_gpfWebTagFlattenChildren(this._children,function(child){if(child instanceof _GpfWebTag){child.appendTo(node);}else{node.appendChild(ownerDocument.createTextNode(child.toString()));}});},appendTo:function(node){var element=this._createElement(node);this._setAttributesTo(element);this._appendChildrenTo(element);return node.appendChild(element);}});function _gpfWebTagCreateFunction(nodeName){if(!nodeName){gpf.Error.missingNodeName();}return function(firstParam){var sliceFrom,attributes;if(_gpfIsLiteralObject(firstParam)){attributes=firstParam;sliceFrom=1;}else{sliceFrom=0;}return new _GpfWebTag(nodeName,attributes,[].slice.call(arguments,sliceFrom));};}gpf.web.createTagFunction=_gpfWebTagCreateFunction;gpf.http={};var _GPF_HTTP_METHODS={GET:"GET",POST:"POST",PUT:"PUT",OPTIONS:"OPTIONS",DELETE:"DELETE",HEAD:"HEAD"};var _gpfHttpHeadersParserRE=new RegExp("([^:\\s]+)\\s*: ?([^\\r]*)","gm");function _gpfHttpParseHeaders(headers){var result={};_gpfArrayForEach(_gpfRegExpForEach(_gpfHttpHeadersParserRE,headers),function(match){result[match[1]]=match[2];});return result;}function _gpfHttpGenSetHeaders(methodName){return function(httpObj,headers){if(headers){Object.keys(headers).forEach(function(headerName){httpObj[methodName](headerName,headers[headerName]);});}};}function _gpfHttpGenSend(methodName){return function(httpObj,data){if(data){httpObj[methodName](data);}else{httpObj[methodName]();}};}var _gpfIThenable=_gpfDefineInterface("Thenable",{"then":2});function _gpfPromisify(value){if(gpf.interfaces.isImplementedBy(gpf.interfaces.IThenable,value)){return value;}return Promise.resolve(value);}function _gpfPromisifyDefined(value){if(undefined!==value){return _gpfPromisify(value);}}gpf.promisify=_gpfPromisify;gpf.promisifyDefined=_gpfPromisifyDefined;var _gpfHttpMockedRequests={};function _gpfHttMockMatchRequest(mockedRequest){var url=mockedRequest.url,match;url.lastIndex=0;match=url.exec(this.url);if(match){return _gpfPromisifyDefined(mockedRequest.response.apply(null,[this].concat([].slice.call(match,1))));}}function _gpfHttMockMatch(mockedRequests,request){return _gpfArrayForEachFalsy(mockedRequests,_gpfHttMockMatchRequest.bind(request));}function _gpfHttpMockCheck(request){return _gpfHttMockMatch(_gpfHttpMockedRequests[request.method],request);}var _gpfHttpMockLastId=0;function _gpfHttpMockAdd(definition){var method=definition.method,id;++_gpfHttpMockLastId;id=method+"."+_gpfHttpMockLastId;_gpfHttpMockedRequests[method].unshift(Object.assign({method:method,id:id},definition));return id;}function _gpfHttpMockRemove(id){var method=id.split(".")[0];_gpfHttpMockedRequests[method]=_gpfHttpMockedRequests[method].filter(function(mockedRequest){return mockedRequest.id!==id;});}function _gpfHttpMockReset(){Object.keys(_GPF_HTTP_METHODS).forEach(function(method){_gpfHttpMockedRequests[method]=[];});}_gpfHttpMockReset();gpf.http.mock=_gpfHttpMockAdd;gpf.http.mock.remove=_gpfHttpMockRemove;gpf.http.mock.reset=_gpfHttpMockReset;var _gpfHttpRequestImplByHost={};function _gpfHttpRequest(request){return _gpfHttpMockCheck(request)||new Promise(function(resolve,reject){_gpfHttpRequestImplByHost[_gpfHost](request,resolve,reject);});}function _gpfProcessAlias(method,url,data){if("string"===typeof url){return _gpfHttpRequest({method:method,url:url,data:data});}return _gpfHttpRequest(Object.assign({method:method},url));}Object.assign(gpf.http,{methods:{get:_GPF_HTTP_METHODS.GET,post:_GPF_HTTP_METHODS.POST,put:_GPF_HTTP_METHODS.PUT,options:_GPF_HTTP_METHODS.OPTIONS,"delete":_GPF_HTTP_METHODS.DELETE,head:_GPF_HTTP_METHODS.HEAD},request:_gpfHttpRequest,get:_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.GET),post:_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.POST),put:_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.PUT),options:_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.OPTIONS),"delete":_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.DELETE),head:_gpfProcessAlias.bind(gpf.http,_GPF_HTTP_METHODS.HEAD)});var _gpfHttpXhrSetHeaders=_gpfHttpGenSetHeaders("setRequestHeader"),_gpfHttpXhrSend=_gpfHttpGenSend("send");function _gpfHttpXhrOpen(request){var xhr=new XMLHttpRequest;xhr.open(request.method,request.url);return xhr;}function _gpfHttpXhrWaitForCompletion(xhr,callback){xhr.onreadystatechange=function(){if(4===xhr.readyState){callback();}};}_gpfHttpRequestImplByHost[_GPF_HOST.BROWSER]=_gpfHttpRequestImplByHost[_GPF_HOST.PHANTOMJS]=function(request,resolve){var xhr=_gpfHttpXhrOpen(request);_gpfHttpXhrSetHeaders(xhr,request.headers);_gpfHttpXhrWaitForCompletion(xhr,function(){resolve({status:xhr.status,headers:_gpfHttpParseHeaders(xhr.getAllResponseHeaders()),responseText:xhr.responseText});});_gpfHttpXhrSend(xhr,request.data);};function _gpfStringFromStream(readableStream){var iWritableString=new _GpfStreamWritableString,iReadableStream=_gpfStreamQueryReadable(readableStream);return iReadableStream.read(iWritableString).then(function(){return iWritableString.toString();});}function _gpfHttpNodeProcessResponse(nodeResponse,resolve){nodeResponse.setEncoding("utf8");var iReadableStream=new _GpfNodeReadableStream(nodeResponse);_gpfStringFromStream(iReadableStream).then(function(responseText){iReadableStream.close();resolve({status:nodeResponse.statusCode,headers:nodeResponse.headers,responseText:responseText});});}function _gpfHttpNodeAdjustSettingsForSend(settings,data){if(data){settings.headers=Object.assign({"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(data)},settings.headers);}}function _gpfHttpNodeBuildRequestSettings(request){var settings=Object.assign(_gpfNodeUrl.parse(request.url),request);_gpfHttpNodeAdjustSettingsForSend(settings,request.data);return settings;}function _gpfHttpNodeAllocate(request,resolve){var settings=_gpfHttpNodeBuildRequestSettings(request);return _gpfNodeHttp.request(settings,function(nodeResponse){_gpfHttpNodeProcessResponse(nodeResponse,resolve);});}function _gpfHttpNodeSend(clientRequest,data){if(data){clientRequest.write(data,"utf8",function(){clientRequest.end();});}else{clientRequest.end();}}_gpfHttpRequestImplByHost[_GPF_HOST.NODEJS]=function(request,resolve,reject){var clientRequest=_gpfHttpNodeAllocate(request,resolve);clientRequest.on("error",reject);_gpfHttpNodeSend(clientRequest,request.data);};var _gpfHttpWScriptSetHeaders=_gpfHttpGenSetHeaders("setRequestHeader"),_gpfHttpWScriptSend=_gpfHttpGenSend("Send");function _gpfHttpWScriptAllocate(request){var winHttp=new ActiveXObject("WinHttp.WinHttpRequest.5.1");winHttp.Open(request.method,request.url);return winHttp;}function _gpfHttpWScriptResolve(winHttp,resolve){resolve({status:winHttp.Status,headers:_gpfHttpParseHeaders(winHttp.GetAllResponseHeaders()),responseText:winHttp.ResponseText});}_gpfHttpRequestImplByHost[_GPF_HOST.WSCRIPT]=function(request,resolve){var winHttp=_gpfHttpWScriptAllocate(request);_gpfHttpWScriptSetHeaders(winHttp,request.headers);_gpfHttpWScriptSend(winHttp,request.data);_gpfHttpWScriptResolve(winHttp,resolve);};var _GpfRhinoBaseStream=_gpfDefine({$class:"gpf.rhino.BaseStream",constructor:function(stream){this._stream=stream;},close:function(){this._stream.close();return Promise.resolve();},_stream:null}),_GpfRhinoReadableStream=_gpfDefine({$class:"gpf.rhino.ReadableStream",$extend:"gpf.rhino.BaseStream",_handleError:function(e){if(e.message.indexOf("java.util.NoSuchElementException")===0){return Promise.resolve();}return Promise.reject(e);},read:_gpfStreamSecureRead(function(output){try{var scanner=new java.util.Scanner(this._stream);return output.write(String(scanner.useDelimiter("\\A").next()));}catch(e){return this._handleError(e);}})}),_GpfRhinoWritableStream=_gpfDefine({$class:"gpf.rhino.WritableStream",$extend:"gpf.rhino.BaseStream",constructor:function(stream){this.$super(stream);this._writer=new java.io.OutputStreamWriter(stream);},write:_gpfStreamSecureWrite(function(buffer){var writer=this._writer;writer.write(buffer);writer.flush();return Promise.resolve();}),close:function(){this._writer.close();return this.$super();},_writer:null});var _gpfHttpRhinoSetHeaders=_gpfHttpGenSetHeaders("setRequestProperty");function _gpfHttpRhinoSendData(httpConnection,data){if(data){httpConnection.setDoOutput(true);var iWritableStream=new _GpfRhinoWritableStream(httpConnection.getOutputStream());return iWritableStream.write(data).then(function(){iWritableStream.close();});}return Promise.resolve();}function _gpfHttpRhinoGetResponse(httpConnection){try{return httpConnection.getInputStream();}catch(e){return httpConnection.getErrorStream();}}function _gpfHttpRhinoGetResponseText(httpConnection){var iReadableStream=new _GpfRhinoReadableStream(_gpfHttpRhinoGetResponse(httpConnection));return _gpfStringFromStream(iReadableStream).then(function(responseText){iReadableStream.close();return responseText;});}function _gpfHttpRhinoGetHeaders(httpConnection){var headers={},headerFields=httpConnection.getHeaderFields(),keys=headerFields.keySet().toArray();keys.forEach(function(key){headers[String(key)]=String(headerFields.get(key).get(0));});return headers;}function _gpfHttpRhinoResolve(httpConnection,resolve){_gpfHttpRhinoGetResponseText(httpConnection).then(function(responseText){resolve({status:httpConnection.getResponseCode(),headers:_gpfHttpRhinoGetHeaders(httpConnection),responseText:responseText});});}_gpfHttpRequestImplByHost[_GPF_HOST.RHINO]=function(request,resolve){var httpConnection=new java.net.URL(request.url).openConnection();httpConnection.setRequestMethod(request.method);_gpfHttpRhinoSetHeaders(httpConnection,request.headers);_gpfHttpRhinoSendData(httpConnection,request.data).then(function(){_gpfHttpRhinoResolve(httpConnection,resolve);});};function _gpfStreamLineLastDoesntEndsWithLF(buffer){var lastItem=buffer[buffer.length-1];return lastItem.charAt(lastItem.length-1)!=="\n";}function _gpfStreamLineTrimCR(line){var lengthMinus1=line.length-1;if(line.lastIndexOf("\r")===lengthMinus1){return line.substr(0,lengthMinus1);}return line;}function _gpfStreamLineWrite(output,lines){if(!lines.length){return Promise.resolve();}return output.write(_gpfStreamLineTrimCR(lines.shift())).then(function(){return _gpfStreamLineWrite(output,lines);});}var _GpfStreamLineAdatper=_gpfDefine({$class:"gpf.stream.LineAdapter",constructor:function(){this._buffer=[];},read:_gpfStreamSecureRead(function(output){var me=this;me._output=output;if(me._buffer.length){return me._process();}return Promise.resolve();}),write:_gpfStreamSecureWrite(function(buffer){var me=this;me._buffer.push(buffer.toString());if(me._output){return me._process();}return Promise.resolve();}),flush:function(){if(_gpfStreamLineLastDoesntEndsWithLF(this._buffer)){return this.write("\n");}return Promise.resolve();},endOfStream:function(){return this.flush();},_output:null,_buffer:[],_extractLines:function(){return this._buffer.join("").split("\n");},_pushBackLastLineIfNotEmpty:function(lines){var lastLine=lines.pop();if(lastLine.length){this._buffer.push(lastLine);}},_process:function(){var lines=this._extractLines();this._buffer.length=0;this._pushBackLastLineIfNotEmpty(lines);return _gpfStreamLineWrite(this._output,lines);}});_gpfStreamSecureInstallProgressFlag(_GpfStreamLineAdatper);var _gpfIFlushableStream=_gpfDefineInterface("FlushableStream",{"flush":0});var _gpfRequireLoadImpl;function _gpfRequireLoadHTTP(name){return _gpfHttpRequest({method:_GPF_HTTP_METHODS.GET,url:name}).then(function(response){return response.responseText;});}function _gpfRequireLoadFS(name){return _gpfFsRead(_gpfPathJoin(".",name));}if(_gpfHost===_GPF_HOST.BROWSER){_gpfRequireLoadImpl=_gpfRequireLoadHTTP;}else{_gpfRequireLoadImpl=_gpfRequireLoadFS;}var _gpfRequireProcessor={};function _gpfRequireLoad(name){var me=this;return _gpfRequireLoadImpl(name).then(function(content){var processor=_gpfRequireProcessor[_gpfPathExtension(name).toLowerCase()];if(processor){return processor.call(me,name,content);}return content;});}function _gpfRequireAllocateWrapper(){return{gpf:Object.create(gpf),promise:Promise.resolve(),_initialDefine:null};}function _gpfRequireWrappedDefine(){var wrapper=this,gpfRequire=wrapper.gpf.require,gpfRequireDefine=wrapper._initialDefine;wrapper.promise=gpfRequireDefine.apply(gpfRequire,arguments);gpfRequire.define=gpfRequireDefine;return wrapper.promise;}function _gpfRequirePlugWrapper(wrapper,require){wrapper._initialDefine=require.define;require.define=_gpfRequireWrappedDefine.bind(wrapper);wrapper.gpf.require=require;return wrapper;}function _gpfRequireWrapGpf(context,name){return _gpfRequirePlugWrapper(_gpfRequireAllocateWrapper(),_gpfRequireAllocate(context,{base:_gpfPathParent(name)}));}_gpfRequireProcessor[".json"]=function(name,content){return JSON.parse(content);};_gpfErrorDeclare("require/javascript",{noCommonJSDynamicRequire:"Dynamic require not supported"});var _gpfRequireJsModuleRegEx=/[^\.]\brequire\b\s*\(\s*(?:['|"]([^"']+)['|"]|[^\)]+)\s*\)/g;function _gpfRequireCommonJSBuildNamedDependencies(requires){return requires.reduce(function(dictionary,name){dictionary[name]=name;return dictionary;},{});}function _gpfRequireCommonJs(myGpf,content,requires){return myGpf.require.define(_gpfRequireCommonJSBuildNamedDependencies(requires),function(require){var module={};_gpfFunc(["gpf","module","require"],content)(myGpf,module,function(name){return require[name]||gpf.Error.noCommonJSDynamicRequire();});return module.exports;});}function _gpfRequireAmdDefineParamsFactoryOnly(params){return{dependencies:[],factory:params[0]};}function _gpfRequireAmdDefineParamsDependenciesAndFactory(params){return{dependencies:params[0],factory:params[1]};}function _gpfRequireAmdDefineParamsAll(params){return{dependencies:params[1],factory:params[2]};}var _gpfRequireAmdDefineParamsMapping=[null,_gpfRequireAmdDefineParamsFactoryOnly,_gpfRequireAmdDefineParamsDependenciesAndFactory,_gpfRequireAmdDefineParamsAll];function _gpfRequireAmdDefine(name,dependencies,factory){var myGpf=this,params=_gpfRequireAmdDefineParamsMapping[arguments.length](arguments);myGpf.require.define(params.dependencies,function(require){require.length=params.dependencies.length;return params.factory.apply(null,[].slice.call(require));});}function _gpfRequireOtherJs(myGpf,content){_gpfFunc(["gpf","define"],content)(myGpf,_gpfRequireAmdDefine.bind(myGpf));}_gpfRequireProcessor[".js"]=function(name,content){var wrapper=_gpfRequireWrapGpf(this,name);var requires=_gpfRegExpForEach(_gpfRequireJsModuleRegEx,content);if(requires.length){return _gpfRequireCommonJs(wrapper.gpf,content,requires.map(function(match){return match[1];}).filter(function(require){return require;}));}_gpfRequireOtherJs(wrapper.gpf,content);return wrapper.promise;};_gpfErrorDeclare("require",{invalidRequireConfigureOption:"Invalid configuration option"});function _gpfRequireOptionPriority(name){if("clearCache"===name){return-1;}return 1;}var _gpfRequireOptionHandler={base:function(base){this.base=base;},cache:function(cache){_gpfArrayForEach(Object.keys(cache),function(name){this.cache[name]=_gpfPromisify(cache[name]);},this);},clearCache:function(){this.cache={};}};function _gpfRequireConfigure(options){var me=this;_gpfArrayForEach(Object.keys(options).sort(function(key1,key2){return _gpfRequireOptionPriority(key1)-_gpfRequireOptionPriority(key2);}),function(key){(_gpfRequireOptionHandler[key]||gpf.Error.invalidRequireConfigureOption).call(me,options[key]);},me);}function _gpfRequireResolve(name){return _gpfPathJoin(this.base,name);}function _gpfRequireGet(name){var me=this,promise;if(me.cache[name]){return me.cache[name];}promise=_gpfRequireLoad.call(me,name);me.cache[name]=promise;return promise;}function _gpfRequireDefine(dependencies,factory){var me=this,promises=[],keys=Object.keys(dependencies);_gpfArrayForEach(keys,function(key){promises.push(_gpfRequireGet.call(me,_gpfRequireResolve.call(me,dependencies[key])));},me);return Promise.all(promises).then(function(resources){var result,require;if("function"===typeof factory){require={};_gpfArrayForEach(keys,function(key,index){require[key]=resources[index];});result=factory(require);}else{result=factory;}return result;});}function _gpfRequireAllocate(parentContext,options){var context=Object.create(parentContext),require={};require.define=_gpfRequireDefine.bind(context);require.resolve=_gpfRequireResolve.bind(context);require.configure=_gpfRequireConfigure.bind(context);if(options){require.configure(options);}return require;}gpf.require=_gpfRequireAllocate({base:"",cache:{}});var _GpfStreamReadableArray=_gpfDefine({$class:"gpf.stream.ReadableArray",constructor:function(buffer){this._buffer=buffer;},read:_gpfStreamSecureRead(function(output){var buffer=this._buffer,step=0;function write(){if(buffer.length===step){return Promise.resolve();}return output.write(buffer[step++]).then(write);}return write();}),_buffer:[]}),_GpfStreamWritableArray=_gpfDefine({$class:"gpf.stream.WritableArray",constructor:function(){this._buffer=[];},write:_gpfStreamSecureWrite(function(buffer){this._buffer.push(buffer);return Promise.resolve();}),toArray:function(){return this._buffer;},_buffer:[]});_gpfStreamSecureInstallProgressFlag(_GpfStreamReadableArray);_gpfStreamSecureInstallProgressFlag(_GpfStreamWritableArray);}));
\No newline at end of file