define("zoomer",["queue","jquery","d3","picture-book","underscore"],function(e,t,n,a,i){function o(){p()||r("syria"),w.init(s)}function s(){var e=w.activeBook;if(C!==e){C=e;var t=[],a=[],o=[];i.each(e.pages,function(e){o.push(e.position),t.push(+e.node.getAttribute("data-pb-zoom"));var n=+e.node.getAttribute("data-pb-focus-x"),i=+e.node.getAttribute("data-pb-focus-y");a.push([n,i])}),b=n.scale.linear().domain(o).range(t).clamp(!0),focusScale=n.scale.linear().domain(o).range(a).clamp(!0),P=E?1.5*b(e.progress):b(e.progress);+e.pages[0].node.getAttribute("data-pb-zoom"),+e.pages[e.pages.length-1].node.getAttribute("data-pb-zoom")}if(!p()){+e.minPage.node.getAttribute("data-pb-zoom"),+e.maxPage.node.getAttribute("data-pb-zoom");y=b(e.progress),O=focusScale(e.progress)}}function r(e){var t=c={};c.slug=e,c.container=n.select("#zoomer-"+e),c.zoomer=c.container.select(".g-zoomer"),c.width=parseInt(c.zoomer.style("width")),c.height=parseInt(c.zoomer.style("height")),c.canvas=c.zoomer.append("canvas").datum(function(){return{slug:e}}).attr("width",c.width).attr("height",c.height).style("width",c.width+"px").style("height",c.height+"px"),c.ctx=c.canvas.node().getContext("2d"),d(t)}function d(t){function n(e,n){u(e,n,t)}var a=t.slug,i=e(1);I[a].forEach(function(e){i.defer(g,e)}),i.awaitAll(n)}function u(e,n,a){t("#zoomer-syria").addClass("show"),l(a)}function g(e,t){var n=v+"/"+e.name;if(x.hasOwnProperty(e.name))e.imageObj=x[e.name],t(null,e);else{var a=new Image;a.src=n,e.imageObj=a,x[e.name]=e.imageObj,a.onload=function(){t(null,e)}}}function l(e){function t(){var n=!1;if(w.activeBook&&e.slug===w.activeBook.slug&&!n){var a={z:y-P,f:[O[0]-z[0],O[1]-z[1]]},i=a.z<0?Math.pow(j,.65):j;a.z=a.z*i,a.f=[a.f[0]*i,a.f[1]*i],P+=a.z,z=[z[0]+a.f[0],z[1]+a.f[1]],h(P,z,e)}requestAnimationFrame(t)}h(A[e.slug],z,e),requestAnimationFrame(t)}function h(e,t,n){var a=n.slug,i=n.width,o=n.height,s=n.ctx;n.zoom=e,n.coverDim=window.innerWidth>window.innerHeight?i:o;var r=n.coverDim,c=m(e,a),d=c.hiImage,u=c.loImage;c.bgImage;E&&(t[1]=k);var g=[t[0]*i,t[1]*o],l=0;E&&e<.02&&"syria"===n.slug&&(s.fillStyle="#152735",s.fillRect(0,0,i,o));e*u.scale<1.2;s.save(),s.translate(g[0],g[1]),s.scale(e,e),s.save(),s.scale(u.scale,u.scale),s.globalAlpha=1-l,s.drawImage(u.imageObj,-r/2,-r/2,r,r),s.restore(),s.save(),s.scale(d.scale,d.scale),s.globalAlpha=c.progress*(1-l),s.drawImage(d.imageObj,-r/2,-r/2,r,r),s.restore(),s.restore(),e<.02&&"syria"===n.slug}function m(e,t){var n,a,o,s,r,c;return e*=.9,i.each(I[t],function(t){var i=t.showAt=1/t.scale,c=Math.abs(i-e),d="undefined"==typeof n,u="undefined"==typeof o;i<=e&&(d||c=0&&(a=t-1)),i>=e&&(u||cr.showAt)&&(r=t,r.distance=c)}),"undefined"==typeof n&&(n=s),"undefined"==typeof a&&(a=s),"undefined"==typeof o&&(o=r),c=(e-n.showAt)/(o.showAt-n.showAt),c=isNaN(c)?0:isFinite(c)?c:1,{loImage:n,bgImage:a,hiImage:o,progress:c}}function f(){return{syria:[{name:"09.jpg",scale:1/.0057},{name:"08.jpg",scale:1/.0114},{name:"07.jpg",scale:1/.0228},{name:"06.jpg",scale:1/.0456},{name:"05.jpg",scale:1/.0912},{name:"04.jpg",scale:1/.184},{name:"03.jpg",scale:1/.368},{name:"02.jpg",scale:1/.736},{name:"01.jpg",scale:1/1.472},{name:"00.jpg",scale:1/2.944}]}}function p(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry/.test(navigator.userAgent)}var b,v=(c={},"/assets/images/syria"),x={},I=f(),w=new a,A={syria:.0057},P=.0057,y=.0057,z=[.5,.5],O=[.5,.5],j=.015,k=.6,C="",B=window.innerWidth,E=B<600;return o}),define("picture-book",[],function(){function e(){return n&&!t()}function t(){return navigator.userAgent.match(/(iPad|iPhone);.*CPU.*OS [8|9]_\d/i)&&navigator.userAgent.indexOf("Safari")>-1&&navigator.userAgent.indexOf("CriOS")==-1||navigator.userAgent.indexOf("Twitter")>-1}var n=(/iPad|iPhone/.test(navigator.userAgent),/Android/.test(navigator.userAgent),/Android|webOS|iPhone|iPad|iPod|BlackBerry/.test(navigator.userAgent)),a=e();return function(e){function t(){return window.scrollY}var n=0,i=.5;this.init=function(e){var t=this;this.books.forEach(function(e){e.datum=[].slice.call(e.node.attributes).filter(function(e){return 0===e.name.indexOf("data-pb-")}).map(function(e){return{name:e.name.replace("data-pb-",""),value:+e.value}})}),document.addEventListener("scroll",function(){t.scroll()},!1),document.addEventListener("resize",function(){t.resize()},!1),a&&(document.body.addEventListener("touchstart",function(){t.scroll()},!1),document.body.addEventListener("touchmove",function(){t.scroll()},!1),document.body.addEventListener("touchend",function(){t.scroll()},!1)),t.update=e,t.scroll()},this.books=[].map.call(document.querySelectorAll(".g-picture-book"),function(e){return{node:e,slug:e.getAttribute("data-slug"),bgNode:e.querySelector(".g-picture-book__bg"),pages:[].map.call(e.querySelectorAll(".g-picture-book__page"),function(e){return{node:e}})}}),this.scroll=function(){var e=this,a=t(),o=!1,s=!1;this.scan(),this.books.forEach(function(t,r){var c=a-n-t.rect.top,d=a-n-t.rect.bottom+t.bgRect.height;if(c<=0&&d<=0)t.bgNode.classList.remove("g-fixed"),t.bgNode.classList.remove("g-bottom");else if(d>0)t.bgNode.classList.remove("g-fixed"),t.bgNode.classList.add("g-bottom");else if(e.activeBook=t,s=!0,o=!0,t.bgNode.classList.add("g-fixed"),t.bgNode.classList.remove("g-bottom"),t.pages.length){var u=t.pages[0],g=t.pages[t.pages.length-1];u.pxPosition=u.rect.middle-t.rect.top,g.pxPosition=g.rect.middle-t.rect.top;var l=c-u.pxPosition+t.bgRect.height/2,h=t.rect.height-u.pxPosition-(t.rect.height-g.pxPosition);t.progress=l/h,t.minIndex=0,t.pages.forEach(function(e,o){var s=a-n-e.rect.top+innerHeight*i,r=a-n-(e.rect.top+e.rect.height/2)+innerHeight*i,c=a-n-e.rect.bottom+innerHeight*i;e.progress=(e.rect.top+e.rect.height/2)/innerHeight,e.midDistance=r,c>=0?(e.distance=c,t.minIndex=o):s<=0?e.distance=s:s>0&&c<0&&(e.distance=0,t.minIndex=o)}),t.maxIndex=Math.min(t.minIndex+1,t.pages.length-1),t.minPage=t.pages[t.minIndex],t.maxPage=t.pages[t.maxIndex],t.remainder=t.minIndex===t.maxIndex?0:1-Math.max(0,-t.minPage.distance/(t.maxPage.distance-t.minPage.distance)),t.middleRemainder=t.minIndex===t.maxIndex?0:1-Math.max(0,t.minPage.midDistance/innerHeight),t.remainder=e.easeInOutQuad(t.remainder),e.activePage=t.minPage,e.update(e.activePage)}}),s||(e.activeBook=null)},this.scan=function(){n=t(),this.books.forEach(function(e){e.rect=e.node.getBoundingClientRect(),e.bgRect=e.bgNode.getBoundingClientRect(),e.pages.forEach(function(e){e.rect=e.node.getBoundingClientRect(),e.rect.middle=e.rect.top+e.rect.height/2});var t=e.pages[0],n=e.pages[e.pages.length-1];e.pages.forEach(function(e){e.position=(e.rect.middle-t.rect.middle)/(n.rect.middle-t.rect.middle),e.node.setAttribute("data-pb-pos",e.position)})})},this.resize=function(){this.scan(),this.scroll()},this.easeLinear=function(e){return e},this.easeInOutSinusoidal=function(e){return(Math.sin(e*Math.PI-Math.PI/2)+1)/2},this.easeInQuad=function(e){return e*e},this.easeOutQuad=function(e){return 1-this.easeInQuad(1-e)},this.easeInOutQuad=function(e){return e<.5?this.easeInQuad(2*e)/2:1-this.easeInQuad(2*(1-e))/2},this.easeInCubic=function(e){return Math.pow(e,3)},this.easeOutCubic=function(e){return 1-this.easeInCubic(1-e)},this.easeInOutCubic=function(e){return e<.5?this.easeInCubic(2*e)/2:1-this.easeInCubic(2*(1-e))/2}}});