")},0b?1:a0&&c(a,b,f,d),f}if(_.isObject(a)&&"function"!=typeof a){var g=b&&b.create?b.create({data:a,parent:d}):{};return e(a,g.mapping,g),g}return a}function e(a,b,c){var e=[];for(var f in a){var g=a[f],h=d(g,b?b[f]:null,c);void 0==c[f]?_.isArray(h)?c[f]=ko.observableArray(h):_.isObject(g)?c[f]=h:c[f]=ko.observable(h):_.isFunction(c[f])?c[f](h):c[f]=h,e.push(f)}void 0!==c.__ko_knockmap_keys?c.__ko_knockmap_keys=_.union(c.__ko_knockmap_keys,e):c.__ko_knockmap_keys=e}return{fromJS:function(a,b,c){e(a,b,c)},toJS:function(a){return b(a)},fromJSON:function(a,b,c){this.fromJS(JSON.parse(a),b,c)},toJSON:function(a){var b=this.toJS(a);return JSON.stringify(b)}}}(),function(){function a(a){var b=this;b.name=a.name||"",b.value=a.value,b.template=a.template,b.sortable=a.sortable,b.sortField=a.sortField,b.width=a.width,b.cssClass=ko.observable("")}ko.dataTable={ViewModel:function(b){var c=this;c.sortable=b.sortable||!1,c.loader=b.loader,c.url=b.url||"",c.selectedItem=ko.observableArray(),c.items=ko.observableArray(b.items||[]),c.columns=[];for(var d=0;d0&&b.forEach(function(a){if(-1!=a.indexOf("=")){var b=a.split("=");c[b[0]]=b[1]}}),c};var f=c.varsFromUrl(window.location.hash),g=0,h="";f.page&&(g=parseInt(f.page)-1),c.pageIndex=ko.observable(g),f.search&&(h=f.search),m_site.search(h),c.pageSearch=ko.observable(h),c.oldSearch=ko.observable(h),c.setVarToUrl=function(a,b){var d=window.location.hash.split("?");if(""!=c.url.length&&m_site.currentPath()&&c.url==m_site.currentPath().split("?")[0]){var e=c.varsFromUrl();e[a]=b;var f=[];for(var g in e)g&&e[g]&&f.push(g+"="+e[g]);var h=f.join("&");window.location.hash=d[0]+"?"+h}},c.hashAdder=ko.computed(function(){m_site.search().length>1&&m_site.search()!=c.oldSearch()&&c.pageIndex(0),c.setVarToUrl("page",c.pageIndex()+1),c.setVarToUrl("search",m_site.search())},c),c.pageSize=ko.observable(b.pageSize||10),c.pageRadius=ko.observable(b.pageRadius||2),c.isFirstPage=ko.computed(function(){return 0===c.pageIndex()}),c.isLastPage=ko.computed(function(){return c.pageIndex()===c.totalPages()-1}),c.pages=ko.computed(function(){var a,b,d,e=[];for(a=1;a<=c.totalPages();a++){var f=c.pageIndex()+1,g=c.totalPages(),h=c.pageRadius();b=1==a||a==g?a:f<2*h+1?a<=2*h+1?a:"ellipsis":f>g-2*h?g-2*h<=a?a:"ellipsis":Math.abs(f-a)<=h?a:"ellipsis","ellipsis"==b&&"ellipsis"==d||e.push(b),d=b}return e}),c.prevPage=function(){c.pageIndex()>0&&c.pageIndex(c.pageIndex()-1)},c.nextPage=function(){c.pageIndex() .header:after {content: "";float: right;margin-top: 7px;visibility: hidden;} .sortDown:after { content: "↑" } .sortUp:after {content: "↓"} .selectedItem {background-color: #f5f5f5} '),b.addTemplate=function(a,b){document.write("")},b.addTemplate("ko_table_header",' \x3c!-- ko if: $data.sortable --\x3e \x3c!-- /ko --\x3e \x3c!-- ko ifnot: $data.sortable --\x3e \x3c!-- /ko --\x3e '),b.addTemplate("ko_table_body",' \x3c!-- ko foreach: $parent.columns --\x3e \x3c!-- ko if: template --\x3e \x3c!-- /ko --\x3e \x3c!-- ko ifnot: template --\x3e \x3c!-- /ko --\x3e \x3c!-- /ko --\x3e '),b.addTemplate("ko_table_pager",'
  • \x3c!-- ko foreach: pages() --\x3e \x3c!-- ko if: $data == "ellipsis" --\x3e
  • ...
  • \x3c!-- /ko --\x3e \x3c!-- ko if: $data != "ellipsis" --\x3e
  • \x3c!-- /ko --\x3e \x3c!-- /ko --\x3e
