(function(a,v,y,k){function d(n,e,t){var i=this;if(a.data(n,"cubeportfolio"))throw new Error("cubeportfolio is already initialized. Destroy it before initialize again!");i.obj=n,i.$obj=a(n),a.data(i.obj,"cubeportfolio",i),e.sortToPreventGaps!==k&&(e.sortByDimension=e.sortToPreventGaps,delete e.sortToPreventGaps),i.options=a.extend({},a.fn.cubeportfolio.options,e,i.$obj.data("cbp-options")),i.isAnimating=!0,i.defaultFilter=i.options.defaultFilter,i.registeredEvents=[],i.queue=[],i.addedWrapp=!1,a.isFunction(t)&&i.registerEvent("initFinish",t,!0);var s=i.$obj.children();i.$obj.addClass("cbp"),(s.length===0||s.first().hasClass("cbp-item"))&&(i.wrapInner(i.obj,"cbp-wrapper"),i.addedWrapp=!0),i.$ul=i.$obj.children().addClass("cbp-wrapper"),i.wrapInner(i.obj,"cbp-wrapper-outer"),i.wrapper=i.$obj.children(".cbp-wrapper-outer"),i.blocks=i.$ul.children(".cbp-item"),i.blocksOn=i.blocks,i.wrapInner(i.blocks,"cbp-item-wrapper"),i.plugins={},a.each(d.plugins,function(c,o){var r=o(i);r&&(i.plugins[c]=r)}),i.triggerEvent("afterPlugins"),i.removeAttrAfterStoreData=a.Deferred(),i.loadImages(i.$obj,i.display)}a.extend(d.prototype,{storeData:function(n,e){var t=this;e=e||0,n.each(function(i,s){var c=a(s),o=c.width(),r=c.height();c.data("cbp",{index:e+i,indexInitial:e+i,wrapper:c.children(".cbp-item-wrapper"),widthInitial:o,heightInitial:r,width:o,height:r,widthAndGap:o+t.options.gapVertical,heightAndGap:r+t.options.gapHorizontal,left:null,leftNew:null,top:null,topNew:null,pack:!1})}),this.removeAttrAfterStoreData.resolve()},wrapInner:function(n,e){var t,i,s;if(e=e||"",!(n.length&&n.length<1))for(n.length===k&&(n=[n]),i=n.length-1;i>=0;i--){for(t=n[i],(s=y.createElement("div")).setAttribute("class",e);t.childNodes.length;)s.appendChild(t.childNodes[0]);t.appendChild(s)}},removeAttrImage:function(n){this.removeAttrAfterStoreData.then(function(){n.removeAttribute("width"),n.removeAttribute("height"),n.removeAttribute("style")})},loadImages:function(n,e){var t=this;requestAnimationFrame(function(){var i=n.find("img").map(function(c,o){if(o.hasAttribute("width")&&o.hasAttribute("height")){if(o.style.width=o.getAttribute("width")+"px",o.style.height=o.getAttribute("height")+"px",o.hasAttribute("data-cbp-src"))return null;if(t.checkSrc(o)===null)t.removeAttrImage(o);else{var r=a("");r.on("load.cbp error.cbp",function(){a(this).off("load.cbp error.cbp"),t.removeAttrImage(o)}),o.srcset?(r.attr("sizes",o.sizes||"100vw"),r.attr("srcset",o.srcset)):r.attr("src",o.src)}return null}return t.checkSrc(o)}),s=i.length;s!==0?a.each(i,function(c,o){var r=a("");r.on("load.cbp error.cbp",function(){a(this).off("load.cbp error.cbp"),--s===0&&e.call(t)}),o.srcset?(r.attr("sizes",o.sizes),r.attr("srcset",o.srcset)):r.attr("src",o.src)}):e.call(t)})},checkSrc:function(n){var e=n.srcset,t=n.src;if(t==="")return null;var i=a("");e?(i.attr("sizes",n.sizes||"100vw"),i.attr("srcset",e)):i.attr("src",t);var s=i[0];return s.complete&&s.naturalWidth!==k&&s.naturalWidth!==0?null:s},display:function(){var n=this;n.width=n.$obj.outerWidth(),n.triggerEvent("initStartRead"),n.triggerEvent("initStartWrite"),n.width>0&&(n.storeData(n.blocks),n.layoutAndAdjustment()),n.triggerEvent("initEndRead"),n.triggerEvent("initEndWrite"),n.$obj.addClass("cbp-ready"),n.runQueue("delayFrame",n.delayFrame)},delayFrame:function(){var n=this;requestAnimationFrame(function(){n.resizeEvent(),n.triggerEvent("initFinish"),n.isAnimating=!1,n.$obj.trigger("initComplete.cbp")})},resizeEvent:function(){var n=this;d.private.resize.initEvent({instance:n,fn:function(){n.triggerEvent("beforeResizeGrid");var e=n.$obj.outerWidth();e&&n.width!==e&&(n.width=e,n.options.gridAdjustment==="alignCenter"&&(n.wrapper[0].style.maxWidth=""),n.layoutAndAdjustment(),n.triggerEvent("resizeGrid")),n.triggerEvent("resizeWindow")}})},gridAdjust:function(){var n=this;n.options.gridAdjustment==="responsive"?n.responsiveLayout():(n.blocks.removeAttr("style"),n.blocks.each(function(e,t){var i=a(t).data("cbp"),s=t.getBoundingClientRect(),c=n.columnWidthTruncate(s.right-s.left),o=Math.round(s.bottom-s.top);i.height=o,i.heightAndGap=o+n.options.gapHorizontal,i.width=c,i.widthAndGap=c+n.options.gapVertical}),n.widthAvailable=n.width+n.options.gapVertical),n.triggerEvent("gridAdjust")},layoutAndAdjustment:function(n){n&&(this.width=this.$obj.outerWidth()),this.gridAdjust(),this.layout()},layout:function(){var n=this;n.computeBlocks(n.filterConcat(n.defaultFilter)),n.options.layoutMode==="slider"?(n.sliderLayoutReset(),n.sliderLayout()):(n.mosaicLayoutReset(),n.mosaicLayout()),n.blocksOff.addClass("cbp-item-off"),n.blocksOn.removeClass("cbp-item-off").each(function(e,t){var i=a(t).data("cbp");i.left=i.leftNew,i.top=i.topNew,t.style.left=i.left+"px",t.style.top=i.top+"px"}),n.resizeMainContainer()},computeFilter:function(n){this.computeBlocks(n),this.mosaicLayoutReset(),this.mosaicLayout(),this.filterLayout()},filterLayout:function(){this.blocksOff.addClass("cbp-item-off"),this.blocksOn.removeClass("cbp-item-off").each(function(n,e){var t=a(e).data("cbp");t.left=t.leftNew,t.top=t.topNew,e.style.left=t.left+"px",e.style.top=t.top+"px"}),this.resizeMainContainer(),this.filterFinish()},filterFinish:function(){this.isAnimating=!1,this.$obj.trigger("filterComplete.cbp"),this.triggerEvent("filterFinish")},computeBlocks:function(n){var e=this;e.blocksOnInitial=e.blocksOn,e.blocksOn=e.blocks.filter(n),e.blocksOff=e.blocks.not(n),e.triggerEvent("computeBlocksFinish",n)},responsiveLayout:function(){var n=this;n.cols=n[a.isArray(n.options.mediaQueries)?"getColumnsBreakpoints":"getColumnsAuto"](),n.columnWidth=n.columnWidthTruncate((n.width+n.options.gapVertical)/n.cols),n.widthAvailable=n.columnWidth*n.cols,n.options.layoutMode==="mosaic"&&n.getMosaicWidthReference(),n.blocks.each(function(t,i){var s,c=a(i).data("cbp"),o=1;n.options.layoutMode==="mosaic"&&(o=n.getColsMosaic(c.widthInitial)),s=n.columnWidth*o-n.options.gapVertical,i.style.width=s+"px",c.width=s,c.widthAndGap=s+n.options.gapVertical,i.style.height=""});var e=[];n.blocks.each(function(t,i){a.each(a(i).find("img").filter("[width][height]"),function(s,c){var o=0;a(c).parentsUntil(".cbp-item").each(function(f,g){var u=a(g).width();if(u>0)return o=u,!1});var r=parseInt(c.getAttribute("width"),10),l=parseInt(c.getAttribute("height"),10),p=parseFloat((r/l).toFixed(10));e.push({el:c,width:o,height:Math.round(o/p)})})}),a.each(e,function(t,i){i.el.width=i.width,i.el.height=i.height,i.el.style.width=i.width+"px",i.el.style.height=i.height+"px"}),n.blocks.each(function(t,i){var s=a(i).data("cbp"),c=i.getBoundingClientRect(),o=Math.round(c.bottom-c.top);s.height=o,s.heightAndGap=o+n.options.gapHorizontal})},getMosaicWidthReference:function(){var n=[];this.blocks.each(function(e,t){var i=a(t).data("cbp");n.push(i.widthInitial)}),n.sort(function(e,t){return e-t}),n[0]?this.mosaicWidthReference=n[0]:this.mosaicWidthReference=this.columnWidth},getColsMosaic:function(n){if(n===this.width)return this.cols;var e=n/this.mosaicWidthReference;return e=e%1>=.79?Math.ceil(e):Math.floor(e),Math.min(Math.max(e,1),this.cols)},getColumnsAuto:function(){if(this.blocks.length===0)return 1;var n=this.blocks.first().data("cbp").widthInitial+this.options.gapVertical;return Math.max(Math.round(this.width/n),1)},getColumnsBreakpoints:function(){var n,e=this,t=e.width;return a.each(e.options.mediaQueries,function(i,s){if(t>=s.width)return n=s,!1}),n||(n=e.options.mediaQueries[e.options.mediaQueries.length-1]),e.triggerEvent("onMediaQueries",n.options),n.cols},columnWidthTruncate:function(n){return Math.floor(n)},resizeMainContainer:function(){var n,e=this,t=Math.max(e.freeSpaces.slice(-1)[0].topStart-e.options.gapHorizontal,0);e.options.gridAdjustment==="alignCenter"&&(n=0,e.blocksOn.each(function(i,s){var c=a(s).data("cbp"),o=c.left+c.width;o>n&&(n=o)}),e.wrapper[0].style.maxWidth=n+"px"),t!==e.height&&(e.obj.style.height=t+"px",e.height!==k&&(d.private.modernBrowser?e.$obj.one(d.private.transitionend,function(){e.$obj.trigger("pluginResize.cbp")}):e.$obj.trigger("pluginResize.cbp")),e.height=t),e.triggerEvent("resizeMainContainer")},filterConcat:function(n){return n.replace(/\|/gi,"")},pushQueue:function(n,e){this.queue[n]=this.queue[n]||[],this.queue[n].push(e)},runQueue:function(n,e){var t=this.queue[n]||[];a.when.apply(a,t).then(a.proxy(e,this))},clearQueue:function(n){this.queue[n]=[]},registerEvent:function(n,e,t){this.registeredEvents[n]||(this.registeredEvents[n]=[]),this.registeredEvents[n].push({func:e,oneTime:t||!1})},triggerEvent:function(n,e){var t,i,s=this;if(s.registeredEvents[n])for(t=0,i=s.registeredEvents[n].length;t0?(e=null,!1):e===null&&void 0}),e},generateF1F2:function(n,e){var t=this.freeSpaces[n],i={leftStart:t.leftStart+e.widthAndGap,leftEnd:t.leftEnd,topStart:t.topStart,topEnd:t.topEnd},s={leftStart:t.leftStart,leftEnd:t.leftEnd,topStart:t.topStart+e.heightAndGap,topEnd:t.topEnd};this.freeSpaces.splice(n,1),i.leftEnd>i.leftStart&&i.topEnd>i.topStart&&(this.freeSpaces.splice(n,0,i),n++),s.leftEnd>s.leftStart&&s.topEnd>s.topStart&&this.freeSpaces.splice(n,0,s)},generateG1G2G3G4:function(n){var e=this,t=[];a.each(e.freeSpaces,function(i,s){var c=e.intersectSpaces(s,n);c!==null?(e.generateG1(s,c,t),e.generateG2(s,c,t),e.generateG3(s,c,t),e.generateG4(s,c,t)):t.push(s)}),e.freeSpaces=t},intersectSpaces:function(n,e){var t={leftStart:e.leftNew,leftEnd:e.leftNew+e.widthAndGap,topStart:e.topNew,topEnd:e.topNew+e.heightAndGap};if(n.leftStart===t.leftStart&&n.leftEnd===t.leftEnd&&n.topStart===t.topStart&&n.topEnd===t.topEnd)return null;var i=Math.max(n.leftStart,t.leftStart),s=Math.min(n.leftEnd,t.leftEnd),c=Math.max(n.topStart,t.topStart),o=Math.min(n.topEnd,t.topEnd);return s<=i||o<=c?null:{leftStart:i,leftEnd:s,topStart:c,topEnd:o}},generateG1:function(n,e,t){n.topStart!==e.topStart&&t.push({leftStart:n.leftStart,leftEnd:n.leftEnd,topStart:n.topStart,topEnd:e.topStart})},generateG2:function(n,e,t){n.leftEnd!==e.leftEnd&&t.push({leftStart:e.leftEnd,leftEnd:n.leftEnd,topStart:n.topStart,topEnd:n.topEnd})},generateG3:function(n,e,t){n.topEnd!==e.topEnd&&t.push({leftStart:n.leftStart,leftEnd:n.leftEnd,topStart:e.topEnd,topEnd:n.topEnd})},generateG4:function(n,e,t){n.leftStart!==e.leftStart&&t.push({leftStart:n.leftStart,leftEnd:e.leftStart,topStart:n.topStart,topEnd:n.topEnd})},cleanFreeSpaces:function(){this.freeSpaces.sort(function(n,e){return n.topStart>e.topStart?1:n.topStarte.leftStart?1:n.leftStart=e.leftEnd&&s.topStart<=e.topStart&&s.topEnd>=e.topEnd?(e=null,!1):void 0}),e})},uniqueFreeSpaces:function(){var n=[];a.each(this.freeSpaces,function(e,t){a.each(n,function(i,s){if(s.leftStart===t.leftStart&&s.leftEnd===t.leftEnd&&s.topStart===t.topStart&&s.topEnd===t.topEnd)return t=null,!1}),t!==null&&n.push(t)}),this.freeSpaces=n},addHeightToBlocks:function(){var n=this;a.each(n.freeSpaces,function(e,t){n.blocksOn.each(function(i,s){var c=a(s).data("cbp");c.pack===!0&&n.intersectSpaces(t,c)&&t.topStart-c.topNew-c.heightAndGap===-1&&(s.style.height=c.height-1+"px")})})},sortBlocks:function(n,e,t,i){t=t===void 0?"leftNew":t,i=i===void 0?1:-1,n.sort(function(s,c){var o=a(s).data("cbp"),r=a(c).data("cbp");return o[e]>r[e]?i:o[e]r[t]?i:o[t]r.index?i:o.index