function HelpViewModel(n){var t=this;t.introActive=ko.observable(-1);t.tutorial=ko.observable(undefined);t.introActive.subscribe(function(){t.introActive()!==-1?(t.tutorial(new TutorialViewModel(t.tutorials()[t.introActive()])),setTimeout(function(){$window.resize()},100)):t.tutorial(undefined)});t.tutorials=ko.observableArray([]);n.tutorials.forEach(function(n){n.requiredElementIdOnPage===undefined?t.tutorials.push(n):$(n.requiredElementIdOnPage).length!==0&&t.tutorials.push(n)})}function TutorialViewModel(n){function i(){t.showNext.enabled()&&t.currentSlide(t.currentSlide()+1);return}function r(){t.showPrev.enabled()&&t.currentSlide(t.currentSlide()-1);return}var t=this;t.title=n.title;t.showTutorialTitle=n.showTutorialTitle||!1;t.slides=ko.observableArray(n.slides.map(function(n){return new SlideViewModel(n)}));t.currentSlide=ko.observable(0);t.currentSlide.subscribe(function(){var n=t.slides()[t.currentSlide()].focus;n&&$("html, body").animate({scrollTop:$(n).offset().top-$(".pt-header").height()},500)});t.showNext=i;t.showNext.enabled=ko.computed(function(){return t.currentSlide()<t.slides().length-1});t.showPrev=r;t.showPrev.enabled=ko.computed(function(){return t.currentSlide()>0})}function SlideViewModel(n){var t=this;t.title=n.title;t.position=n.position;var i=ko.observable(),r=ko.observable(),u=ko.observable(),f=ko.observable(),e=ko.observable();t.highlights=ko.computed(function(){return r(),i(),n.highlights.map(function(n){var t=$(n);return t.length==1?[{x:t.offset().left,y:t.offset().top},{x:t.offset().left+t.outerWidth(),y:t.offset().top+t.outerHeight()}]:[{x:0,y:0},{x:0,y:0}]})}).extend({throttle:0});t.shadersReady=ko.observable(!1);$window.resize(function(){i($window.width());r($window.height());u($document.width());f($document.height())}).resize();$document.scroll(function(){e($document.scrollTop())}).scroll();t.shaders=ko.computed(function(){var i=[[{x:0,y:0},{x:u(),y:f()}]];return t.highlights().forEach(function(n){i=i.map(function(t){return t[0].x>n[1].x||t[1].x<n[0].x||t[0].y>n[1].y||t[1].y<n[0].y?[t]:applyKingMcpheatTaylorVoroninHoleingAlgorithm(n,t)}).reduce(function(n,t){return n.concat(t)})}),setTimeout(function(){t.shadersReady(!0)},0),i.map(mapCoordsToCss).map(function(t){return n.position&&(t.position=n.position||"absolute"),t})}).extend({throttle:0});t.text=n.text;t.focus=n.focus;t.demos=n.demos;t.showMeHow=function(){$.fancybox.open(t.demos,{autoSize:!0,height:"auto",transitionIn:"elastic",transitionOut:"elastic",speedIn:100,speedOut:100,autoDimensions:!0,centerOnScroll:!0})}}function applyKingMcpheatTaylorVoroninHoleingAlgorithm(n,t,i){var r=[];return i=i||0,r.push([{x:t[0].x,y:t[0].y},{x:t[1].x,y:n[0].y-i}]),r.push([{x:t[0].x,y:n[0].y-i},{x:n[0].x-i,y:n[1].y+i}]),r.push([{x:n[1].x+i,y:n[0].y-i},{x:t[1].x,y:n[1].y+i}]),r.push([{x:t[0].x,y:n[1].y+i},{x:t[1].x,y:t[1].y}]),r.map(function(n){return n.map(function(n){return{x:Math.min(Math.max(n.x,t[0].x),t[1].x),y:Math.min(Math.max(n.y,t[0].y),t[1].y)}})})}function mapCoordsToCss(n){return{left:n[0].x+"px",top:n[0].y+"px",width:n[1].x-n[0].x+"px",height:n[1].y-n[0].y+"px"}}var $document=$(document),$window=$(window);ko.bindingHandlers.scrollTo={init:function(n){$(n).css("left",0)},update:function(n,t){var f=t(),e=ko.unwrap(f),i=$(n),u=i.children().eq(e),r;u?(r=u.position().left,r-=i.children().eq(0).position().left,i.css("left",-r)):(r=0,i.css("left",0))}}