UNPKG

w-comor-hapi

Version:

A http communicator in nodejs and browser. Mapping functions from nodejs to other end points, like a simple RPC.

8 lines (7 loc) 24.5 kB
/*! * w-comor-hapi-server v1.0.38 * (c) 2018-2021 yuda-lyu(semisphere) * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@hapi/hapi")):"function"==typeof define&&define.amd?define(["@hapi/hapi"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-comor-hapi-server"]=e(t["@hapi/hapi"])}(this,(function(t){"use strict";function e(t,e){return t===e||t!=t&&e!=e}function r(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}var n=Array.prototype.splice;function o(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}o.prototype.clear=function(){this.__data__=[],this.size=0},o.prototype.delete=function(t){var e=this.__data__,o=r(e,t);return!(o<0)&&(o==e.length-1?e.pop():n.call(e,o,1),--this.size,!0)},o.prototype.get=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]},o.prototype.has=function(t){return r(this.__data__,t)>-1},o.prototype.set=function(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this};var u="object"==typeof global&&global&&global.Object===Object&&global,i="object"==typeof self&&self&&self.Object===Object&&self,c=u||i||Function("return this")(),a=c.Symbol,f=Object.prototype,l=f.hasOwnProperty,s=f.toString,p=a?a.toStringTag:void 0;var v=Object.prototype.toString;var b="[object Null]",h="[object Undefined]",y=a?a.toStringTag:void 0;function j(t){return null==t?void 0===t?h:b:y&&y in Object(t)?function(t){var e=l.call(t,p),r=t[p];try{t[p]=void 0;var n=!0}catch(t){}var o=s.call(t);return n&&(e?t[p]=r:delete t[p]),o}(t):function(t){return v.call(t)}(t)}function d(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var g="[object AsyncFunction]",_="[object Function]",O="[object GeneratorFunction]",w="[object Proxy]";function m(t){if(!d(t))return!1;var e=j(t);return e==_||e==O||e==g||e==w}var A,S=c["__core-js_shared__"],x=(A=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"";var z=Function.prototype.toString;function P(t){if(null!=t){try{return z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var F=/^\[object .+?Constructor\]$/,I=Function.prototype,E=Object.prototype,k=I.toString,N=E.hasOwnProperty,U=RegExp("^"+k.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $(t){return!(!d(t)||(e=t,x&&x in e))&&(m(t)?U:F).test(P(t));var e}function M(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return $(r)?r:void 0}var T=M(c,"Map"),B=M(Object,"create");var C=Object.prototype.hasOwnProperty;var D=Object.prototype.hasOwnProperty;function L(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function R(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function V(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}L.prototype.clear=function(){this.__data__=B?B(null):{},this.size=0},L.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},L.prototype.get=function(t){var e=this.__data__;if(B){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return C.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return B?void 0!==e[t]:D.call(e,t)},L.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=B&&void 0===e?"__lodash_hash_undefined__":e,this},V.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(T||o),string:new L}},V.prototype.delete=function(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e},V.prototype.get=function(t){return R(this,t).get(t)},V.prototype.has=function(t){return R(this,t).has(t)},V.prototype.set=function(t,e){var r=R(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function W(t){var e=this.__data__=new o(t);this.size=e.size}function q(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}W.prototype.clear=function(){this.__data__=new o,this.size=0},W.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},W.prototype.get=function(t){return this.__data__.get(t)},W.prototype.has=function(t){return this.__data__.has(t)},W.prototype.set=function(t,e){var r=this.__data__;if(r instanceof o){var n=r.__data__;if(!T||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new V(n)}return r.set(t,e),this.size=r.size,this};var G=function(){try{var t=M(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),H=G;function J(t,e,r){"__proto__"==e&&H?H(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var K=Object.prototype.hasOwnProperty;function Q(t,r,n){var o=t[r];K.call(t,r)&&e(o,n)&&(void 0!==n||r in t)||J(t,r,n)}function X(t,e,r,n){var o=!r;r||(r={});for(var u=-1,i=e.length;++u<i;){var c=e[u],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?J(r,c,a):Q(r,c,a)}return r}function Y(t){return null!=t&&"object"==typeof t}function Z(t){return Y(t)&&"[object Arguments]"==j(t)}var tt=Object.prototype,et=tt.hasOwnProperty,rt=tt.propertyIsEnumerable,nt=Z(function(){return arguments}())?Z:function(t){return Y(t)&&et.call(t,"callee")&&!rt.call(t,"callee")},ot=nt,ut=Array.isArray;var it="object"==typeof exports&&exports&&!exports.nodeType&&exports,ct=it&&"object"==typeof module&&module&&!module.nodeType&&module,at=ct&&ct.exports===it?c.Buffer:void 0,ft=(at?at.isBuffer:void 0)||function(){return!1},lt=9007199254740991,st=/^(?:0|[1-9]\d*)$/;function pt(t,e){var r=typeof t;return!!(e=null==e?lt:e)&&("number"==r||"symbol"!=r&&st.test(t))&&t>-1&&t%1==0&&t<e}var vt=9007199254740991;function bt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=vt}var ht={};function yt(t){return function(e){return t(e)}}ht["[object Float32Array]"]=ht["[object Float64Array]"]=ht["[object Int8Array]"]=ht["[object Int16Array]"]=ht["[object Int32Array]"]=ht["[object Uint8Array]"]=ht["[object Uint8ClampedArray]"]=ht["[object Uint16Array]"]=ht["[object Uint32Array]"]=!0,ht["[object Arguments]"]=ht["[object Array]"]=ht["[object ArrayBuffer]"]=ht["[object Boolean]"]=ht["[object DataView]"]=ht["[object Date]"]=ht["[object Error]"]=ht["[object Function]"]=ht["[object Map]"]=ht["[object Number]"]=ht["[object Object]"]=ht["[object RegExp]"]=ht["[object Set]"]=ht["[object String]"]=ht["[object WeakMap]"]=!1;var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,dt=jt&&"object"==typeof module&&module&&!module.nodeType&&module,gt=dt&&dt.exports===jt&&u.process,_t=function(){try{var t=dt&&dt.require&&dt.require("util").types;return t||gt&&gt.binding&&gt.binding("util")}catch(t){}}(),Ot=_t&&_t.isTypedArray,wt=Ot?yt(Ot):function(t){return Y(t)&&bt(t.length)&&!!ht[j(t)]},mt=Object.prototype.hasOwnProperty;function At(t,e){var r=ut(t),n=!r&&ot(t),o=!r&&!n&&ft(t),u=!r&&!n&&!o&&wt(t),i=r||n||o||u,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=c.length;for(var f in t)!e&&!mt.call(t,f)||i&&("length"==f||o&&("offset"==f||"parent"==f)||u&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||pt(f,a))||c.push(f);return c}var St=Object.prototype;function xt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||St)}function zt(t,e){return function(r){return t(e(r))}}var Pt=zt(Object.keys,Object),Ft=Object.prototype.hasOwnProperty;function It(t){return null!=t&&bt(t.length)&&!m(t)}function Et(t){return It(t)?At(t):function(t){if(!xt(t))return Pt(t);var e=[];for(var r in Object(t))Ft.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var kt=Object.prototype.hasOwnProperty;function Nt(t){if(!d(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=xt(t),r=[];for(var n in t)("constructor"!=n||!e&&kt.call(t,n))&&r.push(n);return r}function Ut(t){return It(t)?At(t,!0):Nt(t)}var $t="object"==typeof exports&&exports&&!exports.nodeType&&exports,Mt=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=Mt&&Mt.exports===$t?c.Buffer:void 0,Bt=Tt?Tt.allocUnsafe:void 0;function Ct(){return[]}var Dt=Object.prototype.propertyIsEnumerable,Lt=Object.getOwnPropertySymbols,Rt=Lt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,u=[];++r<n;){var i=t[r];e(i,r,t)&&(u[o++]=i)}return u}(Lt(t),(function(e){return Dt.call(t,e)})))}:Ct,Vt=Rt;function Wt(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var qt=zt(Object.getPrototypeOf,Object),Gt=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Wt(e,Vt(t)),t=qt(t);return e}:Ct,Ht=Gt;function Jt(t,e,r){var n=e(t);return ut(t)?n:Wt(n,r(t))}function Kt(t){return Jt(t,Et,Vt)}function Qt(t){return Jt(t,Ut,Ht)}var Xt=M(c,"DataView"),Yt=M(c,"Promise"),Zt=M(c,"Set"),te=M(c,"WeakMap"),ee="[object Map]",re="[object Promise]",ne="[object Set]",oe="[object WeakMap]",ue="[object DataView]",ie=P(Xt),ce=P(T),ae=P(Yt),fe=P(Zt),le=P(te),se=j;(Xt&&se(new Xt(new ArrayBuffer(1)))!=ue||T&&se(new T)!=ee||Yt&&se(Yt.resolve())!=re||Zt&&se(new Zt)!=ne||te&&se(new te)!=oe)&&(se=function(t){var e=j(t),r="[object Object]"==e?t.constructor:void 0,n=r?P(r):"";if(n)switch(n){case ie:return ue;case ce:return ee;case ae:return re;case fe:return ne;case le:return oe}return e});var pe=se,ve=Object.prototype.hasOwnProperty;var be=c.Uint8Array;function he(t){var e=new t.constructor(t.byteLength);return new be(e).set(new be(t)),e}var ye=/\w*$/;var je=a?a.prototype:void 0,de=je?je.valueOf:void 0;var ge="[object Boolean]",_e="[object Date]",Oe="[object Map]",we="[object Number]",me="[object RegExp]",Ae="[object Set]",Se="[object String]",xe="[object Symbol]",ze="[object ArrayBuffer]",Pe="[object DataView]",Fe="[object Float32Array]",Ie="[object Float64Array]",Ee="[object Int8Array]",ke="[object Int16Array]",Ne="[object Int32Array]",Ue="[object Uint8Array]",$e="[object Uint8ClampedArray]",Me="[object Uint16Array]",Te="[object Uint32Array]";function Be(t,e,r){var n,o,u,i=t.constructor;switch(e){case ze:return he(t);case ge:case _e:return new i(+t);case Pe:return function(t,e){var r=e?he(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case Fe:case Ie:case Ee:case ke:case Ne:case Ue:case $e:case Me:case Te:return function(t,e){var r=e?he(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case Oe:return new i;case we:case Se:return new i(t);case me:return(u=new(o=t).constructor(o.source,ye.exec(o))).lastIndex=o.lastIndex,u;case Ae:return new i;case xe:return n=t,de?Object(de.call(n)):{}}}var Ce=Object.create,De=function(){function t(){}return function(e){if(!d(e))return{};if(Ce)return Ce(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Le=De;var Re=_t&&_t.isMap,Ve=Re?yt(Re):function(t){return Y(t)&&"[object Map]"==pe(t)};var We=_t&&_t.isSet,qe=We?yt(We):function(t){return Y(t)&&"[object Set]"==pe(t)},Ge=1,He=2,Je=4,Ke="[object Arguments]",Qe="[object Function]",Xe="[object GeneratorFunction]",Ye="[object Object]",Ze={};function tr(t,e,r,n,o,u){var i,c=e&Ge,a=e&He,f=e&Je;if(r&&(i=o?r(t,n,o,u):r(t)),void 0!==i)return i;if(!d(t))return t;var l=ut(t);if(l){if(i=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&ve.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,i)}else{var s=pe(t),p=s==Qe||s==Xe;if(ft(t))return function(t,e){if(e)return t.slice();var r=t.length,n=Bt?Bt(r):new t.constructor(r);return t.copy(n),n}(t,c);if(s==Ye||s==Ke||p&&!o){if(i=a||p?{}:function(t){return"function"!=typeof t.constructor||xt(t)?{}:Le(qt(t))}(t),!c)return a?function(t,e){return X(t,Ht(t),e)}(t,function(t,e){return t&&X(e,Ut(e),t)}(i,t)):function(t,e){return X(t,Vt(t),e)}(t,function(t,e){return t&&X(e,Et(e),t)}(i,t))}else{if(!Ze[s])return o?t:{};i=Be(t,s,c)}}u||(u=new W);var v=u.get(t);if(v)return v;u.set(t,i),qe(t)?t.forEach((function(n){i.add(tr(n,e,r,n,t,u))})):Ve(t)&&t.forEach((function(n,o){i.set(o,tr(n,e,r,o,t,u))}));var b=l?void 0:(f?a?Qt:Kt:a?Ut:Et)(t);return q(b||t,(function(n,o){b&&(n=t[o=n]),Q(i,o,tr(n,e,r,o,t,u))})),i}Ze[Ke]=Ze["[object Array]"]=Ze["[object ArrayBuffer]"]=Ze["[object DataView]"]=Ze["[object Boolean]"]=Ze["[object Date]"]=Ze["[object Float32Array]"]=Ze["[object Float64Array]"]=Ze["[object Int8Array]"]=Ze["[object Int16Array]"]=Ze["[object Int32Array]"]=Ze["[object Map]"]=Ze["[object Number]"]=Ze[Ye]=Ze["[object RegExp]"]=Ze["[object Set]"]=Ze["[object String]"]=Ze["[object Symbol]"]=Ze["[object Uint8Array]"]=Ze["[object Uint8ClampedArray]"]=Ze["[object Uint16Array]"]=Ze["[object Uint32Array]"]=!0,Ze["[object Error]"]=Ze[Qe]=Ze["[object WeakMap]"]=!1;var er=1,rr=4;var nr="[object Symbol]";function or(t){return"symbol"==typeof t||Y(t)&&j(t)==nr}var ur=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ir=/^\w*$/;function cr(t,e){if(ut(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!or(t))||(ir.test(t)||!ur.test(t)||null!=e&&t in Object(e))}var ar="Expected a function";function fr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(ar);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],u=r.cache;if(u.has(o))return u.get(o);var i=t.apply(this,n);return r.cache=u.set(o,i)||u,i};return r.cache=new(fr.Cache||V),r}fr.Cache=V;var lr,sr,pr,vr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,br=/\\(\\)?/g,hr=(lr=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(vr,(function(t,r,n,o){e.push(n?o.replace(br,"$1"):r||t)})),e},sr=fr(lr,(function(t){return 500===pr.size&&pr.clear(),t})),pr=sr.cache,sr),yr=hr;var jr=1/0,dr=a?a.prototype:void 0,gr=dr?dr.toString:void 0;function _r(t){if("string"==typeof t)return t;if(ut(t))return function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}(t,_r)+"";if(or(t))return gr?gr.call(t):"";var e=t+"";return"0"==e&&1/t==-jr?"-0":e}function Or(t){return null==t?"":_r(t)}function wr(t,e){return ut(t)?t:cr(t,e)?[t]:yr(Or(t))}var mr=1/0;function Ar(t){if("string"==typeof t||or(t))return t;var e=t+"";return"0"==e&&1/t==-mr?"-0":e}function Sr(t,e){for(var r=0,n=(e=wr(e,t)).length;null!=t&&r<n;)t=t[Ar(e[r++])];return r&&r==n?t:void 0}function xr(t,e,r){var n=null==t?void 0:Sr(t,e);return void 0===n?r:n}function zr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new V;++e<r;)this.add(t[e])}function Pr(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Fr(t,e){return t.has(e)}zr.prototype.add=zr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},zr.prototype.has=function(t){return this.__data__.has(t)};var Ir=1,Er=2;function kr(t,e,r,n,o,u){var i=r&Ir,c=t.length,a=e.length;if(c!=a&&!(i&&a>c))return!1;var f=u.get(t),l=u.get(e);if(f&&l)return f==e&&l==t;var s=-1,p=!0,v=r&Er?new zr:void 0;for(u.set(t,e),u.set(e,t);++s<c;){var b=t[s],h=e[s];if(n)var y=i?n(h,b,s,e,t,u):n(b,h,s,t,e,u);if(void 0!==y){if(y)continue;p=!1;break}if(v){if(!Pr(e,(function(t,e){if(!Fr(v,e)&&(b===t||o(b,t,r,n,u)))return v.push(e)}))){p=!1;break}}else if(b!==h&&!o(b,h,r,n,u)){p=!1;break}}return u.delete(t),u.delete(e),p}function Nr(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Ur(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var $r=1,Mr=2,Tr="[object Boolean]",Br="[object Date]",Cr="[object Error]",Dr="[object Map]",Lr="[object Number]",Rr="[object RegExp]",Vr="[object Set]",Wr="[object String]",qr="[object Symbol]",Gr="[object ArrayBuffer]",Hr="[object DataView]",Jr=a?a.prototype:void 0,Kr=Jr?Jr.valueOf:void 0;var Qr=1,Xr=Object.prototype.hasOwnProperty;var Yr=1,Zr="[object Arguments]",tn="[object Array]",en="[object Object]",rn=Object.prototype.hasOwnProperty;function nn(t,r,n,o,u,i){var c=ut(t),a=ut(r),f=c?tn:pe(t),l=a?tn:pe(r),s=(f=f==Zr?en:f)==en,p=(l=l==Zr?en:l)==en,v=f==l;if(v&&ft(t)){if(!ft(r))return!1;c=!0,s=!1}if(v&&!s)return i||(i=new W),c||wt(t)?kr(t,r,n,o,u,i):function(t,r,n,o,u,i,c){switch(n){case Hr:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case Gr:return!(t.byteLength!=r.byteLength||!i(new be(t),new be(r)));case Tr:case Br:case Lr:return e(+t,+r);case Cr:return t.name==r.name&&t.message==r.message;case Rr:case Wr:return t==r+"";case Dr:var a=Nr;case Vr:var f=o&$r;if(a||(a=Ur),t.size!=r.size&&!f)return!1;var l=c.get(t);if(l)return l==r;o|=Mr,c.set(t,r);var s=kr(a(t),a(r),o,u,i,c);return c.delete(t),s;case qr:if(Kr)return Kr.call(t)==Kr.call(r)}return!1}(t,r,f,n,o,u,i);if(!(n&Yr)){var b=s&&rn.call(t,"__wrapped__"),h=p&&rn.call(r,"__wrapped__");if(b||h){var y=b?t.value():t,j=h?r.value():r;return i||(i=new W),u(y,j,n,o,i)}}return!!v&&(i||(i=new W),function(t,e,r,n,o,u){var i=r&Qr,c=Kt(t),a=c.length;if(a!=Kt(e).length&&!i)return!1;for(var f=a;f--;){var l=c[f];if(!(i?l in e:Xr.call(e,l)))return!1}var s=u.get(t),p=u.get(e);if(s&&p)return s==e&&p==t;var v=!0;u.set(t,e),u.set(e,t);for(var b=i;++f<a;){var h=t[l=c[f]],y=e[l];if(n)var j=i?n(y,h,l,e,t,u):n(h,y,l,t,e,u);if(!(void 0===j?h===y||o(h,y,r,n,u):j)){v=!1;break}b||(b="constructor"==l)}if(v&&!b){var d=t.constructor,g=e.constructor;d==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof d&&d instanceof d&&"function"==typeof g&&g instanceof g||(v=!1)}return u.delete(t),u.delete(e),v}(t,r,n,o,u,i))}function on(t,e,r,n,o){return t===e||(null==t||null==e||!Y(t)&&!Y(e)?t!=t&&e!=e:nn(t,e,r,n,on,o))}var un=1,cn=2;function an(t){return t==t&&!d(t)}function fn(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function ln(t){var e=function(t){for(var e=Et(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,an(o)]}return e}(t);return 1==e.length&&e[0][2]?fn(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var o=r.length,u=o,i=!n;if(null==t)return!u;for(t=Object(t);o--;){var c=r[o];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++o<u;){var a=(c=r[o])[0],f=t[a],l=c[1];if(i&&c[2]){if(void 0===f&&!(a in t))return!1}else{var s=new W;if(n)var p=n(f,l,a,t,e,s);if(!(void 0===p?on(l,f,un|cn,n,s):p))return!1}}return!0}(r,t,e)}}function sn(t,e){return null!=t&&e in Object(t)}function pn(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=wr(e,t)).length,u=!1;++n<o;){var i=Ar(e[n]);if(!(u=null!=t&&r(t,i)))break;t=t[i]}return u||++n!=o?u:!!(o=null==t?0:t.length)&&bt(o)&&pt(i,o)&&(ut(t)||ot(t))}(t,e,sn)}var vn=1,bn=2;function hn(t){return t}function yn(t){return cr(t)?(e=Ar(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return Sr(e,t)}}(t);var e}function jn(t){return"function"==typeof t?t:null==t?hn:"object"==typeof t?ut(t)?(e=t[0],r=t[1],cr(e)&&an(r)?fn(Ar(e),r):function(t){var n=xr(t,e);return void 0===n&&n===r?pn(t,e):on(r,n,vn|bn)}):ln(t):yn(t);var e,r}function dn(t){return t!=t}function gn(t,e){return!!(null==t?0:t.length)&&function(t,e,r){return e==e?function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(t,e,r):function(t,e,r,n){for(var o=t.length,u=r+(n?1:-1);n?u--:++u<o;)if(e(t[u],u,t))return u;return-1}(t,dn,r)}(t,e,0)>-1}function _n(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1}var On=Zt&&1/Ur(new Zt([,-0]))[1]==1/0?function(t){return new Zt(t)}:function(){},wn=200;function mn(t,e){return t&&t.length?function(t,e,r){var n=-1,o=gn,u=t.length,i=!0,c=[],a=c;if(r)i=!1,o=_n;else if(u>=wn){var f=e?null:On(t);if(f)return Ur(f);i=!1,o=Fr,a=new zr}else a=e?[]:c;t:for(;++n<u;){var l=t[n],s=e?e(l):l;if(l=r||0!==l?l:0,i&&s==s){for(var p=a.length;p--;)if(a[p]===s)continue t;e&&a.push(s),c.push(l)}else o(a,s,r)||(a!==c&&a.push(s),c.push(l))}return c}(t,jn(e)):[]}function An(t,e){return on(t,e)}var Sn,xn=function(t,e,r){for(var n=-1,o=Object(t),u=r(t),i=u.length;i--;){var c=u[Sn?i:++n];if(!1===e(o[c],c,o))break}return t};var zn=function(t,e){return function(r,n){if(null==r)return r;if(!It(r))return t(r,n);for(var o=r.length,u=e?o:-1,i=Object(r);(e?u--:++u<o)&&!1!==n(i[u],u,i););return r}}((function(t,e){return t&&xn(t,e,Et)})),Pn=zn;function Fn(t,e){var r;return(ut(t)?q:Pn)(t,"function"==typeof(r=e)?r:hn)}function In(){let t,e,r=new Promise((function(){t=arguments[0],e=arguments[1]}));return r.resolve=t,r.reject=e,r}var En=/\s/;var kn=/^\s+/;function Nn(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&En.test(t.charAt(e)););return e}(t)+1).replace(kn,""):t}var Un=NaN,$n=/^[-+]0x[0-9a-f]+$/i,Mn=/^0b[01]+$/i,Tn=/^0o[0-7]+$/i,Bn=parseInt;function Cn(t){if("number"==typeof t)return t;if(or(t))return Un;if(d(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=d(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Nn(t);var r=Mn.test(t);return r||Tn.test(t)?Bn(t.slice(2),r?2:8):$n.test(t)?Un:+t}var Dn=1/0,Ln=17976931348623157e292;function Rn(t){return t?(t=Cn(t))===Dn||t===-Dn?(t<0?-1:1)*Ln:t==t?t:0:0===t?t:0}function Vn(t){var e=Rn(t),r=e%1;return e==e?r?e-r:e:0}function Wn(t){return"[object String]"===Object.prototype.toString.call(t)}function qn(t){return!(!Wn(t)||""===t)}function Gn(t){return t!=t}function Hn(t){let e=!1;if(qn(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Gn(t))return!1;e=!0}return e}function Jn(t){if(!Hn(t))return 0;return Rn(t)}function Kn(t){return!!Hn(t)&&(t=Jn(t),"number"==typeof(e=t)&&e==Vn(e));var e}var Qn=c.isFinite,Xn=Math.min;var Yn=function(t){var e=Math[t];return function(t,r){if(t=Cn(t),(r=null==r?0:Xn(Vn(r),292))&&Qn(t)){var n=(Or(t)+"e").split("e");return+((n=(Or(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Zn=Yn;function to(t){if(!Hn(t))return 0;t=Jn(t);let e=Zn(t);return"0"===String(e)?0:e}let eo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),ro=eo.length;function no(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,e=[];var r;t=Kn(r=t)&&to(r)>0?to(t):32;for(let r=0;r<t;r++)e[r]=eo[0|Math.random()*ro];return e.join("")}function oo(t){return"[object Object]"===Object.prototype.toString.call(t)}function uo(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function io(t){return"[object Array]"===Object.prototype.toString.call(t)}function co(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(oo(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Wn(t)||""!==t)}(t)||(!!function(t){return!!io(t)&&0===t.length}(t)||!!Gn(t)))))}return function(e){let r=[],n=[];(e=tr(e,er|rr)).port||(e.port=8080),e.apiName||(e.apiName="api"),e.routes||(e.routes=[]);let o=[];var u,i;async function c(t){let r=xr(t,"token",""),n=await function(t){let r=In();return uo(e.authenticate)?e.authenticate(t).then((function(t){r.resolve(t)})):r.resolve(!0),r}(r);if(n){let n=xr(t,"func",""),u=xr(t,"input");if("getFuncs"===n)uo(e.filterFuncs)&&(o=await e.filterFuncs(r,o)),t.output={sys:"sys",funcs:o};else if(function(t,e){function r(t){return io(t)?t:[t]}if(co(t))return!1;if(0===(t=r(t)).length)return!1;if(co(t))return!1;if(0===(e=r(e)).length)return!1;for(let r=0;r<t.length;r++)for(let n=0;n<e.length;n++)if(An(t[r],e[n]))return!0;return!1}(o,n)){let r=await e.funcs[n](u);t.output=r}else t.output={err:`can not find: ${n}`}}else t.output={err:`can not authenticate token: ${r}`};return delete t.input,JSON.stringify(t)}function a(t){if(uo(e.onClientChange)){let r=mn(t,"clientId");An(n,r)||(n=r,e.onClientChange(n,e))}}i="funcs",oo(u=e)&&(qn(i)||Hn(i))&&i in u&&(o=Et(e.funcs));let f={path:"/"+e.apiName,method:"POST",options:{payload:{maxBytes:1048576e3,timeout:18e4,multipart:!0},timeout:{socket:3e5}},handler:function(t,e){let n=In(),o=no(),u=xr(t.payload,"clientId"),i={headers:t.headers,info:t.info};return r.push({clientId:u,connId:o,data:i}),a(r),c(t.payload).then((function(t){n.resolve(t)})).catch((function(t){n.reject(t)})).finally((function(){r=r.filter((function(t){return t.connId!==o})),a(r)})),n}};e.serverHapi?e.serverHapi.route(f):async function(){let r=t.server({port:e.port,routes:{cors:!0}});r.route(f),Fn(e.routes,(function(t){r.route(t)})),await r.start(),console.log(`Server running at: ${r.info.uri}`)}()}})); //# sourceMappingURL=w-comor-hapi-server.umd.js.map