// Hprose for HTML5 v2.0.15
// Copyright (c) 2008-2016 http://hprose.com
// Hprose is freely distributable under the MIT license.
// For all details and documentation:
// https://github.com/hprose/hprose-html5
function TimeoutError(e){Error.call(this),this.message=e,this.name=TimeoutError.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,TimeoutError)}!function(e){"use strict";e.hprose=Object.create(null)}(this),function(e,t){"use strict";function r(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return function(t){return e.apply(t,Array.prototype.slice.call(arguments,1))}}function n(e){for(var t=e.length,r=new Array(t),n=0;n>16,i=new Array(r?n+1:n),o=0;o=0?n=i:(n=r+i,n<0&&(n=0));for(var o;n>>0,o=arguments[1],a=0;a>>0,o=arguments[1],a=0;a>>0,i=arguments[1],o=i>>0,a=o<0?Math.max(n+o,0):Math.min(o,n),s=arguments[2],u=s===t?n:s>>0,c=u<0?Math.max(n+u,0):Math.min(u,n);a>>0,o=e>>0,a=o<0?Math.max(i+o,0):Math.min(o,i),s=r>>0,u=s<0?Math.max(i+s,0):Math.min(s,i),c=arguments[2],f=c===t?i:c>>0,l=f<0?Math.max(i+f,0):Math.min(f,i),h=Math.min(l-u,i-a),p=1;for(u0;)u in n?n[a]=n[u]:delete n[a],u+=p,a+=p,h--;return n}}),Array.from||Object.defineProperty(Array,"from",{value:function(){var e=Object.prototype.toString,r=function(t){return"function"==typeof t||"[object Function]"===e.call(t)},n=function(e){var t=Number(e);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t},i=Math.pow(2,53)-1,o=function(e){var t=n(e);return Math.min(Math.max(t,0),i)};return function(e){var n=this,i=Object(e);if(null===e||e===t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var a,s=arguments.length>1?arguments[1]:void t;if("undefined"!=typeof s){if(!r(s))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(a=arguments[2])}for(var u,c=o(i.length),f=r(n)?Object(new n(c)):new Array(c),l=0;lr.length)&&(t=r.length),t-=e.length;var n=r.indexOf(e,t);return n!==-1&&n===t}}),String.prototype.includes||Object.defineProperty(String.prototype,"includes",{value:function(){return"number"==typeof arguments[1]?!(this.length=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1===(1&e)&&(r+=t),e>>>=1,0!==e;)t+=t;return r}}),String.prototype.trim||Object.defineProperty(String.prototype,"trim",{value:function(){return this.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}}),String.prototype.trimLeft||Object.defineProperty(String.prototype,"trimLeft",{value:function(){return this.toString().replace(/^[\s\xa0]+/,"")}}),String.prototype.trimRight||Object.defineProperty(String.prototype,"trimRight",{value:function(){return this.toString().replace(/[\s\xa0]+$/,"")}}),Object.keys||Object.defineProperty(Object,"keys",{value:function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=r.length;return function(i){if("object"!=typeof i&&"function"!=typeof i||null===i)throw new TypeError("Object.keys called on non-object");var o=[];for(var a in i)e.call(i,a)&&o.push(a);if(t)for(var s=0;s0&&Array.isArray(arguments[0]))for(var u=arguments[0],c=0,f=u.length;c0&&Array.isArray(arguments[0]))for(var o=arguments[0],a=0,f=o.length;a0&&Array.isArray(arguments[0]))for(var o=arguments[0],a=0,s=o.length;a0;)i(e.shift())});return r.observe(t,{characterData:!0}),function(){var r=o(arguments);return e.push(r),t.data=1&r,r}},u.messageChannel=function(){var t=new e.MessageChannel;return t.port1.onmessage=function(e){i(Number(e.data))},function(){var e=o(arguments);return t.port2.postMessage(e),e}},u.nextTick=function(){return function(){var t=o(arguments);return e.process.nextTick(r(i,t)),t}},u.postMessage=function(){var e=a.createElement("iframe");e.style.display="none",a.documentElement.appendChild(e);var t=e.contentWindow;t.document.write(''),t.document.close();var r=[];return window.addEventListener("message",function(){for(;r.length>0;)i(r.shift())}),function(){var e=o(arguments);return r.push(e),t.postMessage(1,"*"),e}},u.readyStateChange=function(){var e=a.documentElement;return function(){var t=o(arguments),r=a.createElement("script");return r.onreadystatechange=function(){i(t),r.onreadystatechange=null,e.removeChild(r),r=null},e.appendChild(r),t}},u.setTimeout=function(){return function(){var t=o(arguments);return e.setTimeout(r(i,t),0),t}};var l=Object.getPrototypeOf&&Object.getPrototypeOf(e);l=l&&l.setTimeout?l:e,"undefined"==typeof e.process||"[object process]"!==Object.prototype.toString.call(e.process)||e.process.browser?a&&"onreadystatechange"in a.createElement("script")?l.setImmediate=u.readyStateChange():a&&s?l.setImmediate=u.mutationObserver():e.MessageChannel?l.setImmediate=u.messageChannel():a&&"postMessage"in e&&"addEventListener"in e?l.setImmediate=u.postMessage():l.setImmediate=u.setTimeout():l.setImmediate=u.nextTick(),l.clearImmediate=n}}(this),function(e,t){"use strict";function r(e){Object.defineProperties(this,{_subscribers:{value:[]},resolve:{value:this.resolve.bind(this)},reject:{value:this.reject.bind(this)}});var t=this;"function"==typeof e&&L(function(){try{t.resolve(e())}catch(e){t.reject(e)}})}function n(e){return e instanceof r}function i(t){return n(t)||W&&t instanceof e.Promise&&typeof("function"===t.then)}function o(e){return i(e)?e:u(e)}function a(e,t){var n="function"==typeof t?t:function(){return t},i=new r;return D(function(){try{i.resolve(n())}catch(e){i.reject(e)}},e),i}function s(e){var t=new r;return t.reject(e),t}function u(e){var t=new r;return t.resolve(e),t}function c(e){try{var t=e();return u(t)}catch(e){return s(e)}}function f(e){var t=new r;return e(t.resolve,t.reject),t}function l(e){var t=0;return Array.forEach(e,function(){++t}),t}function h(e){return e=i(e)?e:u(e),e.then(function(e){var t=e.length,n=l(e),i=new Array(t);if(0===n)return u(i);var a=new r;return Array.forEach(e,function(e,t){o(e).then(function(e){i[t]=e,0===--n&&a.resolve(i)},a.reject)}),a})}function p(){return h(arguments)}function g(e){return e=i(e)?e:u(e),e.then(function(e){var t=new r;return Array.forEach(e,function(e){o(e).fill(t)}),t})}function v(e){return e=i(e)?e:u(e),e.then(function(e){var t=e.length,n=l(e);if(0===n)throw new RangeError("any(): array must not be empty");var i=new Array(t),a=new r;return Array.forEach(e,function(e,t){o(e).then(a.resolve,function(e){i[t]=e,0===--n&&a.reject(i)})}),a})}function d(e){return e=i(e)?e:u(e),e.then(function(e){var t=e.length,n=l(e),i=new Array(t);if(0===n)return u(i);var a=new r;return Array.forEach(e,function(e,t){var r=o(e);r.whenComplete(function(){i[t]=r.inspect(),0===--n&&a.resolve(i)})}),a})}function y(e){var r=Array.slice(arguments,1);return h(r).then(function(r){return e.apply(t,r)})}function w(e,t){var r=Array.slice(arguments,2);return h(r).then(function(r){return e.apply(t,r)})}function m(e,t){return function(){return h(arguments).then(function(r){return e.apply(t,r)})}}function b(e,t,r){return h(e).then(function(e){return e.forEach(t,r)})}function T(e,t,r){return h(e).then(function(e){return e.every(t,r)})}function _(e,t,r){return h(e).then(function(e){return e.some(t,r)})}function O(e,t,r){return h(e).then(function(e){return e.filter(t,r)})}function S(e,t,r){return h(e).then(function(e){return e.map(t,r)})}function j(e,t,r){return arguments.length>2?h(e).then(function(e){return i(r)||(r=u(r)),r.then(function(r){return e.reduce(t,r)})}):h(e).then(function(e){return e.reduce(t)})}function B(e,t,r){return arguments.length>2?h(e).then(function(e){return i(r)||(r=u(r)),r.then(function(r){return e.reduceRight(t,r)})}):h(e).then(function(e){return e.reduceRight(t)})}function E(e,t,r){return h(e).then(function(e){return i(t)||(t=u(t)),t.then(function(t){return e.indexOf(t,r)})})}function A(e,r,n){return h(e).then(function(e){return i(r)||(r=u(r)),r.then(function(r){return n===t&&(n=e.length-1),e.lastIndexOf(r,n)})})}function k(e,t,r){return h(e).then(function(e){return i(t)||(t=u(t)),t.then(function(t){return e.includes(t,r)})})}function C(e,t,r){return h(e).then(function(e){return e.find(t,r)})}function I(e,t,r){return h(e).then(function(e){return e.findIndex(t,r)})}function R(e,t,r){L(function(){try{var n=e(r);t.resolve(n)}catch(e){t.reject(e)}})}function M(e,t,r){e?R(e,t,r):t.resolve(r)}function x(e,t,r){e?R(e,t,r):t.reject(r)}function P(){var e=new r;Object.defineProperties(this,{future:{value:e},complete:{value:e.resolve},completeError:{value:e.reject},isCompleted:{get:function(){return e._state!==U}}})}var U=0,N=1,F=2,W="Promise"in e,L=e.setImmediate,D=e.setTimeout,z=e.clearTimeout,q=e.TimeoutError;Object.defineProperties(r,{delayed:{value:a},error:{value:s},sync:{value:c},value:{value:u},all:{value:h},race:{value:g},resolve:{value:u},reject:{value:s},promise:{value:f},isFuture:{value:n},isPromise:{value:i},toPromise:{value:o},join:{value:p},any:{value:v},settle:{value:d},attempt:{value:y},run:{value:w},wrap:{value:m},forEach:{value:b},every:{value:T},some:{value:_},filter:{value:O},map:{value:S},reduce:{value:j},reduceRight:{value:B},indexOf:{value:E},lastIndexOf:{value:A},includes:{value:k},find:{value:C},findIndex:{value:I}}),Object.defineProperties(r.prototype,{_value:{writable:!0},_reason:{writable:!0},_state:{value:U,writable:!0},resolve:{value:function(e){if(e===this)return void this.reject(new TypeError("Self resolution"));if(i(e))return void e.fill(this);if(null!==e&&"object"==typeof e||"function"==typeof e){var t;try{t=e.then}catch(e){return void this.reject(e)}if("function"==typeof t){var r=!0;try{var n=this;return void t.call(e,function(e){r&&(r=!1,n.resolve(e))},function(e){r&&(r=!1,n.reject(e))})}catch(e){r&&(r=!1,this.reject(e))}return}}if(this._state===U){this._state=N,this._value=e;for(var o=this._subscribers;o.length>0;){var a=o.shift();M(a.onfulfill,a.next,e)}}}},reject:{value:function(e){if(this._state===U){this._state=F,this._reason=e;for(var t=this._subscribers;t.length>0;){var r=t.shift();x(r.onreject,r.next,e)}}}},then:{value:function(e,t){"function"!=typeof e&&(e=null),"function"!=typeof t&&(t=null);var n=new r;return this._state===N?M(e,n,this._value):this._state===F?x(t,n,this._reason):this._subscribers.push({onfulfill:e,onreject:t,next:n}),n}},done:{value:function(e,t){this.then(e,t).then(null,function(e){L(function(){throw e})})}},inspect:{value:function(){switch(this._state){case U:return{state:"pending"};case N:return{state:"fulfilled",value:this._value};case F:return{state:"rejected",reason:this._reason}}}},catchError:{value:function(e,t){if("function"==typeof t){var r=this;return this.catch(function(n){if(t(n))return r.catch(e);throw n})}return this.catch(e)}},catch:{value:function(e){return this.then(null,e)}},fail:{value:function(e){this.done(null,e)}},whenComplete:{value:function(e){return this.then(function(t){return e(),t},function(t){throw e(),t})}},complete:{value:function(e){return this.then(e,e)}},always:{value:function(e){this.done(e,e)}},fill:{value:function(e){this.then(e.resolve,e.reject)}},timeout:{value:function(e,t){var n=new r,i=D(function(){n.reject(t||new q("timeout"))},e);return this.whenComplete(function(){z(i)}).fill(n),n}},delay:{value:function(e){var t=new r;return this.then(function(r){D(function(){t.resolve(r)},e)},t.reject),t}},tap:{value:function(e,t){return this.then(function(r){return e.call(t,r),r})}},spread:{value:function(e,t){return this.then(function(r){return e.apply(t,r)})}},get:{value:function(e){return this.then(function(t){return t[e]})}},set:{value:function(e,t){return this.then(function(r){return r[e]=t,r})}},apply:{value:function(e,t){return t=t||[],this.then(function(r){return h(t).then(function(t){return r[e].apply(r,t)})})}},call:{value:function(e){var t=Array.slice(arguments,1);return this.then(function(r){return h(t).then(function(t){return r[e].apply(r,t)})})}},bind:{value:function(e){var t=Array.slice(arguments);{if(!Array.isArray(e)){t.shift();var r=this;return Object.defineProperty(this,e,{value:function(){var n=Array.slice(arguments);return r.then(function(r){return h(t.concat(n)).then(function(t){return r[e].apply(r,t)})})}}),this}for(var n=0,i=e.length;n1?j(this,e,t):j(this,e)}},reduceRight:{value:function(e,t){return arguments.length>1?B(this,e,t):B(this,e)}},indexOf:{value:function(e,t){return E(this,e,t)}},lastIndexOf:{value:function(e,t){return A(this,e,t)}},includes:{value:function(e,t){return k(this,e,t)}},find:{value:function(e,t){return C(this,e,t)}},findIndex:{value:function(e,t){return I(this,e,t)}}}),e.hprose.Future=r,e.hprose.Completer=P,e.hprose.resolved=u,e.hprose.rejected=s,e.hprose.deferred=function(){var e=new r;return Object.create(null,{promise:{value:e},resolve:{value:e.resolve},reject:{value:e.reject}})},W||(e.Promise=function(e){r.call(this),e(this.resolve,this.reject)},e.Promise.prototype=Object.create(r.prototype),e.Promise.prototype.constructor=r,Object.defineProperties(e.Promise,{all:{value:h},race:{value:g},resolve:{value:u},reject:{value:s}}))}(this),function(e,t){"use strict";function r(e,t,r){return e[t++]=r>>>24&255,e[t++]=r>>>16&255,e[t++]=r>>>8&255,e[t++]=255&r,t}function n(e,t,r){return e[t++]=255&r,e[t++]=r>>>8&255,e[t++]=r>>>16&255,e[t++]=r>>>24&255,t}function i(e,t,r){for(var n=r.length,i=0;i>6,e[t++]=128|63&o;else{if(!(o<55296||o>57343)){if(i+1>18,e[t++]=128|s>>12&63,e[t++]=128|s>>6&63,e[t++]=128|63&s,++i;continue}}throw new Error("Malformed string")}e[t++]=224|o>>12,e[t++]=128|o>>6&63,e[t++]=128|63&o}}return t}function o(e,t){for(var r=new Array(t),n=0,i=0,o=e.length;n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r[n]=a;break;case 12:case 13:if(!(i>10&1023|55296,r[n]=1023&s|56320;break;default:throw new Error("Bad UTF-8 encoding 0x"+a.toString(16))}}return n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n[i]=s;break;case 12:case 13:if(!(o>10&1023|55296,n[i]=1023&u|56320;break;default:throw new Error("Bad UTF-8 encoding 0x"+s.toString(16))}if(i>=65534){var c=i+1;n.length=c,r.push(String.fromCharCode.apply(String,n)),t-=c,i=-1}}return i>0&&(n.length=i,r.push(String.fromCharCode.apply(String,n))),[r.join(""),o]}function s(e,r){return(r===t||null===r||r<0)&&(r=e.length),0===r?["",0]:r<1e5?o(e,r):a(e,r)}function u(e,r){if(r===t&&(r=e.length),0===r)return[p,0];for(var n=0,i=0,o=e.length;n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break;case 12:case 13:if(!(i>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1}function f(){var e=arguments;switch(e.length){case 1:switch(e[0].constructor){case Uint8Array:this._bytes=e[0],this._length=e[0].length;break;case f:this._bytes=e[0].toBytes(),this._length=e[0].length;break;case String:this.writeString(e[0]);break;case Number:this._bytes=new Uint8Array(e[0]);break;default:this._bytes=new Uint8Array(e[0]),this._length=this._bytes.length}break;case 2:this._bytes=new Uint8Array(e[0],e[1]),this._length=e[1];break;case 3:this._bytes=new Uint8Array(e[0],e[1],e[2]),this._length=e[2]}this.mark()}function l(e){if(0===e.length)return"";switch(e.constructor){case String:return e;case f:e=e.bytes;case ArrayBuffer:e=new Uint8Array(e);case Uint8Array:return s(e,e.length)[0];default:return String.fromCharCode.apply(String,e)}}var h=e.hprose.toBinaryString,p=new Uint8Array(0),g=1024;Object.defineProperties(f.prototype,{_bytes:{value:null,writable:!0},_length:{value:0,writable:!0},_wmark:{value:0,writable:!0},_off:{value:0,writable:!0},_rmark:{value:0,writable:!0},_grow:{value:function(e){var t=this._bytes,r=this._length+e,n=c(r);if(t){if(n*=2,n>t.length){var i=new Uint8Array(n);i.set(t),this._bytes=i}}else n=Math.max(n,g),this._bytes=new Uint8Array(n)}},length:{get:function(){return this._length}},capacity:{get:function(){return this._bytes?this._bytes.length:0}},position:{get:function(){return this._off}},bytes:{get:function(){return null===this._bytes?p:this._bytes.subarray(0,this._length)}},buffer:{get:function(){if(null===this._bytes)return p.buffer;if(this._bytes.buffer.slice)return this._bytes.buffer.slice(0,this._length);var e=new Uint8Array(this._length);return e.set(this._bytes.subarray(0,this._length)),e.buffer}},mark:{value:function(){this._wmark=this._length,this._rmark=this._off}},reset:{value:function(){this._length=this._wmark,this._off=this._rmark}},clear:{value:function(){this._bytes=null,this._length=0,this._wmark=0,this._off=0,this._rmark=0}},writeByte:{value:function(e){this._grow(1),this._bytes[this._length++]=e}},writeInt32BE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=r(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32BE:{value:function(e){if((2147483647&e)+2147483648===e&&e>=0)return this._grow(4),void(this._length=r(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},writeInt32LE:{value:function(e){if(e===(0|e)&&e<=2147483647)return this._grow(4),void(this._length=n(this._bytes,this._length,e));throw new TypeError("value is out of bounds")}},writeUInt32LE:{value:function(e){if((2147483647&e)+2147483648===e&&e>=0)return this._grow(4),void(this._length=n(this._bytes,this._length,0|e));throw new TypeError("value is out of bounds")}},write:{value:function(e){var t=e.byteLength||e.length;if(0!==t){this._grow(t);var r=this._bytes,n=this._length;switch(e.constructor){case ArrayBuffer:r.set(new Uint8Array(e),n);break;case Uint8Array:r.set(e,n);break;case f:r.set(e.bytes,n);break;default:for(var i=0;ithis._length&&(e=this._length-this._off),0===e?p:this._bytes.subarray(this._off,this._off+=e)}},skip:{value:function(e){return this._off+e>this._length?(e=this._length-this._off,this._off=this._length):this._off+=e,e}},readBytes:{value:function(e){var t,r=Array.indexOf(this._bytes,e,this._off);return r===-1?(t=this._bytes.subarray(this._off,this._length),this._off=this._length):(t=this._bytes.subarray(this._off,r+1),this._off=r+1),t}},readUntil:{value:function(e){var t=Array.indexOf(this._bytes,e,this._off),r="";return t===this._off?this._off++:t===-1?(r=s(this._bytes.subarray(this._off,this._length))[0],this._off=this._length):(r=s(this._bytes.subarray(this._off,t))[0],this._off=t+1),r}},readAsciiString:{value:function(e){return this._off+e>this._length&&(e=this._length-this._off),0===e?"":h(this._bytes.subarray(this._off,this._off+=e))}},readStringAsBytes:{value:function(e){var t=u(this._bytes.subarray(this._off,this._length),e);return this._off+=t[1],t[0]}},readString:{value:function(e){var t=s(this._bytes.subarray(this._off,this._length),e);return this._off+=t[1],t[0]}},takeBytes:{value:function(){var e=this.bytes;return this.clear(),e}},toBytes:{value:function(){return new Uint8Array(this.bytes)}},toString:{value:function(){return s(this.bytes,this._length)[0]}},clone:{value:function(){return new f(this.toBytes())}},trunc:{value:function(){this._bytes=this._bytes.subarray(this._off,this._length),this._length=this._bytes.length,this._off=0,this._wmark=0,this._rmark=0}}}),Object.defineProperty(f,"toString",{value:l}),e.hprose.BytesIO=f}(this),function(e){"use strict";e.hprose.Tags={TagInteger:105,TagLong:108,TagDouble:100,TagNull:110,TagEmpty:101,TagTrue:116,TagFalse:102,TagNaN:78,TagInfinity:73,TagDate:68,TagTime:84,TagUTC:90,TagBytes:98,TagUTF8Char:117,TagString:115,TagGuid:103,TagList:97,TagMap:109,TagClass:99,TagObject:111,TagRef:114,TagPos:43,TagNeg:45,TagSemicolon:59,TagOpenbrace:123,TagClosebrace:125,TagQuote:34,TagPoint:46,TagFunctions:70,TagCall:67,TagResult:82,TagArgument:65,TagError:69,TagEnd:122}}(this),function(e){"use strict";function t(e,t){a.set(e,t),o[t]=e}function r(e){return a.get(e)}function n(e){return o[e]}var i=e.WeakMap,o=Object.create(null),a=new i;e.hprose.ClassManager=Object.create(null,{register:{value:t},getClassAlias:{value:r},getClass:{value:n}}),e.hprose.register=t,t(Object,"Object")}(this),function(e,t){"use strict";function r(e){var t=e.constructor,r=B.getClassAlias(t);if(r)return r;if(t.name)r=t.name;else{var n=t.toString();if(r=n.substr(0,n.indexOf("(")).replace(/(^\s*function\s*)|(\s*$)/gi,""),""===r||"Object"===r)return"function"==typeof e.getClassName?e.getClassName():"Object"}return"Object"!==r&&B.register(t,r),r}function n(e){Object.defineProperties(this,{_stream:{value:e},_ref:{value:new O,writable:!0}})}function i(e){return new n(e)}function o(e,t){Object.defineProperties(this,{stream:{value:e},_classref:{value:Object.create(null),writable:!0},_fieldsref:{value:[],writable:!0},_refer:{value:t?E:i(e)}})}function a(e,n){var i=e.stream;if(n===t||null===n)return void i.writeByte(j.TagNull);switch(n.constructor){case Function:return void i.writeByte(j.TagNull);case Number:return void s(e,n);case Boolean:return void f(e,n);case String:switch(n.length){case 0:return void i.writeByte(j.TagEmpty);case 1:return i.writeByte(j.TagUTF8Char),void i.writeString(n)}return void e.writeStringWithRef(n);case Date:return void e.writeDateWithRef(n);case O:return void e.writeMapWithRef(n);case ArrayBuffer:case Uint8Array:case S:
return void e.writeBytesWithRef(n);case Int8Array:case Int16Array:case Int32Array:case Uint16Array:case Uint32Array:return void y(e,n);case Float32Array:case Float64Array:return void w(e,n);default:if(Array.isArray(n))e.writeListWithRef(n);else{var o=r(n);"Object"===o?e.writeMapWithRef(n):e.writeObjectWithRef(n)}}}function s(e,t){var r=e.stream;t=t.valueOf(),t===(0|t)?0<=t&&t<=9?r.writeByte(t+48):(r.writeByte(j.TagInteger),r.writeAsciiString(""+t),r.writeByte(j.TagSemicolon)):isNaN(t)?r.writeByte(j.TagNaN):isFinite(t)?(r.writeByte(j.TagDouble),r.writeAsciiString(""+t),r.writeByte(j.TagSemicolon)):(r.writeByte(j.TagInfinity),r.writeByte(t>0?j.TagPos:j.TagNeg))}function u(e,t){var r=e.stream;0<=t&&t<=9?r.writeByte(t+48):(t<-2147483648||t>2147483647?r.writeByte(j.TagLong):r.writeByte(j.TagInteger),r.writeAsciiString(""+t),r.writeByte(j.TagSemicolon))}function c(e,t){var r=e.stream;isNaN(t)?r.writeByte(j.TagNaN):isFinite(t)?(r.writeByte(j.TagDouble),r.writeAsciiString(""+t),r.writeByte(j.TagSemicolon)):(r.writeByte(j.TagInfinity),r.writeByte(t>0?j.TagPos:j.TagNeg))}function f(e,t){e.stream.writeByte(t.valueOf()?j.TagTrue:j.TagFalse)}function l(e,t){e._refer.set(t);var r=e.stream,n=("0000"+t.getUTCFullYear()).slice(-4),i=("00"+(t.getUTCMonth()+1)).slice(-2),o=("00"+t.getUTCDate()).slice(-2),a=("00"+t.getUTCHours()).slice(-2),s=("00"+t.getUTCMinutes()).slice(-2),u=("00"+t.getUTCSeconds()).slice(-2),c=("000"+t.getUTCMilliseconds()).slice(-3);r.writeByte(j.TagDate),r.writeAsciiString(n+i+o),r.writeByte(j.TagTime),r.writeAsciiString(a+s+u),"000"!==c&&(r.writeByte(j.TagPoint),r.writeAsciiString(c)),r.writeByte(j.TagUTC)}function h(e,t){e._refer.set(t);var r=e.stream,n=("0000"+t.getFullYear()).slice(-4),i=("00"+(t.getMonth()+1)).slice(-2),o=("00"+t.getDate()).slice(-2),a=("00"+t.getHours()).slice(-2),s=("00"+t.getMinutes()).slice(-2),u=("00"+t.getSeconds()).slice(-2),c=("000"+t.getMilliseconds()).slice(-3);"00"===a&&"00"===s&&"00"===u&&"000"===c?(r.writeByte(j.TagDate),r.writeAsciiString(n+i+o)):"1970"===n&&"01"===i&&"01"===o?(r.writeByte(j.TagTime),r.writeAsciiString(a+s+u),"000"!==c&&(r.writeByte(j.TagPoint),r.writeAsciiString(c))):(r.writeByte(j.TagDate),r.writeAsciiString(n+i+o),r.writeByte(j.TagTime),r.writeAsciiString(a+s+u),"000"!==c&&(r.writeByte(j.TagPoint),r.writeAsciiString(c))),r.writeByte(j.TagSemicolon)}function p(e,t){e._refer.set(t);var r=e.stream,n=("00"+t.getHours()).slice(-2),i=("00"+t.getMinutes()).slice(-2),o=("00"+t.getSeconds()).slice(-2),a=("000"+t.getMilliseconds()).slice(-3);r.writeByte(j.TagTime),r.writeAsciiString(n+i+o),"000"!==a&&(r.writeByte(j.TagPoint),r.writeAsciiString(a)),r.writeByte(j.TagSemicolon)}function g(e,t){e._refer.set(t);var r=e.stream;r.writeByte(j.TagBytes);var n=t.byteLength||t.length;n>0?(r.writeAsciiString(""+n),r.writeByte(j.TagQuote),r.write(t)):r.writeByte(j.TagQuote),r.writeByte(j.TagQuote)}function v(e,t){e._refer.set(t);var r=e.stream,n=t.length;r.writeByte(j.TagString),n>0?(r.writeAsciiString(""+n),r.writeByte(j.TagQuote),r.writeString(t)):r.writeByte(j.TagQuote),r.writeByte(j.TagQuote)}function d(e,t,r){e._refer.set(t);var n=e.stream,i=t.length;if(n.writeByte(j.TagList),i>0){n.writeAsciiString(""+i),n.writeByte(j.TagOpenbrace);for(var o=0;o0){r.writeAsciiString(""+o),r.writeByte(j.TagOpenbrace);for(var s=0;s0?(r.writeAsciiString(""+n),r.writeByte(j.TagOpenbrace),t.forEach(function(t,r){a(e,r),a(e,t)})):r.writeByte(j.TagOpenbrace),r.writeByte(j.TagClosebrace)}function T(e,t){var n,i,o=e.stream,s=r(t);if(s in e._classref)i=e._classref[s],n=e._fieldsref[i];else{n=[];for(var u in t)t.hasOwnProperty(u)&&"function"!=typeof t[u]&&(n[n.length]=u.toString());i=_(e,s,n)}o.writeByte(j.TagObject),o.writeAsciiString(""+i),o.writeByte(j.TagOpenbrace),e._refer.set(t);for(var c=n.length,f=0;f0){n.writeAsciiString(""+i),n.writeByte(j.TagOpenbrace);for(var o=0;o=0;)r[r.length]=n,n=e.indexOf("_",n+1);if(r.length>0){var i=e.split("");if(t=y(i,r,0,"."),null===t&&(t=y(i,r,0,"_")),"function"==typeof t)return te.register(t,e),t}return t=function(){},Object.defineProperty(t.prototype,"getClassName",{value:function(){return e}}),te.register(t,e),t}function m(e,t){var r=e.readUntil(t);return 0===r.length?0:parseInt(r,10)}function b(e){var t=e.stream,n=t.readByte();switch(n){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return n-48;case ee.TagInteger:return T(t);case ee.TagLong:return O(t);case ee.TagDouble:return j(t);case ee.TagNull:return null;case ee.TagEmpty:return"";case ee.TagTrue:return!0;case ee.TagFalse:return!1;case ee.TagNaN:return NaN;case ee.TagInfinity:return E(t);case ee.TagDate:return k(e);case ee.TagTime:return I(e);case ee.TagBytes:return M(e);case ee.TagUTF8Char:return P(e);case ee.TagString:return N(e);case ee.TagGuid:return W(e);case ee.TagList:return D(e);case ee.TagMap:return e.useHarmonyMap?Q(e):q(e);case ee.TagClass:return $(e),J(e);case ee.TagObject:return Y(e);case ee.TagRef:return K(e);case ee.TagError:throw new Error(F(e));default:r(n)}}function T(e){return m(e,ee.TagSemicolon)}function _(e){var t=e.readByte();switch(t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t-48;case ee.TagInteger:return T(e);default:r(t)}}function O(e){var t=e.readUntil(ee.TagSemicolon),r=parseInt(t,10);return r.toString()===t?r:t}function S(e){var t=e.readByte();switch(t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t-48;case ee.TagInteger:case ee.TagLong:return O(e);default:r(t)}}function j(e){return parseFloat(e.readUntil(ee.TagSemicolon))}function B(e){var t=e.readByte();switch(t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t-48;case ee.TagInteger:case ee.TagLong:case ee.TagDouble:return j(e);case ee.TagNaN:return NaN;case ee.TagInfinity:return E(e);default:r(t)}}function E(e){return e.readByte()===ee.TagNeg?-(1/0):1/0}function A(e){var t=e.readByte();switch(t){case ee.TagTrue:return!0;case ee.TagFalse:return!1;default:r(t)}}function k(e){var t,r=e.stream,n=parseInt(r.readAsciiString(4),10),i=parseInt(r.readAsciiString(2),10)-1,o=parseInt(r.readAsciiString(2),10),a=r.readByte();if(a===ee.TagTime){var s=parseInt(r.readAsciiString(2),10),u=parseInt(r.readAsciiString(2),10),c=parseInt(r.readAsciiString(2),10),f=0;a=r.readByte(),a===ee.TagPoint&&(f=parseInt(r.readAsciiString(3),10),a=r.readByte(),a>=48&&a<=57&&(r.skip(2),a=r.readByte(),a>=48&&a<=57&&(r.skip(2),a=r.readByte()))),t=a===ee.TagUTC?new Date(Date.UTC(n,i,o,s,u,c,f)):new Date(n,i,o,s,u,c,f)}else t=a===ee.TagUTC?new Date(Date.UTC(n,i,o)):new Date(n,i,o);return e.refer.set(t),t}function C(e){var t=e.stream.readByte();switch(t){case ee.TagNull:return null;case ee.TagDate:return k(e);case ee.TagRef:return K(e);default:r(t)}}function I(e){var t,r=e.stream,n=parseInt(r.readAsciiString(2),10),i=parseInt(r.readAsciiString(2),10),o=parseInt(r.readAsciiString(2),10),a=0,s=r.readByte();return s===ee.TagPoint&&(a=parseInt(r.readAsciiString(3),10),s=r.readByte(),s>=48&&s<=57&&(r.skip(2),s=r.readByte(),s>=48&&s<=57&&(r.skip(2),s=r.readByte()))),t=s===ee.TagUTC?new Date(Date.UTC(1970,0,1,n,i,o,a)):new Date(1970,0,1,n,i,o,a),e.refer.set(t),t}function R(e){var t=e.stream.readByte();switch(t){case ee.TagNull:return null;case ee.TagTime:return I(e);case ee.TagRef:return K(e);default:r(t)}}function M(e){var t=e.stream,r=m(t,ee.TagQuote),n=t.read(r);return t.skip(1),e.refer.set(n),n}function x(e){var t=e.stream.readByte();switch(t){case ee.TagNull:return null;case ee.TagEmpty:return new Uint8Array(0);case ee.TagBytes:return M(e);case ee.TagRef:return K(e);default:r(t)}}function P(e){return e.stream.readString(1)}function U(e){var t=e.stream,r=t.readString(m(t,ee.TagQuote));return t.skip(1),r}function N(e){var t=U(e);return e.refer.set(t),t}function F(e){var t=e.stream.readByte();switch(t){case ee.TagNull:return null;case ee.TagEmpty:return"";case ee.TagUTF8Char:return P(e);case ee.TagString:return N(e);case ee.TagRef:return K(e);default:r(t)}}function W(e){var t=e.stream;t.skip(1);var r=t.readAsciiString(36);return t.skip(1),e.refer.set(r),r}function L(e){var t=e.stream.readByte();switch(t){case ee.TagNull:return null;case ee.TagGuid:return W(e);case ee.TagRef:return K(e);default:r(t)}}function D(e){var t=e.stream,r=[];e.refer.set(r);for(var n=m(t,ee.TagOpenbrace),i=0;i=0?n:void r(n,e)}},unserialize:{value:function(){return b(this)}},readInteger:{value:function(){return _(this.stream)}},readLong:{value:function(){return S(this.stream)}},readDouble:{value:function(){return B(this.stream)}},readBoolean:{value:function(){return A(this.stream)}},readDateWithoutTag:{value:function(){return k(this)}},readDate:{value:function(){return C(this)}},readTimeWithoutTag:{value:function(){return I(this)}},readTime:{value:function(){return R(this)}},readBytesWithoutTag:{value:function(){return M(this)}},readBytes:{value:function(){return x(this)}},readStringWithoutTag:{value:function(){return N(this)}},readString:{value:function(){return F(this)}},readGuidWithoutTag:{value:function(){return W(this)}},readGuid:{value:function(){return L(this)}},readListWithoutTag:{value:function(){return D(this)}},readList:{value:function(){return z(this)}},readMapWithoutTag:{value:function(){return this.useHarmonyMap?Q(this):q(this)}},readMap:{value:function(){return this.useHarmonyMap?G(this):H(this)}},readObjectWithoutTag:{value:function(){return Y(this)}},readObject:{value:function(){return J(this)}},reset:{value:function(){this.classref.length=0,this.refer.reset()}}}),e.hprose.Reader=V}(this),function(e){"use strict";function t(e,t){var r=new n,o=new i(r,t);return o.serialize(e),r}function r(e,t,r){return e instanceof n||(e=new n(e)),new o(e,t,r).unserialize()}var n=e.hprose.BytesIO,i=e.hprose.Writer,o=e.hprose.Reader;e.hprose.Formatter={serialize:function(e,r){return t(e,r).bytes},unserialize:r},e.hprose.serialize=t,e.hprose.unserialize=r}(this),function(e){"use strict";e.hprose.ResultMode={Normal:0,Serialized:1,Raw:2,RawWithEndTag:3},e.hprose.Normal=e.hprose.ResultMode.Normal,e.hprose.Serialized=e.hprose.ResultMode.Serialized,e.hprose.Raw=e.hprose.ResultMode.Raw,e.hprose.RawWithEndTag=e.hprose.ResultMode.RawWithEndTag}(this),function(e,t){"use strict";function r(){}function n(n,i,o){function m(e,t){for(var r=0,n=$e.length;r=0;r--)e=$e[r].inputFilter(e,t);return e}function T(e,t){return e=m(e,t),ot(e,t).then(function(e){if(!t.oneway)return b(e,t)})}function _(e,t){return ft.sendAndReceive(e,t)}function O(e,t,r,n){it(e,t).then(r,function(i){j(e,t,r,n)||n(i)})}function S(){var e=Pe.length;if(e>1){var t=Ue+1;t>=e&&(t=0,qe++),Ue=t,xe=Pe[Ue]}else qe++;Je(ft)}function j(t,r,n,i){if(r.failswitch&&S(),r.idempotent&&r.retried5e3&&(o=5e3),o>0?e.setTimeout(function(){O(t,r,n,i)},o):O(t,r,n,i),!0}return!1}function B(e){var t={retry:Le,retried:0,idempotent:!0,failswitch:!0,timeout:We,client:ft,userdata:{}},r=function(t){var r=null;try{var n=new c(t),i=new l(n,(!0)),o=n.readByte();switch(o){case s.TagError:r=new Error(i.readString());break;case s.TagFunctions:var a=i.readList();i.checkTag(s.TagEnd),k(e,a);break;default:r=new Error("Wrong Response:\r\n"+c.toString(t))}}catch(e){r=e}null!==r?Xe.reject(r):Xe.resolve(e)};O(p,t,r,Xe.reject)}function E(e,t){return function(){return Ke?P(e,t,Array.slice(arguments),!0):h.all(arguments).then(function(r){return P(e,t,r,!1)})}}function A(e,r,n,i,o){if(r[i]===t&&(r[i]={},typeof o!==v&&o.constructor!==Object||(o=[o]),Array.isArray(o)))for(var a=0;a0||r.byref)&&(i.reset(),i.writeList(t),r.byref&&i.writeBoolean(!0)),n}function x(e,t,r,n){return He?h.promise(function(i,o){Qe.push({batch:n,name:e,args:t,context:r,resolve:i,reject:o})}):n?L(e,t,r):W(e,t,r)}function P(e,t,r,n){return x(t,r,R(e,t,r,n),n)}function U(e,t,r,n){try{r.onerror?r.onerror(e,t):Ye(e,t),n(t)}catch(e){n(e)}}function N(e,t,r){var n=M(e,t,r);return n.writeByte(s.TagEnd),h.promise(function(e,i){O(n.bytes,r,function(n){if(r.oneway)return void e();var o=null,a=null;try{if(r.mode===u.RawWithEndTag)o=n;else if(r.mode===u.Raw)o=n.subarray(0,n.byteLength-1);else{var f=new c(n),h=new l(f,(!1),r.useHarmonyMap),p=f.readByte();if(p===s.TagResult){if(o=r.mode===u.Serialized?h.readRaw():h.unserialize(),p=f.readByte(),p===s.TagArgument){h.reset();var g=h.readList();C(g,t),p=f.readByte()}}else p===s.TagError&&(a=new Error(h.readString()),p=f.readByte());p!==s.TagEnd&&(a=new Error("Wrong Response:\r\n"+c.toString(n)))}}catch(e){a=e}a?i(a):e(o)},i)})}function F(e){return function(){e&&(He=!1,a(function(e){e.forEach(function(e){"settings"in e?H(e.settings).then(e.resolve,e.reject):x(e.name,e.args,e.context,e.batch).then(e.resolve,e.reject)})},Qe),Qe=[])}}function W(e,t,r){r.sync&&(He=!0);var n=h.promise(function(n,i){rt(e,t,r).then(function(o){try{if(r.onsuccess)try{r.onsuccess(o,t)}catch(t){r.onerror&&r.onerror(e,t),i(t)}n(o)}catch(e){i(e)}},function(t){U(e,t,r,i)})});return n.whenComplete(F(r.sync)),n}function L(e,t,r){return h.promise(function(n,i){Ve.push({args:t,name:e,context:r,resolve:n,reject:i})})}function D(e){var t={timeout:We,retry:Le,retried:0,idempotent:De,failswitch:ze,oneway:!1,sync:!1,client:ft,userdata:{}};for(var r in e)r in t&&(t[r]=e[r]);return t}function z(e,t){var r=e.reduce(function(e,t){return e.write(M(t.name,t.args,t.context)),e},new c);return r.writeByte(s.TagEnd),h.promise(function(n,i){O(r.bytes,t,function(r){if(t.oneway)return void n(e);var o=-1,a=new c(r),f=new l(a,(!1)),h=a.readByte();try{for(;h!==s.TagEnd;){var p=null,g=null,v=e[++o].context.mode;if(v>=u.Raw&&(p=new c),h===s.TagResult){if(v===u.Serialized?p=f.readRaw():v>=u.Raw?(p.writeByte(s.TagResult),p.write(f.readRaw())):(f.useHarmonyMap=e[o].context.useHarmonyMap,f.reset(),p=f.unserialize()),h=a.readByte(),h===s.TagArgument){if(v>=u.Raw)p.writeByte(s.TagArgument),p.write(f.readRaw());else{f.reset();var d=f.readList();C(d,e[o].args)}h=a.readByte()}}else h===s.TagError&&(v>=u.Raw?(p.writeByte(s.TagError),p.write(f.readRaw())):(f.reset(),g=new Error(f.readString())),h=a.readByte());if([s.TagEnd,s.TagResult,s.TagError].indexOf(h)<0)return void i(new Error("Wrong Response:\r\n"+c.toString(r)));v>=u.Raw?(v===u.RawWithEndTag&&p.writeByte(s.TagEnd),e[o].result=p.bytes):e[o].result=p,e[o].error=g}}catch(e){return void i(e)}n(e)},i)})}function q(){Ke=!0}function H(e){if(e=e||{},Ke=!1,He)return h.promise(function(t,r){Qe.push({batch:!0,settings:e,resolve:t,reject:r})});var t=Ve.length;if(0===t)return h.value([]);var r=D(e);r.sync&&(He=!0);var n=Ve;Ve=[];var i=h.promise(function(e,t){nt(n,r).then(function(t){t.forEach(function(e){if(e.error)U(e.name,e.error,e.context,e.reject);else try{if(e.context.onsuccess)try{e.context.onsuccess(e.result,e.args)}catch(t){e.context.onerror&&e.context.onerror(e.name,t),e.reject(t)}e.resolve(e.result)}catch(t){e.reject(t)}delete e.context,delete e.resolve,delete e.reject}),e(t)},function(e){n.forEach(function(t){"reject"in t&&U(t.name,e,t.context,t.reject)}),t(e)})});return i.whenComplete(F(r.sync)),i}function Q(){return Ye}function G(e){typeof e===y&&(Ye=e)}function Y(){return Je}function J(e){typeof e===y&&(Je=e)}function $(){return xe}function K(){return Pe}function V(e){if(typeof e===v)Pe=[e];else{if(!Array.isArray(e))return;Pe=e.slice(0),Pe.sort(function(){return Math.random()-.5})}Ue=0,xe=Pe[Ue]}function X(){return ze}function Z(e){ze=!!e}function ee(){return qe}function te(){return We}function re(e){We="number"==typeof e?0|e:0}function ne(){return Le}function ie(e){Le="number"==typeof e?0|e:0}function oe(){return De}function ae(e){De=!!e}function se(e){tt=!!e}function ue(){return tt}function ce(){return Ne}function fe(e){Ne=!!e}function le(){return Fe}function he(e){Fe=!!e}function pe(){return Ge}function ge(e){Ge=!!e}function ve(){return 0===$e.length?null:1===$e.length?$e[0]:$e.slice()}function de(e){$e.length=0,Array.isArray(e)?e.forEach(function(e){ye(e)}):ye(e)}function ye(e){e&&"function"==typeof e.inputFilter&&"function"==typeof e.outputFilter&&$e.push(e)}function we(e){var t=$e.indexOf(e);return t!==-1&&($e.splice(t,1),!0)}function me(){return $e}function be(e,r,n){n===t&&(typeof r===g&&(n=r,r=!1),r||(typeof e===g?(n=e,e=!1):(e&&e.constructor===Object||Array.isArray(e))&&(r=e,e=!1)));var i=ft;return n&&(i={}),e||xe?(e&&(xe=e),(typeof r===v||r&&r.constructor===Object)&&(r=[r]),Array.isArray(r)?(k(i,r),Xe.resolve(i),i):(a(B,i),Xe)):new Error("You should set server uri first!")}function Te(e,t,n){var i=arguments.length;if(i<1||typeof e!==v)throw new Error("name must be a string");if(1===i&&(t=[]),2===i&&!Array.isArray(t)){var o=[];typeof t!==y&&o.push(r),o.push(t),t=o}if(i>2){typeof n!==y&&t.push(r);for(var a=2;a=0&&(i[o]=i[i.length-1],i.length--),0===i.length&&delete e[t]}}else delete e[t]}function Be(e,r,n){if(typeof e!==v)throw new TypeError("topic name must be a string.");if(r===t||null===r){if(typeof n!==y)return void delete Ze[e];r=n}if(typeof r===y&&(n=r,r=null),null===r)if(null===et){if(Ze[e]){var i=Ze[e];for(r in i)je(i,r,n)}}else et.then(function(t){Be(e,t,n)});else h.isPromise(r)?r.then(function(t){Be(e,t,n)}):je(Ze[e],r,n)}function Ee(){return et}function Ae(){return P(ft,"#",[],!1)}function ke(e){at.push(e),rt=at.reduceRight(function(e,t){return function(r,n,i){return h.sync(function(){return t(r,n,i,e)})}},N)}function Ce(e){st.push(e),nt=st.reduceRight(function(e,t){return function(r,n){return h.sync(function(){return t(r,n,e)})}},z)}function Ie(e){ut.push(e),it=ut.reduceRight(function(e,t){return function(r,n){return h.sync(function(){return t(r,n,e)})}},T)}function Re(e){ct.push(e),ot=ct.reduceRight(function(e,t){return function(r,n){return h.sync(function(){return t(r,n,e)})}},_)}function Me(e){return ke(e),ft}var xe,Pe=[],Ue=-1,Ne=!1,Fe=!1,We=3e4,Le=10,De=!1,ze=!1,qe=0,He=!1,Qe=[],Ge=!1,Ye=r,Je=r,$e=[],Ke=!1,Ve=[],Xe=new h,Ze=Object.create(null),et=null,tt=!0,rt=N,nt=z,it=T,ot=_,at=[],st=[],ut=[],ct=[],ft=this;Ae.sync=!0,Ae.idempotent=!0,Ae.failswitch=!0;var lt=Object.create(null,{begin:{value:q},end:{value:H},use:{value:function(e){return Ce(e),lt}}}),ht=Object.create(null,{use:{value:function(e){return Ie(e),ht}}}),pt=Object.create(null,{use:{value:function(e){return Re(e),pt}}});Object.defineProperties(this,{"#":{value:Ae},onerror:{get:Q,set:G},onfailswitch:{get:Y,set:J},uri:{get:$},uriList:{get:K,set:V},id:{get:Ee},failswitch:{get:X,set:Z},failround:{get:ee},timeout:{get:te,set:re},retry:{get:ne,set:ie},idempotent:{get:oe,set:ae},keepAlive:{get:ue,set:se},byref:{get:ce,set:fe},simple:{get:le,set:he},useHarmonyMap:{get:pe,set:ge},filter:{get:ve,set:de},addFilter:{value:ye},removeFilter:{value:we},filters:{get:me},useService:{value:be},invoke:{value:Te},ready:{value:_e},subscribe:{value:Se},unsubscribe:{value:Be},use:{value:Me},batch:{value:lt},beforeFilter:{value:ht},afterFilter:{value:pt}}),o&&typeof o===w&&["failswitch","timeout","retry","idempotent","keepAlive","byref","simple","useHarmonyMap","filter"].forEach(function(e){e in o&&(ft[e]=o[e])}),n&&(V(n),be(i))}function i(e){var t=document.createElement("a");t.href=e;var r=t.protocol;if("http:"!==r&&"https:"!==r&&"tcp:"!==r&&"tcp4:"!==r&&"tcp6:"!==r&&"tcps:"!==r&&"tcp4s:"!==r&&"tcp6s:"!==r&&"tls:"!==r&&"ws:"!==r&&"wss:"!==r)throw new Error("The "+r+" client isn't implemented.")}function o(t,r,n){try{return e.hprose.HttpClient.create(t,r,n)}catch(e){}try{return e.hprose.TcpClient.create(t,r,n)}catch(e){}try{return e.hprose.WebSocketClient.create(t,r,n)}catch(e){}if("string"==typeof t)i(t);else if(Array.isArray(t))throw t.forEach(function(e){i(e)}),new Error("Not support multiple protocol.");throw new Error("You should set server uri first!")}var a=e.setImmediate,s=e.hprose.Tags,u=e.hprose.ResultMode,c=e.hprose.BytesIO,f=e.hprose.Writer,l=e.hprose.Reader,h=e.hprose.Future,p=new Uint8Array(1);p[0]=s.TagEnd;var g="boolean",v="string",d="number",y="function",w="object";Object.defineProperty(n,"create",{value:o}),e.hprose.Client=n}(this),function(e,t){"use strict";function r(){}function n(i,o,f){function h(e,n){var i=new s,o=new XMLHttpRequest;o.open("POST",O.uri,!0),l&&(o.withCredentials="true"),o.responseType="arraybuffer";for(var a in b)o.setRequestHeader(a,b[a]);if(o.onload=function(){o.onload=r,o.status&&(200===o.status?i.resolve(new Uint8Array(o.response)):i.reject(new Error(o.status+":"+o.statusText)))},o.onerror=function(){i.reject(new Error("error"))},o.upload!==t&&(o.upload.onprogress=T),o.onprogress=_,n.timeout>0&&(i=i.timeout(n.timeout).catchError(function(e){throw o.onload=r,o.onerror=r,o.abort(),e},function(e){return e instanceof c})),e.constructor===String||ArrayBuffer.isView)o.send(e);else if(e.buffer.slice)o.send(e.buffer.slice(0,e.length));else{var u=new Uint8Array(e.length);u.set(e),o.send(u.buffer)}return i}function p(t,r){var n=new s;return e.api.ajax({url:O.uri(),method:"post",data:{body:u.toString(t)},timeout:r.timeout,dataType:"text",headers:b,certificate:O.certificate},function(e,t){e?n.resolve(new u(e).takeBytes()):n.reject(new Error(t.msg))}),n}function g(t,r){var n="undefined"!=typeof e.api&&"undefined"!=typeof e.api.ajax,i=n?p(t,r):h(t,r);return r.oneway&&i.resolve(),i}function v(e){"function"==typeof e&&(T=e)}function d(){return T}function y(e){"function"==typeof e&&(_=e)}function w(){return _}function m(e,t){"content-type"!==e.toLowerCase()&&"content-length"!==e.toLowerCase()&&(t?b[e]=t:delete b[e])}if(this.constructor!==n)return new n(i,o,f);a.call(this,i,o,f);var b=Object.create(null),T=r,_=r,O=this;Object.defineProperties(this,{onprogress:{get:d,set:v},onRequestProgress:{get:d,set:v},onResponseProgress:{get:w,set:y},setHeader:{value:m},sendAndReceive:{value:g}})}function i(e){var t=document.createElement("a");if(t.href=e,"http:"!==t.protocol&&"https:"!==t.protocol)throw new Error("This client desn't support "+t.protocol+" scheme.")}function o(e,t,r){if("string"==typeof e)i(e);else{if(!Array.isArray(e))throw new Error("You should set server uri first!");e.forEach(function(e){i(e)})}return new n(e,t,r)}var a=e.hprose.Client,s=e.hprose.Future,u=e.hprose.BytesIO,c=e.TimeoutError,f=e.location!==t&&"file:"===e.location.protocol,l=!f&&"withCredentials"in new XMLHttpRequest;Object.defineProperty(n,"create",{value:o}),e.hprose.HttpClient=n}(this),function(e,t){"use strict";function r(){}function n(e,i,o){function l(){return m<2147483647?++m:m=0}function h(e,t){var r=new a;r.writeInt32BE(e),t.constructor===String?r.writeString(t):r.write(t);var n=r.bytes;ArrayBuffer.isView?S.send(n):n.buffer.slice?S.send(n.buffer.slice(0,n.length)):S.send(n.buffer);
}function p(e){O.resolve(e)}function g(e){var r=new a(e.data),n=r.readInt32BE(),i=T[n];if(delete T[n],i!==t&&(--b,i.resolve(r.read(r.length-4))),b<100&&_.length>0){++b;var o=_.pop();O.then(function(){h(o[0],o[1])})}0!==b||j.keepAlive||w()}function v(e){T.forEach(function(t,r){t.reject(new Error(e.code+":"+e.reason)),delete T[r]}),b=0,S=null}function d(){O=new u,S=new f(j.uri),S.binaryType="arraybuffer",S.onopen=p,S.onmessage=g,S.onerror=r,S.onclose=v}function y(e,t){null!==S&&S.readyState!==f.CLOSING&&S.readyState!==f.CLOSED||d();var r=l(),n=new u;return T[r]=n,t.timeout>0&&(n=n.timeout(t.timeout).catchError(function(e){throw delete T[r],--b,e},function(e){return e instanceof c})),b<100?(++b,O.then(function(){h(r,e)})):_.push([r,e]),t.oneway&&n.resolve(),n}function w(){null!==S&&(S.onopen=r,S.onmessage=r,S.onclose=r,S.close())}if("undefined"==typeof f)throw new Error("WebSocket is not supported by this browser.");if(this.constructor!==n)return new n(e,i,o);s.call(this,e,i,o);var m=0,b=0,T=[],_=[],O=null,S=null,j=this;Object.defineProperties(this,{sendAndReceive:{value:y},close:{value:w}})}function i(e){var t=document.createElement("a");if(t.href=e,"ws:"!==t.protocol&&"wss:"!==t.protocol)throw new Error("This client desn't support "+t.protocol+" scheme.")}function o(e,t,r){if("string"==typeof e)i(e);else{if(!Array.isArray(e))throw new Error("You should set server uri first!");e.forEach(function(e){i(e)})}return new n(e,t,r)}var a=e.hprose.BytesIO,s=e.hprose.Client,u=e.hprose.Future,c=e.TimeoutError,f=e.WebSocket||e.MozWebSocket;Object.defineProperty(n,"create",{value:o}),e.hprose.WebSocketClient=n}(this),function(e,t){"use strict";function r(){}function n(e){var t=s[e.socketId];t.onreceive(e.data)}function i(e){var t=s[e.socketId];t.onerror(e.resultCode),t.destroy()}function o(){null===u&&(u=e.chrome.sockets.tcp,u.onReceive.addListener(n),u.onReceiveError.addListener(i)),this.socketId=new a,this.connected=!1,this.timeid=t,this.onclose=r,this.onconnect=r,this.onreceive=r,this.onerror=r}var a=e.hprose.Future,s={},u=null;Object.defineProperties(o.prototype,{connect:{value:function(e,t,r){var n=this;u.create({persistent:r&&r.persistent},function(i){r&&("noDelay"in r&&u.setNoDelay(i.socketId,r.noDelay,function(e){e<0&&(n.socketId.reject(e),u.disconnect(i.socketId),u.close(i.socketId),n.onclose())}),"keepAlive"in r&&u.setKeepAlive(i.socketId,r.keepAlive,function(e){e<0&&(n.socketId.reject(e),u.disconnect(i.socketId),u.close(i.socketId),n.onclose())})),r&&r.tls?u.setPaused(i.socketId,!0,function(){u.connect(i.socketId,e,t,function(e){e<0?(n.socketId.reject(e),u.disconnect(i.socketId),u.close(i.socketId),n.onclose()):u.secure(i.socketId,function(t){0!==t?(n.socketId.reject(e),u.disconnect(i.socketId),u.close(i.socketId),n.onclose()):u.setPaused(i.socketId,!1,function(){n.socketId.resolve(i.socketId)})})})}):u.connect(i.socketId,e,t,function(e){e<0?(n.socketId.reject(e),u.disconnect(i.socketId),u.close(i.socketId),n.onclose()):n.socketId.resolve(i.socketId)})}),this.socketId.then(function(e){s[e]=n,n.connected=!0,n.onconnect(e)},function(e){n.onerror(e)})}},send:{value:function(e){var t=this,r=new a;return this.socketId.then(function(n){u.send(n,e,function(e){e.resultCode<0?(t.onerror(e.resultCode),r.reject(e.resultCode),t.destroy()):r.resolve(e.bytesSent)})}),r}},destroy:{value:function(){var e=this;this.connected=!1,this.socketId.then(function(t){u.disconnect(t),u.close(t),delete s[t],e.onclose()})}},ref:{value:function(){this.socketId.then(function(e){u.setPaused(e,!1)})}},unref:{value:function(){this.socketId.then(function(e){u.setPaused(e,!0)})}},clearTimeout:{value:function(){this.timeid!==t&&e.clearTimeout(this.timeid)}},setTimeout:{value:function(t,r){this.clearTimeout(),this.timeid=e.setTimeout(r,t)}}}),e.hprose.ChromeTcpSocket=o}(this),function(e,t){"use strict";function r(){}function n(){null===f&&(f=e.api.require("socketManager")),this.socketId=new i,this.connected=!1,this.timeid=t,this.onclose=r,this.onconnect=r,this.onreceive=r,this.onerror=r}var i=e.hprose.Future,o=e.atob,a=e.btoa,s=e.hprose.toUint8Array,u=e.hprose.toBinaryString,c={},f=null;Object.defineProperties(n.prototype,{connect:{value:function(e,t,r){var n=this;f.createSocket({type:"tcp",host:e,port:t,timeout:r.timeout,returnBase64:!0},function(e){if(e)switch(e.state){case 101:break;case 102:n.socketId.resolve(e.sid);break;case 103:n.onreceive(s(o(e.data.replace(/\s+/g,""))));break;case 201:n.socketId.reject(new Error("Create TCP socket failed"));break;case 202:n.socketId.reject(new Error("TCP connection failed"));break;case 203:n.onclose(),n.onerror(new Error("Abnormal disconnect connection"));break;case 204:n.onclose();break;case 205:n.onclose(),n.onerror(new Error("Unknown error"))}}),this.socketId.then(function(e){c[e]=n,n.connected=!0,n.onconnect(e)},function(e){n.onerror(e)})}},send:{value:function(e){var t=this,r=new i;return this.socketId.then(function(n){f.write({sid:n,data:a(u(e)),base64:!0},function(e,n){e.status?r.resolve():(t.onerror(new Error(n.msg)),r.reject(n.msg),t.destroy())})}),r}},destroy:{value:function(){var e=this;this.connected=!1,this.socketId.then(function(t){f.closeSocket({sid:t},function(t,r){t.status||e.onerror(new Error(r.msg))}),delete c[t]})}},ref:{value:r},unref:{value:r},clearTimeout:{value:function(){this.timeid!==t&&e.clearTimeout(this.timeid)}},setTimeout:{value:function(t,r){this.clearTimeout(),this.timeid=e.setTimeout(r,t)}}}),e.hprose.APICloudTcpSocket=n}(this),function(e,t){"use strict";function r(){}function n(e,t){e.onreceive=function(r){"receiveEntry"in e||(e.receiveEntry={stream:new p,headerLength:4,dataLength:-1,id:null});var n=e.receiveEntry,i=n.stream,o=n.headerLength,a=n.dataLength,s=n.id;for(i.write(r);;){if(a<0&&i.length>=o&&(a=i.readInt32BE(),0!==(2147483648&a)&&(a&=2147483647,o=8)),8===o&&null===s&&i.length>=o&&(s=i.readInt32BE()),!(a>=0&&i.length-o>=a))break;t(i.read(a),s),o=4,s=null,i.trunc(),a=-1}n.stream=i,n.headerLength=o,n.dataLength=a,n.id=s}}function i(e){e&&(this.client=e,this.uri=this.client.uri,this.size=0,this.pool=[],this.requests=[])}function o(e){i.call(this,e)}function a(e){i.call(this,e)}function s(e,t,r){function n(){return w}function i(e){w=!!e}function u(){return m}function c(e){m=!!e}function f(){return b}function l(e){"number"==typeof e?(b=0|e,b<1&&(b=10)):b=10}function p(){return T}function v(e){T="number"==typeof e?0|e:0}function d(e,t){var r=new g;return m?(null!==_&&_.uri===y.uri||(_=new o(y)),_.sendAndReceive(e,r,t)):(null!==O&&O.uri===y.uri||(O=new a(y)),O.sendAndReceive(e,r,t)),t.oneway&&r.resolve(),r}if(this.constructor!==s)return new s(e,t,r);h.call(this,e,t,r);var y=this,w=!0,m=!1,b=10,T=3e4,_=null,O=null;Object.defineProperties(this,{noDelay:{get:n,set:i},fullDuplex:{get:u,set:c},maxPoolSize:{get:f,set:l},poolTimeout:{get:p,set:v},sendAndReceive:{value:d}})}function u(e){var t=document.createElement("a");t.href=e;var r=t.protocol;if("tcp:"!==r&&"tcp4:"!==r&&"tcp6:"!==r&&"tcps:"!==r&&"tcp4s:"!==r&&"tcp6s:"!==r&&"tls:"!==r)throw new Error("This client desn't support "+r+" scheme.")}function c(e,t,r){if("string"==typeof e)u(e);else{if(!Array.isArray(e))throw new Error("You should set server uri first!");e.forEach(function(e){u(e)})}return new s(e,t,r)}var f=e.hprose.ChromeTcpSocket,l=e.hprose.APICloudTcpSocket,h=e.hprose.Client,p=e.hprose.BytesIO,g=e.hprose.Future,v=e.TimeoutError;Object.defineProperties(i.prototype,{create:{value:function(){var t=document.createElement("a");t.href=this.uri;var r=t.protocol;t.protocol="http:";var n,i=t.hostname,o=parseInt(t.port,10);if("tcp:"===r||"tcp4:"===r||"tcp6:"===r)n=!1;else{if("tcps:"!==r&&"tcp4s:"!==r&&"tcp6s:"!==r&&"tls:"!==r)throw new Error("Unsupported "+r+" protocol!");n=!0}var a;if(e.chrome&&e.chrome.sockets&&e.chrome.sockets.tcp)a=new f;else{if(!e.api||!e.api.require)throw new Error("TCP Socket is not supported by this browser or platform.");a=new l}var s=this;return a.connect(i,o,{persistent:!0,tls:n,timeout:this.client.timeout,noDelay:this.client.noDelay,keepAlive:this.client.keepAlive}),a.onclose=function(){--s.size},++this.size,a}}}),o.prototype=Object.create(i.prototype,{fetch:{value:function(){for(var e=this.pool;e.length>0;){var t=e.pop();if(t.connected)return 0===t.count&&(t.clearTimeout(),t.ref()),t}return null}},init:{value:function(e){var t=this;e.count=0,e.futures={},e.timeoutIds={},n(e,function(r,n){var i=e.futures[n];i&&(t.clean(e,n),0===e.count&&t.recycle(e),i.resolve(r))}),e.onerror=function(r){var n=e.futures;for(var i in n){var o=n[i];t.clean(e,i),o.reject(r)}}}},recycle:{value:function(e){e.unref(),e.setTimeout(this.client.poolTimeout,function(){e.destroy()})}},clean:{value:function(r,n){r.timeoutIds[n]!==t&&(e.clearTimeout(r.timeoutIds[n]),delete r.timeoutIds[n]),delete r.futures[n],--r.count,this.sendNext(r)}},sendNext:{value:function(e){if(e.count<10)if(this.requests.length>0){var t=this.requests.pop();t.push(e),this.send.apply(this,t)}else this.pool.lastIndexOf(e)<0&&this.pool.push(e)}},send:{value:function(t,r,n,i,o){var a=this,s=i.timeout;s>0&&(o.timeoutIds[n]=e.setTimeout(function(){a.clean(o,n),0===o.count&&a.recycle(o),r.reject(new v("timeout"))},s)),o.count++,o.futures[n]=r;var u=t.length,c=new p(8+u);c.writeInt32BE(2147483648|u),c.writeInt32BE(n),c.write(t),o.send(c.buffer).then(function(){a.sendNext(o)})}},getNextId:{value:function(){return this.nextid<2147483647?++this.nextid:this.nextid=0}},sendAndReceive:{value:function(e,t,r){var n=this.fetch(),i=this.getNextId();if(n)this.send(e,t,i,r,n);else if(this.size0;){var t=e.pop();if(t.connected)return t.clearTimeout(),t.ref(),t}return null}},recycle:{value:function(e){this.pool.lastIndexOf(e)<0&&(e.unref(),e.setTimeout(this.client.poolTimeout,function(){e.destroy()}),this.pool.push(e))}},clean:{value:function(n){n.onreceive=r,n.onerror=r,n.timeoutId!==t&&(e.clearTimeout(n.timeoutId),delete n.timeoutId)}},sendNext:{value:function(e){if(this.requests.length>0){var t=this.requests.pop();t.push(e),this.send.apply(this,t)}else this.recycle(e)}},send:{value:function(t,r,i,o){var a=this,s=i.timeout;s>0&&(o.timeoutId=e.setTimeout(function(){a.clean(o),a.recycle(o),r.reject(new v("timeout"))},s)),n(o,function(e){a.clean(o),a.sendNext(o),r.resolve(e)}),o.onerror=function(e){a.clean(o),r.reject(e)};var u=t.length,c=new p(4+u);c.writeInt32BE(u),c.write(t),o.send(c.buffer)}},sendAndReceive:{value:function(e,t,r){var n=this.fetch();if(n)this.send(e,t,r,n);else if(this.size1?a.stringify(t):a.stringify(t[0])},e.hprose.JSONRPCClientFilter=t}(this),function(e){"use strict";e.hprose.common={Completer:e.hprose.Completer,Future:e.hprose.Future,ResultMode:e.hprose.ResultMode},e.hprose.io={BytesIO:e.hprose.BytesIO,ClassManager:e.hprose.ClassManager,Tags:e.hprose.Tags,RawReader:e.hprose.RawReader,Reader:e.hprose.Reader,Writer:e.hprose.Writer,Formatter:e.hprose.Formatter},e.hprose.client={Client:e.hprose.Client,HttpClient:e.hprose.HttpClient,TcpClient:e.hprose.TcpClient,WebSocketClient:e.hprose.WebSocketClient},e.hprose.filter={JSONRPCClientFilter:e.hprose.JSONRPCClientFilter},"function"==typeof define&&(define.cmd?define("hprose",[],e.hprose):define.amd&&define("hprose",[],function(){return e.hprose})),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=e.hprose)}(this);