'),ko.bindingHandlers.dataTable={init:function(a,b){var c=$(a).html();if(c.length>10){var d=$(a).attr("id")+"_tpl";if($(a).data("tableBodyTemplate",d),0==$("#"+d).length){var e=$("")[0];$("body").append(e)}}return{controlsDescendantBindings:!0}},update:function(a,c,d){var e=c(),f=d(),g=f.tableHeaderTemplate||"ko_table_header",h=f.tableBodyTemplate||$(a).data("tableBodyTemplate")||"ko_table_body",i=f.tablePagerTemplate||"ko_table_pager",j=$(a).prop("tagName"),k=$(document.createElement(j)).addClass("b-table")[0];$(k).addClass($(a).attr("class"));var l=k.appendChild(document.createElement("DIV"));ko.renderTemplate(g,e,{templateEngine:b},l,"replaceNode");var m=k.appendChild(document.createElement("DIV"));t=ko.renderTemplate(h,e,{templateEngine:b},m,"replaceNode");var n=k.appendChild(document.createElement("DIV"));ko.renderTemplate(i,e,{templateEngine:b},n,"replaceNode"),$(a).replaceWith($(k))}}}(),function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.objectHash=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c||a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=0)return this.dispatch("[CIRCULAR:"+i+"]");if(c.push(b),void 0!==f&&f.isBuffer&&f.isBuffer(b))return d("buffer:"),d(b);if("object"===h||"function"===h){var j=Object.keys(b).sort();!1===a.respectType||o(b)||j.splice(0,0,"prototype","__proto__","constructor"),d("object:"+j.length+":");var k=this;return j.forEach(function(c){k.dispatch(c),d(":"),a.excludeValues||k.dispatch(b[c]),d(",")})}if(!this["_"+h]){if(a.ignoreUnknown)return d("["+h+"]");throw new Error('Unknown object type "'+h+'"')}this["_"+h](b)},_array:function(b,e){e=void 0!==e?e:!1!==a.unorderedArrays;var f=this;if(d("array:"+b.length+":"),!e||b.length<=1)return b.forEach(function(a){return f.dispatch(a)});var g=[],h=b.map(function(b){var d=new r,e=c.slice();return q(a,d,e).dispatch(b),g=g.concat(e.slice(c.length)),d.read().toString()});return c=c.concat(g),h.sort(),this._array(h,!1)},_date:function(a){return d("date:"+a.toJSON())},_symbol:function(a){return d("symbol:"+a.toString())},_error:function(a){return d("error:"+a.toString())},_boolean:function(a){return d("bool:"+a.toString())},_string:function(a){d("string:"+a.length+":"),d(a)},_function:function(b){d("fn:"),o(b)?this.dispatch("[native]"):this.dispatch(b.toString()),!1!==a.respectFunctionNames&&this.dispatch("function-name:"+String(b.name)),a.respectFunctionProperties&&this._object(b)},_number:function(a){return d("number:"+a.toString())},_xml:function(a){return d("xml:"+a.toString())},_null:function(){return d("Null")},_undefined:function(){return d("Undefined")},_regexp:function(a){return d("regex:"+a.toString())},_uint8array:function(a){return d("uint8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint8clampedarray:function(a){return d("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(a))},_int8array:function(a){return d("uint8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint16array:function(a){return d("uint16array:"),this.dispatch(Array.prototype.slice.call(a))},_int16array:function(a){return d("uint16array:"),this.dispatch(Array.prototype.slice.call(a))},_uint32array:function(a){return d("uint32array:"),this.dispatch(Array.prototype.slice.call(a))},_int32array:function(a){return d("uint32array:"),this.dispatch(Array.prototype.slice.call(a))},_float32array:function(a){return d("float32array:"),this.dispatch(Array.prototype.slice.call(a))},_float64array:function(a){return d("float64array:"),this.dispatch(Array.prototype.slice.call(a))},_arraybuffer:function(a){return d("arraybuffer:"),this.dispatch(new Uint8Array(a))},_url:function(a){return d("url:"+a.toString(),"utf8")},_map:function(b){d("map:");var c=Array.from(b);return this._array(c,!1!==a.unorderedSets)},_set:function(b){d("set:");var c=Array.from(b);return this._array(c,!1!==a.unorderedSets)},_blob:function(){if(a.ignoreUnknown)return d("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return d("domwindow")},_process:function(){return d("process")},_timer:function(){return d("timer")},_pipe:function(){return d("pipe")},_tcp:function(){return d("tcp")},_udp:function(){return d("udp")},_tty:function(){return d("tty")},_statwatcher:function(){return d("statwatcher")},_securecontext:function(){return d("securecontext")},_connection:function(){return d("connection")},_zlib:function(){return d("zlib")},_context:function(){return d("context")},_nodescript:function(){return d("nodescript")},_httpparser:function(){return d("httpparser")},_dataview:function(){return d("dataview")},_signal:function(){return d("signal")},_fsevent:function(){return d("fsevent")},_tlswrap:function(){return d("tlswrap")}}}function r(){return{buf:"",write:function(a){this.buf+=a},end:function(a){this.buf+=a},read:function(){return this.buf}}}var s=a("crypto");c=b.exports=m,c.sha1=function(a){return m(a)},c.keys=function(a){return m(a,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},c.MD5=function(a){return m(a,{algorithm:"md5",encoding:"hex"})},c.keysMD5=function(a){return m(a,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var t=s.getHashes?s.getHashes().slice():["sha1","md5"];t.push("passthrough");var u=["buffer","hex","binary","base64"];c.writeToStream=function(a,b,c){return void 0===c&&(c=b,b={}),b=n(a,b),q(b,c).dispatch(a)}}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_8c3adc78.js","/")},{buffer:3,crypto:5,lYpoI2:10}],2:[function(a,b,c){(function(a,b,d,e,f,g,h,i,j){!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===f||b===k?62:b===g||b===l?63:b0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new e(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,f=0;d>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function d(a){function b(a){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var d,e,f,g=a.length%3,h="";for(d=0,f=a.length-g;d>2),h+=b(e<<4&63),h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=b(e>>10),h+=b(e>>4&63),h+=b(e<<2&63),h+="="}return h}var e="undefined"!=typeof Uint8Array?Uint8Array:Array,f="+".charCodeAt(0),g="/".charCodeAt(0),h="0".charCodeAt(0),i="a".charCodeAt(0),j="A".charCodeAt(0),k="-".charCodeAt(0),l="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=d}(void 0===c?this.base64js={}:c)}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:10}],3:[function(a,b,c){(function(b,d,e,f,g,h,i,j,k){function e(a,b,c){if(!(this instanceof e))return new e(a,b,c);var d=typeof a;if("base64"===b&&"string"===d)for(a=J(a);a.length%4!=0;)a+="=";var f;if("number"===d)f=L(a);else if("string"===d)f=e.byteLength(a,b);else{if("object"!==d)throw new Error("First argument needs to be a number, array or string.");f=L(a.length)}var g;e._useTypedArrays?g=e._augment(new Uint8Array(f)):(g=this,g.length=f,g._isBuffer=!0);var h;if(e._useTypedArrays&&"number"==typeof a.byteLength)g._set(a);else if(N(a))for(h=0;hf&&(d=f):d=f;var g=b.length;Y(g%2==0,"Invalid hex string"),d>g/2&&(d=g/2);for(var h=0;hd)&&(c=d);for(var e="",f=b;f=e)){var f;return c?(f=a[b],b+1=e)){var f;return c?(b+2>>0)):(b+1>>0),f}}function z(a,b,c,d){if(d||(Y("boolean"==typeof c,"missing or invalid endian"),Y(void 0!==b&&null!==b,"missing offset"),Y(b+1=a.length)){var e=x(a,b,c,!0);return 32768&e?-1*(65535-e+1):e}}function A(a,b,c,d){if(d||(Y("boolean"==typeof c,"missing or invalid endian"),Y(void 0!==b&&null!==b,"missing offset"),Y(b+3=a.length)){var e=y(a,b,c,!0);return 2147483648&e?-1*(4294967295-e+1):e}}function B(a,b,c,d){return d||(Y("boolean"==typeof c,"missing or invalid endian"),Y(b+3=f))for(var g=0,h=Math.min(f-c,2);g>>8*(d?g:1-g)}function E(a,b,c,d,e){e||(Y(void 0!==b&&null!==b,"missing value"),Y("boolean"==typeof d,"missing or invalid endian"),Y(void 0!==c&&null!==c,"missing offset"),Y(c+3=f))for(var g=0,h=Math.min(f-c,4);g>>8*(d?g:3-g)&255}function F(a,b,c,d,e){e||(Y(void 0!==b&&null!==b,"missing value"),Y("boolean"==typeof d,"missing or invalid endian"),Y(void 0!==c&&null!==c,"missing offset"),Y(c+1=a.length||(b>=0?D(a,b,c,d,e):D(a,65535+b+1,c,d,e))}function G(a,b,c,d,e){e||(Y(void 0!==b&&null!==b,"missing value"),Y("boolean"==typeof d,"missing or invalid endian"),Y(void 0!==c&&null!==c,"missing offset"),Y(c+3=a.length||(b>=0?E(a,b,c,d,e):E(a,4294967295+b+1,c,d,e))}function H(a,b,c,d,e){e||(Y(void 0!==b&&null!==b,"missing value"),Y("boolean"==typeof d,"missing or invalid endian"),Y(void 0!==c&&null!==c,"missing offset"),Y(c+3=a.length||$.write(a,b,c,d,23,4)}function I(a,b,c,d,e){e||(Y(void 0!==b&&null!==b,"missing value"),Y("boolean"==typeof d,"missing or invalid endian"),Y(void 0!==c&&null!==c,"missing offset"),Y(c+7=a.length||$.write(a,b,c,d,52,8)}function J(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function K(a,b,c){return"number"!=typeof a?c:(a=~~a,a>=b?b:a>=0?a:(a+=b,a>=0?a:0))}function L(a){return a=~~Math.ceil(+a),a<0?0:a}function M(a){return(Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)})(a)}function N(a){return M(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function O(a){return a<16?"0"+a.toString(16):a.toString(16)}function P(a){for(var b=[],c=0;c=55296&&d<=57343&&c++;for(var f=encodeURIComponent(a.slice(e,c+1)).substr(1).split("%"),g=0;g>8,d=b%256,e.push(d),e.push(c);return e}function S(a){return Z.toByteArray(a)}function T(a,b,c,d){for(var e=0;e=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function U(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function V(a,b){Y("number"==typeof a,"cannot write a non-number as a number"),Y(a>=0,"specified a negative value for writing an unsigned value"),Y(a<=b,"value is larger than maximum value for type"),Y(Math.floor(a)===a,"value has a fractional component")}function W(a,b,c){Y("number"==typeof a,"cannot write a non-number as a number"),Y(a<=b,"value larger than maximum allowed value"),Y(a>=c,"value smaller than minimum allowed value"),Y(Math.floor(a)===a,"value has a fractional component")}function X(a,b,c){Y("number"==typeof a,"cannot write a non-number as a number"),Y(a<=b,"value larger than maximum allowed value"),Y(a>=c,"value smaller than minimum allowed value")}function Y(a,b){if(!a)throw new Error(b||"Failed assertion")}var Z=a("base64-js"),$=a("ieee754");c.Buffer=e,c.SlowBuffer=e,c.INSPECT_MAX_BYTES=50,e.poolSize=8192,e._useTypedArrays=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray}catch(c){return!1}}(),e.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},e.isBuffer=function(a){return!(null===a||void 0===a||!a._isBuffer)},e.byteLength=function(a,b){var c;switch(a+="",b||"utf8"){case"hex":c=a.length/2;break;case"utf8":case"utf-8":c=P(a).length;break;case"ascii":case"binary":case"raw":c=a.length;break;case"base64":c=S(a).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":c=2*a.length;break;default:throw new Error("Unknown encoding")}return c},e.concat=function(a,b){if(Y(M(a),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===a.length)return new e(0);if(1===a.length)return a[0];var c;if("number"!=typeof b)for(b=0,c=0;cf&&(c=f):c=f,d=String(d||"utf8").toLowerCase();var g;switch(d){case"hex":g=l(this,a,b,c);break;case"utf8":case"utf-8":g=m(this,a,b,c);break;case"ascii":g=n(this,a,b,c);break;case"binary":g=o(this,a,b,c);break;case"base64":g=p(this,a,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":g=q(this,a,b,c);break;default:throw new Error("Unknown encoding")}return g},e.prototype.toString=function(a,b,c){var d=this;if(a=String(a||"utf8").toLowerCase(),b=Number(b)||0,(c=void 0!==c?Number(c):c=d.length)===b)return"";var e;switch(a){case"hex":e=v(d,b,c);break;case"utf8":case"utf-8":e=s(d,b,c);break;case"ascii":e=t(d,b,c);break;case"binary":e=u(d,b,c);break;case"base64":e=r(d,b,c);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=w(d,b,c);break;default:throw new Error("Unknown encoding")}return e},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},e.prototype.copy=function(a,b,c,d){var f=this;if(c||(c=0),d||0===d||(d=this.length),b||(b=0),d!==c&&0!==a.length&&0!==f.length){Y(d>=c,"sourceEnd < sourceStart"),Y(b>=0&&b=0&&c=0&&d<=f.length,"sourceEnd out of bounds"),d>this.length&&(d=this.length),a.length-b=this.length))return this[a]},e.prototype.readUInt16LE=function(a,b){return x(this,a,!0,b)},e.prototype.readUInt16BE=function(a,b){return x(this,a,!1,b)},e.prototype.readUInt32LE=function(a,b){return y(this,a,!0,b)},e.prototype.readUInt32BE=function(a,b){return y(this,a,!1,b)},e.prototype.readInt8=function(a,b){if(b||(Y(void 0!==a&&null!==a,"missing offset"),Y(a=this.length)){return 128&this[a]?-1*(255-this[a]+1):this[a]}},e.prototype.readInt16LE=function(a,b){return z(this,a,!0,b)},e.prototype.readInt16BE=function(a,b){return z(this,a,!1,b)},e.prototype.readInt32LE=function(a,b){return A(this,a,!0,b)},e.prototype.readInt32BE=function(a,b){return A(this,a,!1,b)},e.prototype.readFloatLE=function(a,b){return B(this,a,!0,b)},e.prototype.readFloatBE=function(a,b){return B(this,a,!1,b)},e.prototype.readDoubleLE=function(a,b){return C(this,a,!0,b)},e.prototype.readDoubleBE=function(a,b){return C(this,a,!1,b)},e.prototype.writeUInt8=function(a,b,c){c||(Y(void 0!==a&&null!==a,"missing value"),Y(void 0!==b&&null!==b,"missing offset"),Y(b=this.length||(this[b]=a)},e.prototype.writeUInt16LE=function(a,b,c){D(this,a,b,!0,c)},e.prototype.writeUInt16BE=function(a,b,c){D(this,a,b,!1,c)},e.prototype.writeUInt32LE=function(a,b,c){E(this,a,b,!0,c)},e.prototype.writeUInt32BE=function(a,b,c){E(this,a,b,!1,c)},e.prototype.writeInt8=function(a,b,c){c||(Y(void 0!==a&&null!==a,"missing value"),Y(void 0!==b&&null!==b,"missing offset"),Y(b=this.length||(a>=0?this.writeUInt8(a,b,c):this.writeUInt8(255+a+1,b,c))},e.prototype.writeInt16LE=function(a,b,c){F(this,a,b,!0,c)},e.prototype.writeInt16BE=function(a,b,c){F(this,a,b,!1,c)},e.prototype.writeInt32LE=function(a,b,c){G(this,a,b,!0,c)},e.prototype.writeInt32BE=function(a,b,c){G(this,a,b,!1,c)},e.prototype.writeFloatLE=function(a,b,c){H(this,a,b,!0,c)},e.prototype.writeFloatBE=function(a,b,c){H(this,a,b,!1,c)},e.prototype.writeDoubleLE=function(a,b,c){I(this,a,b,!0,c)},e.prototype.writeDoubleBE=function(a,b,c){I(this,a,b,!1,c)},e.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),"string"==typeof a&&(a=a.charCodeAt(0)),Y("number"==typeof a&&!isNaN(a),"value is not a number"),Y(c>=b,"end < start"),c!==b&&0!==this.length){Y(b>=0&&b=0&&c<=this.length,"end out of bounds");for(var d=b;d"},e.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(e._useTypedArrays)return new e(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;bu?b=a(b):b.length>5]|=128<>>9<<4)]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;g>16)+(b>>16)+(c>>16)<<16|65535&c}function s(a,b){return a<>>32-b}var t=a("./helpers");b.exports=function(a){return t.hash(a,l,16)}}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:10}],7:[function(a,b,c){(function(a,c,d,e,f,g,h,i,j){!function(){var a,c,d=this;a=function(a){for(var b,b,c=new Array(a),d=0;d>>((3&d)<<3)&255;return c},d.crypto&&crypto.getRandomValues&&(c=function(a){var b=new Uint8Array(a);return crypto.getRandomValues(b),b}),b.exports=c||a}()}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:10}],8:[function(a,b,c){(function(c,d,e,f,g,h,i,j,k){function l(a,b){a[b>>5]|=128<<24-b%32,a[15+(b+64>>9<<4)]=b;for(var c=Array(80),d=1732584193,e=-271733879,f=-1732584194,g=271733878,h=-1009589776,i=0;i>16)+(b>>16)+(c>>16)<<16|65535&c}function p(a,b){return a<>>32-b}var q=a("./helpers");b.exports=function(a){return q.hash(a,l,20,!0)}}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:10}],9:[function(a,b,c){(function(c,d,e,f,g,h,i,j,k){var l=a("./helpers"),m=function(a,b){var c=(65535&a)+(65535&b);return(a>>16)+(b>>16)+(c>>16)<<16|65535&c},n=function(a,b){return a>>>b|a<<32-b},o=function(a,b){return a>>>b},p=function(a,b,c){return a&b^~a&c},q=function(a,b,c){return a&b^a&c^b&c},r=function(a){return n(a,2)^n(a,13)^n(a,22)},s=function(a){return n(a,6)^n(a,11)^n(a,25)},t=function(a){return n(a,7)^n(a,18)^o(a,3)},u=function(a){return n(a,17)^n(a,19)^o(a,10)},v=function(a,b){var c,d,e,f,g,h,i,j,k,l,n,o,v=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),w=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),x=new Array(64);a[b>>5]|=128<<24-b%32,a[15+(b+64>>9<<4)]=b;for(var k=0;k0)){c.shift()()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),a.title="browser",a.browser=!0,a.env={},a.argv=[],a.on=k,a.addListener=k,a.once=k,a.off=k,a.removeListener=k,a.removeAllListeners=k,a.emit=k,a.binding=function(a){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(a){throw new Error("process.chdir is not supported")}}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:10}],11:[function(a,b,c){(function(a,b,d,e,f,g,h,i,j){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=b<0||0===b&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}}).call(this,a("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/ieee754/index.js","/node_modules/ieee754")},{buffer:3,lYpoI2:10}]},{},[1])(1)}),function(a){"undefined"!=typeof localStorage&&(a.extenders.persist=function(b,c){var d=b();if(c&&null!==localStorage.getItem(c))try{d=JSON.parse(localStorage.getItem(c))}catch(e){}return b(d),b.subscribe(function(b){localStorage.setItem(c,a.toJSON(b))}),b})}(ko);var MAX_LIST_SIZE=9007199254740991,commentNodesHaveTextProperty=document&&"\x3c!--test--\x3e"===document.createComment("test").text,startCommentRegex=commentNodesHaveTextProperty?/^$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,supportsDocumentFragment=document&&"function"==typeof document.createDocumentFragment,PENDING_DELETE_INDEX_KEY=createSymbolOrString("_ko_ffe_pending_delete_index");FastForEach.PENDING_DELETE_INDEX_KEY=PENDING_DELETE_INDEX_KEY,FastForEach.animateFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(a,1e3/60)},FastForEach.prototype.dispose=function(){this.changeSubs&&this.changeSubs.dispose(),this.flushPendingDeletes()},FastForEach.prototype.onArrayChange=function(a,b){for(var c=this,d={added:[],deleted:[]},e=0,f=a.length;e0&&(this.changeQueue.push.apply(this.changeQueue,d.deleted),this.changeQueue.push({status:"clearDeletedIndexes"})),this.changeQueue.push.apply(this.changeQueue,d.added),this.changeQueue.length>0&&!this.rendering_queued&&(this.rendering_queued=!0,b?c.processQueue():FastForEach.animateFrame.call(window,function(){c.processQueue()}))},FastForEach.prototype.processQueue=function(){var a=this,b=MAX_LIST_SIZE;"function"==typeof this.beforeQueueFlush&&this.beforeQueueFlush(this.changeQueue),ko.utils.arrayForEach(this.changeQueue,function(c){"number"==typeof c.index&&(b=Math.min(b,c.index)),a[c.status](c)}),this.flushPendingDeletes(),this.rendering_queued=!1,this.noIndex||this.updateIndexes(b),"function"==typeof this.afterQueueFlush&&this.afterQueueFlush(this.changeQueue),this.changeQueue=[]},FastForEach.prototype.added=function(a){for(var b=a.index,c=a.isBatch?a.values:[a.value],d=this.getLastNodeBeforeIndex(b),e=[],f=0,g=c.length;f=this.firstLastNodesList.length?null:this.firstLastNodesList[a-1].last},FastForEach.prototype.insertAllAfter=function(a,b){var c,d,e,f=this.element;if(void 0===a.nodeType&&void 0===a.length)throw new Error("Expected a single node or a node array");if(void 0!==a.nodeType)return ko.virtualElements.insertAfter(f,a,b),[a];if(1===a.length)ko.virtualElements.insertAfter(f,a[0],b);else if(supportsDocumentFragment){for(c=document.createDocumentFragment(),e=0,d=a.length;e!==d;++e)c.appendChild(a[e]);ko.virtualElements.insertAfter(f,c,b)}else for(e=a.length-1;e>=0;--e){var g=a[e];if(!g)break;ko.virtualElements.insertAfter(f,g,b)}return a},FastForEach.prototype.shouldDelayDeletion=function(a){return a&&("object"==typeof a||"function"==typeof a)},FastForEach.prototype.getPendingDeleteFor=function(a){var b=a&&a[PENDING_DELETE_INDEX_KEY];return void 0===b?null:this.pendingDeletes[b]},FastForEach.prototype.getOrCreatePendingDeleteFor=function(a){var b=this.getPendingDeleteFor(a);return b||(b={data:a,nodesets:[]},a[PENDING_DELETE_INDEX_KEY]=this.pendingDeletes.length,this.pendingDeletes.push(b),b)},FastForEach.prototype.deleted=function(a){if(this.shouldDelayDeletion(a.value)){this.getOrCreatePendingDeleteFor(a.value).nodesets.push(this.getNodesForIndex(a.index))}else this.removeNodes(this.getNodesForIndex(a.index));this.indexesToDelete.push(a.index)},FastForEach.prototype.removeNodes=function(a){if(a.length){var b=function(){for(var b=a[0].parentNode,c=a.length-1;c>=0;--c)ko.cleanNode(a[c]),b.removeChild(a[c])};if(this.beforeRemove){var c=this.beforeRemove({nodesToRemove:a,foreachInstance:this})||{};"function"==typeof c.then&&c.then(b,ko.onError?ko.onError:void 0)}else b()}},FastForEach.prototype.flushPendingDeletes=function(){for(var a=0,b=this.pendingDeletes.length;a!=b;++a){for(var c=this.pendingDeletes[a];c.nodesets.length;)this.removeNodes(c.nodesets.pop());c.data&&void 0!==c.data[PENDING_DELETE_INDEX_KEY]&&delete c.data[PENDING_DELETE_INDEX_KEY]}this.pendingDeletes=[]},FastForEach.prototype.clearDeletedIndexes=function(){for(var a=this.indexesToDelete.length-1;a>=0;--a)this.firstLastNodesList.splice(this.indexesToDelete[a],1);this.indexesToDelete=[]},FastForEach.prototype.getContextStartingFrom=function(a){for(var b;a;){if(b=ko.contextFor(a))return b;a=a.nextSibling}},FastForEach.prototype.updateIndexes=function(a){for(var b,c=a,d=this.firstLastNodesList.length;c4&&a}()},m.isInternetExplorer=function(){return m.isInternetExplorer.cached=void 0!==m.isInternetExplorer.cached?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion())},m.options.html4Mode?m.emulated={pushState:!0,hashChange:!0}:m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&"Apple Computer, Inc."===e.vendor&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&"Apple Computer, Inc."===e.vendor&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);return d.location.port&&(a+=":"+d.location.port),a+="/"},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return 1===a.length&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){return m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl()},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||m.getLocationHref();return b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"})},m.getBasePageUrl=function(){return m.getLocationHref().replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/"},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=void 0===b||b,/[a-z]+\:\/\//.test(a)||(c="/"===d?m.getRootUrl()+a.replace(/^\/+/,""):"#"===d?m.getPageUrl().replace(/#.*/,"")+a:"?"===d?m.getPageUrl().replace(/[\?#].*/,"")+a:b?m.getBaseUrl()+a.replace(/^(\.\/)+/,""):m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,"")},m.getLocationHref=function(a){return a=a||d,a.URL===a.location.href?a.location.href:a.location.href===decodeURIComponent(a.URL)?a.URL:a.location.hash&&decodeURIComponent(a.location.href.replace(/^[^#]+/,""))===a.location.hash?a.location.href:-1==a.URL.indexOf("#")&&-1!=a.location.href.indexOf("#")?a.location.href:a.URL||a.location.href},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){void 0===a&&(a=!0),void 0===b&&(b=!0);var c=m.getLastSavedState() ;return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b,c=m.extractId(a.url);if(!c)if(b=m.getStateString(a),void 0!==m.stateToId[b])c=m.stateToId[b];else if(void 0!==m.store.stateToId[b])c=m.store.stateToId[b];else{for(;c=(new Date).getTime()+String(Math.random()).replace(/\D/g,""),void 0!==m.idToState[c]||void 0!==m.store.idToState[c];);m.stateToId[b]=c,m.idToState[c]=a}return c},m.normalizeState=function(a){var b,c;return a&&"object"==typeof a||(a={}),void 0!==a.normalized?a:(a.data&&"object"==typeof a.data||(a.data={}),b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(a.url?a.url:m.getLocationHref()),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data),(b.title||c)&&!0!==m.options.disableSuid&&(b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id),b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b)},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d)},m.getStateById=function(a){return a=String(a),m.idToState[a]||m.store.idToState[a]||b},m.getStateString=function(a){var b,c;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},k.stringify(c)},m.getStateId=function(a){var b;return b=m.normalizeState(a),b.id},m.getHashByState=function(a){var b;return b=m.normalizeState(a),b.hash},m.extractId=function(a){var b,c;return c=-1!=a.indexOf("#")?a.split("#")[0]:a,b=/(.*)\&_suid=([0-9]+)$/.exec(c),b?b[1]||a:a,(b?String(b[2]||""):"")||!1},m.isTraditionalAnchor=function(a){return!/[\/\?\.]/.test(a)},m.extractState=function(a,b){var c,d,e=null;return b=b||!1,c=m.extractId(a),c&&(e=m.getStateById(c)),e||(d=m.getFullUrl(a),c=m.getIdByUrl(d)||!1,c&&(e=m.getStateById(c)),!e&&b&&!m.isTraditionalAnchor(a)&&(e=m.createStateObject(null,null,d))),e},m.getIdByUrl=function(a){return m.urlToId[a]||m.store.urlToId[a]||b},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b;return b=m.extractState(a.url),b&&b.id!==a.id},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b,c,d,e=!1;return m.savedStates.length&&(b=a.id,c=m.getLastSavedState(),d=c.id,e=b===d),e},m.saveState=function(a){return!m.isLastSavedState(a)&&(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){return void 0===a?m.savedStates[m.savedStates.length-1]:a<0?m.savedStates[m.savedStates.length+a]:m.savedStates[a]},m.getCurrentIndex=function(){return m.savedStates.length<1?0:m.savedStates.length-1},m.getHash=function(a){var b=m.getLocationHref(a);return m.getHashByUrl(b)},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=decodeURIComponent(b)},m.normalizeHash=function(a){return a.replace(/[^#]*#/,"").replace(/#.*/,"")},m.setHash=function(a,b){var c,e;return!1!==b&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(m.busy(!0),c=m.extractState(a,!0),c&&!m.emulated.pushState?m.pushState(c.data,c.title,c.url,!1):m.getHash()!==a&&(m.bugs.setHash?(e=m.getPageUrl(),m.pushState(null,null,e+"#"+a,!1)):d.location.hash=a),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.encodeURIComponent(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b)},m.setTitle=function(a){var b,c=a.title;c||(b=m.getStateByIndex(0))&&b.url===a.url&&(c=b.title||m.options.initialTitle);try{d.getElementsByTagName("title")[0].innerHTML=c.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=c,m},m.queues=[],m.busy=function(a){if(void 0!==a?m.busy.flag=a:void 0===m.busy.flag&&(m.busy.flag=!1),!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(!m.busy.flag)for(a=m.queues.length-1;a>=0;--a)c=m.queues[a],0!==c.length&&(d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay))};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return"function"==typeof a&&(a={callback:a}),void 0!==b&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b,c=m.extractState(m.getLocationHref());if(!m.isLastSavedState(c))return b=c,b||(b=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return!1!==a&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return!1!==a&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m},m.emulated.pushState){var p=function(){};m.pushState=m.pushState||p,m.replaceState=m.replaceState||p}else m.onPopState=function(b,c){var d,e,f=!1,g=!1;return m.doubleCheckComplete(),d=m.getHash(),d?(e=m.extractState(d||m.getLocationHref(),!0),e?m.replaceState(e.data,e.title,e.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(f=m.Adapter.extractEventData("state",b,c)||!1,g=f?m.getStateById(f):m.expectedStateId?m.getStateById(m.expectedStateId):m.extractState(m.getLocationHref()),g||(g=m.createStateObject(null,null,m.getLocationHref())),m.expectedStateId=!1,m.isLastSavedState(g)?(m.busy(!1),!1):(m.storeState(g),m.saveState(g),m.setTitle(g),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(!1!==e&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(!1!==e&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(q){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(m.getLocationHref(),!0))),f&&(m.onUnload=function(){var a,b,c;try{a=k.parse(f.getItem("History.store"))||{}}catch(d){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState)m.idToState.hasOwnProperty(b)&&(a.idToState[b]=m.idToState[b]);for(b in m.urlToId)m.urlToId.hasOwnProperty(b)&&(a.urlToId[b]=m.urlToId[b]);for(b in m.stateToId)m.stateToId.hasOwnProperty(b)&&(a.stateToId[b]=m.stateToId[b]);m.store=a,m.normalizeStore(),c=k.stringify(a);try{f.setItem("History.store",c)}catch(e){if(e.code!==DOMException.QUOTA_EXCEEDED_ERR)throw e;f.length&&(f.removeItem("History.store"),f.setItem("History.store",c))}},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload)),m.emulated.pushState||(m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval)),"Apple Computer, Inc."!==e.vendor&&"Mozilla"!==(e.appCodeName||"")||(m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})))},(!m.options||!m.options.delayInit)&&m.init()}(window),function(a){var b=function(b,c){"use strict";var d=function(a,b){return function(){var d=arguments;return c.computed(function(){return a.apply(b,d)})}},e={};e.page=null,e.now=function(){return Date.now?Date.now():(new Date).valueOf()},e.extendWithPage=function(a){var b=new e.Page;a.$__page__=b,e.page=b,e.activePage$=d(e.getActivePage,e)()};var f=function(a,b,c){c=c||{},c.page=a,e[b].fire(c),a.val(b)&&a.val(b)(c)};b.each(["onBindingError","onSourceError","onNoMatch","onMatch","beforeRemove","afterRemove","beforeHide","afterHide","beforeShow","afterShow"],function(a,c){e[c]=b.Callbacks()}),e.showChild=function(a){var b=a&&1===a.length&&""===a[0]?[]:a;e.page.showPage(b)},e.getParentPage=function(a){for(;a;){if(a.$page&&"none"!==a.$page.val("urlToggle"))return a.$page;if(a.$data&&a.$data.$__page__)return a.$data.$__page__;a=a.$parentContext}return null};var g=null,h=null,i=function(a){h&&h.reject({cancel:!0}),g=null,a.substring(0,e.Href.hash.length)===e.Href.hash&&(a=a.slice(e.Href.hash.length));var b=j(a);e.showChild(b)};e.goTo=i,e.navigate=function(a){e.useHTML5history?e.Href5.history.pushState(null,null,a):location.hash=a};var j=function(a){return b.map(a.replace(/\+/g," ").split("/"),decodeURIComponent)},k={};k.value=c.utils.unwrapObservable,k.arrayValue=function(a){return b.map(a,function(a){return k.value(a)})};var l=function(a){for(var b,c={},d=/([^&=]+)=?([^&]*)/g;b=d.exec(a);)c[b[1]]=b[2];return c},m=function(a){if(!a)return{name:null,params:{}};var b=a.split("?"),c=b[0],d=b[1],e={};return d&&(e=l(d)),{name:c,params:e}};e.ChildManager=function(a,d){this.currentChildO=c.observable(null);var g=this;this.page=d,this.timeStamp=e.now(),this.hideChild=function(){var a=g.currentChildO();a&&(a.isStartPage()||(a.hidePage(function(){}),g.currentChildO(null)))},this.showChild=function(c){var d=0===c.length;this.timeStamp=e.now();var h=this.timeStamp,i=g.currentChildO(),j=null,l=!1,n=m(c[0]),o=n.name,p=null;b.each(a(),function(a,b){if(!l){var c=b.getId();(c===o||(""===o||null==o)&&b.isStartPage())&&(l=!0,j=b),"?"===c&&(p=b)}});for(var q=!1,r=g,s=function(a,b){if(!l){var c=b.getId();b.getValue().modal&&((c===o||(""===o||null==o)&&b.isStartPage())&&(l=!0,j=b,q=!0),"?"!==c||p||(p=b,q=!0))}};!j&&r.page.parentPage&&!r.page.getValue().modal;){var t=r.page.parentPage.children;b.each(t(),s),j||(r=r.page.parentPage.childManager)}j||!p||d||(j=p),g.currentChildO(j),j&&(q?j.currentParentPage(g.page):j.currentParentPage(null));var u=function(){f(g.page,"onNoMatch",{route:c})},v=function(){f(g.page,"onMatch",{route:c});var a=k.value(j.getValue().guard);a?a(j,c,function(){g.timeStamp===h&&j.showPage(c.slice(1),n,c[0])},i):j.showPage(c.slice(1),n,c[0])};i&&i===j?v():i?i.hidePage(function(){j?v():u()}):j?v():u()}},e.Page=function(a,b,d,f,g){this.element=a,this.valueAccessor=b,this.allBindingsAccessor=d,this.viewModel=f,this.bindingContext=g,this.children=c.observableArray([]),this.childManager=new e.ChildManager(this.children,this),this.parentPage=null,this.currentId=null,this.getCurrentId=c.observable(),this.ctx=null,this.currentParentPage=c.observable(null),this.isVisible=c.observable(!1),this.originalRoute=c.observable(null),this.route=null};var n=e.Page.prototype;n.val=function(a){return k.value(this.getValue()[a])},n.currentChildPage=function(){return this.childManager.currentChildO},n.find=function(a){var c=k.value(a),d=this;if("/"===c.substring(0,1))d=e.page,c=c.slice(1);else for(;"../"===c.substring(0,3);)d=d.currentParentPage&&d.currentParentPage()?d.currentParentPage():d.parentPage,c=c.slice(3);var f=j(c);return b.each(f,function(a,b){d=d.child(b)()}),d},n.find$=function(a){return d(this.find,this)(a)},n.path=function(a){var c=this,d=k.value(a);if(d&&"object"==typeof d&&d.path&&d.params&&!(d instanceof e.Page)){var f=d.path,g=d.params;return c.path(f)+"?"+b.param(g)}var h;if(null==d||""===d)h=c;else{if(!(d instanceof e.Page)){if("/"===d.substring(0,1))return e.page.getFullRoute()()+d.substring(1);for(var i=0;"../"===d.substring(0,3);)i++,d=d.slice(3);var j=c.getFullRoute()(),l=j.slice(0,j.length-i).join("/"),m=(""===l?"":l+"/")+d;return e.useHTML5history?b("base").attr("href")+m:e.Href.hash+m}h=d}var n=h.getFullRoute()().join("/");return e.useHTML5history?b("base").attr("href")+n:e.Href.hash+n},n.path$=function(a){return d(this.path,this)(a)},n.async=function(a,b,c,d){var f=this;return function(){h&&h.reject({cancel:!0});var i=a();h=i,d&&d(i.state());var j=Math.random();g=j,i.done(function(){d&&d(i.state()),j===g&&e.navigate(f.path(b))}),i.fail(function(a){d&&d(i.state());var b=a&&a.cancel;j===g&&!b&&c&&e.navigate(f.path(c))})}},n.showPage=function(a,b,c){var d=this,e=d.currentId,f=d.pageRoute?d.pageRoute.params:null,g=d.isVisible();d.currentId=b?b.name||"":"",d.getCurrentId(d.currentId),d.isVisible(!0),c&&d.originalRoute(c),d.route=a,d.pageRoute=b,g?("?"===d.getId()&&e!==d.currentId&&d.show(),b&&f!==b.params&&d.setParams()):(d.setParams(),d.show()),d.childManager.showChild(a)},n.setParams=function(){if(this.pageRoute&&this.pageRoute.params){var a=this.pageRoute.params,d=this.ctx,e=this.val("params")||{};b.isArray(e)?b.each(e,function(b,e){var f=a[e];d[e]?d[e](f):d[e]=c.observable(f)}):b.each(e,function(b,e){var f,g=a[b];f=null==g?k.value(e):g,d[b]?d[b](f):d[b]=c.observable(f)})}if(this.pageRoute){var f=this.getValue().nameParam;f&&("string"==typeof f?this.ctx[f]?this.ctx[f](this.currentId):this.ctx[f]=c.observable(this.currentId):f(this.currentId))}},n.hidePage=function(a){var b=this;"show"!==b.val("urlToggle")?(b.hideElementWrapper(a),b.childManager.hideChild()):a&&a()};var o=function(a){try{c.applyBindingsToDescendants(a.childBindingContext,a.element)}catch(b){f(a,"onBindingError",{error:b})}};n.init=function(){var a=this,d=a.val("urlToggle"),e=a.val("id");if("?"!==e&&a.getCurrentId(e),c.utils.domData.get(a.element,"__ko_pagerjsBindingData"))return{controlsDescendantBindings:!0};c.utils.domData.set(a.element,"__ko_pagerjsBindingData",a),c.utils.domNodeDisposal.addDisposeCallback(a.element,function(){f(a,"beforeRemove"),a.parentPage&&a.parentPage.children.remove(a),f(a,"afterRemove")});var g=a.getValue();if("none"!==d&&(a.parentPage=a.getParentPage(),a.parentPage.children.push(this),a.hideElement()),a.val("source")&&a.loadSource(a.val("source")),a.ctx=null,g.withOnShow)a.ctx={},a.childBindingContext=a.bindingContext.createChildContext(a.ctx),c.utils.extend(a.childBindingContext,{$page:this});else{var h=g.with||a.bindingContext.$observableData||a.viewModel;if(a.ctx=k.value(h),a.augmentContext(),c.isObservable(h)){var i=c.observable(a.ctx);a.childBindingContext=a.bindingContext.createChildContext(i),c.utils.extend(a.childBindingContext,{$page:this,$observableData:h}),o(a),h.subscribe(function(){i(k.value(h))})}else a.childBindingContext=a.bindingContext.createChildContext(a.ctx),c.utils.extend(a.childBindingContext,{$page:this,$observableData:void 0}),o(a)}if("none"!==d){var j=a.parentPage;j.route&&(j.route[0]===a.getId()||j.route.length&&"?"===a.getId())&&setTimeout(function(){j.showPage(j.route)},0)}else{var l=function(){b(a.element).is(":visible")&&a.showPage([])};setTimeout(l,0),a.getParentPage().isVisible.subscribe(function(a){a&&setTimeout(l,0)})}var m=a.getValue().bind;return c.isObservable(m)&&m(a),{controlsDescendantBindings:!0}},n.augmentContext=function(){var a=this,d=a.val("params");d&&(b.isArray(d)?b.each(d,function(b,d){a.ctx[d]||(a.ctx[d]=c.observable())}):b.each(d,function(b,e){a.ctx[b]||(c.isObservable(e)?a.ctx[b]=e:null===e?(d[b]=c.observable(null),a.ctx[b]=c.observable(null)):a.ctx[b]=c.observable(e))})),this.val("vars")&&b.each(this.val("vars"),function(b,d){c.isObservable(d)?a.ctx[b]=d:a.ctx[b]=c.observable(d)});var e=this.getValue().nameParam;e&&"string"==typeof e&&(a.ctx[e]=c.observable(null)),this.setParams()},n.getValue=function(){return this.valueAccessor?k.value(this.valueAccessor()):{}},n.getParentPage=function(){return e.getParentPage(this.bindingContext)},n.getId=function(){return this.val("id")},n.id=function(){var a=this.getCurrentId();return null==a||""===a?this.getId():a},n.sourceUrl=function(a){var b=this;return"?"===this.getId()?c.computed(function(){var c;return c=b.val("deep")?[b.currentId].concat(b.route).join("/"):b.currentId,k.value(a).replace("{1}",c)}):c.computed(function(){return k.value(a)})},n.loadWithOnShow=function(){var a=this;a.withOnShowLoaded&&!0===a.val("sourceCache")||(a.withOnShowLoaded=!0,a.val("withOnShow")(function(b){var d=a.bindingContext.createChildContext(b);a.ctx=b,a.childBindingContext=d,a.augmentContext(),c.utils.extend(d,{$page:a}),o(a),a.route&&a.childManager.showChild(a.route)},a))},n.loadSource=function(a){var d=this.getValue(),f=this,g=this.element,h=null,i=d.loader||e.loader;if("iframe"===d.frame){var j=b("iframe",b(g));0===j.length&&(j=b(""),b(g).append(j)),i&&(h=k.value(i)(f,j),h.load()),j.one("load",function(){h&&h.unload(),d.sourceLoaded&&d.sourceLoaded(f)}),c.applyBindingsToNode(j[0],{attr:{src:this.sourceUrl(a)}})}else{i&&(h=k.value(i)(f,f.element),h.load());var l=function(){h&&h.unload(),f.val("withOnShow")?f.val("withOnShow")&&f.loadWithOnShow():o(f),d.sourceLoaded&&d.sourceLoaded(f),f.route&&f.childManager.showChild(f.route)};if("string"==typeof k.value(a)){var m=k.value(this.sourceUrl(a));q(g,m,function(){l()},f)}else{var n=b(g).children();k.value(a)(this,function(){b.each(n,function(a,b){c.utils.domNodeDisposal.removeNode(b)}),l()})}}};var p=/)<[^<]*)*<\/script>/gi,q=function(a,d,e,g){var h,i,j=b(a),k=d.indexOf(" ");k>=0&&(h=d.slice(k,d.length),d=d.slice(0,k));var l=jQuery.ajax({url:d,type:"GET",dataType:"html",complete:function(a,b){e&&j.each(e,i||[a.responseText,b,a])}}).done(function(a){i=arguments,b.each(j.children(),function(a,b){c.utils.domNodeDisposal.removeNode(b)}),j.html(h?jQuery("
").append(a.replace(p,"")).find(h):a)});return l.fail(function(){f(g,"onSourceError",{url:d,xhrPromise:l})}),j};n.show=function(b){var c=this.element,d=this;d.showElementWrapper(b),d.val("title")&&(a.document.title=d.val("title")),d.val("sourceOnShow")?(!d.val("sourceCache")||!c.__pagerLoaded__||"number"==typeof d.val("sourceCache")&&c.__pagerLoaded__+1e3*d.val("sourceCache")68?1900:2e3);break;case"YYYY":case"YYYYY":e[0]=~~b;break;case"a":case"A":c._isPm="pm"===(b+"").toLowerCase();break;case"H":case"HH":case"h":case"hh":e[3]=~~b;break;case"m":case"mm":e[4]=~~b;break;case"s":case"ss":e[5]=~~b;break;case"S":case"SS":case"SSS":e[6]=~~(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,d=(b+"").match($),d&&d[1]&&(c._tzh=~~d[1]),d&&d[2]&&(c._tzm=~~d[2]),d&&"+"===d[0]&&(c._tzh=-c._tzh,c._tzm=-c._tzm)}null==b&&(c._isValid=!1)}function t(a){var b,c,d=[];if(!a._d){for(b=0;b<7;b++)a._a[b]=d[b]=null==a._a[b]?2===b?1:0:a._a[b];d[3]+=a._tzh||0,d[4]+=a._tzm||0,c=new Date(0),a._useUTC?(c.setUTCFullYear(d[0],d[1],d[2]),c.setUTCHours(d[3],d[4],d[5],d[6])):(c.setFullYear(d[0],d[1],d[2]),c.setHours(d[3],d[4],d[5],d[6])),a._d=c}}function u(a){var b,c,d=a._f.match(M),e=a._i;for(a._a=[],b=0;b0,i[4]=c,y.apply({},i)}function A(a,b,c){var d=c-b,e=c-a.day();return e>d&&(e-=7),e11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return A(a,this._week.dow,this._week.doy)},_week:{dow:0,doy:6}},F=function(a,b,c){return B({_i:a,_f:b,_l:c,_isUTC:!1})},F.utc=function(a,b,c){return B({_useUTC:!0,_isUTC:!0,_l:c,_i:a,_f:b})},F.unix=function(a){return F(1e3*a)},F.duration=function(a,b){var c,d=F.isDuration(a),e="number"==typeof a,g=d?a._data:e?{}:a;return e&&(b?g[b]=a:g.milliseconds=a),c=new f(g),d&&a.hasOwnProperty("_lang")&&(c._lang=a._lang),c},F.version=H,F.defaultFormat=Y,F.lang=function(a,b){if(!a)return F.fn._lang._abbr;b?m(a,b):J[a]||n(a),F.duration.fn._lang=F.fn._lang=n(a)},F.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),n(a)},F.isMoment=function(a){return a instanceof e},F.isDuration=function(a){return a instanceof f},F.fn=e.prototype={clone:function(){return F(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._d},toJSON:function(){return F.utc(this).format("YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return null==this._isValid&&(this._a?this._isValid=!l(this._a,(this._isUTC?F.utc(this._a):F(this._a)).toArray()):this._isValid=!isNaN(this._d.getTime())),!!this._isValid},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){var b=q(this,a||F.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?F.duration(+b,a):F.duration(a,b),j(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?F.duration(+b,a):F.duration(a,b),j(this,c,-1),this},diff:function(a,b,c){var d,e,f=this._isUTC?F(a).utc():F(a).local(),g=6e4*(this.zone()-f.zone());return b&&(b=b.replace(/s$/,"")),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-F(this).startOf("month")-(f-F(f).startOf("month")))/d,"year"===b&&(e/=12)):(d=this-f-g,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?d/864e5:"week"===b?d/6048e5:d),c?e:h(e)},from:function(a,b){return F.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(F(),a)},calendar:function(){var a=this.diff(F().startOf("day"),"days",!0),b=a<-6?"sameElse":a<-1?"lastWeek":a<0?"lastDay":a<1?"sameDay":a<2?"nextDay":a<7?"nextWeek":"sameElse";return this.format(this.lang().calendar(b,this))},isLeapYear:function(){var a=this.year();return a%4==0&&a%100!=0||a%400==0},isDST:function(){return this.zone()+F(a).startOf(b)},isBefore:function(a,b){return b=void 0!==b?b:"millisecond",+this.clone().startOf(b)<+F(a).startOf(b)},isSame:function(a,b){return b=void 0!==b?b:"millisecond",+this.clone().startOf(b)==+F(a).startOf(b)},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return F.utc([this.year(),this.month()+1,0]).date()},dayOfYear:function(a){var b=I((F(this).startOf("day")-F(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},isoWeek:function(a){var b=A(this,1,4);return null==a?b:this.add("d",7*(a-b))},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},lang:function(b){return b===a?this._lang:(this._lang=n(b),this)}},G=0;G<_.length;G++)C(_[G].toLowerCase().replace(/s$/,""),_[G]);C("year","FullYear"),F.fn.days=F.fn.day,F.fn.weeks=F.fn.week,F.fn.isoWeeks=F.fn.isoWeek,F.duration.fn=f.prototype={weeks:function(){return h(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+2592e6*this._months},humanize:function(a){var b=+this,c=z(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},lang:F.fn.lang};for(G in aa)aa.hasOwnProperty(G)&&(E(G,aa[G]),D(G.toLowerCase()));E("Weeks",6048e5),F.lang("en",{ordinal:function(a){var b=a%10;return a+(1==~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th")}}),K&&(module.exports=F),"undefined"==typeof ender&&(this.moment=F),"function"==typeof define&&define.amd&&define("moment",[],function(){return F})}.call(this),moment.lang("ru",{months:monthsCaseReplace,monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdays:weekdaysCaseReplace,weekdaysShort:"вск_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., LT",LLLL:"dddd, D MMMM YYYY г., LT"},calendar:{sameDay:"[Сегодня в] LT",nextDay:"[Завтра в] LT",lastDay:"[Вчера в] LT",nextWeek:function(){return 2===this.day()?"[Во] dddd [в] LT":"[В] dddd [в] LT"},lastWeek:function(){switch(this.day()){case 0:return"[В прошлое] dddd [в] LT";case 1:case 2:case 4:return"[В прошлый] dddd [в] LT";case 3:case 5:case 6:return"[В прошлую] dddd [в] LT"}},sameElse:"L"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:relativeTimeWithPlural,mm:relativeTimeWithPlural,h:"час",hh:relativeTimeWithPlural,d:"день",dd:relativeTimeWithPlural,M:"месяц",MM:relativeTimeWithPlural,y:"год",yy:relativeTimeWithPlural},ordinal:"%d.",week:{dow:1,doy:7}}),function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=Function.prototype,g=d.push,h=d.slice,i=d.concat,j=e.toString,k=e.hasOwnProperty,l=d.forEach,m=d.map,n=d.reduce,o=d.reduceRight,p=d.filter,q=d.every,r=d.some,s=d.indexOf,t=d.lastIndexOf,u=Array.isArray,v=Object.keys,w=f.bind,x=function(a){return a instanceof x?a:this instanceof x?void(this._wrapped=a):new x(a)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=x),exports._=x):a._=x,x.VERSION="1.6.0";var y=x.each=x.forEach=function(a,b,d){if(null==a)return a;if(l&&a.forEach===l)a.forEach(b,d);else if(a.length===+a.length){for(var e=0,f=a.length;f>e;e++)if(b.call(d,a[e],e,a)===c)return}else for(var g=x.keys(a),e=0,f=g.length;f>e;e++)if(b.call(d,a[g[e]],g[e],a)===c)return;return a};x.map=x.collect=function(a,b,c){var d=[];return null==a?d:m&&a.map===m?a.map(b,c):(y(a,function(a,e,f){d.push(b.call(c,a,e,f))}),d)};var z="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),n&&a.reduce===n)return d&&(b=x.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(y(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(z);return c},x.reduceRight=x.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),o&&a.reduceRight===o)return d&&(b=x.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=x.keys(a);f=g.length}if(y(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(z);return c},x.find=x.detect=function(a,b,c){var d;return A(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},x.filter=x.select=function(a,b,c){var d=[];return null==a?d:p&&a.filter===p?a.filter(b,c):(y(a,function(a,e,f){b.call(c,a,e,f)&&d.push(a)}),d)},x.reject=function(a,b,c){return x.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},x.every=x.all=function(a,b,d){b||(b=x.identity);var e=!0;return null==a?e:q&&a.every===q?a.every(b,d):(y(a,function(a,f,g){return(e=e&&b.call(d,a,f,g))?void 0:c}),!!e)};var A=x.some=x.any=function(a,b,d){b||(b=x.identity);var e=!1;return null==a?e:r&&a.some===r?a.some(b,d):(y(a,function(a,f,g){return e||(e=b.call(d,a,f,g))?c:void 0}),!!e)};x.contains=x.include=function(a,b){return null!=a&&(s&&a.indexOf===s?-1!=a.indexOf(b):A(a,function(a){return a===b}))},x.invoke=function(a,b){var c=h.call(arguments,2),d=x.isFunction(b);return x.map(a,function(a){return(d?b:a[b]).apply(a,c)})},x.pluck=function(a,b){return x.map(a,x.property(b))},x.where=function(a,b){return x.filter(a,x.matches(b))},x.findWhere=function(a,b){return x.find(a,x.matches(b))},x.max=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);var d=-1/0,e=-1/0;return y(a,function(a,f,g){var h=b?b.call(c,a,f,g):a;h>e&&(d=a,e=h)}),d},x.min=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);var d=1/0,e=1/0;return y(a,function(a,f,g){var h=b?b.call(c,a,f,g):a;e>h&&(d=a,e=h)}),d},x.shuffle=function(a){var b,c=0,d=[];return y(a,function(a){b=x.random(c++),d[c-1]=d[b],d[b]=a}),d},x.sample=function(a,b,c){return null==b||c?(a.length!==+a.length&&(a=x.values(a)),a[x.random(a.length-1)]):x.shuffle(a).slice(0,Math.max(0,b))};var B=function(a){return null==a?x.identity:x.isFunction(a)?a:x.property(a)};x.sortBy=function(a,b,c){return b=B(b),x.pluck(x.map(a,function(a,d,e){return{value:a,index:d,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.index-b.index}),"value")};var C=function(a){return function(b,c,d){var e={};return c=B(c),y(b,function(f,g){var h=c.call(d,f,g,b);a(e,h,f)}),e}};x.groupBy=C(function(a,b,c){x.has(a,b)?a[b].push(c):a[b]=[c]}),x.indexBy=C(function(a,b,c){a[b]=c}),x.countBy=C(function(a,b){x.has(a,b)?a[b]++:a[b]=1}),x.sortedIndex=function(a,b,c,d){c=B(c);for(var e=c.call(d,b),f=0,g=a.length;g>f;){var h=f+g>>>1;c.call(d,a[h])b?[]:h.call(a,0,b)},x.initial=function(a,b,c){return h.call(a,0,a.length-(null==b||c?1:b))},x.last=function(a,b,c){return null==a?void 0:null==b||c?a[a.length-1]:h.call(a,Math.max(a.length-b,0))},x.rest=x.tail=x.drop=function(a,b,c){return h.call(a,null==b||c?1:b)},x.compact=function(a){return x.filter(a,x.identity)};var D=function(a,b,c){return b&&x.every(a,x.isArray)?i.apply(c,a):(y(a,function(a){x.isArray(a)||x.isArguments(a)?b?g.apply(c,a):D(a,b,c):c.push(a)}),c)};x.flatten=function(a,b){return D(a,b,[])},x.without=function(a){return x.difference(a,h.call(arguments,1))},x.partition=function(a,b){var c=[],d=[];return y(a,function(a){(b(a)?c:d).push(a)}),[c,d]},x.uniq=x.unique=function(a,b,c,d){x.isFunction(b)&&(d=c,c=b,b=!1);var e=c?x.map(a,c,d):a,f=[],g=[];return y(e,function(c,d){(b?d&&g[g.length-1]===c:x.contains(g,c))||(g.push(c),f.push(a[d]))}),f},x.union=function(){return x.uniq(x.flatten(arguments,!0))},x.intersection=function(a){var b=h.call(arguments,1);return x.filter(x.uniq(a),function(a){return x.every(b,function(b){return x.contains(b,a)})})},x.difference=function(a){var b=i.apply(d,h.call(arguments,1));return x.filter(a,function(a){return!x.contains(b,a)})},x.zip=function(){for(var a=x.max(x.pluck(arguments,"length").concat(0)),b=new Array(a),c=0;a>c;c++)b[c]=x.pluck(arguments,""+c);return b},x.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},x.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=x.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}if(s&&a.indexOf===s)return a.indexOf(b,c);for(;e>d;d++)if(a[d]===b)return d;return-1},x.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=null!=c;if(t&&a.lastIndexOf===t)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);for(var e=d?c:a.length;e--;)if(a[e]===b)return e;return-1},x.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);d>e;)f[e++]=a,a+=c;return f};var E=function(){};x.bind=function(a,b){var c,d;if(w&&a.bind===w)return w.apply(a,h.call(arguments,1));if(!x.isFunction(a))throw new TypeError;return c=h.call(arguments,2),d=function(){if(!(this instanceof d))return a.apply(b,c.concat(h.call(arguments)));E.prototype=a.prototype;var e=new E;E.prototype=null;var f=a.apply(e,c.concat(h.call(arguments)));return Object(f)===f?f:e}},x.partial=function(a){var b=h.call(arguments,1);return function(){for(var c=0,d=b.slice(),e=0,f=d.length;f>e;e++)d[e]===x&&(d[e]=arguments[c++]);for(;c=k?(clearTimeout(g),g=null,h=j,f=a.apply(d,e),d=e=null):g||!1===c.trailing||(g=setTimeout(i,k)),f}},x.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=x.now()-g;b>j?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),f=e=null))};return function(){f=this,e=arguments,g=x.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},x.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}},x.wrap=function(a,b){return x.partial(b,a)},x.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},x.after=function(a,b){return function(){return--a<1?b.apply(this,arguments):void 0}},x.keys=function(a){if(!x.isObject(a))return[];if(v)return v(a);var b=[];for(var c in a)x.has(a,c)&&b.push(c);return b},x.values=function(a){for(var b=x.keys(a),c=b.length,d=new Array(c),e=0;c>e;e++)d[e]=a[b[e]];return d},x.pairs=function(a){for(var b=x.keys(a),c=b.length,d=new Array(c),e=0;c>e;e++)d[e]=[b[e],a[b[e]]];return d},x.invert=function(a){for(var b={},c=x.keys(a),d=0,e=c.length;e>d;d++)b[a[c[d]]]=c[d];return b},x.functions=x.methods=function(a){var b=[];for(var c in a)x.isFunction(a[c])&&b.push(c);return b.sort()},x.extend=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)a[c]=b[c]}),a},x.pick=function(a){var b={},c=i.apply(d,h.call(arguments,1));return y(c,function(c){c in a&&(b[c]=a[c])}),b},x.omit=function(a){var b={},c=i.apply(d,h.call(arguments,1));for(var e in a)x.contains(c,e)||(b[e]=a[e]);return b},x.defaults=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)void 0===a[c]&&(a[c]=b[c])}),a},x.clone=function(a){return x.isObject(a)?x.isArray(a)?a.slice():x.extend({},a):a},x.tap=function(a,b){return b(a),a};var F=function(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;if(null==a||null==b)return a===b;a instanceof x&&(a=a._wrapped),b instanceof x&&(b=b._wrapped);var e=j.call(a);if(e!=j.call(b))return!1;switch(e){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]==a)return d[f]==b;var g=a.constructor,h=b.constructor;if(g!==h&&!(x.isFunction(g)&&g instanceof g&&x.isFunction(h)&&h instanceof h)&&"constructor"in a&&"constructor"in b)return!1;c.push(a),d.push(b);var i=0,k=!0;if("[object Array]"==e){if(i=a.length,k=i==b.length)for(;i--&&(k=F(a[i],b[i],c,d)););}else{for(var l in a)if(x.has(a,l)&&(i++,!(k=x.has(b,l)&&F(a[l],b[l],c,d))))break;if(k){for(l in b)if(x.has(b,l)&&!i--)break;k=!i}}return c.pop(),d.pop(),k};x.isEqual=function(a,b){return F(a,b,[],[])},x.isEmpty=function(a){if(null==a)return!0;if(x.isArray(a)||x.isString(a))return 0===a.length;for(var b in a)if(x.has(a,b))return!1;return!0},x.isElement=function(a){return!(!a||1!==a.nodeType)},x.isArray=u||function(a){return"[object Array]"==j.call(a)},x.isObject=function(a){return a===Object(a)},y(["Arguments","Function","String","Number","Date","RegExp"],function(a){x["is"+a]=function(b){return j.call(b)=="[object "+a+"]"}}),x.isArguments(arguments)||(x.isArguments=function(a){return!(!a||!x.has(a,"callee"))}),"function"!=typeof/./&&(x.isFunction=function(a){return"function"==typeof a}),x.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},x.isNaN=function(a){return x.isNumber(a)&&a!=+a},x.isBoolean=function(a){return!0===a||!1===a||"[object Boolean]"==j.call(a)},x.isNull=function(a){return null===a},x.isUndefined=function(a){return void 0===a},x.has=function(a,b){return k.call(a,b)},x.noConflict=function(){return a._=b,this},x.identity=function(a){return a},x.constant=function(a){return function(){return a}},x.property=function(a){return function(b){return b[a]}},x.matches=function(a){return function(b){if(b===a)return!0;for(var c in a)if(a[c]!==b[c])return!1;return!0}},x.times=function(a,b,c){for(var d=Array(Math.max(0,a)),e=0;a>e;e++)d[e]=b.call(c,e);return d},x.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},x.now=Date.now||function(){return(new Date).getTime()};var G={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};G.unescape=x.invert(G.escape);var H={escape:new RegExp("["+x.keys(G.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(G.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(a){x[a]=function(b){return null==b?"":(""+b).replace(H[a],function(b){return G[a][b]})}}),x.result=function(a,b){if(null!=a){var c=a[b];return x.isFunction(c)?c.call(a):c}},x.mixin=function(a){y(x.functions(a),function(b){var c=x[b]=a[b];x.prototype[b]=function(){var a=[this._wrapped];return g.apply(a,arguments),M.call(this,c.apply(x,a))}})};var I=0;x.uniqueId=function(a){var b=++I+"";return a?a+b:b},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var J=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},L=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(a,b,c){var d;c=x.defaults({},c,x.templateSettings);var e=new RegExp([(c.escape||J).source,(c.interpolate||J).source,(c.evaluate||J).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(L,function(a){return"\\"+K[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=new Function(c.variable||"obj","_",g)}catch(h){throw h.source=g,h}if(b)return d(b,x);var i=function(a){return d.call(this,a,x)};return i.source="function("+(c.variable||"obj")+"){\n"+g+"}",i},x.chain=function(a){return x(a).chain()};var M=function(a){return this._chain?x(a).chain():a};x.mixin(x),y(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];x.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],M.call(this,c)}}),y(["concat","join","slice"],function(a){var b=d[a];x.prototype[a]=function(){return M.call(this,b.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return x})}.call(this),translate={},translate.ru={winter_home:"Зимний дом",part_of_house:"Часть дома",cottage:"Коттедж",country_house:"Дача",sector:"Участок",townhouse:"Таунхаус"},function(){"use strict";var a=this,b=a.Chart,c=function(a){this.canvas=a.canvas,this.ctx=a;var b=function(a,b){return a["offset"+b]?a["offset"+b]:document.defaultView.getComputedStyle(a).getPropertyValue(b)},c=this.width=b(a.canvas,"Width"),e=this.height=b(a.canvas,"Height");a.canvas.width=c,a.canvas.height=e;var c=this.width=a.canvas.width,e=this.height=a.canvas.height;return this.aspectRatio=this.width/this.height,d.retinaScale(this),this};c.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},c.types={};var d=c.helpers={},e=d.each=function(a,b,c){var d=Array.prototype.slice.call(arguments,3);if(a)if(a.length===+a.length){var e;for(e=0;e=0;d--){var e=a[d];if(b(e))return e}},d.inherits=function(a){var b=this,c=a&&a.hasOwnProperty("constructor")?a.constructor:function(){return b.apply(this,arguments)},d=function(){this.constructor=c};return d.prototype=b.prototype,c.prototype=new d,c.extend=j,a&&g(c.prototype,a),c.__super__=b.prototype,c}),k=d.noop=function(){},l=d.uid=function(){var a=0;return function(){return"chart-"+a++}}(),m=d.warn=function(a){window.console&&"function"==typeof window.console.warn&&console.warn(a)},n=d.amd="function"==typeof define&&define.amd,o=d.isNumber=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},p=d.max=function(a){return Math.max.apply(Math,a)},q=d.min=function(a){return Math.min.apply(Math,a)},r=(d.cap=function(a,b,c){if(o(b)){if(a>b)return b}else if(o(c)&&c>a)return c;return a},d.getDecimalPlaces=function(a){return a%1!=0&&o(a)?a.toString().split(".")[1].length:0}),s=d.radians=function(a){return a*(Math.PI/180)},t=(d.getAngleFromPoint=function(a,b){var c=b.x-a.x,d=b.y-a.y,e=Math.sqrt(c*c+d*d),f=2*Math.PI+Math.atan2(d,c);return 0>c&&0>d&&(f+=2*Math.PI),{angle:f,distance:e}},d.aliasPixel=function(a){return a%2==0?0:.5}),u=(d.splineCurve=function(a,b,c,d){var e=Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2)),f=Math.sqrt(Math.pow(c.x-b.x,2)+Math.pow(c.y-b.y,2)),g=d*e/(e+f),h=d*f/(e+f);return{inner:{x:b.x-g*(c.x-a.x),y:b.y-g*(c.y-a.y)},outer:{x:b.x+h*(c.x-a.x),y:b.y+h*(c.y-a.y)}}},d.calculateOrderOfMagnitude=function(a){return Math.floor(Math.log(a)/Math.LN10)}),v=(d.calculateScaleRange=function(a,b,c,d,e){var f=2,g=Math.floor(b/(1.5*c)),h=f>=g,i=p(a),j=q(a);i===j&&(i+=.5,j>=.5&&!d?j-=.5:i+=.5);for(var k=Math.abs(i-j),l=u(k),m=Math.ceil(i/(1*Math.pow(10,l)))*Math.pow(10,l),n=d?0:Math.floor(j/(1*Math.pow(10,l)))*Math.pow(10,l),o=m-n,r=Math.pow(10,l),s=Math.round(o/r);(s>g||g>2*s)&&!h;)if(s>g)r*=2,(s=Math.round(o/r))%1!=0&&(h=!0);else if(e&&l>=0){if(r/2%1!=0)break;r/=2,s=Math.round(o/r)}else r/=2,s=Math.round(o/r);return h&&(s=f,r=o/s),{steps:s,stepValue:r,min:n,max:n+s*r}},d.template=function(a,b){function c(a,b){var c=/\W/.test(a)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g," ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):d[a]=d[a];return b?c(b):c}if(a instanceof Function)return a(b);var d={};return c(a,b)}),w=(d.generateLabels=function(a,b,c,d){var f=new Array(b);return labelTemplateString&&e(f,function(b,e){f[e]=v(a,{value:c+d*(e+1)})}),f},d.easingEffects={linear:function(a){return a},easeInQuad:function(a){return a*a},easeOutQuad:function(a){return-1*a*(a-2)},easeInOutQuad:function(a){return(a/=.5)<1?.5*a*a:-.5*(--a*(a-2)-1)},easeInCubic:function(a){return a*a*a},easeOutCubic:function(a){return 1*((a=a/1-1)*a*a+1)},easeInOutCubic:function(a){return(a/=.5)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},easeInQuart:function(a){return a*a*a*a},easeOutQuart:function(a){return-1*((a=a/1-1)*a*a*a-1)},easeInOutQuart:function(a){return(a/=.5)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},easeInQuint:function(a){return 1*(a/=1)*a*a*a*a},easeOutQuint:function(a){return 1*((a=a/1-1)*a*a*a*a+1)},easeInOutQuint:function(a){return(a/=.5)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},easeInSine:function(a){return-1*Math.cos(a/1*(Math.PI/2))+1},easeOutSine:function(a){return 1*Math.sin(a/1*(Math.PI/2))},easeInOutSine:function(a){return-.5*(Math.cos(Math.PI*a/1)-1)},easeInExpo:function(a){return 0===a?1:1*Math.pow(2,10*(a/1-1))},easeOutExpo:function(a){return 1===a?1:1*(1-Math.pow(2,-10*a/1))},easeInOutExpo:function(a){return 0===a?0:1===a?1:(a/=.5)<1?.5*Math.pow(2,10*(a-1)):.5*(2-Math.pow(2,-10*--a))},easeInCirc:function(a){return a>=1?a:-1*(Math.sqrt(1-(a/=1)*a)-1)},easeOutCirc:function(a){return 1*Math.sqrt(1-(a=a/1-1)*a)},easeInOutCirc:function(a){return(a/=.5)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},easeInElastic:function(a){var b=1.70158,c=0,d=1;return 0===a?0:1==(a/=1)?1:(c||(c=.3),da?-.5*d*Math.pow(2,10*(a-=1))*Math.sin(2*(1*a-b)*Math.PI/c):d*Math.pow(2,-10*(a-=1))*Math.sin(2*(1*a-b)*Math.PI/c)*.5+1)},easeInBack:function(a){var b=1.70158;return 1*(a/=1)*a*((b+1)*a-b)},easeOutBack:function(a){var b=1.70158;return 1*((a=a/1-1)*a*((b+1)*a+b)+1)},easeInOutBack:function(a){var b=1.70158;return(a/=.5)<1?.5*a*a*((1+(b*=1.525))*a-b):.5*((a-=2)*a*((1+(b*=1.525))*a+b)+2)},easeInBounce:function(a){return 1-w.easeOutBounce(1-a)},easeOutBounce:function(a){return(a/=1)<1/2.75?7.5625*a*a:2/2.75>a?1*(7.5625*(a-=1.5/2.75)*a+.75):2.5/2.75>a?1*(7.5625*(a-=2.25/2.75)*a+.9375):1*(7.5625*(a-=2.625/2.75)*a+.984375)},easeInOutBounce:function(a){return.5>a?.5*w.easeInBounce(2*a):.5*w.easeOutBounce(2*a-1)+.5}}),x=d.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(a,1e3/60)}}(),y=d.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(a){return window.clearTimeout(a,1e3/60)}}(),z=(d.animationLoop=function(a,b,c,d,e,f){var g=0,h=w[c]||w.linear,i=function(){g++;var c=g/b,j=h(c);a.call(f,j,c,g),d.call(f,j,c),b>g?f.animationFrame=x(i):e.apply(f)};x(i)},d.getRelativePosition=function(a){var b,c,d=a.originalEvent||a,e=a.currentTarget||a.srcElement,f=e.getBoundingClientRect();return d.touches?(b=d.touches[0].clientX-f.left,c=d.touches[0].clientY-f.top):(b=d.clientX-f.left,c=d.clientY-f.top),{x:b,y:c}},d.addEvent=function(a,b,c){a.addEventListener?a.addEventListener(b,c):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c}),A=d.removeEvent=function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=k},B=(d.bindEvents=function(a,b,c){a.events||(a.events={}),e(b,function(b){a.events[b]=function(){c.apply(a,arguments)},z(a.chart.canvas,b,a.events[b])})},d.unbindEvents=function(a,b){e(b,function(b,c){A(a.chart.canvas,c,b)})}),C=d.getMaximumWidth=function(a){return a.parentNode.clientWidth},D=d.getMaximumHeight=function(a){return a.parentNode.clientHeight},E=(d.getMaximumSize=d.getMaximumWidth,d.retinaScale=function(a){var b=a.ctx,c=a.canvas.width,d=a.canvas.height;window.devicePixelRatio&&(b.canvas.style.width=c+"px",b.canvas.style.height=d+"px",b.canvas.height=d*window.devicePixelRatio,b.canvas.width=c*window.devicePixelRatio,b.scale(window.devicePixelRatio,window.devicePixelRatio))}),F=d.clear=function(a){a.ctx.clearRect(0,0,a.width,a.height)},G=d.fontString=function(a,b,c){return b+" "+a+"px "+c},H=d.longestText=function(a,b,c){a.font=b;var d=0;return e(c,function(b){var c=a.measureText(b).width ;d=c>d?c:d}),d},I=d.drawRoundedRectangle=function(a,b,c,d,e,f){a.beginPath(),a.moveTo(b+f,c),a.lineTo(b+d-f,c),a.quadraticCurveTo(b+d,c,b+d,c+f),a.lineTo(b+d,c+e-f),a.quadraticCurveTo(b+d,c+e,b+d-f,c+e),a.lineTo(b+f,c+e),a.quadraticCurveTo(b,c+e,b,c+e-f),a.lineTo(b,c+f),a.quadraticCurveTo(b,c,b+f,c),a.closePath()};c.instances={},c.Type=function(a,b,d){this.options=b,this.chart=d,this.id=l(),c.instances[this.id]=this,b.responsive&&this.resize(),this.initialize.call(this,a)},g(c.Type.prototype,{initialize:function(){return this},clear:function(){return F(this.chart),this},stop:function(){return y(this.animationFrame),this},resize:function(a){this.stop();var b=this.chart.canvas,c=C(this.chart.canvas),d=this.options.maintainAspectRatio?c/this.chart.aspectRatio:D(this.chart.canvas);return b.width=this.chart.width=c,b.height=this.chart.height=d,E(this.chart),"function"==typeof a&&a.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:k,render:function(a){return a&&this.reflow(),this.options.animation&&!a?d.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return v(this.options.legendTemplate,this)},destroy:function(){this.clear(),B(this,this.events);var a=this.chart.canvas;a.width=this.chart.width,a.height=this.chart.height,a.style.removeProperty?(a.style.removeProperty("width"),a.style.removeProperty("height")):(a.style.removeAttribute("width"),a.style.removeAttribute("height")),delete c.instances[this.id]},showTooltip:function(a,b){if(void 0===this.activeElements&&(this.activeElements=[]),function(a){var b=!1;return a.length!==this.activeElements.length?b=!0:(e(a,function(a,c){a!==this.activeElements[c]&&(b=!0)},this),b)}.call(this,a)||b){if(this.activeElements=a,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),a.length>0)if(this.datasets&&this.datasets.length>1){for(var f,g,h=this.datasets.length-1;h>=0&&(f=this.datasets[h].points||this.datasets[h].bars||this.datasets[h].segments,-1===(g=i(f,a[0])));h--);var j=[],k=[],l=function(){var a,b,c,e,f,h=[],i=[],l=[];return d.each(this.datasets,function(b){a=b.points||b.bars||b.segments,a[g]&&a[g].hasValue()&&h.push(a[g])}),d.each(h,function(a){i.push(a.x),l.push(a.y),j.push(d.template(this.options.multiTooltipTemplate,a)),k.push({fill:a._saved.fillColor||a.fillColor,stroke:a._saved.strokeColor||a.strokeColor})},this),f=q(l),c=p(l),e=q(i),b=p(i),{x:e>this.chart.width/2?e:b,y:(f+c)/2}}.call(this,g);new c.MultiTooltip({x:l.x,y:l.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:j,legendColors:k,legendColorBackground:this.options.multiTooltipKeyBackground,title:a[0].label,chart:this.chart,ctx:this.chart.ctx,custom:this.options.customTooltips}).draw()}else e(a,function(a){var b=a.tooltipPosition();new c.Tooltip({x:Math.round(b.x),y:Math.round(b.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:v(this.options.tooltipTemplate,a),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),c.Type.extend=function(a){var b=this,d=function(){return b.apply(this,arguments)};if(d.prototype=f(b.prototype),g(d.prototype,a),d.extend=c.Type.extend,a.name||b.prototype.name){var e=a.name||b.prototype.name,i=c.defaults[b.prototype.name]?f(c.defaults[b.prototype.name]):{};c.defaults[e]=g(i,a.defaults),c.types[e]=d,c.prototype[e]=function(a,b){var f=h(c.defaults.global,c.defaults[e],b||{});return new d(a,f,this)}}else m("Name not provided for this chart, so it hasn't been registered");return b},c.Element=function(a){g(this,a),this.initialize.apply(this,arguments),this.save()},g(c.Element.prototype,{initialize:function(){},restore:function(a){return a?e(a,function(a){this[a]=this._saved[a]},this):g(this,this._saved),this},save:function(){return this._saved=f(this),delete this._saved._saved,this},update:function(a){return e(a,function(a,b){this._saved[b]=this[b],this[b]=a},this),this},transition:function(a,b){return e(a,function(a,c){this[c]=(a-this._saved[c])*b+this._saved[c]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return o(this.value)}}),c.Element.extend=j,c.Point=c.Element.extend({display:!0,inRange:function(a,b){var c=this.hitDetectionRadius+this.radius;return Math.pow(a-this.x,2)+Math.pow(b-this.y,2)=this.startAngle&&c.angle<=this.endAngle,f=c.distance>=this.innerRadius&&c.distance<=this.outerRadius;return e&&f},tooltipPosition:function(){var a=this.startAngle+(this.endAngle-this.startAngle)/2,b=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(a)*b,y:this.y+Math.sin(a)*b}},draw:function(a){var b=this.ctx;b.beginPath(),b.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),b.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),b.closePath(),b.strokeStyle=this.strokeColor,b.lineWidth=this.strokeWidth,b.fillStyle=this.fillColor,b.fill(),b.lineJoin="bevel",this.showStroke&&b.stroke()}}),c.Rectangle=c.Element.extend({draw:function(){var a=this.ctx,b=this.width/2,c=this.x-b,d=this.x+b,e=this.base-(this.base-this.y),f=this.strokeWidth/2;this.showStroke&&(c+=f,d-=f,e+=f),a.beginPath(),a.fillStyle=this.fillColor,a.strokeStyle=this.strokeColor,a.lineWidth=this.strokeWidth,a.moveTo(c,this.base),a.lineTo(c,e),a.lineTo(d,e),a.lineTo(d,this.base),a.fill(),this.showStroke&&a.stroke()},height:function(){return this.base-this.y},inRange:function(a,b){return a>=this.x-this.width/2&&a<=this.x+this.width/2&&b>=this.y&&b<=this.base}}),c.Tooltip=c.Element.extend({draw:function(){var a=this.chart.ctx;a.font=G(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var b=this.caretPadding=2,c=a.measureText(this.text).width+2*this.xPadding,d=this.fontSize+2*this.yPadding,e=d+this.caretHeight+b;this.x+c/2>this.chart.width?this.xAlign="left":this.x-c/2<0&&(this.xAlign="right"),this.y-e<0&&(this.yAlign="below");var f=this.x-c/2,g=this.y-e;if(a.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":a.beginPath(),a.moveTo(this.x,this.y-b),a.lineTo(this.x+this.caretHeight,this.y-(b+this.caretHeight)),a.lineTo(this.x-this.caretHeight,this.y-(b+this.caretHeight)),a.closePath(),a.fill();break;case"below":g=this.y+b+this.caretHeight,a.beginPath(),a.moveTo(this.x,this.y+b),a.lineTo(this.x+this.caretHeight,this.y+b+this.caretHeight),a.lineTo(this.x-this.caretHeight,this.y+b+this.caretHeight),a.closePath(),a.fill()}switch(this.xAlign){case"left":f=this.x-c+(this.cornerRadius+this.caretHeight);break;case"right":f=this.x-(this.cornerRadius+this.caretHeight)}I(a,f,g,c,d,this.cornerRadius),a.fill(),a.fillStyle=this.textColor,a.textAlign="center",a.textBaseline="middle",a.fillText(this.text,f+c/2,g+d/2)}}}),c.MultiTooltip=c.Element.extend({initialize:function(){this.font=G(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=G(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var a=this.ctx.measureText(this.title).width,b=H(this.ctx,this.font,this.labels)+this.fontSize+3,c=p([b,a]);this.width=c+2*this.xPadding;var d=this.height/2;this.y-d<0?this.y=d:this.y+d>this.chart.height&&(this.y=this.chart.height-d),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(a){var b=this.y-this.height/2+this.yPadding,c=a-1;return 0===a?b+this.titleFontSize/2:b+(1.5*this.fontSize*c+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{I(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var a=this.ctx;a.fillStyle=this.fillColor,a.fill(),a.closePath(),a.textAlign="left",a.textBaseline="middle",a.fillStyle=this.titleTextColor,a.font=this.titleFont,a.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),a.font=this.font,d.each(this.labels,function(b,c){a.fillStyle=this.textColor,a.fillText(b,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(c+1)),a.fillStyle=this.legendColorBackground,a.fillRect(this.x+this.xPadding,this.getLineHeight(c+1)-this.fontSize/2,this.fontSize,this.fontSize),a.fillStyle=this.legendColors[c].fill,a.fillRect(this.x+this.xPadding,this.getLineHeight(c+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),c.Scale=c.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var a=r(this.stepValue),b=0;b<=this.steps;b++)this.yLabels.push(v(this.templateString,{value:(this.min+b*this.stepValue).toFixed(a)}));this.yLabelWidth=this.display&&this.showLabels?H(this.ctx,this.font,this.yLabels):0},addXLabel:function(a){this.xLabels.push(a),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var a,b=this.endPoint-this.startPoint;for(this.calculateYRange(b),this.buildYLabels(),this.calculateXLabelRotation();b>this.endPoint-this.startPoint;)b=this.endPoint-this.startPoint,a=this.yLabelWidth,this.calculateYRange(b),this.buildYLabels(),athis.yLabelWidth+10?b/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var d,e=H(this.ctx,this.font,this.xLabels);this.xLabelWidth=e;for(var f=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>f&&0===this.xLabelRotation||this.xLabelWidth>f&&this.xLabelRotation<=90&&this.xLabelRotation>0;)d=Math.cos(s(this.xLabelRotation)),a=d*b,d*c,a+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=a+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=d*e;this.xLabelRotation>0&&(this.endPoint-=Math.sin(s(this.xLabelRotation))*e+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:k,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(a){var b=this.drawingArea()/(this.min-this.max);return this.endPoint-b*(a-this.min)},calculateX:function(a){var b=(this.xLabelRotation,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),c=b/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),d=c*a+this.xScalePaddingLeft;return this.offsetGridLines&&(d+=c/2),Math.round(d)},update:function(a){d.extend(this,a),this.fit()},draw:function(){var a=this.ctx,b=(this.endPoint-this.startPoint)/this.steps,c=Math.round(this.xScalePaddingLeft);this.display&&(a.fillStyle=this.textColor,a.font=this.font,e(this.yLabels,function(e,f){var g=this.endPoint-b*f,h=Math.round(g),i=this.showHorizontalLines;a.textAlign="right",a.textBaseline="middle",this.showLabels&&a.fillText(e,c-10,g),0!==f||i||(i=!0),i&&a.beginPath(),f>0?(a.lineWidth=this.gridLineWidth,a.strokeStyle=this.gridLineColor):(a.lineWidth=this.lineWidth,a.strokeStyle=this.lineColor),h+=d.aliasPixel(a.lineWidth),i&&(a.moveTo(c,h),a.lineTo(this.width,h),a.stroke(),a.closePath()),a.lineWidth=this.lineWidth,a.strokeStyle=this.lineColor,a.beginPath(),a.moveTo(c-5,h),a.lineTo(c,h),a.stroke(),a.closePath()},this),e(this.xLabels,function(b,c){var d=this.calculateX(c)+t(this.lineWidth),e=this.calculateX(c-(this.offsetGridLines?.5:0))+t(this.lineWidth),f=this.xLabelRotation>0,g=this.showVerticalLines;0!==c||g||(g=!0),g&&a.beginPath(),c>0?(a.lineWidth=this.gridLineWidth,a.strokeStyle=this.gridLineColor):(a.lineWidth=this.lineWidth,a.strokeStyle=this.lineColor),g&&(a.moveTo(e,this.endPoint),a.lineTo(e,this.startPoint-3),a.stroke(),a.closePath()),a.lineWidth=this.lineWidth,a.strokeStyle=this.lineColor,a.beginPath(),a.moveTo(e,this.endPoint),a.lineTo(e,this.endPoint+5),a.stroke(),a.closePath(),a.save(),a.translate(d,f?this.endPoint+12:this.endPoint+8),a.rotate(-1*s(this.xLabelRotation)),a.font=this.font,a.textAlign=f?"right":"center",a.textBaseline=f?"middle":"top",a.fillText(b,0,0),a.restore()},this))}}),c.RadialScale=c.Element.extend({initialize:function(){this.size=q([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(a){var b=this.drawingArea/(this.max-this.min);return(a-this.min)*b},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var a=r(this.stepValue),b=0;b<=this.steps;b++)this.yLabels.push(v(this.templateString,{value:(this.min+b*this.stepValue).toFixed(a)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=q([this.height/2-this.pointLabelFontSize-5,this.width/2]),n=this.width,p=0;for(this.ctx.font=G(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),b=0;bn&&(n=a.x+d,e=b),a.x-dn&&(n=a.x+c,e=b):b>this.valuesCount/2&&a.x-c0){var d,e=c*(this.drawingArea/this.steps),f=this.yCenter-e;if(this.lineWidth>0)if(a.strokeStyle=this.lineColor,a.lineWidth=this.lineWidth,this.lineArc)a.beginPath(),a.arc(this.xCenter,this.yCenter,e,0,2*Math.PI),a.closePath(),a.stroke();else{a.beginPath();for(var g=0;g=0;b--){if(this.angleLineWidth>0){var c=this.getPointPosition(b,this.calculateCenterOffset(this.max));a.beginPath(),a.moveTo(this.xCenter,this.yCenter),a.lineTo(c.x,c.y),a.stroke(),a.closePath()}var d=this.getPointPosition(b,this.calculateCenterOffset(this.max)+5);a.font=G(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),a.fillStyle=this.pointLabelFontColor;var f=this.labels.length,g=this.labels.length/2,h=g/2,i=h>b||b>f-h,j=b===h||b===f-h;a.textAlign=0===b?"center":b===g?"center":g>b?"left":"right",a.textBaseline=j?"middle":i?"bottom":"top",a.fillText(this.labels[b],d.x,d.y)}}}}}),d.addEvent(window,"resize",function(){var a;return function(){clearTimeout(a),a=setTimeout(function(){e(c.instances,function(a){a.options.responsive&&a.resize(a.render,!0)})},50)}}()),n?define(function(){return c}):"object"==typeof module&&module.exports&&(module.exports=c),a.Chart=c,c.noConflict=function(){return a.Chart=b,c}}.call(this),function(){"use strict";var a=this,b=a.Chart,c=b.helpers,d={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'
    <% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
'};b.Type.extend({name:"Bar",defaults:d,initialize:function(a){var d=this.options;this.ScaleClass=b.Scale.extend({offsetGridLines:!0,calculateBarX:function(a,b,c){var e=this.calculateBaseWidth(),f=this.calculateX(c)-e/2,g=this.calculateBarWidth(a);return f+g*b+b*d.barDatasetSpacing+g/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*d.barValueSpacing},calculateBarWidth:function(a){return(this.calculateBaseWidth()-(a-1)*d.barDatasetSpacing)/a}}),this.datasets=[],this.options.showTooltips&&c.bindEvents(this,this.options.tooltipEvents,function(a){var b="mouseout"!==a.type?this.getBarsAtEvent(a):[];this.eachBars(function(a){a.restore(["fillColor","strokeColor"])}),c.each(b,function(a){a.fillColor=a.highlightFill,a.strokeColor=a.highlightStroke}),this.showTooltip(b)}),this.BarClass=b.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),c.each(a.datasets,function(b){var d={label:b.label||null,fillColor:b.fillColor,strokeColor:b.strokeColor,bars:[]};this.datasets.push(d),c.each(b.data,function(c,e){d.bars.push(new this.BarClass({value:c,label:a.labels[e],datasetLabel:b.label,strokeColor:b.strokeColor,fillColor:b.fillColor,highlightFill:b.highlightFill||b.fillColor,highlightStroke:b.highlightStroke||b.strokeColor}))},this)},this),this.buildScale(a.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(a,b,d){c.extend(a,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,d,b),y:this.scale.endPoint}),a.save()},this),this.render()},update:function(){this.scale.update(),c.each(this.activeElements,function(a){a.restore(["fillColor","strokeColor"])}),this.eachBars(function(a){a.save()}),this.render()},eachBars:function(a){c.each(this.datasets,function(b,d){c.each(b.bars,a,this,d)},this)},getBarsAtEvent:function(a){for(var b,d=[],e=c.getRelativePosition(a),f=function(a){d.push(a.bars[b])},g=0;g<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};b.Type.extend({name:"Doughnut",defaults:d,initialize:function(a){this.segments=[],this.outerRadius=(c.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=b.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&c.bindEvents(this,this.options.tooltipEvents,function(a){var b="mouseout"!==a.type?this.getSegmentsAtEvent(a):[];c.each(this.segments,function(a){a.restore(["fillColor"])}),c.each(b,function(a){a.fillColor=a.highlightColor}),this.showTooltip(b)}),this.calculateTotal(a),c.each(a,function(a,b){this.addData(a,b,!0)},this),this.render()},getSegmentsAtEvent:function(a){var b=[],d=c.getRelativePosition(a);return c.each(this.segments,function(a){a.inRange(d.x,d.y)&&b.push(a)},this),b},addData:function(a,b,c){var d=b||this.segments.length;this.segments.splice(d,0,new this.SegmentArc({value:a.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:a.color,highlightColor:a.highlight||a.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(a.value),label:a.label})),c||(this.reflow(),this.update())},calculateCircumference:function(a){return 2*Math.PI*(Math.abs(a)/this.total)},calculateTotal:function(a){this.total=0,c.each(a,function(a){this.total+=Math.abs(a.value)},this)},update:function(){this.calculateTotal(this.segments),c.each(this.activeElements,function(a){a.restore(["fillColor"])}),c.each(this.segments,function(a){a.save()}),this.render()},removeData:function(a){var b=c.isNumber(a)?a:this.segments.length-1;this.segments.splice(b,1),this.reflow(),this.update()},reflow:function(){c.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(c.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,c.each(this.segments,function(a){a.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(a){var b=a||1;this.clear(),c.each(this.segments,function(a,c){a.transition({circumference:this.calculateCircumference(a.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},b),a.endAngle=a.startAngle+a.circumference,a.draw(),0===c&&(a.startAngle=1.5*Math.PI),c<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'};b.Type.extend({name:"Line",defaults:d,initialize:function(a){this.PointClass=b.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(a){return Math.pow(a-this.x,2)0&&bthis.scale.endPoint?a.controlPoints.outer.y=this.scale.endPoint:a.controlPoints.outer.ythis.scale.endPoint?a.controlPoints.inner.y=this.scale.endPoint:a.controlPoints.inner.y0&&(d.lineTo(h[h.length-1].x,this.scale.endPoint),d.lineTo(h[0].x,this.scale.endPoint),d.fillStyle=a.fillColor,d.closePath(),d.fill()),c.each(h,function(a){a.draw()})},this)}})}.call(this),function(){"use strict";var a=this,b=a.Chart,c=b.helpers,d={ scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};b.Type.extend({name:"PolarArea",defaults:d,initialize:function(a){this.segments=[],this.SegmentArc=b.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new b.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:a.length}),this.updateScaleRange(a),this.scale.update(),c.each(a,function(a,b){this.addData(a,b,!0)},this),this.options.showTooltips&&c.bindEvents(this,this.options.tooltipEvents,function(a){var b="mouseout"!==a.type?this.getSegmentsAtEvent(a):[];c.each(this.segments,function(a){a.restore(["fillColor"])}),c.each(b,function(a){a.fillColor=a.highlightColor}),this.showTooltip(b)}),this.render()},getSegmentsAtEvent:function(a){var b=[],d=c.getRelativePosition(a);return c.each(this.segments,function(a){a.inRange(d.x,d.y)&&b.push(a)},this),b},addData:function(a,b,c){var d=b||this.segments.length;this.segments.splice(d,0,new this.SegmentArc({fillColor:a.color,highlightColor:a.highlight||a.color,label:a.label,value:a.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(a.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),c||(this.reflow(),this.update())},removeData:function(a){var b=c.isNumber(a)?a:this.segments.length-1;this.segments.splice(b,1),this.reflow(),this.update()},calculateTotal:function(a){this.total=0,c.each(a,function(a){this.total+=a.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(a){var b=[];c.each(a,function(a){b.push(a.value)});var d=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:c.calculateScaleRange(b,c.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);c.extend(this.scale,d,{size:c.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),c.each(this.segments,function(a){a.save()}),this.reflow(),this.render()},reflow:function(){c.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),c.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),c.each(this.segments,function(a){a.update({outerRadius:this.scale.calculateCenterOffset(a.value)})},this)},draw:function(a){var b=a||1;this.clear(),c.each(this.segments,function(a,c){a.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(a.value)},b),a.endAngle=a.startAngle+a.circumference,0===c&&(a.startAngle=1.5*Math.PI),c<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(a){this.PointClass=b.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(a),this.options.showTooltips&&c.bindEvents(this,this.options.tooltipEvents,function(a){var b="mouseout"!==a.type?this.getPointsAtEvent(a):[];this.eachPoints(function(a){a.restore(["fillColor","strokeColor"])}),c.each(b,function(a){a.fillColor=a.highlightFill,a.strokeColor=a.highlightStroke}),this.showTooltip(b)}),c.each(a.datasets,function(b){var d={label:b.label||null,fillColor:b.fillColor,strokeColor:b.strokeColor,pointColor:b.pointColor,pointStrokeColor:b.pointStrokeColor,points:[]};this.datasets.push(d),c.each(b.data,function(c,e){var f;this.scale.animation||(f=this.scale.getPointPosition(e,this.scale.calculateCenterOffset(c))),d.points.push(new this.PointClass({value:c,label:a.labels[e],datasetLabel:b.label,x:this.options.animation?this.scale.xCenter:f.x,y:this.options.animation?this.scale.yCenter:f.y,strokeColor:b.pointStrokeColor,fillColor:b.pointColor,highlightFill:b.pointHighlightFill||b.pointColor,highlightStroke:b.pointHighlightStroke||b.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(a){c.each(this.datasets,function(b){c.each(b.points,a,this)},this)},getPointsAtEvent:function(a){var b=c.getRelativePosition(a),d=c.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},b),e=2*Math.PI/this.scale.valuesCount,f=Math.round((d.angle-1.5*Math.PI)/e),g=[];return(f>=this.scale.valuesCount||0>f)&&(f=0),d.distance<=this.scale.drawingArea&&c.each(this.datasets,function(a){g.push(a.points[f])}),g},buildScale:function(a){this.scale=new b.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:a.labels,valuesCount:a.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(a.datasets),this.scale.buildYLabels()},updateScaleRange:function(a){var b=function(){var b=[];return c.each(a,function(a){a.data?b=b.concat(a.data):c.each(a.points,function(a){b.push(a.value)})}),b}(),d=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:c.calculateScaleRange(b,c.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);c.extend(this.scale,d)},addData:function(a,b){this.scale.valuesCount++,c.each(a,function(a,c){var d=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(a));this.datasets[c].points.push(new this.PointClass({value:a,label:b,x:d.x,y:d.y,strokeColor:this.datasets[c].pointStrokeColor,fillColor:this.datasets[c].pointColor}))},this),this.scale.labels.push(b),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),c.each(this.datasets,function(a){a.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(a){a.save()}),this.reflow(),this.render()},reflow:function(){c.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:c.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(a){var b=a||1,d=this.chart.ctx;this.clear(),this.scale.draw(),c.each(this.datasets,function(a){c.each(a.points,function(a,c){a.hasValue()&&a.transition(this.scale.getPointPosition(c,this.scale.calculateCenterOffset(a.value)),b)},this),d.lineWidth=this.options.datasetStrokeWidth,d.strokeStyle=a.strokeColor,d.beginPath(),c.each(a.points,function(a,b){0===b?d.moveTo(a.x,a.y):d.lineTo(a.x,a.y)},this),d.closePath(),d.stroke(),d.fillStyle=a.fillColor,d.fill(),c.each(a.points,function(a){a.hasValue()&&a.draw()})},this)}})}.call(this),window.lang=function(a,b){b||(b=""),isArray(a)||(a=[a]);var c=[];return a.forEach(function(a){c.push(translate.ru[b+a]||b+a)}),c.join(", ")},initMasks=function(a){setTimeout(function(){$(".masked-phone:visible").mask("+7(999)999-9999"),$(".masked-date:visible").mask("99.99.9999"),$(".mask-datetime:visible").mask("99.99.9999 99:99")},500)},isArray=function(a){return"[object Array]"==Object.prototype.toString.call(a)},auth_icon=function(a){var b={vkontakte:"vk",email:"envelope",google:"google-plus"};return b[a]?"icon-"+b[a]:"icon-"+a},__photo=function(a,b){return a[b]&&a[b].length>0?a[b]:(a.type||(a.type=""),"./img/"+a.type+"_"+b+".jpg")},_photo=function(a,b){if("user"==b)return a.length>1?a:"/img/emptyavatar.jpg"},isadmin=function(){return"admin"==m_site.me().role},isowner=function(a){if("user"==a.type)return a._id==m_site.me()._id},canedit=function(a){return isadmin()||isowner(a)},setCity=function(a){var b="b5ba06b0416ddba8599aaff312cc3d07ab888a40bb42e866e7572c8f8971196b",c="http://api.ipinfodb.com/v3/ip-city/?key="+b+"&format=json&callback=?";$.ajax({type:"POST",url:c,contentType:"application/json; charset=utf-8",dataType:"json",method:"GET",success:function(b){var c=b.cityName,d="2smb",e="http://api.geonames.org/search?name="+c+"&type=JSON&username="+d+"&lang=ru";$.ajax({type:"POST",url:e,success:function(b){a&&a(b.geonames[0].name)}})}})},ko.bindingHandlers.htmltocuttext={init:function(a,b,c){var d=b(),e=d.text,f=d.cut;$(a).html(e);var g=$(a).text();$(a).text(g.substring(0,f)+"...")}},ko.bindingHandlers.styler={init:function(a,b,c){void 0!==b()?setTimeout(function(){$(a).styler(),$(a).find('select, input[type="checkbox"]').styler()},0):($(a).styler(),$(a).find('select, input[type="checkbox"]').styler())}},ko.bindingHandlers.styleIt={init:function(a,b,c){$(".nav_menu").on("click",function(){$(this).parents("nav").find(".sf-menu").slideToggle()})}},ko.bindingHandlers.selectOnClick={init:function(a,b,c){b();$(a).on("click",function(){this.select()})}},roleCss=function(a){return"admin"==a?"label-success":"registered"==a?"label-warning":"label-info"},ko.bindingHandlers.maskedDate={init:function(a,b,c){$(a).mask("99.99.9999 99:99")},update:function(a,b){var c=ko.utils.unwrapObservable(b());$(a).val(moment(c).format("DD.MM.YYYY HH:mm"))}},parseBoolean=function(a){return!0===a||"true"===a},ko.bindingHandlers.mask={init:function(a,b,c){var d=ko.utils.unwrapObservable(b());$(a).mask(d)}},ko.bindingHandlers.initAccordion={init:function(a,b,c){$(a).accordion({header:".accord_caption",collapsible:!0}),$(window).resize(function(){setTimeout(function(){$(a).accordion("refresh")},0)})},update:function(a,b,c){b()();setTimeout(function(){$(a).accordion("destroy").accordion({header:".accord_caption",collapsible:!0}),$(window).resize(function(){$(a).accordion("refresh")})},0)}},ko.bindingHandlers.initMenu={init:function(a,b,c){$(a).on("click",function(){$(this).parents("nav").find(".sf-menu").slideToggle()})}},ko.bindingHandlers.initTabs={init:function(a,b,c){setTimeout(function(){if($(a).easyResponsiveTabs(),void 0!==b()){var c=$(a).find(".resp-cityTabs-list li");c.length>b()&&"function"==typeof c[b()].click&&c[b()].click()}},0)}},ko.bindingHandlers.initSlide={init:function(a,b,c){$(a).find(".toggle_link").on("click",function(a){a.preventDefault(),$(".filter_add_settings").slideToggle(function(){m_site.formExpanded(!m_site.formExpanded())}),$(".toggle_link").toggleClass("active")})}},ko.bindingHandlers.initJqSelect=function(){var a={init:function(b,c,d){if("DIV"==b.tagName)if(d.has("jqOptions")){if($(b).find("select").empty(),0!==d.get("jqOptions")().length&&0==$(b).find("select option").length){var e=_.find(ko.toJS(d.get("jqOptions")()),function(a){return void 0!==a._id?a._id===ko.unwrap(c()):a.id===ko.unwrap(c())});-1==e&&c()(ko.toJS(d.get("jqOptions")())[0].id||ko.toJS(d.get("jqOptions")())[0]._id),$(b).find("select").append(a.optionsForSelect(ko.toJS(d.get("jqOptions")()),ko.unwrap(c()))),$(b).find("select").on("refresh",function(){$(this).closest("div").on("click",function(){a.selectOnClick(this,c());for(var b=$("div [data-bind='"+$(this).attr("data-bind")+"']"),d=0;d0?b[0].val():"undefined"},selectOnClick:function(a,b){var c=(b(),$(a).find("select").val());return void 0!==c&&($(a).find("[value='"+b()+"']").removeAttr("selected"),b(c),$(a).find("[value='"+b()+"']").attr("selected","selected"),$(a).find("select").trigger("change")),!1},optionsForSelect:function(a,b){for(var c="",d=0;d"+f+""}}return c}};return a}(),ko.bindingHandlers.initJqCheckbox=function(){var a={init:function(b,c,d){"DIV"==b.tagName&&(d.has("checkboxActivator")?$(b).on("click tap",function(){a.selectOnClick(this,c(),d.has("checkboxActivator"))}):(a.setValue(b,c()()),$(b).on("click",function(){a.selectOnClick(this,c(),d.has("checkboxActivator"))})))},update:function(b,c,d){var e=c()();"DIV"==b.tagName&&(d.has("checkboxActivator")?setTimeout(function(){a.activate(b,e),$("html").click()},0):a.setValue(b,e))},setValue:function(a,b){1==b?$(a).addClass("checked"):$(a).removeClass("checked")},activate:function(a,b){1==b?$(a).addClass("active"):$(a).removeClass("active")},selectOnClick:function(a,b,c){return b(c?!$(a).hasClass("active"):!!$(a).hasClass("checked")),!1}};return a}(),ko.bindingHandlers.initMask={init:function(a,b,c){"tel"!==$(a).attr("type")?$(a).mask(b(),{reverse:!0,placeholder:" "}):$(a).maskedInput(b(),{placeholder:" "})},update:function(a,b,c){}},ko.bindingHandlers.numberEraser={init:function(a,b,c){$(a).focus(function(){"0"==$(a).val()&&$(a).val("")}),$(a).blur(function(){""==$(a).val().trim()&&$(a).val("0")})}},ko.bindingHandlers.rentControl={update:function(a,b,c){!0===b()()?($($(a).find(".resp-cityTabs-list li")[0]).removeClass("resp-tab-active"),$($(a).find(".resp-cityTabs-list li")[1]).addClass("resp-tab-active")):($($(a).find(".resp-cityTabs-list li")[1]).removeClass("resp-tab-active"),$($(a).find(".resp-cityTabs-list li")[0]).addClass("resp-tab-active"))}},ko.bindingHandlers.initCarousel={init:function(a,b,c){setTimeout(function(){$("#owl_carousel").owlCarousel({navigation:!0,singleItem:!0,transitionStyle:"backSlide"}),$("#carousel").flexslider({animation:"slide",controlNav:!1,animationLoop:!1,slideshow:!1,itemWidth:131,itemMargin:10,asNavFor:"#slider"}),$("#slider").flexslider({animation:"slide",controlNav:!1,animationLoop:!1,slideshow:!1,sync:"#carousel"})},0)}},ko.bindingHandlers.initPhotoCarousel={init:function(a,b,c){var d=ko.toJS(b());setTimeout(function(){$(a).owlCarousel({slideSpeed:250,paginationSpeed:250,goToFirst:!0,goToFirstSpeed:1e3,navigation:!1,navigationText:["prev","next"],pagination:!1,paginationNumbers:!0,responsive:!0,items:d.length,loop:!0,singleItem:!0,autoHeight:!0,autoWidth:!0,rewindSpeed:250,afterInit:function(){gallery.initGallery(d)},afterMove:function(){gallery.updateShownPhoto(d)}})},0)}},ko.bindingHandlers.bubbleTop={init:function(a,b,c){if($(".filter_box").is(":visible"))var d=$(".filter_box").height()+466;else var d=466;$(a).css({top:d}),$(window).resize(function(){var b=$(".filter_box").height()+466;$(a).css({top:b})})},update:function(a,b,c){b()();if(!$(a).is(":animated")){if($(".filter_box").is(":visible"))var d=$(".filter_box").height()+466;else var d=466;var e=$(a).position().top;$(a).animate({top:"+="+(d-e)})}}},ko.bindingHandlers.yandexMap=function(){var a,b,c={},d=[],e=[],f={init:function(g,h,i){var j=ko.unwrap(h());i.has("mapOptions")&&(c=i.get("mapOptions")()),i.has("mapMarkers")&&(d=i.get("mapMarkers")());var k=$(g).find(".cMap")[0];k.id||$(k).uniqueId();var l=function(){if(d[j])var l=d[j].center;if(a&&a.destroy(),a=new ymaps.Map(k.id,{center:l||[57.134547,65.564102],zoom:c.zoom||16,controls:c.controls||[]}),a.behaviors.disable(["scrollZoom"]),f.update(g,h,i),i.has("mapClusterer")){i.get("mapClusterer");b=new ymaps.Clusterer({preset:"islands#invertedVioletClusterIcons",groupByCoordinates:!1,clusterDisableClickZoom:!1,clusterHideIconOnBalloonOpen:!1,geoObjectHideIconOnBalloonOpen:!1,gridSize:80}),b.add(e),a.geoObjects.add(b)}else b&&(b=void 0)};ymaps.ready(l)},update:function(b,e,g){var h=ko.unwrap(e());g();void 0!==a&&(g.has("mapMarkers")&&(d=g.get("mapMarkers")(),f.reloadMarkers(e())),g.has("mapOptions")&&(c=g.get("mapOptions")(),void 0!==d[h]&&a.panTo(d[h].center,{flying:!0,checkZoomRange:!0,callback:function(a){}})))},reloadMarkers:function(c){if(e.length>0&&(b?b.removeAll():_.each(e,function(b){a.geoObjects.remove(b)})),d.length>0){e=[];var f=[[],[]];if(b?(e=_.map(d,function(a,b){return a=new ymaps.Placemark(a.center,a.content,a.style)}),b.add(e),f=b.getBounds()):(e=_.map(d,function(a,b){return new ymaps.Placemark(a.center,a.content,a.style)}),_.each(e,function(b){a.geoObjects.add(b)}),"contacts"==m_site.currentRoute()[0]&&_.each(e,function(a,b){a.events.add("click",function(a){catalog_search_map.current(b),catalog_search_map.directorVisible(!1),a.stopPropagation()})}),f=a.geoObjects.getBounds()||[[57.134547,65.564102],[57.134547,65.564102]]),void 0==d[ko.unwrap(c)]||"catalogue"==m_site.currentRoute()[0]){var g=function(){a.setBounds(f,{preciseZoom:!0,checkZoomRange:!0,zoomMargin:1,callback:function(a){}})};g(),a.events.add("sizechange",g)}}}};return f}(),ko.bindingHandlers.schemeDisk=function(){var a={init:function(b,c,d){var e=c();if(d.has("diskIndex")&&d.has("diskPath")){var f=d.get("diskIndex"),g=d.get("diskPath"),h=d.get("diskTimestamp");$(b).on("click",function(){console.log(b),a.selectDisk(b,f,e,g),h&&h(Date.now())})}},update:function(b,c,d){var e=c();if(d.has("diskIndex")&&d.has("diskPath")){var f=d.get("diskIndex");d.get("diskPath");a.checkDisk(b,f,e)}},selectDisk:function(a,b,c,d){c($(a).hasClass("selected")&&c().length==b?[]:d.slice(0,b))},checkDisk:function(a,b,c){-1!==$.inArray(b,c())?$(a).addClass("selected"):$(a).removeClass("selected")}};return a}(),ko.bindingHandlers.diskName=function(){return{init:function(a,b,c){var d=b()();if(0==d.length)$(a).text("Выберите населенные пункты"),c.has("diskDistance")&&c.get("diskDistance")(0);else{var e=$(a).closest(".estate-map-menu-panel").find(".disk")[d.length-1],f=$(a).closest(".estate-map-menu-panel").find(".disk-caption p")[d.length-1],g=$(f).text(),h=parseInt($(e).text());$(a).text(g+", до "+h+" км"),c.has("diskDistance")&&c.get("diskDistance")(h)}},update:function(a,b,c){var d=b()();if(0==d.length)$(a).text("Выберите населенные пункты"),c.has("diskDistance")&&c.get("diskDistance")(0);else{var e=$(a).closest(".estate-map-menu-panel").find(".disk")[d.length-1],f=$(a).closest(".estate-map-menu-panel").find(".disk-caption p")[d.length-1],g=$(f).text(),h=parseInt($(e).text());$(a).text(g+", до "+h+" км"),c.has("diskDistance")&&c.get("diskDistance")(h)}}}}(),ko.bindingHandlers.diskDistricts=function(){return{init:function(a,b,c){for(var d=b(),e="",f=0;f0){var g=$(a).closest(".estate-map-menu-panel").find(".disk-caption p")[f];e=e+$(g).text()+", "}}""==e&&(e="Выберите населенные пункты"),$(a).text(e.substr(0,e.length-2))},update:function(a,b,c){for(var d=b(),e="",f=0;f0){var g=$(a).closest(".estate-map-menu-panel").find(".disk-caption p")[f];e=e+$(g).text()+", "}}""==e&&(e="Выберите населенные пункты"),$(a).text(e.substr(0,e.length-2))}}}(),ko.bindingHandlers.workobjectSwitch={init:function(a,b,c){function d(){b()(!b()())}$(a).click(d)}},ko.bindingHandlers.sameWorkobjects={init:function(a,b,c){var d=b()(),e=m_site.filter;$(a).click(function(){catalog_search_models.resetFilter();var a=m_site.similarWorkobjectsCount().houseroom_query;if("newhouseroom"==m_site.workobject().buytype()&&(a=m_site.similarWorkobjectsCount().newhouseroom_query),"house"==m_site.workobject().buytype())a=m_site.similarWorkobjectsCount().house_query;else var b=d.square.summ();"commercial"==m_site.workobject().buytype()&&(a=m_site.similarWorkobjectsCount().commercial_query);var c=a.price.$gte||0,f=a.price.$lte||0,g=a.rooms||0;switch(e.common.fullSquareMax(b),e.common.fullSquareMin(b),e.common.priceMax(f),e.common.priceMin(c),g){case 1:e.common.rooms.one(!0);break;case 2:e.common.rooms.two(!0);break;case 3:e.common.rooms.three(!0);break;case 4:e.common.rooms.four(!0)}m_site.workobjects.pickUp()})}},ko.bindingHandlers.dataShowOtherOffers={init:function(a,b,c){$(a).on("click",function(){event.preventDefault(),$(this).parents("tr").toggleClass("active").next("tr.other_offers").toggle()})}},ko.bindingHandlers.dataShowFlatsCriteria={init:function(a,b,c){$(a).on("click",function(){event.preventDefault();var a=$(this).text();$(this).text($(this).attr("data-active-text")),$(this).attr("data-active-text",a),$(this).toggleClass("active").parents(".catalog_list_row").find(".table_wrap").toggle()})}},ko.bindingHandlers.dndMaster={init:function(container,dragObject,allBindings){function getMouseOffset(a,b){var c=getPosition(a);return{x:b.pageX-c.x,y:b.pageY-c.y}}function mouseUp(){dragObject().x(parseInt(dragObject().element.style.left)),dragObject().y(parseInt(dragObject().element.style.top)),document.onmousemove=null,document.onmouseup=null,document.ondragstart=null,document.body.onselectstart=null}function mouseMove(e){with(dragObject().element.style)position="absolute",top=e.pageY-$(container).offset().top-dragObject().mouseOffset.y+"px",left=e.pageX-$(container).offset().left-dragObject().mouseOffset.x+"px";return!1}function getPosition(a){for(var b=0,c=0;a.offsetParent;)b+=a.offsetLeft,c+=a.offsetTop,a=a.offsetParent;return b+=a.offsetLeft,c+=a.offsetTop,{x:b,y:c}}if(allBindings.has("canvasBackground")){var canvasHTML="",canvas=$(canvasHTML).appendTo($(container))[0];canvas.width=$(container).width(),canvas.height=$(container).height();var context=canvas.getContext("2d"),background=new Image;background.src=allBindings.get("canvasBackground"),dragObject().canvas=canvas,background.onload=function(){context.drawImage(background,0,0);canvas.toDataURL("image/png")}}$(container).find(".dnd-marker").each(function(){with(dragObject().element=this,dragObject().element.style)top=dragObject().y()+"px",left=dragObject().x()+"px";$(this).mousedown(function(a){if(1==a.which)return dragObject().mouseOffset=getMouseOffset(this,a),document.onmousemove=mouseMove,document.onmouseup=mouseUp,document.ondragstart=function(){return!1},document.body.onselectstart=function(){return!1},!1})})},update:function(container,dragObject,allBindings){var needUpdate=!1,oX=dragObject().x,oY=dragObject().y,oW=$(dragObject().element).width(),oH=$(dragObject().element).height(),cW=$(container).width(),cH=$(container).height();if(oX()>cW-oW&&(oX(cW-oW),needUpdate=!0),oX()<0&&(oX(0),needUpdate=!0),oY()>cH-oH&&(oY(cH-oH),needUpdate=!0),oY()<0&&(oY(0),needUpdate=!0),needUpdate)with(dragObject().element.style)top=oY()+"px",left=oX()+"px";if(void 0!==typeof dragObject().canvas){var canvas=dragObject().canvas,context=canvas.getContext("2d");context.clearRect(0,0,canvas.width,canvas.height);var background=new Image;background.src=allBindings.get("canvasBackground");var marker=new Image;marker.src=$(dragObject().element).css("background-image").replace("url(","").replace(")",""),background.onload=function(){context.drawImage(background,0,0),context.drawImage(marker,dragObject().x(),dragObject().y());canvas.toDataURL("image/png")}}}};var pageUpdater=function(a){a.page.subscribe(function(b){void 0!==b?a.tableViewModel.moveToPage(parseInt(b)):a.tableViewModel.moveToPage(1)}),a.page.valueHasMutated()};ko.bindingHandlers.fileUpload={init:function(a,b){a.onchange=function(){function a(a,c){"function"==typeof b()[a]?b()[a](c):b()[a]=c}if(this.files.length<1)return!1;var c=m_site.domain();switch(b().type){case"resume":c+="/api/upload/resume";break;default:return!1}a("filename","Ждите, идет загрузка файла..."),a("fileError","");var d=new FormData;if(Math.ceil(this.files[0].size/1024/1024)>10)return a("filename",""),a("fileError","Ошибка: Размер файла не должен превышать 10 Мб."),!1;d.append(b().type,this.files[0]),$.ajax({url:c,type:"POST",data:d,cache:!1,dataType:"json",processData:!1,contentType:!1,success:function(c,d){a("filename",c.name),a("field",c[b().type])},error:function(b,c,d){a("filename",""),a("fileError","Произошла серверная ошибка.")}})}}};var mainPhoto=function(a){var b="/images/noPhoto.png";return a&&a.length&&(b=(a[0]+"").trim()),b};ko.bindingHandlers.b_photo={update:function(a,b,c){var d=ko.utils.unwrapObservable(b()),e=mainPhoto(d),f=location.protocol+"//images."+window.location.hostname+"/200x-/static"+e;$(a).css("background-image",'url("'+f+'")')}},ko.bindingHandlers.w_photo={update:function(a,b,c){var d=ko.utils.unwrapObservable(b()),e=mainPhoto(d),f=location.protocol+"//images."+window.location.hostname+"/200x-/static"+e;$(a).attr("src",f)}},ko.bindingHandlers.heightEqualizer={init:function(a,b){ko.unwrap(b())}},ko.bindingHandlers.expander={init:function(a,b){var c=b(),d="."+ko.unwrap(c.value),e=ko.unwrap(c.openText)||"",f=ko.unwrap(c.closeText)||"",g=$(d);g?$(a).click(function(){$($(g)[0]).is(":visible")?g.slideUp(500,function(){e&&$(a).text(e),$(a).hasClass("expander-open")&&$(a).removeClass("expander-open").addClass("expander-hidden")}):g.slideDown(500,function(){f&&$(a).text(f),$(a).hasClass("expander-hidden")&&$(a).removeClass("expander-hidden").addClass("expander-open")})}):console.log("[email protected]: target is undefined")}},ko.bindingHandlers.autocomplete={update:function(a,b,c){var d=ko.utils.unwrapObservable(b()),e=c(),f=[];d.forEach(function(a){f.push(a.name)});var g=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.whitespace,queryTokenizer:Bloodhound.tokenizers.whitespace,local:f});$(a).typeahead("destroy"),$(a).typeahead({hint:!0,highlight:!0,minLength:1},{name:"streets",source:g}),e.typeaheadSelect&&$(a).bind("typeahead:select",function(b,c){e.typeaheadSelect&&e.typeaheadSelect(c),setTimeout(function(){$(a).typeahead("val","")},0)})}},ko.bindingHandlers.aml=function(){var a={setDeclension:function(a,b){if(b.declension){var c=ko.unwrap(b.declension);c[0]&&c[1]&&c[2]||(c=["значений","значение","значения"])}$(a).attr("data-dec",c.toString())},getDeclension:function(a){var b=a.element;if(b.attr("data-dec")){var c=b.attr("data-dec").split(",");if(c[0]&&c[1]&&c[2])return c}return["значений","значение","значения"]},getValue:function(a){var b=a.element;return b.attr("data-previous")?b.attr("data-previous").split(","):""},setValue:function(a,b){a.element.attr("data-previous",b.toString())},getContent:function(a){var b=$(a);b.addClass("aml_container");var c=b.find(".aml_block"),d=b.find(".aml_list"),e=b.find(".aml_overlay"),f=b.find(".aml_btn");return c.length||(b.append("
    "),c=b.find(".aml_block")),e.length||(b.append("
    "),e=b.find(".aml_overlay")),d.length||(b.append("
    "),d=b.find(".aml_list")),f.length||(b.append("
    "),f=b.find(".aml_btn")),{element:b,block:c,list:d,overlay:e,btn:f}},getContext:function(a){var b={val:a,options:[],chosenOptions:[]};return a.options?b.options=ko.unwrap(a.options):console.log("[email protected]: no options accessor set"),a.value?b.chosenOptions=a.value:console.log("[email protected]: no value accessor set"),b.defaultValue={id:"0",name:"Выберите значение"},ko.unwrap(a.defaultValue)&&(b.defaultValue.name=ko.unwrap(a.defaultValue)),b},bindEvents:function(b,c){b.block.click(function(){a.toggleList(b)}),b.overlay.click(function(){a.toggleList(b)}),$(window).resize(function(){a.resizeAML(b)}),c&&_.map(c,function(c){c.subscribe(function(){a.resizeAML(b)})}),$(".resp-accordion").click(function(){a.resizeAML(b)}),a.resizeAML(b)},init:function(b,c){var d=ko.unwrap(c()),e=a.getContent(b),f=d.subscribal||[];a.setDeclension(b,d),a.bindEvents(e,f)},update:function(b,c){var d=ko.unwrap(c()),e=a.getContent(b),f=a.getContext(d);a.setDeclension(b,d),e.btn.off("click"),e.btn.click(function(){e.btn.hasClass("aml_btn-active")?a.clearValue(e,f):a.toggleList(e)});var g=(a.getValue(e),ko.unwrap(f.chosenOptions));a.setValue(e,g),a.clearValue(e,f),g&&_.map(g,function(b){a.addValue(e,f,b.id)}),a.redrawList(e,f)},clearValue:function(a,b){a.block.text(b.defaultValue.name),a.btn.removeClass("aml_btn-active"),b.chosenOptions().length>0&&b.chosenOptions([])},addValue:function(b,c,d){var e=ko.unwrap(d),f=_.find(c.options,function(a){return a.id==e}),g=_.find(c.chosenOptions(),function(a){return a.id==e});void 0===f||g||c.chosenOptions.push(f),a.updateBlock(b,c)},removeValue:function(b,c,d){var e=ko.unwrap(d),f=-1;void 0!==_.find(c.chosenOptions(),function(a,b){return a.id==e&&(f=b,!0)})&&null!==f&&c.chosenOptions.splice(f,1), a.updateBlock(b,c)},updateBlock:function(b,c){var d=c.chosenOptions(),e=b.block,f=b.btn,g=a.getDeclension(b);0==d.length?(e.text(c.defaultValue.name),f.removeClass("aml_btn-active")):1==d.length?(e.text(d[0].name),f.addClass("aml_btn-active")):(e.text(d.length+" "+dec(g[0],g[1],g[2],d.length)),f.addClass("aml_btn-active"))},resizeAML:function(a){setTimeout(function(){a.element.is(":visible")&&(a.block.width(a.element.width()-a.btn.width()-2-26),a.list.width(a.element.width()-40),a.list.find(".aml_label").width(a.list.width()-15))})},toggleList:function(a){a.list.is(":visible")?(a.overlay.hide(),a.list.fadeOut(500)):(a.overlay.show(),a.list.fadeIn(500))},redrawList:function(b,c){if(c.options.length){var d=b.list;d.html(""),d.append("
    ");var e=d.find(".aml_list_wrapper"),f=_.map(c.chosenOptions(),function(a){return a.id});_.map(c.options,function(a){var b="";-1!==f.indexOf(a.id)&&(b="checked"),e.append("")}),d.find(".aml_label").width(d.width()-15),d.find(".aml_label input").styler(),d.find(".aml_label input").change(function(){var d=$(this).attr("data-value");$(this).attr("checked")?a.addValue(b,c,d):a.removeValue(b,c,d)}),e.jScrollPane({autoReinitialise:!0})}}};return a}(),ko.bindingHandlers.toggleSlide={update:function(a,b){var c=ko.unwrap(b()),d=$(a);c&&!d.is(":visible")?d.slideDown(500):!c&&d.is(":visible")&&d.slideUp(500)}},ko.bindingHandlers.multiselect={init:function(a,b){var c=ko.unwrap(b()),d=$(a),e=getMultiselectOptions(c);d.multiselect(e)},update:function(a,b){var c,d=ko.unwrap(b()),e=$(a),f=ko.unwrap(d.options)||[],g=d.optionValueAttr?d.optionValueAttr:"name";if(e.html())multiSelectUpdate(a,d);else{c=$(e.next(".aml_container_new")),e.append(buildHtmlOptions(f,d,g)),console.time("Multiselect rebuild"),e.multiselect("rebuild"),console.timeEnd("Multiselect rebuild");var h=function(){var b=$(e.next(".aml_container_new")).find(".multiselect-container");if(b.length){if(!b.hasClass("jspScrollable")){var c={autoReinitialise:!0};ko.unwrap(d.width)&&(c.contentWidth=ko.unwrap(d.width)-50),b.jScrollPane(c).bind("mousewheel",function(a){a.preventDefault()}).bind("jsp-scroll-y",function(b){$(a).parent().find(".aml_container_new").find("input").each(function(){-1!=d.value.indexOf($(this).val())&&$(this).parent().addClass("checked")})})}}else setTimeout(h,1e3)};setTimeout(h,1e3),c.find(".caret").click(function(){$(this).hasClass("cross")&&($(a).multiselect("deselectAll",!1),c.find(".jq-checkbox.checked").removeClass("checked"),$(a).multiselect("updateButtonText"),d.value([]))})}}},ko.bindingHandlers.chartHypothecary={update:function(a,b){var c=ko.unwrap(b());if($(a).html(""),c.datasets&&c.datasets.length){c.labels&&c.labels.length&&c.labels.length==c.datasets[0].data.length||(c.labels=_.map(_.range(1,c.datasets[0].data.length+1),function(a){return String(a)+" месяц"}));var d=(parseInt($(a).width())-50)/c.labels.length,e=24,f={scaleLabel:" <%=value/1000%> тыс.",scaleShowVerticalLines:!0,scaleShowHorizontalLines:!1,datasetStroke:!0,legendTemplate:'
      <% for (var i=0; i
    • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    ',multiTooltipTemplate:"<%= datasetLabel %>: <%= value %> руб.",pointHitDetectionRadius:Math.max(d/2,1),pointDotRadius:Math.max(Math.min(4,d/4),1)},g=$(a).find(".hc_block");if(g&&g.remove(),c.labels.length>e){f.pointDot=!1;var h=Math.ceil(c.labels.length/e);c.labels=_.map(c.labels,function(a,b){return b%h==0?a:""})}$(a).append("");var i=$(a).find(".hc_block")[0],j=i.getContext("2d");new Chart(j).Line(c,f)}}},ko.bindingHandlers.hrefBlank={init:function(a,b){var c=ko.unwrap(b());$(a).attr("href",c),$(a).click(function(){return window.open(c,"_blank"),!1})}};var defaultPolygonPoint1=[57.16601622808409,65.50464935302739],defaultPolygonPoint2=[57.1491512053856,65.52691574096684],defaultPolygonPoint3=[57.167050539834904,65.54681015014648];ko.bindingHandlers.polygonMap=function(){var a={defaultBoundaries:null,map:null,init:function(b,c){var d=function(e){var f=c(),g=m_site.getListObjectValues(f.polygon_object_type);e>5||google&&$("#search-popup-map").is(":visible")&&g.length?(console.log("tryInit success",g.length),a.initMap(b,c),setTimeout(a.resize,0)):setTimeout(d,500,e+1)};d(1)},update:function(b,c){google&&a.map&&google.maps.event.trigger(a.map,"resize")},resize:function(){$(".popup__content").height(window.innerHeight-240),$(".popup__polygon-map").height($(".popup__content").height()-130),$(".popup__scrolled").height($(".popup__content").height()-130),$(".popup__scrolled").customScrollbar("resize",!0)},initMap:function(b,c){var d=c(),e=new google.maps.LatLng(57.15222,65.52722),f={zoom:11,center:e,scrollwheel:!1,disableDoubleClickZoom:!0,disableAutoPan:!0,streetViewControl:!1,mapTypeId:google.maps.MapTypeId.RoadMap},g=new google.maps.Map($(b)[0],f);$(window).resize(function(){setTimeout(a.resize,0)}),oldPolygons=[];var h=m_site.getListObjectValues(d.polygon_object_type),i=catalog_search_models.filterOptions.region();h.forEach(function(b){if(b&&b.boundaries()[0]&&b.name){var c=_.find(i,function(a){return a.name==ko.unwrap(b.name)});if(c){var d=[];b.boundaries()[0].forEach(function(a){d.push(new google.maps.LatLng(a[0],a[1]))});var e=new google.maps.Polygon({paths:d,draggable:!1,editable:!1,strokeColor:c.active()?"#fb9a1a":"#9045b7",strokeOpacity:.8,strokeWeight:1,strokeWidth:2,fillColor:c.active()?"#e9c089":"#cfc3d6",fillOpacity:.35});e.activator=c.active,e.timestamp=c.timestamp,e.autoColorSet=ko.computed(function(){e.activator()?e.setOptions({strokeColor:"#fb9a1a",fillColor:"#e9c089"}):e.setOptions({strokeColor:"#9045b7",fillColor:"#cfc3d6"})}),google.maps.event.addListener(e,"click",function(){this.activator&&this.activator(!this.activator()),this.timestamp&&this.timestamp(Date.now()),"function"==typeof event.preventDefault&&event.preventDefault(),"function"==typeof event.stopPropagation&&event.stopPropagation(),"function"==typeof event.stopImmediatePropagation&&event.stopImmediatePropagation()}),attachPolygonInfoWindow(e,"

    "+b.name()+"

    ",g),oldPolygons.push(e),oldPolygons[oldPolygons.length-1].setMap(g),a.map=g}}})}};return a}(),ko.bindingHandlers.loadingWhen={init:function(a){var b=$(a),c=b.css("position");$loader=$('
    ').hide(),b.append($loader),"auto"!=c&&"static"!=c||b.css("position","relative"),$loader.css({position:"absolute",top:"50%",left:"50%","margin-left":-$loader.width()/2+"px","margin-top":-$loader.height()/2+"px"})},update:function(a,b){var c=ko.utils.unwrapObservable(b()),d=$(a),e=d.find("div.sk-fading-circle");$childrenToHide=d.children(":not(div.sk-fading-circle)"),c?($childrenToHide.css("visibility","hidden").attr("disabled","disabled"),e.show()):(e.fadeOut("fast"),$childrenToHide.css("visibility","visible").removeAttr("disabled"))}},ko.bindingHandlers.fadeVisible={init:function(a,b){var c=b();$(a).toggle(ko.unwrap(c))},update:function(a,b){var c=b();ko.unwrap(c)?$(a).fadeIn():$(a).fadeOut()}},ko.bindingHandlers.getThumbnail={init:function(a,b){var c=b(),d="images."+window.location.hostname;$(a).attr("src",d+"/200x-/static/"+c)}};var create=function(){var a=function(a){var b;return b=this.mapping||{},ko.mapping.fromJS(a,b,this)},b=function(a){var b;return b=this.mapping||{},ko.mapping.fromJSON(a,b,this)},c=function(){return ko.mapping.toJSON(this)},d=function(){return ko.mapping.toJS(this)},e=function(a){for(var b in a)_.isFunction(this[b])?this[b](a[b]):this[b]=a[b]};return function(f,g,h){if(!f)return null;var i=null;if(f.hasOwnProperty("all_of_type")&&g&&g.hasOwnProperty("id")){var j=g.id;f.all_of_type.hasOwnProperty(j)&&(i=f.all_of_type[j])}if(i||(i=new f(h)),g){var k=i.mapping||{};"string"==typeof g?ko.mapping.fromJSON(g,k,i):ko.mapping.fromJS(g,k,i)}if(f.hasOwnProperty("all_of_type")){var l=i.id();l&&(f.all_of_type[l]=i)}return i.toJS=d,i.toJSON=c,i.fromJS=a,i.fromJSON=b,i.applyDiff=e,i}}(),getById=function(a,b){return create_class.hasOwnProperty("all_of_type")&&create_class.all_of_type.hasOwnProperty(b)?create_class.all_of_type[b]:null},models={workobject:function(){ko.mapping.fromJS({autonum:0,name:"",address:{city:"",street:"",house_num:"",flat:"",region:[],adm_region:[]},cellar:2.5,lodgiacount:1,sunuselcount:1,bargine:!1,housetype:null,wallmaterial:null,price:0,flatsMinPrice:0,flatsMaxPrice:0,pricePerMeter:0,rooms:0,buytype:"houseroom",offertype:"Продажа",url:"",actualDate:"",offertype_commercial:"Продажа",agent:null,square:{kitchen:0,summ:0,living:0},floor:0,maxfloor:0,photos:[],photosInfo:[],videos:[],info:{phone:!1,lodgia:!1,lift:!1,rubish:!1,closeddvor:!1,internet:!1,parking:!1,konserg:!1,security:!1,videoobserve:!1,electrity:!1,gaz:!1,plumbing:!1,heating:!1,sewerage:!1,alarm:!1,internet:!1},marker:{x:0,y:0},nearest:{school:[],hospital:[],kindergarten:[],schoolAmount:0,hospitalAmount:0,kindergartenAmount:0},addinfo:"",managerinfo:"",search:"",created:Date.now(),modified:Date.now(),arend:!1,arend_type:"monthly",house_objecttype:"",objecttype:"",ur_status:"",createFinishDate:"01/2015",salesStartDate:"01/2014",newhouse:"",sameFlats:[],floors:[],minsquare:0,allflats:[],allflatsShown:[],showMoreButton:!1,objType:"",build_year:0,previous_price:0,last_price_decrease:Date.now(),youtube:""},this.mapping||{},this);var a=this;a.number=ko.observable(!1),a.showNumber=function(){a.number(!0)},a.date=ko.pureComputed(function(){var b=ko.unwrap(a.modified);return"string"==typeof b?moment(b).format("D MMM"):""}),a.stringinfo=ko.pureComputed(function(){var b=a.buytype(),c="";return a.address&&a.address.street&&(c+="ул. "+ko.unwrap(a.address.street)),a.address&&a.address.house_num&&"house"!=b&&(c+="д. "+ko.unwrap(a.address.house_num)),c}),a.priceFormatted=ko.pureComputed(function(){return formatNumber(a.price())}),a.pricePerMeterFormatted=ko.pureComputed(function(){return formatNumber(a.pricePerMeter())}),a.previousPriceFormatted=ko.computed(function(){return formatNumber(a.previous_price())}),a.maxPriceFormatted=ko.pureComputed(function(){return formatNumber(a.flatsMaxPrice())}),a.minPriceFormatted=ko.pureComputed(function(){return formatNumber(a.flatsMinPrice())}),a.objType=ko.pureComputed(function(){return lang(a.house_objecttype())}),a.startFormatted=ko.pureComputed(function(){var b=a.salesStartDate().split("/");return b.length<2?"":moment(b[0],"MM").format("MMMM")+" "+moment(b[1]).format("YYYY")+" г."}),a.finishFormatted=ko.pureComputed(function(){var b=a.createFinishDate().split("/");return b.length<2?"":moment(b[0],"MM").format("MMMM")+" "+moment(b[1]).format("YYYY")+" г."}),a.floorsWithoutFirst=ko.pureComputed(function(){var b=a.floors().slice(1,a.floors().length);return _.filter(a.floors(),function(b){return b===a.floors()[0]}).length==a.floors().length&&(b=[]),b}),this.myAgent=ko.pureComputed(function(){var b=a.agent();return b&&"object"==typeof b?create(models.agent,ko.toJS(b)):null}),this.mapButtonText=ko.pureComputed(function(){return m_site.workobjectMap()?"Показать фотографии":"Посмотреть на карте"}),this.newhouseLink=ko.pureComputed(function(){return"object"==typeof a.newhouse()&&a.newhouse().alias()?"/catalogue/"+a.newhouse().alias():""}),this.newhouseName=ko.pureComputed(function(){return"object"==typeof a.newhouse()&&a.newhouse().name()||""}),this.wallmaterialName=ko.pureComputed(function(){return"function"==typeof a.wallmaterial&&a.wallmaterial()&&void 0!=a.wallmaterial().name?a.wallmaterial().name():""}),this.housetypeName=ko.pureComputed(function(){return"function"==typeof a.housetype&&a.housetype()&&void 0!=a.housetype().name?a.housetype().name():""}),this.printLink=ko.pureComputed(function(){var b=a.autonum();return b?"/printcatalogue/"+b:""}),this.selfLink=ko.pureComputed(function(){var b=a.autonum();return b?"/catalogue/"+b:""}),this.oldPriceFormatted=ko.pureComputed(function(){return a.priceFormatted()}),this.hypothecaryMinimum=ko.observable(""),this.youtubeEmbed=ko.pureComputed(function(){if(this.youtube()){var a=this.youtube().split("/"),b=a[a.length-1].length>0?a[a.length-1]:a[a.length-2];if(-1!=this.youtube().indexOf("youtu")&&b.length>0)return{link:"https://youtube.com/embed/"+b+"/",status:"OK"}}return{link:"",status:"Error"}},this),this.showMoreFlats=function(){for(var b=a.allflats(),c=a.allflatsShown(),d=c.length,e=Math.min(5,Math.abs(b.length-c.length)),f=0;f"+d.name+"")}),c.join(", ")||""}),this.bankName=ko.pureComputed(function(){return a.bank()&&a.bank().name&&a.bank().name()||""}),this.bankLogo=ko.pureComputed(function(){return a.bank()&&a.bank().logo&&a.bank().logo()||""}),this.bankLink=ko.pureComputed(function(){return"/banks/"+(a.bank()&&a.bank()._id()||"")}),this.selfLink=ko.pureComputed(function(){return"/programs/"+(a._id()||"")}),this.paymentTypeString=ko.pureComputed(function(){var b=a.paymentType(),c="";return-1!=b.indexOf("annuity")&&(c+="Аннуитетный,"),-1!=b.indexOf("differentiated")&&(c+=" Дифференцированный"),c.replace(/(,$)/g,"")}),this.showTerms=ko.pureComputed(function(){return a.maximumTerm()||a.minimumTerm()}),this.myNewhouses=ko.pureComputed(function(){var b=a.newhouses();return b&&b.length&&"object"==typeof b[0]?_.map(b,function(a){return create(models.newhouse,ko.toJS(a))}):[]}),this.generalPayment=ko.pureComputed(function(){var b=m_calculator.form,c=12*parseInt(b.timePeriod().replace(/\s/g,"")),d=parseInt(b.endPeriod().replace(/\s/g,""))||0,e=b.loanAmount(),f=a.rateBefore()/12/100,g=a.rateAfter()/12/100,h=(a.paymentType(),[]),i={datasets:[{label:"Суммарный платеж",fillColor:"rgba(179, 178, 173, 0.3)",strokeColor:"#fff",pointColor:"rgba(179, 178, 173, 0.5)",pointStrokeColor:"rgba(179, 178, 173, 0.5)",pointHighlightFill:"#fff",pointHighlightStroke:"rgba(179, 178, 173, 0.75)",data:[]},{label:"Проценты",fillColor:"rgba(255, 156, 0, 1)",strokeColor:"#fff",pointColor:"rgba(255, 156, 0, 1)",pointStrokeColor:"rgba(255, 156, 0, 1)",pointHighlightFill:"#fff",pointHighlightStroke:"rgba(255, 156, 0, 1)",data:[]}]};if("annuity"==m_calculator.form.type())for(var j=e,k=0;k=d?g:f,m=e*(l+l/(Math.pow(1+l,c)-1)),n=j*l,o=m-n;j-=o,i.datasets[0].data.push(Math.ceil(parseFloat(o)+parseFloat(n))),i.datasets[1].data.push(Math.ceil(parseFloat(n))),h.push(m)}if("differentiated"==m_calculator.form.type())for(var m=e/c,k=0;k=d?g:f,o=(e-m*k)*l;i.datasets[0].data.push(Math.ceil(parseFloat(m)+parseFloat(o))),i.datasets[1].data.push(Math.ceil(parseFloat(o))),h.push(m+(e-m*k)*l)}return h&&h.length?{payment:h,chartData:i}:null}),this.payment=ko.pureComputed(function(){var b=a.generalPayment&&a.generalPayment()&&a.generalPayment().payment;if(b){var c=Math.ceil(b[0]),d=Math.ceil(b[b.length-1]);return c!==d?formatNumber(c)+"..."+formatNumber(d):formatNumber(c)}return""}),this.paymentSort=ko.pureComputed(function(){var b=a.generalPayment&&a.generalPayment()&&a.generalPayment().payment;return b?parseInt(b[0]):0}),this.chartData=ko.pureComputed(function(){var b=a.generalPayment&&a.generalPayment()&&a.generalPayment().chartData;return b||{datasets:[]}})},news:function(){var a=this;ko.mapping.fromJS({name:"",alias:"",introtext:"",created_at:"",picture:"",section:{alias:"",name:""},next:{name:"",alias:"",section:{alias:""}},prev:{name:"",alias:"",section:{alias:""}}},this.mapping||{},this),a.thumbnail200=ko.computed(function(){return result=location.protocol+"//images."+window.location.hostname+"/200x-/static"+a.picture()}),a.abspicture=ko.computed(function(){var b=a.picture();return-1==b.indexOf("http")&&-1==b.indexOf("base64")&&(b=m_site.domain()+b),b}),a.link=ko.computed(function(){return a.section&&void 0!==a.section.alias&&void 0!==a.alias?"/novosti/"+a.section.alias()+"/"+a.alias():"/novosti/"}),a.nextLink=ko.computed(function(){return a.next.section.alias()&&a.next.alias()?"../"+a.next.alias():""}),a.prevLink=ko.computed(function(){return a.prev.section.alias()&&a.prev.alias()?"../"+a.prev.alias():""}),a.sectionLink=ko.computed(function(){return void 0!==a.section?"../":""}),a.date=ko.computed(function(){if(a.created_at())var b=moment(ko.unwrap(a.created_at)).format("D MMM");else var b="";return b})},listobject_city:function(){ko.mapping.fromJS({name:"",country:null,country_region:null,boundaries:[],sortindex:""},this.mapping||{},this)},listobject_region:function(){ko.mapping.fromJS({name:"",city:"",direction:[],boundaries:[],sortindex:""},this.mapping||{},this)},listobject_adm_region:function(){ko.mapping.fromJS({name:"",city:"",boundaries:[],sortindex:""},this.mapping||{},this)},listobject_direction:function(){ko.mapping.fromJS({name:"",sortindex:""},this.mapping||{},this)}},POPUP_RATE_LIMIT_TIMEOUT=125,TAGS_PANEL_WIDTH=950,AVERAGE_LETTER_WIDTH=8,ADDITIONAL_TAG_WIDTH=55,MIN_TAG_WIDTH=ADDITIONAL_TAG_WIDTH+AVERAGE_LETTER_WIDTH,cityTabs={flats:[{name:"Районы",declension:["район","района","районов"],content:["map","list"],activeContentIndex:ko.observable(0),showControls:!0},{name:"Улицы",declension:["улиц","улицы","улиц"],content:["list"],activeContentIndex:ko.observable(0),showControls:!1}],activeTabIndex:ko.observable(0),openPopup:function(){var a=function(){console.time("openPopupMap"),m_map_popup.isLoading(!0),m_map_popup.visibleScheme(!1),m_map_popup.visibleMap(!0),m_map_popup.loadPopup(),m_map_popup.isLoading(!1),console.timeEnd("openPopupMap")};0==cityTabs.activeTabIndex()?m_listObject.refreshRegion(function(){a()}):1==cityTabs.activeTabIndex()&&a()}},countryTabs={flats:[{name:"Тракт",content:["scheme"],declension:["тракт","тракта","трактов"],activeContentIndex:ko.observable(0),showControls:!1},{name:"Районы",content:["map","list"],declension:["район","района","районов"],activeContentIndex:ko.observable(0),showControls:!0}],activeTabIndex:ko.observable(0),openPopup:function(){console.time("openPopupScheme");var a=function(){m_map_popup.visibleMap(!1),m_map_popup.visibleScheme(!0),m_map_popup.loadPopup(),console.timeEnd("openPopupScheme")};0==cityTabs.activeTabIndex()?a():1==cityTabs.activeTabIndex()&&m_listObject.refreshRegion(function(){a()})}},m_map_popup={isLoading:ko.observable(!1),visibleMap:ko.observable(!1),visibleScheme:ko.observable(!1),viewMode:ko.observable("alphabet"),confirmSearch:function(){m_map_popup.visibleMap(!1),m_map_popup.visibleScheme(!1),m_map_popup.disposeComputed(),catalog_search.searchCount()},initScrollbar:function(){$(".popup__scrolled").customScrollbar({hScroll:!1,wheelSpeed:10,autoReinitialize:!0})},viewModeAlphabet:function(){m_map_popup.viewMode("alphabet")},viewModeRegion:function(){m_map_popup.viewMode("region")},tS:function(){this.active(!this.active()),this.timestamp(Date.now())},loadPopup:function(){console.time("loadPopup"),m_map_popup.initScrollbar(),ko.bindingHandlers.polygonMap.resize(),console.timeEnd("loadPopup")},getTabs:function(){return m_map_popup.visibleMap()?cityTabs:countryTabs},getActiveTab:function(){var a=m_map_popup.getTabs();return a.flats[a.activeTabIndex()]},changeView:function(a){console.time("changeView"),m_map_popup.getActiveTab().activeContentIndex(a),ko.bindingHandlers.polygonMap.resize(),m_map_popup.initScrollbar(),console.time("changeView")},changeTab:function(a){console.time("changeTab"),m_map_popup.isLoading(!0),m_map_popup.reinitializeRegions(),m_map_popup.disposeComputed(),m_map_popup.initializeComputed(),m_map_popup.updateStreetsHidden(),setTimeout(function(){var b=m_map_popup.getTabs();(b===cityTabs&&0==a||b===countryTabs&&1==a)&&m_listObject.refreshRegion(),b.activeTabIndex(a),ko.bindingHandlers.polygonMap.resize(),m_map_popup.initScrollbar(),m_map_popup.isLoading(!1),console.timeEnd("changeTab")},0)},updateStreetsHidden:function(){console.time("updateStreetsHidden");var a=catalog_search_models.filterOptions.region().filter(function(a){return a.active()}).map(function(a){return a.name}),b=catalog_search_models.filterOptions.streets();a.length?b.forEach(function(b){b.hidden(-1==a.indexOf(b.region))}):b.forEach(function(a){a.hidden(!1)}),console.timeEnd("updateStreetsHidden")},calculateTagWidth:function(a){return a.length*AVERAGE_LETTER_WIDTH+ADDITIONAL_TAG_WIDTH},reinitializeRegions:function(){console.time("reinitializeRegions"),catalog_search_models.filterOptions.region().forEach(function(a){var b=a.active();a.active=ko.observable(b)}),console.timeEnd("reinitializeRegions")},initializeComputed:function(){m_map_popup.activeRegionTags=ko.pureComputed({read:function(){console.time("activeRegionTags");var a=catalog_search_models.filterOptions.region().sort(function(a,b){return a.timestamp()0&&(a.rooms=c),a},a.parseNum=function(a,b,c){var d=0;return b[c]&&(d=Number((b[c]+"").replace(/\s/g,""))),d>0&&(a[c]=d),a},a.setCheckbox=function(a,b,c){return b[c]&&(a[c]=!0),a},a.setString=function(a,b,c){return b[c]&&""!=b[c]&&(a[c]=b[c]),a},a.setRent=function(a){return-1!=vars.buytype().indexOf("rent")&&(a.rent=!0),a},a.getBuyType=function(){var a="houseroom";switch(vars.buytype()){case"flat":case"flatrent":a="houseroom";break;case"house":case"houserent":a="house";break;case"commercial":case"commercialrent":a="commercial";break;case"newhouseroom":a="newhouseroom";break;case"newhouse":a="newhouse";break;case"deals":a="special"}return a},a.setBuytype=function(b){return b.buytype=a.getBuyType(),b},a.setTag=function(a){return vars.tag()&&(a.tag=vars.tag()),a},a.setObjectType=function(a,b){var c=[];return b.separateBuilding&&c.push("separateBuilding"),b.temporaryBuilding&&c.push("temporaryBuilding"),b.builtinFacility&&c.push("builtinFacility"),b.parcel&&c.push("parcel"),b.industrialBase&&c.push("industrialBase"),c.length>0&&(a.objectType=c),a},a.setArray=function(a,b,c){return b[c].length>0&&(a[c]=b[c]),a},a.parseQueryString=function(a){var b={};a=decodeURIComponent(a),0===a.indexOf("?")&&(a=a.substr(1));var c=a.split("&");if(c.length>0)for(var d=0;d0&&b.forEach(function(b){$("#"+a+"_select").multiselect("select",b)})},a.sortListobjectData=function(a){return a.sort(function(a,b){return a.timestamp()0&&(d.type=g),d=c.setCheckbox(d,f,"electricity"),d=c.setCheckbox(d,f,"gas"),d=c.setCheckbox(d,f,"plumbing"),d=c.setCheckbox(d,f,"heating"),d=c.setCheckbox(d,f,"sewerage"),d=c.parseNum(d,f,"priceMin"),d=c.parseNum(d,f,"priceMax"),d=c.setString(d,f,"autonum"),d=c.setObjectType(d,f),d=c.setRent(d),d=c.setBuytype(d),d=c.setTag(d),d=c.setArray(d,f,"houseType"),d=c.setArray(d,f,"wallmaterial");var h=a.getSelectedRegions();h.length>0&&(d.region=h);var i=a.getSelectedStreets();i.length>0&&(d.streets=i);var j=a.getSelectedDirections();j.length>0&&(d.tract=j)}return b&&(d.skip=a.limit()*a.page(),d.limit=a.limit()),d.sort=a.sortField(),!1===a.sortOrder()&&""!==d.sort&&(d.sort="-"+d.sort),d},a.filterHasDefaultValues=ko.computed(function(){var b=ko.toJS(a.filterData),c=ko.toJS(a.defaultFilterData);return objectHash.sha1(b)==objectHash.sha1(c)}),a.resetFilter=function(){m_map_popup.resetPopupData();var b=a.defaultFilterData;a.setFilterFromSource(b)},a.setFilterFromSource=function(b){var c=a.filterData();_.each(_.keys(b),function(d){"true"===b[d]&&(b[d]=!0),"false"===b[d]&&(b[d]=!1),b[d].constructor===Array?c[d](jQuery.extend([],b[d])):c[d](b[d]),"houseType"!==d&&"wallmaterial"!==d||catalog_search_helpers.updateMultiselect(d,b[d]),"region"===d&&b[d].length>0&&(b[d].forEach(function(b){a.filterOptions.region().forEach(function(a){a.name==b&&a.active(!0)})}),m_map_popup.regionTagsCount(b[d].length)),"streets"===d&&b[d].length>0&&(b[d].forEach(function(b){a.filterOptions.streets().forEach(function(a){a.name==b&&a.active(!0)})}),m_map_popup.streetTagsCount(b[d].length)),"directions"===d&&b[d].length>0&&(b[d].forEach(function(b){a.filterOptions.streets().forEach(function(a){a.name==b&&a.active(!0)})}),m_map_popup.directionTagsCount(b[d].length))})},a}(),catalog_search=function(){var a=this;return a.initDone=!1,a.init=function(){catalog_search_models.setDefaultFilterData(),catalog_search_models.resetFilter(),catalog_search_models.loadFilterData(),catalog_search_urls.parseUrl(),a.initDone=!0;var b=catalog_search_helpers.getBuyType();a.changeBuyType(b)},a.changeBuyType=function(b){a.initDone&&(a.data([]),a.type(b),a.formExpanded(!1),a.search(!0))},a.type=ko.observable(),a.loading=ko.observable(!1),a.count=ko.observable(0),a.formExpanded=ko.observable(!1),a.formVisible=ko.observable(!1),a.toggleExpand=function(){a.formExpanded(!ko.unwrap(a.formExpanded))},a.data=ko.observableArray(),a.beforeSearch=function(b,c){b&&catalog_search_models.page(0),a.loading(!0),c()},a.checkFilter=function(){setTimeout(function(){a.formVisible(m_site.arrayInArray(pager.page.route,catalog_search_models.formRoutes))},0)},a.applyResults=function(b,c){var d=a.data(),e=[];e=_.map(b,function(a){return void 0!==typeof a.sameFlats&&(a.sameFlats=_.map(a.sameFlats,function(a){return a.priceFormatted=formatNumber(a.price),a})),void 0!==typeof a.allflats&&(a.allflats=_.map(a.allflats,function(a){return create(models.workobject,a)})),create(models.workobject,a)}),c?a.data(e):a.data(d.concat(e)),a.loading(!1),catalog_search_urls.makeUrlFromFilter()},a.searchButtonClick=function(){"/"==window.location.pathname&&pager.navigate("catalogue/flat"),1==m_site.mode()?catalog_search_map.searchOnMap():a.search(!0)},a.search=function(b){a.beforeSearch(b,function(){$.ajax({type:"POST",data:ko.toJS(catalog_search_models.makeFilterData(!0)),url:"/api/workobjects",success:function(c){a.applyResults(c.content,b),a.showLoadMore(a.data().length0){d=[];var h=[[],[]];d=_.map(c,function(a,b){return a=new ymaps.Placemark(a.center,a.content,a.style)}),b.add(d),h=b.getBounds();var i=function(){a.setBounds(h,{preciseZoom:!0,checkZoomRange:!0,zoomMargin:1})};i(),a.events.add("sizechange",i)}}};return e}();var catalog_search_map=function(){var a=this;return a.directorVisible=ko.observable(!0),a.markers=ko.observableArray([]),a.contactsMarkers=ko.observableArray([]),a.current=ko.observable(0),a.options=ko.observable({zoom:14,controls:["zoomControl"]}),a.applyResultsOnMap=function(b){function c(b){if(data.content.push(create(models.workobjectMarker,b)),void 0!==b.loc&&void 0!==b.name&&null!=b.photos){var c={center:b.loc,content:{hintContent:b.name,balloonContentBody:a.getWorkobjectBalloon(b),balloonContentHeader:b.name,clusterCaption:b.name},style:{iconLayout:"default#image",iconImageHref:"/images/map_marker.png",iconImageSize:[28,35],iconImageOffset:[-14,-35],hideIconOnBalloonOpen:!0}};d.push(c)}}a.markers([]),data.content=[];var d=[];_.each(b,c),a.markers(d),catalog_search.loading()&&catalog_search.loading(!1)},a.getWorkobjectBalloon=function(a){if(a.alias){var b="'/catalogue/"+a.alias+"/'";return'

    '+a.photos.length+' фото

    от '+a.flatsMinPrice+' руб.

    Район:
    '+a.address.region.name+'

    Материал:
    '+a.wallmaterial?a.wallmaterial.name:"
    "}var b="'/catalogue/"+a.autonum+"/'";return'

    '+a.photos.length+' фото

    '+a.price+' руб.

    '+a.pricePerMeter+' руб./кв.м

    Площадь, м2:

    '+a.square.summ+"/"+a.square.living+"/"+a.square.kitchen+'

    Комнат: '+a.rooms+'

    Этаж: '+a.floor+"/"+a.maxfloor+"
    "},a.searchOnMap=function(){catalog_search.loading(!0),$.ajax({type:"POST",data:ko.toJS(catalog_search_models.makeFilterData(!1)),url:"/api/workobjects/mapinfo",success:function(b){a.applyResultsOnMap(b)}})},a}(),catalog_search_urls=function(){var a=this;return a.parseUrl=function(){a.setFilterFromUrl()},a.makeUrlFromFilter=function(){var b=window.location.pathname,c=ko.toJS(a.filterData());_.each(_.keys(c),function(b){c[b]==a.defaultFilterData[b]&&delete c[b]});var d="?"+$.param(c);if("?"==d)return b;window.history.pushState("","",b+d)},a.setFilterFromUrl=function(){var a=window.location.search,b=catalog_search_helpers.parseQueryString(a);jQuery.isEmptyObject(b)||catalog_search_models.setFilterFromSource(b)},a}(),gallery={shownPhoto:ko.observable({id:0,path:""}),startId:ko.observable(0),preparedPhotos:ko.observableArray([]),preparedAmount:ko.observable(5),preparePhotos:function(a){a.length>gallery.preparedAmount()&&gallery.preparedAmount(gallery.preparedAmount()-1);for(var b=gallery.preparedAmount(),c=gallery.startId();c>=a.length;)c-=a.length;for(;c<0;)c+=a.length;var d=a.slice(c,c+b),e=b-d.length;if(e>0){for(var f=a.slice(0,e);f.length0)){var e=a.indexOf("ул.");if(-1!=e){var f=catalog_search.data()[0].address.region()[0];a=a.slice(0,e-1)+" "+f+", "+a.slice(e)}else{var f=catalog_search.data()[0].address.region()[0],g=a.indexOf("Тюмень");a=a.slice(0,g-1)+" "+f+", "+a.slice(g)}}}else a=a.replace(new RegExp(/( д\. [а-я0-9]*\,)/),",");return a},customPage:{name:ko.observable("404"),text:ko.observable("404 - Страница не найдена"),alias:ko.observable("404"),prevUrl:"",isLoading:ko.observable(!1),isNotLoading:ko.observable(!0)},loadCustomPage:function(){var a=m_site.domain()+"/api/pagedata/"+vars.customPage();m_site.customPage.prevUrl!==a&&(m_site.customPage.prevUrl=a,$.getJSON(a,null,function(a){for(var b in a)void 0==m_site.customPage[b]?m_site.customPage[b]=ko.observable(a[b]):m_site.customPage[b](a[b])}))},loadAgent:function(){controller.loadObject("agent"),vars.buytype("flat"),setTimeout(function(){catalog_search.search(!0)},0)},loadBank:function(){controller.loadObject("bank")},loadProgram:function(){controller.loadObject("program")},domain:ko.observable(""),mode:ko.observable(3),formExpanded:ko.observable(!1),printPage:function(a){window.print()},navigate:function(a){pager.navigate(a)},getTabLink:function(a,b){var c="";switch(b){case"flat":case"flatrent":c=a?"flatrent":"flat";break;case"house":case"houserent":c=a?"houserent":"house";break;case"commercial":case"commercialrent":c=a?"commercialrent":"commercial";break;case"newhouseroom":case"newhouse":c=a?"newhouse":"newhouseroom";break;default:c=a?"flatrent":"flat"}return c},getTabCount:function(a,b){return ko.computed(function(){var c=0;return void 0!==m_site.summary[m_site.getTabLink(a,b)]&&(c=m_site.summary[m_site.getTabLink(a,b)].count()),c})},popupNavigate:function(a){var b=m_site.currentPath();m_site.savePageScroll(!0),-1!==$.inArray(b,m_site.popupPaths)?"/"==b.substr(b.length-1)?m_site.navigate(b+"popup/"+a):m_site.navigate(b+"/popup/"+a):"/"==b.substr(b.length-1)?m_site.navigate(b+a):m_site.navigate(b+"/"+a),m_site.savePageScroll(!0),m_site.currentScroll($(window).scrollTop())},popupReturn:function(){return"popup"==m_site.currentRoute()[m_site.currentRoute().length-2]?"../../":"../"},savePageScroll:ko.observable(!1),currentScroll:ko.observable(0),me:ko.observable(),currentPath:ko.observable(),currentRoute:ko.observableArray(),currentPage:ko.observable(),search:ko.observable(""),paths:[{name:"Велижанский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Салаирский тракт",distance:ko.observable(0),full:[1,2,3,4,5],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Ирбитский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6,7],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Московский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6,7,8],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Червишевский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6,7,8],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Ялуторовский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6,7],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Старотобольский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Тобольский тракт",distance:ko.observable(0),full:[1,2,3,4,5,6,7,8],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Центральный",distance:ko.observable(0),full:[1],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Ленинский",distance:ko.observable(0),full:[1],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Восточный",distance:ko.observable(0),full:[1],selected:ko.observableArray([]),timestamp:ko.observable(0)},{name:"Калининский",distance:ko.observable(0),full:[1],selected:ko.observableArray([]),timestamp:ko.observable(0)}],message:{data:{name:ko.observable(""),email:ko.observable(""),phone:ko.observable(""),text:ko.observable(""),type:ko.observable(""),agent:ko.observable(""),workobject:ko.observable(""),resume:ko.observable(""),rawName:ko.observable(""),fileError:ko.observable(""),alreadyClient:ko.observable(!1)},status:ko.observable(0),zeroStatus:function(){m_site.message.status(0)},refresh:function(){m_site.message.status(0),m_site.message.data.text(""),m_site.message.data.type(""),mailObjects.agent(null),m_site.message.data.agent(null),m_site.message.data.workobject(""),m_site.arrayInArray(pager.page.route,[["catalogue","?","popup-proposal"],["catalogue","?","popup-askrieltor"]])&&m_site.message.data.workobject(vars.workobject()),m_site.message.data.alreadyClient(!1)},send:function(a,b){$(b).closest("form").find(".popup-error-message").remove();var c=$(b).closest("form").find(".popup-required"),d=!1;if($.each(c,function(a,b){if($(b).removeClass("popup-input-has-error"),""==$(b).val())d=!0,$(b).addClass("popup-input-has-error"),"INPUT"==$(b)[0].tagName&&$("").insertAfter($(b));else if("email"==$(b).attr("type")){var c=/^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;c.test($(b).val())||(d=!0,$(b).addClass("popup-input-has-error"),"INPUT"==$(b)[0].tagName&&$("").insertAfter($(b)))}}),!d){m_site.message.status(1),m_site.message.data.type(a);var e=m_site.message.data;console.log("[email protected]:",ko.toJS(e)),o.workobject()&&o.workobject()._id&&(e.workobject=o.workobject()._id),mailObjects.agent()&&e.agent(mailObjects.agent()),("askrieltor"==a||"proposal"==a)&&m_site.workobject&&m_site.workobject()&&"function"==typeof m_site.workobject().myAgent&&e.agent(m_site.workobject().myAgent()._id()),"subrequest"==a&&(e.filter=ko.toJS(catalog_search_models.makeFilterData(!1))),e.favourites=m_favourites.getFavouritesArray(),$.ajax({type:"POST",url:m_site.domain()+"/api/sendmessage",data:e,success:function(){m_site.message.analytics($(b).attr("analytics-category"),$(b).attr("analytics-label")),m_site.message.status(2),mailObjects.agent(null)},error:function(){m_site.message.status(3)}})}},analytics:function(a,b){switch(b){case"contact-page":yaCounter965394.reachGoal(a+"-contact-page");break;default:yaCounter965394.reachGoal(a+"-sent")}switch(a){case"callback":gtag("event","callback_up",{event_category:"callback",event_action:"up"});break;case"question":gtag("event","question_up",{event_category:"question",event_action:"up"});break;case"lead":gtag("event","lead_sent",{event_category:"lead",event_action:"sent"});break;case"askrieltor":gtag("event","askrieltor_sent",{event_category:"askrieltor",event_action:"sent"});break;case"resume":gtag("event","resume_sent",{event_category:"resume",event_action:"sent"});break;case"subscribe":gtag("event","subscribe_sent",{event_category:"subscribe",event_action:"sent"})}}},popupPaths:["","/","catalogue","catalogue/","rieltors","rieltors/","banks","banks/","programs","programs/","news","news/","news/photoalbum","news/photoalbum/"],arrayInArray:function(a,b){null!==a&&a.forEach(function(a,b,c){c[b]=a.split("?")[0]});for(var c=0;cb.name.toUpperCase()})})}),c},deferEvaluation:!0}),gRBI:function(a,b){m_site.getRegionsByAlphabet();return m_site.getRegionsByAlphabet()[a].regions[b]},gRA:function(a,b){return m_site.gRBI(a,b).active},getRegionsListHtml:function(){var a=m_site.getRegionsByAlphabet(),b="
      ";return a.forEach(function(a,c){b+='
    • '+a.letter+"
    • ",a.regions.forEach(function(a,d){b+='
    • '+a.name+"
    • "})}),b+="
    "},applyRegionList:function(){console.time("applyRegionList"),ko.applyBindings(m_map_popup,document.getElementById("regions_list")),console.timeEnd("applyRegionList")},removeRegionTag:function(a){catalog_search_models.filterOptions.region().forEach(function(b){b.name==a&&b.active(!1)})},activateAllRegions:function(){console.time("activateAllRegions"),m_map_popup.isLoading(!0);var a=catalog_search_models.filterOptions.region();console.log("[email protected]:",a.length),a.forEach(function(a){a.active(!0)}),m_map_popup.isLoading(!1),console.timeEnd("activateAllRegions")},deactivateAllRegions:function(){console.time("deactivateAllRegions"),m_map_popup.isLoading(!0),catalog_search_models.filterOptions.region().forEach(function(a){a.active(!1)}),m_map_popup.regionTagsCount(0),m_map_popup.isLoading(!1),console.timeEnd("deactivateAllRegions")},tryChooseRegion:function(a){console.time("tryChooseRegion");var b=m_site.popupSearchRegion()||a;if(b){var c=catalog_search_models.filterOptions.region(),d=_.find(c,function(a){return a.name==b});d&&(console.log("tryChooseRegion",d.name),d.active(!0),m_site.popupSearchRegion("")),console.timeEnd("tryChooseRegion")}},getDirectionFilterByCities:ko.pureComputed({read:function(){return m_site.paths},deferEvaluation:!0}).extend({rateLimit:{timeout:200,method:"notifyWhenChangesStop"}}),removeDirectionTag:function(a){a.direction.selected([])},activateAllDirections:function(){var a=m_site.getDirectionFilterByCities();console.log("[email protected]:",a.length),a.forEach(function(a){a.selected(a.full)})},deactivateAllDirections:function(){var a=m_site.getDirectionFilterByCities();console.log("[email protected]:",a.length),a.forEach(function(a){a.selected([])}),m_map_popup.directionTagsCount(0)},popupSearchStreet:ko.observable(""),getStreetsByAlphabet:ko.pureComputed({read:function(){var a=[],b=catalog_search_models.filterOptions.streets(),c=[];return b.forEach(function(b){b.letter=b.name[0].toUpperCase(),-1==a.indexOf(b.letter)&&a.push(b.letter)}),a.sort().forEach(function(a){c.push({letter:a,streets:b.filter(function(b){return b.letter==a}).sort(function(a,b){return a.name.toUpperCase()>b.name.toUpperCase()})})}),c},deferEvaluation:!0}),gSBI:function(a,b){m_site.getStreetsByAlphabet();return m_site.getStreetsByAlphabet()[a].streets[b]},gSA:function(a,b){return m_site.gSBI(a,b).active},gSH:function(a,b){return m_site.gSBI(a,b).hidden},getStreetsListHtml:function(){var a=m_site.getStreetsByAlphabet(),b="
      ";return a.forEach(function(a,c){b+='
    • '+a.letter+"
    • ",a.streets.forEach(function(a,d){b+='
    • '+a.name+"
    • "})}),b+="
    "},applyStreetList:function(){ko.applyBindings(m_map_popup,document.getElementById("streets_list"))},removeStreetTag:function(a){a=a.slice(4),catalog_search_models.filterOptions.streets().forEach(function(b){b.name==a&&b.active(!1)})},activateAllStreets:function(){catalog_search_models.filterOptions.streets().forEach(function(a){a.active(!0)})},deactivateAllStreets:function(){console.time("deactivateAllStreets");var a=catalog_search_models.filterOptions.streets();console.log("[email protected]:",a.length),a.forEach(function(a){a.active(!1)}),m_map_popup.streetTagsCount(0),console.timeEnd("deactivateAllStreets")},tryChooseStreet:function(a){console.time("tryChooseStreet") ;var b=m_site.popupSearchStreet()||a;if(b){var c=catalog_search_models.filterOptions.streets(),d=_.find(c,function(a){return a.name==b});d&&(d.active(!0),m_site.popupSearchStreet("")),console.timeEnd("tryChooseStreet")}},chosenDepartment:ko.observable("53e83b17c18dfc9b6c00000b"),homeNews:ko.observableArray([]),tags:ko.observableArray([]),singleNews:ko.observable(),photoalbum:ko.observable(),vacancy:ko.observableArray([]),workobject:ko.observable(),departments:ko.observableArray([]),workobjectMap:ko.observable(!1),loadHomeNews:function(){m_site.homeNews([]),$.getJSON(m_site.domain()+"/api/pageshome",function(a){m_site.homeNews(_.map(a.content,function(a){return create(models.news,a)}))})},loadSingleNews:function(){m_site.photoalbum([]),$.getJSON("/api/news/"+vars.news(),null,function(a){m_site.photoalbum(create(News,a))})},loadTags:function(){m_site.tags([]),$.getJSON(m_site.domain()+"/api/tags",function(a){var b=[];b=_.map(a,function(a){return create(Tag,a)}),m_site.tags(b)})},loadNewsByAlias:function(){m_site.singleNews(null),$.getJSON(m_site.domain()+"/api/pagebyalias/"+vars.news(),null,function(a){a.page.next=a.next[0],a.page.prev=a.prev[0],m_site.singleNews(create(models.news,a.page))})},loadVacancy:function(){$.getJSON(m_site.domain()+"/api/vacancies/",null,function(a){var b=[],c=0;_.each(a,function(a){a.published&&(b[c]=create(Vacancy,a),c++)}),m_site.vacancy(b)})},similarWorkobjects:ko.observableArray(null),similarWorkobjectsCount:ko.observable({houseroom:0,newhouseroom:0,house:0,comercial:0,houseroom_query:{},newhouseroom_query:{},house_query:{},commercial_query:{}}),printableAgent:function(){controller.loadObject("agent"),$(".main_top,header,footer,nav").hide()},printableWorkobject:function(){m_site.loadWorkobject(function(){m_object_print.initPrintScreen()}),$(".main_top,header,footer,nav").hide()},printable:function(){$(".main_top,header,footer,nav").hide()},loadWorkobject:function(a){function b(a,b){if(null!==a&&Object.keys(a).length&&a.photos.length>0){var c=0;a.videos&&a.videos.length&&(c=a.videos.length);a.photos&&a.photos.length;a.photosInfo=ko.observableArray([]),$.getJSON("/api/workobject/"+a._id+"/getphotos",function(b){var d=0,e=[];if(b.forEach(function(b){var c={id:d,type:ko.observable("photo"),url:ko.observable(b.thumbnail),name:ko.observable(a.name),thumbnail:ko.observable(b.thumbnail)};b.original?c.original=ko.observable(b.original):c.original=ko.observable(b.thumbnail),e.push(c),d++}),c)for(var f=0;f0&&(b.photos=_.map(b.photos,function(a){return m_site.domain()+a}),b.photosInfo=_.map(b.photosInfo,function(a){return a.url=m_site.domain()+a.url(),a})),c.push(create(Workobject,b))}),c.length||(c=null),m_site.similarWorkobjects(c)}),null!==a&&Object.keys(a).length&&"newhouse"!==a.buytype){var d=m_site.domain()+"/api/workobject/"+vars.workobject()+"/similarcount/";$.getJSON(d,null,function(a){m_site.similarWorkobjectsCount(a)})}if(null!=a&&Object.keys(a).length?m_site.workobject(create(models.workobject,a)):m_site.workobject(create(models.workobject,{isactive:ko.observable(!1),state:ko.observable("Does not exist")})),null!==a&&Object.keys(a).length){catalog_search_map.markers([]);var e={iconLayout:"default#image",iconImageHref:"images/map_marker.png",iconImageSize:[28,35],iconImageOffset:[-14,-35]};a.loc||(a.loc=[57.134547,65.564102]);var f=a.loc;gis2lib.getPoints([a.buytype,f],function(c){m_site.workobject().loc=ko.observable(c.loc);var d={center:[c.loc[0]||57.134547,c.loc[1]||65.564102],content:{hintContent:a.name},style:e};m_site.workobject().nearest.kindergartenAmount(c.kindergarten.length),m_site.workobject().nearest.schoolAmount(c.school.length),m_site.workobject().nearest.hospitalAmount(c.hospital.length),m_site.workobject().nearest.kindergarten(c.kindergarten),m_site.workobject().nearest.school(c.school),m_site.workobject().nearest.hospital(c.hospital);var f=_.map(c.hospital.concat(c.school).concat(c.kindergarten),function(a){return{center:[Number(a.lat),Number(a.lon)],content:{hintContent:a.name}}});f.unshift(d),catalog_search_map.markers(f),catalog_search_map.current.valueHasMutated(),b&&b()})}else b&&b();$.ajax({url:m_site.domain()+"/api/stats",type:"POST",data:{id:m_site.workobject()._id(),fp:fingerPrint,timezone:(new Date).getTimezoneOffset(),productSub:navigator.productSub,type:"site"}})}var c=m_site.flats;c.dataChess([]),c.tableViewModel.items([]),m_site.workobject(null),c.mode(4),setTimeout(function(){var c=isNaN(Number(vars.workobject())),d=m_site.domain()+"/api/workobject/"+vars.workobject()+"/detailed";c&&(d=m_site.domain()+"/api/newhouse/"+vars.workobject()+"/detailed"),$.getJSON(d,null,function(d){null!==d&&Object.keys(d).length&&c&&(d.buytype="newhouse"),b(d,a)})},0)},loadDepartments:function(){m_site.departments([]);var a=m_site.domain()+"/api/departments";$.getJSON(a,null,function(b){var c=_.filter(b.content,function(a){return a.published});m_site.departments(_.map(c,function(a){return create(Department,a)})),catalog_search_map.contactsMarkers([]);var d=[];_.each(m_site.departments(),function(b,c){b.address()&&(a="https://geocode-maps.yandex.ru/1.x/?geocode=Тюмень, "+b.address()+"&format=json&results=1",$.getJSON(a,null,function(a){var e=a.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(" ").reverse();e[0]=parseFloat(e[0]),e[1]=parseFloat(e[1]),d[c]={center:e,content:{hintContent:b.name()},style:{iconLayout:"default#image",iconImageHref:"/images/map_marker.png",iconImageSize:[28,35],iconImageOffset:[-14,-35],hideIconOnBalloonOpen:!0}}}))}),setTimeout(function(){catalog_search_map.contactsMarkers(d),catalog_search_map.current.valueHasMutated();var a=ko.toJS(m_site.departments());a.unshift({_id:"",name:"Все офисы"}),m_site.agents.departments(a)},0)})},init:function(a){m_site.refresh(a),m_site.loadGlobals()},agentsOnline:ko.observableArray([]),refresh:function(a){$.getJSON("/api/agentsonline",function(b){m_site.agentsOnline(b),$.getJSON("/api/lendingspecialist",function(b){m_calculator.specialist(create(models.agent,b)),console.timeEnd("refresh"),a&&a()})})},loadGlobals:function(a){$.get("/api/globals",function(b){var c=_.find(b,function(a){return"INITIAL_FEE_PERCENT"==a.alias});m_calculator.INITIAL_FEE_PERCENT=c?String(c.value):"20";var d=_.find(b,function(a){return"TIME_PERIOD"==a.alias});m_calculator.TIME_PERIOD=d?String(d.value):"20",m_calculator.resetData(),a&&a()})},breadcrumbsCompute:function(){m_site.currentPath(window.location.pathname.substring(1)),m_site.currentRoute(m_site.currentPath().split("/"))},isCurrentPage:function(a){return-1!=m_site.currentRoute().indexOf(a)},isRootCurrentPage:function(a){return pager.page.find(a).isVisible()},loader:function(a,b){var c={},d=$('
    ');return c.load=function(){$(b).empty(),$(b).append(d)},c.unload=function(){d.remove()},c},getListObjectValues:function(a){var b=[];return m_site.listobjectsArray().forEach(function(c){c.name==a&&(b=c.objects)}),b},listobjectsArray:ko.observableArray([]),fetchUpdatedListObjectType:function(a,b){$.ajax({url:"/api/listobject/getupdated",type:"GET",data:{type:a},success:function(c){m_site.processListObjectsFromServer(c,a,function(){return b&&b()})}})},processListObjectsFromServer:function(a,b,c){for(var d in a){var e,f=!1,g=0==b||b==d;if("city"==d||"region"==d||"adm_region"==d||"direction"==d){var h=[];a[d].forEach(function(a){h.push(create(models["listobject_"+d],a))}),e=h}else e=a[d];m_site.listobjectsArray().forEach(function(a,b){a.name==d&&g&&(f=!0,m_site.listobjectsArray()[b].objects=e)}),!f&&g&&m_site.listobjectsArray.push({name:d,objects:e})}return c&&c()}};m_site.cleanMap=function(){m_site.paths.forEach(function(a){a.selected([]),a.distance(0)})},m_site.hideSplashScreen=function(){"undefined"!=typeof Storage&&(localStorage.hideSplashScreen=!0)};var m_favourites=function(){var a={listDate:ko.observable(new Date),listEmail:ko.observable(""),tempFavourites:ko.observableArray([]),favourites:ko.observableArray([]).extend({persist:"favourites"}),content:ko.observableArray([]),checkObject:function(b){return-1!=a.favourites().indexOf(b)},localStorageSupport:function(){return"undefined"!=typeof Storage},addToFavourites:function(b){if(!a.localStorageSupport())return alert("Ваш браузер не поддерживает данный функционал"),!1;-1==a.favourites().indexOf(b)&&a.favourites.push(b)},removeFromFavourites:function(b){if(!a.localStorageSupport())return alert("Ваш браузер не поддерживает данный функционал"),!1;var c=a.favourites();-1!=c.indexOf(b)&&c.splice(c.indexOf(b),1),a.favourites(c),0==a.getFavouritesArrayCount()&&pager.navigate("/catalogue/flat")},loadTempFavourites:function(){$.ajax({url:"/api/favourites/list/"+vars.favourites(),success:function(b){a.tempFavourites([]),a.listDate(new Date(b.date)),a.listEmail(b.email),b.favourites.length>0&&a.tempFavourites(JSON.parse(b.favourites)),m_site.favourites.setPageUpdating()}})},menuItemText:function(){return a.localStorageSupport()?"Избранное ("+a.getFavouritesArrayCount()+")":""},getFavouritesArrayCount:function(){return a.getFavouritesArray().length},getFavouritesArray:function(){return a.checkForSavedList()?a.tempFavourites():a.favourites()},checkForSavedList:function(){return"savedlist"==m_site.currentRoute()[1]},initPrint:function(){},initDownload:function(){},email:ko.observable(""),status:ko.observable(0),sendList:function(){""!=a.email()&&(a.status(1),$.ajax({url:"/api/favourites/save",type:"POST",data:{email:a.email(),favourites:a.getFavouritesArray()},success:function(b){"success"==b.result?a.status(2):a.status(3),a.email("")}}))}};return a}(),m_object_print=function(){var a={agent:ko.observable(),userIsAgent:ko.observable(),nextPhoto:function(a){$(a).siblings(".workobject-gallery").children(".owl-carousel").trigger("owl.next")},previousPhoto:function(a){$(a).siblings(".workobject-gallery").children(".owl-carousel").trigger("owl.prev")},makingPdf:ko.observable(!1),makePdf:function(){a.makingPdf(!0),$.ajax({url:"/api/workobject/makepdf",type:"POST",data:{autonum:m_site.workobject().autonum()},success:function(a){window.location=a.link}})},yandexMapSrc:ko.observable(""),setYandexMapSrc:function(){var b="400,450";2==a.imageBlockSize()&&(b="600,450");var c=m_site.workobject();c&&a.yandexMapSrc("https://static-maps.yandex.ru/1.x/?ll="+c.loc()[1]+","+c.loc()[0]+"&size="+b+"&z=13&l=map&z=16&pt="+c.loc()[1]+","+c.loc()[0]+",pm2ntl")},isMapWide:function(){return 1!=a.imageBlockSize()},toggleImageBlockSize:function(){if(1==a.imageBlockSize()?a.imageBlockSize(2):2==a.imageBlockSize()&&a.imageBlockSize(1),2==a.imageBlockType()){$(".wp-map").find(".wp-print-map-gallery").children(".owl-carousel").data("owlCarousel").reinit()}},imageBlockSize:ko.observable(1),imageBlockType:ko.observable(1),currentTemplate:ko.observable(1),changeTemplate:function(b){a.removeMasonry(),a.currentTemplate(b),a.setPhotosShown(!0),a.initMasonry()},resetTemplate:function(){a.currentTemplate(1),a.imageBlockSize(1),a.imageBlockType(1),a.setPhotosShown(!0),a.reloadMasonry()},photosLoaded:ko.observable(!1),photosShown:ko.observableArray([]),removePhoto:function(b){var c=a.photosShown();c.forEach(function(a,d){a.forEach(function(a,e){a==b&&delete c[d][e]})}),a.photosShown(c),a.setPhotosShown(!1),a.reloadMasonry()},descriptionString:function(a){return a.length>400?a.substring(0,400)+"...":a},featuresString:function(a){var b="",c=a.info;for(var d in c)"function"==typeof c[d]&&1==c[d]()&&(b+=m_site.features[a.buytype()][d]+",");return b=b.replace(/(,$)/g,""),b.length>40?b.substring(0,40)+"...":b.replace(/(,$)/g,"")},setPhotosShown:function(b){var c=[];b?c=m_site.workobject().photos().slice(0):a.photosShown().forEach(function(a){a.forEach(function(a){c.push(a)})});var d=0,e=[],f=[];c.forEach(function(a,b){f.push(a),6!=++d&&b+1!=c.length||(e.push(f),f=[],d=0)}),a.photosShown(e)},initPrintScreen:function(){setTimeout(function(){""!=vars.printagent()&&void 0!=vars.printagent()?$.ajax({type:"GET",url:"/api/agent/"+vars.printagent()+"/detailed",success:function(b){void 0!=b._id?(a.userIsAgent(!0),a.agent(b)):a.agent(m_site.workobject().agent())}}):a.agent(m_site.workobject().agent()),a.setYandexMapSrc(),a.setPhotosShown(!0),0==a.photosShown().length&&a.imageBlockSize(2),imagesLoaded("#print-photos",function(){a.photosLoaded(!0),a.initMasonry()})},1e3)},initMasonry:function(){a.photosShown().forEach(function(a,b){$(".grid"+b).masonry({itemSelector:".print-photo-grid-item",gutter:86,columnWidth:400})})},reloadMasonry:function(){a.photosShown().forEach(function(a,b){$(".grid"+b).masonry("reloadItems").masonry("layout")})},removeMasonry:function(){a.photosShown().forEach(function(a,b){$(".grid"+b).masonry().masonry("destroy")})}};return a}();m_object_print.imageBlockSize.subscribe(function(){m_object_print.setYandexMapSrc()}),m_site.agents=new function(){var a=this;a.isApplyed=!1,a.total=ko.observable(0),a.letters=ko.observableArray(),a.search=ko.observable(""),a.oldSearch=ko.observable(""),a.allLetters=ko.observableArray([]),a.letter=ko.observable(null),a.letter.subscribe(function(b){null!==b&&a.search("")}),a.topOnly=ko.observable(),a.requestCount=0,a.previousData={},a.departments=ko.observableArray([]),a.department=ko.observable(""),a.getData=function(b,c,d,e,f,g,h){if("rieltors"!==m_site.currentRoute()[0])return!1;var i=c*b,j={};if(j.skip=i||0,j.limit=c||10,j.search=a.search()||"",""!==j.search&&a.letter(null),j.letter=a.letter(),j.department=a.department(),j.topOnly=a.topOnly(),a.search()!=a.oldSearch&&(a.oldSearch=a.search()),JSON.stringify(j)===JSON.stringify(a.previousData)&&(0!=a.requestCount||0!=a.tableViewModel.items().length))return!1;a.previousData=j;var k=m_site.domain()+"/api/agents/";a.requestCount++;var l=a.requestCount;$.ajax({url:k,data:j,success:function(b){l==a.requestCount&&(a.total(b.total),b.allLetters.sort(),a.allLetters(b.allLetters),b.content=_.map(b.content,function(a){return create(models.agent,a)}),f(b))}})},a.page=ko.observable(),a.setPageUpdating=function(){pageUpdater(a)},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:10,url:"/rieltors"}),a.needRefresh=ko.computed(function(){a.search(),a.letter(),a.topOnly(),a.department(),a.tableViewModel.pageSize(),a.tableViewModel.moveToPage(1)})},m_site.favourites=new function(){var a=this;a.tempFavourites=ko.observableArray([]),a.modelsFlats=ko.observableArray([]),a.modelsHouses=ko.observableArray([]),a.modelsCommerce=ko.observableArray([]),a.isApplyed=!1,a.total=ko.observable(0),a.requestCount=0,a.previousData={},a.getData=function(b,c,d,e,f,g,h){if("favourites"!==m_site.currentRoute()[1]&&"savedlist"!==m_site.currentRoute()[1]||0==m_favourites.getFavouritesArrayCount())return!1;a.requestCount++;var i=a.requestCount;$.ajax({url:m_site.domain()+"/api/favourites/get",type:"POST",data:{favourites:m_favourites.getFavouritesArray()},success:function(b){i==a.requestCount&&(a.total(b.total),b.content=_.map(b.content,function(a){return create(models.workobject,a)}),a.modelsFlats([]),a.modelsHouses([]),a.modelsCommerce([]),b.content.forEach(function(b){"houseroom"!=b.buytype()&&"newhouseroom"!=b.buytype()||a.modelsFlats.push(b),"house"==b.buytype()&&a.modelsHouses.push(b),"commercial"==b.buytype()&&a.modelsCommerce.push(b)}),f(b))}})},a.page=ko.observable(),a.setPageUpdating=function(){pageUpdater(a)},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:10,url:"/catalogue/favourites"}),a.needRefresh=ko.computed(function(){a.tableViewModel.pageSize(),a.tableViewModel.moveToPage(1)})},m_site.banks=new function(){var a=this;a.isApplyed=!1,a.total=ko.observable(0),a.letters=ko.observableArray(),a.allLetters=ko.observableArray([]),a.letter=ko.observable(null),a.sortField=ko.observable("name"),a.sortOrder=ko.observable(!0),a.loadTime=250,a.requestCount=0,a.previousData={},a.isLoading=ko.observable(!0),a.isNotLoading=ko.observable(!1),a.isLoading.subscribe(function(b){1==b?(a.tableViewModel.items([]),a.isNotLoading(!1)):setTimeout(function(){a.isNotLoading(!0)},a.loadTime)}),a.setSort=function(b){b==a.sortField()?a.sortOrder(!a.sortOrder()):(a.sortField(b),a.sortOrder(!0))},a.getData=function(b,c,d,e,f,g,h){var i=c*b,j={};if(j.skip=i||0,j.limit=c||10,j.letter=a.letter(),j.sort=a.sortField(),a.sortOrder()&&(j.sort="-"+j.sort),JSON.stringify(j)===JSON.stringify(a.previousData)&&(0!=a.requestCount||0!=a.tableViewModel.items().length))return!1;a.previousData=j;var k=m_site.domain()+"/api/banks/";a.tableViewModel&&a.tableViewModel.items([]),a.requestCount++,a.isLoading()||a.isLoading(!0);var l=a.requestCount;$.ajax({url:k,data:j,success:function(b){if(l===a.requestCount&&(a.requestCount=0,null!==b)){a.total(b.total),b.allLetters.sort(),a.allLetters(b.allLetters);var c=/^(http(s?):\/\/)?(www\.)+[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/;b.content=_.map(b.content,function(a){return void 0!==a.site&&(c.test(a.site)||(a.phone=a.phone+" \n"+a.site,a.site="")),create(models.bank,a)}),f(b),a.isLoading()&&a.isLoading(!1)}}})},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:10,url:"/banks"}),a.page=ko.observable(),a.setPageUpdating=function(){pageUpdater(a)},a.needRefresh=ko.computed(function(){a.letter(),a.tableViewModel.pageSize(),a.tableViewModel.moveToPage(1)})},m_site.programs=new function(){var a=this;a.isApplyed=!1,a.total=ko.observable(0),a.loadTime=250,a.requestCount=0,a.previousData={},a.isLoading=ko.observable(!0),a.isNotLoading=ko.observable(!1),a.isLoading.subscribe(function(b){1==b?(a.tableViewModel.items([]),a.isNotLoading(!1)):setTimeout(function(){a.isNotLoading(!0)},a.loadTime)}),a.getData=function(b,c,d,e,f,g,h){var i=c*b,j={};if(j.skip=i||0,j.limit=c||100,j.bank=vars.bank()||null,JSON.stringify(j)===JSON.stringify(a.previousData)&&(0!=a.requestCount||0!=a.tableViewModel.items().length))return!1;a.previousData=j,a.tableViewModel&&a.tableViewModel.items([]),a.requestCount++,a.isLoading()||a.isLoading(!0);var k=a.requestCount;$.ajax({url:"/api/programs/",data:j,success:function(b){if(k===a.requestCount&&(a.requestCount=0,null!==b)){var c={};c.content=_.map(b,function(a){return create(models.program,a)}),f(c),a.isLoading()&&a.isLoading(!1)}}})},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:100,url:"/banks"}),a.page=ko.observable()},m_site.news=new function(){var a=this;a.isApplyed=!1,a.total=ko.observable(0),a.tag=ko.observable(),a.fullTag=ko.observable(),a.fulltext=ko.observable(!1),a.loadTime=300,a.requestCount=0,a.previousData={},a.isLoading=ko.observable(!0),a.isNotLoading=ko.observable(!1),a.isLoading.subscribe(function(b){1==b?(a.tableViewModel.items([]),a.isNotLoading(!1)):setTimeout(function(){a.isNotLoading(!0)},a.loadTime)}),a.getData=function(b,c,d,e,f,g,h){var i=c*b,j={};j.skip=i||0,j.limit=c||10,j.tag=a.tag()||"",j.fulltext=a.fulltext()||!1;var k=m_site.domain()+"/api/pagesbytag/";if(JSON.stringify(j)===JSON.stringify(a.previousData)&&(0!=a.requestCount||0!=a.tableViewModel.items().length))return!1;a.previousData=j,a.requestCount++,a.isLoading()||a.isLoading(!0);var l=a.requestCount;$.ajax({url:k,data:j,success:function(b){l===a.requestCount&&(a.requestCount=0,null!==b&&(a.total(b.total),b.content=_.map(b.content,function(a){return create(models.news,a)}),f(b),a.isLoading()||a.isLoading(!1)))}})},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:10,url:ko.computed(function(){return"novosti"==m_site.currentRoute()[0]?a.tag()?"/novosti/"+a.tag():"/novosti":"/aboutcompany"})}),a.page=ko.observable(),a.setPageUpdating=function(){pageUpdater(a)},a.needRefresh=ko.computed(function(){a.tag(),a.tableViewModel.pageSize(),a.tableViewModel.moveToPage(1)})},m_site.news.tag.subscribe(function(a){if(m_site.tags()){var b=ko.toJS(m_site.tags()),c=null;b.forEach(function(b){b.alias==a&&(c=b)}),m_site.news.fullTag(c)}}),vars.customPage.subscribe(function(){m_site.loadCustomPage()}),vars.news.subscribe(function(a){void 0!==a&&(m_site.loadSingleNews(),m_site.loadNewsByAlias())}),vars.buytype.subscribe(function(a){if(void 0==a)vars.buytype("flat");else{var b=catalog_search_helpers.getBuyType();"newhouse"==b&&2==m_site.mode()&&m_site.mode(3),"house"==b&&1==m_site.mode()&&m_site.mode(3),"special"==b&&1==m_site.mode()&&m_site.mode(3),catalog_search_models.rent(-1!=a.indexOf("rent")||"newhouse"==a),catalog_search_models.buytype(b),catalog_search.changeBuyType(b)}}),m_site.currentRoute.subscribe(function(a){"tags"!==a[0]&&vars.tag(""),"catalogue"===a[0]?(a[1]&&""!==a[1]?vars.buytype()!=a[1]&&vars.buytype(a[1]):"flat"!=vars.buytype()&&vars.buytype("flat"),catalog_search.init()):"rieltors"!==a[0]&&"tags"!==a[0]&&vars.buytype("")}),m_site.flats=new function(){var a=this;a.isApplyed=!1,a.total=ko.observable(0),a.mode=ko.observable(4),a.dataChess=ko.observableArray([]),a.currentPorch=ko.observable(0),a.nullResponse=ko.observable(!1),a.previousData=null,a.requestCount=0,a.getData=function(b,c,d,e,f,g,h){var i=c*b,j={};if(j.skip=i||0,j.limit=c||10,j.sort="-floor",4===a.mode()){if(null==m_site.workobject()||void 0==m_site.workobject())return!1;j.limit=a.total()}if(void 0!==vars.workobject()?j.url=m_site.domain()+"/api/flats/"+vars.workobject():j.url=m_site.domain()+"/api/flats/0",JSON.stringify(a.previousData)===JSON.stringify(j)&&(0!=a.requestCount||0!=a.tableViewModel.items().length||a.nullResponse()))return!1;a.previousData=j,a.requestCount++;var k=a.requestCount;$.ajax({url:j.url,data:j,success:function(b){k===a.requestCount&&(a.requestCount=0,null==b.totalPages?a.nullResponse(!0):a.nullResponse(!1),void 0!==b.total&&a.total()!==b.total&&a.total(b.total),b.content=_.map(b.content,function(a){return create(models.workobject,a)}),4===a.mode()?null!==m_site.workobject()&&void 0!==m_site.workobject()&&("newhouse"==m_site.workobject().buytype()?a.calculateDataChess(b,f):a.mode(2)):f(b))}})},a.calculateDataChess=function(b,c){console.time("calculateDataChess");var d=ko.toJS(b.content);a.dataChess([]),d=_.map(d,function(a){return a.squareSumm=a.square.summ,a});var e=_.groupBy(d,function(a){return a.podjezd});for(var f in e){var g=_.sortBy(_.uniq(_(e[f]).flatten(),function(a){return a.onfloor}),function(a){return a.onfloor}),h=a.dataChess().push({titles:g,porch:ko.observable(m_site.workobject().numbersOnFloor()[f-1]),floors:[]})-1,i=a.dataChess()[h];i.floors=[];for(var j=0;j0&&(t=v.titleData)}s.titleData=_.range(i.titles.length).map(function(a){var b=t[a],c={id:"",price:"0",square:0,rooms:0};return c.id=b.id,c.price=b.price,c.square=b.square,c.rooms=b.rooms,c})}s.titleData[k]=m}}}}a.dataChess().length>0&&a.currentPorch(a.dataChess()[0].porch()),a.dataChess.valueHasMutated(),console.timeEnd("calculateDataChess"),c(b)},a.page=ko.observable(),a.setPageUpdating=function(){pageUpdater(a)},a.tableViewModel=new ko.dataTable.ViewModel({reload:function(){},columns:[],paggination:!0,sortable:!1,loader:a.getData,pageSize:10,url:ko.computed(function(){return void 0!==vars.workobject()?"/catalogue/newhouseroom/"+vars.workobject():"/catalogue/newhouseroom/0"})}),a.needRefresh=ko.computed(function(){a.mode(),a.tableViewModel.pageSize(),a.tableViewModel.moveToPage(1)}),a.popup=ko.observable(null),a.switchPopup=function(b){!a.popup()&&b?(console.log("[email protected]:",b),data=_.find(a.tableViewModel.items(),function(a){return a._id()==b}),console.log("[email protected]:",ko.toJS(data)),a.popup(data||null)):a.popup(null)}};var transitions={fadeIn:function(a,b){$(a.element).fadeIn(500,b)},fadeOut:function(a,b){var c=$(a.element);a.pageHiddenOnce?(c.fadeOut(500,function(){c.hide()}),b&&b()):(a.pageHiddenOnce=!0,c.hide())}};m_site.meta=ko.observable({name:ko.observable("Адвекс-тюмень"),description:ko.observable("Агенство недвижимости"),photo:ko.observable("/images/new_logo.png"),reset:{name:"Адвекс-Тюмень - агентство недвижимости. Продажа недвижимости в Тюмени, цены.",description:"Агентство недвижимости Адвекс-Тюмень. Продажа и аренда недвижимости в Тюмени - квартиры, новостройки, дома и участки, офисы, коммерческая недвижимость. Узнать цены и купить недвижимость!",photo:"/images/new_logo.png"}}),m_site.resetMeta=function(){m_site.meta().description(m_site.meta().reset.description),m_site.meta().photo(m_site.meta().reset.photo)},m_site.hideSplashScreen=function(){"undefined"!=typeof Storage&&(localStorage.hideSplashScreen=!0)},m_site.metaSeo=ko.observable(null),m_site.updateMetaFromUrl=function(){function a(a,b){var c=catalog_search_models.filterData().region(),d=m_site.workobjects.rooms(),e=m_site.meta(),f={1:"однокомнатную",2:"двухкомнатную",3:"трехкомнатную",4:"четырехкомнатную"},g="";d&&(g=f[d]);var h=_.find(catalog_search_models.filterOptions.region(),function(a){return a.alias==c});a=a.replace(/\[regionname\]/g,h.name),b=b.replace(/\[regionname\]/g,h.name),a=a.replace(/\[rooms_text\]/g,g),b=b.replace(/\[rooms_text\]/g,g),e.name(a),e.description(b),e.photo("/images/new_logo.png")}var b=window.location.href.split(window.location.host)[1];console.log("[email protected]:",b);var c=-1!=b.indexOf("?")?b.indexOf("?")-1:b.length-1;"/"==b[c]&&(b=b.slice(0,c)+b.slice(c+1));var d=m_site.meta();if(mapMeta[b])return d.name(mapMeta[b].title),d.description(mapMeta[b].description),d.photo("/images/new_logo.png"),mapMeta[b].seo&&m_site.metaSeo(mapMeta[b].seo),!0;var e=m_site.currentRoute();if("catalogue"==e[0]&&isNumber(e[1])&&m_site.workobject()&&m_site.workobject().name().length){var f=m_site.workobject(),g=f.name(),h=f.priceFormatted(),i="/images/new_logo.png",j=f.arend(),k="";switch(f.photos().length&&(i=f.photos()[0]),f.buytype()){case"houseroom":case"newhouseroom":k="Продается [name], купить квартиру в Тюмени, цена [price] руб.",j&&(k="Сдается [name], снять квартиру в Тюмени, цена [price] руб.");break;case"commercial":k="Продается [name], купить помещение в Тюмени, цена [price] руб.",j&&(k="Сдается [name], снять помещение в Тюмени, цена [price] руб.");break;case"house":k="Продается [name], купить дома и участки в Тюмени, цена [price] руб.",j&&(k="Сдается [name], снять дом в Тюмени, цена [price] руб.");break;default:k="[name]. Купить в Тюмени, цена [price] руб."}return k=k.replace(/\[price\]/g,h).replace(/\[name\]/g,g),d.name(k),d.description("Агентство недвижимости Адвекс-Тюмень. Продажа квартир в Тюмени, [name], новостройки. Узнать цены и купить квартиру в [name]!".replace(/\[name\]/g,g)),d.photo(i),!0}var l="",m="",n=catalog_search_models.filterData().region();if("catalogue"==e[0]&&"flatrent"==e[1]&&n)return l=mapMeta.flatrentregion.title,m=mapMeta.flatrentregion.description,a(l,m),!0;if("catalogue"==e[0]&&"flat"==e[1]&&n)return l=mapMeta.flatregion.title,m=mapMeta.flatregion.description,a(l,m),!0;if("catalogue"==e[0]&&"newhouseroom"==e[1]&&n)return l=mapMeta.newhouseroomregion.title,m=mapMeta.newhouseroomregion.description,a(l,m),!0;if("catalogue"==e[0]&&!isNumber(e[1])&&m_site.workobject()&&m_site.workobject().name().length){var o=m_site.workobject().name();return pPhoto="/images/new_logo.png",m_site.workobject().photos().length&&(pPhoto=m_site.workobject().photos()[0]),l=mapMeta.newhouse.title,m=mapMeta.newhouse.description,l=l.replace(/\[newhousename\]/g,o),m=m.replace(/\[newhousename\]/g,o),d.name(l),d.description(m),d.photo(pPhoto),!0}return!1},m_site.updateMeta=function(){var a=m_site.currentRoute(),b=m_site.meta();if(!m_site.updateMetaFromUrl()){if("rieltors"==a[0]&&void 0!==o.agent()&&null!==o.agent()){var c=o.agent();b.name(c.name()),b.description(c.phone()),b.photo(c.photo())}if("catalogue"==a[0]&&void 0!==m_site.workobject()&&null!==m_site.workobject()){var d,c=m_site.workobject(),e=m_site.workobject().buytype(),f=m_site.workobject().price(),g=m_site.workobject().arend(),h=c.name();"houseroom"!=e||g?"houseroom"==e&&g?d="Сдается {name}, снять квартиру в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f):"commercial"!=e||g?"commercial"==e&&g?d="Сдается {name}, снять помещение в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f):"house"!=e||g?"house"==e&&g&&(d="Сдается {name}, снять дом в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f)):d="Продается {name}, купить дома и участки в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f):d="Продается {name}, купить помещение в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f):d="Продается {name}, купить квартиру в Тюмени, цена {price} руб.".replace(/{name}/,h).replace(/{price}/,f),b.name(d),b.description(c.addinfo()),c.photos().length>0?b.photo(c.photos()[0]):b.photo(b.reset.photo)}if("novosti"==a[0]&&void 0!==m_site.singleNews()&&null!==m_site.singleNews()){var c=m_site.singleNews();b.name(c.name()),b.description(strip(c.introtext())),b.photo(c.picture())}if("banks"==a[0]&&void 0!==o.bank()&&null!==o.bank()){var c=o.bank();b.name(c.name()),b.description(c.description()),b.photo(c.logo())}}};var gis2lib=new function(){var a=this;a.apikey="ruwtzx4836",a.getPoints=function(b,c){if("string"==typeof b[1]){var d="https://geocode-maps.yandex.ru/1.x/?geocode="+b[1]+"&format=json&results=1";$.getJSON(d,null,function(d){mainPoint=d.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(" ").reverse(),a.callInfrastructure(b[0],mainPoint,c)})}else a.callInfrastructure(b[0],b[1],c)},a.callInfrastructure=function(b,c,d){var e={loc:[],kindergarten:[],school:[],hospital:[]};e.loc=[parseFloat(c[0]),parseFloat(c[1])];var f=[["kindergarten","детский сад"],["hospital","поликлиника"],["school","школа"]],g=f.length;if("houseroom"!=b&&"newhouseroom"!=b&&"newhouse"!=b)return d&&d(e);_.each(f,function(b){a.dgGetInfrastructureGroup(b,c,function(a){if(e[b[0]]=a,0==--g)return d&&d(e)})})},a.dgGetInfrastructureGroup=function(b,c,d){var e="https://catalog.api.2gis.ru/2.0/catalog/branch/search?format=jsonp&key="+a.apikey+"&callback=?";$.getJSON(e,{q:b[1],point:c[1]+","+c[0],radius:1e3,fields:"items.point"},function(a){var c=[];a.result&&a.result.total>0?($.each(a.result.items,function(a,d){"школа"==b[1]?-1!=d.name.indexOf("общеобразовательная")&&c.push({name:d.name,lat:d.point.lat,lon:d.point.lon}):c.push({name:d.name,lat:d.point.lat,lon:d.point.lon})}),d&&d(c)):d&&d(c)})}};m_site.message.data.resumeName=ko.computed(function(){return""!==m_site.message.data.rawName()?m_site.message.data.rawName():"Прикрепить резюме"}),m_site.customPage.isLoading.subscribe(function(a){1==a?m_site.customPage.isNotLoading(!1):setTimeout(function(){m_site.customPage.isNotLoading(!0)},300)}),m_site.workobjectsForPrint=ko.observableArray([]),m_site.loadWorkobjectsForPrint=function(){m_site.printable(),$.ajax({ url:"/api/workobjectslist",data:{ids:window.location.search.split("=").pop().split(",")},method:"post",success:function(a){var b=[];a.forEach(function(a){b.push(create(models.workobject,a))}),m_site.workobjectsForPrint(b)}})},m_calculator={buytype:ko.observable("houseroom"),newhouse:ko.observable(null),price:ko.observable(1e6),form:{program:ko.observable(null),programOptions:ko.observable([]),INITIAL_FEE_PERCENT:"20",TIME_PERIOD:"20",initialFeeAmount:ko.observable("0"),initialFeePercent:ko.observable("20"),timePeriod:ko.observable("20"),endPeriod:ko.computed(function(){var a=m_site.workobject();if(a&&"newhouseroom"==a.buytype()){var b=new Date,c=a.createFinishDate(),d=b.getMonth()+1,e=b.getFullYear(),f=parseInt(c.split("/")[0]),g=parseInt(c.split("/")[1]),h=Math.max(0,12*(g-e)+f-d);return String(h)}return"0"}),type:ko.observable("annuity")},payment:ko.observableArray([]),expanded:ko.observable(-1),programName:ko.observable(""),programLink:ko.observable(""),specialist:ko.observable(null),availablePrograms:ko.observableArray([]),toggleExpanded:function(a){a==m_calculator.expanded()?m_calculator.expanded(-1):m_calculator.expanded(a)},processData:function(a){if(a&&a.length){var b=[];_.each(a,function(a){var c=create(models.program,a);b.push(c)}),m_calculator.availablePrograms(b)}},loadProgramTable:function(){var a=m_calculator.buytype()||"";-1!=["houseroom","house"].indexOf(a)&&$.get("/api/programsbybuytype/"+a,m_calculator.processData),"newhouseroom"==a&&(m_calculator.newhouse()?$.get("/api/programsbynewhouse/"+m_calculator.newhouse()._id(),m_calculator.processData):$.get("/api/programsbynewhouse/",m_calculator.processData))},resetData:function(){var a=m_calculator.form;a.initialFeePercent(m_calculator.INITIAL_FEE_PERCENT),a.timePeriod(m_calculator.TIME_PERIOD)},askSpecialist:function(){console.log("askSpecialist")},moveToCalculator:function(){$("html, body").animate({scrollTop:$("#hypothecary").offset().top-$($(".main_top")[0]).height()},"slow")},moveToPrograms:function(){$("html, body").animate({scrollTop:$("#lendingPrograms").offset().top-$($(".main_top")[0]).height()},"slow")}},m_calculator.form.loanAmount=ko.computed(function(){return m_calculator.price()?Math.max(m_calculator.price()-parseInt(m_calculator.form.initialFeeAmount().replace(/\s/g,"")),0):0}),m_calculator.form.loanAmountFormatted=ko.computed(function(){return formatNumber(m_calculator.form.loanAmount())}),m_calculator.form.priceFormatted=ko.computed(function(){return formatNumber(parseInt(m_calculator.price()))}),m_calculator.tableData=ko.computed(function(){var a=m_calculator.availablePrograms(),b=m_calculator.form,c=_.filter(a,function(a){return a.minimumTerm()<=b.timePeriod()&&a.maximumTerm()>=b.timePeriod()&&a.minimumContribution()<=b.initialFeePercent()}),d=_.sortBy(c,function(a){return a.paymentSort()});return d=_.filter(d,function(a){return-1!=a.paymentType().indexOf(b.type())}),d.length&&m_site.workobject()&&m_site.workobject().hypothecaryMinimum&&!m_site.workobject().hypothecaryMinimum()&&(m_site.workobject().hypothecaryMinimum(formatNumber(d[0].paymentSort())),d[0].paymentSort.subscribe(function(a){m_site.workobject()&&m_site.workobject().hypothecaryMinimum(formatNumber(a))})),m_calculator.expanded(-1),d}),m_calculator.rateRange=ko.computed(function(){var a=m_calculator.tableData&&m_calculator.tableData();if(a&&a.length){var b=100,c=0;return"newhouseroom"==m_calculator.buytype()?_.map(a,function(a){b=Math.min(b,a.rateBefore(),a.rateAfter()),c=Math.max(c,a.rateBefore(),a.rateAfter())}):_.map(a,function(a){b=Math.min(b,a.rateBefore()),c=Math.max(c,a.rateBefore())}),b!=c?"от "+b+"% до "+c+"%":"от "+b+"%"}return""}),m_calculator.paymentMinimum=ko.computed(function(){var a=m_calculator.tableData&&m_calculator.tableData();if(a.length){var b=a[0].payment();return m_calculator.programName(a[0].name()+", "+a[0].rateBefore()+"%"),m_calculator.programLink("/programs/"+a[0]._id()),b+" руб."}return""}),m_calculator.form.initialFeePercent.subscribe(function(a){_.isString(a)&&(a=a.replace(",","."));var b=parseFloat(a)||0,c=parseFloat(m_calculator.form.initialFeeAmount().replace(/\s/g,""))||0,d=m_calculator.price?parseInt(m_calculator.price()*b/100):0;c!=d&&m_calculator.form.initialFeeAmount(formatNumber(d)),m_calculator.form.initialFeePercent(b.toString())}),m_calculator.form.initialFeeAmount.subscribe(function(a){var b=parseFloat(a.replace(/\s/g,""))||0,c=parseFloat(m_calculator.form.initialFeePercent())||0,d=m_calculator.price?b/m_calculator.price()*100:0;c!=d&&m_calculator.form.initialFeePercent(d.toFixed(2)),m_calculator.form.initialFeeAmount(b.toString())}),m_site.workobject.subscribe(function(a){a&&m_calculator.form.initialFeePercent.valueHasMutated(),m_site.workobject()&&-1!=["houseroom","newhouseroom","house"].indexOf(m_site.workobject().buytype())&&!m_site.workobject().arend()&&(m_calculator.buytype(m_site.workobject().buytype()),m_calculator.newhouse(m_site.workobject().newhouse()),m_calculator.price(m_site.workobject().price()),m_calculator.init())}),m_calculator.buytype.subscribe(function(){m_calculator.loadProgramTable()}),m_calculator.price.subscribe(function(){m_calculator.form.initialFeePercent.valueHasMutated()}),m_calculator.form.initialFeeInvalid=ko.computed(function(){if(m_calculator.availablePrograms().length){var a=m_calculator.form.initialFeePercent(),b=_.min(ko.toJS(_.pluck(m_calculator.availablePrograms(),"minimumContribution")));if(atmax||atmax&&(c+=" до "+tmax),c+=" лет"}}return""}),m_calculator.paymentFormatted=ko.computed(function(){if(m_calculator.payment().length){if("annuity"==m_calculator.form.type())return formatNumber(m_calculator.payment()[0].toFixed(2));var a=m_calculator.payment().length-1;return formatNumber(m_calculator.payment()[0].toFixed(2))+" ... "+formatNumber(m_calculator.payment()[a].toFixed(2))}return""}),m_calculator.paymentSum=ko.computed(function(){if(m_calculator.payment().length){return formatNumber(_.reduce(m_calculator.payment(),function(a,b){return a+parseFloat(b)},0).toFixed(2))}return""}),m_calculator.overpayment=ko.computed(function(){var a=m_calculator.form;return initialSum=a.loanAmount(),realSum=parseFloat(m_calculator.paymentSum().replace(/\s/g,""))||0,difference=realSum-initialSum,difference&&difference>0?formatNumber(difference.toFixed(2)):""}),m_calculator.init=function(){m_calculator.resetData(),m_calculator.form.initialFeePercent.valueHasMutated(),m_calculator.loadProgramTable()};var defaultPolygonPoint1=[57.16601622808409,65.50464935302739],defaultPolygonPoint2=[57.1491512053856,65.52691574096684],defaultPolygonPoint3=[57.167050539834904,65.54681015014648],m_listObject=function(){var a={selectedDirection:ko.observable(""),objectType:ko.observable(""),newObjectName:ko.observable(""),newObjectNameValid:ko.observable(!0),newObjectCity:ko.observable(null),newObjectAdmRegion:ko.observable(null),newObjectRegion:ko.observable(null),newObjectDirection:ko.observableArray([]),newObjectBoundaries:ko.observableArray([defaultPolygonPoint1,defaultPolygonPoint2,defaultPolygonPoint3]),newObjectSortIndex:ko.observable(!1),addingObject:ko.observable(!1),toggleObjectForm:function(){a.newObjectName(""),a.newObjectCity(null),a.newObjectAdmRegion(null),a.newObjectRegion(null),a.newObjectDirection([]),a.newObjectBoundaries([defaultPolygonPoint1,defaultPolygonPoint2,defaultPolygonPoint3]),a.newObjectSortIndex(m_site.getMaxSortForListObjects(a.objectType())),a.addingObject(!a.addingObject())},addNewObjectDirection:function(){a.selectedDirection()&&-1==a.newObjectDirection().indexOf(a.selectedDirection())&&a.newObjectDirection.push(a.selectedDirection())},saveNewObject:function(){a.newObjectNameValid(!0),""==a.newObjectName()&&a.newObjectNameValid(!1),a.newObjectNameValid()&&($(".dim").show(),$.ajax({type:"POST",url:"/api/listobject/add",data:{type:a.objectType,name:a.newObjectName,city:a.newObjectCity,region:a.newObjectRegion,adm_region:a.newObjectAdmRegion,direction:a.newObjectDirection(),boundaries:a.newObjectBoundaries(),sortIndex:a.newObjectSortIndex},success:function(b){$(".dim").hide(),a.refreshSearchScreen(),a.addingObject(!1)}}))},editObject:ko.observable({id:ko.observable(""),name:ko.observable(""),city:ko.observable(""),region:ko.observable(""),adm_region:ko.observable(""),direction:ko.observableArray([]),boundaries:ko.observableArray([]),sortindex:ko.observable(0)}),addDirection:function(){a.selectedDirection()&&-1==a.editObject().direction().indexOf(a.selectedDirection())&&a.editObject().direction.push(a.selectedDirection())},setEditObject:function(b){a.editObject().id(b.id()),a.editObject().name(b.name()),a.editObject().city(b.city()),b.direction()&&"[object Array]"===Object.prototype.toString.call(b.direction())?a.editObject().direction(b.direction()):a.editObject().direction([]),a.editObject().boundaries(b.boundaries()[0]),a.editObject().sortindex(b.sortindex())},updateObject:function(){$(".dim").show(),$.ajax({type:"PUT",url:"/api/listobject/update",data:{type:a.objectType,id:a.editObject().id,name:a.editObject().name,city:a.editObject().city,adm_region:a.editObject().adm_region,region:a.editObject().region,direction:a.editObject().direction(),boundaries:a.editObject().boundaries(),sortindex:a.editObject().sortindex},success:function(){$(".dim").hide(),a.refreshSearchScreen()}})},searchString:ko.observable(""),searchCity:ko.observable(null),searchAdmRegion:ko.observable(null),searchDirection:ko.observable(null),objectsSearch:function(){if(!listobjects)return[];var b=listobjects.getLo(a.objectType()),c=[];return b.forEach(function(b){b.name().toLowerCase().indexOf(a.searchString().toLowerCase())>=0&&(!b.city||b.city()==a.searchCity()||"Все"==a.searchCity())&&c.push(b)}),c},objectToDelete:ko.observable(null),deleteConfirm:function(b){a.objectToDelete(b),m_site.confirmDelete({},a.deleteObject)},deleteObject:function(){$.ajax({url:"/api/listobject/"+a.objectType()+"/"+a.objectToDelete(),type:"delete",success:function(){a.refreshSearchScreen()}})},refreshSearchScreen:function(b){console.time("refreshSearchScreen"),$(".dim").show(),m_site.fetchUpdatedListObjectType(a.objectType(),function(){a.searchCity.valueHasMutated(),a.editObject().id(""),$(".dim").hide(),console.timeEnd("refreshSearchScreen")}),b&&b()},refreshRegion:function(b){console.time("refreshRegion"),a.objectType("region"),a.refreshSearchScreen(function(){console.time("refreshRegion"),"function"==typeof b?b():console.log("refreshRegion[email protected]:",b)})}};return a}();$(document).includeReady(function(){pager.useHTML5history=!0,pager.Href5.history=History,pager.extendWithPage(m_site),m_site.resetMeta(),m_site.breadcrumbsCompute(),m_site.getSummary(),ko.applyBindings(m_site,$("head")[0]);var a=$(".detach_wrapper");a.detach(),ko.applyBindings(m_site,$(a)[0]),$("body").append(a),pager.startHistoryJs(),setTimeout(function(){m_site.updateMeta()},0),setTimeout(function(){m_site.updateMeta()},2e3),$("body").removeClass("loading"),m_site.init(),catalog_search.init(),catalog_search.checkFilter();try{callibriInit()}catch(b){}History.Adapter.bind(window,"statechange",function(){m_site.metaSeo(null),m_site.resetMeta(),m_site.breadcrumbsCompute(),catalog_search.checkFilter(),m_site.getSummary(),m_site.workobjectMap(!1),setTimeout(function(){m_site.updateMeta()},0),setTimeout(function(){m_site.updateMeta()},2e3),!0===m_site.savePageScroll()?m_site.savePageScroll(!1):Number(m_site.currentScroll())>0?$(window).scrollTop(Number(m_site.currentScroll())):window.scrollTo(0,0),$(window).scroll(checkScroll),setTimeout(function(){$("#vacancy_accordion").accordion("refresh")},0);History.savedStates})});var News=function(){ko.mapping.fromJS({name:"",introtext:"",text:"",date:new Date,photos:[]},this.mapping||{},this)},Tag=function(){var a=this;ko.mapping.fromJS({name:"",alias:""},this.mapping||{},this),this.link=ko.computed(function(){return"/novosti/"+a.alias()+"/"})},Vacancy=function(){ko.mapping.fromJS({name:"",experience:"",salary:0,description:"",published:!1},this.mapping||{},this)},Workobject=function(){ko.mapping.fromJS({name:"",text:"",date:new Date,photos:[],nearest:{school:[],hospital:[],kindergarten:[],schoolAmount:0,hospitalAmount:0,kindergartenAmount:0},agent:{_id:"",phone:"",email:"",photo:""},marker:{x:0,y:0},newhouse:"",sameFlats:[],price:0,pricePerMeter:0,createFinishDate:"01/2015",salesStartDate:"01/2014",floors:[]},this.mapping||{},this);var a=this;a.agentLink=ko.computed(function(){return"/rieltors/"+a.agent._id()}),a.priceFormatted=ko.computed(function(){return String(a.price()).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1 ")}),a.pricePerMeterFormatted=ko.computed(function(){return String(a.pricePerMeter()).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1 ")}),a.startFormatted=ko.computed(function(){var b=a.salesStartDate().split("/");return moment(b[0],"MM").format("MMMM")+" "+moment(b[1]).format("YYYY")+" г."}),a.finishFormatted=ko.computed(function(){var b=a.createFinishDate().split("/");return moment(b[0],"MM").format("MMMM")+" "+moment(b[1]).format("YYYY")+" г."}),a.floorsWithoutFirst=ko.computed(function(){var b=a.floors();return b.slice(1,b.length)})},Department=function(){ko.mapping.fromJS({name:"",photo:"",status:"",info:"",address:"",phone:"",director:{phone:"",photo:"",email:"",lastname:"",middlename:"",firstname:""},published:!1},this.mapping||{},this)};