/* turn.js 4.1.1 | Copyright (c) 2012 Emmanuel Garcia - 2019 Raffaele Morganti | turnjs.com | turnjs.com/license.txt */ (function(g){function G(a,b,c){if(c[0]&&"object"!=typeof c[0]){if(b[c[0]])return b[c[0]].apply(a,Array.prototype.slice.call(c,1));throw t(c[0]+" is not a method or property");}return b.init.apply(a,c)}function q(a,b,c,d){return{css:{position:"absolute",top:a,left:b,overflow:d||"hidden",zIndex:c||"auto"}}}function L(a,b,c,d,e){var k=1-e,U=k*k*k,f=e*e*e;return l(Math.round(U*a.x+3*e*k*k*b.x+3*e*e*k*c.x+f*d.x),Math.round(U*a.y+3*e*k*k*b.y+3*e*e*k*c.y+f*d.y))}function l(a,b){return{x:a,y:b}}function H(a, b,c){return c?" translate3d("+a+"px,"+b+"px, 0px) ":" translate("+a+"px, "+b+"px) "}function I(a){return" rotate("+a+"deg) "}function m(a,b){return Object.prototype.hasOwnProperty.call(b,a)}function R(a,b,c,d,e){var k=[];b={x:b.x/100*a.width(),y:b.y/100*a.height()};c={x:c.x/100*a.width(),y:c.y/100*a.height()};var f=c.x-b.x,h=c.y-b.y,g=Math.atan2(h,f),r=g-Math.PI/2;r=Math.abs(a.width()*Math.sin(r))+Math.abs(a.height()*Math.cos(r));f=Math.sqrt(h*h+f*f);c=l(c.xk)throw t('Page "'+b+'" cannot be inserted');}else b=k,d=!0;1<=b&&b<=k&&(c="double"==e.display?b%2?" odd":" even":"",e.done&&this.turn("stop"),b in e.pageObjs&&f._movePages.call(this,b,1), d&&(e.totalPages=k),e.pageObjs[b]=g(a).css({"float":"left"}).addClass("page p"+b+c),f._addPage.call(this,b),f._removeFromDOM.call(this));return this},_addPage:function(a){var b=this.data(),c=b.pageObjs[a];if(c)if(f._necessPage.call(this,a)){if(!b.pageWrap[a]){b.pageWrap[a]=g("
",{"class":"page-wrapper",page:a,css:{position:"absolute",overflow:"hidden"}});this.append(b.pageWrap[a]);b.pagePlace[a]||(b.pagePlace[a]=a,b.pageObjs[a].appendTo(b.pageWrap[a]));var d=f._pageSize.call(this,a,!0);c.css({width:d.width, height:d.height});b.pageWrap[a].css(d)}b.pagePlace[a]==a&&f._makeFlip.call(this,a)}else b.pagePlace[a]=0,b.pageObjs[a]&&b.pageObjs[a].remove()},hasPage:function(a){return m(a,this.data().pageObjs)},center:function(a){var b=this.data(),c=g(this).turn("size"),d=0;b.noCenter||("double"==b.display&&(a=this.turn("view",a||b.tpage||b.page),"ltr"==b.direction?a[0]?a[1]||(d+=c.width/4):d-=c.width/4:a[0]?a[1]||(d-=c.width/4):d+=c.width/4),d==0?d='auto':d,g(this).css({marginLeft:d}));return this},destroy:function(){var a= this,b=this.data();if("prevented"!=v("destroying",this)){b.destroying=!0;g.each("end first flip last pressed released start turning turned zooming missing".split(" "),function(b,d){a.off(d)});this.parent().off("start",b.eventHandlers.start);for(g(document).off(w.move,b.eventHandlers.touchMove).off(w.up,b.eventHandlers.touchEnd);0!==b.totalPages;)this.turn("removePage",b.totalPages);b.fparent&&b.fparent.remove();b.shadow&&b.shadow.remove();this.removeData();b=null;return this}},is:function(){return"object"== typeof this.data().pages},zoom:function(a){var b=this.data();if("number"==typeof a){if(.001>a||100this.data().totalPages)){var b=this.turn("range");for(a=b[0];a<=b[1];a++)f._addPage.call(this,a)}}, range:function(a){var b=this.data();a=a||b.tpage||b.page||1;var c=f._view.call(this,a);if(1>a||a>b.totalPages)throw t('"'+a+'" is not a valid page');c[1]=c[1]||c[0];if(1<=c[0]&&c[1]<=b.totalPages)if(b.totalPages-c[1]>c[0]){a=Math.min(c[0]-1,2);var d=4-a}else d=Math.min(b.totalPages-c[1],2),a=4-d;else d=a=5;return[Math.max(1,c[0]-a),Math.min(b.totalPages,c[1]+d)]},_necessPage:function(a){if(0===a)return!0;var b=this.turn("range");return this.data().pageObjs[a].hasClass("fixed")||a>=b[0]&&a<=b[1]}, _removeFromDOM:function(){var a,b=this.data();for(a in b.pageWrap)m(a,b.pageWrap)&&!f._necessPage.call(this,a)&&f._removePageFromDOM.call(this,a)},_removePageFromDOM:function(a){var b=this.data();if(b.pages[a]){var c=b.pages[a].data();h._moveFoldingPage.call(b.pages[a],!1);c.f&&c.f.fwrapper&&c.f.fwrapper.remove();b.pages[a].removeData();b.pages[a].remove();delete b.pages[a]}b.pageObjs[a]&&b.pageObjs[a].remove();b.pageWrap[a]&&(b.pageWrap[a].remove(),delete b.pageWrap[a]);f._removeMv.call(this,a); delete b.pagePlace[a];delete b.pageZoom[a]},removePage:function(a){var b=this.data();if("*"==a)for(;0!==b.totalPages;)this.turn("removePage",b.totalPages);else{if(1>a||a>b.totalPages)throw t("The page "+a+" doesn't exist");b.pageObjs[a]&&(this.turn("stop"),f._removePageFromDOM.call(this,a),delete b.pageObjs[a]);f._movePages.call(this,a,-1);--b.totalPages;b.page>b.totalPages?(b.page=null,f._fitPage.call(this,b.totalPages)):(f._makeRange.call(this),this.turn("update"))}return this},_movePages:function(a, b){var c,d=this,e=this.data(),k="single"==e.display,h=function(a){var c=a+b,h=c%2,g=h?" odd ":" even ";e.pageObjs[a]&&(e.pageObjs[c]=e.pageObjs[a].removeClass("p"+a+" odd even").addClass("p"+c+g));e.pagePlace[a]&&e.pageWrap[a]&&(e.pagePlace[c]=c,e.pageObjs[c].hasClass("fixed")?e.pageWrap[c]=e.pageWrap[a].attr("page",c):e.pageWrap[c]=e.pageWrap[a].css(f._pageSize.call(d,c,!0)).attr("page",c),e.pages[a]&&(e.pages[c]=e.pages[a].flip("options",{page:c,next:k||h?c+1:c-1})),b&&(delete e.pages[a],delete e.pagePlace[a], delete e.pageZoom[a],delete e.pageObjs[a],delete e.pageWrap[a]))};if(0=a;c--)h(c);else for(c=a;c<=e.totalPages;c++)h(c)},display:function(a){var b=this.data(),c=b.display;if(void 0===a)return c;if(-1==W.indexOf(a))throw t('"'+a+'" is not a value for display');switch(a){case "single":b.pageObjs[0]||(this.turn("stop").css({overflow:"hidden"}),b.pageObjs[0]=g("
",{"class":"page p-temporal"}).css({width:this.width(),height:this.height()}).appendTo(this));this.addClass("shadow"); break;case "double":b.pageObjs[0]&&(this.turn("stop").css({overflow:""}),b.pageObjs[0].remove(),delete b.pageObjs[0]),this.removeClass("shadow")}b.display=a;c&&(a=this.turn("size"),f._movePages.call(this,1,0),this.turn("size",a.width,a.height).turn("update"));return this},direction:function(a){var b=this.data();if(void 0===a)return b.direction;a=a.toLowerCase();if(-1==X.indexOf(a))throw t('"'+a+'" is not a value for direction');"rtl"==a&&g(this).attr("dir","ltr").css({direction:"ltr"});b.direction= a;b.done&&this.turn("size",g(this).width(),g(this).height());return this},animating:function(){return 0a;c--)this.turn("removePage",c);b.totalPages=a;f._fitPage.call(this,b.page);return this}return b.totalPages},_missing:function(a){var b=this.data();if(!(1>b.totalPages)){var c=this.turn("range",a),d=[];for(a=c[0];a<=c[1];a++)b.pageObjs[a]||d.push(a);0d[1]?(h=d[1],g=e[0]):d[0]&&ah?"r":"l"):b.pages[h].flip("turnPage",a>h?"l":"r"):"ltr"==b.direction?b.pages[h].flip("turnPage",c[a>h?1:0]):b.pages[h].flip("turnPage",c[a>h?0:1]))},page:function(a){var b=this.data();if(void 0===a)return b.page;if(!b.disabled&&!b.destroying){a=parseInt(a,10);if(0b.page?b.next:b.page+1),f._addMotionPage.call(a.target));f._updateShadow.call(b.turn)},_eventEnd:function(a,b,c){g(a.target).data();a=b.turn;var d=a.data();if(c){if(c=d.tpage||d.page,c==b.next||c==b.page)delete d.tpage,f._fitPage.call(a,c||b.next,!0)}else f._removeMv.call(a,b.page),f._updateShadow.call(a),a.turn("update")},_eventPressed:function(a){a=g(a.target).data().f;var b=a.opts.turn;b.data().mouseAction=!0;b.turn("update");return a.time= (new Date).getTime()},_eventReleased:function(a,b){var c=g(a.target),d=c.data().f,e=d.opts.turn,k=e.data();b="single"==k.display?"br"==b.corner||"tr"==b.corner?b.xc.width()/2:0>b.x||b.x>c.width();if(200>(new Date).getTime()-d.time||b)a.preventDefault(),f._turnPage.call(e,d.opts.next);k.mouseAction=!1},_flip:function(a){a.stopPropagation();a=g(a.target).data().f.opts;a.turn.trigger("turn",[a.next]);a.turn.data().opts.autoCenter&&a.turn.turn("center",a.next)},_touchStart:function(){var a= this.data(),b;for(b in a.pages)if(m(b,a.pages)&&!1===h._eventStart.apply(a.pages[b],arguments))return!1},_touchMove:function(){var a=this.data(),b;for(b in a.pages)m(b,a.pages)&&h._eventMove.apply(a.pages[b],arguments)},_touchEnd:function(){var a=this.data(),b;for(b in a.pages)m(b,a.pages)&&h._eventEnd.apply(a.pages[b],arguments)},calculateZ:function(a){var b=this,c=this.data();var d=this.turn("view");var e=d[0]||d[1],k=a.length-1,h={pageZ:{},partZ:{},pageV:{}},f=function(a){a=b.turn("view",a);a[0]&& (h.pageV[a[0]]=!0);a[1]&&(h.pageV[a[1]]=!0)};for(d=0;d<=k;d++){var g=a[d];var l=c.pages[g].data().f.opts.next;var n=c.pagePlace[g];f(g);f(l);g=c.pagePlace[l]==l?l:g;h.pageZ[g]=c.totalPages-Math.abs(e-g);h.partZ[n]=2*c.totalPages-k+d}return h},update:function(){var a,b=this.data();if(this.turn("animating")&&0!==b.pageMv[0]){var c=this.turn("calculateZ",b.pageMv),d=this.turn("corner"),e=this.turn("view"),h=this.turn("view",b.tpage);for(a in b.pageWrap)if(m(a,b.pageWrap)){var g=b.pageObjs[a].hasClass("fixed"); b.pageWrap[a].css({display:c.pageV[a]||g?"":"none",zIndex:(b.pageObjs[a].hasClass("hard")?c.partZ[a]:c.pageZ[a])||(g?-1:0)});if(g=b.pages[a])g.flip("z",c.partZ[a]||null),c.pageV[a]&&g.flip("resize"),b.tpage?g.flip("hover",!1).flip("disable",-1==b.pageMv.indexOf(parseInt(a,10))&&a!=h[0]&&a!=h[1]):g.flip("hover",!1===d).flip("disable",a!=e[0]&&a!=e[1])}}else for(a in b.pageWrap)m(a,b.pageWrap)&&(c=f._setPageLoc.call(this,a),b.pages[a]&&b.pages[a].flip("disable",b.disabled||1!=c).flip("hover",!0).flip("z", null));return this},_updateShadow:function(){var a=this.data(),b=this.width(),c=this.height(),d="single"==a.display?b:b/2;var e=this.turn("view");a.shadow||(a.shadow=g("
",{"class":"shadow",css:q(0,0,0).css}).appendTo(this));for(var h=0;h=a.x||0>=a.y||a.x>=c||a.y>=d)return!1;var g=h._cAllowed.call(this);switch(b.effect){case "hard":if(a.x> c-e)a.corner="r";else if(a.x=d-e)a.corner+="b";else return!1;if(a.x<=e)a.corner+="l";else if(a.x>=c-e)a.corner+="r";else return!1}return a.corner&&-1!=g.indexOf(a.corner)?a:!1},_isIArea:function(a){var b=this.data().f.parent.offset();a=x&&a.originalEvent?a.originalEvent.touches[0]:a;return h._cornerActivated.call(this,{x:a.pageX-b.left,y:a.pageY-b.top})},_c:function(a,b){b=b||0;switch(a){case "tl":return l(b,b);case "tr":return l(this.width()- b,b);case "bl":return l(b,this.height()-b);case "br":return l(this.width()-b,this.height()-b);case "l":return l(b,0);case "r":return l(this.width()-b,0)}},_c2:function(a){switch(a){case "tl":return l(2*this.width(),0);case "tr":return l(-this.width(),0);case "bl":return l(2*this.width(),this.height());case "br":return l(-this.width(),this.height());case "l":return l(2*this.width(),0);case "r":return l(-this.width(),0)}},_foldingPage:function(){var a=this.data().f;if(a){var b=a.opts;if(b.turn)return a= b.turn.data(),"single"==a.display?1",q(0,0,1)).css({position:"",width:this.width(),height:this.height()}).appendTo(a.parent));return b},type:function(){return this.data().f.effect},resize:function(a){var b=this.data().f,c=b.opts.turn.data(),d=this.width(), e=this.height();switch(b.effect){case "hard":a&&(b.wrapper.css({width:d,height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&(b.ashadow.css({width:d,height:e}),b.bshadow.css({width:d,height:e})));break;case "sheet":a&&(a=Math.round(Math.sqrt(Math.pow(d,2)+Math.pow(e,2))),b.wrapper.css({width:a,height:a}),b.fwrapper.css({width:a,height:a}).children(":first-child").css({width:d,height:e}),b.fpage.css({width:d,height:e}),c.opts.gradients&&b.ashadow.css({width:d,height:e}),h._backGradient.call(this)&& b.bshadow.css({width:d,height:e})),b.parent.is(":visible")&&(c=B(b.parent[0]),b.fwrapper.css({top:c.top,left:c.left}),c=B(b.opts.turn[0]),b.fparent.css({top:-c.top,left:-c.left})),this.flip("z",b.opts["z-index"])}},_addPageWrapper:function(){var a=this.data().f,b=a.opts.turn.data(),c=this.parent();a.parent=c;if(!a.wrapper)switch(a.effect){case "hard":var d={"transform-style":"preserve-3d","backface-visibility":"hidden"};a.wrapper=g("
",q(0,0,2)).css(d).appendTo(c).prepend(this);a.fpage=g("
", q(0,0,1)).css(d).appendTo(c);b.opts.gradients&&(a.ashadow=g("
",q(0,0,0)).hide().appendTo(c),a.bshadow=g("
",q(0,0,0)));break;case "sheet":this.width(),this.height(),a.fparent=a.opts.turn.data().fparent,a.fparent||(d=g("
",{css:{"pointer-events":"none"}}).hide(),d.data().flips=0,d.css(q(0,0,"auto","visible").css).appendTo(a.opts.turn),a.opts.turn.data().fparent=d,a.fparent=d),this.css({position:"absolute",top:0,left:0,bottom:"auto",right:"auto"}),a.wrapper=g("
",q(0,0,this.css("z-index"))).appendTo(c).prepend(this), a.fwrapper=g("
",q(c.offset().top,c.offset().left)).hide().appendTo(a.fparent),a.fpage=g("
",q(0,0,0,"visible")).css({cursor:"default"}).appendTo(a.fwrapper),b.opts.gradients&&(a.ashadow=g("
",q(0,0,1)).appendTo(a.fpage)),h.setData.call(this,a)}h.resize.call(this,!0)},_fold:function(a){var b=this.data().f,c=b.opts.turn.data(),d=h._c.call(this,a.corner),e=this.width(),g=this.height();switch(b.effect){case "hard":a.x="l"==a.corner?Math.min(Math.max(a.x,0),2*e):Math.max(Math.min(a.x,e), -e);var f=c.totalPages,m=b.opts["z-index"]||f,V={overflow:"visible"},r=d.x?(d.x-a.x)/e:a.x/e,n=90*r,q=90>n;switch(a.corner){case "l":var t="0% 50%";var u="100% 50%";if(q){var y=0;var w=0N&&(p.x+=Math.abs(p.y*b.y/b.x),p.y=0,Math.round(p.x*Math.tan(M-k))N&&(b=M-k,f=T-g/Math.sin(b),z=l(Math.round(f*Math.cos(b)),Math.round(f*Math.sin(b))),E&&(z.x=-z.x),F&&(z.y=-z.y));B=Math.round(p.y/Math.tan(k)+p.x);b=e-B;f=b*Math.cos(2*k);n=b*Math.sin(2*k);S=l(Math.round(E?b-f:B+f),Math.round(F?n:g-n));c.opts.gradients&&(A=b*Math.sin(k),b=h._c2.call(x,a.corner),b=Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y- a.y,2))/e,G=Math.sin(N*(1