(function(l,f){function g(a,b){function d(){c.P()?e||(e=!0,f.i(c.c.f,function(a){a.G||a.g.draggable("disable");a.m||a.g.w("disable")})):e&&(e=!1,f.i(c.c.f,function(a){a.G||a.g.draggable("enable");a.m||a.g.w("enable")}))}var c=this,e;this.h=jQuery(a);this.a=f.oa(b||{},{width:parseInt(this.h.b("data-gs-width"))||12,height:parseInt(this.h.b("data-gs-height"))||0,F:"grid-stack-item",sa:"grid-stack-placeholder",handle:".grid-stack-item-content",j:60,o:20,la:!0,u:100,D:!1,O:"grid-stack-"+(1E4*Math.random()).toFixed(0),
ba:Boolean(this.h.b("data-gs-animate"))||!1});this.h.H(this.a.O);this.l=h.na();this.l.A=0;this.c=new k(this.a.width,function(a){var b=0;f.i(a,function(a){null==a.ia?a.g.remove():(a.g.b("data-gs-x",a.x).b("data-gs-y",a.y).b("data-gs-width",a.width).b("data-gs-height",a.height),b=Math.max(b,a.y+a.height))});c.aa(b+10)},this.a.D,this.a.height);if(this.a.la){var g=[];this.h.find("."+this.a.F).i(function(a,b){b=jQuery(b);g.push({g:b,ra:parseInt(b.b("data-gs-x"))+parseInt(b.b("data-gs-y"))*parseInt(b.b("data-gs-width"))})});
f.U(g).ua(function(a){return a.ra}).i(function(a){c.ja(a.g)})}this.ta(this.a.ba);this.placeholder=jQuery('<div class="'+this.a.sa+" "+this.a.F+'"><div class="placeholder-content" /></div>').pa();this.h.append(this.placeholder);this.h.height(this.c.V()*(this.a.j+this.a.o)-this.a.o);jQuery(window).resize(d);d()}function k(a,b,d,c,e){this.width=a;this.D=d||!1;this.height=c||0;this.f=e||[];this.onchange=b||function(){}}var h={J:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||
b.y+b.height<=a.y)},sort:function(a,b,d){d=d||f.U(a).map(function(a){return a.x+a.width}).max().value();b=-1!=b?1:-1;return f.ua(a,function(a){return b*(a.x+a.y*d)})},na:function(){var a=document.createElement("style");a.appendChild(document.createTextNode(""));document.head.appendChild(a);return a.sheet},N:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""==a||"no"==a||"false"==a||"0"==a)):Boolean(a)}},n=0;k.prototype.W=function(a){this.B(-1);var b=a,d=Boolean(f.find(this.f,
function(a){return a.locked}));for(this.D||d||(b={x:0,y:a.y,width:this.width,height:a.height});;){d=f.find(this.f,function(c){return c!=a&&h.J(c,b)},this);if("undefined"==typeof d)break;this.v(d,d.x,a.y+a.height,d.width,d.height,!0)}};k.prototype.B=function(a){this.f=h.sort(this.f,a,this.width)};k.prototype.Y=function(){this.B();this.D?f.i(this.f,function(a){if(!a.S&&"undefined"!=typeof a.R&&a.y!=a.R)for(var b=a.y;b>=a.R;)f.U(this.f).find(function(d){return a!=d&&h.J({x:a.x,y:b,width:a.width,height:a.height},
d)}).value()||(a.s=!0,a.y=b),--b},this):f.i(this.f,function(a,b){if(!a.locked)for(;0<a.y;){var d=a.y-1,c=0==b;0<b&&(c="undefined"==typeof f.U(this.f).first(b).find(function(b){return h.J({x:a.x,y:d,width:a.width,height:a.height},b)}).value());if(!c)break;a.s=a.y!=d;a.y=d}},this)};k.prototype.Z=function(a,b){a=f.oa(a||{},{width:1,height:1,x:0,y:0});a.x=parseInt(""+a.x);a.y=parseInt(""+a.y);a.width=parseInt(""+a.width);a.height=parseInt(""+a.height);a.T=a.T||!1;a.m=a.m||!1;a.G=a.G||!1;a.width>this.width?
a.width=this.width:1>a.width&&(a.width=1);1>a.height&&(a.height=1);0>a.x&&(a.x=0);a.x+a.width>this.width&&(b?a.width=this.width-a.x:a.x=this.width-a.width);0>a.y&&(a.y=0);return a};k.prototype.X=function(){var a=Array.prototype.slice.call(arguments,1).concat(this.I()),a=a.concat(this.I());this.onchange(a)};k.prototype.ea=function(){f.i(this.f,function(a){a.s=!1})};k.prototype.I=function(){return f.filter(this.f,function(a){return a.s})};k.prototype.ka=function(a){a=this.Z(a);"undefined"!=typeof a.L&&
(a.width=Math.min(a.width,a.L));"undefined"!=typeof a.K&&(a.height=Math.min(a.height,a.K));"undefined"!=typeof a.u&&(a.width=Math.max(a.width,a.u));"undefined"!=typeof a.M&&(a.height=Math.max(a.height,a.M));a.ia=++n;a.s=!0;if(a.T){this.B();for(var b=0;;++b){var d=b%this.width,c=Math.floor(b/this.width);if(!(d+a.width>this.width||f.find(this.f,function(b){return h.J({x:d,y:c,width:a.width,height:a.height},b)}))){a.x=d;a.y=c;break}}}this.f.push(a);this.W(a);this.Y();this.X();return a};k.prototype.da=
function(a,b,d,c,e){var g=Boolean(f.find(this.f,function(a){return a.locked}));if(!this.height&&!g)return!0;var h,m=new k(this.width,null,this.D,0,f.map(this.f,function(b){return b==a?h=jQuery.extend({},b):jQuery.extend({},b)}));m.v(h,b,d,c,e);b=!0;g&&(b&=!Boolean(f.find(m.f,function(a){return a!=h&&Boolean(a.locked)&&Boolean(a.s)})));this.height&&(b&=m.V()<=this.height);return b};k.prototype.v=function(a,b,d,c,e,f){"number"!=typeof b&&(b=a.x);"number"!=typeof d&&(d=a.y);"number"!=typeof c&&(c=a.width);
"number"!=typeof e&&(e=a.height);"undefined"!=typeof a.L&&(c=Math.min(c,a.L));"undefined"!=typeof a.K&&(e=Math.min(e,a.K));"undefined"!=typeof a.u&&(c=Math.max(c,a.u));"undefined"!=typeof a.M&&(e=Math.max(e,a.M));if(a.x!=b||a.y!=d||a.width!=c||a.height!=e){var g=a.width!=c;a.s=!0;a.x=b;a.y=d;a.width=c;a.height=e;a=this.Z(a,g);this.W(a);f||(this.Y(),this.X())}};k.prototype.V=function(){return f.reduce(this.f,function(a,b){return Math.max(a,b.y+b.height)},0)};k.prototype.ca=function(a){f.i(this.f,function(a){a.R=
a.y});a.S=!0};k.prototype.fa=function(){var a=f.find(this.f,function(a){return a.S});a&&(a.S=!1)};g.prototype.aa=function(a){if("undefined"==typeof a){a=this.l.A;for(this.l.A=0;this.l.rules.length;)this.l.removeRule(0);this.C()}if(a>this.l.A){for(var b=this.l.A;b<a;++b){var d;d="."+this.a.O+" ."+this.a.F+'[data-gs-height="'+(b+1)+'"] { height: '+(this.a.j*(b+1)+this.a.o*b)+"px; }";this.l.insertRule(d,b);d="."+this.a.O+" ."+this.a.F+'[data-gs-y="'+b+'"] { top: '+(this.a.j*b+this.a.o*b)+"px; }";this.l.insertRule(d,
b)}this.l.A=a}};g.prototype.C=function(){this.h.height(this.c.V()*(this.a.j+this.a.o)-this.a.o)};g.prototype.P=function(){return jQuery(window).width()<=this.a.u};g.prototype.ja=function(a){function b(){var b=jQuery(this);e.g=b;c.placeholder.pa();b.b("data-gs-x",e.x).b("data-gs-y",e.y).b("data-gs-width",e.width).b("data-gs-height",e.height).Fa("style");c.C();c.h.va("change",[c.c.I()]);c.c.fa();c.c.B();setTimeout(function(){f.i(c.c.f,function(a){a.g.detach();c.h.append(a.g)})},c.a.ba?300:0);c.a.ma(c.c,
a,1);c.a.Ha()}function d(){var a=jQuery(this);c.c.ea();c.c.ca(e);g=Math.ceil(a.outerWidth()/a.b("data-gs-width"));k=c.a.j+c.a.o;c.placeholder.b("data-gs-x",a.b("data-gs-x")).b("data-gs-y",a.b("data-gs-y")).b("data-gs-width",a.b("data-gs-width")).b("data-gs-height",a.b("data-gs-height")).show();e.g=c.placeholder}var c=this;a=jQuery(a);a.H(this.a.F);var e=c.c.ka({x:a.b("data-gs-x"),y:a.b("data-gs-y"),width:a.b("data-gs-width"),height:a.b("data-gs-height"),L:a.b("data-gs-max-width"),u:a.b("data-gs-min-width"),
K:a.b("data-gs-max-height")||100,M:a.b("data-gs-min-height"),T:h.N(a.b("data-gs-auto-position")),m:h.N(a.b("data-gs-no-resize")),G:h.N(a.b("data-gs-no-move")),locked:h.N(a.b("data-gs-locked")),g:a});a.data("_gridstack_node",e);var g,k;a.draggable({handle:this.a.handle,scroll:!1,xa:".screen-layout",za:".screen-layout",axis:"x,y",start:d,stop:b,Aa:function(b,d){var f=Math.round(d.position.left/g),h=Math.floor((d.position.top+k/2)/k);c.c.da(e,f,h,e.width,e.height)&&(c.c.v(e,f,h),c.C(),c.c.ga(a,e),console.log("drag"))}}).w({ya:!0,
Da:"se",minHeight:this.a.j-10,minWidth:70,start:d,stop:b,resize:function(b,d){a.find(" > .grid-stack-item-content").H("hover-block-item");f.i(c.c.f,function(a){a.g.find(" > .grid-stack-item-content").H("hover-block-item")});var h=Math.round(d.size.width/g),l=Math.round(d.size.height/k);c.c.da(e,e.x,e.y,h,l)&&(c.c.v(e,e.x,e.y,h,l),c.C(),c.c.ga(a,e),c.a.ma(c.c,a,1))}});(e.G||this.P())&&a.draggable("disable");(e.m||this.P())&&a.w("disable");a.b("data-gs-locked",e.locked?"yes":null)};g.prototype.ta=function(a){a?
this.h.H("grid-stack-animate"):this.h.Ga("grid-stack-animate")};k.prototype.ga=function(a,b){prevEl=a.Ea();nextEl=a.next();var d=prevEl.data("_gridstack_node"),c=nextEl.data("_gridstack_node");offset=b.x;"undefined"!=typeof d&&(offset=b.x-(d.x+d.width));"undefined"!=typeof c&&(nextOffset=c.x-(b.x+b.width),nextEl.find(".offset-width").qa("o:"+nextOffset+"-w:"+c.width));a.find(".offset-width").qa("o:"+offset+"-w:"+b.width)};g.prototype.w=function(a){a=jQuery(a);a.i(function(a,d){d=jQuery(d);var c=d.data("_gridstack_node");
"undefined"!=typeof c&&(c.m=!0,c.m?d.w("disable"):d.w("enable"))})};g.prototype.locked=function(a,b){a=jQuery(a);a.i(function(a,c){c=jQuery(c);var e=c.data("_gridstack_node");"undefined"!=typeof e&&(e.locked=b||!1,console.log("locked"),c.b("data-gs-locked",e.locked?"yes":null))});return this};g.prototype.$=function(a,b){a=jQuery(a).first();var d=a.data("_gridstack_node");if("undefined"!=typeof d){var c=this;c.c.ea();c.c.ca(d);b.call(this,a,d);c.C();c.h.va("change",[c.c.I()]);c.c.fa();c.c.B();f.i(c.c.f,
function(a){a.g.detach();c.h.append(a.g)})}};g.prototype.resize=function(a,b,d){this.$(a,function(a,e){b=null!=b&&"undefined"!=typeof b?b:e.width;d=null!=d&&"undefined"!=typeof d?d:e.height;this.c.v(e,e.x,e.y,b,d)})};g.prototype.move=function(a,b,d){this.$(a,function(a,e){b=null!=b&&"undefined"!=typeof b?b:e.x;d=null!=d&&"undefined"!=typeof d?d:e.y;this.c.v(e,b,d,e.width,e.height)})};g.prototype.j=function(a){if("undefined"==typeof a)return this.a.j;a=parseInt(a);a!=this.a.j&&(this.a.j=a||this.a.j,
this.aa())};l.ha=g;l.ha.wa=h;jQuery.Ba.Ca=function(a){return this.i(function(){jQuery(this).data("gridstack")||jQuery(this).data("gridstack",new g(this,a))})}})(window,_); 
