-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcf.min.js
More file actions
1 lines (1 loc) · 128 KB
/
Copy pathfcf.min.js
File metadata and controls
1 lines (1 loc) · 128 KB
1
(function(){var fcf=typeof global!=="undefined"&&global.fcf?global.fcf:typeof window!=="undefined"&&window.fcf?window.fcf:{};fcf.NDetails=fcf.NDetails||{};fcf.namespaces=fcf.namespaces||{};if(typeof module!=="undefined")module.exports=fcf;if(typeof global!=="undefined")global.fcf=fcf;if(typeof window!=="undefined")window.fcf=fcf;fcf.isServer=()=>_isServer;const _isServer=typeof module==="object"&&typeof module.filename!=="undefined";if(!fcf.isServer()&&!fcf.NDetails.inlineExecution){fcf.NDetails.inlineExecution={execEnvironment:{functions:{functions:{},items:{}},environment:{},environmentInfo:{parts:{}}},getEnvironment:()=>fcf.NDetails.inlineExecution.execEnvironment,setEnvironment:a_environment=>{fcf.NDetails.inlineExecution.execEnvironment.functions=a_environment.functions;fcf.NDetails.inlineExecution.execEnvironment.environment=a_environment.environment;fcf.NDetails.inlineExecution.execEnvironment.environmentInfo=a_environment.environmentInfo}}}let libResolver,libPath,libFS,libUtil,libState,libLogger;if(_isServer){libResolver=require("./NDetails/resolver.js");libPath=require("path");libFS=require("fs");libUtil=require("util");libInlineInterpreter=require("./NDetails/inlineExecution.js");libLoad=require("./NDetails/load.js");libState=require("./NDetails/state.js");libLogger=require("./NDetails/logger.js")}function _autoParse(a_value){if(typeof a_value=="string"&&a_value.length){let s=0;for(;s<a_value.length&&a_value.charCodeAt(s)<=32;++s);let l=a_value.length-1;for(;l>=0&&a_value.charCodeAt(l)<=32;--l);if(l>=0&&(!isNaN(a_value)||l-s>=1&&a_value[s]=='"'&&a_value[l]=='"'||a_value[s]=="{"&&a_value[l]=="}"||a_value[s]=="["&&a_value[l]=="]"||l-s==3&&a_value[s]=="t"&&a_value[s+1]=="r"&&a_value[s+2]=="u"&&a_value[s+3]=="e"||l-s==4&&a_value[s]=="f"&&a_value[s+1]=="a"&&a_value[s+2]=="l"&&a_value[s+3]=="s"&&a_value[s+4]=="e"||l-s==3&&a_value[s]=="n"&&a_value[s+1]=="u"&&a_value[s+2]=="l"&&a_value[s+3]=="l")){try{let res=JSON.parse(a_value);return res}catch(e){return a_value}}else{return a_value}}else{return a_value}}fcf.str=(a_data,a_fullMode)=>typeof a_data=="string"?a_data:a_data===undefined?"":a_data===null?"":typeof a_data==="number"&&isNaN(a_data)?"":typeof a_data=="object"?a_data instanceof fcf.Exception?fcf.errorToString(a_data,a_fullMode):a_data instanceof Error?fcf.errorToString(a_data,a_fullMode):a_data.sqlMessage&&a_data.sqlState&&a_data.code?a_data.sqlMessage:JSON.stringify(a_data,undefined,2):a_data.toString();fcf.escapeQuotes=(a_str,a_quote)=>{let result="";if(Array.isArray(a_quote)){for(let i=0;i<a_str.length;++i){let c=a_str[i];if(c==="\\"){result+="\\\\"}else if(a_quote.indexOf(c)!=-1){result+="\\";result+=c}else{result+=c}}}else{for(let i=0;i<a_str.length;++i){let c=a_str[i];if(c==="\\"){result+="\\\\"}else if(a_quote&&c===a_quote){result+="\\";result+=a_quote}else if(!a_quote&&c==='"'){result+='\\"'}else if(!a_quote&&c==="'"){result+="\\'"}else{result+=c}}}return result};fcf.unescape=a_data=>{if(typeof a_data=="object"&&a_data!==null){a_data=fcf.clone(a_data);if(Array.isArray(a_data)){for(let key=0;key<a_data.length;++key)a_data[key]=fcf.unescape(a_data[key])}else{for(let key in a_data)a_data[key]=fcf.unescape(a_data[key])}return a_data}else if(typeof a_data=="string"){let result="";let counter=0;for(let i=0;i<a_data.length;++i){let c=a_data[i];if(c=="\\"){++counter;if(counter%2==0)result+=c}else{counter=0;result+=c}}return result}};fcf.replaceAll=(a_str,a_search,a_replacement)=>{a_str=fcf.str(a_str);if(a_str.indexOf(a_search)==-1)return a_str;return a_str.split(a_search).join(a_replacement)};fcf.decodeHtml=a_str=>{a_str=fcf.str(a_str);let zn="0".charCodeAt(0);let nn="9".charCodeAt(0);a_str=fcf.str(a_str);let result="";for(let i=0;i<a_str.length;++i){let c=a_str[i];if(c=="&"){if(a_str[i+1]=="#"){let code="";let p=i+2;for(;p<a_str.length;++p){let c=a_str[p];let cn=a_str.charCodeAt(p);if(cn>=zn&&cn<=nn){code+=c}else{if(c!=";"){--p}break}}if(code.length){result+=String.fromCharCode(parseInt(code));i=p;continue}}else{let p=i+1;let inst="";for(;p<a_str.length;++p){let c=a_str[p];if(c=="&"){--p;break}inst+=c;if(inst in _decodeHtml_map)break;if(inst.length==_decodeHtml_mapMaxLength)break}i=p;if(inst in _decodeHtml_map){if(a_str[i+1]==";")++i;result+=_decodeHtml_map[inst]}else{result+="&";result+=inst}continue}result+=c}else{result+=c}}return result};const _decodeHtml_map={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",bull:"•",infin:"∞",permil:"‰",sdot:"⋅",dagger:"†",mdash:"—",perp:"⊥",par:"∥",euro:"€",trade:"™",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω"};const _decodeHtml_mapMaxLength=7;fcf.encodeHtml=a_str=>{let result="";a_str=fcf.str(a_str);for(let i=0;i<a_str.length;++i){let c=a_str[i];switch(c){case"<":result+="<";break;case">":result+=">";break;case'"':result+=""";break;case"'":result+="'";break;case"&":result+="&";break;default:result+=c;break}}return result};fcf.stripTags=a_str=>fcf.str(a_str).replace(_regStripTags,"");const _regStripTags=new RegExp("(<[^>]*>)","g");fcf.ltrim=(a_str,a_arr)=>{a_str=fcf.str(a_str);let pos=_ltrimPos(a_str,a_arr);return pos!=0?a_str.substr(pos):a_str};fcf.rtrim=(a_str,a_arr)=>{a_str=fcf.str(a_str);let pos=_rtrimPos(a_str,a_arr);return pos!=a_str.length?a_str.substr(0,pos):a_str};fcf.trim=(a_str,a_arr)=>{a_str=fcf.str(a_str);let posBeg=_ltrimPos(a_str,a_arr);let posEnd=_rtrimPos(a_str,a_arr);return posBeg!=0||posEnd!=a_str.length?a_str.substr(posBeg,posEnd-posBeg):a_str};function _rtrimPos(a_str,a_arr){if(!a_str.length)return 0;if(!Array.isArray(a_arr)){a_arr=[a_arr]}let pos=a_str.length-1;for(;pos>=0;--pos){let found=false;for(let i=0;i<a_arr.length;++i){if(!a_arr[i]){let cn=a_str.charCodeAt(pos);if(cn>=0&&cn<=32){found=true;break}}else if(a_str.charAt(pos)==a_arr[i]){found=true;break}}if(!found)break}return pos+1}function _ltrimPos(a_str,a_arr){let pos=0;if(!Array.isArray(a_arr)){a_arr=[a_arr]}for(;pos<a_str.length;++pos){let found=false;for(let i=0;i<a_arr.length;++i){if(!a_arr[i]){let cn=a_str.charCodeAt(pos);if(cn>=0&&cn<=32){found=true;break}}else if(a_str.charAt(pos)===a_arr[i]){found=true;break}}if(!found)break}return pos}fcf.pad=(a_str,a_len,a_fill,a_align)=>{if(isNaN(a_len))return a_str;let fillLen=a_len-a_str.length;if(fillLen<=0)return a_str;if(!a_fill)a_fill=" ";if(typeof a_align!=="string")a_align="l";let leftLen=a_align[0]=="r"?fillLen:a_align[0]=="c"?Math.floor(fillLen/2):0;let rightLen=a_align[0]=="r"?0:a_align[0]=="c"?Math.floor(fillLen/2)+fillLen%2:fillLen;let result="";for(let i=0;i<leftLen;++i){result+=a_fill[i%a_fill.length]}result+=a_str;for(let i=0;i<rightLen;++i){result+=a_fill[i%a_fill.length]}return result};fcf.id=(a_size,a_safeFirstChar)=>{a_size=a_size||32;a_safeFirstChar=a_safeFirstChar===undefined?true:a_safeFirstChar;let result="";for(let i=0;i<a_size;++i){result+=i||!a_safeFirstChar?Math.floor(Math.random()*16).toString(16):"abcdef"[Math.floor(Math.random()*6)]}return result};fcf.uuid=()=>{let res="";for(let i=0;i<36;++i){if(i==8||i==13||i==18||i==23){res+="-"}else if(i==14){res+="4"}else if(i==19){res+=((Math.random()*16|0)&3|8).toString(16)}else{res+=(Math.random()*16|0).toString(16)}}return res};fcf.decodeBase64=function(a_input){function utf8Decode(utftext){let string="";let i=0;let c=0;let c1=0;let c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++}else if(c>191&&c<224){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode((c&31)<<6|c2&63);i+=2}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode((c&15)<<12|(c2&63)<<6|c3&63);i+=3}}return string}let output="";let chr1,chr2,chr3;let enc1,enc2,enc3,enc4;let i=0;a_input=fcf.str(a_input).replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<a_input.length){enc1=_keyBase64.indexOf(a_input.charAt(i++));enc2=_keyBase64.indexOf(a_input.charAt(i++));enc3=_keyBase64.indexOf(a_input.charAt(i++));enc4=_keyBase64.indexOf(a_input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2)}if(enc4!=64){output=output+String.fromCharCode(chr3)}}output=utf8Decode(output);return output};fcf.encodeBase64=function(a_input){function utf8Encode(a_string){a_string=a_string.replace(/\r\n/g,"\n");let utftext="";for(let n=0;n<a_string.length;n++){let c=a_string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c)}else if(c>127&&c<2048){utftext+=String.fromCharCode(c>>6|192);utftext+=String.fromCharCode(c&63|128)}else{utftext+=String.fromCharCode(c>>12|224);utftext+=String.fromCharCode(c>>6&63|128);utftext+=String.fromCharCode(c&63|128)}}return utftext}let output="";let chr1,chr2,chr3,enc1,enc2,enc3,enc4;let i=0;a_input=utf8Encode(fcf.str(a_input));while(i<a_input.length){chr1=a_input.charCodeAt(i++);chr2=a_input.charCodeAt(i++);chr3=a_input.charCodeAt(i++);enc1=chr1>>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>>6;enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else if(isNaN(chr3)){enc4=64}output=output+_keyBase64.charAt(enc1)+_keyBase64.charAt(enc2)+_keyBase64.charAt(enc3)+_keyBase64.charAt(enc4)}return output};const _keyBase64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";fcf.isObject=a_value=>typeof a_value==="object"&&a_value!==null;fcf.isIterable=a_value=>typeof a_value==="object"&&a_value!==null?typeof a_value[Symbol.iterator]==="function":false;fcf.isNumbered=a_value=>{if(typeof a_value!=="object"||a_value===null)return false;if(typeof a_value[Symbol.iterator]!=="function"||typeof a_value.length!=="number")return false;if(a_value.length>0){return 0 in a_value}else{for(let v of a_value){return false}return true}};Object.defineProperty(fcf,"UNDEFINED",{value:0,writable:false});Object.defineProperty(fcf,"NULL",{value:1,writable:false});Object.defineProperty(fcf,"NAN",{value:2,writable:false});Object.defineProperty(fcf,"BOOLEAN",{value:3,writable:false});Object.defineProperty(fcf,"NUMBER",{value:4,writable:false});Object.defineProperty(fcf,"STRING",{value:5,writable:false});Object.defineProperty(fcf,"DATE",{value:6,writable:false});Object.defineProperty(fcf,"OBJECT",{value:7,writable:false});Object.defineProperty(fcf,"ARRAY",{value:8,writable:false});Object.defineProperty(fcf,"ITERABLE",{value:9,writable:false});Object.defineProperty(fcf,"NUMBERED",{value:10,writable:false});Object.defineProperty(fcf,"ENUM",{value:11,writable:false});Object.defineProperty(fcf,"SET",{value:12,writable:false});Object.defineProperty(fcf,"ANY",{value:-1,writable:false});fcf.isNature=(a_value,a_nature,a_softMode)=>{let l=Array.isArray(a_nature)?a_nature.length:1;for(let i=0;i<l;++i){let nature=Array.isArray(a_nature)?a_nature[i]:a_nature;if(typeof nature=="string"){nature=nature=="numbered"?fcf.NUMBERED:nature=="iterable"?fcf.ITERABLE:nature=="array"?fcf.ARRAY:nature=="object"?fcf.OBJECT:nature=="date"?fcf.DATE:nature=="string"?fcf.STRING:nature=="number"?fcf.NUMBER:nature=="boolean"?fcf.BOOLEAN:nature=="nan"?fcf.NAN:nature=="null"?fcf.NULL:fcf.UNDEFINED}switch(nature){case fcf.NUMBERED:if(fcf.isNumbered(a_value))return true;break;case fcf.ITERABLE:if(fcf.isIterable(a_value))return true;break;case fcf.ARRAY:if(Array.isArray(a_value))return true;break;case fcf.OBJECT:if(typeof a_value=="object"&&a_value!==null&&!(a_value instanceof Date))return true;break;case fcf.DATE:if(a_value instanceof Date)return true;if(a_softMode&&typeof a_value=="string"&&!isNaN(new Date(a_value).getTime()))return true;break;case fcf.STRING:if(typeof a_value==="string")return true;break;case fcf.NUMBER:if(typeof a_value==="number"&&!isNaN(a_value))return true;if(a_softMode&&!isNaN(a_value)&&!isNaN(parseFloat(a_value)))return true;break;case fcf.BOOLEAN:if(typeof a_value==="boolean")return true;break;case fcf.NAN:if(typeof a_value==="number"&&isNaN(a_value))return true;break;case fcf.NULL:if(a_value===null)return true;break;case fcf.UNDEFINED:if(a_value===undefined)return true;break}}return false};fcf.nature=(a_value,a_nature,a_softMode)=>{if(fcf.isNature(a_value,a_nature,a_softMode)){return a_value}};const DEFAULT_TYPE_DESCRIPTION={};function _typeToString(a_type){if(typeof a_type=="number"){switch(a_type){case fcf.UNDEFINED:return"undefined";case fcf.NULL:return"null";case fcf.NAN:return"nan";case fcf.BOOLEAN:return"boolean";case fcf.NUMBER:return"number";case fcf.STRING:return"string";case fcf.DATE:return"date";case fcf.OBJECT:return"object";case fcf.ARRAY:return"array";case fcf.ITERABLE:return"iterable";case fcf.NUMBERED:return"numbered";case fcf.ENUM:return"enum";default:return a_type.toString()}}else{return a_type.toString()}}fcf.type=(a_type,a_description)=>{if(a_type._valid){return a_type}if(!a_type){a_type=fcf.ANY}if(typeof a_type=="object"&&!Array.isArray(a_type)){a_description=a_type;a_type=a_description.type}a_description=a_description||DEFAULT_TYPE_DESCRIPTION;let type={require:a_description.require,convert:a_description.convert};if("default"in a_description){type.default=a_description.default}if(!Array.isArray(a_type)){switch(a_type){case fcf.ANY:case"any":type.type=fcf.ANY;break;case fcf.UNDEFINED:case"undefined":type.type=fcf.UNDEFINED;break;case fcf.NULL:case"null":type.type=fcf.NULL;break;case fcf.NAN:case"nan":type.type=fcf.NAN;break;case fcf.BOOLEAN:case"boolean":type.type=fcf.BOOLEAN;break;case fcf.NUMBER:case"number":type.type=fcf.NUMBER;type.min=a_description.min;type.max=a_description.max;break;case fcf.STRING:case"string":type.type=fcf.STRING;type.length=a_description.length;type.minLength=a_description.minLength;type.maxLength=a_description.maxLength;break;case fcf.DATE:case"date":type.type=fcf.DATE;break;case fcf.ARRAY:case"array":type.type=fcf.ARRAY;type.item=a_description.item?fcf.type(a_description.item):fcf.type(fcf.ANY);break;case fcf.NUMBERED:case"numbered":type.type=fcf.NUMBERED;type.item=a_description.item?fcf.type(a_description.item):fcf.type(fcf.ANY);break;case fcf.OBJECT:case"object":type.type=fcf.OBJECT;type.fields={};if(a_description.fields&&typeof a_description.fields=="object"){for(let key in a_description.fields){type.fields[key]=fcf.type(a_description.fields[key])}}type.undeclared=a_description.undeclared===false?a_description.undeclared:a_description.undeclared===true?fcf.type(fcf.ANY):a_description.undeclared||a_description.undeclared===fcf.UNDEFINED?fcf.type(a_description.undeclared):undefined;break;case fcf.ITERABLE:case"iterable":type.type=fcf.ITERABLE;type.item=a_description.item?fcf.type(a_description.item):fcf.type(fcf.ANY);break;case fcf.ENUM:case"enum":type.type=fcf.ENUM;type.items={};if(Array.isArray(a_description.items)){for(const v of a_description.items){if(!type.items[v]){type.items[v]=[]}type.items[v].push(v)}}break;case fcf.SET:case"set":type.type=fcf.SET;type.items={};if(Array.isArray(a_description.items)){for(const v of a_description.items){if(!type.items[v]){type.items[v]=[]}type.items[v].push(v)}}break;default:throw new fcf.Exception("UNKNOWN_TYPE",{type:a_type});break}}else{type.type=-100;type.types=[];for(let t of a_type){type.types.push(fcf.type(t))}}Object.defineProperty(type,"_valid",{value:1,enumerable:false});return type};const _createIterable=a_value=>{if(Array.isArray(a_value)||a_value instanceof Map||a_value instanceof Set){return new a_value.__proto__.constructor}else{return{}}};const _buildType=(a_type,a_value,a_options,a_resultInfo,a_rootType,a_forceError)=>{switch(a_type.type){case fcf.UNDEFINED:if(a_value===undefined){a_resultInfo.error=false;break}a_resultInfo.error=1;if(a_rootType){a_resultInfo.types=["undefined"]}break;case fcf.NULL:if(a_value===null){a_resultInfo.error=false;break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["null"]}break;case fcf.NAN:if(typeof a_value==="number"&&isNaN(a_value)){a_resultInfo.error=false;break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["nan"]}break;case fcf.BOOLEAN:let value=a_value;if(typeof a_value!=="boolean"&&a_type.convert){value=!!a_value}if(typeof value==="boolean"){a_resultInfo.error=false;a_value=value;break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["boolean"]}break;case fcf.NUMBER:{let value=a_value;if(typeof a_value!=="number"&&a_type.convert){value=Number(a_value)}if(typeof value==="number"&&!isNaN(value)){if(a_type.min!==undefined&&value<a_type.min){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("NUMBER_MIN",{value:a_value,min:a_type.min,path:path})}else if(a_type.max!==undefined&&value>a_type.max){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("NUMBER_MAX",{value:a_value,max:a_type.max,path:path})}else{a_resultInfo.error=false;a_value=value;break}}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["number"]}}break;case fcf.STRING:{let value=a_value;if(typeof a_value!=="string"&&a_type.convert){value=fcf.str(a_value)}if(typeof value==="string"){if(a_type.length!==undefined&&a_type.length!=value.length){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("STRING_LENGTH",{currentLength:value.length,length:a_type.length,path:path})}else if(a_type.minLength!==undefined&&value.length<a_type.minLength){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("STRING_MIN_LENGTH",{currentLength:value.length,minLength:a_type.minLength,path:path})}else if(a_type.maxLength!==undefined&&value.length>a_type.maxLength){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("STRING_MAX_LENGTH",{currentLength:value.length,maxLength:a_type.maxLength,path:path})}a_resultInfo.error=false;a_value=value;break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["string"]}}break;case fcf.DATE:{let value=a_value;if(!(a_value instanceof Date)&&a_type.convert){value=new Date(a_value)}if(value instanceof Date&&!isNaN(value.getTime())){a_resultInfo.error=false;a_value=value;break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["date"]}}break;case-100:a_resultInfo.error=false;for(let t of a_type.types){let value=_buildType(t,a_value,a_options,a_resultInfo,false,false);if(!a_resultInfo.error){a_value=value;break}}if(a_resultInfo.error==1){a_resultInfo.types=a_type.types.map((a_type=>{if(a_type.type==fcf.ENUM){let v=[];for(let k in a_type.items){for(let itm of a_type.items[k]){v.push(JSON.stringify(itm))}}let tstr="enum[";tstr+=v.join(";");tstr+="]";return tstr}else{return _typeToString(a_type.type)}}))}break;case fcf.ARRAY:case fcf.NUMBERED:const check=a_type.type==fcf.ARRAY?Array.isArray(a_value):fcf.isNumbered(a_value);if(check){let value=[];a_resultInfo.error=false;for(let i=0;i<a_value.length;++i){a_resultInfo.path.push(i.toString());let item=_buildType(a_type.item,a_value[i],a_options,a_resultInfo,true,false);if(!a_resultInfo.error){value[i]=item}else{let path=fcf.normalizeObjectAddress(a_resultInfo.path);if(a_resultInfo.error==1){throw new fcf.Exception("NOT_MATCH_TYPE",{path:path,types:a_resultInfo.types?a_resultInfo.types:[]})}else{throw new fcf.Exception("FIELD_NOT_SET",{path:path})}}a_resultInfo.path.pop()}a_value=value}else{a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=[a_type.type==fcf.ARRAY?"array":"numbered"]}}break;case fcf.OBJECT:if(a_value&&typeof a_value=="object"){let value={};a_resultInfo.error=false;for(let name in a_type.fields){a_resultInfo.path.push(name);let item=_buildType(a_type.fields[name],a_value[name],a_options,a_resultInfo,true,false);if(a_resultInfo.error==2&&!a_type.fields[name].require){a_resultInfo.error=0;a_resultInfo.path.pop();continue}else if(!a_resultInfo.error){value[name]=item}else{let path=fcf.normalizeObjectAddress(a_resultInfo.path);if(a_resultInfo.error==1){throw new fcf.Exception("NOT_MATCH_TYPE",{path:path,types:a_resultInfo.types?a_resultInfo.types:[]})}else{throw new fcf.Exception("FIELD_NOT_SET",{path:path})}}a_resultInfo.path.pop()}if(a_type.undeclared===false){for(let name in a_value){if(!(name in a_type.fields)){let path=fcf.normalizeObjectAddress(a_resultInfo.path);throw new fcf.Exception("UNDECLARED_FIELD",{path:path,field:name});break}}}else if(a_type.undeclared&&typeof a_type.undeclared=="object"){for(let name in a_value){if(!(name in a_type.fields)){a_resultInfo.path.push(name);let item=_buildType(a_type.undeclared,a_value[name],a_options,a_resultInfo,true,false);if(!a_resultInfo.error){value[name]=item}else{let path=fcf.normalizeObjectAddress(a_resultInfo.path);if(a_resultInfo.error==1){throw new fcf.Exception("NOT_MATCH_TYPE",{path:path,types:a_resultInfo.types?a_resultInfo.types:[]})}else{throw new fcf.Exception("FIELD_NOT_SET",{path:path})}}a_resultInfo.path.pop()}}}a_value=value}else{a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["object"]}}break;case fcf.ITERABLE:if(fcf.isIterable(a_value)){a_resultInfo.error=false;let value=_createIterable(a_value);fcf.each(a_value,((key,item)=>{a_resultInfo.path.push(key.toString());let newItem={};newItem[key]=_buildType(a_type.item,item,a_options,a_resultInfo,true,true);fcf.append(value,newItem);if(a_resultInfo.error){let path=fcf.normalizeObjectAddress(a_resultInfo.path);if(a_resultInfo.error==1){throw new fcf.Exception("NOT_MATCH_TYPE",{path:path,types:a_resultInfo.types?a_resultInfo.types:[]})}else{throw new fcf.Exception("FIELD_NOT_SET",{path:path})}}a_resultInfo.path.pop()}));a_value=value}else{a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){a_resultInfo.types=["array"]}}break;case fcf.SET:{let value=a_value;if(typeof a_value=="string"){let emp=true;value=[];for(let c of a_value){if(emp){emp=false;value.push("")}if(c=="|"||c==";"){emp=true}else{value[value.length-1]+=c}}}if(Array.isArray(value)){value=[...value]}if(Array.isArray(value)){let valid=true;for(let i of value){if(!(i in a_type.items)){valid=false;break}}if(valid){a_resultInfo.error=false;a_value=value;break}}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){let v=[];for(let k in a_type.items){for(let itm of a_type.items[k]){v.push(JSON.stringify(itm))}}let tstr="set[";tstr+=v.join(";");tstr+="]";a_resultInfo.types=[tstr]}}break;case fcf.ENUM:{let found=false;if(a_value in a_type.items){for(let v of a_type.items[a_value]){let eq=a_type.convert?v==a_value:v===a_value;if(eq){a_resultInfo.error=false;a_value=v;found=true;break}}}if(found){break}a_resultInfo.error=a_value===undefined?2:1;if(a_rootType){let v=[];for(let k in a_type.items){for(let itm of a_type.items[k]){v.push(JSON.stringify(itm))}}let tstr="enum[";tstr+=v.join(";");tstr+="]";a_resultInfo.types=[tstr]}}break}if(a_resultInfo.error&&!a_forceError){if("default"in a_type){a_resultInfo.error=false;return a_type.default}else{return}}else{return a_value}};fcf.build=(a_type,a_value,a_options)=>{if(!a_type._valid){a_type=type(a_type)}let resultInfo={error:false,path:[]};a_value=_buildType(a_type,a_value,a_options,resultInfo,true,false);if(resultInfo.error==1){throw new fcf.Exception("NOT_MATCH_TYPE",{path:"",types:resultInfo.types?resultInfo.types:[]})}else if(resultInfo.error==2){throw new fcf.Exception("FIELD_NOT_SET",{path:""})}return a_value};fcf.empty=a_object=>{if(a_object===undefined||a_object===null){return true}else if(typeof a_object==="number"){return isNaN(a_object)}else if(typeof a_object==="string"){return a_object===""}else if(a_object instanceof Error){return false}else if(a_object instanceof Date){return isNaN(a_object.getTime())}else if(fcf.isIterable(a_object)){for(let v of a_object)return false;return true}else if(typeof a_object==="object"){for(var k in a_object)return false;return true}return false};fcf.has=(a_object,a_key)=>{if(typeof a_object!=="object"||a_object===null){return false}if(fcf.isIterable(a_object)&&typeof a_object.has=="function"){return a_object.has(a_key)}if(fcf.isNumbered(a_object)){a_key=parseInt(a_key);return a_key>=0&&a_key<a_object.length}return a_key in a_object};fcf.get=(a_object,a_key)=>{if(typeof a_object!=="object"||a_object===null){return}if(a_object instanceof Set){return a_object.has(a_key)?a_key:undefined}if(a_object instanceof Map){return a_object.get(a_key)}return a_object[a_key]};fcf.equal=(a_left,a_right,a_strict)=>{if(!_equalObject(a_left,a_right,a_strict))return false;if(typeof a_left=="object")return _equalObject(a_right,a_left,a_strict);return true};function _equalObject(a_left,a_right,a_strict){if(Array.isArray(a_left)){if(!Array.isArray(a_right))return false;if(a_left.length!=a_right.length)return false;for(let i=0;i<a_left.length;++i){if(!fcf.equal(a_left[i],a_right[i],a_strict))return false}}else if(a_left instanceof Date||a_right instanceof Date){if(!(a_left instanceof Date)||!(a_right instanceof Date)){return false}else{if(isNaN(a_left.getTime())&&isNaN(a_right.getTime()))return true;return a_left.getTime()==a_right.getTime()}}else if(typeof a_left==="object"&&a_left!==null){if(typeof a_right!=="object"||a_right==null)return false;if(Array.isArray(a_right))return false;if(a_strict&&a_left.constructor!=a_right.constructor){return false}let fastResult;fastResult=fcf.each(a_left,((a_key,a_value)=>{if(a_value!==undefined&&!fcf.has(a_right,a_key))return false;if(!_equalObject(a_value,fcf.get(a_right,a_key),a_strict))return false})).result();if(fastResult!==undefined)return fastResult;fastResult=fcf.each(a_right,((a_key,a_value)=>{if(a_value!==undefined&&!fcf.has(a_left,a_key)){return false}})).result();if(fastResult!==undefined)return false}else{if(typeof a_left=="number"&&isNaN(a_left)&&typeof a_right=="number"&&isNaN(a_right)){return true}if(a_strict){if(a_left!==a_right){return false}}else{if(a_left!=a_right){return false}}}return true}fcf.compare=(a_left,a_right,a_strict)=>{let c=_compareObject(a_left,a_right,a_strict);if(c)return c;c=_compareObject(a_right,a_left,a_strict);return c==0?0:c<0?1:-1};function _compareObject(a_left,a_right,a_strict){if(Array.isArray(a_left)){if(!Array.isArray(a_right)){return 1}if(a_left.length!=a_right.length){return a_left.length<a_right.length?-1:1}for(let i=0;i<a_left.length;++i){let c=fcf.compare(a_left[i],a_right[i],a_strict);if(c){return c}}return 0}else if(typeof a_left==="object"&&a_left!==null&&!(a_left instanceof Date)){if(typeof a_right!=="object"||a_right==null){return 1}if(Array.isArray(a_right)){return-1}if(a_strict){if(a_left.constructor>a_right.constructor){return 1}else if(a_left.constructor<a_right.constructor){return-1}}let fastResult;fastResult=fcf.each(a_left,((a_key,a_value)=>{if(a_value!==undefined&&!fcf.has(a_right,a_key)){return 1}let c=fcf.compare(a_value,fcf.get(a_right,a_key),a_strict);if(c)return c})).result();if(fastResult)return fastResult;fastResult=fcf.each(a_right,((a_key,a_value)=>{if(a_value!==undefined&&!fcf.has(a_left,a_key))return-1})).result();if(fastResult)return-1;return 0}else{if(!a_strict){if(a_left===undefined||a_left===null||a_left===0||a_left===false){if(a_right===undefined||a_right===null||a_right===0||a_right===false){return 0}else if(typeof a_right=="string"){let tr=fcf.trim(a_right);if(tr==""||tr=="0")return 0}}if(a_right===undefined||a_right===null||a_right===0||a_right===false){if(a_left===undefined||a_left===null||a_left===0||a_left===false){return 0}else if(typeof a_left=="string"){let tr=fcf.trim(a_left);if(tr==""||tr=="0")return 0}}}let t1=a_left instanceof Date?"date":typeof a_left;let t2=a_right instanceof Date?"date":typeof a_right;if(!a_strict&&(typeof a_left=="number"||typeof a_right=="number")){if(typeof a_left!="number"){a_left=parseFloat(a_left);t1="number"}if(isNaN(a_left)){t1="nan"}if(typeof a_right!="number"){a_right=parseFloat(a_left);t2="number"}if(isNaN(a_right)){t2="nan"}}let tc1=_compareWeights[t1];let tc2=_compareWeights[t2];if(t1=="nan"&&t2=="nan"){return 0}else if(!a_strict&&a_left==a_right){return 0}else if(tc1==tc2){if(a_left instanceof Date){a_left=a_left.getTime();a_right=a_right.getTime();if(isNaN(a_left)&&isNaN(a_right))return 0}if(a_left==a_right)return 0;if(a_left<a_right)return-1;return 1}else if(tc1>tc2){return 1}else{return-1}}}const _compareWeights={undefined:0,null:1,nan:2,boolean:3,number:4,string:5,date:6,object:7,array:8};fcf.count=(a_object,a_cb)=>{if(!a_cb){if(typeof a_object=="object"&&a_object!==null){if(fcf.isNumbered(a_object)){return a_object.length}else if(a_object instanceof Map||a_object instanceof Set){return a_object.size}else{let count=0;for(let k in a_object)++count;return count}}else if(typeof a_object=="string"){return a_object.length}else{return 0}}else{let res=0;fcf.each(a_object,((a_key,a_val)=>{if(a_cb(a_key,a_val)){++res}}));return res}};fcf.each=(a_obj,a_cb)=>{let asyncResult;let result=undefined;if(fcf.isNumbered(a_obj)&&(a_obj&&typeof a_obj=="object"&&typeof a_obj.forEach!="function")){for(let i=0;i<a_obj.length;++i){result=a_cb(i,a_obj[i]);if(result instanceof Promise||result instanceof fcf.Actions){let index=i+1;let currentResult=result;result=asyncResult?asyncResult:fcf.actions();let actions=fcf.actions();let act=undefined;result.then(((a_res,a_act)=>{act=a_act}));function doAction(){actions.then((()=>{if(index<a_obj.length)return a_cb(index,a_obj[index])})).then((a_res=>{++index;if(a_res===undefined&&index<a_obj.length){doAction()}else{act.complete(a_res)}})).catch((e=>{act.error(e)}))}currentResult.then((a_res=>{if(a_res===undefined){doAction()}else{act.complete(a_res)}})).catch((e=>{act.error(e)}));break}else if(result!==undefined){break}}}else if(typeof a_obj==="object"&&a_obj!==null){let asyncEnable=false;let asyncKeys=[];let index=0;if(typeof a_obj.forEach==="function"){let breakLoop=false;a_obj.forEach(((a_value,a_key)=>{if(breakLoop){return}if(asyncEnable){asyncKeys.push([a_key,a_value])}else{result=a_cb(a_key,a_value);if(result instanceof Promise||result instanceof fcf.Actions){asyncEnable=true}else if(result!==undefined){breakLoop=true;return true}}}))}else{for(let k in a_obj){if(asyncEnable){asyncKeys.push([k,a_obj[k]])}else{result=a_cb(k,a_obj[k]);if(result instanceof Promise||result instanceof fcf.Actions){asyncEnable=true}else if(result!==undefined){break}}}}if(asyncEnable){let currentResult=result;result=asyncResult?asyncResult:fcf.actions();let actions=fcf.actions();let act=undefined;result.then(((a_res,a_act)=>{act=a_act}));function doAction(){actions.then((()=>{if(index<asyncKeys.length)return a_cb(asyncKeys[index][0],asyncKeys[index][1])})).then((a_res=>{++index;if(a_res===undefined&&index<asyncKeys.length){doAction()}else{act.complete(a_res)}})).catch((e=>{act.error(e)}))}currentResult.then((a_res=>{if(a_res===undefined){doAction()}else{act.complete(a_res)}})).catch((e=>{act.error(e)}))}}return(result instanceof fcf.Actions?result:fcf.actions().result(result)).options({quiet:true}).exception()};fcf.append=(...args)=>{let startArg=typeof args[0]==="boolean"?1:0;let req=typeof args[0]==="boolean"&&args[0];if(Array.isArray(args[startArg])){for(let j=startArg+1;j<args.length;++j){if(req){if(Array.isArray(args[j])){for(let i=0;i<args[j].length;++i){let itm=args[j][i]===null?null:args[j][i]instanceof Date?new Date(args[j][i]):Array.isArray(args[j][i])?fcf.append(true,[],args[j][i]):typeof args[j][i]==="object"?fcf.append(true,new args[j][i].__proto__.constructor,args[j][i]):args[j][i];args[startArg].push(itm)}}else{fcf.each(args[j],((a_key,a_value)=>{let itm=a_value===null?null:a_value instanceof Date?new Date(a_value):Array.isArray(a_value)?fcf.append(true,[],a_value):typeof a_value==="object"?fcf.append(true,new a_value.__proto__.constructor,a_value):a_value;args[startArg].push(itm)}))}}else{if(Array.isArray(args[j])){for(let i=0;i<args[j].length;++i){args[startArg].push(args[j][i])}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg].push(a_value)}))}}}}else if(args[startArg]instanceof Set){for(let j=startArg+1;j<args.length;++j){if(typeof args[j]!=="object"||args[j]===null)continue;if(args[j]instanceof Set){for(let key of args[j]){args[startArg].add(key)}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg].add(a_value)}))}}}else if(args[startArg]instanceof Map){for(let j=startArg+1;j<args.length;++j){if(typeof args[j]!=="object"||args[j]===null)continue;if(req){if(args[j]instanceof Map){for(let pair of args[j]){args[startArg].set(pair[0],cloneValue(pair[1]))}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg].set(a_key,cloneValue(a_value))}))}}else{if(args[j]instanceof Map){for(let pair of args[j]){args[startArg].set(pair[0],pair[1])}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg].set(a_key,a_value)}))}}}}else if(typeof args[startArg]==="object"&&args[startArg]!==null){for(let j=startArg+1;j<args.length;++j){if(typeof args[j]!=="object"||args[j]===null)continue;if(req){if(!Array.isArray(args[j])&&!(args[j]instanceof Map)&&!(args[j]instanceof Set)){for(let key of Object.getOwnPropertyNames(args[j])){args[startArg][key]=cloneValue(args[j][key])}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg][a_key]=cloneValue(a_value)}))}}else{if(!Array.isArray(args[j])&&!(args[j]instanceof Map)&&!(args[j]instanceof Set)){for(let key of Object.getOwnPropertyNames(args[j])){args[startArg][key]=args[j][key]}}else{fcf.each(args[j],((a_key,a_value)=>{args[startArg][a_key]=a_value}))}}}}return args[startArg]};const cloneValue=a_source=>{if(a_source===null){return null}else if(a_source instanceof Date){return new Date(a_source)}else if(Array.isArray(a_source)){return fcf.append(true,[],a_source)}else if(typeof a_source==="object"){let base;try{base=new a_source.__proto__.constructor}catch(e){base={}}return fcf.append(true,base,a_source)}else{return a_source}};fcf.clone=a_object=>{if(a_object===null){return null}else if(Array.isArray(a_object)){return fcf.append(true,[],a_object)}else if(a_object instanceof Date){return new Date(a_object)}else if(typeof a_object=="object"){let base;try{base=new a_object.__proto__.constructor}catch(e){base={}}return fcf.append(true,base,a_object)}else{return a_object}};fcf.parseObjectAddress=(a_path,a_exMode)=>{if(Array.isArray(a_path)){let result=[];for(let part of a_path){if(a_exMode){result.push(typeof part=="object"?part:{part:part,array:false})}else{result.push(typeof part=="object"?part.part:part)}}return result}let state=0;let isa=false;let result=[];let buf="";let i=0;while(i<a_path.length){switch(state){case-1:{while(i<a_path.length){if(a_path.charCodeAt(i)<=32){++i;break}if(a_path[i]=="."){state=0;++i;break}else if(a_path[i]=="["){++i;while(i<a_path.length){if(a_path.charCodeAt(i)<=32){++i;continue}if(a_path[i]=="["&&!isa){isa=true;++i;continue}else if(a_path[i]=='"'){++i;state=2;break}else if(a_path[i]=="'"){++i;state=3;break}else{state=1;break}}break}else{state=0;break}}}break;case 0:{let start=true;while(true){if(a_path[i]=="."){let rpos=buf.length-1;while(rpos>=0&&buf.charCodeAt(rpos)<=32){--rpos}if(rpos!=buf.length-1){buf=buf.substring(0,rpos+1)}if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);isa=false;buf="";state=-1;break}else if(a_path[i]=="["){let rpos=buf.length-1;while(rpos>=0&&buf.charCodeAt(rpos)<=32){--rpos}if(rpos!=buf.length-1){buf=buf.substring(0,rpos+1)}if(buf.length||result.length){if(a_exMode)result.push({part:buf,array:isa});else result.push(buf)}isa=false;buf="";state=-1;break}else if(i+1>=a_path.length){buf+=a_path[i];let rpos=buf.length-1;while(rpos>=0&&buf.charCodeAt(rpos)<=32){--rpos}if(rpos!=buf.length-1){buf=buf.substring(0,rpos+1)}if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);isa=false;buf="";++i;break}if(start){if(a_path.charCodeAt(i)>32){buf+=a_path[i];start=false}}else{buf+=a_path[i]}++i}}break;case 1:{while(true){if(a_path[i]=="]"){let rpos=buf.length-1;while(rpos>=0&&buf.charCodeAt(rpos)<=32){--rpos}if(rpos!=buf.length-1){buf=buf.substring(0,rpos+1)}if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);buf="";state=-1;if(isa){++i;while(true){if(i>=a_path.length){break}if(a_path[i]=="]"){++i;break}++i}}else{++i}isa=false;break}else if(i+1>=a_path.length){buf+=a_path[i];let rpos=buf.length-1;while(rpos>=0&&buf.charCodeAt(rpos)<=32){--rpos}if(rpos!=buf.length-1){buf=buf.substring(0,rpos+1)}if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);isa=false;buf="";++i;break}buf+=a_path[i];++i}}break;case 2:case 3:{let sc=0;let stopChar=state==2?'"':"'";while(true){if(a_path[i]==stopChar&&!(sc%2)){if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);buf="";state=-1;while(i<a_path.length){if(a_path[i]=="]"){++i;break}++i}if(isa){while(i<a_path.length){if(a_path[i]=="]"){++i;break}++i}}isa=false;break}if(i+1>=a_path.length){buf+=a_path[i];if(a_exMode)result.push({part:buf,array:isa});else result.push(buf);isa=false;buf="";state=-1;++i;break}if(a_path[i]=="\\"){if(sc%2){buf+=a_path[i]}++sc}else{buf+=a_path[i];sc=0}++i}}break}}if(!result.length){if(a_exMode){result.push({part:"",array:false})}else{result.push("")}}return result};fcf.normalizeObjectAddress=a_path=>{var arr=fcf.parseObjectAddress(a_path,true);var result="";for(var i=0;i<arr.length;++i){let key;let isa;if(typeof arr[i]=="object"){key=arr[i].part;isa=arr[i].array}else{key=arr[i];isa=false}key=fcf.escapeQuotes(key,'"');if(!isa){result+='["'+key+'"]'}else{result+='[["'+key+'"]]'}}return result};fcf.resolve=(a_obj,a_path,a_quiet)=>{let path=fcf.parseObjectAddress(a_path);for(let i=0;i<path.length;++i){if(typeof a_obj!="object"&&typeof a_obj!="function"||a_obj[path[i]]===undefined){if(a_quiet!==undefined&&!a_quiet&&i!=path.length-1){throw new fcf.Exception("ACCESS_FAILED_FIELD_TOKENIZE",{command:a_path})}return}a_obj=a_obj[path[i]]}return a_obj};fcf.resolveEx=(a_obj,a_path,a_createObj)=>{let result={key:undefined,object:undefined};if(typeof a_obj!=="object"&&typeof a_obj!=="function"){return result}let pathArr=fcf.parseObjectAddress(a_path,true);let cur=a_obj;for(var i=0;i<pathArr.length-1;++i){let key=pathArr[i].part;if(typeof cur[key]!=="object"&&typeof cur[key]!=="function"){if(a_createObj){if(pathArr[i].array){cur[key]=[]}else{cur[key]={}}}else{return result}}cur=cur[key]}result.key=pathArr[pathArr.length-1].part;result.object=cur;return result};fcf.prepare=(a_root,a_objectPath)=>{a_objectPath=typeof a_objectPath=="string"?fcf.parseObjectAddress(a_objectPath,true):Array.isArray(a_objectPath)?a_objectPath:false;if(!a_objectPath)return a_root;for(let part of a_objectPath){if(typeof part=="object"){if(part.array){if(!Array.isArray(a_root[part.part])){a_root[part.part]=[]}}else{if(typeof a_root[part.part]!=="object"&&typeof a_root[part.part]!=="function"){a_root[part.part]={}}}a_root=a_root[part.part]}else{if(typeof a_root[part]!=="object"&&typeof a_root[part]!=="function"){a_root[part]={}}a_root=a_root[part]}}return a_root};fcf.getDirectory=a_path=>{let i=a_path.length-1;for(;i>=0;--i){let c=a_path[i];if(c=="\\"||c=="/"){break}}return i==-1?"":a_path.substring(0,i)};fcf.getExtension=a_path=>{if(typeof a_path!=="string")return"";a_path=a_path.split("?")[0].split("#")[0];var arr=a_path.split(".");return arr.length>1?arr[arr.length-1]:""};fcf.getShortFileName=a_path=>{if(!a_path)return"";var offset=-1;for(var p=0;p<a_path.length;++p){var c=a_path.charAt(p);if(c==":"||c=="/"||c=="\\")offset=p}let arr=a_path.substr(offset==-1?0:offset+1).split(".");if(arr.length>1)arr.pop();return arr.join(".")};fcf.getFileName=a_path=>{a_path=fcf.rtrim(a_path,"/");if(!a_path)return"";var offset=0;for(var p=0;p<a_path.length;++p){var c=a_path.charAt(p);if(c==":"||c=="/"||c=="\\")offset=p}if(offset)offset+=1;return a_path.substr(offset)};fcf.resolvePath=function(a_uri,a_aliases){if(a_uri[0]!="@")return a_uri;let pos;pos=Math.min((pos=a_uri.indexOf("+"))!=-1?pos:Infinity,(pos=a_uri.indexOf("?"))!=-1?pos:Infinity,(pos=a_uri.indexOf("#"))!=-1?pos:Infinity,(pos=a_uri.indexOf("/"))!=-1?pos:Infinity,(pos=a_uri.indexOf("\\"))!=-1?pos:Infinity,(pos=a_uri.indexOf(".wrapper.js"))!=-1?pos:Infinity,(pos=a_uri.indexOf(".wrapper.min.js"))!=-1?pos:Infinity);let prefix=pos!=Infinity?a_uri.substring(1,pos):a_uri.substring(1);let suffix=pos!=Infinity?a_uri.substring(pos):"";if(typeof a_aliases=="object"&&prefix in a_aliases){a_uri=a_aliases[prefix]+suffix}else if(prefix in fcf.getConfiguration().aliases){a_uri=fcf.getConfiguration().aliases[prefix]+suffix}else{throw new fcf.Exception("RESOLVE_PATH_ERROR",{path:a_uri})}return a_uri};fcf.normalizePath=(a_path,a_isServerPath)=>{let prefixPosEnd=0;let pos;a_isServerPath=a_isServerPath!==undefined?a_isServerPath:_isServer;if(a_path[0]=="/"){prefixPosEnd=1}else if((pos=a_path.indexOf(":"))!=-1){if((a_isServerPath||a_isServerPath==="*")&&a_path[pos+1]=="\\"&&pos==1){prefixPosEnd=pos+2}else if((!a_isServerPath||a_isServerPath==="*")&&(a_path.indexOf("http://")==0||a_path.indexOf("https://")==0)){a_isServerPath=false;prefixPosEnd=a_path.indexOf("/",a_path.indexOf("://")+3);if(prefixPosEnd==-1){prefixPosEnd=a_path.length}else{prefixPosEnd+=1}}else{let subitem=a_path.substring(0,pos);if(subitem.indexOf("/")==-1&&subitem.indexOf("\\")==-1){prefixPosEnd=pos+1}}}let prefix=a_path.substring(0,prefixPosEnd);let body=a_path.substring(prefixPosEnd);let suffix="";if(!a_isServerPath){if((pos=body.indexOf("?"))!=-1||(pos=body.indexOf("#"))!=-1){suffix=body.substring(pos);body=body.substring(0,pos)}}body=fcf.replaceAll(body,"\\","/");let bodyArr=body.split("/");let resultBodyArr=[];for(let itm of bodyArr){if(itm=="."||itm==""){continue}else if(itm==".."){resultBodyArr.pop()}else{resultBodyArr.push(itm)}}return prefix+resultBodyArr.join("/")+suffix};fcf.normalizeSubpath=a_path=>{let body=fcf.replaceAll(a_path,"\\","/");let bodyArr=body.split("/");let resultBodyArr=[];for(let itm of bodyArr){if(itm=="."||itm==""){continue}else if(itm==".."){resultBodyArr.pop()}else{resultBodyArr.push(itm)}}return resultBodyArr.join("/")};fcf.getPathInfo=(a_path,a_isServerPath,a_quiet)=>{a_isServerPath=a_isServerPath===undefined?fcf.isServer():a_isServerPath;let path=fcf.resolvePath(a_path);path=fcf.normalizePath(path,a_isServerPath);if(path.indexOf("/")==-1&&path.indexOf("\\")==-1&&path.indexOf(":")==-1){return{module:"",subpath:path}}let cwd=fcf.isServer()?fcf.normalizePath(process.cwd()):undefined;if((!a_isServerPath||a_isServerPath==="*")&&(path.indexOf("http://")!=-1||path.indexOf("https://")!=-1)){if(!_isServer){let pos=window.location.href.indexOf("://");if(pos!=-1&&(pos=window.location.href.indexOf("/",pos+3))!=-1&&path.indexOf(window.location.href.substring(0,pos))!=-1){path=path.substring(pos)}else{return{}}}else{return{}}}let pos=path.indexOf(":");if(pos==1)pos=-1;let mod=pos!=-1?path.substring(0,pos):"";if(mod.indexOf("/")!=-1||mod.indexOf("\\")!=-1){mod=undefined;pos=-1}let subpath="";if(pos!=-1){subpath=path.substring(pos+1);return{module:mod,subpath:subpath}}let rootPath=fcf.getPath(path);if(!a_isServerPath||a_isServerPath==="*"){let sources=fcf.getConfiguration().sources;for(let modName in sources){if(!sources[modName].webPackagePath)continue;if((pos=rootPath.indexOf(sources[modName].webPackagePath))==0){return{module:modName,subpath:rootPath.substring(sources[modName].webPackagePath.length+1)}}}}let modDirs;if(_isServer){let splitter=process.platform=="win32"?";":":";modDirs=[];for(let mod of require.main.paths){fcf.append(modDirs,mod.split(splitter).filter((v=>v!=""&&v!=".")))}fcf.append(modDirs,process.env.NODE_PATH.split(splitter).filter((v=>v!=""&&v!=".")))}else{modDirs=[fcf.getConfiguration().webModuleDirectory]}let result=undefined;for(let modDir of modDirs){modDir=fcf.normalizePath(modDir);if(_isServer&&a_isServerPath&&cwd==modDir){continue}if(_isServer&&a_isServerPath){let cwdu=fcf.rtrim(cwd,"/")+"/";let cpath=subpath?cwdu+subpath:fcf.getPath(path);if(cpath.indexOf(cwdu)==0&&cwdu.indexOf(modDir)==0&&modDir!=cwdu){continue}}let modDirEU=modDir+"/";let modDirE=pos=rootPath.indexOf(modDirEU)==0?modDirEU:undefined;if(modDirE!==undefined){mod=rootPath.substring(modDir.length+1).split("/")[0];if(_isServer&&a_isServerPath&&cwd==modDir+"/"+mod){mod=undefined;pos=-1}else if(!mod){mod=undefined;pos=-1}else{return{module:mod,subpath:rootPath.substring(modDir.length+1+mod.length+1)}}}}if(_isServer&&(a_isServerPath||a_isServerPath==="*")&&path.indexOf(cwd)==0){return{module:"",subpath:path.substr(process.cwd().length+1)}}if(!a_isServerPath||a_isServerPath==="*"||path[0]!="/"&&path.indexOf(":\\")!=1){return{module:"",subpath:fcf.ltrim(path,"/")}}if(!a_quiet){throw new fcf.Exception("GET_PATH_INFO_ERROR",{path:a_path})}return{}};fcf.getPath=(a_uri,a_aliases,a_innerServerPath)=>{if(typeof a_aliases!=="object"){a_innerServerPath=a_aliases;a_aliases=undefined}a_innerServerPath=a_innerServerPath!==undefined?a_innerServerPath:_isServer;a_uri=fcf.str(a_uri);a_uri=fcf.resolvePath(a_uri,a_aliases);a_uri=fcf.normalizePath(a_uri,a_innerServerPath);if(a_innerServerPath){let winDSPos=a_uri.indexOf(":\\");if(a_uri[0]=="/"||winDSPos!=-1&&winDSPos<2)return fcf.normalizePath(a_uri)}else{if(a_uri.indexOf("://")!=-1)return a_uri}let modulePos=a_uri.indexOf(":");let moduleName=modulePos!=-1?a_uri.substring(0,modulePos):"";let relativePath=modulePos!=-1?a_uri.substring(modulePos+1):a_uri;if(moduleName.indexOf("/")!=-1||moduleName.indexOf("\\")!=-1){modulePos=-1;relativePath=a_uri;moduleName=""}const configuration=fcf.getConfiguration();if(moduleName!=""){if(a_innerServerPath){let modulePath=libResolver.resolveModule(moduleName);a_uri=fcf.normalizePath(libPath.join(modulePath,relativePath))}else{let prefix="";let srcInfo=configuration.sources[moduleName];if(typeof srcInfo=="string"){srcInfo={webPackagePath:srcInfo}}if(srcInfo&&srcInfo.webPackagePath){prefix+=srcInfo.webPackagePath}else{prefix+=configuration.webModuleDirectory+"/"+moduleName}if(prefix&&relativePath&&relativePath[0]!="/"&&relativePath[0]!="\\"){prefix+="/"}a_uri=prefix+relativePath}}else{if(a_innerServerPath){a_uri=fcf.normalizePath(libPath.join(process.cwd(),relativePath))}else{a_uri="/"+fcf.ltrim(relativePath,["/","\\",":"])}}return a_uri};fcf.styleToString=(a_name,a_value)=>{let result="";if(typeof a_name=="object"&&a_name!==null){let first=true;for(let key in a_name){if(first){first=false}else{result+="; "}result+=fcf.styleToString(key,a_name[key])}}else{if(a_value===undefined||a_value===null||a_value==="")return result;if(["left","top","bottom","right","width","min-width","max-width","height","min-height","max-height"].indexOf(a_name)!=-1){if(!isNaN(a_value)){a_value=a_value+"px"}}result=a_name+": "+a_value}return result};fcf.load=(a_url,a_options)=>{if(typeof a_url==="object"){a_options=a_url;a_url=a_options.url||a_options.path}a_url=fcf.resolvePath(a_url);a_options=typeof a_options=="object"?a_options:{};if(a_options.external===true||!_isServer||a_options.external==="auto"&&a_url.indexOf("http://")==0&&a_url.indexOf("https://")==0){a_url=new fcf.RouteInfo(a_url).url}let isServerMode=_isServer&&a_options.external==="auto"?a_url.indexOf("http://")==-1&&a_url.indexOf("https://")==-1:_isServer&&a_options.external?false:_isServer;a_options=a_options||{};let type=a_options.format;if(!_isServer&&(a_url.indexOf("://")==-1||a_url.indexOf(window.location.href)==0)){let ext=fcf.getExtension(new fcf.RouteInfo(a_url).uri).toLowerCase();if(ext=="js"||ext=="css"){let module=fcf.getPathInfo(a_url,isServerMode).module;if(module&&fcf.getConfiguration().sources[module]&&fcf.getConfiguration().sources[module].version){a_url=fcf.buildUrl(a_url,{version:fcf.getConfiguration().sources[module].version})}}}return fcf.actions().then(((a_res,a_act)=>{if(_isServer){if(!isServerMode){let options=fcf.clone(a_options);options.header=options.header||{};let serverName=new fcf.RouteInfo(a_url).server;let isSendContext=a_url[0]=="@"||a_url[0]=="/"||serverName&&serverName==fcf.getConfiguration().host;if(isSendContext){let ctxt=fcf.append({},fcf.getContext());delete ctxt.route;delete ctxt.args;delete ctxt.safeEnv;options.header["fcf-context"]=fcf.encodeBase64(JSON.stringify(ctxt))}libLoad(a_url,options).then((a_data=>{a_act.complete(a_data)})).catch((a_error=>{a_act.error(a_error)}))}else if(a_options.async===undefined||!!a_options.async){libFS.readFile(fcf.getPath(a_url),"utf8",((a_error,a_data)=>{if(a_error){a_act.error(a_error)}a_act.complete(a_data)}))}else{try{a_act.complete(libFS.readFileSync(fcf.getPath(a_url),"utf8"))}catch(e){a_act.error(e)}}}else{let url=fcf.getPath(a_url);let method=(a_options.method||"GET").toUpperCase();if(method=="GET"){url=fcf.buildUrl(url,a_options.data)}var xmlHttp=new XMLHttpRequest;xmlHttp.onreadystatechange=()=>{if(xmlHttp.readyState==4){if(xmlHttp.status==200){a_act.complete(xmlHttp.responseText)}else{let error=xmlHttp.responseText;try{error=JSON.parse(error)}catch(e){}if(typeof error!=="object"||!error._templateMessage){error=new fcf.Exception("HTTP_REQUEST_ERROR",{code:xmlHttp.status})}else{error=new fcf.Exception(error)}a_act.error(error)}}};xmlHttp.open(method,url,a_options.async!==undefined?a_options.async:true);let serverName=new fcf.RouteInfo(url).server;let isSendContext=url[0]=="@"||url[0]=="/"||serverName&&serverName==window.location.hostname;if(isSendContext){let ctxt=fcf.append({},fcf.getContext());delete ctxt.route;delete ctxt.args;delete ctxt.safeEnv;xmlHttp.setRequestHeader("fcf-context",fcf.encodeBase64(JSON.stringify(ctxt)))}if(typeof a_options.header=="object"){for(let k in a_options.header){xmlHttp.setRequestHeader(k,a_options.header[k])}}if(method!=="GET"){let foundContentType=false;if(typeof a_options.header==="object"){for(let k in a_options.header){if(k.toLowerCase()=="content-type"){foundContentType=true;break}}}if(a_options.body instanceof FormData){if(!foundContentType)xmlHttp.setRequestHeader("Content-Type","multipart/form-data");xmlHttp.send(a_options.body)}else if(typeof a_options.body=="string"){if(!foundContentType)xmlHttp.setRequestHeader("Content-Type","text/plain");xmlHttp.send(a_options.body)}else if(a_options.body!==undefined&&a_options.body!==null){if(!foundContentType)xmlHttp.setRequestHeader("Content-Type","application/json");xmlHttp.send(JSON.stringify(a_options.body))}else{xmlHttp.send(null)}}else{xmlHttp.send(null)}}})).then((a_res=>{if(a_options.format==="auto"){a_res=_autoParse(a_res)}else if(a_options.format==="json"){a_res=JSON.parse(a_res)}return a_res})).catch((a_error=>new fcf.Exception("REQUEST_ERROR",{url:a_url},a_error)))};fcf.getParamCount=a_function=>{if("length"in a_function)return a_function.length;let str=a_function.toString();let pos=str.indexOf("(");let startPos=pos;let end=str.indexOf(")");if(pos==-1||end==-1||pos>=end)return 0;let counter=0;while(true){pos=str.indexOf(",",pos+1);if(pos==-1||pos>=end)break;if(!counter)counter=2;else++counter}if(counter==0){pos=startPos+1;while(pos<end){let c=str.charCodeAt(pos);if(c>32)return 1;++pos}}return counter};fcf.actions=(a_cb,a_options)=>new fcf.Actions(a_cb,a_options);fcf.Actions=class Actions{constructor(a_cb,a_options){if(typeof a_cb=="object"){a_options=a_cb;a_cb=undefined}this._flags=(a_options&&!!a_options.deferred?ACTIONS_FLAGS_DEFERRED:0)|(a_options&&!!a_options.noexcept?ACTIONS_FLAGS_NOEXCEPT:0)|(a_options&&!!a_options.quiet?ACTIONS_FLAGS_QUIET:0);this._stack=[];if(a_options&&a_options.context)fcf.setContext(a_options.context);this._state=fcf.getState();this._errorcbs=[];if(a_options&&a_options.errorResult)this._errorResult=a_options.errorResult;if(typeof a_cb=="function"){this.then(a_cb,undefined,true)}}then(a_cb,a_cberror,_a_skipResult){if(typeof Promise!=="undefined"&&a_cb instanceof Promise){let self=this;a_cb.catch((e=>{self.error(e)}));this.then((()=>a_cb))}else if(a_cb instanceof fcf.Actions){this.then((()=>a_cb))}else{if(a_cb){this._stack.push({cb:a_cb,args:undefined,autoComplete:fcf.getParamCount(a_cb)<(_a_skipResult?1:2),skipResult:_a_skipResult});this._execute()}}if(a_cberror)this.catch(a_cberror);return this}wait(a_timeout){a_timeout=parseFloat(a_timeout);a_timeout=!isNaN(a_timeout)&&a_timeout>0?a_timeout:0;return this.then(((a_res,a_act)=>{setTimeout((()=>{a_act.complete()}),a_timeout)}))}each(a_obj,a_cb){if(typeof a_obj!="function"){if(typeof a_obj=="object"&&a_obj!==null){fcf.each(a_obj,((a_key,a_value)=>{this._stack.push({cb:a_cb,args:[a_key,a_value],autoComplete:fcf.getParamCount(a_cb)<4})}))}this._execute()}else{this.then((a_res=>{a_obj=a_obj();let reverse=[];fcf.each(a_obj,((a_key,a_value)=>{reverse.unshift([a_key,a_value])}));for(let pair of reverse){this._stack.unshift({cb:a_cb,args:pair,autoComplete:fcf.getParamCount(a_cb)<4})}this._execute();return a_res}))}return this}asyncEach(a_obj,a_cb){let self=this;this.then(((a_value,a_act)=>{a_obj=typeof a_obj=="function"?a_obj():a_obj;let autoComplete=fcf.getParamCount(a_cb)<4;let size=fcf.count(a_obj);let counter=0;let error=false;if(size==0){a_act.complete();return}let brk=false;fcf.each(a_obj,((k,a_itemValue)=>{if(brk)return false;let act={_complete:false,isFinished:function(){return this._complete},complete:function(a_value){if(_isServer)fcf.setState(self._state);if(this._complete||error||self._error)return;++counter;self._result=a_value;if(counter==size){this._complete=true;a_act.complete(a_value)}},error:function(a_error){if(_isServer)fcf.setState(self._state);if(self._flags&ACTIONS_FLAGS_NOEXCEPT){this.complete();return}if(this._complete||error||self._error)return;self._result=undefined;this._complete=true;error=true;a_act.error(a_error)}};let args=[k,a_itemValue,self._result];if(!autoComplete)args.push(act);let forceExit=false;let res;try{let asyncPrefix=a_cb.toString().substr(0,5);if(asyncPrefix=="async"&&a_cb.toString().charCodeAt(5)<=32){res=a_cb.apply(self,args).catch((e=>{forceExit=true;brk=true;act.error(e)}))}else{res=a_cb.apply(self,args)}}catch(e){brk=true;act.error(e);return}if(forceExit)return;if(autoComplete&&(typeof Promise!=="undefined"&&res instanceof Promise||res instanceof fcf.Actions)){res.then((a_value=>{act.complete(a_value)})).catch((a_error=>{act.error(a_error)}))}else if(autoComplete){act.complete(res)}}))}));return this}catch(a_options,a_cb){if(typeof a_options=="function"){a_cb=a_options;a_options=undefined}const force=a_options&&typeof a_options=="object"?a_options.force:!!a_options;const shadow=a_options&&typeof a_options=="object"?a_options.shadow:false;if(!shadow){this._flags|=ACTIONS_FLAGS_CATCH}let cerror;if(a_cb){let forseError=!this._error&&this._flags&ACTIONS_FLAGS_NOEXCEPT&&force&&this._ferror?this._ferror:undefined;if(this._error||forseError){let err=this._error||forseError;try{let e=a_cb.call(this,err);if(e instanceof Error){this._error=e}}catch(e){if(!forseError){this._error=e}cerror=e}}else{this._errorcbs.push({force:!!force,shadow:!!shadow,cb:a_cb})}}if(cerror){throw cerror}return this}finally(a_cb){if(a_cb){this._stack.push({cb:a_cb,args:undefined,finally:true,autoComplete:fcf.getParamCount(a_cb)<2});if(this._error){try{a_cb.call(this,undefined,{complete:()=>{},error:()=>{},isFinished:()=>true})}catch(e){this._error=e}}else{this._execute()}}return this}startup(){this._flags&=~ACTIONS_FLAGS_DEFERRED;this._execute();return this}empty(){return!(this._flags&ACTIONS_FLAGS_RUN)&&!this._stack.length}error(a_error){if(!arguments.length){return this._error}else if(typeof a_error==="boolean"){return a_error?this._error||this._ferror:this._error}if(this._flags&ACTIONS_FLAGS_NOEXCEPT){this._ferror=a_error;this._callForceErrors()}else{if(!this._error){this._error=a_error;this._callErrors()}else{this._error=a_error}}return this}result(a_value){if(!arguments.length){return!this._error?this._result:this._errorResult}this._result=a_value;return this}exception(){if(this._error){this.options({quiet:true});throw this._error}return this}options(a_options){if(!arguments.length){return{noexcept:this._flags&ACTIONS_FLAGS_NOEXCEPT?true:false,quiet:this._flags&ACTIONS_FLAGS_QUIET?true:false,deferred:this._flags&ACTIONS_FLAGS_DEFERRED?true:false,errorResult:this._errorResult}}else{if("noexcept"in a_options){if(a_options.noexcept)this._flags|=ACTIONS_FLAGS_NOEXCEPT;else this._flags&=~ACTIONS_FLAGS_NOEXCEPT}if("quiet"in a_options){if(a_options.quiet)this._flags|=ACTIONS_FLAGS_QUIET;else this._flags&=~ACTIONS_FLAGS_QUIET}if("deferred"in a_options){if(a_options.deferred)this._flags|=ACTIONS_FLAGS_DEFERRED;else this._flags&=~ACTIONS_FLAGS_DEFERRED}if("errorResult"in a_options){this._errorResult=a_options.errorResult}return this}}promise(){return new Promise(((a_resolve,a_reject)=>{this.then((a_res=>{a_resolve(a_res)})).catch((a_error=>{a_reject(a_error)}))}))}_callErrors(){let cerror;for(let i=0;i<this._errorcbs.length;++i){try{let e=this._errorcbs[i].cb.call(this,this._error);if(e instanceof Error){this._error=e}}catch(e){this._error=e;cerror=e}}for(let i=0;i<this._stack.length;++i){if(this._stack[i].finally){try{this._stack[i].cb.call(this,undefined,{complete:()=>{},error:()=>{},isFinished:()=>true})}catch(e){this._error=e}}}if(!(this._flags&ACTIONS_FLAGS_CATCH)&&!(this._flags&ACTIONS_FLAGS_QUIET)&&!(this._flags&ACTIONS_FLAGS_NOEXCEPT)){setTimeout((()=>{if(!(this._flags&ACTIONS_FLAGS_CATCH)&&!(this._flags&ACTIONS_FLAGS_QUIET)&&!(this._flags&ACTIONS_FLAGS_NOEXCEPT)){fcf.log.err("FCF",'Unhandled error in fcf.Actions (to handle catch method or "quiet" flag). Error: ',this._error)}}),0)}if(cerror){throw cerror}}_callForceErrors(){for(let i=0;i<this._errorcbs.length;++i){if(!this._errorcbs[i].force){continue}let call=this._errorcbs[i];this._errorcbs.splice(i,1);--i;try{call.cb.call(this,this._ferror)}catch(e){}}}_execute(){let self=this;if(this._flags&ACTIONS_FLAGS_RUN||!this._stack||this._stack.length==0||this._error){if(_isServer&&!(this._flags&ACTIONS_FLAGS_RUN))fcf.setState(self._state);return}if(_isServer)fcf.setState(self._state);if(this._flags&ACTIONS_FLAGS_DEFERRED)return;this._flags|=ACTIONS_FLAGS_RUN;let cbi=this._stack.shift();let act={_end:false,isFinished:function(){return this._end},complete:function(a_value){if(_isServer)fcf.setState(self._state);if(this._end||self._error)return;this._end=true;self._flags&=~ACTIONS_FLAGS_RUN;if(typeof Promise!=="undefined"&&a_value instanceof Promise||a_value instanceof fcf.Actions){a_value.then((a_value=>{self._result=a_value;self._execute()})).catch((a_error=>{this._end=false;this.error(a_error)}))}else{self._result=a_value;self._execute()}},error:function(a_error){if(_isServer)fcf.setState(self._state);self._flags&=~ACTIONS_FLAGS_RUN;self._result=undefined;if(self._flags&ACTIONS_FLAGS_NOEXCEPT){self._ferror=a_error;self._callForceErrors();this.complete();return}if(this._end||self._error)return;this._end=true;self._error=a_error?a_error:new Error("Unknown error");self._callErrors()}};let args=[];if(cbi.args){args.push(cbi.args[0]);args.push(cbi.args[1])}if(!cbi.skipResult){args.push(this._result)}if(!cbi.autoComplete){args.push(act)}let res=undefined;let forceExit=false;try{let asyncPrefix=cbi.cb.toString().substr(0,5);if(asyncPrefix=="async"&&cbi.cb.toString().charCodeAt(5)<=32){res=cbi.cb.apply(this,args).catch((e=>{forceExit=true;act.error(e)}))}else{res=cbi.cb.apply(this,args)}}catch(e){act.error(e);return}if(forceExit)return;if(typeof Promise!=="undefined"&&res instanceof Promise||res instanceof fcf.Actions){if(cbi.autoComplete){res.then((a_value=>{act.complete(a_value)})).catch((a_error=>{act.error(a_error)}))}else{res.catch((a_error=>{act.error(a_error)}))}}else if(cbi.autoComplete){act.complete(res)}}};const ACTIONS_FLAGS_DEFERRED=1;const ACTIONS_FLAGS_NOEXCEPT=2;const ACTIONS_FLAGS_RUN=4;const ACTIONS_FLAGS_QUIET=8;const ACTIONS_FLAGS_CATCH=16;fcf.ActionsQueue=class{constructor(){this._asyncActions={};this._lastAction=undefined;this._completions=[]}getActions(){let actions=fcf.actions();let runAct;actions.then(((a_res,a_act)=>{runAct=a_act}));if(this._completions.length){let completions=this._completions;this._completions=[];for(let c of completions){c()}}if(this._lastAction){let lastActions=this._lastAction;this._lastAction={actions:actions};lastActions.actions.finally((()=>{runAct.complete()}))}else{this._lastAction={actions:actions};runAct.complete()}return actions}getAsyncActions(a_group,a_appendMode){a_group=a_group.toString();if(this._completions.length){let completions=this._completions;this._completions=[];for(let c of completions){c()}}let actions=fcf.actions();let runAct;actions.then(((a_res,a_act)=>{runAct=a_act}));let currentActions;if((!this._lastAction||this._lastAction.counter===0||this._lastAction.group!==a_group)&&(!a_appendMode||!this._asyncActions[a_group])){currentActions={actions:fcf.actions(),completeAct:undefined,complete:undefined,group:a_group,runActs:[runAct],counter:1};currentActions.actions.then(((a_res,a_act)=>{currentActions.completeAct=a_act}));let lastActions=this._lastAction;this._lastAction=currentActions;if(!this._asyncActions[a_group]){this._asyncActions[a_group]=[]}this._asyncActions[a_group].push(currentActions);if(lastActions){lastActions.actions.finally((()=>{currentActions.active=true;for(let ca of currentActions.runActs){ca.complete()}}))}else{currentActions.active=true;for(let ca of currentActions.runActs){ca.complete()}}}else{currentActions=a_appendMode&&this._asyncActions[a_group]?this._asyncActions[a_group][0]:this._lastAction;++currentActions.counter;if(currentActions.active){runAct.complete()}else{currentActions.runActs.push(runAct)}}this._completions.push((()=>{actions.finally((a_res=>{--currentActions.counter;if(!currentActions.counter){this._asyncActions[a_group].shift();if(!this._asyncActions[a_group].length){delete this._asyncActions[a_group]}currentActions.completeAct.complete()}if(this._completions.length){let completions=this._completions;this._completions=[];for(let c of completions){c()}}return a_res}))}));return actions}};fcf.module=a_options=>{let moduleName=_getModulePath(a_options.name);let rootCall=false;if(!_modules[moduleName]){_modules[moduleName]={state:"wait",result:undefined,error:undefined,actions:fcf.actions(),act:undefined,dependencies:[],lazy:[],quiet:a_options.quiet?1:0};rootCall=true}else if(_modules[moduleName].state!="wait"){_modules[moduleName].dependencies=Array.isArray(a_options.dependencies)?a_options.dependencies:[];_modules[moduleName].lazy=Array.isArray(a_options.lazy)?a_options.lazy:[];return}_modules[moduleName].dependencies=Array.isArray(a_options.dependencies)?a_options.dependencies:[];_modules[moduleName].lazy=Array.isArray(a_options.lazy)?a_options.lazy:[];let moduleInfo=_modules[moduleName];moduleInfo.state="processing";fcf.each(a_options.dependencies,((a_key,a_value)=>{a_options.dependencies[a_key]=a_value[0]!="/"?fcf.ltrim(a_value,[":","/"]):"a_value"}));fcf.each(a_options.lazy,((a_key,a_value)=>{a_options.lazy[a_key]=a_value[0]!="/"?fcf.ltrim(a_value,[":","/"]):"a_value"}));let actions=rootCall?_modules[moduleName].actions:fcf.actions();return actions.asyncEach(a_options.dependencies,((k,mod)=>_loadModule(mod,_modules[moduleName].quiet))).then((()=>{let dependencies=[];fcf.each(a_options.dependencies,((k,mod)=>{dependencies.push(_modules[_getModulePath(mod)].result)}));moduleInfo.result=a_options.module.apply(undefined,dependencies);if(_isServer){let moduleNameOSFormat=fcf.isServer()&&process.platform=="win32"?fcf.replaceAll(fcf.replaceAll(moduleName,"/","\\"),":/",":\\"):moduleName;require.cache[moduleNameOSFormat].exports=moduleInfo.result}moduleInfo.state="ready";if(moduleInfo.act){moduleInfo.act.complete()}return fcf.actions().asyncEach(a_options.lazy,((k,mod)=>_loadModule(mod,_modules[moduleName].quiet))).then((()=>{moduleInfo.state="loaded";_callOnModuleLoad();return _waitLazyModule(moduleName)})).then((()=>{moduleInfo.state="ok"})).catch((e=>{_modules[moduleName].quiet=1}))})).then((()=>moduleInfo.result)).catch((a_error=>{moduleInfo.state="error";moduleInfo.error=a_error;if(moduleInfo.act)moduleInfo.act.error(a_error);_callOnModuleLoad();if(_isServer)throw a_error}))};fcf.require=function(a_modules){let quietError=false;let async=true;let modules=[];for(let arg of arguments){if(typeof arg=="object"&&arg!==null&&!Array.isArray(arg)){quietError="quiet"in arg?arg.quiet:false;async=arg.async===false?false:true}else if(typeof arg==="string"){modules.push(arg)}else if(Array.isArray(arg)){modules=modules.concat(arg)}}return fcf.actions({errorResult:[]}).asyncEach(modules,((k,mod)=>_loadModule(mod,quietError,!async))).asyncEach(modules,((k,mod)=>_waitLazyModule(_getModulePath(mod)))).then((()=>{let result=[];fcf.each(modules,((k,mod)=>{result.push(_modules[_getModulePath(mod)].result)}));return result}))};function _loadModule(a_module,a_quietError,a_sync){let path=_getModulePath(a_module);let state=_modules[path]?_modules[path].state:undefined;if(_modules[path]){_modules[path].quiet&=!!a_quietError}if(path=="/home/phoenix/Development/projects/fcf2-sync/fcf-framework-core/tests/base-tests/classes/ConfigurationMergeFunctions.js"){console.log(path,state)}if(state=="ready"||state=="loaded"||state=="ok"){return fcf.actions().then((()=>{_modules[path].quiet=1;return _modules[path].result}))}else if(state=="error"){return fcf.actions().then(((a_res,a_act)=>{if(!_modules[path].quiet){fcf.log.err("FCF",`Failed load module ${a_module}.\n`,_modules[path].error)}_modules[path].quiet=1;a_act.error(_modules[path].error)}))}else if((!a_sync||_isServer)&&(state=="wait"||state=="processing")){return fcf.actions().then(((a_res,a_act)=>{_modules[path].actions.then((()=>{a_act.complete(_modules[path].result)})).catch((a_error=>{if(!_modules[path].quiet){fcf.log.err("FCF",`Failed load module ${a_module}.\n`,a_error)}a_act.error(a_error)}))}))}else{if(!_isServer&&a_sync){++_globalSyncModuleLoad}_modules[path]={state:"wait",result:undefined,error:undefined,actions:fcf.actions(),act:undefined,dependencies:[],lazy:[],quiet:a_quietError?1:0};return fcf.actions().then(((a_res,a_rootAct)=>{_modules[path].actions.then(((a_res,a_act)=>{_modules[path].act=a_act;let{module:moduleName,subpath:filePath}=fcf.getPathInfo(a_module);if(_isServer){let result;try{result=require(path)}catch(e){_modules[path].state="error";_modules[path].error=e;_modules[path].act.error(e);_callOnModuleLoad();return}let moduleInfo=fcf.getConfiguration().sources[moduleName];let resultPath;if(moduleInfo){resultPath=fcf.resolve(moduleInfo,["serverFiles",filePath,"result"])||fcf.resolve(moduleInfo,["files",filePath,"result"]);if(resultPath){_modules[path].result=fcf.resolve(global,resultPath)}}if(!resultPath){_modules[path].result=result}if(_modules[path].state=="wait"){_modules[path].state="ok";_modules[path].act.complete();_callOnModuleLoad()}}else{let moduleInfo=fcf.getConfiguration().sources[moduleName];let loadStateTemplate=fcf.resolve(moduleInfo,["webFiles",filePath,"loadState"])||fcf.resolve(moduleInfo,["files",filePath,"loadState"]);let resultTemplate=fcf.resolve(moduleInfo,["webFiles",filePath,"result"])||fcf.resolve(moduleInfo,["files",filePath,"result"]);let needLoad=!loadStateTemplate;if(!needLoad){try{needLoad=!fcf.tokenize(loadStateTemplate,{},{result:"auto"})}catch(e){needLoad=true;fcf.log.err("FCF",`Failed tokenize load state for the module ${a_module}.\n`,e)}}(needLoad?fcf.load(path,{async:_globalSyncModuleLoad==0}):fcf.actions()).then((a_res=>{if(needLoad){const state=_modules[path].state;if(state=="ready"||state=="loaded"||state=="ok"||state=="error"){return}let script=document.createElement("script");script.textContent=a_res+`\n//# sourceURL=${path}`;document.head.appendChild(script)}if(moduleInfo&&resultTemplate){_modules[path].result=fcf.resolve(window,resultTemplate)}if(_modules[path].state=="wait"){_modules[path].state="ok";_modules[path].act.complete();_callOnModuleLoad()}})).catch((e=>{let error=new Error("Failed to receive module file '"+path+"'");_modules[path].state="error";_modules[path].error=error;_modules[path].act.error(error);_callOnModuleLoad()}))}})).then((()=>{a_rootAct.complete(_modules[path].result)})).finally((()=>{if(!_isServer&&a_sync){if(_globalSyncModuleLoad)--_globalSyncModuleLoad}})).catch((a_error=>{if(!_modules[path].quiet){fcf.log.err("FCF",`Failed load module ${a_module}.\n`,a_error)}_modules[path].quiet=1;a_rootAct.error(a_error)}))}))}}let _globalSyncModuleLoad=0;function _getModulePath(a_module){a_module=fcf.resolvePath(a_module);const isOnlyModule=a_module.indexOf("/")==-1&&a_module.indexOf("\\")==-1&&a_module.indexOf(":")==-1&&a_module.indexOf(".")==-1;if(isOnlyModule&&!_isServer&&a_module[a_module.length-1]!=":"){a_module+=":"}let{module:moduleName,subpath:relativePath}=fcf.getPathInfo(a_module);if(moduleName===undefined){return fcf.getPath(a_module)}let configuration=fcf.getConfiguration();if(!_isServer&&!relativePath){relativePath=configuration.sources[moduleName]&&configuration.sources[moduleName].webMain?configuration.sources[moduleName].webMain:"index.js"}let configPropFilesName=fcf.isServer()?"serverFiles":"webFiles";let configPropFilePathName=fcf.isServer()?"serverFilePath":"webFilePath";let relativeTemplate=fcf.resolve(configuration,["sources",moduleName,configPropFilesName,relativePath,"filePath"])||fcf.resolve(configuration,["sources",moduleName,"files",relativePath,"filePath"])||fcf.resolve(configuration,["sources",moduleName,configPropFilePathName,"js"])||fcf.resolve(configuration,["sources",moduleName,"filePath","js"])||fcf.resolve(configuration,["sources",moduleName,configPropFilePathName,"*"])||fcf.resolve(configuration,["sources",moduleName,"filePath","*"]);if(relativeTemplate){relativePath=fcf.tokenize(relativeTemplate,{path:relativePath,directory:fcf.getDirectory(relativePath),shortName:fcf.getShortFileName(relativePath),name:fcf.getFileName(relativePath),extension:fcf.getExtension(relativePath)},{quiet:true});return fcf.getPath(moduleName+":"+relativePath)}return _isServer&&isOnlyModule?a_module:fcf.getPath(moduleName+":"+relativePath)}function _waitLazyModule(a_modulePath,_a_act){let actions;if(_modules[a_modulePath].state=="ok"){if(_a_act)_a_act.complete();return fcf.actions()}let deps=_getDepsModule(a_modulePath);if(!_a_act){actions=fcf.actions();actions.then(((a_res,a_act)=>{_a_act=a_act}))}let error;let full=true;for(let dep in deps){if(!_modules[dep]){full=false;continue}if(_modules[dep].state=="error"){error=_modules[dep].error}else if(_modules[dep].state!="loaded"&&_modules[dep].state!="ok"){full=false}}if(error){_a_act.error(error)}else if(full){_a_act.complete()}else{_attachOnModuleLoad((()=>{_waitLazyModule(a_modulePath,_a_act)}))}return actions}function _attachOnModuleLoad(a_cb){_moduleCallbacks.push(a_cb)}function _callOnModuleLoad(){let arr=_moduleCallbacks;_moduleCallbacks=[];for(let i=0;i<arr.length;++i){arr[i]()}}function _getDepsModule(a_modulePath,_a_selfPath,_a_dst){if(!_a_selfPath)_a_selfPath=a_modulePath;if(!_a_dst)_a_dst={};if(_modules[a_modulePath]){for(let i=0;i<_modules[a_modulePath].dependencies.length;++i){let dep=_getModulePath(_modules[a_modulePath].dependencies[i]);if(dep in _a_dst||_a_selfPath==dep)continue;_a_dst[dep]=1;_getDepsModule(dep,_a_selfPath,_a_dst)}for(let i=0;i<_modules[a_modulePath].lazy.length;++i){let dep=_getModulePath(_modules[a_modulePath].lazy[i]);if(dep in _a_dst||_a_selfPath==dep)continue;_a_dst[dep]=1;_getDepsModule(dep,_a_selfPath,_a_dst)}}return _a_dst}let _modules={};let _moduleCallbacks=[];fcf.stackToString=a_stack=>{a_stack=fcf.parseStack(a_stack);let result="";for(let i=0;i<a_stack.length;++i){if(i){result+="\n"}result+=fcf.str(a_stack[i].function)+" ("+a_stack[i].file+":"+fcf.str(a_stack[i].line)+":"+fcf.str(a_stack[i].column)+")"}return result};fcf.errorToString=(a_error,a_fullMode)=>{if(a_error instanceof fcf.Exception){return a_error.toString(a_fullMode,a_fullMode)}else{return a_fullMode?a_error.toString()+"\nStack"+fcf.replaceAll("\n"+fcf.stackToString(a_error),"\n","\n "):a_error.toString()}};fcf.parseStack=function(a_stack){if(a_stack instanceof Error){a_stack=a_stack.stack}else if(a_stack instanceof fcf.Exception){return a_stack.stackArr}else if(Array.isArray(a_stack)){return a_stack}if(typeof a_stack!="string"){return[]}return _parseStack(a_stack.split("\n")).stack};fcf.parseError=function(a_error){if(a_error instanceof fcf.Exception){return{message:a_error.toString(),fullMessage:a_error.toString(false,true),stack:fcf.stackToString(a_error.stackArr),stackArr:a_error.stackArr}}else if(!(a_error instanceof Error)){return{message:"",fullMessage:"",stack:"",stackArr:[]}}let arr=a_error.stack.split("\n");let stackInfo=_parseStack(arr);let fullMessage="";for(let j=0;j<=stackInfo.preStart;++j){fullMessage+=arr[j];fullMessage+="\n"}if(!fullMessage){fullMessage=a_error.message}return{message:a_error.message,fullMessage:fullMessage,stackArr:stackInfo.stack,stack:fcf.stackToString(stackInfo.stack)}};function _parseStack(a_lines){let result={stack:[],preStart:-1};let type=undefined;let at=" at ";let i=a_lines.length-1;for(;i>=0;--i){if(i==a_lines.length-1&&a_lines[i]=="")continue;let item={};if(!type){type=a_lines[i].indexOf(at)!==-1?"chrome":"firefox"}if(type=="chrome"){let endPosFunc=a_lines[i].indexOf("(");let atPos=a_lines[i].indexOf(at);let posInfoArr;if(endPosFunc==-1){posInfoArr=a_lines[i].substr(atPos+at.length,a_lines[i].length-atPos-at.length).split(":")}else{posInfoArr=a_lines[i].substr(endPosFunc+1,a_lines[i].length-endPosFunc-2).split(":")}if(posInfoArr.length<3||atPos==-1)break;item.function=endPosFunc!=-1?a_lines[i].substring(atPos+at.length,endPosFunc-1):undefined;item.line=posInfoArr[posInfoArr.length-2];item.column=posInfoArr[posInfoArr.length-1];posInfoArr.pop();posInfoArr.pop();item.file=posInfoArr.join(":")}else{let atPos=a_lines[i].indexOf("@");posInfoArr=a_lines[i].substr(atPos+1,a_lines[i].length-atPos-1).split(":");if(posInfoArr.length<3||atPos==-1)break;if(a_lines[i][atPos-1]=="<")atPos-=1;if(a_lines[i][atPos-1]=="/")atPos-=1;let functionArr=a_lines[i].substr(0,atPos).split("/");functionArr=functionArr[functionArr.length-1].split("*");item.function=functionArr[functionArr.length-1];item.line=posInfoArr[posInfoArr.length-2];item.column=posInfoArr[posInfoArr.length-1];posInfoArr.pop();posInfoArr.pop();item.file=posInfoArr.join(":")}result.stack.unshift(item)}result.preStart=i;return result}fcf.parseDate=(a_string,a_format,a_strict,a_default,a_minOffset)=>{if(!a_format)a_format="Y*m*d*H*i*s*v";let date=a_default instanceof Date?a_default:typeof a_default=="string"?fcf.parseDate(a_default,a_format,false,new Date(1970,0,1,0,0,0,0)):new Date(1970,0,1,0,0,0,0);if(!date||isNaN(date.getTime()))date=new Date;let setPM=false;let setAM=false;let formatIndex=0;let sourceIndex=0;let sc=0;for(;formatIndex<a_format.length&&sourceIndex<a_string.length;++formatIndex){let c=a_format[formatIndex];if(c=="\\"){++sc}else if(c=="Y"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,4));if(isNaN(val))return new Date("");date.setYear(val);sourceIndex+=4}else if(c=="m"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>12||val<1)return new Date("");date.setMonth(val-1);sourceIndex+=2}else if(c=="d"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>31||val<1)return new Date("");date.setDate(val);sourceIndex+=2}else if(c=="H"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>23||val<0)return new Date("");date.setHours(val);sourceIndex+=2}else if(c=="h"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>12||val<1)return new Date("");if(val==0||val>12)val=12;date.setHours(val);sourceIndex+=2}else if(c=="i"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>59||val<0)return new Date("");date.setMinutes(val);sourceIndex+=2}else if(c=="s"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,2));if(isNaN(val)||val>59||val<0)return new Date("");date.setSeconds(val);sourceIndex+=2}else if((c=="a"||c=="A")&&sc%2==0){let m=a_string.substr(sourceIndex,2).toLowerCase();if(m=="pm")setPM=true;else setAM=true;sourceIndex+=2}else if(c=="v"&&sc%2==0){let val=parseInt(a_string.substr(sourceIndex,3));if(isNaN(val))return new Date("");date.setMilliseconds(val);sourceIndex+=3}else if(c=="*"&&sc%2==0){sourceIndex+=1}else{if(a_string[sourceIndex]!=a_format[formatIndex])break;sourceIndex+=1}if(c!="\\"){sc=0}}if(a_strict&&formatIndex!=a_format.length)return new Date("");if(!formatIndex)return new Date("");if(setAM&&date.getHours()==12)date.setHours(0);if(setPM&&date.getHours()<12)date.setHours(date.getHours()+12);if(a_minOffset===false){date=new Date(date.getTime()-(new Date).getTimezoneOffset()*6e4)}if(typeof a_minOffset=="number"){date=new Date(date.getTime()-a_minOffset*6e4)}return date};fcf.formatDate=(a_date,a_format,a_minOffset)=>{let result="";let slashCounter=0;if(!a_format)a_format="Y-m-d H:i:s.v";a_date=new Date(a_date);if(!(a_date instanceof Date)||isNaN(a_date.getTime()))return"";if(typeof a_minOffset=="number"){a_date=new Date(a_date.getTime()+a_minOffset*6e4)}if(a_minOffset===false){a_date=new Date(a_date.getTime()+(new Date).getTimezoneOffset()*6e4)}for(let i=0;i<a_format.length;++i){if(i!=0&&a_format[i-1]=="\\")++slashCounter;else slashCounter=0;if(slashCounter%2==1){result+=a_format[i];continue}else if(a_format[i]=="\\"){continue}else if(a_format[i]=="Y"){result+=(a_date.getYear()+1900).toString().padStart(4,"0")}else if(a_format[i]=="m"){result+=(a_date.getMonth()+1).toString().padStart(2,"0")}else if(a_format[i]=="d"){result+=a_date.getDate().toString().padStart(2,"0")}else if(a_format[i]=="H"){result+=a_date.getHours().toString().padStart(2,"0")}else if(a_format[i]=="h"){let h=a_date.getHours();result+=(h==0?12:h<=12?h:h-12).toString().padStart(2,"0")}else if(a_format[i]=="i"){result+=a_date.getMinutes().toString().padStart(2,"0")}else if(a_format[i]=="s"){result+=a_date.getSeconds().toString().padStart(2,"0")}else if(a_format[i]=="v"){result+=a_date.getMilliseconds().toString().padStart(3,"0")}else if(a_format[i]=="a"){result+=a_date.getHours()<12?"am":"pm"}else if(a_format[i]=="A"){result+=a_date.getHours()<12?"AM":"PM"}else{result+=a_format[i]}}return result};fcf.buildUrl=(a_url,a_args,a_anchor)=>{var urlInfo=a_url instanceof fcf.RouteInfo?a_url:new fcf.RouteInfo(a_url);a_url=`${urlInfo.protocol?urlInfo.protocol+"://":""}${urlInfo.server?urlInfo.server:""}${urlInfo.port?":"+urlInfo.port:""}${urlInfo.uri}`;a_args=fcf.append({},urlInfo.urlArgs,a_args);var first=true;for(var k in a_args){if(first)a_url+=a_url.indexOf("?")!=-1?"&":"?";else a_url+="&";a_url+=k;if(a_args[k]!==null&&a_args[k]!==undefined){a_url+="=";if(typeof a_args[k]!="object"){a_url+=encodeURIComponent(fcf.str(a_args[k]))}else{a_url+=encodeURIComponent(JSON.stringify(a_args[k]))}}first=false}if(!fcf.empty(a_anchor))a_url+="#"+a_anchor;else if(!fcf.empty(urlInfo.anchor))a_url+="#"+urlInfo.anchor;return a_url};fcf.RouteInfo=function(a_settings,a_relativeMode,a_postArgs){this.url="";this.referer="";this.uri="";this.urlArgs={};this.urlArgsRaw={};this.urlArgsStr="";this.postArgs={};this.postArgsRaw={};this.args={};this.argsRaw={};this.subUri="";this.anchor="";this.server="";this.port=undefined;this.protocol="";if(typeof a_settings=="string"){a_settings={url:a_settings}}if(a_settings instanceof fcf.RouteInfo){fcf.append(true,this,a_settings);this.url=fcf.buildUrl(this.referer,this.urlArgs,this.anchor)}else if(a_settings&&typeof a_settings=="object"&&typeof a_settings.url=="string"){let sourceURL=a_settings.url;let protocolPos=-1;let referer;let queryArgsStr;{let pos=sourceURL.indexOf("://");if(pos==-1){pos=0}else{pos+=3}let prefix=sourceURL.substring(0,pos);let body=sourceURL.substring(pos);let pos1=body.indexOf("?");if(pos1==-1)pos1=Infinity;let pos2=body.indexOf("#");if(pos2==-1)pos2=Infinity;pos1=Math.min(pos1,pos2);let suffix=body.substring(pos1!==Infinity?pos1:body.length);body=body.substring(0,pos1!==Infinity?pos1:body.length);let parts=body.split("/");let resultParts=[];for(let i=0;i<parts.length;++i){if(parts[i]==""){if(!prefix.length&&i==0){resultParts.push(parts[i])}else{continue}}else if(parts[i]=="."){continue}else if(parts[i]==".."){if(resultParts.length==1&&(prefix.length||a_relativeMode==="server")){continue}else{resultParts.pop()}}else{resultParts.push(parts[i])}}sourceURL=prefix+resultParts.join("/")+suffix}{referer=fcf.rtrim(sourceURL.split("?")[0].split("#")[0],["/"]);if(referer[0]==="/"){if(a_relativeMode=="server"){sourceURL="http:/"+sourceURL;let pos=referer.indexOf("/",1);this.uri=pos!=-1?referer.substring(pos):"/";referer="http:/"+referer;protocolPos=4}else{this.uri=referer}}else{protocolPos=referer.indexOf("://");if(protocolPos!=-1){let pos2=referer.indexOf("/",protocolPos+3);this.uri=pos2!=-1?referer.substr(pos2):"/"}else{if(a_relativeMode=="root"){this.uri="/"+referer}else if(a_relativeMode=="server"){sourceURL="http://"+sourceURL;let pos=referer.indexOf("/");this.uri=pos!=-1?referer.substring(pos):"/";referer="http://"+referer;protocolPos=4}else{this.uri=referer}}}}{this.protocol=protocolPos!==-1?referer.substring(0,protocolPos):""}{if(protocolPos!=-1){let serverEnd=referer.indexOf("/",protocolPos+3);if(serverEnd==-1){serverEnd=referer.length}this.server=referer.substring(protocolPos+3,serverEnd)}let arr=this.server.split(":");this.server=arr[0];this.port=parseInt(arr[1])||undefined}{this.referer=fcf.rtrim(protocolPos!=-1?this.protocol+"://"+this.server+(this.port?":"+this.port:"")+this.uri:this.uri,["/"])}{let queryPos=sourceURL.indexOf("?");if(queryPos!=-1){let queryPosEnd=-1;queryPosEnd=sourceURL.indexOf("#");if(queryPosEnd==-1){queryPosEnd=sourceURL.length}queryArgsStr=sourceURL.substring(queryPos+1,queryPosEnd);queryArgsArr=queryArgsStr.split("&");for(let queryArg of queryArgsArr){let queryArgArr=queryArg.split("=");this.urlArgs[decodeURIComponent(queryArgArr[0])]=queryArgArr[1]!==undefined?decodeURIComponent(queryArgArr[1]):undefined}}}{let queryPos=sourceURL.indexOf("?");if(queryPos!=-1){let queryPosEnd=-1;queryPosEnd=sourceURL.indexOf("#");if(queryPosEnd==-1){queryPosEnd=sourceURL.length}this.urlArgsStr=sourceURL.substring(queryPos+1,queryPosEnd);queryArgsArr=this.urlArgsStr.split("&");for(let queryArg of queryArgsArr){let queryArgArr=queryArg.split("=");this.urlArgsRaw[decodeURIComponent(queryArgArr[0])]=queryArgArr[1]!==undefined?decodeURIComponent(queryArgArr[1]):undefined}}}{for(let k in this.urlArgsRaw){this.urlArgs[k]=_autoParse(this.urlArgsRaw[k])}}{let pos=sourceURL.indexOf("#");if(pos!=-1){this.anchor=sourceURL.substr(pos+1)}}{this.url=this.referer+(queryArgsStr?"?"+queryArgsStr:"")+(this.anchor?"#"+this.anchor:"")}{if(a_postArgs&&typeof a_postArgs=="object"){fcf.append(true,this.postArgsRaw,a_postArgs)}}{if(a_settings.postArgsRaw&&typeof a_settings.postArgsRaw=="object"){fcf.append(true,this.postArgsRaw,a_settings.postArgsRaw)}}{for(let k in this.postArgsRaw){this.postArgs[k]=_autoParse(this.postArgsRaw[k])}}{if(typeof a_settings.postArgs=="object"){fcf.append(this.postArgs,fcf.clone(a_settings.postArgs))}}{this.args=fcf.clone(fcf.append({},this.urlArgs,this.postArgs))}{this.argsRaw=fcf.clone(fcf.append({},this.urlArgsRaw,this.postArgsRaw))}{if(a_settings.subUri)this.subUri=a_settings.subUri}}};fcf.inlineExecution=(a_code,a_environment)=>{if(_isServer){return libInlineInterpreter.execute(a_code,a_environment)}else{let funcCode=`((___fcf_environment, ___fcf_arg_environment)=>{ with(___fcf_environment) { with(___fcf_arg_environment) { return (${a_code}); } } })`;let func=_inlineFunctions.get(_inlineFunctions);if(!func){func=eval(funcCode);_inlineFunctions.set(funcCode,func)}return func(fcf.NDetails.inlineExecution.getEnvironment().environment||{},typeof a_environment!=="object"?{}:a_environment)}};const _inlineFunctions=new Map;fcf.tokenize=(a_code,a_environment,a_options)=>{if(typeof a_environment!=="object"||!a_environment){a_environment={}}const t=typeof a_code;if(t=="string"){let quiet=a_options?a_options.quiet:false;let resultMode=a_options?a_options.result:"string";return _tokenize(a_code,a_environment,"{{","}}",quiet,resultMode)}else if(t=="object"){for(let k in a_code){const t=typeof a_code[k];if(t=="object"||t=="string"){a_code[k]=fcf.tokenize(a_code[k],a_environment,a_options)}}}return a_code};fcf.pattern=(a_code,a_environment,a_options)=>{if(typeof a_environment!=="object"||!a_environment){a_environment={}}const t=typeof a_code;if(t=="string"){let quiet=a_options?a_options.quiet:false;let resultMode=a_options?a_options.result:"string";return _tokenize(a_code,a_environment,"{","}",quiet,resultMode)}else if(t=="object"){for(let k in a_code){const t=typeof a_code[k];if(t=="object"||t=="string"){a_code[k]=fcf.pattern(a_code[k],a_environment,a_options)}}}return a_code};const _tokenize=(a_code,a_environment,a_construct1,a_construct2,a_quiet,a_resultMode)=>{let result="";let cmd;let lst=0;let found=false;let pos=0;while(true){pos=a_code.indexOf(a_construct1,pos);if(pos==-1)break;found=true;cmd=a_code[pos-1];if(cmd=="@"||cmd=="!"){let nextLst=pos+a_construct1.length;pos=a_code.indexOf(a_construct2+cmd,nextLst);if(pos==-1){result+=a_code.substring(lst,nextLst-1-a_construct1.length);lst=nextLst;lst-=a_construct1.length+1;break}if(a_construct1.length==1&&a_code[nextLst]==a_construct1&&a_code[pos-1]==a_construct2){pos+=a_construct2.length+1;continue}result+=a_code.substring(lst,nextLst-1-a_construct1.length);lst=nextLst;let r;try{if(cmd=="@"){let codeStr=fcf.trim(a_code.substring(lst,pos));if(codeStr.search(/^[a-zA-Z_. ][a-zA-Z0-9_. ]*$/)!=-1&&codeStr!=="true"&&codeStr!=="false"&&codeStr!=="undefined"&&codeStr!=="NaN"&&codeStr!=="null"){let ptr=fcf.resolveEx(a_environment,codeStr);if(ptr.object===undefined||!(ptr.key in ptr.object)){ptr=fcf.resolveEx(fcf.NDetails.inlineExecution.getEnvironment().environment,codeStr);if(ptr.object===undefined){throw new fcf.Exception("ACCESS_FAILED_FIELD_TOKENIZE",{command:codeStr})}}r=ptr.object[ptr.key]}else{r=fcf.inlineExecution(codeStr,a_environment)}}else{r=fcf.t(a_code.substring(lst,pos));if(r.indexOf(a_construct1)!==-1){r=_tokenize(r,a_environment,a_construct1,a_construct2,a_quiet,a_resultMode)}}}catch(e){if(!a_quiet){throw e}pos+=a_construct1.length+1;result+=a_code.substring(lst-a_construct1.length-1,pos);lst=pos;break}if(result.length==0&&pos+a_construct1.length+1==a_code.length&&a_resultMode=="auto"){return r}else{result+=r}pos+=a_construct1.length+1;lst=pos}else{pos+=a_construct1.length;continue}}if(!found){return a_code}result+=a_code.substring(lst);return result};fcf.t=(a_str,a_lang)=>{if(!_translateInit){fcf.appendTranslate()}a_lang=a_lang||(fcf.getContext()?fcf.getContext().language:fcf.getConfiguration().defaultLanguage);return _translations[a_lang]&&a_str in _translations[a_lang]?_translations[a_lang][a_str]:a_str};fcf.translate=(a_str,a_language)=>{const t=typeof a_str;if(t=="string"){return _translate(a_str,a_language)}else if(t=="object"){for(let k in a_str){const t=typeof a_str[k];if(t=="object"||t=="string"){a_str[k]=fcf.translate(a_str[k],a_language)}}}return a_code};const _translate=(a_str,a_language)=>{let result="";let cmd;let lst=0;let pos=0;let found=false;while(true){pos=a_str.indexOf("{",pos);if(pos==-1)break;found=true;if(a_str[pos-1]=="!"){let double=a_str[pos+1]=="{";result+=a_str.substring(lst,pos-1);lst=pos+(double?2:1);pos=a_str.indexOf(double?"}}!":"}!",lst);if(pos==-1){lst-=double?3:2;break}result+=fcf.t(a_str.substring(lst,pos),a_language);pos+=double?3:2;lst=pos}else{pos+=1;continue}}if(!found)return a_str;result+=a_str.substring(lst);return result};fcf.appendTranslate=(a_dataOrFileName,a_reload)=>{let translations={};let translationsFiles={};fcf.actions().then((()=>{if(a_dataOrFileName){a_dataOrFileName=Array.isArray(a_dataOrFileName)?a_dataOrFileName:[a_dataOrFileName];fcf.getConfiguration().append({translations:a_dataOrFileName})}for(let trans of fcf.getConfiguration().translations){let path;if(typeof trans=="string"){path=fcf.getPath(trans);if(!a_reload&&path in _translationsFiles){trans=_translationsFiles[path]}else{let error;trans=fcf.load(path,{format:"json",async:false}).exception().result()}}trans=Array.isArray(trans)?trans:[trans];for(let transItem of trans){translations[transItem.language]=fcf.append({},translations[transItem.language],transItem.translations)}if(path){translationsFiles[path]=trans}}})).then((()=>{_translations=translations;_translationsFiles=translationsFiles})).finally((()=>{_translateInit=true})).catch((e=>{throw e}))};fcf.getTranslations=()=>_translationsFiles;let _translateInit=false;let _translations={};let _translationsFiles={};fcf.EventChannel=class EventChannel{constructor(){this._callbacks={};this._counters={};this._led={}}on(a_eventName,a_options,a_callback){this._on(a_eventName,a_options,a_callback,false)}once(a_eventName,a_options,a_callback){this._on(a_eventName,a_options,a_callback,true)}onmet(a_eventName,a_options,a_callback){if(a_eventName in this._counters){if(typeof a_options==="function"){a_callback=a_options;a_options=undefined}let eventHeader={name:a_eventName};let data=this._led[a_eventName];return fcf.actions().then((()=>a_callback(data,eventHeader))).then((()=>data))}this._on(a_eventName,a_options,a_callback,true)}detach(a_eventName,a_callback){if(typeof a_eventName==="function"){a_callback=a_eventName;a_eventName=undefined}if(!a_callback||!a_callback.___fcffuncids)return;let es;if(a_eventName){es={};if(this._callbacks[a_eventName]){es[a_eventName]=this._callbacks[a_eventName]}}else{es=this._callbacks}for(let eventName in es){let callbacks=es[eventName];for(let id in a_callback.___fcffuncids){let level=a_callback.___fcffuncids[id].level;if(!(level in callbacks.levels))continue;if(callbacks.levels[level][id]){delete a_callback.___fcffuncids[id]}delete callbacks.levels[level][id];if(fcf.empty(callbacks.levels[level])){delete callbacks.levels[level];let index=callbacks.order.indexOf(level);if(index!=-1){callbacks.order.splice(index,1)}if(!callbacks.order.length){delete this._callbacks[eventName]}}}}}send(a_eventName,a_eventOptions,a_event){if(a_event===undefined){a_event=a_eventOptions;a_eventOptions={}}if(!(a_eventName in this._counters))this._counters[a_eventName]=1;else++this._counters[a_eventName];this._led[a_eventName]=a_event;let eventHeader={name:a_eventName};if(!(a_eventName in this._callbacks)){return fcf.actions().result(a_eventOptions.exresult?{event:a_event,header:eventHeader}:a_event)}let callbacks=this._callbacks[a_eventName];let actions;let deferred=[];let rm=[];let error;for(let levelKey of callbacks.order){let levelValue=callbacks.levels[levelKey];for(let id in levelValue){if(!actions){if(levelValue[id].once){rm.push({level:levelKey,id:id})}try{actions=levelValue[id].cb(a_event,eventHeader)}catch(e){error=e;break}if(!(actions instanceof Promise)&&!(actions instanceof fcf.Actions)){actions=undefined}}else{deferred.push([levelKey,id,levelValue[id].cb,levelValue[id].once])}}if(error){break}}if(actions){return fcf.actions().then((()=>actions)).each(deferred,((a_key,a_callbackInfo,a_res,a_act)=>{if(a_callbackInfo[3]){rm.push({level:a_callbackInfo[0],id:a_callbackInfo[1]})}let res;try{res=a_callbackInfo[2](a_event,eventHeader)}catch(e){a_act.error(e);return}if(!(res instanceof Promise)&&!(res instanceof fcf.Actions)){a_act.complete()}else{res.then((()=>{a_act.complete()})).catch((e=>{a_act.error(e)}))}})).finally((()=>{for(let rmitem of rm){delete callbacks.levels[rmitem.level][rmitem.id];if(fcf.empty(callbacks.levels[rmitem.level])){delete callbacks.levels[rmitem.level];let orderIndex=callbacks.order.indexOf(rmitem.level);if(orderIndex!=-1){callbacks.order.splice(orderIndex,1)}if(!callbacks.order.length){delete this._callbacks[a_eventName]}}}})).then((()=>a_eventOptions.exresult?{event:a_event,header:eventHeader}:a_event))}else{for(let rmitem of rm){delete callbacks.levels[rmitem.level][rmitem.id];if(fcf.empty(callbacks.levels[rmitem.level])){delete callbacks.levels[rmitem.level];let orderIndex=callbacks.order.indexOf(rmitem.level);if(orderIndex!=-1){callbacks.order.splice(orderIndex,1)}if(!callbacks.order.length){delete this._callbacks[a_eventName]}}}return!error?fcf.actions().result(a_eventOptions.exresult?{event:a_event,header:eventHeader}:a_event):fcf.actions().error(error)}}count(a_eventName){return a_eventName in this._counters?!this._counters[a_eventName]?1:this._counters[a_eventName]:0}_on(a_eventName,a_options,a_callback,a_once){if(typeof a_options==="function"){a_callback=a_options;a_options=undefined}let level=a_options&&a_options.level?parseFloat(a_options.level):0;let id=fcf.id();if(!("___fcffuncids"in a_callback)){Object.defineProperty(a_callback,"___fcffuncids",{value:{},writable:false,enumerable:false})}a_callback.___fcffuncids[id]={level:level};if(!(a_eventName in this._callbacks)){this._callbacks[a_eventName]={order:[],levels:{}}}let callbacks=this._callbacks[a_eventName];if(!(level in callbacks.levels)){callbacks.levels[level]={};callbacks.order.push(level);callbacks.order.sort(((l,r)=>l<r?-1:l>r?1:0))}callbacks.levels[level][id]={cb:a_callback,once:a_once}}};fcf.Exception=class Exception extends Error{constructor(a_nameOrMessageOrException,a_args,a_stack,a_subException){super(a_nameOrMessageOrException);let exceptionName;let template;let stackTxt;let stackTxtStartLevel=1;a_subException=undefined;a_stack=undefined;a_args=undefined;for(let i=1;i<arguments.length;++i){if(arguments[i]instanceof Error){a_subException=arguments[i];break}}for(let i=1;i<arguments.length;++i){if(typeof arguments[i]=="string"){a_stack=arguments[i];break}}for(let i=1;i<arguments.length;++i){if(typeof arguments[i]=="object"&&!(arguments[i]instanceof Error)){a_args=arguments[i];break}}if(Array.isArray(a_args)){for(var i=0;i<a_args.length;++i)this[i+1]=a_args[i]}else if(typeof a_args=="object"){for(let key in a_args)this[key]=a_args[key]}if(typeof a_nameOrMessageOrException=="string"){template=_exceptions[a_nameOrMessageOrException];if(!template){exceptionName="ERROR";template=_exceptions[exceptionName];this.error=a_nameOrMessageOrException}else{exceptionName=a_nameOrMessageOrException}}else if(a_nameOrMessageOrException instanceof Error){exceptionName="ERROR";stackTxt=a_nameOrMessageOrException.stack||a_nameOrMessageOrException.stacktrace;stackTxtStartLevel=0;template=_exceptions[exceptionName];this.error=fcf.parseError(a_nameOrMessageOrException).fullMessage}else if(typeof a_nameOrMessageOrException=="object"){template=_exceptions[a_nameOrMessageOrException.name];if(!template){if(a_nameOrMessageOrException._templateMessage){for(let key in a_nameOrMessageOrException)this[key]=a_nameOrMessageOrException[key];exceptionName=a_nameOrMessageOrException.name?a_nameOrMessageOrException.name:"ERROR";template=a_nameOrMessageOrException._templateMessage}if(a_nameOrMessageOrException.message&&(a_nameOrMessageOrException.stack||a_nameOrMessageOrException.stacktrace)){exceptionName="ERROR";stackTxt=a_nameOrMessageOrException.stack||a_nameOrMessageOrException.stacktrace;stackTxtStartLevel=0;template=_exceptions[exceptionName];this.error=a_nameOrMessageOrException.message}else{for(let key in a_nameOrMessageOrException)this[key]=a_nameOrMessageOrException[key];exceptionName=a_nameOrMessageOrException.name?a_nameOrMessageOrException.name:"ERROR";template=_exceptions["ERROR"];this.error=a_nameOrMessageOrException.error?a_nameOrMessageOrException.error:a_nameOrMessageOrException.message?a_nameOrMessageOrException.message:"Unknown error"}}else{for(let key in a_nameOrMessageOrException)this[key]=a_nameOrMessageOrException[key];exceptionName=a_nameOrMessageOrException.name}if(typeof this.exception=="object"&&!(this.exception instanceof Error)){this.exception=new fcf.Exception(this.exception)}}if(a_stack){let originStartLine=_parseStack(this.stack.split("\n")).preStart+1;let newStartLine=_parseStack(a_stack.split("\n")).preStart+1;this.stack=this.stack.split("\n").slice(0,originStartLine).concat(a_stack.split("\n").slice(newStartLine)).join("\n");stackTxt=this.stack;stackTxtStartLevel=0;this.stackArr=undefined}this.name=exceptionName;this._templateMessage=template;if(a_subException){this.exception=a_subException}if(!Array.isArray(this.stackArr)){if(!stackTxt)stackTxt=typeof console==="object"&&console.trace==="function"?console.trace():(new Error).stack;if(stackTxt===undefined){try{throw new Error}catch(e){stackTxt=e.stack}}this.stackArr=fcf.parseStack(stackTxt,stackTxtStartLevel)}this.message=this.toString()}toString(a_enableStack,a_enableSubException,a_language){let message="";message=fcf.t(this._templateMessage,a_language);message=fcf.tokenize(message,this,{quiet:true});if(this.exceptionServer&&(this.exceptionServer.server||this.exceptionServer.alias||this.exceptionServer.uuid)){message+=` [${fcf.str(this.exceptionServer.server)}:${fcf.str(this.exceptionServer.alias)}:${fcf.str(this.exceptionServer.uuid)}]`}if(a_enableStack){message+="\nStack: "+fcf.replaceAll("\n"+fcf.stackToString(this),"\n","\n ")}if(a_enableSubException){let errorObject=this;let offset=" ";while(errorObject.exception){errorObject=errorObject.exception;let submessage="\nSub Error: ";submessage+=errorObject.toString(false,false,a_language);if(a_enableStack){submessage+="\nStack: "+fcf.replaceAll("\n"+fcf.stackToString(errorObject),"\n","\n ")}message+=fcf.replaceAll(submessage,"\n","\n"+offset);offset+=" "}}return message}};fcf.addException=function(a_exceptionName,a_message){_exceptions[a_exceptionName]=a_message};let _exceptions={};fcf.addException("INVALID_COMMAND_TOKENIZE_INTERPETER",'Invalid command during interpreter tokenization in command "@{{command}}@"');fcf.addException("ACCESS_FAILED_FIELD_TOKENIZE",'Accessing a field on an invalid element in a command "@{{command}}@" ');fcf.addException("ERROR","@{{error}}@");fcf.addException("RESOLVE_PATH_ERROR","Failed resolve path '@{{path}}@'");fcf.addException("GET_PATH_INFO_ERROR","It was not possible to determine the package for the path '@{{path}}@'");fcf.addException("GET_PATH_ERROR_INVALID_MODULE_NAME","Failed resolve path '@{{path}}@'. Invalid module name");fcf.addException("REQUEST_ERROR","Request failed @{{url}}@");fcf.addException("HTTP_REQUEST_ERROR","HTTP request failed @{{code}}@");fcf.addException("LOAD_MODULE","Failed to load JS module @{{module}}@");fcf.addException("LOAD_UNITEST_MODULE","Failed to load fcf-framework-unitest module. Install the missing module to perform testing: $ npm install fcf-framework-unitest");fcf.addException("UNKNOWN_TYPE","Unknow type @{{type}}@");fcf.addException("FIELD_NOT_SET","The field (@{{path}}@) is not set");fcf.addException("NOT_MATCH_TYPE","The value@{{ path ? '(' + path + ')' : '' }}@ "+"passed does not match the specified types "+"@{{types.length ? '(' + types.join(';') + ')' : ''}}@");fcf.addException("UNDECLARED_FIELD","Object@{{path ? ' ' + path : ''}}@ uses undeclared field \"@{{field}}@\"");fcf.addException("NUMBER_MIN","The value @{{value}}@ @{{path ? 'in the field ' + path + ' is ' : ''}}@less than minimum @{{min}}@");fcf.addException("NUMBER_MAX","The value @{{value}}@ @{{path ? ' in the field ' + path + ' is ' : ''}}@greater than maximum @{{max}}@");fcf.addException("STRING_LENGTH","The string length @{{currentLength}}@ "+"does not match the specified length @{{length}}@"+"@{{path ? ' in ' + path + ' field': ''}}@");fcf.addException("STRING_MIN_LENGTH","The string length @{{currentLength}}@ "+"less than minimum @{{minLength}}@"+"@{{path ? ' in ' + path + ' field' : ''}}@");fcf.addException("STRING_MAX_LENGTH","The string length @{{currentLength}}@ "+"greater than maximum @{{maxLength}}@"+"@{{path ? ' in ' + path + ' field' : ''}}@");fcf.Context=class Context{constructor(a_request,a_preprocessor){this.language=fcf.getConfiguration?fcf.getConfiguration().defaultLanguage:"en";this.debug=false;this.session={user:{groups:{},roles:{},user:""}};let contextData;let cookie=a_request&&a_request.headers&&typeof a_request.headers["cookie"]==="string"?a_request.headers["cookie"]:!_isServer?decodeURIComponent(document.cookie):undefined;if(cookie){let context=cookie.split(";").map((a_item=>{a_item=fcf.trim(a_item);let p=a_item.indexOf("=");return[a_item.substring(0,p),a_item.substring(p+1)]})).find((a_item=>a_item[0]=="fcf-context"));if(context){contextData=context[1]}}if(!contextData&&a_request&&a_request.headers&&typeof a_request.headers["fcf-context"]){contextData=a_request.headers["fcf-context"]}if(!contextData&&a_request&&typeof a_request.context=="string"){contextData=a_request.context}if(contextData){try{let context=JSON.parse(fcf.decodeBase64(contextData));if(!context.session||typeof context.session!=="object"){context.session={}}context.session.user={groups:{},roles:{},user:""};if(typeof a_preprocessor=="function"){a_preprocessor(context)}fcf.append(this,context)}catch(e){console.log("Failed to read context from request")}}else if(a_request&&a_request.context&&typeof a_request.context=="object"){let context=fcf.clone(a_request.context);if(!context.session||typeof context.session!=="object"){context.session={}}context.session.user={groups:{},roles:{},user:""};if(typeof a_preprocessor=="function"){a_preprocessor(context)}fcf.append(this,context)}if(a_request&&a_request.route&&typeof a_request.route.path==="string"){let postData={};if(typeof a_request.body=="object"){postData=a_request.body}this.route=new fcf.RouteInfo(a_request.originalUrl,"relative",postData)}else{this.route=new fcf.RouteInfo(a_request&&typeof a_request.url=="string"?a_request.url:!_isServer?window.location.href:undefined,"relative",a_request&&a_request.postArgs)}}};fcf.getContext=()=>{if(_isServer){let state=libState.getState();if(!state.context){state.context=new fcf.Context;if(fcf.getConfiguration().warnEmptyContext){fcf.log.wrn("FCF","In system using empty context !!!",fcf.stackToString((new Error).stack))}fcf.setContext(state.context)}return state.context}else{return _state.context}};fcf.setContext=a_context=>{if(_isServer){let state=libState.getState();return libState.setState({context:a_context,state:state.state})}else{_state.context=a_context}};fcf.getState=()=>{if(_isServer){return libState.getState()}else{return _state}};fcf.setState=a_state=>{if(_isServer){return libState.setState({context:a_state&&a_state.context,state:a_state&&a_state.state||{}})}else{_state={context:a_state&&a_state.context,state:a_state&&a_state.state||{}}}};fcf.saveContext=a_request=>{let context=fcf.append({},fcf.getContext());delete context.route;delete context.args;if(_isServer){if(a_request){if(typeof a_request.setCookie==="function"){a_request.setCookie("fcf-context",fcf.encodeBase64(JSON.stringify(context)),{maxAge:fcf.getConfiguration().sessionLifetime,path:"/",sameSite:"Lax"})}else if(typeof a_request.cookie==="function"){a_request.cookie("fcf-context",fcf.encodeBase64(JSON.stringify(context)),{maxAge:fcf.getConfiguration().sessionLifetime,path:"/",sameSite:"Lax"})}}}else{let d=new Date;d.setTime(d.getTime()+365*24*60*60*1e3);var expires="expires="+d.toUTCString();document.cookie="fcf-context="+fcf.encodeBase64(JSON.stringify(context))+"; path=/ ; SameSite=Lax;"+expires}};let _state={context:new fcf.Context,state:{}};class EventEmitter{constructor(){Object.defineProperty(this,"___fcf_field_event_emitter_events___",{value:{},writable:false,enumerable:false})}on(a_name,a_options,a_cb){if(typeof a_options=="function"){a_cb=a_options}if(typeof a_options!="object"){a_options={}}if(!(a_name in this.___fcf_field_event_emitter_events___)){this.___fcf_field_event_emitter_events___[a_name]={}}if(typeof a_cb.___fcf_field_event_emitter_events___!=="object"){Object.defineProperty(a_cb,"___fcf_field_event_emitter_events___",{value:{},writable:false,enumerable:false})}if(!a_cb.___fcf_field_event_emitter_events___[a_name]){a_cb.___fcf_field_event_emitter_events___[a_name]={}}let id=fcf.id();a_cb.___fcf_field_event_emitter_events___[a_name][id]=1;this.___fcf_field_event_emitter_events___[a_name]=fcf.append({},this.___fcf_field_event_emitter_events___[a_name]);this.___fcf_field_event_emitter_events___[a_name][id]={cb:a_cb,ignoreBreak:!!a_options.ignoreBreak};return a_cb}detach(a_name,a_cb){if(typeof a_name=="function"){a_cb=a_name;a_name=undefined}if(!a_cb&&!a_name){return}let eventNames={};if(a_name){eventNames[a_name]=1}else{eventNames=a_cb.___fcf_field_event_emitter_events___}if(!eventNames||!a_cb.___fcf_field_event_emitter_events___){return}for(let eventName in eventNames){if(!this.___fcf_field_event_emitter_events___[eventName]||!a_cb.___fcf_field_event_emitter_events___[eventName]){continue}for(let id in a_cb.___fcf_field_event_emitter_events___[eventName]){delete this.___fcf_field_event_emitter_events___[eventName][id]}}}emit(a_name,a_data){if(!(a_name in this.___fcf_field_event_emitter_events___)){return fcf.actions().result(a_data)}let lastError;return fcf.actions().each(this.___fcf_field_event_emitter_events___[a_name],((a_id,a_info)=>{if(lastError&&!a_info.ignoreBreak){return}return fcf.actions({noexcept:true}).then((()=>a_info.cb(a_data))).catch(true,(a_error=>{lastError=a_error}))})).then(((a_res,a_act)=>{if(!lastError){a_act.complete(a_data)}else{a_act.error(lastError)}}))}}fcf.EventEmitter=EventEmitter;class Logger extends fcf.EventEmitter{constructor(a_configuration){super();a_configuration=a_configuration||{};this._configuration=new fcf.Configuration;this._configuration.append({logLevel:Logger.LOG,logFile:undefined,logLifeTime:10,logHandlers:["fcf.Logger.timeHandler","fcf.Logger.spaceServerHandler","fcf.Logger.pidHandler","fcf.Logger.spaceHandler","fcf.Logger.levelHandler","fcf.Logger.spaceHandler","fcf.Logger.modHandler","fcf.Logger.colonHandler","fcf.Logger.messageHandler","fcf.Logger.consoleHandler","fcf.Logger.fileHandler"]});this._configuration.append(a_configuration)}getConfiguration(){return this._configuration}tst(a_module,a_str){return this._log(Logger.TST,arguments)}crh(a_module,a_str){return this._log(Logger.CRH,arguments)}err(a_module,a_str){return this._log(Logger.ERR,arguments)}wrn(a_module,a_str){return this._log(Logger.WRN,arguments)}log(a_module,a_str){return this._log(Logger.LOG,arguments)}inf(a_module,a_str){return this._log(Logger.INF,arguments)}dbg(a_module,a_str){return this._log(Logger.DBG,arguments)}trc(){return this._log(Logger.TRC,arguments)}_log(a_level,a_arguments){let level=this._configuration.logLevel;if(isNaN(level)){level=level=="tst"||level=="test"?Logger.TST:level=="crh"||level=="crash"?Logger.CRH:level=="err"||level=="error"?Logger.ERR:level=="wrn"||level=="warning"?Logger.WRN:level=="inf"||level=="info"?Logger.INF:level=="dbg"||level=="debug"?Logger.DBG:level=="trc"||level=="trace"?Logger.TRC:Logger.LOG}else{level=parseFloat(level)}if(a_level>level)return fcf.actions();let info={level:a_level,module:a_arguments[0],output:"",message:"",args:fcf.append([],a_arguments).slice(1),logger:this,break:false};return fcf.actions().then((()=>this.emit("message_before",info))).each(this._configuration.logHandlers,((a_key,a_handler)=>{if(info.break)return;let func=typeof a_handler=="string"?fcf.resolve(_isServer?global:window,a_handler):typeof a_handler=="function"?a_handler:false;if(typeof func!=="function")return;return func(info)})).then((()=>this.emit("message_after",info)))}}fcf.Logger=Logger;Logger.TST=0;Logger.CRH=10;Logger.ERR=20;Logger.WRN=30;Logger.INF=40;Logger.LOG=50;Logger.DBG=60;Logger.TRC=70;class LoggerOffset{constructor(a_offset,a_linePrefix){this.offset=!isNaN(a_offset)?parseInt(a_offset):0;this.prefix=a_linePrefix}}Logger.Offset=LoggerOffset;Logger.offset=(a_offset,a_linePrefix)=>new LoggerOffset(a_offset,a_linePrefix);fcf.Logger.spaceHandler=a_info=>{a_info.output+=" "};fcf.Logger.spaceServerHandler=a_info=>{if(!_isServer)return;a_info.output+=" "};fcf.Logger.timeHandler=a_info=>{a_info.output+=fcf.formatDate(new Date,"Y-m-d H:i:s.v")};fcf.Logger.pidHandler=a_info=>{if(!_isServer)return;a_info.output+="[PID:"+process.pid+"]"};fcf.Logger.levelHandler=a_info=>{let level=a_info.level<=Logger.TST?"TST":a_info.level<=Logger.CRH?"CRH":a_info.level<=Logger.ERR?"ERR":a_info.level<=Logger.WRN?"WRN":a_info.level<=Logger.INF?"INF":a_info.level<=Logger.LOG?"LOG":a_info.level<=Logger.DBG?"DBG":"TRC";a_info.output+="["+level+"]"};fcf.Logger.modHandler=a_info=>{a_info.output+="[MOD:"+a_info.module+"]"};fcf.Logger.colonHandler=a_info=>{a_info.output+=": "};fcf.Logger.messageHandler=a_info=>{let offset="";let prefix="";let array=[];function putString(a_str){if(offset&&typeof a_str=="string"){a_str=fcf.replaceAll(a_str,"\n","\n"+offset+prefix)}array.push(a_str)}for(var i=0;i<a_info.args.length;++i){if(a_info.args[i]instanceof fcf.Logger.Offset){prefix=a_info.args[i].prefix||prefix;offset+=fcf.pad("",a_info.args[i].offset," ","c")}else if(typeof a_info.args[i]=="object"){if(a_info.args[i]instanceof fcf.Exception){putString(a_info.args[i].toString(true,true,true))}else if(a_info.args[i]instanceof Error){const errorInfo=fcf.parseError(a_info.args[i]);putString(errorInfo.fullMessage);putString("\nStack:");putString(fcf.replaceAll("\n"+errorInfo.stack,"\n","\n "))}else{putString(_objectToString(a_info.args[i]))}}else{putString(a_info.args[i])}}a_info.message=array.join(" ");a_info.output+=a_info.message};function _objectToString(a_object,a_offset,a_path){const offsetInc=2;const skey="d031d461ddb4a4241b0428a137da400b";if(!a_offset)a_offset=0;if(!a_path)a_path="";if(typeof a_object!=="object"||a_object===null||a_object instanceof Date){return JSON.stringify(a_object)}else if(Array.isArray(a_object)){if(a_object[skey]){return`[Recursive Object: ${a_object[skey]}]`}a_object[skey]=a_path;let result="[";for(let i=0;i<a_object.length;++i){if(i){result+=","}result+="\n";result+=fcf.pad("",a_offset+offsetInc," ");result+=_objectToString(a_object[i],a_offset+offsetInc,`${a_path}[${i}]`)}if(a_object.length){result+="\n";result+=fcf.pad("",a_offset," ")}result+="]";delete a_object[skey];return result}else{if(a_object[skey]){return`[Recursive link: ${a_object[skey]}]`}a_object[skey]=a_path;let empty=true;let result="{";fcf.each(a_object,((a_key,a_value)=>{if(a_key==skey)return;if(!empty){result+=","}result+="\n";result+=fcf.pad("",a_offset+offsetInc," ");result+=JSON.stringify(a_key);result+=" : ";result+=_objectToString(a_value,a_offset+offsetInc,`${a_path}[${JSON.stringify(a_key)}]`);empty=false}));if(!empty){result+="\n";result+=fcf.pad("",a_offset," ")}result+="}";delete a_object[skey];return result}}fcf.Logger.consoleHandler=a_info=>{if(!_selfLoggerCall){_selfLoggerCall=true;console.log.call(console,a_info.output);_selfLoggerCall=false}};let _selfLoggerCall=false;fcf.Logger.fileHandler=a_info=>{if(!_isServer)return;return libLogger.fileHandler(a_info)};fcf.test=function(a_part,a_group,a_name,a_cbtest){let currentArguments=arguments;let loadModule=false;return fcf.actions().catch((a_error=>{if(!loadModule){return new fcf.Exception("LOAD_UNITEST_MODULE",a_error)}})).catch((a_error=>{fcf.log.err("unitest",a_error)})).then((()=>{if(!_isServer){if(!("___fcf_unitest"in fcf.getContext().route.args)){return}}return fcf.require("fcf-framework-unitest",{quiet:true})})).then((a_modules=>{if(!fcf.NUnitest||!fcf.NUnitest.unitest){if(!a_modules){return}throw new fcf.Exception("LOAD_MODULE",{module:"fcf-framework-unitest"})}loadModule=true;fcf.NUnitest.unitest.add.apply(fcf.NUnitest.unitest,currentArguments)}))};fcf.Configuration=class Configuration extends EventEmitter{constructor(a_options){super();Object.defineProperty(this,"___fcf_field_configuration___",{value:{},writable:false,enumerable:false});this.___fcf_field_configuration___._forbiddenFields={__proto__:1,___fcf_field_event_emitter_events___:1,___fcf_field_configuration___:1,___fcf_method_build___:1,___fcf_method_apply_config___:1,___fcf_method_copy_to_self___:1,___fcf_method_apply___:1,___fcf_method_push_item___:1,___fcf_method_append___:1,on:1,detach:1,emit:1,append:1,appendPackage:1,appendDefault:1,constructor:1};this.___fcf_field_configuration___._aq=new fcf.ActionsQueue;this.___fcf_field_configuration___._observers={};this.___fcf_field_configuration___._observersPaths={};this.___fcf_field_configuration___._config=[[],[],[]];this.___fcf_field_configuration___._merge=a_options&&a_options.merge?a_options.merge:{};this.___fcf_field_configuration___._mergeParamNames=a_options&&Array.isArray(a_options.mergeParamNames)?a_options.mergeParamNames:a_options&&a_options.mergeParamNames&&typeof a_options.mergeParamNames=="string"?[a_options.mergeParamNames]:[];this.___fcf_field_configuration___._merge=fcf.append(this.___fcf_field_configuration___._merge);for(let mergeParamName of this.___fcf_field_configuration___._mergeParamNames){this.___fcf_field_configuration___._merge[mergeParamName]="fcf.append"}if(a_options&&a_options.enableDefaultParams){this.___fcf_field_configuration___._merge["moduleDirectories"]="fcf.append";this.___fcf_field_configuration___._merge["sources"]="fcf.NDetails.mergeSourcesConfig";this.___fcf_field_configuration___._merge["aliases"]="fcf.append";this.___fcf_field_configuration___._merge["translations"]="fcf.append";this.___fcf_field_configuration___._merge["tokenize"]="fcf.NDetails.mergeTokenizeConfig";this.___fcf_field_configuration___._merge["packages"]="fcf.NDetails.mergePackagesConfig";const compressFilePath='@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(".min.") == -1 ? ".min" : ""}}@.@{{extension}}@';this.___fcf_field_configuration___._config[0].push({warnEmptyContext:false,defaultLanguage:"en",moduleDirectories:_isServer?[libPath.join(require("path").dirname(require.main.filename),"node_modules")]:[],webModuleDirectory:"/node_modules",aliases:{},translations:[],sessionLifetime:365*24*60*60,tokenize:{objects:{},functions:[]},sources:{"fcf-framework-core":{webMain:"fcf.js",webFilePath:{js:compressFilePath}},"fcf-framework-unitest":{webMain:"unitest.js",webFilePath:{js:compressFilePath}}},packages:{}});if(_isServer){let obj=require("./serverConfig.js");this.___fcf_field_configuration___._config[0].push(obj)}}if(a_options&&typeof a_options.configuration==="object"){this.___fcf_field_configuration___._config[2].push(a_options.configuration)}if(a_options&&a_options.isDefault){_configuration=this}this.___fcf_method_append___(undefined,0,true)}on(a_eventName,a_options,a_callback){if(typeof a_options=="function"){a_callback=a_options;a_options={}}if(typeof a_callback!="function"){return}let enp=a_eventName.split(":");if(enp.length>1){if(enp[0]=="change_item"){enp.shift();this._onChange(enp,a_eventName,a_callback,false,1)}else if(enp[0]=="change_item_after"){a_options.ignoreBreak=true;enp.shift();this._onChange(enp,a_eventName,a_callback,false,2)}else if(enp[0]=="update_item_before"){enp.shift();this._onChange(enp,a_eventName,a_callback,true,0)}else if(enp[0]=="update_item"){enp.shift();this._onChange(enp,a_eventName,a_callback,true,1)}else if(enp[0]=="update_item_after"){a_options.ignoreBreak=true;enp.shift();this._onChange(enp,a_eventName,a_callback,true,2)}}if(a_eventName=="update_after"){a_options.ignoreBreak=true}return super.on.call(this,a_eventName,a_options,a_callback)}detach(a_eventName,a_callback){if(arguments.length==1&&typeof a_eventName=="function"){a_callback=a_eventName;a_eventName=undefined}if(typeof a_callback==="function"&&a_callback.___fcfConfChange){for(let callUUID in a_callback.___fcfConfChange){if(this.___fcf_field_configuration___._observers[callUUID]){let paths=this.___fcf_field_configuration___._observers[callUUID].paths;for(let path of paths){delete this.___fcf_field_configuration___._observersPaths[path][callUUID];if(fcf.empty(this.___fcf_field_configuration___._observersPaths[path])){delete this.___fcf_field_configuration___._observersPaths[path]}}delete this.___fcf_field_configuration___._observers[callUUID];delete a_callback.___fcfConfChange[callUUID]}}}return super.detach.apply(this,arguments)}_onChange(a_paths,a_eventName,a_function,a_notEqual,a_level){a_paths=Array.isArray(a_paths)?a_paths:a_paths&&typeof a_paths=="string"?[a_paths]:[];if(!a_paths.length){return}if(typeof a_function!=="function"){return}if(!a_function.___fcfConfChange){Object.defineProperty(a_function,"___fcfConfChange",{value:{},writable:false,enumerable:false})}let callUUID=fcf.uuid();a_function.___fcfConfChange[callUUID]=1;for(let path of a_paths){if(!this.___fcf_field_configuration___._observersPaths[path]){this.___fcf_field_configuration___._observersPaths[path]={}}let pathArr=fcf.parseObjectAddress(path);this.___fcf_field_configuration___._observersPaths[path][callUUID]={event:a_eventName,level:a_level,notEqual:a_notEqual,path:pathArr,paths:a_paths};this.___fcf_field_configuration___._observers[callUUID]={paths:a_paths}}}appendDefault(a_config){if(typeof a_config!="object"){return this.___fcf_field_configuration___._aq.getActions()}return this.___fcf_method_append___(a_config,0)}appendPackage(a_config){if(typeof a_config!="object"){return this.___fcf_field_configuration___._aq.getActions()}return this.___fcf_method_append___(a_config,1)}append(a_config){if(typeof a_config!="object"){return this.___fcf_field_configuration___._aq.getActions()}return this.___fcf_method_append___(a_config,2)}___fcf_method_append___(a_config,a_level,a_isModuleDirectoriesExists){let userData={};let beforeCalls=[];let afterCalls=[];let calls=[];let resConf={};let repConfItem=false;let exconf=[undefined,undefined,undefined];let lastError;let isModuleDirectoriesExists=a_isModuleDirectoriesExists!==undefined?a_isModuleDirectoriesExists:a_config&&typeof a_config=="object"?"moduleDirectories"in a_config:false;return this.___fcf_field_configuration___._aq.getActions().then((()=>{if(!a_config){return}return this.emit("update_before",{object:a_config,configuration:this,userData:userData,level:a_level})})).then((()=>{if(!a_config){return}let fillMap={};for(let pathStr in this.___fcf_field_configuration___._observersPaths){for(let uuid in this.___fcf_field_configuration___._observersPaths[pathStr]){let callInfo=this.___fcf_field_configuration___._observersPaths[pathStr][uuid];let ptr=fcf.resolveEx(a_config,callInfo.path);if(callInfo.event in fillMap){if(ptr.object&&ptr.key in ptr.object){fillMap[callInfo.event].paths.push(callInfo.path)}continue}if(!ptr.object||!(ptr.key in ptr.object)){break}let data={object:a_config,configuration:this,userData:userData,level:a_level,paths:[callInfo.path]};fillMap[callInfo.event]=data;[beforeCalls,calls,afterCalls][callInfo.level].push({name:callInfo.event,data:data,notEqual:callInfo.notEqual,ignore:false})}}return fcf.actions().each(beforeCalls,((a_key,a_callInfo)=>this.emit(a_callInfo.name,a_callInfo.data)))})).then((()=>{if(a_level==2&&!!a_config&&!(a_config instanceof fcf.Configuration)&&!(this.___fcf_field_configuration___._config[2][this.___fcf_field_configuration___._config[2].length-1]instanceof fcf.Configuration)&&typeof this.___fcf_field_configuration___._config[2][this.___fcf_field_configuration___._config[2].length-1]=="object"){repConfItem={dest:this.___fcf_field_configuration___._config[2][this.___fcf_field_configuration___._config[2].length-1],source:fcf.Configuration.clone(a_config)}}exconf[a_level]=a_config;this.___fcf_method_apply___(exconf,resConf);for(let cv of[calls,afterCalls]){for(let c of cv){if(!c.notEqual){let paths=[];for(let p of c.data.paths){let originValue=fcf.resolve(this,p);let newValue=fcf.resolve(resConf,p);if(!fcf.equal(originValue,newValue)){paths.push(p)}}c.data.paths=paths;if(paths.length==0){c.ignore=true}}}}})).then((()=>{if(!a_config){return}return this.emit("update",{object:a_config,configuration:this,newConfiguration:resConf,userData:userData,level:a_level})})).then((()=>fcf.actions().each(calls,((a_key,a_callInfo)=>{if(a_callInfo.ignore){return}a_callInfo.data.newConfiguration=resConf;return this.emit(a_callInfo.name,a_callInfo.data)})))).then((()=>{if(repConfItem){this.___fcf_method_apply_config___(repConfItem.source,repConfItem.dest)}else{this.___fcf_method_push_item___(exconf[a_level],a_level)}this.___fcf_method_copy_to_self___(resConf);if(_isServer&&isModuleDirectoriesExists){libResolver.appendModuleDirectory(this.moduleDirectories)}fcf.appendTranslate()})).then((()=>{if(a_config instanceof fcf.Configuration){a_config.on("update_after",(a_info=>this.___fcf_method_append___(a_info.object,a_info.level,a_info.isModuleDirectoriesExists)))}})).then((()=>{if(!a_config){return}return fcf.actions({noexcept:true}).then((()=>this.emit("update_after",{object:a_config,configuration:this,userData:userData,level:a_level,isModuleDirectoriesExists:isModuleDirectoriesExists}))).catch(true,(a_error=>{if(!lastError){lastError=a_error}}))})).then((()=>fcf.actions().each(afterCalls,((a_key,a_callInfo)=>{if(a_callInfo.ignore){return}return fcf.actions({noexcept:true}).then((()=>this.emit(a_callInfo.name,a_callInfo.data))).catch(true,(a_error=>{if(!lastError){lastError=a_error}}))})))).then(((a_res,a_act)=>{if(lastError){a_act.error(lastError)}else{a_act.complete()}}))}___fcf_method_push_item___(a_item,a_level){if(a_item instanceof fcf.Configuration){for(let i=0;i<3;++i){const l=Math.min(i,a_level);this.___fcf_field_configuration___._config[l].push(fcf.Configuration.clone(a_item.___fcf_field_configuration___._config[i]))}this.___fcf_field_configuration___._merge=fcf.append({},a_item.___fcf_field_configuration___._merge,this.___fcf_field_configuration___._merge);this.___fcf_field_configuration___._mergeParamNames.unshift(...a_item.___fcf_field_configuration___._mergeParamNames)}else{this.___fcf_field_configuration___._config[a_level].push(fcf.Configuration.clone(a_item))}}___fcf_method_apply___(a_exConfig,a_destination){let actions=fcf.actions();let index=0;for(let index=0;index<this.___fcf_field_configuration___._config.length;++index){for(let conf of this.___fcf_field_configuration___._config[index]){this.___fcf_method_apply_config___(conf,a_destination)}if(a_exConfig[index]){this.___fcf_method_apply_config___(a_exConfig[index],a_destination)}}let tokenizeInfo={};this.___fcf_method_build___(a_destination,tokenizeInfo);if(fcf.getConfiguration()==this){fcf.NDetails.inlineExecution.setEnvironment(tokenizeInfo)}}___fcf_method_copy_to_self___(a_object){for(let key in this){delete this[key]}for(let key in a_object){if(key in this.___fcf_field_configuration___._forbiddenFields){continue}this[key]=a_object[key]}}___fcf_method_apply_config___(a_configuration,a_destination){if(!a_configuration||typeof a_configuration!=="object")return;let mergeItems={};for(let mergeParamName of this.___fcf_field_configuration___._mergeParamNames){fcf.append(mergeItems,this[mergeParamName],a_destination[mergeParamName],a_configuration[mergeParamName])}fcf.append(mergeItems,this.___fcf_field_configuration___._merge);let mergeInfo={};for(let k in mergeItems){let itm=mergeItems[k];let file;let type;if(typeof itm==="object"){file=itm.file;type=itm;itm=itm.function}let func=typeof itm=="string"&&itm?itm:false;if(func){if(file&&typeof fcf.resolve(_isServer?global:window,func)!="function"){fcf.require(file,{async:false})}if(typeof fcf.resolve(_isServer?global:window,func)!="function"){fcf.log.wrn("FCF",`Could not find merge function ${func} for config parameter "${k}"`);func=false}}let karr=fcf.parseObjectAddress(k);let m={items:mergeInfo};for(let ki of karr){if(!(ki in m.items)){m.items[ki]={items:{},func:undefined}}m=m.items[ki]}if(func!==false){m.func=func}if(type&&type.type){m.type=fcf.type(type)}}function merge(a_mergeInfo,a_key,a_result,a_dstObject,a_srcObject,a_isRoot,a_merge,a_ignoreAppend){if(a_mergeInfo.items[a_key]||a_isRoot){let func=a_mergeInfo.items[a_key]?a_mergeInfo.items[a_key].func:false;let type=a_mergeInfo.items[a_key]?a_mergeInfo.items[a_key].type:false;func=func&&fcf.resolve(typeof global=="object"?global:window,func);if(func&&!a_ignoreAppend){if(a_key in a_dstObject){let source=fcf.Configuration.clone(a_srcObject[a_key]);if(type){source=fcf.build(type,source)}a_result[a_key]=func(fcf.Configuration.clone(a_dstObject[a_key]),source)}else{if(a_merge){let source=fcf.Configuration.clone(a_srcObject[a_key]);if(type){source=fcf.build(type,source)}a_result[a_key]=source}}}else{if(a_merge){let source=fcf.Configuration.clone(a_srcObject[a_key]);if(type){source=fcf.build(type,source)}a_result[a_key]=source}}if(a_mergeInfo.items[a_key]){let item=a_mergeInfo.items[a_key];for(let k in item.items){if(a_srcObject[a_key]&&k in a_srcObject[a_key]){merge(a_mergeInfo.items[a_key],k,a_result[a_key],a_dstObject[a_key],a_srcObject[a_key],false,item.items[k].func!==undefined||item.items[k].type!==undefined,!(a_key in a_dstObject))}}}}else{if(a_merge){a_result[a_key]=fcf.Configuration.clone(a_srcObject[a_key])}}}let result={};for(let key in a_configuration){if(key[0]=="_")continue;merge({items:mergeInfo},key,result,a_destination,a_configuration,true,true);a_destination[key]=result[key]}}___fcf_method_build___(a_destination,a_tokinizeInfo){a_tokinizeInfo.functions={functions:{},items:{}};let fobjects={};let newCalls=[];let sfunctions=a_destination.tokenize&&a_destination.tokenize.functions?a_destination.tokenize.functions:[];let sobjects=a_destination.tokenize&&a_destination.tokenize.objects?a_destination.tokenize.objects:{};for(let func of sfunctions){let l=typeof func.object=="string"?func.object:Array.isArray(func.object)&&typeof func.object[0]=="string"?func.object[0]:"";let r=typeof func.object=="string"?func.object:Array.isArray(func.object)&&typeof func.object[1]=="string"?func.object[1]:"";let sla=fcf.parseObjectAddress(l);let sra=fcf.parseObjectAddress(r);let newCall=sla.pop();if(func.allow.indexOf("*")==-1&&func.allow.indexOf("constructor")==-1)continue;if(newCall!=""&&newCall!="*"){sra.pop();newCalls.push({object:[sla.length?fcf.normalizeObjectAddress(sla):"",sra.length?fcf.normalizeObjectAddress(sra):""],allow:[newCall]})}else if(newCall=="*"&&func.class){let pathArr=fcf.parseObjectAddress(func.class);newCall=pathArr.pop();newCalls.push({object:pathArr.length?fcf.normalizeObjectAddress(pathArr):"",allow:[newCall]})}}let sources=[sfunctions,newCalls];for(let source of sources){for(let func of source){let tf=a_tokinizeInfo.functions;func=fcf.Configuration.clone(func);let l=typeof func.object=="string"?func.object:Array.isArray(func.object)&&typeof func.object[0]=="string"?func.object[0]:"";let r=typeof func.object=="string"?func.object:Array.isArray(func.object)&&typeof func.object[1]=="string"?func.object[1]:"";func.object=[l,r];let sla=fcf.parseObjectAddress(l);let sra=fcf.parseObjectAddress(r);while(sla.length){if(sla[sla.length-1]=="*"){sla.pop()}else{break}}while(sra.length){if(sra[sra.length-1]=="*"){sra.pop()}else{break}}if(sla.length&&sra.length&&!(sla.length==1&&sla[0]=="")&&!(sra.length==1&&sra[0]=="")){let sl=fcf.normalizeObjectAddress(sla);let sr=fcf.normalizeObjectAddress(sra);fobjects[sl]={variable:sr,access:false}}if(func.object[0]){for(let pathItem of fcf.parseObjectAddress(func.object[0])){if(!tf.items[pathItem])tf.items[pathItem]={functions:{},items:{}};tf=tf.items[pathItem]}}let allow=Array.isArray(func.allow)?func.allow:["*"];for(let allowItem of allow){if(!Array.isArray(tf.functions[allowItem]))tf.functions[allowItem]=[];tf.functions[allowItem].push(func)}}}a_tokinizeInfo.environment={};a_tokinizeInfo.environmentInfo={parts:{}};for(let i=0;i<2;++i){let objects=!i?fobjects:sobjects;let overwrite=!!i;for(let sourcePath in objects){let path=fcf.parseObjectAddress(sourcePath);let subPath=fcf.clone(path);let key=subPath.pop();let root=fcf.prepare(a_tokinizeInfo.environment,subPath);let item=typeof objects[sourcePath]==="string"?{variable:objects[sourcePath]}:typeof objects[sourcePath]==="object"?objects[sourcePath]:{};if(typeof item.variable!=="string"){item.variable=sourcePath}let value=fcf.resolve(typeof global!=="undefined"?global:window,item.variable);try{if(overwrite||(!(key in root)||typeof root[key]==="function")){let desc=Object.getOwnPropertyDescriptor(root,key);if(!desc||desc.writable){root[key]=value}}}catch(e){}let p=a_tokinizeInfo.environmentInfo;for(let pathItem of path){if(!p.parts[pathItem]){p.parts[pathItem]={parts:{}}}p=p.parts[pathItem]}if(overwrite||!("access"in p)){p.access="access"in item?item.access:true}}}}};fcf.Configuration.clone=a_source=>{if(a_source&&typeof a_source=="object"){if(a_source instanceof Date){return new Date(a_source)}else if(Array.isArray(a_source)){let res=[];for(let s of a_source){res.push(fcf.Configuration.clone(s))}return res}else if(a_source.__proto__=={}.__proto__){let res={};for(let k in a_source){res[k]=fcf.Configuration.clone(a_source[k])}return res}else{return a_source}}else{return a_source}};fcf.getConfiguration=()=>_configuration;let _configuration=undefined;fcf.NDetails.mergeTokenizeConfig=(a_dst,a_source)=>{a_dst.objects=fcf.append({},a_dst.objects,a_source.objects);a_dst.functions=fcf.append([],a_dst.functions,a_source.functions);return a_dst};fcf.NDetails.mergeSourcesConfig=(a_dst,a_source)=>{a_dst=a_dst||{};a_source=a_source||{};let result=fcf.Configuration.clone(a_dst);for(let packageName in a_source){result[packageName]=fcf.append({},a_dst[packageName],a_source[packageName]);result[packageName].files=fcf.append(true,{},a_dst[packageName]&&a_dst[packageName].files,a_source[packageName]&&a_source[packageName].files);result[packageName].webFiles=fcf.append(true,{},a_dst[packageName]&&a_dst[packageName].webFiles,a_source[packageName]&&a_source[packageName].webFiles);result[packageName].serverFiles=fcf.append(true,{},a_dst[packageName]&&a_dst[packageName].serverFiles,a_source[packageName]&&a_source[packageName].serverFiles)}return result};fcf.NDetails.mergePackagesConfig=(a_dst,a_source)=>{let result=fcf.Configuration.clone(a_dst);for(let packageName in a_source){if(!result[packageName]){result[packageName]=fcf.Configuration.clone(a_source[packageName])}else{fcf.append(result[packageName],fcf.Configuration.clone(a_source[packageName]))}}return result};new fcf.Configuration({enableDefaultParams:true,isDefault:true,mergeParamNames:["merge"]});fcf.getEventChannel=()=>_eventChannel;_eventChannel=new fcf.EventChannel;fcf.log=new Logger(fcf.getConfiguration());if(_isServer){libResolver.appendModuleDirectory(_configuration.moduleDirectories)}if(!_isServer){if("___fcf_unitest"in fcf.getContext().route.args){fcf.require("fcf-framework-unitest").then((()=>{if(!fcf.NUnitest||!fcf.NUnitest.unitest){throw new fcf.Exception("LOAD_MODULE",{module:"fcf-framework-unitest"})}fcf.getEventChannel().onmet("page_ready",(()=>fcf.actions().then((()=>fcf.NUnitest.unitest.runAutoTests())).catch((e=>{fcf.log.err("UniTest",e)}))))}))}}if(!_isServer){document.addEventListener("DOMContentLoaded",(()=>{fcf.getEventChannel().send("page_ready",{})}))}_modules[_getModulePath("fcf-framework-core:fcf.js")]={state:"ok",result:fcf}})();