var signInPageUrl,__extends,apiphany;(function(n){function r(){return i.hash===""||i.hash==="#"}function f(n,t){for(var i=0;i<n.length;i+=1)if(t(n[i],i,n)===!1)return}function e(n){for(var i=[],t=0,r=n.length;t<r;t++)i=i.concat(n[t]);return i}function o(n,t,i){if(!n.length)return i();var r=0;(function u(){t(n[r],function(t){t||t===!1?(i(t),i=function(){}):(r+=1,r===n.length?i():u())})})()}function c(n,t,i){i=n;for(var r in t)if(t.hasOwnProperty(r)&&(i=t[r](n),i!==n))break;return i===n?"([._a-zA-Z0-9-]+)":i}function l(n,t){for(var i,f=0,e="",r,o,u;i=n.substr(f).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/);)f=i.index+i[0].length,i[0]=i[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=n.substr(0,i.index)+i[0];if(n=e+=n.substr(f),r=n.match(/:([^\/]+)/ig),r)for(o=r.length,u=0;u<o;u++)n=n.replace(r[u],c(r[u],t));return n}function h(n,t,i,r){for(var u=0,o=0,s=0,i=(i||"(").toString(),r=(r||")").toString(),f,h,e=0;e<n.length;e++)f=n[e],f.indexOf(i,u)>f.indexOf(r,u)||~f.indexOf(i,u)&&!~f.indexOf(r,u)||!~f.indexOf(i,u)&&~f.indexOf(r,u)?(o=f.indexOf(i,u),s=f.indexOf(r,u),(~o&&!~s||!~o&&~s)&&(h=n.slice(0,(e||1)+1).join(t),n=[h].concat(n.slice((e||1)+1))),u=(s>o?s:o)+1,e=0):u=0;return n}var i,u,t;Array.prototype.filter||(Array.prototype.filter=function(n,t){for(var r=[],u,i=0,f=this.length;i<f;i++)i in this&&n.call(t,u=this[i],i,this)&&r.push(u);return r});Array.isArray||(Array.isArray=function(n){return Object.prototype.toString.call(n)==="[object Array]"});i=document.location;u={mode:"modern",hash:i.hash,history:!1,check:function(){var n=i.hash;n!=this.hash&&(this.hash=n,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(n,i){function u(n){for(var i=0,r=t.listeners.length;i<r;i++)t.listeners[i](n)}var f=this,r;return this.history=i,t.listeners||(t.listeners=[]),"onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7)?(this.history===!0?setTimeout(function(){window.onpopstate=u},500):window.onhashchange=u,this.mode="modern"):(r=document.createElement("iframe"),r.id="state-frame",r.style.display="none",document.body.appendChild(r),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&f.check()}),window.setInterval(function(){f.check()},50),this.onHashChanged=u,this.mode="legacy"),t.listeners.push(n),this.mode},destroy:function(n){var r,i;if(t&&t.listeners)for(r=t.listeners,i=r.length-1;i>=0;i--)r[i]===n&&r.splice(i,1)},setHash:function(n){return this.mode==="legacy"&&this.writeFrame(n),this.history===!0?(window.history.pushState({},document.title,n),this.fire()):i.hash=n[0]==="/"?n:"/"+n,this},writeFrame:function(n){var i=document.getElementById("state-frame"),t=i.contentDocument||i.contentWindow.document;t.open();t.write("<script>_hash = '"+n+"'; onload = parent.listener.syncHash;<script>");t.close()},syncHash:function(){var n=this._hash;return n!=i.hash&&(i.hash=n),this},onHashChanged:function(){}};t=n.Router=function(n){if(!(this instanceof t))return new t(n);this.params={};this.routes={};this.methods=["on","once","after","before"];this.scope=[];this._methods={};this._insert=this.insert;this.insert=this.insertEx;this.historySupport=(window.history!=null?window.history.pushState:null)!=null;this.configure();this.mount(n||{})};t.prototype.init=function(n){var t=this,f;return this.handler=function(n){var i=n&&n.newURL||window.location.hash,r=t.history===!0?t.getPath():i.replace(/.*#/,"");t.dispatch("on",r)},u.init(this.handler,this.history),this.history===!1?r()&&n?i.hash=n:r()||t.dispatch("on",i.hash.replace(/^#/,"")):(f=r()&&n?n:r()?null:i.hash.replace(/^#/,""),f&&window.history.replaceState({},document.title,f),(f||this.run_in_init===!0)&&this.handler()),this};t.prototype.explode=function(){var n=this.history===!0?this.getPath():i.hash;return n.charAt(1)==="/"&&(n=n.slice(1)),n.slice(1,n.length).split("/")};t.prototype.setRoute=function(n,t,i){var r=this.explode();return typeof n=="number"&&typeof t=="string"?r[n]=t:typeof i=="string"?r.splice(n,t,s):r=[n],u.setHash(r.join("/")),r};t.prototype.insertEx=function(n,t,i,r){return n==="once"&&(n="on",i=function(n){var t=!1;return function(){if(!t)return t=!0,n.apply(this,arguments)}}(i)),this._insert(n,t,i,r)};t.prototype.getRoute=function(n){var t=n,i;return typeof n=="number"?t=this.explode()[n]:typeof n=="string"?(i=this.explode(),t=i.indexOf(n)):t=this.explode(),t};t.prototype.destroy=function(){return u.destroy(this.handler),this};t.prototype.getPath=function(){var n=window.location.pathname;return n.substr(0,1)!=="/"&&(n="/"+n),n};t.prototype.configure=function(n){n=n||{};for(var t=0;t<this.methods.length;t++)this._methods[this.methods[t]]=!0;return this.recurse=n.recurse||this.recurse||!1,this.async=n.async||!1,this.delimiter=n.delimiter||"/",this.strict=typeof n.strict=="undefined"?!0:n.strict,this.notfound=n.notfound,this.resource=n.resource,this.history=n.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&n.run_handler_in_init!==!1,this.every={after:n.after||null,before:n.before||null,on:n.on||null},this};t.prototype.param=function(n,t){n[0]!==":"&&(n=":"+n);var i=new RegExp(n,"g");this.params[n]=function(n){return n.replace(i,t.source||t)}};t.prototype.on=t.prototype.route=function(n,t,i){var r=this;if(i||typeof t!="function"||(i=t,t=n,n="on"),Array.isArray(t))return t.forEach(function(t){r.on(n,t,i)});if(t.source&&(t=t.source.replace(/\\\//ig,"/")),Array.isArray(n))return n.forEach(function(n){r.on(n.toLowerCase(),t,i)});t=t.split(new RegExp(this.delimiter));t=h(t,this.delimiter);this.insert(n,this.scope.concat(t),i)};t.prototype.dispatch=function(n,t,i){function e(){f.last=r.after;f.invoke(f.runlist(r),f,i)}var f=this,r=this.traverse(n,t,this.routes,""),o=this._invoked,u;return(this._invoked=!0,!r||r.length===0)?(this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:n,path:t},i),!1):(this.recurse==="forward"&&(r=r.reverse()),u=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last],u&&u.length>0&&o)?(this.async?this.invoke(u,this,e):(this.invoke(u,this),e()),!0):(e(),!0)};t.prototype.invoke=function(n,t,i){var r=this;this.async?o(n,function u(i,r){if(Array.isArray(i))return o(i,u,r);typeof i=="function"&&i.apply(t,n.captures.concat(r))},function(){i&&i.apply(t,arguments)}):f(n,function u(i){if(Array.isArray(i))return f(i,u);if(typeof i=="function")return i.apply(t,n.captures||[]);typeof i=="string"&&r.resource&&r.resource[i].apply(t,n.captures||[])})};t.prototype.traverse=function(n,t,i,r,u){function c(n){function i(n){for(var r=[],t=0;t<n.length;t++)r[t]=Array.isArray(n[t])?i(n[t]):n[t];return r}function r(n){for(var t=n.length-1;t>=0;t--)Array.isArray(n[t])?(r(n[t]),n[t].length===0&&n.splice(t,1)):u(n[t])||n.splice(t,1)}if(!u)return n;var t=i(n);return t.matched=n.matched,t.captures=n.captures,t.after=n.after.filter(u),r(t),t}var o=[],l,h,s,f,e;if(t===this.delimiter&&i[n])return f=[[i.before,i[n]].filter(Boolean)],f.after=[i.after].filter(Boolean),f.matched=!0,f.captures=[],c(f);for(e in i)if(i.hasOwnProperty(e)&&(!this._methods[e]||this._methods[e]&&typeof i[e]=="object"&&!Array.isArray(i[e]))){if(l=h=r+this.delimiter+e,this.strict||(h+="["+this.delimiter+"]?"),s=t.match(new RegExp("^"+h)),!s)continue;if(s[0]&&s[0]==t&&i[e][n])return f=[[i[e].before,i[e][n]].filter(Boolean)],f.after=[i[e].after].filter(Boolean),f.matched=!0,f.captures=s.slice(1),this.recurse&&i===this.routes&&(f.push([i.before,i.on].filter(Boolean)),f.after=f.after.concat([i.after].filter(Boolean))),c(f);if(f=this.traverse(n,t,i[e],l),f.matched)return f.length>0&&(o=o.concat(f)),this.recurse&&(o.push([i[e].before,i[e].on].filter(Boolean)),f.after=f.after.concat([i[e].after].filter(Boolean)),i===this.routes&&(o.push([i.before,i.on].filter(Boolean)),f.after=f.after.concat([i.after].filter(Boolean)))),o.matched=!0,o.captures=f.captures,o.after=f.after,c(o)}return!1};t.prototype.insert=function(n,t,i,r){var f,e,s,o,u;if(t=t.filter(function(n){return n&&n.length>0}),r=r||this.routes,u=t.shift(),/\:|\*/.test(u)&&!/\\d|\\w/.test(u)&&(u=l(u,this.params)),t.length>0)return r[u]=r[u]||{},this.insert(n,t,i,r[u]);if(!u&&!t.length&&r===this.routes){f=typeof r[n];switch(f){case"function":r[n]=[r[n],i];return;case"object":r[n].push(i);return;case"undefined":r[n]=i;return}return}if(e=typeof r[u],s=Array.isArray(r[u]),r[u]&&!s&&e=="object"){f=typeof r[u][n];switch(f){case"function":r[u][n]=[r[u][n],i];return;case"object":r[u][n].push(i);return;case"undefined":r[u][n]=i;return}}else if(e=="undefined"){o={};o[n]=i;r[u]=o;return}throw new Error("Invalid route context: "+e);};t.prototype.extend=function(n){function u(n){t._methods[n]=!0;t[n]=function(){var i=arguments.length===1?[n,""]:[n];t.on.apply(t,i.concat(Array.prototype.slice.call(arguments)))}}for(var t=this,r=n.length,i=0;i<r;i++)u(n[i])};t.prototype.runlist=function(n){var t=this.every&&this.every.before?[this.every.before].concat(e(n)):e(n);return this.every&&this.every.on&&t.push(this.every.on),t.captures=n.captures,t.source=n.source,t};t.prototype.mount=function(n,t){function u(t,r){var u=t,f=t.split(i.delimiter),o=typeof n[t],e=f[0]===""||!i._methods[f[0]],s=e?"on":u;if(e&&(u=u.slice((u.match(new RegExp(i.delimiter))||[""])[0].length),f.shift()),e&&o==="object"&&!Array.isArray(n[t])){r=r.concat(f);i.mount(n[t],r);return}e&&(r=r.concat(u.split(i.delimiter)),r=h(r,i.delimiter));i.insert(s,r,n[t])}var i,r;if(n&&typeof n=="object"&&!Array.isArray(n)){i=this;t=t||[];Array.isArray(t)||(t=t.split(i.delimiter));for(r in n)n.hasOwnProperty(r)&&u(r,t.slice(0))}}})(typeof exports=="object"?exports:window),function(n){var t;(function(n){var t=function(){function n(){this.disposables=[]}return n.prototype.register=function(n){this.disposables.push(n)},n.prototype.dispose=function(){for(var t=this.disposables,n;t.length>0;)n=t.pop(),n.dispose(),n=null},n}();n.Disposables=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){function t(n){var i,t,r,u;for(n==undefined&&(n=["Something is not right. It could be a temporary glitch or a bug. Please, try again."]),i=[],t=0,r=n.length;t<r;t++)u={message:n[t]},i.push(u);return i}n.stringsToMessages=t;var i=function(){function n(){this.id=0;this.consumers={}}return n.prototype.registerIssueConsumer=function(n){var i=this.consumers,r=this.id++,t="_consumer"+r;return i[t]=n,{dispose:this.unregisterIssueConsumer.bind(this,t)}},n.prototype.unregisterIssueConsumer=function(n){var t=this.consumers,i=t[n];if(i==null)throw new Error('There is no issue consumer with the "'+n+'" key.');t[n]=null;delete t[n]},n.prototype.forEachConsumer=function(n){var t=this.consumers,i,r;for(i in t)t.hasOwnProperty(i)&&(r=t[i],n(r))},n.prototype.reportIssue=function(n){this.forEachConsumer(function(t){t.takeIssue(n)})},n.prototype.reportAllIssues=function(n){this.forEachConsumer(function(t){t.takeAllIssues(n)})},n.prototype.clearAllIssues=function(){this.forEachConsumer(function(n){n.clearAllIssues()})},n}();n.IssueTopic=i})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t=function(){function t(){this.wiredUp=!1;this.consumerOpt=null}return t.prototype.initialize=function(n){if(n==null)throw new Error("External event consumer is not specified.");this.consumerOpt=n},t.prototype.wireUp=function(n){this.wireOnBeforeUnload(n);this.wireKeyboardEvents(n);this.wiredUp=!0},t.prototype.wireOnBeforeUnload=function(n){var t=this,i=n.onbeforeunload;n.onbeforeunload=function(r){var s=t.consumerOpt,u,f,e,h,o,c,l;if(s!=null)return u=[],i!=null&&(f=i.call(n,r),f!=null&&u.push(f)),e=t.createBeforeUnloadEvent(),h=s.takeBeforeUnloadEvent(e),h&&(o=e.promptMessageOpt,o!=null&&u.push(o)),c=u.join(""),c||l}},t.prototype.wireKeyboardEvents=function(n){var t=this;jQuery(n.document).keydown(function(n){var i=t.consumerOpt,r;i!=null&&(r=t.createKeyboardEvent(n),i.takeKeyboardEvent(r))})},t.prototype.createKeyboardEvent=function(t){var i=n.tryMapScanCodeToKeyboardKey(t.which);return{keyboardKey:i,accept:function(n){n.takeKeyboardEvent(this)}}},t.prototype.createBeforeUnloadEvent=function(){return{promptMessageOpt:null,accept:function(n){n.takeBeforeUnloadEvent(this)}}},t.prototype.isWiredUp=function(){return this.wiredUp},t}();n.ExternalEventsNotifier=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){function r(n){var u,t,i;if(!n.muted()&&this.count){u=Array.prototype.slice.call(arguments,0);t=this.callbacks;for(i in t)if(t.hasOwnProperty(i)){var r=t[i],f=r.method,e=r.context;f.apply(e,arguments)}}}function u(){var r,n,t;if(this.count){r=Array.prototype.slice.call(arguments,0);n=this.callbacks;for(t in n)if(n.hasOwnProperty(t)){var i=n[t],u=i.method,f=i.context;u.apply(f,arguments)}}}function f(){return this.count>0}function e(n,t){var i="_"+this.id++,r=this.callbacks;return r[i]={method:n,context:t},this.count++,{dispose:o.bind(r,i)}}function o(n){var t=this.callbacks;typeof t[n]!="undefined"&&(t[n]=null,delete t[n],this.count--)}function s(){for(var n in this)this.hasOwnProperty(n)&&(this[n]=null,delete this[n])}function h(n){return t(n)}function c(n){return t(n)}function l(n){return t(n)}function t(n){var t={id:0,count:0,callbacks:{}},i=n!=null?r.bind(t,n):u.bind(t);return i.watch=e.bind(t),i.dispose=s.bind(t),i.beingWatched=f.bind(t),i}var i=function(){function n(n){this._mutted=n}return n.prototype.mute=function(){this._mutted=!0},n.prototype.muted=function(){return this._mutted},n.prototype.unmute=function(){this._mutted=!1},n}();n.Emitter=i;n.createDateSignal=h;n.createVoidSignal=c;n.createAnythingSignal=l;n.createWhateverSignal=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){function r(n){var r=String(n),t=i[r];return t==null?null:t}var t,i;(function(n){n[n.Up=0]="Up";n[n.Down=1]="Down";n[n.Left=2]="Left";n[n.Right=3]="Right";n[n.Enter=4]="Enter";n[n.Escape=5]="Escape"})(t=n.KeyboardKeys||(n.KeyboardKeys={}));i={"38":t.Up,"40":t.Down,"37":t.Left,"39":t.Right,"13":t.Enter,"27":t.Escape};n.tryMapScanCodeToKeyboardKey=r})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.takeBeforeUnloadEvent=function(){return!1},n.prototype.takeKeyboardEvent=function(){return!1},n}();n.DefaultExternalEventsConsumer=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={}));signInPageUrl="/signin",function(n){var t;(function(n){var t=function(){function n(n,t,i){this.appPath=n;this.antiForgeryToken=t;this.activityId=i;this.sendingRequest=ko.observable(!1);this.request=this.request.bind(this);this.sendForm=this.sendForm.bind(this)}return n.prototype.request=function(n,t,i){var f=this,e,u;this.appPath[this.appPath.length-1]==="/"?n[0]==="/"&&(n=n.substring(1)):n[0]!=="/"&&(n="/"+n);var o=this.appPath+n,r=jQuery.Deferred(),s={type:"POST",url:o,headers:{activityId:this.activityId,"X-Request-Verification-Token":this.antiForgeryToken},data:JSON.stringify(t),contentType:"application/json",dataType:"json",cache:!1};return this.sendingRequest(!0),e=jQuery.extend(s,i),u=jQuery.ajax(e),u.then(function(n){if(f.sendingRequest(!1),n==null){r.resolve();return}n.fail?r.reject(n.errors):r.resolve(n)},function(n){var t,i,u;f.sendingRequest(!1);try{t=n.getResponseHeader("X-Responded-JSON");t!=null?(i=JSON.parse(t),i.status==401&&window.location.assign(signInPageUrl)):(u=JSON.parse(n.responseText),r.reject(u.errors))}catch(e){r.reject(["Something is not right. It could be a temporary glitch or a bug. Please, try again."])}}),u.progress(function(n){r.notify(n)}),r.promise()},n.prototype.sendForm=function(n,t){var i=this;return new Promise(function(r,u){var e=i.appPath+n,f=new XMLHttpRequest,o=function(){u({message:"Request timed out. Please try again later.",code:"RequestError",details:[]})},s=function(){if(f.readyState===4){if(f.status===0){u({message:"Could not complete the request. Please try again later.",code:"RequestError",details:[]});return}var n=f.getAllResponseHeaders();switch(f.status){case 200:r(JSON.parse(f.responseText));break;case 401:window.location.assign(signInPageUrl);break;default:u(["Something is not right. It could be a temporary glitch or a bug. Please, try again."])}}};f.onreadystatechange=s.bind(i);f.ontimeout=o.bind(i);f.open("POST",e,!0);f.timeout=6e4;f.setRequestHeader("Accept","application/json");f.setRequestHeader("X-Request-Verification-Token",i.antiForgeryToken);f.send(t)})},n}();n.Fetcher=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(n){var t=function(n){function t(){var t=n.call(this)||this;return t.consumers=[],t}return __extends(t,n),t.prototype.registerConsumer=function(n){if(n==null)throw new Error("External events consumer is not specified.");this.consumers.push(n)},t.prototype.takeKeyboardEvent=function(n){for(var i=this.consumers,r,u,t=i.length-1;t>=0;t--)if(r=i[t],u=r.takeKeyboardEvent(n),u)return!0;return!1},t}(n.DefaultExternalEventsConsumer);n.ExternalEventsDispatcher=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t=function(){function n(n){var i,r,t,f,u;if(this.callbackEnabled=!0,n!=null&&n.length>0){for(r={},t=0,f=n.length;t<f;t++)u=n[t],r[u.route]=u.handler;i=new Router(r)}else i=new Router;this.router=i;this.router.configure({recurse:!1,async:!1,before:this.before.bind(this)})}return n.prototype.before=function(){return this.callbackEnabled?!0:(this.callbackEnabled=!0,!1)},n.prototype.start=function(n){var t=this.router,i=window.location.hash;t.init();i||t.setRoute(n)},n.prototype.setRouteSilently=function(n){var t=this.router.getRoute().join("/");n[0]=="/"&&(t="/"+t);t!=n&&(this.callbackEnabled=!1,this.router.setRoute(n))},n.prototype.registerRoute=function(n){this.router.on(n.route,n.handler)},n}();n.Navigator=t})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t;(function(n){n.defaultFontFaces=["Segoe UI","Trebuchet MS","Arial","sans-serif"];n.palettes={accent12:["#000033","#001A4D","#003366","#004D80","#006699","#0080B3","#0099CC","#00B3E6","#00ccff","#4EE4FF","#9BFBFF","#CDFDFF"],heatmap12:["#000045","#00008D","#0040BC","#0080EA","#00d3d3","#8ce236","#F0F000","#FFAA00","#FF5500","#FF0000","#D00000"]};n.defaultStyles={colors:{accentLightest:"#edf4f7",accentLighter:"#a0efff",accentLight:"#00ccff",accent:"#0099cc",accentDark:"#006699",accentDarker:"#003366",disturbance:"#ff6600",grayLightest:"#f5f5f5",grayLighter:"#eeeeee",grayLight:"#cccccc",gray:"#999999",grayDark:"#666666",grayDarker:"#333333",grayDarkest:"#000000",black:"#000000",white:"#ffffff"},fonts:{small:{faces:n.defaultFontFaces,size:12},normal:{faces:n.defaultFontFaces,size:14}}}})(t=n.UI||(n.UI={}))})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t;(function(t){var i=function(){function t(){this.couldNotLoadData=ko.observable(!1);this.lastKnownPageOptKo=ko.observable(null);this.data=ko.observable(null);this.tobePaged=n.createWhateverSignal()}return t.prototype.drop=function(){this.data(null)},t.prototype.hasData=function(){var n=this.data();return n!=null&&n.length},t.prototype.hasError=function(){return this.couldNotLoadData()},t.prototype.takeData=function(n,t){return this.lastKnownPageOptKo(n),this.data(t),t},t.prototype.isOrderedBy=function(n){var t=this.lastKnownPageOptKo();return t!=null?t.sorting.name===n:!1},t.prototype.isAscendingOrder=function(){var n=this.lastKnownPageOptKo();return n!=null?n.sorting.direction>0:!1},t.prototype.isDescendingOrder=function(){var n=this.lastKnownPageOptKo();return n!=null?n.sorting.direction<0:!1},t.prototype.requestPage=function(n){return this.tobePaged(n)},t.prototype.trySort=function(n,t,i){if(i===void 0&&(i=!0),this.hasPage()){var r=i?this.flipSortingOrStartOverUnsafe(n,t):this.startSortingOverUnsafe(n,t);this.requestPage(r)}return!1},t.prototype.makeCopy=function(n){return{skip:n.skip,take:n.take,sorting:{direction:n.sorting.direction,name:n.sorting.name}}},t.prototype.hasPage=function(){return this.lastKnownPageOptKo()!=null},t.prototype.copyCurrentPage=function(){var n=this.lastKnownPageOptKo();if(n==null)throw new Error("Page information has not been provided.");return this.makeCopy(n)},t.prototype.tryCopyCurrentPage=function(){var n=this.lastKnownPageOptKo();return n!=null?this.makeCopy(n):null},t.prototype.startSortingOverUnsafe=function(n,t){var i=this.copyCurrentPage(),r=i.sorting;return r.name=n,r.direction=t,i},t.prototype.flipSortingOrStartOverUnsafe=function(n,t){var u=this.copyCurrentPage(),i=u.sorting,f=i.name,r=i.direction;return r=f===n?-r:t,i.name=n,i.direction=r,u},t}();t.Table=i})(t=n.UI||(n.UI={}))})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t){t===void 0&&(t=!0);this.defaultPageSize=10;n!=null&&this.defaultPageSize>n&&(this.defaultPageSize=n);this.showAllOptionAvailable=t;this.page=ko.observable(0);this.pageCount=ko.observable(1);this.totalCount=ko.observable(0);this.pageSizes=ko.observable([this.defaultPageSize]);this.pageSize=ko.observable(this.defaultPageSize);this.maxPageSize=ko.observable(n?n:Number.MAX_VALUE);this.pages=ko.observable([1]);this.pageChanged=new ko.subscribable;this.setPage=this.setPage.bind(this);this.setPageSize=this.setPageSize.bind(this);this.isPageSizeOptionAvailable=this.isPageSizeOptionAvailable.bind(this);this.isPageSizeOptionSelected=this.isPageSizeOptionSelected.bind(this)}return n.prototype.setTotalCount=function(n){this.totalCount()!=n&&(this.totalCount(n),this.updatePages())},n.prototype.setPageSize=function(n){this.pageSize()!=n&&(this.pageSize(+n),this.updatePages(),this.notifyPageChanged())},n.prototype.setPage=function(n){this.page()!=n&&(this.page(n),this.updatePages(),this.notifyPageChanged())},n.prototype.addPageSizes=function(n){for(var t=this.pageSizes(),r,i=0;i<n.length;i++)r=n[i],r<=this.maxPageSize()&&t.indexOf(r)<0&&t.push(r);t.sort(function(n,t){return n-t});this.pageSizes(t)},n.prototype.isPageSizeOptionAvailable=function(n){return this.totalCount()>n&&this.pageSizes().length>1},n.prototype.isPageSizeOptionSelected=function(n){return this.pageSize()==n},n.prototype.isShowAllOptionSelected=function(){return this.pageSize()==0},n.prototype.isShowAllOptionAvailable=function(){return this.showAllOptionAvailable&&this.totalCount()>this.defaultPageSize},n.prototype.updatePages=function(){var n=this.pageSize()==0?1:Math.ceil(this.totalCount()/this.pageSize()),t,r,u,i;for(this.pageCount(n),t=Math.max(this.page()-3,0),r=Math.min(t+6,n-1),t=Math.max(r-6,0),u=[],i=t;i<=r;i++)u.push(i);this.pages(u);this.page()>=n&&this.setPage(Math.max(n-1,0))},n.prototype.notifyPageChanged=function(){this.pageChanged.notifySubscribers(null)},n}();n.AjaxPager=t})(t=n.UI||(n.UI={}))})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={})),function(n){var t;(function(n){var t;(function(t){var i=function(){function t(t){t===void 0&&(t=n.createWhateverSignal());this.tobePickedPage=t;this.sizeOptKo=ko.observable(null);this.indexOptKo=ko.observable(null);this.countOptKo=ko.observable(null)}return t.prototype.takePageAndTotalCount=function(n,t){var r=n.skip,i=n.take,u;if(r%i!=0)throw Error("Number of skipped elements ("+r+") isn't multiple of elements per page ("+i+").");if(i<1)throw new Error("Number of elements per page ("+i+") cannot be less than 1.");u=r/i;this.indexOptKo(u);this.sizeOptKo(n.take);this.countOptKo(t)},t.prototype.canGoNext=function(){return this.canGo(function(n,t,i){return i>(n+1)*t})},t.prototype.drop=function(){this.countOptKo(null);this.indexOptKo(null);this.sizeOptKo(null)},t.prototype.canGo=function(n){var t=this.indexOptKo(),i=this.sizeOptKo(),r=this.countOptKo();return t!=null&&i!=null&&r!=null?n(t,i,r):!1},t.prototype.go=function(n){var t=this.indexOptKo(),i=this.sizeOptKo(),r=this.countOptKo();t!=null&&i!=null&&r!=null&&n(t,i,r)},t.prototype.tryGoNext=function(){var n=this;this.canGoNext()&&this.go(function(t,i){var r=i,u=(t+1)*i,f={skip:u,take:r};n.tobePickedPage(f)})},t.prototype.canGoPrevious=function(){return this.canGo(function(n,t,i){var r=n-1;return r>=0&&i>0})},t.prototype.tryGoPrevious=function(){var n=this;this.canGoPrevious()&&this.go(function(t,i){var r=i,u=(t-1)*i,f={skip:u,take:r};n.tobePickedPage(f)})},t.prototype.currentPageNumberOpt=function(){var n=this.indexOptKo();return n!=null?n+1:null},t.prototype.totalPageCountOpt=function(){var n=this.countOptKo(),t=this.sizeOptKo(),i,r;if(n!=null&&t!=null)return i=n%t,r=(n-i)/t,i!==0&&r++,r},t}();t.Pager=i})(t=n.UI||(n.UI={}))})(t=n.Core||(n.Core={}))}(apiphany||(apiphany={}))